diff --git a/1.2.1/MatrixOne/FAQs/deployment-faqs/index.html b/1.2.1/MatrixOne/FAQs/deployment-faqs/index.html index b106000d86..51641778e9 100644 --- a/1.2.1/MatrixOne/FAQs/deployment-faqs/index.html +++ b/1.2.1/MatrixOne/FAQs/deployment-faqs/index.html @@ -11612,6 +11612,57 @@
操作系统 | +操作系统版本 | +CPU | +内存 | +
---|---|---|---|
OpenCloudOS | +v8.0 / v9.0 | +x86 CPU;4 核 | +16 GB | +
openEuler | +20.03 | +x86 / ARM CPU;4 核 | +16 GB | +
TencentOS Server | +v2.4 / v3.1 | +x86 CPU;4 核 | +16 GB | +
统信 | +V20 | +ARM CPU;4 核 | +16 GB | +
银河麒麟 | +V10 | +ARM CPU;4 核 | +16 GB | +
麒麟信安 | +v3.4 | +x86 / ARM CPU;4 核 | +16 GB | +
可以在红帽系,比如 CentOS 7 下正常使用 MatrixOne 吗?
MatrixOne 对操作系统的要求不严格,支持在 CentOS 7 下使用,但 CentOS 7 在 24 年 6 月底就停止维护了,推荐大家使用更新版本的操作系统。
MatrixOne 是否支持在国产环境下部署?
diff --git a/1.2.1/MatrixOne/Get-Started/install-standalone-matrixone/index.html b/1.2.1/MatrixOne/Get-Started/install-standalone-matrixone/index.html index e4b4ea31c8..7ce5da4b28 100644 --- a/1.2.1/MatrixOne/Get-Started/install-standalone-matrixone/index.html +++ b/1.2.1/MatrixOne/Get-Started/install-standalone-matrixone/index.html @@ -891,6 +891,33 @@单机版 MatrixOne 适用场景即是使用单台开发机器部署 MatrixOne,体验 MatrixOne 的基本功能,与单机版使用一个 MySQL 基本相同。
-推荐安装环境:
+作为一款开源数据库,MatrixOne 目前支持主流的 Linux 和 MacOS 系统。为了快速上手,本文档中优先推荐如下硬件规格:
操作系统 | +操作系统版本 | +CPU | +内存 | +
---|---|---|---|
OpenCloudOS | +v8.0 / v9.0 | +x86 CPU;4 核 | +16 GB | +
openEuler | +20.03 | +x86 / ARM CPU;4 核 | +16 GB | +
TencentOS Server | +v2.4 / v3.1 | +x86 CPU;4 核 | +16 GB | +
统信 | +V20 | +ARM CPU;4 核 | +16 GB | +
银河麒麟 | +V10 | +ARM CPU;4 核 | +16 GB | +
麒麟信安 | +v3.0 | +x86 / ARM CPU;4 核 | +16 GB | +
NOTE: 支持的国产 CPU 有腾云 S2500、FT2000+/64、鲲鹏 916、鲲鹏 920 和海光 H620-G30
你可以在以下三种方式中选择最适合你的一种,在 macOS 上安装并连接 MatrixOne:
更多有关连接 MatrixOne 的方式,参见:
diff --git a/1.2.1/search/search_index.json b/1.2.1/search/search_index.json index e0b5b87487..eb16f387c5 100644 --- a/1.2.1/search/search_index.json +++ b/1.2.1/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["en"],"separator":"[\\s\\-,:!=\\[\\]()\"/]+|[\uff0c\u3002\uff01\uff1f\u2026\uff1a\u201c\u201d\u2018\u2019\uff08\uff09\u2014\u3010\u3011\u300a\u300b]|(?!\\b)(?=[A-Z][a-z])|\\.(?!\\d)|&[lg]t;","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"MatrixOne \u6587\u6863","text":"\u6b22\u8fce\u6765\u5230 MatrixOne \u5b98\u65b9\u6587\u6863\u7f51\u7ad9\uff01
\u8fd9\u4e2a\u5b98\u65b9\u6587\u6863\u7f51\u7ad9\u63d0\u4f9b\u4e86\u76f8\u5173\u6982\u5ff5\u53ca\u6280\u672f\u67b6\u6784\u4ecb\u7ecd\u3001\u4ea7\u54c1\u7279\u6027\u3001\u4f7f\u7528\u6307\u5357\u548c\u53c2\u8003\u624b\u518c\uff0c\u4ee5\u5e2e\u52a9\u60a8\u4f7f\u7528 MatrixOne\u3002
"},{"location":"#_1","title":"\u63a8\u8350\u9605\u8bfb \ud83d\udc49","text":"\u4ece\u4e0b\u9762\u7684\u6587\u7ae0\u4e2d\u9009\u62e9\u4e00\u7bc7\uff0c\u5f00\u59cb\u60a8\u7684 MatrixOne \u4e4b\u65c5\u3002\u5982\u679c\u60a8\uff1a
\u5bf9 MatrixOne \u8fd8\u4e0d\u719f\u6089\uff0c\u8bf7\u4ece\u6982\u8ff0\u5f00\u59cb\uff0c\u4e86\u89e3 MatrixOne \u7684\u57fa\u672c\u6982\u5ff5\uff0c\u5173\u952e\u529f\u80fd\u548c\u6280\u672f\u67b6\u6784\u3002
\u5982\u679c\u60a8\u60f3\u8981\u5feb\u901f\u642d\u5efa MatrixOne \u5e76\u5f00\u59cb\u4f53\u9a8c\u57fa\u672c\u529f\u80fd\uff0c\u8bf7\u4ece\u5feb\u901f\u4e0a\u624b\u5f00\u59cb\u3002
\u5982\u679c\u60a8\u662f\u4e00\u4e2a\u5e94\u7528\u5f00\u53d1\u8005\uff0c\u60f3\u8981\u5c1d\u8bd5\u4f7f\u7528 MatrixOne \u4f5c\u4e3a\u5e95\u5c42\u6570\u636e\u5e93\uff0c\u8bf7\u9009\u62e9\u5f00\u53d1\u6307\u5357\u5f00\u59cb\u3002
\u5982\u679c\u60a8\u662f\u4e00\u4f4d\u7ecf\u9a8c\u4e30\u5bcc\u7684 MatrixOne \u5f00\u53d1\u8005\uff0c\u60f3\u5bfb\u627e\u8be6\u7ec6\u7684 SQL \u8bed\u53e5\uff0c\u6570\u636e\u7c7b\u578b\u6216\u8005\u51fd\u6570\u7684\u7ec6\u8282\u53c2\u6570\uff0c\u8bf7\u81f3\u53c2\u8003\u6587\u6863\u3002
\u65e0\u8bba\u60a8\u9700\u8981\u4e86\u89e3\u57fa\u672c\u6982\u5ff5\u3001\u64cd\u4f5c\u6307\u5357\u3001\u5f00\u53d1\u6307\u5357\u8fd8\u662f\u53c2\u8003\u8d44\u6599\uff0c\u6211\u4eec\u90fd\u5728\u4e3a\u60a8\u91cf\u8eab\u6253\u9020\u5185\u5bb9\u3002
\u6211\u4eec\u8bda\u631a\u5730\u6b22\u8fce\u5927\u5bb6\u4e3a MatrixOne \u6587\u6863\u4f5c\u51fa\u8d21\u732e\u3002\u6211\u4eec\u7684\u793e\u533a\u81f4\u529b\u4e8e\u7b80\u5316\u8d21\u732e\u6d41\u7a0b\uff0c\u4f7f\u5176\u7b80\u5355\u6613\u884c\u3002\u6b64\u5916\uff0c\u6211\u4eec\u8fd8\u5c06\u6301\u7eed\u63d0\u4f9b\u66f4\u65b0\u3002
\u60a8\u4f1a\u5728\u6bcf\u4e2a\u9875\u9762\u9876\u90e8\u53d1\u73b0\u4e00\u4e2a\u7f16\u8f91\u6309\u94ae\uff0c\u70b9\u51fb\u5b83\u4ee5\u8fdb\u5165\u5171\u540c\u7f16\u8f91\u6587\u6863\u3002\u8fd9\u4e9b\u8d44\u6e90\u662f\u4e3a\u60a8\u63d0\u4f9b\u7684\uff0c\u4f9b\u60a8\u5229\u7528\u3002\u60a8\u7684\u53c2\u4e0e\u4e0d\u4ec5\u4f7f\u6211\u4eec\u53d7\u5230\u9f13\u52b1\uff0c\u800c\u4e14\u60a8\u7684\u5efa\u8bae\u4e5f\u81f3\u5173\u91cd\u8981\uff01
\u5982\u679c\u60a8\u53d1\u73b0\u4efb\u4f55\u6587\u6863\u95ee\u9898\uff0c\u8bf7\u968f\u65f6\u521b\u5efa\u4e00\u4e2a Issue \u4ee5\u544a\u77e5\u6211\u4eec\uff0c\u6216\u76f4\u63a5\u63d0\u4ea4\u4e00\u4e2a Pull Request \u4ee5\u534f\u52a9\u4fee\u590d\u6216\u66f4\u65b0\u5185\u5bb9\u3002
Note
\u6709\u5173\u5982\u4f55\u4e3a\u6587\u6863\u505a\u51fa\u8d21\u732e\uff0c\u8bf7\u53c2\u9605 \u6587\u6863\u8d21\u732e\u6307\u5357.
"},{"location":"#_3","title":"\u52a0\u5165\u6211\u4eec\uff01","text":"GitHub \u4e0a\u7684 MatrixOne \u793e\u533a\u5145\u6ee1\u6d3b\u529b\u3001\u70ed\u60c5\u4e14\u77e5\u8bc6\u6e0a\u535a\u3002\u53c2\u4e0e\u8ba8\u8bba\uff0c\u8868\u8fbe\u60a8\u7684\u89c2\u70b9\uff0c\u63d0\u51fa\u529f\u80fd\u5efa\u8bae\uff0c\u5e76\u6df1\u5165\u7814\u7a76\u4ee3\u7801\u3002
\u4e00\u4e2a\u540c\u6837\u70ed\u60c5\u6d0b\u6ea2\u7684\u793e\u533a\u5728 MatrixOne Slack \u9891\u9053\u53ca MatrixOne \u5b98\u7f51\u7b49\u5f85\u7740\u60a8\u3002
"},{"location":"MatrixOne/MatrixCampEvent/","title":"MatrixCampEvent","text":"\u6b22\u8fce\u5927\u5bb6\u6765\u5230 MatrixOne\uff0c\u8fd9\u91cc\u5c31\u662f\u4f60\u8fdb\u5165\u77e9\u9635\u4e16\u754c\u7684\u7535\u8bdd\u4ead\u4e86\uff5e\u53ee\u94c3~~~
\u82f1\u6587\u7248\u672c\u6d3b\u52a8\u8bf4\u660e\u4f20\u9001\u95e8
"},{"location":"MatrixOne/MatrixCampEvent/#matrixcamp2022","title":"MatrixCamp2022 \u6d3b\u52a8","text":"MatrixCamp \u662f\u4e00\u4e2a\u7531 MatrixOne \u793e\u533a\u4e3e\u529e\u7684\u5f00\u53d1\u8005\u6d3b\u52a8\uff0c\u6b22\u8fce\u5bf9\u6570\u636e\u5e93\u6280\u672f\u611f\u5174\u8da3\u7684\u5f00\u53d1\u8005\u4eec\u6765\u53c2\u4e0e\u8fd9\u6b21\u4e3a\u671f 2 \u5468\u7684\u5f00\u53d1\u6311\u6218\u4efb\u52a1\u3002 MatrixOne \u793e\u533a\u4e00\u5171\u51c6\u5907\u4e86 4 \u4e2a\u7c7b\u522b\u7684 56 \u4e2a\u4efb\u52a1\uff0c\u6709\u4e0d\u540c\u7684\u96be\u5ea6\u7ea7\u522b\u548c\u529f\u80fd\u7c7b\u578b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6311\u9009\u81ea\u5df1\u611f\u5174\u8da3\u7684\u8fdb\u884c\u6311\u6218\u3002\u53c2\u4e0e\u6311\u6218\u4ec5\u9700\u8981\u4e00\u4e9b\u57fa\u7840\u7684 Golang \u8bed\u8a00\u7f16\u7a0b\u7ecf\u9a8c\u5c31\u591f\u4e86\uff0c\u53e6\u5916\u6211\u4eec\u4e5f\u6709\u8be6\u5c3d\u7684\u5f00\u53d1\u6307\u5357\u7684\u8010\u5fc3\u7684 mentor \u7ed9\u5927\u5bb6\u8fdb\u884c\u670d\u52a1\u3002
\u8fd9\u6b21\u7684\u4efb\u52a1\u5927\u5bb6\u5c06\u8981\u6311\u6218\u7684\u662f MatrixOne \u7684\u7cfb\u7edf\u51fd\u6570\u548c\u805a\u5408\u51fd\u6570\uff0c\u5bf9\u4e8e\u521a\u5165\u95e8\u6570\u636e\u5e93\u7684\u540c\u5b66\u6765\u8bb2\u662f\u76f8\u5bf9\u57fa\u7840\u4f46\u662f\u53c8\u4e0d\u4e4f\u6311\u6218\u7684\u4efb\u52a1\u3002
\u57fa\u7840\u4efb\u52a1 - \u7cfb\u7edf\u51fd\u6570\uff08Built-in function\uff09: \u6240\u8c13\u7684\u7cfb\u7edf\u51fd\u6570\u5c31\u662f\u6570\u636e\u5e93\u81ea\u5e26\u7684\u9488\u5bf9\u4e00\u4e9b\u57fa\u7840\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u64cd\u4f5c\u7684\u51fd\u6570\uff0c\u6bd4\u5982\u5e38\u89c1\u7684 round(), time(), substring() \u7b49\u7b49\u3002\u7b2c\u4e00\u5468\u5c06\u6709 25 \u4e2a\u7cfb\u7edf\u51fd\u6570\u4f5c\u4e3a\u57fa\u7840\u4efb\u52a1\u53d1\u5e03\u7ed9\u5927\u5bb6\u8fdb\u884c\u6311\u6218\uff0c\u5305\u542b\u6570\u5b66\u7c7b\u51fd\u6570\uff0c\u65f6\u95f4\u65e5\u671f\u7c7b\u51fd\u6570\uff0c\u5b57\u7b26\u4e32\u7c7b\u51fd\u6570\uff0c\u6709 9 \u4e2a\u4efb\u52a1\u975e\u5e38\u5bb9\u6613\uff0c16 \u4e2a\u4efb\u52a1\u7a0d\u5fae\u6709\u4e00\u4e9b\u96be\u5ea6\uff0c\u53ea\u8981\u4f60\u6709\u4e00\u5b9a\u7684 go \u8bed\u8a00\u57fa\u7840\uff0c\u770b\u5f97\u61c2\u82f1\u6587\u6587\u6863\uff0c\u5c31\u80fd\u5feb\u901f\u4e0a\u624b\u89e3\u51b3\u54e6\u3002
\u6311\u6218\u4efb\u52a1 - \u805a\u5408\u51fd\u6570\uff08Aggregate function\uff09\uff1a\u6240\u8c13\u7684\u805a\u5408\u51fd\u6570\u5c31\u662f\u9700\u8981\u805a\u96c6\u4e00\u90e8\u5206\u6570\u636e\u8fdb\u884c\u8fd0\u7b97\u8fd4\u56de\u7ed3\u679c\u7684\u51fd\u6570\uff0c\u6bd4\u5982\u5e38\u89c1\u7684 sum(), count(), avg() \u7b49\u7b49\u3002\u5728 MatrixOne \u4e2d\uff0c\u5b9e\u73b0\u805a\u5408\u51fd\u6570\u662f\u8981\u7528\u5230\u6211\u4eec\u7684\u5927\u6740\u5668\u56e0\u5b50\u5316\u52a0\u901f\u80fd\u529b\u7684\uff0c\u9700\u8981\u5bf9\u56e0\u5b50\u5316\u4e2d\u7684\u201c\u73af\u201d\u6570\u636e\u7ed3\u6784\u7406\u8bba\u6709\u4e00\u5b9a\u7406\u89e3\uff0c\u5b9e\u73b0\u4f1a\u6709\u4e00\u5b9a\u590d\u6742\u5ea6\uff0c\u6240\u4ee5\u6211\u4eec\u5c06 5 \u4e2a\u805a\u5408\u51fd\u6570\u5217\u4e3a\u4e86\u6311\u6218\u4efb\u52a1\u3002
\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5148\u7ed9 MatrixOne \u9879\u76ee Star, Fork, Watch \u4e00\u4e0b\u5427\u3002
\u8bf7\u6ce8\u610f\uff1a1 \u4e2a\u5f00\u53d1\u8005\u53ef\u4ee5\u9009\u62e9\u591a\u4e2a\u6311\u6218\u4efb\u52a1\uff0c\u4f46\u662f 1 \u4e2a\u4efb\u52a1\u53ea\u80fd\u7531 1 \u4e2a\u5f00\u53d1\u8005\u5b8c\u6210
\u6765\u770b\u4e0b\u6211\u4eec\u7684\u4efb\u52a1\u5217\u8868\u5427\uff0c\u5176\u4e2d\u5df2\u7ecf\u88ab assign \u7684\u4efb\u52a1\u8bf7\u67e5\u770b\u82f1\u6587\u7248\u6d3b\u52a8\u8bf4\u660e\uff1a
"},{"location":"MatrixOne/MatrixCampEvent/#1-","title":"1. \u57fa\u7840\u4efb\u52a1 - \u6570\u5b66\u7c7b\u7cfb\u7edf\u51fd\u6570","text":"\u5b8c\u6210\u4ee3\u7801\u7f16\u5199\u4e4b\u540e\uff0c\u6309\u4ee5\u4e0b\u683c\u5f0f\u5411 MatrixOne \u63d0\u4ea4 PR:
PR \u683c\u5f0f\uff1a[MatrixCamp] + function name + PR title
PR \u5185\u5bb9\uff1a\u9075\u5faa [MatrixOne \u7684 PR \u6a21\u7248] (https://github.com/matrixorigin/matrixone/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
\u63d0\u4ea4 PR \u5b8c\u6210\u540e\uff0c\u5728\u4f60\u7684 PR \u4e0b\u9762\u6309\u4ee5\u4e0b\u683c\u5f0f\u8bc4\u8bba\uff1a \u8bc4\u8bba\u683c\u5f0f\uff1a\"I have finished Issue #\" + PR link id
Q: \u5fc5\u987b\u5148\u9886\u4efb\u52a1\u624d\u80fd\u5f00\u59cb\u4e48\uff0c\u53ef\u4ee5\u76f4\u63a5\u63d0 PR \u5417\uff1f A: \u662f\u7684\uff0c\u53c2\u4e0e\u5f00\u53d1\u8005\u90fd\u9700\u8981\u5728 issue \u4e0b\u9762\u8bc4\u8bba\u8ba4\u9886\u540e\u518d\u5f00\u59cb\u4efb\u52a1\uff0c\u4e0d\u5efa\u8bae\u76f4\u63a5\u63d0 PR\u3002\u8fd9\u6837\u662f\u4e3a\u4e86\u907f\u514d\u591a\u540d\u5f00\u53d1\u8005\u9488\u5bf9\u540c\u4e00\u95ee\u9898\u91cd\u590d\u52b3\u52a8\u3002
Q: \u4e3a\u4ec0\u4e48 select abs(-1);
\u548c select d, abs(-1) from t;
\u8fd9\u6837\u7684\u8bed\u53e5\u4f1a\u51fa\u95ee\u9898\uff1f A: \u76ee\u524d MatrixOne \u8fd8\u4e0d\u652f\u6301\u65e0\u8868\u53ca\u5e38\u6570\u53c2\u6570\u7684 SQL \u8bed\u53e5\uff0c\u56e0\u6b64 select abs(-1);
\u548c select abs(-1) from table1;
\u8fd9\u6837\u7684\u8bed\u53e5\u5747\u4f1a\u51fa\u9519\u3002\u6b63\u786e\u7684 SQL \u8bed\u53e5\u662f\u9700\u8981\u521b\u5efa\u4e00\u5f20\u8868\uff0c\u5bfc\u5165\u4e00\u4e9b\u6570\u636e\uff0c\u7136\u540e\u518d\u5c06\u5217\u540d\u4f5c\u4e3a\u53c2\u6570\u8fd0\u884c built-in \u51fd\u6570\u3002\u5982\u4ee5\u4e0b\u4f8b\u5b50\uff1a
select abs(a) from t;\n
Q: \u4e3a\u4ec0\u4e48\u6bcf\u6b21 PR \u5b8c\u6210\u4e4b\u540e\uff0c\u6211\u7684\u4ed3\u5e93\u603b\u662f\u4f1a\u6bd4 MatrixOne \u9886\u5148\uff1f A: MatrixOne \u5bf9\u6240\u6709 pr \u7684\u5408\u5e76\u90fd\u8981\u6c42\u662f squash and merge\uff0c\u56e0\u6b64 pr \u5408\u5e76\u540e\u8ddf\u4e3b\u5e72\u4f1a\u4e0d\u4e00\u81f4\u3002\u8fd9\u91cc\u63a8\u8350\u91c7\u7528\u7684 git \u6d41\u7a0b\uff0c\u53ef\u4ee5\u4fdd\u6301\u672c\u5730 git\uff0c\u8fdc\u7aef git \u4ed3\u5e93\u4e0e MatrixOne \u4ed3\u5e93\u4fdd\u6301\u4e00\u81f4\u7684\u65b9\u6cd5\uff1a
1. \u9996\u5148Fork MatrixOne\u7684\u4ed3\u5e93\u3002\n2. clone\u81ea\u5df1\u7684\u4ed3\u5e93\u5230\u672c\u5730: git clone https://github.com/YOUR_NAME/matrixone.git\n3. \u5c06MatrixOne\u4e3b\u4ed3\u5e93\u6dfb\u52a0\u4e3aremote\u4ed3\u5e93: git remote add upstream https://github.com/matrixorigin/matrixone.git\n4. \u5728\u672c\u5730\u4fee\u6539\u4ee3\u7801\uff0c\u5408\u5e76\u51b2\u7a81\uff0cetc.\n5. push\u5230\u4e00\u4e2a\u65b0\u7684\u5206\u652f: git push origin main:NEW_BRANCH\n6. \u5230\u81ea\u5df1\u4ed3\u5e93\u7684NEW_BRANCH\u5206\u652f\u63d0PR\uff0c\u7b49\u5f85\u5408\u5e76\n7. PR\u5408\u5e76\u4e4b\u540e\uff0c\u8986\u76d6\u672c\u5730\u63d0\u4ea4\u5386\u53f2: git pull --force upstream main:main\n8. \u518d\u6b21\u63d0\u4ea4\u5230\u81ea\u5df1\u7684\u8fdc\u7aef\u4ed3\u5e93\uff1agit push --force origin main:main\n
Q: \u6211\u63d0\u4ea4\u7684 PR \u5728\u81ea\u52a8\u6d4b\u8bd5\u9636\u6bb5\u5931\u8d25\u4e86\uff0c\u8fd9\u4e2a\u662f\u4ec0\u4e48\u539f\u56e0\uff1f A\uff1aMatrixOne \u4f1a\u5728 PR \u63d0\u4ea4\u4e4b\u540e\u81ea\u52a8\u8fdb\u884c\u4e00\u7cfb\u5217 CI \u53ca BVT \u6d4b\u8bd5\uff0c\u5f00\u53d1\u8005\u5728\u63d0\u4ea4\u4e4b\u540e\u53ef\u4ee5\u770b\u5230\u6d4b\u8bd5\u7684\u8fdb\u5c55\u53ca\u65e5\u5fd7\uff0c\u5982\u679c\u662f\u4e0e\u51fd\u6570\u529f\u80fd\u76f8\u5173\u7684\u6d4b\u8bd5\u6ca1\u6709\u901a\u8fc7\uff0c\u8bf7\u4fee\u6539 code \u540e\u91cd\u65b0\u63d0\u4ea4\u3002\u5982\u679c\u662f\u5176\u4ed6\u4e0e\u51fd\u6570\u65e0\u5173\u7684\u6d4b\u8bd5\u95ee\u9898\uff0c\u53ef\u4ee5\u5728 PR \u4e2d\u8fdb\u884c\u8bc4\u8bba\uff0c\u793e\u533a\u5c06\u4f1a\u67e5\u8be2\u95ee\u9898\u6240\u5728\uff0c\u4e0d\u4f1a\u5f71\u54cd\u672c\u6b21\u51fd\u6570\u4efb\u52a1\u7684\u5224\u5b9a\u7ed3\u679c\u3002\u76ee\u524d MatrixOne \u7684 CI \u6d4b\u8bd5\u6709\u4e00\u5b9a\u7684\u4e0d\u7a33\u5b9a\u7a0b\u5ea6\uff0c\u56e0\u6b64\u53ef\u80fd\u6709\u4e00\u4e9b\u4e0e\u51fd\u6570\u65e0\u5173\u7684 CI \u6d4b\u8bd5\u4f1a fail\u3002
Q: MatrixOne \u670d\u52a1\u542f\u52a8\u4e4b\u540e\u7684\u65e5\u5fd7\u4fe1\u606f\u6709\u70b9\u592a\u591a\u4e86\uff0c\u600e\u4e48\u80fd\u5173\u6389\uff1f A: \u76ee\u524d MatrixOne \u7684\u9ed8\u8ba4\u65e5\u5fd7\u7ea7\u522b\u662f DEBUG
\u7ea7\uff0c\u6240\u4ee5\u4fe1\u606f\u662f\u4f1a\u6bd4\u8f83\u591a\u7684\u3002\u63a7\u5236\u8fd9\u4e2a\u65e5\u5fd7\u7ea7\u522b\u7684\u662f\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6 system_vars_config.toml
\uff0c\u53ef\u4ee5\u5728\u8c03\u8bd5\u7684\u65f6\u5019\u5c06\u8be5\u6587\u4ef6\u7684 cubeLogLevel
\u4e0e level
\u4e24\u4e2a\u53c2\u6570\u8bbe\u7f6e\u6210 ERROR
\u7ea7\u522b\uff0c\u8fd9\u6837\u6253\u5370\u7684\u4fe1\u606f\u4f1a\u5c11\u5f88\u591a\u3002
cubeLogLevel = \"error\"\nlevel = \"error\"\n
Q: \u5982\u679c\u6211\u5bf9\u8ba4\u9886\u7684\u51fd\u6570\u5b9e\u73b0\u6709\u4e00\u4e9b\u7591\u95ee\uff0c\u6211\u5e94\u8be5\u5411\u8c01\u8be2\u95ee\uff1f A\uff1a\u5982\u679c\u662f\u9488\u5bf9 MatrixOne \u672c\u8eab\u7684\u6d4b\u8bd5\u548c\u884c\u4e3a\u53d1\u73b0 bug\uff0c\u6b22\u8fce\u5411 MatrixOne \u793e\u533a\u63d0\u51fa issue\uff0c\u6211\u4eec\u6709\u76f8\u5e94\u7684\u6a21\u7248\u5e2e\u52a9\u8bf4\u660e\u5982\u4f55\u5199 issue\uff0c\u793e\u533a\u4f1a\u5bf9 issue \u8fdb\u884c\u5904\u7406\u3002\u5982\u679c\u662f\u9488\u5bf9\u51fd\u6570\u672c\u8eab\u7684\u5b9e\u73b0\u6709\u95ee\u9898\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u8ba4\u9886\u7684 issue \u4e0b\u9762\u8bc4\u8bba\u4f60\u7684\u60f3\u6cd5\u548c\u7591\u95ee\uff0cMatrixOne \u793e\u533a\u7684 mentor \u4f1a\u53ca\u65f6\u56de\u590d\u3002
Q: \u6211\u542f\u52a8\u4e86 MatrixOne \u670d\u52a1\uff0c\u5e76\u4e14\u7528 MySQL \u8fdb\u884c\u8fde\u63a5\uff0c\u4f46\u662f\u597d\u50cf\u6ca1\u6709\u83b7\u5f97\u6b63\u786e\u7684\u7ed3\u679c\uff0c\u5982\u4f55\u624d\u77e5\u9053\u662f\u5426\u6210\u529f\u8fde\u63a5\uff1f A: \u5982\u679c\u4f60\u7684 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u540e\u6253\u5370\u5982\u4e0b\u4fe1\u606f\uff0c\u5c31\u8bf4\u660e\u5df2\u7ecf\u6210\u529f\u8fde\u63a5\uff1a
Welcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 1002\nServer version: 0.3.0 MatrixOne\n\nCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n
Q: \u6211\u7684 MatrixOne \u670d\u52a1\u542f\u52a8\u4e86\uff0c\u4f46\u662f\u6211\u7684 MySQL \u5ba2\u6237\u7aef\u59cb\u7ec8\u8fde\u63a5\u4e0d\u4e0a\uff0c\u8fd9\u4e2a\u5e94\u8be5\u600e\u4e48\u89e3\u51b3\uff1f A: \u8fd9\u4e2a\u53ef\u80fd\u7531\u5404\u79cd\u539f\u56e0\u5bfc\u81f4\uff0c\u9996\u5148\u8bf7\u5173\u6ce8\u9519\u8bef\u7684\u65e5\u5fd7\u4fe1\u606f\u6765\u5b9a\u4f4d\u95ee\u9898\uff0c\u76ee\u524d\u5728 MatrixOne \u4e2d\u6709\u4e24\u79cd\u5e38\u89c1\u9519\u8bef\uff1a
lsof -i:50000
\u547d\u4ee4\u6765\u67e5\u627e\u662f\u54ea\u4e2a\u8fdb\u7a0b\u5728\u5360\u7528\u8fd9\u4e2a\u7aef\u53e3\u3002\u4ece\u8fd9\u4e2a\u547d\u4ee4\u4e2d\u53ef\u4ee5\u83b7\u5f97\u8fd9\u4e2a\u8fdb\u7a0b\u7684 PID\uff0c\u518d\u901a\u8fc7 kill -9 PIDNAME
\u5173\u95ed\u8fd9\u4e2a\u8fdb\u7a0b\u3002Store
\u76ee\u5f55\u6e05\u7a7a\u5e76\u91cd\u542f MatrixOne \u670d\u52a1\u3002Q: Mentor \u8981\u6c42\u6211\u5bf9\u63d0\u4ea4\u7684\u4ee3\u7801\u683c\u5f0f\u8fdb\u884c\u7f29\u8fdb\uff0c\u8fd9\u4e2a\u5982\u4f55\u505a\uff1f A\uff1a\u53ef\u4ee5\u901a\u8fc7 Golang \u8bed\u8a00\u81ea\u5e26\u7684 gofmt \u5de5\u5177\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u884c\u64cd\u4f5c\uff0c\u6216\u8005\u5728\u4e00\u4e9b\u5e38\u89c1\u7684 IDE \u5982 VS Code \u548c GoLand \u4e2d\u4e5f\u5747\u6709\u76f8\u5e94\u7684\u8bbe\u7f6e\u3002
Q: \u5982\u4f55\u7406\u89e3 MatrixOne \u7684 Vector \u6570\u636e\u7ed3\u6784\uff1f A\uff1aVector \u662f MatrixOne \u4e2d\u8868\u793a\u4e00\u5217\u6570\u636e\u7684\u7ed3\u6784\uff0c\u662f MatrixOne \u6700\u91cd\u8981\u7684\u6570\u636e\u7ed3\u6784\u4f53\u4e4b\u4e00\u3002\u5b83\u5176\u4e2d\u7684\u4e0d\u540c\u53d8\u91cf\u542b\u4e49\uff1a
// Vector.Or: \u8868\u793a\u8fd9\u4e2aVector\u662f\u5426\u662f\u4ece\u78c1\u76d8\u8bfb\u53d6\u7684\u539f\u59cbVector\n// Link: \u8fd9\u4e2aVector\u62e5\u6709\u7684\u8f6f\u94fe\u63a5\u4e2a\u6570\n// Data: \u5185\u5b58\u4e2d\u4fdd\u5b58\u7684\u539f\u59cb\u6570\u636e\n// Typ: Vector\u7684\u7c7b\u578b\n// Col: \u5185\u5b58\u4e2d\u7ecf\u8fc7\u5e8f\u5217\u5316\u7f16\u7801\u7684\u6570\u636e\uff0c\u5b83\u4e0eVector.Data\u5171\u4eab\u5185\u5b58\u4f4d\u7f6e\uff0c\u4f46\u662f\u4f1a\u88ab\u8f6c\u6362\u5230\u67d0\u4e2a\u4e13\u95e8\u7684\u7c7b\u578b\uff0c\u6bd4\u5982int32\n// Nsp: \u5b58\u50a8\u4e00\u5217\u4e2d\u6240\u6709NULL\u7684\u4f4d\u56fe\n
"},{"location":"MatrixOne/add_syntax/","title":"Add syntax","text":"\u672c\u6587\u5c06\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u8bb2\u8bc9\u5982\u4f55\u5728 MatrixOne \u4e2d\u6dfb\u52a0\u8bed\u6cd5\u3002
"},{"location":"MatrixOne/add_syntax/#_1","title":"\u8bed\u6cd5\u89c4\u5219","text":"\u9996\u5148\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 MySQL 8.0 \u7684\u6587\u6863\uff08https://dev.mysql.com/doc/refman/8.0/en/clone.html\uff09\uff0cCLONE \u7684\u8bed\u6cd5\u89c4\u5219\u5982\u4e0b\uff1a
```sqs q CLONE clone_action
clone_action: { LOCAL DATA DIRECTORY [=] 'clone_dir' | INSTANCE FROM 'user'@'host':port IDENTIFIED BY 'password' [DATA DIRECTORY [=] 'clone_dir'] [REQUIRE [NO] SSL] }
\u53ef\u4ee5\u770b\u5230 clone_action \u53ef\u4ee5\u662f\uff1a\n
LOCAL DATA DIRECTORY [=] 'clone_dir'; \u6216\u8005\u662f\uff1a\n
INSTANCE FROM 'user'@'host':port IDENTIFIED BY 'password' [DATA DIRECTORY [=] 'clone_dir'] [REQUIRE [NO] SSL] \u672c\u6587\u4f1a\u4e3e\u4f8b\u6dfb\u52a0\u7b2c\u4e00\u4e2a clone_action \u7684\u89c4\u5219\uff0c\u5728\u7b2c\u4e00\u4e2a clone_action \u89c4\u5219\u4e2d\uff0cLOCAL\uff0cDATA\uff0cDIRECTORY \u662f MySQL \u4e2d\u7684\u5173\u952e\u5b57\uff08<https://dev.mysql.com/doc/refman/8.0/en/keywords.html>\uff09\u3002 [=] \u662f\u53ef\u9009\u9879\uff0c\u53ef\u4ee5\u6709\u7b49\u53f7\u6216\u8005\u6ca1\u6709\uff0c'clone_dir' \u662f\u5b57\u7b26\u4e32\u3002\u5bf9\u4e8e\u8fd9\u4e9b token\uff0c\u8bcd\u6cd5\u5206\u6790\u9636\u6bb5\u90fd\u4f1a\u505a\u533a\u5206\u3002\n\n\u6211\u4eec\u53ef\u4ee5\u5148\u5b9a\u4e49\u8bed\u6cd5\u6811\uff0c\u56e0\u4e3a CLONE \u662f\u65b0\u8bed\u53e5\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 tree \u76ee\u5f55\u521b\u5efa clone.go \u7136\u540e\u5b9a\u4e49\uff1a\n
type Clone struct { statementImpl CloneDir string } \u5728 mysql_sql.y \u4e2d\u6dfb\u52a0\u5982\u4e0b\u89c4\u5219\uff1a\n
... %union { // Clone \u5b9e\u73b0\u4e86 statement \u63a5\u53e3 statment tree.Statement } ...
// \u5b9a\u4e49\u7ec8\u7ed3\u7b26 CLONE %token CLONE
...
// \u5b9a\u4e49\u975e\u7ec8\u7ed3\u7b26 clone_stmt %type clone_stmt
...
%% ...
// clone_stmt \u662f stmt \u7684\u5177\u4f53\u5b9e\u73b0 stmt: ... | clone_stmt
// \u5b9a\u4e49 CLONE \u8bed\u6cd5\u89c4\u5219 clone_stmt: CLONE LOCAL DATA DIRECTORY equal_opt STRING { $$ = &tree.Clone{IsLocal: true, CloneDir: $6} }
...
non_reserved_keyword: ... | CLONE ...
...
%%
\u5176\u4e2d LOCAL\uff0cDATA\uff0cDIRECTORY \u5173\u952e\u5b57\u662f\u5df2\u7ecf\u5b9a\u4e49\u597d\u7684\u3002\n\n\u53ea\u9700\u8981\u5b9a\u4e49\u65b0\u7684\u5173\u952e\u5b57 CLONE\uff0c\u53ef\u4ee5\u53c2\u8003\u5176\u4e2d\u4e00\u4e2a\u662f\u600e\u4e48\u5b9a\u4e49\u7684\u3002\u6ce8\u610f\u8981\u5728 MySQL \u6587\u6863 <https://dev.mysql.com/doc/refman/8.0/en/keywords.html> \u4e2d\u67e5\u770b\uff0c\u662f\u4fdd\u7559\u5173\u952e\u5b57\uff0c\u8fd8\u662f\u975e\u4fdd\u7559\u5173\u952e\u5b57\u3002\u7136\u540e\u5728 keywords.go \u4e2d\u6dfb\u52a0\uff1a\n
keywords = map[string]int{ ... \"clone\": CLONE, ... } \u8ba9\u8bcd\u6cd5\u5206\u6790\u5668\u901a\u8fc7 map \u8bc6\u522b CLONE \u4e3a\u5173\u952e\u5b57\u3002\n\nSTRING \u8868\u793a\u5b57\u7b26\u4e32\uff0c\u4f1a\u5728\u8bcd\u6cd5\u5206\u6790\u4e2d\u533a\u5206\u3002equal_opt \u8868\u793a [=]\uff0c\u53ef\u4ee5\u6709\u7b49\u53f7\uff0c\u6216\u8005\u6ca1\u6709\uff1a\n
equal_opt: { $$ = \"\" } | '=' { $$ = string($1) } ## \u751f\u6210\u89e3\u6790\u5668\n\nMO parser \u5199\u4e86 Makefile\uff0c\u901a\u8fc7 goyacc \u751f\u6210\u8bed\u6cd5\u5206\u6790\u5668\u3002\u53ef\u4ee5\u76f4\u63a5\u8fdb\u5165\u5230 parsers \u76ee\u5f55\u4e0b\uff0c\u76f4\u63a5\n
make \u5c31\u4f1a\u751f\u6210\u65b0\u7684\u8bed\u6cd5\u5206\u6790\u5668 (mysql_sql.y)\u3002\u6ce8\u610f\uff1a\u5f53 make \u540e\u62a5 shift/reduce \u6216\u8005 reduce/reduce \u51b2\u7a81\uff0c\u8868\u793a\u7f16\u5199\u7684\u8bed\u6cd5\u89c4\u5219\u6709\u95ee\u9898\uff0c\u9700\u8981\u4fee\u6539\u3002\n\n## Format\n\nformat \u4f1a\u5c06 ast \u8f6c\u5316\u4e3a SQL \u5b57\u7b26\u4e32\uff0c\u4e3b\u8981\u4f5c\u7528\u662f\u65b9\u4fbf\u6d4b\u8bd5\uff0c\u5728 plan \u7684\u6784\u9020\u4e2d\u4e5f\u4f1a\u7528\u5230\u3002COLNE \u7684 format \u51fd\u6570\u5982\u4e0b\uff1a\n
func (node Clone) Format(ctx FmtCtx) { ctx.WriteString(\"clone\") if node.IsLocal { ctx.WriteString(\"local data directory = \") ctx.WriteString(node.CloneDir) } } ## \u6d4b\u8bd5\n\nMO parser \u7684\u6d4b\u8bd5\u4e3b\u8981\u662f\u5355\u4fa7\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 mysql_test.go \u4e2d\u6dfb\u52a0\n
validSQL = []struct { input string output string }{{ input: \"CLONE LOCAL DATA DIRECTORY = '/tmp'\", // \u56e0\u4e3a\u5728 Format \u51fd\u6570\u4e2d\uff0c\u5173\u952e\u5b57\u90fd\u88ab\u56fa\u5b9a\u4e3a\u5c0f\u5199\uff0c\u6240\u4ee5 Format \u540e\u4e5f\u4f1a\u53d8\u6210\u5c0f\u5199 output: \"clone local data directory = /tmp\", }, ... \u7136\u540e\u8dd1 TestValid \u6d4b\u8bd5\u3002\n\n\u5982\u679c\u53ea\u662f\u5355\u7eaf\u5730\u6dfb\u52a0\u8bed\u6cd5\uff0c\u9996\u5148\u5728\u6784\u9020\u6267\u884c\u8ba1\u5212\u65f6\uff0c\u9700\u8981\u629b\u51fa\u529f\u80fd\u4e0d\u652f\u6301\u9519\u8bef\u3002\u53ef\u4ee5\u8c03\u7528 moerr \u629b\u51fa\n
func NewNotSupported(msg string, args ...any) *Error ``` \u7136\u540e\u9700\u8981\u5728 test \u76ee\u5f55\u4e0b\u6dfb\u52a0 bvt \u6d4b\u8bd5\uff0c\u8fd9\u662f\u4e00\u4e2a\u7aef\u5230\u7aef\u7684\u6d4b\u8bd5\uff0c\u9884\u671f\u7ed3\u679c\u662f\u629b\u51fa\u76f8\u5e94\u7684\u9519\u8bef\uff0c\u6216\u6b63\u786e\u7684\u7ed3\u679c\u96c6\u3002\u6700\u540e\u53ef\u4ee5\u7528 mo-tester (\u4f7f\u7528\u53ef\u4ee5\u770b readme) \u4f5c\u4e3a\u68c0\u9a8c\u3002
\u5230\u6b64\uff0c\u4e3a MO parser \u6dfb\u52a0\u4e00\u4e2a\u7b80\u5355\u7684\u8bed\u6cd5\u6210\u529f\uff0c\u5728 MO \u6700\u65b0\u7684\u4ee3\u7801\u4e2d\uff0c\u8be5\u8bed\u6cd5\u8fd8\u672a\u88ab\u6dfb\u52a0\uff0c\u5927\u5bb6\u53ef\u4ee5\u5c1d\u8bd5\u9a8c\u8bc1\u8fd9\u4e2a\u8bed\u6cd5\u662f\u5426\u80fd\u89e3\u6790\u6210\u529f\uff0c\u6216\u8005\u6dfb\u52a0\u5176\u4ed6\u65b0\u7684\u8bed\u6cd5\u3002
"},{"location":"MatrixOne/glossary/","title":"\u672f\u8bed\u8868","text":""},{"location":"MatrixOne/glossary/#_2","title":"\u672f\u8bed","text":"\u9605\u8bfb\u4ee5\u4e0b\u5bf9\u76f8\u5173\u8bcd\u6c47\u7684\u6982\u5ff5\u89e3\u91ca\u6216\u8bb8\u6709\u52a9\u4e8e\u4f60\u7406\u89e3\u6211\u4eec\u7684\u6574\u4f53\u67b6\u6784\u3002
\u672f\u8bed \u5b9a\u4e49 A AST AST \u5373\u62bd\u8c61\u8bed\u6cd5\u6811\uff0c\u662f\u4ee3\u7801\u7684\u6811\u7ed3\u6784\u8868\u793a\u5f62\u5f0f\uff0c\u662f\u7ec4\u6210\u7f16\u8bd1\u5668\u5de5\u4f5c\u6a21\u5f0f\u7684\u57fa\u672c\u90e8\u5206 C Cluster MatrixOne \u7684\u5206\u5e03\u5f0f\u90e8\u7f72\u5f62\u5f0f\uff0c\u7531\u591a\u53f0\u4e3b\u673a\u7ec4\u6210\uff0c\u5728\u903b\u8f91\u4e0a\u6784\u6210\u4e00\u4e2a\u6574\u4f53\u3002 E Explicit Transactions \u663e\u5f0f\u4e8b\u52a1\uff0c\u5373\u662f\u4e00\u79cd\u6307\u5b9a\u7684\u4e8b\u52a1\uff0c\u8fd9\u79cd\u4e8b\u52a1\u9700\u8981\u7531\u4f60\u81ea\u5df1\u51b3\u5b9a\u54ea\u6279\u5de5\u4f5c\u5fc5\u987b\u6210\u529f\u5b8c\u6210\uff0c\u5426\u5219\u6240\u6709\u90e8\u5206\u90fd\u4e0d\u5b8c\u6210\u3002\u53ef\u4ee5\u4f7f\u7528BEGIN TRANSACTION
\u548c ROLLBACK TRANSACTION
\u6216 COMMIT TRANSACTION
\u5173\u952e\u5b57\u8fdb\u884c\u63a7\u5236\u3002 I Implicit transactions \u9690\u5f0f\u4e8b\u52a1\uff0c\u5373\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u3002 O Optimistic transaction \u4e50\u89c2\u4e8b\u52a1\uff0c\u4e50\u89c2\u4e8b\u52a1\u5373\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4e0d\u4f1a\u505a\u51b2\u7a81\u68c0\u6d4b\u6216\u9501\uff0c\u4f1a\u5c06\u5f53\u524d\u76f8\u5173\u6570\u636e\u7f13\u5b58\u81f3\u5bf9\u5e94\u5185\u5b58\u533a\u57df\uff0c\u5e76\u5bf9\u8be5\u6570\u636e\u8fdb\u884c\u589e\u5220\u6539\u3002 P Pessimistic transaction \u60b2\u89c2\u4e8b\u52a1\uff0cMatrixOne \u9ed8\u8ba4\u7684\u4e8b\u52a1\u6a21\u5f0f\uff0c\u5373\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u63d0\u524d\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5b8c\u6210\u4e0a\u9501\u52a8\u4f5c\u540e\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u63d0\u4ea4\u6216\u56de\u6eda\u540e\uff0c\u6570\u636e\u5b8c\u6210\u843d\u76d8\u5e76\u91ca\u653e\u9501\u3002 S Snapshot Isolation (SI) Snapshot Isolation \u662f\u4e00\u79cd\u5728\u5b9e\u8df5\u4e2d\u5e7f\u6cdb\u5e94\u7528\u7684\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\u6280\u672f\uff0cMatrixOne \u652f\u6301 Snapshot \u9694\u79bb\u7ea7\u522b\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u3002"},{"location":"MatrixOne/glossary/#_3","title":"\u91cd\u8981\u6982\u5ff5","text":"\u6982\u5ff5 \u5b9a\u4e49 A Auto-Rebalance \u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u591a\u4e2a\u670d\u52a1\u5668\u7684\u5b58\u50a8\u91cf\u3001\u8bfb\u5199\u8d1f\u8f7d\u7684\u81ea\u52a8\u5e73\u8861\u8fc7\u7a0b\u79f0\u4e4b\u4e3a Auto-Rebalance\u3002 C Consistency MatrixOne \u652f\u6301\u5f3a\u4e00\u81f4\u6027\uff0c\u4fdd\u8bc1\u4e86\u5728\u6210\u529f\u5199\u5165\u6570\u636e\u540e\uff0c\u65e0\u8bba\u5728\u54ea\u4e2a Store(\u8282\u70b9) \u4e0a\u90fd\u80fd\u8bfb\u53d6\u5230\u6700\u65b0\u7684\u6570\u636e\u3002 E Execution Plan \u6570\u636e\u5e93\u4e2d\u7684\u6267\u884c\u8ba1\u5212\u662f\u67e5\u8be2\u4f18\u5316\u5668\u751f\u6210\u7684\u67e5\u8be2\u64cd\u4f5c\u7684\u56fe\u5f62\u8868\u793a\uff0c\u53ef\u4ee5\u5f97\u5230\u6267\u884c\u8be5\u64cd\u4f5c\u7684\u6700\u9ad8\u6548\u65b9\u6cd5 F Fault-Tolerance Fault-Tolerance\uff08\u5bb9\u9519\u6027\uff09\u610f\u5473\u7740\u7cfb\u7edf\u5728\u5176\u4e2d\u4e00\u4e2a\u6216\u591a\u4e2a\u7ec4\u4ef6\u53d1\u751f\u6545\u969c\u540e\u4ecd\u7136\u53ef\u4ee5\u7ee7\u7eed\u8fd0\u884c\u7684\u80fd\u529b\u3002 M Monolitic Engine Monolitic Engine \u5373\u8d85\u878d\u5408\u5f15\u64ce\uff0c\u53ef\u652f\u6301 TP\u3001AP\u3001\u65f6\u5e8f\u3001\u673a\u5668\u5b66\u4e60\u7b49\u6df7\u5408\u5de5\u4f5c\u8d1f\u8f7d\u3002 Materialized View Materialized View \u5373\u7269\u5316\u89c6\u56fe\uff0c\u662f\u9884\u5148\u88ab\u8ba1\u7b97\u597d\u7684\u6570\u636e\u96c6\uff0c\u5b58\u50a8\u4e0b\u6765\u4ee5\u4fbf\u540e\u7eed\u4f7f\u7528\uff0c\u901a\u5e38\u53ef\u4ee5\u63d0\u5347\u67e5\u8be2\u7684\u8fd0\u884c\u6548\u7387\u3002 Metadata Metadata \u5373\u5143\u6570\u636e\uff0c\u662f\u7528\u4e8e\u63cf\u8ff0\u6570\u636e\u5e93\u4e2d\u6570\u636e\u7684\u7ed3\u6784\u4fe1\u606f\u7684\u6570\u636e\u3002 P Paxos Paxos \u662f\u4e00\u79cd\u4e00\u81f4\u6027\u7b97\u6cd5\uff0c\u4fdd\u6301\u4e00\u7ec4\u5f02\u6b65\u7f51\u7edc\u901a\u4fe1\u7684\u5206\u5e03\u5f0f\u8ba1\u7b97\u673a\u4e4b\u95f4\u7684\u4e00\u81f4\u6027\u3002 R Raft Raft \u662f\u4e00\u79cd\u6613\u4e8e\u7406\u89e3\u7684\u4e00\u81f4\u6027\u534f\u8bae\u7b97\u6cd5\uff0c\u5728\u5bb9\u9519\u6027\u4e0e\u6027\u80fd\u4e0a\u4e0e Paxos \u76f8\u5f53\u3002 Raft Group and Leader Raft \u5728\u4e00\u7ec4\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e2a leader \u4ee5\u53ca\u8bb8\u591a followers\u3002\u4e00\u4e2a\u7ec4\u4ee3\u8868\u4e00\u4e2a\u590d\u5236\u72b6\u6001\u673a\uff0c\u53ea\u6709 leader \u624d\u53ef\u4ee5\u54cd\u5e94\u5ba2\u6237\u7aef\u8bf7\u6c42\uff0c\u7136\u540e\u5c06\u4f20\u8fbe\u7ed9 followers\u3002 S SIMD instruction SIMD \u662f Single Instruction/Multiple Data \u7684\u7b80\u5199\uff0c\u5373\u5355\u6307\u4ee4\u591a\u6570\u636e\u6d41\uff0cSIMD \u64cd\u4f5c\u4e00\u822c\u6307\u4e00\u79cd\u4f7f\u7528\u4e00\u6761\u6307\u4ee4\u5373\u53ef\u5904\u7406\u591a\u6761\u6570\u636e\u7684\u8ba1\u7b97\u65b9\u6cd5\u3002 T Transaction \u5728\u6570\u636e\u5e93\u4e2d\u6267\u884c\u7684\u4e00\u7cfb\u5217\u6ee1\u8db3 ACID \u57fa\u672c\u8981\u6c42\u7684\u64cd\u4f5c\u3002 TAE \u5168\u79f0 Transactional Analytic Engine\uff0c\u5b58\u50a8\u5f15\u64ce\u3002\u5b58\u50a8\u5f15\u64ce\u662f\u5b58\u50a8\u5c42\u7684\u4e3b\u8981\u516c\u5f00\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u540c\u65f6\u652f\u6301\u884c\u548c\u5217\u5b58\u50a8\u4ee5\u53ca\u4e8b\u52a1\u5904\u7406\u80fd\u529b\u3002 V Vectorized Execution \u901a\u8fc7\u6709\u6548\u5229\u7528 CPU \u7684\u7f13\u5b58\uff0c\u5411\u91cf\u5316\u6267\u884c\u63d0\u9ad8\u4e86\u5206\u6790\u67e5\u8be2\u5f15\u64ce\u7684\u901f\u5ea6\u3002Arrow \u7684\u5217\u5f0f\u683c\u5f0f\u53ef\u4ee5\u4f7f\u7528\u8f7b\u91cf\u7ea7\u7684\u67b6\u6784\uff0c\u5982 dictionary encoding\uff0cbit packing \u4ee5\u53ca run length encoding\uff0c\u8fd9\u90fd\u8fdb\u4e00\u6b65\u4e86\u63d0\u5347\u4e86\u67e5\u8be2\u6548\u7387\u3002"},{"location":"MatrixOne/parser_camp_event/","title":"Parser","text":""},{"location":"MatrixOne/parser_camp_event/#golang-and-mo-start","title":"Golang and MO start","text":""},{"location":"MatrixOne/parser_camp_event/#1-make-sure-your-golang-environment","title":"1. Make sure your golang environment","text":"To build MatrixOne locally, golang 1.22.3 is required. You can follow these steps to make sure your golang whether is ready.
$ go version\n
If the result is like 'go version go1.22.3 xxxxxx'
, you can skip step 2 and build your MatrixOne. If lower than go 1.22.3 or no golang, your can follow step 2 to configure your own golang 1.22.3 environment locally.
If your OS is Mac OS, download the installation package directly with this url: https://go.dev/dl After installation, use step 1 to make sure again.
If your OS is Linux, still download golang package and modify your profile. Here is a sampe as following. The path can be modified as your preferred.
$ wget https://go.dev/dl/go1.22.3.linux-amd64.tar.gz\n$ sudo tar -zxvf go1.22.3.linux-amd64.tar.gz -C\u00a0/usr/local\n$ cat >> /etc/profile << EOF\nexport GOROOT=/usr/local/go \nexport PATH=$GOROOT/bin:$PATH\nexport GOPATH=/home/go\nexport GOPROXY=https://goproxy.cn,direct \nEOF\n$ source /etc/profile\n$ rm -rf /usr/bin/go\n$ ln -s /usr/local/go/bin/go /usr/bin/go\n
After these, your can check your golang version with go version.
"},{"location":"MatrixOne/parser_camp_event/#3-build-and-run-your-own-matrixone","title":"3. Build and run your own MatrixOne","text":"You can get the code from https://github.com/matrixorigin/matrixone. After download with git clone command, then run the these commands to run MatrixOne instance in the diretory of matrixone.
$ make config\n$ make build\n$ ./mo-service -cfg etc/cn-standalone-test.toml\n
If in the make config
or make build
step, there is any timeout or downloading interrupted, please try to refresh your goproxy as following:
$ go env -w GOPROXY=<https://goproxy.cn,direct>\n
While notified \"Server Listening on : 0.0.0.0:6001\"
, it means your MatrixOne is started.
To access MatrixOne, you need a MySQL client with this url: https://dev.mysql.com/downloads/mysql After the MySQL client installation, you can use this command to access your MatrixOne locally in another CLI session.
$ mysql -P6001 -h127.0.0.1 -uroot -p111\n
When you are in mysql command line, you can start your MatrixOne experience. More details can be found in http://doc.matrixorigin.cn
"},{"location":"MatrixOne/parser_camp_event/#features-tasks","title":"Features Tasks","text":""},{"location":"MatrixOne/parser_camp_event/#1-insert-on-duplicate-key-update-statement","title":"1. INSERT ... ON DUPLICATE KEY UPDATE Statement","text":"If you specify an ON DUPLICATE KEY UPDATE
clause and a row to be inserted would cause a duplicate value in a UNIQUE
index or PRIMARY KEY
, an UPDATE
of the old row occurs.
INSERT\n [INTO] tbl_name\n [(col_name [, col_name] ...)]\n { {VALUES | VALUE} (value_list) [, (value_list)] ... }\n [AS row_alias[(col_alias [, col_alias] ...)]]\n [ON DUPLICATE KEY UPDATE assignment_list]\n\nassignment:\n col_name = \n value\n | [row_alias.]col_name\n | [tbl_name.]col_name\n | [row_alias.]col_alias\n\nassignment_list:\n assignment [, assignment] ...\n
For example, if column a is declared as UNIQUE and contains the value 1, the following two statements have similar effect:
INSERT INTO t1 (a,b,c) VALUES (1,2,3)\n ON DUPLICATE KEY UPDATE c=c+1;\n\nUPDATE t1 SET c=c+1 WHERE a=1;\n
If column b is also unique, the INSERT is equivalent to this UPDATE statement instead:
UPDATE t1 SET c=c+1 WHERE a=1 OR b=2 LIMIT 1;\n
In assignment value expressions in the ON DUPLICATE KEY UPDATE
clause, you can use the VALUES(col_name)
function to refer to column values from the INSERT portion of the INSERT ... ON DUPLICATE KEY UPDATE
statement. In other words, VALUES(col_name)
in the ON DUPLICATE KEY UPDATE
clause refers to the value of col_name that would be inserted, had no duplicate-key conflict occurred. This function is especially useful in multiple-row inserts. The VALUES()
function is meaningful only in the ON DUPLICATE KEY UPDATE
clause or INSERT
statements and returns NULL otherwise. Example:
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6)\n ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);\n
That statement is identical to the following two statements:
INSERT INTO t1 (a,b,c) VALUES (1,2,3)\n ON DUPLICATE KEY UPDATE c=3;\nINSERT INTO t1 (a,b,c) VALUES (4,5,6)\n ON DUPLICATE KEY UPDATE c=9;\n
If the result of INSERT ... ON DUPLICATE KEY UPDATE
is incorrect such as the following example, there should be notified error messages to users and this statement failed.
INSERT INTO t1 (a,b,c) VALUES (1,2,3)\n ON DUPLICATE KEY UPDATE c='a';\n
"},{"location":"MatrixOne/parser_camp_event/#2-replace-statement","title":"2. REPLACE Statement","text":"REPLACE
works exactly like INSERT
, except that if an old row in the table has the same value as a new row for a PRIMARY KEY
or a UNIQUE
index, the old row is deleted before the new row is inserted.
REPLACE \n INTO tbl_name\n [(col_name [, col_name] ...)]\n { {VALUES | VALUE} (value_list) [, (value_list)] ...\n |\n VALUES row_constructor_list\n }\n
Example:
CREATE TABLE test (\n id INT UNSIGNED NOT NULL AUTO_INCREMENT,\n data VARCHAR(64) DEFAULT NULL,\n ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (id)\n);\n
When we create this table and run the statements shown in the mysql client, the result is as follows:
mysql> REPLACE INTO test VALUES (1, 'Old', '2014-08-20 18:47:00');\nQuery OK, 1 row affected (0.04 sec)\n\nmysql> REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42');\nQuery OK, 2 rows affected (0.04 sec)\n\nmysql> SELECT * FROM test;\n+----+------+---------------------+\n| id | data | ts |\n+----+------+---------------------+\n| 1 | New | 2014-08-20 18:47:42 |\n+----+------+---------------------+\n1 row in set (0.00 sec)\n
Now we create a second table almost identical to the first, except that the primary key now covers 2 columns, as shown here (emphasized text):
CREATE TABLE test2 (\n id INT UNSIGNED NOT NULL AUTO_INCREMENT,\n data VARCHAR(64) DEFAULT NULL,\n ts TIMESTAMP NOT NULL,\n PRIMARY KEY (id, ts)\n);\n
When we run on test2 the same two REPLACE
statements as we did on the original test table, we obtain a different result:
mysql> REPLACE INTO test2 VALUES (1, 'Old', '2014-08-20 18:47:00');\nQuery OK, 1 row affected (0.05 sec)\n\nmysql> REPLACE INTO test2 VALUES (1, 'New', '2014-08-20 18:47:42');\nQuery OK, 1 row affected (0.06 sec)\n\nmysql> SELECT * FROM test2;\n+----+------+---------------------+\n| id | data | ts |\n+----+------+---------------------+\n| 1 | Old | 2014-08-20 18:47:00 |\n| 1 | New | 2014-08-20 18:47:42 |\n+----+------+---------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#3-values-statement","title":"3. VALUES STATEMENT","text":"VALUES
is a DML statement which returns a set of one or more rows as a table. In other words, it is a table value constructor which also functions as a standalone SQL statement.
VALUES row_constructor_list [ORDER BY column_designator] [LIMIT number]\n\nrow_constructor_list:\n ROW(value_list)[, ROW(value_list)][, ...]\n\nvalue_list:\n value[, value][, ...]\n\ncolumn_designator:\n column_index\n
The VALUES
statement consists of the VALUES
keyword followed by a list of one or more row constructors, separated by commas. A row constructor consists of the ROW()
row constructor clause with a value list of one or more scalar values enclosed in the parentheses. A value can be a literal of any MatrixOne data type or an expression that resolves to a scalar value. ROW()
cannot be empty (but each of the supplied scalar values can be NULL). Each ROW()
in the same VALUES
statement must have the same number of values in its value list. The DEFAULT
keyword is not supported by VALUES
and causes a syntax error, except when it is used to supply values in an INSERT statement. The output of VALUES
is a table:
mysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8);\n+----------+----------+----------+\n| column_0 | column_1 | column_2 |\n+----------+----------+----------+\n| 1 | -2 | 3 |\n| 5 | 7 | 9 |\n| 4 | 6 | 8 |\n+----------+----------+----------+\n3 rows in set (0.00 sec)\n
The columns of the table output from VALUES
have the implicitly named columns column_0, column_1, column_2, and so on, always beginning with 0. This fact can be used to order the rows by column using an optional ORDER BY
clause in the same way that this clause works with a SELECT
statement, as shown here:
mysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8) ORDER BY column_1;\n+----------+----------+----------+\n| column_0 | column_1 | column_2 |\n+----------+----------+----------+\n| 1 | -2 | 3 |\n| 4 | 6 | 8 |\n| 5 | 7 | 9 |\n+----------+----------+----------+\n3 rows in set (0.00 sec)\n\nmysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8) ORDER BY column_1 limit 1;\n+----------+----------+----------+\n| column_0 | column_1 | column_2 |\n+----------+----------+----------+\n| 1 | -2 | 3 |\n+----------+----------+----------+\n1 row in set (0.00 sec)\n
The VALUES
statement is permissive regarding data types of column values; you can mix types within the same column, as shown here:
mysql> VALUES ROW(\"q\", 42, '2019-12-18'),\n -> ROW(23, \"abc\", 98.6),\n -> ROW(27.0002, \"Mary Smith\", '{\"a\": 10, \"b\": 25}');\n+----------+------------+--------------------+\n| column_0 | column_1 | column_2 |\n+----------+------------+--------------------+\n| q | 42 | 2019-12-18 |\n| 23 | abc | 98.6 |\n| 27.0002 | Mary Smith | {\"a\": 10, \"b\": 25} |\n+----------+------------+--------------------+\n3 rows in set (0.00 sec)\n
With UNION
, as shown here:
mysql> VALUES ROW(1,2), ROW(3,4), ROW(5,6)\n > UNION VALUES ROW(10,15),ROW(20,25);\n+----------+----------+\n| column_0 | column_1 |\n+----------+----------+\n| 1 | 2 |\n| 3 | 4 |\n| 5 | 6 |\n| 10 | 15 |\n| 20 | 25 |\n+----------+----------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#4-do-statement-and-declare-statement","title":"4. DO Statement and DECLARE Statement","text":"DO
executes the expressions but does not return any results. In most respects, DO
is shorthand for SELECT expr, ...
, but has the advantage that it is slightly faster when you do not care about the result.
DO expr [, expr] ...\n
DO
is useful primarily with functions that have side effects, such as RELEASE_LOCK()
. Example: This SELECT
statement pauses, but also produces a result set:
mysql> SELECT SLEEP(5);\n+----------+\n| SLEEP(5) |\n+----------+\n| 0 |\n+----------+\n1 row in set (5.02 sec)\n
DO
, on the other hand, pauses without producing a result set.
mysql> DO SLEEP(5);\nQuery OK, 0 rows affected (4.99 sec)\n
DECLARE
statement declares local variables within stored programs. To provide a default value for a variable, include a DEFAULT
clause. The value can be specified as an expression; it need not be a constant. If the DEFAULT
clause is missing, the initial value is NULL.
DECLARE Statement\nDECLARE var_name [, var_name] ... type [DEFAULT value]\n
"},{"location":"MatrixOne/parser_camp_event/#5-handler-statement","title":"5. HANDLER Statement","text":"The HANDLER
statement provides direct access to table storage engine interfaces.
HANDLER tbl_name OPEN [ [AS] alias]\nHANDLER tbl_name READ { FIRST | NEXT }\n [ WHERE where_condition ] [LIMIT ... ]\nHANDLER tbl_name CLOSE\n
The HANDLER ... OPEN
statement opens a table, making it accessible using subsequent HANDLER ... READ
statements. This table object is not shared by other sessions and is not closed until the session calls HANDLER ... CLOSE
or the session terminates. The HANDLER ... READ
syntax fetches a row from the table in natural row order that matches the WHERE condition. Natural row order is the order in which rows are stored in a TAE table data file. Without a LIMIT
clause, all forms of HANDLER ... READ
fetch a single row if one is available. To return a specific number of rows, include a LIMIT
clause. It has the same syntax as for the SELECT statement. HANDLER ... CLOSE
closes a table that was opened with HANDLER ... OPEN
. Example:
mysql> create table t1(a int ,b int);\nQuery OK, 0 rows affected (0.01 sec)\nmysql> insert into t1 values(1,-1),(2,-2),(3,-3),(4,-4),(5,-5);\nQuery OK, 5 rows affected (0.04 sec)\nRecords: 5 Duplicates: 0 Warnings: 0\nmysql> handler t1 open as th;\nQuery OK, 0 rows affected (0.00 sec)\nmysql> handler th read first;\n+------+------+\n| a | b |\n+------+------+\n| 1 | -1 |\n+------+------+\n1 row in set (0.00 sec)\nmysql> handler th read first limit 3;\n+------+------+\n| a | b |\n+------+------+\n| 1 | -1 |\n| 2 | -2 |\n| 3 | -3 |\n+------+------+\n3 rows in set (0.00 sec)\nmysql> handler th read next;\n+------+------+\n| a | b |\n+------+------+\n| 5 | -5 |\n+------+------+\n2 rows in set (0.00 sec)\nmysql> handler th read next limit 3;\n+------+------+\n| a | b |\n+------+------+\n| 5 | -5 |\n+------+------+\n2 rows in set (0.00 sec)\nmysql> handler th close;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#6-create-table-like-statement-and-create-table-select-statement","title":"6. CREATE TABLE ... LIKE Statement and CREATE TABLE ... SELECT Statement","text":"Use CREATE TABLE ... LIKE
to create an empty table based on the definition of another table, including any column attributes and indexes defined in the original table:
CREATE TABLE new_tbl LIKE orig_tbl;\n
The copy is created using the same version of the table storage format as the original table.
create table test1(a int, b float);\ncreate table test2 like test1;\nshow columns from test2;\n+-------+-------+------+------+---------+---------+\n| Field | Type | Null | Key | Default | Comment |\n+-------+-------+------+------+---------+---------+\n| a | INT | YES | | NULL | |\n| b | FLOAT | YES | | NULL | |\n+-------+-------+------+------+---------+---------+\n2 rows in set (0.11 sec)\n
You can create one table from another by adding a SELECT
statement at the end of the CREATE TABLE
statement:
CREATE TABLE new_tbl [AS] SELECT * FROM orig_tbl;\n
Create new columns for all elements in the SELECT
. For example:
mysql> CREATE TABLE test (a INT NOT NULL AUTO_INCREMENT,\n -> PRIMARY KEY (a), KEY(b))\n -> SELECT b,c FROM test2;\n
This creates a table with three columns, a, b, and c. Notice that the columns from the SELECT
statement are appended to the right side of the table, not overlapped onto it. Take the following example:
mysql> SELECT * FROM foo;\n+---+\n| n |\n+---+\n| 1 |\n+---+\n1 row in set (0.00 sec)\n\nmysql> CREATE TABLE bar (m INT) SELECT n FROM foo;\nQuery OK, 1 row affected (0.02 sec)\nRecords: 1 Duplicates: 0 Warnings: 0\n\nmysql> SELECT * FROM bar;\n+------+---+\n| m | n |\n+------+---+\n| NULL | 1 |\n+------+---+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#7-create-triggerdrop-trigger","title":"7. CREATE TRIGGER/DROP TRIGGER","text":"This statement creates a new trigger. A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. The trigger becomes associated with the table named tbl_name, which must refer to a permanent table.
CREATE\n [DEFINER = user]\n TRIGGER [IF NOT EXISTS] trigger_name\n trigger_time trigger_event\n ON tbl_name FOR EACH ROW\n [trigger_order]\n trigger_body\n\ntrigger_time: { BEFORE | AFTER }\n\ntrigger_event: { INSERT | UPDATE | DELETE }\n\ntrigger_order: { FOLLOWS | PRECEDES } other_trigger_name\n
IF NOT EXISTS
prevents an error from occurring if a trigger having the same name, on the same table, exists in the same schema.
trigger_time
is the trigger action time. It can be BEFORE or AFTER to indicate that the trigger activates before or after each row to be modified.
trigger_event
indicates the kind of operation that activates the trigger. These trigger_event
values are permitted: INSERT
: The trigger activates whenever a new row is inserted into the table (for example, through INSERT, LOAD DATA, and REPLACE statements). UPDATE
: The trigger activates whenever a row is modified (for example, through UPDATE
statements). DELETE
: The trigger activates whenever a row is deleted from the table (for example, through DELETE and REPLACE statements). DROP TABLE
and TRUNCATE TABLE
statements on the table do not activate this trigger, because they do not use DELETE
. Dropping a partition does not activate DELETE
triggers, either. The trigger_event
does not represent a literal type of SQL statement that activates the trigger so much as it represents a type of table operation. For example, an INSERT
trigger activates not only for INSERT
statements but also LOAD DATA
statements because both statements insert rows into a table. trigger_body
is the statement to execute when the trigger activates. To execute multiple statements, use the BEGIN ... END
compound statement construct.
DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name\n
This statement drops a trigger. The schema (database) name is optional. If the schema is omitted, the trigger is dropped from the default schema.
"},{"location":"MatrixOne/parser_camp_event/#8-truncate-table-and-kill-statement","title":"8. TRUNCATE TABLE and KILL Statement","text":"TRUNCATE TABLE Statement
TRUNCATE [TABLE] tbl_name\n
TRUNCATE TABLE
empties a table completely. Logically, TRUNCATE TABLE
is similar to a DELETE
statement that deletes all rows, or a sequence of DROP TABLE
and CREATE TABLE
statements.
KILL Statement
KILL [CONNECTION | QUERY] processlist_id\n
Each connection to mysqld runs in a separate thread. You can kill a thread with the KILL processlist_id
statement.
MatrixOne \u793e\u533a\u6b22\u8fce\u6240\u6709\u5f00\u53d1\u8005\u7684\u52a0\u5165\u548c\u8d21\u732e\uff01\u672c\u7ae0\u8282\u65e8\u5728\u5e2e\u52a9\u60a8\u5feb\u901f\u5b8c\u6210\u9996\u6b21\u8d21\u732e\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#_2","title":"\u5982\u4f55\u8d21\u732e\uff1f","text":"\u5728\u54ea\u4e9b\u65b9\u9762\u53ef\u4ee5\u5927\u5c55\u62f3\u811a\u5462\uff1f\u8be6\u60c5\u8bf7\u53c2\u89c1\u8d21\u732e\u79cd\u7c7b\u3002 \u5982\u679c\u60a8\u662f\u5b8c\u5168\u7684\u65b0\u624b\uff0c\u60a8\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u522b\u4e2d\u9009\u62e9\u4e00\u79cd\u8fdb\u884c\u5c1d\u8bd5\uff0c\u8fd9\u4e9b\u7c7b\u522b\u7684\u95ee\u9898\u5bf9\u60a8\u6280\u672f\u80cc\u666f\u7684\u8981\u6c42\u5f88\u5c11\uff0c\u6240\u4ee5\u4e0d\u5fc5\u62c5\u5fc3\uff01
\u5728\u5f00\u59cb\u5904\u7406\u95ee\u9898\u4e4b\u524d\uff0c\u5efa\u8bae\u60a8\u5148\u5c06\u627e\u5230\u7684\u95ee\u9898\u4f5c\u4e3a GitHub \u4e0a\u7684\u4e00\u9879 Issue \u63d0\u51fa\u3002\u6b64\u5916\uff0c\u6211\u4eec\u51c6\u5907\u4e86\u4e00\u7cfb\u5217\u5e26\u6709 good-first-issue
\u6807\u7b7e\u7684 Issue\uff0c\u5b83\u4eec\u5305\u542b\u4e86\u660e\u6670\u7684\u5b9e\u73b0\u6b65\u9aa4\u548c\u9884\u671f\u7ed3\u679c\uff0c\u60a8\u53ef\u4ee5\u6b64\u4f5c\u4e3a\u7a81\u7834\u53e3\uff01
\u5f53\u60a8\u63d0\u51fa Issue \u4e4b\u540e\u6216\u8005\u662f\u5728\u6d4f\u89c8 good-first-issue
\u540e\u51b3\u5b9a\u4e0a\u624b\u89e3\u51b3\uff0c\u60a8\u9700\u8981\u8ba4\u9886\u8fd9\u6b21 Issue\u3002\u5728\u76f8\u5e94 Issue \u7684\u8bc4\u8bba\u4e2d\u8f93\u5165\u5982\u201cI'd like to work on this issue\u201d\uff0c\u793e\u533a\u4eba\u5458\u4f1a\u5c06\u4efb\u52a1\u5206\u914d\u7ed9\u60a8\uff0c\u6b64\u65f6\uff0c\u60a8\u53ef\u4ee5\u5728\u53f3\u4fa7\u7684 Assignees \u677f\u5757\u770b\u89c1\u81ea\u5df1\uff0c\u63a5\u4e0b\u6765\u4fbf\u53ef\u4ee5\u6b63\u5f0f\u7740\u624b\u89e3\u51b3\u95ee\u9898\u3002
\u8bf7\u786e\u4fdd\u60a8\u81f3\u5c11\u5b89\u88c5\u4e86\u5355\u673a\u7248 MatrixOne \u5e76\u90e8\u7f72\u4e86\u76f8\u5173\u5f00\u53d1\u73af\u5883\u3002\u5177\u4f53\u8bf7\u53c2\u8003\u51c6\u5907\u5de5\u4f5c\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#_5","title":"\u5de5\u4f5c\u6d41\u7a0b","text":""},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#1fork","title":"\u6b65\u9aa4 1\uff1aFork \u9879\u76ee\u4ed3\u5e93","text":"\u9996\u5148\u524d\u5f80 Github \u4e0a\u7684 matrixorigin/matrixone \u4ed3\u5e93\u3002 \u5728\u9875\u9762\u53f3\u4e0a\u89d2\u5904\uff0c\u70b9\u51fb Fork
\u6309\u952e\uff0c\u521b\u5efa\u4e3b\u5e93\u7684\u5206\u53c9\uff0c\u5e76\u4f5c\u4e3a\u60a8\u4e4b\u540e\u4e3b\u8981\u5de5\u4f5c\u7684\u4ed3\u5e93\u3002
\u524d\u5f80\u521a\u624d\u60a8\u521b\u5efa\u7684 Fork \u4ed3\u5e93\uff0c\u70b9\u51fb Code
\uff0c\u7136\u540e\u518d\u70b9\u51fb\u590d\u5236\u56fe\u6807\uff0c\u5c06\u5e93\u7684\u7f51\u5740\u590d\u5236\u5230\u526a\u8d34\u677f\u3002
\u7136\u540e\uff0c\u5728\u60a8\u672c\u5730\u6311\u9009\u4e00\u4e2a\u5408\u9002\u7684\u5de5\u4f5c\u76ee\u5f55\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u8f93\u5165\u4ee5\u4e0b Git \u547d\u4ee4\u5c06\u6587\u4ef6\u514b\u9686\u81f3\u60a8\u672c\u5730\u7684\u76ee\u5f55\uff1a
git clone <content you just copied>\n
\u4f8b\u5982\uff1a
git clone git@github.com:<yourname>/matrixone.git\n
<yourname>
\u662f\u60a8\u7684 Github \u8d26\u53f7\u540d\uff0c\u6362\u8a00\u4e4b\uff0c\u60a8\u8981\u7528\u60a8\u81ea\u5df1\u7684\u8d26\u53f7\u540d\u66ff\u6362\u5b83\u3002
\u60a8\u53ef\u4ee5\u5c06 matrixorigin/matrixone \u6dfb\u52a0\u4e3a\u672c\u5730\u7684\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u4ee5\u4fbf\u540e\u7eed\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a
git remote add upstream https://github.com/matrixorigin/matrixone.git \n
\u5176\u4e2d\uff0cupstream
\u662f\u8be5\u8fdc\u7a0b\u4ed3\u5e93\u7684\u540d\u5b57\uff0c\u60a8\u53ef\u4ee5\u81ea\u884c\u66ff\u6362\uff0c\u4f46\u6ce8\u610f\u540e\u7eed\u5bf9\u8be5\u8bcd\u4e5f\u5e94\u8be5\u4e00\u5e76\u66ff\u6362\u3002
\u514b\u9686\u4ee3\u7801\u5e93\u4e4b\u540e\u60a8\u5c31\u53ef\u4ee5\u5f00\u59cb\u60a8\u7684\u5f00\u53d1\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u5728\u60a8\u6240\u9700\u8981\u7684\u5730\u65b9\u8fdb\u884c\u4efb\u4f55\u4fee\u6539\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#_7","title":"\u8bd5\u8fd0\u884c","text":"\u5982\u679c\u60a8\u5728\u4fee\u6539\u5b8c\u6210\u540e\u60f3\u77e5\u9053\u6539\u52a8\u662f\u5426\u6709\u6548\uff0c\u80fd\u5426\u89e3\u51b3\u6700\u521d\u7684\u95ee\u9898\uff0c\u6216\u8005\u662f\u5426\u5f71\u54cd\u7a0b\u5e8f\u8fd0\u884c\uff0c\u60a8\u53ef\u4ee5\u8fd0\u884c MatrixOne \u8fdb\u884c\u7b80\u5355\u7684\u9884\u89c8\u548c\u6d4b\u8bd5\u3002 \u5f53\u7136\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u6309\u7167\u6559\u7a0b\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#5","title":"\u6b65\u9aa4 5\uff1a\u63d0\u4ea4\u4fee\u6539","text":"\u5f53\u5b8c\u6210\u4ee5\u4e0a\u4fee\u6539\u548c\u6d4b\u8bd5\u540e\uff0c\u60a8\u5c31\u53ef\u4ee5\u5f00\u59cb\u63d0\u4ea4\u4fee\u6539\u3002\u9996\u5148\u4f7f\u7528\u5c06\u60a8\u6240\u66f4\u6539\u7684\u6587\u4ef6\u6dfb\u52a0\u81f3 git \u6240\u7ba1\u7406\u7684\u76ee\u5f55\u4e2d\uff1a
git add <filename>\n
<filename>
\u662f\u60a8\u6240\u4fee\u6539\u7684\u6587\u4ef6\u7684\u540d\u79f0\u3002 \u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff0c\u76f4\u63a5\u5c06\u5f53\u524d\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u90fd\u6dfb\u52a0\u81f3\u7ba1\u7406\u76ee\u5f55\uff1a
git add .\n
\u4e4b\u540e\uff0c\u60a8\u53ef\u4ee5\u63d0\u4ea4\u60a8\u7684\u4fee\u6539
git commit -m \"<commit message>\" -s\n
<commit message>
\u662f\u60a8\u5bf9\u672c\u6b21\u4fee\u6539\u7684\u7b80\u5355\u603b\u7ed3\u548c\u63cf\u8ff0\uff0c\u8bd5\u7740\u505a\u5230\u7b80\u660e\u627c\u8981\u3002
\u63d0\u4ea4\u4fee\u6539\u540e\uff0c\u60a8\u9700\u8981\u5c06\u672c\u5730\u7684\u63d0\u4ea4\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u2014\u2014\u2014\u6211\u4eec\u5f3a\u70c8\u63a8\u8350\u60a8\u63a8\u9001\u81f3\u76ee\u6807\u4ed3\u5e93\u7684\u4e00\u4e2a\u65b0\u5206\u652f\uff1a
git push origin main:NEW_BRANCH\n
NEW_BRANCH
\u60a8\u521b\u5efa\u5e76\u63a8\u9001\u81f3\u7684\u65b0\u5206\u652f\u540d\uff0c\u60a8\u4e5f\u53ef\u4ee5\u968f\u610f\u66ff\u6362\u5b83\uff0c\u4f46\u4e5f\u8bb0\u5f97\u540e\u7eed\u4e00\u5e76\u4fee\u6539\u3002
\u63a8\u9001\u540e\uff0c\u53ef\u4ee5\u5728\u60a8\u6240 Fork \u7684\u4ed3\u5e93\u4e2d\u770b\u5230\u76f8\u5173\u63d0\u793a\u4fe1\u606f\uff0c\u70b9\u51fb Compare & Pull Request \u6309\u952e\u6765\u521b\u5efa\u4e00\u4e2a PR\uff08\u8be5 PR \u5e94\u8be5\u662f\u4ece\u4e2a\u4eba\u4ed3\u5e93\u7684 NEW_BRANCH
\u5206\u652f\u5230\u4e3b\u5e93\u7684 main
\u5206\u652f\uff09\u3002
Note
\u5efa\u8bae\u6309\u7167 PR \u4e2d\u6240\u7ed9\u51fa\u7684\u6a21\u677f\u8981\u6c42\uff0c\u64b0\u5199\u76f8\u5173\u4fe1\u606f\uff0c\u5982\u6b64\u53ef\u4ee5\u51c6\u786e\u8868\u8fbe\u60a8\u7684\u95ee\u9898\u4ee5\u53ca\u6240\u505a\u7684\u4fee\u6539\uff0c\u4ece\u800c\u63d0\u9ad8\u5ba1\u67e5\u6548\u7387\u3002
\u60a8\u7684 PR \u4e00\u65e6\u521b\u5efa\uff0c\u5c31\u6709\u793e\u533a\u8d44\u6df1\u7684\u5f00\u53d1\u4eba\u5458\u5ba1\u6838\u60a8\u7684\u4ee3\u7801\uff0c\u4ed6\u5c06\u4f1a\u68c0\u67e5\u60a8\u505a\u7684\u4fee\u6539\u5e76\u4e14\u8fdb\u884c\u56de\u590d\uff0c\u8bf7\u53ca\u65f6\u4e0e\u60a8\u6c9f\u901a\uff0c\u7136\u540e\u6309\u7167\u8981\u6c42\u8fdb\u884c\u4fee\u6539\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#8","title":"\u6b65\u9aa4 8\uff1a\u540c\u6b65\u4ee3\u7801\u5e93","text":"\u5f53\u8fdb\u884c\u5230\u8fd9\u4e00\u6b65\u65f6\uff0c\u606d\u559c\u60a8\u7684\u4fee\u6539\u5df2\u7ecf\u88ab\u63a5\u53d7\u5e76\u4e14 Merge \u8fdb\u5165\u9879\u76ee\u4e2d\uff0c\u611f\u8c22\u60a8\u505a\u51fa\u7684\u8d21\u732e\uff01 \u4f46\u5de5\u4f5c\u8fd8\u6ca1\u6709\u7ed3\u675f\uff0c\u8fd8\u6709\u4e00\u4e9b\u5de5\u4f5c\u8981\u505a\uff08\u8fd9\u4e9b\u5de5\u4f5c\u6709\u52a9\u4e8e\u4fdd\u8bc1\u63d0\u4ea4\u8bb0\u5f55\u7684\u5e72\u51c0\uff0c\u6709\u5229\u4e8e\u9879\u76ee\u8fdb\u4e00\u6b65\u53d1\u5c55\uff09\u3002 \u53ef\u4ee5\u5c06\u8fdc\u7aef\u4ed3\u5e93\u7684\u4ee3\u7801\u62c9\u53d6\u4e0b\u6765\u8986\u76d6\u672c\u5730\uff0c\u4ee5\u4fdd\u6301\u540c\u6b65\uff1a
git pull --force upstream main:main\n
\u6700\u540e\uff0c\u518d\u5c06\u4ee3\u7801\u63a8\u9001\u5230\u60a8\u7684\u4ed3\u5e93\u4e2d\u7684 main
\u5206\u652f\uff0c\u8fd9\u6837\u5c31\u80fd\u4fdd\u8bc1\u4e09\u4e2a\u4ed3\u5e93\u4ee3\u7801\u5747\u4e00\u81f4\u3002
git push --force origin main:main\n
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/","title":"\u4ee3\u7801\u6ce8\u91ca\u89c4\u8303","text":"\u672c\u6587\u63cf\u8ff0\u4e86 MatrixOne \u6240\u4f7f\u7528\u7684\u4ee3\u7801\u6ce8\u91ca\u7684\u89c4\u8303\u548c\u6837\u5f0f\u3002\u5f53\u4f60\u63d0\u4ea4\u4ee3\u7801\u65f6\uff0c\u8bf7\u52a1\u5fc5\u9075\u5faa\u5df2\u6709\u7684\u4ee3\u7801\u6ce8\u91ca\u89c4\u8303\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#_2","title":"\u4e3a\u4ec0\u4e48\u6ce8\u91ca\u5f88\u91cd\u8981\uff1f","text":"\u4ee5\u4e0b\u7c7b\u578b\u7684\u4ee3\u7801\u65f6\u5f88\u6709\u5fc5\u8981\u505a\u51fa\u6ce8\u91ca\uff1a
\u4ee5\u4e0b\u90e8\u5206\u4e5f\u9700\u8981\u8fdb\u884c\u6ce8\u91ca\uff1a
Go
//
\u6765\u8fdb\u884c\u5355\u884c\u6ce8\u91ca/* ... */
\u5bf9\u4ee3\u7801\u5757\u8fdb\u884c\u6ce8\u91ca\u628a\u5355\u884c\u6ce8\u91ca\u3001\u4ee3\u7801\u5757\u6ce8\u91ca\u653e\u5728\u4ee3\u7801\u4e0a\u65b9
\u6ce8\u91ca\u4e2d\u7684\u6bcf\u884c\u6587\u672c\u4e0d\u8d85\u8fc7 100 \u4e2a\u8bcd
\u5305\u542b URL \u7684\u6ce8\u91ca\uff1a
\u5355\u8bcd
\u8bf7\u7edf\u4e00\u4f7f\u7528\u7f8e\u5f0f\u82f1\u8bed
\u6ce8\u610f\u62fc\u5199\u6b63\u786e
\u4f7f\u7528\u6807\u51c6\u6216\u5b98\u65b9\u7684\u5927\u5199
\u4f7f\u7528\u4e00\u81f4\u6027\u7684\u77ed\u8bed\u548c\u8bcd\u6c47
\u4e0d\u8981\u4f7f\u7528\u5197\u957f\u7684\u590d\u5408\u8bcd
\u5c3d\u91cf\u4e0d\u4f7f\u7528\u7f29\u5199
\u7528 We \u7528\u6765\u4ee3\u6307\u4f5c\u8005\u548c\u8bfb\u8005
\u53e5\u5b50
\u53e5\u5b50\u9996\u5b57\u6bcd\u5927\u5199\uff0c\u5e76\u4ee5\u53e5\u53f7\u7ed3\u5c3e
\u5982\u679c\u4e00\u4e2a\u5c0f\u5199\u7684\u6807\u8bc6\u7b26\u4f4d\u4e8e\u53e5\u5b50\u5f00\u5934\uff0c\u53ef\u4ee5\u4e0d\u7528\u5927\u5199
// enterGame causes Players to enter the\n// video game, which is about a romantic\n// story in ancient China.\nfunc enterGame() os.Error {\n ...\n}\n
\u5f53\u6ce8\u91ca\u7528\u6765\u63cf\u8ff0\u4ee3\u7801\u65f6\uff0c\u5e94\u8be5\u4fdd\u8bc1\u4f7f\u7528\u63cf\u8ff0\u6027\u8bed\u53e5\u800c\u975e\u7948\u4f7f\u53e5
\u4f7f\u7528 \"this\" \u800c\u975e \"the\" \u6765\u6307\u4ee3\u5f53\u524d\u4e8b\u7269
\u5141\u8bb8\u4f7f\u7528 Markdown \u8bed\u6cd5\u683c\u5f0f
log
file \u611f\u8c22\u60a8\u7684\u8d21\u732e\uff01
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/","title":"MatrixOne \u884c\u4e3a\u5b88\u5219","text":""},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_1","title":"\u5171\u540c\u7684\u627f\u8bfa","text":"\u6211\u4eec\u4f5c\u4e3a\u9879\u76ee\u4e0e\u793e\u533a\u7684\u8d21\u732e\u8005\u548c\u7ef4\u62a4\u8005\uff0c\u627f\u8bfa\u5728\u53c2\u4e0e\u9879\u76ee\u4ee5\u53ca\u793e\u533a\u7684\u8fc7\u7a0b\u4e2d\uff0c\u81f4\u529b\u4e8e\u5f7c\u6b64\u5e2e\u52a9\u3001\u5171\u540c\u6210\u957f\uff0c\u7ef4\u62a4\u5f00\u6e90\u5f00\u653e\u3001\u548c\u8c10\u53cb\u5584\u7684\u6c1b\u56f4\uff0c\u65e0\u8bba\u5e74\u9f84\u3001\u4f53\u578b\u3001\u79cd\u65cf\u3001\u6027\u522b\u3001\u6027\u53d6\u5411\u3001\u8868\u8fbe\u3001\u7ecf\u9a8c\u3001\u6559\u80b2\u3001\u793e\u4f1a\u7ecf\u6d4e\u5730\u4f4d\u3001\u56fd\u7c4d\u3001\u4e2a\u4eba\u5916\u8c8c\u3001\u56fd\u5bb6\u3001\u5b97\u6559\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_2","title":"\u884c\u4e3a\u51c6\u5219","text":"\u6211\u4eec\u63d0\u5021\u90a3\u4e9b\u6709\u52a9\u4e8e\u8425\u9020\u7f8e\u597d\u793e\u533a\u73af\u5883\u7684\u884c\u4e3a\uff1a
\u6211\u4eec\u4e0d\u63d0\u5021\u66f4\u4e0d\u63a5\u53d7\u4ee5\u4e0b\u884c\u4e3a\uff1a
\u9879\u76ee\u7ef4\u62a4\u4eba\u5458\u6709\u8d23\u4efb\u660e\u786e\u503c\u5f97\u63d0\u5021\u7684\u884c\u4e3a\u89c4\u8303\uff0c\u5e76\u5bf9\u4efb\u4f55\u4e0d\u5f53\u884c\u4e3a\u91c7\u53d6\u9002\u5f53\u4e14\u516c\u5e73\u7684\u5904\u7406\u63aa\u65bd\u3002
\u9879\u76ee\u7ef4\u62a4\u4eba\u5458\u6709\u6743\u5229\u4e5f\u6709\u8d23\u4efb\u5220\u9664\u3001\u7f16\u8f91\u6216\u62d2\u7edd\u4e0d\u7b26\u5408\u4e0a\u8ff0\u884c\u4e3a\u51c6\u5219\u7684\u8bc4\u8bba\u3001\u63d0\u4ea4\u3001\u4ee3\u7801\u3001wiki \u7f16\u8f91\u548c issue\uff0c\u5e76\u6682\u65f6\u6216\u6c38\u4e45\u5c01\u7981\u53d1\u8868\u4e0d\u5f53\u8a00\u8bba\u6216\u505a\u51fa\u4e0d\u5f53\u884c\u4e3a\u7684\u8d21\u732e\u8005\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_4","title":"\u9002\u7528\u8303\u56f4","text":"\u672c\u884c\u4e3a\u5b88\u5219\u9002\u7528\u4e8e\u6240\u6709\u9879\u76ee\u7a7a\u95f4\uff0c\u4ee5\u53ca\u4efb\u4f55\u4ee3\u8868\u9879\u76ee\u3001\u793e\u533a\u7684\u516c\u5f00\u53d1\u8a00\u3002\u6bd4\u5982\uff1a\u4f7f\u7528\u5b98\u65b9\u7684\u9879\u76ee\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff0c\u901a\u8fc7\u5b98\u65b9\u793e\u4ea4\u5a92\u4f53\u8d26\u6237\u53d1\u5e03\u4fe1\u606f\uff0c\u6216\u4f5c\u4e3a\u6307\u5b9a\u4ee3\u8868\u53c2\u52a0\u7ebf\u4e0a\u7ebf\u4e0b\u6d3b\u52a8\u3002\u5177\u4f53\u6761\u4ef6\u7531\u9879\u76ee\u7ba1\u7406\u8005\u8fdb\u4e00\u6b65\u660e\u786e\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_5","title":"\u5177\u4f53\u5b9e\u65bd","text":"\u82e5\u60a8\u53d1\u73b0\u4efb\u4f55\u4fae\u8fb1\u3001\u9a9a\u6270\u6216\u5176\u4ed6\u4e0d\u5408\u89c4\u5b9a\u7684\u884c\u4e3a\u90fd\u53ef\u4ee5\u62a5\u544a\u7ed9\u9879\u76ee\u56e2\u961f\uff1ahai.jin@matrixorigin.io
\u3002\u6211\u4eec\u5c06\u6df1\u5165\u5ba1\u6838\u3001\u8c03\u67e5\u6240\u6709\u7684\u6295\u8bc9\u5e76\u4e14\u505a\u51fa\u53ca\u65f6\u3001\u5408\u7406\u7684\u53cd\u9988\u3002\u6b64\u5916\uff0c\u9879\u76ee\u56e2\u961f\u6709\u4e49\u52a1\u4fdd\u62a4\u4e3e\u62a5\u4eba\u7684\u9690\u79c1\u5b89\u5168\u3002 \u66f4\u52a0\u5177\u4f53\u7684\u6267\u884c\u653f\u7b56\u5c06\u53e6\u884c\u516c\u5e03\u3002
\u672c\u7bc7\u884c\u4e3a\u5b88\u5219\u6539\u7f16\u81ea\u8d21\u732e\u8005\u516c\u7ea6\uff0cversion 1.4\uff0c\u4e5f\u53ef\u53c2\u89c1 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\u3002
\u76f8\u5173\u95ee\u9898\u7684\u56de\u7b54\u53ef\u53c2\u89c1\uff1ahttps://www.contributor-covenant.org/faq
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/","title":"\u63d0\u4ea4\u4fe1\u606f&PR \u89c4\u8303","text":"\u672c\u6587\u6863\u63cf\u8ff0\u4e86\u5e94\u7528\u4e8e MatrixOrigin \u7684\u6240\u6709\u5b58\u50a8\u5e93\u7684\u63d0\u4ea4\u6d88\u606f (commit mesage) \u548c PR(pull request) \u7684\u6837\u5f0f\u89c4\u8303\u3002\u5f53\u4f60\u63d0\u4ea4\u4ee3\u7801\u65f6\uff0c\u52a1\u5fc5\u9075\u5faa\u8fd9\u79cd\u89c4\u8303\uff0c\u4fdd\u8bc1\u63d0\u4ea4\u7684\u8d28\u91cf\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#commit-message","title":"\u4e00\u6761\u597d\u7684 commit message \u6709\u591a\u91cd\u8981\uff1f","text":"\u6211\u4eec\u8ba4\u4e3a\u6709\u4ee5\u4e0b\u8981\u7d20\uff1a
What is your change? (\u5fc5\u8981)
\u5b83\u53ef\u80fd\u4fee\u590d\u4e86\u4e00\u4e2a\u7279\u5b9a\u7684 bug\uff0c\u6dfb\u52a0\u4e86\u4e00\u4e2a feature\uff0c\u63d0\u9ad8\u4e86\u6027\u80fd\u3001\u53ef\u9760\u6027\u6216\u7a33\u5b9a\u6027\uff0c\u6216\u8005\u53ea\u662f\u4fdd\u969c\u5b89\u5168\u6027\u800c\u8fdb\u884c\u7684\u66f4\u6539\u3002
Why this change was made? (\u5fc5\u8981)
\u5bf9\u4e8e\u7b80\u8981\u7684\u8865\u4e01\uff0c\u8fd9\u90e8\u5206\u53ef\u4ee5\u7701\u7565\u3002
What effect does the commit have? (\u53ef\u9009)
\u9664\u4e86\u5fc5\u7136\u4f1a\u4ea7\u751f\u7684\u5f71\u54cd\u4e4b\u5916\uff0c\u53ef\u80fd\u8fd8\u5305\u62ec\u57fa\u51c6\u6d4b\u8bd5\u6027\u80fd\u53d8\u5316\u3001\u5bf9\u5b89\u5168\u6027\u7684\u5f71\u54cd\u7b49\u3002\u5bf9\u4e8e\u7b80\u8981\u7684\u6539\u52a8\uff0c\u8fd9\u90e8\u5206\u53ef\u4ee5\u7701\u7565\u3002
\u8981\u5199\u51fa\u4e00\u6761\u4f18\u8d28\u7684 commit message\uff0c\u6211\u4eec\u5efa\u8bae\u60a8\u9075\u5faa\u89c4\u5b9a\u7684\u683c\u5f0f\uff0c\u57f9\u517b\u826f\u597d\u7684\u4e60\u60ef\u5e76\u4f7f\u7528\u89c4\u8303\u7684\u8bed\u8a00\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#_1","title":"\u89c4\u5b9a\u7684\u683c\u5f0f","text":"\u8bf7\u5728\u63d0\u4ea4\u65f6\u9075\u5faa\u4ee5\u4e0b\u683c\u5f0f\uff1a
<subsystem>: <what changed>\n<BLANK LINE>\n<why this change was made>\n<BLANK LINE>\n<footer>(optional)\n
\u7b2c\u4e00\u884c
util/codec, util/types:
\u3002*
\uff0c\u5982 *:
\u3002\u7b2c\u4e8c\u884c\u8bf7\u7559\u767d
misc fixes
\u7b49\u8868\u8fbe\u5173\u4e8e Pull Request \u4e2d\u7684\u63cf\u8ff0\uff0c\u8bf7\u53c2\u8003\u4e0b\u9762\u7684 Pull Request \u6a21\u677f\uff0c\u6db5\u76d6\u5fc5\u8981\u4fe1\u606f\uff1a
**What type of PR is this?**\n\n- [ ] API-change\n- [ ] BUG\n- [ ] Improvement\n- [ ] Documentation\n- [ ] Feature\n- [ ] Test and CI\n- [ ] Code Refactoring\n\n**Which issue(s) this PR fixes:**\n\nissue #\n\n**What this PR does / why we need it:**\n\n\n**Special notes for your reviewer:**\n\n\n**Additional documentation (e.g. design docs, usage docs, and so on.):**\n
\u5982\u679c\u9700\u8981\uff0c\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6e05\u5355\u6765\u5217\u4e3e\u5185\u5bb9\uff0cMarkdown \u8bed\u6cd5\u5982\u4e0b\uff1a
- [x] A checked line, something already done or fulfilled\n- [ ] An unchecked line, something not finished yet\n
\u5bf9\u4e8e\u975e\u5e38\u7b80\u8981\u7684 Pull Requests\uff0c\u4f60\u53ef\u4ee5\u7701\u7565\u4e0a\u9762\u7684\u4e00\u4e9b\u4fe1\u606f\u3002 \u975e\u5e38\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff01
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/","title":"\u4ee3\u7801\u8d21\u732e","text":"MatrixOne \u662f\u4e00\u4e2a\u7531\u9879\u76ee\u7ba1\u7406\u8005\u3001\u793e\u533a\u5f00\u53d1\u8005\u5171\u540c\u7ef4\u62a4\u3001\u6539\u8fdb\u548c\u6269\u5c55\u7684\u5f00\u6e90\u9879\u76ee\u3002 \u672c\u6587\u6863\u4e3b\u8981\u63cf\u8ff0\u4e86\u5f00\u53d1\u7684\u51c6\u5219\u4e0e\u4e00\u822c\u6d41\u7a0b\uff0c\u5e76\u63d0\u4f9b\u4e86\u5728\u7f16\u5199\u4ee3\u7801\u3001\u63d0\u4ea4 PR \u8fc7\u7a0b\u4e2d\u9700\u8981\u4f7f\u7528\u7684\u6837\u5f0f\u548c\u6a21\u677f\u3002\u5982\u679c\u60a8\u5728\u53c2\u4e0e MatrixOne \u7684\u8d21\u732e\u8fc7\u7a0b\u4e2d\u9047\u5230\u4efb\u4f55\u95ee\u9898\u6216\u53d1\u73b0\u4e00\u4e9b\u9519\u8bef\uff0c\u8bf7\u5728 Github \u4e0a\u63d0\u51fa issue \u6216\u901a\u5176\u4ed6\u5e73\u53f0\u8054\u7cfb\u6211\u4eec\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_2","title":"\u524d\u7f6e\u51c6\u5907","text":"\u5728\u6b63\u5f0f\u5f00\u53d1\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u9605\u8bfb\u4e86\u51c6\u5907\u5de5\u4f5c\uff0c\u5df2\u7ecf\u5bf9 MatrixOne \u7684\u6838\u5fc3\u7406\u5ff5\u3001\u57fa\u7840\u67b6\u6784\u6709\u4e00\u5b9a\u4e86\u89e3\uff0c\u5e76\u51c6\u5907\u597d\u4e86\u5f00\u53d1\u6240\u9700\u8981\u7684\u76f8\u5e94\u73af\u5883\u3001\u8bed\u8a00\u3001\u5de5\u5177\u7b49\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_3","title":"\u98ce\u683c\u89c4\u8303\u6307\u5357","text":"\u5728\u5bf9 MatrixOne \u8fdb\u884c\u5f00\u53d1\u548c\u5b8c\u5584\u65f6\uff0c\u5e94\u8be5\u4f7f\u4ee3\u7801\u3001\u4ee3\u7801\u6ce8\u91ca\u3001\u63d0\u4ea4\u4fe1\u606f (Committing Message) \u548c\u62c9\u53d6\u8bf7\u6c42 (Pull Request\uff0c\u7b80\u79f0 PR) \u4fdd\u6301\u4e00\u81f4\u7684\u98ce\u683c\u3002\u5f53\u60a8\u63d0\u4ea4 PR \u65f6\uff0c\u6211\u4eec\u5f3a\u70c8\u5efa\u8bae\u60a8\u786e\u4fdd\u6240\u4f5c\u51fa\u7684\u4fee\u6539\u7b26\u5408\u6211\u4eec\u7684\u4e00\u8d2f\u98ce\u683c\uff0c\u8fd9\u4e0d\u4ec5\u4f1a\u63d0\u9ad8 PR \u7684\u901a\u8fc7\u7387\uff0c\u5e76\u4e14\u4e5f\u80fd\u4f7f MatrixOne \u6613\u4e8e\u5ba1\u67e5\u3001\u7ef4\u62a4\u548c\u8fdb\u4e00\u6b65\u5f00\u53d1\u3002
MatrixOne \u91c7\u7528\u4e86 Golang \u793e\u533a\u5efa\u8bae\u7684\u7f16\u7801\u89c4\u8303\uff0c\u8be6\u60c5\u8bf7\u89c1 Effective Go\u3002
\u5173\u4e8e\u4ee3\u7801\u6ce8\u91ca\uff0c\u8bf7\u53c2\u8003\u4ee3\u7801\u6ce8\u91ca\u89c4\u8303\u3002
\u53ef\u53c2\u8003 Commit & PR \u89c4\u8303\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_4","title":"\u4e00\u822c\u5de5\u4f5c\u6d41\u7a0b","text":"\u60a8\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u5de5\u4f5c\u6d41\u7a0b\u6765\u8fdb\u884c\u5f00\u53d1\u5e76\u5728 Github \u4e0a\u63d0\u4ea4\u4fee\u6539\uff0c\u5982\u679c\u60a8\u8fd8\u9700\u8981\u66f4\u52a0\u8be6\u7ec6\u7684\u89e3\u91ca\uff0c\u53ef\u4ee5\u67e5\u770b Make Your First Contribution
1. \u5728 Github \u4e0a Fork matrixorigin/matrixone \u4ed3\u5e93\u3002
2. \u5c06 Fork \u7684\u4ed3\u5e93\u514b\u9686\u81f3\u672c\u5730\uff1a
git clone git@github.com:<yourname>/matrixone.git\n
\u5e76\u4e14\u628a matrixone \u4ed3\u5e93\u6dfb\u52a0\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\uff1a
git remote add upstream https://github.com/matrixorigin/matrixone.git\n
3. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\uff0c\u5206\u652f\u540d\u81ea\u5b9a\u4e49\uff1a
git checkout -b topic-branch\n
4. \u5728\u672c\u5730\u8fdb\u884c\u5f00\u53d1\uff0c\u5b8c\u6210\u76f8\u5173\u4fee\u6539\uff0c\u5e76\u5b8c\u6210\u5fc5\u8981\u7684\u5355\u5143\u6d4b\u8bd5\uff0c\u6700\u540e\u8fdb\u884c\u63d0\u4ea4\u3002
5. \u5c06\u4fee\u6539\u63a8\u9001\u81f3\u4ed3\u5e93\u7684\u4e00\u4e2a\u65b0\u5206\u652f\uff1a
git push origin main:NEW_BRANCH\n
6. \u5728\u4ed3\u5e93\u4e2d\u7684\u65b0\u5206\u652f NEW_BRANCH
\u4e2d\u521b\u5efa Pull Request\uff0c\u5e76\u6dfb\u52a0\u76f8\u5e94\u6807\u7b7e\u3001\u5efa\u7acb\u4e0e\u76f8\u5173 issue \u7684\u5173\u8054\u3002
7. PR \u901a\u8fc7\u540e\uff0c\u8986\u76d6\u672c\u5730\u63d0\u4ea4\u5386\u53f2\uff1a
git pull --force upstream main:main\n
8. \u66f4\u65b0\u60a8\u7684\u4ed3\u5e93\u7684 main
\u5206\u652f\uff1a
git push --force origin main:main\n
\u5982\u679c\u60a8\u4ecd\u7136\u6709\u4e00\u4e9b\u56f0\u60d1\uff0c\u53ef\u4ee5\u53c2\u8003 GitHub \u5b98\u65b9\u6587\u6863\u5bfb\u6c42\u5e2e\u52a9\uff1b\u82e5\u60a8\u53d1\u73b0\u6211\u4eec\u63d0\u4f9b\u7684\u5de5\u4f5c\u6d41\u7a0b\u6709\u9519\u8bef\u6216\u60f3\u8981\u63d0\u51fa\u6539\u5584\u7684\u65b9\u6cd5\uff0c\u6b22\u8fce\u60a8\u63d0\u51fa\u5efa\u8bae\uff01
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_5","title":"\u4ee3\u7801\u5ba1\u9605","text":"\u5f53\u60a8\u521b\u5efa PR \u8bf7\u6c42\u65f6\uff0c\u60a8\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e9b\u5ba1\u9605\u8005\uff0c\u6216\u8005\u7559\u7a7a\u3002\u5e76\u4e14\u60a8\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e9b\u76f8\u5173\u7684\u6807\u7b7e\uff0c\u8fd9\u6837\u66f4\u5bb9\u6613\u8bc6\u522b PR \u7684\u7c7b\u578b\u3001\u4f18\u5148\u7ea7\u7b49\u3002\u5728\u4ee3\u7801\u5ba1\u9605\u671f\u95f4\uff0c\u5ba1\u9605\u8005\u4f1a\u5bf9\u60a8\u7684\u4ee3\u7801\u7247\u6bb5\u7ed9\u51fa\u610f\u89c1\uff0c\u60a8\u53ef\u4ee5\u76f8\u5e94\u5730\u5728\u672c\u5730\u4fee\u6539\u60a8\u7684\u5206\u652f\u4e0a\u7684\u4ee3\u7801\uff0c\u63d0\u4ea4\u66f4\u6539\uff0c\u7136\u540e\u63a8\u9001\u5230 GitHub\uff0c\u65b0\u7684\u63d0\u4ea4\u4f1a\u81ea\u52a8\u9644\u52a0\u5230 PR \u4e0a\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/","title":"\u6587\u6863\u8d21\u732e\u6307\u5357","text":"\u6b22\u8fce\u5bf9 MatrixOne \u6587\u6863\u7684\u63d0\u51fa\u8d21\u732e\u3002MatrixOne \u793e\u533a\u4e00\u76f4\u5728\u52aa\u529b\u7b80\u5316\u6574\u4e2a\u8d21\u732e\u6d41\u7a0b\uff0c\u4e3a\u6b64\uff0c\u6211\u4eec\u521b\u5efa\u672c\u8282\u6765\u4e00\u6b65\u6b65\u5730\u6307\u5bfc\u60a8\u5b8c\u6210\u6587\u6863\u8d21\u732e\u7684\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#_2","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u5f00\u59cb\u4e4b\u524d\u8bf7\u5c3d\u91cf\u719f\u6089\u57fa\u672c\u7684 Markdown \u8bed\u6cd5\u5e76\u9605\u8bfb\u884c\u4e3a\u5b88\u5219\u548c\u8c37\u6b4c\u5f00\u53d1\u8005\u6587\u6863\u98ce\u683c\u6307\u5357\uff0c\u4ee5\u4fbf\u60a8\u5199\u51fa\u66f4\u9ad8\u8d28\u91cf\u7684\u6587\u6863\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#_3","title":"\u6587\u6863\u7ba1\u7406\u903b\u8f91","text":"MatrixOne \u6587\u6863\u901a\u8fc7\u4e09\u4e2a\u4ed3\u5e93\u6765\u534f\u8c03\u7ba1\u7406\uff1a
matrixorigin.io \u4ed3\u5e93\u5305\u542b\u82f1\u6587\u6587\u6863\u7684\u5177\u4f53\u5185\u5bb9\u3002\uff08. md \u6587\u4ef6\uff09
matrixorigin.io.cn \u4ed3\u5e93\u5305\u542b\u4e2d\u6587\u6587\u6863\u7684\u5177\u4f53\u5185\u5bb9\u3002\uff08. md \u6587\u4ef6\uff09
artwork \u4ed3\u5e93\u5305\u542b\u4e86\u6587\u6863\u6240\u7528\u5230\u7684\u56fe\u50cf\u7b49\u975e\u7ed3\u6784\u6027\u6587\u4ef6\u3002\u56fe\u50cf\u7b49\u975e\u7ed3\u6784\u5316\u6587\u4ef6\u5219\u76f4\u63a5\u5f15\u7528 artwork
\u4ed3\u5e93\u7684\u7f51\u7ad9\u94fe\u63a5\uff0c\u5982\uff1a
https://github.com/matrixorigin/artwork/blob/main/docs/overview/overall-architecture.png?raw=true\n
matrixorigin.io
\u548c matrixorigin.io.cn
\u5747\u90e8\u7f72\u4e86\u4e00\u4e2a CI \u7a0b\u5e8f\uff0c\u5f53\u6709\u65b0\u7684\u4ee3\u7801\u88ab\u5408\u5e76\u65f6\u5c06\u81ea\u52a8\u89e6\u53d1\uff0c\u5c06\u6587\u6863\u53d1\u5e03\u5230\u6211\u4eec\u7684\u5b98\u65b9\u6587\u6863\u7f51\u7ad9\u3002 \u6211\u4eec\u7684\u6587\u6863\u662f\u57fa\u4e8e mkdocs-material \u7ec4\u4ef6\u8fdb\u884c\u5f00\u53d1\u7684\uff0c\u60a8\u53ef\u4ee5\u5728\u6b64\u94fe\u63a5\u4e2d\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002
MatrixOne \u6587\u6863\u5185\u5bb9\u53ef\u4ee5\u5206\u4e3a\u5982\u4e0b\u51e0\u4e2a\u6a21\u5757\uff1a
Overview: MatrixOne \u7684\u7b80\u4ecb\uff0c\u5305\u542b\u4e86\u4ea7\u54c1\u7279\u70b9\u3001\u67b6\u6784\u3001\u8bbe\u8ba1\u601d\u8def\u548c\u6280\u672f\u7ec6\u8282\u3002
Getting Started: \u4ecb\u7ecd\u5982\u4f55\u5728\u5355\u673a\u73af\u5883\u4e2d\u5feb\u901f\u90e8\u7f72\u548c\u8fd0\u884c MatrixOne\u3002
Developing Guide: \u4ecb\u7ecd\u5982\u4f55\u5728\u5355\u673a\u6216\u5206\u5e03\u5f0f\u73af\u5883\u4e2d\u6df1\u5ea6\u4f7f\u7528 MatrixOne\u3002
Deploying: \u4ecb\u7ecd\u5982\u4f55\u5728\u90e8\u7f72\u548c\u8fd0\u884c MatrixOne \u96c6\u7fa4\u3002
Maintenance: \u4ecb\u7ecd\u5982\u4f55\u8fd0\u7ef4 MatrixOne\uff0c\u5305\u62ec\u5907\u4efd\u4e0e\u6062\u590d\u6570\u636e\u7b49\u3002
Migrating: \u4ecb\u7ecd\u5982\u4f55\u5c06\u6570\u636e\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8fc1\u79fb\u81f3 MatrixOne\u3002
Testing: \u4ecb\u7ecd\u5982\u4f55\u5728\u4f7f\u7528\u6d4b\u8bd5\u5de5\u5177\u5b8c\u6210\u81ea\u6d4b\uff0c\u6216\u8005\u5bf9 MatrixOne \u8fdb\u884c\u6027\u80fd\u6d4b\u8bd5\u3002
Troubleshooting: \u4ecb\u7ecd\u5982\u4f55\u5bf9 MatrixOne \u8fdb\u884c\u6545\u969c\u8bca\u65ad\u3002
Tuning Performance: \u4ecb\u7ecd\u5982\u4f55\u5728\u5355\u673a\u6216\u5206\u5e03\u5f0f\u73af\u5883\u4e2d\u5bf9 MatrixOne \u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u3002
Privilege: \u4ecb\u7ecd MatrixOne \u96c6\u7fa4\u4e0b\u591a\u79df\u6237\u7ba1\u7406\u3001\u8d26\u53f7\u751f\u547d\u5468\u671f\u7ba1\u7406\u3001\u6388\u6743\u7b49\u3002
Reference: \u5305\u62ec SQL \u53c2\u8003\u6307\u5357\u3001\u914d\u7f6e\u53c2\u6570\u8bbe\u7f6e\u3001\u4f7f\u7528\u9650\u5236\u7b49\u3002
FAQs: \u5173\u4e8e\u4ea7\u54c1\u3001\u6280\u672f\u8bbe\u8ba1\u3001SQL\u3001\u90e8\u7f72\u7684\u5e38\u89c1\u7591\u96be\u95ee\u9898\u3002
Release Notes: \u6240\u6709\u7248\u672c\u7684\u53d1\u5e03\u8bf4\u660e\u3002
Contribution Guide: \u4ecb\u7ecd\u5982\u4f55\u4e3a MatrixOne \u9879\u76ee\u505a\u51fa\u8d21\u732e\u3002
Glossary: \u540d\u8bcd\u91ca\u4e49\u8868\u3002
\u5982\u679c\u60a8\u53d1\u73b0\u4e86\u9519\u522b\u5b57\u6216\u8bed\u6cd5\u9519\u8bef\uff0c\u53ef\u4ee5\u70b9\u51fb\u672c\u9875\u9762\u7684 Edit this Page
\u6309\u952e\u76f4\u63a5\u8fdb\u884c\u4fee\u6539\u3002
\u5f53\u60a8\u9700\u8981\u66f4\u6539\u6587\u6863\u7684\u5177\u4f53\u5185\u5bb9\u4f46\u4e0d\u6d89\u53ca\u7ae0\u8282\u987a\u5e8f\u3001\u67b6\u6784\u7ec4\u7ec7\u7684\u8c03\u6574\u65f6\uff0c\u9700\u8981\u5bf9 matrixorigin.io/tree/main/docs/MatrixOne
\u6216 matrixorigin.io.cn/tree/main/docs/MatrixOne
\u8fdb\u884c\u64cd\u4f5c\u3002
\u5982\u679c\u9700\u8981\u5bf9\u7ae0\u8282\u987a\u5e8f\u3001\u67b6\u6784\u7ec4\u7ec7\u8fdb\u884c\u8c03\u6574\u65f6\uff0c\u9700\u8981\u5bf9 matrixorigin.io/blob/main/mkdocs.yml
\u6216 matrixorigin.io.cn/blob/main/mkdocs.yml
\u8fdb\u884c\u64cd\u4f5c\u3002
\u4ee5\u4e0b\u6d41\u7a0b\u6f14\u793a\u7684\u662f\u5bf9\u4e8c\u8005\u5747\u505a\u4fee\u6539\u7684\u60c5\u51b5\uff0c\u5b9e\u9645\u60c5\u51b5\u53ef\u4ee5\u6839\u636e\u60a8\u7684\u9700\u6c42\u8fdb\u884c\u7b80\u5316\u3002
1. \u5728 GitHub \u4e0a\u5bf9\u82f1\u6587\u6587\u6863\u63d0\u51fa Issue \u6216\u5bf9\u4e2d\u6587\u6587\u6863\u63d0\u51fa Issue\uff0c\u7b80\u5355\u4ecb\u7ecd\u60a8\u53d1\u73b0\u7684\u95ee\u9898\u3002\u5e76\u4e14\u5728 Issue \u4e0b\u9762\u8bc4\u8bba\u8ba4\u9886\u8be5\u95ee\u9898\u3002
2. Fork matrixorigin.io \u548c matrixorigin.io.cn \u4ed3\u5e93\u3002
3. \u514b\u9686 matrixorigin.io \u548c matrixorigin.io.cn \u4ed3\u5e93\u3002
git clone git@github.com:yourusername/matrixorigin.io.git\n
git clone git@github.com:yourusername/matrixorigin.io.cn.git\n
4. \u5728\u60a8\u7684\u672c\u5730 matrixorigin.io \u548c matrixorigin.io.cn \u6587\u4ef6\u5939\u4e2d\u5c06\u5bf9\u5e94\u4ed3\u5e93\u6dfb\u52a0\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\u3002
matrixorigin.io
\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\uff1agit remote add upstream https://github.com/matrixorigin/matrixorigin.io.git\n
matrixorigin.io.cn
\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\uff1agit remote add upstream https://github.com/matrixorigin/matrixorigin.io.cn.git\n
5. \u672c\u5730\u7684 matrixorigin.io \u6216 matrixorigin.io.cn \u6587\u4ef6\u5939\u4e2d\u5c06\u5305\u542b\u6587\u6863\u6240\u9700\u8981\u7684\u5168\u90e8\u6587\u4ef6\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u8fd0\u884c mkdocs serve
\u547d\u4ee4\uff0c\u7136\u540e\u5728 http://localhost:8000
\u7f51\u5740\u4e2d\u9884\u89c8\u6587\u6863\uff0c\u68c0\u67e5\u6574\u4e2a\u9879\u76ee\u6587\u4ef6\u662f\u5426\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\uff0c\u5e76\u4e14\u540e\u7eed\u4e5f\u53ef\u4ee5\u68c0\u67e5\u60a8\u6240\u505a\u7684\u4fee\u6539\u662f\u5426\u6b63\u786e\u3002
mkdocs serve\n
6. \u8fdb\u884c\u6587\u6863\u7684\u4fee\u6539\u548c\u5b8c\u5584\uff0c\u5982\u679c\u60a8\u60f3\u5bf9\u9879\u76ee\u7684\u8bbe\u7f6e\u8fdb\u884c\u6539\u52a8\uff0c\u6216\u8005\u6dfb\u52a0\u65b0\u7684 page \u6765\u66f4\u65b0 sitemap\uff0c\u6216\u66f4\u65b0 CI&CD \u5de5\u4f5c\u6d41\u4ee3\u7801\uff0c\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7 http://localhost:8000
\u6765\u67e5\u770b\u60a8\u7684\u4fee\u6539\u662f\u5426\u6709\u6548\u3002
7. \u786e\u8ba4\u4fee\u6539\u65e0\u8bef\u540e\uff0c\u4f7f\u7528 git add .
\u548c git commit
\u547d\u4ee4\u5728\u672c\u5730\u63d0\u4ea4\u4fee\u6539\uff0c\u5e76\u63a8\u9001\u81f3\u60a8 Fork \u7684\u8fdc\u7a0b\u4ed3\u5e93 matrixorigin.io
\u4e0e matrixorigin.io.cn
\u3002 \u6211\u4eec\u5efa\u8bae\u60a8\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u7684\u65b0\u5206\u652f\uff1a
git push origin main:NEW_BRANCH\n
8. \u5728 Github \u4e0a\u76f8\u5e94\u4ed3\u5e93\u7684 NEW_BRANCH
\u5206\u652f\u63d0\u4ea4 Pull Request\u3002
9. \u4e00\u65e6\u60a8\u7684\u4fee\u6539\u901a\u8fc7\uff0cCI \u5de5\u4f5c\u6d41\u5c06\u5f00\u59cb\u8fd0\u884c\u5e76\u66f4\u65b0\u6587\u6863\u7f51\u7ad9\uff0c\u8fd9\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4\u3002
10. \u6700\u540e\uff0c\u8fd8\u6709\u4e00\u4e9b\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u6301\u60a8\u7684\u8fdc\u7aef\u4ed3\u5e93\u548c\u672c\u5730\u4ed3\u5e93\u5747\u4fdd\u6301\u4e00\u81f4\u3002
\u8986\u76d6\u672c\u5730\u63d0\u4ea4\u5386\u53f2\uff1a
git pull --force upstream main:main\n
\u66f4\u65b0 Github \u4e0a\u7684 main
\u5206\u652f\uff1a
git push --force origin main:main\n
Info
\u82e5\u60a8\u5728\u4e2d\u82f1\u6587\u4e24\u4e2a\u4ed3\u5e93\u90fd\u505a\u4e86\u4fee\u6539\uff0c\u90a3\u4e48\u4ee5\u4e0a\u5927\u90e8\u5206\u64cd\u4f5c\u90fd\u9700\u8981\u5206\u522b\u9488\u5bf9\u4e2d\u82f1\u6587\u4e24\u4e2a\u4ed3\u5e93\u90fd\u6267\u884c\u4e00\u904d\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#_7","title":"\u5199\u4e00\u7bc7\u535a\u6587","text":"\u5982\u679c\u60a8\u6709\u610f\u5199\u4e00\u7bc7\u5173\u4e8e MatrixOne \u7684\u535a\u6587\uff0c\u8bf7\u5728 GitHub \u4e0a\u63d0\u51fa Issue\uff0c\u6216\u8005\u5c06\u60a8\u7684\u60f3\u6cd5\u53d1\u9001\u5230 dengnan@matrixorigin.io\uff0c\u65e0\u8bba\u662f\u7b80\u5355\u7684 Idea \u8fd8\u662f\u5b8c\u6574\u7684\u8349\u6848\uff0c\u6211\u4eec\u7edf\u7edf\u63a5\u53d7\u3002\u6211\u4eec\u4f1a\u5c3d\u5feb\u5ba1\u67e5\u6240\u6709\u5185\u5bb9\uff0c\u5982\u679c\u60a8\u7684\u6587\u7ae0\u6216\u60f3\u6cd5\u5f88\u5951\u5408\u6211\u4eec\u7684\u535a\u5ba2\uff0c\u6211\u4eec\u4f1a\u76f4\u63a5\u8054\u7cfb\u60a8\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/","title":"\u63d0\u4ea4\u8bbe\u8ba1\u65b9\u6848","text":"\u524d\u9762\u7ae0\u8282\u63d0\u5230\u4e86\u5f88\u591a\u79cd\u7c7b\u7684\u4fee\u6539\uff0c\u6bd4\u5982 Bug \u4fee\u590d\u3001\u6587\u6863\u5b8c\u5584\uff0c\u8fd9\u4e9b\u90fd\u53ef\u4ee5\u901a\u8fc7 GitHub \u7684 PR \u5de5\u4f5c\u6d41\u7a0b\u6765\u5b9e\u73b0\uff1b\u4f46\u4e0e\u6b64\u4e0d\u540c\u7684\u662f\uff0c\u5982\u679c\u60a8\u60f3\u8981\u5728 MatrixOne \u4e2d\u5b9e\u73b0\u65b0\u7684\u529f\u80fd\u6216\u589e\u6dfb\u65b0\u7684\u7ec4\u4ef6\uff0c\u90fd\u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a Idea \u8fd9\u4e48\u7b80\u5355\uff0c\u6211\u4eec\u9f13\u52b1\u60a8\u63d0\u51fa\u60f3\u6cd5\u7684\u540c\u65f6\u8fd8\u5236\u5b9a\u76f8\u5e94\u7684\u8bbe\u8ba1\u65b9\u6848\uff0c\u5c06\u5176\u8868\u8fbe\u4e3a\u6280\u672f\u8bbe\u8ba1\u6587\u6863\u3002 \u56e0\u6b64\uff0c\u672c\u8282\u7684\u76ee\u7684\u6b63\u662f\u5f15\u5bfc\u60a8\u64b0\u5199\u4e00\u4efd\u6280\u672f\u8bbe\u8ba1\u6587\u6863\uff0c\u4ee5\u671f\u53ef\u4ee5\u4e3a\u8fd9\u4e2a\u65b0\u529f\u80fd\u63d0\u4f9b\u4e00\u4e2a\u66f4\u52a0\u6743\u5a01\u7684\u3001\u5927\u4f17\u5316\u7684\u89e3\u91ca\uff0c\u5404\u65b9\u4eba\u5458\u53ef\u4ee5\u66f4\u6df1\u5165\u5730\u4e86\u89e3\u8fd9\u4e2a\u6a21\u5757\u7684\u6838\u5fc3\u7406\u5ff5\u4e0e\u53d1\u5c55\u65b9\u5411\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/#_2","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u4e0e\u5176\u4ed6\u5de5\u4f5c\u4e00\u6837\uff0c\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5c3d\u91cf\u505a\u8db3\u51c6\u5907\uff0c\u8fd9\u6837\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u60a8\u7684\u5de5\u4f5c\u6548\u7387\uff0c\u8fd8\u53ef\u4ee5\u589e\u52a0\u65b9\u6848\u901a\u8fc7\u7684\u53ef\u80fd\u6027\uff1b\u76f8\u53cd\uff0c\u4e00\u4efd\u7c97\u7cd9\u800c\u968f\u610f\u7684\u8bbe\u8ba1\u6587\u4ef6\u53ef\u80fd\u4f1a\u56e0\u4e3a\u8d28\u91cf\u592a\u5dee\u800c\u5403\u5230\u95ed\u95e8\u7fb9\u3002 \u6211\u4eec\u9f13\u52b1\u60a8\u5411\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u4eba\u5458\u5bfb\u6c42\u5e2e\u52a9\uff0c\u901a\u8fc7\u4ed6\u4eec\u7684\u5efa\u8bae\u60a8\u53ef\u4ee5\u4fee\u6b63\u8bbe\u8ba1\u67b6\u6784\u5e76\u5b8c\u5584\u6280\u672f\u7ec6\u8282\u3002 \u60a8\u53ef\u4ee5\u5728\u524d\u5f80 Github\uff0c\u63d0\u4ea4\u4e00\u4e2a Feature Request
\u6216 Refactoring Request
\u6765\u5411\u5927\u5bb6\u5c55\u793a\u60a8\u7684\u60f3\u6cd5\u3002
\u901a\u5e38\uff0c\u4ece\u5934\u5230\u5c3e\u5730\u5b8c\u6210\u4e00\u9879\u6280\u672f\u8bbe\u8ba1\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u8bf7\u53ca\u65f6\u67e5\u770b\u5b50\u4efb\u52a1\u7684 Tracking issue \u6765\u8ddf\u8e2a\u4efb\u52a1\u5f00\u53d1\u8fdb\u7a0b\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u975e\u5e38\u6b22\u8fce\u60a8\u53c2\u4e0e\u5230 MatrixOne\uff08\u4ee5\u4e0b\u7b80\u79f0 MO\uff09\u9879\u76ee\u7684\u5efa\u8bbe\u4e2d\u6765\uff01\u65e0\u8bba\u4f60\u662f\u521d\u8bc6 MatrixOne\uff0c\u8fd8\u662f\u5df2\u7ecf\u8feb\u5207\u5730\u60f3\u53c2\u4e0e\u5230\u5f00\u53d1\u5de5\u4f5c\u4e2d\u6765\uff0c\u4ea6\u6216\u662f\u5728\u9605\u8bfb\u6587\u6863\u3001\u4f7f\u7528\u4ea7\u54c1\u7684\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u90fd\u6b22\u8fce\u4f60\u63d0\u51fa\u610f\u89c1\u548c\u5efa\u8bae\uff0c\u4e0e\u6211\u4eec\u5171\u540c\u6253\u9020\u66f4\u52a0\u5f3a\u5927\u3001\u7a33\u5b9a\u7684 MatrixOne\uff01 \u5f53\u7136\uff0c\u5728\u60a8\u5411 MatrixOne \u9879\u76ee\u63d0\u51fa\u6539\u8fdb\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u63d0\u524d\u8bf4\u660e\u4e00\u4e9b\u57fa\u672c\u89c4\u8303\u4e0e\u6d41\u7a0b\uff0c\u4ee5\u63d0\u9ad8\u6574\u4e2a\u8d21\u732e\u8fc7\u7a0b\u7684\u8d28\u91cf\u4e0e\u6d41\u7545\u6027\uff0c\u540c\u65f6\u4e5f\u80fd\u4fdd\u969c MO \u7684\u7a33\u5b9a\u6027\u4e0e\u5b89\u5168\u6027\u3002 \u6b64\u5916\uff0c\u5728\u672c\u7ae0\u4e2d\uff0c\u6211\u4eec\u4e3a\u5c1a\u672a\u719f\u77e5 MO \u7684\u8d21\u732e\u8005\u4eec\u63d0\u4f9b\u4e00\u4e9b\u4e86\u89e3\u6211\u4eec\u7684\u6e20\u9053\uff0c\u5e0c\u671b\u80fd\u4e3a\u4f60\u4eec\u5e26\u6765\u4e00\u4e9b\u4fbf\u5229\uff01
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#matrixone","title":"\u4e86\u89e3 MatrixOne","text":""},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_2","title":"\u7279\u70b9\u4e0e\u6846\u67b6","text":"\u5728 MatrixOne \u7b80\u4ecb\u4e2d\u60a8\u53ef\u4ee5\u4e86\u89e3\u5230 MO \u7684\u8d85\u878d\u5408\u3001\u4e91\u8fb9\u534f\u540c\u7279\u6027\u4ee5\u53ca\u5176\u6240\u521b\u9020\u7684\u4f18\u5f02\u8868\u73b0\u4e0e\u72ec\u7279\u4ef7\u503c\u3002 \u6b64\u5916\uff0c\u5728 MatrixOne \u6846\u67b6\u4e2d\u60a8\u53ef\u4ee5\u8be6\u7ec6\u5730\u4e86\u89e3 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\uff0c\u4ee5\u53ca\u5b58\u50a8\u5c42\u3001\u65e5\u5fd7\u5c42\u7b49\u5177\u4f53\u7ec4\u6210\u60c5\u51b5\u3002 \u540c\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u67e5\u9605 MatrixOne \u672f\u8bed\u8868\u6765\u4e86\u89e3\u4e00\u4e9b\u590d\u6742\u7684\u8bcd\u6c47\u3002 \u5728\u6280\u672f\u5c42\u9762\uff0cSQL \u53c2\u8003\u6307\u5357\u4e3a\u60a8\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684 SQL \u8bed\u8a00\u7684\u53c2\u8003\uff0c\u5176\u4e2d\u5bf9\u8bed\u6cd5\u548c\u793a\u4f8b\u90fd\u6709\u8be6\u7ec6\u89e3\u91ca\uff1b\u540c\u6837\uff0c\u81ea\u5b9a\u4e49\u51fd\u6570\u63d0\u4f9b\u4e86 MO \u4e2d\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u76f8\u5173\u89e3\u91ca\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_3","title":"\u5efa\u8bbe\u60c5\u51b5","text":"\u76ee\u524d\uff0cMatrixOne v1.2.1 \u5df2\u7ecf\u53d1\u5e03\u4e86\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u7248\u672c\u53d1\u5e03\u6307\u5357\u6765\u4e86\u89e3\u6700\u65b0\u7684\u53d1\u5e03\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u6700\u65b0\u7684\u4fee\u6539\u4e0e\u4f18\u5316\u3002
\u5173\u4e8e\u957f\u671f\u7684\u9879\u76ee\u89c4\u5212\uff0c\u8bf7\u53c2\u9605 MatrixOne Roadmap\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_4","title":"\u4f60\u53ef\u4ee5\u505a\u4e9b\u4ec0\u4e48\uff1f","text":"\u5bf9 MatrixOne \u7684\u8d21\u732e\u53ef\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a
\u6211\u4eec\u5c06\u4e3a Github \u4e0a matrixorigin/matrixone \u7684\u9879\u76ee\u76ee\u5f55\u53ca\u5176\u4e2d\u5173\u952e\u6587\u4ef6\u8fdb\u884c\u7b80\u5355\u4ecb\u7ecd\uff0c\u4ee5\u671f\u4e3a\u60a8\u7684\u6df1\u5165\u4e86\u89e3\u548c\u5f00\u53d1\u63d0\u4f9b\u6307\u5bfc\u6027\u5e2e\u52a9\u3002 matrixone \u662f MatrixOne \u4ee3\u7801\u6240\u5728\u7684\u4e3b\u5e93\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5176\u4e2d\u7684\u9879\u76ee\u76ee\u5f55\u4ee5\u53ca\u5173\u952e\u6587\u4ef6\uff0c\u4ee5\u671f\u4e3a\u60a8\u7684\u6df1\u5165\u4e86\u89e3\u548c\u5f00\u53d1\u63d0\u4f9b\u6307\u5bfc\u6027\u5e2e\u52a9\u3002
\u76ee\u5f55 \u5185\u5bb9 /LICENSES \u76f8\u5173\u4f9d\u8d56\u5e93\u7684\u8bb8\u53ef /cmd Go \u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684 binary entry optools \u6d4b\u8bd5\u4e0e\u90e8\u7f72\u5de5\u5177 pkg MatrixOne \u9879\u76ee\u7684\u4e3b\u8981\u4ee3\u7801\u5e93\u5bf9\u4e8e\u4e0d\u540c\u7684\u6280\u672f\u6a21\u5757\uff0c/pkg
\u559c\u7231\u7684\u4ee3\u7801\u7ed3\u6784\u5982\u4e0b\u8868\u6240\u793a\u3002
\u5728\u6587\u6863\u65b9\u9762\uff0cmatrixorigin.io\u3001matrixorigin.io.cn \u4e0e artwork \u90fd\u662f\u5728\u8d21\u732e\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f7f\u7528\u7684\u5e93\uff0c\u8be6\u60c5\u53c2\u89c1\u6587\u6863\u8d21\u732e\u3002
\u76ee\u5f55 \u5185\u5bb9 matrixone/docs/rfcs MatrixOne \u9879\u76ee\u7684\u8bbe\u8ba1\u6587\u6863 matrixorigin.io/docs/MatrixOne \u82f1\u6587\u6587\u6863\u7f51\u7ad9\u7684\u5177\u4f53\u5185\u5bb9\u6587\u4ef6\uff08.md \u6587\u4ef6\uff09 matrixorigin.io.cn/docs/MatrixOne \u4e2d\u6587\u6587\u6863\u7f51\u7ad9\u7684\u5177\u4f53\u5185\u5bb9\u6587\u4ef6\uff08.md \u6587\u4ef6\uff09 matrixorigin.io/mkdocs.yml \u82f1\u6587\u6587\u6863\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6 matrixorigin.io.cn/mkdocs.yml \u4e2d\u6587\u6587\u6863\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6 artwork/docs \u6587\u6863\u5b98\u7f51\u51fa\u73b0\u7684\u56fe\u7247\u548c\u56fe\u8868"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_6","title":"\u5f00\u53d1\u73af\u5883","text":"MO \u4e3b\u8981\u7531 Go \u8bed\u8a00\u7f16\u5199\uff0c\u56e0\u6b64\u9700\u8981\u63d0\u524d\u5b89\u88c5\u90e8\u7f72\u597d\u76f8\u5173\u7684\u5f00\u53d1\u73af\u5883\uff0c\u7b80\u8981\u7684\u793a\u4f8b\u6d41\u7a0b\u5982\u4e0b\uff1a
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin\n
Note
MatrixOne \u4f7f\u7528 Go Modules
\u6765\u7ba1\u7406\u76f8\u5173\u4f9d\u8d56\u3002
\u82e5\u60a8\u9700\u8981\u8865\u5145 Go \u8bed\u8a00\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u53ef\u4ee5\u901a\u8fc7 How to Write Go Code \u8fdb\u884c\u4e86\u89e3\u3002
\u6b64\u5916\uff0c\u786e\u4fdd\u60a8\u81f3\u5c11\u5df2\u7ecf\u5b89\u88c5\u4e86\u5355\u673a\u7248\u672c\u7684 MatrixOne\uff0c\u5177\u4f53\u8fc7\u7a0b\u53ef\u53c2\u7167 Install Standalone MatrixOne\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#github-git","title":"Github & Git","text":"\u4e3a\u66f4\u597d\u5730\u5f00\u53d1\u5efa\u8bbe MatrixOne\uff0c\u6211\u4eec\u91c7\u53d6\u4e86\u5f00\u6e90\u8fd0\u8425\u7684\u65b9\u5f0f\uff0c\u901a\u8fc7 Github \u4e3a\u9879\u76ee\u7ef4\u62a4\u4eba\u5458\u548c\u5176\u4ed6\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u4e2a\u534f\u4f5c\u5e73\u53f0\u3002\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u60f3\u53c2\u4e0e\u5230 MO \u7684\u5f00\u53d1\u4e2d\u6765\uff0c\u6211\u4eec\u5f3a\u70c8\u5efa\u8bae\u60a8\u91c7\u53d6 Github \u7684\u6e20\u9053\u3002 \u82e5\u60a8\u8fd8\u672a\u4f7f\u7528\u8fc7 Github \u6216\u7f3a\u5c11\u76f8\u5173\u5f00\u53d1\u7ecf\u9a8c\uff0c\u60a8\u9996\u5148\u9700\u8981\u719f\u6089 GitHub \u4e0a\u7684\u76f8\u5173\u64cd\u4f5c\uff0c\u5e76\u5b66\u4e60\u57fa\u672c\u7684 git \u547d\u4ee4\u3002 \u5982\u679c\u60a8\u6ca1\u6709 Github \u5e10\u6237\uff0c\u8bf7\u5728 https://github.com \u4e0a\u5b8c\u6210\u6ce8\u518c\u3002 \u5982\u679c\u4f60\u6ca1\u6709 SSH \u5bc6\u94a5\uff0c\u4f60\u53ef\u4ee5\u6309\u7167 GitHub \u4e0a\u5173\u4e8e SSH \u7684\u6559\u7a0b\u6765\u751f\u6210\u3001\u6dfb\u52a0\u5bc6\u94a5\u3002 \u66f4\u591a\u8be6\u60c5\u8bf7\u53c2\u89c1 Github Docs\u3002
\u6b64\u5916\uff0c\u6211\u4eec\u5efa\u8bae\u60a8\u5b66\u4e60\u5e76\u4f7f\u7528 git \u547d\u4ee4\u6765\u5b8c\u6210 Github \u4e0a\u7684\u5404\u79cd\u6d41\u7a0b\uff0c\u56e0\u4e3a\u6211\u4eec\u63d0\u4f9b\u7684\u76f8\u5173\u5de5\u4f5c\u6d41\u7a0b\u5927\u591a\u901a\u8fc7 git \u547d\u4ee4\u5b8c\u6210\uff0c\u8fd9\u6709\u52a9\u4e8e\u60a8\u63d0\u9ad8\u6548\u7387\u3002 \u60a8\u53ef\u901a\u8fc7 Install git \u5b89\u88c5 Git \u73af\u5883\u3002 \u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6559\u7a0b\u6765\u5b66\u4e60\u5982\u4f55\u4f7f\u7528\uff1a
\u60a8\u5728\u4f7f\u7528\u6216\u5f00\u53d1 MatrixOne \u8fc7\u7a0b\u4e2d\u9047\u89c1\u7684\u4efb\u4f55\u95ee\u9898\u90fd\u80fd\u4ee5 Issues \u7684\u5f62\u5f0f\u63d0\u51fa\u6765\uff0c\u6211\u4eec\u4e5f\u9f13\u52b1\u60a8\u6309\u7167\u6211\u4eec\u8bbe\u5b9a\u7684\u6a21\u677f\u548c\u6807\u7b7e\u5bf9 Issues \u8fdb\u884c\u8be6\u7ec6\u63cf\u8ff0\u548c\u5206\u7c7b\uff0c\u4ee5\u4fbf\u66f4\u9ad8\u6548\u5730\u89e3\u51b3\u95ee\u9898\u3002 \u672c\u8282\u65e8\u5728\u4ecb\u7ecd\u63d0\u51fa\u95ee\u9898\u65f6\u9700\u8981\u9075\u5faa\u7684\u6a21\u677f\u3001\u6807\u7b7e\u548c\u6ce8\u610f\u4e8b\u9879\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#_2","title":"\u907f\u514d\u91cd\u590d\u95ee\u9898","text":"\u5728\u63d0\u51fa Issue \u4e4b\u524d\uff0c\u5c3d\u91cf\u5148\u786e\u8ba4\u5176\u4ed6\u4eba\u662f\u5426\u5df2\u7ecf\u63d0\u51fa\u8fc7\u76f8\u540c\u6216\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u907f\u514d\u91cd\u590d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 search bar \u5de5\u5177\u5e2e\u52a9\u60a8\u7b5b\u9009\u67e5\u627e\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#_3","title":"\u6a21\u677f","text":"\u9488\u5bf9\u4e0d\u540c\u79cd\u7c7b\u7684\u95ee\u9898\uff0cMatrixOne \u4f7f\u7528\u4e86\u4e0d\u540c\u7684\u6a21\u677f\u5bf9\u5176\u5185\u5bb9\u8fdb\u884c\u523b\u753b\uff0c\u5176\u4e2d\u5927\u591a\u63cf\u8ff0\u4e86\u95ee\u9898\u7684\u5173\u952e\u4fe1\u606f\uff0c\u6709\u52a9\u4e8e\u5ba1\u67e5\u8005\u4e0e\u5176\u4ed6\u5f00\u53d1\u8005\u7406\u89e3\u5e76\u53c2\u4e0e\u5176\u4e2d\u3002
\u4f8b\u5982\uff0cBug report
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Enhancement
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Feature Request
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Performance Question
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Documentation Issue
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Refactoring Request
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
\u9664\u4e86\u63cf\u8ff0\u95ee\u9898\u7684\u8be6\u7ec6\u4fe1\u606f\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u6839\u636e\u95ee\u9898\u6240\u5c5e\u7684\u7ec4\u4ef6\u4ee5\u53ca\u95ee\u9898\u6240\u5c5e\u7248\u672c\u4e3a\u5176\u6dfb\u52a0\u9002\u5f53\u7684\u6807\u7b7e\u3002\u5f53\u60a8\u7684 Issue \u63d0\u4ea4\u4e4b\u540e\uff0c\u4f1a\u81ea\u52a8\u6253\u4e0a needs-triage
\u7684\u6807\u7b7e\uff0c\u4e4b\u540e\u9879\u76ee\u7ef4\u62a4\u8005\u4f1a\u8be6\u7ec6\u9605\u8bfb\u60a8\u7684 Issue\uff0c\u7136\u540e\u4e3a\u4e4b\u6253\u4e0a\u5408\u9002\u7684\u6807\u7b7e\u5e76\u5206\u914d\u7ed9\u5408\u9002\u7684\u5f00\u53d1\u8005\u3002 \u5982\u679c\u60a8\u60f3\u81ea\u5df1\u4eb2\u624b\u5904\u7406\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u63d0\u51fa\uff0c\u793e\u533a\u7ba1\u7406\u5458\u4f1a\u7ed9\u60a8\u5206\u914d\u8fd9\u4e2a issue\u3002\u82e5\u5728 Assignees \u90e8\u5206\u53ef\u4ee5\u770b\u89c1\u60a8\u81ea\u5df1\uff0c\u8bf4\u660e\u64cd\u4f5c\u6210\u529f\u3002
\u5f53\u60a8\u9996\u6b21\u53c2\u4e0e\u8d21\u732e\u65f6\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9 good-first-issue
\u6807\u7b7e\u4e0b\u7684\u95ee\u9898\u7740\u624b\u89e3\u51b3\uff0c\u5176\u4e0b\u7684\u6bcf\u4e2a\u95ee\u9898\u90fd\u662f\u76f8\u5bf9\u6765\u8bf4\u5bb9\u6613\u89e3\u51b3\u7684\u3002 \u8be6\u60c5\u8bf7\u9605\u8bfb\u5feb\u901f\u4e0a\u624b\u7ae0\u8282\u3002
\u5bf9 MatrixOne \u6765\u8bf4\uff0c\u5bf9 PR \u7684\u5ba1\u9605\u548c\u8bc4\u8bba\u662f\u81f3\u5173\u91cd\u8981\u7684\uff1a\u60a8\u53ef\u4ee5\u5bf9\u4ed6\u4eba\u7684 PR \u8fdb\u884c\u5206\u7c7b\uff0c\u4ee5\u4fbf\u6709\u4e13\u5bb6\u66f4\u5feb\u7684\u6765\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff1b\u60a8\u4e5f\u53ef\u4ee5\u5bf9\u4ee3\u7801\u7684\u5185\u5bb9\u8fdb\u884c\u5ba1\u9605\uff0c\u5bf9\u4ee3\u7801\u7f16\u5199\u7684\u98ce\u683c\u3001\u89c4\u8303\u7b49\u63d0\u51fa\u5efa\u8bae\uff1b\u54ea\u6015\u662f\u5728\u8bc4\u8bba\u533a\u7559\u4e0b\u4e00\u4e2a\u5c0f\u5c0f\u7684 Idea\uff0c\u8fd9\u4e5f\u5f25\u8db3\u73cd\u8d35\u3002 \u6240\u6709\u522b\u518d\u72b9\u8c6b\uff0c\u522b\u518d\u62c5\u5fc3\u60a8\u7684\u60f3\u6cd5\u4e0d\u591f\u5b8c\u5584\uff0c\u65e0\u8bba\u591a\u4e48\u5fae\u5c0f\u7684\u5efa\u8bae\u90fd\u53ef\u80fd\u4f1a\u5bf9 MatrixOne \u4ea7\u751f\u6df1\u8fdc\u5f71\u54cd\u3002
\u5f53\u7136\uff0c\u5728\u6b64\u4e4b\u524d\uff0c\u6211\u4eec\u5e0c\u671b\u60a8\u80fd\u8ba4\u771f\u9605\u8bfb\u672c\u8282\uff0c\u4e86\u89e3\u57fa\u672c\u8981\u6c42\u548c\u76f8\u5173\u65b9\u6cd5\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#_2","title":"\u57fa\u672c\u539f\u5219","text":"\u5f53\u5bf9\u4e00\u4e2a PR \u8fdb\u884c\u8bc4\u8bba\u6216\u8005\u5ba1\u9605\u65f6\uff0c\u65e0\u8bba\u5185\u5bb9\u5982\u4f55\uff0c\u6211\u4eec\u547c\u5401\u6240\u6709\u53c2\u4e0e\u8005\u90fd\u4fdd\u6301\u53cb\u597d\u548c\u5584\u7684\u6001\u5ea6\uff0c\u8425\u9020\u4e00\u4e2a\u548c\u8c10\u7684\u793e\u533a\u6c1b\u56f4\u3002
\u5c0a\u91cd\u4ed6\u4eba \u5c0a\u91cd\u6bcf\u4e00\u4e2a PR \u8bf7\u6c42\u7684\u53d1\u8d77\u4eba\u548c\u5176\u4ed6\u5ba1\u9605\u8005\u3002\u4ee3\u7801\u5ba1\u9605\u662f\u793e\u533a\u6d3b\u52a8\u7684\u91cd\u8981\u90e8\u5206\uff0c\u56e0\u6b64\u8bf7\u9075\u5faa\u793e\u533a\u8981\u6c42\u3002
\u6ce8\u610f\u8bed\u6c14 \u5728\u4e0e\u4ed6\u4eba\u6c9f\u901a\u4ea4\u6d41\u65f6\uff0c\u6211\u4eec\u9f13\u52b1\u60a8\u591a\u4f7f\u7528\u201c\u5efa\u8bae\u201d\u6216\u8005\u201c\u63d0\u95ee\u201d\u7684\u8bed\u6c14\uff0c\u800c\u4e0d\u8981\u603b\u662f\u547d\u4ee4\u4ed6\u4eba\u3002\u6362\u4f4d\u601d\u8003\uff0c\u6240\u6709\u4eba\u90fd\u5e0c\u671b\u88ab\u6e29\u67d4\u4ee5\u5f85\uff01
\u8d5e\u7f8e \u4e0d\u8981\u541d\u556c\u5bf9\u4ed6\u4eba\u7684\u8d5e\u7f8e\uff01\u4e00\u4e2a\u597d\u7684\u60f3\u6cd5\u6216\u8005\u597d\u7684\u6210\u679c\u503c\u5f97\u6211\u4eec\u5938\u8d5e\u3002\u5728\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u9f13\u52b1\u3001\u8d5e\u7f8e\u4ed6\u4eba\u5f80\u5f80\u6bd4\u4e0d\u7559\u60c5\u9762\u7684\u6279\u8bc4\u66f4\u6709\u4ef7\u503c\uff01
\u6b64\u5916\uff0c\u5728\u5177\u4f53\u5185\u5bb9\u4e0a\u6211\u4eec\u6709\u5982\u4e0b\u5efa\u8bae\uff1a
\u8be6\u7ec6\u800c\u5177\u4f53 \u6211\u4eec\u5e0c\u671b\u60a8\u80fd\u5728\u8bc4\u8bba\u4e2d\u63d0\u4f9b\u66f4\u4e3a\u8be6\u7ec6\u800c\u5177\u4f53\u7684\u4fe1\u606f\uff0c\u56e0\u4e3a\u4fe1\u606f\u8d8a\u8be6\u7ec6\uff0c\u4ed6\u4eba\u5c31\u66f4\u5bb9\u6613\u7406\u89e3\uff0c\u4e5f\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u89e3\u51b3\u95ee\u9898\u3002\u5982\u679c\u60a8\u8fdb\u884c\u4e86\u6d4b\u8bd5\uff0c\u5b8c\u5168\u53ef\u4ee5\u653e\u4e0a\u6d4b\u8bd5\u73af\u5883\u548c\u7ed3\u679c\uff1b\u5982\u679c\u60a8\u63d0\u51fa\u4e86\u4e00\u4e9b\u5efa\u8bae\uff0c\u90a3\u4e0d\u59a8\u8bf4\u8bf4\u5e94\u8be5\u5982\u4f55\u843d\u5b9e\u3002
\u5ba2\u89c2\u800c\u516c\u6b63 \u8bf7\u907f\u514d\u4e2a\u4eba\u504f\u89c1\u548c\u4e3b\u89c2\u60c5\u7eea\u3002\u8bda\u7136\uff0c\u6bcf\u4e2a\u4eba\u7684\u8bc4\u8bba\u6216\u591a\u6216\u5c11\u90fd\u4f1a\u5e26\u6709\u4e3b\u89c2\u8272\u5f69\uff0c\u4f46\u662f\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u6210\u719f\u7684\u5ba1\u9605\u8005\uff0c\u60a8\u5e94\u8be5\u6ce8\u91cd\u6280\u672f\u548c\u6570\u636e\uff0c\u800c\u4e0d\u662f\u4e2a\u4eba\u7684\u559c\u597d\u3002
\u7075\u6d3b\u800c\u5ba1\u614e \u5f53\u9047\u89c1\u4e00\u4e9b\u590d\u6742\u95ee\u9898\u65f6\uff0c\u5373\u4f7f\u662f\u5728\u7efc\u5408\u8003\u91cf\u591a\u65b9\u56e0\u7d20\u4e4b\u540e\u4e5f\u5f88\u96be\u6289\u62e9\uff0c\u201c\u63a5\u53d7\u201d\u8fd8\u662f\u201c\u62d2\u7edd\u201d\uff0c\u662f\u4e2a\u4e24\u96be\u7684\u95ee\u9898\u2014\u2014\u2014\u6211\u4eec\u4e5f\u65e0\u6cd5\u7ed9\u51fa\u4e00\u4e2a\u660e\u786e\u3001\u5177\u4f53\u7684\u6807\u51c6\uff0c\u53ea\u80fd\u8bf4\u201c\u5177\u4f53\u60c5\u51b5\uff0c\u5177\u4f53\u5206\u6790\u201d\u3002\u4f46\u662f\u6211\u4eec\u5efa\u8bae\u60a8\u5728\u96be\u4ee5\u6289\u62e9\u65f6\uff0c\u5bfb\u6c42\u4ed6\u4eba\u7684\u5e2e\u52a9\u3002
\u6709\u4e9b PR \u521b\u5efa\u8005\u53ef\u80fd\u5e76\u4e0d\u719f\u6089 MatrixOne \u6216\u76f8\u5173\u5f00\u53d1\u5de5\u4f5c\u6d41\u7a0b\uff0c\u56e0\u6b64\u4e0d\u786e\u5b9a\u5e94\u8be5\u6dfb\u52a0\u4f55\u79cd\u6807\u7b7e\uff0c\u4e5f\u4e0d\u4e86\u89e3\u5e94\u8be5\u628a\u95ee\u9898\u5206\u914d\u7ed9\u8c01\u3002\u5982\u679c\u60a8\u77e5\u9053\u8be5\u5982\u4f55\u505a\uff0c\u6211\u4eec\u5e0c\u671b\u60a8\u53ef\u4ee5\u5411\u4ed6\u4eec\u65bd\u4ee5\u63f4\u624b\uff0c\u4e3a\u95ee\u9898\u8865\u5145\u4e0a\u6807\u7b7e\u7b49\u4fe1\u606f\uff0c\u8fd9\u6709\u52a9\u4e8e\u63a8\u52a8\u95ee\u9898\u7684\u89e3\u51b3\u8fdb\u7a0b\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#_3","title":"\u68c0\u67e5\u6b63\u8bef","text":"\u5f53\u60a8\u68c0\u67e5\u4ee3\u7801\u6216\u5176\u4ed6\u4fee\u6539\u7684\u6b63\u8bef\u65f6\uff0c\u52a1\u5fc5\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a
README.md
\u3002\u7c7b\u4f3c\u5730\uff0c\u5982\u679c\u4e00\u4e2a PR \u5220\u9664\u6216\u5f03\u7528\u4e86\u4e00\u6bb5\u4ee3\u7801\uff0c\u60a8\u5fc5\u987b\u68c0\u67e5\u76f8\u5e94\u7684\u6587\u6863\u662f\u5426\u4e5f\u5e94\u8be5\u88ab\u5220\u9664\u3002\u5bf9 MatrixOne \u7684\u8d21\u732e\u7edd\u4e0d\u4ec5\u9650\u4e8e\u4ee3\u7801\u3002\u4ee5\u4e0b\u4e3a\u60a8\u5c55\u793a\u4e86\u53c2\u4e0e MatrixOne \u9879\u76ee\u5e76\u53c2\u4e0e\u6211\u4eec\u7684\u5f00\u6e90\u793e\u533a\u7684\u5404\u79cd\u65b9\u5f0f\uff1a
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#_2","title":"\u4ee3\u7801\u8d21\u732e","text":"\u7c7b\u578b \u8bf4\u660e \u62a5\u544a Bug \u60a8\u53ef\u4ee5\u5728 GitHub \u4e0a\u63d0\u51fa Issue \u6765\u62a5\u544a\u60a8\u5728\u8fd0\u884c\u6216\u5f00\u53d1 MatrixOne \u65f6\u6240\u9047\u89c1\u7684 Bug\u3002 \u63d0\u4ea4\u4ee3\u7801 \u540c\u6837\uff0c\u60a8\u4e5f\u53ef\u4ee5\u4fee\u590d\u5df2\u6709\u7684 Bug \u6216\u8005\u89e3\u51b3 GitHub \u4e0a\u63d0\u51fa\u7684\u5173\u952e\u6027\u95ee\u9898\uff0c\u4e5f\u53ef\u4ee5\u63d0\u51fa\u65b0\u7684\u529f\u80fd\u9700\u6c42\u4ee5\u53ca\u8bbe\u8ba1\u6784\u601d\u3002\u8bf7\u53c2\u89c1\u4ee3\u7801\u8d21\u732e\u6765\u4e86\u89e3\u5177\u4f53\u7684\u89c4\u8303\u4e0e\u6b65\u9aa4\u3002 \u5ba1\u67e5 \u60a8\u4e5f\u53ef\u4ee5\u4ee5\u5ba1\u67e5\u8005\u7684\u8eab\u4efd\u5bf9 MatrixOne \u4e2d\u7684 PR \u8fdb\u884c\u8bc4\u8bba\u3001\u5ba1\u67e5\uff0c\u4e3a\u4ed6\u4eba\u63d0\u4f9b\u5efa\u8bae\u548c\u5e2e\u52a9\u3002"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#matrixone","title":"\u5b8c\u5584 MatrixOne \u6587\u6863","text":"\u7c7b\u578b \u8bf4\u660e \u62a5\u544a\u6216\u4fee\u590d\u6280\u672f\u6587\u6863\u7684\u95ee\u9898 \u60a8\u53ef\u4ee5\u70b9\u51fb\u6587\u6863\u7f51\u7ad9\u4e0a\u7684 Edit the page \u6309\u952e\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u5f53\u524d\u9875\u9762\u8fdb\u884c\u4fee\u6539\u5e76\u63d0\u4ea4\u82f1\u6587\u6587\u6863 PR \u6216\u63d0\u4ea4\u4e2d\u6587\u6587\u6863 PR\u3002\u5f53\u7136\u60a8\u53ef\u4ee5\u53ef\u4ee5\u5728 GitHub \u7684[Issue]\u4e2d\u63d0\u51fa\u95ee\u9898\uff0c\u5e76\u63cf\u8ff0\u76f8\u5173\u4fe1\u606f\uff1a\u82f1\u6587\u6587\u6863 Issue\u4e2d\u6587\u6587\u6863 Issue \u63d0\u4ea4\u4e00\u4efd\u65b0\u7684\u6587\u6863 \u5728\u64b0\u5199\u4e00\u4efd\u5b8c\u6574\u7684\u6587\u6863\u4e4b\u524d\uff0c\u8bf7\u9605\u8bfb\u6587\u6863\u8d21\u732e\u6307\u5357\u3002"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#_3","title":"\u5176\u4ed6","text":"\u7c7b\u578b \u8bf4\u660e \u5206\u4eab\u7528\u4f8b\u548c\u89e3\u51b3\u65b9\u6848 \u5411\u7528\u6237\u5c55\u793a\u5982\u4f55\u5728\u7279\u5b9a\u573a\u666f\u4e0b\u4f7f\u7528 MatrixOne\uff0c\u53ef\u4ee5\u5c06\u60a8\u7684\u7528\u4f8b\u53d1\u9001\u5230 dengnan@matrixorigin.io\uff0c\u6211\u4eec\u5c06\u5728\u793e\u533a\u4e2d\u53d1\u5e03\u3002 \u64b0\u5199\u535a\u6587\u3001\u6545\u4e8b\u5899\u3001\u767d\u76ae\u4e66 \u64b0\u5199\u9ad8\u8d28\u91cf\u7684\u6587\u7ae0\uff0c\u6e05\u6670\u51c6\u786e\u5730\u89e3\u91ca\u6709\u5173 MatrixOne \u7684\u6280\u672f\u7ec6\u8282\u3002 \u505a\u4e00\u573a\u6280\u672f\u6f14\u8bb2\u6216\u73b0\u573a\u76f4\u64ad \u53d1\u8868\u6f14\u8bb2\u6216\u73b0\u573a\u76f4\u64ad\u53ef\u4ee5\u5e2e\u52a9\u63d0\u9ad8\u5404\u754c\u670b\u53cb\u5bf9 MatrixOne \u7684\u8ba4\u8bc6\u3002 \u4e92\u76f8\u652f\u6301 \u5e2e\u52a9 GitHub \u4e0a\u7684\u7528\u6237\u89e3\u51b3\u4f7f\u7528 MatrixOne \u65f6\u9047\u5230\u7684\u95ee\u9898\u3002 Issue \u5206\u7c7b \u5728 GitHub Issues \u4e2d\u4e3a\u5404\u4e2a Issue \u6dfb\u52a0\u5408\u9002\u7684\u6807\u7b7e\uff0c\u53ef\u4ee5\u5f88\u5feb\u5730\u628a\u95ee\u9898\u5206\u914d\u7ed9\u5bf9\u5e94\u8d1f\u8d23\u4eba\uff0c\u63d0\u9ad8\u95ee\u9898\u7684\u89e3\u51b3\u6548\u7387\u3002\u8fd9\u662f\u5bf9 MatrixOne \u5de5\u4f5c\u5f00\u53d1\u6d41\u7a0b\u7684\u5de8\u5927\u8d21\u732e\u3002 \u5176\u4ed6\u4efb\u4f55\u8d21\u732e \u6211\u4eec\u6b22\u8fce\u4efb\u4f55\u5bf9 MatrixOne \u53ca\u5176\u5f00\u6e90\u793e\u533a\u7684\u53d1\u5c55\u8d77\u5230\u79ef\u6781\u4f5c\u7528\u7684\u8d21\u732e\u3002"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/","title":"Operator \u7ba1\u7406","text":""},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#matrixone-operator","title":"MatrixOne Operator \u6982\u8ff0","text":"MatrixOne Operator \u7528\u6765\u5b9a\u4e49\u548c\u7ba1\u7406 MatrixOne \u96c6\u7fa4\u5728 Kubernetes \u7684\u8d44\u6e90\u9700\u6c42\uff0c\u7531\u4e00\u7ec4 Kubernetes \u81ea\u5b9a\u4e49\u8d44\u6e90\uff08CustomResourceDefinitions, CRD\uff09\uff0c\u4e00\u7ec4 Kubernetes \u63a7\u5236\u5668\u548c\u4e00\u7ec4 WebHook \u670d\u52a1\u7ec4\u6210\uff1a
CRD\uff1a\u5728 Kubernetes \u4e2d\uff0cCRD \u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u7528\u4e8e\u6ce8\u518c\u65b0\u7684\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b\u5230 Kubernetes APIServer \u4e2d\u3002MatrixOne Operator \u4e2d\u5305\u542b\u7684 CRDs \u6ce8\u518c\u4e86\u591a\u79cd\u81ea\u5b9a\u4e49\u8d44\u6e90\uff0c\u5305\u62ec\u7528\u4e8e\u63cf\u8ff0 MatrixOne \u96c6\u7fa4\u7684 MatrixOneCluster \u8d44\u6e90\u3001\u4ee5\u53ca\u63cf\u8ff0\u96c6\u7fa4\u5185\u7ec4\u4ef6\u7684 CNSet\u3001TNSet\u3001LogSet \u7b49\u8d44\u6e90\u3002\u6ce8\u518c\u5b8c\u6210\u540e\uff0c\u5ba2\u6237\u7aef\u5c31\u80fd\u591f\u5728 Kubernetes APIServer \u4e0a\u8bfb\u5199\u8fd9\u4e9b\u8d44\u6e90\u3002
\u63a7\u5236\u5668\uff1a\u63a7\u5236\u5668\u662f\u4e00\u4e2a\u957f\u671f\u8fd0\u884c\u7684\u81ea\u52a8\u5316\u7a0b\u5e8f\uff0c\u8d1f\u8d23\u76d1\u63a7 Kubernetes \u4e2d\u8d44\u6e90\u7684\u671f\u671b\u72b6\u6001\u548c\u6536\u96c6\u8fd9\u4e9b\u8d44\u6e90\u7684\u5b9e\u9645\u72b6\u6001\uff0c\u5e76\u81ea\u52a8\u8fd0\u7ef4\uff0c\u9a71\u52a8\u5b9e\u9645\u72b6\u6001\u5411\u671f\u671b\u72b6\u6001\u8f6c\u79fb\u3002matrixone-operator \u4e2d\u7684\u63a7\u5236\u5668\u4f1a\u76d1\u89c6 MatrixOneCluster\u3001CNSet\u3001TNSet\u3001LogSet \u7b49\u8d44\u6e90\uff0c\u5e76\u8d1f\u8d23\u5b9e\u73b0\u7528\u6237\u901a\u8fc7\u8fd9\u4e9b\u8d44\u6e90\u58f0\u660e\u7684\u671f\u671b\u72b6\u6001\u3002
Webhook \u670d\u52a1\uff1aWebhook \u670d\u52a1\u662f\u4e00\u4e2a\u957f\u671f\u8fd0\u884c\u7684 HTTP \u670d\u52a1\u3002\u5f53 Kubernetes APIServer \u6536\u5230\u7528\u6237\u8bfb\u5199 MatrixOneCluster\u3001CNSet\u3001TNSet\u3001LogSet \u7b49\u8d44\u6e90\u7684\u8bf7\u6c42\u65f6\uff0c\u4f1a\u5c06\u8bf7\u6c42\u8f6c\u53d1\u7ed9 Webhook \u670d\u52a1\uff0c\u7531 Webhook \u670d\u52a1\u6267\u884c\u8bf7\u6c42\u6821\u9a8c\u3001\u9ed8\u8ba4\u503c\u586b\u5145\u7b49\u903b\u8f91\u3002
\u5728\u4f7f\u7528 Helm chart \u5b89\u88c5 Matrixone-Operator \u65f6\uff0c\u4f1a\u81ea\u52a8\u63d0\u4ea4\u6240\u9700\u7684 CRDs \u5230 Kubernetes APIServer\uff0c\u5b8c\u6210\u81ea\u5b9a\u4e49\u8d44\u6e90\u7684\u6ce8\u518c\uff0c\u5e76\u90e8\u7f72\u4e00\u4e2a\u957f\u671f\u8fd0\u884c\u7684 Matrixone-Operator \u5e94\u7528\u3002\u8be5\u5e94\u7528\u4e2d\u6253\u5305\u4e86\u4e0a\u8ff0\u7684\u63a7\u5236\u5668\u548c Webhook \u670d\u52a1\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_1","title":"\u96c6\u7fa4\u7ba1\u7406","text":"MatrixOne Operator \u901a\u8fc7 MatrixOneCluster \u8d44\u6e90\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u58f0\u660e\u5f0f\u7684\u96c6\u7fa4\u7ba1\u7406\u80fd\u529b\u3002\u5177\u4f53\u800c\u8a00\uff0c\u5728 Kubernetes \u4e0a\u90e8\u7f72 MatrixOne \u96c6\u7fa4\u65f6\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528 YAML \u683c\u5f0f\u58f0\u660e\u4e00\u4e2a MatrixOneCluster \u5bf9\u8c61\u6765\u63cf\u8ff0\u96c6\u7fa4\uff0c\u8be5 operator \u7684\u63a7\u5236\u5668\u4f1a\u6839\u636e\u8be5\u63cf\u8ff0\u5b9e\u73b0\u96c6\u7fa4\u7684\u7f16\u6392\uff0c\u5e76\u5c06\u96c6\u7fa4\u72b6\u6001\u66f4\u65b0\u5230 MatrixOneCluster \u5bf9\u8c61\u7684 .status
\u5b57\u6bb5\u4e2d\u3002
MatrixOneCluster \u96c6\u7fa4\u7531\u591a\u4e2a\u7ec4\u4ef6\uff08\u5982 Compute Node\uff08CN\uff09\u3001Transaction Node\uff08TN\uff09\u548c Log Service\uff09\u6784\u6210\uff0c\u8fd9\u4e9b\u7ec4\u4ef6\u5bf9\u5e94\u4e8e CNSet\u3001TNSet \u548c LogSet \u7b49\u5b50\u8d44\u6e90\u3002\u56e0\u6b64\uff0cMatrixOneCluster \u8d44\u6e90\u7684\u63a7\u5236\u5668\u4f1a\u7f16\u6392\u8fd9\u4e9b\u5b50\u8d44\u6e90\uff0c\u5e76\u4f9d\u8d56\u8fd9\u4e9b\u5b50\u8d44\u6e90\u7684\u63a7\u5236\u5668\u6765\u5b8c\u6210\u5b83\u4eec\u7684\u7f16\u6392\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_2","title":"\u90e8\u7f72\u4e0e\u8fd0\u7ef4","text":"\u672c\u7ae0\u8282\u6240\u4ecb\u7ecd\u5230\u7684\u90e8\u7f72\u4e0e\u8fd0\u7ef4\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
\u4ee5\u4e0b\u64cd\u4f5c\u5747\u5728 master0 \u8282\u70b9\u8fdb\u884c\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_3","title":"\u90e8\u7f72","text":"\u53ef\u4ee5\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684 MatrixOne-Operator \u90e8\u7f72\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_4","title":"\u68c0\u67e5\u72b6\u6001","text":"\u6211\u4eec\u91c7\u7528\u4e86 Helm \u5de5\u5177\u5bf9 MatrixOne Operator \u8fdb\u884c\u90e8\u7f72\u3002Helm \u662f Kubernetes \u5e94\u7528\u5305\u7ba1\u7406\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u7ba1\u7406 chart\uff0c\u9884\u5148\u914d\u7f6e\u597d\u7684\u5b89\u88c5\u5305\u8d44\u6e90\uff0c\u7c7b\u4f3c\u4e8e Ubuntu \u7684 APT \u548c CentOS \u4e2d\u7684 YUM\u3002\u4f7f\u7528 helm list
\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b Operator \u7684\u90e8\u7f72\u72b6\u6001\u3002
[root@master0 ~]# NS=\"matrixone-operator\"\n[root@master0 ~]# helm list -n${NS}\nNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION\nmatrixone-operator matrixone-operator 1 2023-05-09 15:19:38.363683192 +0800 CST deployed matrixone-operator-0.8.0-alpha.2 0.1.0\n
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_5","title":"\u5347\u7ea7","text":"MatrixOne-Operator \u9879\u76ee\u662f\u957f\u671f\u7ef4\u62a4\u66f4\u65b0\u7684\u9879\u76ee\uff0c\u8bf7\u66f4\u65b0\u81f3\u6700\u65b0\u7248\u672c\u3002\u4f60\u53ef\u4ee5\u5728 Github \u4e0a\u4e0b\u8f7d\u65b0\u7248\u672c\u7684 Operator\uff0c\u4f8b\u5982\uff1amatrixone-operator-0.8.0-alpha.2
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u89e3\u538b\u6587\u4ef6\uff1a
tar xvf ./matrixone-operator-0.8.0-alpha.2.tgz\ncd matrixone-operator\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 helm upgrade
\u547d\u4ee4\u6765\u5347\u7ea7 Matrixone-Operator\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u83b7\u53d6\u955c\u50cf\u7248\u672c\uff1a
cd matrixone-operator\nNS=\"matrixone-operator\"\nhelm upgrade -n \"${NS}\" matrixone-operator ./ --dependency-update\n
\u5347\u7ea7\u6210\u529f\u540e\uff0c\u4ee3\u7801\u5c55\u793a\u5982\u4e0b\u6240\u793a\uff1a
Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May 9 17:59:06 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 2\nTEST SUITE: None\n
\u5347\u7ea7\u5b8c\u6210\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u7248\u672c\uff1a
#\u83b7\u53d6\u955c\u50cf\u7248\u672c\nNS=\"matrixone-operator\"\nkubectl get pod -n${NS} `kubectl get pod -n${NS} | grep operator | head -1 | awk '{print $1}'` -ojsonpath='{.spec.containers[0].image}'\nmatrixorigin/matrixone-operator:0.8.0-alpha.2\n
\u5728\u5347\u7ea7 Matrixone-Operator \u4e4b\u540e\uff0c\u4f1a\u5728 matrixone-operator
\u547d\u540d\u7a7a\u95f4\u4e0b\u5148\u91cd\u65b0\u751f\u6210\u4e00\u4e2a\u65b0\u7684 matrixone-operator-xxxx-xxx
\u7684 Pod\uff0c\u4e4b\u540e\u4f1a\u628a\u65e7\u7684 Pod \u5220\u9664\u3002
Note
\u5347\u7ea7\u5b8c\u6210\u540e\uff0c\u5047\u5982 Matrixone-Operator \u5347\u7ea7\u6240\u5e26\u6765\u7684\u53d8\u66f4\u4e5f\u4f1a\u66f4\u65b0\u9ed8\u8ba4 .spec
\uff0c\u90a3\u4e48\u6709\u53ef\u80fd\u4f1a\u6eda\u52a8\u66f4\u65b0 MatrixOne \u96c6\u7fa4\u76f8\u5173\u670d\u52a1\u6216\u914d\u7f6e\uff0c\u56e0\u6b64 MatrixOne \u670d\u52a1\u53ef\u80fd\u4f1a\u88ab\u91cd\u542f\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u76d1\u63a7\u5347\u7ea7\u8fc7\u7a0b\uff1awatch -e \"kubectl get pod -nmo-hn -owide\"
\u3002
NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6 1/1 Running 0 164m 10.234.168.43 node1 <none> <none>\n
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_6","title":"\u6269\u7f29\u5bb9","text":"\u7531\u4e8e Operator \u7ecf\u5e38\u4f7f\u7528\u6709\u9650\u7684\u8d44\u6e90\uff0c\u56e0\u6b64\u5782\u76f4\u6269\u7f29\u5bb9\u7684\u573a\u666f\u76f8\u5bf9\u8f83\u5c11\u3002\u4e00\u822c\u800c\u8a00\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8003\u8651\u6c34\u5e73\u6269\u7f29\u5bb9\uff0c\u4e5f\u5c31\u662f\u589e\u52a0\u6216\u51cf\u5c11\u526f\u672c\u7684\u6570\u91cf\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cOperator \u662f\u5355\u526f\u672c\u7684\uff0c\u5982\u679c\u6211\u4eec\u9700\u8981\u589e\u5f3a Operator \u7684\u9ad8\u53ef\u7528\u6027\uff0c\u53ef\u4ee5\u8003\u8651\u5c06\u5176\u6269\u5bb9\uff0c\u4f8b\u5982\u6269\u5bb9\u4e3a\u4e24\u4e2a\u526f\u672c\u3002\u8fd9\u6837\uff0c\u5373\u4f7f\u7b2c\u4e00\u4e2a\u526f\u672c\u51fa\u73b0\u5f02\u5e38\uff08\u4f8b\u5982\uff0c\u5728\u6240\u5728\u8282\u70b9\u4e0a\u62c9\u53d6\u6620\u50cf\u5931\u8d25\uff09\uff0c\u53e6\u4e00\u4e2a\u526f\u672c\u4ecd\u7136\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002\u8fd9\u5bf9\u4e8e MO \u96c6\u7fa4\u7684\u90e8\u7f72\u548c\u8fd0\u7ef4\u7ba1\u7406\u64cd\u4f5c\u975e\u5e38\u91cd\u8981\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u5f53\u524d Operator \u7248\u672c\u7684\u90e8\u7f72\u76ee\u5f55\u4e0b\uff0c\u4f7f\u7528 Helm Upgrade \u547d\u4ee4\u5e76\u6307\u5b9a replicaCount \u7684\u6570\u91cf\u6765\u5b8c\u6210 Operator \u526f\u672c\u6570\u7684\u6269\u7f29\u5bb9\u3002
\u5728\u8fdb\u884c\u6269\u5bb9\u4e4b\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b Operator \u7684\u6570\u91cf\uff1a
NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6 1/1 Running 0 164m 10.234.168.43 node1 <none> <none>\n
# \u526f\u672c\u6570\ncd matrixone-operator\nNUM=2\nNS=\"matrixone-operator\"\nhelm upgrade -n${NS} matrixone-operator ./ --dependency-update --set replicaCount=${NUM}\n
\u6269\u5bb9\u6210\u529f\uff0c\u6253\u5370\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May 9 18:07:03 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 3\nTEST SUITE: None\n
\u4f60\u53ef\u4ee5\u7ee7\u7eed\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u89c2\u5bdf operator \u4e2a\u6570\uff1a
watch -e \"kubectl get pod -nmo-hn -owide\"\nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmatrixone-operator-f8496ff5c-nt8qs 1/1 Running 0 9s 10.234.60.126 node0 <none> <none>\nmatrixone-operator-f8496ff5c-s2lr6 1/1 Running 0 167m 10.234.168.43 node1 <none> <none>\n
\u5982\u679c\u9700\u8981\u6c34\u5e73\u7f29\u5bb9\uff0c\u53ef\u4ee5\u901a\u8fc7 helm upgrade
\u964d\u4f4e replicaCount
\u6570\u91cf\u6765\u5b8c\u6210 operator \u526f\u672c\u6570\u7684\u7f29\u5bb9\u3002
Warning
\u5728\u5378\u8f7d Matrixone-Operator \u4e4b\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e05\u695a\uff0c\u56e0\u4e3a\u5378\u8f7d\u64cd\u4f5c\u4f1a\u76f4\u63a5\u5378\u8f7d Matrixone \u96c6\u7fa4\u76f8\u5173\u7684\u8d44\u6e90\uff0c\u5305\u62ec SVC\u3001Pod \u7b49\uff08\u4f46\u4e0d\u5305\u62ec log service \u4f7f\u7528\u7684 pvc \u8d44\u6e90\uff09\u3002
\u4f7f\u7528\u5982\u4e0b\u6307\u4ee4\u5378\u8f7d Matrixone-Operator\uff1a
helm uninstall matrixone-operator -n mo-hn\n
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/","title":"\u96c6\u7fa4\u6269\u7f29\u5bb9","text":"\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd MatrixOne \u96c6\u7fa4\u5982\u4f55\u8fdb\u884c\u6269\u7f29\u5bb9\uff0c\u5e76\u5305\u62ec Kubernetes \u96c6\u7fa4\u672c\u8eab\u7684\u6269\u7f29\u5bb9\u4e0e MatrixOne \u7684\u5404\u4e2a\u670d\u52a1\u7684\u6269\u7f29\u5bb9\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#_2","title":"\u4f55\u65f6\u9700\u8981\u8fdb\u884c\u6269\u5bb9/\u7f29\u5bb9","text":"\u4e3a\u4e86\u786e\u5b9a\u662f\u5426\u9700\u8981\u5bf9 MatrixOne \u670d\u52a1\u8fdb\u884c\u6269\u7f29\u5bb9\uff0c\u7528\u6237\u9700\u8981\u76d1\u63a7 MatrixOne \u96c6\u7fa4\u6240\u5728\u7684\u8282\u70b9\u548c\u76f8\u5173\u7ec4\u4ef6\u5bf9\u5e94\u7684 Pod \u6240\u4f7f\u7528\u7684\u8d44\u6e90\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 kubectl top
\u547d\u4ee4\u6765\u5b8c\u6210\u6b64\u64cd\u4f5c\u3002\u66f4\u8be6\u7ec6\u7684\u64cd\u4f5c\u6b65\u9aa4\u53ef\u4ee5\u53c2\u8003\u5065\u5eb7\u68c0\u67e5\u4e0e\u8d44\u6e90\u76d1\u63a7\u3002
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u53d1\u73b0\u8282\u70b9\u6216\u8005 Pod \u7684\u8d44\u6e90\u4f7f\u7528\u7387\u8d85\u8fc7\u4e86 60% \u5e76\u4e14\u6301\u7eed\u4e00\u6bb5\u65f6\u95f4\uff0c\u53ef\u80fd\u9700\u8981\u8003\u8651\u8fdb\u884c\u6269\u5bb9\u4ee5\u5e94\u5bf9\u8d1f\u8f7d\u9ad8\u5cf0\u3002\u6b64\u5916\uff0c\u5982\u679c\u6839\u636e\u4e1a\u52a1\u6307\u6807\u89c2\u5bdf\u5230\u9ad8\u7684 TPS \u8bf7\u6c42\u91cf\uff0c\u4e5f\u9700\u8981\u8003\u8651\u8fdb\u884c\u6269\u5bb9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#kubernetes","title":"Kubernetes \u6269\u7f29\u5bb9","text":"\u7531\u4e8e MatrixOne \u5206\u5e03\u5f0f\u7248\u672c\u7684\u57fa\u7840\u786c\u4ef6\u8d44\u6e90\u90fd\u662f\u901a\u8fc7 Kubernetes \u6765\u8fdb\u884c\u7ba1\u7406\u548c\u5206\u914d\u7684\uff0c\u56e0\u6b64\u6574\u4e2a\u96c6\u7fa4\u7684\u786c\u4ef6\u8282\u70b9\u6269\u7f29\u5bb9\u5747\u662f\u7531 Kubernetes \u5b8c\u6210\u7684\u3002
Kubernetes \u53ef\u4ee5\u901a\u8fc7 kuboard spray \u56fe\u5f62\u5316\u7ba1\u7406\u9875\u9762\u6765\u5b8c\u6210\u8282\u70b9\u7684\u6269\u7f29\u5bb9\uff0c\u8be6\u7ec6\u6559\u7a0b\u53ef\u53c2\u89c1 kuboard spray \u7684\u5b98\u65b9\u6587\u6863\u3002
\u4f60\u9700\u8981\u5728\u8be5\u96c6\u7fa4\u4e2d\u589e\u52a0\u4e86\u4e00\u4e2a\u5de5\u4f5c\u8282\u70b9\uff0c\u6574\u4f53\u7684\u786c\u4ef6\u914d\u7f6e\u8d44\u6e90\u5982\u4e0b\u8868\u6240\u793a\uff1a
Host \u5185\u7f51 IP \u5916\u7f51 IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker node1 10.206.134.16 129.211.211.29 8G 2C 50G worker "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#matrixone","title":"MatrixOne \u5404\u670d\u52a1\u7684\u6269\u7f29\u5bb9","text":"\u670d\u52a1\u7684\u6269\u7f29\u5bb9\uff0c\u6307\u7684\u662f MatrixOne \u96c6\u7fa4\u4e2d\u6838\u5fc3\u7684\u7ec4\u4ef6\u670d\u52a1\uff0c\u4f8b\u5982\uff0c\u5bf9 Log Service\u3001TN\u3001CN \u7b49\u8fdb\u884c\u6269\u7f29\u5bb9\u3002
\u6839\u636e MatrixOne \u7684\u67b6\u6784\u7279\u70b9\uff0c\u8fd9\u4e9b\u670d\u52a1\u8282\u70b9\u60c5\u51b5\u5982\u4e0b\uff1a
\u56e0\u6b64\uff0cLog Service\u3001TN \u7684\u8282\u70b9\u53ea\u80fd\u5782\u76f4\u6269\u7f29\u5bb9\uff0cCN \u8282\u70b9\u53ef\u540c\u65f6\u6c34\u5e73\u6269\u7f29\u5bb9\u548c\u5782\u76f4\u6269\u7f29\u5bb9\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#_3","title":"\u6c34\u5e73\u6269\u7f29\u5bb9","text":"\u6c34\u5e73\u6269\u7f29\u5bb9\uff0c\u6307\u7684\u662f\u670d\u52a1\u7684\u526f\u672c\u6570\u589e\u52a0\u6216\u51cf\u5c11\u3002\u53ef\u901a\u8fc7\u4fee\u6539 MatrixOne Operator \u542f\u52a8 yaml \u6587\u4ef6\u4e2d\u7684 .spec.[component].replicas
\u5b57\u6bb5\u7684\u503c\uff0c\u5b8c\u6210\u670d\u52a1\u526f\u672c\u6570\u7684\u66f4\u6539\u3002
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4fee\u6539 yaml \u6587\u4ef6\u4e2d\u7684 .spec.[component].replicas
\u5b57\u6bb5\u7684\u503c\uff1a
kubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff1a
tp:\n replicas: 2 #\u4f8b\u5982\uff0c\u6269\u5bb9\u662f\u7531\u539f\u6765\u7684 1 \u4e2a CN \u66f4\u6539\u4e3a 2 \u4e2a CN\n#\u5176\u4ed6\u5185\u5bb9\u5ffd\u7565 \n
Note
\u7f29\u5bb9\u4e5f\u53ef\u53c2\u8003\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u66f4\u6539 replicas
\u7684\u5b57\u6bb5\u503c\u3002
\u7f16\u8f91\u5b8c\u6210 replicas
\u4e2a\u6570\u4fdd\u5b58\u9000\u51fa\u540e\uff0cMatrixOne Operator \u5c06\u4f1a\u81ea\u52a8\u542f\u52a8\u4e00\u4e2a\u65b0\u7684 CN\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u89c2\u5bdf\u65b0\u7684 CN \u72b6\u6001\uff1a
[root@master0 ~]# kubectl get pods -n mo-hn \nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-6c9c49fbd7-lw2h2 1/1 Running 2 (8h ago) 9h\nmo-tn-0 1/1 Running 0 11m\nmo-log-0 1/1 Running 0 12m\nmo-log-1 1/1 Running 0 12m\nmo-log-2 1/1 Running 0 12m\nmo-tp-cn-0 1/1 Running 0 11m\nmo-tp-cn-1 1/1 Running 0 63s\n
\u53e6\u5916\uff0cKubernetes \u7684 SVC \u4f1a\u81ea\u52a8\u4fdd\u8bc1 CN \u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u7528\u6237\u8fde\u63a5\u7684 connection \u4f1a\u88ab\u5747\u5300\u7684\u5206\u914d\u5230\u4e0d\u540c\u7684 CN \u4e0a\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7 MatrixOne \u5185\u7f6e\u7684 system_metrics.server_connections
\u8868\u67e5\u770b\u6bcf\u4e2a CN \u4e0a\u7684 connection \u4e2a\u6570\u3002
\u5782\u76f4\u6269\u7f29\u5bb9\uff0c\u6307\u7684\u662f\u5bf9\u5355\u4e2a\u7ec4\u4ef6\u670d\u52a1\u526f\u672c\u672c\u8eab\u6240\u9700\u8981\u7684\u8d44\u6e90\uff0c\u4f8b\u5982\uff0c\u5bf9 CPU \u6216\u5185\u5b58\u8fdb\u884c\u8c03\u6574\u3002
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4fee\u6539\u5bf9\u5e94\u7ec4\u4ef6\u7684 .spec.[component].resources
\u4e2d\u7684 requests
\u548c limits
\u914d\u7f6e\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
kubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff1a
metadata:\n name: mo\n # \u4e2d\u95f4\u5185\u5bb9\u7701\u7565\nspec:\n tp:\n resources:\n requests:\n cpu: 1\n memory: 2Gi\n limits:\n cpu: 1\n memory: 2Gi\n...\n# \u5176\u4ed6\u5185\u5bb9\u7701\u7565\n
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cMatrixone-operator \u4e0d\u4f1a\u4e3a\u6bcf\u4e2a\u7ec4\u4ef6\u7684 Pod \u914d\u7f6e\u62d3\u6251\u89c4\u5219\uff0c\u800c\u662f\u4f7f\u7528 Kubernetes \u9ed8\u8ba4\u7684\u8c03\u5ea6\u5668\u6839\u636e\u6bcf\u4e2a Pod \u7684\u8d44\u6e90\u8bf7\u6c42\u8fdb\u884c\u8c03\u5ea6\u3002\u5982\u679c\u9700\u8981\u8bbe\u7f6e\u7279\u5b9a\u7684\u8c03\u5ea6\u89c4\u5219\uff0c\u4f8b\u5982\u5c06 cn \u7ec4\u4ef6\u8c03\u5ea6\u5230\u7279\u5b9a\u7684\u4e24\u4e2a\u8282\u70b9 node0 \u548c node1 \u4e0a\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a
\u4e3a node0
\u548c node1
\u8bbe\u7f6e\u6807\u7b7e\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\u8bbe\u7f6e nodeSelector
\uff0c\u4f7f\u670d\u52a1\u80fd\u591f\u8c03\u5ea6\u5230\u5bf9\u5e94\u7684\u8282\u70b9\u4e0a\u3002
\uff08\u53ef\u9009\uff09\u5728 MatrixOne \u96c6\u7fa4\u4e2d\u8bbe\u7f6e TopologySpread
\u5b57\u6bb5\uff0c\u4ee5\u5b9e\u73b0\u670d\u52a1\u5728\u8282\u70b9\u4e4b\u95f4\u7684\u5747\u5300\u5206\u5e03\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\u8bbe\u7f6e\u526f\u672c\u6570 replicas
\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u9700\u8981\u67e5\u770b\u96c6\u7fa4\u8282\u70b9\u7684\u60c5\u51b5\uff1a
[root@master0 ~]# kubectl get node\nNAME STATUS ROLES AGE VERSION\nmaster0 Ready control-plane,master 47h v1.23.17\nnode0 Ready <none> 47h v1.23.17\nnode1 Ready <none> 65s v1.23.17\n
\u6839\u636e\u4e0a\u8ff0\u8fd4\u56de\u7684\u7ed3\u679c\u548c\u5b9e\u9645\u9700\u6c42\uff0c\u4f60\u53ef\u4ee5\u4e3a\u8282\u70b9\u6253\u4e0a\u6807\u7b7e\uff0c\u53c2\u89c1\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\uff1a
NODE=\"[\u5f85\u6253\u4e0a\u6807\u7b7e\u7684\u8282\u70b9]\" # \u6839\u636e\u4e0a\u8ff0\u7ed3\u679c\uff0c\u6709\u53ef\u80fd\u662f ip\u3001\u4e5f\u53ef\u80fd\u662f\u4e3b\u673a\u540d\u3001\u6216\u8005\u522b\u540d\uff0c\u4f8b\u5982 10.0.0.1\u3001host-10-0-0-1\u3001node01\uff0c\u90a3\u4e48\u8bbe\u7f6e NODE=\"node0\"\nLABEL_K=\"mo-role\" # \u6807\u7b7e\u7684 key\uff0c\u53ef\u6309\u9700\u5b9a\u4e49\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u7528\u793a\u4f8b\nLABEL_V=\"mo-cn\" # \u6807\u7b7e\u7684 value\uff0c\u53ef\u6309\u9700\u5b9a\u4e49\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u7528\u793a\u4f8b\n\nkubectl label node ${NODE} ${LABEL_K}=${LABEL_V}\n
\u5728\u672c\u7bc7\u6848\u4f8b\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5199\u6210\u4ee5\u4e0b\u4e24\u6761\u8bed\u53e5\uff1a
kubectl label node node0 \"mo-role\"=\"mo-cn\"\nkubectl label node node1 \"mo-role\"=\"mo-cn\"\n
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u786e\u8ba4\u8282\u70b9\u6807\u7b7e\u662f\u5426\u5df2\u6253\u4e0a\uff1a
[root@master0 ~]# kubectl get node node0 --show-labels | grep mo_role \nnode0 Ready <none> 47h v1.23.17 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node0,kubernetes.io/os=linux,mo_role=mo_cn\n[root@master0 ~]# kubectl get node node1 --show-labels | grep mo_role\nnode1 Ready <none> 7m25s v1.23.17 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node1,kubernetes.io/os=linux,mo_role=mo_cn\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u6309\u9700\u5220\u9664\u6807\u7b7e\uff1a
kubectl label node ${NODE} ${LABEL_K}-\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u76ee\u524d\u7684 Pod \u5728\u591a\u4e2a\u8282\u70b9\u4e0a\u7684\u5206\u914d\u60c5\u51b5\uff1a
[root@master0 mo]# kubectl get pod -nmo-hn -owide\nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmo-tn-0 1/1 Running 0 34m 10.234.60.120 node0 <none> 2/2\nmo-log-0 1/1 Running 0 34m 10.234.168.72 node1 <none> 2/2\nmo-log-1 1/1 Running 0 34m 10.234.60.118 node0 <none> 2/2\nmo-log-2 1/1 Running 0 34m 10.234.168.73 node1 <none> 2/2\nmo-tp-cn-0 1/1 Running 0 33m 10.234.168.75 node1 <none> 2/2\n
\u6839\u636e\u4e0a\u8ff0\u8f93\u51fa\u548c\u5b9e\u9645\u9700\u6c42\u53ef\u4ee5\u770b\u51fa\u76ee\u524d\u53ea\u6709 1 \u4e2a CN\uff0c\u6211\u4eec\u9700\u8981\u4e3a CN \u7ec4\u4ef6\u8fdb\u884c\u8c03\u5ea6\u89c4\u5219\u7684\u8bbe\u7f6e\u3002\u6211\u4eec\u5c06\u5728 MatrixOne \u96c6\u7fa4\u5bf9\u8c61\u7684\u5c5e\u6027\u4e2d\u8fdb\u884c\u4fee\u6539\u3002\u5728\u8c03\u5ea6\u8303\u56f4\u5185\u5747\u5300\u5206\u5e03\u7684\u89c4\u5219\u4e0b\u65b0\u7684 CN \u4f1a\u88ab\u8c03\u5ea6\u5230 node0 \u4e0a\u3002\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff1a
mo_ns=\"mo-hn\"\nmo_cluster_name=\"mo\" # \u4e00\u822c\u540d\u79f0\u4e3a mo\uff0c\u6839\u636e\u90e8\u7f72\u65f6 matrixonecluster \u5bf9\u8c61\u7684 yaml \u6587\u4ef6\u4e2d\u7684 name \u6307\u5b9a\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7 kubectl get matrixonecluster -n${mo_ns} \u6765\u786e\u8ba4\nkubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u5728\u7f16\u8f91\u6a21\u5f0f\u4e0b\uff0c\u6839\u636e\u4e0a\u8ff0\u573a\u666f\uff0c\u6211\u4eec\u5c06\u8bbe\u7f6e CN \u7684\u526f\u672c\u6570\u4e3a 2\uff0c\u5e76\u4e14\u5728\u6807\u7b7e\u4e3a mo-role:mo-cn
\u7684\u8282\u70b9\u4e0a\u8fdb\u884c\u8c03\u5ea6\uff0c\u5b9e\u73b0\u5728\u8c03\u5ea6\u8303\u56f4\u5185\u7684\u5747\u5300\u5206\u5e03\u3002\u6211\u4eec\u5c06\u4f7f\u7528 spec.[component].nodeSelector
\u6765\u6307\u5b9a\u5177\u4f53\u7ec4\u4ef6\u7684\u6807\u7b7e\u9009\u62e9\u5668\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b\u7684\u7f16\u8f91\u5185\u5bb9\uff1a
metadata:\n name: mo\n# \u4e2d\u95f4\u5185\u5bb9\u7701\u7565\nspec:\n# \u4e2d\u95f4\u5185\u5bb9\u7701\u7565\n tp:\n # \u8bbe\u7f6e\u526f\u672c\u6570\n replicas: 2\n # \u8bbe\u7f6e\u8c03\u5ea6\u89c4\u5219\n nodeSelector:\n mo-role: mo-cn\n # \u8bbe\u7f6e\u5728\u8c03\u5ea6\u8303\u56f4\u5185\u5747\u5300\u5206\u5e03\n topologySpread:\n - topology.kubernetes.io/zone\n - kubernetes.io/hostname\n# \u5176\u4ed6\u5185\u5bb9\u7701\u7565\n
\u66f4\u6539\u751f\u6548\u540e\uff0c\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u4e24\u4e2a CN \u5df2\u7ecf\u5206\u522b\u5728\u4e24\u4e2a\u8282\u70b9\u4e0a\uff1a
[root@master0 ~]# kubectl get pod -nmo-hn -owide \nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmo-tn-0 1/1 Running 1 (2m53s ago) 3m6s 10.234.168.80 node1 <none> 2/2\nmo-log-0 1/1 Running 0 3m40s 10.234.168.78 node1 <none> 2/2\nmo-log-1 1/1 Running 0 3m40s 10.234.60.122 node0 <none> 2/2\nmo-log-2 1/1 Running 0 3m40s 10.234.168.77 node1 <none> 2/2\nmo-tp-cn-0 1/1 Running 0 84s 10.234.60.125 node0 <none> 2/2\nmo-tp-cn-1 1/1 Running 0 86s 10.234.168.82 node1 <none> 2/2\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u7684\u914d\u7f6e\u4f1a\u4f7f\u5f97\u96c6\u7fa4\u4e2d\u7684 Pod \u5728 topology.kubernetes.io/zone
\u548c kubernetes.io/hostname
\u8fd9\u4e24\u4e2a\u7ef4\u5ea6\u4e0a\u5b9e\u73b0\u5747\u5300\u5206\u5e03\u3002\u5728 topologySpread
\u4e2d\u6307\u5b9a\u7684\u6807\u7b7e\u952e\u662f\u6709\u987a\u5e8f\u7684\u3002\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0cPod \u9996\u5148\u5728\u53ef\u7528\u533a\u7ef4\u5ea6\u4e0a\u5747\u5300\u5206\u5e03\uff0c\u7136\u540e\u5728\u6bcf\u4e2a\u53ef\u7528\u533a\u5185\u7684 Pod \u518d\u5747\u5300\u5730\u5206\u5e03\u5230\u8be5\u533a\u57df\u5185\u7684\u8282\u70b9\u4e0a\u3002
\u4f7f\u7528 topologySpread
\u529f\u80fd\u53ef\u4ee5\u63d0\u9ad8\u96c6\u7fa4\u7684\u53ef\u7528\u6027\uff0c\u964d\u4f4e\u7531\u4e8e\u5355\u70b9\u6216\u533a\u57df\u6027\u6545\u969c\u800c\u7834\u574f\u96c6\u7fa4\u4e2d\u7684\u5927\u591a\u6570\u526f\u672c\u7684\u53ef\u80fd\u6027\u3002\u4f46\u8fd9\u4e5f\u589e\u52a0\u4e86\u8c03\u5ea6\u7684\u8981\u6c42\uff0c\u9700\u8981\u786e\u4fdd\u96c6\u7fa4\u5728\u6bcf\u4e2a\u533a\u57df\u5185\u90fd\u6709\u8db3\u591f\u7684\u8d44\u6e90\u53ef\u7528\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u5982\u4f55\u542f\u505c\u5206\u5e03\u5f0f MatrixOne \u96c6\u7fa4\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u5347\u7ea7\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#_2","title":"\u96c6\u7fa4\u505c\u6b62\u4e0b\u7ebf","text":"\u8981\u505c\u6b62 MatrixOne \u96c6\u7fa4\uff0c\u53ea\u9700\u505c\u6b62\u4e1a\u52a1\u7684\u8bfb\u5199\u64cd\u4f5c\uff0c\u7136\u540e\u76f4\u63a5\u5173\u95ed\u670d\u52a1\u5668\u5373\u53ef\u3002\u5173\u95ed\u7684\u987a\u5e8f\u4e3a\uff1a\u9996\u5148\u5173\u95ed node0 \u8282\u70b9\uff0c\u63a5\u7740\u5173\u95ed master0 \u8282\u70b9\uff0c\u6700\u540e\u5173\u95ed Kuboard-Spray \u8282\u70b9\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#_3","title":"\u96c6\u7fa4\u91cd\u542f\u4e0a\u7ebf","text":"\u8981\u91cd\u65b0\u542f\u52a8 MatrixOne \u96c6\u7fa4\uff0c\u5efa\u8bae\u6309\u7167\u4ee5\u4e0b\u786c\u4ef6\u542f\u52a8\u987a\u5e8f\uff1a\u9996\u5148\u542f\u52a8 Kuboard-Spray \u8282\u70b9\uff0c\u63a5\u7740\u542f\u52a8 master0 \u8282\u70b9\uff0c\u6700\u540e\u542f\u52a8 node0 \u8282\u70b9\u3002
\u5728\u786c\u4ef6\u542f\u52a8\u5b8c\u6210\u540e\uff0ck8s \u4f1a\u81ea\u52a8\u8fdb\u884c\u6062\u590d\u3002\u540c\u65f6\uff0cMatrixOne \u548c minio \u76f8\u5173\u670d\u52a1\u4e5f\u4f1a\u81ea\u52a8\u6062\u590d\uff0c\u65e0\u9700\u4eba\u5de5\u5e72\u9884\u3002\u4f46\u662f\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cKuboard-Spray \u8282\u70b9\u7684 Docker \u4e0d\u4f1a\u81ea\u52a8\u6062\u590d\uff0c\u9700\u8981\u624b\u52a8\u542f\u52a8 Kuboard-Spray \u670d\u52a1\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#k8s","title":"\u68c0\u67e5 K8s \u72b6\u6001","text":"\u5728\u64cd\u4f5c k8s \u7684 master0 \u8282\u70b9\u4e0a\uff0c\u53ef\u4ee5\u68c0\u67e5 k8s \u96c6\u7fa4\u8282\u70b9\u7684\u72b6\u6001\u3002
\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u6240\u6709\u8282\u70b9\u7684\u72b6\u6001\u5e94\u8be5\u4e3a Ready\u3002\u5982\u679c\u67d0\u4e9b\u8282\u70b9\u72b6\u6001\u5f02\u5e38\uff0c\u5c31\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u539f\u56e0\u3002
kubectl get node\n# \u5982\u975eready\u72b6\u6001\uff0c\u5219\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u8282\u70b9\u7684\u60c5\u51b5\n# kubectl describe node ${NODE_NAME}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#minio","title":"\u68c0\u67e5 MinIO \u72b6\u6001","text":"\u5728\u64cd\u4f5c k8s \u7684 master0 \u8282\u70b9\u4e0a\uff0c\u53ef\u4ee5\u68c0\u67e5 MinIO \u7684\u72b6\u6001\u3002
\u786c\u4ef6\u542f\u52a8\u540e\uff0cMinIO \u4e5f\u4f1a\u81ea\u52a8\u6062\u590d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5 MinIO \u72b6\u6001\uff1a
NS=\"mostorage\"\nkubectl get pod -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#matrixone","title":"\u68c0\u67e5 MatrixOne \u96c6\u7fa4\u53ca\u7ec4\u4ef6\u72b6\u6001","text":""},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#matrixonecluster","title":"\u68c0\u67e5 MatrixOneCluster \u72b6\u6001","text":"\u9996\u5148\uff0c\u8981\u68c0\u67e5 MatrixOne \u96c6\u7fa4\u662f\u5426\u6b63\u5e38\u3002MatrixOne \u96c6\u7fa4\u5bf9\u5e94\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b MatrixOneCluster\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5 MatrixOneCluster \u7684\u72b6\u6001\uff1a
MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n${NS} ${MO_NAME}\n
\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u72b6\u6001\u5e94\u8be5\u4e3a Ready\u3002\u5982\u679c\u72b6\u6001\u4e3a NotReady\uff0c\u5219\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u72b6\u6001\u56fe\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#matrixone_1","title":"\u67e5\u770b MatrixOne \u96c6\u7fa4\u72b6\u6001\u8be6\u7ec6\u4fe1\u606f","text":"\u5982\u679c MatrixOne \u96c6\u7fa4\u72b6\u6001\u4e0d\u6b63\u5e38\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\uff1a
kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#tnsetcnsetlogset","title":"\u68c0\u67e5 TNSet/CNSet/LogSet \u72b6\u6001","text":"\u5f53\u524d MatrixOne \u96c6\u7fa4\u7684\u7ec4\u4ef6\u4e3b\u8981\u6709\uff1aTN\u3001CN\u3001Log Service\uff0c\u5206\u522b\u5bf9\u5e94\u7684\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b TNSet\u3001CNSet\u3001LogSet\u3002\u8fd9\u4e9b\u5bf9\u8c61\u5747\u7531 MatrixOneCluster \u63a7\u5236\u5668\u751f\u6210\u3002
\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u5404\u7ec4\u4ef6\u7684\u72b6\u6001\uff0c\u4ee5 TN \u4e3a\u4f8b\uff1a
SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#pod","title":"\u68c0\u67e5 Pod \u72b6\u6001","text":"\u53ef\u4ee5\u76f4\u63a5\u68c0\u67e5 MO \u96c6\u7fa4\u4e2d\u751f\u6210\u7684\u539f\u751f k8s \u5bf9\u8c61\uff0c\u6765\u786e\u8ba4\u96c6\u7fa4\u7684\u5065\u5eb7\u7a0b\u5ea6\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7\u5bf9 Pod \u7684\u72b6\u6001\u786e\u8ba4\u5373\u53ef\uff1a
NS=\"mo-hn\"\nkubectl get pod -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
\u4e00\u822c\u6765\u8bf4\uff0cRunning \u72b6\u6001\u5373\u4e3a\u6b63\u5e38\u72b6\u6001\u3002\u4f46\u4e5f\u6709\u5c11\u6570\u4f8b\u5916\u7684\u60c5\u51b5\uff0c\u4f8b\u5982\u72b6\u6001\u4e3a Running\uff0c\u4f46 MO \u96c6\u7fa4\u5b9e\u9645\u4e0a\u4e0d\u6b63\u5e38\uff0c\u4f8b\u5982\u65e0\u6cd5\u901a\u8fc7 MySQL Client \u8fde\u63a5 MO \u96c6\u7fa4\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6392\u67e5 Pod \u7684\u65e5\u5fd7\u662f\u5426\u6709\u5f02\u5e38\u4fe1\u606f\u8f93\u51fa\uff1a
NS=\"mo-hn\"\nPOD_NAME=\"[\u4e0a\u8ff0\u8fd4\u56depod\u7684\u540d\u79f0]\" # \u4f8b\u5982mo-tp-cn-3\nkubectl logs ${POD_NAME} -n${NS}\n
\u5982\u679c\u72b6\u6001\u4e3a\u975e Running\uff0c\u4f8b\u5982 Pending\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b Pod \u72b6\u6001\u4e2d\u7684\u4e8b\u4ef6\uff08event\uff09\u6765\u786e\u8ba4\u5f02\u5e38\u539f\u56e0\u3002\u4f8b\u5982\uff0c\u7531\u4e8e\u96c6\u7fa4\u8d44\u6e90\u65e0\u6cd5\u6ee1\u8db3 mo-tp-cn-3 \u7684\u7533\u8bf7\uff0c\u8fd9\u4e2a Pod \u65e0\u6cd5\u88ab\u8c03\u5ea6\uff0c\u5904\u4e8e Pending \u72b6\u6001\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6269\u5bb9\u8282\u70b9\u8d44\u6e90\u6765\u89e3\u51b3\u3002
kubectl describe pod ${POD_NAME} -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/","title":"\u5065\u5eb7\u68c0\u67e5\u4e0e\u8d44\u6e90\u76d1\u63a7","text":"\u5728 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u4e2d\uff0c\u5305\u542b\u4e86\u591a\u4e2a\u7ec4\u4ef6\u548c\u5bf9\u8c61\uff0c\u4e3a\u4e86\u786e\u4fdd\u5176\u6b63\u5e38\u8fd0\u884c\u5e76\u6392\u9664\u6545\u969c\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u4e00\u7cfb\u5217\u7684\u5065\u5eb7\u68c0\u67e5\u548c\u8d44\u6e90\u76d1\u63a7\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u5065\u5eb7\u68c0\u67e5\u4e0e\u8d44\u6e90\u76d1\u63a7\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#_2","title":"\u68c0\u67e5\u5bf9\u8c61","text":"\u7269\u7406\u8d44\u6e90\u5c42\uff1a\u5305\u62ec\u4e09\u53f0\u865a\u62df\u673a\u7684 CPU\u3001\u5185\u5b58\u548c\u78c1\u76d8\u8d44\u6e90\u3002\u6709\u5173\u76d1\u63a7\u8fd9\u4e9b\u8d44\u6e90\u7684\u6210\u719f\u65b9\u6848\uff0c\u53ef\u4ee5\u53c2\u8003\u76d1\u63a7\u65b9\u6848\u3002\u5728\u6b64\u4e0d\u505a\u8fc7\u591a\u4ecb\u7ecd\u3002
\u903b\u8f91\u8d44\u6e90\u5c42\uff1a\u5305\u62ec MinIO \u7684\u5bb9\u91cf\u4f7f\u7528\u60c5\u51b5\uff0cKubernetes \u7684\u5404\u4e2a\u8282\u70b9\u548c Pod \u7684 CPU \u548c\u5185\u5b58\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\uff0c\u4ee5\u53ca MatrixOne \u7684\u6574\u4f53\u72b6\u6001\u548c\u5404\u4e2a\u7ec4\u4ef6\uff08\u5982 LogService\u3001CN\u3001TN\uff09\u7684\u72b6\u6001\u3002
MinIO \u81ea\u5e26\u4e86\u4e00\u4e2a\u7ba1\u7406\u754c\u9762\uff0c\u901a\u8fc7\u8be5\u754c\u9762\u6211\u4eec\u53ef\u4ee5\u4ee5\u53ef\u89c6\u5316\u7684\u65b9\u5f0f\u76d1\u63a7\u5176\u5bb9\u91cf\u4f7f\u7528\u60c5\u51b5\uff0c\u5305\u62ec\u5269\u4f59\u7a7a\u95f4\u7684\u6570\u91cf\u7b49\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\u3002
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#nodepod","title":"Node/Pod \u8d44\u6e90\u76d1\u63a7","text":"\u4e3a\u4e86\u786e\u5b9a MatrixOne \u670d\u52a1\u662f\u5426\u9700\u8981\u6269\u7f29\u5bb9\uff0c\u7528\u6237\u5f80\u5f80\u9700\u8981\u9488\u5bf9 MatrixOne \u96c6\u7fa4\u6240\u5728 Node \u548c\u7ec4\u4ef6\u5bf9\u5e94 Pod \u6240\u4f7f\u7528\u7684\u8d44\u6e90\u8fdb\u884c\u76d1\u63a7\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 kubectl top
\u547d\u4ee4\u5b8c\u6210\uff0c\u8be6\u7ec6\u7684\u547d\u4ee4\u53ef\u4ee5\u53c2\u8003\u5bf9\u5e94\u7248\u672c\u7684 Kubernetes \u5b98\u7f51\u6587\u6863\u3002
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u67e5\u770b MatrixOne \u96c6\u7fa4\u8282\u70b9\u8be6\u60c5\uff1a
kubectl get node\n
[root@master0 ~]# kubectl get node\nNAME STATUS ROLES AGE VERSION\nmaster0 Ready control-plane,master 22h v1.23.17\nnode0 Ready <none> 22h v1.23.17\n
\u6839\u636e\u4e0a\u8ff0\u8fd4\u56de\u7ed3\u679c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u7279\u5b9a\u8282\u70b9\u7684\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\u3002\u6839\u636e\u4e4b\u524d\u7684\u90e8\u7f72\u65b9\u6848\uff0c\u53ef\u4ee5\u67e5\u770b\u5230 MatrixOne \u96c6\u7fa4\u4f4d\u4e8e\u540d\u4e3a node0 \u7684\u8282\u70b9\u4e0a\uff1a
NODE=\"[\u5f85\u76d1\u63a7\u8282\u70b9]\" # \u6839\u636e\u4e0a\u8ff0\u7ed3\u679c\uff0c\u6709\u53ef\u80fd\u662f ip\u3001\u4e5f\u53ef\u80fd\u662f\u4e3b\u673a\u540d\u3001\u6216\u8005\u522b\u540d\uff0c\u4f8b\u5982 10.0.0.1\u3001host-10-0-0-1\u3001node01\nkubectl top node ${NODE}\n
[root@master0 ~]# kubectl top node\nNAME CPU(cores) CPU% MEMORY(bytes) MEMORY% \nmaster0 179m 9% 4632Mi 66% \nnode0 292m 15% 4115Mi 56% \n[root@master0 ~]# kubectl top node node0\nNAME CPU(cores) CPU% MEMORY(bytes) MEMORY% \nnode0 299m 15% 4079Mi 56% \n
\u4f60\u8fd8\u53ef\u4ee5\u67e5\u770b\u8282\u70b9\u7684\u8d44\u6e90\u5206\u914d\u548c\u8d44\u6e90\u4e0a\u9650\u3002\u8bf7\u6ce8\u610f\uff0c\u5df2\u5206\u914d\u7684\u8d44\u6e90\u5e76\u4e0d\u7b49\u4e8e\u5df2\u4f7f\u7528\u7684\u8d44\u6e90\u3002
[root@master0 ~]# kubectl describe node node0\nName: master0\nRoles: control-plane,master\nLabels: beta.kubernetes.io/arch=amd64\n beta.kubernetes.io/os=linux\n kubernetes.io/arch=amd64\n kubernetes.io/hostname=master0\n kubernetes.io/os=linux\n node-role.kubernetes.io/control-plane=\n node-role.kubernetes.io/master=\n node.kubernetes.io/exclude-from-external-load-balancers=\nAnnotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n node.alpha.kubernetes.io/ttl: 0\n projectcalico.org/IPv4Address: 10.206.134.8/24\n projectcalico.org/IPv4VXLANTunnelAddr: 10.234.166.0\n volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp: Sun, 07 May 2023 12:28:57 +0800\nTaints: node-role.kubernetes.io/master:NoSchedule\nUnschedulable: false\nLease:\n HolderIdentity: master0\n AcquireTime: <unset>\n RenewTime: Mon, 08 May 2023 10:56:08 +0800\nConditions:\n Type Status LastHeartbeatTime LastTransitionTime Reason Message\n ---- ------ ----------------- ------------------ ------ -------\n NetworkUnavailable False Sun, 07 May 2023 12:30:08 +0800 Sun, 07 May 2023 12:30:08 +0800 CalicoIsUp Calico is running on this node\n MemoryPressure False Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 12:28:55 +0800 KubeletHasSufficientMemory kubelet has sufficient memory available\n DiskPressure False Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 12:28:55 +0800 KubeletHasNoDiskPressure kubelet has no disk pressure\n PIDPressure False Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 12:28:55 +0800 KubeletHasSufficientPID kubelet has sufficient PID available\n Ready True Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 20:47:39 +0800 KubeletReady kubelet is posting ready status\nAddresses:\n InternalIP: 10.206.134.8\n Hostname: master0\nCapacity:\n cpu: 2\n ephemeral-storage: 51473868Ki\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7782436Ki\n pods: 110\nAllocatable:\n cpu: 1800m\n ephemeral-storage: 47438316671\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7155748Ki\n pods: 110\nSystem Info:\n Machine ID: fb436be013b5415799d27abf653585d3\n System UUID: FB436BE0-13B5-4157-99D2-7ABF653585D3\n Boot ID: 552bd576-56c8-4d22-9549-d950069a5a77\n Kernel Version: 3.10.0-1160.88.1.el7.x86_64\n OS Image: CentOS Linux 7 (Core)\n Operating System: linux\n Architecture: amd64\n Container Runtime Version: docker://20.10.23\n Kubelet Version: v1.23.17\n Kube-Proxy Version: v1.23.17\nPodCIDR: 10.234.0.0/23\nPodCIDRs: 10.234.0.0/23\nNon-terminated Pods: (12 in total)\n Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits Age\n --------- ---- ------------ ---------- --------------- ------------- ---\n default netchecker-agent-7xnwb 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n default netchecker-agent-hostnet-bw85f 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n kruise-system kruise-daemon-xvl8t 0 (0%) 50m (2%) 0 (0%) 128Mi (1%) 20h\n kube-system calico-node-sbzfc 150m (8%) 300m (16%) 64M (0%) 500M (6%) 22h\n kube-system dns-autoscaler-7874cf6bcf-l55q4 20m (1%) 0 (0%) 10Mi (0%) 0 (0%) 22h\n kube-system kube-apiserver-master0 250m (13%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system kube-controller-manager-master0 200m (11%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system kube-proxy-lfkhk 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system kube-scheduler-master0 100m (5%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system metrics-server-7bd47f88c4-knh9b 100m (5%) 100m (5%) 200Mi (2%) 200Mi (2%) 22h\n kube-system nodelocaldns-dcffl 100m (5%) 0 (0%) 70Mi (1%) 170Mi (2%) 14h\n kuboard kuboard-v3-master0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22h\nAllocated resources:\n (Total limits may be over 100 percent, i.e., overcommitted.)\n Resource Requests Limits\n -------- -------- ------\n cpu 950m (52%) 510m (28%)\n memory 485601280 (6%) 1222190848 (16%)\n ephemeral-storage 0 (0%) 0 (0%)\n hugepages-1Gi 0 (0%) 0 (0%)\n hugepages-2Mi 0 (0%) 0 (0%)\nEvents: <none>\n\n\nName: node0\nRoles: <none>\nLabels: beta.kubernetes.io/arch=amd64\n beta.kubernetes.io/os=linux\n kubernetes.io/arch=amd64\n kubernetes.io/hostname=node0\n kubernetes.io/os=linux\nAnnotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n node.alpha.kubernetes.io/ttl: 0\n projectcalico.org/IPv4Address: 10.206.134.14/24\n projectcalico.org/IPv4VXLANTunnelAddr: 10.234.60.0\n volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp: Sun, 07 May 2023 12:29:46 +0800\nTaints: <none>\nUnschedulable: false\nLease:\n HolderIdentity: node0\n AcquireTime: <unset>\n RenewTime: Mon, 08 May 2023 10:56:06 +0800\nConditions:\n Type Status LastHeartbeatTime LastTransitionTime Reason Message\n ---- ------ ----------------- ------------------ ------ -------\n NetworkUnavailable False Sun, 07 May 2023 12:30:08 +0800 Sun, 07 May 2023 12:30:08 +0800 CalicoIsUp Calico is running on this node\n MemoryPressure False Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 12:29:46 +0800 KubeletHasSufficientMemory kubelet has sufficient memory available\n DiskPressure False Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 12:29:46 +0800 KubeletHasNoDiskPressure kubelet has no disk pressure\n PIDPressure False Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 12:29:46 +0800 KubeletHasSufficientPID kubelet has sufficient PID available\n Ready True Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 20:48:36 +0800 KubeletReady kubelet is posting ready status\nAddresses:\n InternalIP: 10.206.134.14\n Hostname: node0\nCapacity:\n cpu: 2\n ephemeral-storage: 51473868Ki\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7782444Ki\n pods: 110\nAllocatable:\n cpu: 1900m\n ephemeral-storage: 47438316671\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7417900Ki\n pods: 110\nSystem Info:\n Machine ID: a6600151884b44fb9f0bc9af490e44b7\n System UUID: A6600151-884B-44FB-9F0B-C9AF490E44B7\n Boot ID: b7f3357f-44e6-425e-8c90-6ada14e92703\n Kernel Version: 3.10.0-1160.88.1.el7.x86_64\n OS Image: CentOS Linux 7 (Core)\n Operating System: linux\n Architecture: amd64\n Container Runtime Version: docker://20.10.23\n Kubelet Version: v1.23.17\n Kube-Proxy Version: v1.23.17\nPodCIDR: 10.234.2.0/23\nPodCIDRs: 10.234.2.0/23\nNon-terminated Pods: (20 in total)\n Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits Age\n --------- ---- ------------ ---------- --------------- ------------- ---\n default netchecker-agent-6v8rl 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n default netchecker-agent-hostnet-fb2jn 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n default netchecker-server-645d759b79-v4bqm 150m (7%) 300m (15%) 192M (2%) 512M (6%) 22h\n kruise-system kruise-controller-manager-74847d59cf-295rk 100m (5%) 200m (10%) 256Mi (3%) 512Mi (7%) 20h\n kruise-system kruise-controller-manager-74847d59cf-854sq 100m (5%) 200m (10%) 256Mi (3%) 512Mi (7%) 20h\n kruise-system kruise-daemon-rz9pj 0 (0%) 50m (2%) 0 (0%) 128Mi (1%) 20h\n kube-system calico-kube-controllers-74df5cd99c-n9qsn 30m (1%) 1 (52%) 64M (0%) 256M (3%) 22h\n kube-system calico-node-brqrk 150m (7%) 300m (15%) 64M (0%) 500M (6%) 22h\n kube-system coredns-76b4fb4578-9cqc7 100m (5%) 0 (0%) 70Mi (0%) 170Mi (2%) 14h\n kube-system kube-proxy-rpxb5 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system nginx-proxy-node0 25m (1%) 0 (0%) 32M (0%) 0 (0%) 22h\n kube-system nodelocaldns-qkxhv 100m (5%) 0 (0%) 70Mi (0%) 170Mi (2%) 14h\n local-path-storage local-path-storage-local-path-provisioner-d5bb7f8c9-qfp8h 0 (0%) 0 (0%) 0 (0%) 0 (0%) 21h\n mo-hn matrixone-operator-f8496ff5c-fp6zm 0 (0%) 0 (0%) 0 (0%) 0 (0%) 20h\n mo-hn mo-tn-0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-log-0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-log-1 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-log-2 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-tp-cn-0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mostorage minio-674ccf54f7-tdglh 0 (0%) 0 (0%) 512Mi (7%) 0 (0%) 20h\nAllocated resources:\n (Total limits may be over 100 percent, i.e., overcommitted.)\n Resource Requests Limits\n -------- -------- ------\n cpu 785m (41%) 2110m (111%)\n memory 1700542464 (22%) 3032475392 (39%)\n ephemeral-storage 0 (0%) 0 (0%)\n hugepages-1Gi 0 (0%) 0 (0%)\n hugepages-2Mi 0 (0%) 0 (0%)\nEvents: <none>\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#pod","title":"Pod \u76d1\u63a7","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b MatrixOne \u96c6\u7fa4\u7684 Pod\uff1a
NS=\"mo-hn\"\nkubectl get pod -n${NS}\n
\u6839\u636e\u4e0a\u8ff0\u8fd4\u56de\u7ed3\u679c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u7279\u5b9a Pod \u7684\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\uff1a
POD=\"[\u5f85\u76d1\u63a7 pod \u540d\u79f0]\" # \u6839\u636e\u4e0a\u8ff0\u7ed3\u679c\uff0c\u4f8b\u5982\uff1atn \u4e3a mo-tn-0\uff0ccn \u4e3a mo-tp-cn-0\u3001mo-tp-cn-1\u3001...\uff0clogservice \u4e3a mo-log-0\u3001mo-log-1\u3001...\nkubectl top pod ${POD} -n${NS}\n
\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u6307\u5b9a Pod \u7684 CPU \u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u8f93\u51fa\uff1a
[root@master0 ~]# kubectl top pod mo-tp-cn-0 -nmo-hn\nNAME CPU(cores) MEMORY(bytes) \nmo-tp-cn-0 20m 214Mi\n[root@master0 ~]# kubectl top pod mo-tn-0 -nmo-hn \nNAME CPU(cores) MEMORY(bytes) \nmo-tn-0 36m 161Mi \n
\u6b64\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u67e5\u770b\u7279\u5b9a Pod \u7684\u8d44\u6e90\u58f0\u660e\u60c5\u51b5\uff0c\u4ee5\u4fbf\u4e0e\u5b9e\u9645\u4f7f\u7528\u7684\u8d44\u6e90\u8fdb\u884c\u5bf9\u6bd4\u3002
kubectl describe pod ${POD_NAME} -n${NS}\nkubectl get pod ${POD_NAME} -n${NS} -oyaml\n
[root@master0 ~]# kubectl describe pod mo-tp-cn-0 -nmo-hn\nName: mo-tp-cn-0\nNamespace: mo-hn\nPriority: 0\nNode: node0/10.206.134.14\nStart Time: Sun, 07 May 2023 21:01:50 +0800\nLabels: controller-revision-hash=mo-tp-cn-8666cdfb56\n lifecycle.apps.kruise.io/state=Normal\n matrixorigin.io/cluster=mo\n matrixorigin.io/component=CNSet\n matrixorigin.io/instance=mo-tp\n matrixorigin.io/namespace=mo-hn\n statefulset.kubernetes.io/pod-name=mo-tp-cn-0\nAnnotations: apps.kruise.io/runtime-containers-meta:\n {\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"...\n cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n cni.projectcalico.org/podIP: 10.234.60.53/32\n cni.projectcalico.org/podIPs: 10.234.60.53/32\n kruise.io/related-pub: mo\n lifecycle.apps.kruise.io/timestamp: 2023-05-07T13:01:50Z\n matrixone.cloud/cn-label: null\n matrixone.cloud/dns-based-identity: False\nStatus: Running\nIP: 10.234.60.53\nIPs:\n IP: 10.234.60.53\nControlled By: StatefulSet/mo-tp-cn\nContainers:\n main:\n Container ID: docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n Image: matrixorigin/matrixone:nightly-144f3be4\n Image ID: docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n Port: <none>\n Host Port: <none>\n Command:\n /bin/sh\n /etc/matrixone/config/start.sh\n Args:\n -debug-http=:6060\n State: Running\n Started: Sun, 07 May 2023 21:01:54 +0800\n Ready: True\n Restart Count: 0\n Environment:\n POD_NAME: mo-tp-cn-0 (v1:metadata.name)\n NAMESPACE: mo-hn (v1:metadata.namespace)\n HEADLESS_SERVICE_NAME: mo-tp-cn-headless\n AWS_ACCESS_KEY_ID: <set to the key 'AWS_ACCESS_KEY_ID' in secret 'minio'> Optional: false\n AWS_SECRET_ACCESS_KEY: <set to the key 'AWS_SECRET_ACCESS_KEY' in secret 'minio'> Optional: false\n AWS_REGION: us-west-2\n Mounts:\n /etc/matrixone/config from config (ro)\n /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-ngpcs (ro)\nReadiness Gates:\n Type Status\n InPlaceUpdateReady True\n KruisePodReady True\nConditions:\n Type Status\n KruisePodReady True\n InPlaceUpdateReady True\n Initialized True\n Ready True\n ContainersReady True\n PodScheduled True\nVolumes:\n config:\n Type: ConfigMap (a volume populated by a ConfigMap)\n Name: mo-tp-cn-config-5abf454\n Optional: false\n kube-api-access-ngpcs:\n Type: Projected (a volume that contains injected data from multiple sources)\n TokenExpirationSeconds: 3607\n ConfigMapName: kube-root-ca.crt\n ConfigMapOptional: <nil>\n DownwardAPI: true\nQoS Class: BestEffort\nNode-Selectors: <none>\nTolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s\n node.kubernetes.io/unreachable:NoExecute op=Exists for 300s\nEvents: <none>\n[root@master0 ~]# kubectl get pod mo-tp-cn-0 -nmo-hn -oyaml\napiVersion: v1\nkind: Pod\nmetadata:\n annotations:\n apps.kruise.io/runtime-containers-meta: '{\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"hashes\":{\"plainHash\":1670287891}}]}'\n cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n cni.projectcalico.org/podIP: 10.234.60.53/32\n cni.projectcalico.org/podIPs: 10.234.60.53/32\n kruise.io/related-pub: mo\n lifecycle.apps.kruise.io/timestamp: \"2023-05-07T13:01:50Z\"\n matrixone.cloud/cn-label: \"null\"\n matrixone.cloud/dns-based-identity: \"False\"\n creationTimestamp: \"2023-05-07T13:01:50Z\"\n generateName: mo-tp-cn-\n labels:\n controller-revision-hash: mo-tp-cn-8666cdfb56\n lifecycle.apps.kruise.io/state: Normal\n matrixorigin.io/cluster: mo\n matrixorigin.io/component: CNSet\n matrixorigin.io/instance: mo-tp\n matrixorigin.io/namespace: mo-hn\n statefulset.kubernetes.io/pod-name: mo-tp-cn-0\n name: mo-tp-cn-0\n namespace: mo-hn\n ownerReferences:\n - apiVersion: apps.kruise.io/v1beta1\n blockOwnerDeletion: true\n controller: true\n kind: StatefulSet\n name: mo-tp-cn\n uid: 891e0453-89a5-45d5-ad12-16ef048c804f\n resourceVersion: \"72625\"\n uid: 1e3e2df3-f1c2-4444-8694-8d23e7125d35\nspec:\n containers:\n - args:\n - -debug-http=:6060\n command:\n - /bin/sh\n - /etc/matrixone/config/start.sh\n env:\n - name: POD_NAME\n valueFrom:\n fieldRef:\n apiVersion: v1\n fieldPath: metadata.name\n - name: NAMESPACE\n valueFrom:\n fieldRef:\n apiVersion: v1\n fieldPath: metadata.namespace\n - name: HEADLESS_SERVICE_NAME\n value: mo-tp-cn-headless\n - name: AWS_ACCESS_KEY_ID\n valueFrom:\n secretKeyRef:\n key: AWS_ACCESS_KEY_ID\n name: minio\n - name: AWS_SECRET_ACCESS_KEY\n valueFrom:\n secretKeyRef:\n key: AWS_SECRET_ACCESS_KEY\n name: minio\n - name: AWS_REGION\n value: us-west-2\n image: matrixorigin/matrixone:nightly-144f3be4\n imagePullPolicy: Always\n name: main\n resources: {}\n terminationMessagePath: /dev/termination-log\n terminationMessagePolicy: File\n volumeMounts:\n - mountPath: /etc/matrixone/config\n name: config\n readOnly: true\n - mountPath: /var/run/secrets/kubernetes.io/serviceaccount\n name: kube-api-access-ngpcs\n readOnly: true\n dnsPolicy: ClusterFirst\n enableServiceLinks: true\n hostname: mo-tp-cn-0\n nodeName: node0\n preemptionPolicy: PreemptLowerPriority\n priority: 0\n readinessGates:\n - conditionType: InPlaceUpdateReady\n - conditionType: KruisePodReady\n restartPolicy: Always\n schedulerName: default-scheduler\n securityContext: {}\n serviceAccount: default\n serviceAccountName: default\n subdomain: mo-tp-cn-headless\n terminationGracePeriodSeconds: 30\n tolerations:\n - effect: NoExecute\n key: node.kubernetes.io/not-ready\n operator: Exists\n tolerationSeconds: 300\n - effect: NoExecute\n key: node.kubernetes.io/unreachable\n operator: Exists\n tolerationSeconds: 300\n volumes:\n - configMap:\n defaultMode: 420\n name: mo-tp-cn-config-5abf454\n name: config\n - name: kube-api-access-ngpcs\n projected:\n defaultMode: 420\n sources:\n - serviceAccountToken:\n expirationSeconds: 3607\n path: token\n - configMap:\n items:\n - key: ca.crt\n path: ca.crt\n name: kube-root-ca.crt\n - downwardAPI:\n items:\n - fieldRef:\n apiVersion: v1\n fieldPath: metadata.namespace\n path: namespace\nstatus:\n conditions:\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: KruisePodReady\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: InPlaceUpdateReady\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: Initialized\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:54Z\"\n status: \"True\"\n type: Ready\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:54Z\"\n status: \"True\"\n type: ContainersReady\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: PodScheduled\n containerStatuses:\n - containerID: docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n image: matrixorigin/matrixone:nightly-144f3be4\n imageID: docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n lastState: {}\n name: main\n ready: true\n restartCount: 0\n started: true\n state:\n running:\n startedAt: \"2023-05-07T13:01:54Z\"\n hostIP: 10.206.134.14\n phase: Running\n podIP: 10.234.60.53\n podIPs:\n - ip: 10.234.60.53\n qosClass: BestEffort\n startTime: \"2023-05-07T13:01:50Z\"\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#matrixone","title":"MatrixOne \u76d1\u63a7","text":""},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#_4","title":"\u67e5\u770b\u96c6\u7fa4\u72b6\u6001","text":"\u5728 Operator \u90e8\u7f72\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86 matrixOnecluster
\u4f5c\u4e3a\u6574\u4e2a\u96c6\u7fa4\u7684\u81ea\u5b9a\u4e49\u8d44\u6e90\u540d\u79f0\u3002\u901a\u8fc7\u68c0\u67e5 MatrixOneCluster\uff0c\u6211\u4eec\u53ef\u4ee5\u5224\u65ad\u96c6\u7fa4\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u68c0\u67e5\uff1a
MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n${NS} ${MO_NAME}\n
\u5982\u679c\u72b6\u6001\u4e3a \"Ready\"\uff0c\u5219\u8868\u793a\u96c6\u7fa4\u6b63\u5e38\u3002\u5982\u679c\u72b6\u6001\u4e3a \"NotReady\"\uff0c\u5219\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u95ee\u9898\u3002
[root@master0 ~]# MO_NAME=\"mo\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get matrixonecluster -n${NS} ${MO_NAME}\nNAME LOG TN TP AP VERSION PHASE AGE\nmo 3 1 1 nightly-144f3be4 Ready 13h\n
\u8981\u67e5\u770b MatrixOne \u96c6\u7fa4\u72b6\u6001\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n
[root@master0 ~]# kubectl describe matrixonecluster -n${NS} ${MO_NAME}\nName: mo\nNamespace: mo-hn\nLabels: <none>\nAnnotations: <none>\nAPI Version: core.matrixorigin.io/v1alpha1\nKind: MatrixOneCluster\nMetadata:\n Creation Timestamp: 2023-05-07T12:54:17Z\n Finalizers:\n matrixorigin.io/matrixonecluster\n Generation: 2\n Managed Fields:\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:metadata:\n f:annotations:\n .:\n f:kubectl.kubernetes.io/last-applied-configuration:\n f:spec:\n .:\n f:Tn:\n .:\n f:config:\n f:replicas:\n f:imagePullPolicy:\n f:imageRepository:\n f:logService:\n .:\n f:config:\n f:pvcRetentionPolicy:\n f:replicas:\n f:sharedStorage:\n .:\n f:s3:\n .:\n f:endpoint:\n f:secretRef:\n f:type:\n f:volume:\n .:\n f:size:\n f:tp:\n .:\n f:config:\n f:nodePort:\n f:replicas:\n f:serviceType:\n f:version:\n Manager: kubectl-client-side-apply\n Operation: Update\n Time: 2023-05-07T12:54:17Z\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:metadata:\n f:finalizers:\n .:\n v:\"matrixorigin.io/matrixonecluster\":\n Manager: manager\n Operation: Update\n Time: 2023-05-07T12:54:17Z\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:spec:\n f:logService:\n f:sharedStorage:\n f:s3:\n f:path:\n Manager: kubectl-edit\n Operation: Update\n Time: 2023-05-07T13:00:53Z\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:status:\n .:\n f:cnGroups:\n .:\n f:desiredGroups:\n f:readyGroups:\n f:syncedGroups:\n f:conditions:\n f:credentialRef:\n f:Tn:\n .:\n f:availableStores:\n f:conditions:\n f:logService:\n .:\n f:availableStores:\n f:conditions:\n f:discovery:\n .:\n f:address:\n f:port:\n f:phase:\n Manager: manager\n Operation: Update\n Subresource: status\n Time: 2023-05-07T13:02:12Z\n Resource Version: 72671\n UID: be2355c0-0c69-4f0f-95bb-9310224200b6\nSpec:\n Tn:\n Config: \n[dn]\n\n[dn.Ckp]\nflush-interval = \"60s\"\nglobal-interval = \"100000s\"\nincremental-interval = \"60s\"\nmin-count = 100\nscan-interval = \"5s\"\n\n[dn.Txn]\n\n[dn.Txn.Storage]\nbackend = \"TAE\"\nlog-backend = \"logservice\"\n\n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n Replicas: 1\n Resources:\n Service Args:\n -debug-http=:6060\n Shared Storage Cache:\n Memory Cache Size: 0\n Image Pull Policy: Always\n Image Repository: matrixorigin/matrixone\n Log Service:\n Config: \n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n Initial Config:\n TN Shards: 1\n Log Shard Replicas: 3\n Log Shards: 1\n Pvc Retention Policy: Retain\n Replicas: 3\n Resources:\n Service Args:\n -debug-http=:6060\n Shared Storage:\n s3:\n Endpoint: http://minio.mostorage:9000\n Path: minio-mo\n s3RetentionPolicy: Retain\n Secret Ref:\n Name: minio\n Type: minio\n Store Failure Timeout: 10m0s\n Volume:\n Size: 1Gi\n Tp:\n Config: \n[cn]\n\n[cn.Engine]\ntype = \"distributed-tae\"\n\n[log]\nformat = \"json\"\nlevel = \"debug\"\nmax-size = 512\n\n Node Port: 31474\n Replicas: 1\n Resources:\n Service Args:\n -debug-http=:6060\n Service Type: NodePort\n Shared Storage Cache:\n Memory Cache Size: 0\n Version: nightly-144f3be4\nStatus:\n Cn Groups:\n Desired Groups: 1\n Ready Groups: 1\n Synced Groups: 1\n Conditions:\n Last Transition Time: 2023-05-07T13:02:14Z\n Message: the object is synced\n Reason: empty\n Status: True\n Type: Synced\n Last Transition Time: 2023-05-07T13:02:14Z\n Message: \n Reason: AllSetsReady\n Status: True\n Type: Ready\n Credential Ref:\n Name: mo-credential\n Tn:\n Available Stores:\n Last Transition: 2023-05-07T13:01:48Z\n Phase: Up\n Pod Name: mo-tn-0\n Conditions:\n Last Transition Time: 2023-05-07T13:01:48Z\n Message: the object is synced\n Reason: empty\n Status: True\n Type: Synced\n Last Transition Time: 2023-05-07T13:01:48Z\n Message: \n Reason: empty\n Status: True\n Type: Ready\n Log Service:\n Available Stores:\n Last Transition: 2023-05-07T13:01:25Z\n Phase: Up\n Pod Name: mo-log-0\n Last Transition: 2023-05-07T13:01:25Z\n Phase: Up\n Pod Name: mo-log-1\n Last Transition: 2023-05-07T13:01:25Z\n Phase: Up\n Pod Name: mo-log-2\n Conditions:\n Last Transition Time: 2023-05-07T13:01:25Z\n Message: the object is synced\n Reason: empty\n Status: True\n Type: Synced\n Last Transition Time: 2023-05-07T13:01:25Z\n Message: \n Reason: empty\n Status: True\n Type: Ready\n Discovery:\n Address: mo-log-discovery.mo-hn.svc\n Port: 32001\n Phase: Ready\nEvents:\n Type Reason Age From Message\n ---- ------ ---- ---- -------\n Normal ReconcileSuccess 29m (x2 over 13h) matrixonecluster object is synced\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#_5","title":"\u67e5\u770b\u7ec4\u4ef6\u72b6\u6001","text":"\u5f53\u524d MatrixOne \u96c6\u7fa4\u5305\u542b\u4ee5\u4e0b\u7ec4\u4ef6\uff1aTN\u3001CN\u3001Log Service\uff0c\u5b83\u4eec\u5206\u522b\u5bf9\u5e94\u7740\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b TNSet\u3001CNSet\u3001LogSet\uff0c\u8fd9\u4e9b\u5bf9\u8c61\u7531 MatrixOneCluster \u63a7\u5236\u5668\u751f\u6210\u3002
\u8981\u68c0\u67e5\u5404\u7ec4\u4ef6\u662f\u5426\u6b63\u5e38\uff0c\u4ee5 TN \u4e3a\u4f8b\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n${NS}\n
\u8fd9\u5c06\u663e\u793a TN \u7ec4\u4ef6\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u4fe1\u606f\u5982\u4e0b\uff1a
[root@master0 ~]# SET_TYPE=\"tnset\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME IMAGE REPLICAS AGE\nmo matrixorigin/matrixone:nightly-144f3be4 1 13h\n[root@master0 ~]# SET_TYPE=\"cnset\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME IMAGE REPLICAS AGE\nmo-tp matrixorigin/matrixone:nightly-144f3be4 1 13h\n[root@master0 ~]# SET_TYPE=\"logset\" \n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME IMAGE REPLICAS AGE\nmo matrixorigin/matrixone:nightly-144f3be4 3 13h\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#pod_1","title":"\u67e5\u770b Pod \u72b6\u6001","text":"\u4f60\u53ef\u4ee5\u76f4\u63a5\u68c0\u67e5 MO \u96c6\u7fa4\u4e2d\u751f\u6210\u7684\u539f\u751f Kubernetes \u5bf9\u8c61\uff0c\u4ee5\u786e\u8ba4\u96c6\u7fa4\u7684\u5065\u5eb7\u72b6\u6001\u3002\u901a\u5e38\uff0c\u901a\u8fc7\u67e5\u8be2 Pod \u5373\u53ef\u5b8c\u6210\u3002
NS=\"mo-hn\"\nkubectl get pod -n${NS}\n
\u8fd9\u5c06\u663e\u793a Pod \u7684\u72b6\u6001\u4fe1\u606f\u3002
[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get pod -n${NS}\nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-f8496ff5c-fp6zm 1/1 Running 0 19h\nmo-tn-0 1/1 Running 0 13h\nmo-log-0 1/1 Running 0 13h\nmo-log-1 1/1 Running 0 13h\nmo-log-2 1/1 Running 0 13h\nmo-tp-cn-0 1/1 Running 0 13h\n
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cRunning \u72b6\u6001\u8868\u793a Pod \u6b63\u5e38\u8fd0\u884c\u3002\u4f46\u4e5f\u6709\u4e00\u4e9b\u7279\u6b8a\u60c5\u51b5\uff0c\u53ef\u80fd Pod \u72b6\u6001\u4e3a Running\uff0c\u4f46 MatrixOne \u96c6\u7fa4\u5b9e\u9645\u4e0a\u4e0d\u6b63\u5e38\u3002\u4f8b\u5982\uff0c\u65e0\u6cd5\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u96c6\u7fa4\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u8fdb\u4e00\u6b65\u67e5\u770b Pod \u7684\u65e5\u5fd7\uff0c\u4ee5\u68c0\u67e5\u662f\u5426\u6709\u5f02\u5e38\u4fe1\u606f\u8f93\u51fa\u3002
NS=\"mo-hn\"\nPOD_NAME=\"[\u4e0a\u8ff0\u8fd4\u56depod\u7684\u540d\u79f0]\" # \u4f8b\u5982mo-tp-cn-0\nkubectl logs ${POD_NAME} -n${NS}\n
\u5982\u679c Pod \u72b6\u6001\u4e3a\u975e Running \u72b6\u6001\uff0c\u4f8b\u5982 Pending\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b Pod \u7684\u4e8b\u4ef6\uff08Events\uff09\u6765\u786e\u8ba4\u5f02\u5e38\u539f\u56e0\u3002\u4ee5\u524d\u9762\u7684\u4f8b\u5b50\u4e3a\u4f8b\uff0c\u7531\u4e8e\u96c6\u7fa4\u8d44\u6e90\u65e0\u6cd5\u6ee1\u8db3 mo-tp-cn-3
\u7684\u8bf7\u6c42\uff0c\u8be5 Pod \u65e0\u6cd5\u8c03\u5ea6\uff0c\u5e76\u5904\u4e8e Pending \u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6269\u5bb9\u8282\u70b9\u8d44\u6e90\u6765\u89e3\u51b3\u3002
kubectl describe pod ${POD_NAME} -n${NS}\n
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/","title":"\u672c\u5730\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165\u5bfc\u5165\u6570\u636e","text":"\u5728 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u4e2d\uff0c\u9664\u4e86\u672c\u5730\u5bfc\u5165\u6570\u636e\u548c\u4ece\u516c\u6709\u4e91\u5bf9\u8c61\u5b58\u50a8 S3 \u5bfc\u5165\u6570\u636e\u5230 MatrixOne\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u672c\u5730 Minio \u7ec4\u4ef6\u5bfc\u5165\u6570\u636e\u3002
\u901a\u8fc7\u672c\u5730 Minio \u7ec4\u4ef6\u5bfc\u5165\u6570\u636e\u5230 MatrixOne \u9002\u7528\u4e8e\uff1a\u9047\u5230\u6ca1\u6709\u516c\u7f51\u8bbf\u95ee\u6216\u5bfc\u5165\u6587\u4ef6\u8fc7\u5927\u8d85\u51fa\u672c\u5730\u78c1\u76d8\u7a7a\u95f4\u7b49\u60c5\u51b5\u3002
\u672c\u7bc7\u6587\u7ae0\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u4f7f\u7528\u672c\u5730 Minio \u5bfc\u5165 CSV \u6587\u4ef6\u3002\u5e76\u4e14\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\uff0c\u8bf7\u786e\u4fdd\u6574\u4e2a MatrixOne \u5df2\u7ecf\u5b89\u88c5\u5b8c\u6bd5\u3002
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#_2","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#_3","title":"\u5bfc\u5165\u6570\u636e","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee http://192.168.56.10:32001 \u6765\u767b\u5f55 Minio \u7684\u56fe\u5f62\u5316\u754c\u9762\u3002\u8d26\u6237\u548c\u5bc6\u7801\u53ef\u4ee5\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7ae0\u8282\u4e2d\u5b89\u88c5\u548c\u90e8\u7f72 Minio \u8fc7\u7a0b\u4e2d\u521b\u5efa\u7684 rootUser \u548c rootPassword\u3002\u767b\u5f55\u540e\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u4e13\u5c5e\u7684\u5b58\u50a8\u6876 load-from-minio
\uff0c\u5e76\u5c06\u76f8\u5e94\u7684 CSV \u6587\u4ef6\u4e0a\u4f20\u5230\u8be5\u5b58\u50a8\u6876\u4e2d\u3002
\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u7684\u6848\u4f8b\u4e3a\u4e00\u4e2a\u4ec5\u5305\u542b 6 \u884c\u6570\u636e\u7684\u7b80\u5355 addresses.csv
\u6848\u4f8b\u3002
\u4ece\u672c\u5730 Minio \u91cc\u52a0\u8f7d\u6570\u636e\u5230 MatrixOne \u96c6\u7fa4\u7684\u539f\u7406\u4e0e\u4ece\u516c\u6709\u4e91\u7684\u5bf9\u8c61\u5b58\u50a8 S3 \u4e2d\u52a0\u8f7d\u6570\u636e\u65b9\u5f0f\u5b8c\u5168\u76f8\u540c\uff0c\u4ed6\u4eec\u7684\u8bed\u6cd5\u7ed3\u6784\u4e00\u6837\u3002\u4f46\u662f\u516c\u6709\u4e91\u65b9\u5f0f\u5176\u4e2d\u7684\u53c2\u6570\u4f1a\u6709\u516c\u6709\u4e91\u5382\u5546\u7ed9\u51fa\uff0c\u800c\u672c\u5730 Minio \u4e2d\u7684\u53c2\u6570\u9700\u8981\u81ea\u884c\u8bbe\u7f6e\u3002
LOAD DATA\n | URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>', \"provider\"='<string>'}\n INTO TABLE tbl_name\n [{FIELDS | COLUMNS}\n [TERMINATED BY 'string']\n [[OPTIONALLY] ENCLOSED BY 'char']\n [ESCAPED BY 'char']\n ]\n [IGNORE number {LINES | ROWS}]\n [PARALLEL {'TRUE' | 'FALSE'}]\n
\u8981\u4ece\u672c\u5730 Minio \u52a0\u8f7d\u6570\u636e\uff0c\u9996\u5148\u9700\u8981\u627e\u5230 Minio \u7684 endpoint\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b\u6574\u4e2a\u8c03\u7528\u94fe\u8def\u7684\u67b6\u6784\u3002
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#minio","title":"Minio \u8bbf\u95ee\u67b6\u6784","text":"\u903b\u8f91\u4e0a\u6765\u8bf4\uff0cMatrixOne \u901a\u8fc7 Minio \u7684\u8bbf\u95ee\u7aef\u53e3 endpoint \u4e0e Minio \u901a\u4fe1\uff0c\u5e76\u4ece\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u5b9e\u9645\u4e0a\uff0cMinio \u5728 Kubernetes\uff08K8s\uff09\u4e2d\u88ab\u7eb3\u7ba1\uff0c\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u5fc5\u987b\u901a\u8fc7 K8s \u7684 Service\uff08SVC\uff09\u8bbf\u95ee\u3002\u4efb\u52a1\u7684\u5b9e\u9645\u6267\u884c\u662f\u5728 K8s Pod \u4e2d\u5b8c\u6210\u7684\u3002SVC \u53ef\u4ee5\u4fdd\u8bc1\u4e0d\u7ba1 Pod \u5982\u4f55\u53d8\u5316\uff0c\u5bf9\u5916\u90e8\u5e94\u7528\u6765\u8bf4\u59cb\u7ec8\u4fdd\u6301\u7edf\u4e00\u7aef\u53e3\u3002SVC \u4e0e Pod \u7684\u5173\u8054\u9700\u8981\u901a\u8fc7 K8s \u4e2d\u7684 Endpoint\uff08EP\uff09\u6765\u5efa\u7acb\u89c4\u5219\u3002\u56e0\u6b64\uff0cMatrixOne \u5b9e\u9645\u4e0a\u662f\u901a\u8fc7 SVC \u4e0e Minio \u670d\u52a1\u8fde\u63a5\u7684\uff0c\u5177\u4f53\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#_4","title":"\u5b9e\u9645\u547d\u4ee4","text":"\u6211\u4eec\u5728\u5b89\u88c5 Minio \u7684\u65f6\u5019\u521b\u5efa\u4e86\u540d\u4e3a mostorage \u7684\u547d\u540d\u7a7a\u95f4\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u6761 K8s \u547d\u4ee4\u6765\u627e\u51fa\u8fd9\u4e2a endpoint\u3002
kubectl get svc -n${ns}
\uff1a\u5217\u51fa\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709\u7684 SVC\u3002kubectl get pod -n${ns}
\uff1a\u5217\u51fa\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709\u7684 Pod\u3002kubectl get ep -n${ns}
\uff1a\u5217\u51fa\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709\u7684\u8f6c\u53d1\u89c4\u5219\u5173\u7cfb\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
root@VM-32-16-debian:~# ns=\"mostorage\"\nroot@VM-32-16-debian:~# kubectl get svc -n${ns}\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\nminio ClusterIP 10.96.1.65 <none> 80/TCP 127d\nminio1-console NodePort 10.96.3.53 <none> 9090:30869/TCP 127d\nminio1-hl ClusterIP None <none> 9000/TCP 127d\nroot@VM-32-16-debian:~# kubectl get pod -n${ns}\nkubectl get ep -n${ns}NAME READY STATUS RESTARTS AGE\nminio1-ss-0-0 1/1 Running 0 106d\nminio1-ss-0-1 1/1 Running 0 106d\nminio1-ss-0-2 1/1 Running 0 106d\nminio1-ss-0-3 1/1 Running 0 106d\nroot@VM-32-16-debian:~# kubectl get ep -n${ns}\nNAME ENDPOINTS AGE\nminio 100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more... 127d\nminio1-console 100.92.250.195:9090,100.92.250.200:9090,100.92.250.201:9090 + 1 more... 127d\nminio1-hl 100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more... 127d\n
SVC \u7684\u8bbf\u95ee\u5730\u5740\u662f\u5728 Load
\u8bed\u53e5\u4e2d\u9700\u8981\u6dfb\u52a0\u7684\u7ec8\u7aef\u5730\u5740\u3002\u8981\u6784\u5efa SVC \u5730\u5740\uff0c\u53ef\u4ee5\u4f7f\u7528 ${service_name}.{namespace}.svc.cluster.local
\u7684\u65b9\u5f0f\uff08\u540e\u4e09\u4f4d\u53ef\u7701\u7565\uff09\u3002\u4ee5\u4e0a\u547d\u4ee4\u7684\u7ed3\u679c\u8868\u660e\uff0cminio1-hl \u7684 SVC \u4f7f\u7528 9000 \u4f5c\u4e3a\u5bf9\u5916\u8f6c\u53d1\u7aef\u53e3\uff0cminio \u7684 SVC \u4f7f\u7528 80 \u4f5c\u4e3a\u5bf9\u5916\u8f6c\u53d1\u7aef\u53e3\u3002\u56e0\u6b64\uff0c\u8fde\u63a5 Mostorage \u7684 Minio \u7684\u6700\u7ec8 endpoint \u4e3a\uff1ahttp://minio1-hl.mostorage:9000 \u6216\u8005 http://minio.mostorage:80\u3002
\u6309\u7167 addresses.csv
\u7684\u6570\u636e\u7ed3\u6784\u6784\u5efa\u597d\u76f8\u5e94\u7684\u8868\uff1a
create table address (firstname varchar(50), lastname varchar(50), address varchar(500), city varchar(20), state varchar(10), postcode varchar(20));\n
\u53c2\u7167 Load S3 \u7684\u8bed\u6cd5\u7ed3\u6784\uff0c\u5c06\u53c2\u6570\u4fe1\u606f\u586b\u5165 Load
\u8bed\u53e5\u4e2d\u5176\u4e2d\uff1a
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4ece\u672c\u5730 Minio \u5e26\u5165\u9700\u8981\u5728\u53c2\u6570\u4e32\u4e2d\u589e\u52a0\u4e00\u6761 \"provider\"=\"minio\"
\u6765\u6307\u660e\u5e95\u5c42\u5b58\u50a8\u6765\u6e90\u662f\u672c\u5730 Minio\uff0c\u6700\u7ec8\u5f62\u6210\u5982\u4ee5\u4e0b\u7684 SQL \u8bed\u53e5\u3002
MySQL [stock]> load data url s3option{\"endpoint\"='http://minio.mostorage:80',\"access_key_id\"='rootuser', \"secret_access_key\"='rootpass123',\"bucket\"='load-from-minio', \"filepath\"='/addresses.csv', \"compression\"='none', \"provider\"=\"minio\"} INTO TABLE address FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' PARALLEL 'TRUE';\nQuery OK, 6 rows affected (2.302 sec)\n
Note
\"provider\"=\"minio\" \u4ec5\u5728\u672c\u5730 Minio \u73af\u5883\u4e2d\u751f\u6548\uff0c\u5982\u679c\u4ece\u516c\u6709\u4e91\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u5bfc\u5165\u6570\u636e\u65e0\u9700\u52a0\u8be5\u53c2\u6570\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/","title":"\u8d1f\u8f7d\u4e0e\u79df\u6237\u9694\u79bb","text":"Proxy \u662f MatrixOne \u5728 0.8 \u7248\u672c\u4e2d\u5f15\u8fdb\u7684\u65b0\u7cfb\u7edf\u7ec4\u4ef6\uff0c\u5b83\u53ef\u4ee5\u901a\u8fc7\u6d41\u91cf\u4ee3\u7406\u548c\u8f6c\u53d1\u7684\u65b9\u5f0f\u5b9e\u73b0\u79df\u6237\u3001\u8d1f\u8f7d\u9694\u79bb\u7b49\u529f\u80fd\u3002\u5173\u4e8e Proxy \u7684\u6280\u672f\u8bbe\u8ba1\uff0c\u53ef\u4ee5\u53c2\u8003 Proxy \u67b6\u6784\u8be6\u89e3\u3002
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Proxy \u6765\u5efa\u7acb\u4e0d\u540c\u7684 CN \u7ec4\uff0c\u4ee5\u5b9e\u73b0\u79df\u6237\u548c\u8d1f\u8f7d\u7684\u72ec\u7acb\u8d44\u6e90\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_2","title":"\u7cfb\u7edf\u67b6\u6784","text":"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u7528\u6237\u9996\u5148\u8fde\u63a5\u5230 Proxy \u6a21\u5757\u3002Proxy \u7ec4\u4ef6\u6839\u636e\u7528\u6237\u8fde\u63a5\u4e32\u4e2d\u7684\u8eab\u4efd\u548c\u6807\u7b7e\u4fe1\u606f\uff0c\u5c06\u7528\u6237\u7684\u6570\u636e\u5e93\u8fde\u63a5\uff08connection\uff09\u5206\u53d1\u5230\u76f8\u5e94\u7684 CN \u7ec4\u3002\u5176\u4ed6 CN \u7ec4\u4e0d\u4f1a\u63a5\u6536\u5230\u6b64\u7528\u6237\u8fde\u63a5\uff0c\u4e5f\u4e0d\u4f1a\u53c2\u4e0e\u8be5\u8fde\u63a5\u7684\u8ba1\u7b97\u8fc7\u7a0b\u3002
CN \u7ec4\u662f\u7531\u4e00\u7ec4\u5177\u6709\u76f8\u540c\u5c5e\u6027\u548c\u5927\u5c0f\u7684 CN \u8282\u70b9\u7ec4\u6210\u7684\u903b\u8f91 CN \u7ec4\uff0c\u5b83\u662f MatrixOne \u96c6\u7fa4\u4e2d\u7528\u4e8e\u9694\u79bb\u4e0d\u540c\u8d44\u6e90\u7ec4\u7684\u5355\u4f4d\u3002\u6bcf\u4e2a CN \u7ec4\u53ef\u5305\u542b 1 \u4e2a\u5230\u65e0\u9650\u4e2a CN \u8282\u70b9\uff0c\u5e76\u53ef\u4f7f\u7528\u4e00\u7cfb\u5217\u6807\u7b7e\u5b9a\u4e49\u5176\u5c5e\u6027\uff0c\u4f8b\u5982\u5b9a\u4e49\u67d0\u79df\u6237\u5bf9\u5e94\u7684 Account \u6807\u7b7e\uff0c\u5c06\u8fde\u63a5\u8f6c\u53d1\u81f3\u5e26\u6709\u76f8\u5e94\u6807\u7b7e\u7684 CN \u7ec4\uff0c\u4fbf\u53ef\u5b9e\u73b0\u79df\u6237\u8d44\u6e90\u9694\u79bb\u548c\u4e1a\u52a1\u8d1f\u8f7d\u9694\u79bb\u529f\u80fd\u3002\u7ed3\u5408 CN \u7ec4\u4e2d CN \u8282\u70b9\u53ef\u65e0\u9650\u6c34\u5e73\u6269\u5c55\u7684\u7279\u6027\uff0c\u53ef\u5b9e\u73b0\u9488\u5bf9\u79df\u6237\u6216\u6307\u5b9a\u8d1f\u8f7d\u7684\u72ec\u7acb\u6269\u5c55\u3002
\u4e3a\u786e\u4fdd Proxy \u7684\u9ad8\u53ef\u7528\u6027\uff0c\u9700\u8981\u5728\u96c6\u7fa4\u4e2d\u8bbe\u7f6e\u81f3\u5c11 2 \u4e2a\u526f\u672c\u3002
\u5f53\u5bf9 CN \u8fdb\u884c\u7f29\u5bb9\u65f6\uff0cProxy \u5728 YAML \u6587\u4ef6\u7684\u884c\u4e3a\u5982\u4e0b\uff1a
\u540c\u4e00\u4e2a Label \u4f1a\u8bdd\u642c\u8fc1\uff1a\u5f53 CN \u7684\u526f\u672c\u6570\u91cf\u51cf\u5c11\u65f6\uff0c\u5177\u6709\u76f8\u540c Label \u7684\u4f1a\u8bdd\u5c06\u88ab\u8fc1\u79fb\u5230\u5176\u4ed6\u7f29\u5bb9\u540e\u7684 CN \u8282\u70b9\u4e0a\u3002\u8fd9\u6837\u53ef\u4ee5\u4fdd\u6301\u4e0e\u7279\u5b9a Label \u76f8\u5173\u7684\u4f1a\u8bdd\u7684\u8fde\u7eed\u6027\u548c\u53ef\u7528\u6027\u3002
\u4e0d\u540c Label \u4f1a\u8bdd\u642c\u8fc1\uff1a\u5982\u679c\u67d0\u4e2a Label \u7684 CN \u526f\u672c\u88ab\u7f6e\u4e3a 0 \u6216\u53d6\u6d88\uff0c\u6839\u636e Label \u7684\u5339\u914d\u89c4\u5219\uff0c\u5c06\u4f1a\u5728\u5c06\u6765\u7684\u4f1a\u8bdd\u4e2d\u5c06\u8fd9\u4e2a Label \u76f8\u5173\u7684\u4f1a\u8bdd\u8fc1\u79fb\u5230\u7a7a\u95f2\u7684 Label \u4e0a\u3002
Label \u53d6\u6d88\u5e76\u4e14\u6ca1\u6709\u5339\u914d Label\uff1a\u5982\u679c\u67d0\u4e2a Label \u88ab\u53d6\u6d88\uff0c\u800c\u4e14\u6ca1\u6709\u4e0e\u4e4b\u5339\u914d\u7684 Label\uff0c\u76f8\u5173\u4f1a\u8bdd\u5c06\u88ab\u5173\u95ed\uff0c\u56e0\u4e3a\u6ca1\u6709\u76ee\u6807 CN \u53ef\u4ee5\u63a5\u6536\u8fd9\u4e9b\u4f1a\u8bdd\u3002
Proxy \u5728 CN \u7f29\u5bb9\u65f6\u901a\u8fc7\u4ee5\u4e0a\u884c\u4e3a\u5904\u7406\u4f1a\u8bdd\u7684\u8fc1\u79fb\u548c\u5173\u95ed\uff0c\u4ee5\u786e\u4fdd\u8d1f\u8f7d\u548c\u79df\u6237\u4e4b\u95f4\u7684\u9694\u79bb\u4ee5\u53ca\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_3","title":"\u64cd\u4f5c\u6b65\u9aa4","text":"\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u4f7f\u7528 Proxy \u7ba1\u7406 CN \u7ec4\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
\u4e3a\u4e86\u65b9\u4fbf\u4f60\u4e86\u89e3\u8d44\u6e90\u9694\u79bb\u4e0e\u5206\u914d\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u4e0b\u9762\u8868\u683c\u4e2d\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u73af\u5883\u4e2d\u5404\u4e2a\u786c\u4ef6\u8282\u70b9\u60c5\u51b5\u5206\u5e03\uff0c\u5177\u4f53\u5982\u4e0b\u6240\u793a\uff1a
Host \u5185\u7f51 IP \u5916\u7f51 IP \u5185\u5b58 CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#proxy","title":"\u7b2c\u4e00\u6b65\uff1a\u542f\u7528 Proxy","text":"\u5728 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u4e2d\u542f\u7528 Proxy \u7ec4\u4ef6\uff0c\u4f60\u9700\u8981\u5728\u521b\u5efa\u96c6\u7fa4\u65f6\u6307\u5b9a\u6240\u9700\u7684 Proxy \u62d3\u6251\uff0c\u6216\u8005\u5728\u73b0\u6709\u96c6\u7fa4\u4e2d\u6dfb\u52a0 Proxy \u62d3\u6251\u540e\uff0c\u6267\u884c kubectl apply
\u4ee5\u542f\u7528 Proxy \u7ec4\u4ef6\u3002\u8be6\u7ec6\u6b65\u9aa4\u5982\u4e0b\uff1a
\u4fee\u6539 MatrixOne \u96c6\u7fa4\u7684 mo.yaml
\u6587\u4ef6\uff1a
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ proxy:\n+ replicas: 2 #\u4e3a\u4e86\u9ad8\u53ef\u7528\uff0cproxy \u7684 replicas \u9700\u8981\u81f3\u5c11 2 \u4e2a\n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u8fd0\u884c mo.yaml
\u6587\u4ef6\uff1a
kubectl apply -f mo.yaml\n
\u8fd0\u884c kubectl get pod -nmo-hn
\u68c0\u67e5 Proxy \u72b6\u6001\u662f\u5426\u6b63\u5e38\u542f\u52a8\uff1a
root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME READY STATUS RESTARTS AGE\nmo-tn-0 1/1 Running 0 2m51s\nmo-log-0 1/1 Running 0 3m25s\nmo-log-1 1/1 Running 0 3m25s\nmo-log-2 1/1 Running 0 3m25s\nmo-proxy-69zjf 1/1 Running 0 2m51s\nmo-proxy-fpn2g 1/1 Running 0 2m51s\nmo-tp-cn-0 1/1 Running 0 2m25s\n
\u6b63\u5e38\u542f\u52a8\u540e\u7684\u4ee3\u7801\u793a\u4f8b\u5982\u4e0a\u8ff0\u6240\u793a\u3002\u8fd9\u6837\u6700\u5c0f\u5316\u7684 Proxy \u7ec4\u4ef6\u5c31\u542f\u52a8\u5b8c\u6210\u4e86\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 kubectl get svc -nmo-hn
\u901a\u8fc7 Proxy \u7684 SVC \u5730\u5740\u5373\u53ef\u4ee5\u8fde\u63a5\u5230\u8be5\u96c6\u7fa4\uff1a
root@HOST-10-206-134-16:~# kubectl get svc -nmo-hn\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\nmo-tn-headless ClusterIP None <none> <none> 70m\nmo-log-discovery ClusterIP 10.96.3.186 <none> 32001/TCP 71m\nmo-log-headless ClusterIP None <none> <none> 71m\nmo-proxy NodePort 10.96.1.153 <none> 6001:31429/TCP 70m\nmo-tp-cn ClusterIP 10.96.1.43 <none> 6001/TCP 70m\nmo-tp-cn-headless ClusterIP None <none> <none> 70m\nroot@HOST-10-206-134-16:~# mysql -h 10.96.1.153 -P6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 2064\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective owners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
\u82e5\u6574\u4e2a\u96c6\u7fa4\u4e2d\u6709\u591a\u4e2a CN \u7684\u8bdd\uff0cProxy \u4f1a\u81ea\u52a8\u5b9e\u73b0\u8fde\u63a5\u7ea7\u522b\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u5c06\u7528\u6237\u7684\u8fde\u63a5\u5747\u5300\u5206\u914d\u5230\u4e0d\u540c\u7684 CN \u4e0a\u3002\u4f60\u53ef\u4ee5\u67e5\u8be2\u7cfb\u7edf\u8868 system_metrics.server_connections
\u6765\u67e5\u770b\u6bcf\u4e2a CN \u4e0a\u7684\u7528\u6237\u8fde\u63a5\u4e2a\u6570\u3002
\u5728 MatrixOne \u96c6\u7fa4\u7684 mo.yaml
\u6587\u4ef6\u4e2d\uff0c\u4f60\u9700\u8981\u901a\u8fc7\u8bbe\u7f6e cnGroups
\u5b57\u6bb5\u6765\u914d\u7f6e CN \u7ec4\uff0c\u5e76\u5728\u6bcf\u4e2a cnGroups
\u4e2d\u914d\u7f6e cnLabels
\u5b57\u6bb5\uff0c\u4ee5\u8bbe\u5b9a\u8be5 CN \u7ec4\u4e2d\u6240\u6709 CN \u7684\u6807\u7b7e\u3002Proxy \u4f1a\u6839\u636e\u8fde\u63a5\u6807\u7b7e\u8fdb\u884c\u8def\u7531\u8f6c\u53d1\u3002\u4f8b\u5982\uff0c\u5728\u4ee5\u4e0b\u793a\u4f8b\u4e2d\uff0c\u4f60\u8bbe\u7f6e\u4e86\u540d\u4e3a cn-set1
\u548c cn-set2
\u7684\u4e24\u4e2a CN \u7ec4\u3002\u6bcf\u4e2a CN \u7ec4\u53ef\u4ee5\u5177\u6709\u81ea\u5df1\u7684\u72ec\u7acb\u526f\u672c\u6570\u3001\u4e0d\u540c\u7684\u65e5\u5fd7\u7ea7\u522b\u3001CN \u53c2\u6570\u914d\u7f6e\u4ee5\u53ca CN \u6807\u7b7e\u3002
CN \u7ec4\u7684\u6807\u7b7e\u91c7\u7528\u4e00\u5230\u591a\u7ec4 Key/value \u683c\u5f0f\uff0c\u5176\u4e2d\u6bcf\u7ec4 Key \u4e0e value \u4e4b\u95f4\u5b58\u5728\u4e00\u5bf9\u591a\u7684\u5173\u7cfb\uff0c\u5373\u6bcf\u4e2a Key \u53ef\u62e5\u6709\u591a\u4e2a value\u3002
\u8be6\u7ec6\u6b65\u9aa4\u5982\u4e0b\uff1a
\u53c2\u7167\u4e0b\u9762\u7684\u914d\u7f6e\u53c2\u6570\u793a\u4f8b\uff0c\u914d\u7f6e CN \u7ec4\u7684\u6807\u7b7e\uff1a
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+ replicas: 1\n+ cnLabels:\n+ - key: \"cn-set1\"\n+ values: [\"1\", \"high\"]\n+ - key: \"account\"\n+ values: [\"acc1\"]\n+\n+ - name: cn-set2\n+ replicas: 1\n+ cnLabels:\n+ - key: \"cn-set2\"\n+ values: [\"2\", \"medium\"]\n+ - key: \"account\"\n+ values: [\"acc2\"] \n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u8fd0\u884c mo.yaml
\u6587\u4ef6\uff1a
kubectl apply -f mo.yaml\n
\u8fd0\u884c kubectl get pod -nmo-hn
\u68c0\u67e5 Proxy \u72b6\u6001\u662f\u5426\u6b63\u5e38\u542f\u52a8\uff1a
root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME READY STATUS RESTARTS AGE\nmo-cn-set1-cn-0 1/1 Running 0 6s\nmo-cn-set2-cn-0 1/1 Running 0 6s\nmo-tn-0 1/1 Running 0 97m\nmo-log-0 1/1 Running 0 97m\nmo-log-1 1/1 Running 0 97m\nmo-log-2 1/1 Running 0 97m\nmo-proxy-69zjf 1/1 Running 0 97m\nmo-proxy-fpn2g 1/1 Running 0 97m\n
\u6b63\u5e38\u542f\u52a8\u540e\u7684\u4ee3\u7801\u793a\u4f8b\u5982\u4e0a\u8ff0\u6240\u793a\u3002
CN \u7ec4\u7684\u6807\u7b7e\u8bbe\u7f6e\u975e\u5e38\u7075\u6d3b\uff0c\u4f46\u662f\u4e00\u822c\u6700\u5e38\u89c1\u7684\u8fd8\u662f\u7528\u5728\u79df\u6237\u548c\u8d1f\u8f7d\u7684\u9694\u79bb\u4e0a\u3002
\u5173\u4e8e\u5982\u4f55\u5b9e\u73b0\u79df\u6237\u9694\u79bb\u548c\u8d1f\u8f7d\u9694\u79bb\uff0c\u8bf7\u7ee7\u7eed\u53c2\u52a0\u4e0b\u9762\u7684\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_4","title":"\u5b9e\u73b0\u79df\u6237\u9694\u79bb","text":"MatrixOne 0.7 \u7248\u672c\u5df2\u5b9e\u73b0\u5bf9\u591a\u79df\u6237\u6570\u636e\u9694\u79bb\u7684\u652f\u6301\u3002\u82e5\u8981\u5b9e\u73b0\u79df\u6237\u8d1f\u8f7d\u9694\u79bb\uff0c\u5219\u9700\u901a\u8fc7\u914d\u7f6e Proxy \u548c CN \u7ec4\u6765\u5b8c\u6210\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_5","title":"\u666e\u901a\u79df\u6237","text":"\u5728 CN \u7ec4\u7684\u6807\u7b7e\u8bbe\u7f6e\u4e2d\uff0caccount
\u6807\u7b7e\u662f\u4fdd\u7559\u5b57\u6bb5\uff0c\u7528\u4f5c\u5339\u914d\u79df\u6237\u3002
\u5728\u672c\u7ae0\u4e2d\uff0c\u5047\u8bbe\u9700\u8981\u4e3a acc1
\u548c acc2
\u8fd9\u4e24\u4e2a\u79df\u6237\u5b9e\u73b0\u79df\u6237\u8d1f\u8f7d\u9694\u79bb\uff0c\u4f60\u53ef\u4ee5\u53c2\u89c1\u4e0b\u9762\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a
Note
\u4ec5\u652f\u6301\u62e5\u6709\u7cfb\u7edf\u79df\u6237\u6743\u9650\u7684\u7528\u6237\u624d\u80fd\u4e3a\u666e\u901a\u79df\u6237\u914d\u7f6e\u8d1f\u8f7d\u9694\u79bb\u3002
\u4f7f\u7528\u7cfb\u7edf\u79df\u6237\u767b\u5f55\u5230 MatrixOne \u96c6\u7fa4\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u8bf7\u54a8\u8be2\u4f60\u6240\u5728\u516c\u53f8\u7684\u6570\u636e\u5e93\u7ba1\u7406\u5458\u3002\u767b\u5f55\u5230 MatrixOne \u96c6\u7fa4\u540e\uff0c\u5206\u522b\u521b\u5efa\u4e24\u4e2a\u65b0\u79df\u6237 acc1
\u548c acc2
\uff1a
-- \u521b\u5efa\u65b0\u79df\u6237 acc1\uff0c\u5bc6\u7801\u4e3a 123456\uff08\u5728\u8fd9\u91cc\u8bbe\u7f6e\u7b80\u5355\u5bc6\u7801\uff0c\u4ec5\u505a\u4e3a\u793a\u4f8b\u8bb2\u89e3\u4f7f\u7528\uff09\nmysql> create account acc1 admin_name 'admin' identified by '123456';\n-- \u521b\u5efa\u65b0\u79df\u6237 acc2\uff0c\u5bc6\u7801\u4e3a 123456\uff08\u5728\u8fd9\u91cc\u8bbe\u7f6e\u7b80\u5355\u5bc6\u7801\uff0c\u4ec5\u505a\u4e3a\u793a\u4f8b\u8bb2\u89e3\u4f7f\u7528\uff09\nmysql> create account acc2 admin_name 'admin' identified by '123456';\n
\u4fee\u6539 MatrixOne \u96c6\u7fa4\u7684 mo.yaml
\u6587\u4ef6\uff0c\u5c06\u4e24\u4e2a CN \u7ec4\u5206\u522b\u6253\u4e0a\u4e86 account:acc1
\u53ca account:acc2
\u7684\u6807\u7b7e\uff0c\u5206\u522b\u5bf9\u5e94\u540d\u4e3a acc1
\u548c acc2
\u7684\u79df\u6237\uff1a
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+ replicas: 1\n+ cnLabels:\n+ - key: \"account\"\n+ values: [\"acc1\"]\n+\n+ - name: cn-set2\n+ replicas: 1\n+ cnLabels:\n+ - key: \"account\"\n+ values: [\"acc2\"] \n
\u5206\u522b\u4f7f\u7528 acc1
\u548c acc2
\u767b\u5f55\uff0c\u767b\u5f55\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 show backend servers
\u68c0\u67e5\u5b9e\u9645\u767b\u5f55\u4f7f\u7528\u4e86\u54ea\u4e9b CN \u7ec4\u3002\u4ee5\u4e0b\u65e5\u5fd7\u663e\u793a\u4e0d\u540c\u7684\u5e10\u6237\u5df2\u767b\u5f55\u5e76\u4f7f\u7528\u4e86\u76f8\u5e94\u7684 CN \u7ec4
-- acc1 \u79df\u6237\u767b\u5f55 MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc1:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 32309\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc1 \u67e5\u770b\u5b9e\u9645\u767b\u5f55\u4f7f\u7528\u7684 CN \u7ec4\u662f\u54ea\u4e9b\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| UUID | Address | Work State | Labels |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| 32333337-3966-3137-3032-613035306561 | mo-cn-set1-cn-0.mo-cn-set1-cn-headless.mo-hn.svc:6001 | Working | account:acc1;cn-set1:1,high; |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n1 row in set (0.00 sec)\n
-- acc2 \u79df\u6237\u767b\u5f55 MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc2:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 32640\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc2 \u67e5\u770b\u5b9e\u9645\u767b\u5f55\u4f7f\u7528\u7684 CN \u7ec4\u662f\u54ea\u4e9b\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| UUID | Address | Work State | Labels |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| 33663265-3234-3365-3737-333030613535 | mo-cn-set2-cn-0.mo-cn-set2-cn-headless.mo-hn.svc:6001 | Working | account:acc2;cn-set2:2,medium; |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n1 row in set (0.00 sec)\n
\u5982\u679c\u4e00\u4e2a\u666e\u901a\u79df\u6237\u6ca1\u6709\u5bf9\u5e94\u7684 CN \u7ec4\uff0c\u90a3\u4e48\u79df\u6237\u65e0\u6cd5\u767b\u5f55\u6210\u529f\u3002\u4f8b\u5982\uff0c\u4f60\u5982\u679c\u521b\u5efa\u4e00\u4e2a\u6ca1\u6709 CN \u7ec4\u6807\u7b7e\u5bf9\u5e94\u7684\u79df\u6237 acc3
\uff0c\u5e76\u5c1d\u8bd5\u767b\u5f55\uff0c\u4f1a\u51fa\u73b0 no available CN server
\u9519\u8bef\u3002
mysql> create account acc3 admin_name 'admin' identified by '123456';\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc3:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nERROR 1045 (28000): internal error: no available CN server\n
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_6","title":"\u7cfb\u7edf\u79df\u6237","text":"\u5bf9\u4e8e\u7cfb\u7edf\u79df\u6237\uff0cMatrixOne \u5c06\u6309\u7167\u4ee5\u4e0b\u987a\u5e8f\u81ea\u52a8\u9009\u62e9\u5408\u9002\u7684 CN \u7ec4\u8fdb\u884c\u8fde\u63a5\uff1a
account
\u6807\u7b7e\u4e3a sys
\u7684 CN \u7ec4\u3002account
\u6807\u7b7e\u7684 CN \u7ec4\u3002\u6839\u636e\u8fd9\u4e00\u539f\u5219\uff0c\u7cfb\u7edf\u79df\u6237\u4f1a\u4f18\u5148\u9009\u62e9\u4e13\u4e3a\u81ea\u5df1\u4fdd\u7559\u6216\u672a\u88ab\u5176\u4ed6\u79df\u6237\u9884\u7559\u7684 CN \u7ec4\u3002\u7136\u800c\uff0c\u5982\u679c\u4ee5\u4e0a\u6761\u4ef6\u5747\u4e0d\u6ee1\u8db3\uff0c\u7cfb\u7edf\u79df\u6237\u53ef\u80fd\u4f1a\u4e0e\u5176\u4ed6\u79df\u6237\u5171\u4eab CN \u7ec4\uff0c\u4ece\u800c\u65e0\u6cd5\u786e\u4fdd\u7cfb\u7edf\u79df\u6237\u4e0e\u666e\u901a\u79df\u6237\u4e4b\u95f4\u7684\u8d1f\u8f7d\u9694\u79bb\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_7","title":"\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb","text":"Proxy \u4ee3\u7406\u4f7f\u7528\u573a\u666f\u662f\u8d1f\u8f7d\u9694\u79bb\u3002\u5728\u8bb8\u591a\u6807\u51c6\u4e1a\u52a1\u73af\u5883\u4e2d\uff0c\u5982\u9ad8\u5e76\u53d1\u5199\u5165\u3001\u62a5\u8868\u751f\u6210\u3001\u5907\u4efd\u548c\u5927\u6570\u636e\u5bfc\u51fa\u7b49\uff0c\u4f20\u7edf\u6570\u636e\u5e93\u65b9\u6848\u901a\u5e38\u9700\u6c42\u90e8\u7f72\u7279\u5b9a\u7684\u5b9e\u4f8b\u4ee5\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb\u3002\u8fd9\u79cd\u65b9\u5f0f\u540c\u65f6\u8fd8\u4f1a\u5bfc\u81f4\u989d\u5916\u7684\u6570\u636e\u540c\u6b65\u8d1f\u62c5\u3002
MatrixOne \u5229\u7528 Proxy \u6765\u5b9e\u73b0\u8d44\u6e90\u7ec4\u7684\u5212\u5206\uff0c\u5b83\u80fd\u591f\u7075\u6d3b\u5730\u5c06 CN \u7ec4\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u8d1f\u8f7d\u6807\u7b7e\u7ed3\u5408\u3002\u5728\u8d1f\u8f7d\u53d8\u52a8\u7684\u60c5\u51b5\u4e0b\uff0cMatrixOne \u80fd\u591f\u901a\u8fc7\u8f6f\u4ef6\u914d\u7f6e\u8c03\u6574\u8d44\u6e90\u7ec4\u7684\u89c4\u6a21\uff0c\u4ece\u800c\u66f4\u597d\u5730\u9002\u5e94\u53d8\u5316\u3002
\u4ee5\u4e0a\u8ff0\u4e3a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u5c06\u4e24\u4e2a CN \u7684\u8d1f\u8f7d\u6807\u7b7e\u5206\u522b\u8bbe\u7f6e\u4e3a olap
\u548c oltp
\u3002\u7136\u540e\uff0c\u4f7f\u7528 SSB \u6a21\u62df OLTP \u8d1f\u8f7d\uff0c\u5e76\u4f7f\u7528 TPCH \u6a21\u62df OLAP \u8d1f\u8f7d\u3002
Note
\u5728\u8fdb\u884c\u6027\u80fd\u6d4b\u8bd5\u65f6\uff0c\u4f60\u9996\u5148\u9700\u8981\u5bf9\u6574\u4e2a\u96c6\u7fa4\u8fdb\u884c\u6269\u5c55\u3002
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+ replicas: 1\n+ cnLabels:\n+ - key: \"workload\"\n+ # \u8d1f\u8f7d\u6807\u7b7e\u8bbe\u7f6e\u4e3a olap\n+ values: [\"olap\"]\n+\n+ - name: cn-set2\n+ replicas: 1\n+ cnLabels:\n+ - key: \"workload\"\n+ # \u8d1f\u8f7d\u6807\u7b7e\u8bbe\u7f6e\u4e3a oltp\n+ values: [\"oltp\"]\n
\u914d\u7f6e\u5b8c\u96c6\u7fa4\u7684\u8d1f\u8f7d\u4e4b\u540e\uff0c\u53ef\u4ee5\u8fde\u63a5\u5230\u96c6\u7fa4\u8fdb\u884c\u8d1f\u8f7d\u6d4b\u8bd5\uff1a
\u901a\u8fc7 JDBC \u8fde\u63a5\uff1a
\u5728 JDBC \u7684\u8fde\u63a5\u4e32\u4e2d\u6307\u5b9a connectionAttributes\uff0c\u5e76\u8bbe\u7f6e\u76f8\u5e94\u7684 key \u548c value\uff0ckey \u548c value \u4e4b\u95f4\u7528\u5192\u53f7 :
\u95f4\u9694\uff0c\u591a\u4e2a key-value \u4e4b\u95f4\u7528\u9017\u53f7 ,
\u95f4\u9694\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
jdbc:mysql://localhost:6001/test_db1?serverTimezone=UTC&connectionAttributes=workload:olap,another_key:test_value\n
\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u5b9e\u73b0\u8fde\u63a5\uff1a
\u901a\u8fc7\u6269\u5c55\u7528\u6237\u540d\uff08username\uff09\u5b57\u6bb5\uff0c\u5b9e\u73b0\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fdb\u884c\u8fde\u63a5\u3002\u5728\u7528\u6237\u540d\uff08username\uff09\u540e\u6dfb\u52a0 ?
\uff0c\u968f\u540e\u7684\u7f16\u5199\u65b9\u5f0f\u9075\u5faa JDBC \u4e2d\u7684 connectionAttributes \u683c\u5f0f\uff0c\u4e0e JDBC \u4e2d\u7684 connectionAttributes \u683c\u5f0f\u4e0d\u540c\u7684\u662f\uff0ckey \u548c value \u4e4b\u95f4\u7528 =
\u95f4\u9694\uff0c\u591a\u4e2a key-value \u4e4b\u95f4\u7528\u9017\u53f7 ,
\u95f4\u9694\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
mysql -h127.0.0.1 -uuser1?workload=olap,another_key=test_value -P6001 -pxxx\n
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u5982\u4f55\u6eda\u52a8\u5347\u7ea7\u6216\u8005\u91cd\u88c5\u5347\u7ea7 MatrixOne \u96c6\u7fa4\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u5347\u7ea7\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#_2","title":"\u6eda\u52a8\u5347\u7ea7","text":"\u6eda\u52a8\u5347\u7ea7\uff0c\u662f\u4e00\u79cd\u5728\u7ebf\u5347\u7ea7\u65b9\u5f0f\uff0c\u5373 MatrixOne \u96c6\u7fa4\u5728\u4fdd\u8bc1\u90e8\u5206\u6216\u5168\u90e8\u670d\u52a1\u53ef\u7528\u7684\u60c5\u51b5\u4e0b\u5b8c\u6210\u8f6f\u4ef6\u7684\u5347\u7ea7\u3002
MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u4e2d\u4ecb\u7ecd\uff0c\u5b89\u88c5 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u57fa\u4e8e Kubernetes \u548c MatrixOne Operator\uff0c\u56e0\u6b64\u6eda\u52a8\u5347\u7ea7 MatrixOne \u5c31\u662f\u901a\u8fc7\u52a8\u6001\u4fee\u6539 MatrixOne Operator \u4e2d\u7684 MatrixOne \u955c\u50cf\u7248\u672c\u53f7\u6765\u5b9e\u73b0\u81ea\u52a8\u7684\u7248\u672c\u66f4\u65b0\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#_3","title":"\u64cd\u4f5c\u6b65\u9aa4","text":"\u5728 master0 \u8282\u70b9\u7684\u7ec8\u7aef\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fdb\u5165\u52a8\u6001\u4fee\u6539 operator \u4f7f\u7528\u7684 yaml
\u914d\u7f6e\u6587\u4ef6\u7684\u754c\u9762\u3002
mo_ns=\"mo-hn\" #matrixone \u96c6\u7fa4\u7684 namespace\nmo_cluster_name=\"mo\" # matrixone \u7684\u96c6\u7fa4\u540d\u79f0\uff0c\u4e00\u822c\u4e3a mo\uff0c\u6839\u636e\u90e8\u7f72\u65f6 matrixonecluster \u5bf9\u8c61\u7684 yaml \u6587\u4ef6\u4e2d\u7684 name \u6307\u5b9a\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7 kubectl get matrixonecluster -n${mo_ns}\u6765\u786e\u8ba4\n#mo-hn \u53ca mo \u5df2\u5728\u5b89\u88c5\u90e8\u7f72\u7684 mo.yaml \u6587\u4ef6\u4e2d\u8bbe\u7f6e\nkubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\u540e\uff0c\u4fee\u6539 spec.version
\u7684\u503c\uff0c\u5176\u4e2d\uff1a
${TAG}\uff1a\u4e3a\u5bf9\u5e94 dockerhub \u4e0a Matrixone \u7684\u955c\u50cf tag\uff0c\u4f8b\u5982\uff1anightly-f0d52530
${REPO_URL}\uff1a\u662f Matrixone \u516c\u5f00\u955c\u50cf\u4ed3\u5e93\uff0c\u9ed8\u8ba4\u4e3a matrixorigin/matrixone\u3002\u5047\u5982\u76ee\u6807\u7248\u672c\u5728 MatrixOne \u7684\u516c\u5f00\u955c\u50cf\u4ed3\u5e93\u4e0d\u5b58\u5728\uff0c\u5219\u9700\u8981\u540c\u65f6\u4fee\u6539\u955c\u50cf\u4ed3\u5e93\u7684 URL \u4e3a\u5b9e\u9645\u7684\u4ed3\u5e93\uff1a
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u6309 :wq
\u4fdd\u5b58\u5373\u53ef\uff0cMatrixOne Operator \u4f1a\u81ea\u52a8\u62c9\u53d6\u65b0\u7248\u672c\u7684\u955c\u50cf\uff0c\u5e76\u91cd\u542f\u7ec4\u4ef6\u670d\u52a1\uff0c\u5305\u62ec Log Service\uff0cTN \u548c CN\uff0c\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u89c2\u5bdf\u5176\u8fd0\u884c\u72b6\u6001\u3002
watch -e \"kubectl get pod -n${mo_ns}\"\n
NAME READY STATUS RESTARTS AGE\nmatrixone-operator-f8496ff5c-fp6zm 1/1 Running 0 24h\nmo-tn-0 1/1 Running 1 (51s ago) 18h\nmo-log-0 1/1 Running 0 18h\nmo-log-1 1/1 Running 1 (5s ago) 18h\nmo-log-2 1/1 Running 1 (53s ago) 18h\nmo-tp-cn-0 1/1 Running 1 (53s ago) 18h\n
\u5982\u679c\u53d1\u751f error\u3001crashbackoff \u7b49\u60c5\u51b5\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u7ec4\u4ef6\u7684\u65e5\u5fd7\u6765\u8fdb\u4e00\u6b65\u6392\u67e5\u95ee\u9898\u3002
# pod_name \u662f pod \u7684\u540d\u79f0\uff0c\u5982 mo-tn-0,mo-tp-cn-0\npod_name=mo-tn-0\nkubectl logs ${pod_name} -nmo-hn > /tmp/tn.log\nvim /tmp/tn.log\n
\u5f53 MatrixOne \u96c6\u7fa4\u4e2d\u7684\u7ec4\u4ef6\u5747 Restart
\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u7528 MySQL Client \u8fde\u63a5\u96c6\u7fa4\uff0c\u5982\u679c\u8fde\u63a5\u6210\u529f\u4e14\u7528\u6237\u6570\u636e\u5747\u5b8c\u6574\uff0c\u5219\u8bf4\u660e\u5347\u7ea7\u6210\u529f\u3002
# \u4f7f\u7528 'mysql' \u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230 MySQL \u670d\u52a1\n# \u4f7f\u7528 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' \u83b7\u53d6 Kubernetes \u96c6\u7fa4\u4e2d\u670d\u52a1\u7684\u96c6\u7fa4 IP \u5730\u5740\n# '-h' \u53c2\u6570\u6307\u5b9a\u4e86 MySQL \u670d\u52a1\u7684\u4e3b\u673a\u540d\u6216 IP \u5730\u5740\n# '-P' \u53c2\u6570\u6307\u5b9a\u4e86 MySQL \u670d\u52a1\u7684\u7aef\u53e3\u53f7\uff0c\u8fd9\u91cc\u662f 6001\n# '-uroot' \u8868\u793a\u7528 root \u7528\u6237\u767b\u5f55\n# '-p111' \u8868\u793a\u521d\u59cb\u5bc6\u7801\u662f 111\nroot@master0 ~]# mysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nWelcome to the MariaDB monitor. Commands end with ; or \\g.\nYour MySQL connection id is 1005\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\nMySQL [(none)]> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| mo_task |\n| information_schema |\n| mysql |\n| system_metrics |\n| system |\n| test |\n| mo_catalog |\n+--------------------+\n7 rows in set (0.01 sec)\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u6eda\u52a8\u66f4\u65b0\u53ef\u80fd\u56e0\u4e3a\u9519\u8bef\u7684\u914d\u7f6e\u800c\u6682\u505c\uff08\u6bd4\u5982\u5728\u5347\u7ea7\u65f6\u6307\u5b9a\u4e86\u4e0d\u5b58\u5728\u7684\u7248\u672c\uff09\u3002\u6b64\u65f6\uff0c\u9700\u91cd\u65b0\u4fee\u6539 operator \u52a8\u6001\u914d\u7f6e\uff0c\u91cd\u7f6e version \u53f7\uff0c\u56de\u6eda\u53d8\u66f4\uff0c\u5df2\u7ecf\u5931\u8d25\u7684 Pod \u5c06\u88ab\u91cd\u65b0\u66f4\u65b0\u3002
\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d MatrixOne \u90e8\u7f72\u7684\u7248\u672c\u53f7\uff1a
[root@master0 matrixone-operator]# kubectl get matrixoneclusters -n mo-hn -o yaml | grep version\n {\"apiVersion\":\"core.matrixorigin.io/v1alpha1\",\"kind\":\"MatrixOneCluster\",\"metadata\":{\"annotations\":{},\"name\":\"mo\",\"namespace\":\"mo-hn\"},\"spec\":{\"tn\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[dn.Txn.Storage]\\nbackend = \\\"TAE\\\"\\nlog-backend = \\\"logservice\\\"\\n[dn.Ckp]\\nflush-interval = \\\"60s\\\"\\nmin-count = 100\\nscan-interval = \\\"5s\\\"\\nincremental-interval = \\\"60s\\\"\\nglobal-interval = \\\"100000s\\\"\\n[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}}},\"imagePullPolicy\":\"IfNotPresent\",\"imageRepository\":\"matrixorigin/matrixone\",\"logService\":{\"config\":\"[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"pvcRetentionPolicy\":\"Retain\",\"replicas\":3,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"sharedStorage\":{\"s3\":{\"endpoint\":\"http://minio.mostorage:9000\",\"path\":\"minio-mo\",\"secretRef\":{\"name\":\"minio\"},\"type\":\"minio\"}},\"volume\":{\"size\":\"1Gi\"}},\"tp\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[cn.Engine]\\ntype = \\\"distributed-tae\\\"\\n[log]\\nlevel = \\\"debug\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"nodePort\":31429,\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"2Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"serviceType\":\"NodePort\"},\"version\":\"nightly-54b5e8c\"}}\n version: nightly-54b5e8c\n
\u91cd\u88c5\u5347\u7ea7\uff0c\u610f\u5473\u7740 MatrixOne \u96c6\u7fa4\u88ab\u5168\u90e8\u5220\u9664\uff0c\u6570\u636e\u4f1a\u88ab\u820d\u5f03\uff0c\u5373\u91cd\u65b0\u8fdb\u884c\u5b89\u88c5\u3002
\u9002\u7528\u573a\u666f\uff1a
Note
\u64cd\u4f5c\u524d\uff0c\u8bf7\u52a1\u5fc5\u786e\u4fdd\u6570\u636e\u5df2\u5907\u4efd\uff08\u53c2\u89c1 mo-dump \u5907\u4efd\u5de5\u5177\uff09\uff0c\u4e14\u4e1a\u52a1\u5df2\u77e5\u6653\u6570\u636e\u5e93\u5df2\u505c\u6b62\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#_5","title":"\u64cd\u4f5c\u6b65\u9aa4","text":""},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#1","title":"1. \u5220\u9664\u65e7\u7248\u672c\u96c6\u7fa4","text":"\u5728 master0 \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4efb\u610f\u4e00\u79cd\u65b9\u5f0f\u5220\u9664\u65e7\u7248\u672c\u96c6\u7fa4\uff1a
# \u65b9\u5f0f1\uff1a\u901a\u8fc7\u90e8\u7f72\u65f6mo\u96c6\u7fa4\u7684yaml\u6587\u4ef6\u5220\u9664\uff0c\u4f8b\u5982\uff1a\nkubectl delete -f /root/deploy/mo.yaml\n# \u65b9\u5f0f2\uff1a\u901a\u8fc7\u5220\u9664matrixonecluster\u5bf9\u8c61\uff0c\u5176\u4e2dmo\u662f\u540d\u5b57\nkubectl delete matrixonecluster.core.matrixorigin.io mo -nmo-hn\n
\u901a\u8fc7\u67e5\u770b pod \u72b6\u6001\u786e\u8ba4 mo \u76f8\u5173\u8d44\u6e90\u662f\u5426\u5df2\u5220\u9664\uff1a
kubectl get pod -nmo-hn\n
\u53e6\u5916\uff0c\u5982\u679c\u8fd8\u6709 mo \u4f7f\u7528\u7684 pvc \u6ca1\u6709\u5220\u9664\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u624b\u52a8\u5220\u9664\uff1a
kubectl get pvc -nmo-hn\n# \u4f8b\u5982\uff0c\u8fd8\u6709log service\u4f7f\u7528\u7684pvc\u672a\u5220\u9664\uff0c\u624b\u52a8\u5220\u9664\nkubectl delete pvc mo-data-mo-log-0 -nmo-hn\nkubectl delete pvc mo-data-mo-log-1 -nmo-hn\nkubectl delete pvc mo-data-mo-log-2 -nmo-hn\n
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#2","title":"2. \u6e05\u7a7a\u6876\u6570\u636e","text":"\u5728 MinIO \u7ba1\u63a7\u9875\u9762\uff0c\u5220\u9664 MO \u4f7f\u7528\u7684 MinIO \u4f7f\u7528\u7684\u6876\u91cc\u9762\u7684\u6570\u636e\uff0c\u5305\u62ec mo-data\u3001etl \u7b49\u5b50\u76ee\u5f55\u3002
\u6216\u8005\u901a\u8fc7 MinIO \u5ba2\u6237\u7aef mc \u6765\u64cd\u4f5c\uff1a
mc rb --force minio/minio-mo/data/\nmc rb --force minio/minio-mo/etl\n
\u53e6\u5916\uff0c\u5982\u679c\u4e0d\u60f3\u5220\u9664\u65e7\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u65b0\u5efa\u4e00\u4e2a MinIO \u7684\u6876\uff0c\u7136\u540e\u5728\u90e8\u7f72 MatrixOne \u96c6\u7fa4\u7684 yaml \u6587\u4ef6\u6307\u5b9a\u65b0\u7684\u6876\u540d\u5373\u53ef\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#3","title":"3. \u90e8\u7f72\u65b0\u7248\u672c\u96c6\u7fa4","text":"\u7f16\u8f91\u5b9a\u4e49 MO \u96c6\u7fa4\u7684 yaml \u6587\u4ef6\uff0c\u53c2\u8003\u6eda\u52a8\u5347\u7ea7\u7ae0\u8282\uff0c\u4fee\u6539 .spec.version
\u5b57\u6bb5\u4e3a\u6700\u65b0\u7248\u672c\uff0c\u91cd\u65b0\u90e8\u7f72 MatrixOne \u96c6\u7fa4\uff1a
vi mo.yaml\n# \u5185\u5bb9\u7701\u7565\nkubectl apply -f mo.yaml\n
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#4","title":"4. \u68c0\u67e5\u5347\u7ea7\u662f\u5426\u6210\u529f","text":"\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5 MatrixOne \u662f\u5426\u6210\u529f\u542f\u52a8\u3002
\u5982\u4e0b\u9762\u4ee3\u7801\u793a\u4f8b\u6240\u793a\uff0c\u5f53 Log Service, TN, CN \u90fd\u6b63\u5e38\u8fd0\u884c\uff0c\u5219 MatrixOne \u96c6\u7fa4\u6210\u529f\u542f\u52a8\u3002\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7 MySQL Client \u8fde\u63a5\u68c0\u67e5\u6570\u636e\u5e93\u529f\u80fd\u662f\u5426\u6b63\u5e38\u3002
[root@master0 ~]# kubectl get pods -n mo-hn \nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-6c9c49fbd7-lw2h2 1/1 Running 2 (8h ago) 9h\nmo-tn-0 1/1 Running 0 2m13s\nmo-log-0 1/1 Running 0 2m47s\nmo-log-1 1/1 Running 0 2m47s\nmo-log-2 1/1 Running 0 2m47s\nmo-tp-cn-0 1/1 Running 0 111s\n
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/","title":"\u96c6\u7fa4\u90e8\u7f72\u6307\u5357","text":"\u672c\u7bc7\u6587\u6863\u5c06\u4e3b\u8981\u8bb2\u8ff0\u5982\u4f55\u5728\u5df2\u5b58\u5728 Kubernetes \u548c S3 \u73af\u5883\u7684\u57fa\u7840\u4e0a\u90e8\u7f72\u4e00\u4e2a MatrixOne \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_2","title":"\u8d44\u6e90\u9700\u6c42","text":""},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_3","title":"\u4f53\u9a8c\u73af\u5883","text":"MatrixOne \u96c6\u7fa4\u4f53\u9a8c\u73af\u5883\u53ef\u7528\u4e8e\u7b80\u5355\u4f53\u9a8c\u6d4b\u8bd5\u3001\u5b66\u4e60\u6216\u5f00\u53d1\uff0c\u4f46\u4e0d\u9002\u5408\u8fdb\u884c\u4e1a\u52a1\u751f\u4ea7\u3002\u4ee5\u4e0b\u4e3a\u4f53\u9a8c\u73af\u5883\u7684\u8d44\u6e90\u89c4\u5212\uff1a
\u5bb9\u5668\u8d44\u6e90\uff1a
\u7ec4\u4ef6 \u4f5c\u7528 \u670d\u52a1\u526f\u672c \u526f\u672c\u5206\u5e03\u7b56\u7565\u5efa\u8bae cpu(C) \u5185\u5b58 (G) \u5b58\u50a8\u8d44\u6e90\u7c7b\u578b \u5b58\u50a8\u5377\u683c\u5f0f \u5b58\u50a8\u5927\u5c0f (G) \u8bbf\u95ee\u6a21\u5f0f logservice \u9884\u5199\u65e5\u5fd7 WAL \u7ba1\u7406 3 3 \u4e2a\u8282\u70b9\uff0c\u6bcf\u8282\u70b9 1 \u526f\u672c 2 4 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce tn \u4e8b\u52a1\u7ba1\u7406 1 \u5355\u8282\u70b9\u5355\u526f\u672c 4 8 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce cn \u6570\u636e\u8ba1\u7b97 1 \u5355\u8282\u70b9\u5355\u526f\u672c 2 4 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce\u5bf9\u8c61\u5b58\u50a8\u8d44\u6e90 (S3)\uff1a
\u7ec4\u4ef6 \u63a5\u53e3\u534f\u8bae \u5b58\u50a8\u5927\u5c0f (G) \u4e1a\u52a1\u3001\u76d1\u63a7\u3001\u65e5\u5fd7\u7b49\u6570\u636e s3v4 >=50"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_4","title":"\u63a8\u8350\u73af\u5883","text":"MatrixOne \u96c6\u7fa4\u63a8\u8350\u73af\u5883\u5177\u5907\u9ad8\u53ef\u7528\u6027\u3001\u53ef\u9760\u6027\u548c\u5f3a\u5927\u7684\u6027\u80fd\uff0c\u53ef\u7528\u4e8e\u5b9e\u9645\u4e1a\u52a1\u751f\u4ea7\u3002\u4ee5\u4e0b\u4e3a\u63a8\u8350\u73af\u5883\u7684\u8d44\u6e90\u89c4\u5212\uff1a
\u5bb9\u5668\u8d44\u6e90\uff1a
\u7ec4\u4ef6 \u4f5c\u7528 \u670d\u52a1\u526f\u672c \u526f\u672c\u5206\u5e03\u7b56\u7565\u5efa\u8bae cpu(C) \u5185\u5b58 (G) \u5b58\u50a8\u8d44\u6e90\u7c7b\u578b \u5b58\u50a8\u5377\u683c\u5f0f \u5b58\u50a8\u5927\u5c0f (G) \u8bbf\u95ee\u6a21\u5f0f logservice \u9884\u5199\u65e5\u5fd7 WAL \u7ba1\u7406 3 3 \u4e2a\u8282\u70b9\uff0c\u6bcf\u8282\u70b9 1 \u526f\u672c 4 8 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce tn \u4e8b\u52a1\u7ba1\u7406 1 \u5355\u8282\u70b9\u5355\u526f\u672c 16 64 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce cn \u6570\u636e\u8ba1\u7b97 N N \u6839\u636e\u4e1a\u52a1\u9700\u6c42\u5b9a\uff0c\u9ad8\u53ef\u7528\u5efa\u8bae 2+ 16 32 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce\u5bf9\u8c61\u5b58\u50a8\u8d44\u6e90 (S3)\uff1a
\u7ec4\u4ef6 \u63a5\u53e3\u534f\u8bae \u5b58\u50a8\u5927\u5c0f (G) IOPS \u5e26\u5bbd \u4e1a\u52a1\u3001\u76d1\u63a7\u3001\u65e5\u5fd7\u7b49\u6570\u636e s3v4 \u6839\u636e\u4e1a\u52a1\u5b9a\uff0c\u5efa\u8bae>=500 \u987a\u5e8f\u8bfb\u5199\uff1a>=2000\uff0c\u975e\u987a\u5e8f\u8bfb\u5199\uff1a>=10000 >=10GB\u5982\u9700\u4e86\u89e3\u8d44\u6e90\u9700\u6c42\u7684\u66f4\u591a\u4fe1\u606f\u8bf7\u53c2\u8003\u96c6\u7fa4\u62d3\u6251\u89c4\u5212\u7ae0\u8282\u4e2d\u7684\u4f53\u9a8c\u73af\u5883\u548c\u63a8\u8350\u751f\u4ea7\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_5","title":"\u524d\u7f6e\u6761\u4ef6","text":"\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u7ecf\u51c6\u5907\u597d\u4ee5\u4e0b\u73af\u5883\uff1a
\u7b26\u5408\u8d44\u6e90\u9700\u6c42\u7684 Kubernetes \u96c6\u7fa4\u73af\u5883\u548c s3 \u73af\u5883
\u4e00\u53f0\u80fd\u8fde\u63a5 Kubernetes \u96c6\u7fa4\u7684\u5ba2\u6237\u7aef\u673a\u5668\u3002
\u5ba2\u6237\u7aef\u673a\u5668\u9700\u5b89\u88c5\u597d helm\u3001kubectl \u5ba2\u6237\u7aef\uff0c\u5e76\u914d\u7f6e\u8bbf\u95ee\u96c6\u7fa4\u7684 kubeconfig \u6587\u4ef6\uff0c\u6743\u9650\u662f\u80fd\u591f\u90e8\u7f72 helm chart \u5305\u548c\u5b89\u88c5 CRD \u8d44\u6e90\u5bf9\u8c61\u3002
\u5177\u5907\u5916\u7f51\u8bbf\u95ee\u6761\u4ef6\uff0c\u5982 github.io\u3001hub.docker.com \u7b49\uff1b\u5982\u679c\u65e0\u6cd5\u8bbf\u95ee\u5916\u7f51\uff0c\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a\u79c1\u6709\u955c\u50cf\u4ed3\u5e93\u7528\u4e8e\u4e0a\u4f20\u76f8\u5173\u955c\u50cf\uff0c\u5e76\u5728 mo \u96c6\u7fa4 yaml \u5b9a\u4e49\u4e2d\uff0c\u4fee\u6539\u955c\u50cf\u4ed3\u5e93\u5730\u5740\u4e3a\u79c1\u6709\u4ed3\u5e93\u5730\u5740\u3002
\u96c6\u7fa4\u8282\u70b9\u80fd\u8bbf\u95ee\u5230\u5bf9\u8c61\u5b58\u50a8\uff0c\u6bd4\u5982\u80fd\u89e3\u6790\u5bf9\u8c61\u5b58\u50a8\u6240\u5728\u57df\u540d\u3002
Note: \u4ee5\u4e0b\u64cd\u4f5c\u5982\u65e0\u8bf4\u660e\uff0c\u5747\u5728\u5ba2\u6237\u7aef\u673a\u5668\u6267\u884c\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#matrixone-operator","title":"\u90e8\u7f72 MatrixOne Operator","text":"MatrixOne Operator \u662f\u4e00\u4e2a\u5728 Kubernetes \u4e0a\u90e8\u7f72\u548c\u7ba1\u7406 MatrixOne \u96c6\u7fa4\u7684\u72ec\u7acb\u8f6f\u4ef6\u5de5\u5177\uff0c\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b\uff1a
\u4e3a Operator \u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684\u547d\u540d\u7a7a\u95f4 mo-op
NS=\"mo-op\"\nkubectl create ns \"${NS}\"\nkubectl get ns # \u8fd4\u56de\u6709 mo-op\n
\u4e0b\u8f7d\u5e76\u89e3\u538b matrixone-operator \u5b89\u88c5\u5305
wget https://github.com/matrixorigin/matrixone-operator/releases/download/chart-1.1.0-alpha2/matrixone-operator-1.1.0-alpha2.tgz\ntar xvf matrixone-operator-1.1.0-alpha2.tgz\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone-operator/releases/download/chart-1.1.0-alpha2/matrixone-operator-1.1.0-alpha2.tgz\n
\u89e3\u538b\u540e\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u751f\u4ea7\u6587\u4ef6\u5939 matrixone-operator
\u3002
\u90e8\u7f72 matrixone-operator
NS=\"mo-op\"\ncd matrixone-operator/\nhelm install -n ${NS} mo-op ./ --dependency-update # \u6210\u529f\u5e94\u8fd4\u56de deployed \u7684\u72b6\u6001\n
\u4e0a\u8ff0\u4f9d\u8d56\u7684 docker \u955c\u50cf\u6e05\u5355\u4e3a\uff1a
\u8be6\u60c5\u53ef\u67e5\u770b matrixone-operator/values.yaml\u3002
\u68c0\u67e5 operator \u90e8\u7f72\u72b6\u6001
NS=\"mo-op\"\nhelm list -n \"${NS}\" # \u8fd4\u56de\u6709\u5bf9\u5e94\u7684 helm chart \u5305\uff0c\u90e8\u7f72\u72b6\u6001\u4e3a deployed\nkubectl get pod -n \"${NS}\" -owide # \u8fd4\u56de\u6709\u4e00\u4e2a pod \u526f\u672c\uff0c\u72b6\u6001\u4e3a Running\n
\u5982\u9700\u4e86\u89e3\u6709\u5173 Matrixone Operator \u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b Operator \u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#matrixone","title":"\u90e8\u7f72 MatrixOne","text":"\u672c\u8282\u4ecb\u7ecd\u4e86 YAML \u548c Chart \u4e24\u79cd\u90e8\u7f72 MatrixOne \u7684\u65b9\u5f0f\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_6","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u521b\u5efa MatrixOne \u7684\u547d\u540d\u7a7a\u95f4 mo
\uff1a
NS=\"mo\"\nkubectl create ns \"${NS}\"\nkubectl get ns # \u8fd4\u56de\u6709 mo\n
Note
\u5efa\u8bae\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0e MatrixOne Operator \u7684\u547d\u540d\u7a7a\u95f4\u5206\u5f00\uff0c\u4e0d\u8981\u4f7f\u7528\u540c\u4e00\u4e2a\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5728\u547d\u540d\u7a7a\u95f4 mo \u4e2d\u521b\u5efa\u7528\u4e8e\u8bbf\u95ee s3 \u7684 Secret \u670d\u52a1\uff1a
S3 \u5982\u679c\u901a\u8fc7 HTTP \u534f\u8bae\u8bbf\u95ee\uff0c\u4e0d\u9700\u8981\u63d0\u4f9b CA \u8bc1\u4e66
NS=\"mo\"\nname=\"s3mo\"\n\nkubectl -n \"${NS}\" create secret generic \"${name}\" --from-literal=AWS_ACCESS_KEY_ID=51e1bHqcbfKla0fuakAtoJ2LMEvKThg4NiMjxxxx --from-literal=AWS_SECRET_ACCESS_KEY=aDMWw1hO2rqxltyIcBN6sy8qE_leIgzo6Satxxxx\n#\u6839\u636e\u5b9e\u9645\u4fee\u6539\nkubectl get secret -n \"${NS}\" \"${name}\" -oyaml # \u6b63\u5e38\u8f93\u51fa\u5bc6\u94a5\u4fe1\u606f\n
S3 \u901a\u8fc7 HTTPS \u534f\u8bae\u8bbf\u95ee\u5219\u9700\u8981\u63d0\u4f9b CA \u8bc1\u4e66\uff0c\u5e76\u4e14\u5728\u5f00\u59cb\u524d\u8981\u5148\u6267\u884c\u76f8\u5173\u64cd\u4f5c\u548c\u914d\u7f6e\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u6b65\u9aa4\u5982\u4e0b\uff1a
NS=mo\nca_file_path=\"/data/deploy/csp_cert/ca.crt\" # \u8bc1\u4e66\u5728\u5bc6\u94a5\u4e2d\u5b9a\u4e49\u7684\u6587\u4ef6\u8def\u5f84\nca_file_name=\"csp.cert\" # \u8bc1\u4e66\u5728\u5bc6\u94a5\u4e2d\u5b9a\u4e49\u7684\u6587\u4ef6\u540d\u79f0\nca_secret_name=\"csp.cert\" # \u8bc1\u4e66\u5bc6\u94a5\u672c\u8eab\u7684\u540d\u79f0\n# \u521b\u5efa\u5bc6\u94a5\nkubectl -n ${ns} create secret generic ${ca_secret_name} --from-file=${ca_file_name}=${ca_file_path}\n
sharedStorage:\n s3:\n endpoint: xx.yy.com\n path: mypath\n # secretRef is required when there is no environment based auth available.\n secretRef:\n # secretRef.name \u5bf9\u5e94 ca_secret_name\n name: csp\n certificateRef:\n # certificateRef.name \u5bf9\u5e94${ca_file_name}\n name: csp.cert\n files:\n # certificateRef.files \u6570\u7ec4\u4e0b\u9762\u7684\u503c\u5bf9\u5e94${ca_file_path}\n - csp.cert\n
\u7ed9\u673a\u5668\u6dfb\u52a0\u6807\u7b7e
\u4ee5\u4e0b\u6807\u7b7e\u662f\u90e8\u7f72\u524d\u9700\u8981\u6253\u5230\u8282\u70b9\u4e0a\u7684\uff0c\u5426\u5219\u4f1a\u8c03\u5ea6\u5931\u8d25\u3002\u4e0b\u8ff0\u6807\u7b7e\u539f\u5219\u4e0a\u5efa\u8bae\u662f\u627e\u4e0d\u540c\u7684\u8282\u70b9\u6253\uff0c\u4e14\u6839\u636e\u526f\u672c\u9700\u8981\u6253\u591a\u4e2a\u8282\u70b9\uff0c\u5982\u65e0\u6cd5\u6ee1\u8db3\u4e5f\u81f3\u5c11\u9700\u8981\u628a\u4e0b\u8ff0\u6807\u7b7e\u6253\u5230 1 \u4e2a\u8282\u70b9\u4e0a\u3002\uff08\u5efa\u8bae 7 \u4e2a\u4e0d\u540c\u8282\u70b9\uff09
matrixone/cn: true\nmatrixone/tn: true\nmatrixone/lg: true\n
\u7b2c\u4e00\u7ec4\uff1a\u627e\u4e09\u53f0\u4e0d\u540c\u7684\u673a\u5668\uff0c\u5206\u522b\u6253\u4e0a cn \u7684\u6807\u7b7e\u3002
NODE_1=\"10.0.0.1\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_2=\"10.0.0.2\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_3=\"10.0.0.3\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\n\nkubectl label node ${NODE_1} matrixone/cn: true\nkubectl label node ${NODE_2} matrixone/cn: true\nkubectl label node ${NODE_3} matrixone/cn: true\n
\u7b2c\u4e8c\u7ec4\uff1a\u627e\u7b2c 4 \u53f0\u4e0d\u540c\u7684\u673a\u5668\uff0c\u5206\u522b\u6253\u4e0a tn \u7684\u6807\u7b7e\u3002
NODE_4=\"10.0.0.4\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\n\nkubectl label node ${NODE_4} matrixone/tn: true\n
\u7b2c\u4e09\u7ec4\uff1a\u627e\u4e09\u53f0\u4e0d\u540c\u7684\u673a\u5668\uff0c\u5206\u522b\u6253\u4e0a log \u7684\u6807\u7b7e\u3002
NODE_5=\"10.0.0.5\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_6=\"10.0.0.6\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_7=\"10.0.0.7\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\n\nkubectl label node ${NODE_5} matrixone/lg: true\nkubectl label node ${NODE_6} matrixone/lg: true\nkubectl label node ${NODE_7} matrixone/lg: true\n
\u81ea\u5b9a\u4e49 MatrixOne \u96c6\u7fa4\u7684 yaml \u6587\u4ef6\uff0c\u7f16\u5199\u5982\u4e0b mo.yaml \u7684\u6587\u4ef6\uff08\u6309\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u8d44\u6e90\u8bf7\u6c42\uff09\uff1a
apiVersion: core.matrixorigin.io/v1alpha1\nkind: MatrixOneCluster\nmetadata:\n name: mo\n namespace: mo\n\nspec:\n # 1. \u914d\u7f6e cn\n cnGroups:\n - cacheVolume:\n size: 800Gi\n config: |2\n [log]\n level = \"info\"\n name: cng1\n nodeSelector:# \u6dfb\u52a0\u6807\u7b7e\uff0c\u6839\u636e\u5b9e\u9645\u6dfb\u52a0\n matrixone/cn: \"true\"\n serviceType: NodePort\n nodePort: 31429\n replicas: 3\n resources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\n overlay:\n env:\n - name: GOMEMLIMIT\n value: \"57600MiB\" \n # 2. \u914d\u7f6e tn\n tn:\n cacheVolume:\n size: 100Gi\n config: |2\n\n [log]\n level = \"info\"\n nodeSelector:\n matrixone/tn: \"true\"\n replicas: 1\n resources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\n # 3. \u914d\u7f6e logservice\n logService:\n config: |2\n [log]\n level = \"info\"\n nodeSelector: \n matrixone/lg: \"true\"\n pvcRetentionPolicy: Retain\n replicas: 3\n # \u914d\u7f6e logservice \u5bf9\u63a5\u7684 s3 \u5b58\u50a8\n sharedStorage:\n s3:\n endpoint: s3-qos.iot.qiniuec-test.com \n path: mo-test\n s3RetentionPolicy: Retain\n secretRef: #\u914d\u7f6e\u8bbf\u95ee s3 \u7684\u5bc6\u94a5\u5373 secret\uff0c\u540d\u79f0\u4e3a s3mo\n name: s3mo\n volume:\n size: 100Gi \n resources:\n requests:\n cpu: 4000m\n memory: 16000Mi\n limits:\n cpu: 4000m\n memory: 16000Mi\n topologySpread:\n - kubernetes.io/hostname\n imagePullPolicy: IfNotPresent\n imageRepository: registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone\n version: 1.1.1 #\u6b64\u5904\u4e3a MO \u955c\u50cf\u7684\u7248\u672c\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u521b\u5efa MatrixOne \u96c6\u7fa4
kubectl apply -f ./mo.yaml\n
\u5411 helm \u6dfb\u52a0\u4e00\u4e2a matrixone-operator \u4ed3\u5e93
helm repo add matrixone-operator https://matrixorigin.github.io/matrixone-operator\n
\u66f4\u65b0\u4ed3\u5e93
helm repo update\n
\u67e5\u770b MatrixOne Chart \u7248\u672c
helm search repo matrixone-operator/matrixone --devel\n
\u793a\u4f8b\u8fd4\u56de
> helm search repo matrixone-operator/matrixone --devel\nNAME CHART VERSION APP VERSION DESCRIPTION\nmatrixone-operator/matrixone 0.1.0 1.16.0 A Helm chart to deploy MatrixOne on K8S\nmatrixone-operator/matrixone-operator 1.1.0-alpha2 0.1.0 Matrixone Kubernetes Operator\nhelm search repo matrixone-operator/matrixone --devel\n
\u90e8\u7f72 MatrixOne
\u4fee\u6539 values.yaml \u6587\u4ef6\uff0c\u6e05\u7a7a\u539f\u6587\u4ef6\uff0c\u66ff\u6362\u4e3a\u4ee5\u4e0b\u5185\u5bb9\uff08\u6309\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u8d44\u6e90\u8bf7\u6c42\uff09\uff1a
# 1. \u914d\u7f6e cn\ncnGroups:\n- cacheVolume:\n size: 800Gi\nconfig: |2\n [log]\n level = \"info\"\nname: cng1\nnodeSelector:\n matrixone/cn: \"true\"\nserviceType: NodePort\nnodePort: 31429\nreplicas: 3 # cn \u7684\u526f\u672c\u6570\nresources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\noverlay:\n env:\n - name: GOMEMLIMIT\n value: \"57600MiB\" \n# 2. \u914d\u7f6e tn\ntn:\ncacheVolume:\n size: 100Gi\nconfig: |2\n\n [log]\n level = \"info\"\nnodeSelector:\n matrixone/tn: \"true\"\nreplicas: 1 # tn \u7684\u526f\u672c\u6570\uff0c\u4e0d\u53ef\u4fee\u6539\u3002\u5f53\u524d\u7248\u672c\u4ec5\u652f\u6301\u8bbe\u7f6e\u4e3a 1\u3002\nresources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\n# 3. \u914d\u7f6e logService\nlogService:\nconfig: |2\n [log]\n level = \"info\"\nnodeSelector: \n matrixone/lg: \"true\"\npvcRetentionPolicy: Retain\nreplicas: 3 # logService \u7684\u526f\u672c\u6570\n#\u914d\u7f6e logService \u5bf9\u63a5\u7684 s3 \u5b58\u50a8\nsharedStorage:\n s3:\n endpoint: s3-qos.iot.qiniuec-test.com \n path: mo-test\n s3RetentionPolicy: Retain\n secretRef: #\u914d\u7f6e\u8bbf\u95ee s3 \u7684\u5bc6\u94a5\u5373 secret\uff0c\u540d\u79f0\u4e3a s3mo\n name: s3mo\nvolume:\n size: 100Gi\nresources:\n requests:\n cpu: 4000m\n memory: 16000Mi\n limits:\n cpu: 4000m\n memory: 16000Mi\ntopologySpread:\n- kubernetes.io/hostname\nimagePullPolicy: IfNotPresent\nimageRepository: registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone\nversion: 1.1.1 #\u6b64\u5904\u4e3a MO \u955c\u50cf\u7684\u7248\u672c\n
\u5b89\u88c5 MatrixOne Chart\uff08\u8fd9\u4f1a\u90e8\u7f72\u4e00\u4e2a MatrixOneCluster \u5bf9\u8c61\uff09
NS=\"mo\"\nRELEASE_NAME=\"mo_chart\"\nVERSION=v1\nhelm install -n ${NS} ${RELEASE_NAME} matrixone-operator/matrixone --version ${VERSION} -f values.yaml\n
\u89c2\u5bdf\u96c6\u7fa4\u72b6\u6001\uff0c\u76f4\u81f3 Ready
NS=\"mo\"\nkubectl get mo -n \"${NS}\" # \u7b49\u5f85\u72b6\u6001\u4e3a Ready\n
\u89c2\u5bdf pod \u72b6\u6001\uff0c\u76f4\u81f3\u6240\u6709\u4e3a Running
NS=\"mo\"\nkubectl get pod -n \"${NS}\" -owide # \u7b49\u5f85\u72b6\u6001\u4e3a Running\n
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#matrixone_1","title":"\u8fde\u63a5 MatrixOne \u96c6\u7fa4","text":"\u4e3a\u4e86\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u60a8\u9700\u8981\u5c06\u5bf9\u5e94\u670d\u52a1\u7684\u7aef\u53e3\u6620\u5c04\u5230 MatrixOne \u8282\u70b9\u4e0a\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 kubectl port-forward
\u8fde\u63a5 MatrixOne \u96c6\u7fa4\u7684\u6307\u5bfc\uff1a
nohup kubectl port-forward -nmo svc/svc_name 6001:6001 &\n
nohup kubectl port-forward -nmo --address 0.0.0.0 svc/svc_name 6001:6001 &\n
\u5728\u6307\u5b9a\u5141\u8bb8\u672c\u5730\u8bbf\u95ee\u6216\u6307\u5b9a\u67d0\u53f0\u673a\u5668\u6216\u8005\u6240\u6709\u673a\u5668\u8bbf\u95ee\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff1a
# \u4f7f\u7528 'mysql' \u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230MySQL\u670d\u52a1\n# \u4f7f\u7528 'kubectl get svc/svc_name -n mo -o jsonpath='{.spec.clusterIP}' ' \u83b7\u53d6Kubernetes\u96c6\u7fa4\u4e2d\u670d\u52a1\u7684\u96c6\u7fa4IP\u5730\u5740\n# '-h' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u4e3b\u673a\u540d\u6216IP\u5730\u5740\n# '-P' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u7aef\u53e3\u53f7\uff0c\u8fd9\u91cc\u662f6001\n# '-uroot' \u8868\u793a\u7528root\u7528\u6237\u767b\u5f55\n# '-p111' \u8868\u793a\u521d\u59cb\u5bc6\u7801\u662f111\nmysql -h $(kubectl get svc/svc_name -n mo -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 163\nServer version: 8.0.30-MatrixOne-v1.1.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
\u663e\u5f0f mysql>
\u540e\uff0c\u5206\u5e03\u5f0f\u7684 MatrixOne \u96c6\u7fa4\u642d\u5efa\u8fde\u63a5\u5b8c\u6210\u3002
Info
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/","title":"\u96c6\u7fa4\u90e8\u7f72\u6307\u5357","text":"\u672c\u7bc7\u6587\u6863\u5c06\u4e3b\u8981\u8bb2\u8ff0\u5982\u4f55\u4ece 0 \u5f00\u59cb\u90e8\u7f72\u4e00\u4e2a\u57fa\u4e8e\u79c1\u6709\u5316 Kubernetes \u96c6\u7fa4\u7684\u4e91\u539f\u751f\u5b58\u7b97\u5206\u79bb\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93 MatrixOne\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_2","title":"\u4e3b\u8981\u6b65\u9aa4","text":"\u7531\u4e8e\u8be5\u6587\u6863\u4f1a\u6d89\u53ca\u5230\u4f17\u591a Kubernetes \u76f8\u5173\u7684\u540d\u8bcd\uff0c\u4e3a\u4e86\u8ba9\u5927\u5bb6\u80fd\u591f\u7406\u89e3\u642d\u5efa\u6d41\u7a0b\uff0c\u8fd9\u91cc\u5bf9\u6d89\u53ca\u5230\u7684\u91cd\u8981\u540d\u8bcd\u8fdb\u884c\u7b80\u5355\u89e3\u91ca\uff0c\u5982\u679c\u9700\u8981\u8be6\u7ec6\u4e86\u89e3 Kubernetes \u76f8\u5173\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u76f4\u63a5\u53c2\u8003 Kubernetes \u4e2d\u6587\u793e\u533a | \u4e2d\u6587\u6587\u6863
Pod \u662f Kubernetes \u4e2d\u6700\u5c0f\u7684\u8d44\u6e90\u7ba1\u7406\u7ec4\u4ef6\uff0cPod \u4e5f\u662f\u6700\u5c0f\u5316\u8fd0\u884c\u5bb9\u5668\u5316\u5e94\u7528\u7684\u8d44\u6e90\u5bf9\u8c61\u3002\u4e00\u4e2a Pod \u4ee3\u8868\u7740\u96c6\u7fa4\u4e2d\u8fd0\u884c\u7684\u4e00\u4e2a\u8fdb\u7a0b\u3002\u7b80\u5355\u7406\u89e3\uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u4e00\u7ec4\u63d0\u4f9b\u7279\u5b9a\u529f\u80fd\u7684\u5e94\u7528\u79f0\u4e3a\u4e00\u4e2a pod\uff0c\u5b83\u4f1a\u5305\u542b\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5bb9\u5668\u5bf9\u8c61\uff0c\u5171\u540c\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002
Storage Class\uff0c\u7b80\u79f0 SC\uff0c\u7528\u4e8e\u6807\u8bb0\u5b58\u50a8\u8d44\u6e90\u7684\u7279\u6027\u548c\u6027\u80fd\uff0c\u7ba1\u7406\u5458\u53ef\u4ee5\u5c06\u5b58\u50a8\u8d44\u6e90\u5b9a\u4e49\u4e3a\u67d0\u79cd\u7c7b\u522b\uff0c\u6b63\u5982\u5b58\u50a8\u8bbe\u5907\u5bf9\u4e8e\u81ea\u8eab\u7684\u914d\u7f6e\u63cf\u8ff0\uff08Profile\uff09\u3002\u6839\u636e SC \u7684\u63cf\u8ff0\u53ef\u4ee5\u76f4\u89c2\u7684\u5f97\u77e5\u5404\u79cd\u5b58\u50a8\u8d44\u6e90\u7684\u7279\u6027\uff0c\u5c31\u53ef\u4ee5\u6839\u636e\u5e94\u7528\u5bf9\u5b58\u50a8\u8d44\u6e90\u7684\u9700\u6c42\u53bb\u7533\u8bf7\u5b58\u50a8\u8d44\u6e90\u4e86\u3002
Kubernetes \u63d0\u4f9b\u4e86 CSI \u63a5\u53e3\uff08Container Storage Interface\uff0c\u5bb9\u5668\u5b58\u50a8\u63a5\u53e3\uff09\uff0c\u57fa\u4e8e CSI \u8fd9\u5957\u63a5\u53e3\uff0c\u53ef\u4ee5\u5f00\u53d1\u5b9a\u5236\u51fa CSI \u63d2\u4ef6\uff0c\u4ece\u800c\u652f\u6301\u7279\u5b9a\u7684\u5b58\u50a8\uff0c\u8fbe\u5230\u89e3\u8026\u7684\u76ee\u7684\u3002
PersistentVolume\uff0c\u7b80\u79f0 PV\uff0cPV \u4f5c\u4e3a\u5b58\u50a8\u8d44\u6e90\uff0c\u4e3b\u8981\u5305\u62ec\u5b58\u50a8\u80fd\u529b\u3001\u8bbf\u95ee\u6a21\u5f0f\u3001\u5b58\u50a8\u7c7b\u578b\u3001\u56de\u6536\u7b56\u7565\u3001\u540e\u7aef\u5b58\u50a8\u7c7b\u578b\u7b49\u5173\u952e\u4fe1\u606f\u7684\u8bbe\u7f6e\u3002
PersistentVolumeClaim\uff0c\u7b80\u79f0 PVC\uff0c\u4f5c\u4e3a\u7528\u6237\u5bf9\u5b58\u50a8\u8d44\u6e90\u7684\u9700\u6c42\u7533\u8bf7\uff0c\u4e3b\u8981\u5305\u62ec\u5b58\u50a8\u7a7a\u95f4\u8bf7\u6c42\u3001\u8bbf\u95ee\u6a21\u5f0f\u3001PV \u9009\u62e9\u6761\u4ef6\u548c\u5b58\u50a8\u7c7b\u522b\u7b49\u4fe1\u606f\u7684\u8bbe\u7f6e\u3002
\u4e5f\u53eb\u505a SVC\uff0c\u901a\u8fc7\u6807\u7b7e\u9009\u62e9\u7684\u65b9\u5f0f\u5339\u914d\u4e00\u7ec4 Pod \u5bf9\u5916\u8bbf\u95ee\u670d\u52a1\u7684\u4e00\u79cd\u673a\u5236\uff0c\u6bcf\u4e00\u4e2a svc \u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u4e2a\u5fae\u670d\u52a1\u3002
Kubernetes Operator \u662f\u4e00\u79cd\u5c01\u88c5\u3001\u90e8\u7f72\u548c\u7ba1\u7406 Kubernetes \u5e94\u7528\u7684\u65b9\u6cd5\u3002\u6211\u4eec\u4f7f\u7528 Kubernetes API\uff08\u5e94\u7528\u7f16\u7a0b\u63a5\u53e3\uff09\u548c kubectl \u5de5\u5177\u5728 Kubernetes \u4e0a\u90e8\u7f72\u5e76\u7ba1\u7406 Kubernetes \u5e94\u7528\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_4","title":"\u90e8\u7f72\u67b6\u6784","text":""},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_5","title":"\u4f9d\u8d56\u7ec4\u4ef6","text":"MatrixOne \u5206\u5e03\u5f0f\u7cfb\u7edf\u4f9d\u8d56\u4e8e\u4ee5\u4e0b\u7ec4\u4ef6\uff1a
Kubernetes\uff1a\u4f5c\u4e3a\u6574\u4e2a MatrixOne \u96c6\u7fa4\u7684\u8d44\u6e90\u7ba1\u7406\u5e73\u53f0\uff0c\u5305\u62ec Logservice\u3001CN\u3001TN \u7b49\u7ec4\u4ef6\uff0c\u90fd\u5728\u7531 Kubernetes \u7ba1\u7406\u7684 Pod \u4e2d\u8fd0\u884c\u3002\u5982\u679c\u53d1\u751f\u6545\u969c\uff0cKubernetes \u5c06\u8d1f\u8d23\u5254\u9664\u6545\u969c\u7684 Pod \u5e76\u542f\u52a8\u65b0\u7684 Pod \u8fdb\u884c\u66ff\u6362\u3002
Minio\uff1a\u4e3a\u6574\u4e2a MatrixOne \u96c6\u7fa4\u63d0\u4f9b\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff0cMatrixOne \u7684\u6240\u6709\u6570\u636e\u5b58\u50a8\u5728\u7531 Minio \u63d0\u4f9b\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002
\u6b64\u5916\uff0c\u4e3a\u4e86\u5728 Kubernetes \u4e0a\u8fdb\u884c\u5bb9\u5668\u7ba1\u7406\u548c\u7f16\u6392\uff0c\u6211\u4eec\u9700\u8981\u4ee5\u4e0b\u63d2\u4ef6\uff1a
Helm\uff1aHelm \u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406 Kubernetes \u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u7c7b\u4f3c\u4e8e Ubuntu \u7684 APT \u548c CentOS \u7684 YUM\u3002\u5b83\u7528\u4e8e\u7ba1\u7406\u9884\u5148\u914d\u7f6e\u7684\u5b89\u88c5\u5305\u8d44\u6e90\uff0c\u79f0\u4e3a Chart\u3002
local-path-provisioner\uff1a\u4f5c\u4e3a Kubernetes \u4e2d\u5b9e\u73b0\u4e86 CSI\uff08Container Storage Interface\uff09\u63a5\u53e3\u7684\u63d2\u4ef6\uff0clocal-path-provisioner \u8d1f\u8d23\u4e3a MatrixOne \u5404\u7ec4\u4ef6\u7684 Pod \u548c Minio \u521b\u5efa\u6301\u4e45\u5316\u5377\uff08PV\uff09\uff0c\u4ee5\u4fbf\u5b9e\u73b0\u6570\u636e\u7684\u6301\u4e45\u5316\u5b58\u50a8\u3002
\u6574\u4f53\u7684\u90e8\u7f72\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6574\u4f53\u67b6\u6784\u7531\u4ee5\u4e0b\u7ec4\u4ef6\u7ec4\u6210\uff1a
\u5e95\u5c42\u662f\u4e09\u4e2a\u670d\u52a1\u5668\u8282\u70b9\uff1a\u7b2c\u4e00\u53f0\u4f5c\u4e3a\u5b89\u88c5 Kubernetes \u8df3\u677f\u673a\u7684 host1\uff0c\u7b2c\u4e8c\u53f0\u662f Kubernetes \u7684\u4e3b\u8282\u70b9\uff08master\uff09\uff0c\u7b2c\u4e09\u53f0\u662f Kubernetes \u7684\u5de5\u4f5c\u8282\u70b9\uff08node\uff09\u3002
\u4e0a\u5c42\u662f\u5df2\u5b89\u88c5\u7684 Kubernetes \u548c Docker \u73af\u5883\uff0c\u6784\u6210\u4e91\u539f\u751f\u5e73\u53f0\u5c42\u3002
\u57fa\u4e8e Helm \u8fdb\u884c\u7ba1\u7406\u7684 Kubernetes \u63d2\u4ef6\u5c42\uff0c\u5305\u62ec\u5b9e\u73b0 CSI \u63a5\u53e3\u7684 local-path-storage \u63d2\u4ef6\u3001Minio \u548c MatrixOne Operator\u3002
\u6700\u9876\u5c42\u662f\u7531\u8fd9\u4e9b\u7ec4\u4ef6\u914d\u7f6e\u751f\u6210\u7684\u591a\u4e2a Pod \u548c Service\u3002
MatrixOne \u6839\u636e Operator \u7684\u89c4\u5219\u521b\u5efa\u4e00\u7cfb\u5217\u7684 Kubernetes \u5bf9\u8c61\uff0c\u8fd9\u4e9b\u5bf9\u8c61\u6839\u636e\u7ec4\u4ef6\u5206\u7c7b\u5e76\u5f52\u7c7b\u5230\u8d44\u6e90\u7ec4\u4e2d\uff0c\u5206\u522b\u4e3a CNSet\u3001TNSet \u548c LogSet\u3002
Service\uff1a\u6bcf\u4e2a\u8d44\u6e90\u7ec4\u4e2d\u7684\u670d\u52a1\u9700\u8981\u901a\u8fc7 Service \u8fdb\u884c\u5bf9\u5916\u63d0\u4f9b\u3002Service \u627f\u8f7d\u4e86\u5bf9\u5916\u8fde\u63a5\u7684\u529f\u80fd\uff0c\u786e\u4fdd\u5728 Pod \u5d29\u6e83\u6216\u88ab\u66ff\u6362\u65f6\u4ecd\u80fd\u63d0\u4f9b\u670d\u52a1\u3002\u5916\u90e8\u5e94\u7528\u7a0b\u5e8f\u901a\u8fc7 Service \u7684\u516c\u5f00\u7aef\u53e3\u8fde\u63a5\uff0c\u800c Service \u5219\u901a\u8fc7\u5185\u90e8\u8f6c\u53d1\u89c4\u5219\u5c06\u8fde\u63a5\u8f6c\u53d1\u5230\u76f8\u5e94\u7684 Pod\u3002
Pod\uff1aMatrixOne \u7ec4\u4ef6\u7684\u5bb9\u5668\u5316\u5b9e\u4f8b\uff0c\u5176\u4e2d\u8fd0\u884c\u7740 MatrixOne \u7684\u6838\u5fc3\u5185\u6838\u4ee3\u7801\u3002
PVC\uff1a\u6bcf\u4e2a Pod \u90fd\u901a\u8fc7 PVC\uff08Persistent Volume Claim\uff09\u58f0\u660e\u81ea\u5df1\u6240\u9700\u7684\u5b58\u50a8\u8d44\u6e90\u3002\u5728\u6211\u4eec\u7684\u67b6\u6784\u4e2d\uff0cCN \u548c TN \u9700\u8981\u7533\u8bf7\u4e00\u5757\u5b58\u50a8\u8d44\u6e90\u4f5c\u4e3a\u7f13\u5b58\uff0c\u800c LogService \u5219\u9700\u8981\u76f8\u5e94\u7684 S3 \u8d44\u6e90\u3002\u8fd9\u4e9b\u9700\u6c42\u901a\u8fc7 PVC \u8fdb\u884c\u58f0\u660e\u3002
PV\uff1aPV\uff08Persistent Volume\uff09\u662f\u5b58\u50a8\u4ecb\u8d28\u7684\u62bd\u8c61\u8868\u793a\uff0c\u53ef\u4ee5\u770b\u4f5c\u662f\u5b58\u50a8\u5355\u5143\u3002\u5728 PVC \u7684\u7533\u8bf7\u540e\uff0c\u901a\u8fc7\u5b9e\u73b0 CSI \u63a5\u53e3\u7684\u8f6f\u4ef6\u521b\u5efa PV\uff0c\u5e76\u5c06\u5176\u4e0e\u7533\u8bf7\u8d44\u6e90\u7684 PVC \u8fdb\u884c\u7ed1\u5b9a\u3002
\u7531\u4e8e MatrixOne \u7684\u5206\u5e03\u5f0f\u90e8\u7f72\u4f9d\u8d56\u4e8e Kubernetes \u96c6\u7fa4\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4e00\u4e2a Kubernetes \u96c6\u7fa4\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u4f7f\u7528 Kuboard-Spray \u7684\u65b9\u5f0f\u642d\u5efa\u4e00\u4e2a Kubernetes \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_7","title":"\u51c6\u5907\u96c6\u7fa4\u73af\u5883","text":"\u5bf9\u4e8e\u96c6\u7fa4\u73af\u5883\uff0c\u9700\u8981\u505a\u5982\u4e0b\u51c6\u5907\uff1a
\u5404\u4e2a\u673a\u5668\u60c5\u51b5\u5206\u5e03\u5177\u4f53\u5982\u4e0b\u6240\u793a\uff1a
Host \u5185\u7f51 IP \u5916\u7f51 IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kuboard-spray","title":"\u8df3\u677f\u673a\u90e8\u7f72 Kuboard Spray","text":"Kuboard-Spray \u662f\u7528\u6765\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u7684\u4e00\u4e2a\u5de5\u5177\u3002\u5b83\u4f1a\u4f7f\u7528 Docker \u5feb\u901f\u62c9\u8d77\u4e00\u4e2a\u80fd\u591f\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u7684 Web \u5e94\u7528\u3002Kubernetes \u96c6\u7fa4\u73af\u5883\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5c06\u8be5 Docker \u5e94\u7528\u505c\u6389\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_8","title":"\u8df3\u677f\u673a\u73af\u5883\u51c6\u5907","text":"\u5b89\u88c5 Docker\uff1a\u7531\u4e8e\u4f1a\u4f7f\u7528\u5230 Docker\uff0c\u56e0\u6b64\u9700\u8981\u5177\u5907 Docker \u7684\u73af\u5883\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u8df3\u677f\u673a\u5b89\u88c5\u5e76\u542f\u52a8 Docker\uff1a
curl -sSL https://get.docker.io/ | sh\n#\u5982\u679c\u5728\u56fd\u5185\u7684\u7f51\u7edc\u53d7\u9650\u73af\u5883\u4e0b\uff0c\u53ef\u4ee5\u6362\u4ee5\u4e0b\u56fd\u5185\u955c\u50cf\u5730\u5740\ncurl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun\n
\u542f\u52a8 Docker\uff1a
[root@VM-0-6-centos ~]# systemctl start docker\n[root@VM-0-6-centos ~]# systemctl status docker\n\u25cf docker.service - Docker Application Container Engine\n Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n Active: active (running) since Sun 2023-05-07 11:48:06 CST; 15s ago\n Docs: https://docs.docker.com\n Main PID: 5845 (dockerd)\n Tasks: 8\n Memory: 27.8M\n CGroup: /system.slice/docker.service\n \u2514\u25005845 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock\n\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Starting Docker Application Container Engine...\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.391166236+08:00\" level=info msg=\"Starting up\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.421736631+08:00\" level=info msg=\"Loading containers: start.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.531022702+08:00\" level=info msg=\"Loading containers: done.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544715135+08:00\" level=info msg=\"Docker daemon\" commit=94d3ad6 graphdriver=overlay2 version=23.0.5\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544798391+08:00\" level=info msg=\"Daemon has completed initialization\"\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Started Docker Application Container Engine.\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.569274215+08:00\" level=info msg=\"API listen on /run/docker.sock\"\n
\u73af\u5883\u51c6\u5907\u5b8c\u6210\u540e\uff0c\u5373\u53ef\u90e8\u7f72 Kuboard-Spray\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kuboard-spray_1","title":"\u90e8\u7f72 Kuboard-Spray","text":"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Kuboard-Spray\uff1a
docker run -d \\\n --privileged \\\n --restart=unless-stopped \\\n --name=kuboard-spray \\\n -p 80:80/tcp \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n -v ~/kuboard-spray-data:/data \\\n eipwork/kuboard-spray:latest-amd64\n
\u5982\u679c\u7531\u4e8e\u7f51\u7edc\u95ee\u9898\u5bfc\u81f4\u955c\u50cf\u62c9\u53d6\u5931\u8d25\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u5907\u7528\u5730\u5740\uff1a
docker run -d \\\n --privileged \\\n --restart=unless-stopped \\\n --name=kuboard-spray \\\n -p 80:80/tcp \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n -v ~/kuboard-spray-data:/data \\\n swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard-spray:latest-amd64\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u5373\u53ef\u5728\u6d4f\u89c8\u5668\u8f93\u5165 http://1.13.2.100
\uff08\u8df3\u677f\u673a IP \u5730\u5740\uff09\u6253\u5f00 Kuboard-Spray \u7684 Web \u754c\u9762\uff0c\u8f93\u5165\u7528\u6237\u540d admin
\uff0c\u9ed8\u8ba4\u5bc6\u7801 Kuboard123
\uff0c\u5373\u53ef\u767b\u5f55 Kuboard-Spray \u754c\u9762\uff0c\u5982\u4e0b\u6240\u793a\uff1a
\u767b\u5f55\u4e4b\u540e\uff0c\u5373\u53ef\u5f00\u59cb\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kubernetes","title":"\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4","text":"\u767b\u5f55 Kuboard-Spray \u754c\u9762\u4e4b\u540e\uff0c\u5373\u53ef\u5f00\u59cb\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kubernetes_1","title":"\u5bfc\u5165 Kubernetes \u76f8\u5173\u8d44\u6e90\u5305","text":"\u5b89\u88c5\u754c\u9762\u4f1a\u901a\u8fc7\u5728\u7ebf\u4e0b\u8f7d\u7684\u65b9\u5f0f\uff0c\u4e0b\u8f7d Kubernetes \u96c6\u7fa4\u6240\u5bf9\u5e94\u7684\u8d44\u6e90\u5305\uff0c\u4ee5\u5b9e\u73b0\u79bb\u7ebf\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u3002
\u70b9\u51fb\u8d44\u6e90\u5305\u7ba1\u7406\uff0c\u9009\u62e9\u5bf9\u5e94\u7248\u672c\u7684 Kubernetes \u8d44\u6e90\u5305\u4e0b\u8f7d\uff1a
\u4e0b\u8f7d spray-v2.18.0b-2_k8s-v1.23.17_v1.24-amd64
\u7248\u672c
\u70b9\u51fb\u5bfc\u5165\u540e\uff0c\u9009\u62e9\u52a0\u8f7d\u8d44\u6e90\u5305\uff0c\u9009\u62e9\u5408\u9002\u7684\u4e0b\u8f7d\u6e90\uff0c\u7b49\u5f85\u8d44\u6e90\u5305\u4e0b\u8f7d\u5b8c\u6210\u3002
Note
\u63a8\u8350\u60a8\u9009\u62e9 Docker \u4f5c\u4e3a\u7528\u4e8e K8s \u96c6\u7fa4\u7684\u5bb9\u5668\u5f15\u64ce\u3002\u9009\u62e9 Docker \u4f5c\u4e3a K8s \u7684\u5bb9\u5668\u5f15\u64ce\u540e\uff0cKuboard-Spray \u4f1a\u81ea\u52a8\u4f7f\u7528 Docker \u6765\u8fd0\u884c K8s \u96c6\u7fa4\u7684\u5404\u4e2a\u7ec4\u4ef6\uff0c\u5305\u62ec Master \u8282\u70b9\u548c Worker \u8282\u70b9\u4e0a\u7684\u5bb9\u5668\u3002
\u6b64\u65f6\u4f1a pull
\u76f8\u5173\u7684\u955c\u50cf\u4f9d\u8d56\uff1a
\u955c\u50cf\u8d44\u6e90\u5305\u62c9\u53d6\u6210\u529f\u540e\uff0c\u8fd4\u56de Kuboard-Spray \u7684 Web \u754c\u9762\uff0c\u53ef\u4ee5\u770b\u5230\u5bf9\u5e94\u7248\u672c\u7684\u8d44\u6e90\u5305\u5df2\u7ecf\u5bfc\u5165\u5b8c\u6210\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u8fdb\u884c Kubernetes \u96c6\u7fa4\u7684\u5b89\u88c5\u3002
\u9009\u62e9\u96c6\u7fa4\u7ba1\u7406\uff0c\u9009\u62e9\u6dfb\u52a0\u96c6\u7fa4\u5b89\u88c5\u8ba1\u5212\uff1a
\u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\uff0c\u5b9a\u4e49\u96c6\u7fa4\u7684\u540d\u79f0\uff0c\u9009\u62e9\u521a\u521a\u5bfc\u5165\u7684\u8d44\u6e90\u5305\u7684\u7248\u672c\uff0c\u518d\u70b9\u51fb\u786e\u5b9a\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6309\u7167\u4e8b\u5148\u5b9a\u4e49\u597d\u7684\u89d2\u8272\u5206\u7c7b\uff0cKubernetes \u96c6\u7fa4\u91c7\u7528 1 master + 1 worker +1 etcd
\u7684\u6a21\u5f0f\u8fdb\u884c\u90e8\u7f72\u3002
\u5728\u4e0a\u4e00\u6b65\u5b9a\u4e49\u5b8c\u6210\u96c6\u7fa4\u540d\u79f0\uff0c\u5e76\u9009\u62e9\u5b8c\u6210\u8d44\u6e90\u5305\u7248\u672c\uff0c\u70b9\u51fb\u786e\u5b9a\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u53ef\u4ee5\u76f4\u63a5\u8fdb\u5165\u5230\u96c6\u7fa4\u89c4\u5212\u9636\u6bb5\u3002
\u9009\u62e9\u5bf9\u5e94\u8282\u70b9\u7684\u89d2\u8272\u548c\u540d\u79f0\uff1a
\u5728\u6bcf\u4e00\u4e2a\u8282\u70b9\u586b\u5199\u5b8c\u89d2\u8272\u548c\u8282\u70b9\u540d\u79f0\u540e\uff0c\u8bf7\u5728\u53f3\u4fa7\u586b\u5199\u5bf9\u5e94\u8282\u70b9\u7684\u8fde\u63a5\u4fe1\u606f\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u586b\u5199\u5b8c\u6240\u6709\u7684\u89d2\u8272\u4e4b\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u3002\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u51c6\u5907\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u4e86\u3002
\u5728\u4e0a\u4e00\u6b65\u586b\u5199\u5b8c\u6210\u6240\u6709\u89d2\u8272\uff0c\u5e76\u4fdd\u5b58\u540e\uff0c\u70b9\u51fb\u6267\u884c\uff0c\u5373\u53ef\u5f00\u59cb Kubernetes \u96c6\u7fa4\u7684\u5b89\u88c5\u3002
\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u70b9\u51fb\u786e\u5b9a\uff0c\u5f00\u59cb\u5b89\u88c5 Kubernetes \u96c6\u7fa4\uff1a
\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u65f6\uff0c\u4f1a\u5728\u5bf9\u5e94\u8282\u70b9\u4e0a\u6267\u884c ansible
\u811a\u672c\uff0c\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u3002\u6574\u4f53\u4e8b\u4ef6\u4f1a\u6839\u636e\u673a\u5668\u914d\u7f6e\u548c\u7f51\u7edc\u4e0d\u540c\uff0c\u9700\u8981\u7b49\u5f85\u7684\u65f6\u95f4\u4e0d\u540c\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u9700\u8981 5 ~ 10 \u5206\u949f\u3002
Note: \u5982\u679c\u51fa\u73b0\u9519\u8bef\uff0c\u4f60\u53ef\u4ee5\u770b\u65e5\u5fd7\u7684\u5185\u5bb9\uff0c\u786e\u8ba4\u662f\u5426\u662f Kuboard-Spray \u7684\u7248\u672c\u4e0d\u5339\u914d\uff0c\u5982\u679c\u7248\u672c\u4e0d\u5339\u914d\uff0c\u8bf7\u66f4\u6362\u5408\u9002\u7684\u7248\u672c\u3002
\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5230 Kubernetes \u96c6\u7fa4\u7684 master \u8282\u70b9\u4e0a\u6267\u884c kubectl get node
\uff1a
[root@master0 ~]# kubectl get node\nNAME STATUS ROLES AGE VERSION\nmaster0 Ready control-plane,master 52m v1.23.17\nnode0 Ready <none> 52m v1.23.17\n
\u547d\u4ee4\u7ed3\u679c\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5373\u8868\u793a Kubernetes \u96c6\u7fa4\u5b89\u88c5\u5b8c\u6210\u3002
\u5728 Kubernetes \u7684\u6bcf\u4e2a\u8282\u70b9\u4e0a\u8c03\u6574 DNS \u8def\u7531\u8868\u3002\u8bf7\u5728\u6bcf\u53f0\u673a\u5668\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u627e\u5305\u542b 169.254.25.10
\u7684 nameserver\uff0c\u5e76\u5220\u9664\u8be5\u8bb0\u5f55\u3002\uff08\u8be5\u8bb0\u5f55\u53ef\u80fd\u5f71\u54cd\u5404\u4e2a Pod \u4e4b\u95f4\u7684\u901a\u4fe1\u6548\u7387\uff0c\u5982\u679c\u4e0d\u5b58\u5728\u8fd9\u6761\u8bb0\u5f55\u5219\u65e0\u9700\u66f4\u6539\uff09
vim /etc/resolve.conf\n
Helm \u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406 Kubernetes \u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u7ba1\u7406\u5de5\u5177\u3002\u5b83\u901a\u8fc7\u4f7f\u7528 chart\uff08\u9884\u5148\u914d\u7f6e\u7684\u5b89\u88c5\u5305\u8d44\u6e90\uff09\u6765\u7b80\u5316\u5e94\u7528\u7a0b\u5e8f\u7684\u90e8\u7f72\u548c\u7ba1\u7406\u8fc7\u7a0b\u3002\u7c7b\u4f3c\u4e8e Ubuntu \u7684 APT \u548c CentOS \u7684 YUM\uff0cHelm \u63d0\u4f9b\u4e86\u4e00\u79cd\u4fbf\u6377\u7684\u65b9\u5f0f\u6765\u5b89\u88c5\u3001\u5347\u7ea7\u548c\u7ba1\u7406 Kubernetes \u5e94\u7528\u7a0b\u5e8f\u3002
\u5728\u5b89\u88c5 Minio \u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5 Helm\uff0c\u56e0\u4e3a Minio \u7684\u5b89\u88c5\u8fc7\u7a0b\u4f9d\u8d56\u4e8e Helm\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5 Helm \u7684\u6b65\u9aa4\uff1a
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
\u4e0b\u8f7d helm \u5b89\u88c5\u5305\uff1a
wget https://get.helm.sh/helm-v3.10.2-linux-amd64.tar.gz\n#\u5982\u679c\u5728\u56fd\u5185\u7684\u7f51\u7edc\u53d7\u9650\u73af\u5883\u4e0b\uff0c\u53ef\u4ee5\u6362\u4ee5\u4e0b\u56fd\u5185\u955c\u50cf\u5730\u5740\nwget https://mirrors.huaweicloud.com/helm/v3.10.2/helm-v3.10.2-linux-amd64.tar.gz\n
\u89e3\u538b\u5e76\u5b89\u88c5\uff1a
tar -zxf helm-v3.10.2-linux-amd64.tar.gz\nmv linux-amd64/helm /usr/local/bin/helm\n
\u9a8c\u8bc1\u7248\u672c\uff0c\u67e5\u770b\u662f\u5426\u5b89\u88c5\u5b8c\u6210\uff1a
[root@k8s01 home]# helm version\nversion.BuildInfo{Version:\"v3.10.2\", GitCommit:\"50f003e5ee8704ec937a756c646870227d7c8b58\", GitTreeState:\"clean\", GoVersion:\"go1.18.8\"}\n
\u51fa\u73b0\u4e0a\u9762\u6240\u793a\u7248\u672c\u4fe1\u606f\u5373\u8868\u793a\u5b89\u88c5\u5b8c\u6210\u3002
CSI \u4e3a Kubernetes \u7684\u5b58\u50a8\u63d2\u4ef6\uff0c\u4e3a MinIO \u548c MarixOne \u63d0\u4f9b\u5b58\u50a8\u670d\u52a1\u3002\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 local-path-provisioner
\u63d2\u4ef6\u3002
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\uff0c\u5b89\u88c5 CSI\uff1a
wget https://github.com/rancher/local-path-provisioner/archive/refs/tags/v0.0.23.zip\nunzip v0.0.23.zip\ncd local-path-provisioner-0.0.23/deploy/chart/local-path-provisioner\nhelm install --set nodePathMap[0].paths[0]=\"/opt/local-path-provisioner\",nodePathMap[0].node=DEFAULT_PATH_FOR_NON_LISTED_NODES --create-namespace --namespace local-path-storage local-path-storage ./\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/rancher/local-path-provisioner/archive/refs/tags/v0.0.23.zip\n
\u5b89\u88c5\u6210\u529f\u540e\uff0c\u547d\u4ee4\u884c\u663e\u793a\u5982\u4e0b\u6240\u793a\uff1a
root@master0:~# kubectl get pod -n local-path-storage\nNAME READY STATUS RESTARTS AGE\nlocal-path-storage-local-path-provisioner-57bf67f7c-lcb88 1/1 Running 0 89s\n
Note: \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8be5 storageClass \u4f1a\u5728 worker \u8282\u70b9\u7684 \"/opt/local-path-provisioner\" \u76ee\u5f55\u63d0\u4f9b\u5b58\u50a8\u670d\u52a1\u3002\u4f60\u53ef\u4ee5\u4fee\u6539\u4e3a\u5176\u5b83\u8def\u5f84\u3002
\u8bbe\u7f6e\u7f3a\u7701 storageClass
\uff1a
kubectl patch storageclass local-path -p '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io/is-default-class\":\"true\"}}}'\n
\u8bbe\u7f6e\u7f3a\u7701\u6210\u529f\u540e\uff0c\u547d\u4ee4\u884c\u663e\u793a\u5982\u4e0b\uff1a
root@master0:~# kubectl get storageclass\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE\nlocal-path (default) cluster.local/local-path-storage-local-path-provisioner Delete WaitForFirstConsumer true 115s\n
MinIO \u7684\u4f5c\u7528\u662f\u4e3a MatrixOne \u63d0\u4f9b\u5bf9\u8c61\u5b58\u50a8\u3002\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u90e8\u7f72\u4e00\u4e2a\u5355\u8282\u70b9\u7684 MinIO\u3002
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_10","title":"\u5b89\u88c5\u542f\u52a8","text":"\u5b89\u88c5\u5e76\u542f\u52a8 MinIO \u7684\u547d\u4ee4\u884c\u5982\u4e0b\uff1a
helm repo add minio https://charts.min.io/\nmkdir minio_ins && cd minio_ins\nhelm fetch minio/minio\nls -lth\ntar -zxvf minio-5.0.9.tgz # \u8fd9\u4e2a\u7248\u672c\u53ef\u80fd\u4f1a\u53d8\uff0c\u4ee5\u5b9e\u9645\u4e0b\u8f7d\u5230\u7684\u4e3a\u51c6\ncd ./minio/\n\nkubectl create ns mostorage\n\nhelm install minio \\\n--namespace mostorage \\\n--set resources.requests.memory=512Mi \\\n--set replicas=1 \\\n--set persistence.size=10G \\\n--set mode=standalone \\\n--set rootUser=rootuser,rootPassword=rootpass123 \\\n--set consoleService.type=NodePort \\\n--set image.repository=minio/minio \\\n--set image.tag=latest \\\n--set mcImage.repository=minio/mc \\\n--set mcImage.tag=latest \\\n-f values.yaml minio/minio\n
Note
--set resources.requests.memory=512Mi
\u8bbe\u7f6e\u4e86 MinIO \u7684\u5185\u5b58\u6700\u4f4e\u6d88\u8017--set persistence.size=1G
\u8bbe\u7f6e\u4e86 MinIO \u7684\u5b58\u50a8\u5927\u5c0f\u4e3a 1G--set rootUser=rootuser,rootPassword=rootpass123
\u8fd9\u91cc\u7684 rootUser \u548c rootPassword \u8bbe\u7f6e\u7684\u53c2\u6570\uff0c\u5728\u540e\u7eed\u521b\u5efa Kubernetes \u96c6\u7fa4\u7684 scrects \u6587\u4ef6\u65f6\uff0c\u9700\u8981\u7528\u5230\uff0c\u56e0\u6b64\u4f7f\u7528\u4e00\u4e2a\u80fd\u8bb0\u4f4f\u7684\u4fe1\u606f\u3002\u5982\u679c\u7531\u4e8e\u7f51\u7edc\u6216\u5176\u4ed6\u539f\u56e0\u591a\u6b21\u53cd\u590d\u6267\u884c\uff0c\u9700\u8981\u5148\u5378\u8f7d\uff1a
helm uninstall minio --namespace mostorage\n
\u5b89\u88c5\u5e76\u542f\u52a8 MinIO \u6210\u529f\u540e\uff0c\u547d\u4ee4\u884c\u663e\u793a\u5982\u4e0b\u6240\u793a\uff1a
NAME: minio\nLAST DEPLOYED: Sun May 7 14:17:18 2023\nNAMESPACE: mostorage\nSTATUS: deployed\nREVISION: 1\nTEST SUITE: None\nNOTES:\nMinIO can be accessed via port 9000 on the following DNS name from within your cluster:\nminio.mostorage.svc.cluster.local\n\nTo access MinIO from localhost, run the below commands:\n\n 1. export POD_NAME=$(kubectl get pods --namespace mostorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\n\n 2. kubectl port-forward $POD_NAME 9000 --namespace mostorage\n\nRead more about port forwarding here: http://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward/\n\nYou can now access MinIO server on http://localhost:9000. Follow the below steps to connect to MinIO server with mc client:\n\n 1. Download the MinIO mc client - https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart\n\n 2. export MC_HOST_minio-local=http://$(kubectl get secret --namespace mostorage minio -o jsonpath=\"{.data.rootUser}\" | base64 --decode):$(kubectl get secret --namespace mostorage minio -o jsonpath=\"{.data.rootPassword}\" | base64 --decode)@localhost:9000\n\n 3. mc ls minio-local\n
\u76ee\u524d\u4e3a\u6b62\uff0cMinio \u5df2\u7ecf\u6210\u529f\u5b89\u88c5\u5b8c\u6bd5\u3002\u5728\u540e\u7eed\u7684 MatrixOne \u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0cMatrixOne \u5c06\u76f4\u63a5\u901a\u8fc7 Kubernetes \u7684 Service\uff08SVC\uff09\u4e0e Minio \u8fdb\u884c\u901a\u4fe1\uff0c\u65e0\u9700\u8fdb\u884c\u989d\u5916\u7684\u914d\u7f6e\u3002
\u7136\u800c\uff0c\u5982\u679c\u60a8\u5e0c\u671b\u4ece localhost
\u8fde\u63a5\u5230 Minio\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u884c\u6765\u8bbe\u7f6e POD_NAME
\u53d8\u91cf\uff0c\u5e76\u5c06 mostorage
\u8fde\u63a5\u5230 9000 \u7aef\u53e3\uff1a
export POD_NAME=$(kubectl get pods --namespace mostorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\nnohup kubectl port-forward --address 0.0.0.0 $POD_NAME -n mostorage 9000:9000 &\n
\u542f\u52a8\u540e\uff0c\u4f7f\u7528 http://118.195.255.252:32001/ \u5373\u53ef\u767b\u5f55 MinIO \u7684\u9875\u9762\uff0c\u521b\u5efa\u5bf9\u8c61\u5b58\u50a8\u7684\u4fe1\u606f\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u8d26\u6237\u5bc6\u7801\u5373\u4e0a\u8ff0\u6b65\u9aa4\u4e2d --set rootUser=rootuser,rootPassword=rootpass123
\u8bbe\u7f6e\u7684 rootUser \u548c rootPassword\uff1a
\u767b\u5f55\u5b8c\u6210\u540e\uff0c\u4f60\u9700\u8981\u521b\u5efa\u5bf9\u8c61\u5b58\u50a8\u76f8\u5173\u7684\u4fe1\u606f\uff1a
\u70b9\u51fb Bucket > Create Bucket\uff0c\u5728 Bucket Name \u4e2d\u586b\u5199 Bucket \u7684\u540d\u79f0 minio-mo\u3002\u586b\u5199\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u53f3\u4e0b\u65b9\u6309\u94ae Create Bucket\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u90e8\u7f72 MatrixOne \u96c6\u7fa4\u3002
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#matrixone-operator","title":"\u5b89\u88c5 MatrixOne-Operator","text":"MatrixOne Operator \u662f\u4e00\u4e2a\u5728 Kubernetes \u4e0a\u90e8\u7f72\u548c\u7ba1\u7406 MatrixOne \u96c6\u7fa4\u7684\u72ec\u7acb\u8f6f\u4ef6\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4ece\u9879\u76ee\u7684 Release \u5217\u8868\u4e2d\u9009\u62e9\u6700\u65b0\u7684 Operator Release \u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u5728 master0 \u4e0a\u5b89\u88c5 MatrixOne Operator\u3002\u6211\u4eec\u5c06\u4e3a Operator \u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684\u547d\u540d\u7a7a\u95f4 matrixone-operator
\u3002
\u6dfb\u52a0 matrixone-operator \u5730\u5740\u5230 helm \u4ed3\u5e93\uff1a
helm repo add matrixone-operator https://matrixorigin.github.io/matrixone-operator\n
\u66f4\u65b0\u4ed3\u5e93\uff1a
helm repo update\n
\u67e5\u770b MatrixOne Operator \u7248\u672c\uff1a
helm search repo matrixone-operator/matrixone-operator --versions --devel\n
\u6307\u5b9a\u53d1\u5e03\u7248\u672c\u5b89\u88c5 MatrixOne Operator\uff1a
helm install matrixone-operator matrixone-operator/matrixone-operator --version <VERSION> --create-namespace --namespace matrixone-operator\n
Note
\u53c2\u6570 VERSION \u4e3a\u8981\u90e8\u7f72\u7684 MatrixOne Operator \u7684\u7248\u672c\u53f7\uff0c\u5982 1.0.0-alpha.2\u3002
\u5b89\u88c5\u6210\u529f\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u786e\u8ba4\u5b89\u88c5\u72b6\u6001\uff1a
kubectl get pod -n matrixone-operator\n
\u786e\u4fdd\u4e0a\u8ff0\u547d\u4ee4\u8f93\u51fa\u4e2d\u7684\u6240\u6709 Pod \u72b6\u6001\u90fd\u4e3a Running\u3002
[root@master0 matrixone-operator]# kubectl get pod -n matrixone-operator\nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-f8496ff5c-fp6zm 1/1 Running 0 3m26s\n
\u5982\u4e0a\u4ee3\u7801\u884c\u6240\u793a\uff0c\u5bf9\u5e94 Pod \u72b6\u6001\u5747\u6b63\u5e38\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#matrixone","title":"\u521b\u5efa MatrixOne \u96c6\u7fa4","text":"\u9996\u5148\u521b\u5efa MatrixOne \u7684\u547d\u540d\u7a7a\u95f4\uff1a
NS=\"mo-hn\"\nkubectl create ns ${NS}\n
\u81ea\u5b9a\u4e49 MatrixOne \u96c6\u7fa4\u7684 yaml
\u6587\u4ef6\uff0c\u7f16\u5199\u5982\u4e0b mo.yaml
\u7684\u6587\u4ef6\uff1a
apiVersion: core.matrixorigin.io/v1alpha1\nkind: MatrixOneCluster\nmetadata:\n name: mo\n namespace: mo-hn\nspec:\n # 1. \u914d\u7f6e tn\n tn:\n cacheVolume: # tn \u7684\u78c1\u76d8\u7f13\u5b58\n size: 5Gi # \u6839\u636e\u5b9e\u9645\u78c1\u76d8\u5927\u5c0f\u548c\u9700\u6c42\u4fee\u6539\n storageClassName: local-path # \u5982\u679c\u4e0d\u5199\uff0c\u4f1a\u7528\u7cfb\u7edf\u9ed8\u8ba4\u7684 storage class\n resources:\n requests:\n cpu: 100m #1000m=1c\n memory: 500Mi # 1024Mi\n limits: # \u6ce8\u610f limits \u4e0d\u80fd\u4f4e\u4e8e requests\uff0c\u4e5f\u4e0d\u80fd\u8d85\u8fc7\u5355\u8282\u70b9\u7684\u80fd\u529b\uff0c\u4e00\u822c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u5206\u914d\uff0c\u4e00\u822c\u8bbe\u7f6e limits \u548c requests \u4e00\u81f4\u5373\u53ef\n cpu: 200m\n memory: 1Gi\n config: | # tn \u7684\u914d\u7f6e\n [dn.Txn.Storage]\n backend = \"TAE\"\n log-backend = \"logservice\"\n [dn.Ckp]\n flush-interval = \"60s\"\n min-count = 100\n scan-interval = \"5s\"\n incremental-interval = \"60s\"\n global-interval = \"100000s\"\n [log]\n level = \"error\"\n format = \"json\"\n max-size = 512\n replicas: 1 # tn \u7684\u526f\u672c\u6570\uff0c\u4e0d\u53ef\u4fee\u6539\u3002\u5f53\u524d\u7248\u672c\u4ec5\u652f\u6301\u8bbe\u7f6e\u4e3a 1\u3002\n # 2. \u914d\u7f6e logservice\n logService:\n replicas: 3 # logservice \u7684\u526f\u672c\u6570\n resources:\n requests:\n cpu: 100m #1000m=1c\n memory: 500Mi # 1024Mi\n limits: # \u6ce8\u610f limits \u4e0d\u80fd\u4f4e\u4e8e requests\uff0c\u4e5f\u4e0d\u80fd\u8d85\u8fc7\u5355\u8282\u70b9\u7684\u80fd\u529b\uff0c\u4e00\u822c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u5206\u914d\uff0c\u4e00\u822c\u8bbe\u7f6e limits \u548c requests \u4e00\u81f4\u5373\u53ef\n cpu: 200m\n memory: 1Gi\n sharedStorage: # \u914d\u7f6e logservice \u5bf9\u63a5\u7684 s3 \u5b58\u50a8\n s3:\n type: minio # \u6240\u5bf9\u63a5\u7684 s3 \u5b58\u50a8\u7c7b\u578b\u4e3a minio\n path: minio-mo # \u7ed9 mo \u7528\u7684 minio \u6876\u7684\u8def\u5f84\uff0c\u6b64\u524d\u901a\u8fc7\u63a7\u5236\u53f0\u6216 mc \u547d\u4ee4\u521b\u5efa\n endpoint: http://minio.mostorage:9000 # \u6b64\u5904\u4e3a minio \u670d\u52a1\u7684 svc \u5730\u5740\u548c\u7aef\u53e3\n secretRef: # \u914d\u7f6e\u8bbf\u95ee minio \u7684\u5bc6\u94a5\u5373 secret\uff0c\u540d\u79f0\u4e3a minio\n name: minio\n pvcRetentionPolicy: Retain # \u914d\u7f6e\u96c6\u7fa4\u9500\u6bc1\u540e\uff0cpvc \u7684\u5468\u671f\u7b56\u7565\uff0cRetain \u4e3a\u4fdd\u7559\uff0cDelete \u4e3a\u5220\u9664\n volume:\n size: 1Gi # \u914d\u7f6e S3 \u5bf9\u8c61\u5b58\u50a8\u7684\u5927\u5c0f\uff0c\u6839\u636e\u5b9e\u9645\u78c1\u76d8\u5927\u5c0f\u548c\u9700\u6c42\u4fee\u6539\n config: | # logservice \u7684\u914d\u7f6e\n [log]\n level = \"error\"\n format = \"json\"\n max-size = 512\n # 3. \u914d\u7f6e cn\n tp:\n cacheVolume: # cn \u7684\u78c1\u76d8\u7f13\u5b58\n size: 5Gi # \u6839\u636e\u5b9e\u9645\u78c1\u76d8\u5927\u5c0f\u548c\u9700\u6c42\u4fee\u6539\n storageClassName: local-path # \u5982\u679c\u4e0d\u5199\uff0c\u4f1a\u7528\u7cfb\u7edf\u9ed8\u8ba4\u7684 storage class\n resources:\n requests:\n cpu: 100m #1000m=1c\n memory: 500Mi # 1024Mi\n limits: # \u6ce8\u610f limits \u4e0d\u80fd\u4f4e\u4e8e requests\uff0c\u4e5f\u4e0d\u80fd\u8d85\u8fc7\u5355\u8282\u70b9\u7684\u80fd\u529b\uff0c\u4e00\u822c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u5206\u914d\uff0c\u4e00\u822c\u8bbe\u7f6e limits \u548c requests \u4e00\u81f4\u5373\u53ef\n cpu: 200m\n memory: 2Gi\n serviceType: NodePort # cn \u9700\u8981\u5bf9\u5916\u63d0\u4f9b\u8bbf\u95ee\u5165\u53e3\uff0c\u5176 svc \u8bbe\u7f6e\u4e3a NodePort\n nodePort: 31429 # nodePort \u7aef\u53e3\u8bbe\u7f6e\n config: | # cn \u7684\u914d\u7f6e\n [cn.Engine]\n type = \"distributed-tae\"\n [log]\n level = \"debug\"\n format = \"json\"\n max-size = 512\n replicas: 1\n version: nightly-54b5e8c # \u6b64\u5904\u4e3a MO \u955c\u50cf\u7684\u7248\u672c\uff0c\u53ef\u901a\u8fc7 dockerhub \u67e5\u9605\uff0c\u4e00\u822c cn\u3001tn\u3001logservice \u4e3a\u540c\u4e00\u4e2a\u955c\u50cf\u6253\u5305\uff0c\u6240\u4ee5\u7528\u540c\u4e00\u4e2a\u5b57\u6bb5\u6307\u5b9a\u5373\u53ef\uff0c\u4e5f\u652f\u6301\u5355\u72ec\u5728\u5404\u81ea\u90e8\u5206\u4e2d\u6307\u5b9a\uff0c\u4f46\u65e0\u7279\u6b8a\u60c5\u51b5\u8bf7\u7528\u7edf\u4e00\u7684\u955c\u50cf\u7248\u672c\n # https://hub.docker.com/r/matrixorigin/matrixone/tags\n imageRepository: matrixorigin/matrixone # \u955c\u50cf\u4ed3\u5e93\u5730\u5740\uff0c\u5982\u679c\u672c\u5730\u62c9\u53d6\u540e\uff0c\u6709\u4fee\u6539\u8fc7 tag\uff0c\u90a3\u4e48\u53ef\u4ee5\u8c03\u6574\u8fd9\u4e2a\u914d\u7f6e\u9879\n imagePullPolicy: IfNotPresent # \u955c\u50cf\u62c9\u53d6\u7b56\u7565\uff0c\u4e0e k8s \u5b98\u65b9\u53ef\u914d\u7f6e\u503c\u4e00\u81f4\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5728\u547d\u540d\u7a7a\u95f4 mo-hn
\u4e2d\u521b\u5efa\u7528\u4e8e\u8bbf\u95ee MinIO \u7684 Secret \u670d\u52a1\uff1a
kubectl -n mo-hn create secret generic minio --from-literal=AWS_ACCESS_KEY_ID=rootuser --from-literal=AWS_SECRET_ACCESS_KEY=rootpass123\n
\u5176\u4e2d\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u4f7f\u7528\u5728\u521b\u5efa MinIO \u96c6\u7fa4\u65f6\u8bbe\u7f6e\u7684 rootUser
\u548c rootPassword
\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u90e8\u7f72 MatrixOne \u96c6\u7fa4\uff1a
kubectl apply -f mo.yaml\n
\u8bf7\u8010\u5fc3\u7b49\u5f85\u5927\u7ea6 10 \u5206\u949f\uff0c\u5982\u679c\u51fa\u73b0 Pod \u91cd\u542f\uff0c\u8bf7\u7ee7\u7eed\u7b49\u5f85\u3002\u76f4\u5230\u4f60\u770b\u5230\u4ee5\u4e0b\u4fe1\u606f\u8868\u793a\u90e8\u7f72\u6210\u529f\uff1a
[root@master0 mo]# kubectl get pods -n mo-hn \nNAME READY STATUS RESTARTS AGE\nmo-tn-0 1/1 Running 0 74s\nmo-log-0 1/1 Running 1 (25s ago) 2m2s\nmo-log-1 1/1 Running 1 (24s ago) 2m2s\nmo-log-2 1/1 Running 1 (22s ago) 2m2s\nmo-tp-cn-0 1/1 Running 0 50s\n
\u4e3a\u4e86\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u60a8\u9700\u8981\u5c06\u5bf9\u5e94\u670d\u52a1\u7684\u7aef\u53e3\u6620\u5c04\u5230 MatrixOne \u8282\u70b9\u4e0a\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 kubectl port-forward
\u8fde\u63a5 MatrixOne \u96c6\u7fa4\u7684\u6307\u5bfc\uff1a
nohup kubectl port-forward -nmo-hn svc/mo-tp-cn 6001:6001 &\n
nohup kubectl port-forward -nmo-hn --address 0.0.0.0 svc/mo-tp-cn 6001:6001 &\n
\u5728\u6307\u5b9a\u5141\u8bb8\u672c\u5730\u8bbf\u95ee\u6216\u6307\u5b9a\u67d0\u53f0\u673a\u5668\u6216\u8005\u6240\u6709\u673a\u5668\u8bbf\u95ee\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff1a
# \u4f7f\u7528 'mysql' \u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230MySQL\u670d\u52a1\n# \u4f7f\u7528 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' \u83b7\u53d6Kubernetes\u96c6\u7fa4\u4e2d\u670d\u52a1\u7684\u96c6\u7fa4IP\u5730\u5740\n# '-h' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u4e3b\u673a\u540d\u6216IP\u5730\u5740\n# '-P' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u7aef\u53e3\u53f7\uff0c\u8fd9\u91cc\u662f6001\n# '-uroot' \u8868\u793a\u7528root\u7528\u6237\u767b\u5f55\n# '-p111' \u8868\u793a\u521d\u59cb\u5bc6\u7801\u662f111\nmysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 163\nServer version: 8.0.30-MatrixOne-v1.1.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
\u663e\u793a mysql>
\u540e\uff0c\u5206\u5e03\u5f0f\u7684 MatrixOne \u96c6\u7fa4\u642d\u5efa\u8fde\u63a5\u5b8c\u6210\u3002
Info
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/","title":"\u4f53\u9a8c\u73af\u5883","text":"\u672c\u7bc7\u6587\u6863\u4ecb\u7ecd\u7684 MatrixOne \u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u89c4\u5212\u53ef\u4ee5\u7528\u4e8e\u4f53\u9a8c MatrixOne \u7684\u5206\u5e03\u5f0f\u57fa\u7840\u80fd\u529b\uff0c\u4f60\u53ef\u4ee5\u7b80\u5355\u4f53\u9a8c\u6570\u636e\u5e93\u7684\u57fa\u7840\u5f00\u53d1\u3001\u8fd0\u7ef4\u7b49\u529f\u80fd\uff0c\u4f46\u662f\u4e0d\u9002\u7528\u4e8e\u90e8\u7f72\u751f\u4ea7\u73af\u5883\uff0c\u8fdb\u884c\u6027\u80fd\u538b\u6d4b\uff0c\u6216\u8fdb\u884c\u9ad8\u53ef\u7528\u6d4b\u8bd5\u7b49\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_2","title":"\u786c\u4ef6\u914d\u7f6e","text":"\u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u5982\u4e0b\uff1a
\u786c\u4ef6\u73af\u5883\u8981\u6c42 \u7269\u7406\u673a/\u865a\u62df\u673a \u8bbe\u5907\u53f0\u6570 3 \u53f0 CPU \u914d\u7f6e 2 \u6838\u4ee5\u4e0a \u5185\u5b58\u914d\u7f6e 8GB \u4ee5\u4e0a \u78c1\u76d8\u914d\u7f6e 200GB \u4ee5\u4e0a \u7f51\u5361\u914d\u7f6e \u4e0d\u9650"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_3","title":"\u8f6f\u4ef6\u914d\u7f6e","text":"\u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u8f6f\u4ef6\u914d\u7f6e\u8981\u6c42\u5305\u62ec\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u7684\u8981\u6c42\u548c\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42\uff1a
"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_4","title":"\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u8981\u6c42","text":"\u64cd\u4f5c\u7cfb\u7edf \u652f\u6301\u7684 CPU \u67b6\u6784 CentOS 7.3 \u53ca\u4ee5\u4e0a\u7684 7.x \u7248\u672c X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_5","title":"\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42","text":"\u8f6f\u4ef6\u6a21\u5757 \u90e8\u7f72\u53f0\u6570 \u529f\u80fd\u8bf4\u660e Kubernetes 3 \u63d0\u4f9b\u6574\u4e2a\u96c6\u7fa4\u7684\u5bb9\u5668\u5316\u7ba1\u7406 Minio 1 \u63d0\u4f9b MatrixOne \u96c6\u7fa4\u7684\u5b58\u50a8\u670d\u52a1 MatrixOne 1 \u6570\u636e\u5e93\u6838\u5fc3MatrixOne \u5206\u5e03\u5f0f\u73af\u5883\u7684\u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u6307\u5f15\u53ef\u4ee5\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/","title":"\u6700\u5c0f\u751f\u4ea7\u73af\u5883","text":"\u672c\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u7684 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7684\u6700\u5c0f\u751f\u4ea7\u914d\u7f6e\u53ef\u4ee5\u7528\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u53ef\u4ee5\u652f\u6491\u5343\u4e07\u7ea7\u6570\u636e\u6570\u767e\u5e76\u53d1\u7684 OLTP \u4e1a\u52a1\uff0c\u6216\u8005\u6570\u5341 GB \u6570\u636e\u91cf\u7684 OLAP \u4e1a\u52a1\uff0c\u540c\u65f6\u6709\u4e00\u5b9a\u7684\u9ad8\u53ef\u7528\u4fdd\u969c\uff0c3 \u8282\u70b9\u5982\u679c\u6709 1 \u4e2a\u8282\u70b9\u4e0b\u7ebf\u7684\u60c5\u51b5\u4e0b\u4ecd\u7136\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_2","title":"\u786c\u4ef6\u914d\u7f6e","text":"\u6700\u5c0f\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u5982\u4e0b\uff1a
\u786c\u4ef6\u73af\u5883\u8981\u6c42 \u7269\u7406\u673a\u3001\u865a\u62df\u673a\u5747\u53ef \u8bbe\u5907\u53f0\u6570 3 \u53f0 CPU \u914d\u7f6e 8 \u6838\u4ee5\u4e0a \u5185\u5b58\u914d\u7f6e 32GB \u4ee5\u4e0a \u78c1\u76d8\u914d\u7f6e \u6bcf\u8282\u70b9 1 \u5757\u7cfb\u7edf\u76d8 100G, 4-7 \u5757\u6570\u636e\u76d8 100G, \u5747\u9700\u8981 PCIe NVME SSD 3.0 \u7f51\u5361\u914d\u7f6e \u53cc\u4e07\u5146\u7f51\u53e3\uff0c\u4e07\u5146\u7f51\u5361\u53ca\u4ea4\u6362\u673a"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_3","title":"\u8f6f\u4ef6\u914d\u7f6e","text":"\u6700\u5c0f\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u8f6f\u4ef6\u914d\u7f6e\u8981\u6c42\u5305\u62ec\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u7684\u8981\u6c42\u548c\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42\uff1a
"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_4","title":"\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u8981\u6c42","text":"\u64cd\u4f5c\u7cfb\u7edf \u652f\u6301\u7684 CPU \u67b6\u6784 Debian 11 \u4ee5\u4e0a\u7248\u672c\uff08Kernel \u5185\u6838\u8981\u6c42 5.0 \u4ee5\u4e0a\uff09 X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_5","title":"\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42","text":"\u8282\u70b9\u540d\u79f0 \u8d44\u6e90 \u8282\u70b9\u89d2\u8272 \u90e8\u7f72\u6a21\u5757 \u78c1\u76d8\u90e8\u7f72 node0 8c32g \u7ba1\u63a7/\u5b58\u50a8/\u8ba1\u7b97 \u90e8\u7f72\u53ca\u8fd0\u7ef4\u5de5\u5177 mo-ctl, Kubernetes master/node\uff0cMinio\uff0cMatrixOne Proxy\uff0cLogservice\uff0cTN\uff0c\u8d1f\u8f7d\u5747\u8861 Kubernetes \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cMinio \u9700\u8981 1 \u81f3 4 \u5757\u6570\u636e\u76d8\uff08\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u4e5f\u53ef\u903b\u8f91\u5206\u76d8\uff09, Logservice \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cTN \u9700\u8981 1 \u5757\u6570\u636e\u76d8 node1 8c32g \u7ba1\u63a7/\u5b58\u50a8/\u8ba1\u7b97 \u90e8\u7f72\u53ca\u8fd0\u7ef4\u5de5\u5177 mo-ctl, Kubernetes master/node\uff0cMinio\uff0cMatrixOne Proxy\uff0cLogservice\uff0cCN\uff0c\u8d1f\u8f7d\u5747\u8861 Kubernetes \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cMinio \u9700\u8981 1-4 \u5757\u6570\u636e\u76d8\uff08\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u4e5f\u53ef\u903b\u8f91\u5206\u76d8\uff09, Logservice \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cCN \u9700\u8981 1 \u5757\u6570\u636e\u76d8 node2 8c32g \u7ba1\u63a7/\u5b58\u50a8/\u8ba1\u7b97 \u90e8\u7f72\u53ca\u8fd0\u7ef4\u5de5\u5177 mo-ctl, Kubernetes master/node\uff0cMinio\uff0cMatrixOne Proxy\uff0cLogservice\uff0cCN\uff0c\u8d1f\u8f7d\u5747\u8861 Kubernetes \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cMinio \u9700\u8981 1-4 \u5757\u6570\u636e\u76d8\uff08\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u4e5f\u53ef\u903b\u8f91\u5206\u76d8\uff09, Logservice \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cCN \u9700\u8981 1 \u5757\u6570\u636e\u76d8"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/","title":"\u63a8\u8350\u751f\u4ea7\u73af\u5883","text":"\u672c\u7bc7\u6587\u6863\u4ecb\u7ecd\u7684 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7684\u63a8\u8350\u914d\u7f6e\u9002\u7528\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u5e76\u5177\u5907\u5f3a\u5927\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002\u8fd9\u79cd\u914d\u7f6e\u53ef\u4ee5\u652f\u6301\u4ebf\u7ea7\u6570\u636e\u7684\u6570\u5343\u5e76\u53d1 OLTP \u4e1a\u52a1\uff0c\u6216\u8005\u5904\u7406\u6570\u5341 TB \u6570\u636e\u91cf\u7684 OLAP \u4e1a\u52a1\u3002
\u6b64\u914d\u7f6e\u5177\u6709\u9ad8\u5ea6\u7684\u53ef\u7528\u6027\u4fdd\u8bc1\u3002\u65e0\u8bba\u662f Kubernetes\u3001Minio \u8fd8\u662f MatrixOne\uff0c\u7cfb\u7edf\u90fd\u53ef\u4ee5\u5728\u4e00\u4e2a\u8282\u70b9\u4e0b\u7ebf\u7684\u60c5\u51b5\u4e0b\u7ee7\u7eed\u6b63\u5e38\u8fd0\u884c\u3002\u8fd9\u610f\u5473\u7740\u7cfb\u7edf\u5177\u5907\u5f3a\u5927\u7684\u5bb9\u9519\u80fd\u529b\uff0c\u53ef\u4ee5\u5728\u8282\u70b9\u6545\u969c\u7684\u60c5\u51b5\u4e0b\u4fdd\u6301\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002
\u4ee5\u4e0b\u5185\u5bb9\u4e3a\u63a8\u8350\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u89c4\u5212\uff1a
"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#_2","title":"\u8f6f\u4ef6\u53ca\u786c\u4ef6\u914d\u7f6e\u8981\u6c42","text":"\u6a21\u5757 Kubernetes master Minio LogService TN\uff08\u6df7\u90e8 Proxy \u53ca\u8d1f\u8f7d\u5747\u8861\uff09 CN\uff08\u6df7\u90e8 Proxy \u53ca\u8d1f\u8f7d\u5747\u8861\uff09 \u53f0\u6570\uff08\u7269\u7406\u673a\u3001\u865a\u62df\u673a\u5747\u53ef\uff09 3 \u53f0 4 \u53f0 3 \u53f0 1 \u53f0 y \u53f0 \u8282\u70b9\u89d2\u8272 Kubernetes \u7ba1\u63a7 \u5b58\u50a8\u670d\u52a1 MatrixOne \u5de5\u4f5c\u8282\u70b9 MatrixOne \u5de5\u4f5c\u8282\u70b9 MatrixOne \u5de5\u4f5c\u8282\u70b9 CPU \u914d\u7f6e 4 \u6838\u4ee5\u4e0a 4 \u6838\u4ee5\u4e0a 4 \u6838\u4ee5\u4e0a 16 \u6838\u4ee5\u4e0a 16 \u6838\u4ee5\u4e0a \u5185\u5b58\u914d\u7f6e 8GB \u4ee5\u4e0a 8GB \u4ee5\u4e0a 8GB \u4ee5\u4e0a 64GB \u4ee5\u4e0a 32GB \u4ee5\u4e0a \u7f51\u5361 \u53cc\u4e07\u5146\u7f51\u53e3\uff0c\u4e07\u5146\u7f51\u5361 \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u7cfb\u7edf\u76d8\u914d\u7f6e \u6bcf\u8282\u70b9 PCIe NVME SSD 3.0 \u00d7 1 \u5757 100GB\uff0c\u5efa\u8bae\u505a Raid 1 \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a Kubernetes \u76d8\u914d\u7f6e \u6bcf\u8282\u70b9 PCIe NVME SSD 3.0 \u00d7 1 \u5757 100GB\uff0c\u5efa\u8bae\u505a Raid 1 \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u6570\u636e\u76d8\u914d\u7f6e N/A \u6bcf\u8282\u70b9 PCIe NVME SSD 3.0 \u00d7 4 \u5757 \u00d7 a G/\u5757\uff0craid \u65e0\u8981\u6c42\uff0c\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u53ef\u903b\u8f91\u5206\u76d8\u3002 \u6bcf\u8282\u70b9 NVME SSD 3.0/4.0 (1G/s \u4ee5\u4e0a\u8bfb\u53d6\u901f\u7387) \u00d7 1 \u5757 \u00d7 b G/\u5757\u3002 NVME SSD 3.0/4.0 \u00d7 2 \u5757 \u00d7 c G/\u5757 \u6bcf\u8282\u70b9 NVME SSD 3.0/4.0 \u00d7 2 \u5757 \u00d7 d G/\u5757\u3002 \u5907\u6ce8 a \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0ca = \u4e1a\u52a1\u6570\u636e\u91cf\u00d72/16\u3002 b \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0c\u8d8a\u63a5\u8fd1\u8d8a\u597d\u3002 c \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0c\u8d8a\u63a5\u8fd1\u8d8a\u597d\u3002\u5176\u4e2d\u4e00\u5757\u7ed9 TN/CN \u6545\u969c\u6062\u590d\u65f6\u5907\u7528\u3002 d \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0c\u8d8a\u63a5\u8fd1\u8d8a\u597d\u3002\u5176\u4e2d\u4e00\u5757\u7ed9 TN/CN \u6545\u969c\u6062\u590d\u65f6\u5907\u7528\u3002y \u4e0e\u4e1a\u52a1\u8d1f\u8f7d\u76f8\u5173\u3002"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#_3","title":"\u5176\u4ed6\u914d\u7f6e","text":"\u64cd\u4f5c\u7cfb\u7edf \u652f\u6301\u7684 CPU \u67b6\u6784 Debian 11 \u4ee5\u4e0a\u7248\u672c\uff08Kernel \u5185\u6838\u8981\u6c42 5.0 \u4ee5\u4e0a\uff09 X86_64\u7531\u4e8e\u6bcf\u4e2a\u79c1\u6709\u5316\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u573a\u666f\u5747\u5b58\u5728\u5dee\u5f02\uff0c\u6709\u5173\u5177\u4f53\u90e8\u7f72\u65b9\u6848\u53ca\u90e8\u7f72\u7ec6\u8282\uff0c\u8bf7\u8054\u7cfb MatrixOne \u7684\u5ba2\u6237\u652f\u6301\u56e2\u961f\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/","title":"MatrixOne \u96c6\u7fa4\u62d3\u6251\u6982\u8ff0","text":"MatrixOne \u6570\u636e\u5e93\u96c6\u7fa4\u662f\u4e00\u79cd\u5728\u591a\u4e2a\u7269\u7406\u6216\u865a\u62df\u670d\u52a1\u5668\u4e0a\u5206\u5e03\u5f0f\u90e8\u7f72\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u67b6\u6784\uff0c\u65e8\u5728\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u3001\u9ad8\u53ef\u4f38\u7f29\u6027\u3002\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u5206\u6563\u5230\u591a\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u96c6\u7fa4\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u5197\u4f59\u5907\u4efd\u3001\u8d1f\u8f7d\u5747\u8861\u548c\u6545\u969c\u6062\u590d\uff0c\u4ece\u800c\u63d0\u4f9b\u66f4\u9ad8\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002
\u6570\u636e\u5e93\u96c6\u7fa4\u62d3\u6251\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u548c\u6027\u80fd\u8981\u6c42\u7684\u4e0d\u540c\uff0c\u53ef\u4ee5\u9009\u62e9\u9002\u5408\u7684\u67b6\u6784\u3002\u4e86\u89e3\u4e0d\u540c\u62d3\u6251\u7684\u4f18\u7f3a\u70b9\u4ee5\u53ca\u9002\u7528\u573a\u666f\uff0c\u6709\u52a9\u4e8e\u8bbe\u8ba1\u51fa\u7a33\u5b9a\u3001\u9ad8\u6548\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u67b6\u6784\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/#_1","title":"\u62d3\u6251\u90e8\u7f72\u6587\u6863","text":"\u6211\u4eec\u63a8\u8350\u4e09\u79cd\u73af\u5883\u7684\u90e8\u7f72\u6587\u6863\uff0c\u53c2\u8003\uff1a
\u672c\u7bc7\u6587\u7ae0\u53ca\u5176\u540e\u7eed\u7ae0\u8282\u4e3b\u8981\u65e8\u5728\u4ecb\u7ecd\u5982\u4f55\u5229\u7528 MatrixOne \u8fdb\u884c\u5e94\u7528\u5f00\u53d1\u3002\u6211\u4eec\u5c06\u5c55\u793a\u5982\u4f55\u8fde\u63a5\u5230 MatrixOne\uff0c\u5982\u4f55\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\uff0c\u4ee5\u53ca\u5982\u4f55\u6784\u5efa\u57fa\u4e8e\u5e38\u89c1\u7f16\u7a0b\u8bed\u8a00\uff08\u5982 Java\uff0cPython\uff0cGolang\uff09\u7684\u5e94\u7528\u7a0b\u5e8f\u3002
"},{"location":"MatrixOne/Develop/develop-overview/#matrixone","title":"MatrixOne \u4e0e\u5e94\u7528\u7684\u4ea4\u4e92","text":"\u603b\u4f53\u6765\u8bf4\uff0cMatrixOne \u4e0e MySQL 8.0 \u5177\u6709\u9ad8\u5ea6\u7684\u517c\u5bb9\u6027\uff0c\u65e0\u8bba\u5728\u901a\u4fe1\u534f\u8bae\uff0cSQL \u8bed\u6cd5\uff0c\u8fde\u63a5\u5de5\u5177\uff0c\u8fd8\u662f\u5f00\u53d1\u6a21\u5f0f\u4e0a\uff0c\u90fd\u4e0e MySQL \u57fa\u672c\u4e00\u81f4\u3002\u5982\u679c\u672c\u6587\u6863\u4e2d\u6ca1\u6709\u660e\u786e\u8bf4\u660e\u67d0\u4e9b\u7528\u6cd5\uff0c\u4f60\u53ef\u4ee5\u53c2\u7167 MySQL 8.0 \u7684\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u64cd\u4f5c\u3002\u5927\u90e8\u5206\u7684\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\u6216\u7f16\u7a0b\u8bed\u8a00\u90fd\u53ef\u4ee5\u4f7f\u7528 MySQL \u7684\u5ba2\u6237\u7aef\u5e93\u3002
\u5bf9\u4e8e MatrixOne \u548c MySQL \u6709\u663e\u8457\u5dee\u5f02\u7684\u5730\u65b9\uff0c\u8bf7\u53c2\u9605 MySQL \u517c\u5bb9\u6027\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Develop/develop-overview/#matrixone_1","title":"MatrixOne \u4e8b\u52a1\u673a\u5236","text":"MatrixOne \u652f\u6301\u4e50\u89c2\u4e8b\u52a1\u548c\u60b2\u89c2\u4e8b\u52a1\u4e24\u79cd\u6a21\u5f0f\u3002\u5728 MatrixOne \u7684\u5f53\u524d\u7248\u672c\u4e2d\uff0c\u9ed8\u8ba4\u91c7\u7528\u7684\u662f\u60b2\u89c2\u4e8b\u52a1\u6a21\u5f0f\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u6765\u5f00\u542f\u4e50\u89c2\u4e8b\u52a1\u6a21\u5f0f\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 BEGIN
\u6765\u5f00\u542f\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4f7f\u7528 COMMIT
\u6765\u63d0\u4ea4\u4e8b\u52a1\uff0c\u6216\u8005\u4f7f\u7528 ROLLBACK
\u6765\u56de\u6eda\u4e8b\u52a1\u3002MatrixOne \u4f1a\u786e\u4fdd\u4ece BEGIN
\u5f00\u59cb\u5230 COMMIT
\u6216 ROLLBACK
\u7ed3\u675f\u4e4b\u95f4\u7684\u6240\u6709\u8bed\u53e5\u5177\u6709\u539f\u5b50\u6027\uff0c\u5373\u5728\u8fd9\u6bb5\u65f6\u95f4\u5185\u7684\u6240\u6709\u8bed\u53e5\u8981\u4e48\u5168\u90e8\u6210\u529f\uff0c\u8981\u4e48\u5168\u90e8\u5931\u8d25\uff0c\u4ee5\u6b64\u6765\u4fdd\u8bc1\u4f60\u5728\u5e94\u7528\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u9700\u8981\u7684\u6570\u636e\u4e00\u81f4\u6027\u3002
\u5982\u679c\u4f60\u9009\u62e9\u4f7f\u7528\u4e50\u89c2\u4e8b\u52a1\uff0c\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8bf7\u589e\u52a0\u9519\u8bef\u5904\u7406\u548c\u91cd\u8bd5\u673a\u5236\uff0c\u56e0\u4e3a MatrixOne \u5e76\u4e0d\u4fdd\u8bc1\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u80fd\u6267\u884c\u6210\u529f\u3002\u5982\u679c\u4f60\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\uff0c\u90a3\u4e48\u5c31\u65e0\u9700\u8003\u8651\u8fd9\u4e00\u70b9\u3002\u4e50\u89c2\u4e8b\u52a1\u5728\u5e76\u53d1\u6027\u80fd\u4e0a\u4f1a\u4f18\u4e8e\u60b2\u89c2\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/develop-overview/#_2","title":"\u53c2\u8003\u6587\u6863","text":"FineBI \u662f\u65b0\u4e00\u4ee3\u5927\u6570\u636e\u5206\u6790\u5de5\u5177\uff0c\u5b83\u6709\u52a9\u4e8e\u4f01\u4e1a\u7684\u4e1a\u52a1\u4eba\u5458\u6df1\u5165\u4e86\u89e3\u548c\u5145\u5206\u5229\u7528\u4ed6\u4eec\u7684\u6570\u636e\u3002\u5728 FineBI \u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u5236\u4f5c\u591a\u6837\u5316\u7684\u6570\u636e\u53ef\u89c6\u5316\u4fe1\u606f\uff0c\u81ea\u7531\u5206\u6790\u548c\u63a2\u7d22\u6570\u636e\u3002FineBI \u5177\u6709\u591a\u79cd\u6570\u636e\u8fde\u63a5\u529f\u80fd\uff0c\u53ef\u7528\u4e8e\u521b\u5efa\u5404\u79cd\u590d\u6742\u7684\u62a5\u8868\uff0c\u6784\u5efa\u6570\u636e\u51b3\u7b56\u5206\u6790\u7cfb\u7edf\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u516c\u53f8\u7ecf\u8425\u7ba1\u7406\u3001\u751f\u4ea7\u7ba1\u7406\u3001\u8d22\u52a1\u667a\u80fd\u6838\u7b97\u3001\u9500\u552e\u8fd0\u8425\u7b49\u9886\u57df\u3002
MatrixOne \u652f\u6301\u8fde\u63a5\u5230\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177 FineBI\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7 FineBI \u8fde\u63a5\u5230\u5355\u673a\u7248 MatrixOne\uff0c\u5e76\u521b\u5efa\u5404\u79cd\u53ef\u89c6\u5316\u6570\u636e\u62a5\u8868\uff0c\u5c06\u5b83\u4eec\u7ec4\u88c5\u6210\u4eea\u8868\u677f\uff0c\u4ee5\u4fbf\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u63a2\u7d22\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#_2","title":"\u524d\u671f\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5b89\u88c5 FineBI \u548c FineBI \u521d\u59cb\u5316\u8bbe\u7f6e\u3002
Note
\u672c\u7bc7\u6587\u6863\u6240\u5c55\u793a\u7684\u64cd\u4f5c\u793a\u4f8b\u4e2d\u4f7f\u7528\u7684 FineBI \u7248\u672c\u4e3a Linux 6.0 \u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u5b89\u88c5\u5305 Linux_unix_FineBI6_0-CN.sh\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#finebi-matrixone_1","title":"\u901a\u8fc7 FineBI \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u521b\u5efa Demo \u6570\u636e\uff1a
\u9996\u5148\uff0c\u767b\u5f55\u5230 MatrixOne \u6570\u636e\u5e93\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b SQL \u8bed\u53e5\u6765\u521b\u5efa\u6f14\u793a\u6240\u9700\u7684\u6570\u636e\u8868\u548c\u89c6\u56fe\uff1a
create database orders;\nuse orders;\nCREATE TABLE `category` (`product_category_name` VARCHAR(255) DEFAULT NULL,\n`product_category_name_english` VARCHAR(255) DEFAULT NULL );\nCREATE TABLE `item` (`order_id` VARCHAR(255) NOT NULL, `order_item_id` INT DEFAULT null,\n`product_id` VARCHAR(255) DEFAULT null,\n`seller_id` VARCHAR(255) DEFAULT null, `shipping_limit_date` DATETIME DEFAULT null,\n`price` DECIMAL(10,2) DEFAULT null,\n`freight_value` DECIMAL(10,2) DEFAULT null\n);\nCREATE TABLE `review` (\n`review_id` VARCHAR(255) NOT NULL,\n`order_id` VARCHAR(255) DEFAULT null,\n`review_score` TINYINT DEFAULT null,\n`review_comment_title` VARCHAR(255) DEFAULT null,\n`review_comment_message` TEXT DEFAULT null,\n`review_creation_date` DATETIME DEFAULT null,\n`review_answer_timestamp` DATETIME DEFAULT null,\nPRIMARY KEY (`review_id`)\n);\nCREATE TABLE `order_time` (\n`order_id` VARCHAR(255) NOT NULL,\n`customer_id` VARCHAR(255) DEFAULT null,\n`y` INT DEFAULT null,\n`q` INT DEFAULT null,\n`m` INT DEFAULT null,\n`d` DATE DEFAULT null,\n`h` INT DEFAULT null,\n`order_purchase_timestamp` DATETIME DEFAULT null\n);\nCREATE TABLE `orders` (\n`order_id` VARCHAR(255) NOT NULL,\n`customer_id` VARCHAR(255) DEFAULT null,\n`order_status` VARCHAR(255) DEFAULT null,\n`order_purchase_timestamp` DATETIME DEFAULT null,\n`order_approved_at` DATETIME DEFAULT null,\n`order_delivered_carrier_date` DATETIME DEFAULT null,\n`order_delivered_customer_date` DATETIME DEFAULT null,\n`order_estimated_delivery_date` DATETIME DEFAULT null,\nPRIMARY KEY (`order_id`)\n);\nCREATE TABLE `product` (\n`product_id` VARCHAR(255) NOT NULL,\n`product_category_name` VARCHAR(255) DEFAULT null,\n`product_name_lenght` INT DEFAULT null,\n`product_description_lenght` INT DEFAULT null,\n`product_photos_qty` INT DEFAULT null,\n`product_weight_g` INT DEFAULT null,\n`product_length_cm` INT DEFAULT null,\n`product_height_cm` INT DEFAULT null,\n`product_width_cm` INT DEFAULT null,\nPRIMARY KEY (`product_id`)\n);\nCREATE TABLE `rfm` (\n`customer_id` VARCHAR(255) DEFAULT null,\n`user_type` VARCHAR(255) DEFAULT null,\n`shijian` DATE DEFAULT null\n);\n\nCREATE view total_order_value as select t.order_id,product_id,seller_id,(price*total)+(freight_value*total) as order_value from (select order_id,count(*) as total from item group by order_id) t join item on t.order_id=item.order_id;\n\nCREATE view order_detail as select a.order_id,product_id,seller_id, customer_id,round(order_value,2) as order_value, y,q,m,d,h,order_purchase_timestamp from total_order_value a inner join order_time b on a.order_id=b.order_id;\n
\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u4ee5\u4e0b SQL \u5bfc\u5165\u8bed\u53e5\uff0c\u5c06\u9884\u5148\u51c6\u5907\u7684 Demo \u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u7684\u76f8\u5e94\u8868\u4e2d\u3002
Note
\u8bf7\u6ce8\u610f\uff0c\u8def\u5f84 /root/data/table_name.csv
\u662f\u5404\u8868\u6570\u636e\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u60a8\u53ef\u4ee5\u53c2\u8003\u6b64\u8fc7\u7a0b\u81ea\u884c\u751f\u6210\u6570\u636e\u3002
use orders;\nload data local infile '/root/data/category.csv' into table category FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/review.csv' into table review FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/product.csv' into table product FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/item.csv' into table item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/order_time.csv' into table order_time FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/orders.csv' into table orders FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/rfm.csv' into table rfm FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
\u6dfb\u52a0\u6570\u636e\u96c6\uff1a
\u5728 FineBI \u4e2d\uff0c\u70b9\u51fb\u516c\u5171\u6570\u636e\uff0c\u7136\u540e\u70b9\u51fb\u65b0\u5efa\u6587\u4ef6\u5939\uff0c\u521b\u5efa\u5e76\u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u7136\u540e\u70b9\u51fb\u65b0\u5efa\u6570\u636e\u96c6\uff0c\u9009\u62e9 SQL \u6570\u636e\u96c6\uff0c\u5c06 SQL \u67e5\u8be2\u6dfb\u52a0\u5230\u9009\u5b9a\u7684\u6587\u4ef6\u5939\u4e2d\u3002\u8f93\u5165\u6570\u636e\u96c6\u540d\u79f0\u5e76\u586b\u5199 SQL \u67e5\u8be2\uff0c\u5982\u4e0b\u6240\u793a\uff1a
select d,\ncount(order_id) as order_num,\ncount(DISTINCT customer_id)\nfrom orders.order_detail\ngroup by d\norder by d\n
\u60a8\u53ef\u4ee5\u70b9\u51fb\u9884\u89c8\u6309\u94ae\u67e5\u770b SQL \u67e5\u8be2\u7684\u7ed3\u679c\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\u8fdb\u884c\u4fdd\u5b58\uff1a
\u4e0b\u9762\u662f\u672c\u793a\u4f8b\u4e2d\u4f7f\u7528\u7684\u6240\u6709\u67e5\u8be2 SQL \u7684\u793a\u4f8b\uff1a
-- \u65e5\u6d3b\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\nselect d,\ncount(order_id) as order_num,\ncount(DISTINCT customer_id)\nfrom orders.order_detail\ngroup by d\norder by d\n\n-- \u6708\u6d3b\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\nselect count(DISTINCT customer_id),\ncount(order_id),\nconcat(y, '-', m)\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- \u5404\u65f6\u6bb5\u6d3b\u8dc3\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\nselect h,\ncount(DISTINCT customer_id),\ncount(order_id) order_num\nfrom orders.order_detail\ngroup by h\norder by h\n\n-- \u5404\u7c7b\u578b\u7528\u6237\u6570\u91cf\nSELECT count(*),\nuser_type\nfrom orders.rfm\nGROUP BY user_type\n\n-- \u6708 GMV\nselect y,m,\nsum(order_value),\nconcat(y, \"-\", m) month\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- \u5b63\u5ea6 GMV\nselect y,q,\nsum(order_value) gmv,\nconcat(y, \"\u5b63\u5ea6\", q) as quator\nfrom orders.order_detail\ngroup by y,q\norder by concat(y, \"\u5b63\u5ea6\", q) asc\n\n-- \u5b63\u5ea6 ARPU\nselect y,q,\nround((sum(order_value)/count(DISTINCT customer_id)),2) arpu,\nconcat(y, \"\u5b63\u5ea6\", q) as quator\nfrom orders.order_detail\ngroup by y,q\norder by y,q\n\n-- \u6708\u5ea6 ARPU\nselect y,m,\nround((sum(order_value)/count(DISTINCT customer_id)),2) arpu,\nconcat(y, \"-\", m) as month\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- \u91cd\u8981\u633d\u7559\u7528\u6237\u70ed\u95e8\u6307\u6570\nSELECT e.product_category_name_english good_type,\nSUM(a.order_value) ordder_total_value,\nROUND(AVG(c.review_score), 2) good_review_score,\n(0.7*SUM(a.order_value)+\n\n0.3*10000*ROUND(AVG(c.review_score), 7))\ntop_rank_rate\nFROM orders.order_detail a\nINNER JOIN\n(SELECT customer_id\nfrom orders.rfm\nWHERE user_type='\u91cd\u8981\u633d\u7559\u7528\u6237' ) as b ON a.customer_id=b.customer_id\nLEFT JOIN orders.review c ON a.order_id=c.order_id\nLEFT JOIN orders.product d ON a.product_id=d.product_id\nLEFT JOIN orders.category e ON d.product_category_name=e.product_category_name\nwhere e.product_category_name_english is not NULL\nGROUP BY e.product_category_name_english limit 50\n\n-- \u4e00\u822c\u633d\u7559\u7528\u6237\u70ed\u95e8\u6307\u6570\nSELECT e.product_category_name_english good_type,\nSUM(a.order_value) ordder_total_value,\nROUND(AVG(c.review_score), 2) good_review_score,\n(0.7*SUM(a.order_value)+0.3*10000*ROUND(AVG(c.review_score), 7))\ntop_rank_rate\nFROM orders.order_detail a\nINNER JOIN\n(SELECT customer_id from orders.rfm\nWHERE user_type='\u4e00\u822c\u633d\u7559\u7528\u6237' ) as b ON a.customer_id=b.customer_id\nLEFT JOIN orders.review c ON a.order_id=c.order_id\nLEFT JOIN orders.product d ON a.product_id=d.product_id\nLEFT JOIN orders.category e ON d.product_category_name=e.product_category_name\nwhere e.product_category_name_english is not NULL\nGROUP BY e.product_category_name_english limit 50\n
\u66f4\u65b0\u6570\u636e\uff1a
\u4fdd\u5b58\u6570\u636e\u96c6\u540e\uff0c\u60a8\u9700\u8981\u70b9\u51fb\u66f4\u65b0\u6570\u636e\u6309\u94ae\uff0c\u7b49\u5f85\u6570\u636e\u66f4\u65b0\u5b8c\u6210\u540e\u624d\u80fd\u8fdb\u884c\u5206\u6790\uff1a
\u521b\u5efa\u5206\u6790\u4e3b\u9898\uff1a
\u672c\u793a\u4f8b\u7684\u5206\u6790\u4e3b\u9898\u7528\u4e8e\u53ef\u89c6\u5316\u5c55\u793a\u7535\u5546\u5e73\u53f0\u7684\u4e00\u822c\u633d\u7559\u7528\u6237\u3001\u91cd\u8981\u633d\u7559\u7528\u6237\u3001\u6708 ARPU\u3001\u5b63\u5ea6 ARPU\u3001\u4e0d\u540c\u65f6\u6bb5\u6d3b\u8dc3\u7528\u6237\u3001\u65e5\u6d3b\u8dc3\u7528\u6237\u3001\u6708\u6d3b\u8dc3\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\u7b49\u6570\u636e\uff0c\u4ee5\u8f85\u52a9\u51b3\u7b56\u548c\u63d0\u5347\u4e1a\u52a1\u3002\u521b\u5efa\u5206\u6790\u4e3b\u9898\u7684\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a
Note: \u60a8\u53ef\u4ee5\u4f7f\u7528\u6279\u91cf\u9009\u62e9\u529f\u80fd\u6765\u9009\u62e9\u591a\u4e2a\u6570\u636e\u96c6\u8fdb\u884c\u4e3b\u9898\u5206\u6790\u3002
\u70b9\u51fb\u6dfb\u52a0\u7ec4\u4ef6\u6309\u94ae\uff0c\u9009\u62e9\u56fe\u8868\u7c7b\u578b\uff0c\u5c06\u5de6\u4fa7\u7684\u5b57\u6bb5\u6309\u9700\u8981\u62d6\u52a8\u5230\u53f3\u4fa7\uff0c\u53cc\u51fb\u4fee\u6539\u5b57\u6bb5\u53ef\u89c6\u5316\u540d\u79f0\uff0c\u5728\u4e0b\u65b9\u4fee\u6539\u7ec4\u4ef6\u540d\u79f0\uff0c\u7ec4\u4ef6\u540d\u79f0\u5373\u8be5\u7ec4\u4ef6\u6240\u5206\u6790\u7684\u62a5\u8868\u5185\u5bb9\uff1a
\u7ec4\u88c5\u4eea\u8868\u677f\uff1a
\u70b9\u51fb\u6dfb\u52a0\u4eea\u8868\u677f\uff0c\u5c06\u521a\u521a\u521b\u5efa\u7684\u7ec4\u4ef6\u6dfb\u52a0\u5230\u4eea\u8868\u677f\u4e2d\u3002\u60a8\u53ef\u4ee5\u81ea\u7531\u62d6\u52a8\u548c\u7f29\u653e\u7ec4\u4ef6\u7684\u5927\u5c0f\u548c\u4f4d\u7f6e\uff0c\u5e76\u5728\u4e0b\u65b9\u4fee\u6539\u7ec4\u4ef6\u540d\u79f0\uff0c\u4ee5\u63cf\u8ff0\u8be5\u7ec4\u4ef6\u6240\u5206\u6790\u7684\u62a5\u8868\u5185\u5bb9\u3002
\u53d1\u5e03\u4eea\u8868\u677f\uff1a
\u7ec4\u88c5\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u7533\u8bf7\u53d1\u5e03\uff0c\u8bbe\u7f6e\u53d1\u5e03\u540d\u79f0\u3001\u53d1\u5e03\u8282\u70b9\u548c\u5c55\u793a\u5e73\u53f0\u3002\u7136\u540e\u70b9\u51fb\u786e\u8ba4\uff0c\u60a8\u7684\u4eea\u8868\u677f\u5c06\u6210\u529f\u53d1\u5e03\u3002
\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u5728\u9996\u9875\u5bfc\u822a\u4e0b\u627e\u5230\u521a\u521a\u53d1\u5e03\u7684\u4eea\u8868\u677f\uff0c\u5e76\u67e5\u770b\u5176\u5c55\u793a\u6548\u679c\u3002
Superset \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u73b0\u4ee3\u7684\u3001\u8f7b\u91cf\u7ea7 BI \u5206\u6790\u5de5\u5177\uff0c\u80fd\u591f\u8fde\u63a5\u591a\u79cd\u6570\u636e\u6e90\u3001\u63d0\u4f9b\u4e30\u5bcc\u7684\u53ef\u89c6\u5316\u56fe\u8868\uff0c\u652f\u6301\u81ea\u5b9a\u4e49\u4eea\u8868\u76d8\uff0c\u5e2e\u52a9\u7528\u6237\u8f7b\u677e\u63a2\u7d22\u548c\u5448\u73b0\u6570\u636e\u3002
MatrixOne 1.0 \u7248\u672c\u73b0\u5728\u652f\u6301\u4e0e\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177 Superset \u96c6\u6210\u3002\u672c\u6307\u5357\u5c06\u5f15\u5bfc\u60a8\u5feb\u901f\u90e8\u7f72 MatrixOne \u548c Superset \u73af\u5883\uff0c\u901a\u8fc7\u5c06 MatrixOne \u4e0e Superset \u7684\u53ef\u89c6\u5316\u529f\u80fd\u76f8\u7ed3\u5408\uff0c\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u76d1\u63a7\u9762\u677f\uff0c\u7528\u4e8e\u76d1\u6d4b MatrixOne \u6570\u636e\u5e93\uff0c\u4f7f\u7528\u5176\u4e2d\u7684 'system_metric' \u6570\u636e\u3002
\u5982\u679c\u60a8\u5e0c\u671b\u8fdb\u4e00\u6b65\u6269\u5c55\u529f\u80fd\uff0c\u60a8\u8fd8\u53ef\u4ee5\u63a2\u7d22\u5176\u4ed6\u914d\u7f6e\u9009\u9879\uff0c\u4ee5\u76d1\u63a7\u6574\u4e2a MatrixOne \u6570\u636e\u5e93\u7684\u5404\u4e2a\u65b9\u9762\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#_2","title":"\u524d\u671f\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#_3","title":"\u786c\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u5bf9\u4e8e\u673a\u5668\u7684\u786c\u4ef6\u8981\u6c42\u4e0d\u9ad8\uff0c2C 4G \u7684\u5c0f\u578b\u865a\u62df\u673a\u5373\u53ef\u5b8c\u6210\u8fd9\u4e2a\u6d41\u7a0b\u7684\u529f\u80fd\u4f53\u9a8c\u3002
\u672c\u6b21\u5b9e\u8df5\u9700\u8981\u5b89\u88c5\u90e8\u7f72\u4ee5\u4e0b\u8f6f\u4ef6\u73af\u5883\uff1a
\u4f60\u53ef\u4ee5\u53c2\u7167\u4e0b\u9762\u7684\u7ae0\u8282\u8fdb\u884c\u5b89\u88c5\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#docker","title":"\u5b89\u88c5 Docker","text":"\u672c\u6b21\u5b9e\u8df5\u6240\u6709\u8f6f\u4ef6\u73af\u5883\u7684\u5b89\u88c5\u90fd\u662f\u57fa\u4e8e Docker \u8fdb\u884c\uff0c\u4f60\u53ef\u4ee5\u53c2\u7167 Docker \u5b98\u65b9\u6587\u6863\u8fdb\u884c\u5b89\u88c5\u5e76\u542f\u52a8 Docker\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#matrixone","title":"\u5b89\u88c5 MatrixOne","text":"\u4f60\u53ef\u4ee5\u53c2\u7167 macOS \u73af\u5883\u4e0b\u4f7f\u7528 Docker \u90e8\u7f72 MatrixOne \u6216 Linux \u73af\u5883\u4e0b\u4f7f\u7528 Docker \u90e8\u7f72 MatrixOne \u8fdb\u884c\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne.
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#superset","title":"\u5b89\u88c5 Superset","text":"\u4f7f\u7528 Docker \u90e8\u7f72\u5355\u8282\u70b9\u7684 Superset \u6b65\u9aa4\u5982\u4e0b\uff1a
\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 Docker \u4ee5\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ece Docker Hub \u4e2d\u62c9\u53d6 Superset \u7684\u955c\u50cf\uff1a
docker pull amancevice/superset\n
\u542f\u52a8 Superset \u955c\u50cf\uff1a
docker run -e \"SUPERSET_SECRET_KEY=your_secret_key_here\" --name superset -u 0 -d -p 8088:8088 amancevice/superset\n
Note
\u5b89\u5168\u5bc6\u94a5\u53ef\u901a\u8fc7 openssl rand -base64 $num
\u6765\u751f\u6210\uff0c\u4f8b\u5982\u751f\u6210\u5bc6\u94a5 openssl rand -base64 49
\u3002 \u53c2\u6570\u53ef\u53c2\u8003\u5b98\u7f51\u8bf4\u660e\uff1aYour App secret key will be used for securely signing the session cookie and encrypting sensitive information on the database. Make sure you are changing this key for your deployment with a strong key. You can generate a strong key using openssl rand -base64 42
. Alternatively you can set it with SUPERSET_SECRET_KEY
environment variable.
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521d\u59cb\u5316 Superset \u6570\u636e\u5e93\uff1a
docker exec -it superset superset db upgrade\n
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa Superset \u7ba1\u7406\u5458\u7528\u6237\uff0c\u6839\u636e\u63d0\u793a\u8f93\u5165\u76f8\u5173\u6ce8\u518c\u4fe1\u606f\uff1a
docker exec -it superset superset fab create-admin\n
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u9ed8\u8ba4\u8d26\u6237\uff1a
docker exec -it superset superset init\n
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u670d\u52a1\uff0c\u540c\u65f6\u5f00\u542f\u7ebf\u7a0b\u3001\u81ea\u52a8\u91cd\u65b0\u52a0\u8f7d\u548c\u8c03\u8bd5\u6a21\u5f0f\uff1a
docker exec -it superset superset run --with-threads --reload --debugger\n
\u8bbf\u95ee Superset \u7684\u767b\u5f55\u9875\u9762\uff0c\u901a\u5e38\u662f http://ip:8080
\uff0c\u7136\u540e\u8f93\u5165\u60a8\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u767b\u5f55 Superset\u3002
Note: Superset \u7684\u7aef\u53e3\u53ef\u80fd\u662f 8080 \u6216 8088\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u60a8\u7684\u914d\u7f6e\uff1b\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u60a8\u5728\u90e8\u7f72 Superset \u65f6\u8bbe\u7f6e\u7684\u3002
\u767b\u5f55\u540e\uff0c\u60a8\u5c06\u770b\u5230 Superset \u7684\u4e3b\u754c\u9762\u3002
\u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\uff1a
\u5728 Superset \u4e2d\uff0c\u9996\u5148\u9700\u8981\u521b\u5efa\u4e0e MatrixOne \u7684\u6570\u636e\u5e93\u8fde\u63a5\u3002\u5728\u53f3\u4e0a\u89d2\u70b9\u51fb Settings\uff0c\u7136\u540e\u9009\u62e9 Database Connections\u3002
\u5728 Database Connections \u9875\u9762\uff0c\u70b9\u51fb + DATABASE \u6309\u94ae\uff0c\u5e76\u9009\u62e9 MySQL \u4f5c\u4e3a\u6570\u636e\u5e93\u7c7b\u578b\u3002
\u586b\u5199 MatrixOne \u6570\u636e\u5e93\u7684\u8fde\u63a5\u4fe1\u606f\uff0c\u5305\u62ec\u4e3b\u673a\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002
\u586b\u5199\u5b8c\u6bd5\u540e\uff0c\u70b9\u51fb CONNECT \u6309\u94ae\uff0c\u7136\u540e\u518d\u70b9\u51fb FINISH\u3002
\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 MatrixOne \u6570\u636e\u5e93\u521b\u5efa\u4e00\u4e2a\u76d1\u63a7\u4eea\u8868\u677f\u3002
\u70b9\u51fb\u9875\u9762\u4e0a\u7684 SQL > SQL Lab\uff0c\u9009\u62e9\u521a\u521a\u521b\u5efa\u7684 MatrixOne \u6570\u636e\u5e93\u8fde\u63a5\uff0c\u5e76\u7f16\u5199 SQL \u67e5\u8be2\u4ee5\u9009\u62e9\u8981\u76d1\u63a7\u7684\u6570\u636e\u8868\u3002
\u60a8\u53ef\u4ee5\u7f16\u5199\u591a\u4e2a\u67e5\u8be2\u6765\u76d1\u63a7\u4e0d\u540c\u7684\u6307\u6807\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b\u67e5\u8be2\u7684 SQL \u8bed\u53e5\uff1a
SELECT metric_name, collecttime, value\nFROM metric\nWHERE metric_name = 'sys_cpu_combined_percent' or metric_name = 'sys_cpu_seconds_total'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'server_storage_usage'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'server_connections'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_disk_read_bytes' OR metric_name = 'sys_disk_write_bytes'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_net_sent_bytes' OR metric_name = 'sys_net_recv_bytes'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_memory_available' OR metric_name = 'sys_memory_used'\nORDER BY collecttime DESC;\n
\u4e8b\u52a1\u9519\u8bef\u603b\u6570\uff1a
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sql_transaction_errors' OR metric_name = 'sql_transaction_total'\nORDER BY collecttime DESC;\n
SQL \u9519\u8bef\u603b\u6570\uff1a
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sql_statement_errors' OR metric_name = 'sql_statement_total'\nORDER BY collecttime DESC;\n
\u70b9\u51fb SAVE > Save dataset > SAVE & EXPLORE \u4fdd\u5b58\u4e0a\u9762\u7684\u6bcf\u4e2a\u67e5\u8be2\u5e76\u5c06\u5176\u7528\u4f5c\u540e\u7eed\u56fe\u8868\u7684\u6570\u636e\u6e90\u3002
\u7f16\u8f91\u56fe\u8868\uff1a
\u8fd9\u91cc\u6211\u4eec\u7528\u5176\u4e2d\u4e00\u4e2a\u67e5\u8be2\u4e3a\u4f8b\uff0c\u6765\u6f14\u793a\u5982\u4f55\u7f16\u8f91\u4e00\u4e2a\u53ef\u89c6\u5316\u7684\u56fe\u8868\u3002\u9996\u5148\uff0c\u6211\u4eec\u9009\u62e9 disk_read_write
\u7684\u67e5\u8be2\u4f5c\u4e3a\u56fe\u8868\u7684\u5236\u4f5c\u6570\u636e\u6e90\uff0c\u5728 SQL Lab \u4e2d\u5bf9\u5e94\u67e5\u8be2\u7684\u4e0b\u9762\u70b9\u51fb CREATE CHART \u6216\u8005\u5728\u4e0a\u4e00\u6b65\u4fdd\u5b58\u5b8c Query \u4e4b\u540e\uff0c\u9875\u9762\u5c06\u8df3\u8f6c\u81f3\u7f16\u8f91 Chart \u9875\u9762\uff1a
\u8fdb\u5165\u5230\u56fe\u8868\u7f16\u8f91\u7684\u9875\u9762\uff0c\u4f9d\u6b21\u9009\u62e9\u56fe\u8868\u7c7b\u578b\u3001\u65f6\u95f4\u5b57\u6bb5\u3001\u67e5\u8be2\u7684\u6307\u6807\u5217\u3001\u67e5\u8be2\u7684\u5206\u7ec4\u5217\u7b49\u9009\u9879\uff0c\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u9009\u62e9\u8fd0\u884c\uff1a
\u70b9\u51fb UPDATE CHART > SAVE\uff0c\u5c06\u7f16\u8f91\u597d\u7684 Chart \u4fdd\u5b58\u3002
\u521b\u5efa\u4e86\u591a\u4e2a\u56fe\u8868\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 Superset \u4e2d\u7ec4\u88c5\u5b83\u4eec\u4ee5\u521b\u5efa\u4e00\u4e2a\u76d1\u63a7\u4eea\u8868\u677f\uff1a
\u70b9\u51fb Dashboards\uff0c\u7136\u540e\u70b9\u51fb + DASHBOARD \u6765\u521b\u5efa\u65b0\u7684\u4eea\u8868\u677f\uff0c\u6216\u8005\u7f16\u8f91\u73b0\u6709\u7684\u4eea\u8868\u677f\u3002
\u5728\u4eea\u8868\u677f\u7f16\u8f91\u9875\u9762\uff0c\u4f60\u53ef\u4ee5\u4ece\u53f3\u4fa7\u7684 CHARTS \u5217\u8868\u4e2d\u62d6\u62fd\u5df2\u521b\u5efa\u7684\u56fe\u8868\u5230\u4eea\u8868\u677f\u4e0a\u8fdb\u884c\u7ec4\u88c5\u3002\u4f60\u4e5f\u53ef\u4ee5\u81ea\u7531\u8c03\u6574\u56fe\u8868\u7684\u4f4d\u7f6e\uff0c\u6dfb\u52a0\u6807\u9898\u7b49\u3002
\u60a8\u5df2\u7ecf\u6210\u529f\u5730\u8fde\u63a5\u4e86 MatrixOne \u6570\u636e\u5e93\u4e0e Superset\uff0c\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u76d1\u63a7\u4eea\u8868\u677f\uff0c\u4ee5\u53ef\u89c6\u5316\u5c55\u793a MatrixOne \u6570\u636e\u5e93\u7684\u91cd\u8981\u6307\u6807\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/","title":"\u901a\u8fc7\u6c38\u6d2a BI \u5b9e\u73b0 MatrixOne \u7684\u53ef\u89c6\u5316\u62a5\u8868","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_1","title":"\u6982\u8ff0","text":"\u6c38\u6d2a BI \u662f\u4e00\u6b3e\u5168\u9762\u7684\u5927\u6570\u636e\u5e73\u53f0\uff0c\u5b83\u6574\u5408\u4e86\u81ea\u670d\u52a1\u6570\u636e\u51c6\u5907\u3001\u63a2\u7d22\u6027\u81ea\u52a9\u5206\u6790\u3001\u6df1\u5ea6\u5206\u6790\u3001\u4f01\u4e1a\u7ea7\u7ba1\u7406\u548c\u9ad8\u6027\u80fd\u8ba1\u7b97\u529f\u80fd\uff0c\u63d0\u4f9b\u4e86\u4e00\u7ad9\u5f0f\u7684\u5927\u6570\u636e\u89e3\u51b3\u65b9\u6848\u3002\u6c38\u6d2a BI \u7684\u76ee\u6807\u662f\u4e3a\u5404\u79cd\u89c4\u6a21\u7684\u4f01\u4e1a\u63d0\u4f9b\u7075\u6d3b\u6613\u7528\u7684\u5168\u4e1a\u52a1\u94fe\u5927\u6570\u636e\u5206\u6790\u5de5\u5177\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u8f7b\u677e\u53d1\u6398\u5927\u6570\u636e\u7684\u4ef7\u503c\u5e76\u83b7\u5f97\u6df1\u523b\u7684\u6d1e\u5bdf\u529b\u3002
MatrixOne \u652f\u6301\u8fde\u63a5\u5230\u667a\u80fd\u6570\u636e\u5206\u6790\u5de5\u5177\u6c38\u6d2a BI\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7\u6c38\u6d2a BI \u8fde\u63a5\u5230\u5355\u673a\u7248 MatrixOne\uff0c\u5e76\u521b\u5efa\u5404\u79cd\u53ef\u89c6\u5316\u6570\u636e\u62a5\u8868\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u6253\u5f00\u6c38\u6d2a BI\uff0c\u9009\u62e9\u5de6\u4fa7\u7684\u6dfb\u52a0\u6570\u636e\u6e90 > +\uff08\u65b0\u5efa\u6570\u636e\u6e90\uff09\uff0c\u5728\u5f39\u51fa\u7684\u6570\u636e\u5e93\u9009\u9879\u4e2d\u9009\u62e9 MySQL\u3002
\u586b\u5199\u5b8c\u6210 MatrixOne \u6570\u636e\u5e93\u76f8\u5173\u7684\u8fde\u63a5\u4fe1\u606f\u540e\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u53f3\u4e0a\u89d2\u7684\u6d4b\u8bd5\u8fde\u63a5\u6309\u94ae\uff0c\u4ee5\u786e\u4fdd\u8fde\u63a5\u6210\u529f\u3002
\u8fde\u63a5\u6210\u529f\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u4ee5\u4fdd\u5b58\u6211\u4eec\u521a\u521a\u586b\u5199\u7684\u6570\u636e\u6e90\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_4","title":"\u521b\u5efa\u6570\u636e\u96c6","text":"\u5728\u6c38\u6d2a BI \u4e2d\uff0c\u9009\u62e9\u5de6\u4fa7\u7684\u521b\u5efa\u6570\u636e\u96c6\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u521a\u521a\u6dfb\u52a0\u7684\u6570\u636e\u6e90\u3002\u60a8\u5c06\u770b\u5230 MatrixOne \u6570\u636e\u5e93\u4e2d\u7684\u8868\u683c\u548c\u89c6\u56fe\u4fe1\u606f\u3002\u6839\u636e\u60a8\u7684\u4e1a\u52a1\u9700\u6c42\uff0c\u6dfb\u52a0\u81ea\u5b9a\u4e49 SQL\uff0c\u7136\u540e\u70b9\u51fb\u5237\u65b0\u6570\u636e\u3002\u67e5\u8be2\u7ed3\u679c\u5c06\u663e\u793a\u5728\u53f3\u4fa7\uff0c\u786e\u8ba4\u67e5\u8be2\u7ed3\u679c\u662f\u5426\u7b26\u5408\u9884\u671f\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u4ee5\u4fdd\u5b58\u6570\u636e\u96c6\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_5","title":"\u5236\u4f5c\u62a5\u544a","text":"\u9996\u5148\uff0c\u5728\u6c38\u6d2a BI \u4e2d\u9009\u62e9\u5de6\u4fa7\u7684\u5236\u4f5c\u62a5\u544a\u83dc\u5355\uff0c\u7136\u540e\u4ece\u53f3\u4fa7\u9009\u62e9\u5408\u9002\u7684\u56fe\u8868\u7ec4\u4ef6\u5e76\u62d6\u52a8\u5230\u5de6\u4fa7\u3002
\u9009\u62e9\u521a\u521a\u521b\u5efa\u7684\u6570\u636e\u96c6\uff0c\u5c06\u65f6\u95f4\u7ef4\u5ea6\u8bbe\u7f6e\u4e3a X \u8f74\uff0c\u5c06\u65e5\u8ba2\u5355\u6570\u548c\u6d3b\u8dc3\u7528\u6237\u6570\u8bbe\u7f6e\u4e3a Y \u8f74\u3002\u60a8\u53ef\u4ee5\u5c06\u5ea6\u91cf\u548c\u7ef4\u5ea6\u5b57\u6bb5\u6839\u636e\u9700\u8981\u62d6\u52a8\u5230\u76f8\u5e94\u7684\u4f4d\u7f6e\u3002\u7f16\u8f91\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u4ee5\u4fdd\u5b58\u521a\u521a\u5236\u4f5c\u7684\u62a5\u544a\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_6","title":"\u67e5\u770b\u62a5\u544a","text":"\u6700\u540e\uff0c\u5728\u6c38\u6d2a BI \u4e2d\u9009\u62e9\u67e5\u770b\u62a5\u544a\uff0c\u7136\u540e\u70b9\u51fb\u5de6\u4fa7\u7684\u6811\u72b6\u83dc\u5355\u4e2d\u6211\u4eec\u521a\u521a\u521b\u5efa\u7684\u62a5\u544a\u540d\u79f0\uff0c\u60a8\u5c06\u80fd\u591f\u67e5\u770b\u6211\u4eec\u4e0a\u9762\u5236\u4f5c\u7684\u62a5\u544a\u6548\u679c\u3002
\u60a8\u5df2\u7ecf\u6210\u529f\u5730\u4f7f\u7528\u6c38\u6d2a BI \u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u62a5\u544a\uff0c\u7528\u4e8e\u53ef\u89c6\u5316\u5c55\u793a MatrixOne \u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/","title":"\u4f7f\u7528 DataX \u5c06\u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_1","title":"\u6982\u8ff0","text":"\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 DataX \u5de5\u5177\u5c06\u6570\u636e\u79bb\u7ebf\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u3002
DataX \u662f\u4e00\u6b3e\u7531\u963f\u91cc\u5f00\u6e90\u7684\u5f02\u6784\u6570\u636e\u6e90\u79bb\u7ebf\u540c\u6b65\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u7a33\u5b9a\u548c\u9ad8\u6548\u7684\u6570\u636e\u540c\u6b65\u529f\u80fd\uff0c\u65e8\u5728\u5b9e\u73b0\u5404\u79cd\u5f02\u6784\u6570\u636e\u6e90\u4e4b\u95f4\u7684\u9ad8\u6548\u6570\u636e\u540c\u6b65\u3002
DataX \u5c06\u4e0d\u540c\u6570\u636e\u6e90\u7684\u540c\u6b65\u5206\u4e3a\u4e24\u4e2a\u4e3b\u8981\u7ec4\u4ef6\uff1aReader\uff08\u8bfb\u53d6\u6570\u636e\u6e90\uff09 \u548c Writer\uff08\u5199\u5165\u76ee\u6807\u6570\u636e\u6e90\uff09\u3002DataX \u6846\u67b6\u7406\u8bba\u4e0a\u652f\u6301\u4efb\u4f55\u6570\u636e\u6e90\u7c7b\u578b\u7684\u6570\u636e\u540c\u6b65\u5de5\u4f5c\u3002
MatrixOne \u4e0e MySQL 8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u4f46\u7531\u4e8e DataX \u81ea\u5e26\u7684 MySQL Writer \u63d2\u4ef6\u9002\u914d\u7684\u662f MySQL 5.1 \u7684 JDBC \u9a71\u52a8\uff0c\u4e3a\u4e86\u63d0\u5347\u517c\u5bb9\u6027\uff0c\u793e\u533a\u5355\u72ec\u6539\u9020\u4e86\u57fa\u4e8e MySQL 8.0 \u9a71\u52a8\u7684 MatrixOneWriter \u63d2\u4ef6\u3002MatrixOneWriter \u63d2\u4ef6\u5b9e\u73b0\u4e86\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u76ee\u6807\u8868\u7684\u529f\u80fd\u3002\u5728\u5e95\u5c42\u5b9e\u73b0\u4e2d\uff0cMatrixOneWriter \u901a\u8fc7 JDBC \u8fde\u63a5\u5230\u8fdc\u7a0b MatrixOne \u6570\u636e\u5e93\uff0c\u5e76\u6267\u884c\u76f8\u5e94\u7684 insert into ...
SQL \u8bed\u53e5\u5c06\u6570\u636e\u5199\u5165 MatrixOne\uff0c\u540c\u65f6\u652f\u6301\u6279\u91cf\u63d0\u4ea4\u3002
MatrixOneWriter \u5229\u7528 DataX \u6846\u67b6\u4ece Reader \u83b7\u53d6\u751f\u6210\u7684\u534f\u8bae\u6570\u636e\uff0c\u5e76\u6839\u636e\u60a8\u914d\u7f6e\u7684 writeMode
\u751f\u6210\u76f8\u5e94\u7684 insert into...
\u8bed\u53e5\u3002\u5728\u9047\u5230\u4e3b\u952e\u6216\u552f\u4e00\u6027\u7d22\u5f15\u51b2\u7a81\u65f6\uff0c\u4f1a\u6392\u9664\u51b2\u7a81\u7684\u884c\u5e76\u7ee7\u7eed\u5199\u5165\u3002\u51fa\u4e8e\u6027\u80fd\u4f18\u5316\u7684\u8003\u8651\uff0c\u6211\u4eec\u91c7\u7528\u4e86 PreparedStatement + Batch
\u7684\u65b9\u5f0f\uff0c\u5e76\u8bbe\u7f6e\u4e86 rewriteBatchedStatements=true
\u9009\u9879\uff0c\u4ee5\u5c06\u6570\u636e\u7f13\u51b2\u5230\u7ebf\u7a0b\u4e0a\u4e0b\u6587\u7684\u7f13\u51b2\u533a\u4e2d\u3002\u53ea\u6709\u5f53\u7f13\u51b2\u533a\u7684\u6570\u636e\u91cf\u8fbe\u5230\u9884\u5b9a\u7684\u9608\u503c\u65f6\uff0c\u624d\u4f1a\u89e6\u53d1\u5199\u5165\u8bf7\u6c42\u3002
Note
\u6267\u884c\u6574\u4e2a\u4efb\u52a1\u81f3\u5c11\u9700\u8981\u62e5\u6709 insert into ...
\u7684\u6743\u9650\uff0c\u662f\u5426\u9700\u8981\u5176\u4ed6\u6743\u9650\u53d6\u51b3\u4e8e\u4f60\u5728\u4efb\u52a1\u914d\u7f6e\u4e2d\u7684 preSql
\u548c postSql
\u3002
MatrixOneWriter \u4e3b\u8981\u9762\u5411 ETL \u5f00\u53d1\u5de5\u7a0b\u5e08\uff0c\u4ed6\u4eec\u4f7f\u7528 MatrixOneWriter \u5c06\u6570\u636e\u4ece\u6570\u636e\u4ed3\u5e93\u5bfc\u5165\u5230 MatrixOne\u3002\u540c\u65f6\uff0cMatrixOneWriter \u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u6570\u636e\u8fc1\u79fb\u5de5\u5177\u4e3a DBA \u7b49\u7528\u6237\u63d0\u4f9b\u670d\u52a1\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u5f00\u59cb\u4f7f\u7528 DataX \u5c06\u6570\u636e\u5199\u5165 MatrixOne \u4e4b\u524d\uff0c\u9700\u8981\u5b8c\u6210\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\uff1a
plugin/writer/
\u76ee\u5f55\u4e0b\u3002\u4f7f\u7528 Mysql Client \u8fde\u63a5 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u8868\uff1a
CREATE DATABASE mo_demo;\nUSE mo_demo;\nCREATE TABLE m_user(\nM_ID INT NOT NULL,\nM_NAME CHAR(25) NOT NULL\n);\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_4","title":"\u914d\u7f6e\u6570\u636e\u6e90","text":"\u672c\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5185\u5b58\u4e2d\u751f\u6210\u7684\u6570\u636e\u4f5c\u4e3a\u6570\u636e\u6e90\uff1a
\"reader\": {\n\"name\": \"streamreader\", \"parameter\": {\n\"column\" : [ #\u53ef\u4ee5\u5199\u591a\u4e2a\u5217\n{\n\"value\": 20210106, #\u8868\u793a\u8be5\u5217\u7684\u503c\n\"type\": \"long\" #\u8868\u793a\u8be5\u5217\u7684\u7c7b\u578b\n},\n{\n\"value\": \"matrixone\",\n\"type\": \"string\"\n}\n],\n\"sliceRecordCount\": 1000 #\u8868\u793a\u8981\u6253\u5370\u591a\u5c11\u6b21\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_5","title":"\u7f16\u5199\u4f5c\u4e1a\u914d\u7f6e\u6587\u4ef6","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u914d\u7f6e\u6a21\u677f\uff1a
python datax.py -r {YOUR_READER} -w matrixonewriter\n
\u7f16\u5199\u4f5c\u4e1a\u7684\u914d\u7f6e\u6587\u4ef6 stream2matrixone.json
\uff1a
{\n\"job\": {\n\"setting\": {\n\"speed\": {\n\"channel\": 1\n}\n},\n\"content\": [\n{\n\"reader\": {\n\"name\": \"streamreader\",\n\"parameter\": {\n\"column\" : [\n{\n\"value\": 20210106,\n\"type\": \"long\"\n},\n{\n\"value\": \"matrixone\",\n\"type\": \"string\"\n}\n],\n\"sliceRecordCount\": 1000\n}\n},\n\"writer\": {\n\"name\": \"matrixonewriter\",\n\"parameter\": {\n\"writeMode\": \"insert\",\n\"username\": \"root\",\n\"password\": \"111\",\n\"column\": [\n\"M_ID\",\n\"M_NAME\"\n],\n\"preSql\": [\n\"delete from m_user\"\n],\n\"connection\": [\n{\n\"jdbcUrl\": \"jdbc:mysql://127.0.0.1:6001/mo_demo\",\n\"table\": [\n\"m_user\"\n]\n}\n]\n}\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#datax","title":"\u542f\u52a8 DataX","text":"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 DataX\uff1a
$ cd {YOUR_DATAX_DIR_BIN}\n$ python datax.py stream2matrixone.json\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_6","title":"\u67e5\u770b\u8fd0\u884c\u7ed3\u679c","text":"\u4f7f\u7528 Mysql Client \u8fde\u63a5 MatrixOne\uff0c\u4f7f\u7528 select
\u67e5\u8be2\u63d2\u5165\u7684\u7ed3\u679c\u3002\u5185\u5b58\u4e2d\u7684 1000 \u6761\u6570\u636e\u5df2\u6210\u529f\u5199\u5165 MatrixOne\u3002
mysql> select * from m_user limit 5;\n+----------+-----------+\n| m_id | m_name |\n+----------+-----------+\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n+----------+-----------+\n5 rows in set (0.01 sec)\n\nmysql> select count(*) from m_user limit 5;\n+----------+\n| count(*) |\n+----------+\n| 1000 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_7","title":"\u53c2\u6570\u8bf4\u660e","text":"\u4ee5\u4e0b\u662f MatrixOneWriter \u7684\u4e00\u4e9b\u5e38\u7528\u53c2\u6570\u8bf4\u660e\uff1a
\u53c2\u6570\u540d\u79f0 \u53c2\u6570\u63cf\u8ff0 \u662f\u5426\u5fc5\u9009 \u9ed8\u8ba4\u503c jdbcUrl \u76ee\u6807\u6570\u636e\u5e93\u7684 JDBC \u8fde\u63a5\u4fe1\u606f\u3002DataX \u5728\u8fd0\u884c\u65f6\u4f1a\u5728\u63d0\u4f9b\u7684jdbcUrl
\u540e\u9762\u8ffd\u52a0\u4e00\u4e9b\u5c5e\u6027\uff0c\u4f8b\u5982\uff1ayearIsDateType=false&zeroDateTimeBehavior=CONVERT_TO_NULL&rewriteBatchedStatements=true&tinyInt1isBit=false&serverTimezone=Asia/Shanghai
\u3002 \u662f \u65e0 username \u76ee\u6807\u6570\u636e\u5e93\u7684\u7528\u6237\u540d\u3002 \u662f \u65e0 password \u76ee\u6807\u6570\u636e\u5e93\u7684\u5bc6\u7801\u3002 \u662f \u65e0 table \u76ee\u6807\u8868\u7684\u540d\u79f0\u3002\u652f\u6301\u5199\u5165\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\uff0c\u5982\u679c\u914d\u7f6e\u591a\u5f20\u8868\uff0c\u5fc5\u987b\u786e\u4fdd\u5b83\u4eec\u7684\u7ed3\u6784\u4fdd\u6301\u4e00\u81f4\u3002 \u662f \u65e0 column \u76ee\u6807\u8868\u4e2d\u9700\u8981\u5199\u5165\u6570\u636e\u7684\u5b57\u6bb5\uff0c\u5b57\u6bb5\u4e4b\u95f4\u7528\u82f1\u6587\u9017\u53f7\u5206\u9694\u3002\u4f8b\u5982\uff1a\"column\": [\"id\",\"name\",\"age\"]
\u3002\u5982\u679c\u8981\u5199\u5165\u6240\u6709\u5217\uff0c\u53ef\u4ee5\u4f7f\u7528 *
\u8868\u793a\uff0c\u4f8b\u5982\uff1a\"column\": [\"*\"]
\u3002 \u662f \u65e0 preSql \u5199\u5165\u6570\u636e\u5230\u76ee\u6807\u8868\u4e4b\u524d\uff0c\u4f1a\u6267\u884c\u8fd9\u91cc\u914d\u7f6e\u7684\u6807\u51c6 SQL \u8bed\u53e5\u3002 \u5426 \u65e0 postSql \u5199\u5165\u6570\u636e\u5230\u76ee\u6807\u8868\u4e4b\u540e\uff0c\u4f1a\u6267\u884c\u8fd9\u91cc\u914d\u7f6e\u7684\u6807\u51c6 SQL \u8bed\u53e5\u3002 \u5426 \u65e0 writeMode \u63a7\u5236\u5199\u5165\u6570\u636e\u5230\u76ee\u6807\u8868\u65f6\u4f7f\u7528\u7684 SQL \u8bed\u53e5\uff0c\u53ef\u4ee5\u9009\u62e9 insert
\u6216 update
\u3002 insert
\u6216 update
insert
batchSize \u4e00\u6b21\u6027\u6279\u91cf\u63d0\u4ea4\u7684\u8bb0\u5f55\u6570\u5927\u5c0f\uff0c\u53ef\u4ee5\u663e\u8457\u51cf\u5c11 DataX \u4e0e MatrixOne \u7684\u7f51\u7edc\u4ea4\u4e92\u6b21\u6570\uff0c\u63d0\u9ad8\u6574\u4f53\u541e\u5410\u91cf\u3002\u4f46\u662f\u8bbe\u7f6e\u8fc7\u5927\u53ef\u80fd\u5bfc\u81f4 DataX \u8fd0\u884c\u8fdb\u7a0b\u5185\u5b58\u6ea2\u51fa \u5426 1024"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_8","title":"\u7c7b\u578b\u8f6c\u6362","text":"MatrixOneWriter \u652f\u6301\u5927\u591a\u6570 MatrixOne \u6570\u636e\u7c7b\u578b\uff0c\u4f46\u4e5f\u6709\u5c11\u6570\u7c7b\u578b\u5c1a\u672a\u652f\u6301\uff0c\u9700\u8981\u7279\u522b\u6ce8\u610f\u4f60\u7684\u6570\u636e\u7c7b\u578b\u3002
\u4ee5\u4e0b\u662f MatrixOneWriter \u9488\u5bf9 MatrixOne \u6570\u636e\u7c7b\u578b\u7684\u8f6c\u6362\u5217\u8868\uff1a
DataX \u5185\u90e8\u7c7b\u578b MatrixOne \u6570\u636e\u7c7b\u578b Long int, tinyint, smallint, bigint Double float, double, decimal String varchar, char, text Date date, datetime, timestamp, time Boolean bool Bytes blob"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_9","title":"\u53c2\u8003\u5176\u4ed6\u8bf4\u660e","text":"MatrixOne \u517c\u5bb9 MySQL \u534f\u8bae\uff0cMatrixOneWriter \u5b9e\u9645\u4e0a\u662f\u5bf9 MySQL Writer \u8fdb\u884c\u4e86\u4e00\u4e9b JDBC \u9a71\u52a8\u7248\u672c\u4e0a\u7684\u8c03\u6574\u540e\u7684\u6539\u9020\u7248\u672c\uff0c\u4f60\u4ecd\u7136\u53ef\u4ee5\u4f7f\u7528 MySQL Writer \u6765\u5199\u5165 MatrixOne\u3002
\u5728 DataX \u4e2d\u6dfb\u52a0 MatrixOne Writer\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u4e0b\u8f7d matrixonewriter.zip\uff0c\u7136\u540e\u5c06\u5176\u89e3\u538b\u7f29\u5230 DataX \u9879\u76ee\u6839\u76ee\u5f55\u7684 plugin/writer/
\u76ee\u5f55\u4e0b\uff0c\u5373\u53ef\u5f00\u59cb\u4f7f\u7528\u3002
MatrixOne \u64c5\u957f HTAP \u573a\u666f\u7684\u4e8b\u52a1\u5904\u7406\u548c\u4f4e\u5ef6\u8fdf\u5206\u6790\u8ba1\u7b97\uff0cElasticSearch \u64c5\u957f\u5168\u6587\u68c0\u7d22\uff0c\u4e24\u8005\u505a\u4e3a\u6d41\u884c\u7684\u641c\u7d22\u548c\u5206\u6790\u5f15\u64ce\uff0c\u7ed3\u5408\u8d77\u6765\u53ef\u5f62\u6210\u66f4\u5b8c\u5584\u7684\u5168\u573a\u666f\u5206\u6790\u89e3\u51b3\u65b9\u6848\u3002\u4e3a\u4e86\u5728\u4e0d\u540c\u573a\u666f\u95f4\u8fdb\u884c\u6570\u636e\u7684\u9ad8\u6548\u6d41\u8f6c\uff0c\u6211\u4eec\u53ef\u901a\u8fc7 DataX \u8fdb\u884c MatrixOne \u4e0e ElasticSearch \u95f4\u7684\u6570\u636e\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_10","title":"\u73af\u5883\u51c6\u5907","text":"MatrixOne \u7248\u672c\uff1a1.1.3
Elasticsearch \u7248\u672c\uff1a7.10.2
DataX \u7248\u672c\uff1aDataX_v202309
\u521b\u5efa\u6570\u636e\u5e93 mo
\uff0c\u5e76\u5728\u8be5\u5e93\u521b\u5efa\u6570\u636e\u8868 person\uff1a
create database mo;\nCREATE TABLE mo.`person` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`birthday` DATE DEFAULT NULL\n);\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#elasticsearch","title":"\u5728 ElasticSearch \u4e2d\u521b\u5efa\u7d22\u5f15","text":"\u521b\u5efa\u540d\u79f0\u4e3a person \u7684\u7d22\u5f15\uff08\u4e0b\u6587 -u
\u53c2\u6570\u540e\u4e3a ElasticSearch \u4e2d\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u672c\u5730\u6d4b\u8bd5\u65f6\u53ef\u6309\u9700\u8fdb\u884c\u4fee\u6539\u6216\u5220\u9664\uff09\uff1a
curl -X PUT \"http://127.0.0.1:9200/person\" -u elastic:elastic\n
\u8f93\u51fa\u5982\u4e0b\u4fe1\u606f\u8868\u793a\u521b\u5efa\u6210\u529f\uff1a
{\"acknowledged\":true,\"shards_acknowledged\":true,\"index\":\"person\"}\n
\u7ed9\u7d22\u5f15 person \u6dfb\u52a0\u5b57\u6bb5\uff1a
curl -X PUT \"127.0.0.1:9200/person/_mapping\" -H 'Content-Type: application/json' -u elastic:elastic -d'\n{\n \"properties\": {\n \"id\": { \"type\": \"integer\" },\n \"name\": { \"type\": \"text\" },\n \"birthday\": {\"type\": \"date\"}\n }\n}\n'\n
\u8f93\u51fa\u5982\u4e0b\u4fe1\u606f\u8868\u793a\u8bbe\u7f6e\u6210\u529f\uff1a
{\"acknowledged\":true}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#elasticsearch_1","title":"\u4e3a ElasticSearch \u7d22\u5f15\u6dfb\u52a0\u6570\u636e","text":"\u901a\u8fc7 curl \u547d\u4ee4\u6dfb\u52a0\u4e09\u6761\u6570\u636e\uff1a
curl -X POST '127.0.0.1:9200/person/_bulk' -H 'Content-Type: application/json' -u elastic:elastic -d '\n{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":1}}\n{\"id\": 1,\"name\": \"MatrixOne\",\"birthday\": \"1992-08-08\"}\n{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":2}}\n{\"id\": 2,\"name\": \"MO\",\"birthday\": \"1993-08-08\"}\n{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":3}}\n{\"id\": 3,\"name\": \"\u58a8\u58a8\",\"birthday\": \"1994-08-08\"}\n'
\u8f93\u51fa\u5982\u4e0b\u4fe1\u606f\u8868\u793a\u6267\u884c\u6210\u529f\uff1a
{\"took\":5,\"errors\":false,\"items\":[{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":\"1\",\"_version\":1,\"result\":\"created\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"_seq_no\":0,\"_primary_term\":1,\"status\":201}},{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":\"2\",\"_version\":1,\"result\":\"created\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"_seq_no\":1,\"_primary_term\":1,\"status\":201}},{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":\"3\",\"_version\":1,\"result\":\"created\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"_seq_no\":2,\"_primary_term\":1,\"status\":201}}]}\n
\u67e5\u770b\u7d22\u5f15\u4e2d\u6240\u6709\u5185\u5bb9\uff1a
curl -u elastic:elastic -X GET http://127.0.0.1:9200/person/_search?pretty -H 'Content-Type: application/json' -d'\n{\n \"query\" : {\n \"match_all\": {}\n }\n}'\n
\u53ef\u6b63\u5e38\u770b\u5230\u7d22\u5f15\u4e2d\u65b0\u589e\u7684\u6570\u636e\u5373\u8868\u793a\u6267\u884c\u6210\u529f\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#datax_1","title":"\u4f7f\u7528 DataX \u5bfc\u5165\u6570\u636e","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#1-datax","title":"1. \u4e0b\u8f7d\u5e76\u89e3\u538b DataX","text":"DataX \u89e3\u538b\u540e\u76ee\u5f55\u5982\u4e0b\uff1a
[root@node01 datax]# ll\ntotal 4\ndrwxr-xr-x. 2 root root 59 Nov 28 13:48 bin\ndrwxr-xr-x. 2 root root 68 Oct 11 09:55 conf\ndrwxr-xr-x. 2 root root 22 Oct 11 09:55 job\ndrwxr-xr-x. 2 root root 4096 Oct 11 09:55 lib\ndrwxr-xr-x. 4 root root 42 Oct 12 18:42 log\ndrwxr-xr-x. 4 root root 42 Oct 12 18:42 log_perf\ndrwxr-xr-x. 4 root root 34 Oct 11 09:55 plugin\ndrwxr-xr-x. 2 root root 23 Oct 11 09:55 script\ndrwxr-xr-x. 2 root root 24 Oct 11 09:55 tmp\n
\u4e3a\u4fdd\u8bc1\u8fc1\u79fb\u7684\u6613\u7528\u6027\u548c\u9ad8\u6548\u6027\uff0cMatrixOne \u793e\u533a\u5f00\u53d1\u4e86 elasticsearchreader
\u4ee5\u53ca matrixonewriter
\u4e24\u4e2a\u63d2\u4ef6\uff0c\u5c06 elasticsearchreader.zip \u4e0b\u8f7d\u540e\u4f7f\u7528 unzip
\u547d\u4ee4\u89e3\u538b\u81f3 datax/plugin/reader
\u76ee\u5f55\u4e0b\uff08\u6ce8\u610f\u4e0d\u8981\u5728\u8be5\u76ee\u5f55\u4e2d\u4fdd\u7559\u63d2\u4ef6 zip \u5305\uff0c\u5173\u4e8e elasticsearchreader \u7684\u8be6\u7ec6\u4ecb\u7ecd\u53ef\u53c2\u8003\u63d2\u4ef6\u5305\u5185\u7684 elasticsearchreader.md \u6587\u6863\uff09\uff0c\u540c\u6837\uff0c\u5c06 matrixonewriter.zip \u4e0b\u8f7d\u540e\u89e3\u538b\u81f3 datax/plugin/writer
\u76ee\u5f55\u4e0b\uff0cmatrixonewriter \u662f\u793e\u533a\u57fa\u4e8e mysqlwriter \u7684\u6539\u9020\u7248\uff0c\u4f7f\u7528 mysql-connector-j-8.0.33.jar \u9a71\u52a8\u6765\u4fdd\u8bc1\u66f4\u597d\u7684\u6027\u80fd\u548c\u517c\u5bb9\u6027\uff0cwriter \u90e8\u5206\u7684\u5176\u8bed\u6cd5\u53ef\u53c2\u8003\u4e0a\u6587\u201c\u53c2\u6570\u8bf4\u660e\u201d\u7ae0\u8282\u3002
\u5728\u8fdb\u884c\u540e\u7eed\u7684\u64cd\u4f5c\u524d\uff0c\u8bf7\u5148\u68c0\u67e5\u63d2\u4ef6\u662f\u5426\u5df2\u6b63\u786e\u5206\u53d1\u5728\u5bf9\u5e94\u7684\u4f4d\u7f6e\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#2-elasticsearch-matrixone","title":"2. \u7f16\u5199 ElasticSearch \u81f3 MatrixOne \u7684\u8fc1\u79fb\u4f5c\u4e1a\u6587\u4ef6","text":"DataX \u4f7f\u7528 json \u6587\u4ef6\u6765\u914d\u7f6e\u4f5c\u4e1a\u4fe1\u606f\uff0c\u7f16\u5199\u4f5c\u4e1a\u6587\u4ef6\u4f8b\u5982 es2mo.json\uff0c\u4e60\u60ef\u6027\u7684\u53ef\u4ee5\u5c06\u5176\u5b58\u653e\u5728 datax/job
\u76ee\u5f55\u4e2d\uff1a
{\n\"job\":{\n\"setting\":{\n\"speed\":{\n\"channel\":1\n},\n\"errorLimit\":{\n\"record\":0,\n\"percentage\":0.02\n}\n},\n\"content\":[\n{\n\"reader\":{\n\"name\":\"elasticsearchreader\",\n\"parameter\":{\n\"endpoint\":\"http://127.0.0.1:9200\",\n\"accessId\":\"elastic\",\n\"accessKey\":\"elastic\",\n\"index\":\"person\",\n\"type\":\"_doc\",\n\"headers\":{\n\n},\n\"scroll\":\"3m\",\n\"search\":[\n{\n\"query\":{\n\"match_all\":{\n\n}\n}\n}\n],\n\"table\":{\n\"filter\":\"\",\n\"nameCase\":\"UPPERCASE\",\n\"column\":[\n{\n\"name\":\"id\",\n\"type\":\"integer\"\n},\n{\n\"name\":\"name\",\n\"type\":\"text\"\n},\n{\n\"name\":\"birthday\",\n\"type\":\"date\"\n}\n]\n}\n}\n},\n\"writer\":{\n\"name\":\"matrixonewriter\",\n\"parameter\":{\n\"username\":\"root\",\n\"password\":\"111\",\n\"column\":[\n\"id\",\n\"name\",\n\"birthday\"\n],\n\"connection\":[\n{\n\"table\":[\n\"person\"\n],\n\"jdbcUrl\":\"jdbc:mysql://127.0.0.1:6001/mo\"\n}\n]\n}\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#3","title":"3. \u6267\u884c\u8fc1\u79fb\u4efb\u52a1","text":"\u8fdb\u5165 datax \u5b89\u88c5\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u8fc1\u79fb\u4f5c\u4e1a\uff1a
cd datax\npython bin/datax.py job/es2mo.json\n
\u4f5c\u4e1a\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
2023-11-28 15:55:45.642 [job-0] INFO StandAloneJobContainerCommunicator - Total 3 records, 67 bytes | Speed 6B/s, 0 records/s | Error 0 records, 0 bytes | All Task WaitWriterTime 0.000s | All Task WaitReaderTime 0.456s | Percentage 100.00%\n2023-11-28 15:55:45.644 [job-0] INFO JobContainer - \n\u4efb\u52a1\u542f\u52a8\u65f6\u523b : 2023-11-28 15:55:31\n\u4efb\u52a1\u7ed3\u675f\u65f6\u523b : 2023-11-28 15:55:45\n\u4efb\u52a1\u603b\u8ba1\u8017\u65f6 : 14s\n\u4efb\u52a1\u5e73\u5747\u6d41\u91cf : 6B/s\n\u8bb0\u5f55\u5199\u5165\u901f\u5ea6 : 0rec/s\n\u8bfb\u51fa\u8bb0\u5f55\u603b\u6570 : 3\n\u8bfb\u5199\u5931\u8d25\u603b\u6570 : 0\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#4-matrixone","title":"4. \u5728 MatrixOne \u4e2d\u67e5\u770b\u8fc1\u79fb\u540e\u6570\u636e","text":"\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\u67e5\u770b\u76ee\u6807\u8868\u4e2d\u7684\u7ed3\u679c\uff0c\u786e\u8ba4\u8fc1\u79fb\u5df2\u5b8c\u6210\uff1a
mysql> select * from mo.person;\n+------+-----------+------------+\n| id | name | birthday |\n+------+-----------+------------+\n| 1 | MatrixOne | 1992-08-08 |\n| 2 | MO | 1993-08-08 |\n| 3 | \u58a8\u58a8 | 1994-08-08 |\n+------+-----------+------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#5-matrixone-elasticsearch","title":"5. \u7f16\u5199 MatrixOne \u81f3 ElasticSearch \u7684\u4f5c\u4e1a\u6587\u4ef6","text":"\u7f16\u5199 datax \u4f5c\u4e1a\u6587\u4ef6 mo2es.json\uff0c\u540c\u6837\u653e\u5728 datax/job
\u76ee\u5f55\uff0cMatrixOne \u9ad8\u5ea6\u517c\u5bb9 MySQL \u534f\u8bae\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 mysqlreader \u6765\u901a\u8fc7 jdbc \u65b9\u5f0f\u8bfb\u53d6 MatrixOne \u4e2d\u7684\u6570\u636e\uff1a
{\n\"job\": {\n\"setting\": {\n\"speed\": {\n\"channel\": 1\n},\n\"errorLimit\": {\n\"record\": 0,\n\"percentage\": 0.02\n}\n},\n\"content\": [{\n\"reader\": {\n\"name\": \"mysqlreader\",\n\"parameter\": {\n\"username\": \"root\",\n\"password\": \"111\",\n\"column\": [\n\"id\",\n\"name\",\n\"birthday\"\n],\n\"splitPk\": \"id\",\n\"connection\": [{\n\"table\": [\n\"person\"\n],\n\"jdbcUrl\": [\n\"jdbc:mysql://127.0.0.1:6001/mo\"\n]\n}]\n}\n},\n\"writer\": {\n\"name\": \"elasticsearchwriter\",\n\"parameter\": {\n\"endpoint\": \"http://127.0.0.1:9200\",\n\"accessId\": \"elastic\",\n\"accessKey\": \"elastic\",\n\"index\": \"person\",\n\"type\": \"_doc\",\n\"cleanup\": true,\n\"settings\": {\n\"index\": {\n\"number_of_shards\": 1,\n\"number_of_replicas\": 1\n}\n},\n\"discovery\": false,\n\"batchSize\": 1000,\n\"splitter\": \",\",\n\"column\": [{\n\"name\": \"id\",\n\"type\": \"integer\"\n},\n{\n\"name\": \"name\",\n\"type\": \"text\"\n},\n{\n\"name\": \"birthday\",\n\"type\": \"date\"\n}\n]\n\n}\n\n}\n}]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#6matrixone","title":"6.MatrixOne \u6570\u636e\u51c6\u5907","text":"truncate table mo.person;\nINSERT into mo.person (id, name, birthday)\nVALUES(1, 'mo101', '2023-07-09'),(2, 'mo102', '2023-07-08'),(3, 'mo103', '2023-07-12');\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#7-matrixone-elasticsearch","title":"7. \u6267\u884c MatrixOne \u5411 ElasticSearch \u7684\u8fc1\u79fb\u4efb\u52a1","text":"\u8fdb\u5165 datax \u5b89\u88c5\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4
cd datax\npython bin/datax.py job/mo2es.json\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
2023-11-28 17:38:04.795 [job-0] INFO StandAloneJobContainerCommunicator - Total 3 records, 42 bytes | Speed 4B/s, 0 records/s | Error 0 records, 0 bytes | All Task WaitWriterTime 0.000s | All Task WaitReaderTime 0.000s | Percentage 100.00%\n2023-11-28 17:38:04.799 [job-0] INFO JobContainer - \n\u4efb\u52a1\u542f\u52a8\u65f6\u523b : 2023-11-28 17:37:49\n\u4efb\u52a1\u7ed3\u675f\u65f6\u523b : 2023-11-28 17:38:04\n\u4efb\u52a1\u603b\u8ba1\u8017\u65f6 : 15s\n\u4efb\u52a1\u5e73\u5747\u6d41\u91cf : 4B/s\n\u8bb0\u5f55\u5199\u5165\u901f\u5ea6 : 0rec/s\n\u8bfb\u51fa\u8bb0\u5f55\u603b\u6570 : 3\n\u8bfb\u5199\u5931\u8d25\u603b\u6570 : 0\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#8","title":"8. \u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 Elasticsearch \u4e2d\u67e5\u770b\u7ed3\u679c
curl -u elastic:elastic -X GET http://127.0.0.1:9200/person/_search?pretty -H 'Content-Type: application/json' -d'\n{\n \"query\" : {\n \"match_all\": {}\n }\n}'\n
\u7ed3\u679c\u663e\u793a\u5982\u4e0b\uff0c\u8868\u793a\u8fc1\u79fb\u4f5c\u4e1a\u5df2\u6b63\u5e38\u5b8c\u6210\uff1a
{\n\"took\" : 7,\n\"timed_out\" : false,\n\"_shards\" : {\n\"total\" : 1,\n\"successful\" : 1,\n\"skipped\" : 0,\n\"failed\" : 0\n},\n\"hits\" : {\n\"total\" : {\n\"value\" : 3,\n\"relation\" : \"eq\"\n},\n\"max_score\" : 1.0,\n\"hits\" : [\n{\n\"_index\" : \"person\",\n\"_type\" : \"_doc\",\n\"_id\" : \"dv9QFYwBPwIzfbNQfgG1\",\n\"_score\" : 1.0,\n\"_source\" : {\n\"birthday\" : \"2023-07-09T00:00:00.000+08:00\",\n\"name\" : \"mo101\",\n\"id\" : 1\n}\n},\n{\n\"_index\" : \"person\",\n\"_type\" : \"_doc\",\n\"_id\" : \"d_9QFYwBPwIzfbNQfgG1\",\n\"_score\" : 1.0,\n\"_source\" : {\n\"birthday\" : \"2023-07-08T00:00:00.000+08:00\",\n\"name\" : \"mo102\",\n\"id\" : 2\n}\n},\n{\n\"_index\" : \"person\",\n\"_type\" : \"_doc\",\n\"_id\" : \"eP9QFYwBPwIzfbNQfgG1\",\n\"_score\" : 1.0,\n\"_source\" : {\n\"birthday\" : \"2023-07-12T00:00:00.000+08:00\",\n\"name\" : \"mo103\",\n\"id\" : 3\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_11","title":"\u5e38\u89c1\u95ee\u9898","text":"Q: \u5728\u8fd0\u884c\u65f6\uff0c\u6211\u9047\u5230\u4e86\u201c\u914d\u7f6e\u4fe1\u606f\u9519\u8bef\uff0c\u60a8\u63d0\u4f9b\u7684\u914d\u7f6e\u6587\u4ef6/{YOUR_MATRIXONE_WRITER_PATH}/plugin.json \u4e0d\u5b58\u5728\u201d\u7684\u95ee\u9898\u8be5\u600e\u4e48\u5904\u7406\uff1f
A: DataX \u5728\u542f\u52a8\u65f6\u4f1a\u5c1d\u8bd5\u67e5\u627e\u76f8\u4f3c\u7684\u6587\u4ef6\u5939\u4ee5\u5bfb\u627e plugin.json \u6587\u4ef6\u3002\u5982\u679c matrixonewriter.zip \u6587\u4ef6\u4e5f\u5b58\u5728\u4e8e\u76f8\u540c\u7684\u76ee\u5f55\u4e0b\uff0cDataX \u5c06\u5c1d\u8bd5\u4ece .../datax/plugin/writer/matrixonewriter.zip/plugin.json
\u4e2d\u67e5\u627e\u3002\u5728 MacOS \u73af\u5883\u4e0b\uff0cDataX \u8fd8\u4f1a\u5c1d\u8bd5\u4ece .../datax/plugin/writer/.DS_Store/plugin.json
\u4e2d\u67e5\u627e\u3002\u6b64\u65f6\uff0c\u60a8\u9700\u8981\u5220\u9664\u8fd9\u4e9b\u591a\u4f59\u7684\u6587\u4ef6\u6216\u6587\u4ef6\u5939\u3002
Apache Flink \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6846\u67b6\u548c\u5206\u5e03\u5f0f\u5904\u7406\u5f15\u64ce\uff0c\u4e13\u6ce8\u4e8e\u8fdb\u884c\u6709\u72b6\u6001\u8ba1\u7b97\uff0c\u9002\u7528\u4e8e\u5904\u7406\u65e0\u8fb9\u754c\u548c\u6709\u8fb9\u754c\u7684\u6570\u636e\u6d41\u3002Flink \u80fd\u591f\u5728\u5404\u79cd\u5e38\u89c1\u96c6\u7fa4\u73af\u5883\u4e2d\u9ad8\u6548\u8fd0\u884c\uff0c\u5e76\u4ee5\u5185\u5b58\u901f\u5ea6\u6267\u884c\u8ba1\u7b97\uff0c\u652f\u6301\u5904\u7406\u4efb\u610f\u89c4\u6a21\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u4e8b\u4ef6\u9a71\u52a8\u578b\u5e94\u7528
\u4e8b\u4ef6\u9a71\u52a8\u578b\u5e94\u7528\u901a\u5e38\u5177\u5907\u72b6\u6001\uff0c\u5e76\u4e14\u5b83\u4eec\u4ece\u4e00\u4e2a\u6216\u591a\u4e2a\u4e8b\u4ef6\u6d41\u4e2d\u63d0\u53d6\u6570\u636e\uff0c\u6839\u636e\u5230\u8fbe\u7684\u4e8b\u4ef6\u89e6\u53d1\u8ba1\u7b97\u3001\u72b6\u6001\u66f4\u65b0\u6216\u6267\u884c\u5176\u4ed6\u5916\u90e8\u52a8\u4f5c\u3002\u5178\u578b\u7684\u4e8b\u4ef6\u9a71\u52a8\u578b\u5e94\u7528\u5305\u62ec\u53cd\u6b3a\u8bc8\u7cfb\u7edf\u3001\u5f02\u5e38\u68c0\u6d4b\u3001\u57fa\u4e8e\u89c4\u5219\u7684\u62a5\u8b66\u7cfb\u7edf\u548c\u4e1a\u52a1\u6d41\u7a0b\u76d1\u63a7\u3002
\u6570\u636e\u5206\u6790\u5e94\u7528
\u6570\u636e\u5206\u6790\u4efb\u52a1\u7684\u4e3b\u8981\u76ee\u6807\u662f\u4ece\u539f\u59cb\u6570\u636e\u4e2d\u63d0\u53d6\u6709\u4ef7\u503c\u7684\u4fe1\u606f\u548c\u6307\u6807\u3002Flink \u652f\u6301\u6d41\u5f0f\u548c\u6279\u91cf\u5206\u6790\u5e94\u7528\uff0c\u9002\u7528\u4e8e\u5404\u79cd\u573a\u666f\uff0c\u4f8b\u5982\u7535\u4fe1\u7f51\u7edc\u8d28\u91cf\u76d1\u63a7\u3001\u79fb\u52a8\u5e94\u7528\u4e2d\u7684\u4ea7\u54c1\u66f4\u65b0\u548c\u5b9e\u9a8c\u8bc4\u4f30\u5206\u6790\u3001\u6d88\u8d39\u8005\u6280\u672f\u9886\u57df\u7684\u5b9e\u65f6\u6570\u636e\u5373\u5e2d\u5206\u6790\u4ee5\u53ca\u5927\u89c4\u6a21\u56fe\u5206\u6790\u3002
\u6570\u636e\u7ba1\u9053\u5e94\u7528
\u63d0\u53d6 - \u8f6c\u6362 - \u52a0\u8f7d\uff08ETL\uff09\u662f\u5728\u4e0d\u540c\u5b58\u50a8\u7cfb\u7edf\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u8f6c\u6362\u548c\u8fc1\u79fb\u7684\u5e38\u89c1\u65b9\u6cd5\u3002\u6570\u636e\u7ba1\u9053\u548c ETL \u4f5c\u4e1a\u6709\u76f8\u4f3c\u4e4b\u5904\uff0c\u90fd\u53ef\u4ee5\u8fdb\u884c\u6570\u636e\u8f6c\u6362\u548c\u4e30\u5bcc\uff0c\u7136\u540e\u5c06\u6570\u636e\u4ece\u4e00\u4e2a\u5b58\u50a8\u7cfb\u7edf\u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u5b58\u50a8\u7cfb\u7edf\u3002\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u6570\u636e\u7ba1\u9053\u4ee5\u6301\u7eed\u6d41\u6a21\u5f0f\u8fd0\u884c\uff0c\u800c\u4e0d\u662f\u5468\u671f\u6027\u89e6\u53d1\u3002\u5178\u578b\u7684\u6570\u636e\u7ba1\u9053\u5e94\u7528\u5305\u62ec\u7535\u5b50\u5546\u52a1\u4e2d\u7684\u5b9e\u65f6\u67e5\u8be2\u7d22\u5f15\u6784\u5efa\u548c\u6301\u7eed ETL\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u4e24\u79cd\u793a\u4f8b\uff0c\u4e00\u79cd\u662f\u4f7f\u7528\u8ba1\u7b97\u5f15\u64ce Flink \u5b9e\u73b0\u5c06\u5b9e\u65f6\u6570\u636e\u5199\u5165\u5230 MatrixOne\uff0c\u53e6\u4e00\u79cd\u662f\u4f7f\u7528\u8ba1\u7b97\u5f15\u64ce Flink \u5c06\u6d41\u5f0f\u6570\u636e\u5199\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_3","title":"\u524d\u671f\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_4","title":"\u786c\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u5bf9\u4e8e\u673a\u5668\u7684\u786c\u4ef6\u8981\u6c42\u5982\u4e0b\uff1a
\u670d\u52a1\u5668\u540d\u79f0 \u670d\u52a1\u5668 IP \u5b89\u88c5\u8f6f\u4ef6 \u64cd\u4f5c\u7cfb\u7edf node1 192.168.146.10 MatrixOne Debian11.1 x86 node2 192.168.146.12 kafka Centos7.9 node3 192.168.146.11 IDEA\u3001MYSQL win10"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_5","title":"\u8f6f\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u9700\u8981\u5b89\u88c5\u90e8\u7f72\u4ee5\u4e0b\u8f6f\u4ef6\u73af\u5883\uff1a
\u6253\u5f00 IDEA\uff0c\u70b9\u51fb File > New > Project\uff0c\u9009\u62e9 Spring Initializer\uff0c\u5e76\u586b\u5199\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u914d\u7f6e\u793a\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6dfb\u52a0\u9879\u76ee\u4f9d\u8d56\uff0c\u7f16\u8f91\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 pom.xml
\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u5185\u5bb9\u6dfb\u52a0\u5230\u6587\u4ef6\u4e2d\uff1a
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n<modelVersion>4.0.0</modelVersion>\n\n<groupId>com.matrixone.flink</groupId>\n<artifactId>matrixone-flink-demo</artifactId>\n<version>1.0-SNAPSHOT</version>\n\n<properties>\n<scala.binary.version>2.12</scala.binary.version>\n<java.version>1.8</java.version>\n<flink.version>1.17.0</flink.version>\n<scope.mode>compile</scope.mode>\n</properties>\n\n<dependencies>\n\n<!-- Flink Dependency -->\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-connector-hive_2.12</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-java</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-streaming-java</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-clients</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-table-api-java-bridge</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-table-planner_2.12</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<!-- JDBC\u76f8\u5173\u4f9d\u8d56\u5305 -->\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-connector-jdbc</artifactId>\n<version>1.15.4</version>\n</dependency>\n<dependency>\n<groupId>mysql</groupId>\n<artifactId>mysql-connector-java</artifactId>\n<version>8.0.33</version>\n</dependency>\n\n<!-- Kafka\u76f8\u5173\u4f9d\u8d56 -->\n<dependency>\n<groupId>org.apache.kafka</groupId>\n<artifactId>kafka_2.13</artifactId>\n<version>3.5.0</version>\n</dependency>\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-connector-kafka</artifactId>\n<version>3.0.0-1.17</version>\n</dependency>\n\n<!-- JSON -->\n<dependency>\n<groupId>com.alibaba.fastjson2</groupId>\n<artifactId>fastjson2</artifactId>\n<version>2.0.34</version>\n</dependency>\n\n</dependencies>\n\n\n\n\n<build>\n<plugins>\n<plugin>\n<groupId>org.apache.maven.plugins</groupId>\n<artifactId>maven-compiler-plugin</artifactId>\n<version>3.8.0</version>\n<configuration>\n<source>${java.version}</source>\n<target>${java.version}</target>\n<encoding>UTF-8</encoding>\n</configuration>\n</plugin>\n<plugin>\n<artifactId>maven-assembly-plugin</artifactId>\n<version>2.6</version>\n<configuration>\n<descriptorRefs>\n<descriptor>jar-with-dependencies</descriptor>\n</descriptorRefs>\n</configuration>\n<executions>\n<execution>\n<id>make-assembly</id>\n<phase>package</phase>\n<goals>\n<goal>single</goal>\n</goals>\n</execution>\n</executions>\n</plugin>\n\n</plugins>\n</build>\n\n</project>\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#matrixone","title":"\u6b65\u9aa4\u4e8c\uff1a\u8bfb\u53d6 MatrixOne \u6570\u636e","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u540e\uff0c\u521b\u5efa\u6f14\u793a\u6240\u9700\u7684\u6570\u636e\u5e93\u4ee5\u53ca\u6570\u636e\u8868\u3002
\u5728 MatrixOne \u4e2d\u521b\u5efa\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\uff0c\u5e76\u5bfc\u5165\u6570\u636e\uff1a
CREATE DATABASE test;\nUSE test;\nCREATE TABLE `person` (`id` INT DEFAULT NULL, `name` VARCHAR(255) DEFAULT NULL, `birthday` DATE DEFAULT NULL);\nINSERT INTO test.person (id, name, birthday) VALUES(1, 'zhangsan', '2023-07-09'),(2, 'lisi', '2023-07-08'),(3, 'wangwu', '2023-07-12');\n
\u5728 IDEA \u4e2d\u521b\u5efa MoRead.java
\u7c7b\uff0c\u4ee5\u4f7f\u7528 Flink \u8bfb\u53d6 MatrixOne \u6570\u636e\uff1a
package com.matrixone.flink.demo;\n\nimport org.apache.flink.api.common.functions.MapFunction;\nimport org.apache.flink.api.common.typeinfo.BasicTypeInfo;\nimport org.apache.flink.api.java.ExecutionEnvironment;\nimport org.apache.flink.api.java.operators.DataSource;\nimport org.apache.flink.api.java.operators.MapOperator;\nimport org.apache.flink.api.java.typeutils.RowTypeInfo;\nimport org.apache.flink.connector.jdbc.JdbcInputFormat;\nimport org.apache.flink.types.Row;\n\nimport java.text.SimpleDateFormat;\n\n/**\n * @author MatrixOne\n * @description\n */\npublic class MoRead {\n\nprivate static String srcHost = \"192.168.146.10\";\nprivate static Integer srcPort = 6001;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"111\";\nprivate static String srcDataBase = \"test\";\n\npublic static void main(String[] args) throws Exception {\n\nExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();\n// \u8bbe\u7f6e\u5e76\u884c\u5ea6\nenvironment.setParallelism(1);\nSimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd\");\n\n// \u8bbe\u7f6e\u67e5\u8be2\u7684\u5b57\u6bb5\u7c7b\u578b\nRowTypeInfo rowTypeInfo = new RowTypeInfo(\nnew BasicTypeInfo[]{\nBasicTypeInfo.INT_TYPE_INFO,\nBasicTypeInfo.STRING_TYPE_INFO,\nBasicTypeInfo.DATE_TYPE_INFO\n},\nnew String[]{\n\"id\",\n\"name\",\n\"birthday\"\n}\n);\n\nDataSource<Row> dataSource = environment.createInput(JdbcInputFormat.buildJdbcInputFormat()\n.setDrivername(\"com.mysql.cj.jdbc.Driver\")\n.setDBUrl(\"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase)\n.setUsername(srcUserName)\n.setPassword(srcPassword)\n.setQuery(\"select * from person\")\n.setRowTypeInfo(rowTypeInfo)\n.finish());\n\n// \u5c06 Wed Jul 12 00:00:00 CST 2023 \u65e5\u671f\u683c\u5f0f\u8f6c\u6362\u4e3a 2023-07-12\nMapOperator<Row, Row> mapOperator = dataSource.map((MapFunction<Row, Row>) row -> {\nrow.setField(\"birthday\", sdf.format(row.getField(\"birthday\")));\nreturn row;\n});\n\nmapOperator.print();\n}\n}\n
\u5728 IDEA \u4e2d\u8fd0\u884c MoRead.Main()
\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528 Flink \u5c06 MySQL \u6570\u636e\u8fc1\u79fb\u5230 MatrixOne\u3002
\u51c6\u5907 MySQL \u6570\u636e\uff1a\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730 Mysql\uff0c\u521b\u5efa\u6240\u9700\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\u3001\u5e76\u63d2\u5165\u6570\u636e\uff1a
mysql -h127.0.0.1 -P3306 -uroot -proot\nmysql> CREATE DATABASE motest;\nmysql> USE motest;\nmysql> CREATE TABLE `person` (`id` int DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `birthday` date DEFAULT NULL);\nmysql> INSERT INTO motest.person (id, name, birthday) VALUES(2, 'lisi', '2023-07-09'),(3, 'wangwu', '2023-07-13'),(4, 'zhaoliu', '2023-08-08');\n
\u6e05\u7a7a MatrixOne \u8868\u6570\u636e\uff1a
\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 node1 \u7684 MatrixOne\u3002\u7531\u4e8e\u672c\u793a\u4f8b\u7ee7\u7eed\u4f7f\u7528\u524d\u9762\u8bfb\u53d6 MatrixOne \u6570\u636e\u7684\u793a\u4f8b\u4e2d\u7684 test
\u6570\u636e\u5e93\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u9996\u5148\u6e05\u7a7a person
\u8868\u7684\u6570\u636e\u3002
-- \u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5 node1 \u7684 MatrixOne\nmysql -h192.168.146.10 -P6001 -uroot -p111\nmysql> TRUNCATE TABLE test.person;\n
\u5728 IDEA \u4e2d\u7f16\u5199\u4ee3\u7801\uff1a
\u521b\u5efa Person.java
\u548c Mysql2Mo.java
\u7c7b\uff0c\u4f7f\u7528 Flink \u8bfb\u53d6 MySQL \u6570\u636e\uff0c\u6267\u884c\u7b80\u5355\u7684 ETL \u64cd\u4f5c\uff08\u5c06 Row \u8f6c\u6362\u4e3a Person \u5bf9\u8c61\uff09\uff0c\u6700\u7ec8\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u4e2d\u3002
package com.matrixone.flink.demo.entity;\n\n\nimport java.util.Date;\n\npublic class Person {\n\nprivate int id;\nprivate String name;\nprivate Date birthday;\n\npublic int getId() {\nreturn id;\n}\n\npublic void setId(int id) {\nthis.id = id;\n}\n\npublic String getName() {\nreturn name;\n}\n\npublic void setName(String name) {\nthis.name = name;\n}\n\npublic Date getBirthday() {\nreturn birthday;\n}\n\npublic void setBirthday(Date birthday) {\nthis.birthday = birthday;\n}\n}\n
package com.matrixone.flink.demo;\n\nimport com.matrixone.flink.demo.entity.Person;\nimport org.apache.flink.api.common.functions.MapFunction;\nimport org.apache.flink.api.common.typeinfo.BasicTypeInfo;\nimport org.apache.flink.api.java.typeutils.RowTypeInfo;\nimport org.apache.flink.connector.jdbc.*;\nimport org.apache.flink.streaming.api.datastream.DataStreamSink;\nimport org.apache.flink.streaming.api.datastream.DataStreamSource;\nimport org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;\nimport org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;\nimport org.apache.flink.types.Row;\n\nimport java.sql.Date;\n\n/**\n * @author MatrixOne\n * @description\n */\npublic class Mysql2Mo {\n\nprivate static String srcHost = \"127.0.0.1\";\nprivate static Integer srcPort = 3306;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"root\";\nprivate static String srcDataBase = \"motest\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"person\";\n\n\npublic static void main(String[] args) throws Exception {\n\nStreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();\n//\u8bbe\u7f6e\u5e76\u884c\u5ea6\nenvironment.setParallelism(1);\n//\u8bbe\u7f6e\u67e5\u8be2\u7684\u5b57\u6bb5\u7c7b\u578b\nRowTypeInfo rowTypeInfo = new RowTypeInfo(\nnew BasicTypeInfo[]{\nBasicTypeInfo.INT_TYPE_INFO,\nBasicTypeInfo.STRING_TYPE_INFO,\nBasicTypeInfo.DATE_TYPE_INFO\n},\nnew String[]{\n\"id\",\n\"name\",\n\"birthday\"\n}\n);\n\n//\u6dfb\u52a0 srouce\nDataStreamSource<Row> dataSource = environment.createInput(JdbcInputFormat.buildJdbcInputFormat()\n.setDrivername(\"com.mysql.cj.jdbc.Driver\")\n.setDBUrl(\"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase)\n.setUsername(srcUserName)\n.setPassword(srcPassword)\n.setQuery(\"select * from person\")\n.setRowTypeInfo(rowTypeInfo)\n.finish());\n\n//\u8fdb\u884c ETL\nSingleOutputStreamOperator<Person> mapOperator = dataSource.map((MapFunction<Row, Person>) row -> {\nPerson person = new Person();\nperson.setId((Integer) row.getField(\"id\"));\nperson.setName((String) row.getField(\"name\"));\nperson.setBirthday((java.util.Date)row.getField(\"birthday\"));\nreturn person;\n});\n\n//\u8bbe\u7f6e matrixone sink \u4fe1\u606f\nmapOperator.addSink(\nJdbcSink.sink(\n\"insert into \" + destTable + \" values(?,?,?)\",\n(ps, t) -> {\nps.setInt(1, t.getId());\nps.setString(2, t.getName());\nps.setDate(3, new Date(t.getBirthday().getTime()));\n},\nnew JdbcConnectionOptions.JdbcConnectionOptionsBuilder()\n.withDriverName(\"com.mysql.cj.jdbc.Driver\")\n.withUrl(\"jdbc:mysql://\" + destHost + \":\" + destPort + \"/\" + destDataBase)\n.withUsername(destUserName)\n.withPassword(destPassword)\n.build()\n)\n);\n\nenvironment.execute();\n}\n\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_7","title":"\u6b65\u9aa4\u56db\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u8be2\u7ed3\u679c\uff1a
mysql> select * from test.person;\n+------+---------+------------+\n| id | name | birthday |\n+------+---------+------------+\n| 2 | lisi | 2023-07-09 |\n| 3 | wangwu | 2023-07-13 |\n| 4 | zhaoliu | 2023-08-08 |\n+------+---------+------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#2-kafka-matrixone","title":"\u793a\u4f8b 2\uff1a\u5c06 Kafka \u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#kafka","title":"\u6b65\u9aa4\u4e00\uff1a\u542f\u52a8 Kafka \u670d\u52a1","text":"Kafka \u96c6\u7fa4\u534f\u8c03\u548c\u5143\u6570\u636e\u7ba1\u7406\u53ef\u4ee5\u901a\u8fc7 KRaft \u6216 ZooKeeper \u6765\u5b9e\u73b0\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 Kafka 3.5.0 \u7248\u672c\uff0c\u65e0\u9700\u4f9d\u8d56\u72ec\u7acb\u7684 ZooKeeper \u8f6f\u4ef6\uff0c\u800c\u662f\u4f7f\u7528 Kafka \u81ea\u5e26\u7684 KRaft \u6765\u8fdb\u884c\u5143\u6570\u636e\u7ba1\u7406\u3002\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u4f4d\u4e8e Kafka \u8f6f\u4ef6\u6839\u76ee\u5f55\u4e0b\u7684 config/kraft/server.properties
\u3002
\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a
# Licensed to the Apache Software Foundation (ASF) under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding copyright ownership.\n# The ASF licenses this file to You under the Apache License, Version 2.0\n# (the \"License\"); you may not use this file except in compliance with\n# the License. You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n#\n# This configuration file is intended for use in KRaft mode, where\n# Apache ZooKeeper is not present. See config/kraft/README.md for details.\n#\n\n############################# Server Basics #############################\n\n# The role of this server. Setting this puts us in KRaft mode\nprocess.roles=broker,controller\n\n# The node id associated with this instance's roles\nnode.id=1\n\n# The connect string for the controller quorum\ncontroller.quorum.voters=1@192.168.146.12:9093\n\n############################# Socket Server Settings #############################\n\n# The address the socket server listens on.\n# Combined nodes (i.e. those with `process.roles=broker,controller`) must list the controller listener here at a minimum.\n# If the broker listener is not defined, the default listener will use a host name that is equal to the value of java.net.InetAddress.getCanonicalHostName(),\n# with PLAINTEXT listener name, and port 9092.\n# FORMAT:\n# listeners = listener_name://host_name:port\n# EXAMPLE:\n# listeners = PLAINTEXT://your.host.name:9092\n#listeners=PLAINTEXT://:9092,CONTROLLER://:9093\nlisteners=PLAINTEXT://192.168.146.12:9092,CONTROLLER://192.168.146.12:9093\n\n# Name of listener used for communication between brokers.\ninter.broker.listener.name=PLAINTEXT\n\n# Listener name, hostname and port the broker will advertise to clients.\n# If not set, it uses the value for \"listeners\".\n#advertised.listeners=PLAINTEXT://localhost:9092\n\n# A comma-separated list of the names of the listeners used by the controller.\n# If no explicit mapping set in `listener.security.protocol.map`, default will be using PLAINTEXT protocol\n# This is required if running in KRaft mode.\ncontroller.listener.names=CONTROLLER\n\n# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details\nlistener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL\n\n# The number of threads that the server uses for receiving requests from the network and sending responses to the network\nnum.network.threads=3\n\n# The number of threads that the server uses for processing requests, which may include disk I/O\nnum.io.threads=8\n\n# The send buffer (SO_SNDBUF) used by the socket server\nsocket.send.buffer.bytes=102400\n\n# The receive buffer (SO_RCVBUF) used by the socket server\nsocket.receive.buffer.bytes=102400\n\n# The maximum size of a request that the socket server will accept (protection against OOM)\nsocket.request.max.bytes=104857600\n\n\n############################# Log Basics #############################\n\n# A comma separated list of directories under which to store log files\nlog.dirs=/home/software/kafka_2.13-3.5.0/kraft-combined-logs\n\n# The default number of log partitions per topic. More partitions allow greater\n# parallelism for consumption, but this will also result in more files across\n# the brokers.\nnum.partitions=1\n\n# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.\n# This value is recommended to be increased for installations with data dirs located in RAID array.\nnum.recovery.threads.per.data.dir=1\n\n############################# Internal Topic Settings #############################\n# The replication factor for the group metadata internal topics \"__consumer_offsets\" and \"__transaction_state\"\n# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.\noffsets.topic.replication.factor=1\ntransaction.state.log.replication.factor=1\ntransaction.state.log.min.isr=1\n\n############################# Log Flush Policy #############################\n\n# Messages are immediately written to the filesystem but by default we only fsync() to sync\n# the OS cache lazily. The following configurations control the flush of data to disk.\n# There are a few important trade-offs here:\n# 1. Durability: Unflushed data may be lost if you are not using replication.\n# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.\n# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.\n# The settings below allow one to configure the flush policy to flush data after a period of time or\n# every N messages (or both). This can be done globally and overridden on a per-topic basis.\n\n# The number of messages to accept before forcing a flush of data to disk\n#log.flush.interval.messages=10000\n\n# The maximum amount of time a message can sit in a log before we force a flush\n#log.flush.interval.ms=1000\n\n############################# Log Retention Policy #############################\n\n# The following configurations control the disposal of log segments. The policy can\n# be set to delete segments after a period of time, or after a given size has accumulated.\n# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens\n# from the end of the log.\n\n# The minimum age of a log file to be eligible for deletion due to age\nlog.retention.hours=72\n\n# A size-based retention policy for logs. Segments are pruned from the log unless the remaining\n# segments drop below log.retention.bytes. Functions independently of log.retention.hours.\n#log.retention.bytes=1073741824\n\n# The maximum size of a log segment file. When this size is reached a new log segment will be created.\nlog.segment.bytes=1073741824\n\n# The interval at which log segments are checked to see if they can be deleted according\n# to the retention policies\nlog.retention.check.interval.ms=300000\n
\u6587\u4ef6\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8 Kafka \u670d\u52a1\uff1a
#\u751f\u6210\u96c6\u7fa4ID\n$ KAFKA_CLUSTER_ID=\"$(bin/kafka-storage.sh random-uuid)\"\n#\u8bbe\u7f6e\u65e5\u5fd7\u76ee\u5f55\u683c\u5f0f\n$ bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.properties\n#\u542f\u52a8Kafka\u670d\u52a1\n$ bin/kafka-server-start.sh config/kraft/server.properties\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#kafka_1","title":"\u6b65\u9aa4\u4e8c\uff1a\u521b\u5efa Kafka \u4e3b\u9898","text":"\u4e3a\u4e86\u4f7f Flink \u80fd\u591f\u4ece\u4e2d\u8bfb\u53d6\u6570\u636e\u5e76\u5199\u5165\u5230 MatrixOne\uff0c\u6211\u4eec\u9700\u8981\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"matrixone\" \u7684 Kafka \u4e3b\u9898\u3002\u5728\u4e0b\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u4f7f\u7528 --bootstrap-server
\u53c2\u6570\u6307\u5b9a Kafka \u670d\u52a1\u7684\u76d1\u542c\u5730\u5740\u4e3a 192.168.146.12:9092
\uff1a
$ bin/kafka-topics.sh --create --topic matrixone --bootstrap-server 192.168.146.12:9092\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#matrixone_1","title":"\u6b65\u9aa4\u4e09\uff1a\u8bfb\u53d6 MatrixOne \u6570\u636e","text":"\u5728\u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\u4e4b\u540e\uff0c\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\u4ee5\u521b\u5efa\u6240\u9700\u7684\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff1a
\u5728 MatrixOne \u4e2d\u521b\u5efa\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff0c\u5e76\u5bfc\u5165\u6570\u636e\uff1a
CREATE TABLE `users` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL\n)\n
\u5728 IDEA \u96c6\u6210\u5f00\u53d1\u73af\u5883\u4e2d\u7f16\u5199\u4ee3\u7801\uff1a
\u5728 IDEA \u4e2d\uff0c\u521b\u5efa\u4e24\u4e2a\u7c7b\uff1aUser.java
\u548c Kafka2Mo.java
\u3002\u8fd9\u4e9b\u7c7b\u7528\u4e8e\u4f7f\u7528 Flink \u4ece Kafka \u8bfb\u53d6\u6570\u636e\uff0c\u5e76\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u4e2d\u3002
package com.matrixone.flink.demo.entity;\n\npublic class User {\n\nprivate int id;\nprivate String name;\nprivate int age;\n\npublic int getId() {\nreturn id;\n}\n\npublic void setId(int id) {\nthis.id = id;\n}\n\npublic String getName() {\nreturn name;\n}\n\npublic void setName(String name) {\nthis.name = name;\n}\n\npublic int getAge() {\nreturn age;\n}\n\npublic void setAge(int age) {\nthis.age = age;\n}\n}\n
package com.matrixone.flink.demo;\n\nimport com.alibaba.fastjson2.JSON;\nimport com.matrixone.flink.demo.entity.User;\nimport org.apache.flink.api.common.eventtime.WatermarkStrategy;\nimport org.apache.flink.api.common.serialization.AbstractDeserializationSchema;\nimport org.apache.flink.connector.jdbc.JdbcExecutionOptions;\nimport org.apache.flink.connector.jdbc.JdbcSink;\nimport org.apache.flink.connector.jdbc.JdbcStatementBuilder;\nimport org.apache.flink.connector.jdbc.internal.options.JdbcConnectorOptions;\nimport org.apache.flink.connector.kafka.source.KafkaSource;\nimport org.apache.flink.connector.kafka.source.enumerator.initializer.OffsetsInitializer;\nimport org.apache.flink.streaming.api.datastream.DataStreamSource;\nimport org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;\nimport org.apache.kafka.clients.consumer.OffsetResetStrategy;\n\nimport java.nio.charset.StandardCharsets;\n\n/**\n * @author MatrixOne\n * @desc\n */\npublic class Kafka2Mo {\n\nprivate static String srcServer = \"192.168.146.12:9092\";\nprivate static String srcTopic = \"matrixone\";\nprivate static String consumerGroup = \"matrixone_group\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"person\";\n\npublic static void main(String[] args) throws Exception {\n\n//\u521d\u59cb\u5316\u73af\u5883\nStreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();\n//\u8bbe\u7f6e\u5e76\u884c\u5ea6\nenv.setParallelism(1);\n\n//\u8bbe\u7f6e kafka source \u4fe1\u606f\nKafkaSource<User> source = KafkaSource.<User>builder()\n//Kafka \u670d\u52a1\n.setBootstrapServers(srcServer)\n//\u6d88\u606f\u4e3b\u9898\n.setTopics(srcTopic)\n//\u6d88\u8d39\u7ec4\n.setGroupId(consumerGroup)\n//\u504f\u79fb\u91cf \u5f53\u6ca1\u6709\u63d0\u4ea4\u504f\u79fb\u91cf\u5219\u4ece\u6700\u5f00\u59cb\u5f00\u59cb\u6d88\u8d39\n.setStartingOffsets(OffsetsInitializer.committedOffsets(OffsetResetStrategy.LATEST))\n//\u81ea\u5b9a\u4e49\u89e3\u6790\u6d88\u606f\u5185\u5bb9\n.setValueOnlyDeserializer(new AbstractDeserializationSchema<User>() {\n@Override\npublic User deserialize(byte[] message) {\nreturn JSON.parseObject(new String(message, StandardCharsets.UTF_8), User.class);\n}\n})\n.build();\nDataStreamSource<User> kafkaSource = env.fromSource(source, WatermarkStrategy.noWatermarks(), \"kafka_maxtixone\");\n//kafkaSource.print();\n\n//\u8bbe\u7f6e matrixone sink \u4fe1\u606f\nkafkaSource.addSink(JdbcSink.sink(\n\"insert into users (id,name,age) values(?,?,?)\",\n(JdbcStatementBuilder<User>) (preparedStatement, user) -> {\npreparedStatement.setInt(1, user.getId());\npreparedStatement.setString(2, user.getName());\npreparedStatement.setInt(3, user.getAge());\n},\nJdbcExecutionOptions.builder()\n//\u9ed8\u8ba4\u503c 5000\n.withBatchSize(1000)\n//\u9ed8\u8ba4\u503c\u4e3a 0\n.withBatchIntervalMs(200)\n//\u6700\u5927\u5c1d\u8bd5\u6b21\u6570\n.withMaxRetries(5)\n.build(),\nJdbcConnectorOptions.builder()\n.setDBUrl(\"jdbc:mysql://\"+destHost+\":\"+destPort+\"/\"+destDataBase)\n.setUsername(destUserName)\n.setPassword(destPassword)\n.setDriverName(\"com.mysql.cj.jdbc.Driver\")\n.setTableName(destTable)\n.build()\n));\nenv.execute();\n}\n}\n
\u4ee3\u7801\u7f16\u5199\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c Flink \u4efb\u52a1\uff0c\u5373\u5728 IDEA \u4e2d\u9009\u62e9 Kafka2Mo.java
\u6587\u4ef6\uff0c\u7136\u540e\u6267\u884c Kafka2Mo.Main()
\u3002
\u4f7f\u7528 Kafka \u63d0\u4f9b\u7684\u547d\u4ee4\u884c\u751f\u4ea7\u8005\u5de5\u5177\uff0c\u60a8\u53ef\u4ee5\u5411 Kafka \u7684 \"matrixone\" \u4e3b\u9898\u4e2d\u6dfb\u52a0\u6570\u636e\u3002\u5728\u4e0b\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u4f7f\u7528 --topic
\u53c2\u6570\u6307\u5b9a\u8981\u6dfb\u52a0\u5230\u7684\u4e3b\u9898\uff0c\u800c --bootstrap-server
\u53c2\u6570\u6307\u5b9a\u4e86 Kafka \u670d\u52a1\u7684\u76d1\u542c\u5730\u5740\u3002
bin/kafka-console-producer.sh --topic matrixone --bootstrap-server 192.168.146.12:9092\n
\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u60a8\u5c06\u5728\u63a7\u5236\u53f0\u4e0a\u7b49\u5f85\u8f93\u5165\u6d88\u606f\u5185\u5bb9\u3002\u53ea\u9700\u76f4\u63a5\u8f93\u5165\u6d88\u606f\u503c (value)\uff0c\u6bcf\u884c\u8868\u793a\u4e00\u6761\u6d88\u606f\uff08\u4ee5\u6362\u884c\u7b26\u5206\u9694\uff09\uff0c\u5982\u4e0b\u6240\u793a\uff1a
{\"id\": 10, \"name\": \"xiaowang\", \"age\": 22}\n{\"id\": 20, \"name\": \"xiaozhang\", \"age\": 24}\n{\"id\": 30, \"name\": \"xiaogao\", \"age\": 18}\n{\"id\": 40, \"name\": \"xiaowu\", \"age\": 20}\n{\"id\": 50, \"name\": \"xiaoli\", \"age\": 42}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_9","title":"\u6b65\u9aa4\u4e94\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u8be2\u7ed3\u679c\uff1a
mysql> select * from test.users;\n+------+-----------+------+\n| id | name | age |\n+------+-----------+------+\n| 10 | xiaowang | 22 |\n| 20 | xiaozhang | 24 |\n| 30 | xiaogao | 18 |\n| 40 | xiaowu | 20 |\n| 50 | xiaoli | 42 |\n+------+-----------+------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/","title":"\u4f7f\u7528 Spark \u5c06\u6279\u91cf\u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_1","title":"\u6982\u8ff0","text":"Apache Spark \u662f\u4e00\u4e2a\u4e3a\u9ad8\u6548\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u800c\u8bbe\u8ba1\u7684\u5206\u5e03\u5f0f\u8ba1\u7b97\u5f15\u64ce\u3002\u5b83\u91c7\u7528\u5206\u5e03\u5f0f\u5e76\u884c\u8ba1\u7b97\u7684\u65b9\u5f0f\uff0c\u5c06\u6570\u636e\u62c6\u5206\u3001\u8ba1\u7b97\u3001\u5408\u5e76\u7684\u4efb\u52a1\u5206\u6563\u5230\u591a\u53f0\u8ba1\u7b97\u673a\u4e0a\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u9ad8\u6548\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u5927\u89c4\u6a21\u6570\u636e\u5904\u7406\u4e0e\u5206\u6790
Spark \u80fd\u591f\u5904\u7406\u6d77\u91cf\u6570\u636e\uff0c\u901a\u8fc7\u5e76\u884c\u8ba1\u7b97\u4efb\u52a1\u63d0\u9ad8\u4e86\u5904\u7406\u6548\u7387\u3002\u5b83\u5e7f\u6cdb\u5e94\u7528\u4e8e\u91d1\u878d\u3001\u7535\u4fe1\u3001\u533b\u7597\u7b49\u9886\u57df\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002
\u6d41\u5f0f\u6570\u636e\u5904\u7406
Spark Streaming \u5141\u8bb8\u5b9e\u65f6\u5904\u7406\u6570\u636e\u6d41\uff0c\u5c06\u5176\u8f6c\u5316\u4e3a\u53ef\u4f9b\u5206\u6790\u548c\u5b58\u50a8\u7684\u6279\u5904\u7406\u6570\u636e\u3002\u8fd9\u5728\u5728\u7ebf\u5e7f\u544a\u3001\u7f51\u7edc\u5b89\u5168\u7b49\u5b9e\u65f6\u6570\u636e\u5206\u6790\u573a\u666f\u4e2d\u975e\u5e38\u6709\u7528\u3002
\u673a\u5668\u5b66\u4e60
Spark \u63d0\u4f9b\u4e86\u673a\u5668\u5b66\u4e60\u5e93\uff08MLlib\uff09\uff0c\u652f\u6301\u591a\u79cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u548c\u6a21\u578b\u8bad\u7ec3\uff0c\u7528\u4e8e\u63a8\u8350\u7cfb\u7edf\u3001\u56fe\u50cf\u8bc6\u522b\u7b49\u673a\u5668\u5b66\u4e60\u5e94\u7528\u3002
\u56fe\u8ba1\u7b97
Spark \u7684\u56fe\u8ba1\u7b97\u5e93\uff08GraphX\uff09\u652f\u6301\u591a\u79cd\u56fe\u8ba1\u7b97\u7b97\u6cd5\uff0c\u9002\u7528\u4e8e\u793e\u4ea4\u7f51\u7edc\u5206\u6790\u3001\u63a8\u8350\u7cfb\u7edf\u7b49\u56fe\u5206\u6790\u573a\u666f\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u4e24\u79cd\u4f7f\u7528 Spark \u8ba1\u7b97\u5f15\u64ce\u5b9e\u73b0\u6279\u91cf\u6570\u636e\u5199\u5165 MatrixOne \u7684\u793a\u4f8b\u3002\u4e00\u79cd\u793a\u4f8b\u662f\u4ece MySQL \u8fc1\u79fb\u6570\u636e\u81f3 MatrixOne\uff0c\u53e6\u4e00\u79cd\u662f\u5c06 Hive \u6570\u636e\u5199\u5165 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_3","title":"\u524d\u671f\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_4","title":"\u786c\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u5bf9\u4e8e\u673a\u5668\u7684\u786c\u4ef6\u8981\u6c42\u5982\u4e0b\uff1a
\u670d\u52a1\u5668\u540d\u79f0 \u670d\u52a1\u5668 IP \u5b89\u88c5\u8f6f\u4ef6 \u64cd\u4f5c\u7cfb\u7edf node1 192.168.146.10 MatrixOne Debian11.1 x86 node3 192.168.146.11 IDEA\u3001MYSQL\u3001Hadoop\u3001Hive Windows 10"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_5","title":"\u8f6f\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u9700\u8981\u5b89\u88c5\u90e8\u7f72\u4ee5\u4e0b\u8f6f\u4ef6\u73af\u5883\uff1a
\u542f\u52a8 IDEA\uff0c\u70b9\u51fb File > New > Project\uff0c\u9009\u62e9 Spring Initializer\uff0c\u5e76\u586b\u5199\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u6dfb\u52a0\u9879\u76ee\u4f9d\u8d56\uff0c\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 pom.xml
\u5185\u5bb9\u7f16\u8f91\u5982\u4e0b\uff1a
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n<modelVersion>4.0.0</modelVersion>\n\n<groupId>com.example.mo</groupId>\n<artifactId>mo-spark-demo</artifactId>\n<version>1.0-SNAPSHOT</version>\n\n<properties>\n<maven.compiler.source>8</maven.compiler.source>\n<maven.compiler.target>8</maven.compiler.target>\n<spark.version>3.2.1</spark.version>\n</properties>\n\n<dependencies>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-sql_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-hive_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-catalyst_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-core_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-core-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-mapper-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n\n\n<dependency>\n<groupId>mysql</groupId>\n<artifactId>mysql-connector-java</artifactId>\n<version>8.0.16</version>\n</dependency>\n\n</dependencies>\n\n</project>\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#matrixone","title":"\u6b65\u9aa4\u4e8c\uff1a\u8bfb\u53d6 MatrixOne \u6570\u636e","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u540e\uff0c\u521b\u5efa\u6f14\u793a\u6240\u9700\u7684\u6570\u636e\u5e93\u4ee5\u53ca\u6570\u636e\u8868\u3002
\u5728 MatrixOne \u4e2d\u521b\u5efa\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\uff0c\u5e76\u5bfc\u5165\u6570\u636e\uff1a
CREATE DATABASE test;\nUSE test;\nCREATE TABLE `person` (`id` INT DEFAULT NULL, `name` VARCHAR(255) DEFAULT NULL, `birthday` DATE DEFAULT NULL);\nINSERT INTO test.person (id, name, birthday) VALUES(1, 'zhangsan', '2023-07-09'),(2, 'lisi', '2023-07-08'),(3, 'wangwu', '2023-07-12');\n
\u5728 IDEA \u4e2d\u521b\u5efa MoRead.java
\u7c7b\uff0c\u4ee5\u4f7f\u7528 Spark \u8bfb\u53d6 MatrixOne \u6570\u636e\uff1a
package com.matrixone.spark;\n\nimport org.apache.spark.sql.Dataset;\nimport org.apache.spark.sql.Row;\nimport org.apache.spark.sql.SQLContext;\nimport org.apache.spark.sql.SparkSession;\n\nimport java.util.Properties;\n\n/**\n * @auther MatrixOne\n * @desc \u8bfb\u53d6 MatrixOne \u6570\u636e\n */\npublic class MoRead {\n\n// parameters\nprivate static String master = \"local[2]\";\nprivate static String appName = \"mo_spark_demo\";\n\nprivate static String srcHost = \"192.168.146.10\";\nprivate static Integer srcPort = 6001;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"111\";\nprivate static String srcDataBase = \"test\";\nprivate static String srcTable = \"person\";\n\npublic static void main(String[] args) {\nSparkSession sparkSession = SparkSession.builder().appName(appName).master(master).getOrCreate();\nSQLContext sqlContext = new SQLContext(sparkSession);\nProperties properties = new Properties();\nproperties.put(\"user\", srcUserName);\nproperties.put(\"password\", srcPassword);\nDataset<Row> dataset = sqlContext.read()\n.jdbc(\"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase,srcTable, properties);\ndataset.show();\n}\n\n}\n
\u5728 IDEA \u4e2d\u8fd0\u884c MoRead.Main()
\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528 Spark \u5c06 MySQL \u6570\u636e\u8fc1\u79fb\u5230 MatrixOne\u3002
\u51c6\u5907 MySQL \u6570\u636e\uff1a\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730 Mysql\uff0c\u521b\u5efa\u6240\u9700\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\u3001\u5e76\u63d2\u5165\u6570\u636e\uff1a
mysql -h127.0.0.1 -P3306 -uroot -proot\nmysql> CREATE DATABASE motest;\nmysql> USE motest;\nmysql> CREATE TABLE `person` (`id` int DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `birthday` date DEFAULT NULL);\nmysql> INSERT INTO motest.person (id, name, birthday) VALUES(2, 'lisi', '2023-07-09'),(3, 'wangwu', '2023-07-13'),(4, 'zhaoliu', '2023-08-08');\n
\u6e05\u7a7a MatrixOne \u8868\u6570\u636e\uff1a
\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730 MatrixOne\u3002\u7531\u4e8e\u672c\u793a\u4f8b\u7ee7\u7eed\u4f7f\u7528\u524d\u9762\u8bfb\u53d6 MatrixOne \u6570\u636e\u7684\u793a\u4f8b\u4e2d\u7684 test
\u6570\u636e\u5e93\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u9996\u5148\u6e05\u7a7a person
\u8868\u7684\u6570\u636e\u3002
-- \u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5 node1 \u7684 MatrixOne\nmysql -h192.168.146.10 -P6001 -uroot -p111\nmysql> TRUNCATE TABLE test.person;\n
\u5728 IDEA \u4e2d\u7f16\u5199\u4ee3\u7801\uff1a
\u521b\u5efa Person.java
\u548c Mysql2Mo.java
\u7c7b\uff0c\u4f7f\u7528 Spark \u8bfb\u53d6 MySQL \u6570\u636e\u3002Mysql2Mo.java
\u7c7b\u4ee3\u7801\u53ef\u53c2\u8003\u5982\u4e0b\u793a\u4f8b\uff1a
package com.matrixone.spark;\n\nimport org.apache.spark.api.java.function.MapFunction;\nimport org.apache.spark.sql.*;\n\nimport java.sql.SQLException;\nimport java.util.Properties;\n\n/**\n * @auther MatrixOne\n * @desc\n */\npublic class Mysql2Mo {\n\n// parameters\nprivate static String master = \"local[2]\";\nprivate static String appName = \"app_spark_demo\";\n\nprivate static String srcHost = \"127.0.0.1\";\nprivate static Integer srcPort = 3306;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"root\";\nprivate static String srcDataBase = \"motest\";\nprivate static String srcTable = \"person\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"person\";\n\n\npublic static void main(String[] args) throws SQLException {\nSparkSession sparkSession = SparkSession.builder().appName(appName).master(master).getOrCreate();\nSQLContext sqlContext = new SQLContext(sparkSession);\nProperties connectionProperties = new Properties();\nconnectionProperties.put(\"user\", srcUserName);\nconnectionProperties.put(\"password\", srcPassword);\nconnectionProperties.put(\"driver\",\"com.mysql.cj.jdbc.Driver\");\n\n//jdbc.url=jdbc:mysql://127.0.0.1:3306/database\nString url = \"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase + \"?characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai\";\n\n//SparkJdbc \u8bfb\u53d6\u8868\u5185\u5bb9\nSystem.out.println(\"\u8bfb\u53d6\u6570\u636e\u5e93\u4e2d person \u7684\u8868\u5185\u5bb9\");\n// \u8bfb\u53d6\u8868\u4e2d\u6240\u6709\u6570\u636e\nDataset<Row> rowDataset = sqlContext.read().jdbc(url,srcTable,connectionProperties).select(\"*\");\n//\u663e\u793a\u6570\u636e\n//rowDataset.show();\n//\u7b5b\u9009 id > 2 \u7684\u6570\u636e\uff0c\u5e76\u5c06 name \u5b57\u6bb5\u6dfb\u52a0 spark_ \u524d\u7f00\nDataset<Row> dataset = rowDataset.filter(\"id > 2\")\n.map((MapFunction<Row, Row>) row -> RowFactory.create(row.getInt(0), \"spark_\" + row.getString(1), row.getDate(2)), RowEncoder.apply(rowDataset.schema()));\n//\u663e\u793a\u6570\u636e\n//dataset.show();\nProperties properties = new Properties();\nproperties.put(\"user\", destUserName);\nproperties.put(\"password\", destPassword);;\ndataset.write()\n.mode(SaveMode.Append)\n.jdbc(\"jdbc:mysql://\" + destHost + \":\" + destPort + \"/\" + destDataBase,destTable, properties);\n}\n\n}\n
\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6267\u884c\u4e86\u7b80\u5355\u7684 ETL \u64cd\u4f5c\uff08\u7b5b\u9009 id > 2 \u7684\u6570\u636e\uff0c\u5e76\u5728 name \u5b57\u6bb5\u524d\u6dfb\u52a0\u524d\u7f00 \"spark_\"\uff09\uff0c\u5e76\u5c06\u5904\u7406\u540e\u7684\u6570\u636e\u5199\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_7","title":"\u6b65\u9aa4\u56db\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u770b\u6267\u884c\u7ed3\u679c\uff1a
select * from test.person;\n+------+---------------+------------+\n| id | name | birthday |\n+------+---------------+------------+\n| 3 | spark_wangwu | 2023-07-12 |\n| 4 | spark_zhaoliu | 2023-08-07 |\n+------+---------------+------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#2-hive-matrixone","title":"\u793a\u4f8b 2\uff1a\u5c06 Hive \u6570\u636e\u5bfc\u5165\u5230 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_8","title":"\u6b65\u9aa4\u4e00\uff1a\u521d\u59cb\u5316\u9879\u76ee","text":"\u542f\u52a8 IDEA\uff0c\u70b9\u51fb File > New > Project\uff0c\u9009\u62e9 Spring Initializer\uff0c\u5e76\u586b\u5199\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u6dfb\u52a0\u9879\u76ee\u4f9d\u8d56\uff0c\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 pom.xml
\u5185\u5bb9\u7f16\u8f91\u5982\u4e0b\uff1a
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n<modelVersion>4.0.0</modelVersion>\n\n<groupId>com.example.mo</groupId>\n<artifactId>mo-spark-demo</artifactId>\n<version>1.0-SNAPSHOT</version>\n\n<properties>\n<maven.compiler.source>8</maven.compiler.source>\n<maven.compiler.target>8</maven.compiler.target>\n<spark.version>3.2.1</spark.version>\n</properties>\n\n<dependencies>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-sql_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-hive_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-catalyst_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-core_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-core-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-mapper-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n\n\n<dependency>\n<groupId>mysql</groupId>\n<artifactId>mysql-connector-java</artifactId>\n<version>8.0.16</version>\n</dependency>\n\n</dependencies>\n\n</project>\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#hive","title":"\u6b65\u9aa4\u4e8c\uff1a\u51c6\u5907 Hive \u6570\u636e","text":"\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u521b\u5efa Hive \u6570\u636e\u5e93\u3001\u6570\u636e\u8868\uff0c\u5e76\u63d2\u5165\u6570\u636e\uff1a
hive\nhive> create database motest;\nhive> CREATE TABLE `users`(\n`id` int,\n`name` varchar(255),\n`age` int);\nhive> INSERT INTO motest.users (id, name, age) VALUES(1, 'zhangsan', 12),(2, 'lisi', 17),(3, 'wangwu', 19);\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#matrixone_1","title":"\u6b65\u9aa4\u4e09\uff1a\u521b\u5efa MatrixOne \u6570\u636e\u8868","text":"\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 node1 \u7684 MatrixOne\u3002\u7136\u540e\u7ee7\u7eed\u4f7f\u7528\u4e4b\u524d\u521b\u5efa\u7684 \"test\" \u6570\u636e\u5e93\uff0c\u5e76\u521b\u5efa\u65b0\u7684\u6570\u636e\u8868 \"users\"\u3002
CREATE TABLE `users` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL\n)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_9","title":"\u6b65\u9aa4\u56db\uff1a\u62f7\u8d1d\u914d\u7f6e\u6587\u4ef6","text":"\u5c06 Hadoop \u6839\u76ee\u5f55\u4e0b\u7684 \"etc/hadoop/core-site.xml\" \u548c \"hdfs-site.xml\" \u4ee5\u53ca Hive \u6839\u76ee\u5f55\u4e0b\u7684 \"conf/hive-site.xml\" \u8fd9\u4e09\u4e2a\u914d\u7f6e\u6587\u4ef6\u590d\u5236\u5230\u9879\u76ee\u7684 \"resource\" \u76ee\u5f55\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_10","title":"\u6b65\u9aa4\u4e94\uff1a\u7f16\u5199\u4ee3\u7801","text":"\u5728 IntelliJ IDEA \u4e2d\u521b\u5efa\u540d\u4e3a \"Hive2Mo.java\" \u7684\u7c7b\uff0c\u7528\u4e8e\u4f7f\u7528 Spark \u4ece Hive \u4e2d\u8bfb\u53d6\u6570\u636e\u5e76\u5c06\u6570\u636e\u5199\u5165 MatrixOne\u3002
package com.matrixone.spark;\n\nimport org.apache.spark.sql.*;\n\nimport java.sql.SQLException;\nimport java.util.Properties;\n\n/**\n * @auther MatrixOne\n * @date 2022/2/9 10:02\n * @desc\n *\n * 1.\u5728 hive \u548c matrixone \u4e2d\u5206\u522b\u521b\u5efa\u76f8\u5e94\u7684\u8868\n * 2.\u5c06 core-site.xml hdfs-site.xml \u548c hive-site.xml \u62f7\u8d1d\u5230 resources \u76ee\u5f55\u4e0b\n * 3.\u9700\u8981\u8bbe\u7f6e\u57df\u540d\u6620\u5c04\n */\npublic class Hive2Mo {\n\n// parameters\nprivate static String master = \"local[2]\";\nprivate static String appName = \"app_spark_demo\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"users\";\n\n\npublic static void main(String[] args) throws SQLException {\nSparkSession sparkSession = SparkSession.builder()\n.appName(appName)\n.master(master)\n.enableHiveSupport()\n.getOrCreate();\n\n//SparkJdbc \u8bfb\u53d6\u8868\u5185\u5bb9\nSystem.out.println(\"\u8bfb\u53d6 hive \u4e2d person \u7684\u8868\u5185\u5bb9\");\n// \u8bfb\u53d6\u8868\u4e2d\u6240\u6709\u6570\u636e\nDataset<Row> rowDataset = sparkSession.sql(\"select * from motest.users\");\n//\u663e\u793a\u6570\u636e\n//rowDataset.show();\nProperties properties = new Properties();\nproperties.put(\"user\", destUserName);\nproperties.put(\"password\", destPassword);;\nrowDataset.write()\n.mode(SaveMode.Append)\n.jdbc(\"jdbc:mysql://\" + destHost + \":\" + destPort + \"/\" + destDataBase,destTable, properties);\n}\n\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_11","title":"\u6b65\u9aa4\u516d\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u770b\u6267\u884c\u7ed3\u679c\uff1a
mysql> select * from test.users;\n+------+----------+------+\n| id | name | age |\n+------+----------+------+\n| 1 | zhangsan | 12 |\n| 2 | lisi | 17 |\n| 3 | wangwu | 19 |\n+------+----------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/","title":"\u4f7f\u7528 SeaTunnel \u5c06\u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_1","title":"\u6982\u8ff0","text":"SeaTunnel \u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u3001\u9ad8\u6027\u80fd\u3001\u6613\u6269\u5c55\u7684\u6570\u636e\u96c6\u6210\u5e73\u53f0\uff0c\u4e13\u6ce8\u4e8e\u6d77\u91cf\u6570\u636e\uff08\u5305\u62ec\u79bb\u7ebf\u548c\u5b9e\u65f6\u6570\u636e\uff09\u540c\u6b65\u548c\u8f6c\u5316\u3002MatrixOne \u652f\u6301\u4f7f\u7528 SeaTunnel \u4ece\u5176\u4ed6\u6570\u636e\u5e93\u540c\u6b65\u6570\u636e\uff0c\u53ef\u4ee5\u7a33\u5b9a\u9ad8\u6548\u5730\u5904\u7406\u6570\u767e\u4ebf\u6761\u6570\u636e\u3002
\u672c\u6587\u6863\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SeaTunnel \u5411 MatrixOne \u4e2d\u5199\u5165\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u4f7f\u7528 SeaTunnel \u5411 MatrixOne \u5199\u5165\u6570\u636e\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5b8c\u6210\u4ee5\u4e0b\u51c6\u5907\u5de5\u4f5c\uff1a
\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5b89\u88c5 SeaTunnel Version 2.3.3\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7 shell \u547d\u4ee4\u884c\u5b9a\u4e49 SeaTunnel \u7684\u5b89\u88c5\u8def\u5f84\uff1a
export SEATNUNNEL_HOME=\"/root/seatunnel\"\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_3","title":"\u64cd\u4f5c\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_4","title":"\u521b\u5efa\u6d4b\u8bd5\u6570\u636e","text":"\u521b\u5efa\u540d\u4e3a test1
\u7684 MySQL \u6570\u636e\u5e93\uff0c\u5e76\u5728\u5176\u4e2d\u521b\u5efa\u540d\u4e3a test_table
\u7684\u8868\uff0c\u5b58\u50a8\u5728 root \u4e0b\u7684 mysql.sql
\u4e2d\u3002\u4ee5\u4e0b\u662f MySQL \u7684 DDL \u8bed\u53e5\uff1a
create database test1;\nuse test1;\nCREATE TABLE `test_table` (\n`name` varchar(255) DEFAULT NULL,\n`age` int(11) DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n
\u4f7f\u7528 mo_ctl \u5de5\u5177\u5c06 MySQL \u7684 DDL \u8bed\u53e5\u76f4\u63a5\u5bfc\u5165\u81f3 MatrixOne\u3002\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
mo_ctl sql /root/mysql.sql\n
\u672c\u7bc7\u6587\u6863\u4e2d\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SeaTunnel \u7684 connector-jdbc
\u8fde\u63a5\u63d2\u4ef6\u8fde\u63a5 MatrixOne\u3002
\u5728 SeaTunnel \u7684 ${SEATNUNNEL_HOME}/config/plugin_config
\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a
--connectors-v2--\nconnector-jdbc\n--end--\n
\u7248\u672c 2.3.3 \u7684 SeaTunnel \u4e8c\u8fdb\u5236\u5305\u9ed8\u8ba4\u4e0d\u63d0\u4f9b\u8fde\u63a5\u5668\u4f9d\u8d56\u9879\uff0c\u4f60\u9700\u8981\u5728\u9996\u6b21\u4f7f\u7528 SeaTunnel \u65f6\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u8fde\u63a5\u5668\uff1a
sh bin/install-plugin.sh 2.3.3\n
Note: \u672c\u7bc7\u6587\u6863\u4e2d\u4f7f\u7528 SeaTunnel \u5f15\u64ce\u5c06\u6570\u636e\u5199\u5165 MatrixOne\uff0c\u65e0\u9700\u4f9d\u8d56 Flink \u6216 Spark\u3002
\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 MySQL \u6570\u636e\u5e93\u7684 test_table
\u8868\u4f5c\u4e3a\u6570\u636e\u6e90\uff0c\u4e0d\u8fdb\u884c\u6570\u636e\u5904\u7406\uff0c\u76f4\u63a5\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u7684 test_table
\u8868\u4e2d\u3002
\u90a3\u4e48\uff0c\u7531\u4e8e\u6570\u636e\u517c\u5bb9\u6027\u7684\u95ee\u9898\uff0c\u9700\u8981\u914d\u7f6e\u4efb\u52a1\u914d\u7f6e\u6587\u4ef6 ${SEATNUNNEL_HOME}/config/v2.batch.config.template
\uff0c\u5b83\u5b9a\u4e49\u4e86 SeaTunnel \u542f\u52a8\u540e\u7684\u6570\u636e\u8f93\u5165\u3001\u5904\u7406\u548c\u8f93\u51fa\u65b9\u5f0f\u548c\u903b\u8f91\u3002
\u6309\u7167\u4ee5\u4e0b\u5185\u5bb9\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a
env {\nexecution.parallelism = 2\njob.mode = \"BATCH\"\n}\n\nsource {\nJdbc {\nurl = \"jdbc:mysql://192.168.110.40:3306/test\"\ndriver = \"com.mysql.cj.jdbc.Driver\"\nconnection_check_timeout_sec = 100\nuser = \"root\"\npassword = \"123456\"\nquery = \"select * from test_table\"\n}\n}\n\ntransform {\n\n}\n\nsink {\njdbc {\nurl = \"jdbc:mysql://192.168.110.248:6001/test\"\ndriver = \"com.mysql.cj.jdbc.Driver\"\nuser = \"root\"\npassword = \"111\"\nquery = \"insert into test_table(name,age) values(?,?)\"\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_6","title":"\u5b89\u88c5\u6570\u636e\u5e93\u4f9d\u8d56\u9879","text":"\u4e0b\u8f7d mysql-connector-java-8.0.33.jar\uff0c\u5e76\u5c06\u6587\u4ef6\u590d\u5236\u5230 ${SEATNUNNEL_HOME}/plugins/jdbc/lib/
\u76ee\u5f55\u4e0b\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 SeaTunnel \u5e94\u7528\uff1a
./bin/seatunnel.sh --config ./config/v2.batch.config.template -e local\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_7","title":"\u67e5\u770b\u8fd0\u884c\u7ed3\u679c","text":"SeaTunnel \u8fd0\u884c\u7ed3\u675f\u540e\uff0c\u5c06\u663e\u793a\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u7edf\u8ba1\u7ed3\u679c\uff0c\u6c47\u603b\u4e86\u672c\u6b21\u5199\u5165\u7684\u7528\u65f6\u3001\u603b\u8bfb\u53d6\u6570\u636e\u6570\u91cf\u3001\u603b\u5199\u5165\u6570\u91cf\u4ee5\u53ca\u603b\u5199\u5165\u5931\u8d25\u6570\u91cf\uff1a
***********************************************\n Job Statistic Information\n***********************************************\nStart Time : 2023-08-07 16:45:02\nEnd Time : 2023-08-07 16:45:05\nTotal Time(s) : 3\nTotal Read Count : 5000000\nTotal Write Count : 5000000\nTotal Failed Count : 0\n***********************************************\n
\u4f60\u5df2\u7ecf\u6210\u529f\u5c06\u6570\u636e\u4ece MySQL \u6570\u636e\u5e93\u540c\u6b65\u5199\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Message-Queue/Kafka/","title":"\u4f7f\u7528 Kafka \u8fde\u63a5 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Message-Queue/Kafka/#_1","title":"\u6982\u8ff0","text":"Apache Kafka \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u4e8b\u4ef6\u6d41\u5e73\u53f0\uff0c\u88ab\u6570\u5343\u5bb6\u516c\u53f8\u7528\u4e8e\u9ad8\u6027\u80fd\u6570\u636e\u7ba1\u9053\u3001\u6d41\u5206\u6790\u3001\u6570\u636e\u96c6\u6210\u548c\u5173\u952e\u4efb\u52a1\u5e94\u7528\u3002
MatrixOne \u652f\u6301\u4e0e Apache Kafka \u8fdb\u884c\u8fde\u63a5\uff0c\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7 Apache Kafka \u8fde\u63a5\u5230 MatrixOne \u5e76\u5b9e\u73b0\u9ad8\u6548\u6570\u636e\u6d41\u96c6\u6210\u4e0e\u6301\u4e45\u5316\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Message-Queue/Kafka/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u4e0b\u8f7d Apache Kafka \u4e8c\u8fdb\u5236\u5305\u3002
\u89e3\u538b\u4e8c\u8fdb\u5236\u5305 (\u6ce8\u610f\u5bf9\u5e94\u7248\u672c)
tar -xzf kafka_2.13-3.6.1.tgz\ncd kafka_2.13-3.6.1\n
\u542f\u52a8 ZooKeeper
bin/zookeeper-server-start.sh config/zookeeper.properties\n
\u5f00\u542f\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u542f\u52a8 Kafka
bin/kafka-server-start.sh config/server.properties\n
\u5f00\u542f\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u521b\u5efa\u4e00\u4e2a topic
bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test\n
\u5f00\u542f\u4e00\u4e2a\u751f\u4ea7\u8005\u5f80 topic \u4e2d\u5199\u5165 json \u6570\u636e
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test\n{\"c1\": -2147483648,\"c2\":20,\"c3\": -3,\"c4\":8,\"c5\":425,\"c6\":55}\n{\"c1\": 21474,\"c2\":-20,\"c3\": 3,\"c4\":9090,\"c5\":42,\"c6\":53}\n
\u5f00\u542f\u4e00\u4e2a\u6d88\u8d39\u8005\u67e5\u770b\u662f\u5426\u6210\u529f\u5199\u5165 topic\uff1a
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test\n{\"c1\": -2147483648,\"c2\":20,\"c3\": -3,\"c4\":8,\"c5\":425,\"c6\":55}\n{\"c1\": 21474,\"c2\":-20,\"c3\": 3,\"c4\":9090,\"c5\":42,\"c6\":53}\n
\u521b\u5efa Source \u8868
create source stream_test(c1 int,c2 tinyint,c3 smallint,c4 bigint,c5 int unsigned ,c6 tinyint unsigned)\nwith(\n\"type\"='kafka',\n\"topic\"= 'test',\n\"partition\" = '0',\n\"value\"= 'json',\n\"bootstrap.servers\"='127.0.0.1:9092' )
\u67e5\u770b\u662f\u5426\u63a5\u53d7\u4e86\u6570\u636e\uff1a
select * from stream_test;\n+-------------+------+------+------+------+------+\n| c1 | c2 | c3 | c4 | c5 | c6 |\n+-------------+------+------+------+------+------+\n| -2147483648 | 20 | -3 | 8 | 425 | 55 |\n| 21474 | -20 | 3 | 9090 | 42 | 53 |\n+-------------+------+------+------+------+------+\n2 rows in set (0.37 sec)
\u5f80 topic \u4e2d\u6301\u7eed\u5199\u5165 json \u6570\u636e\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u7ee7\u7eed\u63a5\u53d7\u4e86\u6570\u636e\uff1a
{\"c1\": -3421474,\"c2\":92,\"c3\": 333,\"c4\":9,\"c5\":42233,\"c6\":87}\n
\u67e5\u770b\u662f\u5426\u63a5\u53d7\u4e86\u6570\u636e\uff1a
select * from stream_test;\n+-------------+------+------+------+-------+------+\n| c1 | c2 | c3 | c4 | c5 | c6 |\n+-------------+------+------+------+-------+------+\n| -2147483648 | 20 | -3 | 8 | 425 | 55 |\n| 21474 | -20 | 3 | 9090 | 42 | 53 |\n| -3421474 | 92 | 333 | 9 | 42233 | 87 |\n+-------------+------+------+------+-------+------+\n3 rows in set (0.44 sec)\n
\u521b\u5efa\u52a8\u6001\u8868\u4ee5\u6d88\u8d39 Source \u8868\uff1a
create dynamic table dt_test as select c1, c2+c3, c3*c4,c5/c3,c6/10 from stream_test;\n
\u67e5\u770b\u52a8\u6001\u8868\uff1a
select * from dt_test;\n+-------------+---------+---------+---------------------+---------+\n| c1 | c2 + c3 | c3 * c4 | c5 / c3 | c6 / 10 |\n+-------------+---------+---------+---------------------+---------+\n| -2147483648 | 17 | -24 | -141.66666666666666 | 5.5 |\n| 21474 | -17 | 27270 | 14 | 5.3 |\n| -3421474 | 425 | 2997 | 126.82582582582583 | 8.7 |\n+-------------+---------+---------+---------------------+---------+\n3 rows in set (0.00 sec)\n
\u5f80 topic \u4e2d\u6301\u7eed\u5199\u5165 json \u6570\u636e\uff0c\u5e76\u68c0\u67e5\u52a8\u6001\u8868\u662f\u5426\u66f4\u65b0\uff1a
{\"c1\": 1474,\"c2\":2,\"c3\": 453,\"c4\":1,\"c5\":56233,\"c6\":7}\n
\u67e5\u770b\u52a8\u6001\u8868\u53d1\u73b0\u6210\u529f\u66f4\u65b0\uff1a
select * from dt_test;\n+-------------+---------+---------+---------------------+---------+\n| c1 | c2 + c3 | c3 * c4 | c5 / c3 | c6 / 10 |\n+-------------+---------+---------+---------------------+---------+\n| -2147483648 | 17 | -24 | -141.66666666666666 | 5.5 |\n| 21474 | -17 | 27270 | 14 | 5.3 |\n| -3421474 | 425 | 2997 | 126.82582582582583 | 8.7 |\n| 1474 | 455 | 453 | 124.13465783664459 | 0.7 |\n+-------------+---------+---------+---------------------+---------+\n4 rows in set (0.00 sec)\n
Apache DolphinScheduler \u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u3001\u6613\u6269\u5c55\u7684\u53ef\u89c6\u5316 DAG \u5de5\u4f5c\u6d41\u4efb\u52a1\u8c03\u5ea6\u5f00\u6e90\u7cfb\u7edf\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\uff0c\u53ef\u4ee5\u901a\u8fc7\u53ef\u89c6\u5316\u64cd\u4f5c\u4efb\u52a1\u3001\u5de5\u4f5c\u6d41\u548c\u5168\u751f\u547d\u5468\u671f\u7684\u6570\u636e\u5904\u7406\u8fc7\u7a0b\u3002
Apache DolphinScheduler \u7684\u4e3b\u8981\u76ee\u6807\u662f\u89e3\u51b3\u590d\u6742\u7684\u5927\u6570\u636e\u4efb\u52a1\u4f9d\u8d56\u5173\u7cfb\u3002\u5b83\u4f7f\u7528 DAG\uff08Directed Acyclic Graph\uff0c\u6709\u5411\u65e0\u73af\u56fe\uff09\u7684\u6d41\u5f0f\u65b9\u5f0f\u6765\u7ec4\u88c5\u4efb\u52a1\uff0c\u5141\u8bb8\u60a8\u5b9e\u65f6\u76d1\u63a7\u4efb\u52a1\u7684\u6267\u884c\u72b6\u6001\uff0c\u652f\u6301\u4efb\u52a1\u91cd\u8bd5\u3001\u6307\u5b9a\u8282\u70b9\u6062\u590d\u5931\u8d25\u3001\u6682\u505c\u3001\u6062\u590d\u3001\u7ec8\u6b62\u7b49\u64cd\u4f5c\u3002
MatrixOne \u652f\u6301\u4e0e\u53ef\u89c6\u5316 DAG \u5de5\u4f5c\u6d41\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf DolphinScheduler \u8fdb\u884c\u8fde\u63a5\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7 DolphinScheduler \u8fde\u63a5\u5230 MatrixOne \u5e76\u521b\u5efa\u4efb\u52a1\u5de5\u4f5c\u6d41\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Scheduling-Tools/dolphinScheduler/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5b89\u88c5 DolphinScheduler\u3002
\u4e0b\u8f7d MySQL \u9a71\u52a8\u5e76\u5c06\u5176\u590d\u5236\u5230 libs \u76ee\u5f55\uff1a
\u5728\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u9700\u8981\u624b\u52a8\u4e0b\u8f7d mysql-connector-java \u9a71\u52a8\uff08\u7248\u672c 8.0.16\uff09\uff0c\u7136\u540e\u5c06\u5b83\u5206\u522b\u590d\u5236\u5230 DolphinScheduler \u5b89\u88c5\u76ee\u5f55\u4e0b\u7684\u56db\u4e2a\u76ee\u5f55\u4e2d\uff1aapi-server/libs
\u3001alert-server/libs
\u3001master-server/libs
\u548c worker-server/libs
\u3002
\u6ce8\u610f
\u63a8\u8350\u4f7f\u7528 `mysql-connector-java-8.0.16.jar` \u4f5c\u4e3a MySQL \u9a71\u52a8\u5305\u3002\n
\u91cd\u542f DolphinScheduler\uff1a
\u590d\u5236\u9a71\u52a8\u5305\u5b8c\u6210\u540e\uff0c\u9700\u8981\u91cd\u542f DolphinScheduler \u670d\u52a1\u3002\u9996\u5148\u8fdb\u5165 DolphinScheduler \u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u91cd\u542f DolphinScheduler \u670d\u52a1\uff1a
# \u505c\u6b62 Standalone Server \u670d\u52a1\nbash ./bin/dolphinscheduler-daemon.sh stop standalone-server\n# \u542f\u52a8 Standalone Server \u670d\u52a1\nbash ./bin/dolphinscheduler-daemon.sh start standalone-server\n
\u767b\u5f55 DolphinScheduler\uff1a
\u4f7f\u7528\u9ed8\u8ba4\u7528\u6237\u540d admin
\u548c\u5bc6\u7801 dolphinscheduler123
\uff0c\u901a\u8fc7\u8bbf\u95ee http://ip:12345/dolphinscheduler/ui \u767b\u5f55 DolphinScheduler \u7684 Web \u7528\u6237\u754c\u9762\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u521b\u5efa\u6570\u636e\u6e90\uff1a
\u70b9\u51fb\u6570\u636e\u6e90\u4e2d\u5fc3 > \u521b\u5efa\u6570\u636e\u6e90\uff0c\u586b\u5199 MatrixOne \u6570\u636e\u8fde\u63a5\u4fe1\u606f\u3002\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u6d4b\u8bd5\u8fde\u63a5\uff0c\u5982\u679c\u8fde\u63a5\u6210\u529f\uff0c\u70b9\u51fb\u786e\u5b9a\u4fdd\u5b58\uff1a
\u521b\u5efa\u79df\u6237\uff1a
\u5728\u5b89\u5168\u4e2d\u5fc3\u4e2d\uff0c\u70b9\u51fb\u521b\u5efa\u79df\u6237\uff0c\u586b\u5199\u79df\u6237\u540d\u79f0\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6ce8\u610f
\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528 root \u4f5c\u4e3a\u79df\u6237\u3002\n
\u521b\u5efa\u9879\u76ee\uff1a
\u5728\u9879\u76ee\u7ba1\u7406\u4e2d\uff0c\u70b9\u51fb\u521b\u5efa\u9879\u76ee\uff0c\u586b\u5199\u9879\u76ee\u540d\u79f0\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u521b\u5efa\u5de5\u4f5c\u6d41\u5e76\u6dfb\u52a0\u8282\u70b9\uff1a
\u70b9\u51fb\u4e0a\u4e00\u6b65\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\uff0c\u7136\u540e\u70b9\u51fb\u521b\u5efa\u5de5\u4f5c\u6d41\u3002\u4ece\u5de6\u4fa7\u62d6\u52a8 SQL \u8282\u70b9\u5230\u53f3\u4fa7\u7684\u753b\u5e03\u4e0a\uff0c\u586b\u5199\u8282\u70b9\u540d\u79f0\u3001\u6570\u636e\u6e90\u4fe1\u606f\u3001SQL \u7c7b\u578b\u3001SQL \u8bed\u53e5\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6b64\u6b65\u9aa4\u521b\u5efa\u7684\u662f\u4e00\u4e2a\u5efa\u8868\u8282\u70b9\uff0cSQL \u8bed\u53e5\u7528\u4e8e\u521b\u5efa\u8868\u683c\u3002
\u63a5\u4e0b\u6765\uff0c\u7c7b\u4f3c\u5730\u521b\u5efa\u63d2\u5165\u6570\u636e\u548c\u67e5\u8be2\u6570\u636e\u8282\u70b9\u3002\u8fd9\u4e09\u4e2a\u8282\u70b9\u7684\u4f9d\u8d56\u5173\u7cfb\u5982\u4e0b\u56fe\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u8fde\u63a5\u5b83\u4eec\uff1a
\u4e09\u4e2a\u8282\u70b9\u7684 SQL \u8bed\u53e5\u5982\u4e0b\uff1a
#create_table\n\nCREATE TABLE IF NOT EXISTS test_table (id INT AUTO_INCREMENT PRIMARY KEY, name\n\nVARCHAR(255) NOT NULL)\n\n#insert_data\n\nINSERT INTO test_table (name) VALUES ('John Doe')\n\n#select_data\n\nSELECT * FROM test_table\n
\u6839\u636e\u4f9d\u8d56\u5173\u7cfb\u8fde\u63a5\u8fd9\u4e09\u4e2a\u8282\u70b9\uff0c\u7136\u540e\u70b9\u51fb\u4fdd\u5b58\u3002\u586b\u5199\u5de5\u4f5c\u6d41\u540d\u79f0\uff0c\u9009\u62e9\u4e4b\u524d\u521b\u5efa\u7684\u79df\u6237\uff0c\u9009\u62e9\u6267\u884c\u7b56\u7565\u4e3a\u5e76\u884c\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\u3002
\u521b\u5efa\u597d\u5de5\u4f5c\u6d41\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u5de5\u4f5c\u6d41\u5173\u7cfb\u9875\u9762\u770b\u5230\u521b\u5efa\u7684\u5de5\u4f5c\u6d41\uff0c\u5176\u72b6\u6001\u4e3a\u5de5\u4f5c\u6d41\u4e0b\u7ebf\uff1a
\u540c\u6837\uff0c\u60a8\u4e5f\u53ef\u4ee5\u5728\u5de5\u4f5c\u6d41\u5b9a\u4e49\u9875\u9762\u770b\u5230\u5b9a\u4e49\u7684\u5de5\u4f5c\u6d41\uff0c\u5176\u72b6\u6001\u4e3a\u4e0b\u7ebf\uff1a
\u4e0a\u7ebf\u5e76\u8fd0\u884c\u5de5\u4f5c\u6d41\uff1a
\u5de5\u4f5c\u6d41\u5fc5\u987b\u5148\u4e0a\u7ebf\u624d\u80fd\u8fd0\u884c\u3002\u70b9\u51fb\u4e0a\u7ebf\u6309\u94ae\uff0c\u5c06\u4e4b\u524d\u521b\u5efa\u7684\u5de5\u4f5c\u6d41\u4e0a\u7ebf\uff1a
\u4e0a\u7ebf\u540e\uff0c\u5de5\u4f5c\u6d41\u7684\u72b6\u6001\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u63a5\u4e0b\u6765\uff0c\u70b9\u51fb\u8fd0\u884c\u6309\u94ae\uff0c\u8bbe\u7f6e\u542f\u52a8\u524d\u7684\u914d\u7f6e\u53c2\u6570\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\uff1a
\u6700\u540e\uff0c\u8fd4\u56de\u9879\u76ee\u6982\u51b5\uff0c\u67e5\u770b\u5de5\u4f5c\u6d41\u4ee5\u53ca\u4e0b\u9762\u7684\u4e09\u4e2a\u4efb\u52a1\u662f\u5426\u6210\u529f\u8fd0\u884c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u4e0e MySQL \u4e0d\u540c\uff0cMatrixOne \u662f\u4e00\u4e2a\u5177\u5907\u591a\u79df\u6237\u80fd\u529b\u7684\u6570\u636e\u5e93\u3002\u5728\u4e00\u4e2a MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 CREATE ACCOUNT
\u547d\u4ee4\u521b\u5efa\u79df\u6237\u3002\u8fd9\u4e9b\u79df\u6237\u5728\u903b\u8f91\u4e0a\u662f\u5b8c\u5168\u72ec\u7acb\u7684\u6570\u636e\u7a7a\u95f4\uff0c\u6240\u6709\u7684\u6570\u636e\u548c\u64cd\u4f5c\u90fd\u4e0e\u5176\u4ed6\u79df\u6237\u5b8c\u5168\u9694\u79bb\u3002\u5f53\u7528\u6237\u901a\u8fc7\u79df\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u767b\u5f55\u65f6\uff0c\u76f8\u5f53\u4e8e\u8fdb\u5165\u4e86\u4e00\u4e2a\u72ec\u7acb\u7684 MySQL \u5b9e\u4f8b\uff0c\u53ef\u4ee5\u8fdb\u884c\u5404\u79cd\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\u7684\u521b\u5efa\u64cd\u4f5c\uff0c\u800c\u4e0d\u4f1a\u5bf9\u5176\u4ed6\u79df\u6237\u7684\u6570\u636e\u4ea7\u751f\u4efb\u4f55\u5f71\u54cd\u3002
\u5728 MatrixOne \u4e2d\uff0c\u79df\u6237\uff08Account\uff09
\u662f\u6743\u9650\u7ba1\u7406\u4f53\u7cfb\u7684\u4e00\u90e8\u5206\u3002\u53ef\u4ee5\u53c2\u8003\u6743\u9650\u7ba1\u7406\u6982\u8ff0\u7ae0\u8282\u4ee5\u4e86\u89e3\u66f4\u8be6\u7ec6\u7684\u6743\u9650\u7ba1\u7406\u4f53\u7cfb\u4fe1\u606f\u3002
\u591a\u79df\u6237\u7684\u4f7f\u7528\u573a\u666f\u591a\u79cd\u591a\u6837\uff0c\u5305\u62ec\u5728 SaaS \u5e94\u7528\u4e2d\u7684\u591a\u79df\u6237\u8bbe\u8ba1\u3001\u96c6\u56e2\u516c\u53f8\u4e2d\u4e0d\u540c\u5b50\u516c\u53f8\u8d26\u53f7\u7684\u9694\u79bb\u3001\u5fae\u670d\u52a1\u67b6\u6784\u4e0b\u5404\u670d\u52a1\u6570\u636e\u5e93\u7684\u4f7f\u7528\u7b49\u3002\u6709\u5173\u8be6\u7ec6\u7684\u5e94\u7528\u573a\u666f\uff0c\u8bf7\u53c2\u8003 MatrixOne \u529f\u80fd\u6982\u8ff0\u4e2d\u7684\u591a\u79df\u6237\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#_3","title":"\u521b\u5efa\u548c\u4f7f\u7528\u79df\u6237","text":"\u9664\u4e86\u786e\u4fdd\u79df\u6237\u4e4b\u95f4\u7684\u6570\u636e\u548c\u8d1f\u8f7d\u9694\u79bb\u5916\uff0cMatrixOne \u8fd8\u63d0\u4f9b\u4e86\u4e00\u79cd\u5141\u8bb8\u79df\u6237\u95f4\u6570\u636e\u4e92\u901a\u7684\u673a\u5236\uff0c\u5373\u53d1\u5e03\u548c\u8ba2\u9605\u80fd\u529b\u3002\u8fd9\u4e00\u673a\u5236\u53ef\u7528\u4e8e\u89e3\u51b3\u6570\u636e\u540c\u6b65\u548c\u5927\u91cf\u6570\u636e\u5206\u53d1\u7b49\u573a\u666f\u4e2d\u7684\u4e92\u901a\u95ee\u9898\u3002\u8be6\u7ec6\u4fe1\u606f\u8bf7\u53c2\u8003\u53d1\u5e03\u8ba2\u9605\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/","title":"\u53d1\u5e03\u8ba2\u9605","text":"\u6570\u636e\u5e93\u7684\u53d1\u5e03\u8ba2\u9605\uff08Publish-Subscribe\uff0c\u7b80\u79f0 Pub/Sub\uff09\u662f\u4e00\u79cd\u6d88\u606f\u4f20\u9012\u6a21\u5f0f\uff0c\u5176\u4e2d\u53d1\u5e03\u8005\u5c06\u6d88\u606f\u53d1\u9001\u7ed9\u4e00\u4e2a\u6216\u591a\u4e2a\u8ba2\u9605\u8005\uff0c\u800c\u8ba2\u9605\u8005\u5219\u63a5\u6536\u5e76\u5904\u7406\u8be5\u6d88\u606f\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u53d1\u5e03\u8005\u548c\u8ba2\u9605\u8005\u4e4b\u95f4\u662f\u677e\u8026\u5408\u7684\uff0c\u5b83\u4eec\u4e4b\u95f4\u4e0d\u9700\u8981\u76f4\u63a5\u901a\u4fe1\uff0c\u56e0\u6b64\u53ef\u4ee5\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u7684\u53ef\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\u3002
\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u901a\u5e38\u88ab\u7528\u4e8e\u5b9e\u65f6\u6570\u636e\u66f4\u65b0\u3001\u7f13\u5b58\u540c\u6b65\u3001\u4e1a\u52a1\u4e8b\u4ef6\u901a\u77e5\u7b49\u573a\u666f\u3002\u4f8b\u5982\uff0c\u5f53\u6570\u636e\u5e93\u4e2d\u67d0\u4e2a\u8868\u7684\u6570\u636e\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u5b9e\u65f6\u901a\u77e5\u8ba2\u9605\u8005\uff0c\u4ece\u800c\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u540c\u6b65\u548c\u5904\u7406\u3002\u53e6\u5916\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u6765\u5b9e\u73b0\u4e1a\u52a1\u4e8b\u4ef6\u7684\u901a\u77e5\uff0c\u4f8b\u5982\u67d0\u4e2a\u8ba2\u5355\u88ab\u53d6\u6d88\u3001\u67d0\u4e2a\u5e93\u5b58\u6570\u91cf\u4e0d\u8db3\u7b49\u7b49\u3002
\u901a\u5e38\uff0c\u6570\u636e\u5e93\u7684\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u53d1\u5e03\u8005\u548c\u8ba2\u9605\u8005\u3002\u53d1\u5e03\u8005\u8d1f\u8d23\u53d1\u5e03\u6d88\u606f\uff0c\u800c\u8ba2\u9605\u8005\u5219\u8ba2\u9605\u76f8\u5e94\u6d88\u606f\u4ee5\u8fbe\u5230\u6570\u636e\u540c\u6b65\u7684\u76ee\u7684\u3002\u53d1\u5e03\u8005\u548c\u8ba2\u9605\u8005\u4e4b\u95f4\u53ef\u4ee5\u5b58\u5728\u591a\u5bf9\u591a\u7684\u5173\u7cfb\uff0c\u5373\u4e00\u4e2a\u53d1\u5e03\u8005\u53ef\u4ee5\u5411\u591a\u4e2a\u8ba2\u9605\u8005\u53d1\u5e03\u6d88\u606f\uff0c\u800c\u4e00\u4e2a\u8ba2\u9605\u8005\u4e5f\u53ef\u4ee5\u8ba2\u9605\u591a\u4e2a\u6d88\u606f/\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u5177\u6709\u591a\u79cd\u5178\u578b\u7684\u5e94\u7528\u573a\u666f\uff1a
\u6570\u636e\u540c\u6b65\uff1a\u5f53\u4e00\u4e2a\u6570\u636e\u5e93\u9700\u8981\u4e0e\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u4fdd\u6301\u540c\u6b65\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u66f4\u6539\u53d1\u9001\u5230\u8ba2\u9605\u8005\u6570\u636e\u5e93\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u7f51\u7ad9\u9700\u8981\u5c06\u6570\u636e\u4ece\u4e00\u4e2a\u5730\u7406\u4f4d\u7f6e\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u5730\u7406\u4f4d\u7f6e\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u6570\u636e\u540c\u6b65\u3002
\u4e1a\u52a1\u6570\u636e\u5206\u53d1\uff1a\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u4e1a\u52a1\u6570\u636e\u5206\u53d1\u5230\u4e0d\u540c\u7684\u7cfb\u7edf\u6216\u4e1a\u52a1\u6d41\u7a0b\u4e2d\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u94f6\u884c\u9700\u8981\u5c06\u5ba2\u6237\u8d26\u6237\u4fe1\u606f\u5206\u53d1\u5230\u591a\u4e2a\u4e1a\u52a1\u7cfb\u7edf\u4e2d\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u5206\u53d1\u5230\u76f8\u5e94\u7684\u7cfb\u7edf\u4e2d\uff0c\u786e\u4fdd\u5404\u4e2a\u4e1a\u52a1\u6d41\u7a0b\u4e4b\u95f4\u7684\u6570\u636e\u4e00\u81f4\u6027\u3002
\u6570\u636e\u5907\u4efd\uff1a\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5907\u4efd\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u6570\u636e\u5e93\u9700\u8981\u5907\u4efd\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u5907\u4efd\u5230\u8ba2\u9605\u8005\u6570\u636e\u5e93\u4e2d\uff0c\u4ee5\u4fbf\u5728\u4e3b\u6570\u636e\u5e93\u51fa\u73b0\u6545\u969c\u65f6\u6062\u590d\u6570\u636e\u3002
\u5b9e\u65f6\u6570\u636e\u5904\u7406\uff1a\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u5904\u7406\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u7f51\u7ad9\u9700\u8981\u5bf9\u6765\u81ea\u4e0d\u540c\u7528\u6237\u7684\u6570\u636e\u8fdb\u884c\u5904\u7406\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u4f20\u8f93\u5230\u5904\u7406\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u5904\u7406\uff0c\u4ee5\u4fbf\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u3002
\u53d1\u5e03\uff1a\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u53d1\u5e03\u901a\u5e38\u6307\u7684\u662f\u5c06\u4e00\u4e2a\u6570\u636e\u5e93\u5bf9\u8c61\u8bbe\u7f6e\u4e3a\u53ef\u4f9b\u5176\u4ed6\u79df\u6237\u8bbf\u95ee\u7684\u72b6\u6001\u3002\u8fd9\u662f\u6570\u636e\u5171\u4eab\u548c\u590d\u5236\u7684\u4e00\u4e2a\u91cd\u8981\u6b65\u9aa4\uff0c\u53d1\u5e03\u7684\u5bf9\u8c61\u53ef\u4ee5\u88ab\u5176\u4ed6\u79df\u6237\u8ba2\u9605\u5e76\u83b7\u53d6\u6570\u636e\u3002
\u8ba2\u9605\uff1a\u8ba2\u9605\u662f\u6307\u4e00\u4e2a\u6570\u636e\u5e93\u9009\u62e9\u63a5\u6536\u548c\u590d\u5236\u53d1\u5e03\u7684\u6570\u636e\u5e93\u5bf9\u8c61\u7684\u6570\u636e\u3002
\u53d1\u5e03\u7aef\uff08Pub\uff09\uff1a\u53d1\u5e03\u7aef\u662f\u6267\u884c\u53d1\u5e03\u64cd\u4f5c\u7684\u6570\u636e\u5e93\u3002\u53d1\u5e03\u7aef\u8d1f\u8d23\u521b\u5efa\u548c\u7ba1\u7406\u53d1\u5e03\u7684\u5bf9\u8c61\uff0c\u4ee5\u53ca\u7ba1\u7406\u8ba2\u9605\u8be5\u53d1\u5e03\u5bf9\u8c61\u7684\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u3002
\u8ba2\u9605\u7aef\uff08Sub\uff09\uff1a\u8ba2\u9605\u7aef\u662f\u8ba2\u9605\u53d1\u5e03\u5bf9\u8c61\u7684\u79df\u6237\u3002
\u53d1\u5e03\u5bf9\u8c61\uff1a\u53d1\u5e03\u5bf9\u8c61\u662f\u5728\u53d1\u5e03\u7aef\u521b\u5efa\u5e76\u8bbe\u7f6e\u4e3a\u53ef\u53d1\u5e03\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5373\u6570\u636e\u5e93\u3002\u8fd9\u4e9b\u5bf9\u8c61\u7684\u6570\u636e\u53ef\u4ee5\u88ab\u8ba2\u9605\u7aef\u8bbf\u95ee\u548c\u590d\u5236\u3002
\u8ba2\u9605\u5bf9\u8c61\uff1a\u8ba2\u9605\u5bf9\u8c61\u662f\u5728\u8ba2\u9605\u7aef\u590d\u5236\u548c\u5b58\u50a8\u7684\u53d1\u5e03\u5bf9\u8c61\u3002\u8ba2\u9605\u5bf9\u8c61\u7684\u6570\u636e\u4f1a\u6839\u636e\u53d1\u5e03\u7aef\u7684\u6570\u636e\u8fdb\u884c\u66f4\u65b0\u3002
\u53d1\u5e03\u7aef\uff08Pub\uff09\u548c\u8ba2\u9605\u7aef\uff08Sub\uff09\u5747\u4e3a MatrixOne \u7684\u79df\u6237\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#_6","title":"\u53ef\u53d1\u5e03/\u53ef\u8ba2\u9605\u6743\u9650\u8303\u56f4","text":"\u672c\u7ae0\u8282\u5c06\u7ed9\u51fa\u4e00\u4e2a\u793a\u4f8b\uff0c\u4ecb\u7ecd\u5f53\u524d\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u5b58\u5728 3 \u4e2a\u79df\u6237\uff0csys\u3001acc1 \u4e0e acc2\uff0c\u6309\u7167\u64cd\u4f5c\u987a\u5e8f\u5bf9\u4e09\u4e2a\u79df\u6237\u8fdb\u884c\u64cd\u4f5c\uff1a
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u521b\u5efa\u6570\u636e\u5e93 sub1 \u4e0e\u8868 t1\uff0c\u5e76\u53d1\u5e03 pub1\uff1a
create database sub1;\ncreate table sub1.t1(a int,b int);\ncreate publication pub1 database sub1;\nmysql> show publications;\n+-------------+----------+---------------------+-------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+-------------+-------------+----------+\n| pub1 | sub1 | 2024-04-23 10:28:15 | NULL | * | |\n+-------------+----------+---------------------+-------------+-------------+----------+\n1 row in set (0.01 sec)\n
\u8ba2\u9605\u8005\uff1aacc1 \u548c acc2 \u90fd\u521b\u5efa\u8ba2\u9605\u5e93 syssub1\uff0c\u4e8e\u662f\u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1\uff1a
-- all \u9009\u9879\u53ef\u4ee5\u770b\u5230\u6240\u6709\u6709\u6743\u9650\u7684\u8ba2\u9605\uff0c\u672a\u8ba2\u9605\u7684 sub_time, sub_name \u4e3a null\uff0c\u4e0d\u52a0 all \u53ea\u80fd\u770b\u5230\u5df2\u8ba2\u9605\u7684\u53d1\u5e03\u4fe1\u606f\u3002\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+----------+\n1 row in set (0.01 sec)\n\n-- acc1 \u548c acc2 \u521b\u5efa\u8ba2\u9605\u5e93\u7684 sql \u8bed\u53e5\u4e00\u81f4\uff0c\u6b64\u5904\u4e0d\u505a\u8d58\u8ff0\ncreate database syssub1 from sys publication pub1;\nuse syssub1;\n\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub1 |\n+--------------------+\n| t1 |\n+--------------------+\n2 rows in set (0.02 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u521b\u5efa\u6570\u636e\u8868 t2\uff1a
create table sub1.t2(a text);\n
\u8ba2\u9605\u8005\uff1aacc1 \u548c acc2 \u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1 \u548c t2\uff1a
use syssub1;\nmysql> show tables;\n+-------------------+\n| Tables_in_syssub1 |\n+-------------------+\n| t1 |\n| t2 |\n+-------------------+\n2 rows in set (0.01 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u521b\u5efa\u6570\u636e\u5e93 sub2 \u4e0e\u8868 t1\uff0c\u5e76\u53d1\u5e03 pub2 \u7ed9\u79df\u6237 acc1
create database sub2;\ncreate table sub2.t1(a float);\ncreate publication pub2 database sub2 account acc1;\n
\u8ba2\u9605\u8005\uff1aacc1 \u548c acc2 \u90fd\u521b\u5efa\u8ba2\u9605\u5e93 syssub2\uff0cacc1 \u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1\uff1bacc2 \u521b\u5efa\u8ba2\u9605\u5e93 syssub2 \u5931\u8d25\uff1a
mysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:30:43 |\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.01 sec)\n\ncreate database syssub2 from sys publication pub2;\nuse syssub2;\n\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:30:43 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2 |\n+--------------------+\n| t1 |\n+--------------------+\n2 rows in set (0.02 sec)\n
-- acc2 \u770b\u4e0d\u5230 pub2\uff0c\u56e0\u4e3a\u6ca1\u6709\u8ba2\u9605\u6743\u9650\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.01 sec)\n\nmysql> create database syssub2 from sys publication pub2;\nERROR 20101 (HY000): internal error: the account acc2 is not allowed to subscribe the publication pub2\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u4fee\u6539\u53d1\u5e03 pub2 \u7ed9\u5168\u90e8\u79df\u6237\uff1a
alter publication pub2 account all;\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| pub2 | sub2 | 2024-04-23 10:40:54 | 2024-04-23 10:47:53 | * | |\n| pub1 | sub1 | 2024-04-23 10:28:15 | NULL | * | |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n2 rows in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc2 \u521b\u5efa\u8ba2\u9605\u5e93 syssub2 \u6210\u529f\uff0c\u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1\uff1a
-- acc2 \u73b0\u5728\u80fd\u770b\u5230 pub2 \u4e86\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.00 sec)\n\ncreate database syssub2 from sys publication pub2;\nuse syssub2;\n\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:50:43 |\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.00 sec)\n\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2 |\n+--------------------+\n| t1 |\n+--------------------+\n2 rows in set (0.02 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u5220\u9664\u53d1\u5e03 pub1\uff1a
drop publication pub1;\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| pub2 | sub2 | 2024-04-23 10:40:54 | 2024-04-23 10:47:53 | * | |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n1 row in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc1\u3001acc2 \u8fde\u63a5 syspub1 \u5931\u8d25\uff1a
mysql> use syssub1;\nERROR 20101 (HY000): internal error: there is no publication pub1\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u65b0\u5efa\u6570\u636e\u5e93 sub1_new\uff0c\u5e76\u91cd\u65b0\u4ee5 pub1 \u53d1\u5e03
create database sub1_new;\nuse sub1_new;\ncreate table t3(n1 int);\ninsert into t3 values (1);\ncreate publication pub1 database sub1_new;\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| pub2 | sub2 | 2024-04-23 10:40:54 | 2024-04-23 10:47:53 | * | |\n| pub1 | sub1_new | 2024-04-23 10:59:11 | NULL | * | |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n2 rows in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc1\u3001acc2 \u8fde\u63a5 syspub1\uff0c\u53ef\u4ee5\u770b\u5230 pub1 \u65b0\u7684\u5185\u5bb9\uff0c\u5c31\u662f\u8bf4\u5982\u679c\u53d1\u5e03\u65b9\u66f4\u6539\u4e86\u53d1\u5e03\u7684\u5185\u5bb9\uff0c\u8ba2\u9605\u65b9\u4e0d\u7528\u505a\u4efb\u4f55\u64cd\u4f5c\u5373\u53ef\u770b\u5230\u66f4\u65b0\u3002
use syssub1;\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n| pub1 | sys | sub1_new | 2024-04-23 10:59:11 | syssub1 | 2024-04-23 10:30:43 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> show tables;\n+-------------------+\n| Tables_in_syssub1 |\n+-------------------+\n| t3 |\n+-------------------+\n1 row in set (0.01 sec)\n\nmysql> select * from t3;\n+------+\n| n1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n
\u8ba2\u9605\u8005\uff1aacc1 \u5220\u9664\u8ba2\u9605\uff1a
-- \u901a\u8fc7 drop database \u5220\u9664\u8ba2\u9605\ndrop database syssub1;\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u5220\u9664\u5df2\u53d1\u5e03\u7684\u6570\u636e\u5e93\u4e4b\u524d\uff0c\u8981\u5148\u5220\u9664\u5176\u5bf9\u5e94\u7684\u53d1\u5e03\uff1a
mysql> drop database sub1_new;\nERROR 20101 (HY000): internal error: can not drop database 'sub1_new' which is publishing\nmysql> drop publication pub1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> drop database sub1_new;\nQuery OK, 1 row affected (0.03 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u4fee\u6539\u53d1\u5e03\u5185\u5bb9\uff1a
alter publication pub2 comment \"this is pub2\";--\u4fee\u6539comments\nmysql> show publications;\ncreate database new_sub2;\ncreate table new_sub2.new_t (xxx int);\ninsert into new_sub2.new_t values (123);\nalter publication pub2 database new_sub2;--\u4fee\u6539database\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+--------------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+--------------+\n| pub2 | new_sub2 | 2024-04-23 10:40:54 | 2024-04-23 11:04:20 | * | this is pub2 |\n+-------------+----------+---------------------+---------------------+-------------+--------------+\n1 row in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc1\u3001acc2 \u67e5\u770b\u8ba2\u9605\uff0c\u80fd\u770b\u5230\u53d1\u5e03\u6570\u636e\u5e93\u4fee\u6539\u540e\u7684\u5185\u5bb9\uff1a
mysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | new_sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n\nuse syssub2;\nmysql> show tables;\n+-------------------+\n| Tables_in_syssub2 |\n+-------------------+\n| new_t |\n+-------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from new_t;\n+------+\n| xxx |\n+------+\n| 123 |\n+------+\n1 row in set (0.00 sec)\n
\u5728\u8bb8\u591a\u5927\u578b\u3001\u5173\u952e\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u8ba1\u7b97\u673a\u6bcf\u79d2\u949f\u90fd\u5728\u6267\u884c\u5927\u91cf\u7684\u4efb\u52a1\u3002\u66f4\u4e3a\u7ecf\u5e38\u7684\u4e0d\u662f\u8fd9\u4e9b\u4efb\u52a1\u672c\u8eab\uff0c\u800c\u662f\u5c06\u8fd9\u4e9b\u4efb\u52a1\u7ed3\u5408\u5728\u4e00\u8d77\u5b8c\u6210\u4e00\u4e2a\u4e1a\u52a1\u8981\u6c42\uff0c\u79f0\u4e3a\u4e8b\u52a1\u3002\u5982\u679c\u80fd\u6210\u529f\u5730\u6267\u884c\u4e00\u4e2a\u4efb\u52a1\uff0c\u800c\u5728\u7b2c\u4e8c\u4e2a\u6216\u7b2c\u4e09\u4e2a\u76f8\u5173\u7684\u4efb\u52a1\u4e2d\u51fa\u73b0\u9519\u8bef\uff0c\u5c06\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u8fd9\u4e2a\u9519\u8bef\u5f88\u53ef\u80fd\u4f7f\u7cfb\u7edf\u6570\u636e\u5904\u4e8e\u4e0d\u4e00\u81f4\u72b6\u6001\u3002\u8fd9\u65f6\u4e8b\u52a1\u53d8\u5f97\u975e\u5e38\u91cd\u8981\uff0c\u5b83\u80fd\u4f7f\u7cfb\u7edf\u6570\u636e\u6446\u8131\u8fd9\u79cd\u4e0d\u4e00\u81f4\u7684\u72b6\u6001\u3002 \u5982\u4f55\u7406\u89e3\u4e8b\u52a1\u5462\uff1f\u4f8b\u5982\u5728\u67d0\u5bb6\u94f6\u884c\u7684\u94f6\u884c\u7cfb\u7edf\u4e2d\uff0c\u5982\u679c\u6ca1\u6709\u4e8b\u52a1\u5bf9\u6570\u636e\u8fdb\u884c\u63a7\u5236\u548c\u7ba1\u7406\uff0c\u5f88\u53ef\u80fd\u51fa\u73b0 A \u4ece\u4f01\u4e1a\u8d26\u6237\u4e2d\u53d6\u51fa\u4e00\u7b14\u94b1\uff0c\u540c\u65f6 B \u548c C \u4e5f\u4ece\u540c\u4e00\u4f01\u4e1a\u8d26\u6237\u4e2d\u53d6\u94b1\u3002\u6bcf\u4e00\u7b14\u8f6c\u8d26\u6d89\u53ca\u5230\u6700\u5c11\u4e24\u4e2a\u8d26\u6237\u4fe1\u606f\u7684\u53d8\u5316\uff08\u4f8b\u5982\uff0cA \u7684\u94b1\u5230\u8d26\uff0c\u4f01\u4e1a\u8d26\u6237\u51fa\u8d26\uff1bB \u7684\u94b1\u5230\u8d26\uff0c\u4f01\u4e1a\u8d26\u6237\u51fa\u8d26\uff1bC \u7684\u94b1\u5230\u8d26\uff0c\u4f01\u4e1a\u8d26\u6237\u51fa\u8d26\uff09\uff0c\u5982\u679c\u6ca1\u6709\u4e8b\u52a1\uff0c\u90a3\u4e48\u8d26\u9762\u91d1\u989d\u7684\u5177\u4f53\u6570\u503c\u5c06\u65e0\u6cd5\u786e\u5b9a\u3002\u5728\u5f15\u5165\u4e8b\u52a1\u8fd9\u4e00\u4e1a\u52a1\u8981\u6c42\u4e4b\u540e\uff0c\u4e8b\u52a1\u7684\u57fa\u672c\u7279\u6027\uff08ACID\uff09\u786e\u4fdd\u4e86\u94f6\u884c\u8d26\u9762\u7684\u8d44\u91d1\u64cd\u4f5c\u662f\u539f\u5b50\u6027\uff08\u4e0d\u53ef\u518d\u5206\u5272\uff09\u7684\uff0c\u5176\u4ed6\u4eba\u770b\u5230\u7684\u91d1\u989d\u662f\u5177\u5907\u9694\u79bb\u6027\u7684\uff0c\u6bcf\u4e00\u6b21\u64cd\u4f5c\u90fd\u662f\u5177\u6709\u4e00\u81f4\u6027\u7684\uff0c\u6240\u6709\u64cd\u4f5c\u662f\u6301\u4e45\u6027\u7684\uff0c\u8fd9\u6837\u4fdd\u8bc1\u4e86\u94f6\u884c\u7cfb\u7edf\u6570\u636e\u51fa\u5165\u8d26\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_3","title":"\u4ec0\u4e48\u662f\u4e8b\u52a1\uff1f","text":"\u6570\u636e\u5e93\u4e8b\u52a1\uff08\u5373\uff0cTransaction\uff0c\u4e8b\u52a1\uff09\u662f\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e2a\u903b\u8f91\u5355\u4f4d\uff0c\u7531\u4e00\u4e2a\u6709\u9650\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u5e8f\u5217\u6784\u6210\u3002 \u4e8b\u52a1\u5c31\u662f\u4f5c\u4e3a\u4e00\u4e2a\u903b\u8f91\u5355\u4f4d\u63d0\u4ea4\u6216\u8005\u56de\u6eda\u4e00\u7cfb\u5217\u7684 SQL \u8bed\u53e5\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_4","title":"\u4e8b\u52a1\u7684\u7279\u5f81","text":"\u901a\u5e38\u4e8b\u52a1\u9700\u8981\u5177\u5907 ACID \u56db\u4e2a\u7279\u5f81\uff1a
\u4f8b\u5982\uff0c\u6211\u4eec\u73b0\u5728\u6709\u5982\u4e0b\u4e8b\u52a1\uff1a
start transaction;\ninsert into t1 values(1,2,3),(4,5,6);\nupdate t2 set c1='b' where c1='B';\ncommit;\n
\u5982\u679c\u5bf9 t1 \u63d2\u5165\u6570\u636e\u6216\u4fee\u6539 t2 \u6570\u636e\u4e2d\u7684\u4efb\u610f\u4e00\u6761\u53d1\u751f\u9519\u8bef\uff0c\u6574\u4e2a\u4e8b\u52a1\u90fd\u4f1a\u56de\u6eda\uff0c\u800c\u53ea\u6709\u4e24\u6761\u8bed\u53e5\u540c\u65f6\u6210\u529f\u65f6\uff0c\u624d\u4f1a\u63d0\u4ea4\u6210\u529f\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4e00\u4e2a\u64cd\u4f5c\u6210\u529f\u800c\u53e6\u4e00\u4e2a\u64cd\u4f5c\u5931\u8d25\u3002
\u4f8b\u5982\uff0c\u6211\u4eec\u5728\u6570\u636e\u5e93\u4e2d\u5efa\u7acb\u4e00\u4e2a\u65b0\u8868
create table t1(a int primary key,b varchar(5) not null);\n
\u6b64\u5904\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u6027\uff0c\u6211\u4eec\u5728\u63d2\u5165\u6570\u636e\u65f6\uff0c\u4f60\u8981\u4fdd\u8bc1 a \u548c b \u5217\u7684\u6570\u636e\u7c7b\u578b\u4e0e\u8303\u56f4\uff0c\u540c\u65f6\u8fd8\u8981\u6ee1\u8db3 a \u5217\u7684\u4e3b\u952e\u7ea6\u675f\u4e0e b \u5217\u7684\u975e\u7a7a\u7ea6\u675f\uff1a
insert into t1 values(1,'abcde'),(2,'bcdef');\n
\u4f8b\u5982\uff0c\u5982\u4e0b\u4e8b\u52a1\u793a\u4f8b\uff0c\u4f1a\u8bdd\u9694\u79bb\u7ea7\u522b\u662f\u8bfb\u5df2\u63d0\u4ea4\uff0c\u5728\u4f1a\u8bdd 1 \u80fd\u770b\u5230\u7684\u6570\u636e\u5982\u4e0b\uff1a
select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n+------+------+\n
\u6b64\u65f6\u5728\u4f1a\u8bdd 2 \u4e2d\uff0c\u505a\u5982\u4e0b\u64cd\u4f5c\uff1a
begin;\ndelete from t1 where a=3;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u7684\u6570\u636e\u4ecd\u7136\u4e0d\u4f1a\u6709\u53d8\u5316\uff1a
select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n+------+------+\n
\u76f4\u5230\u5728\u4f1a\u8bdd 2 \u4e2d\u63d0\u4ea4\u5f53\u524d\u4e8b\u52a1\uff1a
commit;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\u624d\u4f1a\u770b\u5230\u5df2\u63d0\u4ea4\u4e8b\u52a1\u7684\u7ed3\u679c\uff1a
select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | a |\n| 2 | b |\n+------+------+\n
\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u4e8b\u52a1\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a
\u8fd9\u4e24\u5927\u7c7b\u4e8b\u52a1\u7684\u5206\u7c7b\u5f7c\u6b64\u4e0d\u53d7\u5bf9\u65b9\u9650\u5236\uff0c\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\u53ef\u4ee5\u662f\u4e50\u89c2\u4e8b\u52a1\u6216\u60b2\u89c2\u4e8b\u52a1\uff0c\u540c\u65f6\u4e00\u4e2a\u60b2\u89c2\u4e8b\u52a1\u53ef\u80fd\u662f\u663e\u5f0f\u4e8b\u52a1\u4e5f\u53ef\u80fd\u662f\u9690\u5f0f\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_6","title":"\u663e\u5f0f\u4e8b\u52a1\u548c\u9690\u5f0f\u4e8b\u52a1","text":"\u663e\u5f0f\u4e8b\u52a1\uff1a\u4e00\u822c\u6765\u8bf4\uff0c\u53ef\u4ee5\u901a\u8fc7\u6267\u884c BEGIN \u8bed\u53e5\u663e\u5f0f\u542f\u52a8\u4e8b\u52a1\u3002\u53ef\u4ee5\u901a\u8fc7\u6267\u884c COMMIT \u6216 ROLLBACK \u663e\u5f0f\u7ed3\u675f\u4e8b\u52a1\u3002MatrixOne \u7684\u663e\u793a\u4e8b\u52a1\u542f\u52a8\u548c\u6267\u884c\u65b9\u5f0f\u7565\u6709\u4e0d\u540c\uff0c\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u663e\u5f0f\u4e8b\u52a1\u3002
\u9690\u5f0f\u4e8b\u52a1\uff1a\u5373\u4e8b\u52a1\u53ef\u4ee5\u9690\u5f0f\u5f00\u59cb\u548c\u7ed3\u675f\uff0c\u65e0\u9700\u4f7f\u7528 BEGIN TRANSACTION\u3001COMMIT \u6216\u8005 ROLLBACK \u8bed\u53e5\u5c31\u53ef\u4ee5\u5f00\u59cb\u548c\u7ed3\u675f\u3002\u9690\u5f0f\u4e8b\u52a1\u7684\u884c\u4e3a\u65b9\u5f0f\u4e0e\u663e\u5f0f\u4e8b\u52a1\u76f8\u540c\u3002\u4f46\u662f\uff0c\u786e\u5b9a\u9690\u5f0f\u4e8b\u52a1\u4f55\u65f6\u5f00\u59cb\u7684\u89c4\u5219\u4e0d\u540c\u4e8e\u786e\u5b9a\u663e\u5f0f\u4e8b\u52a1\u4f55\u65f6\u5f00\u59cb\u7684\u89c4\u5219\u3002MatrixOne \u7684\u9690\u5f0f\u4e8b\u52a1\u542f\u52a8\u548c\u6267\u884c\u65b9\u5f0f\u7565\u6709\u4e0d\u540c\uff0c\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u9690\u5f0f\u4e8b\u52a1\u3002
\u65e0\u8bba\u662f\u4e50\u89c2\u4e8b\u52a1\uff0c\u8fd8\u662f\u60b2\u89c2\u4e8b\u52a1\uff0c\u5176\u4e8b\u52a1\u7684\u6267\u884c\u7ed3\u679c\u90fd\u662f\u4e00\u6837\u7684\uff0c\u5373\u4e00\u4e2a\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\uff0c\u5bf9 ACID \u7ea7\u522b\u7684\u8981\u6c42\uff0c\u5b8c\u5168\u4e00\u6837\uff0c\u65e0\u8bba\u662f\u539f\u5b50\u6027\u3001\u4e00\u81f4\u6027\u3001\u9694\u79bb\u6027\u6216\u8005\u6301\u4e45\u6027\uff0c\u90fd\u662f\u5b8c\u5168\u4e00\u81f4\uff0c\u4e0d\u5b58\u5728\u4e50\u89c2\u4e8b\u52a1\u5c31\u5bbd\u677e\u4e00\u4e9b\uff0c\u60b2\u89c2\u4e8b\u52a1\u5c31\u4e25\u683c\u4e00\u4e9b\u7684\u60c5\u51b5\u3002
\u4e50\u89c2\u4e8b\u52a1\u4e0e\u60b2\u89c2\u4e8b\u52a1\u7684\u533a\u522b\uff0c\u5b83\u53ea\u662f\u4e24\u9636\u6bb5\u63d0\u4ea4\u57fa\u4e8e\u5f85\u5904\u7406\u4e1a\u52a1\u72b6\u6001\u7684\u4e0d\u540c\u6267\u884c\u7b56\u7565\uff0c\u5176\u9009\u62e9\u57fa\u4e8e\u6267\u884c\u8005\u7684\u5224\u65ad\uff0c\u5176\u6548\u7387\u9ad8\u4f4e\u57fa\u4e8e\u88ab\u5904\u7406\u4e1a\u52a1\u7684\u5b9e\u9645\u72b6\u6001\uff08\u5e76\u53d1\u4e8b\u52a1\u7684\u5199\u51b2\u7a81\u9891\u7e41\u5ea6\uff09\u3002\u5373\u5728\u4e8e\u5bf9\u4e8e\u4e8b\u52a1\u76f8\u5173\u8d44\u6e90\u7684\u72b6\u6001\u505a\u51fa\u4e0d\u540c\u7684\u5047\u8bbe\uff0c\u4ece\u800c\u5c06\u5199\u9501\u653e\u5728\u4e0d\u540c\u7684\u9636\u6bb5\u4e2d\u3002
\u5728\u4e50\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4e0d\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u8fd9\u4e00\u9636\u6bb5\u4e0d\u4f1a\u5bf9\u6570\u636e\u52a0\u9501\uff0c\u800c\u5728\u6570\u636e\u63d0\u4ea4\u65f6\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5728\u5b8c\u6210\u63d0\u4ea4\u540e\u89e3\u9501\u3002
\u800c\u5728\u60b2\u89c2\u4e8b\u52a1\u4e2d\uff0c\u4e00\u4e2a\u4e8b\u52a1\u5728\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u4e00\u5b9a\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\uff0c\u9884\u5148\u5bf9\u76f8\u5173\u8868\u6216\u884c\u52a0\u9501\u3002\u7136\u540e\u624d\u5728\u5185\u5b58\u4e2d\uff0c\u5bf9\u76f8\u5173\u6570\u636e\u8fdb\u884c\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u5e76\u63d0\u4ea4\u3002\u53ea\u6709\u5728\u63d0\u4ea4\u6216\u56de\u6eda\u5b8c\u6210\u540e\u624d\u5bf9\u6570\u636e\u8fdb\u884c\u89e3\u9501\u3002
\u4e50\u89c2\u4e8b\u52a1\u4e0e\u60b2\u89c2\u4e8b\u52a1\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6709\u7740\u5982\u4e0b\u7684\u4f18\u7f3a\u70b9\uff1a
MatrixOne \u7684\u4e50\u89c2\u4e8b\u52a1\u8be6\u60c5\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u4e50\u89c2\u4e8b\u52a1\u3002
MatrixOne \u7684\u60b2\u89c2\u4e8b\u52a1\u8be6\u60c5\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u60b2\u89c2\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_8","title":"\u4e8b\u52a1\u9694\u79bb","text":"\u5173\u4e8e\u4e8b\u52a1\u7279\u5f81\u4e2d\u6709\u4e00\u6761\u662f\u9694\u79bb\u6027\uff0c\u6211\u4eec\u901a\u5e38\u79f0\u4e4b\u4e3a\u4e8b\u52a1\u9694\u79bb\u3002
\u5728\u6570\u636e\u5e93\u4e8b\u52a1\u7684 ACID \u56db\u4e2a\u5c5e\u6027\u4e2d\uff0c\u9694\u79bb\u6027\u662f\u4e00\u4e2a\u9650\u5236\u6700\u5bbd\u677e\u7684\u3002\u4e3a\u4e86\u83b7\u53d6\u66f4\u9ad8\u7684\u9694\u79bb\u7b49\u7ea7\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u901a\u5e38\u4f7f\u7528\u9501\u673a\u5236\u6216\u8005\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\u673a\u5236\u3002\u5e94\u7528\u8f6f\u4ef6\u4e5f\u9700\u8981\u989d\u5916\u7684\u903b\u8f91\u6765\u4f7f\u5176\u6b63\u5e38\u5de5\u4f5c\u3002
\u5f88\u591a\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff08DBMS\uff09\u5b9a\u4e49\u4e86\u4e0d\u540c\u7684\u201c\u4e8b\u52a1\u9694\u79bb\u7b49\u7ea7\u201d\u6765\u63a7\u5236\u9501\u7684\u7a0b\u5ea6\u3002\u5728\u5f88\u591a\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0c\u591a\u6570\u7684\u4e8b\u52a1\u90fd\u907f\u514d\u9ad8\u7b49\u7ea7\u7684\u9694\u79bb\u7b49\u7ea7\uff08\u5982\u53ef\u4e32\u884c\u5316\uff09\u4ece\u800c\u51cf\u5c11\u9501\u7684\u5f00\u9500\u3002\u7a0b\u5e8f\u5458\u9700\u8981\u5c0f\u5fc3\u7684\u5206\u6790\u6570\u636e\u5e93\u8bbf\u95ee\u90e8\u5206\u7684\u4ee3\u7801\u6765\u4fdd\u8bc1\u9694\u79bb\u7ea7\u522b\u7684\u964d\u4f4e\u4e0d\u4f1a\u9020\u6210\u96be\u4ee5\u53d1\u73b0\u7684\u4ee3\u7801\u9519\u8bef\u3002\u76f8\u53cd\u7684\uff0c\u66f4\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u4f1a\u589e\u52a0\u6b7b\u9501\u53d1\u751f\u7684\u51e0\u7387\uff0c\u540c\u6837\u9700\u8981\u5728\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u53bb\u907f\u514d\u3002
\u7531\u4e8e\u66f4\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u4e2d\u4e0d\u5b58\u5728\u88ab\u4e00\u4e2a\u66f4\u4f4e\u7684\u9694\u79bb\u7ea7\u522b\u7981\u6b62\u7684\u64cd\u4f5c\uff0cDBMS \u88ab\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u6bd4\u8bf7\u6c42\u7684\u9694\u79bb\u7ea7\u522b\u66f4\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u3002
ANSI/ISO SQL \u5b9a\u4e49\u7684\u6807\u51c6\u9694\u79bb\u7ea7\u522b\u5171\u6709\u56db\u4e2a\uff1a
\u9694\u79bb\u7ea7\u522b \u810f\u5199 (Dirty Write) \u810f\u8bfb (Dirty Read) \u4e0d\u53ef\u91cd\u590d\u8bfb (Fuzzy Read) \u5e7b\u8bfb (Phantom) READ UNCOMMITTED Not Possible Possible Possible Possible READ COMMITTED Not Possible Not Possible Possible Possible REPEATABLE READ Not Possible Not Possible Not Possible Possible SERIALIZABLE Not Possible Not Possible Not Possible Not Possible\u8bfb\u672a\u63d0\u4ea4\uff1a\u8bfb\u672a\u63d0\u4ea4\uff08READ UNCOMMITTED\uff09\u662f\u6700\u4f4e\u7684\u9694\u79bb\u7ea7\u522b\u3002\u5141\u8bb8\u201c\u810f\u8bfb\u201d\uff08dirty reads\uff09\uff0c\u4e8b\u52a1\u53ef\u4ee5\u770b\u5230\u5176\u4ed6\u4e8b\u52a1\u201c\u5c1a\u672a\u63d0\u4ea4\u201d\u7684\u4fee\u6539\u3002
\u8bfb\u5df2\u63d0\u4ea4\uff1a\u8bfb\u5df2\u63d0\u4ea4\uff08READ COMMITTED\uff09\u7ea7\u522b\u4e2d\uff0c\u57fa\u4e8e\u9501\u673a\u5236\u5e76\u53d1\u63a7\u5236\u7684 DBMS \u9700\u8981\u5bf9\u9009\u5b9a\u5bf9\u8c61\u7684\u5199\u9501\u4e00\u76f4\u4fdd\u6301\u5230\u4e8b\u52a1\u7ed3\u675f\uff0c\u4f46\u662f\u8bfb\u9501\u5728 SELECT \u64cd\u4f5c\u5b8c\u6210\u540e\u9a6c\u4e0a\u91ca\u653e\u3002\u548c\u524d\u4e00\u79cd\u9694\u79bb\u7ea7\u522b\u4e00\u6837\uff0c\u4e5f\u4e0d\u8981\u6c42\u201c\u8303\u56f4\u9501\u201d\u3002
\u53ef\u91cd\u590d\u8bfb\uff1a\u5728\u53ef\u91cd\u590d\u8bfb\uff08REPEATABLE READS\uff09\u9694\u79bb\u7ea7\u522b\u4e2d\uff0c\u57fa\u4e8e\u9501\u673a\u5236\u5e76\u53d1\u63a7\u5236\u7684 DBMS \u9700\u8981\u5bf9\u9009\u5b9a\u5bf9\u8c61\u7684\u8bfb\u9501\uff08read locks\uff09\u548c\u5199\u9501\uff08write locks\uff09\u4e00\u76f4\u4fdd\u6301\u5230\u4e8b\u52a1\u7ed3\u675f\uff0c\u4f46\u4e0d\u8981\u6c42\u201c\u8303\u56f4\u9501\u201d\uff0c\u56e0\u6b64\u53ef\u80fd\u4f1a\u53d1\u751f\u201c\u5e7b\u8bfb\u201d\u3002MatrixOne \u5b9e\u73b0\u4e86\u5feb\u7167\u9694\u79bb\uff08\u5373 Snapshot Isolation\uff09\uff0c\u4e3a\u4e86\u4e0e MySQL \u9694\u79bb\u7ea7\u522b\u4fdd\u6301\u4e00\u81f4\uff0cMatrixOne \u5feb\u7167\u9694\u79bb\u53c8\u53eb\u505a\u53ef\u91cd\u590d\u8bfb\uff08REPEATABLE READS\uff09\u3002
\u53ef\u4e32\u884c\u5316\uff1a\u53ef\u4e32\u884c\u5316\uff08SERIALIZABLE\uff09\u662f\u6700\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u3002\u5728\u57fa\u4e8e\u9501\u673a\u5236\u5e76\u53d1\u63a7\u5236\u7684 DBMS \u4e0a\uff0c\u53ef\u4e32\u884c\u5316\u8981\u6c42\u5728\u9009\u5b9a\u5bf9\u8c61\u4e0a\u7684\u8bfb\u9501\u548c\u5199\u9501\u76f4\u5230\u4e8b\u52a1\u7ed3\u675f\u540e\u624d\u80fd\u91ca\u653e\u3002\u5728 SELECT \u7684\u67e5\u8be2\u4e2d\u4f7f\u7528\u4e00\u4e2a\u201cWHERE\u201d\u5b50\u53e5\u6765\u63cf\u8ff0\u4e00\u4e2a\u8303\u56f4\u65f6\u5e94\u8be5\u83b7\u5f97\u4e00\u4e2a\u201c\u8303\u56f4\u9501\u201d\uff08range-locks\uff09\u3002
\u901a\u8fc7\u6bd4\u4f4e\u4e00\u7ea7\u7684\u9694\u79bb\u7ea7\u522b\u8981\u6c42\u66f4\u591a\u7684\u9650\u5236\uff0c\u9ad8\u4e00\u7ea7\u7684\u7ea7\u522b\u63d0\u4f9b\u66f4\u5f3a\u7684\u9694\u79bb\u6027\u3002\u6807\u51c6\u5141\u8bb8\u4e8b\u52a1\u8fd0\u884c\u5728\u66f4\u5f3a\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u4e0a\u3002
Note
MatrixOne \u7684\u4e8b\u52a1\u9694\u79bb\u4e0e\u901a\u7528\u7684\u9694\u79bb\u5b9a\u4e49\u7684\u9694\u79bb\u7ea7\u522b\u7684\u5212\u5206\u7565\u6709\u4e0d\u540c\uff0c\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u9694\u79bb\u7ea7\u522b\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/","title":"\u663e\u5f0f\u4e8b\u52a1","text":"\u5728 MatrixOne \u7684\u4e8b\u52a1\u7c7b\u522b\u4e2d\uff0c\u663e\u5f0f\u4e8b\u52a1\u8fd8\u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#_2","title":"\u663e\u5f0f\u4e8b\u52a1\u89c4\u5219","text":"BEGIN...END
\u6216 START TRANSACTION...COMMIT
\u6216 ROLLBACK
\u4f5c\u4e3a\u8d77\u59cb\u7ed3\u675f\u3002START TRANSACTIONS
\u4e4b\u540e\u518d\u9047\u5230 START TRANSACTIONS
\uff0c\u4e24\u4e2a START TRANSACTIONS
\u4e4b\u95f4\u7684\u6240\u6709\u8bed\u53e5\u90fd\u4f1a\u5f3a\u5236\u63d0\u4ea4\uff0c\u65e0\u8bba AUTOCOMMIT
\u7684\u503c\u662f 1 \u6216 0\u3002SET
\u547d\u4ee4\u4e0e\u7ba1\u7406\u7c7b\u547d\u4ee4\uff08CREATE USER/ROLE
\u6216 GRANT
\uff09\uff0c\u53ea\u80fd\u5305\u542b DML \u4e0e DDL\u3002AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4e0d\u4f1a\u5bf9\u4e8b\u52a1\u8fdb\u884c\u4efb\u4f55\u66f4\u6539\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u4f1a\u5728\u4e00\u4e2a\u65b0\u7684\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u4e2d\u6267\u884c\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u4f1a\u5728\u663e\u5f0f\u5f00\u542f\u7684\u4e8b\u52a1\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 \u663e\u5f0f\u4e8b\u52a1\u4e0e\u975e\u81ea\u52a8\u63d0\u4ea4 \u5f53 AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4f1a\u5728\u6bcf\u4e2a\u8bed\u53e5\u6267\u884c\u540e\u81ea\u52a8\u63d0\u4ea4\u672a\u63d0\u4ea4\u7684\u4e8b\u52a1\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u4f1a\u5728\u663e\u5f0f\u5f00\u542f\u7684\u4e8b\u52a1\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 MySQL \u4e0e MatrixOne \u663e\u5f0f\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b
mysql> CREATE TABLE Accounts (account_number INT PRIMARY KEY, balance DECIMAL(10, 2));\nQuery OK, 0 rows affected (0.07 sec)\n\nmysql> INSERT INTO Accounts (account_number, balance) VALUES (1, 1000.00), (2, 500.00);\nQuery OK, 2 rows affected (0.00 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance + 100.00 WHERE account_number = 2;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> COMMIT;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET invalid_column = 0 WHERE account_number = 2;\nERROR 20101 (HY000): internal error: column 'invalid_column' not found in table\nPrevious DML conflicts with existing constraints or data format. This transaction has to be aborted\nmysql> ROLLBACK;\nQuery OK, 0 rows affected (0.00 sec)\nmysql> SELECT * FROM Accounts;\n+----------------+---------+\n| account_number | balance |\n+----------------+---------+\n| 1 | 900.00 |\n| 2 | 600.00 |\n+----------------+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#_3","title":"\u8de8\u5e93\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b","text":"MatrixOne \u652f\u6301\u8de8\u5e93\u4e8b\u52a1\u884c\u4e3a\uff0c\u8fd9\u91cc\u5c06\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u8fdb\u884c\u8bf4\u660e\u3002
\u9996\u5148\uff0c\u8ba9\u6211\u4eec\u521b\u5efa\u4e24\u4e2a\u6570\u636e\u5e93\uff08db1 \u548c db2\uff09\u4ee5\u53ca\u5b83\u4eec\u5404\u81ea\u7684\u8868\uff08table1 \u548c table2\uff09\uff1a
-- \u521b\u5efa db1 \u6570\u636e\u5e93\nCREATE DATABASE db1;\nUSE db1;\n\n-- \u521b\u5efa db1 \u4e2d\u7684\u8868 table1\nCREATE TABLE table1 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield1 INT\n);\n\n-- \u521b\u5efa db2 \u6570\u636e\u5e93\nCREATE DATABASE db2;\nUSE db2;\n\n-- \u521b\u5efa db2 \u4e2d\u7684\u8868 table2\nCREATE TABLE table2 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield2 INT\n);\n
\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u521b\u5efa\u4e86\u4e24\u4e2a\u6570\u636e\u5e93\u548c\u5b83\u4eec\u7684\u8868\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u63d2\u5165\u4e00\u4e9b\u6570\u636e\uff1a
-- \u5728 db1 \u7684 table1 \u4e2d\u63d2\u5165\u6570\u636e\nINSERT INTO db1.table1 (field1) VALUES (100), (200), (300);\n\n-- \u5728 db2 \u7684 table2 \u4e2d\u63d2\u5165\u6570\u636e\nINSERT INTO db2.table2 (field2) VALUES (500), (600), (700);\n
\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u6709\u4e86\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u6267\u884c\u4e00\u4e2a\u8de8\u5e93\u4e8b\u52a1\uff0c\u540c\u65f6\u4fee\u6539\u8fd9\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\uff1a
-- \u5f00\u59cb\u8de8\u5e93\u4e8b\u52a1\nSTART TRANSACTION;\n\n-- \u5728 db1 \u4e2d\u66f4\u65b0 table1 \u7684\u6570\u636e\nUPDATE db1.table1 SET field1 = field1 + 10;\n\n-- \u5728 db2 \u4e2d\u66f4\u65b0 table2 \u7684\u6570\u636e\nUPDATE db2.table2 SET field2 = field2 - 50;\n\n-- \u63d0\u4ea4\u8de8\u5e93\u4e8b\u52a1\nCOMMIT;\n
\u5728\u4e0a\u9762\u7684\u8de8\u5e93\u4e8b\u52a1\u4e2d\uff0c\u9996\u5148\u4f7f\u7528 START TRANSACTION;
\u5f00\u59cb\u4e8b\u52a1\uff0c\u7136\u540e\u5206\u522b\u5728 db1 \u548c db2 \u4e2d\u66f4\u65b0\u4e86\u5404\u81ea\u7684\u8868\u6570\u636e\uff0c\u6700\u540e\u4f7f\u7528 COMMIT;
\u63d0\u4ea4\u4e8b\u52a1\u3002\u5982\u679c\u5728\u4e8b\u52a1\u671f\u95f4\u4efb\u4f55\u4e00\u6b65\u5931\u8d25\uff0c\u6574\u4e2a\u4e8b\u52a1\u5c06\u56de\u6eda\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
\u8fd9\u4e2a\u793a\u4f8b\u5c55\u793a\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u8de8\u5e93\u4e8b\u52a1\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u8de8\u5e93\u4e8b\u52a1\u53ef\u80fd\u66f4\u52a0\u590d\u6742\uff0c\u8fd9\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u57fa\u672c\u7684\u6982\u5ff5\u548c\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/","title":"\u4e8b\u52a1\u4f7f\u7528\u6307\u5357","text":"\u672c\u7ae0\u8282\u5411\u4f60\u4ecb\u7ecd\u5982\u4f55\u7b80\u5355\u7684\u5f00\u542f\u3001\u63d0\u4ea4\u3001\u56de\u6eda\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4ee5\u53ca\u5982\u4f55\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_2","title":"\u5f00\u542f\u4e8b\u52a1","text":"\u5f00\u542f\u4e8b\u52a1\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 START TRANSACTION
\u5f00\u59cb\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4e5f\u53ef\u4ee5\u7528\u65b9\u8a00\u547d\u4ee4 BEGIN
\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a
START TRANSACTION;\ninsert into t1 values(123,'123');\n
\u6216\uff1a
BEGIN;\ninsert into t1 values(123,'123');\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_3","title":"\u63d0\u4ea4\u4e8b\u52a1","text":"\u63d0\u4ea4\u4e8b\u52a1\u65f6\uff0cMatrixOne \u63a5\u53d7 COMMIT
\u547d\u4ee4\u4f5c\u4e3a\u63d0\u4ea4\u547d\u4ee4\u3002\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
START TRANSACTION;\ninsert into t1 values(123,'123');\ncommit;\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_4","title":"\u56de\u6eda\u4e8b\u52a1","text":"\u56de\u6eda\u4e8b\u52a1\u65f6\uff0cMatrixOne \u63a5\u53d7 ROLLBACK
\u547d\u4ee4\u4f5c\u4e3a\u63d0\u4ea4\u547d\u4ee4\u3002\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
START TRANSACTION;\ninsert into t1 values(123,'123');\nrollback;\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_5","title":"\u81ea\u52a8\u63d0\u4ea4","text":"\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e00\u4e2a\u53c2\u6570 AUTOCOMMIT
\uff0c\u51b3\u5b9a\u4e86\u6ca1\u6709 START TRANSACTION
\u6216 BEGIN
\u7684\u60c5\u51b5\u4e0b\uff0c\u5355\u6761 SQL \u8bed\u53e5\u7684\u662f\u5426\u88ab\u5f53\u505a\u72ec\u7acb\u4e8b\u52a1\u81ea\u52a8\u63d0\u4ea4\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a
-- \u8bbe\u7f6e\u8be5\u53c2\u6570\u7684\u503c\nSET AUTOCOMMIT={on|off|0|1} SHOW VARIABLES LIKE 'AUTOCOMMIT';\n
\u5728\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a ON \u6216 1 \u7684\u65f6\u5019\uff0c\u610f\u5473\u7740\u81ea\u52a8\u63d0\u4ea4\uff0c\u6240\u6709\u4e0d\u5728 START TRANSACTION
\u6216 BEGIN
\u4e2d\u7684\u5355\u6761 SQL \u8bed\u53e5\uff0c\u90fd\u4f1a\u5728\u6267\u884c\u65f6\u81ea\u52a8\u63d0\u4ea4\u3002
-- \u6b64\u65f6\u81ea\u52a8\u63d0\u4ea4\ninsert into t1 values(1,2,3);
\u5728\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a OFF \u6216 0 \u7684\u65f6\u5019\uff0c\u610f\u5473\u7740\u975e\u81ea\u52a8\u63d0\u4ea4\uff0c\u6240\u6709\u4e0d\u5728 START TRANSACTION
\u6216 BEGIN
\u4e2d\u7684 SQL \u8bed\u53e5\uff0c\u9700\u8981\u7528 COMMIT
\u6216 ROLLBACK
\u6765\u6267\u884c\u63d0\u4ea4\u6216\u56de\u6eda\u3002
insert into t1 values(1,2,3);\n-- \u6b64\u5904\u9700\u8981\u624b\u52a8\u63d0\u4ea4\nCOMMIT\uff1b
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_6","title":"\u5207\u6362\u4e8b\u52a1\u6a21\u5f0f","text":"MatrixOne \u9ed8\u8ba4\u91c7\u7528\u60b2\u89c2\u4e8b\u52a1\u4e0e RC \u9694\u79bb\u7ea7\u522b\u3002\u4f46\u82e5\u4f60\u9700\u8981\u5207\u6362\u81f3\u4e50\u89c2\u4e8b\u52a1\u6a21\u5f0f\uff0c\u76f8\u5e94\u7684\u9694\u79bb\u7ea7\u522b\u5c06\u81ea\u52a8\u66f4\u6539\u4e3a\u5feb\u7167\u9694\u79bb\u3002
\u5728 matrixone/etc/launch-with-proxy/ \u76ee\u5f55\u4e0b\u7684\u914d\u7f6e\u6587\u4ef6 cn.toml \u4e2d\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\u53c2\u6570\u4ee5\u5207\u6362\u4e8b\u52a1\u6a21\u5f0f\uff1a
[cn.Txn]\nmode = \"optimistic\"\nisolation = \"SI\"\n
Note: \u5982\u679c\u4f60\u53ea\u6dfb\u52a0\u4e8b\u52a1\u6a21\u5f0f\u53c2\u6570 mode = \"optimistic\"
\uff0c\u4f46\u672a\u6dfb\u52a0 isolation = \"SI\"
\uff0c\u7cfb\u7edf\u4e5f\u5c06\u9ed8\u8ba4\u5728\u4e50\u89c2\u4e8b\u52a1\u6a21\u5f0f\u4e0b\u7684\u9694\u79bb\u7ea7\u522b\u4e3a SI \u9694\u79bb\u3002
\u91cd\u542f MatrixOne\uff0c\u4fbf\u80fd\u4f7f\u5207\u6362\u540e\u7684\u4e8b\u52a1\u6a21\u5f0f\u751f\u6548\u3002
\u66f4\u591a\u5173\u4e8e\u914d\u7f6e\u53c2\u6570\u4fe1\u606f\uff0c\u53c2\u89c1\u5206\u5e03\u5f0f\u7248\u901a\u7528\u53c2\u6570\u914d\u7f6e\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/","title":"\u9690\u5f0f\u4e8b\u52a1","text":"\u5728 MatrixOne \u7684\u4e8b\u52a1\u7c7b\u522b\u4e2d\uff0c\u9690\u5f0f\u4e8b\u52a1\u8fd8\u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#_2","title":"\u9690\u5f0f\u4e8b\u52a1\u89c4\u5219","text":"MatrixOne \u5728 AUTOCOMMIT
\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u5bf9\u4e8e\u9690\u5f0f\u4e8b\u52a1\u672a\u63d0\u4ea4\u7684\u60c5\u51b5\u4f1a\u8fdb\u884c\u9519\u8bef\u5904\u7406\uff0c\u5e76\u5411\u7528\u6237\u63d0\u793a\u9700\u8981\u5148\u63d0\u4ea4\u53d8\u5316\u3002
\u5728 AUTOCOMMIT=0
\u4e14\u5f53\u524d\u5b58\u5728\u6d3b\u8dc3\u4e8b\u52a1\u7684\u60c5\u51b5\u4e0b\uff0c\u7981\u6b62\u4fee\u6539\u81ea\u52a8\u63d0\u4ea4\u4e0e\u9694\u79bb\u7ea7\u522b\uff0c\u4ee5\u53ca\u7ba1\u7406\u7c7b\u4e0e\u53c2\u6570\u8bbe\u7f6e\u547d\u4ee4\uff0c\u4f8b\u5982 SET
\u3001CREATE USER/ROLE
\u6216\u6388\u6743\u64cd\u4f5c\u4e5f\u5c06\u88ab\u9650\u5236\u3002
\u5f53 AUTOCOMMIT=1
\u65f6\uff0c\u6bcf\u6761 DML \u8bed\u53e5\u90fd\u88ab\u89c6\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684\u4e8b\u52a1\uff0c\u5728\u6267\u884c\u540e\u7acb\u5373\u8fdb\u884c\u63d0\u4ea4\u3002
\u800c\u5728 AUTOCOMMIT=0
\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6761 DML \u8bed\u53e5\u5728\u6267\u884c\u540e\u5e76\u4e0d\u4f1a\u7acb\u5373\u63d0\u4ea4\uff0c\u9700\u8981\u624b\u52a8\u6267\u884c COMMIT
\u6216 ROLLBACK
\u64cd\u4f5c\u3002\u82e5\u5728\u5c1a\u672a\u63d0\u4ea4\u6216\u56de\u6eda\u7684\u72b6\u6001\u4e0b\u9000\u51fa\u5ba2\u6237\u7aef\uff0c\u5219\u9ed8\u8ba4\u8fdb\u884c\u56de\u6eda\u64cd\u4f5c\u3002
\u5728 AUTOCOMMIT=0
\u7684\u60c5\u51b5\u4e0b\uff0cDML \u4e0e DDL \u53ef\u4ee5\u540c\u65f6\u5b58\u5728\u4e8e\u4e00\u4e2a\u9690\u5f0f\u4e8b\u52a1\u4e2d\uff0c\u4f46 DDL \u7684\u5bf9\u8c61\u7c7b\u578b\u4e0d\u80fd\u4e3a\u6570\u636e\u5e93\u4e0e\u5e8f\u5217\u3002
\u82e5\u5728 AUTOCOMMIT=0
\u7684\u72b6\u6001\u4e0b\u51fa\u73b0 CREATE/DROP DATABASE
\u6216 CREATE/DROP SEQUENCE
\u64cd\u4f5c\uff0c\u5219\u4f1a\u5f3a\u5236\u63d0\u4ea4\u4e4b\u524d\u672a\u63d0\u4ea4\u7684\u6240\u6709\u5185\u5bb9\u3002\u540c\u65f6\uff0cCREATE/DROP DATABASE
\u64cd\u4f5c\u5c06\u4f1a\u7acb\u5373\u4f5c\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684\u4e8b\u52a1\u8fdb\u884c\u63d0\u4ea4\u3002
\u5f53\u5b58\u5728\u672a\u63d0\u4ea4\u5185\u5bb9\u7684\u9690\u5f0f\u4e8b\u52a1\u65f6\uff0c\u82e5\u542f\u52a8\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\uff0c\u5219\u4f1a\u5f3a\u5236\u63d0\u4ea4\u4e4b\u524d\u672a\u63d0\u4ea4\u7684\u5185\u5bb9\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5982\u679c\u5f00\u542f\u4e86\u9690\u5f0f\u4e8b\u52a1\uff08SET AUTOCOMMIT=0
\uff09\uff0c\u5219\u6240\u6709\u64cd\u4f5c\u90fd\u9700\u8981\u624b\u52a8\u6267\u884c COMMIT
\u6216 ROLLBACK
\u6765\u7ed3\u675f\u4e8b\u52a1\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0cMySQL \u5728\u9047\u5230 DDL \u6216\u7c7b\u4f3c SET
\u8bed\u53e5\u65f6\u4f1a\u81ea\u52a8\u63d0\u4ea4\u3002
AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4e0d\u4f1a\u5bf9\u4e8b\u52a1\u8fdb\u884c\u4efb\u4f55\u66f4\u6539\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0cMySQL \u4e5f\u4e0d\u4f1a\u5bf9\u4e8b\u52a1\u8fdb\u884c\u4efb\u4f55\u66f4\u6539\uff0c\u4f46\u968f\u540e\u7684\u8bed\u53e5\u5c06\u7ee7\u7eed\u5728\u5f53\u524d\u4e8b\u52a1\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 \u9690\u5f0f\u4e8b\u52a1\u4e0e\u975e\u81ea\u52a8\u63d0\u4ea4 \u5f53 AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4f1a\u5728\u6bcf\u4e2a\u8bed\u53e5\u6267\u884c\u540e\u81ea\u52a8\u63d0\u4ea4\u672a\u63d0\u4ea4\u7684\u4e8b\u52a1\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0cMySQL \u4f1a\u7ee7\u7eed\u5728\u5f53\u524d\u4e8b\u52a1\u4e2d\u6267\u884c\u968f\u540e\u7684\u8bed\u53e5\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 MySQL \u9690\u5f0f\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b
mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = default;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n
MatrixOne \u9690\u5f0f\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b
mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nERROR 20101 (HY000): internal error: Uncommitted transaction exists. Please commit or rollback first.\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#_3","title":"\u9690\u5f0f\u4e8b\u52a1\u793a\u4f8b","text":"\u4f8b\u5982\uff0c\u5bf9 t1 \u63d2\u5165\u6570\u636e (4,5,6)\uff0c\u5373\u6210\u4e3a\u4e00\u4e2a\u9690\u5f0f\u4e8b\u52a1\u3002\u800c\u8be5\u9690\u5f0f\u4e8b\u52a1\u662f\u5426\u7acb\u5373\u63d0\u4ea4\uff0c\u53d6\u51b3\u4e8e AUTOCOMMIT
\u53c2\u6570\u7684\u503c\uff1a
CREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nSTART TRANSACTION;\nINSERT INTO t1 values(1,2,3);\nCOMMIT;\n\n-- \u67e5\u770b AUTOCOMMIT \u5f00\u5173\u53c2\u6570\nmysql> SHOW VARIABLES LIKE 'AUTOCOMMIT';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit | 1 |\n+---------------+-------+\n1 row in set (0.00 sec)\n-- \u6b64\u5904\u5f00\u59cb\u4e00\u4e2a\u9690\u5f0f\u4e8b\u52a1\uff0c\u5728 AUTOCOMMIT=1 \u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e00\u6761 DML \u5728\u6267\u884c\u540e\u7acb\u5373\u63d0\u4ea4\ninsert into t1 values(4,5,6);\n\n-- \u9690\u5f0f\u4e8b\u52a1\u81ea\u52a8\u63d0\u4ea4\uff0c\u8868\u6570\u636e\u5982\u4e0b\u6240\u793a\nmysql> select * from t1;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 2 | 3 |\n| 4 | 5 | 6 |\n+------+------+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/","title":"\u9694\u79bb\u7ea7\u522b","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#_2","title":"\u8bfb\u5df2\u63d0\u4ea4","text":"MatrixOne \u9ed8\u8ba4\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u9694\u79bb\u7ea7\u522b\uff0c\u5b83\u7684\u7279\u70b9\u5982\u4e0b\uff1a
\u4f60\u53ef\u4ee5\u53c2\u7167\u4e0b\u9762\u7684\u793a\u4f8b\uff0c\u6765\u7406\u89e3\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\u3002
\u9996\u5148\u5728 MatrixOne \u4e2d\uff0c\u6211\u4eec\u5efa\u7acb\u4e00\u4e2a\u547d\u540d\u4e3a test
\u7684\u6570\u636e\u5e93\u4e0e\u8868 t1
\uff0c\u5e76\u63d2\u5165\u6570\u636e\uff1a
create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u5f00\u542f\u4e00\u4e2a\u4e8b\u52a1\uff1a
use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7684\u7ed3\u679c\u662f\u5982\u4e0b\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 2 | version3 |\n| 1 | version1 |\n+------+----------+\n
\u6b64\u65f6\u5f00\u542f\u4f1a\u8bdd 2\uff0c\u5f00\u542f\u4e00\u4e2a\u65b0\u4e8b\u52a1\u53bb\u67e5\u8be2 t1 \u7684\u5185\u5bb9\uff1a
use test;\nbegin;\nSELECT * FROM t1;\n
\u770b\u5230\u7684\u7ed3\u679c\u4ecd\u7136\u662f\u539f\u59cb\u6570\u636e\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version2 |\n+------+----------+\n
\u5728\u4f1a\u8bdd 2 \u4e2d\uff0c\u4fee\u6539 tid=1
\u7684\u884c\uff1a
UPDATE t1 SET tname='version0' WHERE tid=1;\n
\u6b64\u65f6\uff0c\u5728\u4f1a\u8bdd 1 \u4e2d\u67e5\u8be2 t1
\u7684\u5185\u5bb9\u4ecd\u7136\u8fd8\u662f\u4fee\u6539\u540e\u7684\u6570\u636e\uff1a
SELECT * FROM t1;\n+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version3 |\n+------+----------+\n
\u5728\u4f1a\u8bdd 2 \u63d0\u4ea4\u81ea\u5df1\u7684\u6570\u636e\u540e\uff0c\u518d\u67e5\u8be2\u4f1a\u8bdd 1\uff0c\u4f1a\u53d1\u73b0\uff0c\u6b64\u65f6\u4f1a\u8bdd 1 \u7684\u5185\u5bb9\u5df2\u7ecf\u53d8\u6210\u4e86\u4f1a\u8bdd 2 \u63d0\u4ea4\u4e4b\u540e\u7684\u6570\u636e\uff1a
-- \u5728\u4f1a\u8bdd 2 \u4e2d\u63d0\u4ea4\u6570\u636e\uff1a\nCOMMIT;\n
-- \u67e5\u8be2\u4f1a\u8bdd 1 \u7684\u5185\u5bb9\u662f\u5426\u5df2\u7ecf\u53d8\u6210\u4e86\u4f1a\u8bdd 2 \u63d0\u4ea4\u4e4b\u540e\u7684\u6570\u636e\uff1a\nSELECT * FROM t1;\n+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version0 |\n| 2 | version3 |\n+------+----------+\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#_5","title":"\u5feb\u7167\u9694\u79bb","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e5f\u652f\u6301\u5feb\u7167\u9694\u79bb\uff08Snapshot Isolation\uff09\uff0c\u4e3a\u4e86\u4e0e MySQL \u9694\u79bb\u7ea7\u522b\u4fdd\u6301\u4e00\u81f4\uff0cMatrixOne \u5feb\u7167\u9694\u79bb\u53c8\u53eb\u505a\u53ef\u91cd\u590d\u8bfb\uff08REPEATABLE READS\uff09\u3002\u8be5\u7ea7\u522b\u7684\u9694\u79bb\u5b9e\u73b0\u539f\u7406\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#_6","title":"\u5feb\u7167\u9694\u79bb\u539f\u7406","text":"\u4f60\u53ef\u4ee5\u53c2\u7167\u4e0b\u9762\u7684\u793a\u4f8b\uff0c\u6765\u5e2e\u52a9\u7406\u89e3\u5feb\u7167\u9694\u79bb\u3002
\u9996\u5148\u5728 MatrixOne \u4e2d\uff0c\u6211\u4eec\u5efa\u7acb\u4e00\u4e2a\u6570\u636e\u5e93 test \u4e0e\u8868 t1\uff1a
create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u5f00\u542f\u4e00\u4e2a\u4e8b\u52a1\uff1a
use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7684\u7ed3\u679c\u662f\u5982\u4e0b\uff0c\u6839\u636e\u5feb\u7167\u7684\u6570\u636e\u6240\u8fdb\u884c\u7684\u4fee\u6539\u7ed3\u679c\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 2 | version3 |\n| 1 | version1 |\n+------+----------+\n
\u6b64\u65f6\u5f00\u542f\u4f1a\u8bdd 2\uff0c\u53bb\u67e5\u8be2 t1 \u7684\u5185\u5bb9\uff1a
use test;\nSELECT * FROM t1;\n
\u770b\u5230\u7684\u7ed3\u679c\u4ecd\u7136\u662f\u539f\u59cb\u6570\u636e\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version2 |\n+------+----------+\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u6211\u4eec\u5c06\u4e8b\u52a1\u63d0\u4ea4\uff1a
COMMIT;\n
\u6b64\u65f6\uff0c\u5728\u4f1a\u8bdd 2 \u4e2d\u67e5\u8be2 t1 \u7684\u5185\u5bb9\u5c31\u53d8\u6210\u4e86\u63d0\u4ea4\u540e\u7684\u6570\u636e\uff1a
SELECT * FROM t1;\n+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version3 |\n+------+----------+\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/","title":"MVCC","text":"MVCC\uff08Multiversion Concurrency Control\uff0c\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09\u5e94\u7528\u4e8e MatrixOne\uff0c\u4ee5\u4fdd\u8bc1\u4e8b\u52a1\u5feb\u7167\u9694\u79bb\uff0c\u5b9e\u73b0\u4e8b\u52a1\u7684\u9694\u79bb\u6027\u3002
\u57fa\u4e8e\u6570\u636e\u5143\u7ec4\uff08Tuple\uff0c\u5373\u8868\u4e2d\u7684\u6bcf\u884c\uff09\u7684\u6307\u9488\u5b57\u6bb5\u6765\u521b\u5efa\u4e00\u4e2a Latch Free \u7684\u94fe\u8868\uff0c\u79f0\u4e3a\u7248\u672c\u94fe\u3002\u8fd9\u4e2a\u7248\u672c\u94fe\u5141\u8bb8\u6570\u636e\u5e93\u5b9a\u4f4d\u4e00\u4e2a Tuple \u7684\u6240\u9700\u7248\u672c\u3002\u56e0\u6b64\u8fd9\u4e9b\u7248\u672c\u6570\u636e\u7684\u5b58\u653e\u673a\u5236\u662f\u6570\u636e\u5e93\u5b58\u50a8\u5f15\u64ce\u8bbe\u8ba1\u7684\u4e00\u4e2a\u91cd\u8981\u8003\u91cf\u3002
\u4e00\u4e2a\u65b9\u6848\u662f\u91c7\u7528 Append Only \u673a\u5236\uff0c\u4e00\u4e2a\u8868\u7684\u6240\u6709 Tuple \u7248\u672c\u90fd\u5b58\u50a8\u5728\u540c\u4e00\u4e2a\u5b58\u50a8\u7a7a\u95f4\u3002\u8fd9\u79cd\u65b9\u6cd5\u88ab\u7528\u4e8e Postgre SQL\uff0c\u4e3a\u4e86\u66f4\u65b0\u4e00\u4e2a\u73b0\u6709\u7684 Tuple\uff0c\u6570\u636e\u5e93\u9996\u5148\u4e3a\u65b0\u7684\u7248\u672c\u4ece\u8868\u4e2d\u83b7\u53d6\u4e00\u4e2a\u7a7a\u7684\u69fd\uff08Slot\uff09\uff0c\u7136\u540e\uff0c\u5b83\u5c06\u5f53\u524d\u7248\u672c\u7684\u5185\u5bb9\u590d\u5236\u5230\u65b0\u7248\u672c\u3002\u6700\u540e\uff0c\u5b83\u5728\u65b0\u5206\u914d\u7684 Slot \u4e2d\u5e94\u7528\u5bf9 Tuple \u7684\u4fee\u6539\u3002Append Only \u673a\u5236\u7684\u5173\u952e\u662f\u51b3\u5b9a\u5982\u4f55\u4e3a Tuple \u7684\u7248\u672c\u94fe\u6392\u5e8f\uff0c\u7531\u4e8e\u4e0d\u53ef\u80fd\u7ef4\u6301\u4e00\u4e2a\u65e0\u9501\uff08Lock free\uff09\u7684\u53cc\u5411\u94fe\u8868\uff0c\u56e0\u6b64\u7248\u672c\u94fe\u53ea\u6307\u5411\u4e00\u4e2a\u65b9\u5411\uff0c\u6216\u8005\u4ece Old \u5230 New\uff08O2N\uff09\uff0c\u6216\u8005\u4ece New \u5230 Old\uff08N2O\uff09\u3002
\u53e6\u5916\u4e00\u4e2a\u7c7b\u4f3c\u7684\u65b9\u6848\u79f0\u4e3a\u65f6\u95f4\u65c5\u884c\uff08Time Travel\uff09\uff0c\u5b83\u4f1a\u628a\u7248\u672c\u94fe\u7684\u4fe1\u606f\u5355\u72ec\u5b58\u653e\uff0c\u800c\u4e3b\u8868\u7ef4\u62a4\u4e3b\u7248\u672c\u6570\u636e\u3002
\u7b2c\u4e09\u79cd\u65b9\u6848\uff0c\u662f\u5728\u4e3b\u8868\u4e2d\u7ef4\u62a4 Tuple \u7684\u4e3b\u7248\u672c\uff0c\u5728\u4e00\u4e2a\u5355\u72ec\u7684\u6570\u636e\u5e93\u5bf9\u6bd4\u5de5\u5177\uff08Delta\uff09\u5b58\u50a8\u4e2d\u7ef4\u62a4\u4e00\u7cfb\u5217 Delta \u7248\u672c\u3002\u8fd9\u79cd\u5b58\u50a8\u5728 MySQL \u548c Oracle \u4e2d\u88ab\u79f0\u4e3a\u56de\u6eda\u6bb5\u3002\u4e3a\u4e86\u66f4\u65b0\u4e00\u4e2a\u73b0\u6709\u7684 Tuple\uff0c\u6570\u636e\u5e93\u4ece Delta \u5b58\u50a8\u4e2d\u83b7\u53d6\u4e00\u4e2a\u8fde\u7eed\u7684\u7a7a\u95f4\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Delta \u7248\u672c\u3002\u8fd9\u4e2a Delta \u7248\u672c\u5305\u542b\u4fee\u6539\u8fc7\u7684\u5c5e\u6027\u7684\u539f\u59cb\u503c\uff0c\u800c\u4e0d\u662f\u6574\u4e2a Tuple\u3002\u7136\u540e\u6570\u636e\u5e93\u76f4\u63a5\u5bf9\u4e3b\u8868\u4e2d\u7684\u4e3b\u7248\u672c\u8fdb\u884c\u539f\u5730\u66f4\u65b0\uff08In Place Update\uff09\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/","title":"\u4e50\u89c2\u4e8b\u52a1","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#_2","title":"\u4e50\u89c2\u4e8b\u52a1\u539f\u7406","text":"\u4e50\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4e0d\u4f1a\u505a\u51b2\u7a81\u68c0\u6d4b\u6216\u9501\u64cd\u4f5c\uff0c\u4f1a\u5c06\u5f53\u524d\u76f8\u5173\u6570\u636e\u7f13\u5b58\u81f3\u5bf9\u5e94\u5185\u5b58\u533a\u57df\uff0c\u5e76\u5bf9\u8be5\u6570\u636e\u8fdb\u884c\u589e\u5220\u6539\u3002
\u5728\u5b8c\u6210\u4fee\u6539\u540e\uff0c\u8fdb\u5165\u63d0\u4ea4\u9636\u6bb5\u65f6\uff0c\u5c06\u5206\u4e3a\u4e24\u4e2a\u6b65\u9aa4\u8fdb\u884c\u63d0\u4ea4\uff1a
\u6b65\u9aa4\u4e00\uff1a\u5c06\u5f85\u5199\u6570\u636e\u4e2d\u7684\u67d0\u4e00\u5217\u5f53\u505a\u4e3b\u952e\u5217\uff0c\u5e76\u5bf9\u8be5\u5217\u4e0a\u9501\u5e76\u521b\u5efa\u65f6\u95f4\u6233\u3002\u57fa\u4e8e\u6b64\u65f6\u95f4\u6233\u4e4b\u540e\u5bf9\u76f8\u5173\u884c\u8fdb\u884c\u7684\u5199\u5165\u5747\u5224\u5b9a\u4e3a\u5199\u51b2\u7a81\u3002
\u6b65\u9aa4\u4e8c\uff1a\u5199\u5165\u6570\u636e\uff0c\u5e76\u4e14\u8bb0\u5f55\u6b64\u65f6\u7684\u65f6\u95f4\u6233\uff0c\u89e3\u5f00\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#_3","title":"\u4e50\u89c2\u4e8b\u52a1\u6a21\u578b","text":"MatrixOne \u652f\u6301\u4e50\u89c2\u4e8b\u52a1\u6a21\u578b\u3002\u4f60\u5728\u4f7f\u7528\u4e50\u89c2\u5e76\u53d1\u8bfb\u53d6\u4e00\u884c\u65f6\u4e0d\u4f1a\u9501\u5b9a\u8be5\u884c\u3002\u5f53\u4f60\u60f3\u8981\u66f4\u65b0\u4e00\u884c\u65f6\uff0c\u5e94\u7528\u7a0b\u5e8f\u5fc5\u987b\u786e\u5b9a\u5176\u4ed6\u7528\u6237\u662f\u5426\u5728\u8bfb\u53d6\u8be5\u884c\u540e\u5bf9\u8be5\u884c\u4e0a\u9501\u4e86\u3002\u4e50\u89c2\u5e76\u53d1\u4e8b\u52a1\u901a\u5e38\u7528\u4e8e\u6570\u636e\u4e89\u7528\u8f83\u4f4e\u7684\u73af\u5883\u4e2d\u3002
\u5728\u4e50\u89c2\u5e76\u53d1\u6a21\u578b\u4e2d\uff0c\u5982\u679c\u4f60\u4ece\u6570\u636e\u5e93\u63a5\u6536\u5230\u4e00\u4e2a\u503c\u540e\uff0c\u53e6\u4e00\u4e2a\u7528\u6237\u5728\u4f60\u8bd5\u56fe\u4fee\u6539\u8be5\u503c\u4e4b\u524d\u4fee\u6539\u4e86\u8be5\u503c\uff0c\u5219\u4ea7\u751f\u62a5\u9519\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#_4","title":"\u6a21\u578b\u793a\u4f8b","text":"\u4e0b\u9762\u4e3a\u4e50\u89c2\u5e76\u53d1\u7684\u793a\u4f8b\uff0c\u5c06\u4e3a\u4f60\u5c55\u793a MatrixOne \u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u51b2\u7a81\u3002
\u5728\u4e0b\u5348 1:00\uff0c\u7528\u6237 1 \u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u4e00\u884c\uff0c\u5176\u503c\u5982\u4e0b\uff1a
CustID LastName FirstName\n101 Smith Bob\n
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob \u5728\u4e0b\u5348 1:01\uff0c\u7528\u6237 2 \u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u540c\u4e00\u884c\u3002
\u5728\u4e0b\u5348 1:03\uff0c\u7528\u6237 2 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cRobert\u201d\uff0c\u5e76\u66f4\u65b0\u5230\u6570\u636e\u5e93\u91cc\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob\u5982\u4e0a\u8868\u6240\u793a\uff0c\u66f4\u65b0\u65f6\u6570\u636e\u5e93\u4e2d\u7684\u503c\u4e0e\u7528\u6237 2 \u7684\u539f\u59cb\u503c\u5339\u914d\uff0c\u8868\u793a\u66f4\u65b0\u6210\u529f\u3002
\u5728\u4e0b\u5348 1:05\uff0c\u7528\u6237 1 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cJames\u201d\uff0c\u5e76\u5c1d\u8bd5\u8fdb\u884c\u66f4\u65b0\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Robert\u6b64\u65f6\uff0c\u7528\u6237 1 \u9047\u5230\u4e86\u4e50\u89c2\u5e76\u53d1\u51b2\u7a81\uff0c\u56e0\u4e3a\u6570\u636e\u5e93\u4e2d\u7684\u503c\u201cRobert\u201d\u4e0d\u518d\u4e0e\u7528\u6237 1 \u671f\u671b\u7684\u539f\u59cb\u503c\u201cBob\u201d\u5339\u914d\uff0c\u5e76\u53d1\u51b2\u7a81\u63d0\u793a\u66f4\u65b0\u5931\u8d25\u3002\u4e0b\u4e00\u6b65\u9700\u8981\u51b3\u5b9a\uff0c\u662f\u91c7\u7528\u7528\u6237 1 \u7684\u66f4\u6539\u8986\u76d6\u7528\u6237 2 \u7684\u66f4\u6539\uff0c\u8fd8\u662f\u53d6\u6d88\u7528\u6237 1 \u7684\u66f4\u6539\u3002
MatrixOne \u4e8b\u52a1\u9075\u5faa\u6570\u636e\u5e93\u4e8b\u52a1\u7684\u6807\u51c6\u5b9a\u4e49\u4e0e\u57fa\u672c\u7279\u5f81 (ACID)\u3002\u5b83\u65e8\u5728\u5e2e\u52a9\u7528\u6237\u5728\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u73af\u5883\u4e0b\uff0c\u786e\u4fdd\u6bcf\u4e00\u6b21\u6570\u636e\u5e93\u6570\u636e\u64cd\u4f5c\u884c\u4e3a\uff0c\u90fd\u80fd\u591f\u4ee4\u7ed3\u679c\u4fdd\u8bc1\u6570\u636e\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\uff0c\u5728\u5e76\u53d1\u8bf7\u6c42\u4e0b\u4e92\u76f8\u9694\u79bb\u4e0d\u53d7\u5e72\u6270\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone_2","title":"MatrixOne \u7684\u4e8b\u52a1\u7c7b\u578b","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e8b\u52a1\u4e0e\u901a\u7528\u4e8b\u52a1\u4e00\u6837\uff0c\u4e5f\u5206\u4e3a\u4ee5\u4e0b\u4e24\u5927\u7c7b\uff1a
\u8fd9\u4e24\u5927\u7c7b\u4e8b\u52a1\u7684\u5206\u7c7b\u5f7c\u6b64\u4e0d\u53d7\u5bf9\u65b9\u9650\u5236\uff0c\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\u53ef\u4ee5\u662f\u4e50\u89c2\u4e8b\u52a1\u6216\u60b2\u89c2\u4e8b\u52a1\uff0c\u540c\u65f6\u4e00\u4e2a\u60b2\u89c2\u4e8b\u52a1\u53ef\u80fd\u662f\u663e\u5f0f\u4e8b\u52a1\u4e5f\u53ef\u80fd\u662f\u9690\u5f0f\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#_1","title":"\u663e\u5f0f\u4e8b\u52a1","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e00\u4e2a\u4e8b\u52a1\u4ee5 START TRANSACTION
\u663e\u5f0f\u58f0\u660e\uff0c\u5373\u6210\u4e3a\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5982\u679c\u4e00\u4e2a\u4e8b\u52a1\u5e76\u6ca1\u6709\u901a\u8fc7 START TRANSACTION
\u6216 BEGIN
\u6765\u663e\u5f0f\u58f0\u660e\uff0c\u90a3\u4e48\u4e3a\u9690\u5f0f\u4e8b\u52a1\u3002
\u5728\u4e50\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4e0d\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u8fd9\u4e00\u9636\u6bb5\u4e0d\u4f1a\u5bf9\u6570\u636e\u52a0\u9501\uff0c\u800c\u5728\u6570\u636e\u63d0\u4ea4\u65f6\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5728\u5b8c\u6210\u63d0\u4ea4\u540e\u89e3\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#_4","title":"\u60b2\u89c2\u4e8b\u52a1","text":"MatrixOne \u9ed8\u8ba4\u60b2\u89c2\u4e8b\u52a1\u3002\u5728\u60b2\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u63d0\u524d\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5b8c\u6210\u4e0a\u9501\u52a8\u4f5c\u540e\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u63d0\u4ea4\u6216\u56de\u6eda\u540e\uff0c\u6570\u636e\u5b8c\u6210\u843d\u76d8\u5e76\u91ca\u653e\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone_3","title":"MatrixOne \u652f\u6301\u8de8\u6570\u636e\u5e93\u4e8b\u52a1","text":"MatrixOne \u63d0\u4f9b\u4e86\u652f\u6301\u8de8\u6570\u636e\u5e93\u7684\u4e8b\u52a1\u529f\u80fd\uff0c\u5141\u8bb8\u4e00\u4e2a\u4e8b\u52a1\u540c\u65f6\u8bbf\u95ee\u548c\u4fee\u6539\u591a\u4e2a\u4e0d\u540c\u7684\u6570\u636e\u5e93\u3002
\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u67d0\u4e9b\u4e1a\u52a1\u9700\u6c42\u53ef\u80fd\u9700\u8981\u6d89\u53ca\u591a\u4e2a\u6570\u636e\u5e93\u7684\u64cd\u4f5c\uff0c\u800c\u8de8\u6570\u636e\u5e93\u4e8b\u52a1\u7684\u51fa\u73b0\u6b63\u662f\u4e3a\u4e86\u6ee1\u8db3\u8fd9\u79cd\u9700\u6c42\u3002\u8fd9\u79cd\u529f\u80fd\u786e\u4fdd\u4e86\u4e0d\u540c\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u64cd\u4f5c\u80fd\u591f\u4fdd\u6301\u4e00\u81f4\u6027\u548c\u9694\u79bb\u6027\uff0c\u5c31\u50cf\u5728\u5355\u4e2a\u6570\u636e\u5e93\u5185\u6267\u884c\u64cd\u4f5c\u4e00\u6837\u3002\u8fd9\u610f\u5473\u7740\u5f53\u60a8\u9700\u8981\u5728\u591a\u4e2a\u6570\u636e\u5e93\u4e4b\u95f4\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\u65f6\uff0c\u53ef\u4ee5\u5c06\u5b83\u4eec\u5305\u88c5\u5728\u4e00\u4e2a\u4e8b\u52a1\u4e2d\uff0c\u4ee5\u4fbf\u5728\u4fdd\u6301\u6570\u636e\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u7684\u540c\u65f6\u5b8c\u6210\u8fd9\u4e9b\u64cd\u4f5c\u3002
\u8de8\u6570\u636e\u5e93\u4e8b\u52a1\u901a\u5e38\u5728\u590d\u6742\u7684\u4f01\u4e1a\u5e94\u7528\u573a\u666f\u4e2d\u53d1\u6325\u5173\u952e\u4f5c\u7528\u3002\u5728\u8fd9\u4e9b\u573a\u666f\u4e2d\uff0c\u4e0d\u540c\u7684\u4e1a\u52a1\u529f\u80fd\u6216\u90e8\u95e8\u53ef\u80fd\u4f7f\u7528\u4e0d\u540c\u7684\u6570\u636e\u5e93\uff0c\u4f46\u5b83\u4eec\u9700\u8981\u534f\u540c\u5de5\u4f5c\u4ee5\u6ee1\u8db3\u590d\u6742\u7684\u4e1a\u52a1\u9700\u6c42\u3002MatrixOne \u7684\u652f\u6301\u8de8\u6570\u636e\u5e93\u4e8b\u52a1\u529f\u80fd\u63d0\u9ad8\u4e86\u7cfb\u7edf\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0c\u4f46\u540c\u65f6\u4e5f\u9700\u8981\u8c28\u614e\u7684\u8bbe\u8ba1\u548c\u7ba1\u7406\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u5f97\u4ee5\u4fdd\u6301\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone_4","title":"MatrixOne \u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b","text":"MatrixOne \u652f\u6301\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u548c\u5feb\u7167\u9694\u79bb\u4e24\u79cd\u9694\u79bb\u7ea7\u522b\uff0c\u9ed8\u8ba4\u9694\u79bb\u7ea7\u522b\u662f\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#_5","title":"\u8bfb\u5df2\u63d0\u4ea4","text":"\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u662f MatrixOne \u5728 0.8 \u7248\u672c\u4e4b\u540e\u7684\u9ed8\u8ba4\u9694\u79bb\u7ea7\u522b\uff0c\u4e5f\u662f SQL \u6807\u51c6\u4e2d\u7684\u56db\u4e2a\u9694\u79bb\u7ea7\u522b\u4e4b\u4e00\u3002\u5b83\u6700\u663e\u8457\u7684\u7279\u70b9\u662f\uff1a
\u4e0e SQL \u6807\u51c6\u6240\u5b9a\u4e49\u7684\u56db\u4e2a\u9694\u79bb\u7ea7\u522b\u4e0d\u540c\uff0c\u5728 MatrixOne \u4e2d\uff0c\u652f\u6301\u7684\u9694\u79bb\u7ea7\u522b\u662f\u5feb\u7167\u9694\u79bb\uff08Snapshot Isolation\uff09\uff0c\u8be5\u7ea7\u522b\u7684\u9694\u79bb\u5728 SQL-92 \u6807\u51c6\u7684 REPEATABLE READ \u548c SERIALIZABLE \u4e4b\u95f4\u3002\u4e0e\u5176\u4ed6\u9694\u79bb\u7ea7\u522b\u6709\u6240\u533a\u522b\u7684\u662f\uff0c\u5feb\u7167\u9694\u79bb\u5177\u5907\u5982\u4e0b\u7279\u6027\uff1a
\u5feb\u7167\u9694\u79bb\u5bf9\u4e8e\u6307\u5b9a\u4e8b\u52a1\u5185\u8bfb\u53d6\u7684\u6570\u636e\u4e0d\u4f1a\u53cd\u6620\u5176\u4ed6\u540c\u6b65\u7684\u4e8b\u52a1\u5bf9\u6570\u636e\u6240\u505a\u7684\u66f4\u6539\u3002\u6307\u5b9a\u4e8b\u52a1\u4f7f\u7528\u672c\u6b21\u4e8b\u52a1\u5f00\u59cb\u65f6\u8bfb\u53d6\u7684\u6570\u636e\u884c\u3002
\u8bfb\u53d6\u6570\u636e\u65f6\u4e0d\u4f1a\u5bf9\u6570\u636e\u8fdb\u884c\u9501\u5b9a\uff0c\u56e0\u6b64\u5feb\u7167\u4e8b\u52a1\u4e0d\u4f1a\u963b\u6b62\u5176\u4ed6\u4e8b\u52a1\u5199\u5165\u6570\u636e\u3002
\u5199\u5165\u6570\u636e\u7684\u4e8b\u52a1\u4e5f\u4e0d\u4f1a\u963b\u6b62\u5feb\u7167\u4e8b\u52a1\u8bfb\u53d6\u6570\u636e\u3002
\u4e0e\u5176\u4ed6\u9694\u79bb\u7ea7\u522b\u76f8\u6bd4\uff0c\u5feb\u7167\u9694\u79bb\u5bf9\u4e8e\u810f\u8bfb (\u8bfb\u53d6\u672a\u63d0\u4ea4\u6570\u636e)\u3001\u810f\u5199\uff08\u5199\u4e86\u4fee\u6539\u540e\u672a\u63d0\u4ea4\u7684\u8bb0\u5f55\uff09\u3001\u5e7b\u8bfb (\u524d\u540e\u591a\u6b21\u8bfb\u53d6\uff0c\u6570\u636e\u603b\u91cf\u4e0d\u4e00\u81f4) \u7b49\u573a\u666f\u4e5f\u5b9e\u73b0\u4e86\u6709\u6548\u56de\u907f\uff1a
Isolation Level P0 Dirty Write P1 Dirty Read P4C Cursor Lost Update P4 Lost Update P2 Fuzzy Read P3 Phantom A5A Read Skew A5B Write Skew MatrixOne's Snapshot Isolation Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Possible"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/","title":"\u60b2\u89c2\u4e8b\u52a1","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_2","title":"\u60b2\u89c2\u4e8b\u52a1\u539f\u7406","text":"\u60b2\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4e00\u5b9a\u4f1a\u505a\u51b2\u7a81\u68c0\u6d4b\u6216\u9501\u64cd\u4f5c\uff0c\u5728\u672a\u68c0\u6d4b\u5230\u51b2\u7a81\u6216\u9501\u7684\u65f6\u5019\uff0c\u4f1a\u5c06\u5f85\u5199\u6570\u636e\u4e2d\u7684\u67d0\u4e00\u5217\u5f53\u505a\u4e3b\u952e\u5217\uff0c\u5e76\u5bf9\u8be5\u5217\u4e0a\u9501\u5e76\u521b\u5efa\u65f6\u95f4\u6233\u3002\u5bf9\u4e8e\u6b64\u65f6\u95f4\u6233\u4e4b\u540e\u5bf9\u76f8\u5173\u884c\u8fdb\u884c\u7684\u5199\u5165\u5747\u5224\u5b9a\u4e3a\u5199\u51b2\u7a81\u3002
\u5c06\u5f53\u524d\u76f8\u5173\u6570\u636e\u7f13\u5b58\u81f3\u5bf9\u5e94\u5185\u5b58\u533a\u57df\uff0c\u5e76\u5bf9\u8be5\u6570\u636e\u8fdb\u884c\u589e\u5220\u6539\u3002\u5982\u679c\u5f53\u524d\u8868\u5b58\u5728\u9501\uff0c\u5219\u8fdb\u5165\u7b49\u5f85\u72b6\u6001\uff0c\u5f53\u7b49\u5f85\u8d85\u65f6\u540e\uff0c\u7b49\u5f85\u4e8b\u52a1\u5c06\u4f1a\u88ab\u53d6\u6d88\u3002
\u5728\u5b8c\u6210\u4fee\u6539\u540e\uff0c\u8fdb\u5165\u63d0\u4ea4\u9636\u6bb5\uff0c\u5199\u5165\u6570\u636e\uff0c\u5e76\u4e14\u8bb0\u5f55\u6b64\u65f6\u7684\u65f6\u95f4\u6233\uff0c\u89e3\u5f00\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_3","title":"\u60b2\u89c2\u4e8b\u52a1\u6a21\u578b","text":"MatrixOne \u9ed8\u8ba4\u60b2\u89c2\u4e8b\u52a1\u3002
\u4f60\u5728\u4f7f\u7528\u60b2\u89c2\u5e76\u53d1\u8bfb\u53d6\u4e00\u884c\u65f6\uff0c\u4e0d\u4f1a\u9501\u5b9a\u8be5\u884c\u3002\u5f53\u4f60\u60f3\u8981\u66f4\u65b0\u4e00\u884c\u65f6\uff0c\u5e94\u7528\u7a0b\u5e8f\u5fc5\u987b\u786e\u5b9a\u5176\u4ed6\u7528\u6237\u662f\u5426\u5df2\u7ecf\u5bf9\u8be5\u884c\u4e0a\u9501\u3002\u60b2\u89c2\u5e76\u53d1\u4e8b\u52a1\u901a\u5e38\u7528\u4e8e\u6570\u636e\u4e89\u7528\u8f83\u9ad8\u7684\u73af\u5883\u4e2d\u3002
\u5728\u60b2\u89c2\u5e76\u53d1\u6a21\u578b\u4e2d\uff0c\u5982\u679c\u4f60\u4ece\u6570\u636e\u5e93\u63a5\u6536\u5230\u4e00\u4e2a\u503c\u540e\uff0c\u53e6\u4e00\u4e2a\u7528\u6237\u5728\u4f60\u8bd5\u56fe\u4fee\u6539\u8be5\u503c\u4e4b\u524d\uff0c\u5c06\u4f1a\u9047\u5230\u9501\u800c\u8fdb\u5165\u7b49\u5f85\u72b6\u6001\uff0c\u8d85\u8fc7 MatrixOne \u8bbe\u7f6e\u7684\u4e8b\u52a1\u7b49\u5f85\u65f6\u95f4\uff085 \u5206\u949f\uff09\u540e\uff0c\u7b49\u5f85\u4e8b\u52a1\u5c06\u4f1a\u88ab\u5f3a\u5236\u53d6\u6d88\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_4","title":"\u6b7b\u9501","text":"\u5728\u60b2\u89c2\u4e8b\u52a1\u4e2d\uff0c\u6709\u53ef\u80fd\u51fa\u73b0\u4e00\u79cd\u60c5\u51b5\uff0c\u5373\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u4e8b\u52a1\u4e92\u76f8\u9501\u4f4f\u4e86\u5bf9\u65b9\u6240\u9700\u8981\u7684\u8d44\u6e90\u65f6\uff0c\u4ee4\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u65e0\u6cd5\u8fdb\u884c\u4e0b\u53bb\u7684\u72b6\u6001\uff0c\u8fd9\u79cd\u60c5\u51b5\u88ab\u79f0\u4e4b\u4e3a\u6b7b\u9501\uff08Deadlock\uff09\u3002\u53ea\u6709\u901a\u8fc7\u4eba\u4e3a\u5e72\u9884\u5176\u4e2d\u67d0\u4e2a\u4e8b\u52a1\uff0c\u4f8b\u5982\uff0c\u901a\u8fc7\u624b\u52a8 Kill
\u4f1a\u8bdd\u7684\u65b9\u5f0f\uff0c\u624d\u80fd\u7acb\u5373\u7ed3\u675f\u6b7b\u9501\uff0c\u5426\u5219\u53ea\u80fd\u7b49\u4e8b\u52a1\u8d85\u51fa\u6700\u957f\u7b49\u5f85\u65f6\u95f4\u3002
\u6b7b\u9501\u793a\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_5","title":"\u6a21\u578b\u793a\u4f8b","text":"\u4e0b\u9762\u4e3a\u60b2\u89c2\u5e76\u53d1\u7684\u793a\u4f8b\uff0c\u5c06\u4e3a\u4f60\u5c55\u793a MatrixOne \u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u51b2\u7a81\u3002
CustID LastName FirstName\n101 Smith Bob\n
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob \u5728\u4e0b\u5348 1:01\uff0c\u7528\u6237 2 \u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u540c\u4e00\u884c\u3002
\u5728\u4e0b\u5348 1:03\uff0c\u7528\u6237 2 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cRobert\u201d\uff0c\u6b64\u65f6\u5904\u4e8e\u672a\u63d0\u4ea4\u72b6\u6001\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob\u5728\u4e0b\u5348 1:05\uff0c\u7528\u6237 1 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cJames\u201d\uff0c\u5e76\u5c1d\u8bd5\u8fdb\u884c\u66f4\u65b0\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Bob\u6b64\u65f6\uff0c\u7528\u6237 1 \u9047\u5230\u4e86\u60b2\u89c2\u5e76\u53d1\u51b2\u7a81\uff0c\u56e0\u4e3a\u6570\u636e\u5e93\u4e2d\u7684\u503c\u201cRobert\u201d\u6240\u5728\u884c\u5df2\u7ecf\u88ab\u9501\u5b9a\uff0c\u9700\u8981\u7b49\u5f85\u7528\u6237 2 \u7684\u4e0b\u4e00\u6b65\u64cd\u4f5c\u3002
\u5728\u4e0b\u5348 1:06\uff0c\u7528\u6237 1 \u5bf9\u4e8b\u52a1\u63d0\u4ea4\u3002\u6b64\u65f6\u7528\u6237 2 \u89e3\u9664\u7b49\u5f85\u72b6\u6001\u5f00\u59cb\u4e8b\u52a1\uff0c\u4f46\u662f\u56e0\u4e3a\u5df2\u7ecf\u65e0\u6cd5\u5339\u914d\u5230\u5bf9\u5e94\u7684 FirstName\uff0c\u56e0\u6b64\u7528\u6237 2 \u7684\u4e8b\u52a1\u4f1a\u66f4\u65b0\u5931\u8d25\u3002
\u5728\u4e00\u4e2a\u8d22\u52a1\u7cfb\u7edf\u4e2d\uff0c\u4e0d\u540c\u7528\u6237\u4e4b\u95f4\u7684\u8f6c\u8d26\u662f\u975e\u5e38\u5e38\u89c1\u7684\u573a\u666f\uff0c\u800c\u8f6c\u8d26\u5728\u6570\u636e\u5e93\u4e2d\u7684\u5b9e\u9645\u64cd\u4f5c\uff0c\u901a\u5e38\u662f\u4e24\u4e2a\u6b65\u9aa4\uff0c\u9996\u5148\u662f\u5bf9\u4e00\u4e2a\u7528\u6237\u7684\u8d26\u9762\u91d1\u989d\u62b5\u6263\u4e4b\u540e\uff0c\u7136\u540e\u662f\u5bf9\u53e6\u4e00\u4e2a\u7528\u6237\u7684\u8d26\u9762\u91d1\u989d\u8fdb\u884c\u589e\u52a0\u3002\u53ea\u6709\u5229\u7528\u4e8b\u52a1\u7684\u539f\u5b50\u6027\uff0c\u624d\u80fd\u786e\u4fdd\u603b\u8d26\u9762\u8d44\u91d1\u6ca1\u6709\u53d8\u5316\uff0c\u540c\u65f6\u4e24\u4e2a\u7528\u6237\u4e4b\u95f4\u7684\u8d26\u6237\u90fd\u5b8c\u6210\u4e86\u5404\u81ea\u7684\u62b5\u6263\u4e0e\u589e\u52a0\uff0c\u4f8b\u5982 A \u7528\u6237\u6b64\u65f6\u5bf9 B \u7528\u6237\u8f6c\u8d26 50\uff1a
start transaction;\nupdate accounts set balance=balance-50 where name='A';\nupdate accounts set balance=balance+50 where name='B';\ncommit;\n
\u5f53\u4e24\u6b21 update
\u90fd\u6210\u529f\u5e76\u4e14\u6700\u7ec8\u63d0\u4ea4\uff0c\u6574\u4e2a\u8f6c\u8d26\u624d\u7b97\u771f\u6b63\u5b8c\u6210\uff0c\u4efb\u4f55\u4e00\u6b65\u7684\u5931\u8d25\uff0c\u5fc5\u987b\u8ba9\u6574\u4e2a\u4e8b\u52a1\u56de\u6eda\uff0c\u624d\u80fd\u786e\u4fdd\u539f\u5b50\u6027\u3002
\u6b64\u5916\uff0c\u4e24\u4e2a\u8d26\u6237\u8f6c\u8d26\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5728\u6ca1\u6709\u63d0\u4ea4\u4e4b\u524d\uff0c\u65e0\u8bba\u662f A \u6216\u8005 B\uff0c\u770b\u5230\u7684\u90fd\u662f\u5c1a\u672a\u8f6c\u8d26\u5b8c\u6210\u7684\u8d26\u9762\u4f59\u989d\uff0c\u8fd9\u662f\u4e8b\u52a1\u7684\u9694\u79bb\u6027\u3002
\u5728\u8f6c\u8d26\u8fc7\u7a0b\u4e2d\uff0c\u6570\u636e\u5e93\u4f1a\u68c0\u67e5 A \u7684\u8d26\u9762\u8d44\u91d1\u662f\u5426\u5927\u4e8e 50\uff0cA \u548c B \u5728\u7cfb\u7edf\u4e2d\u662f\u5426\u786e\u6709\u5176\u4eba\uff0c\u53ea\u6709\u90fd\u6ee1\u8db3\u8fd9\u4e9b\u7ea6\u675f\uff0c\u624d\u80fd\u4fdd\u8bc1\u4e8b\u52a1\u7684\u4e00\u81f4\u6027\u3002
\u5b8c\u6210\u8f6c\u8d26\u540e\uff0c\u65e0\u8bba\u7cfb\u7edf\u662f\u5426\u91cd\u542f\uff0c\u6570\u636e\u5df2\u7ecf\u5b8c\u6210\u4e86\u6301\u4e45\u5316\uff0c\u4f53\u73b0\u4e86\u4e8b\u52a1\u7684\u6301\u4e45\u6027\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/#matrixone","title":"MatrixOne \u7684\u60b2\u89c2\u4e8b\u52a1\u4e0e\u8bfb\u5df2\u63d0\u4ea4","text":"MatrixOne \u9ed8\u8ba4\u60b2\u89c2\u4e8b\u52a1\u4e0e\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\uff0c\u8fd9\u79cd\u7ec4\u5408\u65b9\u5f0f\u4f7f\u6027\u80fd\u8fbe\u5230\u6700\u4f18\u3002
\u60b2\u89c2\u4e8b\u52a1\uff08Pessimistic Transaction\uff09\u662f\u6307\u5728\u4e8b\u52a1\u671f\u95f4\uff0c\u6301\u6709\u8d44\u6e90\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5c06\u8d44\u6e90\u9501\u5b9a\uff0c\u4ee5\u907f\u514d\u5176\u4ed6\u5e76\u53d1\u4e8b\u52a1\u5bf9\u8be5\u8d44\u6e90\u7684\u4fee\u6539\u6216\u8bfb\u53d6\u3002\u60b2\u89c2\u4e8b\u52a1\u5047\u5b9a\u5e76\u53d1\u4e8b\u52a1\u53ef\u80fd\u4f1a\u5bf9\u8d44\u6e90\u8fdb\u884c\u64cd\u4f5c\uff0c\u5e76\u9632\u6b62\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\u3002
\u5728 MatrixOne \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 UPDATE ... WHERE...
\u8bed\u53e5\u6765\u5b9e\u73b0\u60b2\u89c2\u9501\u5b9a\uff0c\u8be5\u8bed\u53e5\u4f1a\u9501\u5b9a\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u76f4\u5230\u4e8b\u52a1\u63d0\u4ea4\u6216\u56de\u6eda\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u9501\u5b9a\u4e86 user
\u8868\u4e2d id=1
\u7684\u8bb0\u5f55\uff1a
START TRANSACTION;\nUPDATE t1 WHERE id=1;\n-- \u5728\u4e8b\u52a1\u671f\u95f4\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff0c\u4f8b\u5982\u4fee\u6539\u8be5\u8bb0\u5f55\nCOMMIT;\n
\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u662f\u4e00\u79cd\u9694\u79bb\u7ea7\u522b\uff0c\u5b83\u786e\u4fdd\u5728\u4e8b\u52a1\u63d0\u4ea4\u4e4b\u524d\uff0c\u5176\u4ed6\u4e8b\u52a1\u6240\u505a\u7684\u4fee\u6539\u4e0d\u4f1a\u5bf9\u5f53\u524d\u4e8b\u52a1\u53ef\u89c1\u3002\u5728\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u4e8b\u52a1\u53ea\u80fd\u770b\u5230\u5df2\u7ecf\u63d0\u4ea4\u7684\u6570\u636e\uff0c\u65e0\u6cd5\u770b\u5230\u672a\u63d0\u4ea4\u7684\u6570\u636e\u3002\u56e0\u6b64\uff0c\u5728\u8be5\u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u53ef\u4ee5\u907f\u514d\u810f\u8bfb\uff08Dirty Read\uff09\u3002
\u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
\u8bed\u53e5\u8bbe\u7f6e\u9694\u79bb\u7ea7\u522b\u4e3a\u8bfb\u5df2\u63d0\u4ea4\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u67e5\u8be2\u4e86 user \u8868\u4e2d id=1 \u7684\u8bb0\u5f55\uff0c\u4f46\u5982\u679c\u5176\u4ed6\u4e8b\u52a1\u6b63\u5728\u4fee\u6539\u8be5\u8bb0\u5f55\uff0c\u5219\u5f53\u524d\u4e8b\u52a1\u65e0\u6cd5\u770b\u5230\u672a\u63d0\u4ea4\u7684\u4fee\u6539\uff1a
BEGIN TRANSACTION;\nSET TRANSACTION ISOLATION LEVEL READ COMMITTED;\n-- \u5982\u679c\u5176\u4ed6\u4e8b\u52a1\u6b63\u5728\u4fee\u6539 user \u8868\u4e2d id=1 \u7684\u8bb0\u5f55\uff0c\u4e0b\u9762\u7684\u8bed\u53e5\u5c06\u4f1a\u7b49\u5f85\uff0c\u76f4\u5230\u9501\u5b9a\u88ab\u91ca\u653e\nSELECT * FROM user WHERE id = 1;\nCOMMIT;\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u548c\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\u53ef\u4ee5\u907f\u514d\u4e00\u4e9b\u5e76\u53d1\u95ee\u9898\uff0c\u4f46\u4e5f\u53ef\u80fd\u4f1a\u5e26\u6765\u4e00\u4e9b\u989d\u5916\u7684\u5f00\u9500\uff0c\u56e0\u6b64\u9700\u8981\u6743\u8861\u5229\u5f0a\u5e76\u6839\u636e\u5b9e\u9645\u9700\u6c42\u6765\u9009\u62e9\u4f7f\u7528\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/","title":"\u805a\u7c7b\u4e2d\u5fc3","text":""},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_2","title":"\u4ec0\u4e48\u662f\u805a\u7c7b\u4e2d\u5fc3","text":"\u5728\u4f7f\u7528\u805a\u7c7b\u7b97\u6cd5\uff0c\u7279\u522b\u662f K-means \u7b97\u6cd5\u65f6\uff0c\u805a\u7c7b\u6570\u91cf K \u4ee3\u8868\u4e86\u4f60\u60f3\u8981\u5c06\u6570\u636e\u96c6\u5206\u6210\u7684\u7c07\uff08cluster\uff09\u7684\u6570\u91cf\u3002\u6bcf\u4e2a\u7c07\u7531\u5176\u805a\u7c7b\u4e2d\u5fc3\uff08centroid\uff09\u4ee3\u8868\uff0c\u805a\u7c7b\u4e2d\u5fc3\u662f\u7c07\u5185\u6240\u6709\u6570\u636e\u70b9\u7684\u4e2d\u5fc3\u70b9\u6216\u5e73\u5747\u4f4d\u7f6e\u3002
\u5728 K-means \u7b97\u6cd5\u4e2d\uff0cK \u7684\u9009\u62e9\u5bf9\u805a\u7c7b\u7ed3\u679c\u6709\u5f88\u5927\u5f71\u54cd\u3002\u9009\u62e9\u5408\u9002\u7684 K \u503c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u6570\u636e\u7684\u7ed3\u6784\u548c\u6a21\u5f0f\u3002\u5982\u679c K \u503c\u9009\u62e9\u4e0d\u5f53\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4ee5\u4e0b\u95ee\u9898\uff1a
Matrixone \u63d0\u4f9b\u805a\u7c7b\u4e2d\u5fc3\u67e5\u8be2\u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u5217\u7684 K \u4e2a\u805a\u7c7b\u4e2d\u5fc3\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_3","title":"\u805a\u7c7b\u4e2d\u5fc3\u7684\u5e94\u7528\u573a\u666f","text":"\u805a\u7c7b\u5728\u6570\u636e\u5206\u6790\u548c\u673a\u5668\u5b66\u4e60\u9886\u57df\u626e\u6f14\u7740\u91cd\u8981\u89d2\u8272\u3002\u4ee5\u4e0b\u662f\u805a\u7c7b\u4e2d\u5fc3\u7684\u4e00\u4e9b\u4e3b\u8981\u5e94\u7528\u573a\u666f\uff1a
\u5e02\u573a\u7ec6\u5206\uff1a\u5728\u5e02\u573a\u5206\u6790\u4e2d\uff0c\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u4e0d\u540c\u7684\u5ba2\u6237\u7fa4\u4f53\u7279\u5f81\uff0c\u4ece\u800c\u4e3a\u6bcf\u4e2a\u7fa4\u4f53\u5b9a\u5236\u8425\u9500\u7b56\u7565\u3002
\u56fe\u50cf\u5206\u5272\uff1a\u5728\u56fe\u50cf\u5904\u7406\u4e2d\uff0c\u805a\u7c7b\u4e2d\u5fc3\u7528\u4e8e\u533a\u5206\u56fe\u50cf\u4e2d\u4e0d\u540c\u7684\u533a\u57df\u6216\u5bf9\u8c61\uff0c\u5e38\u7528\u4e8e\u56fe\u50cf\u538b\u7f29\u548c\u5206\u5272\u3002
\u793e\u4ea4\u7f51\u7edc\u5206\u6790\uff1a\u901a\u8fc7\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u8bc6\u522b\u793e\u4ea4\u7f51\u7edc\u4e2d\u5177\u6709\u76f8\u4f3c\u884c\u4e3a\u6216\u5174\u8da3\u7684\u7528\u6237\u7fa4\u4f53\u3002
\u5f02\u5e38\u68c0\u6d4b\uff1a\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u6570\u636e\u4e2d\u7684\u5f02\u5e38\u70b9\uff0c\u56e0\u4e3a\u5f02\u5e38\u70b9\u901a\u5e38\u8fdc\u79bb\u6240\u6709\u805a\u7c7b\u4e2d\u5fc3\u3002
\u5929\u6587\u6570\u636e\u5206\u6790\uff1a\u5728\u5929\u6587\u5b66\u4e2d\uff0c\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u7528\u4e8e\u8bc6\u522b\u661f\u7cfb\u56e2\u6216\u6052\u661f\u7fa4\u7684\u7279\u5f81\u3002
\u5728 Matrixone \u4e2d\u786e\u5b9a\u5411\u91cf\u6570\u636e\u96c6\u7684\u805a\u7c7b\u4e2d\u5fc3\uff0c\u6d89\u53ca\u5230\u4ee5\u4e0b\u7b97\u6cd5\uff1a
Random (\u968f\u673a\u521d\u59cb\u5316)\uff1a\u5728\u968f\u673a\u521d\u59cb\u5316\u4e2d\uff0c\u7b97\u6cd5\u4ece\u6570\u636e\u96c6\u4e2d\u968f\u673a\u9009\u62e9 n_clusters \u4e2a\u89c2\u6d4b\u503c\u4f5c\u4e3a\u521d\u59cb\u8d28\u5fc3\u70b9\u3002\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u5feb\u901f\uff0c\u4f46\u53ef\u80fd\u5bfc\u81f4\u805a\u7c7b\u7ed3\u679c\u7684\u8d28\u91cf\u4f9d\u8d56\u4e8e\u521d\u59cb\u8d28\u5fc3\u7684\u9009\u53d6\uff0c\u56e0\u4e3a\u968f\u673a\u9009\u62e9\u53ef\u80fd\u4e0d\u4f1a\u843d\u5728\u6570\u636e\u7684\u7a20\u5bc6\u533a\u57df\u3002
K-means++(k-means++ \u521d\u59cb\u5316)\uff1ak-means++ \u662f\u4e00\u79cd\u66f4\u9ad8\u7ea7\u7684\u521d\u59cb\u5316\u65b9\u6cd5\uff0c\u65e8\u5728\u6539\u5584\u968f\u673a\u521d\u59cb\u5316\u7684\u4e0d\u8db3\uff0c\u5b83\u901a\u8fc7\u591a\u6b65\u9aa4\u8fc7\u7a0b\u6765\u9009\u62e9\u521d\u59cb\u8d28\u5fc3\uff0c\u4ee5\u589e\u52a0\u9009\u62e9\u7684\u8d28\u5fc3\u70b9\u80fd\u591f\u4ee3\u8868\u6570\u636e\u6574\u4f53\u5206\u5e03\u7684\u6982\u7387\u3002
Regular Kmeans\uff08\u5e38\u89c4 K-means \u7b97\u6cd5\uff09\uff1a\u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u805a\u7c7b\u65b9\u6cd5\uff0c\u65e8\u5728\u5c06\u6570\u636e\u70b9\u5212\u5206\u4e3a K \u4e2a\u7c07\uff0c\u4f7f\u5f97\u7c07\u5185\u7684\u6570\u636e\u70b9\u5c3d\u53ef\u80fd\u76f8\u4f3c\uff0c\u800c\u7c07\u95f4\u7684\u6570\u636e\u70b9\u5c3d\u53ef\u80fd\u4e0d\u540c\u3002\u8fd9\u79cd\u65b9\u6cd5\u57fa\u4e8e\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb\u6765\u8861\u91cf\u6570\u636e\u70b9\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\uff0c\u56e0\u6b64\u5b83\u66f4\u9002\u5408\u4e8e\u5728\u5e73\u9762\u7a7a\u95f4\u4e2d\u5904\u7406\u6570\u636e\u3002
Spherical Kmeans\uff08\u7403\u5f62 K-means\uff09\uff1a\u662f\u4e00\u79cd\u5bf9\u6570\u636e\u70b9\u8fdb\u884c\u805a\u7c7b\u7684\u7b97\u6cd5\uff0cSpherical K-means \u7b97\u6cd5\u8ba1\u7b97\u805a\u7c7b\u4e2d\u5fc3\u7684\u8fc7\u7a0b\u6d89\u53ca\u5230\u5bf9\u6570\u636e\u70b9\u8fdb\u884c\u5f52\u4e00\u5316\u5904\u7406\u3002\u7279\u522b\u9002\u7528\u4e8e\u9ad8\u7ef4\u4e14\u7a00\u758f\u9ad8\u7ef4\u4e14\u7a00\u758f\u7684\uff0c\u6216\u8005\u6570\u636e\u70b9\u7684\u65b9\u5411\u6027\u6bd4\u8ddd\u79bb\u66f4\u4e3a\u91cd\u8981\u7684\u6570\u636e\uff0c\u5982\u6587\u672c\u6570\u636e\u3001\u5730\u7406\u4f4d\u7f6e\u6216\u7528\u6237\u5174\u8da3\u6a21\u578b\u3002
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u7ec4\u5ba2\u6237\u7684\u5e74\u5ea6\u8d2d\u7269\u6570\u636e\uff0c\u5305\u62ec\u4ed6\u4eec\u7684\u5e74\u6536\u5165\u548c\u5e74\u5ea6\u6d88\u8d39\u603b\u989d\u3002\u6211\u4eec\u60f3\u8981\u901a\u8fc7\u8fd9\u4e9b\u6570\u636e\u4e86\u89e3\u5ba2\u6237\u7684\u6d88\u8d39\u884c\u4e3a\uff0c\u5e76\u5c06\u5176\u5206\u6210\u4e0d\u540c\u7684\u6d88\u8d39\u884c\u4e3a\u7fa4\u4f53\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_6","title":"\u6b65\u9aa4","text":"\u5efa\u7acb\u5ba2\u6237\u8868\u5e76\u63d2\u5165\u6570\u636e
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a customer_table
\u7684\u8868\uff0c\u63d2\u5165 10 \u6761\u987e\u5ba2\u6570\u636e\u3002\u4e8c\u7ef4\u5411\u91cf\u4ee3\u8868\u5ba2\u6237\u7684\u5e74\u6536\u5165\u548c\u5e74\u5ea6\u6d88\u8d39\u603b\u989d\u3002
CREATE TABLE customer_table(id int auto_increment PRIMARY KEY,in_ex vecf64(2));\nINSERT INTO customer_table(in_ex) VALUES(\"[120,50]\"),(\"[80,25]\"),(\"[200,100]\"),(\"[100,40]\"),(\"[300,120]\"),(\"[150,75]\"),(\"[90,30]\"),(\"[250,90]\"),(\"[75,20]\"),(\"[150,60]\");\n\nmysql> select * from customer_table;\n+------+------------+\n| id | in_ex |\n+------+------------+\n| 1 | [120, 50] |\n| 2 | [80, 25] |\n| 3 | [200, 100] |\n| 4 | [100, 40] |\n| 5 | [300, 120] |\n| 6 | [150, 75] |\n| 7 | [90, 30] |\n| 8 | [250, 90] |\n| 9 | [75, 20] |\n| 10 | [150, 60] |\n+------+------------+\n10 rows in set (0.01 sec)\n
\u786e\u5b9a\u805a\u7c7b\u4e2d\u5fc3
mysql> SELECT cluster_centers(in_ex kmeans '2,vector_l2_ops,random,false') AS centers FROM customer_table;\n+------------------------------------------------------------------------+\n| centers |\n+------------------------------------------------------------------------+\n| [ [109.28571428571428, 42.857142857142854],[250, 103.33333333333333] ] |\n+------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
\u68c0\u67e5\u805a\u7c7b\u4e2d\u5fc3
\u4e00\u4e2a\u597d\u7684\u805a\u7c7b\u901a\u5e38\u4f1a\u5728\u53ef\u89c6\u5316\u4e2d\u663e\u793a\u4e3a\u660e\u663e\u7684\u5206\u79bb\u7fa4\u7ec4\u3002\u7531\u4e0b\u56fe\u89c2\u5bdf\u53ef\u5f97\uff0c\u805a\u7c7b\u4e2d\u5fc3\u9009\u62e9\u8f83\u4e3a\u9002\u5f53\u3002
\u901a\u8fc7\u805a\u7c7b\u4e2d\u5fc3\u7684\u786e\u5b9a\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5ba2\u6237\u5206\u4e3a\u4e24\u4e2a\u7fa4\u4f53\uff1a\u4e00\u4e2a\u7fa4\u4f53\u662f\u4e2d\u7b49\u6536\u5165\u548c\u4e2d\u7b49\u6d88\u8d39\u6c34\u5e73\u7684\u5ba2\u6237\uff08\u805a\u7c7b\u4e2d\u5fc3 A\uff09\uff0c\u53e6\u4e00\u4e2a\u7fa4\u4f53\u662f\u8f83\u9ad8\u6536\u5165\u548c\u8f83\u9ad8\u6d88\u8d39\u6c34\u5e73\u7684\u5ba2\u6237\uff08\u805a\u7c7b\u4e2d\u5fc3 B\uff09\u3002\u5546\u5bb6\u53ef\u4ee5\u6839\u636e\u6bcf\u4e2a\u7fa4\u4f53\u7684\u6d88\u8d39\u7279\u5f81\u8c03\u6574\u4ea7\u54c1\u5b9a\u4f4d\uff0c\u6bd4\u5982\u4e3a\u805a\u7c7b\u4e2d\u5fc3 A \u63d0\u4f9b\u6027\u4ef7\u6bd4\u8f83\u9ad8\u7684\u4ea7\u54c1\uff0c\u800c\u4e3a\u805a\u7c7b\u4e2d\u5fc3 B \u63d0\u4f9b\u9ad8\u7aef\u6216\u5962\u4f88\u54c1\u724c\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#2","title":"\u793a\u4f8b 2","text":"\u4e00\u5bb6\u97f3\u4e50\u6d41\u5a92\u4f53\u670d\u52a1\u60f3\u8981\u6839\u636e\u7528\u6237\u5bf9\u4e0d\u540c\u97f3\u4e50\u7c7b\u578b\u7684\u504f\u597d\u5c06\u4ed6\u4eec\u5206\u4e3a\u51e0\u4e2a\u7fa4\u4f53\uff0c\u4ee5\u4fbf\u63d0\u4f9b\u4e2a\u6027\u5316\u7684\u64ad\u653e\u5217\u8868\u3002\u4ed6\u4eec\u6536\u96c6\u4e86\u7528\u6237\u5bf9\u4ee5\u4e0b 5 \u79cd\u97f3\u4e50\u7c7b\u578b\u7684\u504f\u597d\u8bc4\u5206\uff081 \u5206\u8868\u793a\u4e0d\u611f\u5174\u8da3\uff0c5 \u5206\u8868\u793a\u975e\u5e38\u559c\u6b22\uff09\uff1a\u6447\u6eda\u3001\u6d41\u884c\u3001\u7235\u58eb\u3001\u53e4\u5178\u548c\u563b\u54c8\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_7","title":"\u6b65\u9aa4","text":"\u5efa\u7acb\u97f3\u4e50\u7c7b\u578b\u8868\u5e76\u63d2\u5165\u6570\u636e
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a music_table
\u7684\u8868\uff0c\u63d2\u5165 5 \u6761\u7528\u6237\u6570\u636e\u3002\u4e94\u7ef4\u5411\u91cf\u5bf9\u5e94\u7528\u6237\u5bf9\u6447\u6eda\u3001\u6d41\u884c\u3001\u7235\u58eb\u3001\u53e4\u5178\u548c\u563b\u54c8\u4e94\u79cd\u7c7b\u578b\u97f3\u4e50\u7684\u504f\u597d\u8bc4\u5206\u3002
CREATE TABLE music_table(id int,grade vecf64(5));\nINSERT INTO music_table VALUES(1,\"[5,2,3,1,4]\"),(2,\"[3,5,2,1,4]\"),(3,\"[4,3,5,1,2]\"),(4,\"[2,5,4,3,1]\"),(5,\"[5,4,3,2,5]\");\n\nmysql> select * from music_table;\n+------+-----------------+\n| id | grade |\n+------+-----------------+\n| 1 | [5, 2, 3, 1, 4] |\n| 2 | [3, 5, 2, 1, 4] |\n| 3 | [4, 3, 5, 1, 2] |\n| 4 | [2, 5, 4, 3, 1] |\n| 5 | [5, 4, 3, 2, 5] |\n+------+-----------------+\n5 rows in set (0.01 sec)\n
\u67e5\u770b\u5411\u91cf\u5f52\u4e00\u5316\u7ed3\u679c
mysql> select normalize_l2(grade) from music_table;\n+---------------------------------------------------------------------------------------------------------+\n| normalize_l2(grade) |\n+---------------------------------------------------------------------------------------------------------+\n| [0.6741998624632421, 0.26967994498529685, 0.40451991747794525, 0.13483997249264842, 0.5393598899705937] |\n| [0.40451991747794525, 0.6741998624632421, 0.26967994498529685, 0.13483997249264842, 0.5393598899705937] |\n| [0.5393598899705937, 0.40451991747794525, 0.6741998624632421, 0.13483997249264842, 0.26967994498529685] |\n| [0.26967994498529685, 0.6741998624632421, 0.5393598899705937, 0.40451991747794525, 0.13483997249264842] |\n| [0.562543950463012, 0.4500351603704096, 0.3375263702778072, 0.2250175801852048, 0.562543950463012] |\n+---------------------------------------------------------------------------------------------------------+\n5 rows in set (0.01 sec)\n
\u786e\u5b9a\u805a\u7c7b\u4e2d\u5fc3
mysql> SELECT cluster_centers(grade kmeans '2,vector_l2_ops,kmeansplusplus,true') AS centers FROM music_table;\n+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| centers |\n+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| [ [0.3370999312316211, 0.6741998624632421, 0.40451991747794525, 0.26967994498529685, 0.3370999312316211],[0.5920345676322826, 0.3747450076112172, 0.4720820500729982, 0.16489917505683388, 0.4571945951396342] ] |\n+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
\u68c0\u67e5\u805a\u7c7b\u4e2d\u5fc3
\u4f7f\u7528 t-SNE \u5c06\u9ad8\u7ef4\u6570\u636e\u964d\u5230 2D\uff0c\u5e76\u53ef\u89c6\u5316\u805a\u7c7b\u7ed3\u679c\u3002\u4ece\u4e0b\u56fe\u53ef\u770b\u5230\u6570\u636e\u70b9\u5728\u964d\u7ef4\u540e\u7684\u7a7a\u95f4\u4e2d\u6309\u805a\u7c7b\u4e2d\u5fc3\u660e\u663e\u5206\u5f00\uff0c\u8fd9\u589e\u52a0\u4e86\u805a\u7c7b\u4e2d\u5fc3\u6b63\u786e\u6027\u7684\u4fe1\u5fc3\u3002
\u901a\u8fc7\u805a\u7c7b\u4e2d\u5fc3\u7684\u786e\u5b9a\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u7528\u6237\u5206\u4e3a\u4e24\u4e2a\u7fa4\u4f53\uff1a\u7c07 1 \u4e3b\u8981\u7531\u559c\u6b22\u6447\u6eda\u548c\u563b\u54c8\u97f3\u4e50\u7684\u7528\u6237\u7ec4\u6210\uff0c\u8fd9\u53ef\u80fd\u4ee3\u8868\u4e86\u4e00\u4e2a\u5bfb\u6c42\u73b0\u4ee3\u548c\u8282\u594f\u611f\u5f3a\u70c8\u97f3\u4e50\u7684\u7528\u6237\u7fa4\u4f53\u3002\u7c07 2 \u5219\u7531\u559c\u6b22\u6d41\u884c\u548c\u7235\u58eb\u97f3\u4e50\u7684\u7528\u6237\u7ec4\u6210\uff0c\u8fd9\u53ef\u80fd\u4ee3\u8868\u4e86\u4e00\u4e2a\u504f\u597d\u65cb\u5f8b\u548c\u8f7b\u677e\u6c1b\u56f4\u97f3\u4e50\u7684\u7528\u6237\u7fa4\u4f53\u3002\u5a92\u4f53\u516c\u53f8\u53ef\u4ee5\u6839\u636e\u7528\u6237\u559c\u597d\u6765\u4e3a\u4ed6\u4eec\u63a8\u9001\u76f8\u5e94\u98ce\u683c\u7684\u97f3\u4e50\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_8","title":"\u53c2\u8003\u6587\u6863","text":"\u5411\u91cf\u6570\u636e\u7c7b\u578b
CLUSTER_CENTERS()
L2_DISTANCE()
NORMALIZE_L2()
"},{"location":"MatrixOne/Develop/Vector/vector_search/","title":"\u5411\u91cf\u68c0\u7d22","text":""},{"location":"MatrixOne/Develop/Vector/vector_search/#_2","title":"\u4ec0\u4e48\u662f\u5411\u91cf\u68c0\u7d22","text":"\u5411\u91cf\u68c0\u7d22\u5c31\u662f\u5728\u4e00\u4e2a\u7ed9\u5b9a\u5411\u91cf\u6570\u636e\u96c6\u4e2d\uff0c\u6309\u7167\u67d0\u79cd\u5ea6\u91cf\u65b9\u5f0f\uff0c\u68c0\u7d22\u51fa\u4e0e\u67e5\u8be2\u5411\u91cf\u76f8\u8fd1\u7684 K \u4e2a\u5411\u91cf\uff08K-Nearest Neighbor\uff0cKNN\uff09\u3002\u8fd9\u662f\u4e00\u79cd\u5728\u5927\u89c4\u6a21\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\u4e2d\u5bfb\u627e\u4e0e\u7ed9\u5b9a\u67e5\u8be2\u5411\u91cf\u76f8\u4f3c\u7684\u5411\u91cf\u7684\u6280\u672f\u3002\u5411\u91cf\u68c0\u7d22\u5728\u8bb8\u591a AI \u9886\u57df\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u5982\u56fe\u50cf\u68c0\u7d22\u3001\u6587\u672c\u68c0\u7d22\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u63a8\u8350\u7cfb\u7edf\u7b49\u3002\u5411\u91cf\u68c0\u7d22\u4e0e\u4f20\u7edf\u6570\u636e\u5e93\u68c0\u7d22\u6709\u5f88\u5927\u5dee\u522b\uff0c\u4f20\u7edf\u6570\u636e\u5e93\u4e0a\u7684\u6807\u91cf\u641c\u7d22\u4e3b\u8981\u9488\u5bf9\u7ed3\u6784\u5316\u6570\u636e\u8fdb\u884c\u7cbe\u786e\u7684\u6570\u636e\u67e5\u8be2\uff0c\u800c\u5411\u91cf\u641c\u7d22\u4e3b\u8981\u9488\u5bf9\u975e\u7ed3\u6784\u5316\u6570\u636e\u5411\u91cf\u5316\u4e4b\u540e\u7684\u5411\u91cf\u6570\u636e\u8fdb\u884c\u76f8\u4f3c\u68c0\u7d22\uff0c\u53ea\u80fd\u8fd1\u4f3c\u83b7\u5f97\u6700\u5339\u914d\u7684\u7ed3\u679c\u3002
Matrixone \u76ee\u524d\u652f\u6301\u4f7f\u7528\u4ee5\u4e0b\u8ddd\u79bb\u5ea6\u91cf\u51fd\u6570\u8fdb\u884c\u5411\u91cf\u68c0\u7d22\uff1a
cosine_similarity
cosine_distance
l2_distance
Note
Matrixone \u76ee\u524d\u53ea\u652f\u6301\u5728 l2_distance \u5ea6\u91cf\u4e0a\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\u8fdb\u884c\u5feb\u901f KNN \u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/Vector/vector_search/#_3","title":"\u5411\u91cf\u68c0\u7d22\u7684\u5e94\u7528\u573a\u666f","text":"\u6570\u636e\u5e93\u62e5\u6709\u5411\u91cf\u80fd\u529b\u610f\u5473\u7740\u6570\u636e\u5e93\u7cfb\u7edf\u5177\u5907\u5b58\u50a8\u3001\u67e5\u8be2\u548c\u5206\u6790\u5411\u91cf\u6570\u636e\u7684\u80fd\u529b\u3002\u8fd9\u4e9b\u5411\u91cf\u901a\u5e38\u4e0e\u590d\u6742\u7684\u6570\u636e\u5206\u6790\u3001\u673a\u5668\u5b66\u4e60\u548c\u6570\u636e\u6316\u6398\u4efb\u52a1\u76f8\u5173\u3002\u4ee5\u4e0b\u662f\u6570\u636e\u5e93\u62e5\u6709\u5411\u91cf\u5904\u7406\u80fd\u529b\u540e\u7684\u90e8\u5206\u5e94\u7528\u573a\u666f\uff1a
\u9e22\u5c3e\u82b1\u6570\u636e\u96c6\u662f\u4e00\u4e2a\u8457\u540d\u7684\u591a\u7c7b\u5206\u7c7b\u6570\u636e\u96c6\uff0c\u53ef\u81ea\u884c\u5728\u7f51\u4e0a\u641c\u7d22\u5e76\u4e0b\u8f7d\u3002\u6b64\u6570\u636e\u96c6\u5305\u542b 150 \u4e2a\u6837\u672c\uff0c\u5206\u4e3a 3 \u4e2a\u7c7b\u522b\uff1aIris Setosa\uff08\u5c71\u9e22\u5c3e\uff09\u3001Iris Versicolour\uff08\u53d8\u8272\u9e22\u5c3e\uff09\u548c Iris Virginica\uff08\u7ef4\u5409\u5c3c\u4e9a\u9e22\u5c3e\uff09\u3002\u6bcf\u4e2a\u6837\u672c\u6709 4 \u4e2a\u7279\u5f81\uff1a\u82b1\u843c\u957f\u5ea6\u3001\u82b1\u843c\u5bbd\u5ea6\u3001\u82b1\u74e3\u957f\u5ea6\u548c\u82b1\u74e3\u5bbd\u5ea6\u3002\u4e0b\u9762\u6211\u4eec\u5728\u9e22\u5c3e\u82b1\u6570\u636e\u96c6\u4e0a\u6267\u884c KNN \u67e5\u8be2\uff08\u57fa\u4e8e l2_distance)\uff0c\u6839\u636e\u9e22\u5c3e\u82b1\u7684\u7279\u5f81\u627e\u51fa\u4e0e\u67d0\u4e2a\u7279\u5b9a\u6837\u672c\u6700\u76f8\u4f3c\u7684 K \u4e2a\u6837\u672c\uff0c\u4ece\u800c\u786e\u5b9a\u8be5\u6837\u672c\u7684\u79cd\u7c7b\u3002
\u5efa\u7acb\u9e22\u5c3e\u82b1\u8868\u5e76\u5bfc\u5165\u6570\u636e
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a iris_table
\u7684\u8868\u4ee5\u53ca\u5bf9\u5e94\u7684\u9e22\u5c3e\u82b1\u6570\u636e\u96c6\u6570\u636e\uff0c\u6570\u636e\u96c6\u5171\u6709 150 \u884c\u6570\u636e\uff0c\u6bcf\u884c\u7531\u4e00\u4e2a\u56db\u7ef4\u7684\u7279\u5f81\u5411\u91cf\u548c\u79cd\u7c7b\u7ec4\u6210\u3002
CREATE TABLE iris_table(\nspecies varchar(100),--\u7c7b\u522b\nattributes vecf64(4)--\u7279\u5f81\n);\nLOAD DATA INFILE '/your_path/iris.csv' INTO TABLE iris_table;\n
\u4f7f\u7528 KNN \u6765\u9884\u6d4b\u8fd9\u4e2a\u8f93\u5165\u7279\u5f81\u7684\u7c7b\u522b
mysql> select * from iris_table order by l2_distance(attributes,\"[4,3.3,3,0.9]\") asc limit 1;\n+------------------+--------------------+\n| species | attributes |\n+------------------+--------------------+\n| Iris-versicolour | [4.9, 2.4, 3.3, 1] |\n+------------------+--------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from iris_table order by l2_distance(attributes,\"[4,3.3,3,0.9]\") asc limit 5;\n+------------------+----------------------+\n| species | attributes |\n+------------------+----------------------+\n| Iris-versicolour | [4.9, 2.4, 3.3, 1] |\n| Iris-versicolour | [5.1, 2.5, 3, 1.1] |\n| Iris-versicolour | [5, 2.3, 3.3, 1] |\n| Iris-setosa | [4.8, 3.4, 1.9, 0.2] |\n| Iris-versicolour | [5.2, 2.7, 3.9, 1.4] |\n+------------------+----------------------+\n5 rows in set (0.00 sec)\n
\u7ecf\u8fc7\u68c0\u7d22\uff0c\u6211\u4eec\u53ef\u4ee5\u5927\u81f4\u786e\u5b9a\u8be5\u6837\u672c\u7c7b\u578b\u4e3a\u53d8\u8272\u9e22\u5c3e\u3002
\u5982\u9700\u4e86\u89e3\u5411\u91cf\u68c0\u7d22\u5728\u6784\u5efa RAG \u5e94\u7528\u4e0a\u7684\u4f5c\u7528\uff0c\u8bf7\u53c2\u8003\u67e5\u770b\u5e94\u7528\u5f00\u53d1\u793a\u4f8b\u4e2d\u7684 RAG \u5e94\u7528\u57fa\u7840\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/Vector/vector_search/#_5","title":"\u53c2\u8003\u6587\u6863","text":"\u5411\u91cf\u6570\u636e\u7c7b\u578b
L2_DISTANCE()
"},{"location":"MatrixOne/Develop/Vector/vector_type/","title":"\u5411\u91cf\u7c7b\u578b","text":""},{"location":"MatrixOne/Develop/Vector/vector_type/#_2","title":"\u4ec0\u4e48\u662f\u5411\u91cf\uff1f","text":"\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u5411\u91cf\u901a\u5e38\u662f\u4e00\u7ec4\u6570\u5b57\uff0c\u5b83\u4eec\u4ee5\u7279\u5b9a\u7684\u65b9\u5f0f\u6392\u5217\uff0c\u4ee5\u8868\u793a\u67d0\u79cd\u6570\u636e\u6216\u7279\u5f81\u3002\u8fd9\u4e9b\u5411\u91cf\u53ef\u4ee5\u662f\u4e00\u7ef4\u6570\u7ec4\u3001\u591a\u7ef4\u6570\u7ec4\u6216\u5177\u6709\u66f4\u9ad8\u7ef4\u5ea6\u7684\u6570\u636e\u7ed3\u6784\u3002\u5728\u673a\u5668\u5b66\u4e60\u548c\u6570\u636e\u5206\u6790\u9886\u57df\u4e2d\uff0c\u5411\u91cf\u7528\u4e8e\u8868\u793a\u6570\u636e\u70b9\u3001\u7279\u5f81\u6216\u6a21\u578b\u53c2\u6570\u3002\u5b83\u4eec\u901a\u5e38\u662f\u7528\u6765\u5904\u7406\u975e\u7ed3\u6784\u5316\u6570\u636e\uff0c\u5982\u56fe\u7247\uff0c\u8bed\u97f3\uff0c\u6587\u672c\u7b49\uff0c\u4ee5\u901a\u8fc7\u673a\u5668\u5b66\u4e60\u6a21\u578b\uff0c\u5c06\u975e\u7ed3\u6784\u5316\u6570\u636e\u8f6c\u5316\u4e3a embedding \u5411\u91cf\uff0c\u968f\u540e\u5904\u7406\u5206\u6790\u8fd9\u4e9b\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Vector/vector_type/#matrixone","title":"Matrixone \u652f\u6301\u5411\u91cf\u7c7b\u578b","text":"\u4f20\u7edf\u7684\u5411\u91cf\u6570\u636e\u5e93\u4e13\u95e8\u8bbe\u8ba1\u7528\u4e8e\u5904\u7406\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\uff0c\u57fa\u672c\u662f\u975e\u7ed3\u6784\u5316\u7684\uff0c\u5b58\u5728\u4e00\u5b9a\u7684\u5c40\u9650\u6027\u3002\u5b83\u4eec\u53ef\u80fd\u4e0d\u50cf\u4f20\u7edf\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u90a3\u6837\u63d0\u4f9b\u4e30\u5bcc\u7684\u5bf9\u975e\u5411\u91cf\u5b57\u6bb5\uff08\u4f8b\u5982\uff0c\u5143\u6570\u636e\u6216\u6587\u672c\u63cf\u8ff0\uff09\u7684\u652f\u6301\uff0c\u4e5f\u7f3a\u4e4f\u5bf9\u590d\u6742\u6570\u636e\u5173\u7cfb\u548c\u4e8b\u52a1\u5904\u7406\u7684\u80fd\u529b\uff0c\u4ee5\u53ca\u5728\u6570\u636e\u5b8c\u6574\u6027\u7ea6\u675f\u548c\u5143\u6570\u636e\u7ba1\u7406\u65b9\u9762\u7684\u529f\u80fd\u4e0d\u8db3\u3002\u56e0\u6b64\uff0c\u5411\u91cf\u6570\u636e\u5e93\u53ef\u80fd\u4e0d\u9002\u7528\u4e8e\u9700\u8981\u590d\u6742\u67e5\u8be2\u3001\u591a\u6837\u5316\u6570\u636e\u7c7b\u578b\u652f\u6301\u6216\u5f3a\u6570\u636e\u4e00\u81f4\u6027\u4fdd\u8bc1\u7684\u573a\u666f\u3002
\u800c MatrixOne \u4f5c\u4e3a\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0c\u540c\u65f6\u5177\u5907\u5411\u91cf\u80fd\u529b\uff0c\u80fd\u591f\u63d0\u4f9b\u5f3a\u5927\u7684\u6570\u636e\u7ba1\u7406\u529f\u80fd\u3002MatrixOne \u7ed3\u5408\u4e86\u4f20\u7edf\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4e8b\u52a1\u4e00\u81f4\u6027\u3001\u6570\u636e\u5b8c\u6574\u6027\u3001\u6613\u4e8e\u96c6\u6210\u548c\u4e30\u5bcc\u7684\u5de5\u5177\u751f\u6001\u7cfb\u7edf\u7b49\u4f18\u70b9\uff0c\u540c\u65f6\u589e\u52a0\u4e86\u5bf9\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\u7684\u5b58\u50a8\u548c\u9ad8\u6548\u76f8\u4f3c\u6027\u641c\u7d22\u7684\u80fd\u529b\u3002\u8fd9\u79cd\u7ed3\u5408\u4f7f\u5f97\u6570\u636e\u5e93\u80fd\u591f\u7edf\u4e00\u7ba1\u7406\u548c\u67e5\u8be2\u7ed3\u6784\u5316\u4e0e\u975e\u7ed3\u6784\u5316\u6570\u636e\uff0c\u652f\u6301\u590d\u6742\u7684 AI \u548c\u673a\u5668\u5b66\u4e60\u5e94\u7528\uff0c\u540c\u65f6\u4fdd\u6301\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u6cbb\u7406\uff0c\u964d\u4f4e\u4e86\u7ef4\u62a4\u6210\u672c\u548c\u7cfb\u7edf\u590d\u6742\u6027\uff0c\u4e3a\u73b0\u4ee3\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u7075\u6d3b\u800c\u5168\u9762\u7684\u6570\u636e\u89e3\u51b3\u65b9\u6848\u3002
Matrixone \u76ee\u524d\u652f\u6301 float32
\u53ca float64
\u7c7b\u578b\u7684\u5411\u91cf\uff0c\u5206\u522b\u79f0\u4e4b\u4e3a vecf32
\u4e0e vecf64
\u800c\u4e0d\u652f\u6301\u5b57\u7b26\u4e32\u7c7b\u578b\u548c\u6574\u578b\u7c7b\u578b\u7684\u6570\u5b57\u3002
\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\uff1a\u5728\u5c06\u5411\u91cf\u4ece\u4e00\u79cd\u7c7b\u578b\u8f6c\u6362\u4e3a\u53e6\u4e00\u79cd\u7c7b\u578b\u65f6\uff0c\u5efa\u8bae\u540c\u65f6\u6307\u5b9a\u7ef4\u5ea6\u3002\u4f8b\u5982\uff1a
SELECT b + CAST(\"[1,2,3]\" AS vecf32(3)) FROM t1;\n
\u8fd9\u79cd\u505a\u6cd5\u786e\u4fdd\u4e86\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\u7684\u51c6\u786e\u6027\u548c\u4e00\u81f4\u6027\u3002
\u4f7f\u7528\u4e8c\u8fdb\u5236\u683c\u5f0f\uff1a\u4e3a\u4e86\u63d0\u9ad8\u6574\u4f53\u63d2\u5165\u6027\u80fd\uff0c\u8003\u8651\u4f7f\u7528\u4e8c\u8fdb\u5236\u683c\u5f0f\u800c\u4e0d\u662f\u6587\u672c\u683c\u5f0f\u3002\u5728\u8f6c\u6362\u4e3a\u5341\u516d\u8fdb\u5236\u7f16\u7801\u4e4b\u524d\uff0c\u786e\u4fdd\u6570\u7ec4\u91c7\u7528\u5c0f\u7aef\u5e8f\u683c\u5f0f\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b Python \u4ee3\u7801\uff1a
import binascii\n\n# 'value' \u662f\u4e00\u4e2a NumPy \u5bf9\u8c61\ndef to_binary(value):\n if value is None:\n return value\n\n # \u5c0f\u7aef\u5e8f\u6d6e\u70b9\u6570\u7ec4\n value = np.asarray(value, dtype='<f')\n\n if value.ndim != 1:\n raise ValueError('\u671f\u671b ndim \u4e3a 1')\n\n return binascii.b2a_hex(value)\n
\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6570\u636e\u63d2\u5165\u7684\u6548\u7387\u3002
\u6784\u5efa RAG \u5e94\u7528\uff1a\u8be6\u60c5\u8bf7\u67e5\u770b\u5e94\u7528\u5f00\u53d1\u793a\u4f8b\u4e2d\u7684 RAG \u5e94\u7528\u57fa\u7840\u793a\u4f8b\u3002
\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\uff1a\u8be6\u60c5\u8bf7\u67e5\u770b\u5e94\u7528\u5f00\u53d1\u793a\u4f8b\u4e2d\u7684\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\u57fa\u7840\u793a\u4f8b\u3002
\u5411\u91cf\u6570\u636e\u7c7b\u578b
"},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/","title":"\u914d\u7f6e MatrixOne SSL","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#_1","title":"\u6982\u8ff0","text":"\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u914d\u7f6e SSL \u5b89\u5168\u8fde\u63a5 MatrixOne \u670d\u52a1\u5668\u3002\u5728\u4f20\u9001\u4fe1\u606f\u65f6\uff0c\u91c7\u7528 SSL \u8fde\u63a5\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u907f\u514d\u6076\u610f\u7528\u6237\u62e6\u622a\u4f60\u7684\u6d41\u91cf\u3002
"},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#matrixone-ssl_1","title":"\u914d\u7f6e MatrixOne SSL \u8fde\u63a5","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#ssl","title":"\u65b0\u5efa\u76ee\u5f55\u5b58\u50a8 SSL \u5bc6\u94a5","text":"\u521b\u5efa\u5305\u542b SSL \u5bc6\u94a5\u7684\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u901a\u8fc7 SSH \u767b\u5f55 MatrixOne \u670d\u52a1\uff0c\u5148\u786e\u8ba4\u4f60\u5df2\u5b89\u88c5 mysql_ssl_rsa_setup
\u5de5\u5177\u3002\u4e00\u822c\u5982\u679c MySQL \u5b89\u88c5\u5b8c\u6210\u7684\u8bdd\uff0cmysql_ssl_rsa_setup
\u4e5f\u4f1a\u88ab\u4e00\u8d77\u5b89\u88c5\u3002
\u68c0\u67e5\u4f60\u662f\u5426\u5b89\u88c5 mysql_ssl_rsa_setup
\uff1a\u5982\u679c\u4f60\u5df2\u5b89\u88c5 mysql_ssl_rsa_setup
\uff0c\u5728\u547d\u4ee4\u884c\u5de5\u5177\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4e0b\u5217\u7ed3\u679c\uff0c\u5219\u9700\u8981\u91cd\u65b0\u5b89\u88c5 MySQL, \u53ef\u4ee5\u53c2\u89c1 install MySQL\uff0cmysql_ssl_rsa_setup
\u4e5f\u5c06\u4e00\u5e76\u5b89\u88c5\u3002\u53e6\u5916\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7 whereis mysql_ssl_rsa_setup
\u547d\u4ee4\u67e5\u770b mysql_ssl_rsa_setup
\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002
[pcusername@VM-0-12-centos matrixone]$ mysql_ssl_rsa_setup\n2022-10-19 10:57:30 [ERROR] Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. Supplied value : /var/lib/mysql\n[pcusername@VM-0-12-centos matrixone]$ whereis mysql_ssl_rsa_setup\nmysql_ssl_rsa_setup: /usr/bin/mysql_ssl_rsa_setup /usr/share/man/man1/mysql_ssl_rsa_setup.1.gz\n
\u521b\u5efa\u4e00\u4e2a MatrixOne \u53ef\u4ee5\u8bbf\u95ee\u7684 SSL \u5bc6\u94a5\u5b58\u50a8\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u6267\u884c\u547d\u4ee4 mkdir /home/user/mo_keys
\u521b\u5efa\u76ee\u5f55 mo_keys\u3002
\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa SSL \u5bc6\u94a5\uff1a
\u8fd0\u884c\u547d\u4ee4\u521b\u5efa CA (Certificate Authority) \u5bc6\u94a5\uff1a
mysql_ssl_rsa_setup --datadir=/home/user/mo_keys\n
\u6587\u4ef6\u5939\u5c06\u521b\u5efa\u4ea7\u751f\u591a\u4e2a. pem \u6587\u4ef6\u3002
/mo_keys \u251c\u2500\u2500 ca-key.pem \u251c\u2500\u2500 ca.pem \u251c\u2500\u2500 client-cert.pem \u251c\u2500\u2500 client-key.pem \u251c\u2500\u2500 private_key.pem \u251c\u2500\u2500 public_key.pem \u251c\u2500\u2500 server-cert.pem \u2514\u2500\u2500 server-key.pem
\u5728 MatrixOne \u76ee\u5f55\u4e0b\u7684 etc/launch-with-proxy/cn.toml \u6587\u4ef6\u5185\u7684 [cn.frontend]
\u90e8\u5206\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u6bb5\uff1a
[cn.frontend]\nenableTls = true\ntlsCertFile = \"/home/user/mo_keys/server-cert.pem\"\ntlsKeyFile = \"/home/user/mo_keys/server-key.pem\"\ntlsCaFile = \"/home/user/mo_keys/ca.pem\"\n
\u5982\u679c [cn.frontend]
\u90e8\u5206\u5728 MatrixOne \u7cfb\u7edf\u8bbe\u7f6e\u6587\u4ef6\u4e2d\u4e0d\u5b58\u5728\uff0c\u4f60\u53ef\u4ee5\u7528\u4e0a\u8ff0\u8bbe\u7f6e\u521b\u5efa\u4e00\u4e2a\u3002
\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff0c\u6d4b\u8bd5\u6d4b\u8bd5 SSL \u914d\u7f6e\u662f\u5426\u6210\u529f\uff1a
\u5355\u673a\u90e8\u7f72 MatrixOne \u670d\u52a1\uff0c\u5177\u4f53\u6b65\u9aa4\uff0c\u53c2\u89c1\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4 1 \u4e2d\u5355\u673a\u90e8\u7f72 MatriOne \u670d\u52a1\u5e76\u8fde\u63a5\u6210\u529f\u540e\uff0c\u8fd0\u884c status
\u547d\u4ee4\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
mysql> status\n--------------\nmysql Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)\n\nConnection id: 1001\nCurrent database:\nCurrent user: root@0.0.0.0\nSSL: Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager: stdout\nUsing outfile: ''\nUsing delimiter: ;\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\nProtocol version: 10\nConnection: 127.0.0.1 via TCP/IP\nClient characterset: utf8mb4\nServer characterset: utf8mb4\nTCP port: 6002\nBinary data as: Hexadecimal\n--------------\n
MatrixOne \u652f\u6301 C# \u8fde\u63a5\uff0c\u5e76\u4e14\u652f\u6301 MySQL Connector/NET \u9a71\u52a8\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 C# \u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne
\u5df2\u5b89\u88c5. NET Core SDK
\u5df2\u5b89\u88c5 MySQL Client
\u4f7f\u7528 dotnet \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63a7\u5236\u53f0\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a myapp \u7684\u65b0\u5e94\u7528\uff1a
dotnet new console -o myapp\n
\u968f\u540e\u5207\u6362\u5230 myapp \u76ee\u5f55\u4e0b
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#mysql-connectornet-nuget","title":"\u6b65\u9aa4\u4e8c\uff1a\u6dfb\u52a0 MySQL Connector/NET NuGet \u5305","text":"\u4f7f\u7528 NuGet \u5305\u7ba1\u7406\u5668\u5b89\u88c5 MySql.Data \u5305\uff1a
dotnet add package MySql.Data\n
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#matrixone","title":"\u6b65\u9aa4\u4e09\uff1a\u8fde\u63a5 Matrixone","text":"\u5728 Program.cs \u6587\u4ef6\u4e2d\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a
using System;\nusing MySql.Data.MySqlClient;\n\nclass Program\n{\n static void Main(string[] args)\n {\n Program n =new Program();\n string connectionString = \"server=127.0.0.1;user=root;database=test;port=6001;password=111\";\n using (MySqlConnection connection = new MySqlConnection(connectionString))\n {\n try{\n connection.Open();\n Console.WriteLine(\"\u6210\u529f\u5efa\u7acb\u8fde\u63a5\");\n }\n catch (MySqlException ex)\n {\n Console.WriteLine(ex.Message);\n }\n finally\n {\n connection.Close();\n }\n }\n }\n}\n
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#_2","title":"\u6b65\u9aa4\u56db\uff1a\u8fd0\u884c\u7a0b\u5e8f","text":"\u5728\u7ec8\u7aef\u6267\u884c\u547d\u4ee4 dotnet run
\uff1a
(base) admin@admindeMacBook-Pro myapp % dotnet run \n\u6210\u529f\u5efa\u7acb\u8fde\u63a5\n
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#_3","title":"\u53c2\u8003\u6587\u6863","text":"\u5173\u4e8e\u4f7f\u7528 C# \u901a\u8fc7 MatrixOne \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u7684\u793a\u4f8b\uff0c\u53c2\u89c1 C# \u57fa\u7840\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/","title":"Golang \u8fde\u63a5","text":"MatrixOne \u652f\u6301 Golang \u8fde\u63a5\uff0c\u5e76\u4e14\u652f\u6301 Go-MySQL-Driver
\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 Golang \u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b89\u88c5 Golang 1.18 \u7248\u672c\u53ca\u4ee5\u4e0a\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u70b9\u51fb Golang 1.18 \u7248\u672c\u53ca\u4ee5\u4e0a\u81f3\u5b98\u65b9\u7f51\u7ad9\u8fdb\u884c\u4e0b\u8f7d\u5b89\u88c5\uff1b\u5982\u679c\u4f60\u5df2\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u68c0\u67e5\u7248\u672c\uff1a
#\u68c0\u67e5 Golang \u7248\u672c\u53f7\uff0c\u786e\u8ba4\u662f\u5426\u5b89\u88c5\ngo version\n
\u5df2\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u70b9\u51fb MySQL \u5ba2\u6237\u7aef\u81f3\u5b98\u65b9\u7f51\u7ad9\u8fdb\u884c\u4e0b\u8f7d\u5b89\u88c5\u3002
\u5df2\u5b89\u88c5 Git \u5de5\u5177\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u70b9\u51fb Git \u81f3\u5b98\u65b9\u7f51\u7ad9\u8fdb\u884c\u4e0b\u8f7d\u5b89\u88c5\u3002
Go-MySQL-Driver
\u662f\u4e00\u4e2a\u7528\u4e8e Go \u8bed\u8a00\u7684 MySQL \u9a71\u52a8\u7a0b\u5e8f\uff0c\u5b83\u5b9e\u73b0\u4e86 Go \u6807\u51c6\u5e93\u4e2d database/sql \u63a5\u53e3\u7684\u65b9\u6cd5\uff0c\u4f7f\u5f97 Go \u8bed\u8a00\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u9a71\u52a8\u7a0b\u5e8f\u8fde\u63a5\u548c\u64cd\u4f5c MySQL \u6570\u636e\u5e93\u3002
\u5b89\u88c5 Go-MySQL-Driver
\u5de5\u5177\uff1a
\u4f7f\u7528 Go Tool \u5c06 Go-MySQL-Driver
\u5305\u5b89\u88c5\u5230\u4f60\u7684 $GOPATH\u3002
\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u5b89\u88c5 Go-MySQL-Driver
\u5de5\u5177\uff1a
> go get -u github.com/go-sql-driver/mysql\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 golang_connect_matrixone.go \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
package main\n\nimport (\n\"database/sql\"\n\"fmt\"\n_ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n//\"username:password@[protocol](address:port)/database\"\ndb, _ := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\") // Set database connection\ndefer db.Close() //Close DB\nerr := db.Ping() //Connect to DB\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\nreturn\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\n}\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
> go run golang_connect_matrixone.go\nDatabase Connection Succeed\n
gorm
\u662f\u4e00\u4e2a\u57fa\u4e8e golang \u7684\u4e00\u4e2a\u795e\u5947\u7684\u5168\u529f\u80fd ORM \u5e93\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 gorm.io/gorm
\u548c gorm.io/driver/mysql
\u8fd9\u4e24\u4e2a\u5e93\u6765\u8ba9 Go \u8fde\u63a5\u5230 MYSQL \u6570\u636e\u5e93\u3002
gorm.io/gorm
\u548c gorm.io/driver/mysql
\u5e93\uff0c\u4f7f\u7528 go get
\u547d\u4ee4\u5b89\u88c5\uff1ago get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u6587\u672c\u6587\u4ef6 golang_gorm_connect_matrixone.go \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
package main\nimport (\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"fmt\"\n)\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO \ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ })\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\nfunc main() {\ngetDBConn()\n}\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
> go run golang_gorm_connect_matrixone.go\nDatabase Connection Succeed\n
\u5173\u4e8e\u4f7f\u7528 Golang \u901a\u8fc7 MatrixOne \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u7684\u793a\u4f8b\uff0c\u53c2\u89c1 Golang \u57fa\u7840\u793a\u4f8b\u3002
\u5173\u4e8e\u4f7f\u7528 Gorm \u901a\u8fc7 MatrixOne \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u7684\u793a\u4f8b\uff0c\u53c2\u89c1 Gorm \u57fa\u7840\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/","title":"\u5ba2\u6237\u7aef\u5de5\u5177\u8fde\u63a5","text":"MatrixOne \u73b0\u5728\u652f\u6301\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u6570\u636e\u5e93\u5ba2\u6237\u7aef\u5de5\u5177\u7684\u65b9\u5f0f\u8fde\u63a5 MatrixOne \u670d\u52a1\uff1a
\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#mysql-client-matrixone","title":"\u901a\u8fc7 MySQL Client \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4e0b\u8f7d\u5b89\u88c5 MySQL Client\u3002
\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u6765\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
mysql -h IP -P PORT -uUsername -p\n
\u8fde\u63a5\u7b26\u7684\u683c\u5f0f\u4e0e MySQL \u683c\u5f0f\u76f8\u540c\uff0c\u4f60\u9700\u8981\u63d0\u4f9b\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002
\u6b64\u5904\u4ee5\u5185\u7f6e\u5e10\u53f7\u4f5c\u4e3a\u793a\u4f8b\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password:\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u8fde\u63a5\u6210\u529f\u63d0\u793a\u5982\u4e0b\uff1a
Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 1031\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\nCopyright (c) 2000, 2022, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n
\u66f4\u591a\u5173\u4e8e\u5b89\u88c5\u90e8\u7f72\u7684\u95ee\u9898\uff0c\u53c2\u89c1\u90e8\u7f72\u5e38\u89c1\u95ee\u9898\u3002
Note
MatrixOne \u4e0e\u5ba2\u6237\u7aef\u9ed8\u8ba4\u662f\u975e\u52a0\u5bc6\u4f20\u8f93\uff0c\u5982\u679c\u9700\u8981\u5f00\u542f\u52a0\u5bc6\u4f20\u8f93\u8bf7\u53c2\u89c1\u6570\u636e\u4f20\u8f93\u52a0\u5bc6\u3002
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#navicat-matrixone","title":"\u901a\u8fc7 Navicat \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4e0b\u8f7d\u5b89\u88c5 Navicat\u3002
\u5b89\u88c5 Navicat \u5b8c\u6210\u540e\uff0c\u6253\u5f00 Navicat\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2 Connection > MySQL\uff0c\u5728\u5f39\u7a97\u4e2d\u586b\u5165\u5982\u4e0b\u53c2\u6570\uff1a
\u70b9\u51fb Save \u4fdd\u5b58\u8bbe\u7f6e\u3002
\u53cc\u51fb\u5de6\u4fa7\u6570\u636e\u5e93\u76ee\u5f55\u4e2d\u7684 MatrixOne\uff0c\u56fe\u6807\u70b9\u4eae\uff0c\u8fde\u63a5\u6210\u529f\u3002
\u8fde\u63a5\u5230 MatrixOne \u540e\uff0c\u5728\u5de6\u4fa7\u6570\u636e\u5e93\u76ee\u5f55\u680f\uff0c\u4f60\u5c06\u770b\u5230 6 \u4e2a\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93\uff1a
\u53f3\u4fa7\u7a97\u53e3\u53ef\u67e5\u770b\u6709\u5173\u6b64\u8fde\u63a5\u7684\u57fa\u672c\u4fe1\u606f\uff1a
<div align=\"center\">\n<img src=https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/artwork/docs/develop/navicat-connection.png width=50% heigth=50%/>\n</div>\n
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#dbeaver-matrixone","title":"\u901a\u8fc7 DBeaver \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4e0b\u8f7d\u5b89\u88c5 DBeaver\u3002
\u5b89\u88c5 DBeaver \u5b8c\u6210\u540e\uff0c\u6253\u5f00 DBeaver\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2\u8fde\u63a5\u56fe\u6807\uff0c\u5728\u5f39\u7a97\u4e2d\u9009\u62e9 MySQL\uff0c\u70b9\u51fb Next\u3002
\u5728 Connect to a database \u7a97\u53e3\u7684 Main \u533a\u4e2d\u586b\u5199\u5982\u4e0b\u53c2\u6570\uff1a
\u53cc\u51fb\u5de6\u4fa7\u76ee\u5f55\u4e2d\u7684 MatrixOne\uff0c\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002\u4f60\u53ef\u4ee5\u5728\u5de6\u4fa7\u76ee\u5f55\u6811\u4e2d\u770b\u5230\u9ed8\u8ba4\u7684\u56db\u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\uff1a
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cDBeaver \u4e2d\u4e0d\u5c55\u793a\u89c6\u56fe\u3002\u5982\u9700\u663e\u793a\u5b8c\u6574\u7684\u7cfb\u7edf\u6570\u636e\u5e93\uff0c\u4f60\u53ef\u4ee5\u53f3\u952e\u5355\u51fb MatrixOne\uff0c\u9009\u62e9 Connection view \u5e76\u6253\u5f00 Show system objects\uff1a
\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u4f60\u5c06\u770b\u5230 6 \u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\u3002
MatrixOne \u652f\u6301 Python \u8fde\u63a5\uff0c\u652f\u6301 pymysql
\u548c sqlalchemy
\u4e24\u79cd\u9a71\u52a8\u7a0b\u5e8f\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4e86\u89e3\u5982\u4f55\u901a\u8fc7\u8fd9\u4e24\u4e2a python \u9a71\u52a8\u7a0b\u5e8f\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b89\u88c5 Python 3.8(or plus) version\u3002
#\u68c0\u67e5 Python \u7248\u672c\u53f7\uff0c\u786e\u8ba4\u662f\u5426\u5b89\u88c5\npython3 -V\n
PyMySQL \u662f\u4e00\u4e2a\u7eaf Python MySQL \u5ba2\u6237\u7aef\u5e93\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql \u548c cryptography \u5de5\u5177\uff1a
pip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 pymysql_connect_matrixone.py \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
#!/usr/bin/python3\n\nimport pymysql\n\n# Open database connection\ndb = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n )\n# prepare a cursor object using cursor() method\ncursor = db.cursor()\n\n# execute SQL query using execute() method.\ncursor.execute(\"SELECT VERSION()\")\n\n# Fetch a single row using fetchone() method.\ndata = cursor.fetchone()\nprint (\"Database version : %s \" % data)\n\n# disconnect from server\ndb.close()\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
> python3 pymysql_connect_matrixone.py\nDatabase version : 8.0.30-MatrixOne-v1.2.1\n
SQLAlchemy \u662f Python SQL \u5de5\u5177\u5305\u548c\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668 (ORM)\uff0c\u5b83\u4e3a\u5e94\u7528\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u4e86 SQL \u7684\u5168\u90e8\u529f\u80fd\u3002
\u4e0b\u8f7d\u5e76\u5b89\u88c5 sqlalchemy \u5de5\u5177\uff0c\u4e0b\u8f7d\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
pip3 install sqlalchemy\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff0c\u5e76\u4e14\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a student \u8868\uff0c\u7136\u540e\u63d2\u5165\u4e24\u6761\u6570\u636e\uff1a
mysql> create database test;\nmysql> use test;\nmysql> create table student (name varchar(20), age int);\nmysql> insert into student values (\"tom\", 11), (\"alice\", \"10\");\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 sqlalchemy_connect_matrixone.py \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
#!/usr/bin/python3\nfrom sqlalchemy import create_engine, text\n\n# Open database connection\nmy_conn = create_engine(\"mysql+mysqldb://root:111@127.0.0.1:6001/test\")\n\n# execute SQL query using execute() method.\nquery=text(\"SELECT * FROM student LIMIT 0,10\")\nmy_data=my_conn.execute(query)\n\n# print SQL result\nfor row in my_data:\n print(\"name:\", row[\"name\"])\n print(\"age:\", row[\"age\"])\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
python3 sqlalchemy_connect_matrixone.py\nname: tom\nage: 11\nname: alice\nage: 10\n
\u5728 Java \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 Java \u4ee3\u7801\u4f7f\u7528 JDBC \u8fde\u63a5\u5668\uff08Java Database Connectivity\uff09\u8fde\u63a5\u5230 MatrixOne\u3002JDBC \u662f\u7528\u4e8e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u6807\u51c6 API \u4e4b\u4e00\uff0c\u4f7f\u7528\u5b83\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u8fd0\u884c SQL \u8bed\u53e5\u5e76\u4e14\u4ece\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f7f\u7528 JDBC \u8fde\u63a5 MatrixOne \u524d\uff0c\u9700\u8981\u5b8c\u6210\u4ee5\u4e0b\u4e0b\u8f7d\u5b89\u88c5\u4efb\u52a1\uff1a
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u5728 MatrixOne \u65b0\u5efa\u4e00\u4e2a\u540d\u4e3a test \u6570\u636e\u5e93\u548c\u4e00\u4e2a\u65b0\u7684\u8868 t1\uff1a
create database test;\nuse test;\ncreate table t1\n(\ncode int primary key,\ntitle char(35)\n);\n
\u5728 IDEA \u4e2d\u65b0\u5efa Java \u540d\u79f0\u4e3a testJDBC \u7684\u9879\u76ee\u5e76\u9009\u62e9\u5728 Build System \u4e2d\u9009\u62e9 Maven \u4f5c\u4e3a\u6784\u5efa\u7cfb\u7edf\uff0c\u70b9\u51fb Create\u3002
\u70b9\u51fb File > Project Structure\uff0c\u8fdb\u5165\u5230 Project Setting\uff0c\u70b9\u9009 Library\uff0c\u5e76\u70b9\u51fb + \u6309\u94ae\uff0c\u6dfb\u52a0 From Maven\u3002
\u8f93\u5165\u6846\u4e2d\u8f93\u5165 mysql-connector-java \u641c\u7d22\u6574\u4e2a\u5e93\uff0c\u9009\u62e9 mysql:mysql-connector-java:8.0.30\uff0c\u5e94\u7528\u5230\u672c\u9879\u76ee\u4e2d\u3002
\u4fee\u6539 src/main/java/org/example/Main.java \u4e2d\u7684\u9ed8\u8ba4 Java \u6e90\u4ee3\u7801\u3002\u5982\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\u6240\u793a\uff0c\u8fd9\u6bb5\u4ee3\u7801\u4f7f\u7528\u8fde\u63a5\u5730\u5740\u548c\u51ed\u636e\u521b\u5efa\u8fde\u63a5\u3002\u8fde\u63a5\u5230 MatrixOne \u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 Java \u8bed\u8a00\u5bf9 MatrixOne \u6570\u636e\u5e93\u548c\u8868\u8fdb\u884c\u64cd\u4f5c\u3002
\u6709\u5173\u5982\u4f55\u4f7f\u7528 JDBC \u5728 MatrixOne \u4e2d\u5f00\u53d1 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u5e94\u7528\u7a0b\u5e8f\u7684\u5b8c\u6574\u793a\u4f8b\uff0c\u53c2\u8003 Java CRUD \u793a\u4f8b\u3002
package org.example;\n\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\n\n\npublic class Main {\n\n\n private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n private static String jdbcUsername = \"root\";\n private static String jdbcPassword = \"111\";\n\n public static void main(String[] args) {\n\n\n try {\n Connection connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n // Do something with the Connection\n\n } catch (SQLException ex) {\n // handle any errors\n System.out.println(\"SQLException: \" + ex.getMessage());\n System.out.println(\"SQLState: \" + ex.getSQLState());\n System.out.println(\"VendorError: \" + ex.getErrorCode());\n }\n }\n}\n
\u6709\u5173 MatrixOne \u5bf9 JDBC \u7279\u6027\u652f\u6301\u7684\u5b8c\u6574\u5217\u8868\uff0c\u53c2\u89c1 MatrixOne \u7684 JDBC \u529f\u80fd\u652f\u6301\u5217\u8868\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/","title":"\u4f7f\u7528 Java ORMs \u8fde\u63a5","text":"\u9664\u4e86\u4f7f\u7528 JDBC \u8fde\u63a5 MatrixOne \u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04 (ORM) \u6846\u67b6\u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\u3002\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528 Spring Data JPA \u548c MyBatis \u8fde\u63a5\u5230 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#mybatis","title":"MyBatis","text":"MyBatis \u662f SQL \u6620\u5c04\u6846\u67b6\uff0c\u5b83\u7684\u4f18\u70b9\u662f\u7b80\u5355\u6613\u7528\u3002\u4f60\u53ef\u4ee5\u53c2\u8003 SpringBoot \u548c MyBatis CRUD \u793a\u4f8b\u5b8c\u6574\u6559\u7a0b\u5b66\u4e60\u5982\u4f55\u6784\u5efa\u4e00\u4e2a CRUD \u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u5c06\u91cd\u70b9\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 MatrixOne \u914d\u7f6e MyBatis\u3002
\u4e0b\u9762\u7684\u793a\u4f8b\u662f Maven \u6784\u5efa\u7cfb\u7edf\u7684\u5178\u578b\u8bbe\u7f6e\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-pomxml-mybatis-spring-boot-starter","title":"1. \u5728 Pom.xml \u4e2d\u6dfb\u52a0 MyBatis-Spring-Boot-Starter","text":"\u5728 Spring Boot \u4e0a\u6784\u5efa MyBatis \u5e94\u7528\u7a0b\u5e8f\uff0c\u4f60\u9700\u8981\u5c06 MyBatis-Spring-Boot-Starter \u6a21\u5757\u6dfb\u52a0\u5230 pom.xml \u4e2d\uff0cMyBatis-Spring-Boot-Starter \u6a21\u5757\u5219\u662f\u5728\u9009\u62e9 Maven \u9879\u76ee\u65f6\u8fdb\u884c\u521b\u5efa\u7684\u3002
<dependency>\n <groupId>org.mybatis.spring.boot</groupId>\n <artifactId>mybatis-spring-boot-starter</artifactId>\n <version>2.1.4</version>\n</dependency>\n
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2","title":"2. \u6dfb\u52a0\u914d\u7f6e","text":"\u5728 application.properties
\u4e2d\u9700\u8981\u4fee\u6539\u7684\u53c2\u6570\u5982\u4e0b\uff0c\u5176\u4f59\u53c2\u6570\u53ef\u4ee5\u4fdd\u5b58\u9ed8\u8ba4\u503c\uff1a
spring.datasource.driver-class-name
\uff1aMySQL \u8fde\u63a5\u5668\u7684\u9a71\u52a8\u7a0b\u5e8f\u540d\u79f0\u3002spring.datasource.url
\uff1aJDBC \u8fde\u63a5 URL \u53c2\u6570\u3002spring.datasource.username
\uff1a\u6570\u636e\u5e93\u7528\u6237\u540d\u3002spring.datasource.password
\uff1a\u6570\u636e\u5e93\u5bc6\u7801\u3002mybatis.mapper-locations
\uff1aMapper XML \u914d\u7f6e\u6587\u4ef6\u7684\u4f4d\u7f6e\u3002MatrixOne \u4e2d\u63a8\u8350\u914d\u7f6e\u5982\u4e0b\uff1a
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nmybatis.mapper-locations=classpath:mapping/*xml\n
Note
\u9700\u8981\u4f7f\u7528\u63a8\u8350\u914d\u7f6e\u7684 JDBC \u8fde\u63a5 URL\uff0c\u5426\u5219\u5c06\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#spring-data-jpa","title":"Spring Data JPA","text":"Spring Data JPA \u662f Spring \u57fa\u4e8e ORM \u6846\u67b6\u3001JPA \u89c4\u8303\u7684\u57fa\u7840\u4e0a\u5c01\u88c5\u7684\u4e00\u5957 JPA \u5e94\u7528\u6846\u67b6\uff0c\u53ef\u4f7f\u5f00\u53d1\u8005\u7528\u6781\u7b80\u7684\u4ee3\u7801\u5373\u53ef\u5b9e\u73b0\u5bf9\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\uff0c\u5b83\u6709\u52a9\u4e8e\u51cf\u5c11\u6837\u677f\u4ee3\u7801\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u79cd\u901a\u8fc7\u51e0\u4e2a\u9884\u5b9a\u4e49\u7684\u5b58\u50a8\u5e93\u63a5\u53e3\u4e4b\u4e00\u5b9e\u73b0\u57fa\u672c CRUD \u64cd\u4f5c\u7684\u673a\u5236\uff0c\u5e76\u4e14\u5b83\u4e5f\u63d0\u4f9b\u4e86\u5305\u62ec\u589e\u5220\u6539\u67e5\u7b49\u5728\u5185\u7684\u5e38\u7528\u529f\u80fd\uff0c\u4e14\u6613\u4e8e\u6269\u5c55\u3002
Spring Data JPA \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5e94\u7528\u6846\u67b6\uff0c\u5b83\u6709\u52a9\u4e8e\u51cf\u5c11\u6837\u677f\u4ee3\u7801\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u79cd\u901a\u8fc7\u51e0\u4e2a\u9884\u5b9a\u4e49\u7684\u5b58\u50a8\u5e93\u63a5\u53e3\u4e4b\u4e00\u5b9e\u73b0\u57fa\u672c CRUD \u64cd\u4f5c\u7684\u673a\u5236\u3002\u4f60\u53ef\u4ee5\u53c2\u8003 SpringBoot \u548c Hibernate CRUD \u793a\u4f8b\u5b8c\u6574\u6559\u7a0b\u5b66\u4e60\u5982\u4f55\u6784\u5efa CRUD \u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u5c06\u91cd\u70b9\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 MatrixOne \u8fde\u63a5\u914d\u7f6e Spring JPA\u3002
\u4e0b\u9762\u7684\u793a\u4f8b\u662f Maven \u6784\u5efa\u7cfb\u7edf\u7684\u5178\u578b\u8bbe\u7f6e\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-pomxml-spring-boot-starter-data-jpa","title":"1. \u5728 Pom.xml \u4e2d\u6dfb\u52a0 spring-boot-starter-data-jpa","text":"\u5728 Spring Boot \u4e0a\u6784\u5efa Spring Data JPA \u5e94\u7528\u7a0b\u5e8f\uff0c\u4f60\u9700\u8981\u5c06 spring-boot-starter-data-jpa \u6a21\u5757\u6dfb\u52a0\u5230 pom.xml \u4e2d\uff0cspring-boot-starter-data-jpa \u6a21\u5757\u5219\u662f\u5728\u9009\u62e9 Maven \u9879\u76ee\u65f6\u8fdb\u884c\u521b\u5efa\u7684\u3002
<dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-data-jpa</artifactId>\n</dependency>\n
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2_1","title":"2. \u6dfb\u52a0\u914d\u7f6e","text":"\u5728 application.properties
\u4e2d\u9700\u8981\u4fee\u6539\u7684\u53c2\u6570\u5982\u4e0b\uff0c\u5176\u4f59\u53c2\u6570\u53ef\u4ee5\u4fdd\u5b58\u9ed8\u8ba4\u503c\uff1a
spring.datasource.driver-class-name
\uff1aMySQL \u8fde\u63a5\u5668\u7684\u9a71\u52a8\u7a0b\u5e8f\u540d\u79f0\u3002spring.datasource.url
\uff1aJDBC \u8fde\u63a5 URL \u53c2\u6570\u3002spring.datasource.username
\uff1a\u6570\u636e\u5e93\u7528\u6237\u540d\u3002spring.datasource.password
\uff1a\u6570\u636e\u5e93\u5bc6\u7801\u3002spring.jpa.properties.hibernate.dialect
\uff1aSQL dialect\uff08\u5373 SQL \u65b9\u8a00\uff09\u4f7f Hibernate \u4e3a\u6240\u9009\u6570\u636e\u5e93\u751f\u6210\u66f4\u597d\u7684 SQL\u3002MatrixOne \u5f53\u524d\u4ec5\u652f\u6301 org.hibernate.dialect.MySQLDialect
\u3002
spring.jpa.hibernate.ddl-auto
\uff1aspring.jpa.hibernate.ddl-auto
\u5c5e\u6027\u91c7\u7528\u4e00\u4e2a\u679a\u4e3e\uff0c\u8be5\u679a\u4e3e\u4ee5\u66f4\u53ef\u63a7\u7684\u65b9\u5f0f\u63a7\u5236\u6a21\u5f0f\u751f\u6210\u3002\u53ef\u80fd\u7684\u9009\u9879\u548c\u6548\u679c\u5982\u4e0b\u8868\u6240\u793a\u3002MatrixOne \u5f53\u524d\u4ec5\u652f\u6301 none \u548c validate\u3002
MatrixOne \u4e2d\u63a8\u8350\u914d\u7f6e\u5982\u4e0b\uff1a
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.hibernate.ddl-auto = validate\n
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/","title":"\u4f7f\u7528 BITMAP \u5bf9\u6570\u636e\u53bb\u91cd","text":"Matrixone \u652f\u6301\u4f7f\u7528 BITMAP
\u5904\u7406\u4e0d\u540c\u503c\uff08distinct values\uff09\u7684\u8ba1\u6570\u3002
\u672c\u7bc7\u6587\u7ae0\u5c06\u4ecb\u7ecd BITMAP
\u7684\u4e00\u4e9b\u5e94\u7528\u573a\u666f\u548c\u6848\u4f8b\u3002
\u5728 MatrixOne \u4e2d\uff0cBITMAP
\u7528\u4e8e\u4f18\u5316\u7279\u5b9a\u7c7b\u578b\u7684\u67e5\u8be2\u64cd\u4f5c\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5177\u6709\u4f4e\u57fa\u6570\uff08low cardinality\uff09\u7684\u5217\u65f6\uff0c\u5e2e\u52a9\u7528\u6237\u5728\u5927\u6570\u636e\u73af\u5883\u4e2d\u5b9e\u73b0\u4e86\u5feb\u901f\u7684\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b BITMAP
\u7684\u4f7f\u7528\u573a\u666f\uff1a
\u7528\u6237\u884c\u4e3a\u5206\u6790\uff1a\u5047\u8bbe\u4e00\u4e2a\u7535\u5546\u5e73\u53f0\u60f3\u8981\u5206\u6790\u4e0d\u540c\u7528\u6237\u7684\u884c\u4e3a\u6a21\u5f0f\u3002\u4ed6\u4eec\u6709\u4e00\u4e2a\u4e8b\u4ef6\u8868\uff0c\u8bb0\u5f55\u4e86\u7528\u6237\u7684\u6bcf\u4e00\u6b21\u70b9\u51fb\u4e8b\u4ef6\uff0c\u5305\u62ec\u7528\u6237 ID\u3001\u65f6\u95f4\u6233\u3001\u4e8b\u4ef6\u7c7b\u578b\u7b49\u3002\u901a\u8fc7\u4f7f\u7528 BITMAP
\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5bf9\u7528\u6237\u7684\u884c\u4e3a\u8fdb\u884c\u5206\u7c7b\u548c\u7edf\u8ba1\uff0c\u4f8b\u5982\uff0c\u627e\u51fa\u6240\u6709\u8fdb\u884c\u8fc7\u201c\u8d2d\u4e70\u201d\u884c\u4e3a\u7684\u7528\u6237\u6570\u91cf\u3002
\u591a\u7ef4\u5ea6\u5206\u6790\uff1a\u5728\u6570\u636e\u4ed3\u5e93\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9\u591a\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u5206\u6790\uff0c\u4f8b\u5982\uff0c\u5206\u6790\u7279\u5b9a\u65f6\u95f4\u6bb5\u5185\u4e0d\u540c\u5730\u533a\u7684\u9500\u552e\u60c5\u51b5\u3002\u901a\u8fc7 BITMAP
\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5bf9\u65e5\u671f\u548c\u5730\u533a\u8fd9\u4e24\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u7b5b\u9009\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002
\u7edf\u8ba1\u4e0d\u540c\u503c\u7684\u6570\u91cf\uff1a\u5728\u5904\u7406\u5177\u6709\u5927\u91cf\u552f\u4e00\u503c\u7684\u5217\u65f6\uff0c\u5982\u4ea7\u54c1\u7c7b\u522b\u6216\u7528\u6237\u72b6\u6001\uff0c\u4f7f\u7528 BITMAP
\u53ef\u4ee5\u9ad8\u6548\u5730\u8ba1\u7b97\u8fd9\u4e9b\u5217\u4e2d\u4e0d\u540c\u503c\u7684\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u793e\u4ea4\u5a92\u4f53\u5e73\u53f0\u53ef\u80fd\u9700\u8981\u7edf\u8ba1\u5176\u7528\u6237\u6d3b\u8dc3\u72b6\u6001\uff08\u5728\u7ebf\u3001\u79bb\u7ebf\uff09\u7684\u4e0d\u540c\u6570\u91cf\u3002
\u5c42\u6b21\u5316\u805a\u5408\u52a0\u901f\uff1a\u5728\u9700\u8981\u8fdb\u884c\u5c42\u6b21\u5316\u805a\u5408\u67e5\u8be2\u65f6\uff0c\u5982\u5bf9\u9500\u552e\u6570\u636e\u8fdb\u884c\u5b63\u5ea6\u548c\u5e74\u5ea6\u6c47\u603b\uff0cBITMAP
\u53ef\u4ee5\u52a0\u901f\u8ba1\u7b97\u8fc7\u7a0b\u3002\u901a\u8fc7\u4f7f\u7528 BITMAP
\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u548c\u805a\u5408\uff0c\u4ece\u800c\u5f97\u5230\u6240\u9700\u7684\u7edf\u8ba1\u4fe1\u606f\u3002
\u4f18\u5316\u590d\u6742\u67e5\u8be2\uff1a\u5bf9\u4e8e\u5305\u542b\u591a\u4e2a\u6761\u4ef6\u7684\u590d\u6742\u67e5\u8be2\uff0cBITMAP
\u53ef\u4ee5\u5feb\u901f\u7b5b\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u91d1\u878d\u516c\u53f8\u53ef\u80fd\u9700\u8981\u627e\u51fa\u540c\u65f6\u6ee1\u8db3\u201c\u9ad8\u51c0\u503c\u5ba2\u6237\u201d\u548c\u201c\u6295\u8d44\u4e8e\u7279\u5b9a\u57fa\u91d1\u201d\u7684\u7528\u6237\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#_3","title":"\u6848\u4f8b","text":"\u6839\u636e\u4e0a\u8ff0\u573a\u666f\u4e00\u8bbe\u8ba1\u6848\u4f8b\uff0c\u5206\u6790\u7535\u5546\u5e73\u53f0\u4e0d\u540c\u7528\u6237\u7684\u884c\u4e3a\u6a21\u5f0f\u3002
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#_4","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/distinct-data/bitmap/#1","title":"1. \u5efa\u7acb\u7528\u6237\u8868\u5e76\u5bfc\u5165\u6570\u636e","text":"\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a user_behavior_table
\u7684\u8868\u4ee5\u53ca\u5bf9\u5e94\u7684 csv \u6570\u636e\uff0c\u8fd9\u4e2a csv \u6570\u636e\u8868\u5171\u6709 39270760 \u884c\u6570\u636e\u3002
CREATE TABLE user_behavior_table(\nuser_id int,--\u7528\u6237 id\nbehavior varchar(100),--\u884c\u4e3a\uff0c\u5305\u62ec browser,purchase,returns\noccur_year varchar(100)--\u884c\u4e3a\u53d1\u751f\u5e74\u4efd\n);\n\nLOAD DATA INFILE '/your_path/user_behavior_table.csv' INTO TABLE user_behavior_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#2","title":"2. \u5b9a\u4e49\u9884\u8ba1\u7b97\u8868","text":"\u628a\u7c97\u7c92\u5ea6\u7684\u8ba1\u7b97\u7ed3\u679c\u4fdd\u5b58\u5728\u9884\u8ba1\u7b97\u8868\u4e2d\uff0c\u540e\u7eed\u5404\u79cd\u4e0d\u540c\u7ef4\u5ea6\u805a\u5408\u53ef\u4ee5\u4f7f\u7528\u9884\u8ba1\u7b97\u8868\u4e2d\u7684\u7ed3\u679c\uff0c\u7ecf\u8fc7\u7b80\u5355\u7684\u8ba1\u7b97\u5c31\u53ef\u4ee5\u5f97\u5230\u7ed3\u679c\uff0c\u52a0\u901f\u67e5\u8be2\u3002
CREATE TABLE precompute AS\nSELECT\nbehavior,\noccur_year,\nBITMAP_BUCKET_NUMBER(user_id) as bucket,\nBITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(user_id)) as bitmap FROM user_behavior_table\nGROUP BY behavior,occur_year,bucket;\n
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#3","title":"3. \u6309\u4e0d\u540c\u7ef4\u5ea6\u805a\u5408\u7b5b\u9009\u6570\u636e","text":"\u8ba1\u7b97\u5728\u7528\u6237\u884c\u4e3a\u548c\u5e74\u4efd\u805a\u5408\u60c5\u51b5\u4e0b user_id \u7684\u53bb\u91cd\u6570\u91cf\uff0c\u53cd\u5e94\u7684\u662f\u5728\u4e0d\u540c\u5e74\u4efd\u8fdb\u884c\u5546\u54c1\u6d4f\u89c8\u3001\u8d2d\u4e70\u548c\u9000\u8d27\u7684\u7528\u6237\u6570\u91cf\u3002
mysql> SELECT\n-> behavior,\n-> occur_year,\n-> SUM(BITMAP_COUNT(bitmap))\n-> FROM precompute\n-> GROUP BY behavior,occur_year;\n+----------+------------+---------------------------+\n| behavior | occur_year | sum(bitmap_count(bitmap)) |\n+----------+------------+---------------------------+\n| browser | 2022 | 939995 |\n| browser | 2023 | 1003173 |\n| purchase | 2022 | 669474 |\n| purchase | 2023 | 660605 |\n| returns | 2023 | 4910 |\n| returns | 2022 | 4350 |\n+----------+------------+---------------------------+\n6 rows in set (0.01 sec)\n\nmysql> select behavior,occur_year,count(distinct user_id) from user_behavior_table group by behavior,occur_year;\n+----------+------------+---------------------------+\n| behavior | occur_year | sum(bitmap_count(bitmap)) |\n+----------+------------+---------------------------+\n| browser | 2022 | 939995 |\n| browser | 2023 | 1003173 |\n| purchase | 2022 | 669474 |\n| purchase | 2023 | 660605 |\n| returns | 2023 | 4910 |\n| returns | 2022 | 4350 |\n+----------+------------+---------------------------+\n6 rows in set (3.26 sec)\n
\u8ba1\u7b97 2022-2023 \u5e74\u8fdb\u884c\u5546\u54c1\u6d4f\u89c8\u3001\u8d2d\u4e70\u548c\u9000\u8d27\u7684\u7528\u6237\u6570\u91cf\u3002
mysql> SELECT behavior, SUM(cnt) FROM (\n-> SELECT\n-> behavior,\n-> BITMAP_COUNT(BITMAP_OR_AGG(bitmap)) cnt\n-> FROM precompute\n-> GROUP BY behavior,bucket\n-> )\n-> GROUP BY behavior;\n+----------+----------+\n| behavior | sum(cnt) |\n+----------+----------+\n| browser | 1003459 |\n| purchase | 780308 |\n| returns | 9260 |\n+----------+----------+\n3 rows in set (0.01 sec)\n\nmysql> select behavior,count(distinct user_id) from user_behavior_table group by behavior;\n+----------+-------------------------+\n| behavior | count(distinct user_id) |\n+----------+-------------------------+\n| browser | 1003459 |\n| purchase | 780308 |\n| returns | 9260 |\n+----------+-------------------------+\n3 rows in set (1.44 sec)\n
\u5bf9\u6bd4\u4e24\u79cd\u67e5\u8be2\u7684\u8fd4\u56de\u65f6\u95f4\uff0c\u663e\u7136\u4f7f\u7528 BITMAP
\u66f4\u9ad8\u6548\u3002\u901a\u8fc7\u4f7f\u7528 BITMAP
\uff0c\u5546\u5bb6\u80fd\u591f\u8fc5\u901f\u5730\u7b5b\u9009\u51fa\u7279\u5b9a\u7c7b\u578b\u7684\u4e8b\u4ef6\uff0c\u4ece\u800c\u7edf\u8ba1\u51fa\u5177\u6709\u67d0\u79cd\u884c\u4e3a\u7684\u7528\u6237\u603b\u6570\u3002
COUNT(DISTINCT)
\u63d0\u4f9b\u4e86\u7cbe\u786e\u7684\u53bb\u91cd\u8ba1\u6570\u7ed3\u679c\uff0c\u4f46\u53ef\u80fd\u5728\u5927\u6570\u636e\u96c6\u4e0a\u6548\u7387\u8f83\u4f4e\u3002\u5982\u9700\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u8bf7\u4f7f\u7528 BITMAP\u3002
\u672c\u7bc7\u6587\u7ae0\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 COUNT(DISTINCT)
\u5bf9\u5c11\u91cf\u6570\u636e\u53bb\u91cd\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/distinct-data/count-distinct/#_2","title":"\u793a\u4f8b","text":"--\u5efa\u7acb orders \u8868\uff0c\u6709 customer_id \u548c product_id \u4e24\u4e2a\u5b57\u6bb5\uff0c\u5206\u522b\u8868\u793a\u5ba2\u6237\u548c\u4ea7\u54c1\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002\nCREATE TABLE orders (\norder_id INT AUTO_INCREMENT PRIMARY KEY,\ncustomer_id INT,\nproduct_id INT,\norder_date DATE,\nquantity INT\n);\n\n--\u63d2\u5165\u4e00\u4e9b\u793a\u4f8b\u6570\u636e\uff1a\nINSERT INTO orders (customer_id, product_id, order_date, quantity)\nVALUES\n(1, 101, '2023-04-01', 2),\n(1, 102, '2023-04-02', 1),\n(2, 101, '2023-04-03', 5),\n(3, 103, '2023-04-04', 3),\n(2, 104, '2023-04-05', 1),\n(4, 101, '2023-04-06', 2),\n(4, 102, '2023-04-07', 1),\n(5, 105, '2023-04-08', 4),\n(1, 101, '2023-04-09', 2);\n\n--\u8ba1\u7b97\u4e0d\u540c\u5ba2\u6237\u7684\u6570\u91cf\uff1a\nmysql> SELECT COUNT(DISTINCT customer_id) AS unique_customer_count FROM orders;\n+-----------------------+\n| unique_customer_count |\n+-----------------------+\n| 5 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n--\u8ba1\u7b97\u4e0d\u540c\u4ea7\u54c1\u7684\u6570\u91cf\uff1a\nmysql> SELECT COUNT(DISTINCT product_id) AS unique_product_count FROM orders;\n+----------------------+\n| unique_product_count |\n+----------------------+\n| 5 |\n+----------------------+\n1 row in set (0.01 sec)\n
\u8fd9\u4e24\u4e2a\u67e5\u8be2\u5c06\u5206\u522b\u8fd4\u56de orders \u8868\u4e2d\u552f\u4e00\u5ba2\u6237\u7684\u6570\u91cf\u548c\u552f\u4e00\u4ea7\u54c1\u7684\u6570\u91cf\u3002\u8fd9\u4e9b\u4fe1\u606f\u5bf9\u4e8e\u5206\u6790\u5ba2\u6237\u591a\u6837\u6027\u548c\u4ea7\u54c1\u9500\u552e\u8303\u56f4\u975e\u5e38\u6709\u7528\u3002
"},{"location":"MatrixOne/Develop/distinct-data/count-distinct/#_3","title":"\u53c2\u8003\u6587\u6863","text":"MatrixOne \u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u5bfc\u51fa\u6570\u636e\uff1a
SELECT INTO...OUTFILE
mo-dump
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 mo-dump
\u5bfc\u51fa\u6570\u636e\u3002
mo-dump
\u662f MatrixOne \u7684\u4e00\u4e2a\u5ba2\u6237\u7aef\u5b9e\u7528\u5de5\u5177\uff0c\u4e0e mysqldump
\u4e00\u6837\uff0c\u5b83\u53ef\u4ee5\u88ab\u7528\u4e8e\u901a\u8fc7\u5bfc\u51fa .sql
\u7c7b\u578b\u7684\u6587\u4ef6\u6765\u5bf9 MatrixOne \u6570\u636e\u5e93\u8fdb\u884c\u5907\u4efd\uff0c\u8be5\u6587\u4ef6\u7c7b\u578b\u5305\u542b\u53ef\u6267\u884c\u4ee5\u91cd\u65b0\u521b\u5efa\u539f\u59cb\u6570\u636e\u5e93\u7684 SQL \u8bed\u53e5\u3002
\u4f7f\u7528 mo-dump
\u5de5\u5177\uff0c\u4f60\u5fc5\u987b\u80fd\u591f\u8bbf\u95ee\u8fd0\u884c MatrixOne \u5b9e\u4f8b\u7684\u670d\u52a1\u5668\u3002\u4f60\u8fd8\u5fc5\u987b\u62e5\u6709\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u7684\u7528\u6237\u6743\u9650\u3002
./mo-dump -u ${user} -p ${password} \\\n-h ${host} -P ${port} -db ${database}\\\n[--local-infile=true] [-csv]\\\n[-no-data] [-tbl ${table}...]\\\n-net-buffer-length ${net-buffer-length} > {importStatement.sql}\n
\u53c2\u6570\u91ca\u4e49
-u [user]\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1\u5668\u7684\u7528\u6237\u540d\u3002\u53ea\u6709\u5177\u6709\u6570\u636e\u5e93\u548c\u8868\u8bfb\u53d6\u6743\u9650\u7684\u7528\u6237\u624d\u80fd\u4f7f\u7528 mo-dump
\u5b9e\u7528\u7a0b\u5e8f\uff0c\u9ed8\u8ba4\u503c dump
\u3002
-p [password]\uff1aMatrixOne \u7528\u6237\u7684\u6709\u6548\u5bc6\u7801\u3002\u9ed8\u8ba4\u503c\uff1a111
\u3002
-h [host]\uff1aMatrixOne \u670d\u52a1\u5668\u7684\u4e3b\u673a IP \u5730\u5740\u3002\u9ed8\u8ba4\u503c\uff1a127.0.0.1
\u3002
-P [port]\uff1aMatrixOne \u670d\u52a1\u5668\u7684\u7aef\u53e3\u3002\u9ed8\u8ba4\u503c\uff1a6001
\u3002
-db [databaseName]\uff1a\u5fc5\u9700\u53c2\u6570\u3002\u8981\u5907\u4efd\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a\u6570\u636e\u5e93\uff0c\u6570\u636e\u5e93\u540d\u79f0\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002
-net-buffer-length [\u6570\u636e\u5305\u5927\u5c0f]\uff1a\u6570\u636e\u5305\u5927\u5c0f\uff0c\u5373 SQL \u8bed\u53e5\u5b57\u7b26\u7684\u603b\u5927\u5c0f\u3002\u6570\u636e\u5305\u662f SQL \u5bfc\u51fa\u6570\u636e\u7684\u57fa\u672c\u5355\u4f4d\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\u53c2\u6570\uff0c\u5219\u9ed8\u8ba4 1048576 Byte\uff081M\uff09\uff0c\u6700\u5927\u53ef\u8bbe\u7f6e 16777216 Byte\uff0816M\uff09\u3002\u5047\u5982\u8fd9\u91cc\u7684\u53c2\u6570\u8bbe\u7f6e\u4e3a 16777216 Byte\uff0816M\uff09\uff0c\u90a3\u4e48\uff0c\u5f53\u8981\u5bfc\u51fa\u5927\u4e8e 16M \u7684\u6570\u636e\u65f6\uff0c\u4f1a\u628a\u6570\u636e\u62c6\u5206\u6210\u591a\u4e2a 16M \u7684\u6570\u636e\u5305\uff0c\u9664\u6700\u540e\u4e00\u4e2a\u6570\u636e\u5305\u4e4b\u5916\uff0c\u5176\u5b83\u6570\u636e\u5305\u5927\u5c0f\u90fd\u4e3a 16M\u3002
-csv\uff1a\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5f53\u8bbe\u7f6e\u4e3a true \u65f6\u8868\u793a\u5bfc\u51fa\u7684\u6570\u636e\u4e3a csv \u683c\u5f0f\uff0c\u751f\u6210\u6570\u636e\u5e93\u548c\u8868\u7ed3\u6784\u4ee5\u53ca\u5bfc\u5165\u7684 SQL \u8bed\u53e5\u5c06\u4f1a\u4fdd\u5b58\u5728\u751f\u6210\u7684 sql \u6587\u4ef6\u4e2d\uff0c\u800c\u6570\u636e\u5219\u5bfc\u51fa\u5230\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u7684 ${databaseName}_${tableName}.csv
\u6587\u4ef6\u4e2d\u3002
--local-infile\uff1a\u9ed8\u8ba4\u503c\u4e3a true\uff0c\u4ec5\u5728\u53c2\u6570 -csv \u8bbe\u7f6e\u4e3a true \u65f6\u751f\u6548\u3002\u5f53\u53c2\u6570\u4e3a true \u65f6\uff0cmo-dump \u8f93\u51fa\u7684 sql \u6587\u4ef6\u811a\u672c\u4e2d\u4e3a LOAD DATA LOCAL INFILE\u3002\u5f53\u53c2\u6570\u4e3a false \u65f6\uff0cmo-dump \u8f93\u51fa\u7684 sql \u6587\u4ef6\u811a\u672c\u4e2d\u4e3a LOAD DATA INFILE\u3002
-tbl [tableName]\uff1a\u53ef\u9009\u53c2\u6570\u3002\u5982\u679c\u53c2\u6570\u4e3a\u7a7a\uff0c\u5219\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\u3002\u5982\u679c\u8981\u5907\u4efd\u6307\u5b9a\u8868\uff0c\u5219\u53ef\u4ee5\u5728\u547d\u4ee4\u4e2d\u6dfb\u52a0\u53c2\u6570 -tbl
\u548c tableName
\u3002\u5982\u679c\u6307\u5b9a\u591a\u4e2a\u8868\uff0c\u8868\u540d\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002
-no-data\uff1a\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5f53\u8bbe\u7f6e\u4e3a true \u65f6\u8868\u793a\u4e0d\u5bfc\u51fa\u6570\u636e\uff0c\u4ec5\u5bfc\u51fa\u8868\u7ed3\u6784\u3002
> {importStatement.sql}\uff1a\u5c06\u8f93\u51fa\u7684 SQL \u8bed\u53e5\u5b58\u50a8\u5230\u6587\u4ef6 importStatement.sql \u4e2d\uff0c\u5426\u5219\u5728\u5c4f\u5e55\u4e0a\u8f93\u51fa\u3002
\u4e0b\u8f7d\u65b9\u5f0f\u4e00\u548c\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\u9700\u8981\u5148\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177 wget \u6216 curl\uff0c\u5982\u679c\u4f60\u672a\u5b89\u88c5\uff0c\u8bf7\u5148\u81ea\u884c\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177\u3002
wget
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305 x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-x86_64.zip\nunzip mo-dump-1.0.0-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-arm64.zip\nunzip mo-dump-1.0.0-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-x86_64.zip\nunzip mo-dump-1.0.0-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-arm64.zip\nunzip mo-dump-1.0.0-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-xxx.zip\n
wget
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305 x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-x86_64.zip\nunzip mo-dump-1.0.0-linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-arm64.zip\nunzip mo-dump-1.0.0-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-x86_64.zip\nunzip mo-dump-1.0.0-linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-arm64.zip\nunzip mo-dump-1.0.0-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-xxx.zip\n
Note
\u7531\u4e8e linux \u5185\u6838\u7684\u9650\u5236\uff0cmo-dump \u5728\u4f4e\u7248\u672c\u5185\u6838\uff08\u4f4e\u4e8e 5.0\uff09\u7684 OS \u4e0a\u53ef\u80fd\u4f1a\u51fa\u73b0\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u7684\u60c5\u51b5\uff0c\u6b64\u65f6\u9700\u8981\u5347\u7ea7\u60a8\u7684\u5185\u6838\u7248\u672c\u3002
"},{"location":"MatrixOne/Develop/export-data/modump/#mo-dump-matrixone","title":"\u5982\u4f55\u4f7f\u7528mo-dump
\u5bfc\u51fa MatrixOne \u6570\u636e\u5e93","text":"mo-dump
\u5728\u547d\u4ee4\u884c\u4e2d\u975e\u5e38\u6613\u7528\u3002\u5728\u4f60\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\uff0c\u8fdb\u5165\u5230\u89e3\u538b\u540e\u7684 mo_dump \u6587\u4ef6\u5939\u76ee\u5f55\uff0c\u627e\u5230 mo-dump
\u53ef\u6267\u884c\u6587\u4ef6\uff1amo-dump\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fde\u63a5\u5230 MatrixOne\uff0c\u5e76\u4e14\u5bfc\u51fa\u6570\u636e\u5e93\uff1a
./mo-dump -u username -p password -h host_ip_address -P port -db database > importStatement.sql\n
"},{"location":"MatrixOne/Develop/export-data/modump/#_1","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
\u5982\u679c\u4f60\u5728\u4e0e MatrixOne \u5b9e\u4f8b\u76f8\u540c\u7684\u670d\u52a1\u5668\u4e2d\u542f\u52a8\u7ec8\u7aef\uff0c\u5e76\u4e14\u4f60\u60f3\u8981\u751f\u6210\u5355\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5e93\u4ee5\u53ca\u5176\u4e2d\u6240\u6709\u8868\u7684\u5907\u4efd\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u5728 importMydb.sql \u6587\u4ef6\u4e2d\u751f\u6210 mydb1 \u548c mydb2 \u6570\u636e\u5e93\u4ee5\u53ca\u8868\u7684\u7ed3\u6784\u548c\u6570\u636e\u7684\u5907\u4efd\u3002importMydb.sql \u6587\u4ef6\u4f1a\u4fdd\u5b58\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff1a
./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db mydb1,mydb2 > importMydb.sql\n
\u793a\u4f8b 2
\u5982\u679c\u4f60\u60f3\u5c06\u6570\u636e\u5e93 mydb \u5185\u7684\u8868\u7684\u6570\u636e\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff0c\u6570\u636e\u5e93 mydb \u4e2d\u7684\u6240\u6709\u8868\u7684\u6570\u636e\u5c06\u4f1a\u4ee5 ${databaseName}_${tableName}.csv
\u7684\u683c\u5f0f\u5bfc\u51fa\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u751f\u6210\u6570\u636e\u5e93\u548c\u8868\u7ed3\u6784\u4ee5\u53ca\u5bfc\u5165\u7684 SQL \u8bed\u53e5\u5c06\u4f1a\u4fdd\u5b58\u5728 mydb.sql \u6587\u4ef6\u4e2d\uff1a
./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db mydb -csv > mydb.sql\n
\u793a\u4f8b 3
\u5982\u679c\u8981\u5728\u6570\u636e\u5e93\u4e2d\u6307\u5b9a\u751f\u6210\u67d0\u4e00\u4e2a\u8868\u6216\u8005\u67d0\u51e0\u4e2a\u8868\u7684\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u6570\u636e\u5e93 db1 \u4e2d t1 \u8868\u548c t2 \u8868\u7684\u7ed3\u6784\u548c\u6570\u636e\u5907\u4efd\uff0c\u4fdd\u5b58\u5728 tab2.sql \u6587\u4ef6\u4e2d\u3002
./mo-dump -u root -p 111 -db db1 -tbl t1,t2 > tab2.sql \n
\u793a\u4f8b 4
\u5982\u679c\u8981\u5728\u6570\u636e\u5e93\u4e2d\u67d0\u4e00\u4e2a\u8868\u6216\u8005\u67d0\u51e0\u4e2a\u8868\u7684\u7ed3\u6784\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u6570\u636e\u5e93 db1 \u4e2d t1 \u8868\u548c t2 \u8868\u7684\u7ed3\u6784\uff0c\u4fdd\u5b58\u5728 tab_nodata.sql \u6587\u4ef6\u4e2d\u3002
./mo-dump -u root -p 111 -db db1 -no-data -tbl t1,t2 > tab_nodata.sql\n
"},{"location":"MatrixOne/Develop/export-data/modump/#_2","title":"\u9650\u5236","text":"mo-dump
\u6682\u4e0d\u652f\u6301\u53ea\u5bfc\u51fa\u6570\u636e\u3002\u5982\u679c\u4f60\u60f3\u5728\u6ca1\u6709\u6570\u636e\u5e93\u548c\u8868\u7ed3\u6784\u7684\u60c5\u51b5\u4e0b\u751f\u6210\u6570\u636e\u7684\u5907\u4efd\uff0c\u90a3\u4e48\uff0c\u4f60\u9700\u8981\u624b\u52a8\u62c6\u5206 .sql
\u6587\u4ef6\u3002MatrixOne \u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u5bfc\u51fa\u6570\u636e\uff1a
SELECT INTO...OUTFILE
mo-dump
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SELECT INTO...OUTFILE
\u5bfc\u51fa\u6570\u636e\u3002
\u4f7f\u7528 SELECT...INTO OUTFILE
\u8bed\u6cd5\u53ef\u4ee5\u5c06\u8868\u6570\u636e\u5bfc\u51fa\u5230\u4e3b\u673a\u4e0a\u7684\u6587\u672c\u6587\u4ef6\u4e2d\u3002
SELECT...INTO OUTFILE
\u8bed\u6cd5\u662f SELECT
\u8bed\u6cd5\u548c INTO OUTFILE filename
\u7684\u7ed3\u5408\u3002\u9ed8\u8ba4\u8f93\u51fa\u683c\u5f0f\u4e0e LOAD DATA
\u547d\u4ee4\u76f8\u540c\u3002\u56e0\u6b64\uff0c\u4ee5\u4e0b\u8bed\u53e5\u662f\u5c06\u540d\u79f0\u4e3a test \u7684\u8868\u5bfc\u51fa\u5230\u76ee\u5f55\u8def\u5f84\u4e3a /root/test \u7684. csv \u6587\u4ef6\u4e2d\u3002
mysql> SELECT * FROM TEST\n -> INTO OUTFILE '/root/test.csv';\n
\u4f60\u53ef\u4ee5\u91c7\u7528\u591a\u79cd\u5f62\u5f0f\u548c\u9009\u9879\u66f4\u6539\u8f93\u51fa\u683c\u5f0f\uff0c\u7528\u4e8e\u8868\u793a\u5982\u4f55\u5f15\u7528\u3001\u5206\u9694\u5217\u548c\u8bb0\u5f55\u3002
\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u4ee5. csv \u683c\u5f0f\u5bfc\u51fa TEST \u8868\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u884c\u662f\u7528\u56de\u8f66\u6362\u884c\u8fdb\u884c\u5c55\u793a\u7684\uff1a
mysql> SELECT * FROM TEST INTO OUTFILE '/root/test.csv'\n -> FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n -> LINES TERMINATED BY '\\r\\n';\n
SELECT ... INTO OUTFILE
\u7279\u6027\u5982\u4e0b\uff1a
\u5bfc\u51fa\u7684\u6587\u4ef6\u662f\u7531 MatrixOne \u670d\u52a1\u76f4\u63a5\u521b\u5efa\u7684\uff0c\u56e0\u6b64\u547d\u4ee4\u884c\u4e2d\u7684 filename
\u5e94\u8be5\u6307\u5411\u4f60\u9700\u8981\u6587\u4ef6\u5b58\u5165\u7684\u670d\u52a1\u5668\u4e3b\u673a\u7684\u4f4d\u7f6e\u3002MatrixOne \u6682\u4e0d\u652f\u6301\u5c06\u6587\u4ef6\u5bfc\u51fa\u5230\u5ba2\u6237\u7aef\u6587\u4ef6\u7cfb\u7edf\u3002
SELECT ... INTO OUTFILE
\u662f\u7528\u4e8e\u5c06\u68c0\u7d22\u51fa\u6765\u7684\u6570\u636e\u6309\u683c\u5f0f\u5bfc\u51fa\u5230\u6587\u4ef6\u4e2d\uff0c\u5373\u9700\u8981\u5bfc\u51fa\u7684\u6587\u4ef6\u662f\u7531 MatrixOne \u670d\u52a1\u76f4\u63a5\u521b\u5efa\uff0c\u5bfc\u51fa\u7684\u6587\u4ef6\u53ea\u80fd\u4f4d\u4e8e MatrixOne \u6240\u5728\u7684\u670d\u52a1\u5668\u4e3b\u673a\u4e0a\uff0c\u6240\u4ee5\u4f60\u5fc5\u987b\u5f97\u6709\u767b\u5f55 MatrixOne \u6240\u5728\u7684\u670d\u52a1\u5668\u4e3b\u673a\u7684\u7528\u6237\u540d\u5bc6\u7801\uff0c\u5e76\u4e14\u4f60\u6709\u6743\u9650\u53ef\u4ee5\u4ece MatrixOne \u68c0\u7d22\u6587\u4ef6\u3002
\u4f60\u5fc5\u987b\u6709\u6267\u884c SELECT
\u7684\u6743\u9650\u3002
\u68c0\u67e5\u6587\u4ef6\u9700\u8981\u5bfc\u51fa\u5230\u7684\u76ee\u5f55\u91cc\u4e0d\u8981\u6709\u91cd\u540d\u7684\u6587\u4ef6\uff0c\u5426\u5219\u4f1a\u88ab\u65b0\u5bfc\u51fa\u7684\u6587\u4ef6\u8986\u76d6\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
Note
\u5982\u679c\u4f60\u662f\u901a\u8fc7 docker
\u5b89\u88c5\u7684 MatrixOne\uff0c\u90a3\u4e48\u5bfc\u51fa\u76ee\u5f55\u9ed8\u8ba4\u4f4d\u4e8e docker \u955c\u50cf\u4e2d\u3002\u5982\u679c\u4f60\u8981\u9700\u8981\u6302\u8f7d\u672c\u5730\u76ee\u5f55\uff0c\u53c2\u89c1\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\uff1a\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84 ${local_data_path}/mo-data \u6302\u8f7d\u5230 MatrixOne Docker \u955c\u50cf\u4e2d\uff0c\u5e76\u6620\u5c04\u5230 /mo-data \u8def\u5f84\u4e0b\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 Docker Mount Volume tutorial\u3002
sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:0.8.0\n
"},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#_4","title":"\u6b65\u9aa4","text":"\u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u6570\u636e\u8868\uff1a
create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\ninsert into user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\nselect * from user;\n+------+-----------+------+\n| id | user_name | sex |\n+------+-----------+------+\n| 1 | weder | man |\n| 2 | tom | man |\n| 3 | wederTom | man |\n+------+-----------+------+\n
\u5bf9\u4e8e\u4f7f\u7528\u6e90\u4ee3\u7801\u6216\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u65b9\u5f0f\u5b89\u88c5\u6784\u5efa MatrixOne\uff0c\u5c06\u8868\u5bfc\u51fa\u5230\u672c\u5730\u76ee\u5f55\uff0c\u4f8b\u5982 ~/tmp/export_demo/export_datatable.txt\uff0c\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
select * from user into outfile '~/tmp/export_demo/export_datatable.txt'\n
\u4f7f\u7528 Docker \u5b89\u88c5\u542f\u52a8 MatrixOne\uff0c\u5bfc\u51fa\u5230\u4f60\u6302\u8f7d\u7684\u5bb9\u5668\u76ee\u5f55\u8def\u5f84\uff0c\u5982\u4e0b\u4f8b\u6240\u793a\u3002\u5176\u4e2d\u76ee\u5f55 mo-data \u6307\u7684\u662f\u672c\u5730\u8def\u5f84 ~/tmp/docker_export_demo/mo-data\u3002
select * from user into outfile 'mo-data/export_datatable.txt';\n
\u5230\u4f60\u672c\u5730 export_datatable.txt \u6587\u4ef6\u4e0b\u67e5\u770b\u5bfc\u51fa\u60c5\u51b5\uff1a
id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\n3,\"wederTom\",\"man\"\n
\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u5220\u9664\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/delete-data/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/delete-data/#sql","title":"\u5220\u9664\u6570\u636e SQL \u8bed\u53e5","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e09\u79cd\u65b9\u5f0f\u5220\u9664\u6570\u636e\uff1aDROP TABLE
\u3001TRUNCATE TABLE
\u548c DELETE TABLE
\u3002
\u4e09\u8005\u7684\u533a\u522b\u662f\uff1a
DELETE TABLE
\uff1a\u5f53\u4f60\u8981\u5220\u9664\u90e8\u5206\u8bb0\u5f55\u65f6\uff0c\u7528 DELETE TABLE
\u3002TRUNCATE TABLE
\uff1a\u5f53\u4f60\u4ecd\u8981\u4fdd\u7559\u8be5\u8868\uff0c\u8868\u7684\u7ed3\u6784\u3001\u7d22\u5f15\u548c\u7ea6\u675f\u7b49\u90fd\u9700\u8981\u4fdd\u6301\u4e0d\u53d8\uff0c\u4f46\u8981\u5220\u9664\u6240\u6709\u8bb0\u5f55\u65f6\uff0c\u7528 TRUNCATE TABLE
\u3002DROP TABLE
\uff1a\u5f53\u4f60\u4e0d\u518d\u9700\u8981\u8be5\u8868\u65f6\uff0c\u7528 DROP TABLE
\u3002DELETE
","text":"DELETE FROM tbl_name [[AS] tbl_alias]\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
DELETE FROM tbl_name
\uff1a\u6307\u5b9a\u8981\u4ece\u8868\u4e2d\u5220\u9664\u6570\u636e\u7684\u76ee\u6807\u8868\u3002tbl_name \u662f\u8868\u7684\u540d\u79f0\u3002
[AS] tbl_alias
\uff08\u53ef\u9009\uff09\uff1a\u53ef\u4ee5\u4f7f\u7528 AS \u5173\u952e\u5b57\u4e3a\u76ee\u6807\u8868\u6307\u5b9a\u4e00\u4e2a\u8868\u522b\u540d\uff08tbl_alias\uff09\u3002\u522b\u540d\u662f\u53ef\u9009\u7684\uff0c\u7528\u4e8e\u7b80\u5316\u67e5\u8be2\u5e76\u5728\u8bed\u53e5\u4e2d\u5f15\u7528\u8868\u3002
[WHERE where_condition]
\uff08\u53ef\u9009\uff09\uff1aWHERE \u5b50\u53e5\u7528\u4e8e\u6307\u5b9a\u5220\u9664\u6570\u636e\u7684\u6761\u4ef6\u3002\u53ea\u6709\u6ee1\u8db3\u6307\u5b9a\u6761\u4ef6\u7684\u884c\u624d\u4f1a\u88ab\u5220\u9664\u3002where_condition \u662f\u4e00\u4e2a\u903b\u8f91\u8868\u8fbe\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u5b9a\u4e49\u6761\u4ef6\u3002
[ORDER BY ...]
\uff08\u53ef\u9009\uff09\uff1aORDER BY \u5b50\u53e5\u7528\u4e8e\u6309\u6307\u5b9a\u7684\u5217\u5bf9\u8981\u5220\u9664\u7684\u884c\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\uff0c\u5e76\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002\u6392\u5e8f\u5c06\u5f71\u54cd\u5220\u9664\u7684\u884c\u7684\u987a\u5e8f\u3002
[LIMIT row_count]
\uff08\u53ef\u9009\uff09\uff1aLIMIT \u5b50\u53e5\u7528\u4e8e\u9650\u5236\u4ece\u8868\u4e2d\u5220\u9664\u7684\u884c\u6570\u3002\u5b83\u6307\u5b9a\u8981\u5220\u9664\u7684\u6700\u5927\u884c\u6570\uff08row_count\uff09\u3002\u5982\u679c\u672a\u6307\u5b9a LIMIT \u5b50\u53e5\uff0c\u5219\u5c06\u5220\u9664\u6ee1\u8db3 WHERE \u6761\u4ef6\u7684\u6240\u6709\u884c\u3002
TRUNCATE
","text":"> TRUNCATE [TABLE] table_name;\n
TRUNCATE
\u8bed\u53e5\u7528\u4e8e\u5220\u9664\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\uff0c\u4fdd\u7559\u8868\u7684\u7ed3\u6784\u3002\u5b83\u5c06\u5feb\u901f\u6e05\u7a7a\u8868\uff0c\u800c\u4e0d\u662f\u9010\u884c\u5220\u9664\u6570\u636e\u3002
[TABLE]
\uff08\u53ef\u9009\uff09\u5173\u952e\u5b57\u7528\u4e8e\u63d0\u4f9b\u66f4\u6e05\u6670\u7684\u8bed\u6cd5\uff0c\u4f46\u5728\u5927\u591a\u6570\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\u53ef\u4ee5\u7701\u7565\u3002table_name
\u662f\u8981\u8fdb\u884c\u64cd\u4f5c\u7684\u76ee\u6807\u8868\u7684\u540d\u79f0\u3002DROP
","text":"> DROP TABLE [IF EXISTS] [db.]name\n
DROP TABLE
\u8bed\u53e5\u7528\u4e8e\u5b8c\u5168\u5220\u9664\u6570\u636e\u5e93\u4e2d\u7684\u8868\uff0c\u5305\u62ec\u8868\u7684\u7ed3\u6784\u548c\u6570\u636e\u3002
[IF EXISTS]
\uff08\u53ef\u9009\uff09\u5173\u952e\u5b57\u8868\u793a\u5982\u679c\u8868\u5b58\u5728\uff0c\u5219\u6267\u884c\u5220\u9664\u64cd\u4f5c\u3002\u5982\u679c\u7701\u7565\u6b64\u5173\u952e\u5b57\uff0c\u5e76\u4e14\u8981\u5220\u9664\u7684\u8868\u4e0d\u5b58\u5728\uff0c\u5c06\u5f15\u53d1\u9519\u8bef\u3002[db.]
\uff08\u53ef\u9009\uff09\u6307\u5b9a\u8868\u6240\u5728\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6570\u636e\u5e93\u540d\u79f0\uff0c\u5219\u9ed8\u8ba4\u4e3a\u5f53\u524d\u6570\u636e\u5e93\u3002name
\u662f\u8981\u5220\u9664\u7684\u8868\u7684\u540d\u79f0\u3002\u5728\u9ed8\u8ba4\u914d\u7f6e\u4e0b\uff0cMatrixOne \u5728\u6267\u884c DELETE
\u3001DROP
\u6216 TRUNCATE
\u8bed\u53e5\u540e\uff0c\u5e76\u4e0d\u4f1a\u7acb\u5373\u4ece\u78c1\u76d8\u4e2d\u5220\u9664\u6570\u636e\uff0c\u800c\u662f\u5c06\u8fd9\u4e9b\u6570\u636e\u6807\u8bb0\u4e3a\u53ef\u5220\u9664\u72b6\u6001\u3002\u968f\u540e\uff0cGC\uff08\u5783\u573e\u56de\u6536\uff09\u673a\u5236\u4f1a\u5b9a\u671f\u8fdb\u884c\u626b\u63cf\uff0c\u5e76\u6e05\u7406\u4e0d\u518d\u9700\u8981\u7684\u65e7\u6570\u636e\u3002
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5783\u573e\u56de\u6536\u673a\u5236\u6bcf\u9694 30 \u5206\u949f\u8fdb\u884c\u4e00\u6b21\u626b\u63cf\u3002\u6bcf\u6b21\u626b\u63cf\u4f1a\u67e5\u627e\u8d85\u8fc7 1 \u5c0f\u65f6\u901a\u8fc7 SQL \u8bed\u53e5\u88ab\u5220\u9664\u7684\u6570\u636e\uff0c\u5e76\u5f00\u59cb\u6e05\u7406\u64cd\u4f5c\uff0c\u4ee5\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002\u5b8c\u6210\u6240\u6709\u6e05\u7406\u7684\u6700\u957f\u5468\u671f\u4e3a 90 \u5206\u949f\u3002\u56e0\u6b64\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6267\u884c DELETE
\u3001DROP
\u6216 TRUNCATE
\u8bed\u53e5\u5e76\u4e0d\u4f1a\u7acb\u5373\u51cf\u5c11\u78c1\u76d8\u4f7f\u7528\u91cf\u3002\u53ea\u6709\u5728\u5783\u573e\u56de\u6536\u8fc7\u7a0b\u4e2d\uff0c\u88ab\u6807\u8bb0\u4e3a\u53ef\u5220\u9664\u7684\u6570\u636e\u624d\u4f1a\u88ab\u6e05\u7406\u5e76\u91ca\u653e\u7a7a\u95f4\u3002
-- \u521b\u5efa\u8868\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO employees (id, name, department)\nVALUES (1, 'John Doe', 'HR'),\n(2, 'Jane Smith', 'Marketing'),\n(3, 'Mike Johnson', 'IT'),\n(4, 'Emily Brown', 'Finance');\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id | name | department |\n+------+--------------+------------+\n| 1 | John Doe | HR |\n| 2 | Jane Smith | Marketing |\n| 3 | Mike Johnson | IT |\n| 4 | Emily Brown | Finance |\n+------+--------------+------------+\n4 rows in set (0.01 sec)\n\n-- \u5220\u9664\u90e8\u5206\u6570\u636e\nmysql> DELETE FROM employees WHERE department = 'IT';\nQuery OK, 1 row affected (0.01 sec)\n\n-- \u67e5\u770b\u5220\u9664\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+-------------+------------+\n| id | name | department |\n+------+-------------+------------+\n| 1 | John Doe | HR |\n| 2 | Jane Smith | Marketing |\n| 4 | Emily Brown | Finance |\n+------+-------------+------------+\n3 rows in set (0.00 sec)\n
-- \u521b\u5efa\u8868\nCREATE TABLE orders (\norder_id INT PRIMARY KEY,\ncustomer_name VARCHAR(50),\norder_date DATE\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO orders (order_id, customer_name, order_date)\nVALUES (1, 'John Doe', '2022-01-01'),\n(2, 'Jane Smith', '2022-02-01'),\n(3, 'Mike Johnson', '2022-03-01'),\n(4, 'Emily Brown', '2022-04-01'),\n(5, 'David Wilson', '2022-05-01');\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n| 1 | John Doe | 2022-01-01 |\n| 2 | Jane Smith | 2022-02-01 |\n| 3 | Mike Johnson | 2022-03-01 |\n| 4 | Emily Brown | 2022-04-01 |\n| 5 | David Wilson | 2022-05-01 |\n+----------+---------------+------------+\n5 rows in set (0.01 sec)\n\n-- \u5220\u9664\u6700\u65e9\u7684\u4e24\u4e2a\u8ba2\u5355\nmysql> DELETE FROM orders\nWHERE order_id IN (\nSELECT order_id\nFROM orders\nORDER BY order_date\nLIMIT 2);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- \u67e5\u770b\u5220\u9664\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n| 3 | Mike Johnson | 2022-03-01 |\n| 4 | Emily Brown | 2022-04-01 |\n| 5 | David Wilson | 2022-05-01 |\n+----------+---------------+------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/import-data/insert-data/","title":"INSERT \u63d2\u5165","text":"\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u63d2\u5165\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/insert-data/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into","title":"INSERT INTO \u8bed\u53e5","text":"INSERT INTO
\u8bed\u53e5\u6709\u4ee5\u4e0b\u5199\u6cd5\uff1a
\u6307\u5b9a\u8981\u63d2\u5165\u7684\u5217\u540d\u548c\u503c\uff1a
INSERT INTO tbl_name (a,b,c) VALUES (1,2,3);\n
\u5982\u679c\u8981\u4e3a\u8868\u7684\u6240\u6709\u5217\u6dfb\u52a0\u503c\uff0c\u5219\u4e0d\u9700\u8981\u5728 SQL \u67e5\u8be2\u4e2d\u6307\u5b9a\u5217\u540d\u3002\u5fc5\u987b\u786e\u4fdd\u503c\u7684\u987a\u5e8f\u4e0e\u8868\u4e2d\u5217\u7684\u987a\u5e8f\u76f8\u540c\u3002INSERT INTO
\u8bed\u6cd5\u5982\u4e0b\uff1a
INSERT INTO tbl_name VALUES (1,2,3);\n
\u4f7f\u7528 INSERT...VALUES...
\u8bed\u53e5\u53ef\u4ee5\u63d2\u5165\u591a\u884c\u3002\u8bed\u53e5\u4e2d\u5fc5\u987b\u5305\u542b\u591a\u4e2a\u7528\u9017\u53f7\u5206\u9694\u7684\u503c\u5217\u8868\uff0c\u503c\u5217\u8868\u7528\u5706\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u7528\u9017\u53f7\u5206\u9694\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3), (4,5,6), (7,8,9);\n
\u4ee5\u4e0b\u662f\u4ece Northwind \u793a\u4f8b\u6570\u636e\u5e93\u4e2d\u7684 Customers \u8868\u4e2d\u9009\u62e9\u7684\u8868\u793a\u4f8b\uff1a
CREATE TABLE Customers (\n CustomerID INT AUTO_INCREMENT NOT NULL,\n CustomerName VARCHAR(40) NOT NULL,\n ContactName VARCHAR(30) NULL,\n Address VARCHAR(60) NULL,\n City VARCHAR(15) NULL,\n PostalCode VARCHAR(10) NULL,\n Country VARCHAR(15) NULL,\n PRIMARY KEY (CustomerID)\n );\n
CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into_1","title":"INSERT INTO \u793a\u4f8b","text":"\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5728 Customers \u8868\u4e2d\u63d2\u5165\u4e86\u4e00\u6761\u65b0\u8bb0\u5f55\uff1a
"},{"location":"MatrixOne/Develop/import-data/insert-data/#example","title":"Example","text":"INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)\nVALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal Tom B. Erichsen Skagen 21 Stavanger 4006 Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#_3","title":"\u4ec5\u5728\u6307\u5b9a\u5217\u4e2d\u63d2\u5165\u6570\u636e","text":"MatrixOne \u4e5f\u652f\u6301\u4f7f\u7528 SQL \u8bed\u53e5\u4ec5\u5728\u7279\u5b9a\u5217\u4e2d\u63d2\u5165\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/insert-data/#_4","title":"\u793a\u4f8b","text":"\u4f7f\u7528\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5c06\u63d2\u5165\u4e00\u6761\u65b0\u8bb0\u5f55\uff0c\u4f46\u53ea\u63d2\u5165 CustomerName\u3001City \u548c Country \u5217\u4e2d\u7684\u6570\u636e\uff0c\u540c\u65f6 CustomerID \u5c06\u81ea\u52a8\u66f4\u65b0\uff1a
INSERT INTO Customers (CustomerName, City, Country)\nVALUES ('Cardinal', 'Stavanger', 'Norway');\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal null null Stavanger null Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-intoselect","title":"INSERT INTO...SELECT","text":"\u4f7f\u7528 INSERT INTO SELECT
\uff0c\u4f60\u53ef\u4ee5\u4ece SELECT
\u8bed\u53e5\u7684\u7ed3\u679c\u4e2d\u5feb\u901f\u63d2\u5165\u591a\u884c\u5230\u8868\u4e2d\uff0cSELECT
\u8bed\u53e5\u53ef\u4ee5\u4ece\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u4e2d\u8fdb\u884c\u9009\u62e9\u3002INSERT INTO SELECT
\u8bed\u53e5\u8981\u6c42\u6e90\u8868\u548c\u76ee\u6807\u8868\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u5339\u914d\u3002
\u4ece\u4e00\u4e2a\u8868\u590d\u5236\u6240\u6709\u5217\u5230\u53e6\u4e00\u4e2a\u8868\uff1a
INSERT INTO *table2*\nSELECT * FROM *table1\n*WHERE *condition*;\n
\u53ea\u4ece\u4e00\u4e2a\u8868\u590d\u5236\u4e00\u4e9b\u5217\u5230\u53e6\u4e00\u4e2a\u8868\uff1a
INSERT INTO *table2* (*column1*, *column2*, *column3*, ...)\nSELECT *column1*, *column2*, *column3*, ...\nFROM *table1*\nWHERE *condition*;\n
"},{"location":"MatrixOne/Develop/import-data/insert-data/#northwind","title":"Northwind \u6570\u636e\u5e93\u793a\u4f8b","text":"\u4ee5\u4e0b\u662f\u4ece Northwind \u793a\u4f8b\u6570\u636e\u5e93\u4e2d\u7684\u8868\u4e2d\u9009\u62e9\u7684\u8868\u793a\u4f8b\uff1a
CREATE TABLE Customers (\n CustomerID INT AUTO_INCREMENT NOT NULL,\n CustomerName VARCHAR(40) NOT NULL,\n ContactName VARCHAR(30) NULL,\n Address VARCHAR(60) NULL,\n City VARCHAR(15) NULL,\n PostalCode VARCHAR(10) NULL,\n Country VARCHAR(15) NULL,\n PRIMARY KEY (CustomerID)\n );\nCREATE TABLE Suppliers (\n SupplierID INT AUTO_INCREMENT NOT NULL,\n SupplierName VARCHAR(40) NOT NULL,\n ContactName VARCHAR(30) NULL,\n Address VARCHAR(60) NULL,\n City VARCHAR(15) NULL,\n PostalCode VARCHAR(10) NULL,\n Country VARCHAR(15) NULL,\n PRIMARY KEY (SupplierID)\n );\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 MexicoSuppliers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
SupplierID SupplierName ContactName Address City PostalCode Country 1 Exotic Liquid Charlotte Cooper 49 Gilbert St. Londona EC1 4SD UK 2 New Orleans Cajun Delights Shelley Burke P.O. Box 78934 New Orleans 70117 USA 3 Grandma Kelly's Homestead Regina Murphy 707 Oxford Rd. Ann Arbor 48104 USA"},{"location":"MatrixOne/Develop/import-data/insert-data/#_5","title":"\u793a\u4f8b","text":"\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5c06 Suppliers \u590d\u5236\u5230 Customers \u4e2d\uff0c\u540c\u65f6\u672a\u586b\u5145\u6570\u636e\u7684\u5217\u5c06\u586b\u5145\u4e3a NULL
\uff1a
INSERT INTO Customers (CustomerName, City, Country)\nSELECT SupplierName, City, Country FROM Suppliers;\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 Mexico 4 Exotic Liquid null null Londona null UK 5 New Orleans Cajun Delights null null New Orleans null USA 6 Grandma Kelly's Homestead null null Ann Arbor null USA"},{"location":"MatrixOne/Develop/import-data/prepared/","title":"\u9884\u5904\u7406","text":"MatrixOne \u63d0\u4f9b\u5bf9\u670d\u52a1\u5668\u7aef\u9884\u5904\u7406\u8bed\u53e5\u7684\u652f\u6301\u3002\u5229\u7528\u5ba2\u6237\u7aef\u6216\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u534f\u8bae\u7684\u9ad8\u6548\u6027\uff0c\u5bf9\u53c2\u6570\u503c\u4f7f\u7528\u5e26\u6709\u5360\u4f4d\u7b26\u7684\u8bed\u53e5\u8fdb\u884c\u9884\u5904\u7406\uff0c\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u4f18\u70b9\u5982\u4e0b\uff1a
\u6bcf\u6b21\u6267\u884c\u8bed\u53e5\u65f6\u89e3\u6790\u8bed\u53e5\u7684\u6548\u7387\u63d0\u9ad8\u3002\u901a\u5e38\uff0c\u6570\u636e\u5e93\u5e94\u7528\u7a0b\u5e8f\u5904\u7406\u5927\u91cf\u51e0\u4e4e\u76f8\u540c\u7684\u8bed\u53e5\uff0c\u53ea\u66f4\u6539\u5b50\u53e5\u4e2d\u7684\u6587\u5b57\u6216\u53d8\u91cf\u503c\uff0c\u4f8b\u5982\u7528\u4e8e\u67e5\u8be2\u548c\u5220\u9664\u7684 WHERE
\u3001\u7528\u4e8e\u66f4\u65b0\u7684 SET
\u548c\u7528\u4e8e\u63d2\u5165\u7684 VALUES
\u3002
\u9632\u6b62 SQL \u6ce8\u5165\u3002\u53c2\u6570\u503c\u53ef\u4ee5\u5305\u542b\u672a\u8f6c\u4e49\u7684 SQL \u5f15\u53f7\u548c\u5206\u9694\u7b26\uff0c\u4e00\u6b21\u7f16\u8bd1\uff0c\u591a\u6b21\u8fd0\u884c\uff0c\u7701\u53bb\u4e86\u89e3\u6790\u4f18\u5316\u7b49\u8fc7\u7a0b\u3002
PREPARE
\u3001EXECUTE
\u3001\u548c DEALLOCATE PREPARE
\u8bed\u53e5","text":"PREPARE \u8bed\u53e5\u7684 SQL \u57fa\u672c\u8bed\u6cd5\u4e3b\u8981\u4e3a\u4ee5\u4e0b\u4e09\u79cd SQL \u8bed\u53e5\uff1a
PREPARE\uff1a\u6267\u884c\u9884\u7f16\u8bd1\u8bed\u53e5\u3002
EXECUTE\uff1a\u6267\u884c\u5df2\u9884\u7f16\u8bd1\u7684\u53e5\u3002
DEALLOCATE PREPARE\uff1a\u91ca\u653e\u4e00\u6761\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u3002
PREPARE stmt_name FROM preparable_stmt\n
\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0 preparable_stmt \u5305\u542b SQL \u8bed\u53e5\u6587\u672c\u7684\u5b57\u7b26\u4e32\u6587\u5b57\u6216\u7528\u6237\u53d8\u91cf\u3002\u6587\u672c\u5fc5\u987b\u4ee3\u8868\u5355\u4e2a\u8bed\u53e5\uff0c\u800c\u4e0d\u662f\u591a\u4e2a\u8bed\u53e5\u3002"},{"location":"MatrixOne/Develop/import-data/prepared/#_3","title":"\u6267\u884c\u9884\u5904\u7406\u8bed\u53e5","text":"EXECUTE stmt_name [USING @var_name [, @var_name] ...]\n
\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Develop/import-data/prepared/#_4","title":"\u5220\u9664\u9884\u5904\u7406\u8bed\u53e5","text":"{DEALLOCATE | DROP} PREPARE stmt_name\n
\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Develop/import-data/prepared/#_5","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u8868\nCREATE TABLE customers (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nemail VARCHAR(50)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO customers (id, name, email)\nVALUES (1, 'John Doe', 'john@example.com'),\n(2, 'Jane Smith', 'jane@example.com'),\n(3, 'Mike Johnson', 'mike@example.com');\n\n-- \u8fdb\u884c\u9884\u5904\u7406\nmysql> PREPARE stmt FROM 'SELECT * FROM customers WHERE id = ?';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u6267\u884c\u9884\u5904\u7406\nmysql> SET @id = 2;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> EXECUTE stmt USING @id;\n+------+------------+------------------+\n| id | name | email |\n+------+------------+------------------+\n| 2 | Jane Smith | jane@example.com |\n+------+------------+------------------+\n1 row in set (0.01 sec)\n\n-- \u5220\u9664\u9884\u5904\u7406\nmysql> DEALLOCATE PREPARE stmt;\nQuery OK, 0 rows affected (0.00 sec)\n
\u4e0a\u8ff0\u793a\u4f8b\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a customers
\u7684\u8868\uff0c\u8be5\u8868\u5305\u542b id
\u3001name
\u548c email
\u4e09\u4e2a\u5217\u3002\u63a5\u4e0b\u6765\uff0c\u63d2\u5165\u4e86\u4e09\u6761\u6570\u636e\u5230\u8be5\u8868\u4e2d\u3002
\u7136\u540e\uff0c\u4f7f\u7528 PREPARE
\u8bed\u53e5\u8fdb\u884c\u9884\u5904\u7406\uff0c\u5c06 SELECT * FROM customers WHERE id = ?
\u4f5c\u4e3a\u9884\u5904\u7406\u8bed\u53e5\u4fdd\u5b58\u5728 stmt
\u4e2d\u3002
\u6267\u884c\u9884\u5904\u7406\u65f6\uff0c\u5c06 @id
\u53d8\u91cf\u8bbe\u7f6e\u4e3a 2\uff0c\u5e76\u4f7f\u7528 EXECUTE
\u8bed\u53e5\u6267\u884c\u9884\u5904\u7406\uff0c\u5c06 @id
\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u9884\u5904\u7406\u8bed\u53e5\u3002
\u6700\u540e\uff0c\u4f7f\u7528 DEALLOCATE PREPARE
\u8bed\u53e5\u5220\u9664\u9884\u5904\u7406\uff0c\u91ca\u653e\u76f8\u5173\u8d44\u6e90\u3002
\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u8fdb\u884c\u6d41\u5f0f\u5bfc\u5165\u6570\u636e\u3002\u5177\u4f53\u6765\u8bf4\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA INLINE
\u8bed\u6cd5\u5bf9\u4ee5 csv \u683c\u5f0f\u7ec4\u7ec7\u7684\u5b57\u7b26\u4e32\u8fdb\u884c\u5bfc\u5165\uff0c\u5bfc\u5165\u901f\u5ea6\u8f83 INSERT
\u64cd\u4f5c\u66f4\u5feb\u3002
mysql> LOAD DATA INLINE FORMAT='csv' ,\nDATA=$XXX$\ncsv_string $XXX$\nINTO TABLE tbl_name;\n
\u53c2\u6570\u89e3\u91ca
FORMAT='csv'
\u8868\u793a\u540e\u9762 DATA
\u4e2d\u7684\u5b57\u7b26\u4e32\u6570\u636e\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u7684\u3002
DATA=$XXX$ csv_string $XXX$
\u4e2d\u7684 $XXX$
\u662f\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\u3002csv_string
\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u5b57\u7b26\u4e32\u6570\u636e\uff0c\u4ee5 \\n
\u6216\u8005 \\r\\n
\u4f5c\u4e3a\u6362\u884c\u7b26\u3002
Note
$XXX$
\u4e3a\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\uff0c\u6ce8\u610f\u6570\u636e\u7ed3\u675f\u5904\u7684 $XXX$
\u9700\u8981\u548c\u6700\u540e\u4e00\u884c\u6570\u636e\u653e\u5728\u540c\u4e00\u884c\uff0c\u6362\u884c\u53ef\u80fd\u5bfc\u81f4 ERROR 20101
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/stream-load/#mysql-client-load-data-inline","title":"MySQL Client \u4e2d\u4f7f\u7528LOAD DATA INLINE
\u547d\u4ee4\u5bfc\u5165\u6570\u636e","text":"\u4f60\u53ef\u4ee5\u4f7f\u7528 LOAD DATA INLINE
\u5c06\u6d41\u5f0f\u6570\u636e\u5bfc\u5165 MatrixOne\uff0c\u672c\u7ae0\u5c06\u4ecb\u7ecd\u5982\u4f55\u8fdb\u884c\u6d41\u5f0f\u5bfc\u5165\uff0c\u5e76\u4e14\u7ed9\u51fa\u5bfc\u5165 csv \u6570\u636e\u7684\u793a\u4f8b\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MatrixOne \u4e2d\u6267\u884c LOAD DATA INLINE
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868 user
:
CREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n)\n
\u5728 MySQL \u5ba2\u6237\u7aef\u6267\u884c LOAD DATA INLINE
\u8fdb\u884c\u6570\u636e\u5bfc\u5165\uff0c\u4ee5 csv \u683c\u5f0f\u5bfc\u5165\u6570\u636e\uff1a
mysql> LOAD DATA INLINE FORMAT='csv',\nDATA=$XXX$\nLihua,23,Shanghai\nBob,25,Beijing $XXX$ INTO TABLE user;\n
LOAD DATA INLINE
\u547d\u4ee4\u5bfc\u5165\u6570\u636e","text":"PyMySQL \u662f\u4e00\u4e2a\u7eaf Python MySQL \u5ba2\u6237\u7aef\u5e93\uff0c\u4e0b\u9762\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 PyMySQL \u8fdb\u884c LOAD DATA INLINE
\u64cd\u4f5c\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql\uff1a
pip3 install pymysql #If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff0c\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\u548c user \u7684\u6570\u636e\u8868\uff1a
mysql> create database test;\nuse test;\nCREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n);\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 pymysql_load_data_inline.py \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff0c\u6b64\u5904\u4f5c\u4e3a\u793a\u8303 csv_string \u53ea\u5199\u4e86\u4e24\u884c\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u6d41\u5f0f\u6570\u636e\u51b3\u5b9a csv_string \u7684\u5927\u5c0f\uff1a
#!/usr/bin/python3\nimport pymysql\n\n# Open database connection\ndb = pymysql.connect(\n host='127.0.01',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n )\n# prepare a cursor object using cursor() method\ncursor = db.cursor()\ncsv_string=\"Lihua,23,Shanghai \\n Bob,25,Beijing\"\nsql=\"load data inline format='csv',data=$XXX$\" + csv_string + \" $XXX$ into table user;\"\n# execute SQL query using execute() method.\ncursor.execute(sql)\ndata=db.commit()\n# Fetch a single row using fetchone() method.\n# disconnect from server\ndb.close()\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
python3 pymysql_load_data_inline.py\n
\u6253\u5f00 mysql \u5ba2\u6237\u7aef\uff0c\u67e5\u8be2\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from user;\n+-------+------+-----------+\n| name | age | city |\n+-------+------+-----------+\n| Lihua | 23 | Shanghai |\n| Bob | 25 | Beijing |\n+-------+------+-----------+\n2 rows in set (0.02 sec)\n
\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u66f4\u65b0\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/update-data/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/update-data/#sql","title":"\u66f4\u65b0\u6570\u636e SQL \u8bed\u53e5","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u66f4\u65b0\u6570\u636e\uff1aUPDATE
\u548c INSERT ON DUPLICATE KEY UPDATE
\u3002
\u4e8c\u8005\u7684\u533a\u522b\u662f\uff1a
-UPDATE
\uff1a
INSERT ON DUPLICATE KEY UPDATE
\uff1a
\u5173\u952e\u533a\u522b\uff1a
UPDATE
","text":"UPDATE table_reference\n SET assignment_list\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
UPDATE table_reference
\uff1a\u6307\u5b9a\u8981\u66f4\u65b0\u6570\u636e\u7684\u76ee\u6807\u8868\u3002table_reference \u53ef\u4ee5\u662f\u5355\u4e2a\u8868\u6216\u591a\u4e2a\u8868\u7684\u8054\u63a5\u3002
SET assignment_list
\uff1a\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u503c\u3002assignment_list \u662f\u4e00\u4e2a\u7531\u5217\u540d\u548c\u76f8\u5e94\u7684\u503c\u7ec4\u6210\u7684\u5217\u8868\uff0c\u7528\u9017\u53f7\u5206\u9694\u3002\u6bcf\u4e2a\u5217\u540d\u540e\u9762\u4f7f\u7528\u7b49\u53f7\uff08=\uff09\u5c06\u5176\u4e0e\u8981\u66f4\u65b0\u7684\u65b0\u503c\u76f8\u5173\u8054\u3002
[WHERE where_condition]
\uff08\u53ef\u9009\uff09\uff1aWHERE \u5b50\u53e5\u7528\u4e8e\u6307\u5b9a\u66f4\u65b0\u6570\u636e\u7684\u6761\u4ef6\u3002\u53ea\u6709\u6ee1\u8db3\u6307\u5b9a\u6761\u4ef6\u7684\u884c\u624d\u4f1a\u88ab\u66f4\u65b0\u3002where_condition \u662f\u4e00\u4e2a\u903b\u8f91\u8868\u8fbe\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u5b9a\u4e49\u6761\u4ef6\u3002
[ORDER BY ...]
\uff08\u53ef\u9009\uff09\uff1aORDER BY \u5b50\u53e5\u7528\u4e8e\u6309\u6307\u5b9a\u7684\u5217\u5bf9\u8981\u66f4\u65b0\u7684\u884c\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\uff0c\u5e76\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002\u6392\u5e8f\u5c06\u5f71\u54cd\u66f4\u65b0\u7684\u884c\u7684\u987a\u5e8f\u3002
[LIMIT row_count]
\uff08\u53ef\u9009\uff09\uff1aLIMIT \u5b50\u53e5\u7528\u4e8e\u9650\u5236\u8981\u66f4\u65b0\u7684\u884c\u6570\u3002\u5b83\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u6700\u5927\u884c\u6570\uff08row_count\uff09\u3002\u5982\u679c\u672a\u6307\u5b9a LIMIT \u5b50\u53e5\uff0c\u5219\u5c06\u66f4\u65b0\u6ee1\u8db3 WHERE \u6761\u4ef6\u7684\u6240\u6709\u884c\u3002
\u66f4\u65b0\u6570\u636e\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u8868\u3001\u8981\u66f4\u65b0\u7684\u5217\u548c\u503c\u3001\u66f4\u65b0\u7684\u6761\u4ef6\u4ee5\u53ca\u6392\u5e8f\u548c\u9650\u5236\uff0c\u4ee5\u4fbf\u6839\u636e\u9700\u6c42\u8fdb\u884c\u7075\u6d3b\u7684\u6570\u636e\u66f4\u65b0\u3002
"},{"location":"MatrixOne/Develop/import-data/update-data/#insert-on-duplicate-key-update","title":"INSERT ON DUPLICATE KEY UPDATE
","text":"> INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...
INSERT INTO
\u8bed\u53e5\u7528\u4e8e\u5411\u8868\u4e2d\u63d2\u5165\u65b0\u7684\u884c\u3002[db.]
\uff08\u53ef\u9009\uff09\u6307\u5b9a\u8868\u6240\u5728\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6570\u636e\u5e93\u540d\u79f0\uff0c\u5219\u9ed8\u8ba4\u4e3a\u5f53\u524d\u6570\u636e\u5e93\u3002table
\u662f\u8981\u63d2\u5165\u6570\u636e\u7684\u76ee\u6807\u8868\u7684\u540d\u79f0\u3002[(c1, c2, c3)]
\uff08\u53ef\u9009\uff09\u6307\u5b9a\u8981\u63d2\u5165\u7684\u5217\uff0c\u7528\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u4f7f\u7528\u9017\u53f7\u5206\u9694\u5217\u540d\u3002\u5982\u679c\u672a\u6307\u5b9a\u5217\u540d\uff0c\u5219\u5047\u5b9a\u5c06\u63d2\u5165\u8868\u4e2d\u6240\u6709\u53ef\u7528\u7684\u5217\u3002VALUES
\u5b50\u53e5\u6307\u5b9a\u8981\u63d2\u5165\u7684\u503c\u3002\u6bcf\u4e2a\u503c\u4e0e\u5bf9\u5e94\u7684\u5217\u4e00\u4e00\u5bf9\u5e94\uff0c\u7528\u9017\u53f7\u5206\u9694\uff0c\u653e\u5728\u62ec\u53f7\u4e2d\u3002\u53ef\u4ee5\u63d2\u5165\u591a\u884c\u6570\u636e\uff0c\u6bcf\u4e00\u884c\u7528\u9017\u53f7\u5206\u9694\u3002
[ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...]
ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u7528\u4e8e\u5728\u63d2\u5165\u6570\u636e\u65f6\u5904\u7406\u91cd\u590d\u952e\uff08Duplicate Key\uff09\u7684\u60c5\u51b5\u3002column1, column2, column3
\u7b49\u8868\u793a\u8981\u66f4\u65b0\u7684\u5217\u540d\uff0cvalue1, value2, value3
\u7b49\u8868\u793a\u8981\u66f4\u65b0\u7684\u5bf9\u5e94\u503c\u3002\u8fd9\u4e2a\u8bed\u6cd5\u7ed3\u6784\u5141\u8bb8\u5c06\u4e00\u884c\u6216\u591a\u884c\u6570\u636e\u63d2\u5165\u5230\u6307\u5b9a\u7684\u8868\u4e2d\u3002\u5982\u679c\u51fa\u73b0\u91cd\u590d\u952e\u7684\u60c5\u51b5\uff0c\u5373\u5df2\u5b58\u5728\u76f8\u540c\u952e\u503c\u7684\u884c\uff0c\u53ef\u4ee5\u9009\u62e9\u6267\u884c UPDATE
\u64cd\u4f5c\u6765\u66f4\u65b0\u8be5\u884c\u7684\u6570\u636e\u3002
\u8bf7\u6ce8\u610f\uff0c\u5728\u4f7f\u7528 INSERT INTO \u8bed\u53e5\u65f6\uff0c\u6839\u636e\u8868\u7684\u7ed3\u6784\u548c\u9700\u6c42\uff0c\u63d0\u4f9b\u76f8\u5e94\u7684\u5217\u540d\u548c\u5bf9\u5e94\u7684\u503c\u3002\u5982\u679c\u5b58\u5728\u91cd\u590d\u952e\u7684\u60c5\u51b5\uff0c\u5e76\u4e14\u4f7f\u7528\u4e86 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\uff0c\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u5bf9\u5e94\u7684\u503c\u3002
UPDATE
-- \u521b\u5efa\u8868\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nsalary DECIMAL(10, 2)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO employees (id, name, department, salary)\nVALUES (1, 'John Doe', 'HR', 5000),\n(2, 'Jane Smith', 'Marketing', 6000),\n(3, 'Mike Johnson', 'IT', 7000),\n(4, 'Emily Brown', 'Finance', 8000),\n(5, 'David Wilson', 'HR', 5500);\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id | name | department | salary |\n+------+--------------+------------+---------+\n| 1 | John Doe | HR | 5000.00 |\n| 2 | Jane Smith | Marketing | 6000.00 |\n| 3 | Mike Johnson | IT | 7000.00 |\n| 4 | Emily Brown | Finance | 8000.00 |\n| 5 | David Wilson | HR | 5500.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.01 sec)\n\n-- \u66f4\u65b0\u6570\u636e\uff0c\u4f7f\u7528 UPDATE \u8bed\u53e5\u66f4\u65b0\u4e86\u90e8\u95e8\u4e3a'HR'\u7684\u524d\u4e24\u4e2a\u5458\u5de5\u7684\u85aa\u8d44\uff0c\u85aa\u8d44\u589e\u52a0\u4e86 10%\u3002WHERE \u5b50\u53e5\u6307\u5b9a\u4e86\u66f4\u65b0\u6570\u636e\u7684\u6761\u4ef6\uff0c\u53ea\u6709\u6ee1\u8db3\u90e8\u95e8\u4e3a'HR'\u7684\u884c\u624d\u4f1a\u88ab\u66f4\u65b0\u3002ORDER BY \u5b50\u53e5\u6309\u7167 id \u5217\u8fdb\u884c\u5347\u5e8f\u6392\u5e8f\uff0cLIMIT \u5b50\u53e5\u9650\u5236\u53ea\u66f4\u65b0\u4e24\u884c\u6570\u636e\u3002\nmysql> UPDATE employees\nSET salary = salary * 1.1\nWHERE department = 'HR'\nORDER BY id\nLIMIT 2;\nQuery OK, 2 rows affected (0.02 sec)\n\n-- \u67e5\u770b\u66f4\u65b0\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id | name | department | salary |\n+------+--------------+------------+---------+\n| 2 | Jane Smith | Marketing | 6000.00 |\n| 3 | Mike Johnson | IT | 7000.00 |\n| 4 | Emily Brown | Finance | 8000.00 |\n| 1 | John Doe | HR | 5500.00 |\n| 5 | David Wilson | HR | 6050.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.00 sec)\n
INSERT ... ON DUPLICATE KEY UPDATE
-- \u521b\u5efa\u8868\nCREATE TABLE students (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\ngrade VARCHAR(10)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO students (id, name, age, grade)\nVALUES (1, 'John Doe', 18, 'A'),\n(2, 'Jane Smith', 17, 'B'),\n(3, 'Mike Johnson', 19, 'A'),\n(4, 'Emily Brown', 18, 'A');\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id | name | age | grade |\n+------+--------------+------+-------+\n| 1 | John Doe | 18 | A |\n| 2 | Jane Smith | 17 | B |\n| 3 | Mike Johnson | 19 | A |\n| 4 | Emily Brown | 18 | A |\n+------+--------------+------+-------+\n4 rows in set (0.01 sec)\n\n-- \u66f4\u65b0\u6570\u636e\nmysql> INSERT INTO students (id, name, age, grade)\nVALUES (2, 'Jane Smith', 18, 'A')\nON DUPLICATE KEY UPDATE age = VALUES(age), grade = VALUES(grade);\nQuery OK, 1 row affected (0.01 sec)\n\n-- \u67e5\u770b\u66f4\u65b0\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id | name | age | grade |\n+------+--------------+------+-------+\n| 1 | John Doe | 18 | A |\n| 3 | Mike Johnson | 19 | A |\n| 4 | Emily Brown | 18 | A |\n| 2 | Jane Smith | 18 | A |\n+------+--------------+------+-------+\n4 rows in set (0.00 sec)\n
\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a students
\u7684\u8868\uff0c\u5305\u542b id
\u3001name
\u3001age
\u548c grade
\u56db\u4e2a\u5217\u3002\u7136\u540e\uff0c\u4f7f\u7528 INSERT INTO
\u8bed\u53e5\u63d2\u5165\u4e86\u56db\u884c\u5b66\u751f\u6570\u636e\u3002
\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528 SELECT \u8bed\u53e5\u67e5\u770b\u521d\u59cb\u6570\u636e\u3002\u7136\u540e\uff0c\u4f7f\u7528 INSERT INTO \u8bed\u53e5\u63d2\u5165\u4e86\u4e00\u884c\u5b66\u751f\u6570\u636e\uff0c\u5176\u4e2d id
\u4e3a 2 \u7684\u5b66\u751f\u5df2\u7ecf\u5b58\u5728\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u91cd\u590d\u952e\u7684\u60c5\u51b5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u6765\u66f4\u65b0\u8be5\u884c\u7684\u6570\u636e\u3002\u901a\u8fc7 VALUES \u51fd\u6570\uff0c\u6211\u4eec\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u5bf9\u5e94\u7684\u503c\u3002
\u6700\u540e\uff0c\u4f7f\u7528 SELECT
\u8bed\u53e5\u518d\u6b21\u67e5\u770b\u66f4\u65b0\u540e\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u770b\u5230 id
\u4e3a 2 \u7684\u5b66\u751f\u7684\u5e74\u9f84\u548c\u6210\u7ee9\u5df2\u7ecf\u88ab\u66f4\u65b0\u3002
S3\uff08Simple Storage Service\uff09\u5bf9\u8c61\u5b58\u50a8\u662f\u6307\u4e9a\u9a6c\u900a\u7684\u7b80\u5355\u5b58\u50a8\u670d\u52a1\u3002\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4e0e S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u6765\u5b58\u50a8\u51e0\u4e4e\u4efb\u4f55\u7c7b\u578b\u548c\u5927\u5c0f\u7684\u6570\u636e\uff0c\u5305\u62ec\u6570\u636e\u6e56\u3001\u4e91\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u548c\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089 S3 \u5bf9\u8c61\u670d\u52a1\uff0c\u4f60\u53ef\u4ee5\u5728 AWS \u4e2d\u67e5\u627e\u4e00\u4e9b\u57fa\u672c\u4ecb\u7ecd\u3002
AWS S3 \u5341\u591a\u5e74\u6765\u4e00\u76f4\u975e\u5e38\u6210\u529f\uff0c\u56e0\u6b64\u5b83\u6210\u4e3a\u4e86\u5bf9\u8c61\u5b58\u50a8\u7684\u6807\u51c6\u3002\u56e0\u6b64\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u516c\u6709\u4e91\u5382\u5546\u90fd\u63d0\u4f9b\u4e86\u517c\u5bb9 S3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
MatrixOne \u652f\u6301\u5c06\u6587\u4ef6\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u52a0\u8f7d\u5230\u6570\u636e\u5e93\u4e2d\u3002MatrixOne \u652f\u6301 AWS \u548c\u56fd\u5185\u4e3b\u6d41\u4e91\u5382\u5546\uff08\u963f\u91cc\u4e91\u3001\u817e\u8baf\u4e91\uff09\u3002
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u5bfc\u5165\u6570\u636e\uff1a
Load data
\u5c06\u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u4e2d\u3002\u6b64\u65b9\u6cd5\u4f1a\u5c06\u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4e2d\uff0c\u6240\u6709\u63a5\u4e0b\u6765\u7684\u67e5\u8be2\u90fd\u5c06\u5728 MatrixOne \u4e2d\u8fdb\u884c\u3002\u540c\u65f6\uff0c\u5982\u679c\u8981\u5bfc\u5165\u6765\u81ea\u516c\u6709\u4e91\uff08\u4f8b\u5982 AWS S3 \u6216\u963f\u91cc\u4e91 OSS\uff09\u7684\u6570\u636e\uff0c\u9700\u8981\u5177\u5907\u76f8\u5e94\u7684\u8bbf\u95ee\u6743\u9650\u3002\u901a\u5e38\u6709\u4e24\u79cd\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1a\u89d2\u8272\u8bbf\u95ee\u548c\u5bc6\u94a5\u8bbf\u95ee\u3002
\u89d2\u8272\u8bbf\u95ee\uff1a\u5728\u5b58\u50a8\u6570\u636e\u7684\u516c\u6709\u4e91\u8d26\u6237\u4e2d\u521b\u5efa\u4e00\u4e2a\u7279\u5b9a\u89d2\u8272\uff0c\u8be5\u89d2\u8272\u88ab\u6388\u6743\u8ba9 MatrixOne \u5e94\u7528\u4f7f\u7528\u4ee5\u83b7\u53d6\u6570\u636e\u7684\u6743\u9650\u3002\u8fd9\u79cd\u65b9\u5f0f\u66f4\u4e3a\u5b89\u5168\uff0c\u540c\u65f6\u4e5f\u66f4\u52a0\u4fbf\u4e8e\u7ba1\u7406\u548c\u8c03\u6574\u6570\u636e\u8bbf\u95ee\u6743\u9650\u3002
\u5bc6\u94a5\u8bbf\u95ee\uff1a\u901a\u8fc7\u4f7f\u7528\u62e5\u6709\u6570\u636e\u8bbf\u95ee\u6743\u9650\u7684\u7528\u6237\u7684 Access Key ID
\u548c Secret Access Key
\u6765\u83b7\u53d6\u6570\u636e\u3002\u8fd9\u79cd\u65b9\u5f0f\u76f8\u5bf9\u7b80\u5355\uff0c\u4f46\u4e0d\u591f\u5b89\u5168\uff0c\u56e0\u4e3a\u4e00\u65e6 Access Key ID
\u548c Secret Access Key
\u6cc4\u9732\uff0c\u53ef\u80fd\u4f1a\u9020\u6210\u4e25\u91cd\u540e\u679c\u3002
LOAD DATA
","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA\n| URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com Note:LOAD DATA
\u4ec5\u652f\u6301\u83b7\u53d6 AWS \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u548c\u963f\u91cc\u4e91\u5916\u7f51\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002 access_key_id Access key ID\u3002\u7528\u4e8e\u8eab\u4efd\u9a8c\u8bc1\u7684\u8bbf\u95ee\u5bc6\u94a5 ID\u3002 secret_access_key Secret access key\u3002\u4e0e\u8bbf\u95ee\u5bc6\u94a5 ID \u76f8\u5173\u8054\u7684\u5bc6\u94a5\u3002 bucket \u6307\u5b9a S3 \u5b58\u50a8\u4e2d\u7684\u6876\uff08Bucket\uff09 role_arn AWS \u89d2\u8272\u7684 Amazon \u8d44\u6e90\u540d\u79f0\uff08ARN\uff09\uff0c\u901a\u5e38\u7528\u4e8e\u8de8\u8d26\u6237\u8bbf\u95ee\u3002Note: \u63a8\u8350\u4f7f\u7528\u89d2\u8272\u8bbf\u95ee\u7684\u65b9\u5f0f\u3002\u5982\u679c\u4f60\u9009\u62e9\u89d2\u8272\u8bbf\u95ee\u7684\u65b9\u5f0f\uff0c\u5219\u65e0\u9700\u586b\u5199 access_key_id
\u548c secret_access_key
\uff0c\u4ec5\u586b\u5199\u53c2\u6570 role_arn
\u3002 external_id \u7528\u4e8e\u4e0e\u89d2\u8272 ARN \u4e00\u8d77\u4f7f\u7528\u7684\u5916\u90e8 ID\u3002 filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002 \u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
# LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"bucket\"='test-load-mo', \"role_arn\"='xxxx', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"bucket\"='test-load-data', \"role_arn\"='xxxx', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
# LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-mo', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-data', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression\nLOAD DATA URL s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
Note
MatrixOne \u63d0\u4f9b\u4e86 S3 \u9a8c\u8bc1\u4fe1\u606f\u7684\u5b89\u5168\u4fdd\u8bc1\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u654f\u611f\u4fe1\u606f\u5728\u7cfb\u7edf\u8868\uff08statement_info\uff09\u8bb0\u5f55\u91cc\u5c06\u88ab\u9690\u85cf\uff0c\u4fdd\u8bc1\u4f60\u7684\u8d26\u6237\u5b89\u5168\u3002
\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4ece AWS S3 \u52a0\u8f7d csv \u6587\u4ef6\u7684\u8fc7\u7a0b\u3002
\u5982\u679c\u4f60\u5df2\u7ecf\u62e5\u6709\u4e00\u4e2a AWS \u8d26\u6237\u5e76\u4e14\u5df2\u7ecf\u5728\u4f60\u7684 S3 \u670d\u52a1\u4e2d\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u90a3\u4e48\u8bf7\u7ee7\u7eed\u9605\u8bfb\u672c\u6559\u7a0b\u7ae0\u8282\u3002
\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u8bf7\u5148\u6ce8\u518c\u5e76\u4e0a\u4f20\u4f60\u7684\u6570\u636e\u6587\u4ef6\uff1b\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b AWS S3 \u5b98\u65b9\u6559\u7a0b\u3002\u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u60f3\u8981\u4e0a\u4f20\u5230\u963f\u91cc\u4e91 OSS \u6216\u8005\u817e\u8baf\u4e91 COS \u4e0a\uff0c\u90a3\u4e48\u64cd\u4f5c\u6d41\u7a0b\u4e0e AWS S3 \u7c7b\u4f3c\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u8fdb\u5165 AWS S3 > buckets > \u521b\u5efa\u5b58\u50a8\u6876\uff0c\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u516c\u5171\u8bbf\u95ee\u6743\u9650\u7684\u5b58\u50a8\u6876 test-loading \u5e76\u4e0a\u4f20\u6587\u4ef6 char_varchar_1.csv\u3002
\u83b7\u53d6\u6216\u521b\u5efa\u4f60\u7684 AWS Access key\u3002\u8f93\u5165 Your Account Name > Security Credentials\u3002
\u8fdb\u5165\u5230 Security Credentials > Create access key\uff0c\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 Access key
\u548c Secret access key
\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u8868\uff0cSQL \u793a\u4f8b\u5982\u4e0b\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u6587\u4ef6\u5bfc\u5165 MatrixOne\uff1a
LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"bucket\"='test-loading', \"role_arn\"='xxxx\", \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
\u5bfc\u5165\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c SQL \u8bed\u53e5\u68c0\u67e5\u6587\u4ef6\u5bfc\u5165\u662f\u5426\u6210\u529f\uff1a
mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (0.03 sec)\n
create external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} [{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}];\n
Note
MatrixOne \u5f53\u524d\u4ec5\u652f\u6301\u5bf9\u5916\u90e8\u8868\u8fdb\u884c select
\uff0c\u6682\u4e0d\u652f\u6301 Delete
\uff0cinsert
\uff0cupdate
\u3002
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002\u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
\u6709\u5173\u5916\u90e8\u8868\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u521b\u5efa\u5916\u90e8\u8868\u3002
\u8bed\u6cd5\u793a\u4f8b\uff1a
## Create a external table for a .csv file from AWS S3\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n\n## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' ignore 1 lines;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#s3","title":"\u6559\u7a0b\uff1a\u4f7f\u7528 S3 \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868","text":"\u672c\u6559\u7a0b\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4f7f\u7528\u6765\u81ea AWS S3 \u7684. csv \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868\u7684\u6574\u4e2a\u8fc7\u7a0b\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u4e0b\u8f7d\u6570\u636e\u6587\u4ef6\u3002\u8fdb\u5165 AWS S3 > buckets\uff0c\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u516c\u5171\u8bbf\u95ee\u6743\u9650\u7684\u5b58\u50a8\u6876 test-loading \u5e76\u4e0a\u4f20\u6587\u4ef6 char_varchar_1.csv\u3002
\u83b7\u53d6\u6216\u521b\u5efa\u4f60\u7684 AWS Access key\u3002\u8f93\u5165 Your Account Name > Security Credentials\uff0c\u83b7\u53d6\u4f60\u73b0\u6709\u7684\u8bbf\u95ee\u5bc6\u94a5\u6216\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8bbf\u95ee\u5bc6\u94a5\u3002
\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 Access key
\u548c Secret access key
\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u6307\u5b9a S3 \u6587\u4ef6\u5230\u5916\u90e8\u8868\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u6570\u636e\u7684\u7ed3\u679c\u3002\u4f60\u5c06\u53ef\u4ee5\u770b\u5230\u67e5\u8be2\u901f\u5ea6\u660e\u663e\u6162\u4e8e\u4ece\u672c\u5730\u8868\u67e5\u8be2\u3002
select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (1.32 sec)\n
\uff08\u9009\u505a\uff09\u5982\u679c\u9700\u8981\u5c06\u5916\u90e8\u8868\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u6570\u636e\u8868\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\uff1a \u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u8868 t2\uff1a
create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u5916\u90e8\u8868 t1 \u5bfc\u5165\u5230 t2\uff1a
insert into t2 select * from t1;\n
MatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u5c06\u5927\u91cf\u884c\u63d2\u5165\u81f3 MatrixOne \u6570\u636e\u8868\uff0c\u4e5f\u652f\u6301\u4f7f\u7528 SOURCE
\u547d\u4ee4\u5c06\u8868\u7ed3\u6784\u548c\u6570\u636e\u5bfc\u5165\u6574\u4e2a\u6570\u636e\u5e93\u3002
LOAD DATA
","text":"MatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u4ece\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u6216 S3 \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u6279\u91cf\u5bfc\u5165 csv \u6587\u4ef6\u3001jsonline \u6587\u4ef6\u3002
\u6839\u636e\u6570\u636e\u6587\u4ef6\u7c7b\u578b\u4e0d\u540c\u7684\u60c5\u51b5\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u5bfc\u5165 csv \u548c jl \u683c\u5f0f\u3002
\u6839\u636e\u6570\u636e\u5b58\u50a8\u4f4d\u7f6e\u4e0d\u540c\u7684\u60c5\u51b5\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u4ece\u672c\u5730\u8fdb\u884c\u5bfc\u5165\u548c\u4ece\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff08Simple Storage Service, S3) \u5bfc\u5165\u3002
SOURCE
","text":"MatrixOne \u652f\u6301\u4f7f\u7528 SOURCE
\u547d\u4ee4\u4ece\u5916\u90e8 SQL \u811a\u672c\u6587\u4ef6\u6267\u884c SQL \u8bed\u53e5\u5bfc\u5165\u6574\u4e2a\u6570\u636e\u5e93\u7ed3\u6784\uff08\u5305\u62ec\u8868\u7ed3\u6784\u548c\u6570\u636e\uff09\u3002SOURCE
\u547d\u4ee4\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u53ef\u80fd\u6ca1\u6709 LOAD DATA
\u547d\u4ee4\u6027\u80fd\u9ad8\uff0c\u56e0\u4e3a\u5b83\u9700\u8981\u89e3\u6790\u548c\u6267\u884c\u6bcf\u4e2a SQL \u8bed\u53e5\u3002
LOAD DATA
\u5bfc\u5165\u6570\u636e\u7684\u53c2\u6570\u8bf4\u660e\u3002\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5728 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u65f6\u5982\u4f55\u5b8c\u6210 csv \u683c\u5f0f\u6570\u636e\u5bfc\u5165\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#_1","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
LOAD DATA LOCAL\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#mysql-client-load-data","title":"MySQL Client \u4e2d\u4f7f\u7528Load data
\u547d\u4ee4\u5bfc\u5165\u6570\u636e","text":"\u4f60\u53ef\u4ee5\u4f7f\u7528 Load Data
\u4ece\u5927\u6570\u636e\u6587\u4ef6\u4e2d\u5bfc\u5165\u6570\u636e\uff0c\u672c\u7ae0\u5c06\u4ecb\u7ecd\u5982\u4f55\u5bfc\u5165 csv \u683c\u5f0f\u6587\u4ef6\u3002
Note: csv\uff08\u9017\u53f7\u5206\u9694\u503c\uff09\u6587\u4ef6\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u6587\u4ef6\u7c7b\u578b\uff0c\u53ef\u5728 Excel \u4e2d\u521b\u5efa\u6216\u7f16\u8f91\uff0ccsv \u6587\u4ef6\u4e0d\u662f\u91c7\u7528\u591a\u5217\u7684\u5f62\u5f0f\u5b58\u50a8\u4fe1\u606f\uff0c\u800c\u662f\u4f7f\u7528\u9017\u53f7\u5206\u9694\u7684\u5f62\u5f0f\u5b58\u50a8\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#_3","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#matrixone","title":"\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a","text":"\u5728 MatrixOne \u4e2d\u6267\u884c Load Data
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MySQL \u5ba2\u6237\u7aef\u5bf9\u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\u6267\u884c LOAD DATA
\uff1a
mysql> LOAD DATA INFILE '/tmp/xxx.csv'\nINTO TABLE table_name\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
\u5728 MatrixOne \u4e2d\u6267\u884c LOAD DATA LOCAL
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h <mo-host-ip> -P 6001 -uroot -p111 --local-infile\n
\u5728 MySQL \u5ba2\u6237\u7aef\u5bf9\u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\u6267\u884c LOAD DATA LOCAL
\uff1a
mysql> LOAD DATA LOCAL INFILE '/tmp/xxx.csv'\nINTO TABLE table_name\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
Load data
","text":"\u5982\u679c\u4f60\u901a\u8fc7 Docker \u5b89\u88c5 MatrixOne\uff0c\u90a3\u4e48\u6587\u4ef6\u9ed8\u8ba4\u5b58\u50a8\u5728 Docker \u955c\u50cf\u4e2d\u3002\u5982\u679c\u4f60\u9700\u8981\u5c06\u6587\u4ef6\u5b58\u50a8\u5728\u672c\u5730\u76ee\u5f55\uff0c\u4f60\u9700\u8981\u5148\u5c06\u672c\u5730\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u3002
\u5728\u4ee5\u4e0b\u793a\u4f8b\u4e2d\uff0c\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84 ~/tmp/docker_loaddata_demo/
\u6302\u8f7d\u5230 MatrixOne Docker \u955c\u50cf\uff0c\u5e76\u6620\u5c04\u5230 Docker \u5bb9\u5668\u5185\u7684 /ssb-dbgen-path
\u76ee\u5f55\u3002\u672c\u7bc7\u793a\u4f8b\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 Docker \u52a0\u8f7d\u6570\u636e\u3002
\u4e0b\u8f7d\u6570\u636e\u96c6\uff0c\u5e76\u4e14\u5c06\u6570\u636e\u96c6\u5b58\u50a8\u5230\u672c\u5730 ~/tmp/docker_loaddata_demo/ \u8def\u5f84\u4e0b\uff1a
cd ~/tmp/docker_loaddata_demo/\nwget https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
\u89e3\u538b\u6570\u636e\u96c6\uff1a
tar -jxvf lineorder_flat.tar.bz2\n
\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne\uff0c\u542f\u52a8\u65f6\u5c06\u5b58\u653e\u4e86\u6570\u636e\u6587\u4ef6\u7684\u76ee\u5f55 ~/tmp/docker_loaddata_demo/ \u6302\u8f7d\u5230\u5bb9\u5668\u7684\u67d0\u4e2a\u76ee\u5f55\u4e0b\uff0c\u8fd9\u91cc\u5bb9\u5668\u76ee\u5f55\u4ee5 /ssb-dbgen-path \u4e3a\u4f8b\uff1a
sudo docker run --name matrixone --privileged -d -p 6001:6001 -v ~/tmp/docker_loaddata_demo/:/ssb-dbgen-path:rw matrixorigin/matrixone:1.2.1\n
\u8fde\u63a5 MatrixOne \u670d\u52a1\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note: \u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\uff0c\u5373\u6570\u636e\u6587\u4ef6\u5728\u4f60\u6240\u4f7f\u7528\u7684\u5ba2\u6237\u7aef\u673a\u5668\u4e0a\u65f6\uff0c\u90a3\u4e48\u4f60\u8fde\u63a5 MatrixOne \u670d\u52a1\u4e3b\u673a\u9700\u8981\u4f7f\u7528\u547d\u4ee4\u884c\uff1amysql -h <mo-host-ip> -P 6001 -uroot -p111 --local-infile
\uff1b\u5e76\u4e14\u5bfc\u5165\u7684\u547d\u4ee4\u884c\u9700\u8981\u4f7f\u7528 LOAD DATA LOCAL INFILE
\u8bed\u6cd5\u3002
\u5728 MatrixOne \u4e2d\u65b0\u5efa\u8868 lineorder_flat\uff0c\u5e76\u4e14\u5c06\u6570\u636e\u96c6\u5bfc\u5165\u81f3 MatriOne\uff1a
mysql> create database if not exists ssb;\nmysql> use ssb;\nmysql> drop table if exists lineorder_flat;\nmysql> CREATE TABLE lineorder_flat(\n LO_ORDERKEY bigint key,\n LO_LINENUMBER int,\n LO_CUSTKEY int,\n LO_PARTKEY int,\n LO_SUPPKEY int,\n LO_ORDERDATE date,\n LO_ORDERPRIORITY char(15),\n LO_SHIPPRIORITY tinyint,\n LO_QUANTITY double,\n LO_EXTENDEDPRICE double,\n LO_ORDTOTALPRICE double,\n LO_DISCOUNT double,\n LO_REVENUE int unsigned,\n LO_SUPPLYCOST int unsigned,\n LO_TAX double,\n LO_COMMITDATE date,\n LO_SHIPMODE char(10),\n C_NAME varchar(25),\n C_ADDRESS varchar(25),\n C_CITY char(10),\n C_NATION char(15),\n C_REGION char(12),\n C_PHONE char(15),\n C_MKTSEGMENT char(10),\n S_NAME char(25),\n S_ADDRESS varchar(25),\n S_CITY char(10),\n S_NATION char(15),\n S_REGION char(12),\n S_PHONE char(15),\n P_NAME varchar(22),\n P_MFGR char(6),\n P_CATEGORY char(7),\n P_BRAND char(9),\n P_COLOR varchar(11),\n P_TYPE varchar(25),\n P_SIZE int,\n P_CONTAINER char(10)\n);\nmysql> load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u6570\u636e\u7684\u884c\u6570\uff1a
select count(*) from lineorder_flat;\n/*\n expected results:\n */\n+----------+\n| count(*) |\n+----------+\n| 10272594 |\n+----------+\n
\u52a0\u8f7d csv
\u683c\u5f0f\u652f\u6301 JSON \u7c7b\u578b\uff0c\u4f46\u662f\u9700\u8981\u786e\u4fdd JSON \u5185\u4e0d\u542b\u6709\u5b57\u6bb5\u7ec8\u6b62\u7b26\u53f7\uff0c\u5982\u679c JSON \u5185\u542b\u6709\u5b57\u6bb5\u7ec8\u6b62\u7b26\u53f7\uff0c\u90a3\u4e48 JSON \u9700\u8981\u7528\u53cc\u5f15\u53f7\u5305\u88f9\u8d77\u6765\u3002\u4f8b\u5982\uff1a
\"{\"a\":1, \"b\":2}\", 2
{\"a\":1, \"b\":2}, 2
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06 JSONLines \u683c\u5f0f\u6570\u636e\uff08\u5373 jl \u6216 jsonl \u6587\u4ef6\uff09\u5bfc\u5165 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#jsonlines_1","title":"\u6709\u5173 JSONLines \u683c\u5f0f","text":"JSON\uff08JavaScript Object Notation\uff09\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u3002\u4f60\u53ef\u4ee5\u53c2\u89c1\u5b98\u65b9\u6587\u6863\u83b7\u53d6\u66f4\u591a\u6709\u5173 JSON \u7684\u4fe1\u606f\u3002
JSONLines \u6587\u672c\u683c\u5f0f\uff0c\u4e5f\u79f0\u4e3a\u6362\u884c\u7b26\u5206\u9694\u7684 JSON\uff0c\u5b83\u662f\u4e00\u79cd\u66f4\u4e3a\u65b9\u4fbf\u5b58\u50a8\u7ed3\u6784\u5316\u7684\u6570\u636e\u683c\u5f0f\uff0c\u53ef\u4ee5\u4e00\u6b21\u5904\u7406\u4e00\u6761\u8bb0\u5f55\u3002\u5b83\u6bcf\u4e00\u884c\u90fd\u662f\u5b8c\u6574\u3001\u5408\u6cd5\u7684 JSON \u503c\uff1b\u5b83\u91c7\u7528 \\n
\u4f5c\u4e3a\u884c\u5206\u9694\u7b26\u3002JSONLines \u7684\u6bcf\u4e00\u884c\u90fd\u662f\u72ec\u7acb\u7684\uff0c\u56e0\u6b64\u884c\u7684\u5f00\u5934\u6216\u7ed3\u5c3e\u4e0d\u9700\u8981\u9017\u53f7\u3002JSONLines \u7684\u5168\u90e8\u5185\u5bb9\u4e5f\u4e0d\u9700\u8981\u7528 []
\u6216 {}
\u62ec\u8d77\u6765\u3002
JSONLines \u5bf9\u4e8e\u6570\u636e\u6d41\u6765\u8bf4\u66f4\u4e3a\u53cb\u597d\u3002\u56e0\u4e3a\u6bcf\u4e00\u4e2a\u65b0\u7684\u884c\u610f\u5473\u7740\u4e00\u4e2a\u5355\u72ec\u7684\u6761\u76ee\uff0c\u56e0\u6b64 JSON \u884c\u683c\u5f0f\u7684\u6587\u4ef6\u53ef\u4ee5\u6d41\u5f0f\u4f20\u8f93\u3002\u5b83\u4e0d\u9700\u8981\u81ea\u5b9a\u4e49\u89e3\u6790\u5668\u3002\u53ea\u9700\u8bfb\u53d6\u4e00\u884c\uff0c\u89e3\u6790\u4e3a JSON\uff0c\u518d\u8bfb\u53d6\u4e00\u884c\uff0c\u89e3\u6790\u4e3a JSON\uff0c\u4e00\u76f4\u5230\u5b8c\u6210\u3002
JSONLines \u683c\u5f0f\u6709\u4ee5\u4e0b\u4e09\u4e2a\u8981\u6c42\uff1a
UTF-8 \u7f16\u7801\uff1aJSON \u5141\u8bb8\u4ec5\u4f7f\u7528 ASCII \u8f6c\u4e49\u5e8f\u5217\u5bf9 Unicode \u5b57\u7b26\u4e32\u8fdb\u884c\u7f16\u7801\uff0c\u4f46\u662f\u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\uff0c\u8fd9\u4e9b\u8f6c\u4e49\u96be\u4ee5\u9605\u8bfb\u3002JSON Lines \u6587\u4ef6\u7684\u4f5c\u8005\u53ef\u4ee5\u9009\u62e9\u8f6c\u4e49\u5b57\u7b26\u6765\u5904\u7406\u7eaf ASCII \u6587\u4ef6\u3002
\u6bcf\u884c\u90fd\u662f\u4e00\u4e2a\u5408\u6cd5\u7684 JSON \u503c\uff1a\u6700\u5e38\u89c1\u7684\u503c\u662f\u5bf9\u8c61\u6216\u6570\u7ec4\uff0c\u4efb\u4f55 JSON \u503c\u90fd\u662f\u5408\u6cd5\u7684\u3002
\u884c\u5206\u9694\u7b26\u4e3a \\n
\uff1a\u7531\u4e8e\u5728\u89e3\u6790 JSON \u503c\u65f6\u4f1a\u9690\u5f0f\u5ffd\u7565\u5468\u56f4\u7684\u7a7a\u683c\u5728\u652f\u6301\u884c\u5206\u9694\u7b26 \\n
\u7684\u540c\u65f6\u4e5f\u652f\u6301\u201c\\r\\n\u201d\u3002
JSONLines \u683c\u5f0f\u53ea\u9700\u8981\u6bcf\u4e00\u884c\u90fd\u6709\u4e00\u4e2a\u6709\u6548\u7684 JSON \u503c\u3002\u4f46 MatrixOne \u9700\u8981\u66f4\u7ed3\u6784\u5316\u7684 JSONLines \u683c\u5f0f\uff0c\u5728 MatrixOne \u4e2d\u53ea\u5141\u8bb8\u5177\u6709\u76f8\u540c\u7c7b\u578b\u503c\u548c\u666e\u901a\u7ed3\u6784\u7684 JSON \u5bf9\u8c61\u6216 JSON \u6570\u7ec4\u3002\u5982\u679c\u60a8\u7684 JSONLines \u6587\u4ef6\u6709\u5d4c\u5957\u7ed3\u6784\uff0cMatrixOne \u6682\u65f6\u4e0d\u652f\u6301\u52a0\u8f7d\u5b83\u3002
\u4e00\u4e2a\u6709\u6548\u5bf9\u8c61 JSONLines \u793a\u4f8b\uff1a
{\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\"}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\"}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\"}\n
\u65e0\u6548\u5bf9\u8c61 JSONLines \u793a\u4f8b\uff08\u5177\u6709\u5d4c\u5957\u7ed3\u6784\uff09\uff1a
{\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\",\"children\":[\"Tom\"]}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\",\"children\":[\"Jessika\",\"Antony\",\"Jack\"]}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\",\"children\":[\"Jerry\",\"Karol\"]}\n
\u4e00\u4e2a\u6709\u6548\u6570\u7ec4 JSONLines \u793a\u4f8b\uff0c\u5b83\u66f4\u50cf\u662f csv \u683c\u5f0f\u3002
[\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n
\u65e0\u6548\u6570\u7ec4 JSONLines \u793a\u4f8b\uff08\u65e0\u6548\u539f\u56e0\u662f\u56e0\u4e3a\u6570\u636e\u7c7b\u578b\u548c\u5217\u53f7\u4e0d\u5339\u914d\uff09\uff1a
[\"Gilbert\", \"2013\", 24, true, 100]\n[\"Alexa\", \"2013\", \"twenty nine\", true]\n[\"May\", \"2012B\", 14, \"no\"]\n[\"Deloise\", \"2012A\", 19, true, 40]\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#_1","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA INFILE\n {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS]\n [PARALLEL {'TRUE' | 'FALSE'}];\n
LOAD DATA LOCAL INFILE\n {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS]\n [PARALLEL {'TRUE' | 'FALSE'}];\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u503c \u5fc5\u987b/\u53ef\u9009 \u63cf\u8ff0 filepath String \u5fc5\u987b \u6587\u4ef6\u8def\u5f84 compression auto/none/bz2/gzip/lz4 \u53ef\u9009 \u538b\u7f29\u683c\u5f0f format csv/jsonline \u53ef\u9009 \u52a0\u8f7d\u6587\u4ef6\u683c\u5f0f\uff0c\u9ed8\u8ba4 .csv jsondata object/array \u53ef\u9009 JSON \u6570\u636e\u683c\u5f0f\u3002\u5982\u679cformat
\u4e3a jsonline\uff0c\u5219\u5fc5\u987b\u6307\u5b9a jsondata table_name String \u5fc5\u987b \u9700\u52a0\u8f7d\u6570\u636e\u5230\u8868\u7684\u8868\u540d\u79f0 x Number \u53ef\u9009 \u52a0\u8f7d\u65f6\u8981\u5ffd\u7565\u7684\u884c JSONLines \u683c\u5f0f\u6570\u636e\u7684 DDL \u6307\u5357
\u5728\u5c06 JSONLines \u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u8868\u3002
\u7531\u4e8e JSON \u6570\u636e\u7c7b\u578b\u4e0e MatrixOne \u7684\u6570\u636e\u7c7b\u578b\u4e0d\u540c\uff0c\u53c2\u89c1\u4e0b\u8868\uff0c\u53ef\u4ee5\u67e5\u770b JSON \u6570\u636e\u7c7b\u578b\u5bf9\u5e94\u5230 MatrixOne \u4e2d\u65f6\u7684\u6570\u636e\u7c7b\u578b\uff1a
JSON \u7c7b\u578b MatrixOne \u4e2d\u7684\u6570\u636e\u7c7b\u578b String VARCHAR (\u5b9a\u957f\u5b57\u7b26\u4e32) String TEXT (\u957f\u6587\u672c\u6570\u636e) String DATETIME or TIMESTAMP (\u683c\u5f0f\u4e3a \"YYYY-MM-DD HH:MM:SS.XXXXXX\") String DATE (\u683c\u5f0f\u4e3a \"YYYY-MM-DD\") String TIME (\u683c\u5f0f\u4e3a \"HH-MM-SS.XXXXXX\") Number INT (\u6574\u6570) Number FLOAT \u6216 DOUBLE (\u6d6e\u70b9\u6570) Boolean BOOL(true/false) Object Json \u7c7b\u578b Array Json \u7c7b\u578b Null \u652f\u6301\u6240\u6709\u7c7b\u578b\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u5148\u4f7f\u7528 SQL \u8bed\u53e5\u4e3a JSONLines \u683c\u5f0f\u6587\u4ef6\u5148\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u8868\uff0c\u5982\u4e0b\u6240\u793a\uff1a
mysql> create table t1 (name varchar(100), session varchar(100), score int, completed bool);\n
[\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n
\u793a\u4f8b
\u4ee5\u4e0b\u4ee3\u7801\u6bb5\u662f\u5c06 JSONLines \u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u7684\u5b8c\u6574 SQL \u793a\u4f8b\u3002
#Load a BZIP2 compressed jsonline object file\nload data infile {'filepath'='data.bzip2', 'compression'='bz2','format'='jsonline','jsondata'='object'} into table db.a\n\n#Load a plain jsonline array file\nload data infile {'filepath'='data.jl', 'format'='jsonline','jsondata'='array'} into table db.a\n\n#Load a gzip compressed jsonline array file and ignore the first line\nload data infile {'filepath'='data.jl.gz', 'compression'='gzip','format'='jsonline','jsondata'='array'} into table db.a ignore 1 lines;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#_2","title":"\u6559\u7a0b\u793a\u4f8b","text":"\u5728\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u52a0\u8f7d\u4e24\u4e2a\u5177\u6709\u5bf9\u8c61\u548c\u6570\u7ec4 json \u683c\u5f0f\u7684 jsonline \u6587\u4ef6\u3002
Note: \u672c\u6559\u7a0b\u4e2d\uff0c\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u3002\u5982\u679c\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 Load Data
\u8fdb\u884c\u6570\u636e\u5bfc\u5165\u3002
\u51c6\u5907\u6570\u636e\u3002\u4f60\u4e5f\u53ef\u4ee5\u4e0b\u8f7d\u4f7f\u7528\u6211\u4eec\u51c6\u5907\u597d\u7684 jl \u6587\u4ef6\u3002
\u6253\u5f00\u7ec8\u7aef\uff0c\u8fdb\u5165\u5230 jl \u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c\u8f93\u5165\u4e0b\u9762\u7684\u547d\u4ee4\u884c\uff0c\u663e\u793a\u6587\u4ef6\u5185\u7684\u5177\u4f53\u5185\u5bb9\uff1a
> cd /$filepath\n> head jsonline_object.jl\n{\"col1\":true,\"col2\":1,\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":121.11}\n{\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\"}\n{\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\"}\n{\"col2\":1,\"col3\":\"var\",\"col1\":true,\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col8\":121.11}\n> head jsonline_array.jl\n[true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\"]\n
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5\u5230 MatrixOne\u3002
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note: \u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\uff0c\u5373\u6570\u636e\u6587\u4ef6\u5728\u4f60\u6240\u4f7f\u7528\u7684\u5ba2\u6237\u7aef\u673a\u5668\u4e0a\u65f6\uff0c\u90a3\u4e48\u4f60\u8fde\u63a5 MatrixOne \u670d\u52a1\u4e3b\u673a\u9700\u8981\u4f7f\u7528\u547d\u4ee4\u884c\uff1amysql -h <mo-host-ip> -P <mo-host-ip> -uroot -p111 --local-infile
\uff1b\u5e76\u4e14\u5bfc\u5165\u7684\u547d\u4ee4\u884c\u9700\u8981\u4f7f\u7528 LOAD DATA LOCAL INFILE
\u8bed\u6cd5\u3002
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MatrixOne \u5efa\u8868\uff1a
create database db1;\nuse db1;\ndrop table if exists t1;\ncreate table t1(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\ndrop table if exists t2;\ncreate table t2(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\n
\u5728 MySQL \u5ba2\u6237\u7aef\u5bf9\u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\u6267\u884c LOAD DATA
\uff0c\u5bfc\u5165 jsonline_object.jl \u548c jsonline_array.jl \u6587\u4ef6\uff1a
load data infile {'filepath'='$filepath/jsonline_object.jl','format'='jsonline','jsondata'='object'} into table t1;\nload data infile {'filepath'='$filepath/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t2;\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u7ed3\u679c\uff1a
select * from t1;\ncol1 col2 col3 col4 col5 col6 col7 col8\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\n
Note
\u5982\u679c\u60a8\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne\uff0c\u5f53\u4f60\u9700\u8981\u5bfc\u5165 JSONline \u6587\u4ef6\u65f6\uff0c\u8bf7\u786e\u4fdd\u4f60\u5df2\u5c06\u6570\u636e\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u3002\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b\u5bfc\u5165 csv \u683c\u5f0f\u6570\u636e\uff0c\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 Docker \u6302\u8f7d\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/","title":"\u4ece\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165\u6587\u4ef6","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#_2","title":"\u6982\u8ff0","text":"S3\uff08Simple Storage Service\uff09\u5bf9\u8c61\u5b58\u50a8\u662f\u6307\u4e9a\u9a6c\u900a\u7684\u7b80\u5355\u5b58\u50a8\u670d\u52a1\u3002\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4e0e S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u6765\u5b58\u50a8\u51e0\u4e4e\u4efb\u4f55\u7c7b\u578b\u548c\u5927\u5c0f\u7684\u6570\u636e\uff0c\u5305\u62ec\u6570\u636e\u6e56\u3001\u4e91\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u548c\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089 S3 \u5bf9\u8c61\u670d\u52a1\uff0c\u4f60\u53ef\u4ee5\u5728 AWS \u4e2d\u67e5\u627e\u4e00\u4e9b\u57fa\u672c\u4ecb\u7ecd\u3002
AWS S3 \u5341\u591a\u5e74\u6765\u4e00\u76f4\u975e\u5e38\u6210\u529f\uff0c\u56e0\u6b64\u5b83\u6210\u4e3a\u4e86\u5bf9\u8c61\u5b58\u50a8\u7684\u6807\u51c6\u3002\u56e0\u6b64\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u516c\u6709\u4e91\u5382\u5546\u90fd\u63d0\u4f9b\u4e86\u517c\u5bb9 S3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
MatrixOne \u652f\u6301\u5c06\u6587\u4ef6\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u52a0\u8f7d\u5230\u6570\u636e\u5e93\u4e2d\u3002MatrixOne \u652f\u6301 AWS \u548c\u56fd\u5185\u4e3b\u6d41\u4e91\u5382\u5546\uff08\u963f\u91cc\u4e91\u3001\u817e\u8baf\u4e91\uff09\u3002
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u5bfc\u5165\u6570\u636e\uff1a
Load data
\u5c06\u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u4e2d\u3002\u6b64\u65b9\u6cd5\u4f1a\u5c06\u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4e2d\uff0c\u6240\u6709\u63a5\u4e0b\u6765\u7684\u67e5\u8be2\u90fd\u5c06\u5728 MatrixOne \u4e2d\u8fdb\u884c\u3002LOAD DATA
","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA\n| URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 role_arn external_id filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002\u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
\u8bed\u6cd5\u793a\u4f8b\uff1a
# LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-mo', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-data', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression\nLOAD DATA URL s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
Note
MatrixOne \u63d0\u4f9b\u4e86 S3 \u9a8c\u8bc1\u4fe1\u606f\u7684\u5b89\u5168\u4fdd\u8bc1\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u654f\u611f\u4fe1\u606f\u5728\u7cfb\u7edf\u8868\uff08statement_info\uff09\u8bb0\u5f55\u91cc\u5c06\u88ab\u9690\u85cf\uff0c\u4fdd\u8bc1\u4f60\u7684\u8d26\u6237\u5b89\u5168\u3002
\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4ece AWS S3 \u52a0\u8f7d. csv \u6587\u4ef6\u7684\u8fc7\u7a0b\u3002
\u5982\u679c\u4f60\u5df2\u7ecf\u62e5\u6709\u4e00\u4e2a AWS \u8d26\u6237\u5e76\u4e14\u5df2\u7ecf\u5728\u4f60\u7684 S3 \u670d\u52a1\u4e2d\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u90a3\u4e48\u8bf7\u7ee7\u7eed\u9605\u8bfb\u672c\u6559\u7a0b\u7ae0\u8282\u3002
\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u8bf7\u5148\u6ce8\u518c\u5e76\u4e0a\u4f20\u4f60\u7684\u6570\u636e\u6587\u4ef6\uff1b\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b AWS S3 \u5b98\u65b9\u6559\u7a0b\u3002\u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u60f3\u8981\u4e0a\u4f20\u5230\u963f\u91cc\u4e91 OSS \u6216\u8005\u817e\u8baf\u4e91 COS \u4e0a\uff0c\u90a3\u4e48\u64cd\u4f5c\u6d41\u7a0b\u4e0e AWS S3 \u7c7b\u4f3c\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 `Access key` \u548c `Secret access key`\u3002\n
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u8868\uff0cSQL \u793a\u4f8b\u5982\u4e0b\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u6587\u4ef6\u5bfc\u5165 MatrixOne\uff1a
LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
\u5bfc\u5165\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c SQL \u8bed\u53e5\u68c0\u67e5\u6587\u4ef6\u5bfc\u5165\u662f\u5426\u6210\u529f\uff1a
mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (0.03 sec)\n
create external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} [{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}];\n
Note
MatrixOne \u5f53\u524d\u4ec5\u652f\u6301\u5bf9\u5916\u90e8\u8868\u8fdb\u884c select
\uff0c\u6682\u4e0d\u652f\u6301 Delete
\uff0cinsert
\uff0cupdate
\u3002
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002\u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
\u6709\u5173\u5916\u90e8\u8868\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u521b\u5efa\u5916\u90e8\u8868\u3002
\u8bed\u6cd5\u793a\u4f8b\uff1a
## Create a external table for a .csv file from AWS S3\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n\n## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' ignore 1 lines;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#s3","title":"\u6559\u7a0b\uff1a\u4f7f\u7528 S3 \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868","text":"\u672c\u6559\u7a0b\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4f7f\u7528\u6765\u81ea AWS S3 \u7684. csv \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868\u7684\u6574\u4e2a\u8fc7\u7a0b\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 `Access key` \u548c `Secret access key`\u3002\n
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u6307\u5b9a S3 \u6587\u4ef6\u5230\u5916\u90e8\u8868\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u6570\u636e\u7684\u7ed3\u679c\u3002\u4f60\u5c06\u53ef\u4ee5\u770b\u5230\u67e5\u8be2\u901f\u5ea6\u660e\u663e\u6162\u4e8e\u4ece\u672c\u5730\u8868\u67e5\u8be2\u3002
select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (1.32 sec)\n
\uff08\u9009\u505a\uff09\u5982\u679c\u9700\u8981\u5c06\u5916\u90e8\u8868\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u6570\u636e\u8868\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\uff1a
\u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u8868 t2\uff1a
create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u5916\u90e8\u8868 t1 \u5bfc\u5165\u5230 t2\uff1a
insert into t2 select * from t1;\n
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 source
\u547d\u4ee4\u6279\u91cf\u5bfc\u5165\u6570\u636e\u81f3 MatrixOne\u3002
SOURCE /path/to/your/sql_script.sql;\n
/path/to/your/sql_script.sql
\u662f SQL \u811a\u672c\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\u3002\u5f53\u6267\u884c\u6b64\u547d\u4ee4\u65f6\uff0c\u5ba2\u6237\u7aef\u4f1a\u8bfb\u53d6\u6307\u5b9a\u7684 SQL \u811a\u672c\u6587\u4ef6\uff0c\u5e76\u6267\u884c\u5176\u4e2d\u5305\u542b\u7684\u6240\u6709 SQL \u8bed\u53e5\u3002
\u5728\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 source
\u547d\u4ee4\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#_4","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#1-mysql","title":"1. MySQL \u6570\u636e\u8f6c\u50a8","text":"\u4f60\u9700\u8981\u62e5\u6709\u5bf9 MySQL \u5b9e\u4f8b\u7684\u5b8c\u5168\u8bbf\u95ee\u6743\u9650\u3002
\u9996\u5148\uff0c\u4f7f\u7528 mysqldump
\u5c06 MySQL \u8868\u7ed3\u6784\u548c\u6570\u636e\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8f6c\u50a8\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089\u5982\u4f55\u4f7f\u7528 mysqldump
\uff0c\u53ef\u53c2\u89c1 mysqldump \u6559\u7a0b\u3002
mysqldump -h IP_ADDRESS -uUSERNAME -pPASSWORD -d DB_NAME1 DB_NAME2 ... OUTPUT_FILE_NAME.SQL\n
\u793a\u4f8b\u5982\u4e0b\uff0c\u4f7f\u7528\u547d\u4ee4\u5c06\u4e00\u4e2a\u547d\u540d\u4e3a test \u6570\u636e\u5e93\u7684\u6240\u6709\u8868\u7ed3\u6784\u548c\u6570\u636e\u8f6c\u50a8\u5230\u4e00\u4e2a\u540d\u4e3a a.sql \u7684\u6587\u4ef6\u4e2d\u3002
mysqldump -h 127.0.0.1 -uroot -proot -d test > a.sql\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#2-matrixone","title":"2. \u5bfc\u5165\u81f3 MatrixOne","text":"\u5c06\u6574\u4e2a\u8868\u7ed3\u6784\u548c\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\u3002
\u6253\u5f00 MySQL \u7ec8\u7aef\u5e76\u8fde\u63a5\u5230 MatrixOne\u3002
\u901a\u8fc7 source
\u547d\u4ee4\u5c06 sql \u6587\u4ef6\u5bfc\u5165 MatrixOne\u3002
mysql> use test;\nmysql> source /YOUR_PATH/a.sql\n
\u5982\u679c sql \u6587\u4ef6\u8f83\u5927\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5728\u540e\u53f0\u8fd0\u884c\u5bfc\u5165\u4efb\u52a1\uff1a
nohup mysql -h 127.0.0.1 -P 6001 -uroot -p111 -e -D test 'source /YOUR_PATH/a.sql' &\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#3","title":"3. \u68c0\u67e5\u6570\u636e","text":"\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u7ed3\u679c\uff1a
select * from tool;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#_5","title":"\u9650\u5236\u8bf4\u660e","text":"MatrixOne 1.2.1 \u7248\u672c\u5df2\u7ecf\u652f\u6301 MySQL \u7684\u5efa\u8868\u8bed\u53e5\uff0c\u56e0\u6b64\u53ef\u4ee5\u987a\u7545\u5730\u5c06 MySQL \u8868\u8fc1\u79fb\u5230 MatrixOne \u4e0a\u3002\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f\uff0c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u517c\u5bb9 MySQL \u90e8\u5206\u5173\u952e\u5b57\uff0c\u5982 engine=
\u7b49\uff0c\u5728 MatrixOne \u4e2d\u4f1a\u88ab\u81ea\u52a8\u5ffd\u7565\uff0c\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u8868\u7ed3\u6784\u7684\u8fc1\u79fb\u3002
\u4f46\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c\u5c3d\u7ba1 MatrixOne \u652f\u6301 MySQL \u5efa\u8868\u8bed\u53e5\uff0c\u5982\u679c\u8fc1\u79fb\u7684\u8868\u4e2d\u5305\u542b\u4e0d\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3001\u89e6\u53d1\u5668\u3001\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ecd\u9700\u8981\u624b\u52a8\u4fee\u6539\u3002\u66f4\u591a\u8be6\u7ec6\u7684\u517c\u5bb9\u6027\u4fe1\u606f\uff0c\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u3002
"},{"location":"MatrixOne/Develop/read-data/cte/","title":"\u516c\u5171\u8868\u8868\u8fbe\u5f0f (CTE)","text":"\u516c\u7528\u8868\u8868\u8fbe\u5f0f\uff08CTE,Common table expression) \u662f\u4e00\u4e2a\u547d\u540d\u7684\u4e34\u65f6\u7ed3\u679c\u96c6\uff0c\u4ec5\u5728\u5355\u4e2a SQL \u8bed\u53e5 (\u4f8b\u5982 SELECT
\uff0cINSERT
\uff0cUPDATE
\u6216 DELETE
) \u7684\u6267\u884c\u8303\u56f4\u5185\u5b58\u5728\u3002
\u4e0e\u6d3e\u751f\u8868\u7c7b\u4f3c\uff0cCTE \u4e0d\u4f5c\u4e3a\u5bf9\u8c61\u5b58\u50a8\uff0c\u4ec5\u5728\u67e5\u8be2\u6267\u884c\u671f\u95f4\u6301\u7eed\uff1b\u4e0e\u6d3e\u751f\u8868\u4e0d\u540c\uff0cCTE \u53ef\u4ee5\u662f\u81ea\u5f15\u7528\uff0c\u4e5f\u53ef\u4ee5\u5728\u540c\u4e00\u67e5\u8be2\u4e2d\u591a\u6b21\u5f15\u7528\u3002\u6b64\u5916\uff0c\u4e0e\u6d3e\u751f\u8868\u76f8\u6bd4\uff0cCTE \u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u53ef\u8bfb\u6027\u548c\u6027\u80fd\u3002
\u5e94\u7528\u573a\u666f\uff1a
\u901a\u7528\u8868\u8868\u8fbe\u5f0f\u5206\u4e3a\u975e\u9012\u5f52\u548c\u9012\u5f52\u4e24\u79cd\u7c7b\u578b\uff1a
WITH <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
WITH RECURSIVE <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
"},{"location":"MatrixOne/Develop/read-data/cte/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/read-data/cte/#cte_1","title":"CTE \u8bed\u53e5\u4f7f\u7528\u793a\u4f8b","text":"\u5047\u8bbe\u6211\u4eec\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a EMPLOYEES
\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u5458\u5de5\u7684\u5c42\u6b21\u7ed3\u6784\u5173\u7cfb\uff0c\u7136\u540e\u4f7f\u7528\u975e\u9012\u5f52 Common Table Expression\uff08CTE\uff09\u548c\u9012\u5f52 CTE \u5206\u522b\u67e5\u8be2\u5458\u5de5\u5c42\u6b21\u7ed3\u6784\u3002
\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a EMPLOYEES
\u8868\u5e76\u63d2\u5165\u4e00\u4e9b\u793a\u4f8b\u6570\u636e\uff1a
CREATE TABLE EMPLOYEES (\nEMPLOYEE_ID INT PRIMARY KEY,\nNAME VARCHAR(50),\nMANAGER_ID INT\n);\n\nINSERT INTO EMPLOYEES (EMPLOYEE_ID, NAME, MANAGER_ID) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Carol', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3),\n(7, 'Grace', 3),\n(8, 'Hannah', 4),\n(9, 'Ian', 4);\n
\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528\u9012\u5f52 CTE \u67e5\u8be2\u5458\u5de5\u5c42\u6b21\u7ed3\u6784\uff1a
WITH RECURSIVE EmployeeHierarchy AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID, 0 AS LEVEL\nFROM EMPLOYEES\nWHERE MANAGER_ID IS NULL\n\nUNION ALL\n\nSELECT e.EMPLOYEE_ID, e.NAME, e.MANAGER_ID, eh.LEVEL + 1\nFROM EMPLOYEES e\nINNER JOIN EmployeeHierarchy eh ON e.MANAGER_ID = eh.EMPLOYEE_ID\n)\nSELECT * FROM EmployeeHierarchy;\n+-------------+--------+------------+-------+\n| employee_id | name | manager_id | level |\n+-------------+--------+------------+-------+\n| 1 | Alice | NULL | 0 |\n| 2 | Bob | 1 | 1 |\n| 3 | Carol | 1 | 1 |\n| 4 | David | 2 | 2 |\n| 5 | Eve | 2 | 2 |\n| 6 | Frank | 3 | 2 |\n| 7 | Grace | 3 | 2 |\n| 8 | Hannah | 4 | 3 |\n| 9 | Ian | 4 | 3 |\n+-------------+--------+------------+-------+\n9 rows in set (0.01 sec)\n
\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u975e\u9012\u5f52 CTE \u67e5\u8be2\u5458\u5de5\u4fe1\u606f\uff1a
WITH EmployeeInfo AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID\nFROM EMPLOYEES\n)\nSELECT * FROM EmployeeInfo;\n+-------------+--------+------------+\n| employee_id | name | manager_id |\n+-------------+--------+------------+\n| 1 | Alice | NULL |\n| 2 | Bob | 1 |\n| 3 | Carol | 1 |\n| 4 | David | 2 |\n| 5 | Eve | 2 |\n| 6 | Frank | 3 |\n| 7 | Grace | 3 |\n| 8 | Hannah | 4 |\n| 9 | Ian | 4 |\n+-------------+--------+------------+\n9 rows in set (0.00 sec)\n
\u6211\u4eec\u4f7f\u7528\u4e86\u4e00\u4e2a\u9012\u5f52 CTE EmployeeHierarchy
\uff0c\u5b83\u9996\u5148\u9009\u62e9\u9876\u5c42\u7ecf\u7406\uff08MANAGER_ID IS NULL
\uff09\uff0c\u7136\u540e\u901a\u8fc7\u9012\u5f52\u8fde\u63a5\u627e\u5230\u6bcf\u4e2a\u5458\u5de5\u7684\u76f4\u63a5\u4e0b\u5c5e\uff0c\u540c\u65f6\u8ddf\u8e2a\u5c42\u6b21\u7ea7\u522b\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u67e5\u8be2 CTE \u6765\u83b7\u53d6\u5458\u5de5\u5c42\u6b21\u7ed3\u6784\u7684\u8be6\u7ec6\u4fe1\u606f\u3002
\u975e\u9012\u5f52 CTE \u793a\u4f8b\u53ea\u662f\u4ece EMPLOYEES
\u8868\u4e2d\u9009\u62e9\u6240\u6709\u5458\u5de5\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5305\u62ec EMPLOYEE_ID
\u3001NAME
\u548c MANAGER_ID
\u3002
\u6ce8\u610f\uff0c\u9012\u5f52 CTE \u9700\u8981\u4f7f\u7528 RECURSIVE
\u5173\u952e\u5b57\u6765\u58f0\u660e\u3002
\u66f4\u591a\u5173\u4e8e CTE \u7684\u4f7f\u7528\u6587\u6863\uff0c\u53c2\u8003 WITH (Common Table Expressions)
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/","title":"\u591a\u8868\u8fde\u63a5\u67e5\u8be2","text":"\u4e00\u4e9b\u4f7f\u7528\u6570\u636e\u5e93\u7684\u573a\u666f\u4e2d\uff0c\u9700\u8981\u4e00\u4e2a\u67e5\u8be2\u5f53\u4e2d\u4f7f\u7528\u5230\u591a\u5f20\u8868\u7684\u6570\u636e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7 JOIN
\u8bed\u53e5\u5c06\u4e24\u5f20\u6216\u591a\u5f20\u8868\u7684\u6570\u636e\u7ec4\u5408\u5728\u4e00\u8d77\u3002
\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_3","title":"\u6570\u636e\u51c6\u5907","text":"\u4e0b\u8f7d\u6570\u636e\u96c6\uff1a
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
\u521b\u5efa\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff1a
create database d1;\nuse d1;\nCREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL,\nR_NAME CHAR(25) NOT NULL,\nR_COMMENT VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART ( P_PARTKEY INTEGER NOT NULL,\nP_NAME VARCHAR(55) NOT NULL,\nP_MFGR CHAR(25) NOT NULL,\nP_BRAND CHAR(10) NOT NULL,\nP_TYPE VARCHAR(25) NOT NULL,\nP_SIZE INTEGER NOT NULL,\nP_CONTAINER CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY INTEGER NOT NULL,\nS_NAME CHAR(25) NOT NULL,\nS_ADDRESS VARCHAR(40) NOT NULL,\nS_NATIONKEY INTEGER NOT NULL,\nS_PHONE CHAR(15) NOT NULL,\nS_ACCTBAL DECIMAL(15,2) NOT NULL,\nS_COMMENT VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY INTEGER NOT NULL,\nPS_SUPPKEY INTEGER NOT NULL,\nPS_AVAILQTY INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY INTEGER NOT NULL,\nC_NAME VARCHAR(25) NOT NULL,\nC_ADDRESS VARCHAR(40) NOT NULL,\nC_NATIONKEY INTEGER NOT NULL,\nC_PHONE CHAR(15) NOT NULL,\nC_ACCTBAL DECIMAL(15,2) NOT NULL,\nC_MKTSEGMENT CHAR(10) NOT NULL,\nC_COMMENT VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS ( O_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
\u628a\u6570\u636e\u5bfc\u5165\u5230\u6570\u636e\u8868\u4e2d\uff1a
load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u73b0\u5728\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u6570\u636e\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#join","title":"Join \u7c7b\u578b","text":""},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_4","title":"\u5185\u8fde\u63a5","text":"\u5185\u8fde\u63a5\u7684\u8fde\u63a5\u7ed3\u679c\u53ea\u8fd4\u56de\u5339\u914d\u8fde\u63a5\u6761\u4ef6\u7684\u884c\u3002
SELECT <select_list> FROM TableA A INNER JOIN TableB B ON A.Key=B.Key\n
\u5185\u8fde\u63a5\u6709\u4e24\u79cd\u4e66\u5199\u65b9\u5f0f\uff0c\u5728\u7ed3\u679c\u4e0a\u662f\u5b8c\u5168\u7b49\u4ef7\u7684\uff1a
mysql> SELECT l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER,\nORDERS,\nLINEITEM\nWHERE\nc_mktsegment = 'BUILDING'\nAND c_custkey = o_custkey\nAND l_orderkey = o_orderkey\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n| 2456423 | 406181.011100000000 | 1995-03-05 | 0 |\n| 3459808 | 405838.698900000000 | 1995-03-04 | 0 |\n| 492164 | 390324.061000000000 | 1995-02-19 | 0 |\n| 1188320 | 384537.935900000000 | 1995-03-09 | 0 |\n| 2435712 | 378673.055800000000 | 1995-02-26 | 0 |\n| 4878020 | 378376.795200000000 | 1995-03-12 | 0 |\n| 5521732 | 375153.921500000000 | 1995-03-13 | 0 |\n| 2628192 | 373133.309400000000 | 1995-02-22 | 0 |\n| 993600 | 371407.459500000000 | 1995-03-05 | 0 |\n| 2300070 | 367371.145200000000 | 1995-03-13 | 0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n
\u5199\u6210 Join
\u7684\u5f62\u5f0f\uff0c\u8bed\u6cd5\u5982\u4e0b\uff1a
mysql> SELECT l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER\njoin ORDERS on c_custkey = o_custkey\njoin LINEITEM on l_orderkey = o_orderkey\nWHERE\nc_mktsegment = 'BUILDING'\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n| 2456423 | 406181.011100000000 | 1995-03-05 | 0 |\n| 3459808 | 405838.698900000000 | 1995-03-04 | 0 |\n| 492164 | 390324.061000000000 | 1995-02-19 | 0 |\n| 1188320 | 384537.935900000000 | 1995-03-09 | 0 |\n| 2435712 | 378673.055800000000 | 1995-02-26 | 0 |\n| 4878020 | 378376.795200000000 | 1995-03-12 | 0 |\n| 5521732 | 375153.921500000000 | 1995-03-13 | 0 |\n| 2628192 | 373133.309400000000 | 1995-02-22 | 0 |\n| 993600 | 371407.459500000000 | 1995-03-05 | 0 |\n| 2300070 | 367371.145200000000 | 1995-03-13 | 0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_5","title":"\u5916\u8fde\u63a5","text":"\u5916\u8fde\u63a5\u53c8\u5206\u4e3a\u5de6\u8fde\u63a5\u3001\u53f3\u8fde\u63a5\uff0c\u4e24\u8005\u4e4b\u95f4\u662f\u53ef\u4ee5\u5b9e\u73b0\u7b49\u4ef7\u8bed\u4e49\u7684\uff1a
LEFT JOIN
\u5de6\u5916\u8fde\u63a5\u4f1a\u8fd4\u56de\u5de6\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\u884c\uff0c\u4ee5\u53ca\u53f3\u8868\u5f53\u4e2d\u80fd\u591f\u5339\u914d\u8fde\u63a5\u6761\u4ef6\u7684\u503c\uff0c\u5982\u679c\u5728\u53f3\u8868\u5f53\u4e2d\u6ca1\u6709\u627e\u5230\u80fd\u591f\u5339\u914d\u7684\u884c\uff0c\u5219\u4f7f\u7528 NULL \u586b\u5145\u3002
SELECT <select_list> FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key\n
SELECT <select_list> FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL\n
RIGHT JOIN
\u53f3\u5916\u8fde\u63a5\u8fd4\u56de\u53f3\u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u4ee5\u53ca\u5de6\u8868\u5f53\u4e2d\u80fd\u591f\u5339\u914d\u8fde\u63a5\u6761\u4ef6\u7684\u503c\uff0c\u6ca1\u6709\u5339\u914d\u7684\u503c\u5219\u4f7f\u7528 NULL \u586b\u5145\u3002
SELECT <select_list> FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key\n
SELECT <select_list> FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL\n
\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 147457 | 16 |\n| 147458 | 7 |\n| 147459 | 0 |\n| 147460 | 16 |\n| 147461 | 7 |\n| 147462 | 0 |\n| 147463 | 14 |\n| 147464 | 11 |\n| 147465 | 0 |\n| 147466 | 17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n
\u6216\u8005\uff1a
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nORDERS\nRIGHT OUTER JOIN CUSTOMER ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 147457 | 16 |\n| 147458 | 7 |\n| 147459 | 0 |\n| 147460 | 16 |\n| 147461 | 7 |\n| 147462 | 0 |\n| 147463 | 14 |\n| 147464 | 11 |\n| 147465 | 0 |\n| 147466 | 17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_6","title":"\u5168\u8fde\u63a5","text":"\u5168\u8fde\u63a5\u662f\u5de6\u53f3\u5916\u8fde\u63a5\u7684\u5e76\u96c6\u3002\u8fde\u63a5\u8868\u5305\u542b\u88ab\u8fde\u63a5\u7684\u8868\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u5982\u679c\u7f3a\u5c11\u5339\u914d\u7684\u8bb0\u5f55\uff0c\u5373\u4ee5 NULL \u586b\u5145\u3002
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nFULL JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 1 | 6 |\n| 2 | 7 |\n| 4 | 20 |\n| 5 | 4 |\n| 7 | 16 |\n| 8 | 13 |\n| 10 | 20 |\n| 11 | 13 |\n| 13 | 18 |\n| 14 | 9 |\n+-----------+---------+\n10 rows in set (0.77 sec)\n
\u5168\u8fde\u63a5\u540c\u6837\u53ef\u4ee5\u901a\u8fc7\u6539\u5199\u7684\u65b9\u5f0f\u83b7\u5f97\u76f8\u540c\u7684\u8bed\u4e49\uff1a
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey\nUNION\nSELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nWHERE c_custkey IS NULL\nGROUP BY c_custkey\nlimit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 147457 | 16 |\n| 147458 | 7 |\n| 147459 | 0 |\n| 147460 | 16 |\n| 147461 | 7 |\n| 147462 | 0 |\n| 147463 | 14 |\n| 147464 | 11 |\n| 147465 | 0 |\n| 147466 | 17 |\n+-----------+---------+\n10 rows in set (1.09 sec)\n
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_7","title":"\u9690\u5f0f\u8fde\u63a5","text":"\u5728 SQL \u8bed\u53e5\u5f53\u4e2d\uff0c\u9664\u4e86\u4f7f\u7528 JOIN
\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7 FROM t1, t2
\u5b50\u53e5\u6765\u8fde\u63a5\u4e24\u5f20\u6216\u591a\u5f20\u8868\uff0c\u901a\u8fc7 WHERE t1.id = t2.id
\u5b50\u53e5\u6765\u6307\u5b9a\u8fde\u63a5\u7684\u6761\u4ef6\u3002
\u672c\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u6765\u5bf9\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
CREATE DATABASE token_demo;\nUSE token_demo;\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#token_count","title":"\u65b0\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a token_count \u7684\u8868","text":"CREATE TABLE token_count (\nid int,\ntoken varchar(100) DEFAULT '' NOT NULL,\ncount int DEFAULT 0 NOT NULL,\nqty int,\nphone char(1) DEFAULT '' NOT NULL,\ntimes datetime DEFAULT '2000-01-01 00:00:00' NOT NULL\n);\nINSERT INTO token_count VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');\nINSERT INTO token_count VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');\nINSERT INTO token_count VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_4","title":"\u7b80\u5355\u7684\u67e5\u8be2","text":"\u5728 MySQL Client \u7b49\u5ba2\u6237\u7aef\u8f93\u5165\u5e76\u6267\u884c\u5982\u4e0b SQL \u8bed\u53e5\uff1a
mysql> SELECT id, token FROM token_count;\n
\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+\n| id | token |\n+------+----------------------------------+\n| 21 | e45703b64de71482360de8fec94c3ade |\n| 22 | e45703b64de71482360de8fec94c3ade |\n| 18 | 346d1cb63c89285b2351f0ca4de40eda |\n| 17 | ca6ddeb689e1b48a04146b1b5b6f936a |\n| 16 | ca6ddeb689e1b48a04146b1b5b6f936a |\n| 26 | a71250b7ed780f6ef3185bfffe027983 |\n| 24 | 4d75906f3c37ecff478a1eb56637aa09 |\n| 25 | 4d75906f3c37ecff478a1eb56637aa09 |\n| 27 | a71250b7ed780f6ef3185bfffe027983 |\n| 28 | a71250b7ed780f6ef3185bfffe027983 |\n| 29 | a71250b7ed780f6ef3185bfffe027983 |\n+------+----------------------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_5","title":"\u5bf9\u7ed3\u679c\u8fdb\u884c\u7b5b\u9009","text":"\u5982\u679c\u4f60\u9700\u8981\u4ece\u8bf8\u591a\u67e5\u8be2\u5f97\u5230\u7684\u7ed3\u679c\u4e2d\u7b5b\u9009\u51fa\u4f60\u9700\u8981\u7684\u7ed3\u679c\uff0c\u53ef\u4ee5\u901a\u8fc7 WHERE
\u8bed\u53e5\u5bf9\u67e5\u8be2\u7684\u7ed3\u679c\u8fdb\u884c\u8fc7\u6ee4\uff0c\u4ece\u800c\u627e\u5230\u60f3\u8981\u67e5\u8be2\u7684\u90e8\u5206\u3002
\u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 WHERE
\u5b50\u53e5\u6dfb\u52a0\u7b5b\u9009\u7684\u6761\u4ef6\uff1a
mysql> SELECT * FROM token_count WHERE id = 25;\n
\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+-------+------+-------+---------------------+\n| id | token | count | qty | phone | times |\n+------+----------------------------------+-------+------+-------+---------------------+\n| 25 | 4d75906f3c37ecff478a1eb56637aa09 | 4 | 6500 | y | 1999-12-23 17:29:12 |\n+------+----------------------------------+-------+------+-------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_6","title":"\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f","text":"\u4f7f\u7528 ORDER BY
\u8bed\u53e5\u53ef\u4ee5\u8ba9\u67e5\u8be2\u7ed3\u679c\u6309\u7167\u671f\u671b\u7684\u65b9\u5f0f\u8fdb\u884c\u6392\u5e8f\u3002
\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5bf9 token_count \u8868\u7684\u6570\u636e\u6309\u7167 times \u5217\u8fdb\u884c\u964d\u5e8f (DESC) \u6392\u5e8f\u3002
mysql> SELECT id, token, times FROM token_count ORDER BY times DESC;\n
\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+---------------------+\n| id | token | times |\n+------+----------------------------------+---------------------+\n| 29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n| 28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n| 26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n| 25 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n| 21 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n| 22 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n| 18 | 346d1cb63c89285b2351f0ca4de40eda | 1999-12-23 11:58:04 |\n| 17 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n| 16 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n+------+----------------------------------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_7","title":"\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u6570\u91cf","text":"\u5982\u679c\u5e0c\u671b\u53ea\u8fd4\u56de\u90e8\u5206\u7ed3\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 LIMIT
\u8bed\u53e5\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u8fd4\u56de\u7684\u8bb0\u5f55\u6570\u3002
mysql> SELECT id, token, times FROM token_count ORDER BY times DESC LIMIT 5;\n
\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+---------------------+\n| id | token | times |\n+------+----------------------------------+---------------------+\n| 29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n| 28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n| 26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n+------+----------------------------------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_8","title":"\u805a\u5408\u67e5\u8be2","text":"\u5982\u679c\u4f60\u60f3\u8981\u5173\u6ce8\u6570\u636e\u6574\u4f53\u7684\u60c5\u51b5\uff0c\u800c\u4e0d\u662f\u90e8\u5206\u6570\u636e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 GROUP BY
\u8bed\u53e5\u914d\u5408\u805a\u5408\u51fd\u6570\uff0c\u6784\u5efa\u4e00\u4e2a\u805a\u5408\u67e5\u8be2\u6765\u5e2e\u52a9\u4f60\u5bf9\u6570\u636e\u7684\u6574\u4f53\u60c5\u51b5\u6709\u4e00\u4e2a\u66f4\u597d\u7684\u4e86\u89e3\u3002
\u6bd4\u5982\u8bf4\uff0c\u4f60\u53ef\u4ee5\u5c06\u57fa\u672c\u4fe1\u606f\u6309\u7167 id\u3001count\u3001times \u5217\u8fdb\u884c\u5206\u7ec4\uff0c\u7136\u540e\u5206\u522b\u7edf\u8ba1\uff1a
mysql> SELECT id, count, times FROM token_count GROUP BY id, count, times\nORDER BY times DESC\nLIMIT 5;\n
\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
+------+-------+---------------------+\n| id | count | times |\n+------+-------+---------------------+\n| 29 | 4 | 1999-12-27 09:45:05 |\n| 28 | 3 | 1999-12-27 09:44:36 |\n| 26 | 5 | 1999-12-27 09:44:24 |\n| 27 | 3 | 1999-12-27 09:44:24 |\n| 24 | 3 | 1999-12-23 17:29:12 |\n+------+-------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/subquery/","title":"\u5b50\u67e5\u8be2","text":"\u672c\u7bc7\u6587\u6863\u5411\u4f60\u4ecb\u7ecd MatrixOne \u7684\u5b50\u67e5\u8be2\u529f\u80fd\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_2","title":"\u6982\u8ff0","text":"\u5b50\u67e5\u8be2\u662f\u5d4c\u5957\u5728\u53e6\u4e00\u4e2a\u67e5\u8be2\u4e2d\u7684 SQL \u8868\u8fbe\u5f0f\uff0c\u501f\u52a9\u5b50\u67e5\u8be2\uff0c\u53ef\u4ee5\u5728\u4e00\u4e2a\u67e5\u8be2\u5f53\u4e2d\u4f7f\u7528\u53e6\u5916\u4e00\u4e2a\u67e5\u8be2\u7684\u67e5\u8be2\u7ed3\u679c\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4ece SQL \u8bed\u53e5\u7ed3\u6784\u4e0a\uff0c\u5b50\u67e5\u8be2\u8bed\u53e5\u4e00\u822c\u6709\u4ee5\u4e0b\u51e0\u79cd\u5f62\u5f0f\uff1a
SELECT (SELECT s1 FROM t2) FROM t1
\u3002SELECT t1.s1 FROM (SELECT s1 FROM t2) t1
\u3002WHERE NOT EXISTS(SELECT ... FROM t2)
\uff0cWHERE t1.a IN (SELECT ... FROM t2)
\u3002WHERE t1.a = ANY(SELECT ... FROM t2)
\u3002WHERE t1.a > (SELECT ... FROM t2)
\u3002\u5173\u4e8e\u5b50\u67e5\u8be2 SQL \u8bed\u53e5\uff0c\u53c2\u89c1 SUBQUERY\u3002
\u53e6\u5916\uff0c\u4ece SQL \u8bed\u53e5\u6267\u884c\u60c5\u51b5\u4e0a\uff0c\u5b50\u67e5\u8be2\u8bed\u53e5\u4e00\u822c\u6709\u4ee5\u4e0b\u4e24\u79cd\u5f62\u5f0f\uff1a
\u5173\u8054\u5b50\u67e5\u8be2\uff08Correlated Subquery\uff09\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u548c\u5916\u5c42\u67e5\u8be2\u4e0d\u76f8\u4e92\u72ec\u7acb\uff0c\u5185\u5c42\u67e5\u8be2\u4e5f\u4f9d\u8d56\u4e8e\u5916\u5c42\u67e5\u8be2\u3002\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u5148\u4ece\u5916\u5c42\u67e5\u8be2\u4e2d\u67e5\u8be2\u4e2d\u4e00\u6761\u8bb0\u5f55\u3002
\u518d\u5c06\u67e5\u8be2\u5230\u7684\u8bb0\u5f55\u653e\u5230\u5185\u5c42\u67e5\u8be2\u4e2d\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u518d\u653e\u5230\u5916\u5c42\u4e2d\u67e5\u8be2\u3002
\u91cd\u590d\u4ee5\u4e0a\u6b65\u9aa4
\u4f8b\u5982\uff1aselect * from tableA where tableA.cloumn < (select column from tableB where tableA.id = tableB.id))
\u65e0\u5173\u8054\u5b50\u67e5\u8be2 (Self-contained Subquery)\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u662f\u5b8c\u5168\u72ec\u7acb\u4e8e\u5916\u5c42\u67e5\u8be2\u7684\u3002\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u4f8b\u5982\uff1aselect * from tableA where tableA.column = (select tableB.column from tableB )
\u5b50\u67e5\u8be2\u7684\u4f5c\u7528\uff1a
JOIN
\u548c UNION
\u6765\u5b9e\u73b0\u7684\u64cd\u4f5c\u3002\u6211\u4eec\u5c06\u4e3e\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5e2e\u52a9\u4f60\u7406\u89e3\u5173\u8054\u5b50\u67e5\u8be2\u548c\u65e0\u5173\u8054\u5b50\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_3","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Develop/read-data/subquery/#_4","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u4e0b\u8f7d\u6570\u636e\u96c6\uff1a
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
\u521b\u5efa\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff1a
create database d1;\nuse d1;\nCREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL,\nR_NAME CHAR(25) NOT NULL,\nR_COMMENT VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART ( P_PARTKEY INTEGER NOT NULL,\nP_NAME VARCHAR(55) NOT NULL,\nP_MFGR CHAR(25) NOT NULL,\nP_BRAND CHAR(10) NOT NULL,\nP_TYPE VARCHAR(25) NOT NULL,\nP_SIZE INTEGER NOT NULL,\nP_CONTAINER CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY INTEGER NOT NULL,\nS_NAME CHAR(25) NOT NULL,\nS_ADDRESS VARCHAR(40) NOT NULL,\nS_NATIONKEY INTEGER NOT NULL,\nS_PHONE CHAR(15) NOT NULL,\nS_ACCTBAL DECIMAL(15,2) NOT NULL,\nS_COMMENT VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY INTEGER NOT NULL,\nPS_SUPPKEY INTEGER NOT NULL,\nPS_AVAILQTY INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY INTEGER NOT NULL,\nC_NAME VARCHAR(25) NOT NULL,\nC_ADDRESS VARCHAR(40) NOT NULL,\nC_NATIONKEY INTEGER NOT NULL,\nC_PHONE CHAR(15) NOT NULL,\nC_ACCTBAL DECIMAL(15,2) NOT NULL,\nC_MKTSEGMENT CHAR(10) NOT NULL,\nC_COMMENT VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS ( O_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
\u628a\u6570\u636e\u5bfc\u5165\u5230\u6570\u636e\u8868\u4e2d\uff1a
load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u73b0\u5728\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u6570\u636e\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_6","title":"\u65e0\u5173\u8054\u5b50\u67e5\u8be2","text":"\u5bf9\u4e8e\u5c06\u5b50\u67e5\u8be2\u4f5c\u4e3a\u6bd4\u8f83\u8fd0\u7b97\u7b26 (>
/ >=
/ <
/ <=
/ =
/ !=
) \u64cd\u4f5c\u6570\u7684\u8fd9\u7c7b\u65e0\u5173\u8054\u5b50\u67e5\u8be2\u800c\u8a00\uff0c\u5185\u5c42\u5b50\u67e5\u8be2\u53ea\u9700\u8981\u8fdb\u884c\u4e00\u6b21\u67e5\u8be2\uff0cMatrixOne \u5728\u751f\u6210\u6267\u884c\u8ba1\u5212\u9636\u6bb5\u4f1a\u5c06\u5185\u5c42\u5b50\u67e5\u8be2\u6539\u5199\u4e3a\u5e38\u91cf\u3002
mysql> select p.p_name from (select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200) p, partsupp ps where p.p_partkey=ps.ps_partkey and p.p_name like '%pink%' limit 10;\n
\u5728 MatrixOne \u6267\u884c\u4e0a\u8ff0\u67e5\u8be2\u7684\u65f6\u5019\u4f1a\u5148\u6267\u884c\u4e00\u6b21\u5185\u5c42\u5b50\u67e5\u8be2\uff1a
mysql> select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+-----------------------------------+\n| p_name |\n+-----------------------------------+\n| olive chartreuse smoke pink tan |\n| olive chartreuse smoke pink tan |\n| olive chartreuse smoke pink tan |\n| olive chartreuse smoke pink tan |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| honeydew orchid cyan magenta pink |\n| honeydew orchid cyan magenta pink |\n+-----------------------------------+\n10 rows in set (0.06 sec)\n
\u5bf9\u4e8e\u5b58\u5728\u6027\u6d4b\u8bd5\u548c\u96c6\u5408\u6bd4\u8f83\u4e24\u79cd\u60c5\u51b5\u4e0b\u7684\u65e0\u5173\u8054\u5217\u5b50\u67e5\u8be2\uff0cMatrixOne \u4f1a\u5c06\u5176\u8fdb\u884c\u6539\u5199\u548c\u7b49\u4ef7\u66ff\u6362\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6267\u884c\u6027\u80fd\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_7","title":"\u5173\u8054\u5b50\u67e5\u8be2","text":"\u5bf9\u4e8e\u5173\u8054\u5b50\u67e5\u8be2\u800c\u8a00\uff0c\u7531\u4e8e\u5185\u5c42\u7684\u5b50\u67e5\u8be2\u5f15\u7528\u5916\u5c42\u67e5\u8be2\u7684\u5217\uff0c\u5b50\u67e5\u8be2\u9700\u8981\u5bf9\u5916\u5c42\u67e5\u8be2\u5f97\u5230\u7684\u6bcf\u4e00\u884c\u90fd\u6267\u884c\u4e00\u904d\uff0c\u4e5f\u5c31\u662f\u8bf4\u5047\u8bbe\u5916\u5c42\u67e5\u8be2\u5f97\u5230\u4e00\u5343\u4e07\u7684\u7ed3\u679c\uff0c\u90a3\u4e48\u5b50\u67e5\u8be2\u4e5f\u4f1a\u88ab\u6267\u884c\u4e00\u5343\u4e07\u6b21\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u67e5\u8be2\u9700\u8981\u6d88\u8017\u66f4\u591a\u7684\u65f6\u95f4\u548c\u8d44\u6e90\u3002
\u56e0\u6b64\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\uff0cMatrixOne \u4f1a\u5c1d\u8bd5\u5bf9\u5173\u8054\u5b50\u67e5\u8be2\u53bb\u5173\u8054\uff0c\u4ee5\u4ece\u6267\u884c\u8ba1\u5212\u5c42\u9762\u4e0a\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002
mysql> select p_name from part where P_PARTKEY in (select PS_PARTKEY from PARTSUPP where PS_SUPPLYCOST>=500) and p_name like '%pink%' limit 10;\n
MatrixOne \u5728\u5904\u7406\u8be5 SQL \u8bed\u53e5\u662f\u4f1a\u5c06\u5176\u6539\u5199\u4e3a\u7b49\u4ef7\u7684 JOIN
\u67e5\u8be2\uff1a
select p_name from part join partsupp on P_PARTKEY=PS_PARTKEY where PS_SUPPLYCOST>=500 and p_name like '%pink%' limit 10;\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+------------------------------------+\n| p_name |\n+------------------------------------+\n| papaya red almond hot pink |\n| turquoise hot smoke green pink |\n| purple cornsilk red pink floral |\n| pink cyan purple white burnished |\n| sandy dark pink indian cream |\n| powder cornsilk chiffon slate pink |\n| rosy light black pink orange |\n| pink white goldenrod ivory steel |\n| cornsilk dim pink tan sienna |\n| lavender navajo steel sandy pink |\n+------------------------------------+\n10 rows in set (0.23 sec)\n
\u4f5c\u4e3a\u6700\u4f73\u5b9e\u8df5\uff0c\u5728\u5b9e\u9645\u5f00\u53d1\u5f53\u4e2d\uff0c\u4e3a\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\uff0c\u5c3d\u91cf\u9009\u62e9\u7b49\u4ef7\u8ba1\u7b97\u65b9\u6cd5\u8fdb\u884c\u67e5\u8be2\uff0c\u907f\u514d\u4f7f\u7528\u5173\u8054\u5b50\u67e5\u8be2\u7684\u65b9\u5f0f\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/views/","title":"\u89c6\u56fe","text":"\u672c\u7bc7\u6587\u6863\u5411\u4f60\u4ecb\u7ecd MatrixOne \u7684\u89c6\u56fe\u529f\u80fd\u3002
"},{"location":"MatrixOne/Develop/read-data/views/#_2","title":"\u6982\u8ff0","text":"\u89c6\u56fe\u4f5c\u4e3a\u4e00\u4e2a\u865a\u62df\u8868\uff0c\u8fdb\u884c\u5b58\u50a8\u67e5\u8be2\uff0c\u5728\u8c03\u7528\u65f6\u4ea7\u751f\u7ed3\u679c\u96c6\u3002
\u89c6\u56fe\u7684\u4f5c\u7528\uff1a
\u7b80\u5316\u7528\u6237\u64cd\u4f5c\uff1a\u89c6\u56fe\u673a\u5236\u4f7f\u7528\u6237\u53ef\u4ee5\u5c06\u6ce8\u610f\u529b\u96c6\u4e2d\u5728\u6240\u5173\u5fc3\u5730\u6570\u636e\u4e0a\u3002\u5982\u679c\u8fd9\u4e9b\u6570\u636e\u4e0d\u662f\u76f4\u63a5\u6765\u81ea\u57fa\u672c\u8868\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u89c6\u56fe\uff0c\u4f7f\u6570\u636e\u5e93\u770b\u8d77\u6765\u7ed3\u6784\u7b80\u5355\u3001\u6e05\u6670\uff0c\u5e76\u4e14\u53ef\u4ee5\u7b80\u5316\u7528\u6237\u7684\u6570\u636e\u67e5\u8be2\u64cd\u4f5c\u3002
\u4ee5\u591a\u79cd\u89d2\u5ea6\u770b\u5f85\u540c\u4e00\u6570\u636e\uff1a\u89c6\u56fe\u673a\u5236\u80fd\u4f7f\u4e0d\u540c\u7684\u7528\u6237\u4ee5\u4e0d\u540c\u7684\u65b9\u5f0f\u770b\u5f85\u540c\u4e00\u6570\u636e\uff0c\u5f53\u8bb8\u591a\u4e0d\u540c\u79cd\u7c7b\u7684\u7528\u6237\u5171\u4eab\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u65f6\uff0c\u8fd9\u79cd\u7075\u6d3b\u6027\u662f\u975e\u5e38\u5fc5\u8981\u7684\u3002
\u5bf9\u91cd\u6784\u6570\u636e\u5e93\u63d0\u4f9b\u4e86\u4e00\u5b9a\u7a0b\u5ea6\u7684\u903b\u8f91\u72ec\u7acb\u6027\uff1a\u6570\u636e\u7684\u7269\u7406\u72ec\u7acb\u6027\u662f\u6307\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0d\u4f9d\u8d56\u4e8e\u6570\u636e\u5e93\u7684\u7269\u7406\u7ed3\u6784\u3002\u6570\u636e\u7684\u903b\u8f91\u72ec\u7acb\u6027\u662f\u6307\u5f53\u6570\u636e\u5e93\u91cd\u6784\u9020\u65f6\uff0c\u5982\u589e\u52a0\u65b0\u7684\u5173\u7cfb\u6216\u5bf9\u539f\u6709\u7684\u5173\u7cfb\u589e\u52a0\u65b0\u7684\u5b57\u6bb5\uff0c\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0d\u4f1a\u53d7\u5f71\u54cd\u3002\u5c42\u6b21\u6570\u636e\u5e93\u548c\u7f51\u72b6\u6570\u636e\u5e93\u4e00\u822c\u80fd\u8f83\u597d\u5730\u652f\u6301\u6570\u636e\u7684\u7269\u7406\u72ec\u7acb\u6027\uff0c\u800c\u5bf9\u4e8e\u903b\u8f91\u72ec\u7acb\u6027\u5219\u4e0d\u80fd\u5b8c\u5168\u7684\u652f\u6301\u3002
\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u65b0\u5efa\u4e24\u5f20\u8868\uff0c\u65b9\u4fbf\u540e\u7eed\u4e3a\u4f7f\u7528\u89c6\u56fe\u505a\u51c6\u5907\uff1a
CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\n
\u53ef\u4ee5\u67e5\u770b\u4e00\u4e0b\u8868 t00 \u7684\u7ed3\u6784\uff1a
mysql> select * from t00;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n+------+\n
\u53ef\u4ee5\u67e5\u770b\u4e00\u4e0b\u8868 t01 \u7684\u7ed3\u6784\uff1a
> select * from t01;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n
"},{"location":"MatrixOne/Develop/read-data/views/#_5","title":"\u521b\u5efa\u89c6\u56fe","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7 CREATE VIEW
\u8bed\u53e5\u6765\u5c06\u67d0\u4e2a\u8f83\u4e3a\u590d\u6742\u7684\u67e5\u8be2\u5b9a\u4e49\u4e3a\u89c6\u56fe\uff0c\u5176\u8bed\u6cd5\u5982\u4e0b\uff1a
CREATE VIEW view_name AS query;\n
\u521b\u5efa\u7684\u89c6\u56fe\u540d\u79f0\u4e0d\u80fd\u4e0e\u5df2\u6709\u7684\u89c6\u56fe\u6216\u8868\u91cd\u540d\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\nQuery OK, 0 rows affected (0.02 sec)\n
"},{"location":"MatrixOne/Develop/read-data/views/#_6","title":"\u67e5\u8be2\u89c6\u56fe","text":"\u89c6\u56fe\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u4fbf\u53ef\u4ee5\u4f7f\u7528 SELECT
\u8bed\u53e5\u50cf\u67e5\u8be2\u4e00\u822c\u6570\u636e\u8868\u4e00\u6837\u67e5\u8be2\u89c6\u56fe\u3002
mysql> SELECT * FROM v0;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n| 2 | NULL |\n+------+------+\n
"},{"location":"MatrixOne/Develop/read-data/views/#_7","title":"\u83b7\u53d6\u89c6\u56fe\u76f8\u5173\u4fe1\u606f","text":"\u4f7f\u7528 SHOW CREATE TABLE|VIEW view_name
\u8bed\u53e5\uff1a
mysql> SHOW CREATE VIEW v0;\n+------+----------------------------------------------------------------------------+\n| View | Create View |\n+------+----------------------------------------------------------------------------+\n| v0 | CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/read-data/views/#_8","title":"\u5220\u9664\u89c6\u56fe","text":"\u901a\u8fc7 DROP VIEW view_name;
\u8bed\u53e5\u53ef\u4ee5\u5220\u9664\u5df2\u7ecf\u521b\u5efa\u7684\u89c6\u56fe\u3002
mysql> DROP VIEW v0;\n
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/","title":"\u65f6\u95f4\u7a97\u53e3","text":"\u5728\u65f6\u5e8f\u573a\u666f\u4e2d\uff0c\u6570\u636e\u901a\u5e38\u662f\u6d41\u5f0f\u7684\uff0c\u6d41\u6570\u636e\u901a\u5e38\u662f\u65e0\u7a77\u65e0\u5c3d\u7684\uff0c\u6211\u4eec\u65e0\u6cd5\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u6570\u636e\u6e90\u4f1a\u7ee7\u7eed/\u505c\u6b62\u53d1\u9001\u6570\u636e\uff0c\u6240\u4ee5\u5728\u6d41\u4e0a\u5904\u7406\u805a\u5408\u4e8b\u4ef6\uff08count\u3001sum \u7b49\uff09\u7684\u5904\u7406\u65b9\u5f0f\u4e0e\u6279\u5904\u7406\u4e2d\u7684\u5904\u7406\u65b9\u5f0f\u4f1a\u6709\u6240\u5dee\u5f02\u3002\u5728\u65f6\u5e8f\u6570\u636e\u6d41\u4e0a\u4e00\u822c\u7528\u65f6\u95f4\u7a97\u53e3\uff08Windows\uff09\u6765\u9650\u5b9a\u805a\u5408\u7684\u8303\u56f4\uff0c\u4f8b\u5982\u201c\u8fc7\u53bb 2 \u5206\u949f\u7f51\u7ad9\u70b9\u51fb\u91cf\u7684\u8ba1\u6570\u201d\u3002\u65f6\u95f4\u7a97\u53e3\u7684\u6982\u5ff5\u76f8\u5f53\u4e8e\u5e2e\u6211\u4eec\u6839\u636e\u91c7\u96c6\u65f6\u95f4\u6536\u96c6\u4e86\u4e00\u5f20\u6709\u9650\u6570\u636e\u7684\u52a8\u6001\u8868\uff0c\u6211\u4eec\u53ef\u4ee5\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u805a\u5408\u8ba1\u7b97\u3002\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u8fd9\u4e2a\u7a97\u53e3\u4f1a\u5411\u524d\u6ed1\u52a8\uff0c\u6301\u7eed\u6355\u6349\u65b0\u7684\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\u3002
\u65f6\u95f4\u7a97\u53e3\u5206\u4e3a Tumble Window\uff08\u7ffb\u6eda\u7a97\u53e3\uff09\u548c Sliding Window\uff08\u6ed1\u52a8\u7a97\u53e3\uff09\u3002Tumble Window \u7684\u65f6\u95f4\u7a97\u53e3\u957f\u5ea6\u56fa\u5b9a\uff0c\u6bcf\u4e2a\u7a97\u53e3\u65f6\u95f4\u4e0d\u91cd\u53e0\u3002\u800c Sliding Window \u7684\u65f6\u95f4\u7a97\u53e3\u957f\u5ea6\u4e5f\u56fa\u5b9a\uff0c\u4f46\u662f\u7a97\u53e3\u4e4b\u95f4\u6709\u91cd\u53e0\u90e8\u5206\uff0c\u53ef\u4ee5\u66f4\u9891\u7e41\u5730\u6355\u6349\u6570\u636e\u53d8\u5316\u3002
\u7528\u6237\u4f7f\u7528\u65f6\u95f4\u7a97\u53e3\u529f\u80fd\u65f6\uff0c\u53ef\u4ee5\u5728\u6bcf\u4e2a\u65f6\u95f4\u7a97\u53e3\u5185\u505a\u8ba1\u7b97\uff0c\u7a97\u53e3\u968f\u7740\u65f6\u95f4\u7684\u6d41\u52a8\u5411\u524d\u6ed1\u52a8\u3002\u5728\u5b9a\u4e49\u8fde\u7eed\u67e5\u8be2\u7684\u65f6\u5019\u9700\u8981\u6307\u5b9a\u65f6\u95f4\u7a97\u53e3\u7684\u5927\u5c0f\u548c\u4e0b\u4e2a\u7a97\u53e3\u5411\u524d\u7684\u589e\u91cf\u65f6\u95f4\u3002
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/#downsampling","title":"\u964d\u91c7\u6837 (Downsampling)","text":"\u964d\u91c7\u6837\u662f\u6307\u4ece\u5927\u91cf\u6570\u636e\u4e2d\u63d0\u53d6\u8f83\u5c0f\u3001\u7ba1\u7406\u6027\u66f4\u5f3a\u7684\u6570\u636e\u5b50\u96c6\u7684\u8fc7\u7a0b\u3002\u8fd9\u5728\u5904\u7406\u5927\u89c4\u6a21\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u65f6\u5c24\u4e3a\u91cd\u8981\uff0c\u53ef\u4ee5\u51cf\u5c11\u5b58\u50a8\u9700\u6c42\uff0c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\uff0c\u5e76\u5728\u6570\u636e\u53ef\u89c6\u5316\u4e2d\u63d0\u4f9b\u66f4\u6e05\u6670\u7684\u8d8b\u52bf\u56fe\u3002\u65f6\u95f4\u7a97\u53e3\u529f\u80fd\u662f\u6570\u636e\u5e93\u5b9e\u73b0\u964d\u91c7\u6837\u529f\u80fd\u7684\u6838\u5fc3\u80fd\u529b\uff0c\u901a\u8fc7\u5b9a\u4e49\u65f6\u95f4\u7a97\u53e3\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6bcf\u4e2a\u7a97\u53e3\u5185\u5bf9\u6570\u636e\u8fdb\u884c\u805a\u5408\uff0c\u4ece\u800c\u5b9e\u73b0\u964d\u91c7\u6837\u3002\u65f6\u95f4\u7a97\u53e3\u7684\u5927\u5c0f\u548c\u6ed1\u52a8\u8ddd\u79bb\u51b3\u5b9a\u4e86\u964d\u91c7\u6837\u7684\u7c92\u5ea6\u3002
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/#_2","title":"\u65f6\u5e8f\u8868\u4e0e\u65f6\u95f4\u7a97\u53e3\u8bed\u6cd5","text":"\u5728 MatrixOne \u4e2d\uff0c\u65f6\u95f4\u7a97\u53e3\u9700\u8981\u7ed3\u5408\u65f6\u5e8f\u8868\u6765\u4f7f\u7528\uff0c\u65f6\u5e8f\u8868\u662f\u6307\u5efa\u8868\u65f6\u5fc5\u987b\u4ee5 ts
\u5217\u4e3a\u4e3b\u952e\u7684\u8868\uff0c\u4e14\u7c7b\u578b\u4e3a timestamp
.
DDL Clause:\nCREATE TABLE TS_TBL (ts timestamp(6) primary key, SIGNAL1 FLOAT, SIGNAL2 DOUBLE, ...);\n\ntime_window_clause:\nINTERVAL(timestamp_col, interval_val, time_unit) [SLIDING (sliding_val)] [fill_clause]\n\ntime_unit:\nSECOND | MINUTE | HOUR | DAY\n\nfill_clause:\nFILL(NONE | PREV | NEXT | NULL | VALUE, val | LINEAR)\n
\u521b\u5efa\u65f6\u5e8f\u8868\u7684\u65f6\u5019 ts
\u5217\u53ef\u4ee5\u6307\u5b9a timestamp
\u7684\u7cbe\u5ea6\uff0c\u6700\u5927\u4e3a timestamp(6)
\uff08\u5fae\u79d2\u7ea7\u522b\uff09\u3002
INTERVAL \u8bed\u53e5\u4e2d\u7684\u53c2\u6570\u542b\u4e49\uff1a
INTERVAL (timestamp_col, interval_val) \u4f5c\u7528\u4e8e\u6570\u636e\u4ea7\u751f\u76f8\u5f53\u65f6\u95f4\u5468\u671f interval_val \u7a97\u53e3\uff0cSLIDING \u7528\u4ee5\u6307\u5b9a\u7a97\u53e3\u5411\u524d\u6ed1\u52a8\u7684 sliding_val \u65f6\u95f4\u8ddd\u79bb\u3002
\u5f53 interval_val \u7b49\u4e8e sliding_val \u65f6\u4e3a Tumble window\u3002
\u5f53 interval_val \u5927\u4e8e sliding_val \u65f6\u4e3a Sliding window\u3002
\u5176\u4ed6\u4f7f\u7528\u8bf4\u660e\uff1a
\u4f7f\u7528\u793a\u4f8b\uff1a
\u8fd9\u4e2a\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u5728 10 \u5206\u949f\u7684\u65f6\u95f4\u7a97\u53e3\u5185\uff0c\u6bcf 5 \u5206\u949f\u6ed1\u52a8\u4e00\u6b21\uff0c\u7ed9\u51fa\u6bcf 5 \u5206\u949f\u7684\u6e29\u5ea6\u6700\u5927\u6700\u5c0f\u503c\u3002
mysql> drop table if exists sensor_data;\nCREATE TABLE sensor_data (ts timestamp(3) primary key, temperature FLOAT);\nINSERT INTO sensor_data VALUES('2023-08-01 00:00:00', 25.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:05:00', 26.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:15:00', 28.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:20:00', 30.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:25:00', 27.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:30:00', null);\nINSERT INTO sensor_data VALUES('2023-08-01 00:35:00', null);\nINSERT INTO sensor_data VALUES('2023-08-01 00:40:00', 28);\nINSERT INTO sensor_data VALUES('2023-08-01 00:45:00', 38);\nINSERT INTO sensor_data VALUES('2023-08-01 00:50:00', 31);\ninsert into sensor_data values('2023-07-31 23:55:00', 22);\nmysql> select _wstart, _wend, max(temperature), min(temperature) from sensor_data where ts > \"2023-08-01 00:00:00.000\" and ts < \"2023-08-01 00:50:00\" interval(ts, 10, minute) sliding(5, minute);\n+-------------------------+-------------------------+------------------+------------------+\n| _wstart | _wend | max(temperature) | min(temperature) |\n+-------------------------+-------------------------+------------------+------------------+\n| 2023-08-01 00:00:00.000 | 2023-08-01 00:10:00.000 | 26 | 26 |\n| 2023-08-01 00:05:00.000 | 2023-08-01 00:15:00.000 | 26 | 26 |\n| 2023-08-01 00:10:00.000 | 2023-08-01 00:20:00.000 | 28 | 28 |\n| 2023-08-01 00:15:00.000 | 2023-08-01 00:25:00.000 | 30 | 28 |\n| 2023-08-01 00:20:00.000 | 2023-08-01 00:30:00.000 | 30 | 27 |\n| 2023-08-01 00:25:00.000 | 2023-08-01 00:35:00.000 | 27 | 27 |\n| 2023-08-01 00:30:00.000 | 2023-08-01 00:40:00.000 | NULL | NULL |\n| 2023-08-01 00:35:00.000 | 2023-08-01 00:45:00.000 | 28 | 28 |\n| 2023-08-01 00:40:00.000 | 2023-08-01 00:50:00.000 | 38 | 28 |\n| 2023-08-01 00:45:00.000 | 2023-08-01 00:55:00.000 | 38 | 38 |\n+-------------------------+-------------------------+------------------+------------------+\n10 rows in set (0.04 sec)\n
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/#_3","title":"\u63d2\u503c","text":"\u5728\u5904\u7406\u65f6\u5e8f\u6570\u636e\u65f6\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u7f3a\u5931\u503c\u7684\u60c5\u51b5\u3002\u63d2\u503c\uff08FILL\uff09\u529f\u80fd\u5141\u8bb8\u6211\u4eec\u4ee5\u591a\u79cd\u65b9\u5f0f\u586b\u5145\u8fd9\u4e9b\u7f3a\u5931\u503c\uff0c\u786e\u4fdd\u6570\u636e\u7684\u8fde\u7eed\u6027\u548c\u5b8c\u6574\u6027\uff0c\u8fd9\u5bf9\u4e8e\u6570\u636e\u5206\u6790\u548c\u964d\u91c7\u6837\u8fc7\u7a0b\u81f3\u5173\u91cd\u8981\u3002\u65f6\u95f4\u7a97\u53e3\u7684 FIll
\u5b50\u53e5\u4f5c\u7528\u4e8e\u586b\u5145\u805a\u5408\u7ed3\u679c\u3002
MatrixOne \u63d0\u4f9b\u591a\u79cd\u63d2\u503c\u65b9\u6cd5\uff0c\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u6570\u636e\u5904\u7406\u9700\u6c42\uff1a
\u4f7f\u7528\u793a\u4f8b\uff1a
\u8fd9\u4e2a\u793a\u4f8b\u5728\u4e4b\u524d\u90a3\u5f20\u8868\u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u63d2\u503c\u903b\u8f91\uff0c\u4f1a\u5c06 NULL \u503c\u586b\u5145\u3002
select _wstart(ts), _wend(ts), max(temperature), min(temperature) from sensor_data where ts > \"2023-08-01 00:00:00.000\" and ts < \"2023-08-01 00:50:00.000\" interval(ts, 10, minute) sliding(5, minute) fill(prev);\n_wstart | _wend | max(temperature) | min(temperature) |\n==================================================================================================\n2023-08-01 00:00:00.000 | 2023-08-01 00:10:00.000 | 26.0000000 | 26.0000000 |\n2023-08-01 00:05:00.000 | 2023-08-01 00:15:00.000 | 26.0000000 | 26.0000000 |\n2023-08-01 00:10:00.000 | 2023-08-01 00:20:00.000 | 28.0000000 | 28.0000000 |\n2023-08-01 00:15:00.000 | 2023-08-01 00:25:00.000 | 30.0000000 | 28.0000000 |\n2023-08-01 00:20:00.000 | 2023-08-01 00:30:00.000 | 30.0000000 | 27.0000000 |\n2023-08-01 00:25:00.000 | 2023-08-01 00:35:00.000 | 27.0000000 | 27.0000000 |\n2023-08-01 00:30:00.000 | 2023-08-01 00:40:00.000 | 27.0000000 | 27.0000000 |\n2023-08-01 00:35:00.000 | 2023-08-01 00:45:00.000 | 28.0000000 | 28.0000000 |\n2023-08-01 00:40:00.000 | 2023-08-01 00:50:00.000 | 38.0000000 | 28.0000000 |\n2023-08-01 00:45:00.000 | 2023-08-01 00:55:00.000 | 38.0000000 | 38.0000000 |\n
"},{"location":"MatrixOne/Develop/read-data/window-function/window-function/","title":"\u7a97\u53e3\u51fd\u6570","text":"\u7a97\u53e3\u51fd\u6570\uff08Window Function\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u51fd\u6570\uff0c\u5b83\u80fd\u591f\u5728\u67e5\u8be2\u7ed3\u679c\u96c6\u7684\u67d0\u4e2a\u7a97\u53e3\uff08Window\uff09\u4e0a\u6267\u884c\u8ba1\u7b97\u64cd\u4f5c\u3002\u7a97\u53e3\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u5206\u7ec4\u3001\u6392\u5e8f\u548c\u805a\u5408\u64cd\u4f5c\uff0c\u540c\u65f6\u8fd8\u80fd\u591f\u5728\u6bcf\u4e2a\u7a97\u53e3\u5185\u8ba1\u7b97\u6bcf\u884c\u6570\u636e\u7684\u76f8\u5173\u503c\uff0c\u800c\u65e0\u9700\u6539\u53d8\u7ed3\u679c\u96c6\u7684\u884c\u6570\u3002\u5373\u901a\u8fc7\u7a97\u53e3\u51fd\u6570\uff0c\u53ef\u4ee5\u5728\u4e0d\u5f15\u5165\u989d\u5916\u7684\u5b50\u67e5\u8be2\u6216\u8fde\u63a5\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\uff0c\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u7075\u6d3b\u7684\u5206\u6790\u548c\u5904\u7406\u3002
SQL \u7a97\u53e3\u51fd\u6570\u5728\u591a\u79cd\u4e1a\u52a1\u573a\u666f\u4e2d\u90fd\u6709\u5176\u5e7f\u6cdb\u7684\u5e94\u7528\uff1a
\u884c\u5185\u6bd4\u8f83\uff1a\u5c06\u6bcf\u4e00\u884c\u7684\u67d0\u4e2a\u503c\u4e0e\u540c\u4e00\u7ec4\u5185\u7684\u5176\u4ed6\u884c\u8fdb\u884c\u6bd4\u8f83\uff0c\u4f8b\u5982\u8ba1\u7b97\u6bcf\u4e2a\u5458\u5de5\u7684\u85aa\u6c34\u4e0e\u90e8\u95e8\u5e73\u5747\u85aa\u6c34\u7684\u5dee\u503c\u3002\u8fd9\u65f6\u5019\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528\u7a97\u53e3\u51fd\u6570\u3002
\u6570\u636e\u6392\u540d\uff1a\u7a97\u53e3\u51fd\u6570\u53ef\u4ee5\u65b9\u4fbf\u5730\u751f\u6210\u6570\u636e\u7684\u6392\u540d\u4fe1\u606f\uff0c\u4f8b\u5982\uff0c\u4f60\u60f3\u8981\u67e5\u770b\u9500\u552e\u989d\u7684\u6392\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528 RANK()
\u6216\u8005 ROW_NUMBER()
\u51fd\u6570\u3002
\u6eda\u52a8\u8ba1\u7b97\uff1a\u8ba1\u7b97\u79fb\u52a8\u5e73\u5747\u3002\u4f60\u53ef\u4ee5\u5b9a\u4e49\u7a97\u53e3\u51fd\u6570\u7684\u7a97\u53e3\u8303\u56f4\uff0c\u7136\u540e\u8fdb\u884c\u6eda\u52a8\u8ba1\u7b97\u3002
\u5927\u591a\u6570\u805a\u5408\u51fd\u6570\u4e5f\u53ef\u4ee5\u7528\u4f5c\u7a97\u53e3\u51fd\u6570\uff0c\u4f8b\u5982\uff0cSUM()
\u3001AVG()
\u3001COUNT()
\u8fd9\u4e9b\u805a\u5408\u51fd\u6570\u53ef\u4ee5\u4e0e\u7a97\u53e3\u51fd\u6570\u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u5728\u7a97\u53e3\u5185\u8ba1\u7b97\u67d0\u4e2a\u5217\u7684\u603b\u548c\u3001\u5e73\u5747\u503c\u6216\u8ba1\u6570\u3002MatrixOne \u652f\u6301\u7684\u53ef\u505a\u7a97\u53e3\u51fd\u6570\u7684\u805a\u5408\u51fd\u6570\u548c\u53c2\u8003\u6587\u6863\u53c2\u89c1\uff1a
\u5176\u4ed6\u7a97\u53e3\u51fd\u6570\u53c2\u89c1\u4e0b\u8868\uff1a
\u4f7f\u7528\u7a97\u53e3\u51fd\u6570\u901a\u5e38\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u5b9a\u4e49\u7a97\u53e3\uff08Window\uff09\uff1a\u901a\u8fc7\u4f7f\u7528 OVER \u5b50\u53e5\u6765\u5b9a\u4e49\u7a97\u53e3\u7684\u8303\u56f4\uff0c\u53ef\u4ee5\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u89c4\u5219\u3001\u5206\u533a\u65b9\u5f0f\u548c\u884c\u8303\u56f4\u7b49\u3002
\u7f16\u5199\u7a97\u53e3\u51fd\u6570\uff1a\u5728 SELECT
\u8bed\u53e5\u4e2d\uff0c\u5c06\u7a97\u53e3\u51fd\u6570\u4e0e\u5176\u4ed6\u5217\u4e00\u8d77\u5217\u51fa\uff0c\u6307\u5b9a\u9700\u8981\u5728\u7a97\u53e3\u5185\u8ba1\u7b97\u7684\u5217\u548c\u64cd\u4f5c\u3002
\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528\u7a97\u53e3\u51fd\u6570\u8ba1\u7b97\u6bcf\u4e2a\u90e8\u95e8\u7684\u9500\u552e\u603b\u989d\u548c\u90e8\u95e8\u5185\u6bcf\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u6392\u540d\uff1a
CREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\nSELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR | Charlie | 850 | 1650 | 1 |\n| HR | Alice | 800 | 1650 | 2 |\n| Marketing | Jane | 1200 | 2200 | 1 |\n| Marketing | John | 1000 | 2200 | 2 |\n| Sales | Bob | 1100 | 2000 | 1 |\n| Sales | Alex | 900 | 2000 | 2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0cPARTITION BY
\u5b50\u53e5\u7528\u4e8e\u5c06\u7ed3\u679c\u96c6\u6309\u90e8\u95e8\u5206\u533a\uff0c\u7136\u540e SUM()
\u51fd\u6570\u8ba1\u7b97\u6bcf\u4e2a\u90e8\u95e8\u7684\u9500\u552e\u603b\u989d\u3002\u540c\u65f6\uff0cORDER BY
\u5b50\u53e5\u6307\u5b9a\u6309\u9500\u552e\u989d\u964d\u5e8f\u6392\u5217\uff0cRANK()
\u51fd\u6570\u6839\u636e\u9500\u552e\u989d\u4e3a\u6bcf\u4e2a\u90e8\u95e8\u5185\u7684\u5458\u5de5\u5206\u914d\u6392\u540d\u3002
\u672c\u7bc7\u6587\u7ae0\u7b80\u8981\u6982\u8ff0\u4e86 MatrixOne \u7684\u6570\u636e\u5e93\u6a21\u5f0f\u3002\u672c\u7bc7\u6982\u8ff0\u4e3b\u8981\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u76f8\u5173\u672f\u8bed\u548c\u540e\u7eed\u7684\u6570\u636e\u8bfb\u5199\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#-","title":"\u5173\u952e\u672f\u8bed - \u6570\u636e\u5e93\u6a21\u5f0f","text":"\u6570\u636e\u5e93\u6a21\u5f0f (Schema)\uff1a\u672c\u7bc7\u6587\u7ae0\u6240\u63d0\u5230\u7684\u6570\u636e\u5e93\u6a21\u5f0f\u7b49\u540c\u4e8e\u903b\u8f91\u5bf9\u8c61\u6570\u636e\u5e93\uff0c\u4e0e MySQL \u4e00\u6837\uff0c\u4e0d\u505a\u533a\u5206\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#database","title":"\u6570\u636e\u5e93 Database","text":"MatrixOne \u6570\u636e\u5e93\u6216 MatrixOne Database\uff0c\u4e3a\u8868\u7684\u96c6\u5408\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 SHOW DATABASES;
\u67e5\u770b MatrixOne \u6240\u5305\u542b\u7684\u9ed8\u8ba4\u6570\u636e\u5e93\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 CREATE DATABASE database_name;
\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u3002
MatrixOne \u6240\u6307\u7684\u8868\u6216 Table\uff0c\u4ece\u5c5e\u4e8e MatrixOne \u7684\u67d0\u4e2a\u6570\u636e\u5e93\u3002
\u8868\u5305\u542b\u6570\u636e\u884c\u3002\u6bcf\u884c\u6570\u636e\u4e2d\u7684\u6bcf\u4e2a\u503c\u90fd\u5c5e\u4e8e\u4e00\u4e2a\u7279\u5b9a\u7684\u5217\u3002\u6bcf\u5217\u90fd\u53ea\u5141\u8bb8\u5355\u4e00\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#index","title":"\u7d22\u5f15 Index","text":"\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u6570\u636e\u5e93\u8868\u683c\u4e2d\u7684\u6570\u636e\u3002\u5b83\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u672c\u76ee\u5f55\uff0c\u5305\u542b\u6709\u5173\u8868\u683c\u4e2d\u5404\u884c\u6570\u636e\u7684\u6307\u9488\uff0c\u4f7f\u5f97\u67e5\u8be2\u53ef\u4ee5\u66f4\u5feb\u901f\u5730\u5b9a\u4f4d\u5230\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u6570\u636e\u3002
\u6570\u636e\u5e93\u4e2d\u5e38\u7528\u7684\u7d22\u5f15\u7c7b\u578b\u5305\u62ec\u4e3b\u952e\u7d22\u5f15\u3001\u6b21\u7ea7\u7d22\u5f15\u7b49\u3002\u5176\u4e2d\uff0c\u552f\u4e00\u7d22\u5f15\u7528\u4e8e\u4fdd\u8bc1\u7279\u5b9a\u5217\u6216\u5217\u7ec4\u5408\u7684\u552f\u4e00\u6027\uff0c\u666e\u901a\u7d22\u5f15\u7528\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\uff0c\u5168\u6587\u7d22\u5f15\u5219\u7528\u4e8e\u5728\u6587\u672c\u6570\u636e\u4e2d\u8fdb\u884c\u5168\u6587\u68c0\u7d22\u3002
\u7d22\u5f15\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u7c7b\u578b\uff0c\u5206\u522b\u4e3a\uff1a
Note: \u5f53\u524d MatrixOne \u4ec5\u652f\u6301\u4e3b\u952e\u7d22\u5f15\uff08Primary Key\uff09\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#_2","title":"\u5176\u4ed6\u5bf9\u8c61","text":"MatrixOne \u652f\u6301\u4e00\u4e9b\u548c\u8868\u540c\u7ea7\u7684\u5bf9\u8c61\uff1a
MatrixOne \u73b0\u5728\u652f\u6301\u5b58\u50a8\u548c\u67e5\u8be2\u5411\u91cf\u3002\u5411\u91cf\u662f\u901a\u5e38\u7531 AI \u6a21\u578b\uff08\u5982\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff09\u751f\u6210\u7684\u6570\u5b57\u5217\u8868\u3002
Note: \u5f53\u524d MatrixOne \u4ec5\u652f\u6301\u63d2\u5165\u548c\u67e5\u8be2\u5411\u91cf\u6570\u636e\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u5411\u91cf
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#_4","title":"\u8bbf\u95ee\u63a7\u5236","text":"MatrixOne \u652f\u6301\u57fa\u4e8e\u7528\u6237\u6216\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u89d2\u8272\u6216\u76f4\u63a5\u6307\u5411\u7528\u6237\uff0c\u4ece\u800c\u6388\u4e88\u7528\u6237\u67e5\u770b\u3001\u4fee\u6539\u6216\u5220\u9664\u6570\u636e\u5bf9\u8c61\u548c\u6570\u636e\u6a21\u5f0f\u7684\u6743\u9650\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 MatrixOne \u4e2d\u7684\u6743\u9650\u63a7\u5236\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-database/","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"\u672c\u7bc7\u6587\u6863\u4e2d\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u6765\u521b\u5efa\u6570\u636e\u5e93\uff0c\u53ca\u521b\u5efa\u6570\u636e\u5e93\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219\u3002
Note
\u6b64\u5904\u4ec5\u5bf9 CREATE DATABASE
\u8bed\u53e5\u8fdb\u884c\u7b80\u5355\u63cf\u8ff0\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE DATABASE\u3002
\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u5728 MatrixOne \u4e2d\u6570\u636e\u5e93\u5bf9\u8c61\u53ef\u4ee5\u5305\u542b\u8868\u3001\u89c6\u56fe\u7b49\u5bf9\u8c61\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-database/#_4","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"\u53ef\u4f7f\u7528 CREATE DATABASE
\u8bed\u53e5\u6765\u521b\u5efa\u6570\u636e\u5e93\u3002
CREATE DATABASE IF NOT EXISTS `modatabase`;\n
\u6b64\u8bed\u53e5\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a modatabase \u7684\u6570\u636e\u5e93\uff08\u5982\u679c\u5c1a\u4e0d\u5b58\u5728\uff09\u3002
\u8981\u67e5\u770b\u96c6\u7fa4\u4e2d\u7684\u6570\u636e\u5e93\uff0c\u53ef\u5728\u547d\u4ee4\u884c\u6267\u884c\u4e00\u6761 SHOW DATABASES
\u8bed\u53e5\uff1a
SHOW DATABASES;\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+--------------------+\n| Database |\n+--------------------+\n| mo_catalog |\n| system |\n| system_metrics |\n| mysql |\n| information_schema |\n| modatabase |\n+--------------------+\n
"},{"location":"MatrixOne/Develop/schema-design/create-database/#_5","title":"\u6570\u636e\u5e93\u521b\u5efa\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219","text":"\u4f60\u53ef\u4ee5\u4f7f\u7528 CREATE DATABASE
\u8bed\u53e5\u6765\u521b\u5efa\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u5728 SQL \u4f1a\u8bdd\u4e2d\u4f7f\u7528 USE {databasename};
\u8bed\u53e5\u6765\u4f7f\u7528\u4f60\u6240\u521b\u5efa\u7684\u6570\u636e\u5e93\u3002
\u79df\u6237\u6216\u7528\u6237\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u3001\u89d2\u8272\u6216\u5b50\u7ea7\u7528\u6237\u65f6\uff0c\u53ea\u8d4b\u4e88\u79df\u6237\u6216\u7528\u6237\u5fc5\u8981\u7684\u6743\u9650\uff0c\u53c2\u89c1 MatrixOne \u4e2d\u7684\u6743\u9650\u63a7\u5236\u3002
\u4f60\u5df2\u7ecf\u51c6\u5907\u5b8c\u6bd5 modatabase \u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u5c06\u8868\u6dfb\u52a0\u5230\u8be5\u6570\u636e\u5e93\u4e2d\uff0c\u53c2\u89c1\u4e0b\u4e00\u7ae0\u8282\u521b\u5efa\u8868\u3002
\u5728\u975e\u4e3b\u952e\u4e0a\u6807\u8bc6\u7684\u7d22\u5f15\uff0c\u6b21\u7ea7\u7d22\u5f15\u4e5f\u79f0\u4e3a\u975e\u805a\u96c6\u7d22\u5f15\uff08non-clustered index\uff09\uff0c\u7528\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u548c\u52a0\u901f\u6570\u636e\u68c0\u7d22\u3002\u6b21\u7ea7\u7d22\u5f15\u5e76\u4e0d\u76f4\u63a5\u5b58\u50a8\u8868\u6570\u636e\uff0c\u800c\u662f\u5bf9\u6570\u636e\u7684\u4e00\u90e8\u5206\uff08\u5982\u67d0\u4e2a\u5217\uff09\u5efa\u7acb\u7d22\u5f15\uff0c\u4ece\u800c\u5141\u8bb8\u6570\u636e\u5e93\u7cfb\u7edf\u5feb\u901f\u5b9a\u4f4d\u8868\u4e2d\u5305\u542b\u7279\u5b9a\u503c\u7684\u884c\u3002
\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\u53ef\u4ee5\u5e2e\u52a9\u52a0\u901f\u67e5\u8be2\u64cd\u4f5c\uff0c\u7279\u522b\u662f\u5728\u5bf9\u5927\u578b\u8868\u8fdb\u884c\u67e5\u8be2\u65f6\u3002\u6b21\u7ea7\u7d22\u5f15\u8fd8\u53ef\u4ee5\u7528\u4e8e\u652f\u6301\u6392\u5e8f\u3001\u5206\u7ec4\u548c\u8fde\u63a5\u64cd\u4f5c\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u901a\u5e38\u9700\u8981\u5bf9\u8868\u4e2d\u7684\u4e00\u90e8\u5206\u6570\u636e\u8fdb\u884c\u6392\u5e8f\u6216\u8005\u5339\u914d\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#_3","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\u79cd\u662f\u5728\u5efa\u8868\u7684\u65f6\u5019\u5c31\u5efa\u7acb KEY
\u6b21\u7ea7\u7d22\u5f15\uff0c\u53e6\u4e00\u79cd\u53ef\u4ee5\u5728\u5efa\u8868\u540e\u901a\u8fc7 CREATE INDEX
\u6216\u8005 ALTER TABLE ADD index
\u8bed\u53e5\u52a8\u6001\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\uff0c\u6307\u5b9a\u7d22\u5f15\u6240\u9488\u5bf9\u7684\u5217\u4ee5\u53ca\u5176\u4ed6\u7d22\u5f15\u9009\u9879\u3002
\u8bed\u6cd5\u7ed3\u6784\u5206\u522b\u4e3a\uff1a
CREATE TABLE table_name (\ncol1 int primary key, col2 int, KEY index_name (col2) );\n\nCREATE INDEX index_name ON table_name (column_name);\n\nALTER TABLE ADD INDEX index_name ON table_name (column_name);\n
\u5176\u4e2d\uff0cindex_name
\u662f\u7d22\u5f15\u7684\u540d\u79f0\uff0ctable_name
\u662f\u8981\u5728\u5176\u4e0a\u521b\u5efa\u7d22\u5f15\u7684\u8868\u683c\u540d\u79f0\uff0c\u800c column_name
\u662f\u7528\u4e8e\u521b\u5efa\u7d22\u5f15\u7684\u5217\u540d\u3002
\u4f8b\u5982\uff0c\u5982\u679c\u8981\u5728\u540d\u4e3a employees
\u7684\u8868\u683c\u7684 last_name
\u5217\u4e0a\u521b\u5efa\u4e00\u4e2a\u6b21\u7ea7\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\uff1a
CREATE INDEX idx_lastname ON employees (last_name);\n
\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\uff1a\u53ef\u4ee5\u5728\u67e5\u8be2\u8bed\u53e5\u4e2d\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\u6765\u5b9a\u4f4d\u6570\u636e\u884c\u3002SQL \u67e5\u8be2\u4f18\u5316\u5668\u4f1a\u81ea\u52a8\u9009\u62e9\u5408\u9002\u7684\u7d22\u5f15\u6765\u6267\u884c\u67e5\u8be2\u64cd\u4f5c\uff0c\u4ee5\u83b7\u5f97\u6700\u4f73\u6027\u80fd\u3002\u5982\uff1a
SELECT * FROM employees WHERE last_name = 'Smith';\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u67e5\u8be2\u4f18\u5316\u5668\u4f1a\u4f7f\u7528 idx_lastname
\u7d22\u5f15\u6765\u5b9a\u4f4d last_name
\u4e3a Smith
\u7684\u6570\u636e\u884c\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u521b\u5efa\u7d22\u5f15\u4f1a\u589e\u52a0\u6570\u636e\u5e93\u7684\u5b58\u50a8\u548c\u7ef4\u62a4\u6210\u672c\uff0c\u5e76\u4e14\u5728\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u6570\u636e\u65f6\u4e5f\u53ef\u80fd\u4f1a\u5f71\u54cd\u6027\u80fd\u3002\u56e0\u6b64\uff0c\u5728\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\u65f6\u9700\u8981\u4ed4\u7ec6\u8003\u8651\u5176\u5bf9\u6570\u636e\u5e93\u6027\u80fd\u7684\u5f71\u54cd\uff0c\u5e76\u8fdb\u884c\u5fc5\u8981\u7684\u4f18\u5316\u548c\u8c03\u6574\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#sql","title":"SQL \u793a\u4f8b","text":"CREATE TABLE users (id INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\nemail VARCHAR(50)\n);\n-- \u6211\u4eec\u53ef\u4ee5\u5728\u8868\u683c\u4e0a\u521b\u5efa\u4e00\u4e2a\u6b21\u7ea7\u7d22\u5f15\u6765\u52a0\u5feb\u6309\u540d\u5b57\u67e5\u8be2\u7528\u6237\u7684\u901f\u5ea6\nCREATE INDEX idx_users_name ON users(name);\n-- \u63d2\u5165\u4e00\u4e9b\u6570\u636e\nINSERT INTO users VALUES ('1', 'John', '30', 'john@gmail.com');\nINSERT INTO users VALUES ('2', 'Tommy', '50', 'tom@gmail.com');\nINSERT INTO users VALUES ('3', 'Ann', '33', 'ann@gmail.com');\n-- \u6267\u884c\u5982\u4e0b\u67e5\u8be2\uff0c\u6570\u636e\u5e93\u53ef\u4ee5\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\u6765\u5feb\u901f\u5730\u67e5\u627e\u6240\u6709\u540d\u5b57\u4e3a\u201cJohn\u201d\u7684\u7528\u6237\uff0c\u800c\u4e0d\u5fc5\u626b\u63cf\u6574\u4e2a\u8868\u683c\u3002\nmysql> SELECT * FROM users WHERE name = 'John';\n+------+------+------+----------------+\n| id | name | age | email |\n+------+------+------+----------------+\n| 1 | John | 30 | john@gmail.com |\n+------+------+------+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#_5","title":"\u590d\u5408\u6b21\u7ea7\u7d22\u5f15","text":"MatrixOne \u4e5f\u652f\u6301\u590d\u5408\u6b21\u7ea7\u7d22\u5f15\uff0c\u5373\u5728\u4e24\u4e2a\u6216\u66f4\u591a\u5217\u4e0a\u521b\u5efa\u7684\u7d22\u5f15\u3002\u5b83\u5141\u8bb8\u5728\u4e00\u4e2a\u7d22\u5f15\u4e2d\u5305\u542b\u591a\u4e2a\u5217\uff0c\u4ece\u800c\u4f18\u5316\u6d89\u53ca\u8fd9\u4e9b\u5217\u7684\u67e5\u8be2\u3002
\u5bf9\u4e8e\u8de8\u591a\u4e2a\u5217\u7684\u67e5\u8be2\uff0c\u590d\u5408\u7d22\u5f15\u53ef\u4ee5\u5927\u5e45\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002\u5b83\u4eec\u5728\u6267\u884c\u6392\u5e8f\u548c\u8fc7\u6ee4\u4efb\u52a1\u65f6\u7279\u522b\u6709\u6548\uff0c\u5c24\u5176\u662f\u5f53\u8fd9\u4e9b\u64cd\u4f5c\u6d89\u53ca\u5230\u591a\u4e2a\u5b57\u6bb5\u65f6\u3002\u5982\u679c\u67e5\u8be2\u53ea\u6d89\u53ca\u7d22\u5f15\u4e2d\u7684\u5217\uff0c\u6570\u636e\u5e93\u53ef\u4ee5\u76f4\u63a5\u4ece\u7d22\u5f15\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u800c\u65e0\u9700\u8bbf\u95ee\u8868\u4e2d\u7684\u884c\uff0c\u8fd9\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002
\u590d\u5408\u6b21\u7ea7\u7d22\u5f15\u4f7f\u7528\u6ce8\u610f\u4e8b\u9879\uff1a
\u5047\u8bbe\u6709\u4e00\u4e2a\u8ba2\u5355\u8868 orders
\uff0c\u5176\u4e2d\u5305\u542b customer_id
, order_date
, \u548c status
\u5217\u3002\u4e3a\u4e86\u4f18\u5316\u6d89\u53ca\u8fd9\u4e9b\u5217\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u590d\u5408\u7d22\u5f15\uff1a
CREATE INDEX idx_customer_date_status ON orders(customer_id, order_date, status);\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u6709\u57fa\u4e8e customer_id
\u548c order_date
\u7684\u67e5\u8be2\uff0c\u8fd9\u4e2a\u590d\u5408\u7d22\u5f15\u4f1a\u975e\u5e38\u6709\u7528\u3002\u7136\u800c\uff0c\u5982\u679c\u67e5\u8be2\u53ea\u6d89\u53ca order_date
\uff0c\u8fd9\u4e2a\u590d\u5408\u7d22\u5f15\u53ef\u80fd\u4e0d\u4f1a\u88ab\u6709\u6548\u5229\u7528\uff0c\u56e0\u4e3a order_date
\u4e0d\u662f\u7d22\u5f15\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5217\u3002
MatrixOne \u6682\u65f6\u4e0d\u652f\u6301 Online DDL\u3002\u52a8\u6001\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\uff0c\u65e0\u8bba\u662f ALTER TABLE ADD INDEX
\u8fd8\u662f CREATE INDEX
\u90fd\u4f1a\u5bfc\u81f4\u539f\u8868\u4e0a\u9501\uff0c\u5176\u4ed6\u4e8b\u52a1\u7684 DML \u64cd\u4f5c\u4f1a\u88ab\u963b\u585e (INSERT, UPDATE,DELETE, SELECT FOR UPDATE)\u3002
MatrixOne \u76ee\u524d\u4e0d\u652f\u6301 FULLTEXT \u53ca SPATIAL \u7d22\u5f15\u3002
CTAS(Create Table As Select)\uff0c\u662f\u4e00\u79cd SQL \u8bed\u53e5\uff0c\u7528\u4e8e\u57fa\u4e8e\u73b0\u6709\u8868\u6216\u67e5\u8be2\u7ed3\u679c\u5feb\u901f\u521b\u5efa\u4e00\u4e2a\u65b0\u8868 (\u590d\u5236\u8868\uff09\u3002CTAS \u8bed\u53e5\u6267\u884c\u65f6\uff0c\u4f1a\u6839\u636e SELECT \u5b50\u53e5\u751f\u6210\u7684\u6570\u636e\u76f4\u63a5\u521b\u5efa\u4e00\u4e2a\u65b0\u8868\uff0c\u5e76\u4e14\u65b0\u8868\u7684\u5217\u7ed3\u6784\u548c\u6570\u636e\u7c7b\u578b\u4f1a\u4e0e SELECT \u5b50\u53e5\u4e2d\u7684\u7ed3\u679c\u96c6\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_1","title":"\u5e94\u7528\u573a\u666f","text":"CTAS \u7684\u5e94\u7528\u573a\u666f\u975e\u5e38\u5e7f\u6cdb\uff0c\u4e3b\u8981\u5305\u62ec\uff1a
\u6570\u636e\u8fc1\u79fb\uff1a\u4f7f\u7528 CTAS \u53ef\u4ee5\u5feb\u901f\u5730\u5c06\u6570\u636e\u4ece\u4e00\u4e2a\u8868\u8fc1\u79fb\u5230\u53e6\u4e00\u4e2a\u8868\uff0c\u540c\u65f6\u53ef\u4ee5\u6539\u53d8\u8868\u7684\u5b58\u50a8\u7ed3\u6784\u548c\u5206\u5e03\u7b56\u7565\uff0c\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u67e5\u8be2\u548c\u5b58\u50a8\u9700\u6c42\u3002
\u6570\u636e\u5907\u4efd\uff1aCTAS \u53ef\u4ee5\u7528\u6765\u521b\u5efa\u6570\u636e\u7684\u5907\u4efd\u526f\u672c\uff0c\u8fd9\u5bf9\u4e8e\u6570\u636e\u6062\u590d\u548c\u5386\u53f2\u6570\u636e\u5206\u6790\u975e\u5e38\u6709\u7528\u3002
\u8868\u7ed3\u6784\u53d8\u66f4\uff1a\u5f53\u9700\u8981\u4fee\u6539\u8868\u7ed3\u6784\uff08\u5982\u6dfb\u52a0\u6216\u5220\u9664\u5217\u3001\u66f4\u6539\u6570\u636e\u7c7b\u578b\u7b49\uff09\u65f6\uff0cCTAS \u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868\u6765\u53cd\u6620\u8fd9\u4e9b\u66f4\u6539\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u539f\u59cb\u8868\u3002
\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\uff1a\u5728\u6570\u636e\u79d1\u5b66\u9879\u76ee\u4e2d\uff0cCTAS \u53ef\u4ee5\u7528\u4e8e\u51c6\u5907\u6570\u636e\u96c6\uff0c\u521b\u5efa\u9002\u5408\u673a\u5668\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u7684\u5e72\u51c0\u3001\u683c\u5f0f\u5316\u7684\u6570\u636e\u8868\u3002
CTAS \u662f\u4e00\u79cd\u9ad8\u6548\u7684 SQL \u64cd\u4f5c\uff0c\u5b83\u901a\u8fc7\u7b80\u5316\u6570\u636e\u7ba1\u7406\u6d41\u7a0b\u548c\u589e\u5f3a\u64cd\u4f5c\u7684\u7075\u6d3b\u6027\uff0c\u5927\u5e45\u63d0\u5347\u4e86\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u7684\u6548\u7387\u3002\u4f46\u5728\u5e94\u7528 CTAS \u65f6\uff0c\u9700\u8981\u8003\u8651\u5230\u76ee\u6807\u6570\u636e\u5e93\u7cfb\u7edf\u5bf9 CTAS \u7684\u652f\u6301\u7a0b\u5ea6\u53ca\u5176\u5bf9\u7cfb\u7edf\u6027\u80fd\u7684\u6f5c\u5728\u5f71\u54cd\uff0c\u4ee5\u4fdd\u8bc1\u6570\u636e\u540c\u6b65\u548c\u64cd\u4f5c\u7684\u51c6\u786e\u6027\u548c\u6709\u6548\u6027\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#ctas_2","title":"\u5982\u4f55\u4f7f\u7528 CTAS","text":""},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_3","title":"\u8bed\u6cd5","text":"CTAS
\u8bed\u53e5\u901a\u5e38\u91c7\u7528\u4ee5\u4e0b\u5f62\u5f0f\uff1a
CREATE [TEMPORARY] TABLE table_name as select
\u6709\u5173\u66f4\u591a\u7684\u8bed\u6cd5\u8bf4\u660e\uff0c\u8bf7\u67e5\u770b\u7ae0\u8282 Create Table As Select
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_4","title":"\u6848\u4f8b","text":"\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u7535\u5b50\u5546\u52a1\u5e73\u53f0\uff0c\u5e76\u4e14\u6211\u4eec\u60f3\u8981\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u8868\u6765\u5206\u6790\u6bcf\u4e2a\u8ba2\u5355\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u8ba2\u5355\u53f7\u3001\u5ba2\u6237 ID\u3001\u8ba2\u5355\u65e5\u671f\u3001\u4ea7\u54c1 ID\u3001\u4ea7\u54c1\u6570\u91cf\u548c\u4ea7\u54c1\u4ef7\u683c\u3002
CREATE TABLE orders(\norder_id int auto_increment PRIMARY KEY,\ncustomer_id int,\norder_date date,\nproduct_id int,\nquantity int,\nprice float\n);\n\nINSERT INTO orders(customer_id,order_date,product_id,quantity,price) values(30,\"2023-04-01\",5001,2,19.99);\nINSERT INTO orders(customer_id,order_date,product_id,quantity,price) values(40,\"2023-04-02\",5002,1,29.99);\nINSERT INTO orders(customer_id,order_date,product_id,quantity,price) values(30,\"2023-04-03\",5001,1,19.99);\n\nmysql> select * from orders;\n+----------+-------------+------------+------------+----------+-------+\n| order_id | customer_id | order_date | product_id | quantity | price |\n+----------+-------------+------------+------------+----------+-------+\n| 1 | 30 | 2023-04-01 | 5001 | 2 | 19.99 |\n| 2 | 40 | 2023-04-02 | 5002 | 1 | 29.99 |\n| 3 | 30 | 2023-04-03 | 5001 | 1 | 19.99 |\n+----------+-------------+------------+------------+----------+-------+\n3 rows in set (0.00 sec)\n\n--\u4e3a\u4e86\u4fbf\u4e8e\u5206\u6790\uff0c\u6211\u4eec\u60f3\u8981\u5c06\u6bcf\u4e2a\u8ba2\u5355\u7684\u603b\u4ef7\u683c\u8ba1\u7b97\u51fa\u6765\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u8ba2\u5355\u53f7\u3001\u5ba2\u6237 ID\u3001\u8ba2\u5355\u65e5\u671f\u548c\u8ba2\u5355\u603b\u4ef7\u683c\u3002\nCREATE TABLE orders_analysis AS\nSELECT order_id,\ncustomer_id,\norder_date,\nproduct_id,\nquantity,\nprice,\nCAST((quantity * price) AS float) AS total_price\nFROM orders;\n\nmysql> select * from orders_analysis;\n+----------+-------------+------------+------------+----------+-------+-------------+\n| order_id | customer_id | order_date | product_id | quantity | price | total_price |\n+----------+-------------+------------+------------+----------+-------+-------------+\n| 1 | 30 | 2023-04-01 | 5001 | 2 | 19.99 | 39.98 |\n| 2 | 40 | 2023-04-02 | 5002 | 1 | 29.99 | 29.99 |\n| 3 | 30 | 2023-04-03 | 5001 | 1 | 19.99 | 19.99 |\n+----------+-------------+------------+------------+----------+-------+-------------+\n3 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cCTAS \u8bed\u53e5\u4e0d\u4ec5\u590d\u5236\u4e86\u539f\u59cb\u8868\u4e2d\u7684\u5217\uff0c\u800c\u4e14\u8fd8\u6dfb\u52a0\u4e86\u4e00\u4e2a\u65b0\u7684\u8ba1\u7b97\u5217 total_price\uff0c\u8be5\u5217\u901a\u8fc7\u5c06\u6bcf\u4e2a\u8ba2\u5355\u7684\u4ea7\u54c1\u6570\u91cf\u4e58\u4ee5\u4ef7\u683c\u6765\u8ba1\u7b97\u8ba2\u5355\u884c\u9879\u7684\u603b\u4ef7\u683c\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u5f97\u5230\u4e86\u4e00\u4e2a\u9002\u5408\u8fdb\u884c\u9500\u552e\u5206\u6790\u7684\u65b0\u8868\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528\u4e8e\u751f\u6210\u62a5\u544a\u6216\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u6570\u636e\u5206\u6790\u3002
\u8fd9\u4e2a\u4f8b\u5b50\u5c55\u793a\u4e86 CTAS \u5728\u6570\u636e\u8f6c\u6362\u548c\u51c6\u5907\u65b9\u9762\u7684\u5f3a\u5927\u80fd\u529b\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\u5728\u521b\u5efa\u65b0\u8868\u7684\u540c\u65f6\u8fdb\u884c\u6570\u636e\u7684\u6e05\u6d17\u548c\u8f6c\u6362\uff0c\u4ece\u800c\u4e3a\u6570\u636e\u5206\u6790\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/","title":"\u521b\u5efa\u8868","text":"\u672c\u7bc7\u6587\u6863\u4e2d\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u6765\u521b\u5efa\u8868\u3002\u4e0a\u4e00\u7bc7\u6587\u6863\u4e2d\u4ecb\u7ecd\u4e86\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a modatabase \u7684\u6570\u636e\u5e93\uff0c\u672c\u7bc7\u6587\u6863\u6211\u4eec\u4ecb\u7ecd\u5728\u8fd9\u4e2a\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u8868\u3002
Note
\u6b64\u5904\u4ec5\u5bf9 CREATE TABLE
\u8bed\u53e5\u8fdb\u884c\u7b80\u5355\u63cf\u8ff0\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE TABLE\u3002
\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u8868\u662f MatrixOne \u6570\u636e\u5e93\u96c6\u7fa4\u4e2d\u7684\u4e00\u79cd\u903b\u8f91\u5bf9\u8c61\uff0c\u5b83\u4ece\u5c5e\u4e8e\u67d0\u4e2a\u6570\u636e\u5e93\uff0c\u7528\u4e8e\u4fdd\u5b58\u6570\u636e\u3002
\u8868\u4ee5\u884c\u548c\u5217\u7684\u5f62\u5f0f\u7ec4\u7ec7\u6570\u636e\u8bb0\u5f55\uff0c\u4e00\u5f20\u8868\u81f3\u5c11\u6709\u4e00\u5217\u3002\u82e5\u5728\u8868\u4e2d\u5b9a\u4e49\u4e86 n \u4e2a\u5217\uff0c\u90a3\u4e48\u6bcf\u4e00\u884c\u6570\u636e\u90fd\u5c06\u62e5\u6709\u4e0e\u8fd9 n \u4e2a\u5217\u4e2d\u6570\u636e\u683c\u5f0f\u5b8c\u5168\u4e00\u81f4\u7684\u5b57\u6bb5\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_4","title":"\u547d\u540d\u8868","text":"\u521b\u5efa\u4e00\u4e2a\u6709\u5b9e\u9645\u610f\u4e49\u7684\u8868\u540d\u79f0\uff0c\u542b\u6709\u5173\u952e\u8bcd\u6216\u7f16\u53f7\u89c4\u8303\u7684\u8868\u540d\u79f0\uff0c\u9075\u5faa\u547d\u540d\u89c4\u8303\uff0c\u65b9\u4fbf\u67e5\u627e\u548c\u4f7f\u7528\u3002
CREATE TABLE
\u8bed\u53e5\u901a\u5e38\u91c7\u7528\u4ee5\u4e0b\u5f62\u5f0f\uff1a
CREATE TABLE {table_name} ({elements});\n
\u53c2\u6570\u63cf\u8ff0
\u5217\u4ece\u5c5e\u4e8e\u8868\uff0c\u6bcf\u5f20\u8868\u90fd\u81f3\u5c11\u6709\u4e00\u5217\u3002\u5217\u901a\u8fc7\u5c06\u6bcf\u884c\u4e2d\u7684\u503c\u5206\u6210\u4e00\u4e2a\u4e2a\u5355\u4e00\u6570\u636e\u7c7b\u578b\u7684\u5c0f\u5355\u5143\u6765\u4e3a\u8868\u63d0\u4f9b\u7ed3\u6784\u3002
\u5217\u5b9a\u4e49\u901a\u5e38\u4f7f\u7528\u4ee5\u4e0b\u5f62\u5f0f\uff1a
{column_name} {data_type} {column_qualification}\n
\u53c2\u6570\u63cf\u8ff0
\u8fd9\u91cc\u4ecb\u7ecd\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a NATION \u7684\u8868\u6765\u5b58\u50a8 modatabase \u5e93\u4e2d\u7684\u7528\u6237\u4fe1\u606f\u3002
\u53ef\u4ee5\u4e3a NATION \u8868\u6dfb\u52a0\u4e00\u4e9b\u5217\u3002
CREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152)\n);\n
\u793a\u4f8b\u89e3\u91ca
\u4e0b\u8868\u5c06\u89e3\u91ca\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u7684\u5b57\u6bb5\uff1a
\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b \u4f5c\u7528 \u89e3\u91ca N_NATIONKEY INTEGER \u6c11\u65cf\u7684\u552f\u4e00\u6807\u8bc6 \u6240\u6709\u6807\u8bc6\u90fd\u5e94\u8be5\u662f INTEGER \u7c7b\u578b\u7684 N_NAME CHAR \u6c11\u65cf\u540d\u5b57 \u6c11\u65cf\u7684\u540d\u79f0\u90fd\u662f char \u7c7b\u578b\uff0c\u4e14\u4e0d\u8d85\u8fc7 25 \u5b57\u7b26 N_REGIONKEY INTEGER \u5730\u533a\u533a\u53f7\uff0c\u552f\u4e00\u6807\u8bc6 \u6240\u6709\u6807\u8bc6\u90fd\u5e94\u8be5\u662f INTEGER \u7c7b\u578b\u7684 N_COMMENT VARCHAR comment \u4fe1\u606f varchar \u7c7b\u578b\uff0c\u4e14\u4e0d\u8d85\u8fc7 152 \u5b57\u7b26MatrixOne \u652f\u6301\u8bb8\u591a\u5176\u4ed6\u7684\u5217\u6570\u636e\u7c7b\u578b\uff0c\u5305\u542b\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u65f6\u95f4\u7b49\uff0c\u53c2\u89c1\u6570\u636e\u7c7b\u578b\u3002
\u521b\u5efa\u4e00\u4e2a\u590d\u6742\u8868
\u521b\u5efa\u4e00\u5f20 ORDERS \u8868\u3002
CREATE TABLE ORDERS(\nO_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n
\u8fd9\u5f20\u8868\u6bd4 NATION \u8868\u5305\u542b\u66f4\u591a\u7684\u6570\u636e\u7c7b\u578b\uff1a
\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b \u4f5c\u7528 \u89e3\u91ca O_TOTALPRICE DECIMAL \u7528\u4e8e\u6807\u8bb0\u4ef7\u683c \u7cbe\u5ea6\u4e3a 15\uff0c\u6bd4\u4f8b\u4e3a 2\uff0c\u5373\u7cbe\u5ea6\u4ee3\u8868\u5b57\u6bb5\u6570\u503c\u7684\u603b\u4f4d\u6570\uff0c\u800c\u6bd4\u4f8b\u4ee3\u8868\u5c0f\u6570\u70b9\u540e\u6709\u591a\u5c11\u4f4d\uff0c\u4f8b\u5982\uff1adecimal(5,2)\uff0c\u5373\u7cbe\u5ea6\u4e3a 5\uff0c\u6bd4\u4f8b\u4e3a 2 \u65f6\uff0c\u5176\u53d6\u503c\u8303\u56f4\u4e3a -999.99 \u5230 999.99\u3002decimal(6,1) \uff0c\u5373\u7cbe\u5ea6\u4e3a 6\uff0c\u6bd4\u4f8b\u4e3a 1 \u65f6\uff0c\u5176\u53d6\u503c\u8303\u56f4\u4e3a -99999.9 \u5230 99999.9\u3002 O_ORDERDATE DATE \u65e5\u671f\u503c \u8ba2\u5355\u4ea7\u751f\u7684\u65e5\u671f"},{"location":"MatrixOne/Develop/schema-design/create-table/#_6","title":"\u9009\u62e9\u4e3b\u952e","text":"\u4e3b\u952e\u662f\u4e00\u4e2a\u6216\u4e00\u7ec4\u5217\uff0c\u8fd9\u4e2a\u7531\u6240\u6709\u4e3b\u952e\u5217\u7ec4\u5408\u8d77\u6765\u7684\u503c\u662f\u6570\u636e\u884c\u7684\u552f\u4e00\u6807\u8bc6\u3002
\u4e3b\u952e\u5728 CREATE TABLE
\u8bed\u53e5\u4e2d\u5b9a\u4e49\u3002\u4e3b\u952e\u7ea6\u675f\u8981\u6c42\u6240\u6709\u53d7\u7ea6\u675f\u7684\u5217\u4ec5\u5305\u542b\u975e NULL
\u503c\u3002
\u4e00\u4e2a\u8868\u53ef\u4ee5\u6ca1\u6709\u4e3b\u952e\uff0c\u4e3b\u952e\u4e5f\u53ef\u4ee5\u662f\u975e\u6574\u6570\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_7","title":"\u6dfb\u52a0\u5217\u7ea6\u675f","text":"\u9664\u4e3b\u952e\u7ea6\u675f\u5916\uff0cMatrixOne \u8fd8\u652f\u6301\u5176\u4ed6\u7684\u5217\u7ea6\u675f\uff0c\u5982\uff1a\u975e\u7a7a\u7ea6\u675f NOT NULL\u3001\u9ed8\u8ba4\u503c DEFAULT \u7b49\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_8","title":"\u586b\u5145\u9ed8\u8ba4\u503c","text":"\u5982\u9700\u5728\u5217\u4e0a\u8bbe\u7f6e\u9ed8\u8ba4\u503c\uff0c\u8bf7\u4f7f\u7528 DEFAULT
\u7ea6\u675f\u3002\u9ed8\u8ba4\u503c\u5c06\u53ef\u4ee5\u4f7f\u4f60\u65e0\u9700\u6307\u5b9a\u6bcf\u4e00\u5217\u7684\u503c\uff0c\u5c31\u53ef\u4ee5\u63d2\u5165\u6570\u636e\u3002
\u4f60\u53ef\u4ee5\u5c06 DEFAULT
\u4e0e\u652f\u6301\u7684 SQL \u51fd\u6570\u7ed3\u5408\u4f7f\u7528\uff0c\u5c06\u9ed8\u8ba4\u503c\u7684\u8ba1\u7b97\u79fb\u51fa\u5e94\u7528\u5c42\uff0c\u4ece\u800c\u8282\u7701\u5e94\u7528\u5c42\u7684\u8d44\u6e90\uff08\u5f53\u7136\uff0c\u8ba1\u7b97\u6240\u6d88\u8017\u7684\u8d44\u6e90\u5e76\u4e0d\u4f1a\u51ed\u7a7a\u6d88\u5931\uff0c\u53ea\u662f\u88ab\u8f6c\u79fb\u5230\u4e86 MatrixOne \u96c6\u7fa4\u4e2d\uff09\u3002\u8fd9\u91cc\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u4f8b\u5b50\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a
create table t1(a int default (1), b int);\ninsert into t1(b) values(1), (1);\n> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n| 1 | 1 |\n+------+------+\n2 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0ca \u7684\u503c\u9ed8\u8ba4\u662f 1\u3002
\u4f60\u4e5f\u53ef\u4ee5\u5c06\u9ed8\u8ba4\u503c\u8bbe\u7f6e\u4e3a\u63d2\u5165\u503c\u65f6\u7684\u65f6\u95f4\uff0c\u53c2\u8003\u4e0b\u9762\u7684\u7b80\u5355\u7684\u793a\u4f8b\uff1a
-- \u521b\u5efa\u8868\u5e76\u8bbe\u7f6e\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u65f6\u95f4\nCREATE TABLE t2 (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ncreated_at DATETIME DEFAULT NOW()\n);\n\nINSERT INTO t2 (id, name) VALUES\n(1, 'John'),\n(2, 'Jane'),\n(3, 'Mike');\n\n> SELECT * FROM t2;\n+------+------+---------------------+\n| id | name | created_at |\n+------+------+---------------------+\n| 1 | John | 2023-07-10 11:57:27 |\n| 2 | Jane | 2023-07-10 11:57:27 |\n| 3 | Mike | 2023-07-10 11:57:27 |\n+------+------+---------------------+\n3 rows in set (0.00 sec)\n
\u6267\u884c\u4e0a\u8ff0\u63d2\u5165\u8bed\u53e5\u540e\uff0c\u6bcf\u884c\u7684 created_at
\u5217\u90fd\u4f1a\u88ab\u81ea\u52a8\u8bbe\u7f6e\u4e3a\u5f53\u524d\u65f6\u95f4\u3002
\u5982\u679c\u4f60\u9700\u8981\u9632\u6b62\u5217\u4e2d\u51fa\u73b0\u91cd\u590d\u503c\uff0c\u90a3\u4f60\u53ef\u4ee5\u4f7f\u7528 UNIQUE
\u7ea6\u675f\u3002
\u4f8b\u5982\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u6c11\u65cf\u6807\u8bb0\u7684\u503c\u552f\u4e00\uff0c\u53ef\u4ee5\u8fd9\u6837\u6539\u5199 NATION \u8868\u7684\u521b\u5efa SQL\uff1a
CREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nUNIQUE KEY (N_NATIONKEY)\n);\n
\u5982\u679c\u4f60\u5728 NATION \u8868\u4e2d\u5c1d\u8bd5\u63d2\u5165\u76f8\u540c\u7684 N_NATIONKEY\uff0c\u5c06\u8fd4\u56de\u9519\u8bef\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_10","title":"\u9632\u6b62\u7a7a\u503c","text":"\u5982\u679c\u4f60\u9700\u8981\u9632\u6b62\u5217\u4e2d\u51fa\u73b0\u7a7a\u503c\uff0c\u90a3\u5c31\u53ef\u4ee5\u4f7f\u7528 NOT NULL
\u7ea6\u675f\u3002
\u8fd8\u662f\u4f7f\u7528\u6c11\u65cf\u540d\u79f0\u6765\u4e3e\u4f8b\u5b50\uff0c\u9664\u4e86\u6c11\u65cf\u6807\u8bb0\u7684\u503c\u552f\u4e00\uff0c\u8fd8\u5e0c\u671b\u6c11\u65cf\u540d\u79f0\u4e0d\u53ef\u4e3a\u7a7a\uff0c\u4e8e\u662f\u6b64\u5904\u53ef\u4ee5\u8fd9\u6837\u5199 NATION \u8868\u7684\u521b\u5efa SQL\uff1a
CREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n
"},{"location":"MatrixOne/Develop/schema-design/create-table/#show-tables","title":"\u6267\u884c SHOW TABLES
\u8bed\u53e5","text":"\u9700\u67e5\u770b modatabase \u6570\u636e\u5e93\u4e0b\u7684\u6240\u6709\u8868\uff0c\u53ef\u4f7f\u7528 SHOW TABLES
\u8bed\u53e5\uff1a
SHOW TABLES IN `modatabase`;\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+----------------------+\n| tables_in_modatabase |\n+----------------------+\n| nation |\n| orders |\n+----------------------+\n
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_11","title":"\u521b\u5efa\u8868\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219","text":""},{"location":"MatrixOne/Develop/schema-design/create-table/#_12","title":"\u547d\u540d\u8868\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219","text":"\u4f7f\u7528\u5b8c\u5168\u9650\u5b9a\u7684\u8868\u540d\u79f0\uff08\u4f8b\u5982\uff1aCREATE TABLE {database_name}.{table_name}
\uff09\u3002\u8fd9\u662f\u56e0\u4e3a\u4f60\u5728\u4e0d\u6307\u5b9a\u6570\u636e\u5e93\u540d\u79f0\u65f6\uff0cMatrixOne \u5c06\u4f7f\u7528\u4f60 SQL \u4f1a\u8bdd\u4e2d\u7684\u5f53\u524d\u6570\u636e\u5e93\u3002\u82e5\u4f60\u672a\u5728 SQL \u4f1a\u8bdd\u4e2d\u4f7f\u7528 USE {databasename};
\u6765\u6307\u5b9a\u6570\u636e\u5e93\uff0cMatrixOne \u5c06\u4f1a\u8fd4\u56de\u9519\u8bef\u3002
\u8bf7\u4f7f\u7528\u6709\u610f\u4e49\u7684\u8868\u540d\uff0c\u4f8b\u5982\uff0c\u82e5\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u8868\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u540d\u79f0\uff1auser\uff0ct_user\uff0cusers \u7b49\uff0c\u6216\u9075\u5faa\u4f60\u516c\u53f8\u6216\u7ec4\u7ec7\u7684\u547d\u540d\u89c4\u8303\u3002\u5982\u679c\u4f60\u7684\u516c\u53f8\u6216\u7ec4\u7ec7\u6ca1\u6709\u76f8\u5e94\u7684\u547d\u540d\u89c4\u8303\uff0c\u53ef\u53c2\u8003\u8868\u547d\u540d\u89c4\u8303\u3002
\u591a\u4e2a\u5355\u8bcd\u4ee5\u4e0b\u5212\u7ebf\u5206\u9694\uff0c\u4e0d\u63a8\u8350\u8d85\u8fc7 32 \u4e2a\u5b57\u7b26\u3002
\u4e0d\u540c\u4e1a\u52a1\u6a21\u5757\u7684\u8868\u5355\u72ec\u5efa\u7acb DATABASE\uff0c\u5e76\u589e\u52a0\u76f8\u5e94\u6ce8\u91ca\u3002
JOIN
\u7684\u5b57\u6bb5\uff0c\u6570\u636e\u7c7b\u578b\u4fdd\u969c\u7edd\u5bf9\u4e00\u81f4\uff0c\u907f\u514d\u9690\u5f0f\u8f6c\u6362\u3002\u4e34\u65f6\u8868\uff08temporary table\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u8868\uff0c\u5b83\u5728\u521b\u5efa\u540e\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u53ef\u89c1\u3002\u5728\u5f53\u524d\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u6570\u636e\u5e93\u81ea\u52a8\u5220\u9664\u4e34\u65f6\u8868\u5e76\u91ca\u653e\u6240\u6709\u7a7a\u95f4\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 DROP TABLE
\u5220\u9664\u4e34\u65f6\u8868\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e34\u65f6\u8868\u5728\u4e00\u6b21\u4f1a\u8bdd\u4e2d\u4fdd\u5b58\u4e00\u4e9b\u4e2d\u95f4\u7ed3\u679c\uff0c\u4f8b\u5982\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u591a\u6b21\u67e5\u8be2\u8fd9\u4e9b\u7ed3\u679c\uff0c\u6216\u8005\u8fd9\u4e9b\u7ed3\u679c\u662f\u5176\u4ed6\u67e5\u8be2\u7684\u5b50\u96c6\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#_3","title":"\u4e34\u65f6\u8868\u7684\u4f18\u70b9","text":"\u4e34\u65f6\u8868\u5728\u6570\u636e\u5e93\u8bbe\u8ba1\u4e2d\u5177\u6709\u591a\u79cd\u7528\u9014\u548c\u4f18\u70b9\uff1a
\u6570\u636e\u9694\u79bb\uff1a\u4e34\u65f6\u8868\u5728\u6bcf\u4e2a\u4f1a\u8bdd\u6216\u4e8b\u52a1\u4e2d\u662f\u72ec\u7acb\u7684\u3002\u8fd9\u610f\u5473\u7740\uff0c\u4e24\u4e2a\u76f8\u540c\u540d\u79f0\u7684\u4e34\u65f6\u8868\u53ef\u4ee5\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u4f1a\u8bdd\u4e2d\u5b58\u5728\uff0c\u5e76\u4e14\u4e0d\u4f1a\u4e92\u76f8\u5f71\u54cd\u3002
\u7b80\u5316\u590d\u6742\u67e5\u8be2\uff1a\u5982\u679c\u4e00\u4e2a\u67e5\u8be2\u975e\u5e38\u590d\u6742\uff0c\u6d89\u53ca\u5230\u591a\u4e2a\u8054\u63a5\u548c\u5b50\u67e5\u8be2\uff0c\u90a3\u4e48\u53ef\u4ee5\u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5230\u4e34\u65f6\u8868\u4e2d\uff0c\u7136\u540e\u5728\u8fd9\u4e2a\u4e34\u65f6\u8868\u4e0a\u8fdb\u884c\u64cd\u4f5c\uff0c\u4ece\u800c\u7b80\u5316\u67e5\u8be2\u548c\u63d0\u9ad8\u6027\u80fd\u3002
\u63d0\u9ad8\u6027\u80fd\uff1a\u5bf9\u4e8e\u5927\u6570\u636e\u96c6\u7684\u590d\u6742\u67e5\u8be2\uff0c\u5c06\u6570\u636e\u4fdd\u5b58\u5728\u4e34\u65f6\u8868\u4e2d\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002\u56e0\u4e3a\u4e34\u65f6\u8868\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u6240\u4ee5\u8bbf\u95ee\u901f\u5ea6\u5feb\u3002
\u4fdd\u62a4\u6570\u636e\uff1a\u4f7f\u7528\u4e34\u65f6\u8868\u53ef\u4ee5\u907f\u514d\u5bf9\u539f\u59cb\u6570\u636e\u8fdb\u884c\u4fee\u6539\u3002\u5f53\u4f60\u9700\u8981\u6267\u884c\u53ef\u80fd\u4f1a\u6539\u53d8\u539f\u59cb\u6570\u636e\u7684\u64cd\u4f5c\u65f6\uff0c\u53ef\u4ee5\u5148\u5c06\u6570\u636e\u5b58\u5165\u4e34\u65f6\u8868\uff0c\u7136\u540e\u5728\u4e34\u65f6\u8868\u4e0a\u8fdb\u884c\u64cd\u4f5c\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u8bef\u6539\u539f\u59cb\u6570\u636e\u3002
\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\uff1a\u4e34\u65f6\u8868\u5728\u4e0d\u518d\u9700\u8981\u65f6\u4f1a\u81ea\u52a8\u5220\u9664\uff0c\u8fd9\u6837\u53ef\u4ee5\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\u3002
\u6709\u52a9\u4e8e\u8c03\u8bd5\uff1a\u5728\u590d\u6742\u7684\u5d4c\u5957\u67e5\u8be2\u4e2d\uff0c\u4e34\u65f6\u8868\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u4e2d\u95f4\u7ed3\u679c\uff0c\u4ee5\u5e2e\u52a9\u8c03\u8bd5\u548c\u9a8c\u8bc1\u6bcf\u4e00\u6b65\u7684\u8f93\u51fa\u7ed3\u679c\u3002
\u8bf7\u6ce8\u610f\uff0c\u4e34\u65f6\u8868\u5e76\u975e\u4e07\u80fd\u7684\uff0c\u5b83\u4eec\u4e5f\u6709\u4e00\u4e9b\u9650\u5236\uff0c\u6bd4\u5982\u53ea\u80fd\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u8bbf\u95ee\uff0c\u800c\u4e14\u4e00\u65e6\u4f1a\u8bdd\u7ed3\u675f\uff0c\u4e34\u65f6\u8868\u5c31\u4f1a\u6d88\u5931\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#_4","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u4f7f\u7528\u4e34\u65f6\u8868\u7684\u8bed\u6cd5\u4e0e\u5e38\u89c4\u8868\u76f8\u540c\uff0c\u53ea\u662f\u5728\u521b\u5efa\u8868\u7684\u8bed\u53e5\u524d\u9762\u6dfb\u52a0\u4e86 TEMPORARY \u5173\u952e\u5b57\uff1a
CREATE TEMPORARY TABLE temp_table_name (column_list);\n
\u4f60\u53ef\u4ee5\u5728\u4e34\u65f6\u8868\u548c\u5e38\u89c4\u8868\u4e2d\u4f7f\u7528\u76f8\u540c\u7684\u8868\u540d\uff0c\u800c\u4e0d\u4f1a\u4ea7\u751f\u51b2\u7a81\uff0c\u56e0\u4e3a\u5b83\u4eec\u5b9e\u9645\u4e0a\u662f\u5728\u4e0d\u540c\u7684\u547d\u540d\u7a7a\u95f4\u4e2d\u3002\u4f46\u662f\uff0c\u5728\u540c\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\uff0c\u4e24\u4e2a\u4e34\u65f6\u8868\u4e0d\u80fd\u5171\u4eab\u76f8\u540c\u7684\u540d\u79f0\u3002
Note
DROP TABLE
\u8bed\u53e5\uff0c\u8fd9\u4e2a\u65f6\u5019\u5220\u9664\u7684\u53ef\u80fd\u662f\u6c38\u4e45\u8868\u800c\u4e0d\u662f\u4e34\u65f6\u8868\uff0c\u8fd9\u79cd\u7ed3\u679c\u662f\u4e0d\u53ef\u9884\u6599\u7684\u3002SHOW TABLES
\u547d\u4ee4\u663e\u793a\u6570\u636e\u8868\u5217\u8868\u65f6\uff0c\u4f60\u4e5f\u65e0\u6cd5\u770b\u5230\u4e34\u65f6\u8868\u5217\u8868\u3002-- \u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u8868 'temp_employees'\nCREATE TEMPORARY TABLE temp_employees (\nemployee_id INT AUTO_INCREMENT, -- \u81ea\u589e\u7684\u5458\u5de5 ID\nfirst_name VARCHAR(50), -- \u5458\u5de5\u540d\nlast_name VARCHAR(50), -- \u5458\u5de5\u59d3\nemail VARCHAR(100), -- \u5458\u5de5\u7535\u5b50\u90ae\u4ef6\u5730\u5740\nPRIMARY KEY (employee_id) -- \u8bbe\u5b9a 'employee_id' \u4e3a\u4e3b\u952e\n);\n\n-- \u5411 'temp_employees' \u8868\u4e2d\u63d2\u5165\u4e00\u4e9b\u6570\u636e\nINSERT INTO temp_employees (first_name, last_name, email)\nVALUES ('John', 'Doe', 'john.doe@example.com'),\n('Jane', 'Doe', 'jane.doe@example.com'),\n('Jim', 'Smith', 'jim.smith@example.com'),\n('Jack', 'Johnson', 'jack.johnson@example.com'),\n('Jill', 'Jackson', 'jill.jackson@example.com');\n\n-- \u67e5\u8be2\u4e34\u65f6\u8868\uff0c\u67e5\u770b\u6240\u6709\u5458\u5de5\u4fe1\u606f\nSELECT * FROM temp_employees;\n+-------------+------------+-----------+--------------------------+\n| employee_id | first_name | last_name | email |\n+-------------+------------+-----------+--------------------------+\n| 1 | John | Doe | john.doe@example.com |\n| 2 | Jane | Doe | jane.doe@example.com |\n| 3 | Jim | Smith | jim.smith@example.com |\n| 4 | Jack | Johnson | jack.johnson@example.com |\n| 5 | Jill | Jackson | jill.jackson@example.com |\n+-------------+------------+-----------+--------------------------+\n5 rows in set (0.01 sec)\n\n-- \u6ce8\u610f\uff1a\u5728\u8fd9\u4e2a\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u4e34\u65f6\u8868 'temp_employees' \u5c06\u88ab\u81ea\u52a8\u5220\u9664\n
"},{"location":"MatrixOne/Develop/schema-design/create-view/","title":"\u521b\u5efa\u89c6\u56fe","text":""},{"location":"MatrixOne/Develop/schema-design/create-view/#_2","title":"\u4ec0\u4e48\u662f\u89c6\u56fe","text":"\u89c6\u56fe\uff08View\uff09\u662f\u4e00\u4e2a\u57fa\u4e8e SQL \u8bed\u53e5\u7684\u7ed3\u679c\u96c6\u7684\u53ef\u89c6\u5316\u3001\u53ea\u8bfb\u7684\u865a\u62df\u8868\uff0c\u5176\u5185\u5bb9\u7531\u67e5\u8be2\u5b9a\u4e49\u3002\u4e0e\u666e\u901a\u8868\uff08\u5b58\u50a8\u6570\u636e\u7684\u8868\uff09\u4e0d\u540c\uff0c\u89c6\u56fe\u4e0d\u5305\u542b\u6570\u636e\uff0c\u4ec5\u4ec5\u662f\u57fa\u4e8e\u57fa\u8868\uff08\u88ab\u67e5\u8be2\u7684\u8868\uff09\u7684\u67e5\u8be2\u7ed3\u679c\u7684\u683c\u5f0f\u5316\u663e\u793a\u3002\u4f60\u53ef\u4ee5\u628a\u89c6\u56fe\u770b\u4f5c\u662f\u4e00\u5f20\u8868\u7684\u7a97\u53e3\uff0c\u8fd9\u4e2a\u7a97\u53e3\u4e2d\u7684\u6570\u636e\u53cd\u6620\u5728\u5176\u4ed6\u8868\u4e0a\u3002\u5f53\u67e5\u8be2\u89c6\u56fe\u65f6\uff0c\u6570\u636e\u5e93\u4f1a\u5c06\u8be5\u89c6\u56fe\u7684 SQL \u67e5\u8be2\u5e94\u7528\u5230\u5176\u57fa\u7840\u8868\u4e0a\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-view/#_3","title":"\u89c6\u56fe\u7684\u4f18\u70b9","text":"\u7b80\u5316\u67e5\u8be2\uff1a\u5bf9\u4e8e\u590d\u6742\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u521b\u5efa\u89c6\u56fe\u6765\u9690\u85cf\u67e5\u8be2\u7684\u590d\u6742\u6027\uff0c\u53ea\u9700\u8981\u4ece\u89c6\u56fe\u4e2d\u9009\u62e9\u6570\u636e\uff0c\u800c\u4e0d\u9700\u8981\u8bb0\u4f4f\u590d\u6742\u7684\u67e5\u8be2\u8bed\u53e5\u3002
\u589e\u52a0\u989d\u5916\u7684\u5b89\u5168\u5c42\uff1a\u89c6\u56fe\u53ef\u4ee5\u9650\u5236\u7528\u6237\u8bbf\u95ee\u67d0\u4e9b\u6570\u636e\u5e93\u5b57\u6bb5\uff0c\u53ea\u5c55\u793a\u4ed6\u4eec\u9700\u8981\u770b\u5230\u7684\u5b57\u6bb5\uff0c\u8fd9\u6837\u53ef\u4ee5\u4fdd\u62a4\u6570\u636e\u7684\u5b89\u5168\u3002
\u4fdd\u6301\u6570\u636e\u4e00\u81f4\u6027\uff1a\u5982\u679c\u591a\u4e2a\u67e5\u8be2\u9700\u8981\u7528\u5230\u76f8\u540c\u7684\u67e5\u8be2\u5b50\u53e5\uff0c\u90a3\u4e48\u521b\u5efa\u89c6\u56fe\u53ef\u4ee5\u4fdd\u6301\u6570\u636e\u4e00\u81f4\u6027\u3002
\u903b\u8f91\u62bd\u8c61\uff1a\u89c6\u56fe\u53ef\u4ee5\u8868\u793a\u57fa\u8868\u6570\u636e\u7684\u6709\u7528\u90e8\u5206\uff0c\u6216\u8005\u6c47\u603b\uff0c\u4ee5\u53ca\u4ece\u51e0\u4e2a\u8868\u7ec4\u5408\u800c\u6765\u7684\u4fe1\u606f\u3002
\u4f46\u662f\u89c6\u56fe\u4e5f\u6709\u7f3a\u70b9\uff1a
\u6027\u80fd\uff1a\u4ece\u6570\u636e\u5e93\u89c6\u56fe\u67e5\u8be2\u6570\u636e\u53ef\u80fd\u4f1a\u5f88\u6162\uff0c\u7279\u522b\u662f\u5982\u679c\u89c6\u56fe\u662f\u57fa\u4e8e\u5176\u4ed6\u89c6\u56fe\u521b\u5efa\u7684\u3002
\u4f9d\u8d56\u5176\u4ed6\u8868\uff1a\u5c06\u6839\u636e\u6570\u636e\u5e93\u7684\u57fa\u7840\u8868\u521b\u5efa\u4e00\u4e2a\u89c6\u56fe\u3002\u5e76\u4e0d\u662f\u6240\u6709\u7684\u89c6\u56fe\u90fd\u652f\u6301\u5bf9\u6570\u636e\u8fdb\u884c\u66f4\u65b0\uff0c\u8fd9\u4e3b\u8981\u53d6\u51b3\u4e8e\u89c6\u56fe\u7684\u5b9a\u4e49\u4ee5\u53ca\u5b83\u7684\u57fa\u7840\u8868\u3002
\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u521b\u5efa\u89c6\u56fe\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a
CREATE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;\n
\u521b\u5efa\u89c6\u56fe\u540e\uff0c\u4f60\u53ef\u4ee5\u50cf\u67e5\u8be2\u5176\u4ed6\u8868\u4e00\u6837\u67e5\u8be2\u89c6\u56fe\uff1a
SELECT column1, column2, ...\nFROM view_name;\n
"},{"location":"MatrixOne/Develop/schema-design/create-view/#_6","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 'orders' \u7684\u8868\nCREATE TABLE orders (\norder_id INT AUTO_INCREMENT,\ncustomer_id INT,\norder_date DATE,\norder_amount DOUBLE,\nPRIMARY KEY (order_id)\n);\n\n-- \u5411 'orders' \u8868\u4e2d\u63d2\u5165\u4e00\u4e9b\u6570\u636e\nINSERT INTO orders (customer_id, order_date, order_amount)\nVALUES (1, '2023-01-01', 99.99),\n(1, '2023-01-03', 29.99),\n(2, '2023-01-03', 49.99),\n(3, '2023-01-05', 89.99),\n(1, '2023-01-07', 59.99),\n(2, '2023-01-07', 19.99);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 'order_summary' \u7684\u89c6\u56fe\uff0c\u5b83\u5c55\u793a\u6bcf\u4e2a\u5ba2\u6237\u7684\u603b\u8ba2\u5355\u6570\u91cf\u548c\u603b\u8ba2\u5355\u91d1\u989d\nCREATE VIEW order_summary AS\nSELECT customer_id, COUNT(*) as order_count, SUM(order_amount) as total_amount\nFROM orders\nGROUP BY customer_id;\n\n-- \u67e5\u8be2\u89c6\u56fe\nmysql> SELECT *\nFROM order_summary;\n+-------------+-------------+--------------+\n| customer_id | order_count | total_amount |\n+-------------+-------------+--------------+\n| 1 | 3 | 189.97 |\n| 2 | 2 | 69.98 |\n| 3 | 1 | 89.99 |\n+-------------+-------------+--------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/schema-design/overview/","title":"\u6570\u636e\u5e93\u6a21\u5f0f\u8bbe\u8ba1\u6982\u8ff0","text":"\u672c\u7bc7\u6587\u7ae0\u7b80\u8981\u6982\u8ff0\u4e86 MatrixOne \u7684\u6570\u636e\u5e93\u6a21\u5f0f\u3002\u672c\u7bc7\u6982\u8ff0\u4e3b\u8981\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u76f8\u5173\u672f\u8bed\u548c\u540e\u7eed\u7684\u6570\u636e\u8bfb\u5199\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/schema-design/overview/#-","title":"\u5173\u952e\u672f\u8bed - \u6570\u636e\u5e93\u6a21\u5f0f","text":"\u6570\u636e\u5e93\u6a21\u5f0f (Schema)\uff1a\u672c\u7bc7\u6587\u7ae0\u6240\u63d0\u5230\u7684\u6570\u636e\u5e93\u6a21\u5f0f\u7b49\u540c\u4e8e\u903b\u8f91\u5bf9\u8c61\u6570\u636e\u5e93\uff0c\u4e0e MySQL \u4e00\u6837\uff0c\u4e0d\u505a\u533a\u5206\u3002
"},{"location":"MatrixOne/Develop/schema-design/overview/#database","title":"\u6570\u636e\u5e93 Database","text":"MatrixOne \u6570\u636e\u5e93\u6216 MatrixOne Database\uff0c\u4e3a\u8868\u7684\u96c6\u5408\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 SHOW DATABASES;
\u67e5\u770b MatrixOne \u6240\u5305\u542b\u7684\u9ed8\u8ba4\u6570\u636e\u5e93\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 CREATE DATABASE database_name;
\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u3002
MatrixOne \u6240\u6307\u7684\u8868\u6216 Table\uff0c\u4ece\u5c5e\u4e8e MatrixOne \u7684\u67d0\u4e2a\u6570\u636e\u5e93\u3002
\u8868\u5305\u542b\u6570\u636e\u884c\u3002\u6bcf\u884c\u6570\u636e\u4e2d\u7684\u6bcf\u4e2a\u503c\u90fd\u5c5e\u4e8e\u4e00\u4e2a\u7279\u5b9a\u7684\u5217\u3002\u6bcf\u5217\u90fd\u53ea\u5141\u8bb8\u5355\u4e00\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/overview/#index","title":"\u7d22\u5f15 Index","text":"\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u6570\u636e\u5e93\u8868\u683c\u4e2d\u7684\u6570\u636e\u3002\u5b83\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u672c\u76ee\u5f55\uff0c\u5305\u542b\u6709\u5173\u8868\u683c\u4e2d\u5404\u884c\u6570\u636e\u7684\u6307\u9488\uff0c\u4f7f\u5f97\u67e5\u8be2\u53ef\u4ee5\u66f4\u5feb\u901f\u5730\u5b9a\u4f4d\u5230\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u6570\u636e\u3002
\u6570\u636e\u5e93\u4e2d\u5e38\u7528\u7684\u7d22\u5f15\u7c7b\u578b\u5305\u62ec\u4e3b\u952e\u7d22\u5f15\u3001\u6b21\u7ea7\u7d22\u5f15\u7b49\u3002\u5176\u4e2d\uff0c\u552f\u4e00\u7d22\u5f15\u7528\u4e8e\u4fdd\u8bc1\u7279\u5b9a\u5217\u6216\u5217\u7ec4\u5408\u7684\u552f\u4e00\u6027\uff0c\u666e\u901a\u7d22\u5f15\u7528\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\uff0c\u5168\u6587\u7d22\u5f15\u5219\u7528\u4e8e\u5728\u6587\u672c\u6570\u636e\u4e2d\u8fdb\u884c\u5168\u6587\u68c0\u7d22\u3002
\u7d22\u5f15\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u7c7b\u578b\uff0c\u5206\u522b\u4e3a\uff1a
MatrixOne \u652f\u6301\u4e00\u4e9b\u548c\u8868\u540c\u7ea7\u7684\u5bf9\u8c61\uff1a
MatrixOne \u73b0\u5728\u652f\u6301\u5b58\u50a8\u548c\u67e5\u8be2\u5411\u91cf\u3002\u5411\u91cf\u662f\u901a\u5e38\u7531 AI \u6a21\u578b\uff08\u5982\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff09\u751f\u6210\u7684\u6570\u5b57\u5217\u8868\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u5411\u91cf
"},{"location":"MatrixOne/Develop/schema-design/overview/#_4","title":"\u8bbf\u95ee\u63a7\u5236","text":"MatrixOne \u652f\u6301\u57fa\u4e8e\u7528\u6237\u6216\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u89d2\u8272\u6216\u76f4\u63a5\u6307\u5411\u7528\u6237\uff0c\u4ece\u800c\u6388\u4e88\u7528\u6237\u67e5\u770b\u3001\u4fee\u6539\u6216\u5220\u9664\u6570\u636e\u5bf9\u8c61\u548c\u6570\u636e\u6a21\u5f0f\u7684\u6743\u9650\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 MatrixOne \u4e2d\u7684\u6743\u9650\u63a7\u5236\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/","title":"AUTO INCREMENT \u81ea\u589e\u7ea6\u675f","text":"\u81ea\u589e\u7ea6\u675f\uff08Auto-Increment Constraint\uff09\u662f MatrixOne \u4e00\u79cd\u7528\u4e8e\u81ea\u52a8\u4e3a\u8868\u4e2d\u7684\u5217\u751f\u6210\u552f\u4e00\u6807\u8bc6\u503c\u7684\u7279\u6027\u3002\u5b83\u5141\u8bb8\u4f60\u5728\u63d2\u5165\u65b0\u884c\u65f6\uff0c\u81ea\u52a8\u4e3a\u6307\u5b9a\u7684\u81ea\u589e\u5217\u751f\u6210\u4e00\u4e2a\u9012\u589e\u7684\u552f\u4e00\u503c\u3002\u8fd9\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\u975e\u5e38\u6709\u7528\uff0c\u4f8b\u5982\u7528\u4f5c\u4e3b\u952e\u6216\u6807\u8bc6\u7b26\u3002
\u81ea\u589e\u7ea6\u675f\u7279\u6027
\u81ea\u589e\u7ea6\u675f\u53ef\u4ee5\u7b80\u5316\u6807\u8bc6\u7b26\u7684\u751f\u6210\u548c\u7ba1\u7406\u3002\u5728\u4f7f\u7528\u81ea\u589e\u5217\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a
\u8bf7\u6839\u636e\u5177\u4f53\u7684\u8868\u7ed3\u6784\u548c\u9700\u6c42\uff0c\u4f7f\u7528\u81ea\u589e\u7ea6\u675f\u6765\u7b80\u5316\u6807\u8bc6\u7b26\u7684\u751f\u6210\u548c\u7ba1\u7406\uff0c\u5e76\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u552f\u4e00\u6027\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u521b\u5efa\u8868\u65f6\uff0c\u53ef\u4ee5\u4e3a\u4e00\u4e2a\u5217\u5b9a\u4e49\u81ea\u589e\u7ea6\u675f\u3002\u901a\u5e38\uff0c\u81ea\u589e\u5217\u7684\u6570\u636e\u7c7b\u578b\u4e3a\u6574\u6570\u7c7b\u578b\uff08\u5982 INT
\u6216 BIGINT
\uff09\u3002\u5728\u521b\u5efa\u8868\u65f6\uff0c\u4f7f\u7528 AUTO_INCREMENT
\u5173\u952e\u5b57\u4e3a\u5217\u6dfb\u52a0\u81ea\u589e\u7ea6\u675f\u3002
CREATE TABLE table_name (\ncolumn_name data_type AUTO_INCREMENT,\n...\nPRIMARY KEY (primary_key_column)\n);\n
table_name
\uff1a\u8868\u7684\u540d\u79f0\u3002column_name
\uff1a\u8981\u5b9a\u4e49\u4e3a\u81ea\u589e\u7684\u5217\u7684\u540d\u79f0\u3002data_type
\uff1a\u5217\u7684\u6570\u636e\u7c7b\u578b\uff0c\u901a\u5e38\u4e3a\u6574\u6570\u7c7b\u578b\uff08\u5982 INT
\u6216 BIGINT
\uff09\u3002primary_key_column
\uff1a\u8868\u7684\u4e3b\u952e\u5217\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u521b\u5efa\u5e26\u6709\u81ea\u589e\u5217\u7684\u8868\u7684\u793a\u4f8b\uff1a
-- \u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a `employees` \u7684\u8868\uff0c\u5176\u4e2d `id` \u5217\u88ab\u5b9a\u4e49\u4e3a\u81ea\u589e\u5217\u3002`id` \u5217\u7684\u6570\u636e\u7c7b\u578b\u4e3a `INT`\uff0c\u5e76\u901a\u8fc7 `AUTO_INCREMENT` \u5173\u952e\u5b57\u6307\u5b9a\u4e86\u81ea\u589e\u7ea6\u675f\u3002\u8868\u7684\u4e3b\u952e\u8bbe\u7f6e\u4e3a `id` \u5217\nCREATE TABLE employees (\nid INT AUTO_INCREMENT,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nPRIMARY KEY (id)\n);\n\n-- \u63d2\u5165\u6570\u636e\uff0c\u5e76\u8ba9\u81ea\u589e\u5217\u81ea\u52a8\u751f\u6210\u552f\u4e00\u7684\u6807\u8bc6\u503c\uff0c\u6ca1\u6709\u4e3a `id` \u5217\u6307\u5b9a\u503c\uff0c\u800c\u662f\u901a\u8fc7\u63d2\u5165\u6570\u636e\u65f6\u81ea\u52a8\u4e3a `id` \u5217\u751f\u6210\u9012\u589e\u7684\u552f\u4e00\u503c\u3002\u6bcf\u6b21\u63d2\u5165\u65b0\u884c\u65f6\uff0c`id` \u5217\u7684\u503c\u5c06\u81ea\u52a8\u9012\u589e\u3002\n\nINSERT INTO employees (name, department)\nVALUES ('John Doe', 'HR'),\n('Jane Smith', 'Marketing'),\n('Mike Johnson', 'IT');\n\n-- `id` \u5217\u7684\u503c\u81ea\u52a8\u9012\u589e\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u65b0\u63d2\u5165\u7684\u884c\u751f\u6210\u552f\u4e00\u7684\u6807\u8bc6\u503c\u3002\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id | name | department |\n+------+--------------+------------+\n| 1 | John Doe | HR |\n| 2 | Jane Smith | Marketing |\n| 3 | Mike Johnson | IT |\n+------+--------------+------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#_3","title":"\u9650\u5236","text":"ALTER TABLE
\u4fee\u6539\u81ea\u589e\u503c\u7684\u8d77\u59cb\u503c\u548c\u9012\u589e\u6b65\u957f\u3002set @@auto_increment_increment=n
\u6765\u8bbe\u7f6e\u9012\u589e\u6b65\u957f\uff0c\u4e5f\u4ec5\u8bed\u6cd5\u652f\u6301\u4f7f\u7528 set @@auto_increment_offset=n
\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u81ea\u589e\u5217\u521d\u59cb\u503c\uff0c\u4f46\u5b9e\u9645\u4e0a\u5e76\u4e0d\u751f\u6548\uff1b\u5f53\u524d\u652f\u6301\u8bbe\u7f6e\u81ea\u589e\u5217\u7684\u521d\u59cb\u503c AUTO_INCREMENT=n
\uff0c\u4f46\u6b65\u957f\u4ecd\u7136\u9ed8\u8ba4\u4e3a 1\u3002FOREIGN KEY \u5916\u952e\u7ea6\u675f\u5141\u8bb8\u8868\u5185\u6216\u8de8\u8868\u4ea4\u53c9\u5f15\u7528\u76f8\u5173\u6570\u636e\uff0c\u6709\u52a9\u4e8e\u4fdd\u6301\u76f8\u5173\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
\u5f53\u5efa\u7acb\u5916\u952e\u65f6\uff0cMatrixone \u9ed8\u8ba4\u4f1a\u68c0\u67e5\u5916\u952e\u7ea6\u675f\u7684\u5b8c\u6574\u6027\u3002\u5982\u9700\u7981\u7528\u5916\u952e\u7ea6\u675f\u68c0\u67e5\uff0c\u8bf7\u53c2\u8003\u7ae0\u8282\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u3002
\u9075\u5faa\u89c4\u5219
\u5b9a\u4e49\u5916\u952e\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e0b\u5217\u89c4\u5219\uff1a
\u4e3b\u8868\u5fc5\u987b\u5df2\u7ecf\u5b58\u5728\u4e8e\u6570\u636e\u5e93\u4e2d\uff0c\u6216\u8005\u662f\u5f53\u524d\u6b63\u5728\u521b\u5efa\u7684\u8868\u3002\u5982\u679c\u662f\u540e\u4e00\u79cd\u60c5\u51b5\uff0c\u5219\u4e3b\u8868\u4e0e\u4ece\u8868\u662f\u540c\u4e00\u4e2a\u8868\uff0c\u8fd9\u6837\u7684\u8868\u79f0\u4e3a\u81ea\u53c2\u7167\u8868\uff0c\u8fd9\u79cd\u7ed3\u6784\u79f0\u4e3a\u81ea\u53c2\u7167\u5b8c\u6574\u6027\u3002
\u5fc5\u987b\u4e3a\u4e3b\u8868\u5b9a\u4e49\u4e3b\u952e\u3002
\u4e3b\u952e\u4e0d\u80fd\u5305\u542b\u7a7a\u503c\uff0c\u4f46\u5141\u8bb8\u5728\u5916\u952e\u4e2d\u51fa\u73b0\u7a7a\u503c\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ea\u8981\u5916\u952e\u7684\u6bcf\u4e2a\u975e\u7a7a\u503c\u51fa\u73b0\u5728\u6307\u5b9a\u7684\u4e3b\u952e\u4e2d\uff0c\u8fd9\u4e2a\u5916\u952e\u7684\u5185\u5bb9\u5c31\u662f\u6b63\u786e\u7684\u3002
\u5728\u4e3b\u8868\u7684\u8868\u540d\u540e\u9762\u6307\u5b9a\u5217\u540d\u6216\u5217\u540d\u7684\u7ec4\u5408\u3002\u8fd9\u4e2a\u5217\u6216\u5217\u7684\u7ec4\u5408\u5fc5\u987b\u662f\u4e3b\u8868\u7684\u4e3b\u952e\u6216\u5019\u9009\u952e\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u76ee\u5fc5\u987b\u548c\u4e3b\u8868\u7684\u4e3b\u952e\u4e2d\u5217\u7684\u6570\u76ee\u76f8\u540c\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u548c\u4e3b\u8868\u4e3b\u952e\u4e2d\u5bf9\u5e94\u5217\u7684\u6570\u636e\u7c7b\u578b\u76f8\u540c\u3002
\u5916\u952e\u7684\u503c\u5fc5\u987b\u8ddf\u4e3b\u8868\u4e3b\u952e\u7684\u503c\u4fdd\u6301\u4e00\u81f4\u3002
\u5916\u952e\u7279\u6027
\u5916\u952e\u81ea\u5f15\u7528\uff1a\u662f\u6307\u4e00\u4e2a\u8868\u4e2d\u7684\u5217\u5f15\u7528\u540c\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\u3002\u8fd9\u79cd\u8bbe\u8ba1\u901a\u5e38\u7528\u4e8e\u8868\u793a\u5c42\u7ea7\u5173\u7cfb\u6216\u7236\u5b50\u5173\u7cfb\uff0c\u6bd4\u5982\u7ec4\u7ec7\u7ed3\u6784\u3001\u5206\u7c7b\u76ee\u5f55\u7b49\u3002
\u591a\u5217\u5916\u952e\uff1a\u8fd9\u79cd\u5916\u952e\u662f\u5728\u4e00\u4e2a\u8868\u4e2d\u4e24\u4e2a\u6216\u66f4\u591a\u7684\u5217\u8054\u5408\u8d77\u6765\u5f15\u7528\u53e6\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fd9\u4e9b\u5217\u5171\u540c\u5b9a\u4e49\u4e86\u5bf9\u53e6\u4e00\u4e2a\u8868\u7684\u5f15\u7528\u3002\u5b83\u4eec\u5fc5\u987b\u4ee5\u7ec4\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u4e14\u9700\u8981\u540c\u65f6\u6ee1\u8db3\u5916\u952e\u7ea6\u675f\u3002
\u591a\u5c42\u5916\u952e\uff1a\u8fd9\u79cd\u60c5\u51b5\u901a\u5e38\u6d89\u53ca\u5230\u4e09\u4e2a\u6216\u66f4\u591a\u7684\u8868\uff0c\u5e76\u4e14\u5b83\u4eec\u4e4b\u95f4\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u3002\u4e00\u4e2a\u8868\u7684\u5916\u952e\u53ef\u4ee5\u662f\u53e6\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\uff0c\u800c\u8fd9\u4e2a\u8868\u7684\u5916\u952e\u53c8\u53ef\u4ee5\u662f\u7b2c\u4e09\u4e2a\u8868\u7684\u4e3b\u952e\uff0c\u5f62\u6210\u591a\u5c42\u5916\u952e\u7684\u60c5\u51b5\u3002
\u5916\u952e\u662f\u5728\u5b50\u8868\u4e2d\u5b9a\u4e49\u7684\uff0c\u57fa\u672c\u7684\u5916\u952e\u7ea6\u675f\u8bed\u6cd5\u5982\u4e0b\uff1a
> CREATE TABLE child_table (\n ...,\n foreign_key_column data_type,\n FOREIGN KEY (foreign_key_column) REFERENCES parent_table (parent_key_column)\n [ON DELETE reference_option]\n [ON UPDATE reference_option]\n);\n\nreference_option:\n RESTRICT | CASCADE | SET NULL | NO ACTION\n
\u53c2\u6570\u91ca\u4e49
\u5728\u4e0a\u8ff0\u5916\u952e\u7ea6\u675f\u7684\u8bed\u6cd5\u7ed3\u6784\u4e2d\uff0c\u4ee5\u4e0b\u662f\u5404\u4e2a\u53c2\u6570\u7684\u91ca\u4e49\uff1a
child_table
\uff1a\u5b50\u8868\u7684\u540d\u79f0\uff0c\u5373\u5305\u542b\u5916\u952e\u7684\u8868\u3002foreign_key_column
\uff1a\u5b50\u8868\u4e2d\u7528\u4e8e\u5f15\u7528\u7236\u8868\u7684\u5916\u952e\u5217\u7684\u540d\u79f0\u3002data_type
\uff1a\u5916\u952e\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002parent_table
\uff1a\u88ab\u5f15\u7528\u7684\u7236\u8868\u7684\u540d\u79f0\u3002parent_key_column
\uff1a\u7236\u8868\u4e2d\u7528\u4e8e\u5efa\u7acb\u5173\u7cfb\u7684\u4e3b\u952e\u5217\u7684\u540d\u79f0\u3002[ON DELETE reference_option]
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a\u5728\u5220\u9664\u7236\u8868\u4e2d\u7684\u8bb0\u5f55\u65f6\u6267\u884c\u7684\u64cd\u4f5c\u3002
RESTRICT
\uff1a\u5982\u679c\u5728\u5f15\u7528\u8868\u4e2d\u6709\u76f8\u5173\u7684\u5916\u952e\u6570\u636e\u5b58\u5728\uff0c\u4e0d\u5141\u8bb8\u5220\u9664\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u6765\u9632\u6b62\u8bef\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u7ef4\u62a4\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
CASCADE
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u540c\u65f6\u5220\u9664\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u7ea7\u8054\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002
SET NULL
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5c06\u5916\u952e\u5217\u7684\u503c\u8bbe\u7f6e\u4e3a NULL\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u5728\u5220\u9664\u5f15\u7528\u6570\u636e\u65f6\u4fdd\u7559\u5916\u952e\u6570\u636e\uff0c\u4f46\u65ad\u5f00\u4e0e\u5f15\u7528\u6570\u636e\u7684\u5173\u8054\u3002
NO ACTION
\uff1a\u8868\u793a\u4e0d\u91c7\u53d6\u4efb\u4f55\u64cd\u4f5c\uff0c\u53ea\u662f\u68c0\u67e5\u662f\u5426\u6709\u5173\u8054\u6570\u636e\u5b58\u5728\u3002\u8fd9\u7c7b\u4f3c\u4e8e RESTRICT
\uff0c\u4f46\u53ef\u80fd\u5728\u67d0\u4e9b\u6570\u636e\u5e93\u4e2d\u6709\u5fae\u5c0f\u7684\u5dee\u5f02\u3002
[ON UPDATE reference_option]
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a\u5728\u66f4\u65b0\u7236\u8868\u4e2d\u7684\u8bb0\u5f55\u65f6\u6267\u884c\u7684\u64cd\u4f5c\u3002\u53ef\u80fd\u7684\u503c\u4e0e [ON DELETE reference_option]
\u76f8\u540c\u3002
\u8fd9\u4e9b\u53c2\u6570\u4e00\u8d77\u5b9a\u4e49\u4e86\u5916\u952e\u7ea6\u675f\uff0c\u5b83\u4eec\u786e\u4fdd\u4e86\u5b50\u8868\u4e0e\u7236\u8868\u4e4b\u95f4\u7684\u6570\u636e\u5b8c\u6574\u6027\u5173\u7cfb\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#_2","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#1","title":"\u793a\u4f8b 1","text":"-- \u521b\u5efa\u540d\u4e3a t1 \u7684\u8868\uff0c\u5305\u542b\u4e24\u5217\uff1aa \u548c b\u3002a \u5217\u4e3a int \u7c7b\u578b\u5e76\u8bbe\u4e3a\u4e3b\u952e\uff0cb \u5217\u4e3a varchar \u7c7b\u578b\uff0c\u957f\u5ea6\u4e3a 5\ncreate table t1(a int primary key, b varchar(5));\n\n-- \u521b\u5efa\u540d\u4e3a t2 \u7684\u8868\uff0c\u5305\u542b\u4e09\u5217\uff1aa\u3001b \u548c c\u3002a \u5217\u4e3a int \u7c7b\u578b\uff0cb \u5217\u4e3a varchar \u7c7b\u578b\uff0c\u957f\u5ea6\u4e3a 5\u3002c \u5217\u4e3a int \u7c7b\u578b\uff0c\u5e76\u4e14\u88ab\u8bbe\u5b9a\u4e3a\u5916\u952e\uff0c\u4e0e t1 \u8868\u7684 a \u5217\u5efa\u7acb\u5173\u7cfb\ncreate table t2(a int ,b varchar(5), c int, foreign key(c) references t1(a));\n\n-- \u5728 t1 \u8868\u4e2d\u63d2\u5165\u4e24\u884c\u6570\u636e\uff1a(101, 'abc') \u548c (102, 'def')\nmysql> insert into t1 values(101,'abc'),(102,'def');\nQuery OK, 2 rows affected (0.01 sec)\n\n-- \u5728 t2 \u8868\u4e2d\u63d2\u5165\u4e24\u884c\u6570\u636e\uff1a(1, 'zs1', 101) \u548c (2, 'zs2', 102)\uff0c\u5176\u4e2d\u7684 101 \u548c 102 \u662f t1 \u8868\u7684\u4e3b\u952e\nmysql> insert into t2 values(1,'zs1',101),(2,'zs2',102);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- \u5728 t2 \u8868\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff1a(3, 'xyz', null)\uff0c\u5176\u4e2d\u7684 null \u8868\u793a\u8fd9\u884c\u6570\u636e\u5728 c \u5217\uff08\u5373\u5916\u952e\u5217\uff09\u6ca1\u6709\u5173\u8054\u7684\u4e3b\u952e\nmysql> insert into t2 values(3,'xyz',null);\nQuery OK, 1 row affected (0.01 sec)\n\n-- \u5c1d\u8bd5\u5728 t2 \u8868\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff1a(3, 'xxa', 103)\uff0c\u4f46\u662f 103 \u5728 t1 \u8868\u7684\u4e3b\u952e\u4e2d\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u63d2\u5165\u5931\u8d25\uff0c\u8fdd\u53cd\u4e86\u5916\u952e\u7ea6\u675f\nmysql> insert into t2 values(3,'xxa',103);\nERROR 20101 (HY000): internal error: Cannot add or update a child row: a foreign key constraint fails\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0ct2 \u7684 c \u5217\u53ea\u80fd\u5f15\u7528 t1 \u4e2d a \u5217\u7684\u503c\u6216\u7a7a\u503c\uff0c\u56e0\u6b64\u63d2\u5165 t2 \u7684\u524d 3 \u884c\u64cd\u4f5c\u90fd\u80fd\u591f\u6210\u529f\u63d2\u5165\uff0c\u4f46\u662f\u7b2c 4 \u884c\u4e2d\u7684 103 \u5e76\u4e0d\u662f t1 \u4e2d a \u5217\u7684\u67d0\u4e2a\u503c\uff0c\u8fdd\u53cd\u4e86\u5916\u952e\u7ea6\u675f\uff0c\u56e0\u6b64\u63d2\u5165\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#2-","title":"\u793a\u4f8b 2 - \u5916\u952e\u81ea\u5f15\u7528","text":"-- \u521b\u5efa\u540d\u4e3a categories \u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5546\u54c1\u5206\u7c7b\u4fe1\u606f\nCREATE TABLE categories (\nid INT AUTO_INCREMENT PRIMARY KEY,--id \u662f\u4e3b\u952e\uff0c\u7528\u4e8e\u552f\u4e00\u6807\u8bc6\u6bcf\u4e2a\u5206\u7c7b\nname VARCHAR(255) NOT NULL,--name \u662f\u5206\u7c7b\u7684\u540d\u79f0\nparent_id INT,\nFOREIGN KEY (parent_id) REFERENCES categories(id)--parent_id \u662f\u4e00\u4e2a\u5916\u952e\uff0c\u5b83\u5f15\u7528\u4e86 categories \u8868\u4e2d\u7684 id \u5217\n);\n\n--parent_id \u5217\u5141\u8bb8\u6211\u4eec\u6307\u5b9a\u4e00\u4e2a\u5206\u7c7b\u7684\u7236\u5206\u7c7b\u3002\u5982\u679c\u6ca1\u6709\u7236\u5206\u7c7b\uff08\u5373\u9876\u7ea7\u5206\u7c7b\uff09\uff0cparent_id \u53ef\u4ee5\u8bbe\u7f6e\u4e3a NULL\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u63d2\u5165\u4e00\u4e9b\u6570\u636e\u6765\u5c55\u793a\u8fd9\u79cd\u5c42\u7ea7\u5173\u7cfb\uff1a\n\n--\u63d2\u5165\u9876\u7ea7\u5206\u7c7b\nmysql> INSERT INTO categories (name) VALUES ('Electronics'),('Books');\nQuery OK, 2 rows affected (0.01 sec)\n\n--\u63d2\u5165\u5b50\u5206\u7c7b\nmysql> INSERT INTO categories (name, parent_id) VALUES ('Laptops', 1),('Smartphones', 1),('Science Fiction', 2),('Mystery', 2);\nQuery OK, 4 rows affected (0.01 sec)\n\nmysql> select * from categories;\n+------+-----------------+-----------+\n| id | name | parent_id |\n+------+-----------------+-----------+\n| 1 | Electronics | NULL |\n| 2 | Books | NULL |\n| 3 | Laptops | 1 |\n| 4 | Smartphones | 1 |\n| 5 | Science Fiction | 2 |\n| 6 | Mystery | 2 |\n+------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4e86\u521b\u5efa\u540d\u4e3a categories
\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5546\u54c1\u5206\u7c7b\u4fe1\u606f\uff0c\u9996\u5148\u63d2\u5165\u4e86\u4e24\u4e2a\u9876\u7ea7\u5206\u7c7b Electronics
\u548c Books
\u3002\u7136\u540e\uff0c\u6211\u4eec\u4e3a\u6bcf\u4e2a\u9876\u7ea7\u5206\u7c7b\u6dfb\u52a0\u4e86\u5b50\u5206\u7c7b\uff0c\u6bd4\u5982 Laptops
\u548c Smartphones
\u662f Electronics
\u7684\u5b50\u5206\u7c7b\uff0c\u800c Science Fiction
\u548c Mystery
\u662f Books
\u7684\u5b50\u5206\u7c7b\u3002
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"Student\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5b66\u751f\u4fe1\u606f\nCREATE TABLE Student (\nStudentID INT, -- \u5b66\u751f ID \u5b57\u6bb5\uff0c\u6574\u578b\nName VARCHAR(100), -- \u5b66\u751f\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nPRIMARY KEY (StudentID) -- \u5c06 StudentID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"Course\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u8bfe\u7a0b\u4fe1\u606f\nCREATE TABLE Course (\nCourseID INT, -- \u8bfe\u7a0b ID \u5b57\u6bb5\uff0c\u6574\u578b\nCourseName VARCHAR(100), -- \u8bfe\u7a0b\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nPRIMARY KEY (CourseID) -- \u5c06 CourseID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"StudentCourse\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5b66\u751f\u9009\u8bfe\u4fe1\u606f\nCREATE TABLE StudentCourse (\nStudentID INT, -- \u5b66\u751f ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e Student \u8868\u7684 StudentID \u5b57\u6bb5\u5bf9\u5e94\nCourseID INT, -- \u8bfe\u7a0b ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e Course \u8868\u7684 CourseID \u5b57\u6bb5\u5bf9\u5e94\nPRIMARY KEY (StudentID, CourseID), -- \u5c06 StudentID \u548c CourseID \u7684\u7ec4\u5408\u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\nFOREIGN KEY (StudentID) REFERENCES Student(StudentID), -- \u8bbe\u7f6e StudentID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 Student \u8868\u7684 StudentID \u5b57\u6bb5\nFOREIGN KEY (CourseID) REFERENCES Course(CourseID) -- \u8bbe\u7f6e CourseID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 Course \u8868\u7684 CourseID \u5b57\u6bb5\n);\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u4e00\u4e2a\u662f\u5b66\u751f\u8868 (Student)\uff0c\u4e00\u4e2a\u662f\u8bfe\u7a0b\u8868 (Course)\uff0c\u8fd8\u6709\u4e00\u4e2a\u9009\u8bfe\u8868 (StudentCourse) \u7528\u4e8e\u8bb0\u5f55\u54ea\u4e2a\u5b66\u751f\u9009\u62e9\u4e86\u54ea\u95e8\u8bfe\u7a0b\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u9009\u8bfe\u8868\u4e2d\u7684\u5b66\u751f ID \u548c\u8bfe\u7a0b ID \u53ef\u4ee5\u4f5c\u4e3a\u5916\u952e\uff0c\u5171\u540c\u5f15\u7528\u5b66\u751f\u8868\u548c\u8bfe\u7a0b\u8868\u7684\u4e3b\u952e\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#4-","title":"\u793a\u4f8b 4 - \u591a\u5c42\u5916\u952e","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"Country\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u56fd\u5bb6\u4fe1\u606f\nCREATE TABLE Country (\nCountryID INT, -- \u56fd\u5bb6 ID \u5b57\u6bb5\uff0c\u6574\u578b\nCountryName VARCHAR(100), -- \u56fd\u5bb6\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nPRIMARY KEY (CountryID) -- \u5c06 CountryID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"State\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5dde/\u7701\u4efd\u4fe1\u606f\nCREATE TABLE State (\nStateID INT, -- \u5dde/\u7701\u4efd ID \u5b57\u6bb5\uff0c\u6574\u578b\nStateName VARCHAR(100), -- \u5dde/\u7701\u4efd\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nCountryID INT, -- \u56fd\u5bb6 ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e Country \u8868\u7684 CountryID \u5b57\u6bb5\u5bf9\u5e94\nPRIMARY KEY (StateID), -- \u5c06 StateID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\nFOREIGN KEY (CountryID) REFERENCES Country(CountryID) -- \u8bbe\u7f6e CountryID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 Country \u8868\u7684 CountryID \u5b57\u6bb5\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"City\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u57ce\u5e02\u4fe1\u606f\nCREATE TABLE City (\nCityID INT, -- \u57ce\u5e02 ID \u5b57\u6bb5\uff0c\u6574\u578b\nCityName VARCHAR(100), -- \u57ce\u5e02\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nStateID INT, -- \u5dde/\u7701\u4efd ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e State \u8868\u7684 StateID \u5b57\u6bb5\u5bf9\u5e94\nPRIMARY KEY (CityID), -- \u5c06 CityID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\nFOREIGN KEY (StateID) REFERENCES State(StateID) -- \u8bbe\u7f6e StateID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 State \u8868\u7684 StateID \u5b57\u6bb5\n);\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6709\u4e09\u4e2a\u8868\uff0c\u56fd\u5bb6\u8868 (Country)\uff0c\u5dde/\u7701\u4efd\u8868 (State)\uff0c\u57ce\u5e02\u8868 (City)\u3002\u5dde/\u7701\u4efd\u8868\u6709\u4e00\u4e2a\u5b57\u6bb5 CountryID\uff0c\u8fd9\u662f\u56fd\u5bb6\u8868\u7684\u4e3b\u952e\uff0c\u540c\u65f6\u4e5f\u662f\u5dde/\u7701\u4efd\u8868\u7684\u5916\u952e\u3002\u57ce\u5e02\u8868\u6709\u4e00\u4e2a\u5b57\u6bb5 StateID\uff0c\u8fd9\u662f\u5dde/\u7701\u4efd\u8868\u7684\u4e3b\u952e\uff0c\u540c\u65f6\u4e5f\u662f\u57ce\u5e02\u8868\u7684\u5916\u952e\u3002\u8fd9\u5c31\u5f62\u6210\u4e86\u4e00\u79cd\u591a\u5c42\u5916\u952e\u7684\u60c5\u51b5\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/","title":"NOT NULL \u975e\u7a7a\u7ea6\u675f","text":"NOT NULL \u7ea6\u675f\u53ef\u7528\u4e8e\u9650\u5236\u4e00\u4e2a\u5217\u4e2d\u4e0d\u80fd\u5305\u542b NULL \u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"> column_name data_type NOT NULL;\n
\u4f60\u65e0\u6cd5\u5411\u5305\u542b NOT NULL
\u7ea6\u675f\u7684\u5217\u4e2d\u63d2\u5165 NULL
\u503c\uff0c\u6216\u66f4\u65b0\u65e7\u503c\u4e3a NULL
\u3002
create table t1(a int not null,b int);\nmysql> insert into t1 values(null,1);\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\nmysql> insert into t1 values(1,null);\nQuery OK, 1 row affected (0.01 sec)\nmysql> update t1 set a=null where a=1;\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u56e0\u4e3a a \u5217\u5b58\u5728\u975e\u7a7a\u7ea6\u675f\uff0c\u56e0\u6b64\u7b2c 1 \u6761\u63d2\u5165\u8bed\u53e5\u4f1a\u6267\u884c\u5931\u8d25\uff0c\u7b2c 2 \u6761\u8bed\u53e5\u6ee1\u8db3 a \u5217\u7684\u975e\u7a7a\u7ea6\u675f\uff0cb \u5217\u4e0d\u5b58\u5728\u975e\u7a7a\u7ea6\u675f\uff0c\u56e0\u6b64\u53ef\u4ee5\u6210\u529f\u63d2\u5165\u3002\u800c\u66f4\u65b0\u8bed\u53e5\u56e0\u4e3a\u89e6\u53d1\u4e86 a \u5217\u7684\u975e\u7a7a\u7ea6\u675f\uff0c\u56e0\u6b64\u66f4\u65b0\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/","title":"\u7ea6\u675f\u6982\u8ff0","text":"\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\uff0c\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u7684\u6b63\u786e\u6027\u3001\u5b8c\u6574\u6027\u3001\u6709\u6548\u6027\uff0c\u5728\u5efa\u8868\u8bed\u53e5\u4e2d\uff0c\u4f1a\u5bf9\u67d0\u4e9b\u5217\u52a0\u5165\u9650\u5236\u6761\u4ef6\uff0c\u786e\u4fdd\u6570\u636e\u5e93\u5185\u5b58\u50a8\u7684\u4fe1\u606f\u9075\u4ece\u4e00\u5b9a\u7684\u4e1a\u52a1\u89c4\u5219\uff0c\u8fd9\u4e9b\u9650\u5236\u6761\u4ef6\u88ab\u79f0\u4e3a\u7ea6\u675f\u3002\u4f8b\u5982\uff0c\u5982\u679c DML \u8bed\u53e5\u7684\u6267\u884c\u7ed3\u679c\u8fdd\u53cd\u4e86\u5b8c\u6574\u6027\u7ea6\u675f\uff08Integrity Constraint\uff09\uff0c\u5c06\u56de\u6eda\u8bed\u53e5\u5e76\u8fd4\u56de\u9519\u8bef\u6d88\u606f\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/#_2","title":"\u5b8c\u6574\u6027\u7ea6\u675f\u7c7b\u578b","text":"MatrixOne \u5b58\u5728\u591a\u79cd\u7ea6\u675f\uff0c\u4e0d\u540c\u7684\u7ea6\u675f\u5bf9\u4e8e\u6570\u636e\u5e93\u884c\u4e3a\u6709\u7740\u4e0d\u540c\u7684\u9650\u5236\u3002\u76ee\u524d\u652f\u6301\u7684\u7ea6\u675f\u90fd\u662f\u8868\u7ea7\u522b\u7684\u7ea6\u675f\uff1a
\u975e\u7a7a\u7ea6\u675f\u662f\u6307\uff0c\u67d0\u4e00\u5217\u7684\u6570\u636e\u4e0d\u80fd\u51fa\u73b0\u7a7a\u503c\uff08NULL\uff09\uff0c\u8fdd\u53cd\u4e86\u8be5\u9650\u5236\u6761\u4ef6\u7684\u6570\u636e\u4e0d\u80fd\u88ab\u63d2\u5165\u6216\u66f4\u65b0\u5728\u5bf9\u5e94\u5217\u4e2d\u3002\u5728 MatrixOne \u4e2d\uff0c\u4e00\u5f20\u8868\u5141\u8bb8\u6709\u96f6\u4e2a\u3001\u4e00\u4e2a\u6216\u591a\u4e2a\u975e\u7a7a\u7ea6\u675f\u3002
\u552f\u4e00\u952e\u7ea6\u675f\u662f\u6307\uff0c\u5728\u4e00\u5f20\u8868\u4e2d\u5b58\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u7ec4\u5408\u4e2d\uff0c\u88ab\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u884c\u5728\u6b64\u5217\uff08\u6216\u5217\u96c6\uff09\u7684\u503c\u662f\u552f\u4e00\u7684\u3002\u5728 MatrixOne \u4e2d\uff0c\u4e00\u5f20\u8868\u4e2d\u5141\u8bb8\u5b58\u5728\u96f6\u4e2a\u3001\u4e00\u4e2a\u6216\u591a\u4e2a\u552f\u4e00\u952e\u7ea6\u675f\uff0c\u4f46\u4e0e\u5176\u4ed6\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u7684\u552f\u4e00\u952e\u7ea6\u675f\u4e5f\u5fc5\u987b\u975e\u7a7a\u3002
\u4e3b\u952e\u7ea6\u675f\u662f\u6307\uff0c\u5728\u4e00\u5f20\u8868\u4e2d\u5b58\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u7ec4\u5408\u4e2d\uff0c\u6bcf\u4e00\u6570\u636e\u884c\u90fd\u53ef\u4ee5\u7531\u67d0\u4e00\u4e2a\u952e\u503c\u552f\u4e00\u5730\u786e\u5b9a\u4e14\u975e\u7a7a\u7684\uff0c\u5e76\u4e14\u4e3b\u952e\u7ea6\u675f\u5728\u4e00\u5f20\u8868\u4e2d\u6700\u591a\u53ea\u80fd\u6709 1 \u4e2a\u3002
\u5916\u952e\u7ea6\u675f\u662f\u6307\uff0c\u5728\u4e00\u5f20\u8868\u4e2d\u5b58\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u7ec4\u5408\u4e2d\uff0c\u88ab\u53e6\u4e00\u5f20\u8868\u4e2d\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u6240\u5f15\u7528\uff0c\u88ab\u5f15\u7528\u8868\u901a\u5e38\u79f0\u4e3a\u7236\u8868\uff0c\u5f15\u7528\u8868\u79f0\u4e3a\u5b50\u8868\u3002\u5b50\u8868\u5f15\u7528\u7236\u8868\u7684\u5bf9\u5e94\u5217\u7684\u6570\u636e\uff0c\u53ea\u80fd\u662f\u7236\u8868\u7684\u6570\u636e\u6216\u7a7a\u503c\uff0c\u8fd9\u79cd\u7ea6\u675f\u88ab\u79f0\u4e3a\u5916\u952e\u7ea6\u675f\u3002
\u81ea\u589e\u7ea6\u675f\u662f\u4e00\u79cd\u7528\u4e8e\u5728\u8868\u4e2d\u81ea\u52a8\u4e3a\u4e00\u4e2a\u5217\u751f\u6210\u552f\u4e00\u6807\u8bc6\u503c\u7684\u7279\u6027\u3002\u5b83\u5141\u8bb8\u4f60\u5728\u63d2\u5165\u65b0\u884c\u65f6\uff0c\u81ea\u52a8\u4e3a\u6307\u5b9a\u7684\u81ea\u589e\u5217\u751f\u6210\u4e00\u4e2a\u9012\u589e\u7684\u552f\u4e00\u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/","title":"PRIMARY KEY \u4e3b\u952e\u7ea6\u675f","text":"PRIMARY KEY \u7ea6\u675f\u53ef\u7528\u4e8e\u786e\u4fdd\u8868\u5185\u7684\u6bcf\u4e00\u6570\u636e\u884c\u90fd\u53ef\u4ee5\u7531\u67d0\u4e00\u4e2a\u952e\u503c\u552f\u4e00\u5730\u786e\u5b9a\u3002 \u5e76\u4e14\u6bcf\u4e2a\u6570\u636e\u5e93\u8868\u4e0a\u6700\u591a\u53ea\u80fd\u5b9a\u4e49\u4e00\u4e2a PRIMARY KEY
\u7ea6\u675f\u3002
\u9075\u5faa\u89c4\u5219
\u5b9a\u4e49\u4e3b\u952e\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e0b\u5217\u89c4\u5219\uff1a
\u552f\u4e00\u6027\uff1a\u4e3b\u952e\u5217\u7684\u503c\u5fc5\u987b\u662f\u552f\u4e00\u7684\uff0c\u5373\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u90fd\u5fc5\u987b\u5177\u6709\u4e0d\u540c\u7684\u4e3b\u952e\u503c\u3002
\u975e\u7a7a\u6027\uff1a\u4e3b\u952e\u5217\u7684\u503c\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u5373\u5b83\u4eec\u4e0d\u80fd\u5305\u542b NULL \u503c\u3002
\u4e0d\u53ef\u66f4\u6539\u6027\uff1a\u4e3b\u952e\u5217\u7684\u503c\u5728\u63d2\u5165\u540e\u4e0d\u80fd\u88ab\u66f4\u6539\u6216\u66f4\u65b0\u3002\u8fd9\u662f\u4e3a\u4e86\u4fdd\u6301\u4e3b\u952e\u7684\u552f\u4e00\u6027\u3002\u5982\u679c\u786e\u5b9e\u9700\u8981\u66f4\u6539\u4e3b\u952e\u503c\uff0c\u901a\u5e38\u9700\u8981\u5148\u5220\u9664\u539f\u59cb\u884c\uff0c\u7136\u540e\u63d2\u5165\u5177\u6709\u65b0\u4e3b\u952e\u503c\u7684\u65b0\u884c\u3002
\u6700\u5c0f\u6027\uff1a\u4e3b\u952e\u53ef\u4ee5\u7531\u5355\u4e2a\u5217\u6216\u591a\u4e2a\u5217\u7ec4\u5408\u800c\u6210\u3002\u590d\u5408\u4e3b\u952e\u53ef\u4ee5\u7528\u4e8e\u552f\u4e00\u6807\u8bc6\u884c\uff0c\u4f46\u5b83\u4eec\u7684\u590d\u5408\u503c\u5fc5\u987b\u552f\u4e00\uff0c\u4e0d\u80fd\u5b58\u5728\u91cd\u590d\u7ec4\u5408\u3002
\u5f15\u7528\u5b8c\u6574\u6027\uff1a\u4e3b\u952e\u901a\u5e38\u7528\u4f5c\u5916\u952e\uff08Foreign Key\uff09\u7684\u5f15\u7528\u3002
\u81ea\u52a8\u521b\u5efa\u7d22\u5f15\uff1a\u4e3b\u952e\u5217\u4f1a\u81ea\u52a8\u521b\u5efa\u7d22\u5f15\uff0c\u4ee5\u63d0\u9ad8\u68c0\u7d22\u6027\u80fd\u3002
> column_name data_type PRIMARY KEY;\n
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#_2","title":"\u793a\u4f8b","text":"mysql> create table t1(a int primary key, b int, c int, primary key(b,c));\nERROR 20301 (HY000): invalid input: more than one primary key defined\nmysql> create table t2(a int, b int, c int, primary key(b,c));\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t3(a int, b int, c int, primary key(a));\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,1);\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,2);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(2,1,1);\nQuery OK, 1 row affected (0.01 sec)\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0ct1 \u5305\u542b\u4e86\u4e24\u7ec4\u4e3b\u952e\uff0c\u56e0\u6b64\u521b\u5efa\u5931\u8d25\u3002t2 \u548c t3 \u53ea\u6709\u4e00\u7ec4\u4e3b\u952e\uff0c\u56e0\u6b64\u53ef\u4ee5\u521b\u5efa\u3002\u56db\u6761\u63d2\u5165\u8bed\u53e5\u90fd\u6ca1\u6709\u8fdd\u53cd\u7ea6\u675f\uff0c\u5747\u53ef\u6210\u529f\u6267\u884c\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#_3","title":"\u9650\u5236","text":"MatrixOne \u6682\u4e0d\u652f\u6301\u5220\u9664 PRIMARY KEY
\u7ea6\u675f\u3002
UNIQUE KEY \u7ea6\u675f\u53ef\u7528\u4e8e\u786e\u4fdd\u5c06\u8981\u88ab\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u884c\u7684\u5217\u6216\u5217\u7ec4\u7684\u503c\u662f\u552f\u4e00\u7684\uff0c\u8868\u7684\u4efb\u610f\u4e24\u884c\u7684\u67d0\u5217\u6216\u67d0\u4e2a\u5217\u96c6\u7684\u503c\u4e0d\u91cd\u590d\uff0c\u5e76\u4e14\u552f\u4e00\u952e\u7ea6\u675f\u4e5f\u5fc5\u987b\u975e\u7a7a\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"> column_name data_type UNIQUE KEY;\n
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#_2","title":"\u793a\u4f8b","text":"create table t1(a int unique key, b int, c int, unique key(b,c));\nmysql> insert into t1 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\nmysql> insert into t1 values(2,1,1);\nERROR 20307 (HY000): Duplicate entry '3a15013a1501' for key '__mo_index_idx_col'\nmysql> insert into t1 values(1,1,2);\nERROR 20307 (HY000): Duplicate entry '1' for key '__mo_index_idx_col'\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5b58\u5728\u4e24\u4e2a\u552f\u4e00\u952e\u7ea6\u675f\u5217 a \u4e0e\u5217 (b,c)\u3002\u5728\u63d2\u5165\u6570\u636e\u65f6\uff0c\u7b2c 2 \u6761\u63d2\u5165\u8bed\u53e5\u8fdd\u53cd\u4e86 (b,c) \u7684\u552f\u4e00\u7ea6\u675f\uff0c\u4e0e\u7b2c 1 \u6761\u63d2\u5165\u503c\u91cd\u590d\uff0c\u56e0\u6b64\u63d2\u5165\u5931\u8d25\u3002\u7b2c 3 \u6761\u63d2\u5165\u8bed\u53e5\u8fdd\u53cd\u4e86\u5217 a \u7684\u7ea6\u675f\uff0c\u4e5f\u56e0\u6b64\u63d2\u5165\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/","title":"UDF-Python-\u8fdb\u9636","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 UDF \u8fdb\u9636\u529f\u80fd\uff0c\u5305\u62ec\u4ee5 phython \u6587\u4ef6\u3001whl \u5305\u6784\u5efa UDF\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_2","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus), \u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
#To check with Python installation and its version\npython3 -V\n
Note
\u82e5\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u540c\u65f6\u62e5\u6709 Pyhon2 \u548c Python3\uff0c\u4f7f\u7528 UDF \u524d\u9700\u8981\u5168\u5c40\u914d\u7f6e\u4e3a Python3\uff0c\u4f8b\u5982\u53ef\u4ee5\u901a\u8fc7\u91cd\u547d\u540d /usr/bin/python
\uff0c\u7136\u540e\u5728\u8be5\u5904\u521b\u5efa\u540c\u540d\u7684 python3 \u8f6f\u94fe\u6765\u5b9e\u73b0\u5168\u5c40\u914d\u7f6e\uff0c\u76f8\u5173\u547d\u4ee4\u793a\u4f8b\uff1a
mv /usr/bin/python /usr/bin/python.bak\nln -s /usr/local/python3/bin/python3 /usr/bin/python\n
\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff1a
pip3 install protobuf\npip3 install grpcio\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u6309\u7167\u5feb\u901f\u5f00\u59cb\u7ae0\u8282\u7684\u6b65\u9aa4\u4f7f\u7528 mo_ctl \u5b8c\u6210 MatrixOne \u7684\u90e8\u7f72\u3002\u90e8\u7f72\u5b8c\u6210\u540e\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u4fee\u6539 mo_ctl \u7684\u914d\u7f6e\uff1a
mo_ctl set_conf MO_CONF_FILE=\"\\${MO_PATH}/matrixone/etc/launch-with-python-udf-server/launch.toml\"\n
\u4fee\u6539\u914d\u7f6e\u540e\u9700\u8981\u542f\u52a8\uff08\u6216\u91cd\u542f\uff09MatrixOne \u670d\u52a1\u6765\u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u4f8b\u5982\u4f7f\u7528 mo_ctl \u542f\u52a8 MatrixOne \u670d\u52a1\uff1a
mo_ctl start\n
\u5f85 MatrixOne \u670d\u52a1\u6b63\u5e38\u542f\u52a8\uff08\u82e5 MatrixOne \u662f\u9996\u6b21\u542f\u52a8\uff0c\u540e\u53f0\u521d\u59cb\u5316\u4f1a\u9700\u8981\u5341\u79d2\u5de6\u53f3\u7684\u65f6\u95f4\uff0c\u521d\u59cb\u5316\u5b8c\u6210\u540e\u624d\u53ef\u8fde\u63a5\uff09\u3002\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u8bbf\u95ee MatrixOne \u670d\u52a1\uff1a
mo_ctl connect\n
\u8fde\u63a5\u6210\u529f\u540e\u5c06\u8fdb\u5165 mysql client \u547d\u4ee4\u884c\u5de5\u5177\u3002
\u5d4c\u5165\u5f0f UDF \u5c06\u51fd\u6570\u4f53\u76f4\u63a5\u5199\u5728 SQL \u4e2d\uff0c\u82e5\u51fd\u6570\u903b\u8f91\u5341\u5206\u590d\u6742\uff0c\u4f1a\u8ba9 SQL \u8bed\u53e5\u81a8\u80c0\u4e14\u4e0d\u5229\u4e8e\u4ee3\u7801\u7684\u7ef4\u62a4\u3002\u4e3a\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06 UDF \u51fd\u6570\u4f53\u7f16\u5199\u5728\u5916\u90e8\u5355\u72ec\u7684 Python \u6587\u4ef6\u4e2d\uff0c\u7136\u540e\u901a\u8fc7\u5bfc\u5165 Python \u6587\u4ef6\u7684\u65b9\u5f0f\u5728 MatrixOne \u4e2d\u521b\u5efa\u51fd\u6570\u3002
\u51c6\u5907\u597d python \u6587\u4ef6
\u53ef\u5c06\u539f SQL \u51fd\u6570\u4f53\u4e2d\u7684 python \u4ee3\u7801\u7f16\u5199\u5728 /opt/add_func.py
\u6587\u4ef6\u5185\uff1a
def add(a, b):\n return a + b\n
\u521b\u5efa UDF \u51fd\u6570
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u51fd\u6570\uff0c\u6211\u4eec\u4f7f\u7528 import \u5173\u952e\u5b57\u6765\u5bfc\u5165\u6307\u5b9a\u8def\u5f84\u4e0b\u7684 add_func.py \u6587\u4ef6\u3002
create or replace function py_add_2(a int, b int) returns int language python import '/opt/add_func.py' -- python \u6587\u4ef6\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u7edd\u5bf9\u8def\u5f84\nhandler 'add';\n
\u8c03\u7528 UDF \u51fd\u6570
\u51fd\u6570\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u53ef\u4f7f\u7528\u51fd\u6570\u540d + \u5339\u914d\u7c7b\u578b\u7684\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528 UDF \u51fd\u6570\uff0c\u4f8b\u5982\uff1a
select py_add_2(12345,23456);\n+-------------------------+\n| py_add(12345, 23456) |\n+-------------------------+\n| 35801 |\n+-------------------------+\n1 row in set (0.02 sec)\n
WHL file \u662f\u7528\u4e8e python \u5206\u53d1\u7684\u6807\u51c6\u5185\u7f6e\u5305\u683c\u5f0f\uff0c\u5141\u8bb8\u5728\u4e0d\u6784\u5efa\u6e90\u4ee3\u7801\u5206\u53d1\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u5b89\u88c5\u5305\uff0cWHL file \u672c\u8d28\u4e0a\u662f ZIP \u6587\u4ef6\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_3","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u5728\u6784\u5efa whl \u5305\u524d\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u5de5\u5177\uff1a
pip install setuptools wheel\n# setuptools\uff1a\u7528\u4e8e\u6784\u5efa\u548c\u6253\u5305 Python \u5e93\n# wheel\uff1a\u7528\u4e8e\u751f\u6210.whl \u6587\u4ef6\n
\u6309\u7167\u5982\u4e0b\u7684\u6587\u4ef6\u7ed3\u6784\u521b\u5efa\u6587\u4ef6\u4ee5\u53ca\u5185\u5bb9
\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684 Python \u5de5\u7a0b\u76ee\u5f55 func_add
\uff08\u6587\u4ef6\u5939\u540d\u79f0\u53ef\u4efb\u610f\u547d\u540d\uff09\uff0c\u5176\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a
func_add/\n\u251c\u2500\u2500 add_udf.py\n\u2514\u2500\u2500 setup.py\n
\u5176\u4e2d\uff0cadd_udf.py
\u662f\u53ef\u6b63\u5e38\u53ef\u6267\u884c\u7684 Python \u4ee3\u7801\u6587\u4ef6\uff0c\u7528\u6765\u5b9e\u73b0\u51fd\u6570\u65b9\u6cd5\u4f53\u903b\u8f91\uff0c\u4e5f\u53ef\u5c06\u5176\u89c6\u4e3a\u4e00\u4e2a\u6a21\u5757\uff08module\uff09\u3002add_udf.py
\u4e2d\u7684\u4ee3\u7801\u4f8b\u5982\uff1a
# function\n\ndef add(a, b):\n return a + b\n
setup.py
\u6587\u4ef6\u7528\u6765\u5b9a\u4e49\u5e93\u7684\u5143\u6570\u636e\u548c\u914d\u7f6e\u4fe1\u606f\u7b49\uff0c\u4ee3\u7801\u4f8b\u5982\uff1a
# setup.py\n\nfrom setuptools import setup\n\nsetup(\nname=\"udf\",\nversion=\"1.0.0\",\n# \u5305\u542b\u51fd\u6570\u4f53\u7684 python \u6587\u4ef6\u540d\u53bb\u6389\u62d3\u5c55\u540d.py \u540e\u5373\u4e3a\u6a21\u5757\u540d\npy_modules=[\"add_udf\"]\n)\n
\u6784\u5efa whl \u5305
\u5de5\u7a0b\u6587\u4ef6\u7f16\u5199\u5c31\u4f4d\u540e\uff0c\u5728 func_add
\u76ee\u5f55\u5185\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u6784\u5efa wheel \u5305\uff1a
python setup.py bdist_wheel\n
\u6253\u5305\u5b8c\u6210\u540e\uff0c\u4f1a\u5728 func_add/dist
\u76ee\u5f55\u4e0b\u751f\u6210 udf-1.0.0-py3-none-any.whl
\u6587\u4ef6\u3002
\u521b\u5efa UDF \u51fd\u6570
\u5c06 whl \u5305\u62f7\u8d1d\u81f3\u89c4\u5212\u4e2d\u7684\u51fd\u6570\u5b58\u653e\u76ee\u5f55\uff0c\u4f8b\u5982\u8def\u5f84\u4e3a\uff1a/opt/udf/udf-1.0.0-py3-none-any.whl
\uff0c\u5728\u521b\u5efa\u8bed\u53e5\u4e2d\u4f7f\u7528\u8be5 whl \u5305\u521b\u5efa UDF \u51fd\u6570\uff0c\u521b\u5efa\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a
create or replace function py_add_3(a int, b int) returns int language python import '/opt/udf/udf-1.0.0-py3-none-any.whl' -- wheel \u5305\u6240\u5728\u76ee\u5f55\nhandler 'add_udf.add'; -- \u6307\u5b9a\u8c03\u7528 whl \u5305\u4e2d add_udf \u6a21\u5757\u7684 add \u51fd\u6570\n
\u8c03\u7528 UDF \u51fd\u6570
\u51fd\u6570\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u53ef\u4f7f\u7528\u51fd\u6570\u540d + \u5339\u914d\u7c7b\u578b\u7684\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528 UDF \u51fd\u6570\uff0c\u4f8b\u5982\uff1a
select py_add_3(12345,23456);\n+-------------------------+\n| py_add(12345, 23456) |\n+-------------------------+\n| 35801 |\n+-------------------------+\n1 row in set (0.02 sec)\n
\u5728\u90e8\u5206\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u4f1a\u5e0c\u671b python \u51fd\u6570\u4e00\u6b21\u6027\u63a5\u6536\u591a\u4e2a\u5143\u7ec4\u6765\u63d0\u9ad8\u8fd0\u884c\u6548\u7387\u3002\u5982\u5728\u6a21\u578b\u63a8\u7406\u65f6\uff0c\u6211\u4eec\u901a\u5e38\u662f\u4ee5\u4e00\u4e2a batch \u4e3a\u5355\u4f4d\u8fdb\u884c\uff0c\u8fd9\u91cc\u7684 batch \u5373\u4e3a\u5143\u7ec4\u7684 vector\uff0cMatrixOne \u63d0\u4f9b\u51fd\u6570\u7684 vector \u9009\u9879\u6765\u5904\u7406\u8fd9\u79cd\u60c5\u51b5\u3002\u6211\u4eec\u4ecd\u4ee5 py_add \u51fd\u6570\u4e3a\u4f8b\uff0c\u6765\u5c55\u793a vector \u9009\u9879\u7684\u7528\u6cd5\u3002
\u5728 udf_test \u5e93\u4e0b\u521b\u5efa\u4e00\u5f20\u540d\u4e3a grades \u7684\u6570\u636e\u8868\uff1a
create table grades(chinese int,math int);\n
\u63d2\u5165\u51e0\u6761\u6d4b\u8bd5\u6570\u636e\uff1a
insert into grades values(97,100),(85,89),(79,99);\n
\u67e5\u770b\u4e0b\u8868\u91cc\u7684\u6570\u636e\uff1a
select * from grades;\n+---------+------+\n| chinese | math |\n+---------+------+\n| 97 | 100 |\n| 85 | 89 |\n| 79 | 99 |\n+---------+------+\n
\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u521b\u5efa UDF \u51fd\u6570 \u6211\u4eec\u4f7f\u7528 add.vector = True
\u6765\u6807\u8bb0 python \u51fd\u6570 add \u63a5\u6536\u4e24\u4e2a int \u5217\u8868\uff08vector\uff09\u800c\u4e0d\u662f int \u503c\uff1a
create or replace function py_add_4(a int, b int) returns int language python as $$\ndef add(a, b): # a, b are list\nreturn [a[i] + b[i] for i in range(len(a))]\nadd.vector = True\n$$\nhandler 'add';\n
\u8c03\u7528 UDF \u51fd\u6570
\u540c\u6837\u901a\u8fc7\u51fd\u6570\u540d\u548c\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528\u51fd\u6570\uff0c\u8be5\u5904\u7684\u53c2\u6570\u5217\u8868\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 grades \u8868\u4e2d\u7684\u4e24\u4e2a\u6574\u6570\u5b57\u6bb5\u5217\uff0c\u4f8b\u5982\uff1a
select py_add_4(chinese,math) as Total from grades;\n+-------+\n| Total |\n+-------+\n| 197 |\n| 174 |\n| 178 |\n+-------+\n
\u4f7f\u7528 vector \u9009\u9879\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u81ea\u7531\u7684\u9009\u62e9\u51fd\u6570\u7684\u5904\u7406\u5f62\u5f0f\uff0c\u4f8b\u5982\u4e00\u6b21\u4e00\u5143\u7ec4\uff0c\u6216\u8005\u4e00\u6b21\u591a\u5143\u7ec4\u3002
\u672c\u8282\u4ee5\u201c\u4fe1\u7528\u5361\u6b3a\u8bc8\u68c0\u6d4b\u201d\u4e3a\u4f8b\uff0c\u8bb2\u8ff0\u4e86 python UDF \u5728\u673a\u5668\u5b66\u4e60\u63a8\u7406\u6d41\u6c34\u7ebf\u4e2d\u7684\u5e94\u7528\u3002\uff08\u76f8\u5173\u4ee3\u7801\u8be6\u89c1 github-demo\uff0c\u5305\u542b\u4ee5\u4e0b\u5373\u5c06\u4e0b\u8f7d\u548c\u7f16\u5199\u7684\u6587\u4ef6\uff09
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_5","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u786e\u4fdd\u672c\u5730 python \u73af\u5883\u5df2\u5b89\u88c5\u4e86 numpy \u548c scikit-learn \u4ee5\u53ca joblib\u3002
pip install numpy\npip install scikit-learn\npip install joblib\n
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_6","title":"\u80cc\u666f\u53ca\u6570\u636e","text":"\u4fe1\u7528\u5361\u516c\u53f8\u9700\u8981\u8bc6\u522b\u6b3a\u8bc8\u4ea4\u6613\uff0c\u4ee5\u9632\u6b62\u5ba2\u6237\u7684\u4fe1\u7528\u5361\u88ab\u4ed6\u4eba\u6076\u610f\u4f7f\u7528\u3002\uff08\u8be6\u89c1 kaggle Credit Card Fraud Detection\uff09
\u6570\u636e\u96c6\u5305\u542b\u4e86 2013 \u5e74 9 \u6708\u6b27\u6d32\u6301\u5361\u4eba\u4f7f\u7528\u4fe1\u7528\u5361\u8fdb\u884c\u7684\u4ea4\u6613\u8bb0\u5f55\u3002\u6570\u636e\u683c\u5f0f\u5982\u4e0b\uff1a
\u5217\u540d \u7c7b\u578b \u542b\u4e49 Time int \u6b64\u4ea4\u6613\u4e0e\u6570\u636e\u96c6\u4e2d\u7684\u7b2c\u4e00\u4e2a\u4ea4\u6613\u4e4b\u95f4\u7ecf\u8fc7\u7684\u79d2\u6570 V1\uff5eV28 double \u4f7f\u7528 PCA \u63d0\u53d6\u7684\u7279\u5f81\uff08\u4ee5\u4fdd\u62a4\u7528\u6237\u8eab\u4efd\u548c\u654f\u611f\u7279\u5f81\uff09 Amount double \u4ea4\u6613\u91d1\u989d Class int 1: \u6b3a\u8bc8\u4ea4\u6613\uff0c0: \u975e\u6b3a\u8bc8\u4ea4\u6613\u6211\u4eec\u628a\u6570\u636e\u6309\u7167 8: 1: 1 \u7684\u6bd4\u4f8b\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u3001\u9a8c\u8bc1\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002\u7531\u4e8e\u8bad\u7ec3\u8fc7\u7a0b\u4e0d\u662f\u672c\u6587\u7684\u91cd\u70b9\uff0c\u4e0d\u5728\u6b64\u5904\u8fdb\u884c\u8fc7\u591a\u7684\u4ecb\u7ecd\u3002
\u6211\u4eec\u628a\u6d4b\u8bd5\u96c6\u5f53\u4f5c\u751f\u4ea7\u8fc7\u7a0b\u4e2d\u65b0\u51fa\u73b0\u7684\u6570\u636e\u5b58\u50a8\u5230 MO \u4e2d\uff0c\u53ef\u4ee5\u70b9\u51fb\u6b64\u5904\u83b7\u5f97 ddl.sql
\u6587\u4ef6\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5bfc\u5165\u6570\u636e\u8868\u4ee5\u53ca\u90e8\u5206\u6d4b\u8bd5\u6570\u636e\uff1a
source /your_download_path/ddl.sql\n
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#python-whl","title":"\u51c6\u5907 python-whl \u5305","text":"\u7f16\u5199 detection.py
:
# coding = utf-8\n# -*- coding:utf-8 -*-\nimport decimal\nimport os\nfrom typing import List\n\nimport joblib\nimport numpy as np\n\nmodel_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'model_with_scaler')\n\n\ndef detect(featuresList: List[List[int]], amountList: List[decimal.Decimal]) -> List[bool]:\n model_with_scaler = joblib.load(model_path)\n\n columns_features = np.array(featuresList)\n column_amount = np.array(amountList, dtype='float').reshape(-1, 1)\n column_amount = model_with_scaler['amount_scaler'].transform(column_amount)\n data = np.concatenate((columns_features, column_amount), axis=1)\n predictions = model_with_scaler['model'].predict(data)\n return [pred == 1 for pred in predictions.tolist()]\n\n\ndetect.vector = True\n
\u7f16\u5199 __init__.py
:
# coding = utf-8\n# -*- coding:utf-8 -*-\nfrom .detection import detect\n
\u70b9\u51fb\u4e0b\u8f7d\u5df2\u7ecf\u8bad\u7ec3\u597d\u7684\u6a21\u578b model_with_scaler
\u7f16\u5199 setup.py
:
# coding = utf-8\n# -*- coding:utf-8 -*-\nfrom setuptools import setup, find_packages\n\nsetup(\n name=\"detect\",\n version=\"1.0.0\",\n packages=find_packages(),\n package_data={\n 'credit': ['model_with_scaler']\n },\n)\n
\u5c06\u4e0a\u8ff0\u6587\u4ef6\u7ec4\u7ec7\u6210\u4e0b\u65b9\u7684\u7ed3\u6784\uff1a
|-- demo/\n |-- credit/\n |-- __init__.py\n |-- detection.py # \u63a8\u7406\u51fd\u6570\n|-- model_with_scaler # \u6a21\u578b\n|-- setup.py\n
\u8fdb\u5165\u76ee\u5f55 demo
\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6784\u5efa wheel \u5305 detect-1.0.0-py3-none-any.whl\uff1a
python setup.py bdist_wheel
\u521b\u5efa udf \u51fd\u6570\uff1a
create or replace function py_detect(features json, amount decimal) returns bool language python import 'your_code_path/detect-1.0.0-py3-none-any.whl' -- \u66ff\u6362\u4e3a wheel \u5305\u6240\u5728\u76ee\u5f55\nhandler 'credit.detect'; -- credit module \u4e0b\u7684 detect \u51fd\u6570\n
\u8c03\u7528 udf \u51fd\u6570\u8fdb\u884c\u6b3a\u8bc8\u68c0\u6d4b\uff1a
select id, py_detect(features, amount) as is_fraud from credit_card_transaction limit 10;\n
\u8f93\u51fa\uff1a
+---------+----------+\n| id | is_fraud |\n+---------+----------+\n| 1 | false |\n| 2 | false |\n| 3 | true |\n| 4 | false |\n| 5 | false |\n| 6 | false |\n| 7 | false |\n| 8 | true |\n| 9 | false |\n| 10 | false |\n+---------+----------+\n
\u81f3\u6b64\uff0c\u6211\u4eec\u5df2\u7ecf\u5728 MO \u4e2d\u5b8c\u6210\u4e86\u4fe1\u7528\u5361\u6b3a\u8bc8\u68c0\u6d4b\u4efb\u52a1\u7684\u63a8\u7406\u3002
\u901a\u8fc7\u8be5\u6848\u4f8b\u53ef\u4ee5\u770b\u51fa\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u4f7f\u7528 python UDF \u6765\u5904\u7406 SQL \u89e3\u51b3\u4e0d\u4e86\u7684\u4efb\u52a1\u3002Python UDF \u65e2\u6269\u5c55\u4e86 SQL \u7684\u8bed\u4e49\uff0c\u53c8\u907f\u514d\u4e86\u6211\u4eec\u624b\u52a8\u7f16\u5199\u6570\u636e\u79fb\u52a8\u548c\u8f6c\u6362\u7684\u7a0b\u5e8f\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u5f00\u53d1\u6548\u7387\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_7","title":"\u53c2\u8003\u6587\u6863","text":"\u6709\u5173 MatrixOne \u4e2d UDF \u7684\u57fa\u7840\u7528\u6cd5\uff0c\u53c2\u89c1 UDF \u57fa\u7840\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u521b\u5efa\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u521b\u5efa UDF\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u5220\u9664\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u5220\u9664 UDF\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python/","title":"UDF-Python","text":"\u60a8\u53ef\u4ee5\u4f7f\u7528 Python \u7f16\u5199\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570 (UDF) \u7684\u5904\u7406\u7a0b\u5e8f\u3002\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u7b80\u5355 Python UDF\uff0c\u5305\u62ec\u4f7f\u7528\u73af\u5883\u8981\u6c42\u3001UDF \u521b\u5efa\u3001\u67e5\u770b\u3001\u4f7f\u7528\u548c\u5220\u9664\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/udf/udf-python/#_2","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus), \u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
#To check with Python installation and its version\npython3 -V\n
Note
\u82e5\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u540c\u65f6\u62e5\u6709 Pyhon2 \u548c Python3\uff0c\u4f7f\u7528 UDF \u524d\u9700\u8981\u5168\u5c40\u914d\u7f6e\u4e3a Python3\uff0c\u4f8b\u5982\u53ef\u4ee5\u901a\u8fc7\u91cd\u547d\u540d /usr/bin/python
\uff0c\u7136\u540e\u5728\u8be5\u5904\u521b\u5efa\u540c\u540d\u7684 python3 \u8f6f\u94fe\u6765\u5b9e\u73b0\u5168\u5c40\u914d\u7f6e\uff0c\u76f8\u5173\u547d\u4ee4\u793a\u4f8b\uff1a
mv /usr/bin/python /usr/bin/python.bak\nln -s /usr/local/python3/bin/python3 /usr/bin/python\n
\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff1a
pip3 install protobuf\npip3 install grpcio\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u6309\u7167\u5feb\u901f\u5f00\u59cb\u7ae0\u8282\u7684\u6b65\u9aa4\u4f7f\u7528 mo_ctl \u5b8c\u6210 MatrixOne \u7684\u90e8\u7f72\u3002\u90e8\u7f72\u5b8c\u6210\u540e\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u4fee\u6539 mo_ctl \u7684\u914d\u7f6e\uff1a
mo_ctl set_conf MO_CONF_FILE=\"\\${MO_PATH}/matrixone/etc/launch-with-python-udf-server/launch.toml\"\n
\u4fee\u6539\u914d\u7f6e\u540e\u9700\u8981\u542f\u52a8\uff08\u6216\u91cd\u542f\uff09MatrixOne \u670d\u52a1\u6765\u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u4f8b\u5982\u4f7f\u7528 mo_ctl \u542f\u52a8 MatrixOne \u670d\u52a1\uff1a
mo_ctl start\n
\u5f85 MatrixOne \u670d\u52a1\u6b63\u5e38\u542f\u52a8\uff08\u82e5 MatrixOne \u662f\u9996\u6b21\u542f\u52a8\uff0c\u540e\u53f0\u521d\u59cb\u5316\u4f1a\u9700\u8981\u5341\u79d2\u5de6\u53f3\u7684\u65f6\u95f4\uff0c\u521d\u59cb\u5316\u5b8c\u6210\u540e\u624d\u53ef\u8fde\u63a5\uff09\u3002\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u8bbf\u95ee MatrixOne \u670d\u52a1\uff1a
mo_ctl connect\n
\u8fde\u63a5\u6210\u529f\u540e\u5c06\u8fdb\u5165 mysql client \u547d\u4ee4\u884c\u5de5\u5177\u3002
MatrixOne \u652f\u6301\u5728 SQL \u4e2d\u901a\u8fc7 AS \u5173\u952e\u5b57\u76f4\u63a5\u4f7f\u7528 Python \u4ee3\u7801\u7f16\u5199\u51fd\u6570\u4f53\u6765\u521b\u5efa UDF\uff0c\u4ee5\u8fd9\u79cd\u5f62\u5f0f\u521b\u5efa\u7684 UDF \u88ab\u79f0\u4e3a\u5d4c\u5165\u5f0f UDF\u3002
\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u5e93
\u5728\u521b\u5efa UDF \u51fd\u6570\u4e4b\u524d\uff0c\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u5e93\uff1a
mysql> create database udf_test;\nQuery 0k, 1 row affected (0.02 sec)\nmysql> use udf_test;\nDatabase changed\n
\u521b\u5efa UDF \u51fd\u6570
\u5728\u76ee\u6807\u5e93\u5185\uff0c\u53ef\u6267\u884c CREATE \u547d\u4ee4\u914d\u5408 Python \u8bed\u53e5\u521b\u5efa UDF \u51fd\u6570\u3002\u4f8b\u5982\u4f7f\u7528\u5982\u4e0b SQL \u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a py_add \u7684\u51fd\u6570\uff0c\u5b9a\u4e49\u53c2\u6570\u5217\u8868\u63a5\u6536\u4e24\u4e2a\u7c7b\u578b\u4e3a int \u7684\u53c2\u6570\uff0c\u51fd\u6570\u529f\u80fd\u662f\u8fd4\u56de\u4e24\u4e2a\u53c2\u6570\u7684\u548c\uff0c\u5177\u4f53\u7684\u51fd\u6570\u903b\u8f91\u5728 as \u540e\u7684 python \u4ee3\u7801\u4e2d\uff0c\u7136\u540e\uff0c\u4f7f\u7528 handler \u5173\u952e\u5b57\u6307\u5b9a\u8c03\u7528\u7684 python \u51fd\u6570\u540d\u79f0\uff1a
create or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\n
Note
\u5f53\u524d\u7248\u672c matrixone \u4e0d\u4f1a\u5728\u521b\u5efa UDF \u65f6\u68c0\u67e5 python \u8bed\u6cd5\uff0c\u7528\u6237\u9700\u8981\u81ea\u884c\u4fdd\u8bc1 python \u8bed\u6cd5\u7684\u6b63\u786e\u6027\uff0c\u5426\u5219\u5728\u6267\u884c\u540e\u7eed\u6267\u884c\u51fd\u6570\u65f6\u4f1a\u62a5\u9519\u3002
\u8c03\u7528 UDF \u51fd\u6570
\u51fd\u6570\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u53ef\u4f7f\u7528\u51fd\u6570\u540d + \u5339\u914d\u7c7b\u578b\u7684\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528 UDF \u51fd\u6570\uff0c\u4f8b\u5982\uff1a
select py_add(12345,23456);\n+-------------------------+\n| py_add(12345, 23456) |\n+-------------------------+\n| 35801 |\n+-------------------------+\n1 row in set (0.02 sec)\n
\u53ef\u901a\u8fc7 drop function
\u547d\u4ee4\u5bf9\u5df2\u521b\u5efa\u7684 UDF \u51fd\u6570\u8fdb\u884c\u5220\u9664\u3002MatrixOne \u901a\u8fc7 \u51fd\u6570\u540d(\u53c2\u6570\u5217\u8868)
\u6765\u5b8c\u6574\u6807\u8bc6\u4e00\u4e2a UDF \u51fd\u6570\uff0c\u56e0\u6b64\u5220\u9664 UDF \u51fd\u6570\u65f6\u9700\u8981\u663e\u5f0f\u6307\u5b9a\u51fd\u6570\u540d\u4e0e\u53c2\u6570\u5217\u8868\uff0c\u4f8b\u5982\uff1a
drop function py_add(int, int);\n
"},{"location":"MatrixOne/Develop/udf/udf-python/#udf_2","title":"\u67e5\u770b UDF","text":"\u5df2\u521b\u5efa UDF \u51fd\u6570\u7684\u4fe1\u606f\u4f1a\u4fdd\u5b58\u5728 MatrixOne \u7684\u5143\u6570\u636e\u4e2d\uff0c\u53ef\u901a\u8fc7\u67e5\u8be2\u7cfb\u7edf\u8868 mo_catalog.mo_user_defined_function
\u6765\u83b7\u53d6 MatrixOne \u4e2d\u5df2\u6709\u7684 UDF \u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\uff1a
mysql> select * from mo_catalog.mo_user_defined_function\\G\n*************************** 1. row ***************************\nfunction_id: 9000016\nname: py_add\nowner: 0\nargs: [{\"name\": \"a\", \"type\": \"int\"}, {\"name\": \"b\", \"type\": \"int\"}]\nrettype: int\nbody: {\"handler\":\"add\",\"import\":false,\"body\":\"\\ndef add(a, b):\\n return a + b\\n\"}\nlanguage: python\ndb: udf_test\ndefiner: root\nmodified_time: 2023-12-26 13:59:39\ncreated_time: 2023-12-26 13:59:39\ntype: FUNCTION\nsecurity_type: DEFINER\ncomment: character_set_client: utf8mb4\ncollation_connection: utf8mb4_0900_ai_ci\ndatabase_collation: utf8mb4_0900_ai_ci\n
"},{"location":"MatrixOne/Develop/udf/udf-python/#_3","title":"\u53c2\u8003\u6587\u6863","text":"\u6709\u5173 MatrixOne \u4e2d UDF \u7684\u8fdb\u9636\u7528\u6cd5\uff0c\u53c2\u89c1 UDF \u8fdb\u9636\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u521b\u5efa\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u521b\u5efa UDF\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u5220\u9664\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u5220\u9664 UDF\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/","title":"\u90e8\u7f72\u5e38\u89c1\u95ee\u9898","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#_2","title":"\u73af\u5883\u76f8\u5173","text":"\u90e8\u7f72 MatrixOne \u6240\u9700\u7684\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u662f\u4ec0\u4e48\uff1f
\u5bf9\u4e8e\u4f4e\u7248\u672c\u5185\u6838\u7684 Linux \u7cfb\u7edf\uff0c\u5982\u679c\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u5b89\u88c5\u90e8\u7f72\u65b9\u5f0f\uff0c\u63a8\u8350\u4f7f\u7528\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u8fdb\u884c\u90e8\u7f72\uff0c\u8be6\u60c5\u53ef\u89c1\u5355\u673a\u90e8\u7f72 Matrixone \u6982\u8ff0\u4e2d\u7684\u63a8\u8350\u5b89\u88c5\u73af\u5883\u7ae0\u8282\u3002
\u53ef\u4ee5\u5728\u7ea2\u5e3d\u7cfb\uff0c\u6bd4\u5982 CentOS 7 \u4e0b\u6b63\u5e38\u4f7f\u7528 MatrixOne \u5417\uff1f
MatrixOne \u5bf9\u64cd\u4f5c\u7cfb\u7edf\u7684\u8981\u6c42\u4e0d\u4e25\u683c\uff0c\u652f\u6301\u5728 CentOS 7 \u4e0b\u4f7f\u7528\uff0c\u4f46 CentOS 7 \u5728 24 \u5e74 6 \u6708\u5e95\u5c31\u505c\u6b62\u7ef4\u62a4\u4e86\uff0c\u63a8\u8350\u5927\u5bb6\u4f7f\u7528\u66f4\u65b0\u7248\u672c\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002
MatrixOne \u662f\u5426\u652f\u6301\u5728\u56fd\u4ea7\u73af\u5883\u4e0b\u90e8\u7f72\uff1f
\u5bf9\u4e8e\u56fd\u4ea7\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u82af\u7247\uff0c\u82af\u7247\u6211\u4eec\u5df2\u7ecf\u9002\u914d\u8fc7\u9cb2\u9e4f\u548c\u6d77\u5149\uff0c\u64cd\u4f5c\u7cfb\u7edf\u5df2\u7ecf\u9002\u914d\u8fc7\u94f6\u6cb3\u9e92\u9e9f\uff0c\u6b27\u62c9\uff0c\u9e92\u9e9f\u4fe1\u5b89\u3002
\u6211\u53ef\u4ee5\u5728\u54ea\u91cc\u90e8\u7f72 MatrixOne\uff1f
MatrixOne \u53ef\u4ee5\u672c\u5730\u90e8\u7f72\u3001\u516c\u5171\u4e91\u3001\u79c1\u6709\u4e91\u6216 kubernetes \u4e0a\u3002
MatrixOne \u662f\u5426\u652f\u6301\u5728\u963f\u91cc\u4e91 ecs \u670d\u52a1\u5668\u4e0a\u5206\u5e03\u5f0f\u90e8\u7f72\u5417\uff1f
\u76ee\u524d\u9700\u8981\u57fa\u4e8e ECS \u642d\u5efa K8S \u6216\u8005\u4f7f\u7528\u963f\u91cc\u4e91 ACK \u624d\u80fd\u8fdb\u884c\u5206\u5e03\u5f0f\u90e8\u7f72\u3002
\u96c6\u7fa4\u90e8\u7f72\u53ea\u652f\u6301 K8s \u5417\uff1f\u80fd\u4e0d\u80fd\u7269\u7406\u5206\u5e03\u5f0f\u672c\u5730\u90e8\u7f72\uff1f
\u5982\u679c\u63d0\u524d\u6ca1\u6709 k8s \u548c minio \u73af\u5883\u7684\u8bdd\u3002\u6211\u4eec\u7684\u5b89\u88c5\u5de5\u5177\u4f1a\u81ea\u5e26 k8s \u548c minio\uff0c\u4e5f\u53ef\u4ee5\u5728\u7269\u7406\u673a\u4e00\u952e\u90e8\u7f72\u3002
MatrixOne \u76ee\u524d\u8fd8\u4e0d\u652f\u6301\u975e k8s \u7248\u672c\u4e3b\u4ece\u914d\u7f6e\uff0c\u540e\u7eed\u4f1a\u652f\u6301\u3002
\u751f\u4ea7\u73af\u5883\u53ea\u80fd\u7528 k8s \u6a21\u5f0f\u90e8\u7f72\u5417\uff1f
\u662f\u7684\uff0c\u4e3a\u4e86\u5f97\u5230\u5206\u5e03\u5f0f\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0c\u6211\u4eec\u63a8\u8350\u751f\u4ea7\u7cfb\u7edf\u662f\u7528 k8s \u90e8\u7f72\uff0c\u5047\u5982\u6ca1\u6709\u73b0\u6210\u7684 k8s\uff0c\u53ef\u4ee5\u4f7f\u7528\u6258\u7ba1 k8s \u8fdb\u884c\u90e8\u7f72\uff0c\u964d\u4f4e\u590d\u6742\u5ea6\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/#_3","title":"\u786c\u4ef6\u76f8\u5173","text":"MatrixOne \u5bf9\u90e8\u7f72\u786c\u4ef6\u7684\u914d\u7f6e\u8981\u6c42\u5982\u4f55\uff1f
\u5355\u673a\u5b89\u88c5\u60c5\u51b5\u4e0b\uff0cMatrixOne \u5f53\u524d\u53ef\u4ee5\u8fd0\u884c\u5728 Intel x86-64 \u548c ARM \u67b6\u6784\u7684 64 \u4f4d\u901a\u7528\u786c\u4ef6\u670d\u52a1\u5668\u5e73\u53f0\u4e0a\u3002
\u5bf9\u4e8e\u5f00\u53d1\u3001\u6d4b\u8bd5\u548c\u751f\u4ea7\u73af\u5883\u7684\u670d\u52a1\u5668\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u548c\u5efa\u8bae\u5982\u4e0b\uff1a
ARM \u67b6\u6784\u7684 Macbook M1/M2 \u4e5f\u9002\u5408\u5f00\u53d1\u73af\u5883\u3002
\u5206\u5e03\u5f0f\u5b89\u88c5\u60c5\u51b5\u4e0b\uff0cMatrixOne \u5bf9\u4e8e\u5f00\u53d1\u3001\u6d4b\u8bd5\u548c\u751f\u4ea7\u73af\u5883\u7684\u670d\u52a1\u5668\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u548c\u5efa\u8bae\u53ef\u4ee5\u53c2\u8003\u96c6\u7fa4\u62d3\u6251\u89c4\u5212\u6982\u8ff0\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/#_4","title":"\u914d\u7f6e\u76f8\u5173","text":"\u5b89\u88c5\u65f6\u9700\u8981\u66f4\u6539\u4ec0\u4e48\u8bbe\u7f6e\u5417\uff1f
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5b89\u88c5\u65f6\uff0c\u4f60\u65e0\u9700\u66f4\u6539\u4efb\u4f55\u8bbe\u7f6e\u3002launch.toml
\u9ed8\u8ba4\u8bbe\u7f6e\u5b8c\u5168\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c MatrixOne\u3002\u4f46\u662f\u5982\u679c\u4f60\u9700\u8981\u81ea\u5b9a\u4e49\u76d1\u542c\u7aef\u53e3\u3001IP \u5730\u5740\u3001\u5b58\u50a8\u6570\u636e\u6587\u4ef6\u8def\u5f84\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539\u76f8\u5e94\u7684 cn.toml
\u3001tn.toml
\u6216 log.toml
\uff0c\u8fd9\u4e9b\u6587\u4ef6\u5185\u53c2\u6570\u914d\u7f6e\u8be6\u60c5\u53ef\u53c2\u8003\u901a\u7528\u53c2\u6570\u914d\u7f6e
\u5f53\u6211\u60f3\u5c06 MatrixOne \u7684\u6570\u636e\u76ee\u5f55\u4fdd\u5b58\u5230\u6211\u6307\u5b9a\u7684\u6587\u4ef6\u76ee\u5f55\u4e2d\uff0c\u6211\u5e94\u8be5\u5982\u4f55\u64cd\u4f5c\uff1f
\u5f53\u4f60\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne\uff0c\u4f60\u53ef\u4ee5\u5c06\u4f60\u6307\u5b9a\u7684\u6570\u636e\u76ee\u5f55\u6302\u8f7d\u81f3 Docker \u5bb9\u5668\uff0c\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
\u5f53\u4f60\u4f7f\u7528\u6e90\u7801\u6216\u4e8c\u8fdb\u5236\u5305\u7f16\u8bd1\u5e76\u542f\u52a8 MatrixOne\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u9ed8\u8ba4\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a\u6253\u5f00 MatrixOne \u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 matrixone/etc/launch-with-proxy
\uff0c\u4fee\u6539 cn.toml
\u3001tn.toml
\u548c log.toml
\u4e09\u4e2a\u6587\u4ef6\u5185\u7684\u914d\u7f6e\u53c2\u6570 data-dir = \"./mo-data\"
\u4e3a data-dir = \"your_local_path\"
\uff0c\u4fdd\u5b58\u540e\u91cd\u542f MatrixOne \u5373\u53ef\u751f\u6548\u3002
\u4e8c\u8fdb\u5236\u5305\u5b89\u88c5\u53ef\u4ee5\u901a\u8fc7 mo_ctl \u7ba1\u7406\u5417\uff1f
\u901a\u8fc7\u8bbe\u7f6e MO_PATH \u914d\u7f6e\u4e8c\u8fdb\u5236\u5305\u7684\u8def\u5f84\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528 mo_ctl \u8fdb\u884c\u7ba1\u7406\u4e86\u3002
mo_ctl \u5de5\u5177\u662f\u5426\u652f\u6301\u6e90\u7801\u90e8\u7f72\u5347\u7ea7
\u901a\u8fc7 upgrade \u547d\u4ee4\u53ef\u4ee5\u6307\u5b9a\u5bf9\u5e94\u7684\u7248\u672c\u6216\u8005 commitid \u8fdb\u884c\u7ec6\u7c92\u5ea6\u5347\u7ea7\uff0c\u9700\u8981\u6ce8\u610f\u7684\u8bbe\u7f6e\u5f53\u524d\u7248\u672c MO_PATH\uff0c\u4ee5\u53ca\u7f16\u8bd1\u73af\u5883\u3002
mo_ctl \u5de5\u5177\u662f\u5426\u652f\u6301\u90e8\u7f72 matrixOne \u96c6\u7fa4
\u5f53\u524d\u8fd8\u4e0d\u652f\u6301\uff0c\u540e\u7eed\u8003\u8651\u52a0\u5165\u96c6\u7fa4\u90e8\u7f72\u548c\u7ba1\u7406\u3002
helm \u5b89\u88c5 operator\uff0c\u600e\u4e48\u6837\u770b\u662f\u5426\u5b89\u88c5\u6210\u529f\u4e86\uff1f
\u4f7f\u7528 helm list -A \u5c31\u53ef\u4ee5\u67e5\u770b\u3002
helm \u65b9\u5f0f\u90e8\u7f72\u7684 operator \u5982\u4f55\u8fdb\u884c\u5378\u8f7d\uff1f
\u901a\u8fc7 helm uninstall \u547d\u4ee4\u6307\u5b9a\u540d\u79f0\u548c\u547d\u540d\u7a7a\u95f4\u8fdb\u884c\u5378\u8f7d\u3002
operator \u7684\u7248\u672c\u5728\u90e8\u7f72\u7684\u662f\u5426\u6709\u8981\u6c42\uff1f
operator \u662f\u7528\u6765\u7ba1\u7406 matrixOne \u96c6\u7fa4\u7684\uff0c\u6240\u4ee5 operator \u7248\u672c\u5c3d\u91cf\u4e0e\u96c6\u7fa4\u7684\u7248\u672c\u4fdd\u6301\u4e00\u81f4\uff0c\u6bd4\u5982\u6211\u4eec\u5b89\u88c5\u4e86 1.0.0-rc2 \u8fd9\u4e2a\u7248\u672c\u7684\u96c6\u7fa4\uff0c\u5bf9\u5e94\u63d0\u524d\u5b89\u88c5\u7684 operator \u7248\u672c\u4e5f\u5e94\u8be5\u4e3a 1.0.0-rc2\u3002\u5982\u672a\u627e\u5230\u7248\u672c\u4e00\u81f4\u7684 operator\uff0c\u5efa\u8bae\u4f7f\u7528\u76f8\u8fd1\u7248\u672c\u7684 operator\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/#_6","title":"\u62a5\u9519\u76f8\u5173","text":"\u5f53\u6211\u5b89\u88c5\u5b8c\u6210 MySQL \u5ba2\u6237\u7aef\u540e\uff0c\u6253\u5f00\u7ec8\u7aef\u8fd0\u884c mysql
\u4ea7\u751f\u62a5\u9519 command not found: mysql
\uff0c\u6211\u8be5\u5982\u4f55\u89e3\u51b3\uff1f
\u4ea7\u751f\u8fd9\u4e2a\u62a5\u9519\u662f\u73af\u5883\u53d8\u91cf\u672a\u8bbe\u7f6e\u7684\u539f\u56e0\uff0c\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
Linux \u73af\u5883MacOS \u73af\u5883echo 'export PATH=\"/path/to/mysql/bin:$PATH\"' >> ~/.bash_profile\nsource ~/.bash_profile\n
\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684/path/to/mysql/bin
\u66ff\u6362\u4e3a\u4f60\u7cfb\u7edf\u4e2d MySQL \u7684\u5b89\u88c5\u8def\u5f84\u3002\u4e00\u822c\u662f /usr/local/mysql/bin
, \u5982\u679c\u4f60\u4e0d\u786e\u5b9a MySQL \u7684\u5b89\u88c5\u8def\u5f84\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u627e\u5230\uff1a
whereis mysql\n
macOS 10 \u4e4b\u540e\u5c06 zsh
\u4f5c\u4e3a\u9ed8\u8ba4 shell
\uff0c\u6b64\u5904\u4f7f\u7528zsh\u505a\u793a\u4f8b\uff0c\u82e5\u4f7f\u7528\u5176\u4ed6 shell
\u53ef\u81ea\u884c\u8f6c\u6362\u3002
echo export PATH=/path/to/mysql/bin:$PATH >> ~/.zshrc\nsource ~/.zshrc\n
\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684/path/to/mysql/bin
\u66ff\u6362\u4e3a\u4f60\u7cfb\u7edf\u4e2d MySQL \u7684\u5b89\u88c5\u8def\u5f84\u3002\u4e00\u822c\u662f /usr/local/mysql/bin
, \u5982\u679c\u4f60\u4e0d\u786e\u5b9a MySQL \u7684\u5b89\u88c5\u8def\u5f84\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u627e\u5230\uff1a
whereis mysql\n
\u5f53\u6211\u5b89\u88c5\u9009\u62e9\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u6784\u5efa MatrixOne \u65f6\uff0c\u4ea7\u751f\u4e86\u4ee5\u4e0b\u9519\u8bef\u6216\u6784\u5efa\u5931\u8d25\u63d0\u793a\uff0c\u6211\u8be5\u5982\u4f55\u7ee7\u7eed\uff1f
\u62a5\u9519\uff1aGet \"https://proxy.golang.org/........\": dial tcp 142.251.43.17:443: i/o timeout
\u7531\u4e8e MatrixOne \u9700\u8981\u8bb8\u591a GO \u5e93\u4f5c\u4e3a\u4f9d\u8d56\u9879\uff0c\u6240\u4ee5\u5b83\u5728\u6784\u5efa\u65f6\uff0c\u4f1a\u540c\u65f6\u4e0b\u8f7d GO \u5e93\u3002\u4e0a\u8ff0\u6240\u793a\u7684\u62a5\u9519\u662f\u4e0b\u8f7d\u8d85\u65f6\u7684\u9519\u8bef\uff0c\u4e3b\u8981\u539f\u56e0\u662f\u7f51\u7edc\u95ee\u9898\u3002
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u9700\u8981\u8bbe\u7f6e\u4f60\u7684 GO \u73af\u5883\u5230\u4e00\u4e2a\u4e2d\u56fd\u7684\u955c\u50cf\u7f51\u7ad9\uff0c\u4ee5\u52a0\u5feb GO \u5e93\u7684\u4e0b\u8f7d\u3002
\u5982\u679c\u4f60\u901a\u8fc7 go env
\u68c0\u67e5\u4f60\u7684 GO \u73af\u5883\uff0c\u4f60\u53ef\u80fd\u4f1a\u770b\u5230 GOPROXY=\"https://proxy.golang.org,direct\"
\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u8fdb\u884c\u4e0b\u9762\u8bbe\u7f6e\uff1a
go env -w GOPROXY=https://goproxy.cn,direct\n
\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0cmake build
\u5e94\u8be5\u5f88\u5feb\u5c31\u80fd\u5b8c\u6210\u3002
\u5f53\u6211\u901a\u8fc7 MO-Tester \u5bf9 MatrixOne \u8fdb\u884c\u6d4b\u8bd5\u65f6\uff0c\u6211\u5982\u4f55\u89e3\u51b3\u4ea7\u751f\u7684 too many open files
\u9519\u8bef\uff1f
\u4e3a\u4e86\u5bf9 MatrixOne \u8fdb\u884c\u6d4b\u8bd5\uff0cMO-Tester \u4f1a\u5feb\u901f\u5730\u6253\u5f00\u548c\u5173\u95ed\u8bb8\u591a SQL \u6587\u4ef6\uff0c\u4e8e\u662f\u5f88\u5feb\u5c31\u8fbe\u5230 Linux \u548c MacOS \u7cfb\u7edf\u7684\u6700\u5927\u6253\u5f00\u6587\u4ef6\u9650\u5236\uff0c\u8fd9\u5c31\u662f\u5bfc\u81f4 too many open files
\u9519\u8bef\u7684\u539f\u56e0\u3002
ulimit -n 65536\n
\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u5c06\u4e0d\u4f1a\u51fa\u73b0 too many open files
\u9519\u8bef\u3002
\u6211\u7684 PC \u662f M1 \u82af\u7247\uff0c\u5f53\u6211\u8fdb\u884c SSB \u6d4b\u8bd5\u65f6\uff0c\u53d1\u73b0\u65e0\u6cd5\u7f16\u8bd1\u6210\u529f ssb-dbgen
\u786c\u4ef6\u914d\u7f6e\u4e3a M1 \u82af\u7247\u7684 PC \u5728\u7f16\u8bd1 ssb-dbgen
\u4e4b\u524d\uff0c\u8fd8\u9700\u8981\u8fdb\u884c\u5982\u4e0b\u914d\u7f6e\uff1a
\u4e0b\u8f7d\u5e76\u5b89\u88c5 GCC11\u3002
\u8f93\u5165\u547d\u4ee4\uff0c\u786e\u8ba4 gcc-11 \u662f\u5426\u6210\u529f\uff1a
gcc-11 -v\n
\u5982\u4e0b\u7ed3\u679c\uff0c\u8868\u793a\u6210\u529f\uff1a
Using built-in specs.\nCOLLECT_GCC=gcc-11\nCOLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc@11/11.3.0/bin/../libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper\nTarget: aarch64-apple-darwin21\nConfigured with: ../configure --prefix=/opt/homebrew/opt/gcc@11 --libdir=/opt/homebrew/opt/gcc@11/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.3.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --build=aarch64-apple-darwin21 --with-system-zlib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk\nThread model: posix\nSupported LTO compression algorithms: zlib zstd\ngcc version 11.3.0 (Homebrew GCC 11.3.0)\n
\u624b\u52a8\u4fee\u6539 ssb-dbgen \u76ee\u5f55\u4e0b\u7684 bm_utils.c \u914d\u7f6e\u6587\u4ef6\uff1a
\u5c06\u7b2c 41 \u884c\u7684 #include <malloc.h>
\u4fee\u6539\u4e3a #include <sys/malloc.h>
\u5c06\u7b2c 398 \u884c\u7684 open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT|O_LARGEFILE,0644);
\u4fee\u6539\u4e3a open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT,0644);
\u624b\u52a8\u4fee\u6539 ssb-dbgen \u76ee\u5f55\u4e0b\u7684 varsub.c \u914d\u7f6e\u6587\u4ef6\uff1a
#include <malloc.h>
\u4fee\u6539\u4e3a #include <sys/malloc.h>
\u624b\u52a8\u4fee\u6539 ssb-dbgen \u76ee\u5f55\u4e0b\u7684 makefile \u914d\u7f6e\u6587\u4ef6\uff1a
CC = gcc
\u4fee\u6539\u4e3a CC = gcc-11
\u518d\u6b21\u8fdb\u5165 ssb-dbgen \u76ee\u5f55\uff0c\u8fdb\u884c\u7f16\u8bd1\uff1a
cd ssb-dbgen\nmake\n
\u67e5\u770b ssb-dbgen \u76ee\u5f55\uff0c\u751f\u6210 dbgen \u53ef\u6267\u884c\u6587\u4ef6\uff0c\u8868\u793a\u7f16\u8bd1\u6210\u529f\u3002
\u6211\u5148\u5728 main \u5206\u652f\u6784\u5efa\u4e86 MatrixOne\uff0c\u73b0\u5728\u5207\u6362\u5230\u5176\u4ed6\u7248\u672c\u518d\u8fdb\u884c\u6784\u5efa\u51fa\u73b0 panic
\u5f53 MatrixOne \u7248\u672c\u5207\u6362\u6d89\u53ca\u5230 0.8.0 \u4e4b\u524d\u7684\u7248\u672c\u5e76\u4e14\u4f7f\u7528 make build
\u547d\u4ee4\u7684\u65f6\u5019\u53ef\u80fd\u4f1a\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u662f MatrixOne \u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5347\u7ea7\u9020\u6210\u7684\u4e0d\u517c\u5bb9\u95ee\u9898\uff0c\u4f46\u81ea 0.8.0 \u7684\u7248\u672c\u5f00\u59cb\u4f1a\u6301\u7eed\u517c\u5bb9\u3002
Note
\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5f3a\u70c8\u5efa\u8bae\u4f60\u91cd\u65b0\u5b89\u88c5\u6700\u65b0\u7a33\u5b9a\u7248\u7684 MatrixOne \u7248\u672c\u4ee5\u5b9e\u73b0\u540e\u7eed\u7684\u6570\u636e\u517c\u5bb9\uff0c\u540c\u65f6\u63a8\u8350\u4f7f\u7528 mo_ctl \u5de5\u5177\u8fdb\u884c\u5feb\u901f\u6784\u5efa\u548c\u542f\u52a8\u3002
\u5177\u4f53\u6765\u8bf4\uff0c\u5728 MatrixOne \u7248\u672c 0.8.0 \u4e4b\u524d\u65f6\uff0c\u6267\u884c make build
\u540e\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u540d\u4e3a mo-data \u7684\u6570\u636e\u76ee\u5f55\u6587\u4ef6\uff0c\u7528\u4e8e\u5b58\u653e\u6570\u636e\u3002\u5982\u679c\u4f60\u518d\u5207\u6362\u5230\u5176\u4ed6\u5206\u652f\u4e0a\u5e76\u91cd\u65b0\u8fdb\u884c make build
\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u5e76\u4e0d\u4f1a\u81ea\u52a8\u5220\u9664 mo-data \u6570\u636e\u76ee\u5f55\uff0c\u6b64\u65f6\u7531\u4e8e\u6570\u636e\u683c\u5f0f\u4e0d\u517c\u5bb9\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4 panic \u60c5\u51b5\u53d1\u751f\u3002
\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f60\u9700\u8981\u5148\u6e05\u7406 mo-data \u6570\u636e\u76ee\u5f55\uff08\u5373\u6267\u884c rm -rf mo-data
\u547d\u4ee4\uff09\uff0c\u7136\u540e\u518d\u91cd\u65b0\u6784\u5efa MatrixOne\u3002
\u4ee5\u4e0b\u53c2\u8003\u4ee3\u7801\u793a\u4f8b\u4f7f\u7528\u8f83\u65e9\u7684\u6784\u5efa\u6d41\u7a0b\uff1a
[root ~]# cd matrixone // \u8fdb\u5165 matrixone \u6587\u4ef6\u76ee\u5f55\n[root ~]# git branch // \u67e5\u770b\u5f53\u524d\u5206\u652f\n* 0.8.0\n[root ~]# make build // \u6784\u5efa matrixone\n... // \u6b64\u5904\u7701\u7565\u6784\u5efa\u8fc7\u7a0b\u4ee3\u7801\u3002\u5982\u679c\u4f60\u6b64\u65f6\u60f3\u8981\u5207\u6362\u5230\u5176\u4ed6\u7248\u672c\uff0c\u4f8b\u5982 0.7.0 \u7248\u672c\n[root ~]# git checkout 0.7.0 // \u5207\u6362\u5230 0.7.0 \u7248\u672c\n[root ~]# rm -rf mo-data // \u6e05\u7406\u6570\u636e\u76ee\u5f55\n[root ~]# make build // \u6784\u5efa matrixone\n... // \u6b64\u5904\u7701\u7565\u6784\u5efa\u8fc7\u7a0b\u4ee3\u7801\n
\u6211\u4f7f\u7528\u5e26 CN \u6807\u7b7e\u7684\u65b9\u5f0f\u8fde proxy\uff0c\u767b\u5f55 MatrixOne \u96c6\u7fa4\u51fa\u73b0\u5bc6\u7801\u9a8c\u8bc1\u9519\u8bef\u7684\u63d0\u793a
\u95ee\u9898\u539f\u56e0\uff1a\u8fde\u63a5\u5b57\u7b26\u4e32\u4e66\u5199\u6709\u8bef\u3002\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u652f\u6301\u6269\u5c55\u7528\u6237\u540d\uff08username\uff09\u5b57\u6bb5\uff0c\u5728\u7528\u6237\u540d\uff08username\uff09\u540e\u6dfb\u52a0 ?
\uff0c?
\u540e\u53ef\u4ee5\u8ddf\u968f CN \u7ec4\u6807\u7b7e\uff0cCN \u7ec4\u6807\u7b7e\u7684 key \u548c value \u4e4b\u95f4\u7528 =
\u95f4\u9694\uff0c\u591a\u4e2a key-value \u4e4b\u95f4\u7528\u9017\u53f7 ,
\u95f4\u9694\u3002
\u89e3\u51b3\u65b9\u6cd5\uff1a\u8bf7\u53c2\u8003\u4ee5\u4e0b\u793a\u4f8b\u3002
\u5047\u8bbe\u5728\u4f60\u7684 MatrixOne \u7684 mo.yaml
\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0cCN \u7ec4\u7684\u914d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a
## \u4ec5\u5c55\u793a\u90e8\u5206\u4ee3\u7801\n...\n- cacheVolume:\nsize: 100Gi\ncnLabels:\n- key: workload\nvalues:\n- bk\n...\n
\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u793a\u4f8b\uff1amysql -u root?workload=bk -p111 -h 10.206.16.10 -P 31429
\u3002\u5176\u4e2d\uff0cworkload=bk
\u4e3a CN \u6807\u7b7e\uff0c\u4f7f\u7528 =
\u8fde\u63a5\u3002
\u5b89\u88c5\u6700\u65b0\u7684 operator\uff0c\u4e00\u76f4\u6709\u4e00\u4e2a\u53eb job-bucket \u7684 pod \u8d77\u4e0d\u6765\uff0c\u8bf7\u95ee\u5e94\u8be5\u600e\u4e48\u6392\u67e5\uff1f
\u53ef\u4ee5\u770b\u770b\u662f\u5426\u6ca1\u6709 secret\u3002\u53ef\u80fd\u662f\u6ca1\u6709\u914d\u7f6e minio \u8fde\u63a5\u4fe1\u606f\u5bfc\u81f4\u6ca1\u529e\u6cd5\u8fde\u63a5 minio\u3002
\u540c\u7406\uff0c\u4f7f\u7528 mo-dump
\u5de5\u5177\u5bfc\u51fa\u6570\u636e\u7684\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u793a\u4f8b\uff1amo-dump -u \"dump?workload=bk\" -h 10.206.16.10 -P 31429 -db tpch_10g > /tmp/mo/tpch_10g.sql
\u3002
\u4ec0\u4e48\u662f MatrixOne\uff1f
MatrixOne \u662f\u4e00\u6b3e\u9762\u5411\u672a\u6765\u7684\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0c\u901a\u8fc7\u8d85\u878d\u5408\u6570\u636e\u5f15\u64ce\u652f\u6301\u4e8b\u52a1/\u5206\u6790/\u6d41\u5904\u7406\u7b49\u6df7\u5408\u5de5\u4f5c\u8d1f\u8f7d\uff0c\u901a\u8fc7\u5f02\u6784\u4e91\u539f\u751f\u67b6\u6784\u652f\u6301\u8de8\u673a\u623f\u534f\u540c/\u591a\u5730\u534f\u540c/\u4e91\u8fb9\u534f\u540c\u3002MatrixOne \u5e0c\u671b\u7b80\u5316\u6570\u636e\u7cfb\u7edf\u5f00\u53d1\u548c\u8fd0\u7ef4\u7684\u6210\u672c\uff0c\u6d88\u51cf\u590d\u6742\u7cfb\u7edf\u95f4\u7684\u6570\u636e\u788e\u7247\uff0c\u6253\u7834\u6570\u636e\u878d\u5408\u7684\u5404\u79cd\u8fb9\u754c\u3002 \u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e MatrixOne \u7684\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u6d4f\u89c8 MatrixOne \u7b80\u4ecb\u3002
MatrixOne \u662f\u57fa\u4e8e MySQL \u6216\u8005\u5176\u4ed6\u6570\u636e\u5e93\u5f00\u53d1\u7684\u5417\uff1f
MatrixOne \u662f\u4e00\u4e2a\u4ece\u96f6\u6253\u9020\u7684\u5168\u65b0\u6570\u636e\u5e93\u3002MatrixOne \u517c\u5bb9 MySQL \u7684\u90e8\u5206\u8bed\u6cd5\u4e0e\u8bed\u4e49\uff0c\u5e76\u4e14\u5728\u672a\u6765\u5c06\u4f1a\u4ea7\u751f\u66f4\u591a\u4e0e MySQL \u4e0d\u540c\u7684\u8bed\u4e49\uff0c\u4ee5\u4fbf\u6211\u4eec\u5c06\u4e4b\u6253\u9020\u4e3a\u4e00\u6b3e\u66f4\u5f3a\u5927\u7684\u8d85\u878d\u5408\u6570\u636e\u5e93\u3002 \u5173\u4e8e\u4e0e MySQL \u7684\u517c\u5bb9\u6027\uff0c\u60a8\u53ef\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u3002
MatrixOne \u4f7f\u7528\u4ec0\u4e48\u7f16\u7a0b\u8bed\u8a00\u5f00\u53d1\u7684\uff1f
MatrixOne \u76ee\u524d\u4e3b\u8981\u4f7f\u7528 Golang \u4f5c\u4e3a\u6700\u4e3b\u8981\u7684\u7f16\u7a0b\u8bed\u8a00\u3002
\u76ee\u524d\u8fde\u63a5 MatrixOne \u652f\u6301\u54ea\u4e9b\u7f16\u7a0b\u8bed\u8a00\uff1f
MatrixOne \u652f\u6301 Java\u3001Python\u3001Golang \u8bed\u8a00\u548c ORM \u8fde\u63a5\uff0c\u5176\u4ed6\u8bed\u8a00\u4e5f\u53ef\u4ee5\u5c06 MO \u5f53\u4f5c MySQL \u6765\u8fdb\u884c\u8fde\u63a5\u3002
MatrixOne \u5217\u5b58\u4f7f\u7528\u4ec0\u4e48\u538b\u7f29\u7b97\u6cd5\uff1f
MatrixOne \u5217\u5b58\u76ee\u524d\u4f7f\u7528\u7684\u662f LZ4 \u538b\u7f29\u7b97\u6cd5\uff0c\u4e14\u4e0d\u652f\u6301\u901a\u8fc7\u914d\u7f6e\u4fee\u6539\u3002
\u8bf7\u95ee\u4f4e\u7248\u672c\u80fd\u5426\u5347\u7ea7\u5230\u6700\u65b0\u7684\u7248\u672c\uff1f
MatrixOne 0.8.0 \u53ca\u4ee5\u4e0a\u7248\u672c\u7686\u53ef\u4f7f\u7528 mo_ctl upgrade latest
\u4ece\u4f4e\u7248\u672c\u76f4\u63a5\u5347\u7ea7\u81f3\u6700\u65b0\u7248\u672c\uff0c\u60a8\u53ef\u53c2\u8003 mo_ctl \u5de5\u5177\u30020.8.0 \u4e4b\u524d\u7684\u7248\u672c\u5982\u6709\u5347\u7ea7\u9700\u8981\uff0c\u5efa\u8bae\u5907\u4efd\u6570\u636e\uff0c\u8fdb\u884c\u91cd\u88c5\u540e\u5bfc\u5165\u3002
\u73b0\u5728 MatrixOne \u53d1\u7a33\u5b9a\u7248\u4e86\u5417\uff1f\u63a8\u8350\u4f7f\u7528\u54ea\u4e2a\u7248\u672c\uff1f
MatrixOne \u73b0\u5df2\u53d1\u5e03 1.2.1 \u7248\u672c\uff0c\u5728\u7a33\u5b9a\u6027\u4e0a\u6211\u4eec\u505a\u4e86\u5927\u91cf\u7684\u4f18\u5316\u5de5\u4f5c\uff0c\u5df2\u7ecf\u53ef\u4ee5\u7528\u4e8e\u751f\u4ea7\u4e1a\u52a1\uff0c\u6b22\u8fce\u5927\u5bb6\u8bd5\u7528\u53cd\u9988\u3002
\u6709\u6ca1\u6709 MatrixOne \u4e91\u7248\u672c\uff1f\u60f3\u5feb\u901f\u6d4b\u8bd5\u770b\u770b
\u6709\u7684\u3002\u73b0 mo cloud \u5df2\u7ecf\u5f00\u59cb\u516c\u6d4b\u3002\u8be6\u60c5\u67e5\u770b MatrixOne Cloud \u6587\u6863
"},{"location":"MatrixOne/FAQs/product-faqs/#_3","title":"\u67b6\u6784\u76f8\u5173","text":"MatrixOne \u7684\u6743\u9650\u4e5f\u662f\u57fa\u4e8e RBAC \u6a21\u578b\u8bbe\u8ba1\u7684\u5417\uff1f\u53ef\u4e0d\u53ef\u4ee5\u5c06\u6743\u9650\u76f4\u63a5\u6388\u4e88\u5230\u7528\u6237\uff1f
MatrixOne \u7684\u6743\u9650\u7ba1\u7406\u662f\u7ed3\u5408\u4e86\u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236 (RBAC\uff0cRole-based access control) \u548c\u81ea\u4e3b\u8bbf\u95ee\u63a7\u5236 (DAC\uff0cDiscretionary access control) \u4e24\u79cd\u5b89\u5168\u6a21\u578b\u8bbe\u8ba1\u548c\u5b9e\u73b0\u7684\uff0c\u4e0d\u652f\u6301\u5c06\u6743\u9650\u76f4\u63a5\u6388\u4e88\u7528\u6237\uff0c\u9700\u8981\u901a\u8fc7\u89d2\u8272\u8fdb\u884c\u6388\u6743\u3002
\u9ad8\u53ef\u7528\u67b6\u6784\u8981\u600e\u4e48\u7528\uff1f
MatrixOne \u7684\u5355\u673a\u7248\u76ee\u524d\u8fd8\u6ca1\u6709\u9ad8\u53ef\u7528\u67b6\u6784\uff0c\u4e3b\u4ece\u7248\u7684\u9ad8\u53ef\u7528\u67b6\u6784\u8fd8\u5728\u8bbe\u8ba1\u4e2d\u3002\u5206\u5e03\u5f0f\u7248\u672c\u6765\u5c31\u662f\u9ad8\u53ef\u7528\u7684\uff0ck8s \u548c s3 \u672c\u6765\u5c31\u90fd\u662f\u9ad8\u53ef\u7528\u67b6\u6784\u3002MatrixOne \u7684\u8282\u70b9\u91cc cn \u548c tn \u90fd\u662f\u65e0\u72b6\u6001\u7684\uff0c\u6302\u4e86\u53ef\u4ee5\u968f\u65f6\u62c9\u8d77\uff0clog service \u6709\u72b6\u6001\uff0c\u5b83\u7684 3 \u8282\u70b9\u662f\u63d0\u4f9b\u4e00\u4e2a raft group \u7684\u5206\u5e03\u5f0f\u67b6\u6784\uff0c\u6302 1 \u4e2a\u6ca1\u5173\u7cfb\uff0c\u7ee7\u7eed\u8fd0\u884c\uff0c\u6302 2 \u4e2a\u7cfb\u7edf\u624d\u4f1a\u4e0d\u53ef\u7528\u3002
k8s \u96c6\u7fa4\u8282\u70b9\u5f53\u524d tn \u8282\u70b9\u662f\u5426\u652f\u6301\u6269\u5bb9\uff1f
MatrixOne \u5f53\u524d tn \u8282\u70b9\u8fd8\u4e0d\u652f\u6301\u6269\u5bb9\u3002
\u5404\u4e2a\u7ec4\u4ef6\u90fd\u662f\u505a\u4ec0\u4e48\u7528\u7684\uff1f\u6700\u5c0f\u5316\u9700\u8981\u90e8\u7f72\u90fd\u591a\u5c11\u4e2a\u5b9e\u4f8b\uff1f\u540e\u671f\u80fd\u652f\u6301\u4e0d\u505c\u670d\u65e0\u611f\u6269\u5bb9\u5417\uff1f
MatrixOne \u6838\u5fc3\u7684\u7ec4\u4ef6\u6709 4 \u4e2a\uff0cproxy\uff0ccn\uff0ctn\uff0clog service\u3002cn \u5c31\u662f\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9\uff0ctn \u662f\u4e8b\u52a1\u8282\u70b9\uff0clog service \u662f\u4e8b\u52a1\u7684\u65e5\u5fd7\uff0c\u76f8\u5f53\u4e8e WAL\u3002proxy \u662f\u7528\u6765\u505a\u8d1f\u8f7d\u5747\u8861\u548c\u8d44\u6e90\u7ec4\u7ba1\u7406\u7684\u3002\u5982\u679c\u90fd\u6df7\u5408\u90e8\u7f72\u7684\u8bdd\u53ef\u4ee5\u5728 3 \u53f0\u7269\u7406\u673a/\u865a\u62df\u673a\u641e\u5b9a\u3002\u53ef\u4ee5\u65e0\u611f\u6269\u5bb9\uff0cmo \u662f\u5b58\u7b97\u5206\u79bb\u7684\uff0c\u5b58\u50a8\u7684\u6269\u5bb9\u5c31\u662f s3 \u7684\u6269\u5bb9\u3002\u8ba1\u7b97\u7684\u6269\u5bb9\u5c31\u662f cn\uff0c\u672c\u8eab\u57fa\u4e8e k8s\uff0ccn \u65e0\u72b6\u6001\uff0c\u800c\u4e14\u662f\u5bb9\u5668\uff0c\u53ef\u4ee5\u5feb\u901f\u6269\u5bb9\u3002
\u591a\u79df\u6237\u4e4b\u95f4\u662f\u5982\u4f55\u5b9e\u73b0\u8d44\u6e90\u9694\u79bb\u7684\uff1f
MatrixOne \u7684\u8d44\u6e90\u9694\u79bb\u6838\u5fc3\u662f ACCOUNT \u53ef\u4ee5\u5bf9\u5e94\u5230 CN Set \u7684\u8d44\u6e90\u7ec4\u4e0a\uff0c\u6216\u8005\u53ef\u4ee5\u8ba4\u4e3a\u79df\u6237\u7684\u9694\u79bb\u5c31\u662f CN \u7684\u5bb9\u5668\u9694\u79bb\u3002\u9664\u4e86\u591a\u79df\u6237\u53ef\u4ee5\u5206\u914d\u4e0d\u540c\u8d44\u6e90\u7ec4\u4ee5\u5916\uff0c\u5355\u4e2a\u79df\u6237\u5185\u90e8\u4e5f\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u7c7b\u578b\u8fdb\u4e00\u6b65\u5206\u914d CN \u8d44\u6e90\u7ec4\uff0c\u8fdb\u884c\u66f4\u7ec6\u7c92\u5ea6\u7684\u63a7\u5236\u3002\u5173\u4e8e\u8d44\u6e90\u9694\u79bb\u7684\u5b8c\u6574\u63cf\u8ff0\uff0c\u60a8\u53ef\u53c2\u89c1\u8d1f\u8f7d\u4e0e\u79df\u6237\u9694\u79bb
MySQL \u4e2d\u7684\u8868\u5f15\u64ce\u80fd\u76f4\u63a5\u8fc1\u79fb\u5417\uff1f\u517c\u5bb9 InnoDB \u7b49\u5f15\u64ce\u5417\uff1f
MatrixOne \u4e0d\u652f\u6301 MySQL \u7684 InnoDB\uff0cMyISAM \u7b49\u5f15\u64ce\uff0c\u4f46\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 MySQL \u7684\u8bed\u53e5\uff0cMatrixOne \u4f1a\u5ffd\u7565\u8fd9\u4e9b\u5f15\u64ce\uff0c\u5728 MatrixOne \u4e2d\u4ec5\u6709 TAE \u4e00\u79cd\u5b58\u50a8\u5f15\u64ce\uff0c\u5b83\u662f\u5b8c\u5168\u72ec\u7acb\u7814\u53d1\u7684\uff0c\u53ef\u4ee5\u53cb\u597d\u7684\u9002\u7528\u4e8e\u5404\u7c7b\u573a\u666f\uff0c\u65e0\u9700\u4f7f\u7528 ENGINE=XXX \u6765\u66f4\u6362\u5f15\u64ce\u3002
"},{"location":"MatrixOne/FAQs/product-faqs/#_4","title":"\u529f\u80fd\u76f8\u5173","text":"MatrxOne \u652f\u6301\u54ea\u4e9b\u5e94\u7528\uff1f
MatrixOne \u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u6781\u81f4\u7684 HTAP \u670d\u52a1\uff0cMatrixOne \u53ef\u4ee5\u88ab\u5e94\u7528\u5728\u4f01\u4e1a\u6570\u636e\u4e2d\u53f0\uff0c\u5927\u6570\u636e\u5206\u6790\u7b49\u573a\u666f\u4e2d\u3002
MatrixOne \u517c\u5bb9\u54ea\u4e2a\u6570\u636e\u5e93\uff1f
MatrixOne \u5728\u4f7f\u7528\u4e0a\u4fdd\u6301\u5bf9 MySQL 8.0 \u7684\u9ad8\u5ea6\u517c\u5bb9\uff0c\u5305\u62ec SQL \u8bed\u6cd5\uff0c\u4f20\u8f93\u534f\u8bae\uff0c\u64cd\u4f5c\u7b26\u4e0e\u51fd\u6570\u7b49\u7b49\u3002\u4e0e MySQL 8.0 \u517c\u5bb9\u6027\u7684\u5dee\u5f02\u5217\u8868\u53ef\u4ee5\u8be6\u7ec6\u53c2\u8003 MySQL \u517c\u5bb9\u6027\u5217\u8868\u3002
\u5bf9 MySQL \u7684\u517c\u5bb9\u6027\u600e\u4e48\u6837\uff0cBI \u91cc\u76f4\u63a5\u5f53 MySQL \u7528\u5417\uff1f
MatrixOne \u4e0e MySQL 8.0 \u5177\u6709\u9ad8\u5ea6\u7684\u517c\u5bb9\u6027\uff0c\u65e0\u8bba\u5728\u901a\u4fe1\u534f\u8bae\uff0cSQL \u8bed\u6cd5\uff0c\u8fde\u63a5\u5de5\u5177\uff0c\u8fd8\u662f\u5f00\u53d1\u6a21\u5f0f\u4e0a\uff0c\u90fd\u4e0e MySQL \u57fa\u672c\u4e00\u81f4\u3002\u7ba1\u7406\u548c\u751f\u6001\u5de5\u5177\u5f88\u591a\u4e5f\u90fd\u53ef\u4ee5\u590d\u7528 MySQL \u7684\u5de5\u5177\u3002BI \u91cc\u53ef\u4ee5\u76f4\u63a5\u5f53 MySQL \u7528\uff0c\u8be6\u60c5\u8bf7\u53c2\u8003\u901a\u8fc7 FineBI \u5b9e\u73b0 MatrixOne \u7684\u53ef\u89c6\u5316\u62a5\u8868\uff0c\u901a\u8fc7\u6c38\u6d2a BI \u5b9e\u73b0 MatrixOne \u7684\u53ef\u89c6\u5316\u62a5\u8868\uff0c\u901a\u8fc7 Superset \u5b9e\u73b0 MatrixOne \u53ef\u89c6\u5316\u76d1\u63a7\u3002
"},{"location":"MatrixOne/FAQs/product-faqs/#_5","title":"\u6570\u636e\u5e93\u5bf9\u6bd4\u76f8\u5173","text":"MatrixOne \u5355\u673a\u548c MySQL \u6027\u80fd\u5bf9\u6bd4\u5982\u4f55\uff1f
MatrixOne \u5355\u673a\u7248\u672c\u5728 TP \u6027\u80fd\u4e0a\u4e0e MySQL \u76f8\u6bd4\u7565\u5dee\uff0c\u4f46\u5728 Load\uff0c\u6d41\u5f0f\u5199\u5165\uff0c\u5206\u6790\u67e5\u8be2\u4e0a\u6027\u80fd\u8fdc\u8d85\u8fc7 MySQL\u3002
\u4e0e HTAP \u6570\u636e\u5e93 TiDB \u6709\u4ec0\u4e48\u533a\u522b\uff1f
MatrixOne \u4e0e TiDB \u7684\u67b6\u6784\u4e0d\u4e00\u6837\u3002MatrixOne \u662f\u5b58\u7b97\u5206\u79bb\u7684\uff0c\u662f\u57fa\u4e8e\u4e91\u7684 share storage \u67b6\u6784\uff0c\u6570\u636e\u90fd\u5728\u4e00\u4e2a\u5730\u65b9\uff0c\u53ea\u5b58\u4e00\u4efd\uff0c\u662f\u7528\u4e00\u4e2a\u5f15\u64ce\u5b9e\u73b0\u7684 HTAP\u3002\u800c TiDB \u662f Share nothing \u67b6\u6784\uff0c\u6570\u636e\u8981\u5206\u7247\uff0cTiKV \u505a TP\uff0cTiFlash \u505a AP\uff0c\u4f7f\u7528\u4e24\u4e2a\u5f15\u64ce\u52a0\u4e86\u4e2a ETL \u505a\u5230\u7684 HTAP\uff0c\u6570\u636e\u4e5f\u8981\u5b58\u4e24\u4efd\u3002
"},{"location":"MatrixOne/FAQs/product-faqs/#_6","title":"\u5176\u5b83","text":"MatrixOne \u662f\u4e00\u4e2a\u5b8c\u5168\u5728 Github \u4e0a\u8fdb\u884c\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u6b22\u8fce\u6240\u6709\u5f00\u53d1\u8005\u7684\u8d21\u732e\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u6211\u4eec\u7684\u8d21\u732e\u6307\u5357\u3002
\u76ee\u524d\uff0cMatrixOne \u6587\u6863\u662f\u83b7\u53d6 MatrixOne \u76f8\u5173\u77e5\u8bc6\u6700\u91cd\u8981\u3001\u6700\u53ca\u65f6\u7684\u9014\u5f84\u3002\u6b64\u5916\uff0c\u6211\u4eec\u5728 Slack \u548c\u5fae\u4fe1\u8fd8\u6709\u4e00\u4e9b\u6280\u672f\u4ea4\u6d41\u7fa4\u3002\u5982\u6709\u4efb\u4f55\u9700\u6c42\uff0c\u8bf7\u8054\u7cfb opensource@matrixorigin.io\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/","title":"SQL \u5e38\u89c1\u95ee\u9898","text":""},{"location":"MatrixOne/FAQs/sql-faqs/#_1","title":"\u57fa\u672c\u529f\u80fd\u76f8\u5173","text":"MatrixOne \u5bf9\u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u654f\u611f\u5417\uff1f
MatrixOne \u9ed8\u8ba4\u5bf9\u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff0c\u5e76\u652f\u6301\u901a\u8fc7 lower_case_table_names \u53c2\u6570\u6765\u8fdb\u884c\u5927\u5c0f\u5199\u654f\u611f\u7684\u652f\u6301\uff0c\u5bf9\u4e8e\u53c2\u6570\u7684\u8be6\u7ec6\u4ecb\u7ecd\u53ef\u53c2\u89c1\u5927\u5c0f\u5199\u654f\u611f\u652f\u6301
MatrixOne \u652f\u6301\u54ea\u4e9b SQL \u8bed\u53e5\uff1f
MatrixOne \u76ee\u524d\u652f\u6301\u7684 SQL \u8bed\u53e5\u53ef\u4ee5\u53c2\u8003 SQL \u8bed\u53e5\u7684\u5206\u7c7b\u3002
MatrixOne \u652f\u6301\u54ea\u4e9b\u6570\u636e\u7c7b\u578b\uff1f
MatrixOne \u76ee\u524d\u652f\u6301\u5e38\u7528\u7684\u6574\u578b\uff0c\u6d6e\u70b9\u6570\uff0c\u5b57\u7b26\u4e32\uff0c\u65f6\u95f4\u65e5\u671f\uff0c\u5e03\u5c14\uff0c\u679a\u4e3e\uff0c\u4e8c\u8fdb\u5236\uff0cJSON \u7c7b\u578b\uff0c\u8bf7\u53c2\u8003\u6570\u636e\u7c7b\u578b\u6982\u89c8\u3002
MatrixOne \u652f\u6301\u4ec0\u4e48\u7c7b\u578b\u7684\u5b57\u7b26\u96c6\uff1f
MatrixOne \u9ed8\u8ba4\u652f\u6301 UTF-8 \u5b57\u7b26\u96c6\uff0c\u4e14\u76ee\u524d\u53ea\u652f\u6301 UTF-8\u3002
MatrixOne \u652f\u6301\u54ea\u4e9b\u7ea6\u675f\u548c\u7d22\u5f15\uff1f
MatrixOne \u76ee\u524d\u652f\u6301\u4e3b\u952e (Primary Key), \u552f\u4e00 (Unique Key), \u975e\u7a7a (Not Null)\uff0c\u5916\u952e (Foreign Key)\uff0c\u81ea\u589e\u7ea6\u675f (Auto Increment) \u53ca\u6b21\u7ea7\u7d22\u5f15\uff08Secondary Index\uff09\u3002\u6b21\u7ea7\u7d22\u5f15\u76ee\u524d\u4ec5\u5b9e\u73b0\u8bed\u6cd5\u652f\u6301\uff0c\u6ca1\u6709\u52a0\u901f\u4f5c\u7528\u3002 \u53e6\u5916 MatrixOne \u8fd8\u63d0\u4f9b\u4e86\u9488\u5bf9\u65e0\u4e3b\u952e\u8868\u7684\u6392\u5e8f\u952e (Cluster by), \u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u63d0\u524d\u9488\u5bf9\u9700\u8981\u67e5\u8be2\u7684\u5217\u8fdb\u884c\u6392\u5e8f\uff0c\u52a0\u901f\u67e5\u8be2\u3002
MatrixOne \u652f\u6301\u54ea\u4e9b\u67e5\u8be2\u7c7b\u578b\uff1f
MatrixOne \u652f\u6301\u5927\u90e8\u5206\u5e38\u7528 SQL \u67e5\u8be2\uff1a
\u57fa\u7840\u67e5\u8be2\uff1a\u652f\u6301\u5e38\u89c1\u7684\u5206\u7ec4\uff0c\u53bb\u91cd\uff0c\u8fc7\u6ee4\uff0c\u6392\u5e8f\uff0c\u9650\u5b9a\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u7b49\u57fa\u7840\u67e5\u8be2\u80fd\u529b\u3002
\u9ad8\u7ea7\u67e5\u8be2\uff1a\u652f\u6301\u89c6\u56fe\uff0c\u5b50\u67e5\u8be2\uff0c\u8054\u63a5\uff0c\u7ec4\u5408\uff0c\u516c\u5171\u8868\u8868\u8fbe\u5f0f\uff08CTE\uff09\uff0c\u7a97\u53e3\u51fd\u6570\uff0cPrepare \u9884\u5904\u7406\u7b49\u9ad8\u7ea7\u67e5\u8be2\u80fd\u529b\u3002
\u805a\u5408\u51fd\u6570\uff1a\u652f\u6301\u5e38\u89c1\u7684 AVG\uff0cCOUNT\uff0cMIN\uff0cMAX\uff0cSUM \u7b49\u805a\u5408\u51fd\u6570\u3002
\u7cfb\u7edf\u51fd\u6570\u53ca\u64cd\u4f5c\u7b26\uff1a\u652f\u6301\u5e38\u89c1\u7684\u5b57\u7b26\u4e32\uff0c\u65e5\u671f\u65f6\u95f4\uff0c\u6570\u5b66\u51fd\u6570\u53ca\u5e38\u89c1\u64cd\u4f5c\u7b26\u3002
MatrixOne \u6709\u54ea\u4e9b\u4fdd\u7559\u5173\u952e\u5b57\uff1f
MatrixOne \u7684\u4fdd\u7559\u5173\u952e\u5b57\u5217\u8868\u53ef\u53c2\u89c1\u5173\u952e\u5b57\u3002
\u5c06\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\uff0c\u5426\u5219\u5c06\u4ea7\u751f\u62a5\u9519\u3002\u5c06\u975e\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u65e0\u9700\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\u3002
MatrixOne \u652f\u4e0d\u652f\u6301\u7269\u5316\u89c6\u56fe\uff1f
MatrixOne \u76ee\u524d\u4e0d\u652f\u6301\u7269\u5316\u89c6\u56fe\uff0c\u5728\u76ee\u524d\u7684 AP \u6027\u80fd\u652f\u6491\u4e0b\uff0c\u76f4\u63a5\u8fdb\u884c\u5206\u6790\u4e5f\u53ef\u4ee5\u83b7\u5f97\u8f83\u9ad8\u7684\u5206\u6790\u4f53\u9a8c\u3002\u7269\u5316\u89c6\u56fe\u529f\u80fd\u4e5f\u5df2\u7ecf\u5728 MatrixOne \u7684 Roadmap \u4e2d\uff0c\u5982\u679c\u60a8\u5bf9\u7269\u5316\u89c6\u56fe\u6709\u521a\u6027\u8f83\u9ad8\u7684\u9700\u6c42\uff0c\u6b22\u8fce\u7ed9\u6211\u4eec\u63d0 Issue \u6765\u63cf\u8ff0\u60a8\u7684\u573a\u666f\uff1ahttps://github.com/matrixorigin/matrixone/issues
MatrixOne \u652f\u4e0d\u652f\u6301 Geometry\uff1f
\u76ee\u524d\u8fd8\u4e0d\u652f\u6301\uff0c\u540e\u7eed\u4f1a\u652f\u6301\u3002
MatrixOne \u4e2d\u7684\u51fd\u6570\u548c\u5173\u952e\u5b57\u662f\u5426\u533a\u5206\u5927\u5c0f\u5199\uff1f
\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u5728 MatrixOne \u4e2d\uff0c\u53ea\u6709\u4e00\u79cd\u60c5\u51b5\u9700\u8981\u533a\u5206\u5927\u5c0f\u5199\uff1a\u5982\u679c\u4f60\u521b\u5efa\u7684\u8868\u548c\u5c5e\u6027\u5e26\u6709 ``\uff0c`` \u4e2d\u7684\u540d\u79f0\u9700\u8981\u6ce8\u610f\u5927\u5c0f\u5199\u3002\u67e5\u8be2\u8fd9\u4e2a\u8868\u540d\u6216\u5c5e\u6027\u540d\uff0c\u90a3\u4e48\u8868\u540d\u548c\u5c5e\u6027\u540d\u4e5f\u9700\u8981\u88ab\u5305\u542b\u5728``\u91cc\u3002
MatrixOne \u662f\u5426\u652f\u6301\u4e8b\u52a1\uff1f\u652f\u6301\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u662f\u4ec0\u4e48\uff1f
MatrixOne \u652f\u6301 ACID\uff08\u539f\u5b50\u6027\u3001\u4e00\u81f4\u6027\u3001\u9694\u79bb\u6027\u3001\u6301\u4e45\u6027\uff09\u7684\u4e8b\u52a1\u80fd\u529b\uff0c\u652f\u6301\u60b2\u89c2\u548c\u4e50\u89c2\u4e8b\u52a1\uff0c\u9ed8\u8ba4\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u3002\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u7684\u65f6\u5019\u4f1a\u91c7\u7528 Read Committed \u9694\u79bb\u7ea7\u522b\uff0c\u5207\u6362\u6210\u4e50\u89c2\u4e8b\u52a1\u7684\u65f6\u5019\u4f1a\u91c7\u7528 Snapshot Isolation \u9694\u79bb\u7ea7\u522b\u3002
MatrixOne \u4e2d\u7684\u51fd\u6570\u548c\u5173\u952e\u5b57\u662f\u5426\u533a\u5206\u5927\u5c0f\u5199\uff1f
\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u5728 MatrixOne \u4e2d\uff0c\u53ea\u6709\u4e00\u79cd\u60c5\u51b5\u9700\u8981\u533a\u5206\u5927\u5c0f\u5199\uff1a\u5982\u679c\u4f60\u521b\u5efa\u7684\u8868\u548c\u5c5e\u6027\u5e26\u6709 ``\uff0c`` \u4e2d\u7684\u540d\u79f0\u9700\u8981\u6ce8\u610f\u5927\u5c0f\u5199\u3002\u67e5\u8be2\u8fd9\u4e2a\u8868\u540d\u6216\u5c5e\u6027\u540d\uff0c\u90a3\u4e48\u8868\u540d\u548c\u5c5e\u6027\u540d\u4e5f\u9700\u8981\u88ab\u5305\u542b\u5728``\u91cc\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/#_2","title":"\u6570\u636e\u5bfc\u5165/\u5bfc\u51fa\u76f8\u5173","text":"\u5982\u4f55\u5c06\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\uff1f
MatrixOne \u652f\u6301\u4e0e MySQL \u76f8\u540c\u7684 INSERT
\u6570\u636e\u63d2\u5165\u8bed\u53e5\uff0c\u53ef\u4ee5\u901a\u8fc7 INSERT
\u8fdb\u884c\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u540c\u65f6\u4e5f\u652f\u6301 LOAD DATA
\u7684\u79bb\u7ebf\u6279\u91cf\u5bfc\u5165\u8bed\u53e5\u3002
\u5982\u4f55\u5c06\u6570\u636e\u4ece MatrixOne \u5bfc\u51fa\u5230\u6587\u4ef6\uff1f
\u5728 MatrixOne \u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 mo-dump
\u8fd9\u4e2a\u4e8c\u8fdb\u5236\u5de5\u5177\u628a\u6570\u636e\u5bfc\u51fa\u6210 SQL \u6216\u8005 csv \u6587\u4ef6\uff0c\u6216\u8005\u4f7f\u7528 SELECT INTO
\u5bfc\u51fa csv
\u6587\u4ef6\u3002
\u5982\u4f55\u901a\u8fc7 mo-dump \u5de5\u5177\u53ea\u5bfc\u51fa\u8868\u7ed3\u6784\uff1f
\u53ef\u4ee5\u5728\u5bfc\u51fa\u547d\u4ee4\u540e\u52a0-no-data \u53c2\u6570\uff0c\u6307\u5b9a\u4e0d\u5bfc\u51fa\u6570\u636e\u3002
\u4f7f\u7528 load data \u5bfc\u5165\u7684 json \u5bf9\u8c61\u4e2d\u7f3a\u5c11\u67d0\u4e9b\u5b57\u6bb5\uff0c\u5bfc\u5165\u4f1a\u62a5\u9519\u5417\uff1f
\u4f1a\u62a5\u9519\uff0c\u5bfc\u5165 json \u4e2d\uff0c\u5b57\u6bb5\u591a\u4e8e\u8868\u4e2d\u5b57\u6bb5\uff0c\u53ef\u4ee5\u6b63\u5e38\u5bfc\u5165\uff0c\u4e0d\u8fc7\u591a\u51fa\u5b57\u6bb5\u4f1a\u88ab\u5ffd\u7565\uff0c\u5982\u679c\u5c11\u4e8e\u7684\u8bdd\uff0c\u5219\u65e0\u6cd5\u5bfc\u5165\u3002
\u5728\u6267\u884c source \u5bfc\u5165\u7684\u65f6\u5019\u5bfc\u5165\u6587\u4ef6\u662f\u5426\u53ef\u4ee5\u5199\u76f8\u5bf9\u8def\u5f84\uff1f
\u53ef\u4ee5\uff0c\u4f46\u662f\u662f\u76f8\u5bf9\u4e8e\u60a8\u4f7f\u7528 mysql \u5ba2\u6237\u7aef\u7684\u5f53\u524d\u8def\u5f84\uff0c\u9632\u6b62\u51fa\u9519\uff0c\u8fd8\u662f\u5efa\u8bae\u5199\u5168\u8def\u5f84\uff0c\u53e6\u9700\u6ce8\u610f\u6587\u4ef6\u6743\u9650\u95ee\u9898\u3002
\u4f7f\u7528 load data \u547d\u4ee4\u5bfc\u5165\u4e00\u4e2a\u5927\u6587\u4ef6\u65f6\u6bd4\u8f83\u8017\u65f6\uff0c\u80fd\u5426\u4f18\u5316\u5462\uff1f
\u60a8\u53ef\u4ee5\u5728\u5bfc\u5165\u65f6\u5019\u6307\u5b9a PARALLEL \u4e3a true \u5f00\u542f\u5e76\u884c\u5bfc\u5165\uff0c\u4f8b\u5982\uff0c\u5bf9\u4e8e 2 \u4e2a G \u7684\u5927\u6587\u4ef6\uff0c\u4f7f\u7528\u4e24\u4e2a\u7ebf\u7a0b\u53bb\u8fdb\u884c\u52a0\u8f7d\uff0c\u7b2c 2 \u4e2a\u7ebf\u7a0b\u5148\u62c6\u5206\u5b9a\u4f4d\u5230 1G \u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u4e00\u76f4\u5f80\u540e\u8bfb\u53d6\u5e76\u8fdb\u884c\u52a0\u8f7d\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u505a\u5230\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u53d6\u5927\u6587\u4ef6\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u8bfb\u53d6 1G \u7684\u6570\u636e\u3002\u4e5f\u53ef\u4ee5\u81ea\u5df1\u5207\u5206\u6570\u636e\u6587\u4ef6\u3002
load data \u5bfc\u5165\u6709\u4e8b\u52a1\u5417\uff1f
\u6240\u6709\u7684 load \u8bed\u53e5\u90fd\u662f\u6709\u4e8b\u52a1\u7684\u3002
source \u5bfc\u5165 sql \u65f6\u6d89\u53ca\u89e6\u53d1\u5668\u548c\u5b58\u50a8\u8fc7\u7a0b\u4f1a\u6267\u884c\u751f\u6548\u5417\uff1f
\u76ee\u524d\u5982\u679c sql \u4e2d\u5b58\u5728\u4e0d\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3001\u89e6\u53d1\u5668\u3001\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ecd\u9700\u8981\u624b\u52a8\u4fee\u6539\uff0c\u5426\u5219\u6267\u884c\u4f1a\u62a5\u9519\u3002
mo-dump \u652f\u6301\u6279\u91cf\u5bfc\u51fa\u591a\u4e2a\u6570\u636e\u5e93\u5417\uff1f
\u76ee\u524d\u4ec5\u652f\u6301\u5bfc\u51fa\u5355\u4e2a\u6570\u636e\u5e93\u7684\u5907\u4efd\uff0c\u5982\u679c\u4f60\u6709\u591a\u4e2a\u6570\u636e\u5e93\u9700\u8981\u5907\u4efd\uff0c\u9700\u8981\u624b\u52a8\u8fd0\u884c mo-dump \u591a\u6b21\u3002
MatrixOne \u652f\u6301\u4ece Minio \u5bfc\u5165\u6570\u636e\u5417\uff1f
\u662f\u652f\u6301\u7684\uff0cload data \u547d\u4ee4\u652f\u6301\u4ece\u672c\u5730\u6587\u4ef6\u3001S3 \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u4ee5\u53ca S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u4e2d\u5bfc\u5165\u6570\u636e\u5230 matrixone \u4e2d\uff0c \u800c Minio \u4e5f\u662f\u57fa\u4e8e S3 \u534f\u8bae\u7684\uff0c\u6240\u4ee5\u4e5f\u662f\u652f\u6301\u7684\uff0c\u8be6\u60c5\u53c2\u89c1\u672c\u5730\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165\u6570\u636e
MatrixOne \u5bfc\u5165\u5bfc\u51fa\u6570\u636e\u65f6\uff0c\u5982\u679c\u51fa\u73b0\u7f16\u7801\u95ee\u9898\uff0c\u5bfc\u81f4\u6570\u636e\u4e71\u7801\uff0c\u6211\u4eec\u4e00\u822c\u662f\u600e\u4e48\u89e3\u51b3\u7684
\u7531\u4e8e matrixone \u9ed8\u8ba4\u53ea\u652f\u6301 UTF8 \u8fd9\u4e00\u79cd\u7f16\u7801\u4e14\u65e0\u6cd5\u66f4\u6539\uff0c\u6240\u4ee5\u5728\u5bfc\u5165\u6570\u636e\u65f6\u5982\u679c\u51fa\u73b0\u4e86\u4e71\u7801\uff0c\u6211\u4eec\u5c31\u4e0d\u80fd\u901a\u8fc7\u4fee\u6539\u6570\u636e\u5e93\u548c\u8868\u7684\u5b57\u7b26\u96c6\u6765\u89e3\u51b3\uff0c\u53ef\u4ee5\u8bd5\u7740\u8f6c\u6362\u6570\u636e\u7f16\u7801\u4e3a UTF8\u3002\u5e38\u89c1\u7684\u8f6c\u6362\u5de5\u5177\u6709 iconv \u548c recode\uff0c\u6bd4\u5982\uff1a\u5c06 GBK \u7f16\u7801\u7684\u6570\u636e\u8f6c\u6362\u4e3a UTF-8 \u7f16\u7801\uff1aiconv -f GBK -t UTF8 t1.sql > t1_utf8.sql\u3002
MatrixOne \u5bfc\u5165\u5bfc\u51fa\u65f6\uff0c\u9700\u8981\u54ea\u4e9b\u6743\u9650\uff1f
\u5982\u679c\u662f\u79df\u6237\u7ba1\u7406\u5458\u7684\u8bdd\uff0c\u901a\u8fc7\u9ed8\u8ba4\u89d2\u8272\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u5bfc\u5165\u3001\u5bfc\u51fa\u64cd\u4f5c\u3002\u666e\u901a\u7528\u6237\u7684\u8bdd\uff0c\u5bfc\u5165\u65f6\uff0c\u9700\u8981\u5bfc\u5165\u8868\u7684 'insert' \u6743\u9650\uff1bselect...into outfile \u65b9\u5f0f\u5bfc\u51fa\u65f6\uff0c\u9700\u8981\u5bfc\u51fa\u8868\u7684 'select' \u6743\u9650\uff1bmo-dump \u5bfc\u51fa\u65f6\uff0c\u9700\u8981\u6240\u6709\u8868 (table.) \u7684 'select' \u6743\u9650\u548c\u6240\u6709\u5e93 (database.) \u7684 'show tables' \u6743\u9650\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/#_3","title":"\u6743\u9650\u76f8\u5173","text":"\u666e\u901a\u7528\u6237\u80fd\u6388\u4e88 MOADMIN \u89d2\u8272\u5417\uff1f
\u4e0d\u53ef\u4ee5\u7684\uff0cMOADMIN \u4e3a\u6700\u9ad8\u7684\u96c6\u7fa4\u7ba1\u7406\u5458\u6743\u9650\uff0c\u53ea\u6709 root \u7528\u6237\u62e5\u6709\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/#_4","title":"\u5176\u5b83","text":"MatrixOne \u4e2d\u7684 sql_mode
\u662f\u4ec0\u4e48\uff1f
MatrixOne \u9ed8\u8ba4\u7684 sql_mode
\u662f MySQL \u4e2d\u7684 only_full_group_by
\u3002\u56e0\u6b64\u9ed8\u8ba4\u67e5\u8be2\u8bed\u6cd5\u4e2d\u6240\u6709 select
\u7684\u5b57\u6bb5\uff0c\u9664\u805a\u5408\u51fd\u6570\u4e2d\u7684\u5b57\u6bb5\uff0c\u90fd\u5fc5\u987b\u5728 group by
\u4e2d\u51fa\u73b0\u3002\u4f46\u662f MatrixOne \u4e5f\u652f\u6301\u4fee\u6539 sql_mode
\u4ee5\u517c\u5bb9\u4e0d\u5b8c\u5168\u89c4\u8303\u7684 group by
\u8bed\u6cd5\u3002
MatrixOne \u4e2d show tables \u65e0\u6cd5\u67e5\u770b\u4e34\u65f6\u8868\uff0c\u5982\u4f55\u67e5\u770b\u662f\u5426\u521b\u5efa\u6210\u529f\uff1f
\u76ee\u524d\u53ef\u4ee5\u901a\u8fc7 \"show create table \u4e34\u65f6\u8868\u540d\" \u6765\u67e5\u770b\uff0c\u7531\u4e8e\u4e34\u65f6\u8868\u5728\u521b\u5efa\u540e\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u53ef\u89c1\uff0c\u5728\u5f53\u524d\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u6570\u636e\u5e93\u81ea\u52a8\u5220\u9664\u4e34\u65f6\u8868\u5e76\u91ca\u653e\u6240\u6709\u7a7a\u95f4\uff0c\u5728\u5b83\u7684\u751f\u547d\u5468\u671f\u5185\u6211\u4eec\u901a\u5e38\u662f\u53ef\u4ee5\u4eba\u4e3a\u611f\u77e5\u7684\u3002
\u5982\u4f55\u67e5\u770b\u6211\u7684 Query \u6267\u884c\u8ba1\u5212\uff1f
\u8981\u67e5\u770b MatrixOne \u5bf9\u7ed9\u5b9a\u67e5\u8be2\u7684\u6267\u884c\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528 EXPLAIN
\u8bed\u53e5\uff0c\u5b83\u5c06\u6253\u5370\u51fa\u67e5\u8be2\u8ba1\u5212\u3002
EXPLAIN SELECT col1 FROM tbl1;
MatrixOne \u517c\u5bb9 MySQL\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u6216\u5176\u4ed6\u65b9\u5f0f\u8fde\u63a5 MatrixOne\u3002\u53c2\u52a0 MySQL \u517c\u5bb9\u6027\u548c\u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
"},{"location":"MatrixOne/Get-Started/basic-sql/#sql","title":"\u4ec0\u4e48\u662f SQL \u8bed\u8a00\uff1f","text":"SQL (Structured Query Language: \u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00) \u662f\u7528\u4e8e\u7ba1\u7406\u5173\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff08RDBMS\uff09\u3002SQL \u7684\u8303\u56f4\u5305\u62ec\u6570\u636e\u63d2\u5165\u3001\u67e5\u8be2\u3001\u66f4\u65b0\u548c\u5220\u9664\uff0c\u6570\u636e\u5e93\u6a21\u5f0f\u521b\u5efa\u548c\u4fee\u6539\uff0c\u4ee5\u53ca\u6570\u636e\u8bbf\u95ee\u63a7\u5236\u3002
"},{"location":"MatrixOne/Get-Started/basic-sql/#matrixone-sql_1","title":"MatrixOne \u7684 SQL \u90fd\u5206\u4e3a\u54ea\u51e0\u7c7b\uff1f","text":"SQL \u8bed\u8a00\u901a\u5e38\u6309\u7167\u529f\u80fd\u5212\u5206\u6210\u4ee5\u4e0b\u7684 6 \u4e2a\u90e8\u5206\uff1a
DDL (Data Definition Language)\uff1a\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff0c\u7528\u6765\u5b9a\u4e49\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5305\u62ec\u5e93\u3001\u8868\u3001\u89c6\u56fe\u7b49\u3002\u4f8b\u5982\uff0cCREATE
\uff0cALTER
\uff0c\u548c DROP
\u7b49\u3002
DML (Data Manipulation Language)\uff1a\u6570\u636e\u4fee\u6539\u8bed\u8a00\uff0c\u7528\u6765\u4fee\u6539\u548c\u4e1a\u52a1\u76f8\u5173\u7684\u8bb0\u5f55\u3002\u4f8b\u5982\uff0cSELECT
\uff0cDELETE
\uff0c\u6216 INSERT
\u7b49\u3002
DQL (Data Query Language)\uff1a\u6570\u636e\u67e5\u8be2\u8bed\u8a00\uff0c\u7528\u6765\u67e5\u8be2\u7ecf\u8fc7\u6761\u4ef6\u7b5b\u9009\u7684\u8bb0\u5f55\u3002\u4f8b\u5982\uff0cSELECT...FROM...[WHERE]
\u8fd9\u79cd\u591a\u4e2a\u5b50\u53e5\u7ec4\u5408\u800c\u6210\u7684 SQL \u8bed\u53e5\u3002
TCL\uff08Transaction Control Language\uff09\uff1a\u4e8b\u52a1\u63a7\u5236\u8bed\u8a00\uff0c\u7528\u4e8e\u4e8b\u52a1\u7ba1\u63a7\u3002\u4f8b\u5982\uff0cCOMMIT
\uff0cROLLBACK
\uff0c\u6216 SET TRANSACTION
\u7b49\u3002
DCL (Data Control Language)\uff1a\u6570\u636e\u63a7\u5236\u8bed\u8a00\uff0c\u7528\u6765\u5206\u914d\u4e0e\u56de\u6536\u8d44\u6e90\uff0c\u521b\u5efa\u548c\u9610\u8ff0\u7528\u6237\u4e0e\u89d2\u8272\uff0c\u6388\u6743\u548c\u56de\u6536\u6743\u9650\u3002\u4f8b\u5982\uff0cCREATET ACCOUNT
\uff0cDROP ACCOUNT
\uff0c\u6216 GRANT
\u7b49\u3002
\u5176\u4ed6\uff1a\u5728 MatrixOne \u4e2d\uff0c\u5176\u4ed6\u7c7b\u578b\u7684\u7ba1\u7406\u8bed\u8a00\u662f\u6307\u4e0e\u6570\u636e\u6ca1\u6709\u76f4\u63a5\u5173\u8054\uff0c\u5bf9\u6570\u636e\u5e93\u53c2\u6570\u3001\u8d44\u6e90\u5206\u914d\u7684\u83b7\u53d6\u4e0e\u4fee\u6539\u7684\u603b\u79f0\u3002\u4f8b\u5982\uff0cSHOW
\uff0cSET variable
\uff0c\u6216 KILL
\u7b49\u3002
MatrixOne \u4e2d\u7684\u6570\u636e\u5e93\u662f\u8868\u7684\u96c6\u5408\u3002
SHOW DATABASES
\u8bed\u53e5\uff1aSHOW DATABASES;\n
CREATE DATABASE db_name [options];
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aCREATE DATABASE dbdemo;\n
\u6216\uff1a
CREATE DATABASE IF NOT EXISTS dbdemo;\n
\u6dfb\u52a0 IF NOT EXISTS
\u6761\u4ef6\u53ef\u4ee5\u9632\u6b62\u9519\u8bef\u3002
USE dbdemo;\n
SHOW TABLES
\u8bed\u53e5\u67e5\u770b\u6570\u636e\u5e93\u4e2d\u6240\u6709\u7684\u8868\uff0c\u4f8b\u5982\uff1aSHOW TABLES FROM dbdemo;\n
DROP DATABASE
\u8bed\u53e5\uff1aDROP DATABASE dbdemo;\n
"},{"location":"MatrixOne/Get-Started/basic-sql/#_2","title":"\u521b\u5efa\u3001\u67e5\u770b\u548c\u5220\u9664\u8868","text":"CREATE TABLE
\u8bed\u53e5\uff1aCREATE TABLE table_name column_name data_type constraint;\n
\u4f8b\u5982\uff0c\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a person \u7684\u8868\uff0c\u5305\u62ec\u7f16\u53f7\u3001\u540d\u5b57\u3001\u751f\u65e5\u7b49\u5b57\u6bb5\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a
CREATE TABLE person (\nid INT(11),\nname VARCHAR(255),\nbirthday DATE\n);\n
SHOW CREATE
\u8bed\u53e5\uff1aSHOW CREATE table person;\n
\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
+--------+-----------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n| person | CREATE TABLE `person` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`birthday` DATE DEFAULT NULL\n) |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
DROP TABLE
\u8bed\u53e5\uff1aDROP TABLE person;\n
"},{"location":"MatrixOne/Get-Started/basic-sql/#_3","title":"\u589e\u52a0\u3001\u5220\u9664\u3001\u4fee\u6539\u8868\u8bb0\u5f55","text":"\u901a\u7528\u7684 DML \u5373\u589e\u5220\u6539\u8868\u8bb0\u5f55\uff0c\u57fa\u672c\u7684\u8bed\u53e5\u4e3a INSERT
\uff0cUPDATE
\u3001REPLACE
\u548c DELETE
\u3002
INSERT
\u8bed\u53e5\uff1aINSERT INTO person VALUES(1,'tom','20170912');\n
INSERT
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aINSERT INTO person(id,name) VALUES('2','bob');\n
UPDATE
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aUPDATE person SET birthday='20180808' WHERE id=2;\n
UPDATE
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aREPLACE INTO person SET birthday='20180809' WHERE id=2;\n
DELETE
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aDELETE FROM person WHERE id=2;\n
Note
UPDATE
\u548c DELETE
\u64cd\u4f5c\u5982\u679c\u4e0d\u5e26 WHERE
\u8fc7\u6ee4\u6761\u4ef6\u5219\u662f\u5bf9\u5168\u8868\u8fdb\u884c\u64cd\u4f5c\u3002
DQL \u7528\u4e8e\u4ece\u4e00\u4e2a\u8868\u6216\u591a\u4e2a\u8868\u68c0\u7d22\u6240\u9700\u7684\u6570\u636e\u884c\u3002
SELECT
\u8bed\u53e5\uff1aSELECT * FROM person;\n
\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
+------+------+------------+\n| id | name | birthday |\n+------+------+------------+\n| 1 | tom | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
SELECT
\u8bed\u53e5\u52a0\u4e0a\u8981\u67e5\u8be2\u7684\u5217\u540d\uff1aSELECT name FROM person;\n+------+\n| name |\n+------+\n| tom |\n+------+\n1 rows in set (0.00 sec)\n
\u4f7f\u7528 WHERE
\u5b50\u53e5\uff0c\u5bf9\u6240\u6709\u8bb0\u5f55\u8fdb\u884c\u662f\u5426\u7b26\u5408\u6761\u4ef6\u7684\u7b5b\u9009\u540e\u518d\u8fd4\u56de\u3002\u4f8b\u5982\uff1a
SELECT * FROM person where id<5;\n
\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
+------+------+------------+\n| id | name | birthday |\n+------+------+------------+\n| 1 | tom | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Get-Started/basic-sql/#_5","title":"\u521b\u5efa\u3001\u6388\u6743\u548c\u5220\u9664\u7528\u6237","text":"\u5982\u679c\u4f60\u5b89\u88c5\u90e8\u7f72\u5355\u673a\u7248\u7684 MatrixOne\uff0c\u8fde\u63a5\u767b\u5f55 MatrixOne \u65f6\uff0c\u4f60\u672c\u8eab\u4fbf\u5177\u6709\u6700\u9ad8\u6743\u9650\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u5185\u5bb9\u521b\u5efa\u7528\u6237\u5e76\u6388\u6743\uff0c\u4ee5\u4fbf\u4f53\u9a8c MatrixOne \u96c6\u7fa4\u7684\u6743\u9650\u7ba1\u7406\u529f\u80fd\u3002
CREATE USER
\u8bed\u53e5\u521b\u5efa\u4e00\u4e2a\u7528\u6237 mouser\uff0c\u5bc6\u7801\u4e3a 111\uff1a> CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n
> CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n
> GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n
> GRANT create table on database * to role_r1;\nQuery OK, 0 rows affected (0.03 sec)\n
> SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account `mouser`@`localhost` |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n
\u4f60\u53ef\u4ee5\u770b\u5230\u4f60\u5df2\u7ecf\u6210\u529f\u628a\u5728 dbdemo \u6570\u636e\u5e93\u91cc\u5efa\u8868\u7684\u6743\u9650\u6388\u4e88\u7ed9\u4e86 mouser\u3002
DROP USER mouser;\n
\u6743\u9650\u7ba1\u7406\u662f\u6570\u636e\u5e93\u4e2d\u4f53\u7cfb\u5e9e\u5927\u4f46\u662f\u975e\u5e38\u6709\u7528\u7684\u529f\u80fd\uff0c\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u66f4\u591a\uff0c\u53c2\u89c1\u6743\u9650\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/","title":"\u5355\u673a\u90e8\u7f72 MatrixOne","text":"\u5355\u673a\u7248 MatrixOne \u9002\u7528\u573a\u666f\u5373\u662f\u4f7f\u7528\u5355\u53f0\u5f00\u53d1\u673a\u5668\u90e8\u7f72 MatrixOne\uff0c\u4f53\u9a8c MatrixOne \u7684\u57fa\u672c\u529f\u80fd\uff0c\u4e0e\u5355\u673a\u7248\u4f7f\u7528\u4e00\u4e2a MySQL \u57fa\u672c\u76f8\u540c\u3002
\u63a8\u8350\u5b89\u88c5\u73af\u5883\uff1a
\u4f5c\u4e3a\u4e00\u6b3e\u5f00\u6e90\u6570\u636e\u5e93\uff0cMatrixOne \u76ee\u524d\u652f\u6301\u4e3b\u6d41\u7684 Linux \u548c MacOS \u7cfb\u7edf\u3002\u4e3a\u4e86\u5feb\u901f\u4e0a\u624b\uff0c\u672c\u6587\u6863\u4e2d\u4f18\u5148\u63a8\u8350\u5982\u4e0b\u786c\u4ef6\u89c4\u683c\uff1a
\u64cd\u4f5c\u7cfb\u7edf \u64cd\u4f5c\u7cfb\u7edf\u7248\u672c CPU \u5185\u5b58 Debian 11 \u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GB Ubuntu 20.04 \u53ca\u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GB CentOS 7 \u53ca\u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GB macOS Monterey 12.3 \u53ca\u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GBNote
\u5982\u679c\u60a8\u5f53\u524d\u4f7f\u7528\u7684 Linux \u7cfb\u7edf\u5185\u6838\u7248\u672c\u8f83\u4f4e\uff08\u4f4e\u4e8e 5.0\uff09\uff0c\u7531\u4e8e linux \u5185\u6838\u7684\u9650\u5236\uff0c\u4f7f\u7528\u57fa\u4e8e glibc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u8fdb\u884c Matrixone \u7684\u90e8\u7f72\u65f6\u53ef\u80fd\u4f1a\u62a5\u4e0e glibc \u76f8\u5173\u7684\u9519\u8bef\uff0c\u8fd9\u65f6\u5019\u60a8\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u90e8\u7f72\u4e2d\u7684\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u8fdb\u884c\u90e8\u7f72\u3002musl libc \u662f\u4e00\u4e2a\u4e3a Linux \u7cfb\u7edf\u8bbe\u8ba1\u7684\u8f7b\u91cf\u7ea7 C \u6807\u51c6\u5e93\uff0c\u4f7f\u7528 musl libc \u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u8ba9\u4f60\u751f\u6210\u4e0d\u4f9d\u8d56\u4e8e\u7cfb\u7edf C \u5e93\u7684\u9759\u6001\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u6b64\u5916\uff0c\u7531\u4e8e CentOS 8 \u5df2\u7ecf\u505c\u6b62\u5b98\u65b9\u652f\u6301\uff0c\u4e14 CentOS 7 \u4e5f\u5c06\u5728 2024 \u5e74 6 \u6708 30 \u65e5\u7ed3\u675f\u7ef4\u62a4\u5468\u671f\uff0c\u76ee\u524d\u4f7f\u7528\u8fd9\u4e9b\u7248\u672c\u7684\u7528\u6237\u53ef\u80fd\u4f1a\u9762\u4e34\u4e00\u4e9b\u98ce\u9669\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5efa\u8bae\u7528\u6237\u4f7f\u7528\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u3002
\u4f60\u4e5f\u53ef\u4ee5\u67e5\u9605\u786c\u4ef6\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u8981\u6c42\uff0c\u67e5\u770b\u66f4\u591a\u5173\u4e8e\u786c\u4ef6\u89c4\u683c\u63a8\u8350\uff0c\u9009\u7528\u5408\u9002\u7684\u786c\u4ef6\u73af\u5883\u3002
"},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#macos","title":"\u5728 macOS \u4e0a\u90e8\u7f72","text":"\u4f60\u53ef\u4ee5\u5728\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\u4e2d\u9009\u62e9\u6700\u9002\u5408\u4f60\u7684\u4e00\u79cd\uff0c\u5728 macOS \u4e0a\u5b89\u88c5\u5e76\u8fde\u63a5 MatrixOne\uff1a
\u4f60\u53ef\u4ee5\u5728\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\u4e2d\u9009\u62e9\u6700\u9002\u5408\u4f60\u7684\u4e00\u79cd\uff0c\u5728 Linux \u4e0a\u5b89\u88c5\u5e76\u8fde\u63a5 MatrixOne\uff1a
\u66f4\u591a\u6709\u5173\u8fde\u63a5 MatrixOne \u7684\u65b9\u5f0f\uff0c\u53c2\u89c1\uff1a
\u5e38\u89c1\u7684\u5b89\u88c5\u548c\u90e8\u7f72\u95ee\u9898\uff0c\u53c2\u89c1\u5b89\u88c5\u548c\u90e8\u7f72\u5e38\u89c1\u95ee\u9898\u3002
\u5173\u4e8e\u5206\u5e03\u5f0f\u90e8\u7f72 MatrixOne\uff0c\u53c2\u89c1 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u6e90\u4ee3\u7801\u5728 Linux \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002\u6211\u4eec\u5c06\u91c7\u7528 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u7684 Linux \u7cfb\u7edf\u3002\u672c\u6587\u4ee5 Debian11.1 x86 \u67b6\u6784\u4e3a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5b8c\u6210\u5168\u6d41\u7a0b\u3002\u5982\u679c\u4f7f\u7528 Ubuntu \u7cfb\u7edf\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u9ed8\u8ba4\u6ca1\u6709 root \u6743\u9650\uff0c\u5efa\u8bae\u5168\u6d41\u7a0b\u547d\u4ee4\u90fd\u52a0 sudo
\u8fdb\u884c\u3002
\u901a\u8fc7\u6e90\u7801\u5b89\u88c5\u53ca\u4f7f\u7528\u5355\u673a\u7248 MatrixOne\uff0c\u9700\u8981\u4f9d\u8d56\u4e8e\u4ee5\u4e0b\u4e00\u4e9b\u8f6f\u4ef6\u5305\u3002
\u4f9d\u8d56\u8f6f\u4ef6 \u7248\u672c golang 1.22.3 \u53ca\u4ee5\u4e0a gcc gcc8.5 \u53ca\u4ee5\u4e0a git 2.20 \u53ca\u4ee5\u4e0a MySQL Client 8.0 \u53ca\u4ee5\u4e0a"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1","title":"\u6b65\u9aa4 1: \u5b89\u88c5\u4f9d\u8d56","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-go","title":"1. \u5b89\u88c5\u90e8\u7f72 Go \u8bed\u8a00","text":"\u70b9\u51fb Go Download and install \u5165\u5230 Go \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 Go \u8bed\u8a00\u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 Go \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 go version
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff1a
go version go1.22.3 linux/amd64\n
Debian11.1 \u4e2d\u4e00\u822c\u5df2\u7ecf\u81ea\u5e26 9.0 \u4ee5\u4e0a\u7248\u672c\u7684 GCC\uff0c\u53ef\u4ee5\u5148\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1 GCC \u73af\u5883\u662f\u5426\u9700\u8981\u5b89\u88c5\u3002
gcc -v\nbash: gcc: command not found\n
\u5982\u4ee3\u7801\u6240\u793a\uff0c\u672a\u663e\u793a GCC \u7684\u7248\u672c\uff0c\u5219\u8868\u793a GCC \u7684\u73af\u5883\u9700\u8981\u5b89\u88c5\u3002
\u70b9\u51fb GCC Download and install \u5165\u5230 GCC \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 GCC \u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 GCC \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 gcc -v
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff08\u53ea\u5c55\u793a\u90e8\u5206\u4ee3\u7801\uff09\uff1a
Using built-in specs.\nCOLLECT_GCC=gcc\n...\nThread model: posix\ngcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)\n
\u68c0\u67e5 Git \u662f\u5426\u5df2\u652f\u6301\u3002\u5982\u4ee3\u7801\u6240\u793a\uff0c\u672a\u663e\u793a git \u7684\u7248\u672c\uff0c\u5219\u8868\u793a git \u9700\u8981\u5b89\u88c5\u3002
git version\n-bash: git: command not found\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Git\u3002
sudo apt install git\n
\u9a8c\u8bc1 Git \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 git version
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff1a
git version\ngit version 2.40.0\n
Debian11.1 \u7248\u672c\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5 MySQL Client\uff0c\u56e0\u6b64\u9700\u8981\u624b\u52a8\u4e0b\u8f7d\u5b89\u88c5\u3002
\u5b89\u88c5 MySQL Client \u9700\u8981\u7528\u5230 wget
\u4e0b\u8f7d\u5de5\u5177\uff0cwget
\u662f\u7528\u6765\u4ece\u6307\u5b9a\u7684 URL \u4e0b\u8f7d\u6587\u4ef6\u3002\u4f9d\u6b21\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5b89\u88c5 wget
\uff1a
## \u66f4\u65b0\u8f6f\u4ef6\u6e90\u5217\u8868\u7f13\u5b58\nsudo apt update\n## \u5b89\u88c5 wget\nsudo apt install wget\n
\u5b89\u88c5\u5b8c\u6210\u540e\u8bf7\u8f93\u5165\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u9a8c\u8bc1\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c\uff08\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801\uff09\u5982\u4e0b\uff1a
GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n
\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 MySQL Client\uff1a
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
\u6267\u884c\u547d\u4ee4 mysql --version
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff0c\u5b89\u88c5\u6210\u529f\u7ed3\u679c\u5982\u4e0b\uff1a
mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
Note
\u6570\u636e\u5e93\u7cfb\u7edf\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff08\u5982 TPC-H 100G \u6d4b\u8bd5\uff09\uff0c\u4f1a\u4f7f\u7528\u5185\u5b58\u6620\u5c04\u6587\u4ef6\u6765\u63d0\u9ad8 I/O \u6027\u80fd\u3002Linux \u7cfb\u7edf\u53c2\u6570 vm.max_map_count \u5b9a\u4e49\u4e86\u8fdb\u7a0b\u53ef\u4ee5\u62e5\u6709\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u6570\u91cf\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u8bbe\u7f6e\u5f97\u592a\u4f4e\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u53ef\u80fd\u65e0\u6cd5\u521b\u5efa\u8db3\u591f\u7684\u5185\u5b58\u6620\u5c04\u533a\u57df\u6765\u5904\u7406\u5176\u65e5\u5e38\u64cd\u4f5c\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u5e93\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5982\u5185\u5b58\u4e0d\u8db3 (OOM) \u548c\u8fdb\u7a0b\u5d29\u6e83\u3002\u4e3a\u4e86\u63d0\u9ad8 Matrixone \u5728 Linux \u4e2d\u8fd0\u884c\u7684\u7a33\u5b9a\u6027\uff0c\u5efa\u8bae\u5c06 vm.max_map_count \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u8f83\u9ad8\u7684\u503c\uff0c\u63a8\u8350\u503c\u4e3a 262144\uff0c\u8fd9\u4e2a\u503c\u9002\u7528\u4e8e\u5927\u591a\u6570\u9700\u8981\u5927\u91cf\u5185\u5b58\u6620\u5c04\u7684\u573a\u666f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 sysctl -w vm.max_map_count = 262144
\u4f7f\u5176\u4e34\u65f6\u751f\u6548\uff0c\u6216\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 /etc/sysctl.conf
\u4f7f\u5176\u6c38\u4e45\u751f\u6548\u3002
mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-mo_ctl","title":"1. \u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\uff1a
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n
\u5b89\u88c5\u5b8c\u6210\u4ee5\u540e\uff0c\u901a\u8fc7 mo_ctl
\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a
> mo_ctl\n Usage : mo_ctl [option_1] [option_2]\n\n [option_1] : available: auto_backup | auto_clean_logs | backup | clean_backup | clean_logs | connect | csv_convert | ddl_convert | deploy | get_branch | get_cid | get_conf | help | monitor | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | version | watchdog\n auto_backup : setup a crontab task to backup your databases automatically\n auto_clean_logs : set up a crontab task to clean system log table data automatically\n backup : create a backup of your databases manually\n build_image : build an MO image from source code\n clean_backup : clean old backups older than conf 31 days manually\n clean_logs : clean system log table data manually\n connect : connect to mo via mysql client using connection info configured\n csv_convert : convert a csv file to a sql file in format \"insert into values\" or \"load data inline format='csv'\"\n ddl_convert : convert a ddl file to mo format from other types of database\n deploy : deploy mo onto the path configured\n get_branch : upgrade or downgrade mo from current version to a target commit id or stable version\n get_cid : print mo git commit id from the path configured\n get_conf : get configurations\n help : print help information\n monitor : monitor system related operations\n pprof : collect pprof information\n precheck : check pre-requisites for mo_ctl\n restart : a combination operation of stop and start\n set_conf : set configurations\n sql : execute sql from string, or a file or a path containg multiple files\n start : start mo-service from the path configured\n status : check if there's any mo process running on this machine\n stop : stop all mo-service processes found on this machine\n uninstall : uninstall mo from path MO_PATH=/Users/admin/mo//matrixone\n upgrade : upgrade or downgrade mo from current version to a target commit id or stable version\n version : show mo_ctl and matrixone version\n watchdog : setup a watchdog crontab task for mo-service to keep it alive\n e.g. : mo_ctl status\n\n [option_2] : Use \" mo_ctl [option_1] help \" to get more info\n e.g. : mo_ctl deploy help\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#2-mo_ctl_1","title":"2. \u8bbe\u7f6e mo_ctl \u7684\u914d\u7f6e\u53c2\u6570","text":"mo_ctl \u5de5\u5177\u4e2d\u6709\u90e8\u5206\u53c2\u6570\u53ef\u80fd\u9700\u8981\u4f60\u8fdb\u884c\u8c03\u6574\u8bbe\u7f6e\uff0c\u901a\u8fc7 mo_ctl get_conf
\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u5f53\u524d\u53c2\u6570\u3002
root@VM-16-2-debian:~# mo_ctl get_conf\n2023-08-23 18:23:35.444 UTC+0800 [INFO] Below are all configurations set in conf file /root/mo_ctl/conf/env.sh\nMO_PATH=\"/data/mo/\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.22.3\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"v1.2.1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n
\u4e00\u822c\u53ef\u80fd\u4f1a\u9700\u8981\u8c03\u6574\u7684\u53c2\u6570\u5982\u4e0b\uff1a
mo_ctl set_conf MO_PATH=\"yourpath\" # \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u7684MatrixOne\u4e0b\u8f7d\u8def\u5f84\nmo_ctl set_conf MO_GIT_URL=\"https://githubfast.com/matrixorigin/matrixone.git\" #\u9488\u5bf9github\u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\u95ee\u9898\uff0c\u8bbe\u7f6e\u955c\u50cf\u4e0b\u8f7d\u5730\u5740\nmo_ctl set_conf MO_DEFAULT_VERSION=\"v1.2.1\" # \u8bbe\u7f6e\u6240\u4e0b\u8f7d\u7684MatrixOne\u7248\u672c\nmo_ctl set_conf MO_DEPLOY_MODE=git #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u6e90\u7801\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u4e00\u952e\u5b89\u88c5 MatrixOne","text":"\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/matrixone/logs/
\u4e2d\u3002
root@VM-16-2-debian:~# mo_ctl start\n2023-07-07_09:55:01 [INFO] No mo-service is running\n2023-07-07_09:55:01 [INFO] Starting mo-service: cd /data/mo/matrixone/matrixone/ && /data/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo/matrixone/matrixone/etc/launch/launch.toml >/data/mo/matrixone/logs/stdout-20230707_095501.log 2>/data/mo/matrixone/logs/stderr-20230707_095501.log\n2023-07-07_09:55:01 [INFO] Wait for 2 seconds\n2023-07-07_09:55:03 [INFO] At least one mo-service is running. Process info:\n2023-07-07_09:55:03 [INFO] root 748128 1 2 09:55 ? 00:00:00 /data/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_09:55:03 [INFO] Pids:\n2023-07-07_09:55:03 [INFO] 748128\n2023-07-07_09:55:03 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
root@VM-16-2-debian:~# mo_ctl connect\n2023-07-07_10:30:20 [INFO] Checking connectivity\n2023-07-07_10:30:20 [INFO] Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u5728 Linux \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\uff0c\u8fd9\u79cd\u5b89\u88c5\u65b9\u6848\u65e0\u9700\u5b89\u88c5\u524d\u7f6e\u4f9d\u8d56\u548c\u7f16\u8bd1\u6e90\u7801\u5305\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u7684 Linux \u7cfb\u7edf\u3002\u672c\u6587\u4ee5 Debian11.1 x86 \u67b6\u6784\u4e3a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5b8c\u6210\u5168\u6d41\u7a0b\u3002\u5982\u679c\u4f7f\u7528 Ubuntu \u7cfb\u7edf\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u9ed8\u8ba4\u6ca1\u6709 root \u6743\u9650\uff0c\u5efa\u8bae\u5168\u6d41\u7a0b\u547d\u4ee4\u90fd\u52a0 sudo
\u8fdb\u884c\u3002
\u901a\u8fc7\u4e8c\u8fdb\u5236\u5305\u90e8\u7f72\u548c\u5b89\u88c5 MatrixOne\uff0c\u4ec5\u9700\u5b89\u88c5 MySQL Client
\u5de5\u5177\u3002
Tips: \u5efa\u8bae\u4f60\u4e0b\u8f7d\u5b89\u88c5\u8fd9\u4e24\u4e2a\u4e0b\u8f7d\u5de5\u5177\u5176\u4e2d\u4e4b\u4e00\uff0c\u65b9\u4fbf\u540e\u7eed\u901a\u8fc7\u547d\u4ee4\u884c\u4e0b\u8f7d MySQL Client
\u548c\u4e8c\u8fdb\u5236\u5305\u3002
wget
\u5b89\u88c5 curl
wget
\u5de5\u5177\u7528\u6765\u4ece\u6307\u5b9a\u7684 URL \u4e0b\u8f7d\u6587\u4ef6\u3002wget
\u662f\u4e13\u95e8\u7684\u6587\u4ef6\u4e0b\u8f7d\u5de5\u5177\uff0c\u5b83\u975e\u5e38\u7a33\u5b9a\uff0c\u800c\u4e14\u4e0b\u8f7d\u901f\u5ea6\u5feb\u3002\u4f9d\u6b21\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5b89\u88c5 wget
\uff1a
## \u66f4\u65b0\u8f6f\u4ef6\u6e90\u5217\u8868\u7f13\u5b58\nsudo apt udpate\n## \u5b89\u88c5 wget\nsudo apt install wget\n
\u5b89\u88c5\u5b8c\u6210\u540e\u8bf7\u8f93\u5165\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u9a8c\u8bc1\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n
curl
\u662f\u4e00\u4e2a\u5229\u7528 URL \u89c4\u5219\u5728\u547d\u4ee4\u884c\u4e0b\u5de5\u4f5c\u7684\u6587\u4ef6\u4f20\u8f93\u5de5\u5177\u3002curl
\u662f\u7efc\u5408\u4f20\u8f93\u5de5\u5177\uff0c\u652f\u6301\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d\u3002
\u8fdb\u5165\u5230Curl\u5b98\u7f51\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5 curl
\u3002 \u9a8c\u8bc1 curl
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
curl --version\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
curl 7.84.0 (x86_64-pc-linux-gnu) libcurl/7.84.0 OpenSSL/1.1.1k-fips zlib/1.2.11\nRelease-Date: 2022-06-27\n...\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-mysql-client","title":"2. \u5b89\u88c5 MySQL Client","text":"\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
\u6267\u884c\u547d\u4ee4 mysql --version
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff0c\u5b89\u88c5\u6210\u529f\u7ed3\u679c\u5982\u4e0b\uff1a
mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
Note
\u6570\u636e\u5e93\u7cfb\u7edf\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff08\u5982 TPC-H 100G \u6d4b\u8bd5\uff09\uff0c\u4f1a\u4f7f\u7528\u5185\u5b58\u6620\u5c04\u6587\u4ef6\u6765\u63d0\u9ad8 I/O \u6027\u80fd\u3002Linux \u7cfb\u7edf\u53c2\u6570 vm.max_map_count \u5b9a\u4e49\u4e86\u8fdb\u7a0b\u53ef\u4ee5\u62e5\u6709\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u6570\u91cf\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u8bbe\u7f6e\u5f97\u592a\u4f4e\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u53ef\u80fd\u65e0\u6cd5\u521b\u5efa\u8db3\u591f\u7684\u5185\u5b58\u6620\u5c04\u533a\u57df\u6765\u5904\u7406\u5176\u65e5\u5e38\u64cd\u4f5c\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u5e93\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5982\u5185\u5b58\u4e0d\u8db3 (OOM) \u548c\u8fdb\u7a0b\u5d29\u6e83\u3002\u4e3a\u4e86\u63d0\u9ad8 Matrixone \u5728 Linux \u4e2d\u8fd0\u884c\u7684\u7a33\u5b9a\u6027\uff0c\u5efa\u8bae\u5c06 vm.max_map_count \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u8f83\u9ad8\u7684\u503c\uff0c\u63a8\u8350\u503c\u4e3a 262144\uff0c\u8fd9\u4e2a\u503c\u9002\u7528\u4e8e\u5927\u591a\u6570\u9700\u8981\u5927\u91cf\u5185\u5b58\u6620\u5c04\u7684\u573a\u666f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 sysctl -w vm.max_map_count = 262144
\u4f7f\u5176\u4e34\u65f6\u751f\u6548\uff0c\u6216\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 /etc/sysctl.conf
\u4f7f\u5176\u6c38\u4e45\u751f\u6548\u3002
\u6211\u4eec\u63d0\u4f9b\u4e86\u4e24\u7c7b\u4e8c\u8fdb\u5236\u5305\uff1a\u4e00\u7c7b\u662f\u4f9d\u6258 glibc \u6784\u5efa\u7684\uff0c\u53e6\u4e00\u7c7b\u662f\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u3002\u5bf9\u4e8e\u4f7f\u7528\u8f83\u65e7\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u6765\u8fdb\u884c\u90e8\u7f72\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u89e3\u91ca\u4e24\u79cd\u5b89\u88c5\u5305\u7684\u4e0b\u8f7d\u6d41\u7a0b\uff1a
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#glibc","title":"\u57fa\u4e8e glibc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305","text":"\u4e0b\u8f7d\u65b9\u5f0f\u4e00\uff1awget
\u5de5\u5177\u4e0b\u8f7d\u5b89\u88c5\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e09\uff1a\u9875\u9762\u4e0b\u8f7d x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-x86_64.zip\nunzip mo-v1.2.1-linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-arm64.zip\nunzip mo-v1.2.1-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-x86_64.zip\nunzip mo-v1.2.--linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-arm64.zip\nunzip mo-v1.2.1-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-xxx.zip\n
\u5982\u679c\u4f60\u60f3\u901a\u8fc7\u66f4\u76f4\u89c2\u7684\u9875\u9762\u4e0b\u8f7d\u7684\u65b9\u5f0f\u4e0b\u8f7d\uff0c\u76f4\u63a5\u70b9\u51fb\u8fdb\u5165\u7248\u672c 1.2.1\uff0c\u4e0b\u62c9\u627e\u5230 Assets \u680f\uff0c\u70b9\u51fb\u5b89\u88c5\u5305 mo-v1.2.1-linux-x86_64.zip \u6216\u8005 mo-v1.2.1-linux-arm64.zip \u4e0b\u8f7d\u518d\u4f7f\u7528 unzip
\u547d\u4ee4\u89e3\u538b\u5373\u53ef\u3002
wget
\u5de5\u5177\u4e0b\u8f7d\u5b89\u88c5\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e09\uff1a\u9875\u9762\u4e0b\u8f7d x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-x86_64.zip\nunzip mo-v1.2.1-musl-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-arm64.zip\nunzip mo-v1.2.1-musl-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-x86_64.zip\nunzip mo-v1.2.1-musl-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-arm64.zip\nunzip mo-v1.2.1-musl-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-xxx.zip\n
\u5982\u679c\u4f60\u60f3\u901a\u8fc7\u66f4\u76f4\u89c2\u7684\u9875\u9762\u4e0b\u8f7d\u7684\u65b9\u5f0f\u4e0b\u8f7d\uff0c\u76f4\u63a5\u70b9\u51fb\u8fdb\u5165\u7248\u672c 1.2.1\uff0c\u4e0b\u62c9\u627e\u5230 Assets \u680f\uff0c\u70b9\u51fb\u5b89\u88c5\u5305 mo-v1.2.1-musl-x86_64.zip \u6216\u8005 mo-v1.2.1-musl-arm64.zip \u4e0b\u8f7d\u518d\u4f7f\u7528 unzip
\u547d\u4ee4\u89e3\u538b\u5373\u53ef\u3002
mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#1-mo_ctl","title":"1. \u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-mo_ctl","title":"2. \u8bbe\u7f6e mo_ctl \u7684\u914d\u7f6e\u53c2\u6570","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_PATH=\"/yourpath/mo-v1.2.1-xx-xx\" #\u8bbe\u7f6eMatrixOne\u8def\u5f84\u4e3a\u4e8c\u8fdb\u5236\u89e3\u538b\u6587\u4ef6\u76ee\u5f55\nmo_ctl set_conf MO_CONF_FILE=\"/yourpath/mo-v1.2.1-xx-xx/etc/launch/launch.toml\" #\u8bbe\u7f6eMatrixOne\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\nmo_ctl set_conf MO_DEPLOY_MODE=binary #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u4e8c\u8fdb\u5236\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/mo-v1.2.1-xx-xx/matrixone/logs/
\u4e2d\u3002
> mo_ctl start\n2024-03-07 14:34:04.942 UTC+0800 [INFO] No mo-service is running\n2024-03-07 14:34:04.998 UTC+0800 [INFO] Get conf succeeded: MO_DEPLOY_MODE=\"binary\"\n2024-03-07 14:34:05.024 UTC+0800 [INFO] GO memory limit(Mi): 14745\n2024-03-07 14:34:05.072 UTC+0800 [INFO] Starting mo-service: cd /Users/admin/mo-v1.2.1-linux-arm64/ && GOMEMLIMIT=14745MiB /Users/admin/mo-v1.2.1-linux-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-linux-arm64/etc/launch/launch.toml >/Users/admin/mo-v1.2.1-linux-arm64/matrixone/logs/stdout-20240307_143405.log 2>/Users/admin/mo-v1.2.1-linux-arm64/matrixone/logs/stderr-20240307_143405.log\n2024-03-07 14:34:05.137 UTC+0800 [INFO] Wait for 2 seconds\n2024-03-07 14:34:07.261 UTC+0800 [INFO] At least one mo-service is running. Process info: \n 501 27145 1 0 2:34\u4e0b\u5348 ?? 0:00.18 /Users/admin/mo-v1.2.1-linux-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-linux-arm64/etc/launch/launch.toml\n2024-03-07 14:34:07.284 UTC+0800 [INFO] List of pid(s): \n27145\n2024-03-07 14:34:07.308 UTC+0800 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
> mo_ctl connect\n2024-03-07 14:34:59.902 UTC+0800 [INFO] Checking connectivity\n2024-03-07 14:34:59.942 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 426\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 Docker \u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#1","title":"\u6b65\u9aa4 1\uff1a\u524d\u7f6e\u6761\u4ef6","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#docker_1","title":"\u5b89\u88c5 docker","text":"\u70b9\u51fb Get Docker\uff0c\u8fdb\u5165 Docker \u7684\u5b98\u65b9\u6587\u6863\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4e0b\u8f7d\u5b89\u88c5\u5bf9\u5e94\u7684 Docker\uff0cDocker \u7248\u672c\u63a8\u8350\u9009\u62e9\u5728 20.10.18 \u53ca\u4ee5\u4e0a\uff0c\u4e14\u5c3d\u91cf\u4fdd\u6301 Docker client \u548c Docker server \u7684\u7248\u672c\u4e00\u81f4\u3002
\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4e0b\u8ff0\u4ee3\u7801\u884c\u786e\u8ba4 Docker \u7248\u672c\uff0c\u9a8c\u8bc1 Docker \u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a
docker --version\n
\u5b89\u88c5\u6210\u529f\uff0c\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
Docker version 20.10.18, build 100c701\n
\u5728\u4f60\u7ec8\u7aef\u91cc\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8 Docker \u5e76\u67e5\u770b\u8fd0\u884c\u72b6\u6001\u662f\u5426\u6210\u529f\uff1a
systemctl start docker\nsystemctl status docker\n
\u8868\u793a Docker \u6b63\u5728\u8fd0\u884c\u7684\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff0c\u51fa\u73b0 Active: active (running)
\u5373\u8868\u793a Docker \u5df2\u7ecf\u5728\u8fd0\u884c\u4e2d\u3002
docker.service - Docker Application Container Engine\n Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n Active: active (running) since Sat 2022-11-26 17:48:32 CST; 6s ago\n Docs: https://docs.docker.com\n Main PID: 234496 (dockerd)\n Tasks: 8\n Memory: 23.6M\n
Debian11.1 \u7248\u672c\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5 MySQL Client\uff0c\u56e0\u6b64\u9700\u8981\u624b\u52a8\u4e0b\u8f7d\u5b89\u88c5\u3002
\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
\u6267\u884c\u547d\u4ee4 mysql --version
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff0c\u5b89\u88c5\u6210\u529f\u7ed3\u679c\u5982\u4e0b\uff1a
mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
Note
\u6570\u636e\u5e93\u7cfb\u7edf\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff08\u5982 TPC-H 100G \u6d4b\u8bd5\uff09\uff0c\u4f1a\u4f7f\u7528\u5185\u5b58\u6620\u5c04\u6587\u4ef6\u6765\u63d0\u9ad8 I/O \u6027\u80fd\u3002Linux \u7cfb\u7edf\u53c2\u6570 vm.max_map_count \u5b9a\u4e49\u4e86\u8fdb\u7a0b\u53ef\u4ee5\u62e5\u6709\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u6570\u91cf\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u8bbe\u7f6e\u5f97\u592a\u4f4e\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u53ef\u80fd\u65e0\u6cd5\u521b\u5efa\u8db3\u591f\u7684\u5185\u5b58\u6620\u5c04\u533a\u57df\u6765\u5904\u7406\u5176\u65e5\u5e38\u64cd\u4f5c\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u5e93\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5982\u5185\u5b58\u4e0d\u8db3 (OOM) \u548c\u8fdb\u7a0b\u5d29\u6e83\u3002\u4e3a\u4e86\u63d0\u9ad8 Matrixone \u5728 Linux \u4e2d\u8fd0\u884c\u7684\u7a33\u5b9a\u6027\uff0c\u5efa\u8bae\u5c06 vm.max_map_count \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u8f83\u9ad8\u7684\u503c\uff0c\u63a8\u8350\u503c\u4e3a 262144\uff0c\u8fd9\u4e2a\u503c\u9002\u7528\u4e8e\u5927\u591a\u6570\u9700\u8981\u5927\u91cf\u5185\u5b58\u6620\u5c04\u7684\u573a\u666f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 sysctl -w vm.max_map_count = 262144
\u4f7f\u5176\u4e34\u65f6\u751f\u6548\uff0c\u6216\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 /etc/sysctl.conf
\u4f7f\u5176\u6c38\u4e45\u751f\u6548\u3002
\u6b64\u8282\u4ecb\u7ecd\u4f7f\u7528 docker \u76f4\u63a5\u62c9\u53d6 MatrixOne \u955c\u50cf\u548c\u4f7f\u7528 mo_ctl \u5de5\u5177\u4e24\u79cd\u90e8\u7f72\u65b9\u5f0f
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#docker_2","title":"docker \u90e8\u7f72","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u4ece Docker Hub \u4e2d\u62c9\u53d6 MatrixOne \u955c\u50cf\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff0c\u6216\u5f00\u53d1\u7248\u672c\u955c\u50cf\uff0c\u5f53 Tag \u4e3a latest
\u65f6\u83b7\u53d6\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002
docker pull matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.2.1\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\n
\u83b7\u53d6\u6700\u65b0\u5f00\u53d1\u7248\u672c\u7684\u955c\u50cf\uff0c\u53c2\u89c1Docker Hub\uff0c\u627e\u5230\u6700\u65b0Tag\uff0c\u62c9\u53d6\u955c\u50cf\u3002\u62c9\u53d6\u955c\u50cf\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u5f00\u53d1\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n
Note: \u5982\u4e0a\u9762\u4ee3\u7801\u6240\u793a\uff0cnightly \u4e3a\u6807\u8bc6\u7684 Tag \u7248\u672c\u6bcf\u5929\u90fd\u8fdb\u884c\u66f4\u65b0\uff0c\u8bf7\u6ce8\u610f\u83b7\u53d6\u6700\u65b0\u7684\u955c\u50cf\u3002
\u82e5 Docker \u7248\u672c\u4f4e\u4e8e 20.10.18 \u6216\u8005 Docker client \u548c Docker server \u7684\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u63a8\u8350\u540c\u65f6\u5347\u7ea7\u5230 Docker \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u540e\u518d\u5c1d\u8bd5\u3002\u82e5\u575a\u6301\u4f7f\u7528\uff0c\u9700\u8981\u5728 docker run
\u547d\u4ee4\u4e2d\u52a0\u4e0a\u53c2\u6570 --privileged=true
\uff0c\u5982\uff1a
docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.2.1\n
\u5982\u9700\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u6216\u914d\u7f6e\u81ea\u5b9a\u4e49\u6587\u4ef6\uff0c\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#mo_ctl","title":"mo_ctl \u90e8\u7f72","text":"mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_CONTAINER_DATA_HOST_PATH=\"/yourpath/mo/\" # \u5bbf\u4e3b\u673amo\u7684\u6570\u636e\u76ee\u5f55\nmo_ctl set_conf MO_CONTAINER_IMAGE=\"matrixorigin/matrixone:1.2.1\" # \u8bbe\u7f6e\u955c\u50cf\uff0c\u56fd\u5185\u7684\u53ef\u4ee5\u7528registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1 \nmo_ctl set_conf MO_DEPLOY_MODE=docker #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3adocker\u90e8\u7f72\u65b9\u5f0f\n
\u4ee5\u4e0b\u4e3a\u53ef\u9009\u53c2\u6570\uff1a
MO_CONTAINER_NAME=\"mo\" # mo \u5bb9\u5668\u540d\nMO_CONTAINER_PORT=\"6001\" # mo \u7aef\u53e3\u53f7\nMO_CONTAINER_DEBUG_PORT=\"12345\" #\u5bb9\u5668\u5185 debug \u7aef\u53e3\nMO_CONTAINER_CONF_HOST_PATH=\"\" # \u5bbf\u4e3b\u673a mo \u7684\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff0c\u9700\u8981\u53c2\u8003\nMO_CONTAINER_CONF_CON_FILE=\"/etc/quickstart/launch.toml\" # \u5bb9\u5668\u5185\u914d\u7f6e\u6587\u4ef6\nMO_CONTAINER_LIMIT_MEMORY=\"\" # \u5185\u5b58\u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1am\nMO_CONTAINER_MEMORY_RATIO=90 # \u5982\u679c\u4e0d\u8bbe\u7f6e\u5185\u5b58\u5927\u5c0f\uff0c\u5c31\u4f1a\u6839\u636e\u8fd9\u4e2a\u503c\u6765\u8bbe\u7f6e\u4e3b\u673a\u7684 x% \u5185\u5b58\uff0c\u9ed8\u8ba4 90%\nMO_CONTAINER_AUTO_RESTART=\"yes\" # \u662f\u5426\u8bbe\u7f6e\u5bb9\u5668\u81ea\u52a8\u91cd\u542f\nMO_CONTAINER_LIMIT_CPU=\"\" # cpu \u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1a\u6838\u6570\nMO_CONTAINER_EXTRA_MOUNT_OPTION=\"\" #\u989d\u5916\u7684\u6302\u8f7d\u53c2\u6570\uff0c\u6bd4\u5982 -v xx:xx:xx\n
\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
mo_ctl start\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u8fde\u63a5 MatrixOne","text":"\u9664\u4e86\u53ef\u4ee5\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u6765\u8fde\u63a5 MatrixOne\uff0c\u5728\u5df2\u90e8\u7f72 mo_ctl \u5de5\u5177\u7684\u60c5\u51b5\u4e0b\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 mo_ctl \u5de5\u5177\u6765\u8fde\u63a5 MatrixOne\u3002\u6b64\u8282\u4ecb\u7ecd\u4e24\u79cd\u8fde\u63a5\u65b9\u5f0f\u7684\u5177\u4f53\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#mysql","title":"MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u8fde\u63a5","text":"mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: # \u521d\u59cb\u5bc6\u7801\u9ed8\u8ba4\u4e3a 111\n
\u8fde\u63a5\u6210\u529f\u5c06\u8fd4\u56de\u4ee5\u4e0b\u4fe1\u606f\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5982\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
\u76ee\u524d\uff0cMatrixOne \u53ea\u652f\u6301 TCP \u76d1\u542c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#mo_ctl_1","title":"mo_ctl \u5de5\u5177\u8fde\u63a5","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
mo_ctl connect\n2024-03-08 11:13:34.347 UTC+0800 [INFO] Checking connectivity\n2024-03-08 11:13:34.420 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5849\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u6e90\u4ee3\u7801\u5728 macOS \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002\u6211\u4eec\u5c06\u91c7\u7528 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u7684 macOS \u7cfb\u7edf\uff0c\u672c\u6587\u4ee5 Macbook M1 ARM \u7248\u672c\u4e3a\u4f8b\u5b50\u5c55\u793a\u6574\u4e2a\u90e8\u7f72\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#_1","title":"\u524d\u7f6e\u4f9d\u8d56\u53c2\u8003","text":"\u901a\u8fc7\u6e90\u7801\u5b89\u88c5\u53ca\u4f7f\u7528\u5355\u673a\u7248 MatrixOne\uff0c\u9700\u8981\u4f9d\u8d56\u4e8e\u4ee5\u4e0b\u4e00\u4e9b\u8f6f\u4ef6\u5305\u3002
\u4f9d\u8d56\u8f6f\u4ef6 \u7248\u672c golang 1.22.3 \u53ca\u4ee5\u4e0a gcc/clang gcc8.5 \u53ca\u4ee5\u4e0a\uff0cclang13.0 \u53ca\u4ee5\u4e0a git 2.20 \u53ca\u4ee5\u4e0a MySQL Client 8.0 \u53ca\u4ee5\u4e0a"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#1","title":"\u6b65\u9aa4 1\uff1a\u5b89\u88c5\u4f9d\u8d56","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#1-go","title":"1. \u5b89\u88c5\u90e8\u7f72 Go \u8bed\u8a00","text":"\u70b9\u51fb Go Download and install \u8fdb\u5165\u5230 Go \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 Go \u8bed\u8a00\u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 Go \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 go version
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff1a
> go version\ngo version go1.22.3 darwin/arm64\n
macOS \u4e2d\u4e00\u822c\u5df2\u7ecf\u81ea\u5e26 Clang \u7f16\u8bd1\u5668\uff0c\u5176\u4e0e GCC \u57fa\u672c\u8d77\u5230\u76f8\u540c\u4f5c\u7528\u3002\u9a8c\u8bc1 GCC/Clang \u73af\u5883\u662f\u5426\u9700\u8981\u5b89\u88c5\uff1a
gcc -v\nbash: gcc: command not found\n
\u5982\u4ee3\u7801\u6240\u793a\uff0c\u672a\u663e\u793a GCC \u6216 Clang \u7684\u7248\u672c\uff0c\u5219\u8868\u793a GCC/Clang \u7684\u73af\u5883\u9700\u8981\u5b89\u88c5\u3002
\u4f60\u53ef\u4ee5\u9009\u62e9\u70b9\u51fb GCC Download and install \u8fdb\u5165\u5230 GCC \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 GCC \u7684\u5b89\u88c5\u3002\u6216\u8005\u4e5f\u53ef\u4ee5\u901a\u8fc7 Apple \u5b98\u65b9\u7684 Xcode \u8fdb\u884c Clang \u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 GCC/Clang \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 gcc -v
\uff0c\u65e0\u8bba\u663e\u793a\u7684\u662f Clang \u6216\u8005 GCC \u7248\u672c\u5747\u8bf4\u660e\u5b89\u88c5\u6210\u529f\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
Apple clang version 14.0.3 (clang-1403.0.22.14.1)\nTarget: arm64-apple-darwin22.5.0\nThread model: posix\nInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n
\u901a\u8fc7\u5b98\u65b9\u6587\u6863\u5b89\u88c5 Git\u3002
\u4f7f\u7528 git version
\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
> git version\ngit version 2.40.0\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#4-mysql-client","title":"4. \u5b89\u88c5 MySQL Client","text":"\u70b9\u51fb MySQL Community Downloads\uff0c\u8fdb\u5165\u5230 MySQL \u5ba2\u6237\u7aef\u4e0b\u8f7d\u5b89\u88c5\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\u73af\u5883\uff0c\u4e0b\u62c9\u9009\u62e9 Select Operating System > macOS\uff0c\u518d\u4e0b\u62c9\u9009\u62e9 Select OS Version\uff0c\u6309\u9700\u9009\u62e9\u4e0b\u8f7d\u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u73af\u5883\u53d8\u91cf\uff1a
\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
vim ~/.bash_profile\n
\u56de\u8f66\u6267\u884c\u4e0a\u9762\u7684\u547d\u4ee4\u540e\uff0c\u5373\u8fdb\u5165\u4e86 bash_profile\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 i \u8fdb\u5165 insert \u72b6\u6001\uff0c\u5373\u53ef\u5728\u6587\u4ef6\u4e0b\u65b9\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
export PATH=${PATH}:/usr/local/mysql/bin\n
\u8f93\u5165\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 esc \u9000\u51fa insert \u72b6\u6001\uff0c\u5e76\u5728\u6700\u4e0b\u65b9\u8f93\u5165 :wq
\u4fdd\u5b58\u9000\u51fa\u3002
\u6267\u884c\u547d\u4ee4 source ~/.bash_profile
\uff0c\u56de\u8f66\u6267\u884c\uff0c\u8fd0\u884c\u73af\u5883\u53d8\u91cf\u3002
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff1a
\u6267\u884c\u547d\u4ee4 mysql --version
\uff0c\u5b89\u88c5\u6210\u529f\u63d0\u793a\uff1amysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)
\u3002
mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u5148\u5b89\u88c5 wget
\u4e0b\u8f7d\u5de5\u5177\uff1a\u8fdb\u5165\u5230 Homebrew \u9875\u9762\u6309\u7167\u6b65\u9aa4\u63d0\u793a\uff0c\u5148\u5b89\u88c5 Homebrew\uff0c\u518d\u5b89\u88c5 wget
\u3002\u9a8c\u8bc1 wget
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c\uff08\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801\uff09\u5982\u4e0b\uff1a
GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1\u3002\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\uff1a
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u5b89\u88c5\u5b8c\u6210\u4ee5\u540e\uff0c\u901a\u8fc7 mo_ctl
\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\uff0c\u6210\u529f\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
> mo_ctl\n Usage : mo_ctl [option_1] [option_2]\n\n [option_1] : available: auto_backup | auto_clean_logs | backup | clean_backup | clean_logs | connect | csv_convert | ddl_convert | deploy | get_branch | get_cid | get_conf | help | monitor | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | version | watchdog\n auto_backup : setup a crontab task to backup your databases automatically\n auto_clean_logs : set up a crontab task to clean system log table data automatically\n backup : create a backup of your databases manually\n build_image : build an MO image from source code\n clean_backup : clean old backups older than conf 31 days manually\n clean_logs : clean system log table data manually\n connect : connect to mo via mysql client using connection info configured\n csv_convert : convert a csv file to a sql file in format \"insert into values\" or \"load data inline format='csv'\"\n ddl_convert : convert a ddl file to mo format from other types of database\n deploy : deploy mo onto the path configured\n get_branch : upgrade or downgrade mo from current version to a target commit id or stable version\n get_cid : print mo git commit id from the path configured\n get_conf : get configurations\n help : print help information\n monitor : monitor system related operations\n pprof : collect pprof information\n precheck : check pre-requisites for mo_ctl\n restart : a combination operation of stop and start\n set_conf : set configurations\n sql : execute sql from string, or a file or a path containg multiple files\n start : start mo-service from the path configured\n status : check if there's any mo process running on this machine\n stop : stop all mo-service processes found on this machine\n uninstall : uninstall mo from path MO_PATH=/Users/admin/mo//matrixone\n upgrade : upgrade or downgrade mo from current version to a target commit id or stable version\n version : show mo_ctl and matrixone version\n watchdog : setup a watchdog crontab task for mo-service to keep it alive\n e.g. : mo_ctl status\n\n [option_2] : Use \" mo_ctl [option_1] help \" to get more info\n e.g. : mo_ctl deploy help\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#mo_ctl","title":"\u8bbe\u7f6e mo_ctl \u7684\u914d\u7f6e\u53c2\u6570","text":"mo_ctl \u5de5\u5177\u4e2d\u6709\u90e8\u5206\u53c2\u6570\u53ef\u80fd\u9700\u8981\u4f60\u8fdb\u884c\u8c03\u6574\u8bbe\u7f6e\uff0c\u901a\u8fc7 mo_ctl get_conf
\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u5f53\u524d\u53c2\u6570\u3002
> mo_ctl get_conf\n2023-07-07_15:31:24 [INFO] Below are all configurations set in conf file /Users/username/mo_ctl/conf/env.sh\nMO_PATH=\"/Users/username/mo/matrixone\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.22.3\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"v1.2.1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n
\u9700\u8981\u8c03\u6574\u7684\u53c2\u6570\u5982\u4e0b\uff1a
mo_ctl set_conf MO_PATH=\"yourpath\" # \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u7684MatrixOne\u4e0b\u8f7d\u8def\u5f84\nmo_ctl set_conf MO_GIT_URL=\"https://githubfast.com/matrixorigin/matrixone.git\" #\u9488\u5bf9github\u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\u95ee\u9898\uff0c\u8bbe\u7f6e\u955c\u50cf\u4e0b\u8f7d\u5730\u5740\nmo_ctl set_conf MO_DEFAULT_VERSION=\"v1.2.1\" # \u8bbe\u7f6e\u6240\u4e0b\u8f7d\u7684MatrixOne\u7248\u672c\nmo_ctl set_conf MO_DEPLOY_MODE=git #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u6e90\u7801\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u4e00\u952e\u5b89\u88c5 MatrixOne","text":"\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/matrixone/logs/
\u4e2d\u3002
> mo_ctl start\n2023-07-07_15:33:45 [INFO] No mo-service is running\n2023-07-07_15:33:45 [INFO] Starting mo-service: cd /Users/username/mo/matrixone/matrixone/ && /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml >/Users/username/mo/matrixone/matrixone/logs/stdout-20230707_153345.log 2>/Users/username/mo/matrixone/matrixone/logs/stderr-20230707_153345.log\n2023-07-07_15:33:45 [INFO] Wait for 2 seconds\n2023-07-07_15:33:48 [INFO] At least one mo-service is running. Process info:\n2023-07-07_15:33:48 [INFO] 501 66932 1 0 3:33PM ?? 0:00.27 /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_15:33:48 [INFO] Pids:\n2023-07-07_15:33:48 [INFO] 66932\n2023-07-07_15:33:48 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
> mo_ctl connect\n2023-07-07_10:30:20 [INFO] Checking connectivity\n2023-07-07_10:30:20 [INFO] Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u5728 macOS \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\uff0c\u8fd9\u79cd\u5b89\u88c5\u65b9\u6848\u65e0\u9700\u5b89\u88c5\u524d\u7f6e\u4f9d\u8d56\u548c\u7f16\u8bd1\u6e90\u7801\u5305\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u4e24\u79cd\u67b6\u6784\u7684 macOS \u7cfb\u7edf\uff0c\u672c\u6587\u4ee5 Macbook M1 ARM \u7248\u672c\u4e3a\u4f8b\u5c55\u793a\u6574\u4e2a\u90e8\u7f72\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#_1","title":"\u524d\u7f6e\u4f9d\u8d56\u53c2\u8003","text":"\u901a\u8fc7\u4e8c\u8fdb\u5236\u5305\u90e8\u7f72\u548c\u5b89\u88c5 MatrixOne\uff0c\u4ec5\u9700\u5b89\u88c5 MySQL Client
\u5de5\u5177\u3002
\u70b9\u51fb MySQL Community Downloads\uff0c\u8fdb\u5165\u5230 MySQL \u5ba2\u6237\u7aef\u4e0b\u8f7d\u5b89\u88c5\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\u73af\u5883\uff0c\u4e0b\u62c9\u9009\u62e9 Select Operating System > macOS\uff0c\u518d\u4e0b\u62c9\u9009\u62e9 Select OS Version\uff0c\u6309\u9700\u9009\u62e9\u4e0b\u8f7d\u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u73af\u5883\u53d8\u91cf\uff1a
vim ~/.bash_profile\n
export PATH=${PATH}:/usr/local/mysql/bin\n
\u8f93\u5165\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 esc \u9000\u51fa insert \u72b6\u6001\uff0c\u5e76\u5728\u6700\u4e0b\u65b9\u8f93\u5165 :wq
\u4fdd\u5b58\u9000\u51fa\u3002
\u6267\u884c\u547d\u4ee4 source ~/.bash_profile
\uff0c\u56de\u8f66\u6267\u884c\uff0c\u8fd0\u884c\u73af\u5883\u53d8\u91cf\u3002
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff1a
\u6267\u884c\u547d\u4ee4 mysql --version
\uff0c\u5b89\u88c5\u6210\u529f\u63d0\u793a\uff1amysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)
\u3002
Tips: \u5efa\u8bae\u4f60\u4e0b\u8f7d\u5b89\u88c5\u8fd9\u4e24\u4e2a\u4e0b\u8f7d\u5de5\u5177\u5176\u4e2d\u4e4b\u4e00\uff0c\u65b9\u4fbf\u540e\u7eed\u901a\u8fc7\u547d\u4ee4\u884c\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u3002
\u5b89\u88c5wget
\u5b89\u88c5 curl
wget
\u5de5\u5177\u7528\u6765\u4ece\u6307\u5b9a\u7684 URL \u4e0b\u8f7d\u6587\u4ef6\u3002wget
\u662f\u4e13\u95e8\u7684\u6587\u4ef6\u4e0b\u8f7d\u5de5\u5177\uff0c\u5b83\u975e\u5e38\u7a33\u5b9a\uff0c\u800c\u4e14\u4e0b\u8f7d\u901f\u5ea6\u5feb\u3002
\u8fdb\u5165\u5230Homebrew\u9875\u9762\u6309\u7167\u6b65\u9aa4\u63d0\u793a\uff0c\u5148\u5b89\u88c5 Homebrew\uff0c\u518d\u5b89\u88c5 wget
\u3002 \u9a8c\u8bc1 wget
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1\u3002\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n
curl
\u662f\u4e00\u4e2a\u5229\u7528 URL \u89c4\u5219\u5728\u547d\u4ee4\u884c\u4e0b\u5de5\u4f5c\u7684\u6587\u4ef6\u4f20\u8f93\u5de5\u5177\u3002curl
\u662f\u7efc\u5408\u4f20\u8f93\u5de5\u5177\uff0c\u652f\u6301\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d\u3002
\u8fdb\u5165\u5230Curl\u5b98\u7f51\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5 curl
\u3002 \u9a8c\u8bc1 curl
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
curl --version\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
curl 7.84.0 (x86_64-apple-darwin22.0) libcurl/7.84.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0\nRelease-Date: 2022-06-27\n...\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#2_1","title":"2. \u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u5e76\u89e3\u538b","text":"\u4e0b\u8f7d\u65b9\u5f0f\u4e00\u548c\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\u9700\u8981\u5148\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177 wget
\u6216 curl
\uff0c\u5982\u679c\u4f60\u672a\u5b89\u88c5\uff0c\u8bf7\u5148\u81ea\u884c\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177\u3002
wget
\u5de5\u5177\u4e0b\u8f7d\u5b89\u88c5\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e09\uff1a\u9875\u9762\u4e0b\u8f7d x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-x86_64.zip\nunzip mo-v1.2.1-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-arm64.zip\nunzip mo-v1.2.1-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-x86_64.zip\nunzip mo-v1.2.1-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-arm64.zip\nunzip mo-v1.2.1-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-xxx.zip\n
\u5982\u679c\u4f60\u60f3\u901a\u8fc7\u66f4\u76f4\u89c2\u7684\u9875\u9762\u4e0b\u8f7d\u7684\u65b9\u5f0f\u4e0b\u8f7d\uff0c\u76f4\u63a5\u70b9\u51fb\u8fdb\u5165\u7248\u672c 1.2.1\uff0c\u4e0b\u62c9\u627e\u5230 Assets \u680f\uff0c\u70b9\u51fb\u5b89\u88c5\u5305 mo-v1.2.1-darwin-x86_64.zip \u6216 mo-v1.2.1-darwin-arm64.zip \u4e0b\u8f7d\u5373\u53ef\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#3-mo_ctl","title":"\u6b65\u9aa4 3\uff1a\u5b89\u88c5 mo_ctl \u5de5\u5177","text":"mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_PATH=\"/yourpath/mo-v1.2.1-xx-xx\" #\u8bbe\u7f6eMatrixOne\u8def\u5f84\u4e3a\u4e8c\u8fdb\u5236\u89e3\u538b\u6587\u4ef6\u76ee\u5f55\nmo_ctl set_conf MO_CONF_FILE=\"/yourpath/mo-v1.2.1-xx-xx/etc/launch/launch.toml\" #\u8bbe\u7f6eMatrixOne\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\nmo_ctl set_conf MO_DEPLOY_MODE=binary #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u4e8c\u8fdb\u5236\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/mo-v1.2.1-xx-xx/matrixone/logs/
\u4e2d\u3002
> mo_ctl start\n2024-03-07 14:34:04.942 UTC+0800 [INFO] No mo-service is running\n2024-03-07 14:34:04.998 UTC+0800 [INFO] Get conf succeeded: MO_DEPLOY_MODE=\"binary\"\n2024-03-07 14:34:05.024 UTC+0800 [INFO] GO memory limit(Mi): 14745\n2024-03-07 14:34:05.072 UTC+0800 [INFO] Starting mo-service: cd /Users/admin/mo-v1.2.1-darwin-arm64/ && GOMEMLIMIT=14745MiB /Users/admin/mo-v1.2.1-darwin-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-darwin-arm64/etc/launch/launch.toml >/Users/admin/mo-v1.2.1-darwin-arm64/matrixone/logs/stdout-20240307_143405.log 2>/Users/admin/mo-v1.2.1-darwin-arm64/matrixone/logs/stderr-20240307_143405.log\n2024-03-07 14:34:05.137 UTC+0800 [INFO] Wait for 2 seconds\n2024-03-07 14:34:07.261 UTC+0800 [INFO] At least one mo-service is running. Process info: \n 501 27145 1 0 2:34\u4e0b\u5348 ?? 0:00.18 /Users/admin/mo-v1.2.1-darwin-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-darwin-arm64/etc/launch/launch.toml\n2024-03-07 14:34:07.284 UTC+0800 [INFO] List of pid(s): \n27145\n2024-03-07 14:34:07.308 UTC+0800 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
> mo_ctl connect\n2024-03-07 14:34:59.902 UTC+0800 [INFO] Checking connectivity\n2024-03-07 14:34:59.942 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 426\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 Docker \u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#1","title":"\u6b65\u9aa4 1\uff1a\u524d\u7f6e\u6761\u4ef6","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#docker_1","title":"\u5b89\u88c5 docker","text":"\u70b9\u51fb Get Docker\uff0c\u8fdb\u5165 Docker \u7684\u5b98\u65b9\u6587\u6863\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4e0b\u8f7d\u5b89\u88c5\u5bf9\u5e94\u7684 Docker\uff0cDocker \u7248\u672c\u63a8\u8350\u9009\u62e9\u5728 20.10.18 \u53ca\u4ee5\u4e0a\uff0c\u4e14\u5c3d\u91cf\u4fdd\u6301 Docker client \u548c Docker server \u7684\u7248\u672c\u4e00\u81f4\u3002
\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4e0b\u8ff0\u4ee3\u7801\u884c\u786e\u8ba4 Docker \u7248\u672c\uff0c\u9a8c\u8bc1 Docker \u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a
docker --version\n
\u5b89\u88c5\u6210\u529f\uff0c\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
Docker version 20.10.18, build 100c701\n
\u76f4\u63a5\u6253\u5f00\u4f60\u672c\u5730 Docker \u5ba2\u6237\u7aef\uff0c\u542f\u52a8 Docker\u3002
\u70b9\u51fb MySQL Community Downloads\uff0c\u8fdb\u5165\u5230 MySQL \u5ba2\u6237\u7aef\u4e0b\u8f7d\u5b89\u88c5\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\u73af\u5883\uff0c\u4e0b\u62c9\u9009\u62e9 Select Operating System > macOS\uff0c\u518d\u4e0b\u62c9\u9009\u62e9 Select OS Version\uff0c\u6309\u9700\u9009\u62e9\u4e0b\u8f7d\u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u73af\u5883\u53d8\u91cf\uff1a
\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
vim ~/.bash_profile\n
\u56de\u8f66\u6267\u884c\u4e0a\u9762\u7684\u547d\u4ee4\u540e\uff0c\u5373\u8fdb\u5165\u4e86 bash_profile\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 i \u8fdb\u5165 insert \u72b6\u6001\uff0c\u5373\u53ef\u5728\u6587\u4ef6\u4e0b\u65b9\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
export PATH=${PATH}:/usr/local/mysql/bin\n
\u8f93\u5165\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 esc \u9000\u51fa insert \u72b6\u6001\uff0c\u5e76\u5728\u6700\u4e0b\u65b9\u8f93\u5165 :wq
\u4fdd\u5b58\u9000\u51fa\u3002
\u6267\u884c\u547d\u4ee4 source ~/.bash_profile
\uff0c\u56de\u8f66\u6267\u884c\uff0c\u8fd0\u884c\u73af\u5883\u53d8\u91cf\u3002
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff1a
\u6267\u884c\u547d\u4ee4 mysql --version
\uff0c\u5b89\u88c5\u6210\u529f\u63d0\u793a\uff1amysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)
\u3002
\u6b64\u8282\u4ecb\u7ecd\u4f7f\u7528 docker \u76f4\u63a5\u62c9\u53d6 MatrixOne \u955c\u50cf\u548c\u4f7f\u7528 mo_ctl \u5de5\u5177\u90e8\u7f72\u4e24\u79cd\u65b9\u5f0f
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#docker_2","title":"docker \u90e8\u7f72","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u4ece Docker Hub \u4e2d\u62c9\u53d6 MatrixOne \u955c\u50cf\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff0c\u6216\u5f00\u53d1\u7248\u672c\u955c\u50cf\uff0c\u5f53 Tag \u4e3a latest
\u65f6\u83b7\u53d6\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002
docker pull matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.2.1\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\n
\u83b7\u53d6\u6700\u65b0\u5f00\u53d1\u7248\u672c\u7684\u955c\u50cf\uff0c\u53c2\u89c1Docker Hub\uff0c\u627e\u5230\u6700\u65b0Tag\uff0c\u62c9\u53d6\u955c\u50cf\u3002\u62c9\u53d6\u955c\u50cf\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u5f00\u53d1\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n
Note: \u5982\u4e0a\u9762\u4ee3\u7801\u6240\u793a\uff0cnightly \u4e3a\u6807\u8bc6\u7684 Tag \u7248\u672c\u6bcf\u5929\u90fd\u8fdb\u884c\u66f4\u65b0\uff0c\u8bf7\u6ce8\u610f\u83b7\u53d6\u6700\u65b0\u7684\u955c\u50cf\u3002
\u82e5 Docker \u7248\u672c\u4f4e\u4e8e 20.10.18 \u6216\u8005 Docker client \u548c Docker server \u7684\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u63a8\u8350\u540c\u65f6\u5347\u7ea7\u5230 Docker \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u540e\u518d\u5c1d\u8bd5\u3002\u82e5\u575a\u6301\u4f7f\u7528\uff0c\u9700\u8981\u5728 docker run
\u547d\u4ee4\u4e2d\u52a0\u4e0a\u53c2\u6570 --privileged=true
\uff0c\u5982\uff1a
docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.2.1\n
\u5982\u9700\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u6216\u914d\u7f6e\u81ea\u5b9a\u4e49\u6587\u4ef6\uff0c\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#mo_ctl","title":"mo_ctl \u90e8\u7f72","text":"mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_CONTAINER_DATA_HOST_PATH=\"/yourpath/mo/\" # \u5bbf\u4e3b\u673amo\u7684\u6570\u636e\u76ee\u5f55\nmo_ctl set_conf MO_CONTAINER_IMAGE=\"matrixorigin/matrixone:1.2.1\" # \u8bbe\u7f6e\u955c\u50cf\uff0c\u56fd\u5185\u7684\u53ef\u4ee5\u7528registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\nmo_ctl set_conf MO_DEPLOY_MODE=docker #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3adocker\u90e8\u7f72\u65b9\u5f0f\n
\u4ee5\u4e0b\u4e3a\u53ef\u9009\u53c2\u6570\uff1a
MO_CONTAINER_NAME=\"mo\" # mo \u5bb9\u5668\u540d\nMO_CONTAINER_PORT=\"6001\" # mo \u7aef\u53e3\u53f7\nMO_CONTAINER_DEBUG_PORT=\"12345\" #\u5bb9\u5668\u5185 debug \u7aef\u53e3\nMO_CONTAINER_CONF_HOST_PATH=\"\" # \u5bbf\u4e3b\u673a mo \u7684\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff0c\u9700\u8981\u53c2\u8003\nMO_CONTAINER_CONF_CON_FILE=\"/etc/quickstart/launch.toml\" # \u5bb9\u5668\u5185\u914d\u7f6e\u6587\u4ef6\nMO_CONTAINER_LIMIT_MEMORY=\"\" # \u5185\u5b58\u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1am\nMO_CONTAINER_MEMORY_RATIO=90 # \u5982\u679c\u4e0d\u8bbe\u7f6e\u5185\u5b58\u5927\u5c0f\uff0c\u5c31\u4f1a\u6839\u636e\u8fd9\u4e2a\u503c\u6765\u8bbe\u7f6e\u4e3b\u673a\u7684 x% \u5185\u5b58\uff0c\u9ed8\u8ba4 90%\nMO_CONTAINER_AUTO_RESTART=\"yes\" # \u662f\u5426\u8bbe\u7f6e\u5bb9\u5668\u81ea\u52a8\u91cd\u542f\nMO_CONTAINER_LIMIT_CPU=\"\" # cpu \u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1a\u6838\u6570\nMO_CONTAINER_EXTRA_MOUNT_OPTION=\"\" #\u989d\u5916\u7684\u6302\u8f7d\u53c2\u6570\uff0c\u6bd4\u5982 -v xx:xx:xx\n
\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
mo_ctl start\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u8fde\u63a5 MatrixOne","text":"\u9664\u4e86\u53ef\u4ee5\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u6765\u8fde\u63a5 MatrixOne\uff0c\u5728\u5df2\u90e8\u7f72 mo_ctl \u5de5\u5177\u7684\u60c5\u51b5\u4e0b\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 mo_ctl \u5de5\u5177\u6765\u8fde\u63a5 MatrixOne\u3002\u6b64\u8282\u4ecb\u7ecd\u4e24\u79cd\u8fde\u63a5\u65b9\u5f0f\u7684\u5177\u4f53\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#mysql","title":"MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u8fde\u63a5","text":"mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: # \u521d\u59cb\u5bc6\u7801\u9ed8\u8ba4\u4e3a 111\n
\u8fde\u63a5\u6210\u529f\u5c06\u8fd4\u56de\u4ee5\u4e0b\u4fe1\u606f\uff1a
>mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5982\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
\u76ee\u524d\uff0cMatrixOne \u53ea\u652f\u6301 TCP \u76d1\u542c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#mo_ctl_1","title":"mo_ctl \u5de5\u5177\u8fde\u63a5","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
mo_ctl connect\n2024-03-08 11:13:34.347 UTC+0800 [INFO] Checking connectivity\n2024-03-08 11:13:34.420 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5849\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u5b8c\u6210 MatrixOne \u642d\u5efa\u548c\u8fde\u63a5\u540e\uff0c\u9996\u6b21\u6267\u884c\u65f6\uff0cMatrixOne \u4f1a\u81ea\u52a8\u751f\u6210\u4ee5\u4e0b\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u653e\u5404\u7c7b\u6570\u636e\u6587\u4ef6\u6216\u5143\u6570\u636e\u4fe1\u606f\u3002
\u8fdb\u5165 matrixone \u76ee\u5f55\u6267\u884c ls
\u67e5\u770b\u76ee\u5f55\u7ed3\u6784\uff0c\u76f8\u5173\u76ee\u5f55\u7ed3\u6784\u4ee5\u53ca\u7528\u9014\u5982\u4e0b\uff1a
matrixone \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne \u4e3b\u76ee\u5f55 |-- etc \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- quickstart \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 |-- mo-data \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u6570\u636e\u6587\u4ef6\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- local \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u672c\u5730 fileservice \u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- cnservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//cn \u8282\u70b9\u4fe1\u606f\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- tnservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//tn \u8282\u70b9\u4fe1\u606f\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- etl \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5916\u90e8\u8868\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- sys \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5916\u90e8\u8868\u4fe1\u606f\u5f52\u5c5e\u4e8e\u54ea\u4e2a\u79df\u6237 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- logs \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u7c7b\u578b \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5e74\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u6708\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5929\u6570 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u8def\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- merged \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u8fc7\u5f80\u5916\u90e8\u8868\u4fe1\u606f\u7684\u5408\u5e76\u8bb0\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5e74\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u6708\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5929\u6570 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u8def\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- logservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice \u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 7c4dccb4-4d3c-41f8-b482-5251dc7a41bf \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice \u8282\u70b9\u5bf9\u5e94\u76ee\u5f55\uff08\u968f\u673a\u751f\u6210 uuid\uff09 \u2502\u00a0\u00a0\u00a0\u00a0 |--hostname \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne \u7684\u670d\u52a1\u5668\u57df\u540d \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 00000000000000000001 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5feb\u7167\u4fdd\u5b58\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- exported-snapshot \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5bfc\u51fa\u5feb\u7167\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- snapshot-part-n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5feb\u7167\u5206\u90e8\u4fdd\u5b58\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- tandb \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//bootstrap \u4fe1\u606f\u4fdd\u5b58\u76ee\u5f55 |-- s3 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u6570\u636e\u4fdd\u5b58\u76ee\u5f55
"},{"location":"MatrixOne/Maintain/mount-data-by-docker/","title":"\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5728\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne \u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u4f55\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u6216\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u5230 Docker \u5bb9\u5668\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cDocker \u4e0d\u80fd\u5bf9\u5df2\u7ecf\u542f\u52a8\u8fc7\u7684\u5bb9\u5668\u8fdb\u884c\u6302\u8f7d\uff0c\u82e5\u60f3\u8981\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u5219\u9700\u8981\u91cd\u65b0\u521b\u5efa\u4e00\u4e2a Docker \u5bb9\u5668\u3002
"},{"location":"MatrixOne/Maintain/mount-data-by-docker/#_1","title":"\u6302\u8f7d\u6570\u636e\u76ee\u5f55","text":"\u53c2\u8003\u4ee5\u4e0b\u8be6\u7ec6\u6b65\u9aa4\uff0c\u6302\u8f7d\u672c\u5730\u6570\u636e\u76ee\u5f55\u5230 Docker \u5bb9\u5668\uff1a
\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u7a7a\u76ee\u5f55 ${local_data_path}/mo-data\uff0c\u5176\u4e2d ${local_data_path} \u4e3a\u4f60\u7684\u672c\u5730\u6587\u4ef6\u5939\u8def\u5f84\u3002\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
mkdir ${local_data_path}/mo-data\n
\u628a\u672c\u5730\u7a7a\u76ee\u5f55 ${local_data_path}/mo-data \u6302\u8f7d\u5230 Docker \u5bb9\u5668\u76ee\u5f55 /mo-data \u4e0b\uff0c\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
sudo docker run --name <name> -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:1.2.1\n
\u53c2\u6570 \u63cf\u8ff0 ${local_data_path}/mo-data:/mo-data \u6302\u8f7d\u672c\u5730\u6570\u636e\u76ee\u5f55 ${local_data_path}/mo-data \u5230\u5bb9\u5668 /mo-data \u6587\u4ef6\u5939 Tips: \u9700\u8981\u6302\u8f7d\u7684\u672c\u5730\u6570\u636e\u76ee\u5f55\u5fc5\u987b\u4e3a\u7a7a\u76ee\u5f55\u3002 \u5982\u679c\u4f60\u9700\u8981\u4fee\u6539\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\uff0c\u5efa\u8bae\u4f60\u5148\u5c06 Docker \u5185\u7684\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u62f7\u8d1d\u5230\u4f60\u672c\u5730\u76ee\u5f55\uff0c\u7136\u540e\u5c06\u5b58\u653e\u914d\u7f6e\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u6302\u8f7d\u5230 Docker \u5bb9\u5668\u76ee\u5f55\u4e0b\uff0c\u53c2\u8003\u4ee5\u4e0b\u8be6\u7ec6\u6b65\u9aa4\uff0c\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6\u5230 Docker \u5bb9\u5668\uff1a
\u9996\u5148\u542f\u52a8\u4e00\u4e2a MatrixOne \u7684\u5bb9\u5668\u5b9e\u4f8b\uff0c\u8fd9\u4e2a\u5bb9\u5668\u5b9e\u4f8b\u5c06\u63d0\u4f9b\u4e00\u5957\u6807\u51c6\u7684\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\uff1a
docker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.2.1\n
\u67e5\u770b Docker \u5df2\u7ecf\u542f\u52a8\u7684 MatrixOne \u7684 containerID\uff0c\u5e76\u5c06\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\u62f7\u8d1d\u5230\u672c\u5730\u76ee\u5f55\u7684 ${local_config_path} \u76ee\u5f55\u4e0b\uff1a
docker ps\ndocker cp <containerID>:/etc/launch ${local_config_path}\n
\u62f7\u8d1d\u5b8c\u6210\u540e\uff0c\u5173\u505c\u5e76\u9500\u6bc1\u5f53\u524d\u7684 MatrixOne\uff1a
docker stop <containerID>\ndocker rm <containerID>\n
\uff08\u9009\u505a\uff09\u82e5\u9700\u8981\u4fee\u6539\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\uff0c\u5219\u4fee\u6539\u672c\u5730\u76ee\u5f55 ${local_config_path}/launch \u4e0b\u7684\u914d\u7f6e\u6587\u4ef6\u5e76\u4fdd\u5b58\u3002
\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6\u5230 Docker \u5bb9\u5668\u76ee\u5f55\uff0c\u540c\u65f6\u521b\u5efa\u5e76\u542f\u52a8 MatrixOne\uff0c\u6302\u8f7d\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
sudo docker run --name <name> -d -p 6001:6001 -v ${local_config_path}/launch:/etc/launch:rw --entrypoint \"/mo-service\" matrixorigin/matrixone:1.2.1 -launch /etc/launch/launch.toml\n
\u53c2\u6570 \u63cf\u8ff0 ${local_config_path}/launch:/etc/launch \u6302\u8f7d\u672c\u5730\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 ${local_config_path}/launch \u5230\u5bb9\u5668 /etc/launch \u6587\u4ef6\u5939 --entrypoint \"/mo-service\" \u5bb9\u5668\u5165\u53e3\u547d\u4ee4\uff0c\u5373\u8ba9\u5bb9\u5668\u542f\u52a8 MatrixOne \u670d\u52a1 -launch /etc/launch/launch.toml \u5bb9\u5668\u5165\u53e3\u547d\u4ee4\u5bf9\u5e94\u7684\u547d\u4ee4\u53c2\u6570\uff0c\u5373\u4f7f\u7528\u5bb9\u5668\u5185 /etc/launch/launch.toml \u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u542f\u52a8 MatrixOne \u670d\u52a1 Note
\u82e5 Docker \u7248\u672c\u4f4e\u4e8e 20.10.18 \u6216\u8005 Docker client \u548c Docker server \u7684\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u63a8\u8350\u540c\u65f6\u5347\u7ea7\u5230 Docker \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u540e\u518d\u5c1d\u8bd5\u3002\u82e5\u575a\u6301\u4f7f\u7528\uff0c\u9700\u8981\u5728 ```docker run``` \u547d\u4ee4\u4e2d\u52a0\u4e0a\u53c2\u6570 ```--privileged=true```\uff0c\u5982\uff1a\n\n```bash\ndocker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.2.1\n```\n
\u66f4\u591a\u5173\u4e8e Docker run \u7684\u6307\u4ee4\u91ca\u4e49\uff0c\u8fd0\u884c\u547d\u4ee4 docker run --help
\u8fdb\u884c\u67e5\u770b\u3002
\u6570\u636e\u5e93\u5907\u4efd\u4e0e\u6062\u590d\u662f\u4efb\u4f55\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u6838\u5fc3\u64cd\u4f5c\u4e4b\u4e00\uff0c\u4e5f\u662f\u6570\u636e\u5b89\u5168\u4e0e\u53ef\u7528\u6027\u7684\u91cd\u8981\u4fdd\u969c\u3002MatrixOne \u4e5f\u63d0\u4f9b\u4e86\u7075\u6d3b\u4e14\u5f3a\u5927\u7684\u6570\u636e\u5e93\u5907\u4efd\u4e0e\u6062\u590d\u529f\u80fd\uff0c\u4ee5\u786e\u4fdd\u7528\u6237\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u6301\u7eed\u6027\u3002\u672c\u6587\u5c06\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u5907\u4efd\u4e0e\u6062\u590d\u7684\u91cd\u8981\u6027\u3001\u5907\u4efd\u7b56\u7565\u3001\u5907\u4efd\u65b9\u6cd5\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#_1","title":"\u5907\u4efd\u548c\u6062\u590d\u7b56\u7565","text":"\u5728\u4e0d\u540c\u707e\u96be\u6062\u590d\u60c5\u51b5\u4e0b\uff0c\u53ef\u4f7f\u7528\u6570\u636e\u5e93\u5907\u4efd\u6062\u590d\u8fd0\u884c\u72b6\u6001\u3002
\u4ee5\u4e0b\u662f\u9488\u5bf9\u4e0d\u540c\u60c5\u51b5\u7684\u5907\u4efd\u6062\u590d\u65b9\u6cd5\uff1a
\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff1a
\u7535\u6e90\uff08\u68c0\u6d4b\uff09\u5931\u8d25\uff1a
\u6587\u4ef6\u7cfb\u7edf\u5d29\u6e83\uff1a
\u786c\u4ef6\u95ee\u9898\uff08\u786c\u76d8\u3001\u4e3b\u677f\u7b49\uff09\uff1a
\u9488\u5bf9\u5907\u4efd\u6062\u590d\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u7b56\u7565\uff1a
\u5907\u4efd\u9891\u7387: \u786e\u5b9a\u5907\u4efd\u7684\u9891\u7387\uff0c\u901a\u5e38\u5206\u4e3a\u5168\u91cf\u5907\u4efd\u548c\u589e\u91cf\u5907\u4efd\u3002\u5168\u91cf\u5907\u4efd\u4f1a\u5360\u7528\u66f4\u591a\u5b58\u50a8\u7a7a\u95f4\u548c\u65f6\u95f4\uff0c\u4f46\u6062\u590d\u901f\u5ea6\u8f83\u5feb\uff0c\u800c\u589e\u91cf\u5907\u4efd\u5219\u66f4\u52a0\u7ecf\u6d4e\u3002
\u5907\u4efd\u5b58\u50a8: \u9009\u62e9\u5b89\u5168\u7684\u5907\u4efd\u5b58\u50a8\u4f4d\u7f6e\uff0c\u786e\u4fdd\u5907\u4efd\u6570\u636e\u4e0d\u6613\u53d7\u5230\u7834\u574f\u6216\u4e22\u5931\u3002\u901a\u5e38\u4f7f\u7528\u79bb\u7ebf\u5b58\u50a8\u4ecb\u8d28\u6216\u4e91\u5b58\u50a8\u6765\u5b58\u653e\u5907\u4efd\u3002
\u5907\u4efd\u4fdd\u7559\u671f: \u786e\u5b9a\u5907\u4efd\u6570\u636e\u7684\u4fdd\u7559\u671f\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u65f6\u8fdb\u884c\u5386\u53f2\u6570\u636e\u7684\u68c0\u7d22\u548c\u6062\u590d\u3002\u6839\u636e\u6cd5\u89c4\u548c\u4e1a\u52a1\u9700\u6c42\uff0c\u5236\u5b9a\u76f8\u5e94\u7684\u6570\u636e\u4fdd\u7559\u653f\u7b56\u3002
\u65e0\u8bba\u4f55\u79cd\u6062\u590d\u60c5\u51b5\uff0c\u5e94\u9075\u5faa\u4ee5\u4e0b\u539f\u5219\uff1a
MatrixOne \u63d0\u4f9b\u591a\u79cd\u5907\u4efd\u65b9\u5f0f\uff0c\u53ef\u6839\u636e\u6570\u636e\u5e93\u9700\u6c42\u3001\u6027\u80fd\u3001\u8d44\u6e90\u548c\u6062\u590d\u65f6\u95f4\u7b49\u56e0\u7d20\uff0c\u7efc\u5408\u8003\u8651\u9009\u62e9\u9002\u5f53\u5907\u4efd\u65b9\u6cd5\u3002
MatrixOne \u6570\u636e\u5e93\u63d0\u4f9b\u4e86\u591a\u79cd\u5907\u4efd\u5de5\u5177\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u573a\u666f\u548c\u9700\u6c42\uff1a
mo-dump: \u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u548c\u6a21\u5f0f\u3002\u5b83\u751f\u6210\u53ef\u6062\u590d\u7684 SQL \u811a\u672c\uff0c\u7528\u4e8e\u903b\u8f91\u5907\u4efd\u3002
mo-backup: \u7528\u4e8e\u7269\u7406\u5907\u4efd\u548c\u6062\u590d\u3002mo-backup
\u662f MatrixOne \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u5e2e\u52a9\u4f60\u4fdd\u62a4\u5176 MatrixOne \u6570\u636e\u5e93\uff0c\u5e76\u5728\u9700\u8981\u65f6\u8fdb\u884c\u53ef\u9760\u7684\u6062\u590d\u64cd\u4f5c\u3002
!!! note mo-backup \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#_3","title":"\u903b\u8f91\u5907\u4efd\u4e0e\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#select-into-outfile","title":"\u4f7f\u7528SELECT INTO OUTFILE
\u5907\u4efd","text":"\u4f7f\u7528 SELECT ... INTO OUTFILE
\u547d\u4ee4\u5c06\u68c0\u7d22\u7684\u6570\u636e\u6309\u683c\u5f0f\u5bfc\u51fa\u5230\u6587\u4ef6\uff0c\u5bfc\u51fa\u7684\u6587\u4ef6\u7531 MatrixOne \u670d\u52a1\u521b\u5efa\uff0c\u4ec5\u5728 MatrixOne \u670d\u52a1\u5668\u4e3b\u673a\u4e0a\u3002\u4e0d\u652f\u6301\u5bfc\u51fa\u81f3\u5ba2\u6237\u7aef\u6587\u4ef6\u7cfb\u7edf\uff0c\u5bfc\u51fa\u76ee\u5f55\u52ff\u91cd\u540d\u6587\u4ef6\uff0c\u907f\u514d\u65b0\u6587\u4ef6\u8986\u76d6\u3002
\u64cd\u4f5c\u6b65\u9aa4\u53ca\u793a\u4f8b\uff0c\u53c2\u89c1 SELECT INTO...OUTFILE
mo-dump
\u5907\u4efd","text":"MatrixOne \u652f\u6301\u4f7f\u7528 mo-dump
\u5de5\u5177\u8fdb\u884c\u903b\u8f91\u5907\u4efd\uff0c\u751f\u6210\u53ef\u7528\u4e8e\u91cd\u65b0\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u6570\u636e\u7684 SQL \u8bed\u53e5\u3002
\u64cd\u4f5c\u6b65\u9aa4\u53ca\u793a\u4f8b\uff0c\u53c2\u89c1 mo-dump \u5de5\u5177\u5199\u51fa
MatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u5c06\u5927\u91cf\u884c\u63d2\u5165\u6570\u636e\u5e93\u8868\uff0c\u4e5f\u652f\u6301\u4f7f\u7528 SOURCE
\u547d\u4ee4\u5bfc\u5165\u8868\u7ed3\u6784\u548c\u6570\u636e\u81f3\u6574\u4e2a\u6570\u636e\u5e93\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u8003\u6279\u91cf\u5bfc\u5165
"},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#_5","title":"\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#mo_br","title":"\u4f7f\u7528mo_br
\u5907\u4efd\u4e0e\u6062\u590d","text":"MatrixOne \u652f\u6301\u4f7f\u7528 mo_br
\u5de5\u5177\u8fdb\u884c\u5e38\u89c4\u7269\u7406\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u3002
\u64cd\u4f5c\u6b65\u9aa4\u53ca\u793a\u4f8b\uff0c\u53c2\u89c1 mo-br \u4f7f\u7528\u6307\u5357
MatrixOne \u652f\u6301\u4f7f\u7528 SQL \u8fdb\u884c\u5feb\u7167\u5907\u4efd\u4e0e\u6062\u590d\u3002
\u6709\u5173\u4f7f\u7528 SQL \u8fdb\u884c\u5feb\u7167\u5907\u4efd\u4e0e\u6062\u590d\u7684\u65b9\u6cd5\uff0c\u8bf7\u53c2\u8003\u6587\u6863\uff1a
\u7269\u7406\u5907\u4efd\u662f\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u76f4\u63a5\u590d\u5236\u5230\u5907\u4efd\u4ecb\u8d28\uff08\u5982\u78c1\u5e26\u3001\u786c\u76d8\u7b49\uff09\u4e0a\u7684\u8fc7\u7a0b\u3002\u6b64\u65b9\u5f0f\u5c06\u6570\u636e\u5e93\u7684\u6240\u6709\u7269\u7406\u6570\u636e\u5757\u590d\u5236\u5230\u5907\u4efd\u4ecb\u8d28\uff0c\u5305\u62ec\u6570\u636e\u6587\u4ef6\u3001\u63a7\u5236\u6587\u4ef6\u548c\u91cd\u505a\u65e5\u5fd7\u6587\u4ef6\u7b49\u3002\u5907\u4efd\u7684\u6570\u636e\u662f\u5b9e\u9645\u5b58\u50a8\u5728\u78c1\u76d8\u4e0a\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u6062\u590d\u64cd\u4f5c\u901a\u5e38\u8fc5\u901f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_4","title":"\u5feb\u7167\u5907\u4efd","text":"\u6570\u636e\u5e93\u5feb\u7167\u5907\u4efd\u4e3a\u7269\u7406\u5907\u4efd\u7684\u4e00\u79cd\u5f62\u5f0f\uff0c\u4f46\u533a\u522b\u4e8e\u4f20\u7edf\u7684\u7269\u7406\u5907\u4efd\uff0c\u5b83\u901a\u8fc7\u6355\u6349\u6570\u636e\u5e93\u5728\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u53ea\u8bfb\u9759\u6001\u89c6\u56fe\u6765\u521b\u5efa\u6570\u636e\u7684\u5373\u65f6\u526f\u672c\u3002\u8fd9\u79cd\u5907\u4efd\u65b9\u5f0f\u5229\u7528\u589e\u91cf\u5b58\u50a8\u673a\u5236\uff0c\u4ec5\u8bb0\u5f55\u81ea\u4e0a\u4e00\u4e2a\u5feb\u7167\u4ee5\u6765\u53d1\u751f\u53d8\u5316\u7684\u6570\u636e\u5757\uff0c\u4ece\u800c\u9ad8\u6548\u5730\u4f7f\u7528\u5b58\u50a8\u7a7a\u95f4\u3002\u5feb\u7167\u5907\u4efd\u652f\u6301\u5feb\u901f\u6062\u590d\uff0c\u56e0\u4e3a\u5b83\u4eec\u63d0\u4f9b\u4e86\u6570\u636e\u5e93\u7684\u5b8c\u6574\u4e00\u81f4\u6027\u89c6\u56fe\uff0c\u9002\u7528\u4e8e\u6570\u636e\u4fdd\u62a4\u3001\u62a5\u544a\u751f\u6210\u3001\u5206\u6790\u548c\u5176\u4ed6\u9700\u8981\u6570\u636e\u4e00\u81f4\u6027\u7684\u573a\u666f\u3002\u6b64\u5916\uff0c\u5b83\u4eec\u901a\u5e38\u4f9d\u8d56\u4e8e\u5e95\u5c42\u5b58\u50a8\u7cfb\u7edf\u7684\u5feb\u7167\u529f\u80fd\uff0c\u80fd\u591f\u5728\u4e0d\u5f71\u54cd\u6570\u636e\u5e93\u6b63\u5e38\u8fd0\u884c\u7684\u60c5\u51b5\u4e0b\uff0c\u4e3a\u6570\u636e\u5e93\u63d0\u4f9b\u4e00\u4e2a\u5b89\u5168\u7684\u6570\u636e\u8bbf\u95ee\u526f\u672c\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_5","title":"\u903b\u8f91\u5907\u4efd","text":"\u903b\u8f91\u5907\u4efd\u662f\u901a\u8fc7 SQL \u8bed\u53e5\u5907\u4efd\u6570\u636e\u5e93\u4e2d\u7684\u903b\u8f91\u5bf9\u8c61\uff08\u5982\u8868\u3001\u7d22\u5f15\u3001\u5b58\u50a8\u8fc7\u7a0b\u7b49\uff09\u3002\u8fd9\u79cd\u5907\u4efd\u65b9\u5f0f\u5c06\u903b\u8f91\u5bf9\u8c61\u7684\u5b9a\u4e49\u548c\u6570\u636e\u5bfc\u51fa\u81f3\u5907\u4efd\u6587\u4ef6\uff0c\u4f46\u4e0d\u6d89\u53ca\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u3002\u867d\u7136\u6062\u590d\u901f\u5ea6\u8f83\u6162\uff0c\u5907\u4efd\u6570\u636e\u901a\u5e38\u66f4\u6613\u9605\u8bfb\u548c\u4fee\u6539\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_6","title":"\u533a\u522b","text":"\u6570\u636e\u7269\u7406\u5907\u4efd\u3001\u903b\u8f91\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u662f\u4e09\u79cd\u4e0d\u540c\u7684\u6570\u636e\u4fdd\u62a4\u7b56\u7565\uff1a\u7269\u7406\u5907\u4efd\u901a\u8fc7\u76f4\u63a5\u590d\u5236\u6570\u636e\u5e93\u7684\u5b58\u50a8\u6587\u4ef6\u6765\u521b\u5efa\u6570\u636e\u5e93\u7684\u4e00\u4e2a\u5b8c\u6574\u526f\u672c\uff0c\u9002\u7528\u4e8e\u5feb\u901f\u6062\u590d\u548c\u5927\u89c4\u6a21\u6570\u636e\u8fc1\u79fb\uff1b\u903b\u8f91\u5907\u4efd\u5219\u5bfc\u51fa\u6570\u636e\u5e93\u7684\u903b\u8f91\u7ed3\u6784\uff0c\u5982 SQL \u8bed\u53e5\uff0c\u4ee5\u6587\u672c\u5f62\u5f0f\u5b58\u50a8\u6570\u636e\u548c\u7ed3\u6784\uff0c\u4fbf\u4e8e\u8de8\u5e73\u53f0\u548c\u7248\u672c\u7684\u6570\u636e\u8fc1\u79fb\uff1b\u800c\u5feb\u7167\u5907\u4efd\u662f\u6570\u636e\u5e93\u5728\u67d0\u4e00\u65f6\u523b\u7684\u53ea\u8bfb\u89c6\u56fe\uff0c\u5229\u7528\u589e\u91cf\u5b58\u50a8\u6280\u672f\u8bb0\u5f55\u53d8\u5316\uff0c\u9002\u7528\u4e8e\u5feb\u901f\u6062\u590d\u81f3\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u72b6\u6001\uff0c\u901a\u5e38\u4f9d\u8d56\u4e8e\u5b58\u50a8\u7cfb\u7edf\u7684\u652f\u6301\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_7","title":"\u5168\u91cf\u5907\u4efd\u3001\u589e\u91cf\u5907\u4efd\u4e0e\u5dee\u5f02\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_8","title":"\u5168\u91cf\u5907\u4efd","text":"\u5168\u91cf\u5907\u4efd\u5c06\u6574\u4e2a\u6570\u636e\u96c6\u5907\u4efd\u81f3\u5b58\u50a8\u8bbe\u5907\uff0c\u5305\u62ec\u6240\u6709\u6587\u4ef6\u548c\u6587\u4ef6\u5939\u3002\u5c3d\u7ba1\u901a\u5e38\u8017\u65f6\u957f\u4e14\u9700\u8981\u5927\u5b58\u50a8\u7a7a\u95f4\uff0c\u4f46\u53ef\u5b8c\u5168\u8fd8\u539f\u6570\u636e\uff0c\u65e0\u9700\u5176\u4ed6\u5907\u4efd\u6587\u4ef6\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_9","title":"\u589e\u91cf\u5907\u4efd","text":"\u589e\u91cf\u5907\u4efd\u4ec5\u5907\u4efd\u6700\u8fd1\u66f4\u6539\u6216\u65b0\u589e\u7684\u6587\u4ef6\u6216\u6570\u636e\u5757\u3002\u4ec5\u5907\u4efd\u4e0a\u6b21\u5907\u4efd\u4ee5\u6765\u7684\u53d8\u66f4\uff0c\u901a\u5e38\u5907\u4efd\u65f6\u95f4\u548c\u5b58\u50a8\u7a7a\u95f4\u8f83\u5c11\u3002\u901a\u5e38\u5728\u5b9a\u671f\u5168\u91cf\u5907\u4efd\u4e4b\u95f4\u6267\u884c\uff0c\u4ee5\u786e\u4fdd\u5907\u4efd\u6570\u636e\u4fdd\u6301\u6700\u65b0\u3002\u6062\u590d\u6570\u636e\u9700\u4f7f\u7528\u6240\u6709\u589e\u91cf\u5907\u4efd\u548c\u6700\u65b0\u5168\u91cf\u5907\u4efd\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_10","title":"\u5dee\u5f02\u5907\u4efd","text":"\u5dee\u5f02\u5907\u4efd\u662f\u5907\u4efd\u81ea\u4e0a\u6b21\u5b8c\u6574\u5907\u4efd\u4ee5\u6765\u53d1\u751f\u53d8\u5316\u7684\u6570\u636e\uff0c\u56e0\u6b64\u5907\u4efd\u6570\u636e\u91cf\u8f83\u589e\u91cf\u5907\u4efd\u5927\uff0c\u5907\u4efd\u65f6\u95f4\u8f83\u957f\u3002\u6062\u590d\u6570\u636e\u65f6\uff0c\u53ea\u9700\u5148\u6062\u590d\u6700\u8fd1\u7684\u5b8c\u6574\u5907\u4efd\uff0c\u518d\u6062\u590d\u6700\u8fd1\u7684\u5dee\u5f02\u5907\u4efd\u5373\u53ef\u3002\u7531\u4e8e\u4e0d\u4f9d\u8d56\u4e4b\u524d\u5907\u4efd\u6570\u636e\uff0c\u6062\u590d\u65f6\u95f4\u8f83\u77ed\uff0c\u5907\u4efd\u548c\u6062\u590d\u8fc7\u7a0b\u76f8\u5bf9\u7b80\u5355\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_11","title":"\u5168\u91cf\u5907\u4efd\u3001\u589e\u91cf\u5907\u4efd\u4e0e\u5dee\u5f02\u5907\u4efd\u7684\u533a\u522b","text":"\u7269\u7406\u6062\u590d\u662f\u5229\u7528\u7269\u7406\u5907\u4efd\u8fdb\u884c\u6570\u636e\u5e93\u6062\u590d\u3002\u901a\u5e38\u7528\u4e8e\u4e25\u91cd\u6545\u969c\u5982\u786c\u76d8\u6545\u969c\u3001\u64cd\u4f5c\u7cfb\u7edf\u6545\u969c\u6216\u6587\u4ef6\u7cfb\u7edf\u6545\u969c\u3002\u5728\u7269\u7406\u6062\u590d\u4e2d\uff0c\u4f7f\u7528\u4e13\u4e1a\u6062\u590d\u5de5\u5177\u6216\u8f6f\u4ef6\u8bfb\u53d6\u5907\u4efd\u6587\u4ef6\u6216\u5b58\u50a8\u4ecb\u8d28\u4e2d\u5b9e\u9645\u6570\u636e\u5757\uff0c\u5e76\u5c1d\u8bd5\u4fee\u590d\u635f\u574f\u5757\u3002
\u7269\u7406\u6062\u590d\u4f18\u52bf\u5728\u4e8e\u5feb\u901f\u8fd8\u539f\u6570\u636e\u5e93\uff0c\u56e0\u65e0\u9700\u6267\u884c SQL \u8bed\u53e5\u6216\u5176\u4ed6\u9ad8\u5c42\u64cd\u4f5c\uff0c\u76f4\u63a5\u5904\u7406\u6570\u636e\u5757\u3002\u6b64\u5916\uff0c\u7269\u7406\u6062\u590d\u80fd\u8fd8\u539f\u6240\u6709\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5305\u62ec\u8868\u3001\u7d22\u5f15\u3001\u5b58\u50a8\u8fc7\u7a0b\u7b49\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_14","title":"\u5b8c\u5168\u6062\u590d\u4e0e\u4e0d\u5b8c\u5168\u6062\u590d","text":"\u5bf9\u4e8e\u4f01\u4e1a\u800c\u8a00\uff0c\u6bcf\u5929\u90fd\u4f1a\u4ea7\u751f\u5927\u91cf\u6570\u636e\uff0c\u90a3\u4e48\u5bf9\u4e8e\u6570\u636e\u5e93\u7684\u5907\u4efd\u5c31\u975e\u5e38\u91cd\u8981\u3002\u5728\u7cfb\u7edf\u5d29\u6e83\u6216\u8005\u786c\u4ef6\u6545\u969c\uff0c\u53c8\u6216\u8005\u7528\u6237\u8bef\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u6062\u590d\u6570\u636e\u5e76\u91cd\u542f\u7cfb\u7edf\uff0c\u4e0d\u4f1a\u9020\u6210\u6570\u636e\u4e22\u5931\u3002
\u53e6\u5916\uff0c\u6570\u636e\u5907\u4efd\u4e5f\u4f5c\u4e3a\u5347\u7ea7 MatrixOne \u5b89\u88c5\u4e4b\u524d\u7684\u4fdd\u969c\uff0c\u540c\u65f6\u6570\u636e\u5907\u4efd\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06 MatrixOne \u5b89\u88c5\u8f6c\u79fb\u5230\u53e6\u4e00\u4e2a\u7cfb\u7edf\u3002
MatrixOne \u652f\u6301\u901a\u8fc7 mo-dump
\u5b9e\u7528\u7a0b\u5e8f\u8fdb\u884c\u903b\u8f91\u5907\u4efd\u3002modump
\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5b9e\u7528\u7a0b\u5e8f\uff0c\u7528\u4e8e\u751f\u6210 MatrixOne \u6570\u636e\u5e93\u7684\u903b\u8f91\u5907\u4efd\u3002\u5b83\u751f\u6210\u53ef\u7528\u4e8e\u91cd\u65b0\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u6570\u636e\u7684 SQL \u8bed\u53e5\u3002\u4f60\u53ef\u4ee5\u5728 mo-dump \u7ae0\u8282\u4e2d\u67e5\u627e\u5b83\u7684\u8bed\u6cd5\u8bf4\u660e\u548c\u4f7f\u7528\u6307\u5357\u3002
\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bb2\u8ff0\u5982\u4f55\u4f7f\u7528 mo-dump
\u5b9e\u7528\u7a0b\u5e8f\u5b8c\u6210\u6570\u636e\u5907\u4efd\u548c\u8fd8\u539f\u7684\u8fc7\u7a0b\u3002
\u53c2\u89c1 mo-dump \u5de5\u5177\u5199\u51fa\u7ae0\u8282\uff0c\u5b8c\u6210 mo-dump
\u5de5\u5177\u7684\u90e8\u7f72\u3002
\u793a\u4f8b\u5982\u4e0b\uff0c\u4f7f\u7528\u4ee5\u4e0b SQL \u521b\u5efa\u7684\u6570\u636e\u5e93 t \u53ca\u5176\u8868 t1\uff1a
DROP DATABASE IF EXISTS `t`;\nCREATE DATABASE `t`;\nUSE `t`;\ncreate table t1\n(\n c1 int primary key auto_increment,\n c2 tinyint not null default 4,\n c3 smallint,\n c4 bigint,\n c5 tinyint unsigned,\n c6 smallint unsigned,\n c7 int unsigned,\n c8 bigint unsigned,\n c9 float,\n c10 double,\n c11 date,\n c12 datetime,\n c13 timestamp on update current_timestamp,\n c14 char,\n c15 varchar,\n c16 json,\n c17 decimal,\n c18 text,\n c19 blob,\n c20 uuid\n);\ninsert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2019-01-01', '2019-01-01 00:00:00', '2019-01-01 00:00:00', 'a', 'a', '{\"a\":1}','1212.1212', 'a', 'aza', '00000000-0000-0000-0000-000000000000');\n
\u5982\u679c\u8981\u751f\u6210\u5355\u4e2a\u6570\u636e\u5e93\u7684\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u547d\u540d\u4e3a t \u7684\u6570\u636e\u5e93\u7684\u5907\u4efd\uff0c\u5176\u4e2d\u5305\u542b t.sql \u6587\u4ef6\u4e2d\u7684\u7ed3\u6784\u548c\u6570\u636e\u3002
./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db t > t.sql\n
\u5982\u679c\u8981\u5728\u6570\u636e\u5e93\u4e2d\u751f\u6210\u5355\u4e2a\u8868\u7684\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u547d\u540d\u4e3a t \u7684\u6570\u636e\u5e93\u7684 t1 \u8868\u7684\u5907\u4efd\uff0c\u5176\u4e2d\u5305\u542b t.sql \u6587\u4ef6\u4e2d\u7684\u7ed3\u6784\u548c\u6570\u636e\u3002
./mo-dump -u root -p 111 -db t -tbl t1 > t1.sql\n
Note
\u5982\u679c\u4f60\u60f3\u751f\u6210\u591a\u4e2a\u6570\u636e\u5e93/\u8868\u7684\u5907\u4efd\uff0c\u9700\u8981\u5728\u6570\u636e\u5e93\u540d/\u8868\u540d\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002
\u5c06\u5bfc\u51fa\u7684 sql \u6587\u4ef6\u6062\u590d\u81f3 MatrixOne \u6570\u636e\u5e93\u76f8\u5bf9\u7b80\u5355\u3002\u8981\u6062\u590d\u4f60\u7684\u6570\u636e\u5e93\uff0c\u4f60\u5fc5\u987b\u5148\u521b\u5efa\u4e00\u4e2a\u7a7a\u6570\u636e\u5e93\uff0c\u5e76\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fdb\u884c\u6062\u590d\u3002
\u5c06 MatrixOne \u4e0e MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3\u540c\u4e00\u670d\u52a1\u5668\u4e0a\uff0c\u5e76\u786e\u4fdd\u5bfc\u51fa\u7684 sql \u6587\u4ef6\u4e5f\u5728\u540c\u4e00\u670d\u52a1\u5668\u4e0a\u3002
mysql> create database t if not exists;\nmysql> source /YOUR_SQL_FILE_PATH/t.sql\n
\u6210\u529f\u6267\u884c\u4ee5\u4e0a\u547d\u4ee4\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u68c0\u67e5\u662f\u5426\u5728\u547d\u540d\u4e3a t \u6570\u636e\u5e93\u4e0a\u521b\u5efa\u4e86\u6240\u6709\u5bf9\u8c61\u3002
mysql> use t;\nmysql> show tables;\nmysql> select count(*) from t1;\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/","title":"mo_br \u5907\u4efd\u4e0e\u6062\u590d","text":"\u5bf9\u4e8e\u4f01\u4e1a\u800c\u8a00\uff0c\u6bcf\u5929\u90fd\u4f1a\u4ea7\u751f\u5927\u91cf\u6570\u636e\uff0c\u90a3\u4e48\u5bf9\u4e8e\u6570\u636e\u5e93\u7684\u5907\u4efd\u5c31\u975e\u5e38\u91cd\u8981\u3002\u5728\u7cfb\u7edf\u5d29\u6e83\u6216\u8005\u786c\u4ef6\u6545\u969c\uff0c\u53c8\u6216\u8005\u7528\u6237\u8bef\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u6062\u590d\u6570\u636e\u5e76\u91cd\u542f\u7cfb\u7edf\uff0c\u4e0d\u4f1a\u9020\u6210\u6570\u636e\u4e22\u5931\u3002
\u53e6\u5916\uff0c\u6570\u636e\u5907\u4efd\u4e5f\u4f5c\u4e3a\u5347\u7ea7 MatrixOne \u5b89\u88c5\u4e4b\u524d\u7684\u4fdd\u969c\uff0c\u540c\u65f6\u6570\u636e\u5907\u4efd\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06 MatrixOne \u5b89\u88c5\u8f6c\u79fb\u5230\u53e6\u4e00\u4e2a\u7cfb\u7edf\u3002
MatrixOne \u652f\u6301\u901a\u8fc7 mo_br
\u5b9e\u7528\u5de5\u5177\u8fdb\u884c\u7269\u7406\u5907\u4efd\u3002mo_br
\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5b9e\u7528\u7a0b\u5e8f\uff0c\u7528\u4e8e\u751f\u6210 MatrixOne \u6570\u636e\u5e93\u7684\u7269\u7406\u5907\u4efd\u3002\u5b83\u751f\u6210\u53ef\u7528\u4e8e\u91cd\u65b0\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u6570\u636e\u7684 SQL \u8bed\u53e5\u3002
\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bb2\u8ff0\u5982\u4f55\u4f7f\u7528 mo_br
\u5b9e\u7528\u7a0b\u5e8f\u5b8c\u6210\u6570\u636e\u5907\u4efd\u548c\u8fd8\u539f\u7684\u8fc7\u7a0b\u3002
mo_br backup\n --host\n --port \n --user \n --password \n --backup_dir s3|filesystem \n //s3 oss minio\n --endpoint\n --access_key_id \n --secret_access_key \n --bucket \n --filepath\n --region \n --compression \n --role_arn \n --is_minio\n --parallelism \n //filesystem\n --path\n --parallelism\n --meta_path \n //\u589e\u91cf\u5907\u4efd\u9700\u8981\n --backup_type\n --base_id\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 backup_dir \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002s3 \u6216 filesystem endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5230 s3 \u7684\u670d\u52a1\u7684 URL access_key_id \u5907\u4efd\u5230 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230 s3 \u7684 Secret access key bucket \u5907\u4efd\u5230\u7684 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u5907\u4efd\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 region \u5907\u4efd\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression \u5907\u4efd\u5230 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 role_arn \u5907\u4efd\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 is_minio \u6307\u5b9a\u5907\u4efd\u5230\u7684 s3 \u662f\u5426\u4e3a minio path \u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u8def\u5f84 parallelism \u5e76\u884c\u5ea6 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 backup_type \u6307\u5b9a\u5907\u4efd\u7c7b\u578b\u4e3a\u589e\u91cf\u5907\u4efd\uff0cincremental\u3002 base_id \u4e0a\u6b21\u4e00\u6b21\u5907\u4efd\u7684 ID\uff0c\u4e3b\u8981\u7528\u4e8e\u786e\u5b9a\u4e0a\u6b21\u5907\u4efd\u7684\u65f6\u95f4\u6233\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_3","title":"\u793a\u4f8b","text":"./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\"\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"s3\" --endpoint \"http://127.0.0.1:9000\" --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\" --bucket \"bucket1\" --filepath \"/backup1\" --is_minio\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\" --backup_type \"incremental\" --base_id \"xxx\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_4","title":"\u67e5\u770b\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_5","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br list\n -- ID\n //\u8981\u67e5\u8be2\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key \n --not_check_data \n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_check_data \u53ea\u67e5\u770b meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u67e5\u770b\u5907\u4efd\u6570\u636e\u3002\u9ed8\u8ba4\u4e0d\u5e26\u8fd9\u4e2a\u53c2\u6570\u7684\uff0c\u5c31\u662f\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u3002\u5f53\u524d\u53ea\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_6","title":"\u793a\u4f8b","text":"./mo_br list\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n| 01108122-10f9-11ef-9359-26dd28356ef2 | 8.3 MB | BackupDir: filesystem Path: | 2024-05-13 15:18:28 +0800 | 3.394437375s | 2024-05-13 15:18:32 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n
./mo_br list 4d21b228-10dd-11ef-9497-26dd28356ef2\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n\nChecking the backup data(currently,no checksum)...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/log.toml_018f70d1-3100-7762-b28b-8f85ac4ed3cd\ncheck: config/tn.toml_018f70d1-310e-78fc-ac96-aa5e06981bd7\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_7","title":"\u5220\u9664\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_8","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br delete ID \n //\u8981\u5220\u9664\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key\n --not_delete_data\n --meta_path\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u5220\u9664\u7684\u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_delete_data \u53ea\u5220\u9664 meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u5220\u9664\u5907\u4efd\u6570\u636e\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_9","title":"\u793a\u4f8b","text":"./mo_br delete e4cade26-3139-11ee-8631-acde48001122\n
./mo_br delete e4cade26-3139-11ee-8631-acde48001122 --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_10","title":"\u6062\u590d\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_11","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br restore ID\n //\u8bfb\u53d6\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id\n --backup_secret_access_key \n\n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath \n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u6062\u590d\u7684 ID backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730\u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6//\u6062\u590d\u3002\nmo_br restore\n --backup_dir s3|filesystem \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --backup_endpoint \n --backup_access_key_id \n --backup_secret_access_key\n --backup_bucket\n --backup_filepath\n --backup_region \n --backup_compression \n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path \n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath\n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 \u6216 filesystem restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730 matrixone \u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_12","title":"\u793a\u4f8b","text":"\u4ece\u6587\u4ef6\u7cfb\u7edf\u6062\u590d\u5230\u6587\u4ef6\u7cfb\u7edf
\u6b65\u9aa4\u4e00\uff1a\u505c\u6b62 mo\uff0c\u5220\u9664 mo-data
\u6b65\u9aa4\u4e8c\uff1a\u6267\u884c\u4ee5\u4e0b\u6062\u590d\u547d\u4ee4
./mo_br restore fb26fd88-41bc-11ee-93f8-acde48001122 --restore_dir filesystem --restore_path \"your_mopath\"\n
\u6062\u590d\u540e\u4f1a\u5728 matrixone \u751f\u6210\u65b0\u7684 mo-data \u6587\u4ef6
\u6b65\u9aa4\u4e09\uff1a\u542f\u52a8 mo
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_13","title":"\u6821\u9a8c\u5907\u4efd\u7684\u6821\u9a8c\u7801","text":"\u8bfb\u53d6\u5907\u4efd\u6587\u4ef6\u5939\u4e2d\u7684\u6bcf\u4e2a\u6587\u4ef6\u53ca\u5176 sha256 \u6587\u4ef6\u3002\u8ba1\u7b97\u6587\u4ef6\u7684 sha256 \u503c\u5e76\u4e0e sha256 \u6587\u4ef6\u503c\u5bf9\u6bd4\u3002sha256 \u6587\u4ef6\u662f\u5728\u6587\u4ef6\u521b\u5efa\u6216\u66f4\u65b0\u65f6\uff0c\u521b\u5efa\u7684\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_14","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br check ID\n //\u6821\u9a8c\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id string\n --backup_secret_access_key string\n --meta_path string \u6307\u5b9ameta\u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684mo_br.meta\u6587\u4ef6\u3002\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002mo_br check\n --backup_dir s3|filesystem \n //s3 \n --backup_endpoint\n --backup_access_key_id\n --backup_secret_access_key \n --backup_bucket\n --backup_filepath \n --backup_region \n --backup_compression\n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path\n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u5907\u4efd\u6240\u5728\u7684\u8def\u5f84\u7c7b\u578b\uff0c\u5728\u6ca1\u6709\u6307\u5b9a ID \u65f6\uff0c\u5fc5\u987b\u8981\u6307\u5b9a\u3002s3 \u6216 filesystem backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_15","title":"\u793a\u4f8b","text":"./mo_br check 1614f462-126c-11ef-9af3-26dd28356ef3\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| 1614f462-126c-11ef-9af3-26dd28356ef3 | 126 MB | BackupDir: filesystem Path: | 2024-05-15 11:34:28 +0800 | 22.455633916s | 2024-05-15 11:34:50 +0800 |\n| | | /Users/admin/soft/incbackup/back2 | | | |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n\nChecking the backup data...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\n...\n
(base) admin@admindeMacBook-Pro mo-backup % ./mo_br check --backup_dir filesystem --backup_path /Users/admin/soft/incbackup/back2\n2024/05/15 11:40:30.011160 +0800 INFO malloc/malloc.go:42 malloc {\"max buffer size\": 1073741824, \"num shards\": 16, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 23}\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\ncheck: config/log.toml_018f7a50-d30c-7ed0-85bc-191e9f1eb753\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_16","title":"\u6700\u4f73\u5b9e\u8df5","text":"\u4e0b\u9762\u6211\u4eec\u5c06\u901a\u8fc7\u51e0\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bb2\u8ff0\u5982\u4f55\u4f7f\u7528 mo_br \u8fdb\u884c\u6570\u636e\u7684\u5907\u4efd\u4e0e\u8fd8\u539f
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#1","title":"\u793a\u4f8b 1 \u5168\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback1\"\n\nBackup ID\n 25536ff0-126f-11ef-9902-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| 25536ff0-126f-11ef-9902-26dd28356ef3 | 65 MB | BackupDir: filesystem Path: | 2024-05-15 11:56:44 +0800 | 8.648091083s | 2024-05-15 11:56:53 +0800 | 1715745404915410000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback1 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 25536ff0-126f-11ef-9902-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback1\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\nrestore tae file path ./mo-data/shared, parallelism 1, parallel count num: 1\nrestore file num: 1, total file num: 733, cost : 549\u00b5s\nCopy tae file 1\n 018f7a41-1881-7999-bbd6-858c3d4acc18_00000 => mo-data/shared/018f7a41-1881-7999-bbd6-858c3d4acc18_00000\n ... \n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#2","title":"\u793a\u4f8b 2 \u589e\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\"\n\nBackup ID\n 2289638c-1284-11ef-85e4-26dd28356ef3\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\" --backup_type \"incremental\" --base_id \"2289638c-1284-11ef-85e4-26dd28356ef3\"\n\nBackup ID\n 81531c5a-1284-11ef-9ba3-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| 2289638c-1284-11ef-85e4-26dd28356ef3 | 70 MB | BackupDir: filesystem Path: | 2024-05-15 14:26:59 +0800 | 9.927034917s | 2024-05-15 14:27:09 +0800 | 1715754419668571000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n| 81531c5a-1284-11ef-9ba3-26dd28356ef3 | 72 MB | BackupDir: filesystem Path: | 2024-05-15 14:29:38 +0800 | 2.536263666s | 2024-05-15 14:29:41 +0800 | 1715754578690660000-1 | incremental |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n
\u5bf9\u6bd4\u589e\u91cf\u5907\u4efd\u548c\u5168\u91cf\u5907\u4efd\u7684\u7684\u8017\u65f6 (Duration)\uff0c\u53ef\u4ee5\u770b\u5230\u589e\u91cf\u5907\u4efd\u8017\u65f6\u8f83\u5c11\u3002
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 81531c5a-1284-11ef-9ba3-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\n2024/05/15 14:35:27.910925 +0800 INFO malloc/malloc.go:43 malloc {\"max buffer size\": 2147483648, \"num shards\": 8, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 22}\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback2\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\n...\n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/","title":"mo_br \u5e38\u89c4\u7269\u7406\u5907\u4efd\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#_1","title":"\u539f\u7406\u6982\u8ff0","text":"\u6570\u636e\u5e93\u5e38\u89c4\u7269\u7406\u5907\u4efd\u662f\u76f4\u63a5\u590d\u5236\u6570\u636e\u5e93\u7684\u7269\u7406\u5b58\u50a8\u6587\u4ef6\uff0c\u5305\u62ec\u6570\u636e\u6587\u4ef6\u3001\u65e5\u5fd7\u6587\u4ef6\u548c\u63a7\u5236\u6587\u4ef6\u7b49\uff0c\u4ee5\u521b\u5efa\u6570\u636e\u5e93\u7684\u4e00\u4e2a\u72ec\u7acb\u526f\u672c\u3002\u8fd9\u4e00\u8fc7\u7a0b\u901a\u5e38\u5728\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u8fdb\u884c\uff0c\u53ef\u4ee5\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7684\u547d\u4ee4\u5b9e\u73b0\uff0c\u751f\u6210\u7684\u5907\u4efd\u662f\u6570\u636e\u5e93\u7684\u5b8c\u6574\u5907\u4efd\uff0c\u5305\u542b\u4e86\u6240\u6709\u7684\u6570\u636e\u548c\u5bf9\u8c61\u3002\u5907\u4efd\u6587\u4ef6\u53ef\u4ee5\u5b58\u50a8\u5728\u591a\u79cd\u4ecb\u8d28\u4e0a\uff0c\u5e76\u53ef\u901a\u8fc7\u538b\u7f29\u548c\u52a0\u5bc6\u6765\u8282\u7701\u7a7a\u95f4\u548c\u63d0\u9ad8\u5b89\u5168\u6027\u3002\u5728\u6062\u590d\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06\u8fd9\u4e9b\u6587\u4ef6\u590d\u5236\u5230\u9700\u8981\u7684\u4f4d\u7f6e\uff0c\u4ece\u800c\u5feb\u901f\u5730\u6062\u590d\u6574\u4e2a\u6570\u636e\u5e93\u3002\u6b64\u5916\uff0c\u7269\u7406\u5907\u4efd\u652f\u6301\u8de8\u5e73\u53f0\u8fc1\u79fb\uff0c\u9002\u7528\u4e8e\u707e\u96be\u6062\u590d\u548c\u6570\u636e\u5e93\u8fc1\u79fb\u573a\u666f\uff0c\u4f46\u53ef\u80fd\u9700\u8981\u8f83\u591a\u7684\u5b58\u50a8\u7a7a\u95f4\u548c\u65f6\u95f4\u3002
\u5168\u91cf\u5907\u4efd\u662f\u6307\u5907\u4efd\u6570\u636e\u5e93\u4e2d\u6240\u6709\u6570\u636e\u7684\u5907\u4efd\u8fc7\u7a0b\u3002\u5b83\u521b\u5efa\u4e86\u4e00\u4e2a\u6570\u636e\u5e93\u7684\u5b8c\u6574\u526f\u672c\uff0c\u8fd9\u901a\u5e38\u9700\u8981\u66f4\u591a\u7684\u5b58\u50a8\u7a7a\u95f4\u548c\u66f4\u957f\u7684\u65f6\u95f4\u6765\u5b8c\u6210\u3002\u7531\u4e8e\u5305\u542b\u4e86\u6240\u6709\u6570\u636e\uff0c\u5168\u91cf\u5907\u4efd\u5728\u6062\u590d\u65f6\u8f83\u4e3a\u7b80\u5355\uff0c\u53ef\u4ee5\u76f4\u63a5\u6062\u590d\u5230\u5907\u4efd\u65f6\u7684\u72b6\u6001\u3002
\u589e\u91cf\u5907\u4efd\u662f\u6307\u5907\u4efd\u81ea\u4e0a\u6b21\u5907\u4efd\u4ee5\u6765\u53d1\u751f\u53d8\u5316\u7684\u6570\u636e\u3002\u5b83\u53ea\u590d\u5236\u5728\u4e24\u6b21\u5907\u4efd\u4e4b\u95f4\u6709\u4fee\u6539\u7684\u6570\u636e\u5757\u6216\u6570\u636e\u6587\u4ef6\uff0c\u56e0\u6b64\u5907\u4efd\u96c6\u901a\u5e38\u8f83\u5c0f\uff0c\u5907\u4efd\u901f\u5ea6\u8f83\u5feb\u3002\u589e\u91cf\u5907\u4efd\u53ef\u4ee5\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\u548c\u5907\u4efd\u65f6\u95f4\uff0c\u4f46\u5728\u6570\u636e\u6062\u590d\u65f6\u53ef\u80fd\u66f4\u590d\u6742\uff0c\u56e0\u4e3a\u9700\u8981\u4f9d\u6b21\u5e94\u7528\u4e00\u7cfb\u5217\u589e\u91cf\u5907\u4efd\u6765\u6062\u590d\u5230\u6700\u65b0\u72b6\u6001\u3002
MatrixOne \u652f\u6301\u4f7f\u7528 mo_br
\u8fdb\u884c\u589e\u91cf\u548c\u5168\u91cf\u7269\u7406\u5907\u4efd\u6062\u590d\uff1a
Note
mo_br \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#_2","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#1","title":"\u793a\u4f8b 1 \u5168\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback1\"\n\nBackup ID\n 25536ff0-126f-11ef-9902-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| 25536ff0-126f-11ef-9902-26dd28356ef3 | 65 MB | BackupDir: filesystem Path: | 2024-05-15 11:56:44 +0800 | 8.648091083s | 2024-05-15 11:56:53 +0800 | 1715745404915410000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback1 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 25536ff0-126f-11ef-9902-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback1\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\nrestore tae file path ./mo-data/shared, parallelism 1, parallel count num: 1\nrestore file num: 1, total file num: 733, cost : 549\u00b5s\nCopy tae file 1\n 018f7a41-1881-7999-bbd6-858c3d4acc18_00000 => mo-data/shared/018f7a41-1881-7999-bbd6-858c3d4acc18_00000\n ... \n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#2","title":"\u793a\u4f8b 2 \u589e\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\"\n\nBackup ID\n 2289638c-1284-11ef-85e4-26dd28356ef3\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\" --backup_type \"incremental\" --base_id \"2289638c-1284-11ef-85e4-26dd28356ef3\"\n\nBackup ID\n 81531c5a-1284-11ef-9ba3-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| 2289638c-1284-11ef-85e4-26dd28356ef3 | 70 MB | BackupDir: filesystem Path: | 2024-05-15 14:26:59 +0800 | 9.927034917s | 2024-05-15 14:27:09 +0800 | 1715754419668571000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n| 81531c5a-1284-11ef-9ba3-26dd28356ef3 | 72 MB | BackupDir: filesystem Path: | 2024-05-15 14:29:38 +0800 | 2.536263666s | 2024-05-15 14:29:41 +0800 | 1715754578690660000-1 | incremental |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n
\u5bf9\u6bd4\u589e\u91cf\u5907\u4efd\u548c\u5168\u91cf\u5907\u4efd\u7684\u7684\u8017\u65f6 (Duration)\uff0c\u53ef\u4ee5\u770b\u5230\u589e\u91cf\u5907\u4efd\u8017\u65f6\u8f83\u5c11\u3002
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 81531c5a-1284-11ef-9ba3-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\n2024/05/15 14:35:27.910925 +0800 INFO malloc/malloc.go:43 malloc {\"max buffer size\": 2147483648, \"num shards\": 8, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 22}\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback2\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\n...\n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/","title":"mo_br \u5de5\u5177\u8fdb\u884c\u5feb\u7167\u5907\u4efd\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#_1","title":"\u5feb\u7167\u5907\u4efd\u6062\u590d\u5b9e\u73b0\u539f\u7406","text":"\u6570\u636e\u5e93\u5feb\u7167\u5907\u4efd\u6062\u590d\u901a\u8fc7\u521b\u5efa\u6570\u636e\u5e93\u5728\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u53ea\u8bfb\u9759\u6001\u89c6\u56fe\uff0c\u8fd9\u4e2a\u89c6\u56fe\u88ab\u79f0\u4e3a\u5feb\u7167\u3002\u5feb\u7167\u5229\u7528\u5b58\u50a8\u7cfb\u7edf\u7684\u5199\u65f6\u590d\u5236\uff08COW\uff09\u6280\u672f\uff0c\u4ec5\u5728\u539f\u59cb\u6570\u636e\u9875\u88ab\u4fee\u6539\u524d\u590d\u5236\u5e76\u5b58\u50a8\u8be5\u9875\uff0c\u4ece\u800c\u751f\u6210\u6570\u636e\u5e93\u5728\u5feb\u7167\u521b\u5efa\u65f6\u523b\u7684\u72b6\u6001\u526f\u672c\u3002\u5728\u9700\u8981\u6062\u590d\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u9009\u53d6\u5feb\u7167\u4e2d\u7684\u6570\u636e\u5e76\u5c06\u5176\u590d\u5236\u6216\u6062\u590d\u5230\u65b0\u7684\u6216\u73b0\u6709\u7684\u6570\u636e\u5e93\u4e2d\u3002\u5feb\u7167\u6587\u4ef6\u6700\u521d\u5f88\u5c0f\uff0c\u968f\u7740\u6e90\u6570\u636e\u5e93\u7684\u66f4\u6539\u800c\u9010\u6e10\u589e\u957f\uff0c\u56e0\u6b64\u9700\u8981\u76d1\u63a7\u5176\u5927\u5c0f\u5e76\u5728\u5fc5\u8981\u65f6\u8fdb\u884c\u7ba1\u7406\u3002\u5feb\u7167\u5fc5\u987b\u4e0e\u6e90\u6570\u636e\u5e93\u4f4d\u4e8e\u540c\u4e00\u670d\u52a1\u5668\u5b9e\u4f8b\uff0c\u5e76\u4e14\u7531\u4e8e\u5b83\u4eec\u662f\u53ea\u8bfb\u7684\uff0c\u4e0d\u80fd\u76f4\u63a5\u5728\u5176\u4e0a\u8fdb\u884c\u5199\u64cd\u4f5c\u3002\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5feb\u7167\u6062\u590d\u64cd\u4f5c\u4f1a\u8986\u76d6\u5f53\u524d\u6570\u636e\uff0c\u56e0\u6b64\u9700\u8981\u8c28\u614e\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u6570\u636e\u5e93\u5feb\u7167\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5728\u591a\u79cd\u573a\u666f\u4e0b\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u53ef\u7528\u6027\u548c\u6027\u80fd\u3002\u4ee5\u4e0b\u4e3a\u5feb\u7167\u7684\u4e00\u4e9b\u5e94\u7528\u573a\u666f\uff1a
\u6570\u636e\u5907\u4efd\u4e0e\u6062\u590d\uff1a\u5feb\u7167\u53ef\u4ee5\u4f5c\u4e3a\u6570\u636e\u5e93\u5907\u4efd\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u5b83\u5141\u8bb8\u5728\u4e0d\u505c\u6b62\u6570\u636e\u5e93\u670d\u52a1\u7684\u60c5\u51b5\u4e0b\u521b\u5efa\u6570\u636e\u5e93\u7684\u53ea\u8bfb\u526f\u672c\uff0c\u7528\u4e8e\u6570\u636e\u5907\u4efd\u548c\u6062\u590d\u3002
\u62a5\u8868\u548c\u6570\u636e\u5206\u6790\uff1a\u5728\u9700\u8981\u6570\u636e\u5e93\u4fdd\u6301\u9759\u6001\u72b6\u6001\u8fdb\u884c\u62a5\u8868\u751f\u6210\u6216\u6570\u636e\u5206\u6790\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5feb\u7167\u6765\u907f\u514d\u5f71\u54cd\u5728\u7ebf\u4e8b\u52a1\u5904\u7406\u3002
\u5f00\u53d1\u548c\u6d4b\u8bd5\uff1a\u5728\u5f00\u53d1\u65b0\u529f\u80fd\u6216\u6d4b\u8bd5\u7cfb\u7edf\u524d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5feb\u7167\u521b\u5efa\u6570\u636e\u5e93\u7684\u4e00\u4e2a\u526f\u672c\uff0c\u4ee5\u4fbf\u6d4b\u8bd5\u53ef\u4ee5\u5728\u4e0d\u5f71\u54cd\u751f\u4ea7\u73af\u5883\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u3002
\u6570\u636e\u8fc1\u79fb\uff1a\u5728\u6570\u636e\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5feb\u7167\u6765\u786e\u4fdd\u6570\u636e\u7684\u4e00\u81f4\u6027\uff0c\u907f\u514d\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u7684\u6570\u636e\u53d8\u66f4\u3002
\u9ad8\u5371\u64cd\u4f5c\u4fdd\u62a4\uff1a\u5728\u6267\u884c\u53ef\u80fd\u5bf9\u6570\u636e\u5e93\u7a33\u5b9a\u6027\u9020\u6210\u5f71\u54cd\u7684\u64cd\u4f5c\uff08\u5982\u6570\u636e\u5e93\u5347\u7ea7\u3001\u7ed3\u6784\u53d8\u66f4\u7b49\uff09\u4e4b\u524d\uff0c\u53ef\u4ee5\u521b\u5efa\u5feb\u7167\uff0c\u4ee5\u4fbf\u5728\u64cd\u4f5c\u5931\u8d25\u65f6\u80fd\u591f\u5feb\u901f\u6062\u590d\u3002
MatrixOne \u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\u79df\u6237\u7ea7\u522b\u7684\u5feb\u7167\u5907\u4efd\u6062\u590d\uff1a
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 mo_br
\u8fdb\u884c\u79df\u6237\u7ea7\u522b\u5feb\u7167\u5907\u4efd\u6062\u590d\u3002
Note
mo_br \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#_3","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne
\u5df2\u5b8c\u6210 mo_br \u5de5\u5177\u90e8\u7f72
create db if not exists snapshot_read;\nuse snapshot_read;\ncreate table test_snapshot_read (a int);\nINSERT INTO test_snapshot_read (a) VALUES(1), (2), (3), (4), (5),(6), (7), (8), (9), (10), (11), (12),(13), (14), (15), (16), (17), (18), (19), (20),(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),(31), (32), (33), (34), (35), (36), (37), (38), (39), (40),(41), (42), (43), (44), (45), (46), (47), (48), (49), (50),(51), (52), (53), (54), (55), (56), (57), (58), (59), (60),(61), (62), (63), (64), (65), (66), (67), (68), (69), (70),(71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90),(91), (92), (93), (94), (95), (96), (97), (98), (99), (100);\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"sp_01\" --account \"sys\" \n\n./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsp_01 2024-05-10 02:06:08.01635 account sys \n
delete from snapshot_read.test_snapshot_read where a <= 50;\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 50 |\n+----------+\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --table \"test_snapshot_read\" --sname \"sp_01\"\n
mysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#2","title":"\u793a\u4f8b 2 \u6570\u636e\u5e93\u7ea7\u522b\u6062\u590d","text":"create db if not exists snapshot_read;\nuse snapshot_read;\ncreate table test_snapshot_read (a int);\nINSERT INTO test_snapshot_read (a) VALUES(1), (2), (3), (4), (5),(6), (7), (8), (9), (10), (11), (12),(13), (14), (15), (16), (17), (18), (19), (20),(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),(31), (32), (33), (34), (35), (36), (37), (38), (39), (40),(41), (42), (43), (44), (45), (46), (47), (48), (49), (50),(51), (52), (53), (54), (55), (56), (57), (58), (59), (60),(61), (62), (63), (64), (65), (66), (67), (68), (69), (70),(71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90),(91), (92), (93), (94), (95), (96), (97), (98), (99), (100);\ncreate table test_snapshot_read_1(a int);\nINSERT INTO test_snapshot_read_1 (a) VALUES(1), (2), (3), (4), (5),(6), (7), (8), (9), (10), (11), (12),(13), (14), (15), (16), (17), (18), (19), (20),(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),(31), (32), (33), (34), (35), (36), (37), (38), (39), (40),(41), (42), (43), (44), (45), (46), (47), (48), (49), (50),(51), (52), (53), (54), (55), (56), (57), (58), (59), (60),(61), (62), (63), (64), (65), (66), (67), (68), (69), (70),(71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90),(91), (92), (93), (94), (95), (96), (97), (98), (99), (100);\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 200 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from snapshot_read.test_snapshot_read_1;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n1 row in set (0.01 sec)\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"sp_02\" --account \"sys\"\n\n./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsp_02 2024-05-10 02:47:15.638519 account sys \n
delete from snapshot_read.test_snapshot_read where a <= 50;\ndelete from snapshot_read.test_snapshot_read_1 where a >= 50;\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from snapshot_read.test_snapshot_read_1;\n+----------+\n| count(*) |\n+----------+\n| 49 |\n+----------+\n1 row in set (0.01 sec)\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --sname \"sp_02\"\n
mysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 200 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from snapshot_read.test_snapshot_read_1;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#3","title":"\u793a\u4f8b 3 \u79df\u6237\u7ea7\u522b\u6062\u590d","text":"\u79df\u6237\u7ea7\u522b\u6062\u590d
create database if not exists snapshot_read;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| snapshot_read |\n| system |\n| system_metrics |\n+--------------------+\n8 rows in set (0.00 sec)\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"sp_03\" --account \"sys\"\n\n./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsp_03 2024-05-11 03:20:16.065685 account sys \n
drop database snapshot_read;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.01 sec)\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\" --new_account \"acc2\" --new_admin_name \"admin\" --new_admin_password \"111\";\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| snapshot_read |\n| system |\n| system_metrics |\n+--------------------+\n8 rows in set (0.00 sec)\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| snapshot_read |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/","title":"mo_br \u5907\u4efd\u4e0e\u6062\u590d","text":"\u6570\u636e\u5e93\u7269\u7406\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u662f\u4e24\u79cd\u91cd\u8981\u7684\u6570\u636e\u4fdd\u62a4\u7b56\u7565\uff0c\u5b83\u4eec\u5728\u5f88\u591a\u573a\u666f\u4e0b\u90fd\u53d1\u6325\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002\u7269\u7406\u5907\u4efd\u901a\u8fc7\u590d\u5236\u6570\u636e\u5e93\u7684\u7269\u7406\u6587\u4ef6\uff0c\u5982\u6570\u636e\u6587\u4ef6\u548c\u65e5\u5fd7\u6587\u4ef6\uff0c\u80fd\u591f\u5b9e\u73b0\u5feb\u901f\u548c\u5b8c\u6574\u7684\u6570\u636e\u5e93\u6062\u590d\uff0c\u7279\u522b\u9002\u5408\u4e8e\u6570\u636e\u5e93\u6574\u4f53\u8fc1\u79fb\u6216\u707e\u96be\u6062\u590d\u7684\u60c5\u51b5\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u5feb\u7167\u5907\u4efd\u901a\u8fc7\u8bb0\u5f55\u6570\u636e\u5728\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u72b6\u6001\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u5feb\u901f\u4e14\u5b58\u50a8\u6548\u7387\u9ad8\u7684\u5907\u4efd\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u9700\u8981\u8fdb\u884c\u65f6\u95f4\u70b9\u6062\u590d\u6216\u53ea\u8bfb\u67e5\u8be2\u64cd\u4f5c\u7684\u573a\u666f\uff0c\u5982\u751f\u6210\u62a5\u544a\u6216\u8fdb\u884c\u6570\u636e\u5206\u6790\u3002\u7269\u7406\u5907\u4efd\u7684\u6062\u590d\u53ef\u80fd\u9700\u8981\u8f83\u957f\u65f6\u95f4\uff0c\u800c\u5feb\u7167\u5907\u4efd\u5219\u53ef\u4ee5\u63d0\u4f9b\u5feb\u901f\u7684\u6570\u636e\u8bbf\u95ee\uff0c\u4e24\u8005\u7ed3\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u4e3a\u6570\u636e\u5e93\u63d0\u4f9b\u5168\u9762\u7684\u4fdd\u62a4\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002
MatrixOne \u652f\u6301\u901a\u8fc7 mo_br
\u5b9e\u7528\u5de5\u5177\u8fdb\u884c\u5e38\u89c4\u7269\u7406\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u3002\u672c\u7ae0\u8282\u5c06\u4ecb\u7ecd mo_br
\u7684\u4f7f\u7528\u65b9\u6cd5\u3002
Note
mo_br \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_1","title":"\u53c2\u8003\u547d\u4ee4\u6307\u5357","text":"help - \u6253\u5370\u53c2\u8003\u6307\u5357
./mo_br help\nthe backup and restore tool for the matrixone\n\nUsage:\n mo_br [flags]\n mo_br [command]\n\nAvailable Commands:\n backup backup the matrixone data\n check check the backup\n completion Generate the autocompletion script for the specified shell\n delete delete the backup\n help Help about any command\n list search the backup\n restore restore the matrixone data\n snapshot Manage snapshots\n\nFlags:\n --config string config file (default \"./mo_br.toml\")\n -h, --help help for mo_br\n --log_file string log file (default \"console\")\n --log_level string log level (default \"error\")\n\nUse \"mo_br [command] --help\" for more information about a command.\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_2","title":"\u7269\u7406\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_3","title":"\u521b\u5efa\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_4","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br backup\n --host\n --port \n --user \n --password \n --backup_dir s3|filesystem \n //s3 oss minio\n --endpoint\n --access_key_id \n --secret_access_key \n --bucket \n --filepath\n --region \n --compression \n --role_arn \n --is_minio\n --parallelism \n //filesystem\n --path\n --parallelism\n --meta_path \n //\u589e\u91cf\u5907\u4efd\u9700\u8981\n --backup_type\n --base_id\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 backup_dir \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002s3 \u6216 filesystem endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5230 s3 \u7684\u670d\u52a1\u7684 URL access_key_id \u5907\u4efd\u5230 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230 s3 \u7684 Secret access key bucket \u5907\u4efd\u5230\u7684 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u5907\u4efd\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 region \u5907\u4efd\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression \u5907\u4efd\u5230 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 role_arn \u5907\u4efd\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 is_minio \u6307\u5b9a\u5907\u4efd\u5230\u7684 s3 \u662f\u5426\u4e3a minio path \u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u8def\u5f84 parallelism \u5e76\u884c\u5ea6 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 backup_type \u6307\u5b9a\u5907\u4efd\u7c7b\u578b\u4e3a\u589e\u91cf\u5907\u4efd\uff0cincremental\u3002 base_id \u4e0a\u6b21\u4e00\u6b21\u5907\u4efd\u7684 ID\uff0c\u4e3b\u8981\u7528\u4e8e\u786e\u5b9a\u4e0a\u6b21\u5907\u4efd\u7684\u65f6\u95f4\u6233\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_5","title":"\u793a\u4f8b","text":"./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\"\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"s3\" --endpoint \"http://127.0.0.1:9000\" --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\" --bucket \"bucket1\" --filepath \"/backup1\" --is_minio\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\" --backup_type \"incremental\" --base_id \"xxx\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_6","title":"\u67e5\u770b\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_7","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br list\n -- ID\n //\u8981\u67e5\u8be2\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key \n --not_check_data \n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_check_data \u53ea\u67e5\u770b meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u67e5\u770b\u5907\u4efd\u6570\u636e\u3002\u9ed8\u8ba4\u4e0d\u5e26\u8fd9\u4e2a\u53c2\u6570\u7684\uff0c\u5c31\u662f\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u3002\u5f53\u524d\u53ea\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_8","title":"\u793a\u4f8b","text":"./mo_br list\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n| 01108122-10f9-11ef-9359-26dd28356ef2 | 8.3 MB | BackupDir: filesystem Path: | 2024-05-13 15:18:28 +0800 | 3.394437375s | 2024-05-13 15:18:32 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n
./mo_br list 4d21b228-10dd-11ef-9497-26dd28356ef2\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n\nChecking the backup data(currently,no checksum)...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/log.toml_018f70d1-3100-7762-b28b-8f85ac4ed3cd\ncheck: config/tn.toml_018f70d1-310e-78fc-ac96-aa5e06981bd7\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_9","title":"\u5220\u9664\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_10","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br delete ID \n //\u8981\u5220\u9664\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key\n --not_delete_data\n --meta_path\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u5220\u9664\u7684\u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_delete_data \u53ea\u5220\u9664 meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u5220\u9664\u5907\u4efd\u6570\u636e\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_11","title":"\u793a\u4f8b","text":"./mo_br delete e4cade26-3139-11ee-8631-acde48001122\n
./mo_br delete e4cade26-3139-11ee-8631-acde48001122 --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_12","title":"\u6062\u590d\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_13","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br restore ID\n //\u8bfb\u53d6\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id\n --backup_secret_access_key \n\n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath \n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u6062\u590d\u7684 ID backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730\u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6//\u6062\u590d\u3002\nmo_br restore\n --backup_dir s3|filesystem \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --backup_endpoint \n --backup_access_key_id \n --backup_secret_access_key\n --backup_bucket\n --backup_filepath\n --backup_region \n --backup_compression \n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path \n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath\n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 \u6216 filesystem restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730 matrixone \u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_14","title":"\u793a\u4f8b","text":"\u4ece\u6587\u4ef6\u7cfb\u7edf\u6062\u590d\u5230\u6587\u4ef6\u7cfb\u7edf
\u6b65\u9aa4\u4e00\uff1a\u505c\u6b62 mo\uff0c\u5220\u9664 mo-data
\u6b65\u9aa4\u4e8c\uff1a\u6267\u884c\u4ee5\u4e0b\u6062\u590d\u547d\u4ee4
./mo_br restore fb26fd88-41bc-11ee-93f8-acde48001122 --restore_dir filesystem --restore_path \"your_mopath\"\n
\u6062\u590d\u540e\u4f1a\u5728 matrixone \u751f\u6210\u65b0\u7684 mo-data \u6587\u4ef6
\u6b65\u9aa4\u4e09\uff1a\u542f\u52a8 mo
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_15","title":"\u6821\u9a8c\u5907\u4efd\u7684\u6821\u9a8c\u7801","text":"\u8bfb\u53d6\u5907\u4efd\u6587\u4ef6\u5939\u4e2d\u7684\u6bcf\u4e2a\u6587\u4ef6\u53ca\u5176 sha256 \u6587\u4ef6\u3002\u8ba1\u7b97\u6587\u4ef6\u7684 sha256 \u503c\u5e76\u4e0e sha256 \u6587\u4ef6\u503c\u5bf9\u6bd4\u3002sha256 \u6587\u4ef6\u662f\u5728\u6587\u4ef6\u521b\u5efa\u6216\u66f4\u65b0\u65f6\uff0c\u521b\u5efa\u7684\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_16","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br check ID\n //\u6821\u9a8c\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id string\n --backup_secret_access_key string\n --meta_path string \u6307\u5b9ameta\u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684mo_br.meta\u6587\u4ef6\u3002\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002mo_br check\n --backup_dir s3|filesystem \n //s3 \n --backup_endpoint\n --backup_access_key_id\n --backup_secret_access_key \n --backup_bucket\n --backup_filepath \n --backup_region \n --backup_compression\n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path\n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u5907\u4efd\u6240\u5728\u7684\u8def\u5f84\u7c7b\u578b\uff0c\u5728\u6ca1\u6709\u6307\u5b9a ID \u65f6\uff0c\u5fc5\u987b\u8981\u6307\u5b9a\u3002s3 \u6216 filesystem backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_17","title":"\u793a\u4f8b","text":"./mo_br check 1614f462-126c-11ef-9af3-26dd28356ef3\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| 1614f462-126c-11ef-9af3-26dd28356ef3 | 126 MB | BackupDir: filesystem Path: | 2024-05-15 11:34:28 +0800 | 22.455633916s | 2024-05-15 11:34:50 +0800 |\n| | | /Users/admin/soft/incbackup/back2 | | | |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n\nChecking the backup data...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\n...\n
(base) admin@admindeMacBook-Pro mo-backup % ./mo_br check --backup_dir filesystem --backup_path /Users/admin/soft/incbackup/back2\n2024/05/15 11:40:30.011160 +0800 INFO malloc/malloc.go:42 malloc {\"max buffer size\": 1073741824, \"num shards\": 16, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 23}\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\ncheck: config/log.toml_018f7a50-d30c-7ed0-85bc-191e9f1eb753\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_18","title":"\u5feb\u7167\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_19","title":"\u521b\u5efa\u5feb\u7167","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_20","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br snapshot create\n --host\n --port \n --user\n --password \n --level \n --account \n --sname \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 level \u5feb\u7167\u5907\u4efd\u7684\u8303\u56f4\uff0c\u6682\u53ea\u652f\u6301 account account \u5feb\u7167\u5907\u4efd\u7684\u79df\u6237\u5bf9\u8c61\u540d sname \u5feb\u7167\u540d\u79f0"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_21","title":"\u793a\u4f8b","text":"./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"snapshot_01\" --account \"sys\"\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"snapshot_02\" --account \"acc1\" \n
\u666e\u901a\u79df\u6237\u521b\u5efa\u5feb\u7167\uff1a
create account acc1 admin_name admin IDENTIFIED BY '111';\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"acc1#admin\" --password \"111\" --level \"account\" --account \"acc1\" --sname \"snapshot_03\"\n
mo_br snapshot show\n --host\n --port \n --user \n --password \n --account \n --db \n --table \n --sname \n --beginTs \n --endTs\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 account \u8981\u7b5b\u9009\u7684\u79df\u6237\u540d\uff0c\u4ec5\u9650 sys \u7ba1\u7406\u5458\u4f7f\u7528 db \u8981\u7b5b\u9009\u7684\u6570\u636e\u5e93\u540d table \u8981\u7b5b\u9009\u7684\u8868\u540d sname \u8981\u7b5b\u9009\u7684\u5feb\u7167\u540d\u79f0 beginTs \u8981\u7b5b\u9009\u7684\u5feb\u7167\u65f6\u95f4\u6233\u7684\u5f00\u59cb\u65f6\u95f4 endTs \u8981\u7b5b\u9009\u7684\u5feb\u7167\u65f6\u95f4\u6233\u7684\u7ed3\u675f\u65f6\u95f4"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_24","title":"\u793a\u4f8b","text":"./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsnapshot_02 2024-05-11 02:29:23.07401 account acc1 \nsnapshot_01 2024-05-11 02:26:03.462462 account sys \n
./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"acc1#admin\" --password \"111\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsnapshot_03 2024-05-11 02:29:31.572512 account acc1 \n
./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"acc1\" --beginTs \"2024-05-11 00:00:00\" \nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsnapshot_02 2024-05-11 02:29:23.07401 account acc1 \n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_25","title":"\u5220\u9664\u5feb\u7167","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_26","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br snapshot drop\n --host\n --port \n --user \n --password \n --sname \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 sname \u8981\u7b5b\u9009\u7684\u5feb\u7167\u540d\u79f0"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_27","title":"\u793a\u4f8b","text":"./mo_br snapshot drop --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --sname \"snapshot_01\"\n
./mo_br snapshot drop --host \"127.0.0.1\" --port 6001 --user \"acc1#admin\" --password \"111\" --sname \"snapshot_03\" \n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_28","title":"\u6062\u590d\u5feb\u7167","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_29","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br snapshot restore\n --host \n --port \n --user \n --password \n --sname \n --account \n --db \n --table \n --newaccount \n --newaccountadmin \n --newaccountpwd \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 sname \u8981\u6062\u590d\u7684\u5feb\u7167\u540d\u79f0 account \u8981\u6062\u590d\u7684\u79df\u6237\u540d\uff0c\u4ec5\u9650 sys \u7ba1\u7406\u5458\u4f7f\u7528 db \u8981\u6062\u590d\u7684\u6570\u636e\u5e93\u540d table \u8981\u6062\u590d\u7684\u8868\u540d newaccount \u65b0\u521b\u5efa\u7684\u79df\u6237\u540d newaccountadmin \u79df\u6237\u7ba1\u7406\u5458 newaccountpwd \u79df\u6237\u7ba1\u7406\u5458\u5bc6\u7801NOTE: \u53ea\u6709\u7cfb\u7edf\u79df\u6237\u624d\u53ef\u4ee5\u6267\u884c\u6062\u590d\u6570\u636e\u5230\u65b0\u79df\u6237\uff0c\u4e14\u53ea\u5141\u8bb8\u79df\u6237\u7ea7\u522b\u7684\u6062\u590d\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_30","title":"\u793a\u4f8b","text":"./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --table \"test_snapshot_read\" --sname \"sp_01\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --sname \"sp_02\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\" --new_account \"acc2\" --new_admin_name \"admin\" --new_admin_password \"111\";\n
"},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/","title":"\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
MatrixOne \u4fdd\u6301\u4e86\u5bf9 MySQL \u8bed\u6cd5\u7684\u9ad8\u5ea6\u517c\u5bb9\uff0c\u56e0\u6b64\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u65e0\u9700\u5176\u4ed6\u64cd\u4f5c\uff0c\u53ef\u5b9e\u73b0\u65e0\u7f1d\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e2d\uff0c\u6570\u636e\u7c7b\u578b\u5728\u4fdd\u6301\u4e0e MySQL \u547d\u540d\u4e00\u81f4\u7684\u60c5\u51b5\u4e0b\uff0c\u5728\u7cbe\u5ea6\u4e0e\u8303\u56f4\u4e0a\uff0c\u4e0e MySQL \u5b58\u5728\u6709\u7740\u7ec6\u5fae\u7684\u5dee\u5f02\uff0c\u5177\u4f53\u53ef\u53c2\u89c1\u6570\u636e\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece MySQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL \u70b9\u51fb\u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a tpch_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u8fde\u63a5 MatrixOne\uff0c\u5e76\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
\u6253\u5f00 DBeaver\uff0c\u4ece MySQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
mysqldump
\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089\u5982\u4f55\u4f7f\u7528 mysqldump
\uff0c\u53ef\u53c2\u89c1 mysqldump \u6559\u7a0b\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece MySQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a tpch_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u4f7f\u7528 mysqldump
\u5c06 MySQL \u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\u6587\u4ef6\u3002\u8bf7\u786e\u4fdd\u4f60\u5bf9 filepath \u8def\u5f84\u5177\u6709\u5199\u6743\u9650\uff0c\u5e76\u68c0\u67e5 secure_file_priv
\u914d\u7f6e\uff1a
mysqldump -u root -p -t -T /{filepath} tpch --fields-terminated-by='|'\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 mysqldump
\u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 mysqldump
\u5bfc\u51fa\u6570\u636e\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u5c3d\u91cf\u5927\uff0cnet_buffer_length
\u8fd9\u4e2a\u53c2\u6570\u5c3d\u91cf\u5728 10mb \u8d77\u6b65\uff1a
mysqldump -t tpch -uroot -p --net_buffer_length=10m > tpch_data.sql\n
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff0c\u671f\u95f4\u4f1a\u6709\u62a5\u9519\u4fe1\u606f\uff0c\u4f46\u662f\u4e0d\u5f71\u54cd\u6570\u636e\u7684\u63d2\u5165\uff1a
source '/YOUR_PATH/tpch_data.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u5982\u679c\u4f60\u662f\u65b0\u624b\uff0c\u60f3\u5c1d\u8bd5\u8fc1\u79fb\u5c0f\u6570\u636e\u91cf\u7684\u6570\u636e\uff0c\u53ef\u53c2\u89c1\u4f7f\u7528 source
\u547d\u4ee4\u6279\u91cf\u5bfc\u5165\u6570\u636e\u3002
MatrixOne 1.2.1 \u7248\u672c\u5df2\u7ecf\u652f\u6301 MySQL \u7684\u5efa\u8868\u8bed\u53e5\uff0c\u56e0\u6b64\u53ef\u4ee5\u987a\u7545\u5730\u5c06 MySQL \u8868\u8fc1\u79fb\u5230 MatrixOne \u4e0a\u3002\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f\uff0c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u517c\u5bb9 MySQL \u90e8\u5206\u5173\u952e\u5b57\uff0c\u5982 engine=
\u7b49\uff0c\u5728 MatrixOne \u4e2d\u4f1a\u88ab\u81ea\u52a8\u5ffd\u7565\uff0c\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u8868\u7ed3\u6784\u7684\u8fc1\u79fb\u3002
\u4f46\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c\u5c3d\u7ba1 MatrixOne \u652f\u6301 MySQL \u5efa\u8868\u8bed\u53e5\uff0c\u5982\u679c\u8fc1\u79fb\u7684\u8868\u4e2d\u5305\u542b\u4e0d\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3001\u89e6\u53d1\u5668\u3001\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ecd\u9700\u8981\u624b\u52a8\u4fee\u6539\u3002\u66f4\u591a\u8be6\u7ec6\u7684\u517c\u5bb9\u6027\u4fe1\u606f\uff0c\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/","title":"\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
Oracle \u662f\u5168\u7403\u76ee\u524d\u6700\u5e7f\u6cdb\u4f7f\u7528\u7684\u5546\u4e1a\u6570\u636e\u5e93\uff0c\u5176\u4f7f\u7528\u573a\u666f\u4e0e\u6d41\u884c\u5ea6\u90fd\u5e38\u5e74\u9ad8\u5c45 DBEngine \u7b2c\u4e00\u540d\uff0cMatrixOne \u540c\u6837\u53ef\u4ee5\u652f\u6301\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u7684\u573a\u666f\u3002\u6839\u636e Oracle \u7684\u6570\u636e\u91cf\u5927\u5c0f\uff0c\u672c\u6587\u4f9d\u7136\u63a8\u8350\u4f7f\u7528\u5728\u7ebf\u4e0e\u79bb\u7ebf\u4e24\u79cd\u6a21\u5f0f\u8fdb\u884c\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e0e Oracle \u81ea\u5e26\u7684\u6570\u636e\u7c7b\u578b\u5b58\u5728\u7740\u8f83\u591a\u7684\u5dee\u5f02\uff0c\u8fd9\u4e9b\u5dee\u5f02\u6709\u4e9b\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u7c7b\u578b\u6765\u66ff\u6362\uff0c\u6709\u4e9b\u5219\u6682\u65f6\u65e0\u6cd5\u652f\u6301\uff0c\u5177\u4f53\u5217\u8868\u5982\u4e0b\uff1a
Oracle MatrixOne varchar2 \u4f7f\u7528 text \u66ff\u6362 nchar/nvarcahr \u4f7f\u7528 char/varchar \u66ff\u6362 NUMBER(3,0), NUMBER(5,0) \u4f7f\u7528 smallint \u66ff\u6362 NUMBER(10,0) \u4f7f\u7528 int \u66ff\u6362 NUMBER(38,0) \u4f7f\u7528 bitint \u66ff\u6362 NUMBER(n,p) (p>0) \u4f7f\u7528 decimal(n,p) \u66ff\u6362 binary_float/binary_double \u4f7f\u7528 float/double \u66ff\u6362 long \u4f7f\u7528 text \u66ff\u6362 long raw \u4f7f\u7528 blob \u66ff\u6362 raw \u4f7f\u7528 varbinary \u66ff\u6362 clob/nclob \u4f7f\u7528 text \u66ff\u6362 bfile \u6682\u4e0d\u652f\u6301 rowid/urowid \u6682\u4e0d\u652f\u6301 user-defined types \u6682\u4e0d\u652f\u6301 any \u6682\u4e0d\u652f\u6301 xml \u6682\u4e0d\u652f\u6301 spatial \u6682\u4e0d\u652f\u6301"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u901a\u8fc7 DBeaver\uff0c\u5c06\u6e90\u7aef\u7684\u6570\u636e\u6309\u6279\u6b21\u83b7\u53d6\uff0c\u518d\u5c06\u6570\u636e\u4ee5 INSERT
\u7684\u65b9\u5f0f\uff0c\u63d2\u5165\u5230\u76ee\u6807\u5e93\u3002\u5982\u679c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u62a5\u9519 heap \u7a7a\u95f4\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6bcf\u4e2a\u6279\u6b21\u83b7\u53d6\u5e76\u63d2\u5165\u6570\u636e\u7684\u89c4\u6a21\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a oracle_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u66ff\u6362 oracle_ddl.sql \u6587\u4ef6\u5185 MatrixOne \u4e0d\u652f\u6301\u7684\u5173\u952e\u5b57\uff1a
# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n#MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a oracle_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u66ff\u6362 oracle_ddl.sql \u6587\u4ef6\u5185 MatrixOne \u4e0d\u652f\u6301\u7684\u5173\u952e\u5b57\uff1a
# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n#MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u4f7f\u7528 DBeaver \u5148\u5c06 Oracle \u7684\u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff0c\u5e76\u4f7f\u7528 MatrixOne \u7684\u5e76\u884c\u52a0\u8f7d\u529f\u80fd\u5c06\u6570\u636e\u8fc1\u79fb\u81f3 MatrixOne\uff1a
\u6253\u5f00 DBeaver\uff0c\u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff0c\u5c06 Oracle \u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\u6587\u4ef6\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9 CSV\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1a
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 DBeaver \u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 DBeaver \u5bfc\u51fa\u6570\u636e\uff1a\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e > SQL\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u53c2\u6570\u6bcf\u6761\u8bed\u53e5\u7684\u6570\u636e\u884c\u6570\u8bbe\u7f6e\u4e3a 5000\uff1a
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff1a
source '/YOUR_PATH/oracle_data.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece PostgreSQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
PostgreSQL \u662f\u76ee\u524d\u5168\u4e16\u754c\u6700\u5148\u8fdb\u7684\u5f00\u6e90\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e4b\u4e00\uff0c\u62e5\u6709\u8005\u6781\u5176\u5b8c\u5907\u7684\u6570\u636e\u7c7b\u578b\u3001\u5bf9\u8c61\u7c7b\u578b\u3001SQL \u6a21\u578b\u4ee5\u53ca\u5176\u4ed6\u529f\u80fd\uff0c\u5728\u4f01\u4e1a\u3001\u6559\u80b2\u79d1\u7814\u7b49\u8bf8\u591a\u9886\u57df\u6709\u7740\u91cd\u8981\u7684\u5730\u4f4d\u3002\u6839\u636e PostgreSQL \u7684\u6570\u636e\u91cf\u5927\u5c0f\uff0c\u672c\u6587\u4f9d\u7136\u63a8\u8350\u4f7f\u7528\u5728\u7ebf\u4e0e\u79bb\u7ebf\u4e24\u79cd\u6a21\u5f0f\u8fdb\u884c\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e0e PostgreSQL \u81ea\u5e26\u7684\u6570\u636e\u7c7b\u578b\u5b58\u5728\u7740\u8f83\u591a\u7684\u5dee\u5f02\uff0c\u8fd9\u4e9b\u5dee\u5f02\u6709\u4e9b\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u7c7b\u578b\u6765\u66ff\u6362\uff0c\u6709\u4e9b\u5219\u6682\u65f6\u65e0\u6cd5\u652f\u6301\u3002\u540c\u65f6\uff0cPostgreSQL \u652f\u6301\u4e09\u5c42\u903b\u8f91\u7ed3\u6784\uff1aDatabase\uff08\u6570\u636e\u5e93\uff09 - Schema\uff08\u6a21\u5f0f\uff09 - Table\uff08\u8868\uff09\uff0c\u5373\u4f60\u53ef\u4ee5\u5728\u4e00\u4e2a\u6570\u636e\u5e93\u5185\u521b\u5efa\u591a\u4e2a\u6a21\u5f0f\uff0c\u6bcf\u4e2a\u6a21\u5f0f\u5185\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u8868\uff0c\u8fd9\u6837\u7684\u5c42\u7ea7\u7ed3\u6784\u5141\u8bb8\u66f4\u597d\u5730\u7ec4\u7ec7\u548c\u7ba1\u7406\u6570\u636e\uff1b\u800c MatrixOne \u4ec5\u652f\u6301\u4e24\u5c42\u903b\u8f91\u7ed3\u6784\uff1aDatabase\uff08\u6570\u636e\u5e93\uff09 - Table\uff08\u8868\uff09\u3002\u5728 MatrixOne \u4e2d\uff0c\u76f4\u63a5\u5728\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u8868\uff0c\u6240\u4ee5\u6570\u636e\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u4e5f\u4f1a\u5b58\u5728\u4e9b\u8bb8\u4e0d\u540c\u3002
\u6570\u636e\u7c7b\u578b\u5dee\u5f02\u5177\u4f53\u5217\u8868\u5982\u4e0b\uff1a
PostgreSQL MatrixOne serial \u901a\u8fc7\u81ea\u589e\u5217\u66ff\u6362 money \u4f7f\u7528 decimal \u66ff\u6362 bytea \u4f7f\u7528 binary \u6216 varbinary \u66ff\u6362 geometric \u6682\u4e0d\u652f\u6301 network adress \u4f7f\u7528 char \u6216 varchar \u66ff\u6362 bit string \u6682\u4e0d\u652f\u6301 text search \u6682\u4e0d\u652f\u6301 xml \u6682\u4e0d\u652f\u6301 array \u6682\u4e0d\u652f\u6301 composite \u6682\u4e0d\u652f\u6301 range \u6682\u4e0d\u652f\u6301 domain \u6682\u4e0d\u652f\u6301 object identifier \u6682\u4e0d\u652f\u6301 pg_lsn \u6682\u4e0d\u652f\u6301 pseudo \u6682\u4e0d\u652f\u6301"},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece PostgreSQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u901a\u8fc7 DBeaver\uff0c\u5c06\u6e90\u7aef\u7684\u6570\u636e\u6309\u6279\u6b21\u83b7\u53d6\uff0c\u518d\u5c06\u6570\u636e\u4ee5 INSERT
\u7684\u65b9\u5f0f\uff0c\u63d2\u5165\u5230\u76ee\u6807\u5e93\u3002\u5982\u679c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u62a5\u9519 heap \u7a7a\u95f4\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6bcf\u4e2a\u6279\u6b21\u83b7\u53d6\u5e76\u63d2\u5165\u6570\u636e\u7684\u89c4\u6a21\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece PostgreSQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece PostgreSQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL \u70b9\u51fb\u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a pg_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\u7684 DDL\uff1a**
a. \u9996\u5148\uff0c\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5c06 pg_ddl.sql \u6587\u4ef6\u4e2d\u7684 bpchar
\u66ff\u6362\u4e3a char
\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n
b. \u63a5\u4e0b\u6765\uff0c\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\uff0c\u5e76\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230 mysql_ddl.sql \u6587\u4ef6\u4e2d\uff1a
```\n# Linux \u548c MacOS \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5747\u5982\u4e0b\uff1a\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n
c. \u8f6c\u6362\u540e\u7684 DDL \u4f1a\u4fdd\u7559\u539f\u59cb\u7684 Postgresql schema \u540d\u79f0\u3002\u5982\u679c\u6709\u5fc5\u8981\uff0c\u4f60\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06 schema \u540d\u79f0\u66ff\u6362\u4e3a MySQL \u4e2d\u7684\u6570\u636e\u5e93\u540d\u79f0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n
d. \u6700\u540e\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u7edf\u4e00\u5c06 mysql_ddl.sql \u6587\u4ef6\u4e2d\u7684 numeric
\u66ff\u6362\u4e3a decimal
\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b9e\u73b0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
\u8fde\u63a5 MatrixOne\uff0c\u5e76\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
\u6253\u5f00 DBeaver\uff0c\u4ece PostgreSQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
DDL \u8f6c\u8bd1\u5de5\u5177\uff1a\u5728\u8df3\u677f\u673a\u4e0a\u4e0b\u8f7d pg2mysql\u3002
\u5728 PostgreSQL \u670d\u52a1\u5668\u7aef\u5b89\u88c5 pgdump
\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089\u5982\u4f55\u4f7f\u7528 mysqldump
\uff0c\u53ef\u53c2\u89c1 pgdump \u6559\u7a0b
\u6253\u5f00 DBeaver\uff0c\u4ece PostgreSQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL \u70b9\u51fb\u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a pg_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\u7684 DDL\uff1a**
a. \u9996\u5148\uff0c\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5c06 pg_ddl.sql \u6587\u4ef6\u4e2d\u7684 bpchar
\u66ff\u6362\u4e3a char
\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n
b. \u63a5\u4e0b\u6765\uff0c\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\uff0c\u5e76\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230 mysql_ddl.sql \u6587\u4ef6\u4e2d\uff1a
```\n# Linux \u548c MacOS \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5747\u5982\u4e0b\uff1a\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n
c. \u8f6c\u6362\u540e\u7684 DDL \u4f1a\u4fdd\u7559\u539f\u59cb\u7684 Postgresql schema \u540d\u79f0\u3002\u5982\u679c\u6709\u5fc5\u8981\uff0c\u4f60\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06 schema \u540d\u79f0\u66ff\u6362\u4e3a MySQL \u4e2d\u7684\u6570\u636e\u5e93\u540d\u79f0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n
d. \u6700\u540e\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u7edf\u4e00\u5c06 mysql_ddl.sql \u6587\u4ef6\u4e2d\u7684 numeric
\u66ff\u6362\u4e3a decimal
\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b9e\u73b0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
\u8fde\u63a5 MatrixOne\uff0c\u5e76\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u5728 PostgreSQL \u6570\u636e\u5e93\u547d\u4ee4\u884c\u73af\u5883\u4e0b\u5c06 PostgreSQL \u7684\u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff1a
postgres=# \\c tpch;\npostgres=# COPY tpch.nation TO '/{filepath}/nation.tbl' DELIMITER '|';\npostgres=# COPY tpch.region TO '/{filepath}/region.tbl' DELIMITER '|';\npostgres=# COPY tpch.customer TO '/{filepath}/customer.tbl' DELIMITER '|';\npostgres=# COPY tpch.part TO '/{filepath}/part.tbl' DELIMITER '|';\npostgres=# COPY tpch.supplier TO '/{filepath}/supplier.tbl' DELIMITER '|';\npostgres=# COPY tpch.partsupp TO '/{filepath}/partsupp.tbl' DELIMITER '|';\npostgres=# COPY tpch.lineitem TO '/{filepath}/lineitem.tbl' DELIMITER '|';\npostgres=# COPY tpch.orders TO '/{filepath}/orders.tbl' DELIMITER '|';\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.tbl' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.tbl' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.tbl' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.tbl' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.tbl' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.tbl' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.tbl' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.tbl' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 pgdump
\u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 pgdump
\u5bfc\u51fa\u6570\u636e\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u5c3d\u91cf\u5927\uff0cnet_buffer_length
\u8fd9\u4e2a\u53c2\u6570\u5c3d\u91cf\u5728 10mb \u8d77\u6b65\uff1a
$ pg_dump -U postgres --no-acl --no-owner --inserts --rows-per-insert 5000 --format p --data-only --schema=tpch tpch -f pg_data.sql\n
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff0c\u671f\u95f4\u4f1a\u6709\u62a5\u9519\u4fe1\u606f\uff0c\u4f46\u662f\u4e0d\u5f71\u54cd\u6570\u636e\u7684\u63d2\u5165\uff1a
source '/YOUR_PATH/pg_data.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u5982\u679c\u4f60\u662f\u65b0\u624b\uff0c\u60f3\u5c1d\u8bd5\u8fc1\u79fb\u5c0f\u6570\u636e\u91cf\u7684\u6570\u636e\uff0c\u53ef\u53c2\u89c1\u4f7f\u7528 source
\u547d\u4ee4\u6279\u91cf\u5bfc\u5165\u6570\u636e\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
SQLServer \u4f5c\u4e3a\u4e00\u6b3e\u6210\u719f\u7684\u5546\u4e1a\u6570\u636e\u5e93\uff0c\u5728\u5404\u4e2a\u884c\u4e1a\u5185\u5747\u6709\u7740\u5e7f\u6cdb\u5730\u4f7f\u7528\uff0c\u5e76\u4e14\u5176\u529f\u80fd\u4e0e\u6027\u80fd\u90fd\u975e\u5e38\u51fa\u4f17\u3002\u4f5c\u4e3a\u4e00\u6b3e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0cMatrixOne \u540c\u6837\u652f\u6301\u591a\u79cd\u4ece SQLServer \u800c\u6765\u7684\u6570\u636e\u5e93\u8fc1\u79fb\u6a21\u5f0f\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e0e SQL Server \u5b58\u5728\u7740\u8bf8\u591a\u7c7b\u578b\u4e0a\u7684\u5dee\u5f02\uff0c\u8fd9\u4e9b\u5dee\u5f02\u6709\u4e9b\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u7c7b\u578b\u6765\u66ff\u6362\uff0c\u6709\u4e9b\u5219\u6682\u65f6\u65e0\u6cd5\u652f\u6301\uff0c\u5177\u4f53\u5217\u8868\u5982\u4e0b\uff1a
SQLServer MatrixOne real \u4f7f\u7528 double \u66ff\u6362 money, smallmoney \u4f7f\u7528 decimal \u66ff\u6362 datetimeoffset \u4f7f\u7528 timestmap \u4e0e\u65f6\u533a\u66ff\u6362 nchar/nvarchar/ntext \u4f7f\u7528 char/varchar/text \u66ff\u6362 image \u4f7f\u7528 blob \u66ff\u6362 uniqueidentifier \u4f7f\u7528 uuid \u66ff\u6362 bit \u6682\u4e0d\u652f\u6301 rowversion \u6682\u4e0d\u652f\u6301 hierarchyid \u6682\u4e0d\u652f\u6301 sql_variant \u6682\u4e0d\u652f\u6301 xml \u6682\u4e0d\u652f\u6301 geometry \u6682\u4e0d\u652f\u6301 geography \u6682\u4e0d\u652f\u6301"},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u901a\u8fc7 DBeaver\uff0c\u5c06\u6e90\u7aef\u7684\u6570\u636e\u6309\u6279\u6b21\u83b7\u53d6\uff0c\u518d\u5c06\u6570\u636e\u4ee5 INSERT
\u7684\u65b9\u5f0f\uff0c\u63d2\u5165\u5230\u76ee\u6807\u5e93\u3002\u5982\u679c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u62a5\u9519 heap \u7a7a\u95f4\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6bcf\u4e2a\u6279\u6b21\u83b7\u53d6\u5e76\u63d2\u5165\u6570\u636e\u7684\u89c4\u6a21\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece SQL Server \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece SQL Server \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a sqlserver_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u4f7f\u7528 LOAD DATA
\u5148\u5c06 SQL Server \u7684\u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff0c\u5e76\u4f7f\u7528 MatrixOne \u7684\u5e76\u884c LOAD \u529f\u80fd\u5c06\u6570\u636e\u8fc1\u79fb\u81f3 MatrixOne\uff1a
\u6253\u5f00 DBeaver\uff0c\u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff0c\u5c06 SQL Server \u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\u6587\u4ef6\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9 CSV\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1a
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 DBeaver \u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 DBeaver \u5bfc\u51fa\u6570\u636e\uff1a\u6253\u5f00 DBeaver\uff0c\u4ece SQL Server \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e > SQL\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u53c2\u6570\u6bcf\u6761\u8bed\u53e5\u7684\u6570\u636e\u884c\u6570\u8bbe\u7f6e\u4e3a 5000\uff1a
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u66ff\u6362 sqlserver_ddl.sql \u6587\u4ef6\u5185 MatrixOne \u4e0d\u652f\u6301\u7684\u5173\u952e\u5b57\uff1a
# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/,N/,/g' mssql_data.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/,N/,/g' mssql_data.sql\n
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff1a
ues tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u5728\u4f7f\u7528 MatrixOne \u65f6\uff0c\u6709\u65f6\u9700\u8981\u5c06\u6570\u636e\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8fc1\u79fb\u81f3 MatrixOne\u3002\u7531\u4e8e\u4e0d\u540c\u6570\u636e\u5e93\u4e4b\u95f4\u5b58\u5728\u5dee\u5f02\uff0c\u6570\u636e\u8fc1\u79fb\u9700\u8981\u4e00\u4e9b\u989d\u5916\u7684\u5de5\u4f5c\u3002\u4e3a\u4e86\u65b9\u4fbf\u7528\u6237\u5feb\u901f\u5bfc\u5165\u5916\u90e8\u6570\u636e\uff0cMatrixOne \u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177\u548c\u529f\u80fd\u3002
\u4ee5\u4e0b\u662f\u5176\u4e2d\u7684\u4e00\u4e9b\u5e38\u89c1\u7684\u5de5\u5177\u548c\u529f\u80fd\uff1a
"},{"location":"MatrixOne/Migrate/migrate-overview/#load-data","title":"LOAD DATA","text":"\u4e0e MySQL \u7c7b\u4f3c\uff0cMatrixOne \u63d0\u4f9b\u4e86 LOAD DATA \u529f\u80fd\uff0c\u5141\u8bb8\u7528\u6237\u5c06\u5916\u90e8\u7684 CSV \u6587\u4ef6\u6216 JSON \u6587\u4ef6\u5feb\u901f\u5e76\u884c\u5730\u5bfc\u5165\u5230\u4e0e\u8868\u7ed3\u6784\u5339\u914d\u7684\u8868\u4e2d\u3002
"},{"location":"MatrixOne/Migrate/migrate-overview/#source","title":"SOURCE","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 SOURCE \u547d\u4ee4\u5c06\u6570\u636e\u548c\u8868\u7ed3\u6784\u8fc1\u79fb\u5230\u76ee\u6807\u6570\u636e\u5e93\u4e2d\u3002
\u66f4\u591a\u5173\u4e8e\u4f7f\u7528 LOAD DATA \u6216 SOURCE \u8fdb\u884c\u6279\u91cf\u5bfc\u5165\u7684\u6587\u6863\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
"},{"location":"MatrixOne/Migrate/migrate-overview/#_1","title":"\u53c2\u8003\u6587\u6863","text":"MatrixOne \u63d0\u4f9b\u4e86\u4ee5\u4e0b\u6587\u6863\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u4e86\u89e3\u5982\u4f55\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u5c06\u6570\u636e\u8fc1\u79fb\u81f3 MatrixOne\uff1a
\u672c\u6587\u6863\u5217\u51fa\u4e86 MatrixOne \u6700\u65b0\u7248\u672c\u6240\u652f\u6301\u7684\u529f\u80fd\u6e05\u5355\uff0c\u9488\u5bf9\u5e38\u89c1\u4ee5\u53ca\u5728 MatrixOne \u7684\u8def\u7ebf\u56fe\u4e2d\u7684\u529f\u80fd\u4f46\u662f\u76ee\u524d\u4e0d\u652f\u6301\u7684\u529f\u80fd\u4e5f\u5c06\u5217\u51fa\u3002
"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-definition-language-ddl","title":"\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff08Data definition language, DDL\uff09","text":"\u6570\u636e\u5b9a\u4e49\u8bed\u8a00 (DDL) \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u521b\u5efa\u6570\u636e\u5e93 CREATE DATABASE Y \u5220\u9664\u6570\u636e\u5e93 DROP DATABASE Y \u4fee\u6539\u6570\u636e\u5e93 ALTER DATABASE N \u521b\u5efa\u8868 CREATE TABLE Y \u4fee\u6539\u8868 ALTER TABLE E \u4fee\u6539\u8868\u540d RENAME TABLE N\uff0c\u53ef\u7528 ALTER TABLE tbl RENAME TO new_tbl \u66ff\u4ee3 \u5220\u9664\u8868 DROP TABLE Y \u521b\u5efa\u7ea6\u675f CREATE INDEX Y \u5220\u9664\u7ea6\u675f DROP INDEX Y \u4fee\u6539\u5217 MODIFY COLUMN Y \u4e3b\u952e PRIMARY KEY Y \u521b\u5efa\u89c6\u56fe CREATE VIEW Y \u4fee\u6539\u89c6\u56fe ALTER VIEW Y \u5220\u9664\u89c6\u56fe DROP VIEW Y \u6e05\u7a7a\u8868 TRUNCATE TABLE Y \u81ea\u589e\u5217 AUTO_INCREMENT Y \u5e8f\u5217 SEQUENCE Y \u4e34\u65f6\u8868 TEMPORARY TABLE Y \u6d41\u5f0f\u8868 CREATE DYNAMIC TABLE E\uff0c\u90e8\u5206\u652f\u6301 \u5206\u533a\u8868 PARTITION BY E\uff0c\u90e8\u5206\u7c7b\u578b\u652f\u6301 \u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u987a\u5e8f CHARSET\uff0cCOLLATION N\uff0c\u4ec5\u9ed8\u8ba4\u652f\u6301 UTF8"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-manipulationquery-language-dmldql","title":"\u6570\u636e\u4fee\u6539/\u67e5\u8be2\u8bed\u8a00\uff08Data manipulation/query language, DML/DQL\uff09","text":"SQL \u8bed\u53e5 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) SELECT Y INSERT Y UPDATE Y DELETE Y REPLACE Y INSERT ON DUPLICATE KEY UPDATE Y \u5bfc\u5165\u6570\u636e LOAD DATA Y \u5bfc\u51fa\u6570\u636e SELECT INTO Y \u8fde\u63a5 INNER/LEFT/RIGHT/OUTER JOIN Y \u8054\u5408 UNION, UNION ALL Y EXCEPT, INTERSECT Y GROUP BY, ORDER BY Y \u9884\u6392\u5e8f CLUSTER BY Y \u5b50\u67e5\u8be2 SUBQUERY Y \u516c\u5171\u8868\u8868\u8fbe\u5f0f (Common Table Expressions\uff0cCTE) Y \u4e8b\u52a1\u8bed\u53e5 BEGIN/START TRANSACTION, COMMIT, ROLLBACK Y EXPLAIN Y EXPLAIN ANALYZE Y \u8868\u7ea7\u9501 LOCK/UNLOCK TABLE N \u7528\u6237\u81ea\u5b9a\u4e49\u53d8\u91cf Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#sql","title":"\u9ad8\u7ea7 SQL \u529f\u80fd","text":"\u9ad8\u7ea7 SQL \u529f\u80fd \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u9884\u5904\u7406 PREPARE Y \u5b58\u50a8\u8fc7\u7a0b STORED PROCEDURE N \u89e6\u53d1\u5668 TRIGGER N \u65f6\u95f4\u8c03\u5ea6\u5668 EVENT SCHEDULER N \u81ea\u5b9a\u4e49\u51fd\u6570 UDF Y \u7269\u5316\u89c6\u56fe Materialized VIEW N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_1","title":"\u6d41\u8ba1\u7b97","text":"\u6d41\u8ba1\u7b97\u529f\u80fd \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u52a8\u6001\u8868 E Kafka \u8fde\u63a5\u5668 E \u7269\u5316\u89c6\u56fe N (\u589e\u91cf) \u7269\u5316\u89c6\u56fe N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_2","title":"\u65f6\u5e8f","text":"\u6d41\u8ba1\u7b97\u529f\u80fd \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u65f6\u5e8f\u8868 Y \u6ed1\u52a8\u7a97\u53e3 Y \u964d\u91c7\u6837 Y \u63d2\u503c Y TTL\uff08Time To Live\uff09 N ROLLUP N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_3","title":"\u6570\u636e\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b\u5206\u7c7b \u6570\u636e\u7c7b\u578b \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u6574\u6570\u7c7b\u578b TINYINT/SMALLINT/INT/BIGINT (UNSIGNED) Y BIT N \u6d6e\u70b9\u7c7b\u578b FLOAT Y DOUBLE Y \u5b57\u7b26\u4e32\u7c7b\u578b CHAR Y VARCHAR Y BINARY Y VARBINARY Y TINYTEXT/TEXT/MEDIUMTEXT/LONGTEXT Y ENUM Y SET N \u4e8c\u8fdb\u5236\u7c7b\u578b TINYBLOB/BLOB/MEDIUMBLOB/LONGBLOB Y \u65f6\u95f4\u4e0e\u65e5\u671f DATE Y TIME Y DATETIME Y TIMESTAMP Y YEAR Y Boolean BOOL Y \u5b9a\u70b9\u7c7b\u578b DECIMAL Y\uff0c\u6700\u9ad8\u5230 38 \u4f4d JSON \u7c7b\u578b JSON Y \u5411\u91cf\u7c7b\u578b VECTOR Y \u6570\u7ec4\u7c7b\u578b ARRAY N\uff08\u4e0e MySQL \u4e00\u81f4\uff0c\u5728 JSON \u4e2d\u63d0\u4f9b\u6570\u7ec4\u64cd\u4f5c\uff09 \u4f4d\u56fe\u7c7b\u578b BITMAP N \u7a7a\u95f4\u7c7b\u578b GEOMETRY/POINT/LINESTRING/POLYGON N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_4","title":"\u7d22\u5f15\u4e0e\u7ea6\u675f","text":"\u7d22\u5f15\u4e0e\u7ea6\u675f \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u4e3b\u952e\u7ea6\u675f Y \u590d\u5408\u4e3b\u952e Y \u552f\u4e00\u7ea6\u675f Y \u6b21\u7ea7\u7d22\u5f15 Y \u5411\u91cf\u7d22\u5f15 Y \u5916\u952e\u7ea6\u675f Y \u65e0\u6548\u6570\u636e\u5f3a\u5236\u7ea6\u675f Y ENUM \u548c SET \u7ea6\u675f N \u975e\u7a7a\u7ea6\u675f Y \u81ea\u589e\u7ea6\u675f Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_5","title":"\u4e8b\u52a1","text":"\u4e8b\u52a1 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u60b2\u89c2\u4e8b\u52a1 Y\uff08\u9ed8\u8ba4\u6a21\u5f0f\uff09 \u4e50\u89c2\u4e8b\u52a1 Y \u8de8\u5e93\u4e8b\u52a1 Y \u5206\u5e03\u5f0f\u4e8b\u52a1 Y \u53ef\u91cd\u590d\u8bfb\u9694\u79bb\uff08\u5feb\u7167 SI \u9694\u79bb\uff09 Y \u8bfb\u5df2\u63d0\u4ea4 RC \u9694\u79bb Y\uff08\u9ed8\u8ba4\u6a21\u5f0f\uff09"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_6","title":"\u51fd\u6570\u4e0e\u64cd\u4f5c\u7b26","text":"\u51fd\u6570\u4e0e\u64cd\u4f5c\u7b26 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u805a\u5408\u51fd\u6570 Y \u6570\u503c\u7c7b\u51fd\u6570 Y \u65f6\u95f4\u65e5\u671f\u7c7b\u51fd\u6570 Y \u5b57\u7b26\u4e32\u51fd\u6570 Y Cast \u51fd\u6570 Y \u6d41\u7a0b\u63a7\u5236\u51fd\u6570 E \u7a97\u53e3\u51fd\u6570 Y JSON \u51fd\u6570 Y \u5411\u91cf\u51fd\u6570 Y \u7cfb\u7edf\u51fd\u6570 Y \u5176\u4ed6\u51fd\u6570 Y \u64cd\u4f5c\u7b26 YMatrixOne \u7684\u5b8c\u6574\u51fd\u6570\u5217\u8868\u53ef\u4ee5\u53c2\u89c1\u8be5\u51fd\u6570\u603b\u8868.
"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_7","title":"\u5206\u533a","text":"\u5206\u533a \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) KEY \u5206\u533a E HASH \u5206\u533a E RANGE \u5206\u533a E RANGE COLUMNS \u5206\u533a E LIST \u5206\u533a E LIST COLUMNS \u5206\u533a E"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_8","title":"\u6570\u636e\u5bfc\u5165\u548c\u5bfc\u51fa","text":"\u6570\u636e\u5bfc\u5165\u548c\u5bfc\u51fa \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) INSERT INTO \u5199\u5165 Y SQL \u5bfc\u5165 SOURCE Y \u6587\u4ef6\u5bfc\u5165 LOAD DATA INFILE Y \u6d41\u5f0f\u5bfc\u5165 LOAD DATA INLINE Y \u4ece\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165 Y mo-dump \u5de5\u5177\u5bfc\u51fa SQL/CSV Y SELECT INTO \u5bfc\u51fa CSV/JSON Y mysqldump \u539f\u751f\u5de5\u5177 N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_9","title":"\u5b89\u5168\u4e0e\u8bbf\u95ee\u63a7\u5236","text":"\u5b89\u5168 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u4f20\u8f93\u5c42\u52a0\u5bc6 TLS Y \u9759\u6001\u52a0\u5bc6 Y \u4ece\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165 Y \u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\uff08RBAC\uff09 Y \u591a\u79df\u6237 Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_10","title":"\u5907\u4efd\u548c\u6062\u590d","text":"\u5907\u4efd\u548c\u6062\u590d \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u903b\u8f91\u5907\u4efd\u6062\u590d Y\uff0c\u4ec5\u652f\u6301 mo-dump \u5de5\u5177 \u7269\u7406\u5907\u4efd\u6062\u590d Y\uff0c\u4ec5\u652f\u6301 mobackup \u5de5\u5177 \u5feb\u7167\u5907\u4efd\u6062\u590d Y\uff0c\u652f\u6301 mobackup \u5de5\u5177 \u548c SQL CDC \u540c\u6b65 N\uff08MatrixOne \u4f5c\u4e3a\u6e90\u7aef\u4e0d\u652f\u6301\uff09"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_11","title":"\u7ba1\u7406\u5de5\u5177","text":"\u7ba1\u7406\u5de5\u5177 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u5355\u673a mo_ctl \u90e8\u7f72\u7ba1\u7406 Y \u5206\u5e03\u5f0f mo_ctl \u90e8\u7f72\u7ba1\u7406 E\uff0c\u4ec5\u4f01\u4e1a\u7248 \u53ef\u89c6\u5316\u7ba1\u7406\u5e73\u53f0 E\uff0c\u4ec5\u516c\u6709\u4e91\u7248\u672c \u7cfb\u7edf\u65e5\u5fd7\u8bb0\u5f55 Y \u7cfb\u7edf\u6307\u6807\u76d1\u63a7 Y \u6162\u67e5\u8be2\u65e5\u5fd7 Y SQL \u8bb0\u5f55 Y Kubernetes operator Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_12","title":"\u90e8\u7f72\u65b9\u5f0f","text":"\u90e8\u7f72\u65b9\u5f0f \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u5355\u673a\u73af\u5883\u79c1\u6709\u5316\u90e8\u7f72 Y \u5206\u5e03\u5f0f\u73af\u5883\u79c1\u6709\u5316\u90e8\u7f72 Y\uff0c\u81ea\u5efa Kubernetes \u4e0e minIO \u5bf9\u8c61\u5b58\u50a8 \u963f\u91cc\u4e91\u5206\u5e03\u5f0f\u81ea\u5efa\u90e8\u7f72 Y\uff0cACK+OSS \u817e\u8baf\u4e91\u5206\u5e03\u5f0f\u81ea\u5efa\u90e8\u7f72 Y\uff0cTKE+COS AWS \u5206\u5e03\u5f0f\u81ea\u5efa\u90e8\u7f72 Y\uff0cEKS+S3 \u516c\u6709\u4e91 Serverless Y\uff0cMatrixOne Cloud\uff0c\u652f\u6301 AWS\uff0c\u963f\u91cc\u4e91"},{"location":"MatrixOne/Overview/matrixone-feature-list/#orm","title":"\u5e94\u7528\u8fde\u63a5\u5668\u53ca\u5e38\u89c1 ORM","text":"\u5e94\u7528\u8fde\u63a5\u5668 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09 JDBC Y ODBC N pymysql Y go-sql-driver Y MyBatis Y MyBatis-plus Y Spring-JPA Y Hibernate Y GORM Y SQL Alchemy Y\u6ce8\u610f\uff1a\u672a\u5728\u4e0a\u9762\u6807\u660e\u7684\u5e94\u7528\u8fde\u63a5\u5668\u6216\u8005 ORM \u5de5\u5177\u5e76\u4e0d\u4e00\u5b9a\u4e0d\u652f\u6301\uff0cMatrixOne \u672c\u8eab\u5bf9 MySQL 8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u56e0\u6b64\u5982\u679c\u8fde\u63a5 MySQL \u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u7684\u90fd\u57fa\u672c\u53ef\u4ee5\u9002\u914d MatrixOne\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u5c1d\u8bd5\u57fa\u4e8e MySQL \u53ef\u4ee5\u8dd1\u901a\u7684\u6210\u719f\u5de5\u5177\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_13","title":"\u751f\u6001\u5de5\u5177\u9002\u914d","text":"\u5de5\u5177\u79cd\u7c7b \u5de5\u5177\u540d\u79f0 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09 \u6570\u636e\u5e93\u7ba1\u7406 IDE Navicat Y MySQL Workbench Y DBeaver Y HeidiSQL Y SQLyog Y ETL \u5de5\u5177 DataX Y Canal Y Kettle Y Seatunnel Y FlinkCDC Y \u6d88\u606f\u961f\u5217 Kafka Y \u8ba1\u7b97\u5f15\u64ce Spark Y Flink Y BI \u5de5\u5177 Superset Y Tableau Y FineBI Y \u6c38\u6d2a BI Y Datafor Y \u6570\u636e\u8c03\u5ea6 DolphinScheduler Y \u53ef\u89c6\u5316\u76d1\u63a7 Grafana Y\u6ce8\u610f\uff1a\u672a\u5728\u4e0a\u9762\u6807\u660e\u7684\u751f\u6001\u5de5\u5177\u5e76\u4e0d\u4e00\u5b9a\u4e0d\u652f\u6301\uff0cMatrixOne \u672c\u8eab\u5bf9 MySQL 8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u56e0\u6b64\u5982\u679c\u8fde\u63a5 MySQL \u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u7684\u90fd\u57fa\u672c\u53ef\u4ee5\u9002\u914d MatrixOne\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u5c1d\u8bd5\u57fa\u4e8e MySQL \u53ef\u4ee5\u8dd1\u901a\u7684\u6210\u719f\u5de5\u5177\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/","title":"MatrixOne \u7b80\u4ecb","text":"MatrixOne \u662f\u4e00\u6b3e\u8d85\u878d\u5408\u5f02\u6784\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u901a\u8fc7\u4e91\u539f\u751f\u5316\u548c\u5b58\u50a8\u3001\u8ba1\u7b97\u3001\u4e8b\u52a1\u5206\u79bb\u7684\u67b6\u6784\u6784\u5efa HSTAP \u8d85\u878d\u5408\u6570\u636e\u5f15\u64ce\uff0c\u5b9e\u73b0\u5355\u4e00\u6570\u636e\u5e93\u7cfb\u7edf\u652f\u6301 OLTP\u3001OLAP\u3001\u6d41\u8ba1\u7b97\u7b49\u591a\u79cd\u4e1a\u52a1\u8d1f\u8f7d\uff0c\u5e76\u4e14\u652f\u6301\u516c\u6709\u4e91\u3001\u79c1\u6709\u4e91\u3001\u8fb9\u7f18\u4e91\u90e8\u7f72\u548c\u4f7f\u7528\uff0c\u5b9e\u73b0\u5f02\u6784\u57fa\u7840\u8bbe\u65bd\u7684\u517c\u5bb9\u3002
MatrixOne \u5177\u5907\u5b9e\u65f6 HTAP\uff0c\u591a\u79df\u6237\uff0c\u6d41\u5f0f\u8ba1\u7b97\uff0c\u6781\u81f4\u6269\u5c55\u6027\uff0c\u9ad8\u6027\u4ef7\u6bd4\uff0c\u4f01\u4e1a\u7ea7\u9ad8\u53ef\u7528\u53ca MySQL \u9ad8\u5ea6\u517c\u5bb9\u7b49\u91cd\u8981\u7279\u6027\uff0c\u901a\u8fc7\u4e3a\u7528\u6237\u63d0\u4f9b\u4e00\u7ad9\u5f0f\u8d85\u878d\u5408\u6570\u636e\u89e3\u51b3\u65b9\u6848\uff0c\u53ef\u4ee5\u5c06\u8fc7\u53bb\u7531\u591a\u4e2a\u6570\u636e\u5e93\u5b8c\u6210\u7684\u5de5\u4f5c\u5408\u5e76\u5230\u4e00\u4e2a\u6570\u636e\u5e93\u91cc\uff0c\u4ece\u800c\u7b80\u5316\u5f00\u53d1\u8fd0\u7ef4\uff0c\u6d88\u51cf\u6570\u636e\u788e\u7247\uff0c\u63d0\u9ad8\u5f00\u53d1\u654f\u6377\u5ea6\u3002
MatrixOne \u9002\u7528\u4e8e\u9700\u8981\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u6570\u636e\u89c4\u6a21\u8f83\u5927\uff0c\u8d1f\u8f7d\u6ce2\u52a8\u9891\u7e41\uff0c\u540c\u65f6\u62e5\u6709\u6d41\u7a0b\u578b\u4e1a\u52a1\u548c\u5206\u6790\u578b\u4e1a\u52a1\u7684\u573a\u666f\uff0c\u6bd4\u5982\u79fb\u52a8\u4e92\u8054\u7f51 APP\u3001IoT \u6570\u636e\u5e94\u7528\u3001\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u3001SaaS \u5e73\u53f0\u7b49\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_1","title":"\u6838\u5fc3\u7279\u6027","text":""},{"location":"MatrixOne/Overview/matrixone-introduction/#_2","title":"\u8d85\u878d\u5408\u5f15\u64ce","text":"\u8d85\u878d\u5408\u5f15\u64ce
HTAP \u6570\u636e\u5f15\u64ce\uff0c\u5355\u6570\u636e\u5e93\u5373\u53ef\u652f\u6301 TP\u3001AP\u3001\u65f6\u5e8f\u3001\u673a\u5668\u5b66\u4e60\u7b49\u6df7\u5408\u5de5\u4f5c\u8d1f\u8f7d\u3002
\u5185\u7f6e\u6d41\u5f15\u64ce
\u5185\u7f6e\u6d41\u8ba1\u7b97\u5f15\u64ce\uff0c\u652f\u6301\u5b9e\u65f6\u6570\u636e\u6d41\u5165\u3001\u5b9e\u65f6\u6570\u636e\u8f6c\u6362\u53ca\u5b9e\u65f6\u6570\u636e\u67e5\u8be2\u3002
\u5b58\u7b97\u5206\u79bb\u67b6\u6784
\u5c06\u5b58\u50a8\u3001\u8ba1\u7b97\u3001\u4e8b\u52a1\u4e09\u5c42\u89e3\u8026\uff0c\u901a\u8fc7\u5b8c\u5168\u5bb9\u5668\u5316\u7684\u8bbe\u8ba1\u6765\u5b9e\u73b0\u6781\u81f4\u6269\u5c55\u3002
\u591a\u57fa\u7840\u8bbe\u65bd\u517c\u5bb9
\u652f\u6301\u8de8\u673a\u623f\u534f\u540c/\u591a\u5730\u534f\u540c/\u4e91\u8fb9\u534f\u540c\uff0c\u5b9e\u73b0\u65e0\u611f\u77e5\u6269\u7f29\u5bb9\uff0c\u63d0\u4f9b\u9ad8\u6548\u7edf\u4e00\u7684\u6570\u636e\u7ba1\u7406\u3002
\u9ad8\u6027\u80fd\u6267\u884c\u5f15\u64ce
\u901a\u8fc7 Compute Node \u548c Transaction node \u7684\u7075\u6d3b\u914d\u5408\u517c\u987e\u70b9\u67e5\u8be2\u4e0e\u6279\u5904\u7406\uff0c\u5bf9\u4e8e OLTP \u548c OLAP \u90fd\u5177\u5907\u6781\u81f4\u6027\u80fd\u3002
\u4f01\u4e1a\u7ea7\u9ad8\u53ef\u7528
\u5728\u9886\u5148\u7684 Multi-Raft \u590d\u5236\u72b6\u6001\u673a\u6a21\u578b\u4e0b\u5efa\u7acb\u5f3a\u4e00\u81f4\u5171\u4eab\u65e5\u5fd7\uff0c\u53ef\u5728\u907f\u514d\u6570\u636e\u91cd\u590d\u7684\u540c\u65f6\u4fdd\u8bc1\u96c6\u7fa4\u7684\u9ad8\u53ef\u7528\u3002
\u81ea\u5e26\u591a\u79df\u6237\u529f\u80fd\uff0c\u79df\u6237\u65e2\u76f8\u4e92\u9694\u79bb\uff0c\u72ec\u7acb\u6269\u7f29\u5bb9\u53c8\u53ef\u8fdb\u884c\u7edf\u4e00\u7ba1\u7406\uff0c\u7b80\u5316\u4e0a\u5c42\u5e94\u7528\u7684\u591a\u79df\u6237\u8bbe\u8ba1\u590d\u6742\u5ea6\u3002
MatrixOne \u4e0e MySQL8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u5305\u62ec\u4f20\u8f93\u534f\u8bae\uff0cSQL \u8bed\u6cd5\u548c\u751f\u6001\u5de5\u5177\uff0c\u964d\u4f4e\u4f7f\u7528\u548c\u8fc1\u79fb\u95e8\u69db\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_6","title":"\u9ad8\u6027\u4ef7\u6bd4","text":"\u4ee5\u6210\u672c\u4f4e\u5ec9\u7684\u5bf9\u8c61\u5b58\u50a8\u4f5c\u4e3a\u4e3b\u5b58\u50a8\uff0c\u901a\u8fc7\u7ea0\u5220\u7801\u6280\u672f\u4ec5\u9700\u8981 150% \u5de6\u53f3\u7684\u6570\u636e\u5197\u4f59\u5373\u53ef\u5b9e\u73b0\u9ad8\u53ef\u7528\uff0c\u540c\u65f6\u63d0\u4f9b\u9ad8\u901f\u7f13\u5b58\u80fd\u529b\uff0c\u901a\u8fc7\u51b7\u70ed\u5206\u79bb\u591a\u7ea7\u5b58\u50a8\u65b9\u6848\u517c\u987e\u6210\u672c\u548c\u6027\u80fd\u3002
\u7528\u6237\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u60c5\u51b5\u81ea\u7531\u8c03\u6574\u4e3a OLTP \u53ca OLAP \u5206\u914d\u7684\u8d44\u6e90\u6bd4\u4f8b\uff0c\u5b9e\u73b0\u8d44\u6e90\u6700\u5927\u5316\u5229\u7528\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_7","title":"\u4f01\u4e1a\u7ea7\u5b89\u5168\u5408\u89c4","text":"\u7b80\u5316\u6570\u636e\u5f00\u53d1\u548c\u8fd0\u7ef4
\u968f\u7740\u4e1a\u52a1\u53d1\u5c55\uff0c\u4f01\u4e1a\u4f7f\u7528\u7684\u6570\u636e\u5f15\u64ce\u548c\u4e2d\u95f4\u4ef6\u8d8a\u6765\u8d8a\u591a\uff0c\u800c\u6bcf\u4e00\u4e2a\u6570\u636e\u5f15\u64ce\u5e73\u5747\u4f9d\u8d56 5+ \u4e2a\u57fa\u7840\u7ec4\u4ef6\uff0c\u5b58\u50a8 3+ \u4e2a\u6570\u636e\u526f\u672c\uff0c\u6bcf\u4e00\u4e2a\u6570\u636e\u5f15\u64ce\u90fd\u8981\u5404\u81ea\u5b89\u88c5\u3001\u76d1\u63a7\u3001\u8865\u4e01\u548c\u5347\u7ea7\u3002\u8fd9\u4e9b\u90fd\u5bfc\u81f4\u6570\u636e\u5f15\u64ce\u7684\u9009\u578b\u3001\u5f00\u53d1\u53ca\u8fd0\u7ef4\u6210\u672c\u9ad8\u6602\u4e14\u4e0d\u53ef\u63a7\u3002\u5728 MatrixOne \u7684\u4e00\u4f53\u5316\u67b6\u6784\u4e0b\uff0c\u7528\u6237\u4f7f\u7528\u5355\u4e2a\u6570\u636e\u5e93\u5373\u53ef\u670d\u52a1\u591a\u79cd\u6570\u636e\u5e94\u7528\uff0c\u5f15\u5165\u7684\u6570\u636e\u7ec4\u4ef6\u548c\u6280\u672f\u6808\u51cf\u5c11 80%\uff0c\u5927\u5927\u7b80\u5316\u4e86\u6570\u636e\u5e93\u7ba1\u7406\u548c\u7ef4\u62a4\u7684\u6210\u672c\u3002
\u6d88\u51cf\u6570\u636e\u788e\u7247\u548c\u4e0d\u4e00\u81f4
\u5728\u65e2\u6709\u590d\u6742\u7684\u7cfb\u7edf\u67b6\u6784\u5185\uff0c\u5b58\u5728\u591a\u6761\u6570\u636e\u7ba1\u9053\u591a\u4efd\u6570\u636e\u5b58\u50a8\u5197\u4f59\u3002\u6570\u636e\u4f9d\u8d56\u590d\u6742\uff0c\u5bfc\u81f4\u6570\u636e\u66f4\u65b0\u7ef4\u62a4\u590d\u6742\uff0c\u4e0a\u4e0b\u6e38\u6570\u636e\u4e0d\u4e00\u81f4\u95ee\u9898\u9891\u53d1\uff0c\u4eba\u5de5\u6821\u5bf9\u96be\u5ea6\u589e\u5927\u3002MatrixOne \u7684\u9ad8\u5185\u805a\u67b6\u6784\u548c\u72ec\u6709\u7684\u589e\u91cf\u7269\u5316\u89c6\u56fe\u80fd\u529b\uff0c\u4f7f\u5f97\u4e0b\u6e38\u53ef\u4ee5\u652f\u6301\u4e0a\u6e38\u6570\u636e\u7684\u5b9e\u65f6\u66f4\u65b0\uff0c\u6446\u8131\u5197\u4f59\u7684 ETL \u6d41\u7a0b\uff0c\u5b9e\u73b0\u7aef\u5230\u7aef\u5b9e\u65f6\u6570\u636e\u5904\u7406\u3002
\u65e0\u9700\u7ed1\u5b9a\u57fa\u7840\u8bbe\u65bd
\u56e0\u4e3a\u57fa\u7840\u8bbe\u65bd\u7684\u788e\u7247\u5316\uff0c\u4f01\u4e1a\u7684\u79c1\u6709\u5316\u6570\u636e\u96c6\u7fa4\u548c\u516c\u6709\u4e91\u6570\u636e\u96c6\u7fa4\u4e4b\u95f4\u6570\u636e\u67b6\u6784\u548c\u5efa\u8bbe\u65b9\u6848\u5272\u88c2\uff0c\u6570\u636e\u8fc1\u79fb\u6210\u672c\u9ad8\u3002\u800c\u6570\u636e\u4e0a\u4e91\u4e00\u65e6\u9009\u578b\u786e\u5b9a\u6570\u636e\u5e93\u5382\u5546\uff0c\u540e\u7eed\u7684\u96c6\u7fa4\u6269\u5bb9\u3001\u5176\u4ed6\u7ec4\u4ef6\u91c7\u8d2d\u7b49\u90fd\u5c06\u88ab\u65e2\u6709\u5382\u5546\u7ed1\u5b9a\u3002MatrixOne \u63d0\u4f9b\u7edf\u4e00\u7684\u4e91\u8fb9\u57fa\u7840\u67b6\u6784\u548c\u9ad8\u6548\u7edf\u4e00\u7684\u6570\u636e\u7ba1\u7406\uff0c\u4f01\u4e1a\u6570\u636e\u67b6\u6784\u4e0d\u518d\u88ab\u57fa\u7840\u8bbe\u65bd\u7ed1\u5b9a\uff0c\u5b9e\u73b0\u5355\u6570\u636e\u96c6\u7fa4\u8de8\u4e91\u65e0\u611f\u77e5\u6269\u7f29\u5bb9\uff0c\u63d0\u5347\u6027\u4ef7\u6bd4\u3002
\u6781\u901f\u7684\u5206\u6790\u6027\u80fd
\u76ee\u524d\uff0c\u7531\u4e8e\u7f13\u6162\u7684\u590d\u6742\u67e5\u8be2\u6027\u80fd\u4ee5\u53ca\u5197\u4f59\u7684\u4e2d\u95f4\u8868\uff0c\u6570\u636e\u4ed3\u5e93\u5728\u4e1a\u52a1\u654f\u6377\u6027\u4e0a\u7684\u8868\u73b0\u4e0d\u5c3d\u4eba\u610f\uff0c\u5927\u91cf\u5bbd\u8868\u7684\u521b\u5efa\u4e5f\u4e25\u91cd\u5f71\u54cd\u8fed\u4ee3\u901f\u5ea6\u3002MatrixOne \u901a\u8fc7\u7279\u6709\u7684\u56e0\u5b50\u5316\u8ba1\u7b97\u548c\u5411\u91cf\u5316\u6267\u884c\u5f15\u64ce\uff0c\u652f\u6301\u6781\u901f\u7684\u590d\u6742\u67e5\u8be2\uff0c\u5355\u8868\u3001\u661f\u578b\u548c\u96ea\u82b1\u67e5\u8be2\u90fd\u5177\u5907\u6781\u901f\u5206\u6790\u6027\u80fd\u3002
\u50cf TP \u4e00\u6837\u53ef\u9760\u7684 AP \u4f53\u9a8c
\u4f20\u7edf\u6570\u636e\u4ed3\u5e93\u6570\u636e\u66f4\u65b0\u4ee3\u4ef7\u975e\u5e38\u9ad8\uff0c\u5f88\u96be\u505a\u5230\u6570\u636e\u66f4\u65b0\u5373\u53ef\u89c1\u3002\u5728\u8425\u9500\u98ce\u63a7\uff0c\u65e0\u4eba\u9a7e\u9a76\uff0c\u667a\u80fd\u5de5\u5382\u7b49\u5b9e\u65f6\u8ba1\u7b97\u8981\u6c42\u9ad8\u7684\u573a\u666f\u6216\u8005\u4e0a\u6e38\u6570\u636e\u53d8\u5316\u5feb\u7684\u573a\u666f\u4e2d\uff0c\u5f53\u524d\u7684\u5927\u6570\u636e\u5206\u6790\u7cfb\u7edf\u65e0\u6cd5\u652f\u6301\u589e\u91cf\u66f4\u65b0\uff0c\u5f80\u5f80\u9700\u8981\u505a\u5168\u91cf\u7684\u66f4\u65b0\uff0c\u8017\u65f6\u8017\u529b\u3002MatrixOne \u901a\u8fc7\u63d0\u4f9b\u8de8\u5b58\u50a8\u5f15\u64ce\u7684\u9ad8\u6027\u80fd\u5168\u5c40\u5206\u5e03\u5f0f\u4e8b\u52a1\u80fd\u529b\uff0c\u652f\u6301\u6761\u7ea7\u522b\u7684\u5b9e\u65f6\u589e\u91cf\u66f4\u65b0\uff0c\u5728\u4fdd\u8bc1\u6781\u901f\u5206\u6790\u6027\u80fd\u7684\u540c\u65f6\u652f\u6301\u66f4\u65b0\u3001\u5220\u9664\u548c\u5b9e\u65f6\u70b9\u67e5\u8be2\u3002
\u4e0d\u505c\u670d\u81ea\u52a8\u6269\u7f29\u5bb9
\u4f20\u7edf\u6570\u4ed3\u65e0\u6cd5\u517c\u987e\u6027\u80fd\u548c\u7075\u6d3b\u5ea6\uff0c\u6027\u4ef7\u6bd4\u65e0\u6cd5\u505a\u5230\u6700\u4f18\u3002MatrixOne \u57fa\u4e8e\u5b58\u7b97\u5206\u79bb\u7684\u6280\u672f\u67b6\u6784\uff0c\u652f\u6301\u5b58\u50a8\u8282\u70b9\u4e0e\u8ba1\u7b97\u8282\u70b9\u72ec\u7acb\u6269\u7f29\u5bb9\uff0c\u9ad8\u6548\u5e94\u5bf9\u8d1f\u8f7d\u53d8\u5316\u3002
\u4f01\u4e1a\u5e38\u7528\u7684\u4e1a\u52a1\u7cfb\u7edf\uff0c\u5982 OA\uff0cERP\uff0cCRM \u7b49\u7cfb\u7edf\u968f\u7740\u4e1a\u52a1\u7684\u53d1\u5c55\u6570\u636e\u91cf\u589e\u5927\uff0c\u4f20\u7edf\u7684\u5355\u673a\u6570\u636e\u5e93\u65e0\u6cd5\u6ee1\u8db3\u5176\u6027\u80fd\u9700\u6c42\uff0c\u5c24\u5176\u5728\u7279\u6b8a\u65f6\u95f4\u70b9\u7684\u4e1a\u52a1\u5206\u6790\u9700\u6c42\uff0c\u5f88\u591a\u4f01\u4e1a\u4f1a\u4e13\u95e8\u914d\u5907\u4e00\u5957\u5206\u6790\u6570\u636e\u5e93\u7cfb\u7edf\u6765\u6ee1\u8db3\u6708\u672b\uff0c\u5b63\u672b\u7b49\u91cd\u8981\u8282\u70b9\u7684\u7edf\u8ba1\u62a5\u8868\u9700\u6c42\u3002\u8fd9\u79cd\u573a\u666f\u91c7\u7528 MatrixOne \u6570\u636e\u5e93\u53ef\u4ee5\u7528\u4e00\u5957\u6570\u636e\u5e93\u540c\u65f6\u6ee1\u8db3\u4e1a\u52a1\u7cfb\u7edf\u548c\u5206\u6790\u7cfb\u7edf\u7684\u9700\u6c42\uff0c\u540c\u65f6\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u968f\u7740\u4e1a\u52a1\u589e\u957f\u53ef\u4ee5\u65e0\u7f1d\u6269\u5bb9\u3002
\u9488\u5bf9\u4f01\u4e1a\u5178\u578b\u7684 OLAP \u7c7b\u578b\u5e94\u7528\uff0c\u5982\u770b\u677f\u3001BI \u62a5\u8868\u7b49\u5206\u6790\u7cfb\u7edf\uff0c\u5f80\u5f80\u9700\u8981\u8fdb\u884c\u6d77\u91cf\u6570\u636e\u7684\u5206\u6790\uff0c\u6570\u636e\u91cf\u4e00\u65e6\u8f83\u4e3a\u5e9e\u5927\u5219\u4f1a\u9762\u4e34\u6027\u80fd\u74f6\u9888\uff0c\u5bfc\u81f4\u65f6\u6548\u6027\u8f83\u5dee\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u5206\u6790\u6027\u80fd\u548c\u53ef\u6269\u5c55\u80fd\u529b\uff0c\u53ef\u4ee5\u9488\u5bf9\u5404\u7c7b\u590d\u6742\u548c\u6570\u636e\u91cf\u5e9e\u5927\u7684 SQL \u67e5\u8be2\u8fdb\u884c\u52a0\u901f\uff0c\u83b7\u5f97\u79d2\u7ea7\u4f53\u9a8c\u7684\u6548\u679c\uff0c\u63d0\u9ad8\u4f01\u4e1a\u51b3\u7b56\u5206\u6790\u7684\u654f\u6377\u5ea6\u3002
\u968f\u7740\u4f20\u611f\u5668\u548c\u7f51\u7edc\u6280\u672f\u7684\u5927\u91cf\u5e94\u7528\uff0c\u6d77\u91cf\u7684\u5404\u7c7b IoT \u8bbe\u5907\u751f\u4ea7\u4e86\u5927\u91cf\u7684\u6570\u636e\uff0c\u6bd4\u5982\u5236\u9020\u4e1a\u5de5\u5382\u4ea7\u7ebf\uff0c\u65b0\u80fd\u6e90\u6c7d\u8f66\uff0c\u57ce\u5e02\u5b89\u9632\u76d1\u63a7\u6444\u50cf\u5934\u7b49\u7b49\uff0c\u5176\u89c4\u6a21\u53ef\u80fd\u8f7b\u6613\u80fd\u8fbe\u5230\u6570\u767e TB \u751a\u81f3 PB \u7ea7\u522b\uff0c\u800c\u5bf9\u6570\u5b57\u5316\u7684\u9700\u6c42\u4e5f\u8d8a\u6765\u8d8a\u591a\u7684\u8981\u6c42\u4f01\u4e1a\u5b58\u50a8\u548c\u5229\u7528\u8fd9\u4e9b\u6570\u636e\u3002\u4f46\u662f\u4f20\u7edf\u7684\u6570\u636e\u5e93\u65b9\u6848\u65e0\u6cd5\u6ee1\u8db3\u5982\u6b64\u6d77\u91cf\u4e14\u5927\u89c4\u6a21\u7684\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u4ee5\u53ca\u52a0\u5de5\u5e94\u7528\u7684\u573a\u666f\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u6d41\u5f0f\u6570\u636e\u5199\u5165\u548c\u52a0\u5de5\u7684\u80fd\u529b\uff0c\u540c\u65f6\u5f3a\u5927\u7684\u53ef\u6269\u5c55\u6027\u53ef\u4ee5\u9002\u5e94\u4efb\u610f\u89c4\u6a21\u7684\u8d1f\u8f7d\u548c\u6570\u636e\u91cf\uff0c\u53ef\u4ee5\u5b8c\u5168\u6ee1\u8db3\u8be5\u573a\u666f\u7684\u9700\u6c42\u3002
\u4e2d\u5927\u578b\u4f01\u4e1a\u5f80\u5f80\u6709\u5f88\u591a\u5957\u4e1a\u52a1\u7cfb\u7edf\uff0c\u4e3a\u4e86\u7edf\u4e00\u5206\u6790\u548c\u6253\u901a\u5404\u7c7b\u6570\u636e\uff0c\u5f88\u591a\u4f01\u4e1a\u4f1a\u5efa\u8bbe\u4e00\u4e2a\u6253\u901a\u5404\u4e2a\u7cfb\u7edf\u6570\u636e\u6e90\u7684\u6570\u636e\u4e2d\u53f0\uff0c\u4ee5\u5168\u9762\u7684\u4e86\u89e3\u4f01\u4e1a\u7684\u6574\u4f53\u72b6\u51b5\u3002\u4f20\u7edf\u627f\u8f7d\u6570\u636e\u4e2d\u53f0\u7684\u89e3\u51b3\u65b9\u6848\u90fd\u662f\u57fa\u4e8e Hadoop \u4f53\u7cfb\uff0c\u4f46\u662f Hadoop \u7ec4\u4ef6\u6781\u4e3a\u590d\u6742\uff0c\u6709\u8f83\u9ad8\u7684\u5f00\u53d1\u548c\u8fd0\u7ef4\u95e8\u69db\uff0c\u5bf9\u4e8e\u5f88\u591a\u4f01\u4e1a\u6765\u8bf4\u6210\u672c\u592a\u9ad8\u3002MatrixOne \u7684\u4e00\u7ad9\u5f0f HTAP \u67b6\u6784\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u4ee5\u4f7f\u7528 MySQL \u4e00\u6837\u7684\u5f62\u5f0f\u6765\u4f7f\u7528\u4e00\u4e2a\u6570\u636e\u4e2d\u53f0\uff0c\u76f4\u63a5\u5728 MatrixOne \u4e2d\u5bf9\u6d77\u91cf\u6570\u636e\u8fdb\u884c SQL \u5206\u6790\u83b7\u5f97\u62a5\u8868\uff0c\u6781\u5927\u7684\u964d\u4f4e\u4e86\u6210\u672c\u3002
\u5bf9\u4e8e\u6e38\u620f\uff0c\u7535\u5546\uff0c\u6587\u5a31\uff0c\u793e\u4ea4\uff0c\u65b0\u95fb\u7b49\u4e92\u8054\u7c7b\u5e94\u7528\u6765\u8bf4\uff0c\u7528\u6237\u6570\u91cf\u5e9e\u5927\u4e14\u4e1a\u52a1\u6ce2\u52a8\u5267\u70c8\u800c\u9891\u7e41\uff0c\u5728\u70ed\u95e8\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u5019\uff0c\u5f80\u5f80\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u6765\u652f\u6491\u4e1a\u52a1\u9700\u6c42\u3002MatrixOne \u5b8c\u5168\u4e91\u539f\u751f\u5316\u7684\u67b6\u6784\u5177\u5907\u8d85\u5f3a\u7684\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u8ddf\u968f\u4e1a\u52a1\u7684\u53d8\u5316\u81ea\u52a8\u7684\u5feb\u901f\u6269\u7f29\u5bb9\uff0c\u6781\u5927\u7684\u964d\u4f4e\u7528\u6237\u7684\u8fd0\u7ef4\u96be\u5ea6\u3002
\u4f01\u4e1a\u7ea7 SaaS \u5e94\u7528\u5728\u8fd1\u51e0\u5e74\u6210\u7206\u53d1\u5f0f\u7684\u589e\u957f\u8d8b\u52bf\uff0cSaaS \u7684\u5e94\u7528\u5f00\u53d1\u4e2d\u90fd\u9700\u8981\u8003\u8651\u81ea\u5df1\u7684\u591a\u79df\u6237\u6a21\u578b\uff0c\u4f20\u7edf\u7684\u65b9\u6848\u4e2d\u4f1a\u6709\u591a\u79df\u6237\u5171\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u548c\u5355\u79df\u6237\u72ec\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u4e24\u79cd\u6a21\u5f0f\uff0c\u4f46\u662f\u4f1a\u9762\u4e34\u7ba1\u7406\u6210\u672c\u548c\u9694\u79bb\u6027\u7684\u4e24\u96be\u9009\u62e9\u3002MatrixOne \u81ea\u5e26\u591a\u79df\u6237\u80fd\u529b\uff0c\u79df\u6237\u4e4b\u95f4\u5929\u7136\u8d1f\u8f7d\u9694\u79bb\u4e14\u53ef\u4ee5\u72ec\u7acb\u6269\u5c55\uff0c\u540c\u65f6\u53c8\u63d0\u4f9b\u4e86\u7edf\u4e00\u7ba1\u7406\u80fd\u529b\uff0c\u53ef\u4ee5\u517c\u987e\u4f01\u4e1a\u5bf9\u6210\u672c\uff0c\u7ba1\u7406\u7b80\u6613\u5ea6\u548c\u9694\u79bb\u6027\u7684\u9700\u6c42\uff0c\u662f SaaS \u5e94\u7528\u7684\u6700\u4f73\u9009\u62e9\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_10","title":"\u76f8\u5173\u4fe1\u606f","text":"\u672c\u8282\u63cf\u8ff0\u4e86 MatrixOne \u7684\u57fa\u672c\u4ecb\u7ecd\uff0c\u5982\u679c\u60a8\u60f3\u4e86\u89e3\u5176\u4ed6\u66f4\u591a\u5173\u4e8e MatrixOne \u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u4ee5\u4e0b\u5185\u5bb9\uff1a
MatrixOne \u7684\u6700\u65b0\u7248\u672c\u4e3a 1.2.1\uff0c\u53d1\u5e03\u4e8e 2024 \u5e74 06 \u6708 30 \u65e5\uff0c\u8be6\u60c5\u8bf7\u89c1\uff1a
MatrixOne \u662f\u4e00\u6b3e\u9762\u5411\u672a\u6765\u7684\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0c\u901a\u8fc7\u7b80\u5316\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u5f15\u64ce\uff0c\u8de8\u591a\u4e2a\u6570\u636e\u4e2d\u5fc3\u3001\u4e91\u3001\u8fb9\u7f18\u548c\u5176\u4ed6\u5f02\u6784\u57fa\u7840\u8bbe\u65bd\uff0c\u540c\u65f6\u652f\u6301\u4e8b\u52a1\u6027\uff08OLTP\uff09\u3001\u5206\u6790\u6027\uff08OLAP\uff09\u548c\u6d41\u5f0f\u5de5\u4f5c\uff08Sreaming\uff09\u8d1f\u8f7d\uff0c\u8fd9\u79cd\u591a\u79cd\u5f15\u64ce\u7684\u878d\u5408\uff0c\u79f0\u4e3a HSTAP\u3002
MatrixOne HSTAP \u6570\u636e\u5e93\u5bf9 HTAP \u6570\u636e\u5e93\u8fdb\u884c\u4e86\u91cd\u65b0\u5b9a\u4e49\uff0cHSTAP \u65e8\u5728\u6ee1\u8db3\u5355\u4e00\u6570\u636e\u5e93\u5185\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u548c\u5206\u6790\u5904\u7406\uff08AP\uff09\u7684\u6240\u6709\u9700\u6c42\u3002\u4e0e\u4f20\u7edf\u7684 HTAP \u76f8\u6bd4\uff0cHSTAP \u5f3a\u8c03\u5176\u5185\u7f6e\u7684\u7528\u4e8e\u8fde\u63a5 TP \u548c AP \u8868\u6570\u636e\u6d41\u5904\u7406\u80fd\u529b\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u6570\u636e\u5e93\u53ef\u4ee5\u50cf\u5927\u6570\u636e\u5e73\u53f0\u4e00\u6837\u7075\u6d3b\u7684\u4f7f\u7528\u4f53\u9a8c\u3002\u4e5f\u6070\u6070\u5f97\u76ca\u4e8e\u5927\u6570\u636e\u7684\u7e41\u8363\uff0c\u5f88\u591a\u7528\u6237\u5df2\u7ecf\u719f\u6089\u4e86\u8fd9\u79cd\u4f53\u9a8c\u3002\u7528\u6237\u4f7f\u7528 MatrixOne \u53ea\u9700\u8981\u5c11\u91cf\u7684\u96c6\u6210\u5de5\u4f5c\uff0c\u5373\u53ef\u4ee5\u83b7\u5f97\u8986\u76d6\u6574\u4e2a TP \u548c AP \u573a\u666f\u7684\u4e00\u7ad9\u5f0f\u4f53\u9a8c\uff0c\u540c\u65f6\u53ef\u4ee5\u6446\u8131\u4f20\u7edf\u5927\u6570\u636e\u5e73\u53f0\u7684\u81c3\u80bf\u67b6\u6784\u53ca\u5404\u79cd\u9650\u5236\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone_2","title":"MatrixOne \u67b6\u6784\u5c42\u7ea7","text":"MatrixOne \u5b9e\u73b0\u4e86\u4e09\u4e2a\u72ec\u7acb\u7684\u5c42\u7ea7\uff0c\u6bcf\u4e2a\u5c42\u7ea7\u90fd\u6709\u81ea\u5df1\u7684\u5bf9\u8c61\u5355\u5143\u548c\u5206\u5de5\u3002\u4e0d\u540c\u7c7b\u578b\u7684\u8282\u70b9\u53ef\u4ee5\u81ea\u7531\u4f38\u7f29\uff0c\u4e0d\u518d\u53d7\u5230\u5176\u4ed6\u5c42\u7684\u5236\u7ea6\u3002\u8fd9\u4e09\u4e2a\u5c42\u7ea7\u662f\uff1a
\u5728\u786e\u5b9a\u4e86 TAE \u4f5c\u4e3a\u552f\u4e00\u5b58\u50a8\u5f15\u64ce\u4e4b\u540e\uff0c\u5bf9\u878d\u5408\u540e\u7684 TAE \u5f15\u64ce\u8fdb\u884c\u4e86\u591a\u9879\u8bbe\u8ba1\u4e0a\u7684\u8c03\u6574\uff0c\u624d\u6709\u4e86\u540e\u6765\u7684 TAE \u5b58\u50a8\u5f15\u64ce\u3002\u8fd9\u4e2a\u5f15\u64ce\u5177\u6709\u5982\u4e0b\u4f18\u52bf\uff1a
\u8ba1\u7b97\u5f15\u64ce\u57fa\u4e8e\u517c\u5bb9 MySQL \u7684\u6839\u672c\u76ee\u6807\uff0c\u5bf9\u4e8e\u8282\u70b9\u8c03\u5ea6\u3001\u6267\u884c\u8ba1\u5212\u548c SQL \u80fd\u529b\u6709\u7740\u66f4\u9ad8\u7684\u8981\u6c42\u3002\u9ad8\u6027\u80fd\u8ba1\u7b97\u5f15\u64ce\u65e2\u5177\u5907\u5b9e\u9a8c\u67b6\u6784\u4e2d\u8ba1\u7b97\u5f15\u64ce\u7684 MPP\uff1a
MatrixOne \u67b6\u6784\u5982\u4e0b\u5982\u6240\u793a\uff1a
\u53c2\u7167\u4e0a\u9762\u7684\u56fe\u793a\uff0cMatrixOne \u7684\u4f53\u7cfb\u7ed3\u6784\u5206\u4e3a\u4e94\u5c42\uff0c\u4ee5\u4e0b\u5185\u5bb9\u662f\u4ece\u4e0a\u81f3\u4e0b\u5bf9\u6bcf\u5c42\u7684\u4ecb\u7ecd\uff1a
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#_1","title":"\u96c6\u7fa4\u7ba1\u7406\u5c42","text":"\u8fd9\u4e00\u5c42\u8d1f\u8d23\u96c6\u7fa4\u7ba1\u7406\uff0c\u5728\u4e91\u539f\u751f\u73af\u5883\u4e2d\u4e0e Kubernetes \u4ea4\u4e92\u52a8\u6001\u83b7\u53d6\u8d44\u6e90\uff1b\u5728\u672c\u5730\u90e8\u7f72\u65f6\uff0c\u6839\u636e\u914d\u7f6e\u83b7\u53d6\u8d44\u6e90\u3002\u96c6\u7fa4\u72b6\u6001\u6301\u7eed\u76d1\u63a7\uff0c\u6839\u636e\u8d44\u6e90\u4fe1\u606f\u5206\u914d\u6bcf\u4e2a\u8282\u70b9\u7684\u4efb\u52a1\u3002\u63d0\u4f9b\u7cfb\u7edf\u7ef4\u62a4\u670d\u52a1\u4ee5\u786e\u4fdd\u6240\u6709\u7cfb\u7edf\u7ec4\u4ef6\u5728\u5076\u5c14\u51fa\u73b0\u8282\u70b9\u548c\u7f51\u7edc\u6545\u969c\u7684\u60c5\u51b5\u4e0b\u6b63\u5e38\u8fd0\u884c\uff0c\u5e76\u5728\u5fc5\u8981\u65f6\u91cd\u65b0\u5e73\u8861\u8282\u70b9\u4e0a\u7684\u8d1f\u8f7d\u3002\u96c6\u7fa4\u7ba1\u7406\u5c42\u7684\u4e3b\u8981\u7ec4\u4ef6\u662f\uff1a
Serverless \u5c42\u662f\u4e00\u7cfb\u5217\u65e0\u72b6\u6001\u8282\u70b9\u7684\u603b\u79f0\uff0c\u6574\u4f53\u4e0a\u5305\u542b\u4e09\u7c7b\uff1a
\u4f5c\u4e3a MatrixOne \u7684\u5355\u4e00\u6570\u636e\u6e90 (\u5373 Single source of truth)\uff0c\u6570\u636e\u4e00\u65e6\u5199\u5165\u65e5\u5fd7\u5c42\uff0c\u5219\u5c06\u6c38\u4e45\u5730\u5b58\u50a8\u5728 MatrixOne \u4e2d\u3002\u5b83\u5efa\u7acb\u5728\u6211\u4eec\u4e16\u754c\u7ea7\u7684\u590d\u5236\u72b6\u6001\u673a\u6a21\u578b\u7684\u4e13\u4e1a\u77e5\u8bc6\u4e4b\u4e0a\uff0c\u4ee5\u4fdd\u8bc1\u6211\u4eec\u7684\u6570\u636e\u5177\u6709\u6700\u5148\u8fdb\u7684\u9ad8\u541e\u5410\u91cf\u3001\u9ad8\u53ef\u7528\u6027\u548c\u5f3a\u4e00\u81f4\u6027\u3002\u5b83\u672c\u8eab\u9075\u5faa\u5b8c\u5168\u6a21\u5757\u5316\u548c\u5206\u89e3\u7684\u8bbe\u8ba1\uff0c\u4e5f\u5e2e\u52a9\u89e3\u8026\u5b58\u50a8\u548c\u8ba1\u7b97\u5c42\u7684\u6838\u5fc3\u7ec4\u4ef6\uff0c\u4e0e\u4f20\u7edf\u7684 NewSQL \u67b6\u6784\u76f8\u6bd4\uff0c\u6211\u4eec\u7684\u67b6\u6784\u5177\u6709\u66f4\u9ad8\u7684\u5f39\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#_3","title":"\u5b58\u50a8\u5c42","text":"\u5b58\u50a8\u5c42\u5c06\u6765\u81ea\u65e5\u5fd7\u5c42\u7684\u4f20\u5165\u6570\u636e\u8f6c\u6362\u4e3a\u6709\u6548\u7684\u5f62\u5f0f\uff0c\u4ee5\u4f9b\u5c06\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u548c\u5b58\u50a8\u3002\u5305\u62ec\u4e3a\u5feb\u901f\u8bbf\u95ee\u5df2\u5199\u5165 S3 \u7684\u6570\u636e\u8fdb\u884c\u7684\u7f13\u5b58\u7ef4\u62a4\u7b49\u3002
\u5728 MatrixOne \u4e2d\uff0cTAE\uff08\u5373 Transactional Analytic Engine\uff09\u5b58\u50a8\u5f15\u64ce\u662f\u5b58\u50a8\u5c42\u7684\u4e3b\u8981\u516c\u5f00\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u540c\u65f6\u652f\u6301\u884c\u548c\u5217\u5b58\u50a8\u4ee5\u53ca\u4e8b\u52a1\u5904\u7406\u80fd\u529b\u3002\u6b64\u5916\uff0c\u5b58\u50a8\u5c42\u8fd8\u5305\u62ec\u5176\u4ed6\u5185\u90e8\u4f7f\u7528\u7684\u5b58\u50a8\u529f\u80fd\uff0c\u4f8b\u5982\u6d41\u5a92\u4f53\u7684\u4e2d\u95f4\u5b58\u50a8\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#_4","title":"\u5b58\u50a8\u4f9b\u5e94\u5c42","text":"\u4f5c\u4e3a\u4e0e\u57fa\u7840\u67b6\u6784\u89e3\u8026\u7684 DBMS\uff0cMatrixOne \u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5728 S3/HDFS\u3001\u672c\u5730\u78c1\u76d8\u3001\u672c\u5730\u670d\u52a1\u5668\u3001\u6df7\u5408\u4e91\u6216\u5176\u4ed6\u5404\u7c7b\u578b\u4e91\uff0c\u4ee5\u53ca\u667a\u80fd\u8bbe\u5907\u7684\u5171\u4eab\u5b58\u50a8\u4e2d\u3002\u5b58\u50a8\u4f9b\u5e94\u5c42\u901a\u8fc7\u4e3a\u4e0a\u5c42\u63d0\u4f9b\u4e00\u4e2a\u7edf\u4e00\u7684\u63a5\u53e3\u6765\u8bbf\u95ee\u8fd9\u4e9b\u591a\u6837\u5316\u7684\u5b58\u50a8\u8d44\u6e90\uff0c\u5e76\u4e14\u4e0d\u5411\u4e0a\u5c42\u66b4\u9732\u5b58\u50a8\u7684\u590d\u6742\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone_4","title":"MatrixOne \u7cfb\u7edf\u7ec4\u4ef6","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e3a\u5b9e\u73b0\u5206\u5e03\u5f0f\u4e0e\u591a\u5f15\u64ce\u7684\u878d\u5408\uff0c\u6784\u5efa\u4e86\u591a\u79cd\u4e0d\u540c\u7684\u7cfb\u7edf\u7ec4\u4ef6\u7528\u4e8e\u5b8c\u6210\u67b6\u6784\u76f8\u5173\u7684\u5c42\u7ea7\u7684\u529f\u80fd\uff1a
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#file-service","title":"File Service","text":"File Service \u662f MatrixOne \u8d1f\u8d23\u6240\u6709\u5b58\u50a8\u4ecb\u8d28\u8bfb\u5199\u7684\u7ec4\u4ef6\u3002\u5b58\u50a8\u4ecb\u8d28\u5305\u62ec\u5185\u5b58\u3001\u78c1\u76d8\u3001\u5bf9\u8c61\u5b58\u50a8\u7b49\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Log Service \u662f MatrixOne \u4e2d\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u4e8b\u52a1\u65e5\u5fd7\u7684\u7ec4\u4ef6\uff0c\u5b83\u5177\u6709\u5982\u4e0b\u529f\u80fd\u7279\u6027\uff1a
Transaction Node\uff08TN)\uff0c\u662f\u7528\u6765\u8fd0\u884c MatrixOne \u7684\u5206\u5e03\u5f0f\u5b58\u50a8\u5f15\u64ce TAE \u7684\u8f7d\u4f53\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Computing Node\uff08CN)\uff0c\u662f Matrixone \u63a5\u6536\u7528\u6237\u8bf7\u6c42\u5e76\u5904\u7406 SQL \u7684\u7ec4\u4ef6\uff0c\u5177\u4f53\u5305\u62ec\u4ee5\u4e0b\u6a21\u5757\uff1a
Stream Engine \u662f MatrixOne \u5185\u7f6e\u7684\u5168\u65b0\u7ec4\u4ef6\uff0c\u65e8\u5728\u652f\u6301\u5b9e\u65f6\u6570\u636e\u67e5\u8be2\u3001\u5904\u7406\u4ee5\u53ca\u589e\u5f3a\u6570\u636e\u5b58\u50a8\uff0c\u7279\u522b\u9488\u5bf9\u4f20\u5165\u7684\u6570\u636e\u6d41\uff08\u6570\u636e\u70b9\u5e8f\u5217\uff09\u3002\u501f\u52a9 Stream Engine\uff0c\u60a8\u80fd\u591f\u4f7f\u7528 SQL \u5b9a\u4e49\u5e76\u6784\u5efa\u6d41\u5904\u7406\u7ba1\u9053\uff0c\u5c06\u5176\u4f5c\u4e3a\u5b9e\u65f6\u6570\u636e\u540e\u7aef\u63d0\u4f9b\u670d\u52a1\uff1b\u540c\u65f6\uff0c\u60a8\u4e5f\u80fd\u591f\u8fd0\u7528 SQL \u67e5\u8be2\u6d41\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4e0e\u975e\u6d41\u5f0f\u6570\u636e\u96c6\u8fdb\u884c\u8054\u63a5\uff0c\u4ece\u800c\u66f4\u8fdb\u4e00\u6b65\u5730\u7b80\u5316\u6574\u4e2a\u6570\u636e\u5806\u6808\u7684\u5904\u7406\u6d41\u7a0b\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#proxy","title":"Proxy","text":"Proxy \u7ec4\u4ef6\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u4e0e SQL \u8def\u7531\u3002\u5b83\u5177\u6709\u4ee5\u4e0b\u529f\u80fd\uff1a
\u672c\u8282\u4ecb\u7ecd\u4e86 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\u6982\u89c8\u3002\u5176\u4ed6\u4fe1\u606f\u53ef\u53c2\u89c1\uff1a
\u5b89\u88c5\u5355\u673a\u7248 MatrixOne
\u6700\u65b0\u53d1\u5e03\u4fe1\u606f
\u6570\u636e\u7f13\u5b58\u53ca\u51b7\u70ed\u6570\u636e\u5206\u79bb\u662f MatrixOne \u7684\u4e00\u9879\u5173\u952e\u7279\u6027\uff0c\u8be5\u7279\u6027\u5c06\u6570\u636e\u5206\u4e3a\u70ed\u6570\u636e\u548c\u51b7\u6570\u636e\uff0c\u4ee5\u4f7f\u7528\u9891\u7387\u4e3a\u533a\u5206\u6807\u51c6\uff0c\u5e76\u5c06\u5b83\u4eec\u4ee5\u4e0d\u540c\u7684\u5b58\u50a8\u65b9\u5f0f\u8fdb\u884c\u7ba1\u7406\u3002\u8fd9\u4e00\u8bbe\u8ba1\u4f7f\u5f97 MatrixOne \u5728\u4fdd\u6301\u4f18\u5f02\u6027\u80fd\u7684\u540c\u65f6\u4e5f\u7ef4\u6301\u4e86\u8f83\u4f4e\u7684\u8fd0\u884c\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_2","title":"\u6280\u672f\u67b6\u6784","text":"\u5728 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\u4e2d\uff0c\u6709\u4e24\u4e2a\u90e8\u5206\u8d1f\u8d23\u6301\u4e45\u5316\u6570\u636e\u5b58\u50a8\uff0c\u4e00\u4e2a\u662f\u5168\u4f53 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u5171\u4eab\u7684\u5bf9\u8c61\u5b58\u50a8\uff0c\u5b83\u4e5f\u662f\u96c6\u7fa4\u7684\u4e3b\u8981\u5b58\u50a8\u8bbe\u5907\uff1b\u53e6\u4e00\u4e2a\u662f\u5404\u8ba1\u7b97\u8282\u70b9\uff08CN\uff09\u4e0a\u7684\u672c\u5730\u5b58\u50a8\uff0c\u4e3b\u8981\u7528\u4e8e\u6570\u636e\u7f13\u5b58\u3002\u4e3b\u5b58\u50a8\u5305\u542b\u6574\u4e2a\u96c6\u7fa4\u7684\u5168\u91cf\u6570\u636e\uff0c\u800c\u7f13\u5b58\u5219\u4ec5\u4fdd\u5b58\u6700\u8fd1\u67e5\u8be2\u65f6\u4ece\u4e3b\u5b58\u50a8\u4e2d\u63d0\u53d6\u7684\u6570\u636e\u3002\u6b64\u5916\uff0cCN \u8282\u70b9\u7684\u5185\u5b58\u4e5f\u4f5c\u4e3a\u6570\u636e\u7f13\u5b58\u7684\u4e00\u90e8\u5206\u6765\u4f7f\u7528\u3002
\u5f53\u7528\u6237\u53d1\u8d77\u67e5\u8be2\u65f6\uff0c\u7cfb\u7edf\u9996\u5148\u4f1a\u68c0\u67e5\u7528\u6237\u6240\u8fde\u63a5\u7684 CN \u7684\u7f13\u5b58\u4e2d\u662f\u5426\u5df2\u7ecf\u5305\u542b\u6240\u9700\u6570\u636e\u3002\u5982\u679c\u5b58\u5728\uff0c\u7cfb\u7edf\u5c06\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u7ed9\u7528\u6237\uff0c\u67e5\u8be2\u4f18\u5148\u7ea7\u662f\u5148\u5185\u5b58\u540e\u78c1\u76d8\u3002\u5982\u679c\u5728\u5f53\u524d\u8fde\u63a5\u7684 CN \u7684\u7f13\u5b58\u4e2d\u6ca1\u6709\u627e\u5230\u6240\u9700\u6570\u636e\uff0c\u7cfb\u7edf\u4f1a\u67e5\u8be2\u5168\u5c40\u5143\u6570\u636e\u4fe1\u606f\uff0c\u770b\u8be5\u7528\u6237\u5176\u4ed6\u53ef\u7528\u7684 CN \u7f13\u5b58\u4e2d\u662f\u5426\u5b58\u5728\u6240\u9700\u6570\u636e\uff0c\u68c0\u67e5\u987a\u5e8f\u540c\u6837\u662f\u5148\u5185\u5b58\u540e\u78c1\u76d8\u3002\u5982\u679c\u5b58\u5728\uff0c\u7cfb\u7edf\u5c06\u8bf7\u6c42\u8f6c\u5411\u5305\u542b\u6b64\u6570\u636e\u7684 CN\uff0c\u7531\u5b83\u5904\u7406\u8bf7\u6c42\uff0c\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u7528\u6237\u3002\u5982\u679c\u6240\u6709\u53ef\u7528 CN \u7684\u7f13\u5b58\u4e2d\u90fd\u6ca1\u6709\u6240\u67e5\u627e\u7684\u6570\u636e\uff0c\u7cfb\u7edf\u5c06\u53d1\u8d77\u5bf9\u5bf9\u8c61\u5b58\u50a8\u7684\u8bfb\u53d6\u8bf7\u6c42\uff0c\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u7528\u6237\u3002
\u5f53\u7528\u6237\u67e5\u8be2\u5bf9\u8c61\u5b58\u50a8\u7684\u6570\u636e\u65f6\uff0c\u67e5\u8be2\u5230\u7684\u6570\u636e\u5757 (block) \u4f1a\u6839\u636e\u7f13\u5b58\u7684\u67e5\u8be2\u987a\u5e8f\uff0c\u4f9d\u6b21\u586b\u5145\u5230\u76f8\u5e94\u4f4d\u7f6e\u3002\u4f8b\u5982\uff0c\u7528\u6237\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u67e5\u8be2\u51fa\u4e86 100M \u7684\u6570\u636e\uff0c\u8fd9 100M \u7684\u6570\u636e\u4f1a\u9996\u5148\u5199\u5165\u7528\u6237\u6240\u8fde\u63a5\u7684 CN \u8282\u70b9\u7684\u5185\u5b58\uff0c\u7136\u540e\u518d\u5199\u5165\u8fd9\u4e2a CN \u8282\u70b9\u7684\u78c1\u76d8\u7f13\u5b58\u3002\u6bcf\u6b21\u6709\u65b0\u67e5\u8be2\u4ea7\u751f\u65f6\uff0c\u90fd\u4f1a\u6309\u7167\u8fd9\u4e2a\u89c4\u5219\u66f4\u65b0\u7f13\u5b58\u4e2d\u7684\u6570\u636e\u3002\u65e0\u8bba\u662f\u5185\u5b58\u8fd8\u662f\u78c1\u76d8\uff0cCN \u7f13\u5b58\u4e2d\u6570\u636e\u7684\u66ff\u6362\u90fd\u9075\u5faa LRU\uff08\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\uff09\u539f\u5219\u3002\u901a\u8fc7\u8fd9\u6837\u7684\u673a\u5236\uff0c\u6700\u65b0\u7684\u6570\u636e\u59cb\u7ec8\u5904\u4e8e\u6700\u6613\u83b7\u53d6\u7684\u4f4d\u7f6e\uff0c\u800c\u76f8\u5bf9\u51b7\u95e8\u7684\u6570\u636e\u5219\u4f1a\u9010\u6b65\u4ece\u7f13\u5b58\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_3","title":"\u4ea7\u54c1\u7279\u6027","text":"\u6570\u636e\u7f13\u5b58\u53ca\u51b7\u70ed\u6570\u636e\u5206\u79bb\u7684\u7279\u6027\u4e3a\u4ea7\u54c1\u5e26\u6765\u4e86\u4e00\u4e9b\u72ec\u7279\u4f18\u52bf\u3002\u4e3a\u4e86\u5177\u4f53\u8bf4\u660e\uff0c\u6211\u4eec\u5c06\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u4f8b\u8fdb\u884c\u5c55\u793a\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_4","title":"\u73af\u5883\u914d\u7f6e","text":"\u672c\u7ae0\u6240\u4ecb\u7ecd\u5230\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\uff0c\u8bf7\u786e\u4fdd\u6574\u4e2a MatrixOne \u5df2\u7ecf\u5b89\u88c5\u5b8c\u6bd5\u3002
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a pe
\u7684\u8868\u683c\u4ee5\u53ca\u5bf9\u5e94\u7684 csv \u6570\u636e\u3002\u8fd9\u4e2a csv \u6570\u636e\u8868\u7684\u5927\u5c0f\u4e3a 35.8MB\uff0c\u5171\u6709 1,048,575 \u884c\u6570\u636e\u3002\u6211\u4eec\u5c06\u4f7f\u7528\u4ee5\u4e0b\u7684 SQL \u8bed\u53e5\u521b\u5efa\u4e24\u4e2a\u6570\u636e\u5e93\uff0c\u5e76\u5c06\u76f8\u540c\u7684\u6570\u636e\u8868\u52a0\u8f7d\u81f3\u8fd9\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u7684 pe
\u8868\u3002
create database stock;\ndrop table if exists stock.pe;\ncreate table stock.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n\ncreate database stock2;\ndrop table if exists stock2.pe;\ncreate table stock2.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n
\u63a5\u4e0b\u6765\u8fdb\u884c\u76f8\u5e94\u7684\u7f13\u5b58\u914d\u7f6e\u3002\u5728 MatrixOne \u7684\u96c6\u7fa4 yaml \u8bbe\u7f6e\u4e2d\uff0cTN\u3001Log Service \u4ee5\u53ca CN \u90fd\u6709\u4e0e\u7f13\u5b58\u76f8\u5173\u7684\u8bbe\u7f6e\uff0c\u4f46\u4f60\u53ea\u9700\u5173\u6ce8\u4e0e\u67e5\u8be2\u76f4\u63a5\u76f8\u5173\u7684 CN \u7f13\u5b58\uff0c\u4e3b\u8981\u7684\u7f13\u5b58\u5927\u5c0f\u7531 memoryCacheSize
\u548c diskCacheSize
\u6765\u7ba1\u7406\u3002
metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n# \u4e2d\u95f4\u914d\u7f6e\u7701\u7565\nsharedStorageCache: # \u914d\u7f6e CN \u7f13\u5b58\u7684\u6838\u5fc3\u53c2\u6570\nmemoryCacheSize: 250Mi # CN \u7684\u5185\u5b58\u7f13\u5b58\uff0cMi \u4ee3\u8868 MB\ndiskCacheSize: 1Gi # CN \u7684\u78c1\u76d8\u7f13\u5b58\uff0cGi \u4ee3\u8868 GB\n
\u5f53\u8fd9\u4e24\u4e2a\u53c2\u6570\u90fd\u88ab\u8bbe\u7f6e\u4e3a \"1\" \u65f6\uff0c\u5373\u4ee3\u8868\u5173\u95ed\u4e86\u7f13\u5b58\uff0cMatrixOne \u7684\u6240\u6709\u67e5\u8be2\u8bf7\u6c42\u5c06\u76f4\u63a5\u4e0e\u5e95\u5c42\u5bf9\u8c61\u5b58\u50a8\u8fdb\u884c\u4ea4\u4e92\uff0c\u67e5\u8be2\u6548\u7387\u5c06\u5927\u5927\u964d\u4f4e\u3002
\u4e3a\u4e86\u7b80\u5316\u5c55\u793a\uff0c\u4f60\u53ef\u4ee5\u5728\u6b64\u5148\u5c06\u5185\u5b58\u7f13\u5b58\u5173\u95ed\uff0c\u4ec5\u8bbe\u7f6e\u4e00\u5b9a\u5927\u5c0f\u7684\u78c1\u76d8\u7f13\u5b58\u3002\u7531\u4e8e\u539f\u59cb\u6570\u636e\u5728\u5165\u5e93\u540e\u4f1a\u6839\u636e\u6570\u636e\u7c7b\u578b\u6709\u4e00\u5b9a\u7684\u538b\u7f29\u6bd4\u4f8b\uff0c\u6240\u4ee5\u4f60\u9700\u8981\u5148\u5c06\u5c06\u78c1\u76d8\u7f13\u5b58\u8bbe\u7f6e\u4e3a 20MB\uff0c\u8fd9\u5927\u6982\u8db3\u4ee5\u5b58\u653e\u538b\u7f29\u540e\u7684 35.8MB \u6570\u636e\u6587\u4ef6\u3002
metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n##\u7701\u7565\u4e2d\u95f4\u914d\u7f6e\nsharedStorageCache: #\u8c03\u914d CN \u7f13\u5b58\u7684\u6838\u5fc3\u53c2\u6570\nmemoryCacheSize: \"1\" #CN \u7684\u5185\u5b58\u7f13\u5b58\uff0cMi \u4ee3\u8868 MB\ndiskCacheSize: 20Mi #CN \u7684\u78c1\u76d8\u7f13\u5b58\uff0cGi \u4ee3\u8868 GB\n
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_5","title":"\u67e5\u8be2\u52a0\u901f","text":"\u5b8c\u6210\u4ee5\u4e0a\u8bbe\u7f6e\u5e76\u542f\u52a8 MatrixOne \u96c6\u7fa4\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u591a\u6b21\u67e5\u8be2\u7684\u7ed3\u679c\u6765\u4f53\u9a8c\u7f13\u5b58\u52a0\u901f\u7684\u6548\u679c\u3002\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u8fde\u7eed\u8fd0\u884c\u591a\u6b21 stock.pe
\u7684\u5168\u8868\u626b\u63cf\u3002
mysql> select * from stock.pe into outfile \"test01.txt\";\nEmpty set (6.53 sec)\n\nmysql> select * from stock.pe into outfile \"test02.txt\";\nEmpty set (4.01 sec)\n\nmysql> select * from stock.pe into outfile \"test03.txt\";\nEmpty set (3.84 sec)\n\nmysql> select * from stock.pe into outfile \"test04.txt\";\nEmpty set (3.96 sec)\n
\u4ece\u4e0a\u8ff0\u7ed3\u679c\u4e2d\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u7b2c\u4e00\u6b21\u67e5\u8be2\u65f6\uff0c\u7531\u4e8e\u9700\u8981\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u901f\u5ea6\u660e\u663e\u8f83\u6162\u3002\u7136\u800c\uff0c\u5728\u540e\u7eed\u7684\u4e09\u6b21\u67e5\u8be2\u4e2d\uff0c\u7531\u4e8e\u6570\u636e\u5df2\u88ab\u7f13\u5b58\u81f3\u78c1\u76d8\uff0c\u67e5\u8be2\u901f\u5ea6\u663e\u8457\u63d0\u5347\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_6","title":"\u7f13\u5b58\u7f6e\u6362","text":"\u63a5\u4e0b\u6765\uff0c\u4f60\u53ef\u4ee5\u4ea4\u66ff\u8fd0\u884c\u591a\u6b21 stock.pe
\u53ca stock2.pe
\u7684\u5168\u8868\u626b\u63cf\u3002
mysql> select * from stock2.pe into outfile \"test05.txt\";\nEmpty set (5.84 sec)\n\nmysql> select * from stock2.pe into outfile \"test06.txt\";\nEmpty set (4.27 sec)\n\nmysql> select * from stock2.pe into outfile \"test07.txt\";\nEmpty set (4.15 sec)\n\nmysql> select * from stock.pe into outfile \"test08.txt\";\nEmpty set (6.37 sec)\n\nmysql> select * from stock.pe into outfile \"test09.txt\";\nEmpty set (4.14 sec)\n\nmysql> select * from stock.pe into outfile \"test10.txt\";\nEmpty set (3.81 sec)\n
\u4f60\u53ef\u80fd\u4f1a\u6ce8\u610f\u5230\uff0c\u6bcf\u6b21\u5207\u6362\u67e5\u8be2\u7684\u6570\u636e\u8868\u65f6\uff0c\u67e5\u8be2\u6548\u7387\u6709\u663e\u8457\u4e0b\u964d\u3002\u8fd9\u662f\u56e0\u4e3a\u7f13\u5b58\u6709\u7f6e\u6362\u673a\u5236\uff0c\u4f60\u53ea\u8bbe\u5b9a\u4e86\u4e00\u5757\u8f83\u5c0f\u7684\u7f13\u5b58\uff0c\u53ea\u8db3\u591f\u5b58\u653e\u4e00\u5f20\u8868\u7684\u5168\u91cf\u6570\u636e\uff0c\u56e0\u6b64\u6bcf\u6b21\u4ea4\u66ff\u67e5\u8be2\u65f6\uff0c\u65e7\u7684\u7f13\u5b58\u6570\u636e\u4f1a\u88ab\u7f6e\u6362\u51fa\u53bb\uff0c\u65b0\u7684\u67e5\u8be2\u9700\u8981\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u800c\u518d\u6b21\u67e5\u8be2\u65f6\uff0c\u7531\u4e8e\u6570\u636e\u5df2\u88ab\u7f13\u5b58\uff0c\u67e5\u8be2\u901f\u5ea6\u5f97\u5230\u63d0\u5347\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_7","title":"\u67e5\u8be2\u9884\u70ed","text":"\u5728\u8bb8\u591a\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u7531\u4e8e\u6570\u636e\u91cf\u5e9e\u5927\u6216\u67e5\u8be2\u590d\u6742\uff0c\u6211\u4eec\u5e38\u5e38\u9700\u8981\u52a0\u901f\u67e5\u8be2\u3002\u800c MatrixOne \u7684\u7f13\u5b58\u673a\u5236\u53ef\u4ee5\u901a\u8fc7\u9884\u70ed\u6570\u636e\u6765\u5b9e\u73b0\u67e5\u8be2\u52a0\u901f\u3002
\u4f8b\u5982\uff0c\u4ee5\u4e0b\u7684 SQL \u67e5\u8be2\uff1a
SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT 1;\n
\u5982\u679c\u672a\u8fdb\u884c\u4f18\u5316\uff0c\u76f4\u63a5\u6267\u884c\u7684\u901f\u5ea6\u5982\u4e0b\uff1a
SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT\n\n1;\n+-----------+------+--------+\n| ts_code | pe | pb |\n+-----------+------+--------+\n| 000038.SZ | 0 | 1.2322 |\n+-----------+------+--------+\n1 row in set (5.21 sec)\n
\u8fd9\u6761 SQL \u67e5\u8be2\u4ec5\u6d89\u53ca stock2.pe
\u8868\u7684\u67e5\u8be2\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u9884\u5148\u626b\u63cf\u5168\u8868\u6570\u636e\uff0c\u5c06\u8868\u6570\u636e\u9884\u70ed\u5230\u7f13\u5b58\u4e2d\uff0c\u8fd9\u6837\u518d\u8fdb\u884c\u67e5\u8be2\u5c31\u53ef\u4ee5\u5927\u5e45\u63d0\u9ad8\u8fd9\u6761 SQL \u7684\u67e5\u8be2\u901f\u5ea6\u3002
mysql> select * from stock2.pe into outfile \"test11.txt\";\nEmpty set (6.48 sec)\n\nmysql> SELECT pe1.ts_code, pe1.pe, pe1.pb FROM stock2.pe as pe1 WHERE pe1.pe = (SELECT min(pe2.pe) FROM stock2.pe as pe2 WHERE pe1.ts_code = pe2.ts_code) ORDER BY trade_date DESC LIMIT 1;\n+-----------+------+---------+\n| ts_code | pe | pb |\n+-----------+------+---------+\n| 000068.SZ | 0 | 14.6959 |\n+-----------+------+---------+\n1 row in set (2.21 sec)\n
\u6b64\u529f\u80fd\u5c24\u5176\u9002\u7528\u4e8e\u4e00\u4e9b\u56fa\u5b9a\u7684\u62a5\u8868\u8ba1\u7b97\u573a\u666f\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u9884\u70ed\u67e5\u8be2\u6d89\u53ca\u7684\u6570\u636e\uff0c\u7136\u540e\u518d\u8fdb\u884c\u67e5\u8be2\uff0c\u8fd9\u6837\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u67e5\u8be2\u6548\u679c\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/","title":"Logservice \u67b6\u6784\u8be6\u89e3","text":"Logservice \u5728 MatrixOne \u4e2d\u626e\u6f14\u7740\u975e\u5e38\u91cd\u8981\u7684\u89d2\u8272\uff0c\u5b83\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u670d\u52a1\uff0c\u901a\u8fc7 RPC \u7684\u65b9\u5f0f\u4f9b\u5916\u90e8\u7ec4\u4ef6\u4f7f\u7528\uff0c\u7528\u4e8e\u65e5\u5fd7\u7ba1\u7406\u3002
Logservice \u4f7f\u7528\u57fa\u4e8e Raft \u534f\u8bae\u7684 dragonboat \u5e93\uff08multi-raft group \u7684 Go \u8bed\u8a00\u5f00\u6e90\u5b9e\u73b0\uff09\uff0c\u901a\u5e38\u4f7f\u7528\u672c\u5730\u78c1\u76d8\u4ee5\u591a\u526f\u672c\u7684\u65b9\u5f0f\u5b58\u50a8\u65e5\u5fd7\uff0c\u7c7b\u4f3c\u4e8e\u5bf9 WAL\uff08Write-Ahead Log\uff09\u7684\u7ba1\u7406\u3002\u4e8b\u52a1\u7684\u63d0\u4ea4\u53ea\u9700\u8981\u5199\u5165 Logservice \u4e2d\uff0c\u800c\u65e0\u9700\u5c06\u6570\u636e\u5199\u5165 S3\u3002\u53e6\u5916\u7684\u7ec4\u4ef6\u4f1a\u5f02\u6b65\u5730\u5c06\u6570\u636e\u6279\u91cf\u5199\u5165 S3 \u4e0a\u3002\u8fd9\u6837\u7684\u8bbe\u8ba1\u4fdd\u8bc1\u4e86\u4e8b\u52a1\u63d0\u4ea4\u65f6\u7684\u4f4e\u5ef6\u8fdf\uff0c\u5e76\u4e14\u591a\u4e2a\u526f\u672c\u786e\u4fdd\u4e86\u6570\u636e\u7684\u9ad8\u53ef\u9760\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#logservice_1","title":"Logservice \u67b6\u6784","text":"Logservice \u7684\u67b6\u6784\u7531\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e24\u90e8\u5206\u7ec4\u6210\u3002\u670d\u52a1\u7aef\u5305\u62ec handler\u3001dragonboat \u548c RSM\uff08Replicated State Machine\uff09\u7b49\u6a21\u5757\uff0c\u800c\u5ba2\u6237\u7aef\u5219\u5305\u542b\u591a\u4e2a\u5173\u952e\u63a5\u53e3\u3002\u5b83\u4eec\u4e4b\u95f4\u7684\u534f\u4f5c\u5173\u7cfb\u5982\u4e0b\u56fe\u6240\u793a\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#_1","title":"\u5ba2\u6237\u7aef","text":"Logservice \u5ba2\u6237\u7aef\u4e3b\u8981\u7531 TN\uff08\u4e8b\u52a1\u8282\u70b9\uff09\u8c03\u7528\uff0c\u5e76\u63d0\u4f9b\u4ee5\u4e0b\u5173\u952e\u63a5\u53e3\uff1a
Close()
\uff1a\u5173\u95ed\u5ba2\u6237\u7aef\u8fde\u63a5\u3002Config()
\uff1a\u83b7\u53d6\u5ba2\u6237\u7aef\u76f8\u5173\u914d\u7f6e\u3002GetLogRecord()
\uff1a\u8fd4\u56de\u4e00\u4e2a pb.LogRecord
\u53d8\u91cf\uff0c\u5176\u4e2d\u5305\u542b 8 \u5b57\u8282\u7684 LSN\uff08\u65e5\u5fd7\u5e8f\u5217\u53f7\uff09\u30014 \u5b57\u8282\u7684\u8bb0\u5f55\u7c7b\u578b\u548c 1 \u4e2a\u7c7b\u578b\u4e3a []byte
\u7684\u6570\u636e\u5b57\u6bb5\u3002\u6570\u636e\u5b57\u6bb5\u5305\u62ec 4 \u5b57\u8282\u7684 pb.UserEntryUpdate
\u30018 \u5b57\u8282\u7684\u526f\u672c TN ID\uff0c\u4ee5\u53ca payload []byte
\u3002Append()
\uff1a\u5c06 pb.LogRecord
\u8ffd\u52a0\u5230 Logservice\uff0c\u5e76\u8fd4\u56de LSN\u3002\u5728\u8c03\u7528\u7aef\uff0c\u53c2\u6570 pb.LogRecord
\u53ef\u4ee5\u590d\u7528\u3002Read()
\uff1a\u4ece Logservice \u4e2d\u8bfb\u53d6\u4ece\u6307\u5b9a firstLsn
\u5f00\u59cb\u7684\u65e5\u5fd7\uff0c\u76f4\u5230\u8fbe\u5230 maxSize
\u4e3a\u6b62\u3002\u8fd4\u56de\u7684 LSN \u4f5c\u4e3a\u4e0b\u4e00\u6b21\u8bfb\u53d6\u7684\u8d77\u70b9\u3002Truncate()
\uff1a\u5220\u9664\u6307\u5b9a LSN \u4e4b\u524d\u7684\u65e5\u5fd7\uff0c\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002GetTruncatedLsn()
\uff1a\u8fd4\u56de\u6700\u8fd1\u5220\u9664\u7684\u65e5\u5fd7\u7684 LSN\u3002GetTSOTimestamp()
\uff1a\u5411 TSO\uff08Timestamp Oracle\uff09\u8bf7\u6c42\u6307\u5b9a\u6570\u91cf\u7684\u65f6\u95f4\u6233\u3002\u8c03\u7528\u8005\u5360\u7528 [returned value, returned value + count]
\u7684\u8303\u56f4\u3002\u76ee\u524d\u8be5\u65b9\u6cd5\u6682\u672a\u4f7f\u7528\u3002Logservice \u5ba2\u6237\u7aef\u901a\u8fc7 MO-RPC \u5411 Logservice \u670d\u52a1\u7aef\u53d1\u9001\u8bf7\u6c42\uff0c\u670d\u52a1\u7aef\u4e0e Raft
/dragonboat
\u8fdb\u884c\u4ea4\u4e92\u5e76\u8fd4\u56de\u7ed3\u679c\u3002
Logservice \u7684\u670d\u52a1\u5668\u7aef\u63a5\u6536\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u5e76\u8fdb\u884c\u5904\u7406\u3002\u5165\u53e3\u51fd\u6570\u4e3a (*Service).handle()
\uff0c\u4e0d\u540c\u7684\u8bf7\u6c42\u4f1a\u8c03\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff1a
(*NodeHost) SyncPropose()
\u65b9\u6cd5\u8fdb\u884c\u540c\u6b65\u63d0\u4ea4 propose \u8bf7\u6c42\u3002\u9700\u8981\u7b49\u5f85\u65e5\u5fd7\u63d0\u4ea4\u5e76\u5e94\u7528\u540e\u624d\u80fd\u8fd4\u56de\uff0c\u8fd4\u56de\u503c\u662f\u6210\u529f\u5199\u5165\u65e5\u5fd7\u540e\u7684 LSN\uff08\u65e5\u5fd7\u5e8f\u5217\u53f7\uff09\u3002(*NodeHost) SyncRead()
\u65b9\u6cd5\u4ece\u72b6\u6001\u673a\u4e2d\u8fdb\u884c\u7ebf\u6027\u8bfb\u53d6\u5230\u5f53\u524d\u7684 LSN\uff0c\u7136\u540e\u6839\u636e LSN \u8c03\u7528 (*NodeHost) QueryRaftLog()
\u65b9\u6cd5\u4ece\u65e5\u5fd7\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u65e5\u5fd7\u6761\u76ee\u3002Bootstrap \u662f\u5728 logservice \u670d\u52a1\u542f\u52a8\u65f6\u8fdb\u884c\u7684\u8fc7\u7a0b\uff0c\u901a\u8fc7 HAKeeper \u5206\u7247\uff08shard ID \u4e3a 0\uff09\u5b8c\u6210\u3002\u5165\u53e3\u51fd\u6570\u4e3a (*Service) BootstrapHAKeeper
\u3002 \u65e0\u8bba\u914d\u7f6e\u4e2d\u8bbe\u7f6e\u4e86\u591a\u5c11\u4e2a\u526f\u672c\uff0c\u6bcf\u4e2a logservice \u8fdb\u7a0b\u5728\u542f\u52a8\u65f6\u90fd\u4f1a\u542f\u52a8\u4e00\u4e2a HAKeeper \u7684\u526f\u672c\u3002\u6bcf\u4e2a\u526f\u672c\u5728\u542f\u52a8\u65f6\u90fd\u4f1a\u8bbe\u7f6e\u6210\u5458\uff08members\uff09\uff0cHAKeeper \u5206\u7247\u4ee5\u8fd9\u4e9b\u6210\u5458\u4f5c\u4e3a\u9ed8\u8ba4\u7684\u526f\u672c\u6570\u542f\u52a8 Raft\u3002 \u5728\u5b8c\u6210 Raft \u7684\u9886\u5bfc\u8005\u9009\u4e3e\u540e\uff0c\u6267\u884c\u8bbe\u7f6e\u521d\u59cb\u96c6\u7fa4\u4fe1\u606f\uff08set initial cluster info
\uff09\uff0c\u8bbe\u7f6e\u65e5\u5fd7\u548c TN \u7684\u5206\u7247\u6570\u4ee5\u53ca\u65e5\u5fd7\u7684\u526f\u672c\u6570\u3002 \u8bbe\u7f6e\u5b8c\u6210\u526f\u672c\u6570\u540e\uff0c\u591a\u4f59\u7684 HAKeeper \u526f\u672c\u5c06\u88ab\u505c\u6b62\u3002
\u8be5\u5fc3\u8df3\u662f\u7531 Logservice\u3001CN \u548c TN \u53d1\u9001\u5230 HAKeeper \u7684\u5fc3\u8df3\uff0c\u800c\u4e0d\u662f Raft \u526f\u672c\u4e4b\u95f4\u7684\u5fc3\u8df3\u3002\u5b83\u4e3b\u8981\u6709\u4e24\u4e2a\u4f5c\u7528\uff1a
Logservice \u7684\u5fc3\u8df3\u6d41\u7a0b\u5982\u4e0b\u56fe\u6240\u793a\uff0cCN \u548c TN \u7684\u6d41\u7a0b\u7c7b\u4f3c\u3002
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5fc3\u8df3\u6bcf\u79d2\u6267\u884c\u4e00\u6b21\uff0c\u5176\u539f\u7406\u5982\u4e0b\uff1a
(*Service) handleLogHeartbeat()
\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff0c\u5e76\u8c03\u7528 propose \u5c06\u5fc3\u8df3\u53d1\u9001\u5230 Raft\u3002(*stateMachine) handleLogHeartbeat()
\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff0c\u4e3b\u8981\u6267\u884c\u4ee5\u4e0b\u4e24\u4e2a\u4efb\u52a1\uff1a(*LogState) Update()
\u65b9\u6cd5\u66f4\u65b0\u5b58\u50a8\u548c\u5206\u7247\u7684\u4fe1\u606f\u3002ScheduleCommands
\u4e2d\u83b7\u53d6\u547d\u4ee4\uff0c\u5e76\u8fd4\u56de\u7ed9\u53d1\u8d77\u7aef\u6267\u884c\u3002CN \u548c TN \u5411 HAKeeper \u53d1\u9001\u5fc3\u8df3\u7684\u539f\u7406\u4e5f\u7c7b\u4f3c\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#rsm","title":"\u72b6\u6001\u673a\uff08RSM\uff09","text":"Logservice \u548c HAKeeper \u7684\u72b6\u6001\u673a\u90fd\u662f\u57fa\u4e8e\u5185\u5b58\u7684\u72b6\u6001\u673a\u6a21\u578b\uff0c\u6240\u6709\u6570\u636e\u4ec5\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\u3002\u5b83\u4eec\u90fd\u5b9e\u73b0\u4e86 IStateMachine \u63a5\u53e3\uff0c\u5176\u4e2d\u5173\u952e\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a
Update()
\uff1a\u5728\u5b8c\u6210\u4e00\u6b21 propose \u5e76\u63d0\u4ea4\uff08\u5373\u591a\u6570\u526f\u672c\u5b8c\u6210\u5199\u5165\uff09\u540e\uff0c\u4f1a\u8c03\u7528 Update()
\u65b9\u6cd5\u6765\u66f4\u65b0\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u3002Update()
\u65b9\u6cd5\u7684\u5b9e\u73b0\u7531\u7528\u6237\u5b8c\u6210\uff0c\u5fc5\u987b\u662f\u65e0\u526f\u4f5c\u7528\u7684\uff08Side effect\uff09\uff0c\u5373\u76f8\u540c\u7684\u8f93\u5165\u5fc5\u987b\u5f97\u5230\u76f8\u540c\u7684\u8f93\u51fa\u7ed3\u679c\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u72b6\u6001\u673a\u4e0d\u7a33\u5b9a\u3002Update()
\u65b9\u6cd5\u7684\u7ed3\u679c\u901a\u8fc7 Result \u7ed3\u6784\u8fd4\u56de\uff0c\u5982\u679c\u53d1\u751f\u9519\u8bef\uff0c\u5219 error \u4e0d\u4e3a\u7a7a\u3002Lookup()
\uff1a\u7528\u4e8e\u67e5\u627e\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u3002\u901a\u8fc7 interface{}
\u53c2\u6570\u6307\u5b9a\u8981\u67e5\u627e\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8fd4\u56de\u7684\u7ed3\u679c\u4e5f\u662f interface{}
\u7c7b\u578b\u3002\u56e0\u6b64\uff0c\u7528\u6237\u9700\u8981\u81ea\u5df1\u5b9a\u4e49\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4f20\u5165\u76f8\u5e94\u7684\u6570\u636e\u7c7b\u578b\uff0c\u518d\u8fdb\u884c\u7c7b\u578b\u65ad\u8a00\u3002Lookup() \u662f\u53ea\u8bfb\u65b9\u6cd5\uff0c\u4e0d\u5e94\u4fee\u6539\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u3002SaveSnapshot()
\uff1a\u521b\u5efa\u5feb\u7167\uff0c\u5c06\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u5199\u5165 io.Writer
\u63a5\u53e3\uff0c\u901a\u5e38\u662f\u6587\u4ef6\u53e5\u67c4\u3002\u56e0\u6b64\uff0c\u6700\u7ec8\u4f1a\u4fdd\u5b58\u5230\u672c\u5730\u78c1\u76d8\u6587\u4ef6\u4e2d\u3002ISnapshotFileCollection
\u8868\u793a\u72b6\u6001\u673a\u4ee5\u5916\u7684\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u6587\u4ef6\u5217\u8868\uff08\u5982\u679c\u6709\uff09\uff0c\u8fd9\u4e9b\u6587\u4ef6\u4e5f\u4f1a\u4e00\u5e76\u5b58\u50a8\u5230\u5feb\u7167\u4e2d\u3002\u7b2c\u4e09\u4e2a\u53c2\u6570\u7528\u4e8e\u901a\u77e5\u5feb\u7167\u8fc7\u7a0b\uff0cRaft \u526f\u672c\u5df2\u505c\u6b62\uff0c\u7ec8\u6b62\u5feb\u7167\u64cd\u4f5c\u3002RecoverFromSnapshot()
\uff1a\u6062\u590d\u72b6\u6001\u673a\u6570\u636e\uff0c\u4ece io.Reader
\u4e2d\u8bfb\u53d6\u6700\u65b0\u7684\u5feb\u7167\u6570\u636e\u3002[]SnapshotFile
\u8868\u793a\u4e00\u4e9b\u989d\u5916\u7684\u6587\u4ef6\u5217\u8868\uff0c\u76f4\u63a5\u590d\u5236\u5230\u72b6\u6001\u673a\u6570\u636e\u76ee\u5f55\u4e2d\u3002\u7b2c\u4e09\u4e2a\u53c2\u6570\u7528\u4e8e\u63a7\u5236\uff0c\u5728\u8fdb\u884c Raft \u526f\u672c\u65f6\u4e5f\u505c\u6b62\u6062\u590d\u5feb\u7167\u7684\u64cd\u4f5c\u3002Close()
\uff1a\u5173\u95ed\u72b6\u6001\u673a\uff0c\u6267\u884c\u4e00\u4e9b\u6e05\u7406\u5de5\u4f5c\u3002\u5728 Logservice \u4e2d\uff0c\u4e00\u6b21\u8bfb\u5199\u8bf7\u6c42\u7684\u5927\u81f4\u6d41\u7a0b\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#_4","title":"\u5199\u6d41\u7a0b","text":"\u8bfb\u53d6\u6570\u636e\u5206\u4e3a\u4e24\u79cd\u60c5\u51b5\uff1a
\u4ece\u72b6\u6001\u673a\u4e2d\u8bfb\u53d6\u6570\u636e\u3002
\u4ece\u65e5\u5fd7\u6570\u636e\u5e93\uff08log db\uff09\u4e2d\u8bfb\u53d6\u65e5\u5fd7\u6761\u76ee\u3002
\u5f53 logservice \u7684\u65e5\u5fd7\u6761\u76ee\u5728 log db \u4e2d\u4e0d\u65ad\u589e\u957f\u65f6\uff0c\u4f1a\u5bfc\u81f4\u78c1\u76d8\u7a7a\u95f4\u4e0d\u8db3\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5b9a\u671f\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff0c\u8fd9\u901a\u8fc7\u622a\u65ad\uff08truncation\uff09\u6765\u5b8c\u6210\u3002
logservice \u4f7f\u7528\u57fa\u4e8e\u5185\u5b58\u7684\u72b6\u6001\u673a\uff0c\u72b6\u6001\u673a\u4e2d\u53ea\u8bb0\u5f55\u4e86\u4e00\u4e9b\u5143\u6570\u636e\u548c\u72b6\u6001\u4fe1\u606f\uff0c\u4f8b\u5982 tick\u3001state \u548c LSN \u7b49\uff0c\u5e76\u6ca1\u6709\u8bb0\u5f55\u7528\u6237\u6570\u636e\uff0c\u8fd9\u4e9b\u6570\u636e\u7531\u6570\u636e\u8282\u70b9\uff08TN\uff09\u81ea\u5df1\u8bb0\u5f55\u3002\u53ef\u4ee5\u5c06\u5176\u7406\u89e3\u4e3a\u5728\u4e3b\u4ece\u67b6\u6784\u4e2d\uff0c\u72b6\u6001\u673a\u662f\u5206\u79bb\u7684\uff0cTN \u548c logservice \u5206\u522b\u7ef4\u62a4\u5404\u81ea\u7684\u72b6\u6001\u673a\u3002
\u5728\u8fd9\u79cd\u72b6\u6001\u673a\u5206\u79bb\u7684\u8bbe\u8ba1\u4e0b\uff0c\u7b80\u5355\u7684\u5feb\u7167\uff08snapshot\uff09\u673a\u5236\u4f1a\u5bfc\u81f4\u95ee\u9898\uff1a
\u4e3a\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff0c\u5f53\u524d\u7684\u622a\u65ad\u5de5\u4f5c\u6d41\u7a0b\u5982\u4e0b\uff1a
Logtail \u662f CN\uff08Computation Node\uff0c\u8ba1\u7b97\u8282\u70b9\uff09\u4e0e TN\uff08Transaction Node\uff0c\u4e8b\u52a1\u8282\u70b9\uff09\u4e4b\u95f4\u7684\u4e00\u79cd\u65e5\u5fd7\u540c\u6b65\u534f\u8bae\uff0c\u5b83\u4f5c\u4e3a CN \u548c TN \u534f\u540c\u5de5\u4f5c\u7684\u57fa\u7840\u3002\u672c\u6587\u5c06\u6df1\u5165\u4ecb\u7ecd Logtail \u534f\u8bae\u7684\u57fa\u672c\u5b9a\u4f4d\u3001\u534f\u8bae\u5185\u5bb9\u4ee5\u53ca\u4ea7\u751f\u8fc7\u7a0b\u3002
TAE \u662f MatrixOne \u4e91\u539f\u751f\u4e8b\u52a1\u4e0e\u5206\u6790\u5f15\u64ce\uff0c\u4e0e TN \u8282\u70b9\u76f8\u5173\u7684\u804c\u8d23\u76ee\u524d\u5305\u62ec\uff1a
\u5728 1 \u548c 3 \u5b8c\u6210\u65f6\uff0c\u90fd\u4f1a\u4ea7\u751f\u72b6\u6001\u53d8\u5316\uff0c\u4f8b\u5982\u6570\u636e\u6210\u529f\u5199\u5165\u5185\u5b58\u6216\u5bf9\u8c61\u5b58\u50a8\u3002Logtail \u662f\u4e00\u79cd\u65e5\u5fd7\u540c\u6b65\u534f\u8bae\uff0c\u65e8\u5728\u4ee5\u4f4e\u6210\u672c\u7684\u65b9\u5f0f\u540c\u6b65 TN \u7684\u90e8\u5206\u72b6\u6001\uff0c\u4f7f CN \u80fd\u591f\u5728\u672c\u5730\u91cd\u5efa\u6240\u9700\u7684\u53ef\u8bfb\u6570\u636e\u3002\u4f5c\u4e3a MatrixOne \u5b58\u7b97\u5206\u79bb\u67b6\u6784\u7684\u5173\u952e\u534f\u8bae\uff0cLogtail \u5177\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a
Logtail \u652f\u6301\u4e24\u79cd\u83b7\u53d6\u6a21\u5f0f\uff1apull \u548c push\u3002
Logtail \u652f\u6301\u8868\u7ea7\u522b\u7684\u8ba2\u9605\u548c\u6536\u96c6\uff0c\u4f7f\u5176\u5728\u591a CN \u652f\u6301\u65b9\u9762\u66f4\u52a0\u7075\u6d3b\uff0c\u6709\u52a9\u4e8e\u5b9e\u73b0 CN \u8d1f\u8f7d\u7684\u5747\u8861\u3002
Logtail \u534f\u8bae\u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff1a\u5185\u5b58\u6570\u636e\u548c\u5143\u6570\u636e\uff0c\u5176\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u6570\u636e\u662f\u5426\u5df2\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002
\u4e00\u6b21\u4e8b\u52a1 commit
\u4ea7\u751f\u7684\u66f4\u65b0\u5728\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u4e4b\u524d\uff0c\u5176\u65e5\u5fd7\u4ee5\u5185\u5b58\u6570\u636e\u7684\u5f62\u5f0f\u5b58\u5728\u4e8e Logtail \u4e2d\u3002\u4efb\u4f55\u6570\u636e\u4e0a\u7684\u4fee\u6539\u90fd\u53ef\u4ee5\u5f52\u7ed3\u4e3a\u63d2\u5165\u548c\u5220\u9664\uff1a
\u663e\u7136\uff0c\u5185\u5b58\u6570\u636e\u4e0d\u80fd\u6c38\u8fdc\u4fdd\u7559\u5728\u5185\u5b58\u4e2d\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u589e\u52a0\u5185\u5b58\u538b\u529b\u3002\u51fa\u4e8e\u65f6\u95f4\u6216\u5bb9\u91cf\u7684\u8003\u8651\uff0c\u5185\u5b58\u6570\u636e\u4f1a\u88ab\u5237\u65b0\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\uff0c\u5f62\u6210\u4e00\u4e2a\u5bf9\u8c61\u3002\u6bcf\u4e2a\u5bf9\u8c61\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5757\uff08block\uff09\u3002\u6570\u636e\u5757\u662f\u8868\u6570\u636e\u7684\u6700\u5c0f\u5b58\u50a8\u5355\u4f4d\uff0c\u6bcf\u4e2a\u5757\u4e2d\u7684\u884c\u6570\u4e0d\u8d85\u8fc7\u56fa\u5b9a\u4e0a\u9650\uff0c\u76ee\u524d\u9ed8\u8ba4\u4e3a 8192 \u884c\u3002\u5237\u65b0\u5b8c\u6210\u540e\uff0cLogtail \u5c06\u5757\u7684\u5143\u6570\u636e\u4f20\u9012\u7ed9 CN\uff0cCN \u6839\u636e\u4e8b\u52a1\u65f6\u95f4\u6233\u8fc7\u6ee4\u51fa\u53ef\u89c1\u7684\u5757\u5217\u8868\uff0c\u8bfb\u53d6\u5757\u4e2d\u7684\u5185\u5bb9\uff0c\u7ed3\u5408\u5185\u5b58\u6570\u636e\uff0c\u5f97\u5230\u67d0\u4e2a\u65f6\u523b\u7684\u5b8c\u6574\u6570\u636e\u89c6\u56fe\u3002
\u4e0a\u8ff0\u8fc7\u7a0b\u662f\u57fa\u7840\u6b65\u9aa4\uff0c\u968f\u7740\u6027\u80fd\u4f18\u5316\u7684\u5f15\u5165\uff0c\u5c06\u5448\u73b0\u66f4\u591a\u7ec6\u8282\uff0c\u4f8b\u5982\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#1-checkpoint","title":"1. \u68c0\u67e5\u70b9\uff08checkpoint\uff09","text":"\u5f53 TN \u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u540e\uff0c\u5728\u67d0\u4e2a\u65f6\u523b\u6267\u884c\u68c0\u67e5\u70b9\uff0c\u5373\u5c06\u6b64\u65f6\u4e4b\u524d\u7684\u6240\u6709\u6570\u636e\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u3002\u56e0\u6b64\uff0c\u6240\u6709\u8fd9\u4e9b\u5143\u6570\u636e\u5c06\u88ab\u6574\u7406\u6210\u4e00\u4e2a\u201c\u538b\u7f29\u5305\u201d\u3002\u5f53\u65b0\u542f\u52a8\u7684 CN \u8fde\u63a5\u5230 TN \u5e76\u8bf7\u6c42\u9996\u6b21 Logtail \u65f6\uff0c\u5982\u679c\u8ba2\u9605\u65f6\u95f4\u6233\u5927\u4e8e\u68c0\u67e5\u70b9\u65f6\u95f4\u6233\uff0cTN \u53ef\u4ee5\u901a\u8fc7 Logtail \u76f4\u63a5\u4f20\u9012\u68c0\u67e5\u70b9\u5143\u6570\u636e\uff08\u4e00\u4e2a\u5b57\u7b26\u4e32\uff09\uff0c\u4ece\u800c\u8ba9 CN \u76f4\u63a5\u8bfb\u53d6\u68c0\u67e5\u70b9\u4e4b\u524d\u751f\u6210\u7684\u5757\u4fe1\u606f\uff0c\u51cf\u8f7b\u4e86\u4ece\u5934\u4f20\u9012\u5757\u5143\u6570\u636e\u7684\u7f51\u7edc\u8d1f\u62c5\uff0c\u964d\u4f4e\u4e86 TN \u7684 I/O \u538b\u529b\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#2","title":"2. \u5185\u5b58\u6e05\u7406","text":"\u5f53 TN \u5c06\u5757\u5143\u6570\u636e\u4f20\u9012\u7ed9 CN \u65f6\uff0c\u5c06\u6839\u636e\u5757\u6807\u8bc6\u7b26\u6e05\u7406\u5148\u524d\u4f20\u9012\u7684\u5185\u5b58\u6570\u636e\u3002\u7136\u800c\uff0c\u5728 TN \u5237\u65b0\u4e8b\u52a1\u671f\u95f4\uff0c\u53ef\u80fd\u4f1a\u53d1\u751f\u6570\u636e\u66f4\u65b0\uff0c\u4f8b\u5982\u5237\u65b0\u7684\u5757\u4e0a\u53ef\u80fd\u4f1a\u65b0\u4ea7\u751f\u5220\u9664\u64cd\u4f5c\u3002\u5982\u679c\u7b56\u7565\u662f\u56de\u6eda\u548c\u91cd\u8bd5\uff0c\u90a3\u4e48\u5df2\u7ecf\u5199\u5165\u7684\u6570\u636e\u5c06\u53d8\u5f97\u65e0\u6548\u3002\u5728\u66f4\u65b0\u9891\u7e41\u7684\u8d1f\u8f7d\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u4f1a\u4ea7\u751f\u5927\u91cf\u7684\u56de\u6eda\u64cd\u4f5c\uff0c\u6d6a\u8d39 TN \u8d44\u6e90\u3002\u4e3a\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0cTN \u5c06\u7ee7\u7eed\u63d0\u4ea4\uff0c\u5bfc\u81f4\u5237\u65b0\u4e8b\u52a1\u5f00\u59cb\u540e\u751f\u6210\u7684\u5185\u5b58\u6570\u636e\u65e0\u6cd5\u4ece CN \u4e2d\u5220\u9664\u3002\u5728 Logtail \u7684\u5757\u5143\u4fe1\u606f\u4e2d\u4f20\u9012\u4e00\u4e2a\u65f6\u95f4\u6233\uff0c\u5728\u8fd9\u4e2a\u65f6\u95f4\u6233\u4e4b\u524d\uff0c\u8be5\u5757\u7684\u5185\u5b58\u6570\u636e\u624d\u80fd\u4ece\u5185\u5b58\u4e2d\u6e05\u7406\u3002\u8fd9\u4e9b\u672a\u6e05\u7406\u7684\u66f4\u65b0\u5c06\u5728\u4e0b\u4e00\u6b21\u5237\u65b0\u4e2d\u5f02\u6b65\u5237\u5165\u78c1\u76d8\uff0c\u5e76\u901a\u8fc7 CN \u8fdb\u884c\u5220\u9664\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#3","title":"3. \u66f4\u5feb\u7684\u8bfb\u53d6","text":"\u5df2\u7ecf\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u5757\u53ef\u80fd\u4f1a\u7ee7\u7eed\u4ea7\u751f\u5220\u9664\u64cd\u4f5c\uff0c\u56e0\u6b64\u5728\u8bfb\u53d6\u8fd9\u4e9b\u5757\u65f6\uff0c\u9700\u8981\u7ed3\u5408\u5185\u5b58\u4e2d\u7684\u5220\u9664\u6570\u636e\u3002\u4e3a\u4e86\u66f4\u5feb\u5730\u786e\u5b9a\u54ea\u4e9b\u5757\u9700\u8981\u4e0e\u5185\u5b58\u6570\u636e\u7ed3\u5408\uff0cCN \u989d\u5916\u7ef4\u62a4\u4e00\u4e2a\u5757\u7684 Btree \u7d22\u5f15\u3002\u5e94\u7528 Logtail \u65f6\u9700\u8981\u8c28\u614e\u4fee\u6539\u8fd9\u4e2a\u7d22\u5f15\uff0c\u4ee5\u52a0\u5feb\u8bfb\u53d6\u901f\u5ea6\uff1a\u5904\u7406\u5185\u5b58\u6570\u636e\u65f6\u589e\u52a0\u7d22\u5f15\u6761\u76ee\uff0c\u5904\u7406\u5757\u5143\u6570\u636e\u65f6\u51cf\u5c11\u7d22\u5f15\u6761\u76ee\u3002\u53ea\u6709\u5728\u8fd9\u4e2a\u7d22\u5f15\u4e2d\u7684\u5757\u624d\u9700\u8981\u68c0\u67e5\u5185\u5b58\u6570\u636e\uff0c\u5728\u5757\u6570\u91cf\u8f83\u591a\u65f6\uff0c\u8fd9\u5c06\u5e26\u6765\u5de8\u5927\u7684\u6027\u80fd\u63d0\u5347\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#logtail_2","title":"Logtail \u7684\u751f\u6210","text":"\u5982\u524d\u6240\u8ff0\uff0cLogtail \u53ef\u4ee5\u901a\u8fc7 pull \u548c push \u4e24\u79cd\u65b9\u5f0f\u83b7\u53d6\u3002\u8fd9\u4e24\u79cd\u6a21\u5f0f\u5177\u6709\u4e0d\u540c\u7684\u7279\u70b9\uff0c\u4e0b\u9762\u5c06\u5206\u522b\u4ecb\u7ecd\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#1-pull","title":"1. Pull","text":"\u5982\u524d\u6240\u8ff0\uff0cpull \u5b9e\u9645\u4e0a\u662f\u540c\u6b65\u8868\u7684\u5feb\u7167\uff0c\u4ee5\u53ca\u540e\u7eed\u4ea7\u751f\u7684\u589e\u91cf\u65e5\u5fd7\u4fe1\u606f\u3002
\u4e3a\u4e86\u8fbe\u6210\u8fd9\u4e2a\u76ee\u7684\uff0cTN \u7ef4\u62a4\u4e86\u4e00\u4e2a\u6309\u7167\u4e8b\u52a1 prepare \u65f6\u95f4\u6392\u5e8f\u7684 txn handle \u5217\u8868\uff0clogtail table\uff0c\u7ed9\u5b9a\u4efb\u610f\u65f6\u523b\uff0c\u901a\u8fc7\u4e8c\u5206\u67e5\u627e\u5f97\u5230\u8303\u56f4\u5185\u7684 txn handle\uff0c\u518d\u7531 txn handle \u5f97\u5230\u8be5\u4e8b\u52a1\u5728\u54ea\u4e9b block \u4e0a\u505a\u8fc7\u66f4\u65b0\uff0c\u901a\u8fc7\u904d\u5386\u8fd9\u4e9b block\uff0c\u5c31\u80fd\u5f97\u5230\u5b8c\u6574\u7684\u65e5\u5fd7\u3002\u4e3a\u4e86\u52a0\u5feb\u67e5\u627e\u901f\u5ea6\uff0c\u5bf9 txn handle \u505a\u4e86\u5206\u9875\uff0c\u4e00\u4e2a\u9875\u7684 bornTs \u5c31\u662f\u5f53\u524d\u9875\u4e2d\u7684 txn handle \u7684\u6700\u5c0f prepare \u65f6\u95f4\uff0c\u7b2c\u4e00\u5c42\u4e8c\u5206\u7684\u5bf9\u8c61\u5c31\u662f\u8fd9\u4e9b\u9875\u3002
\u57fa\u4e8e logtail table\uff0c\u4ece\u63a5\u6536\u5230 pull \u8bf7\u6c42\uff0c\u4e3b\u8981\u5de5\u4f5c\u8def\u5f84\u5982\u4e0b\uff1a
\u6839\u636e\u5df2\u6709\u7684 checkpoints\uff0c\u8c03\u6574\u8bf7\u6c42\u7684\u65f6\u95f4\u8303\u56f4\uff0c\u66f4\u65e9\u7684\u53ef\u4ee5\u901a\u8fc7 checkpoint \u7ed9\u51fa\u3002
\u53d6 logtail table \u7684\u4e00\u4efd\u5feb\u7167\uff0c\u57fa\u4e8e\u8bbf\u95ee\u8005\u6a21\u5f0f\u7528 RespBuilder \u53bb\u8fed\u4ee3\u8fd9\u4efd\u5feb\u7167\u4e2d\u76f8\u5173\u7684 txn handle\uff0c\u6536\u96c6\u5df2\u63d0\u4ea4\u7684\u65e5\u5fd7\u4fe1\u606f\u3002
\u5c06\u6536\u96c6\u5230\u7684\u65e5\u5fd7\u4fe1\u606f\uff0c\u6309\u7167 logtail \u534f\u8bae\u683c\u5f0f\u8f6c\u6362\uff0c\u4f5c\u4e3a\u54cd\u5e94\u8fd4\u56de\u7ed9 CN\u3002
type RespBuilder interface {\n OnDatabase(database *DBEntry) error\n OnPostDatabase(database *DBEntry) error\n OnTable(table *TableEntry) error\n OnPostTable(table *TableEntry) error\n OnPostSegment(segment *SegmentEntry) error\n OnSegment(segment *SegmentEntry) error\n OnBlock(block *BlockEntry) error\n BuildResp() (api.SyncLogtailResp, error)\n Close()\n}\n
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#2-push","title":"2. Push","text":"Push \u7684\u4e3b\u8981\u76ee\u7684\u662f\u66f4\u5b9e\u65f6\u5730 TN \u540c\u6b65\u589e\u91cf\u65e5\u5fd7\u5230 CN\u3002\u6574\u4f53\u6d41\u7a0b\u5206\u4e3a\u8ba2\u9605\u3001\u6536\u96c6\u3001\u63a8\u9001\u4e09\u4e2a\u9636\u6bb5\u3002
\u8ba2\u9605\uff1a\u4e00\u4e2a\u65b0 CN \u542f\u52a8\u540e\u7684\u5fc5\u8981\u6d41\u7a0b\uff0c\u5c31\u662f\u4f5c\u4e3a\u5ba2\u6237\u7aef\uff0c\u548c\u670d\u52a1\u7aef TN \u5efa\u7acb\u4e00\u4e2a RPC stream\uff0c\u5e76\u4e14\u8ba2\u9605 catalog \u76f8\u5173\u8868\uff0c\u5f53 database\u3001table\u3001column \u8fd9\u4e9b\u57fa\u672c\u4fe1\u606f\u540c\u6b65\u5b8c\u6210\u540e\uff0cCN \u624d\u80fd\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002\u5f53 TN \u6536\u5230\u8ba2\u9605\u4e00\u4e2a\u8868\u7684\u8bf7\u6c42\u65f6\uff0c\u5176\u5b9e\u5148\u8d70\u4e00\u904d pull \u6d41\u7a0b\uff0c\u4f1a\u628a\u622a\u6b62\u5230\u4e0a\u6b21 push \u65f6\u95f4\u6233\u524d\u7684\u6240\u6709 Logtail \u90fd\u5305\u542b\u5728\u8ba2\u9605\u54cd\u5e94\u4e2d\u3002\u76ee\u524d\u5bf9\u4e00\u4e2a CN\uff0cLogtail \u7684\u8ba2\u9605\u3001\u53d6\u6d88\u8ba2\u9605\u3001\u6570\u636e\u53d1\u9001\uff0c\u90fd\u53d1\u751f\u5728\u4e00\u6761 RPC stream \u94fe\u63a5\u4e0a\uff0c\u5982\u679c\u5b83\u6709\u4efb\u4f55\u5f02\u5e38\uff0cCN \u4f1a\u8fdb\u5165\u91cd\u8fde\u6d41\u7a0b\uff0c\u76f4\u5230\u6062\u590d\u3002\u4e00\u65e6\u8ba2\u9605\u6210\u529f\uff0c\u540e\u7eed\u7684 Logtail \u5c31\u662f\u63a8\u9001\u589e\u91cf\u65e5\u5fd7\u3002
\u6536\u96c6\uff1a\u5728 TN\uff0c\u4e00\u4e2a\u4e8b\u52a1\u5b8c\u6210 WAL \u5199\u5165\u540e\uff0c\u89e6\u53d1\u56de\u8c03\u6267\u884c\uff0c\u5728\u5f53\u524d\u4e8b\u52a1\u4e2d\u6536\u96c6 Logtail\u3002\u4e3b\u8981\u6d41\u7a0b\u662f\u904d\u5386 workspace \u4e2d\u7684 TxnEntry\uff08\u4e00\u79cd\u4e8b\u52a1\u66f4\u65b0\u7684\u57fa\u672c\u5bb9\u5668\uff0c\u76f4\u63a5\u53c2\u4e0e\u5230 commit pipeline \u4e2d\uff09\uff0c\u4f9d\u636e\u5176\u7c7b\u578b\uff0c\u53d6\u5bf9\u5e94\u7684\u65e5\u5fd7\u4fe1\u606f\u8f6c\u6362\u4e3a Logtail \u534f\u8bae\u7684\u6570\u636e\u683c\u5f0f\u3002\u8fd9\u4e2a\u6536\u96c6\u8fc7\u7a0b\u901a\u8fc7 pipeline\uff0c\u548c WAL \u7684 fysnc \u5e76\u53d1\u6267\u884c\uff0c\u51cf\u5c11\u963b\u585e\u3002
\u63a8\u9001\uff1a\u63a8\u9001\u9636\u6bb5\u4e3b\u8981\u505a\u4e00\u6b21\u8fc7\u6ee4\uff0c\u5982\u679c\u53d1\u73b0\u67d0\u4e2a CN \u6ca1\u6709\u8ba2\u9605\u8be5\u8868\uff0c\u5c31\u8df3\u8fc7\u8be5 CN\uff0c\u907f\u514d\u63a8\u9001\u3002
\u5982\u679c\u4e00\u4e2a\u8868\u957f\u65f6\u95f4\u6ca1\u6709\u66f4\u65b0\u65f6\uff0c\u5982\u4f55\u4f7f CN \u83b7\u77e5\uff1f\u8fd9\u91cc\u5c31\u52a0\u5165\u4e86\u5fc3\u8df3\u673a\u5236\uff0c\u9ed8\u8ba4\u662f 2 ms\uff0cTN \u7684 commit \u961f\u5217\u4e2d\u4f1a\u653e\u5165\u4e00\u4e2a heartbeat \u7684\u7a7a\u4e8b\u52a1\uff0c\u4e0d\u505a\u4efb\u4f55\u5b9e\u8d28\u6027\u5de5\u4f5c\uff0c\u53ea\u6d88\u8017\u65f6\u95f4\u6233\uff0c\u4ece\u800c\u89e6\u53d1\u4e00\u6b21\u5fc3\u8df3 Logtail \u53d1\u9001\uff0c\u544a\u77e5 CN \u6b64\u524d\u7684\u6240\u6709\u8868\u6570\u636e\u5df2\u7ecf\u53d1\u9001\u8fc7\u66f4\u65b0\uff0c\u63a8\u52a8 CN \u4fa7\u7684\u65f6\u95f4\u6233\u6c34\u4f4d\u66f4\u65b0\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/","title":"Matrixone-Operator \u8bbe\u8ba1\u4e0e\u5b9e\u73b0\u8be6\u89e3","text":"MatrixOne \u662f\u4e00\u6b3e\u4e91\u539f\u751f\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u5929\u7136\u9002\u5e94\u4e91\u57fa\u7840\u8bbe\u65bd\u5e76\u9762\u5411\u4e91\u7684\u6210\u672c\u6a21\u578b\u8fdb\u884c\u4f18\u5316\u3002\u800c\u4e0e\u4e00\u822c\u7684 SaaS \u670d\u52a1\u4e0d\u540c\uff0c\u51fa\u4e8e\u5bf9\u6027\u80fd\u548c\u6570\u636e\u5b89\u5168\u7684\u9700\u6c42\uff0c\u5728\u4e25\u8083\u573a\u666f\u4e0b\u6570\u636e\u5e93\u5f80\u5f80\u9700\u8981\u8ddf\u7740\u5e94\u7528\u8d70\uff0c\u4e0e\u5e94\u7528\u8fd0\u884c\u5728\u76f8\u540c\u7684\u57fa\u7840\u8bbe\u65bd\u4e0a\u3002\u4e3a\u4e86\u670d\u52a1\u5c3d\u53ef\u80fd\u591a\u7684\u7528\u6237\uff0cMatrixOne \u9700\u8981\u9002\u914d\u5404\u7c7b\u516c\u6709\u4e91\u3001\u79c1\u6709\u4e91\u4e43\u81f3\u6df7\u5408\u4e91\u3002\u800c\u5176\u4e2d\u7684\u6700\u5927\u516c\u7ea6\u6570\u6b63\u662f Kubernetes\uff08\u4e0b\u6587\u7b80\u79f0 K8S\uff09\u3002\u56e0\u6b64\uff0cMatrixOne \u5c06 K8S \u4f5c\u4e3a\u5206\u5e03\u5f0f\u90e8\u7f72\u65f6\u7684\u9ed8\u8ba4\u8fd0\u884c\u73af\u5883\uff0c\u4ee5\u7edf\u4e00\u65b9\u5f0f\u9002\u914d\u4e0d\u540c\u7684\u4e91\u3002 MatrixOne-Operator \u6b63\u662f MatrixOne \u5728 K8S \u4e0a\u7684\u81ea\u52a8\u5316\u90e8\u7f72\u8fd0\u7ef4\u8f6f\u4ef6\uff0c\u5b83\u6269\u5c55 K8S\uff0c\u4ee5 K8S \u98ce\u683c\u7684\u58f0\u660e\u5f0f API \u5bf9\u5916\u63d0\u4f9b MatrixOne \u96c6\u7fa4\u7684\u8fd0\u7ef4\u7ba1\u7406\u80fd\u529b\u3002
\u8fd9\u7bc7\u6587\u7ae0\u5c06\u89e3\u8bfb MatrixOne-Operator \u7684\u8bbe\u8ba1\u4e0e\u5b9e\u73b0\uff0c\u5e76\u5206\u4eab\u6211\u4eec\u7684\u7ecf\u9a8c\u601d\u8003\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#matrixone-operator_1","title":"MatrixOne-Operator \u8bbe\u8ba1","text":"\u5c3d\u7ba1 K8S \u539f\u751f\u63d0\u4f9b\u4e86 StatefulSet API \u6765\u670d\u52a1\u6709\u72b6\u6001\u5e94\u7528\u7684\u7f16\u6392\uff0c\u4f46\u7531\u4e8e\u4e0d\u540c\u6709\u72b6\u6001\u5e94\u7528\u7684\u5e94\u7528\u5c42\u72b6\u6001\u96be\u4ee5\u8fdb\u884c\u7edf\u4e00\u62bd\u8c61\uff0c\u56e0\u6b64 K8S \u539f\u751f\u5e76\u4e0d\u652f\u6301\u7ba1\u7406\u5e94\u7528\u72b6\u6001\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0cOperator \u6a21\u5f0f\u5e94\u8fd0\u800c\u751f\u3002\u4e00\u4e2a\u5178\u578b\u7684 K8S Operator \u7531 API \u548c\u63a7\u5236\u5668 (Controller) \u4e24\u90e8\u5206\u6784\u6210\uff1a
\u901a\u5e38\u901a\u8fc7 K8S \u7684 CustomResourceDefinition\uff08CRD\uff09\u5bf9\u8c61\u8fdb\u884c\u58f0\u660e\uff0c\u5728\u63d0\u4ea4\u4e00\u4e2a K8S CRD \u5230 K8S \u7684 api-server \u540e\uff0capi-server \u5c31\u4f1a\u5728\u81ea\u8eab\u6ce8\u518c\u4e00\u4e2a\u5bf9\u5e94\u7684 Restful API\u3002\u6240\u6709\u7684 K8SClient \u90fd\u80fd\u4ee5\u7c7b\u4f3c\u64cd\u4f5c\u539f\u751f\u8d44\u6e90\u7684\u65b9\u5f0f\u5bf9\u8fd9\u4e2a\u65b0\u58f0\u660e\u7684 API \u8fdb\u884c GET,LIST, POST, DELETE \u7b49\u64cd\u4f5c\u3002\u6309\u7167\u60ef\u4f8b\uff0c\u6bcf\u4e2a API \u5bf9\u8c61\u5185\u7684\uff0c.spec
\u7ed3\u6784\u7531\u7528\u6237\u7ba1\u7406\uff0c\u7528\u4e8e\u58f0\u660e\u5bf9\u8c61\u7684\u671f\u671b\u72b6\u6001\uff0c.status
\u7ed3\u6784\u5219\u7531\u4e0b\u6587\u7684\u63a7\u5236\u5668\u7ba1\u7406\uff0c\u7528\u4e8e\u5bf9\u5916\u66b4\u9732\u5bf9\u8c61\u7684\u5b9e\u9645\u72b6\u6001\u3002
\u63a7\u5236\u5668\u662f\u4e00\u6bb5\u6301\u7eed\u8fd0\u884c\u7684\u4ee3\u7801\uff0c\u5b83\u76d1\u89c6 (watch) \u4e00\u7cfb\u5217 K8S \u5bf9\u8c61\uff0c\u5305\u62ec\u6211\u4eec\u521a\u521a\u5b9a\u4e49\u7684 API \u5bf9\u8c61\u3002\u7136\u540e\uff0c\u6839\u636e\u8fd9\u4e9b\u5bf9\u8c61\u7684\u671f\u671b\u72b6\u6001\u548c\u4ece\u73b0\u5b9e\u4e2d\u6536\u96c6\u5230\u7684\u5b9e\u9645\u72b6\u6001\uff08\u6ce8\u610f\uff1a\u8fd9\u91cc\u7684\u5b9e\u9645\u72b6\u6001\u662f\u4ece\u73b0\u5b9e\u4e2d\u6536\u96c6\u5230\u518d\u5199\u8fdb .status
\u7684\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u6765\u81ea .status
\uff09\u6267\u884c\u81ea\u52a8\u5316\u64cd\u4f5c\uff0c\u9a71\u52a8\u5b9e\u9645\u72b6\u6001\u5411\u671f\u671b\u72b6\u6001\u8f6c\u79fb\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4f1a\u6301\u7eed\u5faa\u73af\u8fdb\u884c\uff0c\u88ab\u5f62\u8c61\u5730\u79f0\u4f5c\u201c\u63a7\u5236\u5faa\u73af\u201d\uff08control loop\uff09\uff0c\u6709\u4e9b\u5730\u65b9\u4e5f\u4f1a\u7528\u4e00\u4e2a\u66f4\u5177\u53e4\u5178\u4e50\u98ce\u5473\u7684\u8bcd\u201c\u8c03\u8c10\u5faa\u73af\u201d(reconciliation loop)\uff0c\u5de7\u5999\u5730\u548c K8S \u7684\u201c\u7f16\u6392\u201d(Orchestration) \u4e00\u8bcd\u4fdd\u6301\u4e86\u98ce\u5473\u7edf\u4e00\u3002
\u4e0b\u56fe\u4ee5\u7b80\u5316\u540e\u7684 MatrixOneCluster API \u4f5c\u4e3a\u4f8b\u5b50\uff0c\u6982\u62ec\u6027\u5730\u63cf\u8ff0\u4e86\u8fd9\u4e2a\u8fc7\u7a0b\uff1a
MatrixOne-Operator \u4e0d\u4ec5\u63d0\u4f9b MatrixOneCluster \u8fd9\u6837\u7528\u4e8e\u7ba1\u7406 MO \u96c6\u7fa4\u7684\u8d1f\u8f7d\u578b API\uff0c\u8fd8\u63d0\u4f9b\u5907\u4efd\u6062\u590d\u8fd9\u6837\u7684\u4efb\u52a1\u578b API \u548c\u5bf9\u8c61\u5b58\u50a8\u6876\u8fd9\u6837\u7684\u8d44\u6e90\u578b API\u3002\u6bcf\u79cd API \u548c\u5b83\u4eec\u7684\u63a7\u5236\u5668\u5728\u8bbe\u8ba1\u65f6\u90fd\u6709\u72ec\u7279\u7684\u8003\u91cf\uff0c\u4f46\u4e07\u53d8\u4e0d\u79bb\u5176\u5b97\uff0c\u6240\u6709\u7684 API \u548c\u63a7\u5236\u5668\u90fd\u662f\u4ee5\u4e0a\u8ff0\u6a21\u5f0f\u8fdb\u884c\u6784\u5efa\u7684\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u7ee7\u7eed\u63a2\u7d22\u6bcf\u4e2a API \u8bbe\u8ba1\u4e2d\u7684\u53d6\u820d\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#api","title":"\u96c6\u7fa4 API \u8bbe\u8ba1","text":"\u4e00\u4e2a\u5206\u5e03\u5f0f MO \u96c6\u7fa4\u7531\u65e5\u5fd7\u670d\u52a1\u3001\u4e8b\u52a1\u8282\u70b9\u3001\u8ba1\u7b97\u8282\u70b9\u548c Proxy \u7b49\u591a\u4e2a\u7ec4\u4ef6\u7ec4\u6210\uff0c\u5176\u4e2d\u8ba1\u7b97\u8282\u70b9\u8fd8\u6709\u660e\u786e\u7684\u5f02\u6784\u9700\u6c42\u6765\u5b9e\u73b0\u9488\u5bf9\u8d1f\u8f7d\u7684\u673a\u578b\u4f18\u5316\u548c\u8de8\u4e91\u3001\u4e91\u8fb9\u4e00\u4f53\u7b49\u80fd\u529b\u3002\u5c06\u6574\u4e2a\u96c6\u7fa4\u7684\u7ba1\u7406\u90fd\u96c6\u4e2d\u5230\u4e00\u4e2a API \u5bf9\u8c61\u4e2d\u58f0\u660e\u518d\u4f7f\u7528\u4e00\u4e2a\u63a7\u5236\u5668\u8fdb\u884c\u7ba1\u7406\u867d\u7136\u4fbf\u4e8e\u4f7f\u7528\uff0c\u4f46\u5374\u662f\u4ee3\u7801\u7ef4\u62a4\u7684\u5669\u68a6\u3002\u56e0\u6b64\uff0cMatrixOne-Operator \u5728\u8bbe\u8ba1\u4e4b\u521d\u5c31\u660e\u786e\u4e86\u677e\u8026\u5408\u7684\u7ec6\u7c92\u5ea6 API \u8fd9\u4e00\u539f\u5219\uff0c\u8bbe\u8ba1\u4e86 LogSet,CNSet,ProxySet,BucketClaim \u7b49\u804c\u8d23\u660e\u786e\u7684 API \u548c\u5f7c\u6b64\u72ec\u7acb\u7684\u63a7\u5236\u5668\u3002\u4e3a\u4e86\u4fdd\u6301\u6613\u7528\u6027\uff0c\u53c8\u5f15\u5165\u4e86 MatrixOneCluster API\u3002\u8d1f\u8d23 MatrixOneCluster \u63a7\u5236\u5668\u4e0d\u91cd\u590d\u5176\u4ed6\u63a7\u5236\u5668\u7684\u5de5\u4f5c\u2014\u2014\u5f53\u4e00\u5957\u96c6\u7fa4\u9700\u8981\u4e00\u4e2a LogSet \u63d0\u4f9b\u65e5\u5fd7\u670d\u52a1\u65f6\uff0cMatrixOneCluster \u63a7\u5236\u5668\u4ec5\u4ec5\u662f\u521b\u5efa\u4e00\u4e2a LogSet \u5bf9\u8c61\uff0c\u5176\u4f59\u7684\u5de5\u4f5c\u5219\u59d4\u6258\u7ed9 LogSet \u63a7\u5236\u5668\u3002
\u5728\u8fd9\u6837\u7684\u8bbe\u8ba1\u4e0b\uff0c\u867d\u7136 API \u5f88\u591a\uff0c\u4f46\u7528\u6237\u59cb\u7ec8\u53ea\u9700\u8981\u5173\u5fc3 MatrixOneCluster API\uff0c\u800c MatrixOne-Operator \u7684\u5f00\u53d1\u8005\u4e5f\u5728\u6dfb\u52a0\u7279\u6027\u6216\u89e3\u51b3\u95ee\u9898\u65f6\uff0c\u95ee\u9898\u57df\u4e5f\u5f80\u5f80\u4e0d\u5927\u4e8e\u4e00\u4e2a\u7ec6\u7c92\u5ea6\u7684 API \u548c\u63a7\u5236\u5668\u3002
\u5f53\u7136\uff0c\u591a\u4e2a API \u5bf9\u8c61\u95f4\u4f1a\u6709\u67d0\u4e9b\u4f9d\u8d56\u5173\u7cfb\uff0c\u6bd4\u5982\u4e8b\u52a1\u8282\u70b9\u548c\u8ba1\u7b97\u8282\u70b9\u90fd\u4f9d\u8d56\u8fd0\u884c\u4e8e\u65e5\u5fd7\u670d\u52a1\u4e2d\u7684 HAKeeper \u6765\u83b7\u53d6\u96c6\u7fa4\u4fe1\u606f\u8fdb\u884c\u670d\u52a1\u53d1\u73b0\u3002\u8fd9\u8981\u6c42\u90e8\u7f72\u96c6\u7fa4\u65f6\u9996\u5148\u542f\u52a8\u65e5\u5fd7\u670d\u52a1\u5e76\u5b8c\u6210 HAKeeper \u7684 bootstrap \u624d\u80fd\u7ee7\u7eed\u542f\u52a8\u4e8b\u52a1\u8282\u70b9\u548c\u8ba1\u7b97\u8282\u70b9\u3002\u8fd9\u7c7b\u903b\u8f91\u56fa\u7136\u53ef\u4ee5\u7531 MatrixOneCluster \u63a7\u5236\u5668\u5b9e\u73b0\uff0c\u4f46\u8fd9\u4e5f\u610f\u5473\u7740\u6cc4\u9732\u4e86\u5176\u4ed6\u63a7\u5236\u5668\u7684\u4e1a\u52a1\u77e5\u8bc6\uff0c\u5404\u4e2a\u63a7\u5236\u7684\u5b9e\u73b0\u4ecd\u7136\u4ea7\u751f\u4e86\u8026\u5408\u3002\u56e0\u6b64\uff0c\u5728 mo-operator \u4e2d\uff0c\u6211\u4eec\u5c06\u6240\u6709\u7ec4\u4ef6\u95f4\u4ea7\u751f\u4f9d\u8d56\u7684\u4e1a\u52a1\u903b\u8f91\u90fd\u5728\u4f9d\u8d56\u65b9\u8fdb\u884c\u5b9e\u73b0\uff0c\u88ab\u4f9d\u8d56\u65b9\u4ec5\u4ec5\u901a\u8fc7\u7ea6\u5b9a\u4fd7\u6210\u7684 .status
\u5b57\u6bb5\u5bf9\u5916\u66b4\u9732\u81ea\u8eab\u72b6\u6001\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0c\u63a7\u5236\u5668\u5728\u8c03\u8c10\u4e00\u4e2a CNset \u65f6\uff0c\u4f1a\u4e3b\u52a8\u7b49\u5f85 CNSet \u6307\u5411\u7684 LogSet \u5c31\u7eea\u518d\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\uff0c\u800c LogSet \u63a7\u5236\u5668\u548c\u4e0a\u5c42\u7684 MatrixOneCluster \u63a7\u5236\u5668\u90fd\u4e0d\u9700\u8981\u611f\u77e5\u5230\u8fd9\u4ef6\u4e8b\u3002
\u677e\u8026\u5408\u7ec6\u7c92\u5ea6\u7684 API \u80fd\u591f\u5f88\u597d\u5730\u9002\u5e94 CN \u7684\u5f02\u6784\u7f16\u6392\u573a\u666f\u3002\u5728 MatrixOne-Operator \u4e2d\uff0c\u9664\u4e86\u5728 MatrixOneCluster \u4e2d\u58f0\u660e\u591a\u4e2a CN \u7ec4\u6765\u8fdb\u884c\u5f02\u6784\u7f16\u6392\u8fd9\u79cd\u4fbf\u6377\u7528\u6cd5\u4e4b\u5916\uff0c\u8fd8\u80fd\u76f4\u63a5\u521b\u5efa\u4e00\u4e2a CNSet \u6765\u52a0\u5165\u73b0\u6709\u96c6\u7fa4\uff0c\u8fd9\u610f\u5473\u7740\u65b0\u7684 CNSet \u53ef\u4ee5\u90e8\u7f72\u5728\u53e6\u4e00\u5957 K8S \u96c6\u7fa4\u4e2d\uff0c\u914d\u5408\u7f51\u7edc\u5c42\u9762\u7684\u652f\u6301\uff0c\u5c31\u80fd\u8fdb\u884c\u8de8\u4e91\u6216\u4e91\u8fb9\u573a\u666f\u4e0b\u7684 MO \u7f16\u6392\u3002
\u5728\u5404\u4e2a\u63a7\u5236\u5668\u7684\u8fed\u4ee3\u8fc7\u7a0b\u4e2d\uff0cMatrixOne-Operator \u4e5f\u503e\u5411\u4e8e\u901a\u8fc7\u6dfb\u52a0\u65b0\u7684 API \u5bf9\u8c61\u6765\u6dfb\u52a0\u65b0\u7279\u6027\u3002\u6bd4\u5982\uff0c\u5728\u5b9e\u73b0\u5bf9\u8c61\u5b58\u50a8\u7ba1\u7406\u65f6\uff0cMatrixOne-Operator \u9700\u8981\u4fdd\u8bc1\u4e0d\u540c\u96c6\u7fa4\u4f7f\u7528\u7684\u5bf9\u8c61\u5b58\u50a8\u8def\u5f84\u4e4b\u95f4\u6ca1\u6709\u4ea4\u96c6\u5e76\u4e14\u5728\u96c6\u7fa4\u9500\u6bc1\u540e\u81ea\u52a8\u6e05\u7406\u3002MatrixOne-Operator \u7684\u89e3\u51b3\u65b9\u6848\u5c31\u662f\u65b0\u589e\u4e00\u4e2a BucketClaim API\uff0c\u53c2\u8003 K8S PersistentVolumeClaim \u7684\u63a7\u5236\u903b\u8f91\uff0c\u5728\u72ec\u7acb\u7684\u63a7\u5236\u5668\u4e2d\u5b8c\u6210\u4e00\u4e2a\u5bf9\u8c61\u5b58\u50a8\u8def\u5f84\u7684\u751f\u547d\u5468\u671f\u7ba1\u7406\uff0c\u907f\u514d\u590d\u6742\u7684\u7ade\u6001\u6761\u4ef6\u5904\u7406\u548c\u4ee3\u7801\u8026\u5408\u95ee\u9898\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_1","title":"\u63a7\u5236\u5668\u5b9e\u73b0","text":"K8S \u63d0\u4f9b\u4e86 controller-runtime \u5305\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9e\u73b0\u81ea\u5df1\u7684\u63a7\u5236\u5668\uff0c\u4f46\u4e3a\u4e86\u901a\u7528\u6027\uff0c\u63a5\u53e3\u8bbe\u8ba1\u662f\u76f8\u5bf9\u5e95\u5c42\u7684\uff1a
Reconcile(ctx context.Context, req Request)(Result, error)\n
\u63a7\u5236\u5668\u9700\u8981\u5b9e\u73b0 Reconcile \u63a5\u53e3\uff0c\u518d\u901a\u8fc7 controller-runtime \u7684\u63a5\u53e3\u8fdb\u884c\u6ce8\u518c\uff0c\u58f0\u660e\u8981\u76d1\u542c\u7684\u5bf9\u8c61\u4ee5\u53ca\u4e00\u4e9b\u76d1\u542c\u7684\u8fc7\u6ee4\u89c4\u5219\uff0ccontroller-runtime \u5c31\u4f1a\u5728\u6bcf\u6b21\u5bf9\u8c61\u53d1\u751f\u53d8\u5316\u6216\u8005\u91cd\u8bd5 Reconcile \u65f6\u8c03\u7528\u63a7\u5236\u5668\u7684 Reconcile \u65b9\u6cd5\uff0c\u5e76\u5728 req \u53c2\u6570\u4e2d\u4f20\u5165\u76ee\u6807\u5bf9\u8c61\u7684\u6807\u8bc6\u7b26\u3002\u8fd9\u4e2a\u63a5\u53e3\u5185\u4f1a\u5b58\u5728\u4e0d\u5c11\u6a21\u677f\u4ee3\u7801\uff0c\u7528\u4f2a\u4ee3\u7801\u6765\u8868\u793a\u901a\u5e38\u662f\uff1a
func \u8c03\u8c10(\u5bf9\u8c61 A \u7684 Namespace+Name) {\n \u83b7\u53d6\u5bf9\u8c61 A \u7684Spec\n if \u5bf9\u8c61 A \u6b63\u5728\u88ab\u5220\u9664 {\n \u6267\u884c\u6e05\u7406\u903b\u8f91\n \u66f4\u65b0\u6e05\u7406\u8fdb\u5ea6\u5230 A.status\n \u79fb\u9664\u5bf9\u8c61 A \u4e0a\u7684 finalizer\n } else {\n \u4e3a A \u6dfb\u52a0 finalizer\n \u6267\u884c\u8c03\u8c10\u903b\u8f91\n \u66f4\u65b0\u8c03\u8c10\u8fdb\u5ea6\u5230 A.status\n }\n}\n
\u7c7b\u4f3c\u7684\u903b\u8f91\u5728\u5404\u79cd\u793e\u533a\u63a7\u5236\u5668\u5b9e\u73b0\u4e2d\u53cd\u590d\u51fa\u73b0\uff0c\u5e76\u4e14\u5f00\u53d1\u8005\u9700\u8981\u5173\u5fc3\u5f88\u591a\u4e1a\u52a1\u4e4b\u5916\u7684\u5185\u5bb9\uff1a\u6b63\u786e\u5730\u5904\u7406 finalizer \u4ee5\u786e\u4fdd\u8d44\u6e90\u4e0d\u4f1a\u6cc4\u9732\u3001\u5c06\u8fdb\u5ea6\u548c\u9519\u8bef\u53ca\u65f6\u66f4\u65b0\u5230 status \u4e2d\u6765\u63d0\u5347\u53ef\u89c1\u5ea6\u4ee5\u53ca\u66f4\u7ec6\u8282\u7684 logger \u9700\u8981\u5e26 context \u548c kubeClient \u9700\u8981\u5e26 cache \u7b49\u95ee\u9898\u3002
\u7531\u4e8e\u4e0d\u9700\u8981\u8003\u8651\u901a\u7528\u6027\uff0cMatrixOne-Operator \u5185\u8fdb\u884c\u4e86\u66f4\u7279\u5316\u7684\u62bd\u8c61\uff0c\u8bbe\u8ba1\u4e86 Actor \u63a5\u53e3\uff1a
type Actor[T client.Object] interface { \n Observe(*Context[T]) (Action[T], error) \n Finalize(*Context[T]) (done bool, err error) \n}\n\ntype Action[T client.Object] func(*Context[T]) error\n
\u5728\u80cc\u540e\uff0c\u901a\u7528\u7684\u63a7\u5236\u5668\u6846\u67b6\u903b\u8f91\u4f1a\u5904\u7406\u597d\u6240\u6709\u7c7b\u4f3c\u4e0a\u6587\u6a21\u677f\u4ee3\u7801\u7684\u903b\u8f91\u548c\u7ec6\u8282\uff0c\u5728 Context[T] \u5185\u51c6\u5907\u597d\u5f53\u524d\u9700\u8981 reconcile \u7684\u5bf9\u8c61\u548c\u5df2\u7ecf\u5904\u7406\u597d\u4e0a\u4e0b\u6587\u7684 Logger, EventRecorder, KubeClient \u5bf9\u8c61\u3002\u6700\u540e\uff1a
\u5728\u8c03\u8c10\u4e00\u4e2a\u672a\u88ab\u5220\u9664\u7684\u5bf9\u8c61\u65f6\uff0c\u8c03\u7528 Actor.Observe \u8ba9\u771f\u6b63\u7684\u4e1a\u52a1\u903b\u8f91\u6267\u884c\u8c03\u8c10\uff1b
\u5728\u8c03\u8c10\u4e00\u4e2a\u5220\u9664\u4e2d\u5bf9\u8c61\u65f6\uff0c\u8c03\u7528 Actor.Finalize \u6267\u884c\u4e1a\u52a1\u903b\u8f91\u5185\u7684\u8d44\u6e90\u6e05\u7406\u884c\u4e3a\uff0c\u4e0d\u65ad\u91cd\u8bd5\uff0c\u76f4\u5230 Finalize \u8fd4\u56de\u5b8c\u6210\uff0c\u624d\u79fb\u9664\u5bf9\u8c61\u7684 finalizer\u3002
\u4e00\u4e2a\u5bf9\u8c61\u7684\u72b6\u6001\u673a\u5982\u4e0b\uff1a
\u5728\u8fd9\u4e2a\u6d41\u7a0b\u4e0b\uff0c\u4e00\u4e2a\u63a7\u5236\u5668\u5bf9 API \u5bf9\u8c61\u751f\u547d\u5468\u671f\u7ba1\u7406\u4e2d\u7684\u521b\u5efa\u548c\u9500\u6bc1\u4e24\u90e8\u5206\u7684\u5b9e\u73b0\u975e\u5e38\u76f4\u767d\u3002\u65e0\u975e\u662f\u7ed3\u5408 MO \u7684\u8fd0\u7ef4\u77e5\u8bc6\uff0c\u8c03\u7528 K8S \u7684 API \u7533\u8bf7\u5b58\u50a8\u3001\u90e8\u7f72\u5de5\u4f5c\u8d1f\u8f7d\u3001\u914d\u7f6e\u670d\u52a1\u53d1\u73b0\uff1b\u6216\u662f\u53cd\u8fc7\u6765\uff0c\u5728 API \u5904\u4e8e\u5220\u9664\u9636\u6bb5\u65f6\uff0c\u5c06\u521b\u5efa\u7684\u5916\u90e8\u8d44\u6e90\u5168\u90e8\u9500\u6bc1\u3002\u5bf9\u8c61\u7684\u66f4\u65b0\u540e\u7684\u8c03\u8c10\u64cd\u4f5c\u4e5f\u662f\u5e38\u89c4\u7684 diff \u903b\u8f91\uff0c\u4ee5 MatrixOneCluster \u7684\u3002cnSets \u5b57\u6bb5\u4e3a\u4f8b\uff0c\u8c03\u8c10\u6d41\u7a0b\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u4f2a\u4ee3\u7801\u8868\u793a\uff1a
func sync(c MatrixOneCluster) {\n existingCNSets := \u6536\u96c6\u8fd9\u4e2a\u96c6\u7fa4\u7684\u6240\u6709CNSet\n for _, desired := range c.spec.CNSets {\n cnSet := \u6784\u5efaCNSet(desired)\n if _, ok := existingCNSets[cnSet.Name]; ok {\n // 1. CNSet \u5b58\u5728\uff0c\u66f4\u65b0 CNSet\n ....\n // 2. \u6807\u8bb0\u8fd9\u4e2a cnSet \u662f\u671f\u671b\u72b6\u6001\u4e2d\u9700\u8981\u7684\n delete(existingCNSets, cnSet.Name)\n } else {\n // CNSet \u4e0d\u5b58\u5728\uff0c\u521b\u5efa\n ....\n }\n }\n for _, orphan := range existingCNSets {\n // \u5bf9\u4e8e\u5b9e\u9645\u5b58\u5728\u4f46\u671f\u671b\u72b6\u6001\u4e2d\u4e0d\u5b58\u5728\u7684 CNSet\uff0c\u8fdb\u884c\u6e05\u7406\n }\n}\n
\u6bd4\u8f83\u5bb9\u6613\u51fa\u9519\u7684\u662f ConfigMap / Secret \u7684\u66f4\u65b0\u903b\u8f91\uff0cMO \u548c\u5f88\u591a\u5e94\u7528\u4e00\u6837\uff0c\u9700\u8981\u914d\u7f6e\u6587\u4ef6\u5e76\u4e14\u6bcf\u6b21\u914d\u7f6e\u66f4\u65b0\u65f6\u9700\u8981\u91cd\u542f\u91cd\u65b0\u8bfb\u53d6\u914d\u7f6e\uff0c\u800c\u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u7528 K8S \u539f\u751f\u7684 ConfigMap \u5bf9\u8c61\u8fdb\u884c\u5b58\u50a8\u3002\u6709\u4e00\u4e2a\u5bb9\u6613\u8e29\u5751\u7684\u5730\u65b9\u5728\u4e8e ConfigMap \u5bf9\u8c61\u7684\u5185\u5bb9\u662f\u53ef\u53d8\u7684\uff0c\u800c\u5927\u90e8\u5206\u5e94\u7528\u5f80\u5f80\u53ea\u5728\u542f\u52a8\u65f6\u8bfb\u53d6\u4e00\u6b21 ConfigMap \u5185\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u540e\u7eed\u4e0d\u4f1a\u518d reload\u3002\u56e0\u6b64\uff0c\u67e5\u770b Pod \u5f53\u524d\u5f15\u7528\u7684 ConfigMap \u5185\u7684\u5185\u5bb9\u5e76\u4e0d\u80fd\u786e\u5b9a Pod \u76ee\u524d\u4f7f\u7528\u7684\u914d\u7f6e\uff08\u6709\u53ef\u80fd\u5728\u542f\u52a8\u540e ConfigMap \u5185\u5bb9\u53d1\u751f\u4e86\u53d8\u5316\uff09\u3002\u53e6\u5916\uff0c\u5047\u5982\u60f3\u5728 ConfigMap \u53d8\u5316\u540e\u6eda\u52a8\u66f4\u65b0\u5e94\u7528\uff0c\u4e00\u4e2a\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u5c06 ConfigMap \u7684\u5185\u5bb9\u505a\u4e00\u4e2a Hash \u586b\u5230 PodTemplate \u7684 Annotation \u4e2d\uff0c\u6bcf\u6b21\u66f4\u65b0 ConfigMap \u53d8\u5316\u540e\u66f4\u65b0\u8fd9\u4e2a Annotation \u89e6\u53d1\u5e94\u7528\u7684\u6eda\u52a8\u66f4\u65b0\u3002\u4f46\u8fd9\u79cd\u505a\u6cd5\u4e5f\u4f1a\u56e0\u4e3a\u539f\u5730\u4fee\u6539 ConfigMap \u800c\u51fa\u73b0\u975e\u9884\u671f\u7684\u60c5\u51b5\uff1a
\u4ee5\u4e0a\u56fe\u4e3a\u4f8b\uff0c\u5047\u8bbe Annotation \u4e2d\u7684 ConfigMap Hash \u4ece 123 \u66f4\u65b0\u6210\u4e86 321\uff0c\u800c 321 \u542f\u52a8\u540e\u56e0\u4e3a ConfigMap \u914d\u7f6e\u6709\u95ee\u9898\u800c\u65e0\u6cd5 Ready\uff0c\u8fd9\u65f6\u5019\u5728\u5408\u9002\u7684\u7b56\u7565\u914d\u7f6e\u4e0b\uff0c\u6eda\u52a8\u66f4\u65b0\u4f1a\u5361\u4f4f\u907f\u514d\u6545\u969c\u8303\u56f4\u6269\u5927\u3002\u7136\u800c\uff0c\u5c1a\u672a\u66f4\u65b0\u7684 Pod \u5185\u4e5f\u5df2\u7ecf\u8bfb\u5230\u4e86\u65b0\u7248\u672c\u7684 ConfigMap\uff0c\u53ea\u8981\u53d1\u751f\u4e00\u6b21\u5bb9\u5668\u91cd\u542f\u6216 Pod \u91cd\u5efa\uff0c\u5c31\u4f1a\u7acb\u523b\u53d1\u751f\u95ee\u9898\u3002\u8fd9\u548c\u66f4\u65b0\u955c\u50cf\u6216\u5176\u4ed6\u5b57\u6bb5\u7684\u884c\u4e3a\u663e\u7136\u4e0d\u4e00\u6837\uff0c\u66f4\u65b0\u5176\u4ed6\u5b57\u6bb5\u65f6\uff0c\u7eff\u8272\u7684 Pod \u8fd8\u5c5e\u4e8e\u65e7\u7684 ReplicaSet/ControllerRevision\uff0c\u91cd\u542f\u6216\u91cd\u5efa\u90fd\u4e0d\u4f1a\u4f7f\u7528\u65b0\u7248\u672c\u7684\u914d\u7f6e\u542f\u52a8\uff0c\u6545\u969c\u8303\u56f4\u662f\u53ef\u63a7\u7684\u3002
\u95ee\u9898\u7684\u6839\u6e90\u5728\u4e8e ConfigMap \u7684\u5185\u5bb9\u5e76\u4e0d\u5728 Pod \u7684 spec \u5185\uff0c\u76f4\u63a5\u4fee\u6539 ConfigMap \u7684\u5185\u5bb9\u548c Pod \u7684\u4e0d\u53ef\u53d8\u57fa\u7840\u8bbe\u65bd\u539f\u5219\u662f\u51b2\u7a81\u7684\u3002
\u56e0\u6b64\uff0cMatrixOne-Operator \u4e2d\u5c06\u6240\u6709 Pod \u5185\u4f1a\u5f15\u7528\u7684\u5bf9\u8c61\u90fd\u8bbe\u8ba1\u6210\u4e0d\u53ef\u53d8\u7684\uff0c\u4ee5 ConfigMap \u4e3a\u4f8b\uff0c\u6bcf\u6b21\u901a\u8fc7 CRD \u66f4\u65b0\u67d0\u4e2a\u7ec4\u4ef6\u7684\u914d\u7f6e\uff0cMatrixOne-Operator \u90fd\u4f1a\u751f\u6210\u4e00\u4e2a\u65b0\u7684 ConfigMap \u5e76\u5c06\u7ec4\u4ef6\u7684\u6240\u6709\u526f\u672c\u6eda\u52a8\u66f4\u65b0\u5230\u8fd9\u4e2a\u65b0\u7684 ConfigMap \u4e0a\uff1a
\u57fa\u4e8e\u8fd9\u4e2a\u539f\u5219\uff0c\u4efb\u610f\u65f6\u523b\u6211\u4eec\u90fd\u53ef\u4ee5\u901a\u8fc7\u5f53\u524d\u7684 Pod Spec \u660e\u786e\u6240\u6709 Pod \u5185\u7684\u4fe1\u606f\u3002\u6eda\u52a8\u66f4\u65b0\u7684\u95ee\u9898\u4e5f\u8fce\u5203\u800c\u89e3\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_2","title":"\u5e94\u7528\u72b6\u6001\u7ba1\u7406","text":"\u9664\u4e86\u5e94\u7528\u672c\u8eab\u7684\u751f\u547d\u5468\u671f\u7ba1\u7406\u5916\uff0cMatrixOne-Operator \u8fd8\u6709\u4e00\u4e2a\u91cd\u8981\u804c\u8d23\u662f\u7ba1\u7406\u5e94\u7528\u672c\u8eab\u7684\u72b6\u6001\u3002\u4f46\u662f\uff0c\u5206\u5e03\u5f0f\u7cfb\u7edf\u901a\u5e38\u90fd\u4f1a\u57fa\u4e8e\u5fc3\u8df3\u6216\u7c7b\u4f3c\u7684\u673a\u5236\u7ba1\u7406\u81ea\u8eab\u7684\u5e94\u7528\u72b6\u6001\uff0c\u4e3a\u4ec0\u4e48 Operator \u4e2d\u8fd8\u8981\u591a\u6b64\u4e00\u4e3e\u5462\uff1f
\u539f\u56e0\u5728\u4e8e Operator \u7684\u4ee3\u7801\u5185\u62e5\u6709\u5173\u4e8e\u81ea\u52a8\u5316\u8fd0\u7ef4\u7684\u77e5\u8bc6\uff0c\u6bd4\u5982 Operator \u660e\u786e\u5730\u77e5\u9053\u5728\u6eda\u52a8\u66f4\u65b0\u8fc7\u7a0b\u4e2d\u63a5\u4e0b\u6765\u54ea\u4e00\u4e2a Pod \u8981\u88ab\u91cd\u5efa/\u91cd\u542f\u4e86\u3002\u56e0\u6b64\u53ef\u4ee5\u63d0\u524d\u8c03\u6574\u5e94\u7528\u5185\u7684\u72b6\u6001\uff0c\u6bd4\u5982\u5c06 Pod \u4e0a\u7684\u8d1f\u8f7d\u8fdb\u884c\u8fc1\u79fb\uff0c\u6700\u5c0f\u5316\u6eda\u52a8\u66f4\u65b0\u7684\u5f71\u54cd\u3002\u8fd9\u7c7b\u5e94\u7528\u72b6\u6001\u7684\u7ba1\u7406\u903b\u8f91\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u5b9e\u73b0\u65b9\u5f0f\uff1a
\u501f\u52a9 Pod \u672c\u8eab\u7684\u5404\u7c7b\u751f\u547d\u5468\u671f\u94a9\u5b50\uff0c\u6bd4\u5982 InitContainer\u3001PostStart Hook \u548c PreStop Hook\uff0c\u5728\u8fd9\u4e9b\u94a9\u5b50\u5185\u540c\u6b65\u5e94\u7528\u72b6\u6001\u3002
\u5728 Operator \u7684\u8c03\u8c10\u5faa\u73af\u5185\u8c03\u7528\u5e94\u7528\u63a5\u53e3\u8c03\u6574\u5e94\u7528\u72b6\u6001\u3002
\u65b9\u5f0f\u4e00\u5b9e\u73b0\u8d77\u6765\u6bd4\u8f83\u7b80\u5355\uff0c\u65b9\u5f0f\u4e8c\u66f4\u81ea\u6d3b\u81ea\u7531\uff0c\u80fd\u66f4\u597d\u5730\u5e94\u5bf9\u590d\u6742\u573a\u666f\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5728\u7f29\u5bb9 CNSet \u65f6\uff0c\u8981\u5148\u5c06\u88ab\u7f29\u5bb9\u7684 CN Pod \u4e0a\u7684 session \u8fc1\u79fb\u5230\u5176\u4ed6 CN Pod \u4e0a\u518d\u505c\u6b62 CN Pod\u3002\u5047\u5982\u8fd9\u4e2a\u64cd\u4f5c\u653e\u5728 Pod PreStop Hook \u4e2d\uff0c\u90a3\u5c31\u662f\u65e0\u6cd5\u64a4\u9500\u7684\u3002\u800c\u5b9e\u9645\u573a\u666f\u4e2d\uff0c\u786e\u5b9e\u5b58\u5728\u4e00\u7ec4 CN \u5148\u88ab\u7f29\u5bb9\uff0c\u5728\u7f29\u5bb9\u5b8c\u6210\u524d\u53c8\u518d\u6269\u5bb9\u4e0a\u53bb\u7684\u573a\u666f\uff08\u5c24\u5176\u662f\u5728\u5f00\u542f\u4e86\u81ea\u52a8\u4f38\u7f29\u540e\uff09\uff0c\u8fd9\u65f6\u5019\uff0cOperator \u5185\u7684\u8c03\u8c10\u5faa\u73af\u5c31\u53ef\u4ee5\u8ba1\u7b97\u51fa\u6b64\u65f6\u53ef\u4ee5\u76f4\u63a5\u590d\u7528\u4ecd\u7136\u5728\u4e0b\u7ebf\u4e2d\u7684 CN\uff0c\u8c03\u7528 MO \u5185\u90e8\u7684\u7ba1\u7406\u63a5\u53e3\u5c06 CN \u5c06\u8fd9\u4e2a CN \u91cd\u65b0\u6062\u590d\u6210\u670d\u52a1\u72b6\u6001\uff0c\u4e0d\u518d\u5411\u5176\u4ed6 CN \u8fc1\u79fb session \u5e76\u4e14\u91cd\u65b0\u5411 Proxy \u63a5\u53d7\u65b0 session\uff0c\u800c\u4e0d\u9700\u8981\u518d\u6269\u5bb9\u51fa\u4e00\u4e2a\u65b0\u7684 CN\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_3","title":"\u603b\u7ed3","text":"\u4f5c\u4e3a\u6269\u5c55 K8S \u7f16\u6392\u80fd\u529b\u7684\u4e3b\u6d41\u9009\u9879\uff0cOperator \u6a21\u5f0f\u53d1\u5c55\u5230\u4eca\u5929\u5df2\u7ecf\u62e5\u6709\u6210\u719f\u7684\u57fa\u7840\u5e93\u548c\u5de5\u5177\u94fe\uff0c\u793e\u533a\u4e2d\u4e5f\u6709\u5927\u91cf\u7684\u6210\u719f\u5f00\u6e90\u9879\u76ee\u53ef\u4f9b\u53c2\u8003\uff0c\u5728 K8S \u4e0a\u5f00\u53d1\u4e00\u4e2a Operator \u5df2\u7ecf\u4e0d\u518d\u662f\u4e00\u4e2a\u65b0\u9c9c\u7684\u8bdd\u9898\u3002\u4f46\u771f\u6b63\u7684\u590d\u6742\u5ea6\u6c38\u8fdc\u85cf\u5728\u5b9e\u9645\u4e1a\u52a1\u7684\u7ec6\u8282\u4e2d\uff0c\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u9700\u8981\u5bf9\u7ed3\u5408\u5bf9 K8S \u548c\u81ea\u8eab\u4e1a\u52a1\u7cfb\u7edf\u9886\u57df\u77e5\u8bc6\u7684\u5145\u5206\u7406\u89e3\u3002MatrixOne \u4f5c\u4e3a\u4e00\u6b3e\u4e91\u539f\u751f\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u5176\u4e2d\u5f88\u591a\u8bbe\u8ba1\u7406\u5ff5\u548c\u9886\u57df\u77e5\u8bc6\u4e0e\u5176\u4ed6\u4e91\u539f\u751f\u7cfb\u7edf\u5b58\u5728\u5171\u901a\u4e4b\u5904\u3002\u5e0c\u671b\u8fd9\u7bc7\u77ed\u6587\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u4f60\u4e86\u89e3 mo-operator \u7684\u8bbe\u8ba1\u5b9e\u73b0\uff0c\u4e5f\u80fd\u7ed9\u4f60\u5728\u8bbe\u8ba1\u81ea\u5df1\u7684 Operator \u65f6\u63d0\u4f9b\u7ecf\u9a8c\u53c2\u8003\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_4","title":"\u53c2\u8003\u6587\u6863","text":"\u82e5\u5982\u60f3\u8981\u4e86\u89e3\u5173\u4e8e MatrixOne-Operator \u7684\u90e8\u7f72\u8fd0\u7ef4\uff0c\u8bf7\u53c2\u89c1\u7ae0\u8282 Operator \u7ba1\u7406
"},{"location":"MatrixOne/Overview/architecture/architecture-proxy/","title":"Proxy \u67b6\u6784\u8be6\u89e3","text":"Proxy \u4f5c\u4e3a MatrixOne \u4e2d\u627f\u62c5\u8d1f\u8f7d\u5747\u8861\u4e0e SQL \u8bf7\u6c42\u5206\u53d1\u7684\u552f\u4e00\u7ec4\u4ef6\uff0c\u901a\u8fc7\u5c06 CN \u5206\u7ec4\u6807\u7b7e\u7684\u65b9\u5f0f\uff0c\u642d\u914d Proxy \u7684 SQL \u5206\u53d1\uff0c\u5b9e\u73b0\u4f1a\u8bdd\u7ea7\u522b\u7684 SQL \u8def\u7531\u529f\u80fd\uff0c\u4ece\u800c\u9002\u914d\u591a\u79cd\u573a\u666f\u3002
\u5b83\u7684 SQL \u8bf7\u6c42\u5206\u53d1\u67b6\u6784\u56fe\u793a\u5982\u4e0b\uff1a
\u4f9d\u636e MatrixOne \u5b58\u50a8\u8ba1\u7b97\u5206\u79bb\u7684\u591a CN \u67b6\u6784\u4ee5\u53ca Proxy \u7684\u804c\u8d23\uff0c\u5728 HAKeeper \u4e0e Proxy \u4e2d\u5f15\u5165 CN \u6807\u7b7e\u7ec4\u7684\u6982\u5ff5\uff0c\u5373\u56fa\u5b9a\u540d\u79f0\u548c\u6570\u91cf\u7684 CN \u96c6\u5408\u3002
\u7531\u4e0a\u56fe\u6240\u793a\uff0c\u6280\u672f\u5b9e\u73b0\u6d41\u7a0b\u89e3\u6790\u5982\u4e0b\uff1a
yaml
\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u9009\u9879\uff08\u5305\u62ec\u914d\u7f6e\u3001\u526f\u672c\u6570\u548c\u79df\u6237\uff09\u521b\u5efa\u4e0d\u540c\u7684 CN \u6807\u7b7e\u3002Proxy \u7ec4\u4ef6\u901a\u8fc7\u8fde\u63a5\u4f1a\u8bdd\u53c2\u6570\u5224\u65ad\uff0c\u5c06\u67d0\u4e2a\u4f1a\u8bdd\u8f6c\u53d1\u7ed9\u76f8\u5e94\u7684 CN \u7ec4\uff0c\u5b9e\u73b0 SQL \u8def\u7531\u3002
\u5728\u540c\u4e00\u4e2a CN \u6807\u7b7e\u7ec4\u5185\uff0cProxy \u8d1f\u8d23\u7ec4\u5185\u8d1f\u8f7d\u5747\u8861\u3002
Proxy \u901a\u8fc7\u5206\u6790\u4f1a\u8bdd\u8bf7\u6c42\u4e2d\u7684\u53c2\u6570\u6765\u5224\u65ad\u8bf7\u6c42\u662f\u5426\u5339\u914d CN \u6807\u7b7e\u3002\u5728\u5b9e\u73b0 SQL \u8def\u7531\u65f6\uff0c\u4f1a\u8bdd\u53c2\u6570\u4f1a\u88ab\u7528\u4e8e\u67e5\u627e\u4e0e\u8bf7\u6c42\u5339\u914d\u7684 CN \u6807\u7b7e\u7ec4\u3002\u5177\u4f53\u6765\u8bf4\uff0cProxy \u53ef\u80fd\u4f1a\u68c0\u67e5 CN \u6807\u7b7e\u4e2d\u7684\u7279\u5b9a\u5b57\u6bb5\uff0c\u4f8b\u5982\u79df\u6237\u4fe1\u606f\u3001\u526f\u672c\u6570\u7b49\uff0c\u4ee5\u4fbf\u5c06\u8bf7\u6c42\u8def\u7531\u5230\u9002\u5f53\u7684 CN \u6807\u7b7e\u7ec4\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0cProxy \u53ef\u4ee5\u5b9e\u73b0\u4f1a\u8bdd\u8bf7\u6c42\u4e0e CN \u6807\u7b7e\u7684\u5339\u914d\uff0c\u5e76\u786e\u4fdd\u5c06\u8bf7\u6c42\u8def\u7531\u5230\u6b63\u786e\u7684 CN \u8282\u70b9\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-proxy/#_2","title":"\u53c2\u8003\u6587\u6863","text":"\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u5982\u4f55\u901a\u8fc7 Proxy \u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\uff0c\u53c2\u89c1\u4f7f\u7528 Proxy \u5b9e\u73b0\u79df\u6237\u548c\u8d1f\u8f7d\u72ec\u7acb\u8d44\u6e90\u7ba1\u7406
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/","title":"\u5b58\u50a8\u5f15\u64ce\u67b6\u6784\u8be6\u89e3","text":"MatrixOne \u7684\u5b58\u50a8\u5f15\u64ce\u79f0\u4e3a\u4e8b\u52a1\u5206\u6790\u5f15\u64ce\uff08Transactional Analytical Engine\uff0cTAE\uff09\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_2","title":"\u5b58\u50a8\u5f15\u64ce\u67b6\u6784","text":"TAE \u7684\u6700\u5c0f IO \u5355\u4f4d\u88ab\u79f0\u4e3a\u5217\u5757\uff08Column Block\uff09\uff0c\u76ee\u524d\u56fa\u5b9a\u884c\u6570\u8fdb\u884c\u7ec4\u7ec7\uff0c\u5bf9\u4e8e Blob \u7c7b\u578b\u7684\u5217\uff0c\u6211\u4eec\u8fdb\u884c\u4e86\u7279\u522b\u7684\u5904\u7406\u3002
TAE \u4ee5\u8868\u7684\u5f62\u5f0f\u7ec4\u7ec7\u6570\u636e\uff0c\u6bcf\u4e2a\u8868\u7684\u6570\u636e\u7ed3\u6784\u5316\u4e3a\u4e00\u4e2a LSM\uff08Log-structured Merge-tree\uff09\u6811\u3002\u5f53\u524d TAE \u7684\u5b9e\u73b0\u662f\u4e00\u4e2a\u4e09\u5c42 LSM \u6811\uff0c\u5305\u62ec L0\u3001L1 \u548c L2\u3002\u5176\u4e2d\uff0cL0 \u89c4\u6a21\u8f83\u5c0f\uff0c\u5168\u90e8\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u800c L1 \u548c L2 \u5219\u6301\u4e45\u5316\u5b58\u50a8\u5728\u786c\u76d8\u4e0a\u3002
\u5728 TAE \u4e2d\uff0cL0 \u7531\u88ab\u79f0\u4e3a\u4e34\u65f6\u5757\uff08Transient Block\uff09\u7684\u7ec4\u4ef6\u7ec4\u6210\uff0c\u6570\u636e\u5728\u6b64\u5e76\u672a\u8fdb\u884c\u6392\u5e8f\u3002\u800c L1 \u7531\u5df2\u6392\u5e8f\u5757\uff08Sorted Block\uff09\u7ec4\u6210\uff0c\u5305\u542b\u4e86\u5df2\u7ecf\u6392\u5e8f\u7684\u6570\u636e\u3002\u65b0\u7684\u6570\u636e\u603b\u662f\u88ab\u63d2\u5165\u5230\u6700\u65b0\u7684\u4e34\u65f6\u5757\u4e2d\u3002\u5f53\u63d2\u5165\u7684\u6570\u636e\u4f7f\u5f97\u8be5\u5757\u7684\u884c\u6570\u8d85\u8fc7\u9650\u5236\u65f6\uff0c\u8be5\u5757\u5c06\u8fdb\u884c\u4e3b\u952e\u6392\u5e8f\u540e\u4f5c\u4e3a\u4e00\u4e2a\u5df2\u6392\u5e8f\u5757\u5237\u65b0\u5230 L1\u3002\u5982\u679c\u5df2\u6392\u5e8f\u7684\u5757\u6570\u91cf\u8d85\u8fc7\u4e00\u4e2a\u6bb5\uff08Segment\uff09\u7684\u6700\u5927\u6570\u91cf\uff0c\u4f1a\u4f7f\u7528\u5408\u5e76\u6392\u5e8f\uff08Merge Sort\uff09\u65b9\u6cd5\u6309\u4e3b\u952e\u6392\u5e8f\u5e76\u5199\u5165 L2\u3002
L1 \u548c L2 \u5b58\u50a8\u7684\u90fd\u662f\u6309\u4e3b\u952e\u6392\u5e8f\u7684\u6570\u636e\u3002\u8fd9\u4e24\u5c42\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\uff0cL1 \u786e\u4fdd\u5757\u5185\u90e8\u7684\u6570\u636e\u6309\u4e3b\u952e\u6392\u5e8f\uff0c\u800c L2 \u786e\u4fdd\u6bcf\u4e2a\u6bb5\u5185\u7684\u6570\u636e\u6309\u4e3b\u952e\u6392\u5e8f\u3002\u8fd9\u91cc\u7684\u6bb5\u662f\u4e00\u4e2a\u903b\u8f91\u6982\u5ff5\uff0c\u7b49\u540c\u4e8e\u5176\u4ed6\u5b9e\u73b0\u4e2d\u7684\u884c\u7ec4\uff08Row Group\uff09\u6216\u884c\u96c6\uff08Row Set\uff09\u7b49\u3002\u4e00\u4e2a\u6bb5\u53ef\u4ee5\u6839\u636e\u66f4\u65b0\uff08\u5220\u9664\uff09\u64cd\u4f5c\u7684\u591a\u5c11\u8fdb\u884c\u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u6bb5\u3002\u540c\u65f6\uff0c\u4e5f\u53ef\u4ee5\u5c06\u591a\u4e2a\u6bb5\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u6bb5\u3002\u8fd9\u4e9b\u64cd\u4f5c\u90fd\u662f\u7531\u540e\u53f0\u7684\u5f02\u6b65\u4efb\u52a1\u5b8c\u6210\uff0c\u5176\u8c03\u5ea6\u7b56\u7565\u4e3b\u8981\u6743\u8861\u5199\u653e\u5927\u548c\u8bfb\u653e\u5927\u4e4b\u95f4\u7684\u5173\u7cfb\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_3","title":"\u529f\u80fd\u7279\u6027","text":"TAE\uff0c\u5982\u4f20\u7edf\u5217\u5b58\u50a8\u5f15\u64ce\u4e00\u6837\uff0c\u5728\u5757\uff08Block\uff09\u548c\u6bb5\uff08Segment\uff09\u7ea7\u522b\u5f15\u5165\u4e86 Zonemap\uff08\u6700\u5c0f/\u6700\u5927\u6570\u636e\uff09\u4fe1\u606f\u3002\u4f5c\u4e3a\u4e00\u4e2a\u652f\u6301\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u7684\u5b58\u50a8\u5f15\u64ce\uff0cTAE \u5b9e\u73b0\u4e86\u5b8c\u6574\u7684\u4e3b\u952e\u7ea6\u675f\u529f\u80fd\uff0c\u5305\u62ec\u652f\u6301\u591a\u5217\u4e3b\u952e\u548c\u5168\u5c40\u81ea\u589e ID\u3002\u6bcf\u4e2a\u8868\u7684\u4e3b\u952e\u90fd\u4f1a\u9ed8\u8ba4\u521b\u5efa\u4e00\u4e2a\u4e3b\u952e\u7d22\u5f15\uff0c\u4e3b\u8981\u7528\u4e8e\u63d2\u5165\u6570\u636e\u65f6\u53bb\u91cd\u4ee5\u6ee1\u8db3\u4e3b\u952e\u7ea6\u675f\uff0c\u4ee5\u53ca\u6839\u636e\u4e3b\u952e\u8fdb\u884c\u8fc7\u6ee4\u3002
\u4e3b\u952e\u53bb\u91cd\u662f\u6570\u636e\u63d2\u5165\u7684\u5173\u952e\u6b65\u9aa4\uff0cTAE \u5728\u4ee5\u4e0b\u4e09\u4e2a\u65b9\u9762\u8fbe\u5230\u5e73\u8861\u6548\u679c\uff1a
\u4ece\u7d22\u5f15\u7c92\u5ea6\u6765\u770b\uff0cTAE \u53ef\u4ee5\u5206\u4e3a\u4e24\u7c7b\uff1a\u8868\u7ea7\u7d22\u5f15\u548c\u6bb5\u7ea7\u7d22\u5f15\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u6709\u4e00\u4e2a\u8868\u7ea7\u7d22\u5f15\uff0c\u6216\u8005\u6bcf\u4e2a\u6bb5\u90fd\u6709\u4e00\u4e2a\u7d22\u5f15\u3002\u7531\u4e8e TAE \u7684\u8868\u6570\u636e\u7531\u591a\u4e2a\u6bb5\u7ec4\u6210\uff0c\u6bcf\u4e2a\u6bb5\u7684\u6570\u636e\u90fd\u4f1a\u7ecf\u5386\u4ece L1 \u5230 L3\uff0c\u4ece\u65e0\u5e8f\u5230\u6709\u5e8f\u7684\u538b\u7f29/\u5408\u5e76\u8fc7\u7a0b\uff0c\u8fd9\u5bf9\u8868\u7ea7\u7d22\u5f15\u4e0d\u53cb\u597d\uff0c\u56e0\u6b64\uff0cTAE \u7684\u7d22\u5f15\u5efa\u7acb\u5728\u6bb5\u7ea7\u3002
\u5728\u6bb5\u7ea7\u7d22\u5f15\u4e2d\uff0c\u6709\u4e24\u79cd\u7c7b\u578b\u7684\u6bb5\uff0c\u4e00\u79cd\u53ef\u4ee5\u8fdb\u884c\u8ffd\u52a0\u4fee\u6539\uff0c\u53e6\u4e00\u79cd\u4e0d\u53ef\u4fee\u6539\u3002\u5bf9\u4e8e\u4e0d\u53ef\u4fee\u6539\u7684\u6bb5\uff0c\u6bb5\u7ea7\u7d22\u5f15\u662f\u4e00\u4e2a\u5305\u542b Bloomfilter \u548c Zonemap \u7684\u4e24\u7ea7\u7ed3\u6784\u3002\u5bf9\u4e8e\u53ef\u8ffd\u52a0\u4fee\u6539\u7684\u6bb5\uff0c\u5b83\u81f3\u5c11\u7531\u4e00\u4e2a\u53ef\u8ffd\u52a0\u7684\u5757\u548c\u591a\u4e2a\u4e0d\u53ef\u8ffd\u52a0\u7684\u5757\u7ec4\u6210\u3002\u53ef\u8ffd\u52a0\u7684\u5757\u7d22\u5f15\u662f\u4e00\u4e2a\u5e38\u9a7b\u5185\u5b58\u7684 ART-tree\uff08Adaptive Radix Tree\uff09\u7ed3\u6784\u548c Zonemap\uff0c\u800c\u4e0d\u53ef\u8ffd\u52a0\u7684\u5219\u662f Bloomfilter \u548c Zonemap\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_5","title":"\u7f13\u5b58\u533a\u7ba1\u7406","text":"\u5728\u7a33\u5b9a\u7684\u5b58\u50a8\u5f15\u64ce\u4e2d\uff0c\u7cbe\u7ec6\u7684\u5185\u5b58\u7ba1\u7406\u79bb\u4e0d\u5f00\u7f13\u5b58\u533a\u7ba1\u7406\u3002\u867d\u7136\u7f13\u5b58\u533a\u7ba1\u7406\u5728\u7406\u8bba\u4e0a\u53ea\u662f\u4e00\u4e2a\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\uff08LRU\uff09\u7f13\u5b58\u7684\u6982\u5ff5\uff0c\u4f46\u6570\u636e\u5e93\u4e0d\u4f1a\u76f4\u63a5\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u9875\u7f13\u5b58\uff08Page Cache\uff09\u6765\u4ee3\u66ff\u7f13\u5b58\u7ba1\u7406\u5668\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u7c7b\u578b\u7684\u6570\u636e\u5e93\u3002
\u5728 MatrixOne \u4e2d\uff0c\u4f7f\u7528\u7f13\u5b58\u7ba1\u7406\u5668\u5bf9\u5185\u5b58\u7f13\u51b2\u533a\u8fdb\u884c\u7ba1\u7406\u3002\u6bcf\u4e2a\u7f13\u51b2\u533a\u8282\u70b9\uff08buffer node\uff09\u5177\u6709\u56fa\u5b9a\u7684\u5927\u5c0f\uff0c\u5e76\u5206\u914d\u7ed9\u4ee5\u4e0b\u56db\u4e2a\u533a\u57df\uff1a
\u6bcf\u4e2a\u7f13\u51b2\u533a\u8282\u70b9\u90fd\u6709 Loaded \u548c Unloaded \u4e24\u79cd\u72b6\u6001\u3002\u5f53\u7528\u6237\u8981\u6c42\u7f13\u5b58\u7ba1\u7406\u5668\u5bf9\u8282\u70b9\u8fdb\u884c\u56fa\u5b9a\uff08Pin\uff09\u64cd\u4f5c\u65f6\uff0c\u5982\u679c\u8282\u70b9\u5904\u4e8e Loaded \u72b6\u6001\uff0c\u5f15\u7528\u8ba1\u6570\u4f1a\u589e\u52a0 1\uff1b\u5982\u679c\u8282\u70b9\u5904\u4e8e Unloaded \u72b6\u6001\uff0c\u5b83\u4f1a\u4ece\u786c\u76d8\u6216\u8fdc\u7a0b\u5b58\u50a8\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u5e76\u589e\u52a0\u8282\u70b9\u7684\u5f15\u7528\u8ba1\u6570\u3002\u5f53\u5185\u5b58\u7a7a\u95f4\u4e0d\u8db3\u65f6\uff0c\u7cfb\u7edf\u4f1a\u6309\u7167 LRU \u7b56\u7565\u4ece\u5185\u5b58\u4e2d\u79fb\u9664\u4e00\u4e9b\u8282\u70b9\uff0c\u4ee5\u91ca\u653e\u7a7a\u95f4\u3002\u5f53\u7528\u6237\u53d6\u6d88\u5bf9\u8282\u70b9\u7684\u56fa\u5b9a\uff08Unpin\uff09\u65f6\uff0c\u53ea\u9700\u5173\u95ed\u8282\u70b9\u53e5\u67c4\u3002\u5982\u679c\u5f15\u7528\u8ba1\u6570\u4e3a 0\uff0c\u8be5\u8282\u70b9\u5c06\u6210\u4e3a\u53ef\u80fd\u88ab\u79fb\u9664\u7684\u5019\u9009\u8282\u70b9\uff1b\u5982\u679c\u5f15\u7528\u8ba1\u6570\u5927\u4e8e 0\uff0c\u8be5\u8282\u70b9\u5c06\u4e0d\u4f1a\u88ab\u79fb\u9664\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_6","title":"\u9884\u5199\u65e5\u5fd7\u4e0e\u65e5\u5fd7\u56de\u653e","text":"\u5728 TAE \u4e2d\uff0c\u6211\u4eec\u4f18\u5316\u4e86 redo log \u7684\u5904\u7406\u65b9\u5f0f\uff0c\u4f7f\u5f97\u5217\u5b58\u50a8\u5f15\u64ce\u7684\u9884\u5199\u65e5\u5fd7\uff08WAL\uff0cWrite Ahead Log\uff09\u8bbe\u8ba1\u66f4\u52a0\u9ad8\u6548\u3002\u76f8\u6bd4\u884c\u5b58\u50a8\u5f15\u64ce\uff0cTAE \u53ea\u9700\u8981\u5728\u4e8b\u52a1\u63d0\u4ea4\u65f6\u8bb0\u5f55 redo log\uff0c\u800c\u4e0d\u662f\u6bcf\u6b21\u5199\u64cd\u4f5c\u90fd\u8bb0\u5f55\u3002\u6211\u4eec\u5229\u7528\u7f13\u5b58\u7ba1\u7406\u5668\u964d\u4f4e\u4e86\u8f93\u5165\u8f93\u51fa\uff08IO\uff09\u7684\u4f7f\u7528\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u751f\u547d\u5468\u671f\u77ed\u4e14\u53ef\u80fd\u9700\u8981\u56de\u6eda\u7684\u4e8b\u52a1\uff0c\u6211\u4eec\u907f\u514d\u4e86 IO \u4e8b\u4ef6\u7684\u53d1\u751f\u3002\u6b64\u5916\uff0cTAE \u8fd8\u80fd\u591f\u652f\u6301\u5927\u578b\u6216\u957f\u65f6\u95f4\u7684\u4e8b\u52a1\u3002
TAE \u7684\u9884\u5199\u65e5\u5fd7\u91c7\u7528\u4ee5\u4e0b\u683c\u5f0f\u7684\u65e5\u5fd7\u6761\u76ee\u5934\u90e8\uff08Log Entry Header\uff09\uff1a
\u9879\u76ee \u5b57\u8282\u5927\u5c0f GroupID 4 LSN 8 \u957f\u5ea6 8 \u7c7b\u578b 1\u4e8b\u52a1\u65e5\u5fd7\u6761\u76ee\u5305\u62ec\u4ee5\u4e0b\u7c7b\u578b\uff1a
\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u503c \u8bf4\u660e AC int8 0x10 \u5df2\u63d0\u4ea4\u4e8b\u52a1\u7684\u5b8c\u6574\u5199\u64cd\u4f5c PC int8 0x11 \u5df2\u63d0\u4ea4\u4e8b\u52a1\u7684\u90e8\u5206\u5199\u64cd\u4f5c UC int8 0x12 \u672a\u63d0\u4ea4\u4e8b\u52a1\u7684\u90e8\u5206\u5199\u64cd\u4f5c RB int8 0x13 \u4e8b\u52a1\u56de\u6eda CKP int8 0x40 \u68c0\u67e5\u70b9\u5927\u90e8\u5206\u4e8b\u52a1\u53ea\u6709\u4e00\u4e2a\u65e5\u5fd7\u6761\u76ee\uff0c\u4f46\u66f4\u5927\u6216\u66f4\u957f\u7684\u4e8b\u52a1\u53ef\u80fd\u9700\u8981\u8bb0\u5f55\u591a\u4e2a\u65e5\u5fd7\u6761\u76ee\u3002\u56e0\u6b64\uff0c\u4e00\u4e2a\u4e8b\u52a1\u7684\u65e5\u5fd7\u53ef\u80fd\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a UC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\u548c\u4e00\u4e2a PC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\uff0c\u6216\u8005\u53ea\u6709\u4e00\u4e2a AC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\u3002UC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\u88ab\u5206\u914d\u5230\u4e00\u4e2a\u4e13\u95e8\u7684\u7ec4\u3002
\u5728 TAE \u4e2d\uff0c\u4e8b\u52a1\u65e5\u5fd7\u6761\u76ee\u7684\u6709\u6548\u8f7d\u8377\uff08Payload\uff09\u5305\u542b\u591a\u4e2a\u4e8b\u52a1\u8282\u70b9\u3002\u4e8b\u52a1\u8282\u70b9\u5305\u62ec\u6570\u636e\u64cd\u4f5c\u8bed\u8a00\uff08DML\uff09\u7684\u5220\u9664\u3001\u6dfb\u52a0\u3001\u66f4\u65b0\u64cd\u4f5c\uff0c\u4ee5\u53ca\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff08DDL\uff09\u7684\u521b\u5efa/\u5220\u9664\u8868\u3001\u521b\u5efa/\u5220\u9664\u6570\u636e\u5e93\u7b49\u3002\u6bcf\u4e2a\u4e8b\u52a1\u8282\u70b9\u90fd\u662f\u5df2\u63d0\u4ea4\u65e5\u5fd7\u6761\u76ee\u7684\u5b50\u9879\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u4e8b\u52a1\u65e5\u5fd7\u7684\u4e00\u90e8\u5206\u3002\u6d3b\u52a8\u4e8b\u52a1\u7684\u8282\u70b9\u5171\u4eab\u56fa\u5b9a\u5927\u5c0f\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5e76\u7531\u7f13\u5b58\u7ba1\u7406\u5668\u8fdb\u884c\u7ba1\u7406\u3002\u5f53\u5269\u4f59\u7a7a\u95f4\u4e0d\u8db3\u65f6\uff0c\u90e8\u5206\u4e8b\u52a1\u8282\u70b9\u4f1a\u88ab\u5378\u8f7d\uff08Unload\uff09\uff0c\u5e76\u5c06\u76f8\u5e94\u7684\u65e5\u5fd7\u6761\u76ee\u4fdd\u5b58\u5728 Redo Log \u4e2d\u3002\u5728\u52a0\u8f7d\u65f6\uff0c\u8fd9\u4e9b\u65e5\u5fd7\u6761\u76ee\u4f1a\u88ab\u56de\u653e\uff0c\u5373\u5e94\u7528\u5230\u76f8\u5e94\u7684\u4e8b\u52a1\u8282\u70b9\u4e2d\u3002
Checkpoint \u662f\u4e00\u79cd\u5b89\u5168\u70b9\uff0c\u5728\u7cfb\u7edf\u91cd\u542f\u671f\u95f4\uff0c\u72b6\u6001\u673a\u53ef\u4ee5\u4ece\u8be5\u70b9\u5f00\u59cb\u5e94\u7528\u65e5\u5fd7\u6761\u76ee\u3002Checkpoint \u4e4b\u524d\u7684\u65e5\u5fd7\u6761\u76ee\u4e0d\u518d\u9700\u8981\uff0c\u5e76\u4f1a\u5728\u9002\u5f53\u7684\u65f6\u673a\u88ab\u7269\u7406\u9500\u6bc1\u3002TAE \u901a\u8fc7\u7ec4\uff08Group\uff09\u6765\u8bb0\u5f55\u6700\u540e\u4e00\u4e2a Checkpoint \u7684\u4fe1\u606f\uff0c\u4f7f\u5f97\u5728\u7cfb\u7edf\u91cd\u542f\u65f6\u53ef\u4ee5\u4ece\u6700\u540e\u4e00\u4e2a Checkpoint \u5f00\u59cb\u8fdb\u884c\u65e5\u5fd7\u56de\u653e\u3002
TAE \u7684 WAL \u548c\u65e5\u5fd7\u56de\u653e\u90e8\u5206\u5df2\u88ab\u72ec\u7acb\u62bd\u8c61\u4e3a\u4e00\u4e2a\u540d\u4e3a logstore \u7684\u4ee3\u7801\u6a21\u5757\u3002\u5b83\u63d0\u4f9b\u4e86\u5bf9\u5e95\u5c42\u65e5\u5fd7\u5b58\u53d6\u64cd\u4f5c\u7684\u62bd\u8c61\uff0c\u53ef\u4ee5\u9002\u914d\u4e0d\u540c\u7684\u5b9e\u73b0\uff0c\u4ece\u5355\u673a\u5230\u5206\u5e03\u5f0f\u3002\u5728\u7269\u7406\u5c42\u9762\uff0clogstore \u7684\u884c\u4e3a\u7c7b\u4f3c\u4e8e\u6d88\u606f\u961f\u5217\u3002\u4ece MatrixOne 0.6 \u7248\u672c\u5f00\u59cb\uff0c\u6211\u4eec\u5c06\u6f14\u8fdb\u4e3a\u4e91\u539f\u751f\u7248\u672c\uff0c\u5e76\u4f7f\u7528\u72ec\u7acb\u7684 shared log \u670d\u52a1\u4f5c\u4e3a\u65e5\u5fd7\u670d\u52a1\u3002\u56e0\u6b64\uff0c\u5728\u5c06\u6765\u7684\u7248\u672c\u4e2d\uff0cTAE \u7684 logstore \u5c06\u8fdb\u884c\u9002\u5f53\u7684\u4fee\u6539\uff0c\u76f4\u63a5\u8bbf\u95ee\u5916\u90e8\u7684 shared log \u670d\u52a1\uff0c\u800c\u4e0d\u4f9d\u8d56\u4e8e\u4efb\u4f55\u672c\u5730\u5b58\u50a8\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_7","title":"\u4e8b\u52a1\u5904\u7406","text":"TAE \u901a\u8fc7\u91c7\u7528\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff08MVCC\uff09\u673a\u5236\u6765\u4fdd\u8bc1\u4e8b\u52a1\u7684\u9694\u79bb\u6027\u3002\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u914d\u5907\u4e00\u4e2a\u7531\u4e8b\u52a1\u542f\u52a8\u65f6\u95f4\u51b3\u5b9a\u7684\u4e00\u81f4\u6027\u8bfb\u53d6\u89c6\u56fe\uff08\u8bfb\u89c6\u56fe\uff09\uff0c\u56e0\u6b64\u4e8b\u52a1\u5185\u90e8\u8bfb\u53d6\u7684\u6570\u636e\u6c38\u4e0d\u4f1a\u53cd\u6620\u5176\u4ed6\u5e76\u53d1\u4e8b\u52a1\u6240\u505a\u7684\u4fee\u6539\u3002TAE \u63d0\u4f9b\u4e86\u7ec6\u7c92\u5ea6\u7684\u4e50\u89c2\u5e76\u53d1\u63a7\u5236\uff0c\u5728\u5bf9\u540c\u4e00\u884c\u548c\u540c\u4e00\u5217\u8fdb\u884c\u66f4\u65b0\u64cd\u4f5c\u65f6\u624d\u53ef\u80fd\u53d1\u751f\u51b2\u7a81\u3002\u4e8b\u52a1\u4f7f\u7528\u7684\u662f\u5728\u4e8b\u52a1\u5f00\u59cb\u65f6\u5df2\u5b58\u5728\u7684\u503c\u7248\u672c\uff0c\u5e76\u5728\u8bfb\u53d6\u6570\u636e\u65f6\u4e0d\u5bf9\u5176\u8fdb\u884c\u52a0\u9501\u3002\u5f53\u4e24\u4e2a\u4e8b\u52a1\u8bd5\u56fe\u66f4\u65b0\u540c\u4e00\u4e2a\u503c\u65f6\uff0c\u7b2c\u4e8c\u4e2a\u4e8b\u52a1\u4f1a\u56e0\u4e3a\u5199 - \u5199\u51b2\u7a81\u800c\u5931\u8d25\u3002
\u5728 TAE \u7684\u67b6\u6784\u4e2d\uff0c\u4e00\u4e2a\u8868\u7531\u591a\u4e2a\u6bb5\u7ec4\u6210\uff0c\u6bcf\u4e2a\u6bb5\u662f\u591a\u4e2a\u4e8b\u52a1\u5171\u540c\u4ea7\u751f\u7684\u7ed3\u679c\u3002\u56e0\u6b64\uff0c\u4e00\u4e2a\u6bb5\u53ef\u4ee5\u8868\u793a\u4e3a $[T{start}, T{end}]$
\u3002$[T{start}
\u662f\u6700\u65e9\u4e8b\u52a1\u7684\u63d0\u4ea4\u65f6\u95f4\uff0cT{end}]$
\u662f\u6700\u65b0\u4e8b\u52a1\u7684\u63d0\u4ea4\u65f6\u95f4\u3002\u4e3a\u4e86\u80fd\u591f\u538b\u7f29\u6bb5\u5e76\u8fdb\u884c\u5408\u5e76\uff0c\u6211\u4eec\u9700\u8981\u5728\u6bb5\u7684\u8868\u793a\u4e2d\u589e\u52a0\u4e00\u4e2a\u7ef4\u5ea6\u4ee5\u533a\u5206\u7248\u672c\uff0c\u5373 $([T{start} T{end}]
\uff0c[T{create}, T{drop}])$
\u3002$T{create}$
\u662f\u6bb5\u7684\u521b\u5efa\u65f6\u95f4\uff0c$T{drop}$
\u662f\u6bb5\u7684\u5220\u9664\u65f6\u95f4\u3002\u5f53 $T{drop} = 0$
\u65f6\u8868\u793a\u8be5\u6bb5\u672a\u88ab\u4e22\u5f03\u3002\u5757\u7684\u8868\u793a\u65b9\u5f0f\u4e0e\u6bb5 $([T{start}, T{end}]
\uff0c[T{create}, T{drop}])$
\u76f8\u540c\u3002\u4e8b\u52a1\u63d0\u4ea4\u65f6\uff0c\u9700\u8981\u6839\u636e\u63d0\u4ea4\u65f6\u95f4\u6765\u83b7\u53d6\u5b83\u7684\u8bfb\u89c6\u56fe\uff1a$(Txn{commit} \\geqslant T{create})\\bigcap\uff08(T{drop}= 0)\\bigcup\uff08T{drop} > Txn{commit}))$
\u3002
\u6bb5\u7684\u751f\u6210\u548c\u53d8\u5316\u7531\u540e\u53f0\u5f02\u6b65\u4efb\u52a1\u5904\u7406\uff0c\u4e3a\u786e\u4fdd\u6570\u636e\u8bfb\u53d6\u7684\u4e00\u81f4\u6027\uff0cTAE \u5c06\u8fd9\u4e9b\u5f02\u6b65\u4efb\u52a1\u7eb3\u5165\u5230\u4e8b\u52a1\u5904\u7406\u6846\u67b6\u4e2d\uff0c\u5982\u4e0b\u4f8b\u6240\u793a\uff1a
L0 \u5c42\u7684\u5757 $Block1 {L0}$
\u5728 $t1$
\u65f6\u521b\u5efa\uff0c\u5b83\u5305\u542b\u4e86\u6765\u81ea $Txn1
\u3001Txn2
\u3001Txn3
\u3001Txn4$
\u7684\u6570\u636e\u3002$Block1 {L0}$
\u5728 $t11$
\u5f00\u59cb\u6392\u5e8f\uff0c\u5b83\u7684\u8bfb\u89c6\u56fe\u662f\u57fa\u7ebf\u52a0\u4e0a\u4e00\u4e2a\u672a\u63d0\u4ea4\u7684\u66f4\u65b0\u8282\u70b9\u3002\u6392\u5e8f\u548c\u6301\u4e45\u5316\u5757\u53ef\u80fd\u9700\u8981\u8f83\u957f\u65f6\u95f4\u3002\u5728\u63d0\u4ea4\u6392\u5e8f\u7684 $Block2 {L1}$
\u4e4b\u524d\uff0c\u5b58\u5728\u4e24\u4e2a\u5df2\u63d0\u4ea4\u4e8b\u52a1 $Txn5
\u3001Txn6$
\u548c\u4e00\u4e2a\u672a\u63d0\u4ea4\u4e8b\u52a1 $Txn7$
\u3002\u5f53 $Txn7$
\u5728 $t16$
\u63d0\u4ea4\u65f6\uff0c\u5c06\u5931\u8d25\uff0c\u56e0\u4e3a $Block1 {L0}$
\u5df2\u7ecf\u88ab\u7ec8\u6b62\u3002\u5728 $(t11, t16)$
\u671f\u95f4\u63d0\u4ea4\u7684\u66f4\u65b0\u8282\u70b9 $Txn5
\u3001Txn6$
\u5c06\u88ab\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u66f4\u65b0\u8282\u70b9\uff0c\u5b83\u5c06\u4e0e $Block2 {L1}$
\u5728 $t16$
\u65f6\u4e00\u540c\u63d0\u4ea4\u3002
\u538b\u7f29\u8fc7\u7a0b\u4f1a\u7ec8\u6b62\u4e00\u7cfb\u5217\u5757\u6216\u6bb5\uff0c\u5e76\u539f\u5b50\u6027\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5757\u6216\u6bb5\uff08\u6216\u5efa\u7acb\u7d22\u5f15\uff09\u3002\u4e0e\u5e38\u89c4\u4e8b\u52a1\u76f8\u6bd4\uff0c\u6b64\u8fc7\u7a0b\u901a\u5e38\u9700\u8981\u66f4\u957f\u7684\u65f6\u95f4\uff0c\u800c\u6211\u4eec\u4e0d\u5e0c\u671b\u963b\u6b62\u6d89\u53ca\u7684\u5757\u6216\u6bb5\u7684\u66f4\u65b0\u6216\u5220\u9664\u4e8b\u52a1\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u6269\u5c55\u4e86\u8bfb\u89c6\u56fe\uff0c\u5c06\u5757\u548c\u6bb5\u7684\u5143\u6570\u636e\u7eb3\u5165\u5176\u4e2d\u3002\u5728\u63d0\u4ea4\u5e38\u89c4\u4e8b\u52a1\u65f6\uff0c\u4e00\u65e6\u68c0\u6d4b\u5230\u5199\u64cd\u4f5c\u5bf9\u5e94\u7684\u5757\uff08\u6216\u6bb5\uff09\u7684\u5143\u6570\u636e\u5df2\u66f4\u6539\uff08\u63d0\u4ea4\uff09\uff0c\u8be5\u4e8b\u52a1\u5c06\u5931\u8d25\u3002\u5bf9\u4e8e\u538b\u7f29\u4e8b\u52a1\uff0c\u5176\u5199\u64cd\u4f5c\u5305\u62ec\u5757\uff08\u6216\u6bb5\uff09\u7684\u8f6f\u5220\u9664\u548c\u6dfb\u52a0\u3002\u5728\u4e8b\u52a1\u6267\u884c\u671f\u95f4\uff0c\u6bcf\u6b21\u5199\u5165\u64cd\u4f5c\u90fd\u4f1a\u68c0\u6d4b\u662f\u5426\u5b58\u5728\u5199 - \u5199\u51b2\u7a81\u3002\u4e00\u65e6\u51b2\u7a81\u53d1\u751f\uff0c\u4e8b\u52a1\u5c06\u88ab\u63d0\u524d\u7ec8\u6b62\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#mvcc","title":"MVCC\uff08\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09","text":"\u6570\u636e\u5e93\u7684\u7248\u672c\u5b58\u50a8\u673a\u5236\u51b3\u5b9a\u4e86\u7cfb\u7edf\u5982\u4f55\u4fdd\u5b58\u4e0d\u540c\u7248\u672c\u7684\u5143\u7ec4\u4ee5\u53ca\u6bcf\u4e2a\u7248\u672c\u6240\u5305\u542b\u7684\u4fe1\u606f\u3002TAE \u521b\u5efa\u4e86\u4e00\u4e2a\u79f0\u4e3a\u7248\u672c\u94fe\u7684\u65e0\u9501\u94fe\u8868\uff0c\u5b83\u57fa\u4e8e\u6570\u636e\u5143\u7ec4\u7684\u6307\u9488\u5b57\u6bb5\u3002\u7248\u672c\u94fe\u4f7f\u5f97\u6570\u636e\u5e93\u80fd\u591f\u51c6\u786e\u5730\u5b9a\u4f4d\u5230\u6240\u9700\u5143\u7ec4\u7684\u7248\u672c\u3002\u56e0\u6b64\uff0c\u7248\u672c\u6570\u636e\u7684\u5b58\u50a8\u673a\u5236\u662f\u6570\u636e\u5e93\u5b58\u50a8\u5f15\u64ce\u8bbe\u8ba1\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u8003\u8651\u56e0\u7d20\u3002
\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\u662f\u91c7\u7528\u8ffd\u52a0\u6a21\u5f0f\uff08Append Only\uff09\u673a\u5236\uff0c\u5c06\u4e00\u4e2a\u8868\u7684\u6240\u6709\u5143\u7ec4\u7248\u672c\u5b58\u50a8\u5728\u540c\u4e00\u4e2a\u5b58\u50a8\u7a7a\u95f4\u4e2d\u3002\u7531\u4e8e\u65e0\u6cd5\u7ef4\u62a4\u4e00\u4e2a\u65e0\u9501\u7684\u53cc\u5411\u94fe\u8868\uff0c\u7248\u672c\u94fe\u53ea\u80fd\u6307\u5411\u4e00\u4e2a\u65b9\u5411\uff0c\u8981\u4e48\u662f\u4ece\u65e7\u5230\u65b0\uff08O2N\uff09\uff0c\u8981\u4e48\u662f\u4ece\u65b0\u5230\u65e7\uff08N2O\uff09\u3002
\u53e6\u4e00\u79cd\u7c7b\u4f3c\u7684\u65b9\u6848\u88ab\u79f0\u4e3a\u65f6\u5149\u65c5\u884c\uff08Time-Travel\uff09\uff0c\u5b83\u5c06\u7248\u672c\u94fe\u7684\u4fe1\u606f\u5355\u72ec\u5b58\u653e\uff0c\u800c\u4e3b\u8868\u5219\u7ef4\u62a4\u4e3b\u7248\u672c\u7684\u6570\u636e\u3002
\u7b2c\u4e09\u79cd\u65b9\u6848\u662f\u5728\u4e3b\u8868\u4e2d\u7ef4\u62a4\u5143\u7ec4\u7684\u4e3b\u7248\u672c\uff0c\u5e76\u5728\u5355\u72ec\u7684\u589e\u91cf\u5b58\u50a8\u4e2d\u7ef4\u62a4\u4e00\u7cfb\u5217\u589e\u91cf\u7248\u672c\u3002\u5728\u66f4\u65b0\u73b0\u6709\u5143\u7ec4\u65f6\uff0c\u6570\u636e\u5e93\u4ece\u589e\u91cf\u5b58\u50a8\u4e2d\u83b7\u53d6\u4e00\u6bb5\u8fde\u7eed\u7684\u7a7a\u95f4\uff0c\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u589e\u91cf\u7248\u672c\uff0c\u8be5\u589e\u91cf\u7248\u672c\u4ec5\u5305\u542b\u88ab\u4fee\u6539\u5c5e\u6027\u7684\u539f\u59cb\u503c\uff0c\u800c\u4e0d\u662f\u6574\u4e2a\u5143\u7ec4\u3002\u7136\u540e\u6570\u636e\u5e93\u76f4\u63a5\u5bf9\u4e3b\u8868\u4e2d\u7684\u4e3b\u7248\u672c\u8fdb\u884c\u539f\u5730\u66f4\u65b0\u3002
\u4ee5\u4e0a\u5404\u79cd\u65b9\u6848\u90fd\u6709\u5176\u7279\u70b9\uff0c\u5e76\u5bf9\u5b83\u4eec\u5728 OLTP \u5de5\u4f5c\u8d1f\u8f7d\u4e2d\u7684\u8868\u73b0\u4ea7\u751f\u5f71\u54cd\u3002\u5bf9\u4e8e LSM \u6811\u6765\u8bf4\uff0c\u7531\u4e8e\u5176\u5929\u7136\u7684\u8ffd\u52a0\u6a21\u5f0f\u7ed3\u6784\uff0c\u56e0\u6b64\u66f4\u63a5\u8fd1\u7b2c\u4e00\u79cd\u65b9\u6848\u3002\u4f46\u662f\u7248\u672c\u94fe\u7684\u94fe\u8868\u53ef\u80fd\u4e0d\u4f1a\u663e\u73b0\u3002
TAE \u76ee\u524d\u9009\u62e9\u4e86\u7b2c\u4e09\u79cd\u65b9\u6848\u7684\u53d8\u4f53\uff1a
\u5728\u5927\u91cf\u66f4\u65b0\u7684\u60c5\u51b5\u4e0b\uff0cLSM \u6811\u7ed3\u6784\u7684\u65e7\u7248\u672c\u6570\u636e\u4f1a\u5bfc\u81f4\u5927\u91cf\u7684\u8bfb\u653e\u5927\u3002\u800c TAE \u7684\u7248\u672c\u94fe\u7531\u7f13\u51b2\u533a\u7ba1\u7406\u5668\u7ef4\u62a4\uff0c\u5f53\u9700\u8981\u88ab\u66ff\u6362\u65f6\uff0c\u5b83\u4f1a\u4e0e\u4e3b\u8868\u6570\u636e\u5408\u5e76\uff0c\u91cd\u65b0\u751f\u6210\u65b0\u7684\u5757\u3002\u56e0\u6b64\uff0c\u5728\u8bed\u4e49\u4e0a\uff0c\u5b83\u662f\u539f\u5730\u66f4\u65b0\uff0c\u4f46\u5728\u5b9e\u73b0\u4e0a\u662f\u5199\u65f6\u590d\u5236\uff0c\u8fd9\u5bf9\u4e8e\u4e91\u5b58\u50a8\u6765\u8bf4\u662f\u5fc5\u9700\u7684\u3002\u91cd\u65b0\u751f\u6210\u7684\u65b0\u5757\u7684\u8bfb\u653e\u5927\u8f83\u5c11\uff0c\u8fd9\u5bf9\u4e8e\u9891\u7e41\u66f4\u65b0\u540e\u7684 AP \u67e5\u8be2\u66f4\u6709\u5229\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/","title":"\u4e8b\u52a1\u4e0e\u9501\u673a\u5236\u5b9e\u73b0\u8be6\u89e3","text":"\u672c\u6587\u5c06\u5411\u4f60\u4ecb\u7ecd MatrixOne \u7684\u4e8b\u52a1\u4e0e\u9501\u673a\u5236\u7684\u5b9e\u73b0\u7ec6\u8282\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#matrixone","title":"MatrixOne \u4e8b\u52a1\u7279\u6027","text":"MatrixOne \u9ed8\u8ba4\u652f\u6301\u60b2\u89c2\u4e8b\u52a1\u4ee5\u53ca\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u9694\u79bb\u7ea7\u522b\u3002\u540c\u65f6\u4e5f\u652f\u6301\u57fa\u4e8e\u5feb\u7167\u9694\u79bb\uff08Snapshot Isolation\uff09\u7684\u4e50\u89c2\u4e8b\u52a1\u3002\u4f46\u4e50\u89c2\u4e8b\u52a1\u548c\u60b2\u89c2\u4e8b\u52a1\u4e0d\u80fd\u540c\u65f6\u8fd0\u884c\u3002\u5728\u96c6\u7fa4\u4e2d\uff0c\u8981\u4e48\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u6a21\u578b\uff0c\u8981\u4e48\u4f7f\u7528\u4e50\u89c2\u4e8b\u52a1\u6a21\u578b\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#matrixone_1","title":"MatrixOne \u4e8b\u52a1\u67b6\u6784","text":"MatrixOne \u96c6\u7fa4\u7531\u4e09\u4e2a\u5185\u7f6e\u670d\u52a1\u6784\u6210\uff1aCN\uff08Compute Node\uff09\u3001TN\uff08Transaction Node\uff09\u3001LogService\uff0c\u4ee5\u53ca\u4e00\u4e2a\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#cn-compute-node","title":"CN (Compute Node)","text":"CN \u662f\u8ba1\u7b97\u8282\u70b9\uff0c\u8d1f\u8d23\u6267\u884c\u5927\u90e8\u5206\u8ba1\u7b97\u5de5\u4f5c\u3002\u6bcf\u4e2a\u4e8b\u52a1\u5ba2\u6237\u7aef\uff08\u5982 JDBC \u6216 MySQL \u5ba2\u6237\u7aef\uff09\u90fd\u4f1a\u4e0e\u4e00\u4e2a CN \u5efa\u7acb\u8fde\u63a5\uff0c\u53d1\u8d77\u7684\u4e8b\u52a1\u5c06\u5728\u76f8\u5e94\u7684 CN \u4e0a\u521b\u5efa\u3002\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u4f1a\u5728 CN \u4e0a\u5206\u914d\u4e00\u4e2a\u5de5\u4f5c\u7a7a\u95f4\uff0c\u7528\u4e8e\u5b58\u50a8\u4e8b\u52a1\u7684\u4e34\u65f6\u6570\u636e\u3002\u5f53\u4e8b\u52a1\u63d0\u4ea4\u65f6\uff0c\u5de5\u4f5c\u7a7a\u95f4\u4e2d\u7684\u6570\u636e\u5c06\u88ab\u53d1\u9001\u5230 TN \u8282\u70b9\u4ee5\u8fdb\u884c\u63d0\u4ea4\u5904\u7406\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#tn-transaction-node","title":"TN (Transaction Node)","text":"TN \u662f\u4e8b\u52a1\u8282\u70b9\uff0c\u8d1f\u8d23\u5904\u7406\u6240\u6709 CN \u8282\u70b9\u4e0a\u7684\u4e8b\u52a1\u63d0\u4ea4\u3002TN \u8282\u70b9\u7684\u804c\u8d23\u5305\u62ec\u5c06\u4e8b\u52a1\u7684\u63d0\u4ea4\u65e5\u5fd7\u5199\u5165 LogService\uff0c\u5e76\u5c06\u63d0\u4ea4\u7684\u6570\u636e\u5199\u5165\u5185\u5b58\u3002\u5f53\u5185\u5b58\u6570\u636e\u8fbe\u5230\u4e00\u5b9a\u6761\u4ef6\u65f6\uff0cTN \u8282\u70b9\u4f1a\u5c06\u63d0\u4ea4\u7684\u6570\u636e\u5199\u5165\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\uff0c\u5e76\u6e05\u7406\u76f8\u5173\u7684\u65e5\u5fd7\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#logservice","title":"LogService","text":"LogService \u662f\u65e5\u5fd7\u8282\u70b9\uff0c\u7c7b\u4f3c\u4e8e TN \u8282\u70b9\u7684 Write-Ahead Logging\uff08WAL\uff09\u7cfb\u7edf\u3002\u5b83\u4f7f\u7528 Raft \u534f\u8bae\u5c06\u65e5\u5fd7\u5b58\u50a8\u4e3a\u591a\u4e2a\u526f\u672c\uff0c\u4ee5\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u5f3a\u4e00\u81f4\u6027\u3002MatrixOne \u968f\u65f6\u53ef\u4ee5\u901a\u8fc7 LogService \u6765\u6062\u590d TN \u8282\u70b9\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLogService \u4e2d\u5b58\u50a8\u7684\u65e5\u5fd7\u5e76\u4e0d\u4f1a\u65e0\u9650\u589e\u957f\u3002\u5f53\u65e5\u5fd7\u5927\u5c0f\u8fbe\u5230\u4e00\u5b9a\u9608\u503c\u65f6\uff0cTN \u4f1a\u5c06 LogService \u4e2d\u7684\u65e5\u5fd7\u5bf9\u5e94\u7684\u6570\u636e\u5199\u5165\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\uff0c\u5e76\u622a\u65ad LogService \u4e2d\u7684\u65e5\u5fd7\u3002\u8fd9\u622a\u65ad\u540e\u7684\u65e5\u5fd7\u6570\u636e\u88ab\u79f0\u4e3a \"LogTail\"\uff0c\u52a0\u4e0a\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u6570\u636e\u6784\u6210\u4e86 MatrixOne \u6570\u636e\u5e93\u7684\u5168\u90e8\u6570\u636e\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_2","title":"\u65f6\u949f\u65b9\u6848","text":"MatrixOne \u91c7\u7528 HLC\uff08Hybrid Logical Clocks\uff09\u65f6\u949f\u65b9\u6848\uff0c\u5e76\u4e0e\u5185\u7f6e\u7684 MORPC\uff08MatrixOne Remote Procedure Call\uff09\u96c6\u6210\uff0c\u7528\u4e8e\u5b9e\u73b0 CN \u548c TN \u8282\u70b9\u4e4b\u95f4\u7684\u65f6\u949f\u540c\u6b65\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_3","title":"\u4e8b\u52a1\u7684\u8bfb\u64cd\u4f5c","text":"\u4e8b\u52a1\u7684\u8bfb\u64cd\u4f5c\u53d1\u751f\u5728 CN \u8282\u70b9\uff0c\u5b83\u53ef\u4ee5\u67e5\u770b MVCC\uff08\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09\u4e2d\u7684\u6570\u636e\u7248\u672c\uff0c\u8fd9\u53d6\u51b3\u4e8e\u4e8b\u52a1\u7684\u5feb\u7167\u65f6\u95f4\u6233\uff08SnapshotTS\uff09\u3002
\u4e00\u65e6\u4e8b\u52a1\u786e\u5b9a\u4e86\u5176 SnapshotTS\uff0c\u5b83\u9700\u8981\u8bbf\u95ee\u4e24\u4e2a\u6570\u636e\u96c6\uff1a\u4e00\u4e2a\u5b58\u50a8\u5728\u5bf9\u8c61\u5b58\u50a8\u4e2d\uff0c\u53e6\u4e00\u4e2a\u5b58\u50a8\u5728 LogTail \u4e2d\u3002\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u6570\u636e\u53ef\u4ee5\u88ab CN \u76f4\u63a5\u8bbf\u95ee\uff0c\u5e76\u63d0\u4f9b\u4e86\u7f13\u5b58\u4ee5\u63d0\u9ad8\u6570\u636e\u8bfb\u53d6\u7684\u6027\u80fd\u3002\u800c LogTail \u4e2d\u7684\u6570\u636e\u5206\u5e03\u5728 TN \u8282\u70b9\u7684\u5185\u5b58\u4e2d\u3002
\u5728\u4ee5\u5f80\u7684\u7248\u672c\u4e2d\uff0cCN \u8282\u70b9\u91c7\u7528 \"Pull \u6a21\u5f0f\"\uff0c\u5373\u53ea\u6709\u5728\u4e8b\u52a1\u5f00\u59cb\u540e\u624d\u4e3b\u52a8\u4e0e TN \u540c\u6b65 LogTail \u6570\u636e\uff0c\u8fd9\u5bfc\u81f4\u4e86\u6027\u80fd\u8f83\u5dee\u3001\u5ef6\u8fdf\u8f83\u9ad8\u548c\u541e\u5410\u91cf\u8f83\u4f4e\u7684\u95ee\u9898\u3002\u4f46\u4ece 0.8 \u7248\u672c\u5f00\u59cb\uff0cMatrixOne \u5f15\u5165\u4e86 \"Push \u6a21\u5f0f\"\uff0c\u5176\u4e2d LogTail \u7684\u540c\u6b65\u4e0d\u518d\u5728\u4e8b\u52a1\u5f00\u59cb\u65f6\u53d1\u8d77\uff0c\u800c\u662f\u91c7\u7528 CN \u7ea7\u522b\u7684\u8ba2\u9605\u65b9\u5f0f\uff0cTN \u8282\u70b9\u5728\u6bcf\u6b21 LogTail \u53d8\u5316\u65f6\u5c06\u589e\u91cf\u7684 LogTail \u540c\u6b65\u7ed9\u8ba2\u9605\u7684 CN \u8282\u70b9\u3002
\u5728 Push \u6a21\u5f0f\u4e0b\uff0c\u6bcf\u4e2a CN \u8282\u70b9\u4f1a\u4e0d\u65ad\u63a5\u6536\u6765\u81ea TN \u8282\u70b9\u7684 LogTail \u63a8\u9001\uff0c\u5e76\u5728 CN \u8282\u70b9\u4e0a\u7ef4\u62a4\u4e0e TN \u8282\u70b9\u76f8\u540c\u7684\u5185\u5b58\u6570\u636e\u7ed3\u6784\uff0c\u4ee5\u53ca\u6700\u540e\u4e00\u6b21\u6d88\u8d39\u7684 LogTail \u65f6\u95f4\u6233\u3002\u4e00\u65e6\u4e8b\u52a1\u7684 SnapshotTS \u786e\u5b9a\uff0c\u53ea\u9700\u8981\u7b49\u5f85\u6700\u540e\u4e00\u6b21\u6d88\u8d39\u7684 LogTail \u7684\u65f6\u95f4\u6233\u5927\u4e8e\u6216\u7b49\u4e8e SnapshotTS\uff0c\u5c31\u8868\u793a CN \u62e5\u6709\u5b8c\u6574\u7684 SnapshotTS \u6570\u636e\u96c6\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_4","title":"\u6570\u636e\u53ef\u89c1\u6027","text":"\u4e8b\u52a1\u80fd\u591f\u8bfb\u53d6\u7684\u6570\u636e\u53d6\u51b3\u4e8e\u5176 SnapshotTS\u3002
\u5982\u679c\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u4f7f\u7528\u6700\u65b0\u7684\u65f6\u95f4\u6233\u4f5c\u4e3a SnapshotTS\uff0c\u90a3\u4e48\u8be5\u4e8b\u52a1\u53ef\u4ee5\u8bfb\u53d6\u5728\u5176\u4e4b\u524d\u63d0\u4ea4\u7684\u4efb\u4f55\u6570\u636e\u3002\u8fd9\u5c06\u786e\u4fdd\u8bfb\u53d6\u7684\u6570\u636e\u59cb\u7ec8\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e5f\u4f1a\u4ed8\u51fa\u4e00\u4e9b\u6027\u80fd\u4ee3\u4ef7\u3002
\u5728 Pull \u6a21\u5f0f\u4e0b\uff0c\u9700\u8981\u7b49\u5f85 TN \u8282\u70b9\u540c\u6b65 SnapshotTS \u4e4b\u524d\u7684\u6240\u6709\u4e8b\u52a1\u90fd\u5df2\u63d0\u4ea4\u3002\u5feb\u7167 TS \u8d8a\u65b0\uff0c\u9700\u8981\u7b49\u5f85\u7684\u4e8b\u52a1\u63d0\u4ea4\u8d8a\u591a\uff0c\u4ece\u800c\u5bfc\u81f4\u5ef6\u8fdf\u8f83\u9ad8\u3002
\u5728 Push \u6a21\u5f0f\u4e0b\uff0cCN \u8282\u70b9\u9700\u8981\u7b49\u5f85 SnapshotTS \u4e4b\u524d\u7684\u6240\u6709\u4e8b\u52a1\u7684 Commit \u7684 LogTail \u88ab\u6d88\u8d39\u3002\u4e5f\u662f\u8d8a\u65b0\u7684 SnapshotTS \u9700\u8981\u7b49\u5f85\u7684\u4e8b\u52a1\u63d0\u4ea4\u8d8a\u591a\uff0c\u4ece\u800c\u5bfc\u81f4\u8f83\u9ad8\u7684\u5ef6\u8fdf\u3002
\u7136\u800c\uff0c\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u5e76\u4e0d\u9700\u8981\u59cb\u7ec8\u8bfb\u53d6\u6700\u65b0\u6570\u636e\u3002MatrixOne \u76ee\u524d\u63d0\u4f9b\u4e86\u4e24\u79cd\u6570\u636e\u65b0\u9c9c\u5ea6\u7ea7\u522b\uff1a
\u4f7f\u7528\u5f53\u524d\u65f6\u95f4\u6233\u4f5c\u4e3a SnapshotTS\uff0c\u4ee5\u59cb\u7ec8\u67e5\u770b\u6700\u65b0\u6570\u636e\u3002
\u4f7f\u7528 CN \u8282\u70b9\u5df2\u6d88\u8d39\u5b8c\u7684\u6700\u5927 LogTail \u65f6\u95f4\u6233\u4f5c\u4e3a SnapshotTS\u3002
\u5bf9\u4e8e\u7b2c\u4e8c\u79cd\u65b9\u5f0f\uff0c\u5b83\u7684\u597d\u5904\u5728\u4e8e\u4e8b\u52a1\u51e0\u4e4e\u6ca1\u6709\u5ef6\u8fdf\uff0c\u53ef\u4ee5\u7acb\u5373\u5f00\u59cb\u8bfb\u5199\u6570\u636e\uff0c\u56e0\u4e3a\u6240\u9700\u7684 LogTail \u6570\u636e\u90fd\u5df2\u51c6\u5907\u5c31\u7eea\uff0c\u6027\u80fd\u548c\u5ef6\u8fdf\u8868\u73b0\u826f\u597d\u3002\u4f46\u662f\uff0c\u8fd9\u4e5f\u5e26\u6765\u4e00\u4e2a\u95ee\u9898\uff0c\u5982\u679c\u540c\u4e00\u6570\u636e\u5e93\u8fde\u63a5\u4e0a\u7684\u591a\u4e2a\u4e8b\u52a1\uff0c\u540e\u4e00\u4e2a\u4e8b\u52a1\u53ef\u80fd\u65e0\u6cd5\u770b\u5230\u524d\u4e00\u4e2a\u4e8b\u52a1\u7684\u5199\u5165\u64cd\u4f5c\uff0c\u56e0\u4e3a\u540e\u4e00\u4e2a\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0cTN \u8282\u70b9\u5c1a\u672a\u5c06\u524d\u4e00\u4e2a\u4e8b\u52a1\u7684 Commit \u7684 LogTail \u63a8\u9001\u5230\u5f53\u524d CN \u8282\u70b9\uff0c\u4ece\u800c\u5bfc\u81f4\u540e\u4e00\u4e2a\u4e8b\u52a1\u4f7f\u7528\u8f83\u65e7\u7684 SnapshotTS\uff0c\u65e0\u6cd5\u770b\u5230\u524d\u4e00\u4e2a\u4e8b\u52a1\u7684\u5199\u5165\u3002
\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cMatrixOne \u7ef4\u62a4\u4e86\u4e24\u4e2a\u65f6\u95f4\u6233\uff1a\u5f53\u524d CN \u8282\u70b9\u7684\u6700\u540e\u4e00\u4e2a\u4e8b\u52a1\u7684 CommitTS\uff08CNCommitTS\uff09\u548c\u5f53\u524d\u4f1a\u8bdd\uff08\u6570\u636e\u5e93\u8fde\u63a5\uff09\u7684\u6700\u540e\u4e00\u4e2a\u4e8b\u52a1\u7684 CommitTS\uff08SessionCommitTS\uff09\u3002\u6b64\u5916\uff0cMatrixOne \u63d0\u4f9b\u4e86\u4e24\u79cd\u6570\u636e\u53ef\u89c1\u6027\u7ea7\u522b\uff08\u5c06\u5f53\u524d CN \u8282\u70b9\u6d88\u8d39\u7684\u6700\u5927 LogTail \u7684\u65f6\u95f4\u6233\u79f0\u4e3a LastLogTailTS\uff09\uff1a
\u4f1a\u8bdd\u7ea7\u522b\u7684\u6570\u636e\u53ef\u89c1\u6027\uff0c\u4f7f\u7528 Max(SessionCommitTS, LastLogTailTS) \u4f5c\u4e3a\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u4ee5\u4fdd\u8bc1\u540c\u4e00\u4f1a\u8bdd\u4e2d\u53d1\u751f\u7684\u4e8b\u52a1\u6570\u636e\u7684\u53ef\u89c1\u6027\u3002
CN \u7ea7\u522b\u7684\u6570\u636e\u53ef\u89c1\u6027\uff0c\u4f7f\u7528 Max(CNCommitTS, LastLogTailTS) \u4f5c\u4e3a\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u4ee5\u4fdd\u8bc1\u540c\u4e00 CN \u8282\u70b9\u4e0a\u53d1\u751f\u7684\u4e8b\u52a1\u6570\u636e\u7684\u53ef\u89c1\u6027\u3002
\u524d\u9762\u7684\u7ae0\u8282\u4e3b\u8981\u4ecb\u7ecd\u4e86 MatrixOne \u4e8b\u52a1\u7684\u5904\u7406\uff0cMatrixOne \u4e4b\u524d\u4ec5\u652f\u6301 SI \u9694\u79bb\u7ea7\u522b\uff0c\u57fa\u4e8e MVCC \u5b9e\u73b0\uff0c\u6570\u636e\u5177\u6709\u591a\u4e2a\u7248\u672c\u3002\u7136\u800c\uff0c\u73b0\u5728 MatrixOne \u8fd8\u652f\u6301 RC\uff08Read Committed\uff09\u9694\u79bb\u7ea7\u522b\u3002
\u8981\u5728\u591a\u7248\u672c\u4e0a\u5b9e\u73b0 RC \u9694\u79bb\u7ea7\u522b\uff0c\u5bf9\u4e8e SI \u4e8b\u52a1\uff0c\u9700\u8981\u7ef4\u62a4\u4e00\u81f4\u7684\u5feb\u7167\uff0c\u4e0d\u7ba1\u4f55\u65f6\u8bfb\u53d6\uff0c\u90fd\u80fd\u770b\u5230\u76f8\u540c\u7684\u6570\u636e\u3002\u4f46\u662f RC \u9700\u8981\u67e5\u770b\u6700\u65b0\u63d0\u4ea4\u7684\u6570\u636e\uff0c\u8fd9\u76f8\u5f53\u4e8e\u4e00\u81f4\u7684\u5feb\u7167\u4e0d\u518d\u662f\u4e8b\u52a1\u751f\u547d\u5468\u671f\u5185\u7684\uff0c\u800c\u662f\u9488\u5bf9\u6bcf\u4e2a\u67e5\u8be2\u7684\u3002\u6bcf\u6b21\u67e5\u8be2\u5f00\u59cb\u65f6\uff0c\u4f7f\u7528\u5f53\u524d\u65f6\u95f4\u6233\u4f5c\u4e3a\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u4ee5\u786e\u4fdd\u67e5\u8be2\u53ef\u4ee5\u770b\u5230\u4e4b\u524d\u63d0\u4ea4\u7684\u6570\u636e\u3002
\u5728 RC \u6a21\u5f0f\u4e0b\uff0c\u5bf9\u4e8e\u5e26\u6709\u66f4\u65b0\u7684\u8bed\u53e5\uff08UPDATE\u3001DELETE\u3001SELECT FOR UPDATE\uff09\uff0c\u4e00\u65e6\u51fa\u73b0\u5199 - \u5199\u51b2\u7a81\uff0c\u5373\u610f\u5473\u7740\u5176\u4ed6\u5e76\u53d1\u4e8b\u52a1\u5df2\u4fee\u6539\u4e86\u67e5\u8be2\u6240\u6d89\u53ca\u7684\u6570\u636e\u3002\u7531\u4e8e RC \u9700\u8981\u770b\u5230\u6700\u65b0\u7684\u5199\u5165\uff0c\u56e0\u6b64\u5982\u679c\u51fa\u73b0\u51b2\u7a81\u4e8b\u52a1\u5df2\u63d0\u4ea4\uff0c\u5fc5\u987b\u66f4\u65b0\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u7136\u540e\u91cd\u8bd5\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_5","title":"\u60b2\u89c2\u4e8b\u52a1","text":"\u672c\u7ae0\u4ecb\u7ecd MatrixOne \u5982\u4f55\u5b9e\u73b0\u60b2\u89c2\u4e8b\u52a1\u4ee5\u53ca\u76f8\u5173\u8bbe\u8ba1\u8003\u8651\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_6","title":"\u9700\u8981\u89e3\u51b3\u7684\u6838\u5fc3\u95ee\u9898","text":"MatrixOne \u5b9e\u73b0\u60b2\u89c2\u4e8b\u52a1\u9700\u8981\u89e3\u51b3\u4e00\u4e9b\u5173\u952e\u95ee\u9898\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_7","title":"\u63d0\u4f9b\u9501\u670d\u52a1","text":"\u9501\u670d\u52a1\u7528\u4e8e\u9501\u5b9a\u5355\u4e2a\u8bb0\u5f55\u3001\u8303\u56f4\u751a\u81f3\u6574\u4e2a\u8868\u3002\u5f53\u4e8b\u52a1\u5728\u8bfb/\u5199\u64cd\u4f5c\u4e2d\u9700\u8981\u9501\u5b9a\u8d44\u6e90\u65f6\uff0c\u5982\u679c\u53d1\u73b0\u9501\u51b2\u7a81\uff0c\u9700\u8981\u5b9e\u73b0\u9501\u7b49\u5f85\u3002\u5f53\u5f62\u6210\u6b7b\u9501\u73af\u8def\u65f6\uff0c\u9700\u8981\u6709\u6b7b\u9501\u68c0\u6d4b\u673a\u5236\u6765\u89e3\u9664\u6b7b\u9501\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_8","title":"\u53ef\u6269\u5c55\u7684\u9501\u670d\u52a1\u6027\u80fd","text":"MatrixOne \u7684\u4e8b\u52a1\u53ef\u80fd\u53d1\u751f\u5728\u4efb\u4f55 CN \u8282\u70b9\u3002\u5f53\u591a\u4e2a\u8282\u70b9\u540c\u65f6\u8bbf\u95ee\u9501\u670d\u52a1\u65f6\uff0c\u9501\u670d\u52a1\u7684\u6027\u80fd\u5fc5\u987b\u5177\u5907\u53ef\u6269\u5c55\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#tn-commit","title":"\u53bb\u6389 TN \u8282\u70b9 Commit \u9636\u6bb5\u7684\u51b2\u7a81\u68c0\u6d4b","text":"\u5728\u60b2\u89c2\u6a21\u5f0f\u4e0b\uff0cMatrixOne \u96c6\u7fa4\u4e2d\u5b58\u5728\u591a\u4e2a TN \u8282\u70b9\uff0c\u56e0\u6b64\u9700\u8981\u786e\u4fdd\u53ef\u4ee5\u5b89\u5168\u5730\u53bb\u9664 Commit \u9636\u6bb5\u7684\u51b2\u7a81\u68c0\u6d4b\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_9","title":"\u9501\u670d\u52a1","text":"MatrixOne \u5df2\u7ecf\u5b9e\u73b0\u4e86 LockService \u6765\u63d0\u4f9b\u9501\u670d\u52a1\uff0c\u5305\u62ec\u52a0\u9501\u3001\u89e3\u9501\u3001\u9501\u51b2\u7a81\u68c0\u6d4b\u3001\u9501\u7b49\u5f85\u4ee5\u53ca\u6b7b\u9501\u68c0\u6d4b\u7684\u529f\u80fd\u3002
LockService \u5e76\u4e0d\u662f\u4e00\u4e2a\u72ec\u7acb\u90e8\u7f72\u7684\u7ec4\u4ef6\uff0c\u800c\u662f\u4e00\u4e2a CN \u7684\u7ec4\u4ef6\u3002\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u6bcf\u4e2a CN \u7684 LockService \u5b9e\u4f8b\u90fd\u80fd\u611f\u77e5\u5230\u5176\u4ed6 LockService \u5b9e\u4f8b\uff0c\u534f\u8c03\u6574\u4e2a\u96c6\u7fa4\u4e2d\u7684 LockService \u4e00\u8d77\u5de5\u4f5c\u3002\u6bcf\u4e2a CN \u53ea\u4f1a\u8bbf\u95ee\u5f53\u524d\u8282\u70b9\u7684 LockService \u5b9e\u4f8b\uff0c\u4e0d\u4f1a\u611f\u77e5\u5230\u5176\u4ed6 LockService \u5b9e\u4f8b\u3002\u5bf9\u4e8e CN \u6765\u8bf4\uff0c\u5f53\u524d\u8282\u70b9\u7684 LockService \u8868\u73b0\u5f97\u5c31\u50cf\u662f\u4e00\u4e2a\u672c\u5730\u7684\u7ec4\u4ef6\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#locktable","title":"LockTable","text":"\u9501\u4fe1\u606f\u5b58\u50a8\u5728\u4e00\u4e2a\u540d\u4e3a LockTable \u7684\u7ec4\u4ef6\u4e2d\uff0c\u4e00\u4e2a LockService \u53ef\u4ee5\u5305\u542b\u591a\u4e2a LockTable\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u7b2c\u4e00\u6b21\u8bbf\u95ee\u67d0\u4e2a\u8868\u7684\u9501\u670d\u52a1\u65f6\uff0cLockService \u4f1a\u521b\u5efa\u4e00\u4e2a LockTable \u5b9e\u4f8b\uff0c\u8fd9\u4e2a LockTable \u5c06\u88ab\u9644\u52a0\u5230\u5f53\u524d CN \u7684 LockService \u5b9e\u4f8b\u4e2d\u3002\u5728\u6574\u4e2a\u96c6\u7fa4\u4e2d\uff0c\u4e00\u4e2a LockTable \u5c06\u4f1a\u6709\u4e00\u4e2a\u672c\u5730 LockTable \u548c\u591a\u4e2a\u8fdc\u7a0b LockTable \u5b9e\u4f8b\u3002\u53ea\u6709\u672c\u5730 LockTable \u624d\u771f\u6b63\u4fdd\u5b58\u9501\u4fe1\u606f\uff0c\u8fdc\u7a0b LockTable \u5145\u5f53\u8bbf\u95ee\u672c\u5730 LockTable \u7684\u4ee3\u7406\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#locktableallocator","title":"LockTableAllocator","text":"LockTableAllocator \u662f\u7528\u4e8e\u5206\u914d LockTable \u7684\u7ec4\u4ef6\uff0c\u5b83\u5728\u5185\u5b58\u4e2d\u8bb0\u5f55\u4e86 MatrixOne \u96c6\u7fa4\u4e2d\u6240\u6709 LockTable \u7684\u5206\u5e03\u60c5\u51b5\u3002
LockTableAllocator \u4e0d\u662f\u4e00\u4e2a\u72ec\u7acb\u90e8\u7f72\u7684\u7ec4\u4ef6\uff0c\u5b83\u662f TN \u7684\u4e00\u4e2a\u7ec4\u4ef6\u3002\u7531\u4e8e LockTable \u548c LockService \u7684\u7ed1\u5b9a\u662f\u53ef\u53d8\u7684\uff0c\u6bd4\u5982 LockTableAllocator \u68c0\u6d4b\u5230\u67d0\u4e2a CN \u4e0b\u7ebf\uff0c\u7ed1\u5b9a\u5173\u7cfb\u5c06\u53d1\u751f\u53d8\u5316\uff0c\u6bcf\u6b21\u7ed1\u5b9a\u5173\u7cfb\u53d8\u5316\u65f6\uff0c\u7ed1\u5b9a\u7248\u672c\u53f7\u90fd\u4f1a\u589e\u52a0\u3002
\u5728\u4e8b\u52a1\u5f00\u59cb\u548c\u4e8b\u52a1\u63d0\u4ea4\u7684\u65f6\u95f4\u7a97\u53e3\u5185\uff0cLockTable \u548c LockService \u7684\u7ed1\u5b9a\u5173\u7cfb\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u8fd9\u79cd\u4e0d\u4e00\u81f4\u53ef\u80fd\u4f1a\u5f15\u53d1\u6570\u636e\u51b2\u7a81\uff0c\u4ece\u800c\u5bfc\u81f4\u60b2\u89c2\u4e8b\u52a1\u6a21\u578b\u5931\u6548\u3002\u56e0\u6b64\uff0cLockTableAllocator \u662f TN \u7684\u7ec4\u4ef6\uff0c\u4f1a\u5728\u5904\u7406\u4e8b\u52a1\u63d0\u4ea4\u4e4b\u524d\u68c0\u67e5\u7ed1\u5b9a\u5173\u7cfb\u662f\u5426\u6709\u53d8\u5316\uff0c\u5982\u679c\u53d1\u73b0\u67d0\u4e2a\u4e8b\u52a1\u8bbf\u95ee\u7684
LockTable \u7684\u7ed1\u5b9a\u5173\u7cfb\u5df2\u8fc7\u65f6\uff0c\u5c06\u4e2d\u6b62\u8be5\u4e8b\u52a1\u4ee5\u786e\u4fdd\u6b63\u786e\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_10","title":"\u5206\u5e03\u5f0f\u6b7b\u9501\u68c0\u6d4b","text":"\u6240\u6709\u6d3b\u52a8\u4e8b\u52a1\u6240\u6301\u6709\u7684\u9501\u5206\u5e03\u5728\u591a\u4e2a LockService \u7684\u672c\u5730 LockTable \u4e2d\uff0c\u56e0\u6b64\u9700\u8981\u4e00\u79cd\u5206\u5e03\u5f0f\u6b7b\u9501\u68c0\u6d4b\u673a\u5236\u3002
\u6bcf\u4e2a LockService \u90fd\u6709\u4e00\u4e2a\u6b7b\u9501\u68c0\u6d4b\u6a21\u5757\uff0c\u5176\u68c0\u6d4b\u673a\u5236\u5927\u81f4\u5982\u4e0b\uff1a
\u4e3a\u6bcf\u4e2a\u9501\u5728\u5185\u5b58\u4e2d\u7ef4\u62a4\u4e00\u4e2a\u7b49\u5f85\u961f\u5217\uff1b
\u5f53\u53d1\u751f\u65b0\u7684\u51b2\u7a81\u65f6\uff0c\u9700\u8981\u5c06\u4e8b\u52a1\u6dfb\u52a0\u5230\u9501\u6301\u6709\u8005\u7684\u7b49\u5f85\u961f\u5217\u4e2d\uff1b
\u542f\u52a8\u5f02\u6b65\u4efb\u52a1\uff0c\u9012\u5f52\u67e5\u627e\u7b49\u5f85\u961f\u5217\u4e2d\u6240\u6709\u4e8b\u52a1\u6301\u6709\u7684\u9501\uff0c\u68c0\u67e5\u662f\u5426\u5b58\u5728\u7b49\u5f85\u73af\u8def\u3002\u5982\u679c\u9047\u5230\u8fdc\u7a0b\u4e8b\u52a1\u7684\u9501\uff0c\u4f7f\u7528 RPC \u83b7\u53d6\u8fdc\u7a0b\u4e8b\u52a1\u6301\u6709\u7684\u6240\u6709\u9501\u4fe1\u606f\u3002
\u6574\u4e2a\u9501\u670d\u52a1\u7684\u5173\u952e\u6570\u636e\u90fd\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u5305\u62ec\u9501\u4fe1\u606f\u3001LockTable \u548c LockService \u7684\u7ed1\u5b9a\u5173\u7cfb\u3002\u5bf9\u4e8e\u672c\u5730 LockTable \u5185\u90e8\u8bb0\u5f55\u7684\u9501\u4fe1\u606f\uff0c\u5982\u679c CN \u5b95\u673a\uff0c\u90a3\u4e48\u4e0e\u8be5 CN \u8fde\u63a5\u7684\u4e8b\u52a1\u5c06\u5931\u8d25\uff0c\u56e0\u4e3a\u6570\u636e\u5e93\u8fde\u63a5\u65ad\u5f00\u3002\u7136\u540e LockTableAllocator \u4f1a\u91cd\u65b0\u5206\u914d LockTable \u548c LockService \u7684\u7ed1\u5b9a\u5173\u7cfb\uff0c\u4ece\u800c\u786e\u4fdd\u6574\u4e2a\u9501\u670d\u52a1\u53ef\u4ee5\u7ee7\u7eed\u63d0\u4f9b\u670d\u52a1\u3002
LockTableAllocator \u8fd0\u884c\u5728 TN \u4e2d\uff0c\u4e00\u65e6 TN \u5b95\u673a\uff0cHAKeeper \u4f1a\u4fee\u590d\u4e00\u4e2a\u65b0\u7684 TN\uff0c\u5bfc\u81f4\u6240\u6709\u7ed1\u5b9a\u5173\u7cfb\u5931\u6548\u3002\u8fd9\u610f\u5473\u7740\u5f53\u524d\u6d3b\u52a8\u7684\u6240\u6709\u4e8b\u52a1\u90fd\u4f1a\u56e0\u7ed1\u5b9a\u5173\u7cfb\u4e0d\u5339\u914d\u800c\u63d0\u4ea4\u5931\u8d25\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_12","title":"\u5982\u4f55\u4f7f\u7528\u9501\u670d\u52a1","text":"\u4e3a\u4e86\u66f4\u597d\u5730\u4f7f\u7528\u9501\u670d\u52a1\uff0cMatrixOne \u5b9e\u73b0\u4e86\u4e00\u4e2a Lock \u7b97\u5b50\uff0c\u8d1f\u8d23\u8c03\u7528\u548c\u5904\u7406\u9501\u670d\u52a1\u3002
\u5728 SQL \u7684\u8ba1\u5212\u9636\u6bb5\uff0c\u5982\u679c\u662f\u60b2\u89c2\u4e8b\u52a1\uff0c\u4f1a\u5904\u7406\u76f8\u5e94\u7684\u60c5\u51b5\uff0c\u7136\u540e\u5728\u6267\u884c\u9636\u6bb5\uff0c\u5728\u5408\u9002\u7684\u4f4d\u7f6e\u63d2\u5165 Lock \u7b97\u5b50\u3002
\u5bf9\u4e8e INSERT
\u63d2\u5165\u64cd\u4f5c\uff0c\u8ba1\u5212\u9636\u6bb5\u4f1a\u5728\u5176\u4ed6 Insert \u7b97\u5b50\u4e4b\u524d\u9996\u5148\u63d2\u5165 Lock \u7b97\u5b50\uff0c\u540e\u7eed\u6267\u884c\u65f6\uff0c\u53ea\u6709\u5728\u6210\u529f\u83b7\u53d6\u9501\u540e\u624d\u4f1a\u6267\u884c\u540e\u7eed\u7b97\u5b50\u3002
\u5bf9\u4e8e DELETE
\u5220\u9664\u64cd\u4f5c\uff0c\u4e0e\u63d2\u5165\u7c7b\u4f3c\uff0c\u8ba1\u5212\u9636\u6bb5\u4f1a\u5728\u5176\u4ed6 Delete \u7b97\u5b50\u4e4b\u524d\u63d2\u5165 Lock \u7b97\u5b50\uff0c\u7136\u540e\u53ea\u6709\u5728\u6210\u529f\u83b7\u53d6\u9501\u540e\u624d\u4f1a\u6267\u884c\u540e\u7eed\u7b97\u5b50\u3002
\u5bf9\u4e8e UPDATE
\u66f4\u65b0\u64cd\u4f5c\uff0c\u8ba1\u5212\u9636\u6bb5\u4f1a\u88ab\u62c6\u5206\u6210 Delete+Insert\uff0c\u56e0\u6b64\u4f1a\u6709\u4e24\u6b21\u9501\u5b9a\u9636\u6bb5\uff08\u5982\u679c\u672a\u4fee\u6539\u4e3b\u952e\uff0c\u5219\u4f1a\u4f18\u5316\u4e3a\u4e00\u6b21\u9501\u5b9a\uff0cInsert \u9636\u6bb5\u5c06\u4e0d\u4f1a\u9501\u5b9a\uff09\u3002
WAL\uff08Write Ahead Log\uff09\u662f\u4e00\u9879\u4e0e\u6570\u636e\u5e93\u539f\u5b50\u6027\u548c\u6301\u4e45\u6027\u76f8\u5173\u7684\u6280\u672f\uff0c\u5728\u4e8b\u52a1\u63d0\u4ea4\u65f6\u628a\u968f\u673a\u5199\u8f6c\u6362\u6210\u987a\u5e8f\u8bfb\u5199\u3002\u4e8b\u52a1\u7684\u66f4\u6539\u968f\u673a\u5730\u53d1\u751f\u5728\u5404\u9875\u4e0a\uff0c\u8fd9\u4e9b\u9875\u5f88\u5206\u6563\uff0c\u968f\u673a\u5199\u7684\u5f00\u9500\u5927\u4e8e\u987a\u5e8f\u5199\uff0c\u4f1a\u964d\u4f4e\u63d0\u4ea4\u7684\u6027\u80fd\u3002WAL \u53ea\u8bb0\u5f55\u4e8b\u52a1\u7684\u66f4\u6539\u64cd\u4f5c\uff0c\u4f8b\u5982\u5728\u67d0\u4e2a block \u4e2d\u589e\u52a0\u4e86\u4e00\u884c\uff0c\u63d0\u4ea4\u4e8b\u52a1\u65f6\u65b0\u7684 WAL entry \u987a\u5e8f\u5730\u5199\u5728 WAL \u6587\u4ef6\u672b\u5c3e\uff0c\u63d0\u4ea4\u4e4b\u540e\u518d\u5f02\u6b65\u5730\u66f4\u65b0\u90a3\u4e9b\u810f\u9875\uff0c\u9500\u6bc1\u5bf9\u5e94\u7684 WAL entry\uff0c\u91ca\u653e\u7a7a\u95f4\u3002
MatrixOne \u7684 WAL \u662f\u7269\u7406\u65e5\u5fd7\uff0c\u5b83\u4f1a\u8bb0\u5f55\u6bcf\u884c\u66f4\u65b0\u53d1\u751f\u7684\u4f4d\u7f6e\uff0c\u6bcf\u6b21\u56de\u653e\u51fa\u6765\uff0c\u6570\u636e\u4e0d\u4ec5\u5728\u903b\u8f91\u4e0a\u76f8\u540c\uff0c\u5728\u5e95\u5c42\u7684\u7ec4\u7ec7\u7ed3\u6784\u4e5f\u662f\u4e00\u6837\u7684\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#commit-pipeline","title":"Commit Pipeline","text":"Commit Pipeline \u662f\u5904\u7406\u4e8b\u52a1\u63d0\u4ea4\u7684\u7ec4\u4ef6\u3002\u63d0\u4ea4\u4e4b\u524d\u8981\u66f4\u65b0 memtable\uff0c\u6301\u4e45\u5316 WAL entry\uff0c\u6267\u884c\u8fd9\u4e9b\u4efb\u52a1\u7684\u8017\u65f6\u51b3\u5b9a\u4e86\u63d0\u4ea4\u7684\u6027\u80fd\u3002\u6301\u4e45\u5316 WAL entry \u6d89\u53ca\u5230 IO\uff0c\u6bd4\u8f83\u8017\u65f6\u3002MatrixOne \u4e2d\u91c7\u7528 commit pipeline\uff0c\u5f02\u6b65\u6301\u4e45\u5316 WAL entry\uff0c\u4e0d\u963b\u585e\u5185\u5b58\u4e2d\u7684\u66f4\u65b0\u3002
\u4e8b\u52a1\u63d0\u4ea4\u7684\u6d41\u7a0b\u662f\uff1a
\u628a\u66f4\u6539\u66f4\u65b0\u5230 memtable \u4e2d\uff0c\u4e8b\u52a1\u8fdb\u5165 commit pipeline \u4e4b\u524d\uff0c\u5148\u5e76\u53d1\u66f4\u65b0 memtable\uff0c\u4e8b\u52a1\u4e4b\u95f4\u4e92\u76f8\u4e0d \u963b\u585e\u3002\u8fd9\u65f6\u8fd9\u4e9b\u66f4\u6539\u7684\u72b6\u6001\u4e3a\u672a\u63d0\u4ea4\uff0c\u5bf9\u4efb\u4f55\u4e8b\u52a1\u4e0d\u53ef\u89c1\uff1b
\u8fdb\u5165 commit pipeline \u68c0\u67e5\u51b2\u7a81\uff1b
\u6301\u4e45\u5316 WAL entry\uff0c\u4ece\u5185\u5b58\u6536\u96c6 WAL entry \u5199\u5230\u540e\u7aef\u3002\u6301\u4e45\u5316 WAL entry \u662f\u5f02\u6b65\u7684\uff0c\u961f\u5217\u91cc\u53ea\u628a WAL entry \u4f20\u7ed9\u540e\u7aef\u5c31\u7acb\u523b\u8fd4\u56de\uff0c\u4e0d\u7528\u7b49\u5f85\u5199\u5165\u6210\u529f\uff0c\u8fd9\u6837\u4e0d\u4f1a\u963b\u585e\u540e\u7eed\u5176\u4ed6\u4e8b\u52a1\u3002\u540e\u7aef\u540c\u65f6\u5904\u7406\u4e00\u6279 entry\uff0c\u901a\u8fc7 Group Commit \u8fdb\u4e00\u6b65\u52a0\u901f\u6301\u4e45\u5316\u3002
\u66f4\u65b0 memtable \u4e2d\u7684\u72b6\u6001\u4f7f\u4e8b\u52a1\u53ef\u89c1\uff0c\u4e8b\u52a1\u6309\u7167\u8fdb\u961f\u5217\u7684\u987a\u5e8f\u4f9d\u6b21\u66f4\u65b0\u72b6\u6001\uff0c\u8fd9\u6837\u4e8b\u52a1\u53ef\u89c1\u7684\u987a\u5e8f\u548c\u961f\u5217\u91cc\u5199 WAL entry \u7684\u987a\u5e8f\u662f\u4e00\u81f4\u7684\u3002
Checkpoint \u5c06\u810f\u6570\u636e\u5199\u5165 Storage\uff0c\u9500\u6bc1\u65e7\u7684 log entry\uff0c\u91ca\u653e\u7a7a\u95f4\u3002MatrixOne \u4e2d\uff0ccheckpoint \u662f\u4e00\u4e2a\u540e\u53f0\u53d1\u8d77\u7684\u4efb\u52a1\uff0c\u5b83\u7684\u6d41\u7a0b\u662f\uff1a
\u9009\u5b9a\u4e00\u4e2a\u5408\u9002\u7684\u65f6\u95f4\u6233\u4f5c\u4e3a checkpoint\uff0c\u7136\u540e\u626b\u63cf\u65f6\u95f4\u6233\u4e4b\u524d\u7684\u4fee\u6539\u3002\u56fe\u4e0a\u7684 t0 \u662f\u4e0a\u4e2a checkpoint\uff0ct1 \u662f\u5f53\u524d\u9009\u5b9a\u7684 checkpoint\u3002[t0,t1] \u4e4b\u95f4\u53d1\u751f\u7684\u66f4\u6539\u9700\u8981\u8f6c\u5b58\u3002
\u8f6c\u5b58 DML \u4fee\u6539\u3002DML \u66f4\u6539\u5b58\u5728 memtable \u4e2d\u7684\u5404\u4e2a block \u4e2d\u3002Logtail Mgr \u662f\u4e00\u4e2a\u5185\u5b58\u6a21\u5757\uff0c\u8bb0\u5f55\u7740\u6bcf\u4e2a\u4e8b\u52a1\u6539\u52a8\u4e86\u54ea\u4e9b block\u3002\u5728 Logtail Mgr \u4e0a\u626b\u63cf [t0,t1] \u4e4b\u95f4\u7684\u4e8b\u52a1\uff0c\u53d1\u8d77\u540e\u53f0\u4e8b\u52a1\u628a\u8fd9\u4e9b block \u8f6c\u5b58\u5230 Storage \u4e0a\uff0c\u5728\u5143\u6570\u636e\u4e2d\u8bb0\u5f55\u5730\u5740\u3002\u8fd9\u6837\uff0c\u6240\u6709 t1 \u524d\u63d0\u4ea4\u7684 DML \u66f4\u6539\u90fd\u80fd\u901a\u8fc7\u5143\u6570\u636e\u4e2d\u7684\u5730\u5740\u67e5\u5230\u3002\u4e3a\u4e86\u53ca\u65f6\u505a checkpoint\uff0c\u4e0d\u8ba9 WAL \u65e0\u9650\u589e\u957f\uff0c\u54ea\u6015\u533a\u95f4\u4e2d block \u53ea\u6539\u52a8\u4e86\u4e00\u884c\uff0c\u4e5f\u9700\u8981\u8f6c\u5b58\u3002
MatrixOne \u7684 WAL \u80fd\u5199\u5728\u5404\u79cd Log Backend \u4e2d\u3002\u6700\u521d\u7684 Log Backend \u57fa\u4e8e\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u3002\u4e3a\u4e86\u5206\u5e03\u5f0f\u7279\u6027\uff0c\u6211\u4eec\u81ea\u7814\u4e86\u9ad8\u53ef\u9760\u4f4e\u5ef6\u8fdf Log Service \u4f5c\u4e3a\u65b0\u7684 Log Backend\u3002\u6211\u4eec\u4e3a\u9002\u914d\u4e0d\u540c\u7684 log backend\uff0c\u62bd\u8c61\u51fa\u4e00\u4e2a\u865a\u62df\u7684 backend, \u901a\u8fc7\u4e00\u4e9b\u5f88\u8f7b\u91cf\u7684 driver \u5f00\u53d1\uff0c\u5bf9\u63a5\u4e0d\u540c\u7684 backend\u3002
Driver \u9700\u8981\u9002\u914d\u51fa\u8fd9\u4e9b\u63a5\u53e3\uff1a
Append(entry) (Lsn, error)\n
Read(Lsn, maxSize) (entry, Lsn, error)\n
Truncate(lsn Lsn) error\n
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#group-commit","title":"Group Commit","text":"Group Commit \u53ef\u4ee5\u52a0\u901f\u6301\u4e45\u5316 log entry\u3002\u6301\u4e45\u5316 log entry \u6d89\u53ca\u5230 IO\uff0c\u975e\u5e38\u8017\u65f6\uff0c\u7ecf\u5e38\u662f\u63d0\u4ea4\u7684\u74f6\u9888\u3002\u4e3a\u4e86\u964d\u4f4e\u5ef6\u8fdf\uff0c\u6279\u91cf\u5411 Log Backend \u4e2d\u5199\u5165 log entry\u3002\u6bd4\u5982\uff0c\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d fsync \u8017\u65f6\u5f88\u4e45\u3002\u5982\u679c\u6bcf\u6761 entry \u90fd fsync\uff0c\u4f1a\u8017\u8d39\u5927\u91cf\u65f6\u95f4\u3002\u57fa\u4e8e\u6587\u4ef6\u7cfb\u7edf\u7684 Log Backend \u4e2d\uff0c\u591a\u4e2a entry \u5199\u5b8c\u540e\u7edf\u4e00\u53ea\u505a\u4e00\u6b21 fsync\uff0c\u8fd9\u4e9b entry \u5237\u76d8\u7684\u65f6\u95f4\u6210\u672c\u4e4b\u548c\u8fd1\u4f3c\u4e00\u6761 entry \u5237\u76d8\u7684\u65f6\u95f4\u3002
Log Service \u4e2d\u652f\u6301\u5e76\u53d1\u5199\u5165\uff0c\u5404\u6761 entry \u5237\u76d8\u7684\u65f6\u95f4\u53ef\u4ee5\u91cd\u53e0\uff0c\u8fd9\u4e5f\u80fd\u7f29\u77ed\u5199 entry \u7684\u603b\u65f6\u95f4\uff0c\u63d0\u9ad8\u4e86\u63d0\u4ea4\u7684\u5e76\u53d1\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#log-backend-lsn","title":"\u5904\u7406 Log Backend \u7684\u4e71\u5e8f LSN","text":"\u4e3a\u4e86\u52a0\u901f\uff0c\u5411 Log Backend \u5e76\u53d1\u5199\u5165 entry\uff0c\u5199\u5165\u6210\u529f\u7684\u987a\u5e8f\u548c\u53d1\u51fa\u8bf7\u6c42\u7684\u987a\u5e8f\u4e0d\u4e00\u81f4\uff0c\u5bfc\u81f4 Log Backend \u4e2d\u4ea7\u751f\u7684 LSN \u548c\u4e0a\u5c42\u4f20\u7ed9 Driver \u7684\u903b\u8f91 LSN \u4e0d\u4e00\u81f4\u3002Truncate \u548c\u91cd\u542f\u7684\u65f6\u5019\u8981\u5904\u7406\u8fd9\u4e9b\u4e71\u5e8f LSN\u3002\u4e3a\u4e86\u4fdd\u8bc1 Log Backend \u4e2d\u7684 LSN \u57fa\u672c\u6709\u5e8f\uff0c\u4e71\u5e8f\u7684\u8de8\u5ea6\u4e0d\u8981\u592a\u5927\uff0c\u7ef4\u6301\u4e86\u4e00\u4e2a\u903b\u8f91 LSN \u7684\u7a97\u53e3\uff0c\u5982\u679c\u6709\u5f88\u65e9\u7684 log entry \u6b63\u5728\u5199\u5165\u8fd8\u672a\u6210\u529f\uff0c\u4f1a\u505c\u6b62\u5411 Log Backend \u5199\u5165\u65b0\u7684 entry\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7a97\u53e3\u7684\u957f\u5ea6\u662f 7\uff0c\u56fe\u4e2d\u7684 LSN \u4e3a 13 \u7684 entry \u8fd8\u672a\u8fd4\u56de\uff0c\u5c31\u4f1a\u963b\u585e\u4f4f LSN \u5927\u4e8e\u7b49\u4e8e 20 \u7684 entry\u3002
Log Backend \u4e2d\u901a\u8fc7 truncate \u64cd\u4f5c\u9500\u6bc1\u65e5\u5fd7\uff0c\u9500\u6bc1\u6307\u5b9a LSN \u4e4b\u524d\u7684\u6240\u6709 entry\u3002\u8fd9\u4e2a LSN \u4e4b\u524d\u7684 entry \u6240\u5bf9\u5e94\u7684\u903b\u8f91 LSN \u90fd\u8981\u5c0f\u4e8e\u903b\u8f91 truncate \u70b9\u3002\u6bd4\u5982\u56fe\u4e2d\u903b\u8f91 truncate \u5230 7\uff0c\u8fd9\u6761 entry \u5bf9\u5e94 Log Backend \u4e2d\u7684 11\uff0c\u4f46\u662f Log Backend \u4e2d 5\uff0c6\uff0c7\uff0c10 \u5bf9\u5e94\u7684\u903b\u8f91 LSN \u90fd\u5927\u4e8e 7\uff0c\u4e0d\u80fd\u88ab truncate\u3002Log Backend \u53ea\u80fd truncate 4\u3002
\u91cd\u542f\u65f6\uff0c\u4f1a\u8df3\u8fc7\u5f00\u59cb\u548c\u672b\u5c3e\u90a3\u4e9b\u4e0d\u8fde\u7eed\u7684 entry\u3002\u6bd4\u5982\u56fe\u4e0a\u7684 Log Backend \u5199\u5230 14 \u65f6\uff0c\u6574\u4e2a\u673a\u5668\u65ad\u7535\u4e86\uff0c\u91cd\u542f\u65f6\u4f1a\u6839\u636e\u4e0a\u6b21\u7684 truncate \u4fe1\u606f\u8fc7\u6ee4\u6389\u5f00\u5934 8\uff0c9\uff0c11\u3002\u7b49\u8bfb\u5b8c\u6240\u6709\u7684 entry \u53d1\u73b0 6\uff0c14 \u7684\u903b\u8f91 LSN \u548c\u5176\u4ed6\u7684 entry \u4e0d\u8fde\u7eed\uff0c\u5c31\u4e22\u5f03\u672b\u5c3e\u7684 6 \u548c 14\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#matrixone-wal","title":"MatrixOne \u4e2d WAL \u7684\u5177\u4f53\u683c\u5f0f","text":"\u6bcf\u4e2a\u5199\u4e8b\u52a1\u5bf9\u5e94\u4e00\u6761 log entry\uff0c\u7531 LSN\uff0cTransaction Context \u548c\u591a\u4e2a Command \u7ec4\u6210\u3002
+---------------------------------------------------------+\n| Transaction Entry |\n+-----+---------------------+-----------+-----------+- -+\n| LSN | Transaction Context | Command-1 | Command-2 | ... |\n+-----+---------------------+-----------+-----------+- -+\n
LSN\uff1a\u6bcf\u6761 log entry \u5bf9\u5e94\u4e00\u4e2a LSN\u3002LSN \u8fde\u7eed\u9012\u589e\uff0c\u5728\u505a checkpoint \u65f6\u7528\u6765\u5220\u9664 entry\u3002
Transaction Context\uff1a\u8bb0\u5f55\u4e8b\u52a1\u4fe1\u606f
+---------------------------+\n| Transaction Context |\n+---------+----------+------+\n| StartTS | CommitTS | Memo |\n+---------+----------+------+\n
Transaction Commands\uff1a\u4e8b\u52a1\u4e2d\u6bcf\u79cd\u5199\u64cd\u4f5c\u5bf9\u5e94\u4e00\u4e2a\u6216\u591a\u4e2a command\u3002log entry \u4f1a\u8bb0\u5f55\u4e8b\u52a1\u4e2d\u6240\u6709\u7684 command\u3002
Operator Command DDL Update Catalog Insert Update Catalog Append Delete Delete Compact&Merge Update CatalogOperators\uff1aMatrixOne \u4e2d DN \u8d1f\u8d23\u63d0\u4ea4\u4e8b\u52a1\uff0c\u5411 Log Backend \u4e2d\u5199 log entry\uff0c\u505a checkpoint\u3002DN \u652f\u6301\u5efa\u5e93\uff0c\u5220\u5e93\uff0c\u5efa\u8868\uff0c\u5220\u8868\uff0c\u66f4\u65b0\u8868\u7ed3\u6784\uff0c\u63d2\u5165\uff0c\u5220\u9664\uff0c\u540c\u65f6\u540e\u53f0\u4f1a\u81ea\u52a8\u89e6\u53d1\u6392\u5e8f\u3002\u66f4\u65b0\u64cd\u4f5c\u88ab\u62c6\u5206\u6210\u63d2\u5165\u548c\u5220\u9664\u3002
DDL DDL \u5305\u62ec\u5efa\u5e93\uff0c\u5220\u5e93\uff0c\u5efa\u8868\uff0c\u5220\u8868\uff0c\u66f4\u65b0\u8868\u7ed3\u6784\u3002DN \u5728 Catalog \u91cc\u8bb0\u5f55\u4e86\u8868\u548c\u5e93\u7684\u4fe1\u606f\u3002\u5185\u5b58\u91cc\u7684 Catalog \u662f\u4e00\u68f5\u6811\uff0c\u6bcf\u4e2a\u7ed3\u70b9\u662f\u4e00\u6761 catalog entry\u3002catalog entry \u6709 4 \u7c7b\uff0cdatabase\uff0ctable\uff0csegment \u548c block\uff0c\u5176\u4e2d segment \u548c block \u662f\u5143\u6570\u636e\uff0c\u5728\u63d2\u5165\u6570\u636e\u548c\u540e\u53f0\u6392\u5e8f\u7684\u65f6\u5019\u4f1a\u53d8\u66f4\u3002\u6bcf\u6761 database entry \u5bf9\u5e94\u4e00\u4e2a\u5e93\uff0c\u6bcf\u6761 table entry \u5bf9\u5e94\u4e00\u5f20\u8868\u3002\u6bcf\u4e2a DDL \u64cd\u4f5c\u5bf9\u5e94\u4e00\u6761 database/table entry\uff0c\u5728 entry \u91cc\u8bb0\u5f55\u6210 Update Catalog Command\u3002
Insert \u65b0\u63d2\u5165\u7684\u6570\u636e\u8bb0\u5f55\u5728 Append Command \u4e2d\u3002DN \u4e2d\u7684\u6570\u636e\u8bb0\u5f55\u5728 block \u4e2d\uff0c\u591a\u4e2a block \u7ec4\u6210\u4e00\u4e2a segment\u3002\u5982\u679c DN \u4e2d\u6ca1\u6709\u8db3\u591f\u7684 block \u6216 segment \u8bb0\u5f55\u65b0\u63d2\u5165\u7684\u6570\u636e\uff0c\u5c31\u4f1a\u65b0\u5efa\u4e00\u4e2a\u3002\u8fd9\u4e9b\u53d8\u5316\u8bb0\u5f55\u5728 Update Catalog Command \u4e2d\u3002\u5927\u4e8b\u52a1\u4e2d\uff0c\u7531 CN \u76f4\u63a5\u628a\u6570\u636e\u5199\u5165 S3\uff0cDN \u53ea\u63d0\u4ea4\u5143\u6570\u636e\u3002\u8fd9\u6837\uff0cAppend Command \u4e2d\u7684\u6570\u636e\u4e0d\u4f1a\u5f88\u5927\u3002
Delete DN \u8bb0\u5f55 Delete \u53d1\u751f\u7684\u884c\u53f7\u3002\u8bfb\u53d6\u65f6\uff0c\u5148\u8bfb\u6240\u6709\u63d2\u5165\u8fc7\u7684\u6570\u636e\uff0c\u7136\u540e\u518d\u51cf\u53bb\u8fd9\u4e9b\u884c\u3002\u4e8b\u52a1\u4e2d\uff0c\u540c\u4e00\u4e2a block \u4e0a\u6240\u6709\u7684\u5220\u9664\u5408\u5e76\u8d77\u6765\uff0c\u5bf9\u5e94\u4e00\u4e2a Delete Command\u3002
Compact & Merge DN \u540e\u53f0\u53d1\u8d77\u4e8b\u52a1\uff0c\u628a\u5185\u5b58\u91cc\u7684\u6570\u636e\u8f6c\u5b58\u5230 s3 \u4e0a\u3002\u628a S3 \u4e0a\u7684\u6570\u636e\u6309\u4e3b\u952e\u6392\u5e8f\uff0c\u65b9\u4fbf\u8bfb\u7684\u65f6\u5019\u8fc7\u6ee4\u3002compact \u53d1\u751f\u5728\u4e00\u4e2a block \u4e0a\uff0ccompact \u4e4b\u540e block \u5185\u7684\u6570\u636e\u662f\u6709\u5e8f\u7684\u3002merge \u53d1\u751f\u5728 segment \u91cc\uff0c\u4f1a\u6d89\u53ca\u591a\u4e2a block\uff0cmerge \u4e4b\u540e\u6574\u4e2a segment \u5185\u6709\u5e8f\u3002compact/merge \u524d\u540e\u7684\u6570\u636e\u4e0d\u53d8\uff0c\u53ea\u6539\u53d8\u5143\u6570\u636e\uff0c\u5220\u9664\u65e7\u7684 block/segment\uff0c\u521b\u5efa\u65b0\u7684 block/segment\u3002\u6bcf\u6b21\u5220\u9664/\u521b\u5efa\u5bf9\u5e94\u4e00\u6761 Update Catalog Command\u3002
Commands
Catalog \u4ece\u4e0a\u5230\u4e0b\u6bcf\u5c42\u5206\u522b\u662f database\uff0ctable\uff0csegment \u548c block\u3002\u4e00\u6761 Updata Catalog Command \u5bf9\u5e94\u4e00\u6761 Catalog Entry\u3002\u6bcf\u6b21 ddl \u6216\u8005\u8ddf\u65b0\u5143\u6570\u636e\u5bf9\u5e94\u4e00\u6761 Update Catalog Command\u3002Update Catalog Command \u5305\u542b Dest \u548c EntryNode\u3002
+-------------------+\n| Update Catalog |\n+-------+-----------+\n| Dest | EntryNode |\n+-------+-----------+\n
Dest \u662f\u8fd9\u6761 Command \u4f5c\u7528\u7684\u4f4d\u7f6e\uff0c\u8bb0\u5f55\u4e86\u5bf9\u5e94\u7ed3\u70b9\u548c\u4ed6\u7684\u7956\u5148\u7ed3\u70b9\u7684 id\u3002\u91cd\u542f\u7684\u65f6\u5019\u4f1a\u901a\u8fc7 Dest\uff0c\u5728 Catalog \u4e0a\u5b9a\u4f4d\u5230\u64cd\u4f5c\u7684\u4f4d\u7f6e\u3002
Type Dest Update Database database id Update Table database id,table id Update Segment database id,table id,segment id Update Block atabase id,table id,segment id,block idEntryNode \u8bb0\u5f55\u4e86 entry \u7684\u521b\u5efa\u65f6\u95f4\u548c\u5220\u9664\u65f6\u95f4\u3002\u5982\u679c entry \u6ca1\u88ab\u5220\u9664\uff0c\u5220\u9664\u65f6\u95f4\u4e3a 0\u3002\u5982\u679c\u5f53\u524d\u4e8b\u52a1\u6b63\u5728\u521b\u5efa\u6216\u8005\u5220\u9664\uff0c\u5bf9\u5e94\u7684\u65f6\u95f4\u4e3a UncommitTS\u3002
+-------------------+\n| Entry Node |\n+---------+---------+\n| Create@ | Delete@ |\n+---------+---------+\n
\u5bf9\u4e8e segment \u548c block\uff0cEntry Node \u8fd8\u8bb0\u5f55\u4e86 metaLoc\uff0cdeltaLoc\uff0c\u5206\u522b\u662f\u6570\u636e\u548c\u5220\u9664\u8bb0\u5f55\u5728 S3 \u4e0a\u7684\u5730\u5740\u3002
+----------------------------------------+\n | Entry Node |\n +---------+---------+---------+----------+\n | Create@ | Delete@ | metaLoc | deltaLoc |\n +---------+---------+---------+----------+\n
\u5bf9\u4e8e table\uff0cEntry Node \u8fd8\u8bb0\u5f55\u4e86\u8868\u7ed3\u6784 schema\u3002
+----------------------------+\n | Entry Node |\n +---------+---------+--------+\n | Create@ | Delete@ | schema |\n +---------+---------+--------+\n
\u00a0\u00a0\u00a02. \u00a0Append Append Command \u4e2d\u8bb0\u5f55\u4e86\u63d2\u5165\u7684\u6570\u636e\u548c\u548c\u8fd9\u4e9b\u6570\u636e\u7684\u4f4d\u7f6e\u3002
+-------------------------------------------+\n| Append Command |\n+--------------+--------------+- -+-------+\n| AppendInfo-1 | AppendInfo-2 | ... | Batch |\n+--------------+--------------+- -+-------+\n
Batch \u662f\u63d2\u5165\u7684\u6570\u636e\u3002
AppendInfo \u4e00\u4e2a Append Data Command \u4e2d\u7684\u6570\u636e\u53ef\u80fd\u8de8\u591a\u4e2a block\u3002\u6bcf\u4e2a block \u5bf9\u5e94\u4e00\u4e2a Append Info\uff0c\u8bb0\u5f55\u4e86\u6570\u636e\u5728 Command \u7684 Batch \u4e2d\u7684\u4f4d\u7f6e pointer to data\uff0c\u8fd8\u6709\u6570\u636e\u5728 block \u4e2d\u7684\u4f4d\u7f6e destination\u3002
+------------------------------------------------------------------------------+\n| AppendInfo |\n+-----------------+------------------------------------------------------------+\n| pointer to data | destination |\n+--------+--------+-------+----------+------------+----------+--------+--------+\n| offset | length | db id | table id | segment id | block id | offset | length |\n+--------+--------+-------+----------+------------+----------+--------+--------+\n
\u00a0\u00a0\u00a03. \u00a0Delete Command \u6bcf\u4e2a Delete Command \u53ea\u5305\u542b\u4e00\u4e2a block \u4e2d\u7684\u5220\u9664\u3002
+---------------------------+\n| Delete Command |\n+-------------+-------------+\n| Destination | Delete Mask |\n+-------------+-------------+\n
MatrixOne \u662f\u4e00\u6b3e\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\u3002
\u8d85\u878d\u5408\u662f\u6307\u652f\u6491\u591a\u79cd\u8d1f\u8f7d\u7684\u80fd\u529b\u878d\u5408\uff0cMatrixOne \u652f\u6301\u5728\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u4e2d\u652f\u6491\u4e8b\u52a1\u6027\uff08OLTP\uff09\u3001\u5206\u6790\u6027\uff08OLAP\uff09\u548c\u6d41\u5f0f\u5de5\u4f5c\uff08Sreaming\uff09\u8d1f\u8f7d\uff0c\u8fd9\u79cd\u591a\u5de5\u4f5c\u8d1f\u8f7d\u8d1f\u8f7d\u7684\u80fd\u529b\u878d\u5408\uff0c\u6211\u4eec\u79f0\u4e4b\u4e3a HSTAP (Hybrid Streaming & Transaction/Analytical Processing). HSTAP \u6570\u636e\u5e93\u5bf9 HTAP \u6570\u636e\u5e93\u8fdb\u884c\u4e86\u91cd\u65b0\u5b9a\u4e49\uff0cHSTAP \u65e8\u5728\u6ee1\u8db3\u5355\u4e00\u6570\u636e\u5e93\u5185\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u548c\u5206\u6790\u5904\u7406\uff08AP\uff09\u7684\u6240\u6709\u9700\u6c42\u3002\u4e0e\u4f20\u7edf\u7684 HTAP \u76f8\u6bd4\uff0cHSTAP \u5f3a\u8c03\u5176\u5185\u7f6e\u7684\u7528\u4e8e\u8fde\u63a5 TP \u548c AP \u8868\u6570\u636e\u6d41\u5904\u7406\u80fd\u529b\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u6570\u636e\u5e93\u53ef\u4ee5\u50cf\u5927\u6570\u636e\u5e73\u53f0\u4e00\u6837\u7075\u6d3b\u7684\u4f7f\u7528\u4f53\u9a8c\u3002\u4e5f\u6070\u6070\u5f97\u76ca\u4e8e\u5927\u6570\u636e\u7684\u7e41\u8363\uff0c\u5f88\u591a\u7528\u6237\u5df2\u7ecf\u719f\u6089\u4e86\u8fd9\u79cd\u4f53\u9a8c\u3002\u7528\u6237\u4f7f\u7528 MatrixOne \u53ea\u9700\u8981\u5c11\u91cf\u7684\u96c6\u6210\u5de5\u4f5c\uff0c\u5373\u53ef\u4ee5\u83b7\u5f97\u8986\u76d6\u6574\u4e2a TP \u548c AP \u573a\u666f\u7684\u4e00\u7ad9\u5f0f\u4f53\u9a8c\uff0c\u540c\u65f6\u53ef\u4ee5\u6446\u8131\u4f20\u7edf\u5927\u6570\u636e\u5e73\u53f0\u7684\u81c3\u80bf\u67b6\u6784\u53ca\u5404\u79cd\u9650\u5236\u3002
\u5f02\u6784\u4e91\u539f\u751f\u662f\u6307\u9762\u5411\u4e91\u539f\u751f\u57fa\u7840\u8bbe\u65bd\uff08K8s \u53ca\u5bf9\u8c61\u5b58\u50a8\uff09\uff0cMatrixOne \u5b8c\u5168\u91cd\u65b0\u8bbe\u8ba1\u4e86\u4e00\u5957\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u5f15\u64ce\uff0c\u53ef\u4ee5\u6ee1\u8db3\u516c\u6709\u4e91\uff0c\u79c1\u6709\u4e91\uff0c\u8fb9\u7f18\u4e91\u7b49\u591a\u79cd\u5355\u4e00\u4e91\u73af\u5883\u53ca\u591a\u79cd\u8de8\u4e91\u73af\u5883\u7684\u90e8\u7f72\u6a21\u5f0f\uff0c\u540c\u65f6\u6700\u5927\u7a0b\u5ea6\u7684\u5229\u7528\u4e91\u539f\u751f\u73af\u5883\u7684\u7279\u70b9\uff0c\u5b9e\u73b0\u5b58\u7b97\u5206\u79bb\u53ca\u7ebf\u6027\u6269\u5c55\u3002\u5728\u4ee5 K8s \u4e3b\u5bfc\u7684\u4e91\u539f\u751f\u73af\u5883\u4e2d\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u4e00\u76f4\u4ee5\u6765\u4f5c\u4e3a\u6709\u72b6\u6001\u7cfb\u7edf\u90fd\u672a\u88ab\u5f88\u597d\u7684\u7edf\u4e00\u7eb3\u7ba1\u8d77\u6765\uff0c\u800c\u662f\u4ecd\u7136\u57fa\u4e8e\u7269\u7406\u673a\u6216\u8005\u865a\u62df\u673a\u7684\u5f62\u5f0f\u72ec\u7acb\u90e8\u7f72\u53ca\u8fd0\u7ef4\uff0c\u6839\u672c\u539f\u56e0\u662f\u56e0\u4e3a\u4f20\u7edf\u7684\u5355\u673a/\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u672a\u6839\u636e\u4e91\u539f\u751f\u73af\u5883\u8fdb\u884c\u6539\u9020\u3002\u800c MatrixOne \u5219\u662f\u4ece 0 \u5f00\u59cb\uff0c\u5b58\u50a8\u4e0e\u8ba1\u7b97\u5f15\u64ce\u5747\u5b8c\u5168\u81ea\u7814\uff0c\u9762\u5411\u4e91\u539f\u751f\u73af\u5883\u8bbe\u8ba1\uff0c\u53ef\u4ee5\u6700\u5927\u7a0b\u5ea6\u7684\u5229\u7528\u5bb9\u5668\u5316\u7684\u8f6f\u4ef6\u5b9a\u4e49\u8d44\u6e90\u4ee5\u53ca\u7075\u6d3b\u8c03\u914d\u7684\u7279\u70b9\uff0c\u5b9e\u73b0\u4e0e\u5e94\u7528\u5c42\u7edf\u4e00\u5230\u540c\u4e00\u5957\u4e91\u539f\u751f\u73af\u5883\u4e2d\u3002\u540c\u65f6\u7531\u4e8e K8s \u672c\u8eab\u7684\u8de8\u4e91\u80fd\u529b\uff0cMatrixOne \u53ef\u4ee5\u65e0\u7f1d\u517c\u5bb9\u5404\u79cd\u5f02\u6784\u7684\u4e91\u53ca IaaS \u73af\u5883\uff0c\u5e76\u4e14\u7075\u6d3b\u5b9e\u73b0\u8de8\u591a\u4e91\u548c\u591a\u7aef\u7684\u90e8\u7f72\u3002
"},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone_2","title":"MatrixOne \u67b6\u6784\u5c42\u7ea7","text":"\u5982\u4e0b\u56fe\u6240\u793a\uff0cMatrixOne \u6574\u4f53\u662f\u57fa\u4e8e Kubernetes \u800c\u6784\u5efa\uff0c\u5168\u90e8\u662f\u4ee5\u5bb9\u5668\u5316\u7684\u5f62\u5f0f\u6784\u5efa\u53ca\u7ba1\u7406\u3002MatrixOne \u6574\u4f53\u5206\u6210\u4e09\u5c42\u67b6\u6784\uff0c\u5206\u522b\u662f\u8ba1\u7b97\u5c42\uff0c\u4e8b\u52a1\u5c42\uff0c\u5b58\u50a8\u5c42\u3002MatrixOne \u7684\u5b58\u50a8\uff0c\u8ba1\u7b97\u548c\u4e8b\u52a1\u4e09\u5c42\u662f\u5b8c\u5168\u5206\u79bb\u89e3\u8026\u7684\uff0c\u6bcf\u5c42\u90fd\u6709\u81ea\u5df1\u7684\u5bf9\u8c61\u5355\u5143\u548c\u5206\u5de5\uff0c\u4e0d\u540c\u5c42\u7684\u8282\u70b9\u548c\u8d44\u6e90\u5b8c\u5168\u89e3\u8026\uff0c\u72ec\u7acb\u81ea\u7531\u4f38\u7f29\u3002
\u5b58\u50a8\u5c42\uff1aMatrixOne \u9762\u5411\u4e91\u539f\u751f\u73af\u5883\u8bbe\u8ba1\uff0c\u5728\u4e91\u73af\u5883\u4e2d\u5bf9\u8c61\u5b58\u50a8\u5df2\u7ecf\u6210\u4e3a\u4e8b\u5b9e\u4e0a\u7684\u5b58\u50a8\u6807\u51c6\uff0c\u53ef\u9760\u6027\u9ad8\uff0c\u4ef7\u683c\u4f4e\u5ec9\uff0c\u5e76\u4e14\u81ea\u5e26\u8fd1\u4e4e\u65e0\u9650\u6269\u5c55\u80fd\u529b\u3002\u56e0\u6b64 MatrixOne \u9009\u7528\u517c\u5bb9 S3 \u534f\u8bae\u7684\u5bf9\u8c61\u5b58\u50a8\u4f5c\u4e3a\u4e3b\u5b58\u50a8\uff0c\u6240\u6709\u7684\u6570\u636e\u6700\u7ec8\u90fd\u4f1a\u6301\u4e45\u5316\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002\u76ee\u524d\u4e3b\u6d41\u7684\u516c\u6709\u4e91\u53ca\u79c1\u6709\u5316\u5382\u5546\u5747\u63d0\u4f9b\u4e86\u517c\u5bb9 S3 \u534f\u8bae\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff0cMatrixOne \u5747\u53ef\u4ee5\u65e0\u7f1d\u517c\u5bb9\u3002\u9488\u5bf9\u4e0d\u5e26\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684\u7269\u7406\u673a/\u865a\u62df\u673a\u73af\u5883\uff0c\u53ef\u4ee5\u901a\u8fc7\u90e8\u7f72\u5f00\u6e90 Minio \u7684\u5f62\u5f0f\u81ea\u884c\u642d\u5efa\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
\u8ba1\u7b97\u5c42\uff1a\u4ee5\u8ba1\u7b97\u8282\u70b9 Compute Node (\u7b80\u79f0 CN) \u4e3a\u5355\u4f4d\uff0c\u5728 K8s \u91cc\uff0c\u6bcf\u4e2a CN \u90fd\u662f\u4e00\u4e2a\u65e0\u72b6\u6001\u7684\u5bb9\u5668 Pod\uff0c\u53ef\u4ee5\u901a\u8fc7\u8f6f\u4ef6\u5b9a\u4e49\u7684\u65b9\u5f0f\u81ea\u7531\u6307\u5b9a\u8d44\u6e90\u5927\u5c0f\u53ca\u4e2a\u6570\uff0c\u7531 K8s \u8d1f\u8d23\u8d44\u6e90\u4f9b\u7ed9\u3002\u4e3a\u4e86\u52a0\u5feb\u67e5\u8be2\u6027\u80fd\uff0c\u6bcf\u4e2a CN \u8282\u70b9\u4e2d\u4f1a\u6709\u5185\u5b58\u53ca\u672c\u5730\u78c1\u76d8\u7684\u4e24\u7ea7\u7f13\u5b58\uff0c\u65b0\u67e5\u8be2\u8fc7\u7684\u6570\u636e\u4f1a\u7f13\u5b58\u5230 CN \u8282\u70b9\u4e2d\uff0c\u7f6e\u6362\u7b56\u7565\u4e3a LRU\u3002\u7531\u4e8e CN \u8282\u70b9\u5b8c\u5168\u65e0\u72b6\u6001\uff0c\u56e0\u6b64\u53ef\u4ee5\u4efb\u610f\u91cd\u542f\uff0c\u4efb\u610f\u7eb5\u5411\u548c\u6a2a\u5411\u6269\u5c55\uff0c\u4e14\u4f5c\u4e3a\u5bb9\u5668 Pod\uff0cCN \u8282\u70b9\u53ef\u4ee5\u505a\u5230\u79d2\u7ea7\u7684\u5feb\u901f\u6269\u7f29\u5bb9\uff0c\u540c\u65f6\u5728\u53d1\u751f\u4e86\u6545\u969c\u7684\u65f6\u5019\u8fc5\u901f\u91cd\u542f\u6216\u8005\u5207\u6362\u5176\u4ed6 CN\u3002
\u4e8b\u52a1\u5c42\uff1aMatrixOne \u6574\u4f53\u662f\u642d\u5efa\u5728\u5bb9\u5668\u670d\u52a1\u53ca\u5bf9\u8c61\u5b58\u50a8\u4e0a\u7684\u67b6\u6784\uff0c\u8fd9\u4e2a\u67b6\u6784\u5bf9\u4e8e\u63d0\u4f9b OLAP \u670d\u52a1\u662f\u975e\u5e38\u5408\u9002\u7684\uff0cOLAP \u5bf9\u6570\u636e IO \u7684\u5e76\u53d1\u8981\u6c42\u8f83\u4f4e\uff0c\u4e14\u6570\u636e\u5757\u8f83\u5927\u3002\u4f46\u662f\u5982\u679c\u9700\u8981\u63d0\u4f9b\u9ad8\u5e76\u53d1\u5199\u5165\u7684 TP \u80fd\u529b\uff0c\u5b8c\u5168\u57fa\u4e8e\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u65e0\u6cd5\u6ee1\u8db3\u8981\u6c42\u3002\u7531\u4e8e S3 \u534f\u8bae\u7684\u5bf9\u8c61\u5b58\u50a8\u53ea\u80fd\u652f\u6301\u6570\u767e\u7ea7\u522b\u7684 IO \u5e76\u53d1\uff0c\u4e14\u5bf9\u4e8e\u5c0f\u6587\u4ef6\u7684\u8bfb\u5199\u4e0d\u53cb\u597d\u3002\u56e0\u6b64\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cMatrixOne \u4e13\u95e8\u8bbe\u8ba1\u4e86\u4e00\u5c42\u4e8b\u52a1\u5c42\u3002\u4e8b\u52a1\u5c42\u5305\u542b\u4e24\u4e2a\u7ec4\u4ef6\uff0c\u4e8b\u52a1\u8282\u70b9 Transaction Node\uff08\u7b80\u79f0 TN\uff09\u548c\u65e5\u5fd7\u670d\u52a1 Log Service\uff08\u7b80\u79f0 LS\uff09\u3002TN \u548c LS \u4e3b\u8981\u670d\u52a1\u4e8e\u6570\u636e\u5199\u5165\u76f8\u5173\u6d41\u7a0b\u3002
\u5728 MatrixOne \u4e2d\uff0c\u4e3a\u5b9e\u73b0\u5206\u5e03\u5f0f\u4e0e\u591a\u5f15\u64ce\u7684\u878d\u5408\uff0c\u6784\u5efa\u4e86\u591a\u79cd\u4e0d\u540c\u7684\u7cfb\u7edf\u7ec4\u4ef6\u7528\u4e8e\u5b8c\u6210\u67b6\u6784\u76f8\u5173\u7684\u5c42\u7ea7\u7684\u529f\u80fd\uff1a
"},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#file-service","title":"File Service","text":"File Service \u662f MatrixOne \u8d1f\u8d23\u6240\u6709\u5b58\u50a8\u4ecb\u8d28\u8bfb\u5199\u7684\u7ec4\u4ef6\u3002\u5b58\u50a8\u4ecb\u8d28\u5305\u62ec\u5185\u5b58\u3001\u78c1\u76d8\u3001\u5bf9\u8c61\u5b58\u50a8\u7b49\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Log Service \u662f MatrixOne \u4e2d\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u4e8b\u52a1\u65e5\u5fd7\u7684\u7ec4\u4ef6\uff0c\u5b83\u5177\u6709\u5982\u4e0b\u529f\u80fd\u7279\u6027\uff1a
Transaction Node\uff08TN\uff09\uff0c\u662f\u7528\u6765\u8fd0\u884c MatrixOne \u7684\u5206\u5e03\u5f0f\u5b58\u50a8\u5f15\u64ce TAE \u7684\u8f7d\u4f53\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Computing Node\uff08CN\uff09\uff0c\u662f Matrixone \u63a5\u6536\u7528\u6237\u8bf7\u6c42\u5e76\u5904\u7406 SQL \u7684\u7ec4\u4ef6\uff0c\u5177\u4f53\u5305\u62ec\u4ee5\u4e0b\u6a21\u5757\uff1a
Stream Engine \u662f MatrixOne \u5185\u7f6e\u7684\u5168\u65b0\u7ec4\u4ef6\uff0c\u65e8\u5728\u652f\u6301\u5b9e\u65f6\u6570\u636e\u67e5\u8be2\u3001\u5904\u7406\u4ee5\u53ca\u589e\u5f3a\u6570\u636e\u5b58\u50a8\uff0c\u7279\u522b\u9488\u5bf9\u4f20\u5165\u7684\u6570\u636e\u6d41\uff08\u6570\u636e\u70b9\u5e8f\u5217\uff09\u3002\u501f\u52a9 Stream Engine\uff0c\u60a8\u80fd\u591f\u4f7f\u7528 SQL \u5b9a\u4e49\u5e76\u6784\u5efa\u6d41\u5904\u7406\u7ba1\u9053\uff0c\u5c06\u5176\u4f5c\u4e3a\u5b9e\u65f6\u6570\u636e\u540e\u7aef\u63d0\u4f9b\u670d\u52a1\uff1b\u540c\u65f6\uff0c\u60a8\u4e5f\u80fd\u591f\u8fd0\u7528 SQL \u67e5\u8be2\u6d41\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4e0e\u975e\u6d41\u5f0f\u6570\u636e\u96c6\u8fdb\u884c\u8054\u63a5\uff0c\u4ece\u800c\u66f4\u8fdb\u4e00\u6b65\u5730\u7b80\u5316\u6574\u4e2a\u6570\u636e\u5806\u6808\u7684\u5904\u7406\u6d41\u7a0b\u3002
"},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#proxy","title":"Proxy","text":"Proxy \u7ec4\u4ef6\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u4e0e SQL \u8def\u7531\u3002\u5b83\u5177\u6709\u4ee5\u4e0b\u529f\u80fd\uff1a
\u672c\u8282\u4ecb\u7ecd\u4e86 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\u6982\u89c8\u3002\u5176\u4ed6\u4fe1\u606f\u53ef\u53c2\u89c1\uff1a
\u5b89\u88c5\u5355\u673a\u7248 MatrixOne
\u6700\u65b0\u53d1\u5e03\u4fe1\u606f
MatrixOne \u5185\u7f6e\u6d41\u5f15\u64ce\uff0c\u7528\u4e8e\u5b9e\u65f6\u67e5\u8be2\u3001\u5904\u7406\u548c/\u6216\u4e30\u5bcc\u4f20\u5165\u7684\u4e00\u7cfb\u5217\u6570\u636e\u70b9\uff08\u5373\u6570\u636e\u6d41\uff09\u7684\u6570\u636e\u5b58\u50a8\u3002\u5f00\u53d1\u4eba\u5458\u73b0\u5728\u53ef\u4ee5\u4f7f\u7528 SQL \u6765\u5b9a\u4e49\u548c\u521b\u5efa\u6d41\u5904\u7406\u7ba1\u9053\uff0c\u5e76\u4f5c\u4e3a\u5b9e\u65f6\u6570\u636e\u540e\u7aef\u63d0\u4f9b\u670d\u52a1\uff1b\u5f00\u53d1\u4eba\u5458\u8fd8\u53ef\u4ee5\u4f7f\u7528 SQL \u67e5\u8be2\u6d41\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4e0e\u975e\u6d41\u5f0f\u6570\u636e\u96c6\u8fde\u63a5\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u7b80\u5316\u6570\u636e\u5806\u6808\u3002
"},{"location":"MatrixOne/Overview/architecture/streaming/#_2","title":"\u6280\u672f\u67b6\u6784","text":"MatrixOne \u6d41\u5f15\u64ce\u6280\u672f\u67b6\u6784\u5982\u4e0b\u6240\u793a\uff1a
MatrixOne \u5df2\u6210\u529f\u5f00\u53d1\u51fa\u4e00\u5957\u9ad8\u6548\u7684\u6d41\u5f0f\u8868\u521b\u5efa\u673a\u5236\uff0c\u76ee\u524d\u7279\u522b\u9488\u5bf9 Kafka \u8fdb\u884c\u4e86\u6df1\u5ea6\u6574\u5408\u3002\u6b64\u4e3e\u65e8\u5728\u4f18\u5316\u5927\u89c4\u6a21\u65f6\u5e8f\u6570\u636e\u573a\u666f\u4e0b\u7684\u6d41\u5f0f\u6570\u636e\u5904\u7406\u80fd\u529b\u3002
\u4ece\u6280\u672f\u7ec6\u8282\u6765\u770b\uff0cMatrixOne \u901a\u8fc7 Source \u529f\u80fd\u5b9e\u73b0\u4e0e\u5916\u90e8\u6d41\u5f0f\u6570\u636e\u6e90\u7684\u9ad8\u6548\u8fde\u63a5\u4e0e\u96c6\u6210\u3002\u901a\u8fc7\u52a8\u6001\u8868\u4e0e Source \u7684\u94fe\u63a5\uff0cMatrixOne \u4e0d\u4ec5\u80fd\u591f\u5b9e\u73b0\u6570\u636e\u7684\u6301\u4e45\u5316\u5b58\u50a8\uff0c\u8fd8\u80fd\u5bf9\u6d41\u5165\u6570\u636e\u6267\u884c\u590d\u6742\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u5347\u6570\u636e\u5904\u7406\u7684\u7075\u6d3b\u6027\u548c\u6548\u7387\u3002
"},{"location":"MatrixOne/Overview/architecture/streaming/#source","title":"Source","text":"\u5728 MatrixOne \u7684\u67b6\u6784\u4e2d\uff0cSource \u626e\u6f14\u7740\u5173\u952e\u89d2\u8272\uff0c\u5b83\u662f\u5916\u90e8\u6570\u636e\u6d41\u4e0e MatrixOne \u6570\u636e\u5e93\u8868\u4e4b\u95f4\u7684\u6865\u6881\u3002\u901a\u8fc7\u5b9e\u73b0\u7cbe\u786e\u7684\u8fde\u63a5\u4e0e\u6570\u636e\u6620\u5c04\u673a\u5236\uff0cSource \u4e0d\u4ec5\u786e\u4fdd\u4e86\u6570\u636e\u6d41\u7684\u65e0\u7f1d\u5bf9\u63a5\uff0c\u800c\u4e14\u4fdd\u969c\u4e86\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\u3002
\u6bcf\u5f53\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Source \u5b9e\u4f8b\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u540c\u540d\u7684 Source \u8868\u3002\u8fd9\u4e2a\u8868\u88ab\u8bbe\u8ba1\u4e3a\u4e34\u65f6\u6027\u6570\u636e\u5b58\u50a8\u7a7a\u95f4\uff0c\u80fd\u591f\u5bb9\u7eb3\u6240\u6709\u6d41\u5165\u7684\u6570\u636e\uff0c\u5e76\u652f\u6301\u6570\u636e\u7684\u52a8\u6001\u589e\u957f\u548c\u5b9e\u65f6\u66f4\u65b0\u3002
\u76ee\u524d MatrixOne \u4ec5\u652f\u6301\u8fde\u63a5\u5230 Kafka\uff0c\u5e76\u4f7f\u7528 JSON \u6570\u636e\u8fdb\u884c\u6620\u5c04\uff0c\u4ee5\u4e0b\u662f\u521b\u5efa Source \u7684\u8bed\u6cd5\uff1a
CREATE [OR REPLACE] SOURCE [IF NOT EXISTS] stream_name ( { column_name data_type [KEY | HEADERS | HEADER(key)] } [, ...] )\nWITH ( property_name = expression [, ...]);\n
\u4f8b\u5982\u4f7f\u7528\u4e0b\u9762\u7684 sql \u8bed\u53e5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a stream_test \u7684 source\uff1a
create source stream_test(c1 char(25),c2 varchar(500),c3 text,c4 tinytext,c5 mediumtext,c6 longtext )with(\n\"type\"='kafka',\n\"topic\"= 'test',\n\"partition\" = '0',\n\"value\"= 'json',\n\"bootstrap.servers\"='127.0.0.1:9092' )\n
"},{"location":"MatrixOne/Overview/architecture/streaming/#dynamic-table","title":"\u52a8\u6001\u8868 Dynamic Table","text":"\u52a8\u6001\u8868\uff08Dynamic Table\uff09\u662f MatrixOne \u4e2d\u7684\u4e00\u4e2a\u6570\u636e\u7ba1\u9053\u3002\u52a8\u6001\u8868\u80fd\u591f\u5b9e\u65f6\u6355\u6349\u3001\u5904\u7406\u5e76\u8f6c\u6362\u6d41\u5165\u7684\u6570\u636e\uff0c\u4ece\u800c\u4fdd\u8bc1\u4fe1\u606f\u6d41\u5728\u6574\u4e2a\u7cfb\u7edf\u4e2d\u7684\u5373\u65f6\u66f4\u65b0\u548c\u51c6\u786e\u8868\u8fbe\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4e0d\u4ec5\u63d0\u5347\u4e86\u6570\u636e\u5904\u7406\u7684\u7075\u6d3b\u6027\u548c\u6548\u7387\uff0c\u8fd8\u4f18\u5316\u4e86\u6574\u4e2a\u7cfb\u7edf\u5bf9\u4e8e\u590d\u6742\u6570\u636e\u573a\u666f\u7684\u54cd\u5e94\u80fd\u529b\u548c\u5904\u7406\u6027\u80fd\u3002
\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u8bed\u6cd5\u7ed3\u6784\u521b\u5efa\u52a8\u6001\u8868\uff1a
CREATE DYNAMIC TABLE [IF NOT EXISTS] table_name AS SELECT ... from stream_name ;\n
\u793a\u4f8b\u5982\u4e0b\uff1a
create dynamic table dt_test as select * from stream_test;\n
"},{"location":"MatrixOne/Overview/feature/cost-effective/","title":"\u9ad8\u6027\u4ef7\u6bd4","text":"MatrixOne \u662f\u4e00\u6b3e\u5168\u65b0\u8bbe\u8ba1\u7684\u6570\u636e\u5e93\uff0c\u5176\u67b6\u6784\u8bbe\u8ba1\u7406\u5ff5\u5f3a\u8c03\u9ad8\u6027\u4ef7\u6bd4\u3002MatrixOne \u7684\u9ad8\u6027\u4ef7\u6bd4\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
"},{"location":"MatrixOne/Overview/feature/cost-effective/#htap","title":"\u5355\u96c6\u7fa4\u652f\u6301\u6df7\u5408\u8d1f\u8f7d HTAP","text":"\u968f\u7740\u5927\u6570\u636e\u5e94\u7528\u7684\u5feb\u901f\u666e\u53ca\u4e0e\u591a\u5143\u5316\u53d1\u5c55\uff0c\u4f20\u7edf\u7684\u6570\u636e\u5904\u7406\u65b9\u6848\u8d8a\u6765\u8d8a\u96be\u4ee5\u6ee1\u8db3\u6d77\u91cf\u6570\u636e\u5b9e\u65f6\u5206\u6790\u7684\u9700\u6c42\u3002\u73b0\u4ee3\u6570\u636e\u5e94\u7528\u9700\u6c42\u66f4\u52a0\u503e\u5411\u4e8e\u540c\u65f6\u8003\u8651\u9ad8\u5e76\u53d1\u7684 OLTP \u4e8b\u52a1\u578b\u4e1a\u52a1\u548c\u5927\u89c4\u6a21\u6570\u636e\u7684 OLAP \u5206\u6790\u578b\u4e1a\u52a1\u3002
MatrixOne \u662f\u4e13\u95e8\u8bbe\u8ba1\u7528\u6765\u89e3\u51b3\u6df7\u5408\u8d1f\u8f7d\u95ee\u9898\u7684\u6570\u636e\u5e93\u3002MatrixOne \u80fd\u591f\u5728\u540c\u4e00\u4e2a\u96c6\u7fa4\u4e2d\u540c\u65f6\u652f\u6301 OLTP \u548c OLAP\uff0c\u771f\u6b63\u5b9e\u73b0\u6df7\u5408\u4e8b\u52a1/\u5206\u6790\u5904\u7406\uff08Hybrid Transaction and Analytical Processing\uff0cHTAP\uff09\u3002\u7528\u6237\u4e0d\u518d\u9700\u8981\u5206\u522b\u642d\u5efa OLTP \u548c OLAP \u4e24\u4e2a\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u53ea\u9700\u4e00\u4e2a\u6570\u636e\u5e93\u5c31\u80fd\u652f\u6301\u6df7\u5408\u8d1f\u8f7d\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u4e0d\u4ec5\u907f\u514d\u4e86\u5efa\u8bbe\u548c\u7ef4\u62a4\u4e24\u5957\u7cfb\u7edf\u7684\u6210\u672c\uff0c\u8fd8\u907f\u514d\u4e86\u5c06\u6570\u636e\u4ece OLTP \u7cfb\u7edf\u540c\u6b65\u5230 OLAP \u7cfb\u7edf\u7684 ETL \u8fc7\u7a0b\u3002\u7528\u6237\u80fd\u591f\u5728\u540c\u4e00\u4e2a\u96c6\u7fa4\u4e2d\u65b9\u4fbf\u5730\u5904\u7406\u4e1a\u52a1\u548c\u5206\u6790\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#htap_1","title":"\u5355\u4e00\u5b58\u50a8\u5f15\u64ce\u5b9e\u73b0 HTAP","text":"\u5728\u6570\u636e\u5e93\u9886\u57df\uff0c\u5b9e\u73b0 HTAP \u901a\u5e38\u9700\u8981\u5c06\u4e00\u4e2a OLTP \u5f15\u64ce\u548c\u4e00\u4e2a OLAP \u5f15\u64ce\u5c01\u88c5\u5230\u4e00\u4e2a\u6570\u636e\u5e93\u4ea7\u54c1\u4e2d\u3002\u867d\u7136\u6570\u636e\u5728\u4e24\u4e2a\u5b58\u50a8\u5f15\u64ce\u4e4b\u95f4\u7684\u8f6c\u6362\u8fc7\u7a0b\u5bf9\u7528\u6237\u662f\u9690\u85cf\u7684\uff0c\u7528\u6237\u53ea\u770b\u5230\u4e00\u4e2a\u7edf\u4e00\u7684 SQL \u63a5\u53e3\uff0c\u4f46\u5b9e\u9645\u4e0a\u6570\u636e\u5728\u4e24\u4e2a\u5b58\u50a8\u5f15\u64ce\u5404\u5b58\u4e00\u4efd\uff0c\u786c\u4ef6\u548c\u5b58\u50a8\u6210\u672c\u5e76\u672a\u964d\u4f4e\u3002
\u4e0e\u4e0a\u8ff0\u5f15\u64ce\u5c01\u88c5\u65b9\u5f0f\u4e0d\u540c\uff0cMatrixOne \u5229\u7528\u5355\u4e00\u5b58\u50a8\u5f15\u64ce\u5b9e\u73b0 HTAP\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0cMatrixOne \u901a\u8fc7\u5bf9\u4e0d\u540c\u8ba1\u7b97\u8282\u70b9 CN \u8fdb\u884c\u5206\u7ec4\uff0c\u4ee5\u53ca\u5728\u8d1f\u8f7d\u7684\u8fd0\u884c\u94fe\u8def\u4e0a\u8fdb\u884c\u533a\u5206\uff0c\u5b9e\u73b0\u5355\u5f15\u64ce\u7684 HTAP\u3002\u5f53\u7528\u6237\u7684\u5e94\u7528\u8bf7\u6c42\u8fdb\u5165 MatrixOne \u96c6\u7fa4\u65f6\uff0cProxy \u6a21\u5757\u4f1a\u5c06 OLAP \u7c7b\u7684\u8bf7\u6c42\u5206\u53d1\u5230\u4e13\u95e8\u5904\u7406 OLAP \u7684 CN \u7ec4\u3002\u8fd9\u4e9b\u8bf7\u6c42\u901a\u5e38\u9700\u8981\u5927\u8303\u56f4\u5730\u8bfb\u53d6\u6216\u5199\u5165\u6570\u636e\uff0c\u7531 CN \u8282\u70b9\u76f4\u63a5\u4e0e\u5bf9\u8c61\u5b58\u50a8\u8fdb\u884c\u4ea4\u4e92\u3002\u800c OLTP \u7c7b\u7684\u8bf7\u6c42\uff0c\u5982\u5c0f\u6570\u636e\u91cf\u7684 INSERT
\uff0cUPDATE
\uff0cDELETE
\uff0c\u5219\u4f1a\u901a\u8fc7\u53e6\u4e00\u7ec4\u4e13\u95e8\u5904\u7406 OLTP \u7684 CN \u7ec4\uff0c\u5e76\u7531 TN \u8282\u70b9\u5904\u7406\u4e8b\u52a1\u4fe1\u606f\uff0c\u5e76\u5199\u5165 LogService \u7684\u5171\u4eab\u65e5\u5fd7\u3002TN \u8fd8\u4f1a\u4e0d\u65ad\u5730\u5c06 LogService \u4e2d\u7684\u5c11\u91cf\u4e8b\u52a1\u7c7b\u6570\u636e\u8fdb\u884c\u538b\u7f29\u548c\u5408\u5e76\uff0c\u518d\u5199\u5165\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002
\u603b\u7684\u6765\u8bf4\uff0c\u7528\u6237\u5199\u5165 MatrixOne \u7684\u6570\u636e\u53ea\u5b58\u5728\u4e00\u4efd\uff0c\u5e76\u901a\u8fc7\u5355\u4e00\u7684\u5b58\u50a8\u5f15\u64ce\u8fdb\u884c\u5904\u7406\uff0c\u5927\u5e45\u5ea6\u964d\u4f4e\u4e86\u5b58\u50a8\u548c\u8ba1\u7b97\u786c\u4ef6\u7684\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#_2","title":"\u7075\u6d3b\u7684\u8d44\u6e90\u5206\u914d\u63d0\u9ad8\u673a\u5668\u5229\u7528\u7387","text":"\u5728\u5b9e\u9645\u7684\u6570\u636e\u5e94\u7528\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u7cfb\u7edf\u5927\u90e8\u5206\u65f6\u95f4\u662f\u670d\u52a1\u4e8e\u57fa\u4e8e CRUD \u7684\u4e8b\u52a1\u578b\u4e1a\u52a1\u3002\u7136\u800c\uff0c\u5728\u7279\u5b9a\u7684\u65f6\u95f4\u70b9\uff0c\u5982\u665a\u4e0a\u3001\u6708\u5e95\u6216\u8005\u5e74\u5e95\uff0c\u9700\u8981\u5bf9\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u603b\u4f53\u6570\u636e\u8fdb\u884c\u5206\u6790\u3002\u8fd9\u65f6\uff0c\u5982\u679c\u7528\u6237\u53ea\u6709\u4e00\u4e2a\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u5c31\u9700\u8981\u4e34\u65f6\u51cf\u5c11\u4e1a\u52a1\u8d1f\u8f7d\uff0c\u6216\u8005\u5728\u4e1a\u52a1\u8d1f\u8f7d\u8f83\u4f4e\u7684\u65f6\u5019\u8fdb\u884c OLAP \u5206\u6790\u4efb\u52a1\u3002\u7136\u800c\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u901a\u5e38\u4f1a\u9762\u4e34\u5206\u6790\u65f6\u95f4\u8fc7\u957f\uff0c\u4e0d\u80fd\u5f71\u54cd\u4e1a\u52a1\u8fd0\u884c\u7684\u957f\u65f6\u95f4\u7b49\u95ee\u9898\u3002\u5982\u679c\u7528\u6237\u4e3a OLAP \u5206\u6790\u578b\u4e1a\u52a1\u5355\u72ec\u90e8\u7f72\u4e00\u5957\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u4f46\u5b9e\u9645\u7684\u5206\u6790\u578b\u4e1a\u52a1\u5f80\u5f80\u96be\u4ee5\u6700\u5927\u5316\u5229\u7528\uff0c\u4e5f\u4f1a\u5bfc\u81f4\u4e00\u5b9a\u7684\u8d44\u6e90\u6d6a\u8d39\u3002
\u5982\u4e0a\u4e00\u90e8\u5206\u6240\u4ecb\u7ecd\u7684\uff0cMatrixOne \u901a\u8fc7\u5bf9\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9\u8fdb\u884c\u5206\u7ec4\uff0c\u4ee5\u53ca\u5728\u5e95\u5c42\u901a\u8fc7\u4e0d\u540c\u7684\u94fe\u8def\u652f\u6301 OLTP \u548c OLAP \u4e1a\u52a1\uff0c\u5b9e\u73b0 HTAP\u3002\u8fd9\u79cd\u67b6\u6784\u4f7f\u5f97 MatrixOne \u80fd\u591f\u6839\u636e\u5b9e\u9645\u4e1a\u52a1\u9700\u6c42\uff0c\u7075\u6d3b\u5730\u8c03\u6574\u8d44\u6e90\u5206\u914d\uff0c\u4ee5\u6b64\u63d0\u9ad8\u673a\u5668\u5229\u7528\u7387\uff0c\u5b9e\u73b0\u771f\u6b63\u7684\u9ad8\u6027\u4ef7\u6bd4\u3002 \u5982\u679c CRUD \u7c7b\u578b\u7684\u4e1a\u52a1\u9700\u6c42\u8f83\u9ad8\u65f6\uff0c\u4f60\u53ef\u4ee5\u4e3a OLTP \u5206\u914d\u66f4\u591a\u7684 CN \u8282\u70b9\u3002\u76f8\u5e94\u5730\uff0c\u5f53\u5206\u6790\u578b\u4e1a\u52a1\u9700\u6c42\u5347\u9ad8\u65f6\uff0c\u4f60\u53ef\u4ee5\u4e3a OLAP \u5206\u914d\u66f4\u591a\u7684 CN \u8282\u70b9\u3002\u8fd9\u79cd\u8c03\u6574\u5747\u662f\u5168\u52a8\u6001\u53ef\u914d\u7f6e\u7684\u3002
\u4ee5\u4e0b\u56fe\u4e3a\u4f8b\uff0c\u5047\u8bbe\u7528\u6237\u539f\u5148\u9700\u8981 3 \u4e2a\u8ba1\u7b97\u8282\u70b9\u6765\u5904\u7406 OLTP \u4e1a\u52a1\uff0c\u4ee5\u53ca 3 \u4e2a\u8ba1\u7b97\u8282\u70b9\u6765\u5904\u7406 OLAP \u4e1a\u52a1\uff0c\u5e76\u4e14\u8fd9\u4e9b\u786c\u4ef6\u8d44\u6e90\u662f\u5b8c\u5168\u7ed1\u5b9a\u7684\uff0c\u5373\u4e3a OLTP \u670d\u52a1\u7684\u8282\u70b9\u4e0d\u80fd\u4e3a OLAP \u63d0\u4f9b\u670d\u52a1\uff0c\u53cd\u4e4b\u4ea6\u7136\uff0c\u800c\u4e14\u7528\u6237\u5bf9\u673a\u5668\u8d44\u6e90\u7684\u89c4\u5212\u5f80\u5f80\u8d85\u51fa\u5b9e\u9645\u9700\u6c42\u7684\u4e0a\u9650\u3002\u7136\u800c\uff0c\u5728\u5b9e\u9645\u4e1a\u52a1\u4e2d\uff0c\u8fbe\u5230\u5168\u5cf0\u9700\u6c42\u7684\u65f6\u95f4\u76f8\u5f53\u6709\u9650\u3002\u5982\u679c\u8bbe\u8ba1\u4f7f\u7528 MatrixOne \u96c6\u7fa4\u652f\u6301\u8fd9\u4e9b\u4e1a\u52a1\uff0c\u90a3\u4e48\u53ef\u4ee5\u8c03\u6574\u4e3a\u603b\u5171 4 \u4e2a\u8ba1\u7b97\u8282\u70b9\uff0c\u5e73\u65f6 3 \u4e2a\u8282\u70b9\u5904\u7406 OLTP \u4e1a\u52a1\uff0c1 \u4e2a\u8282\u70b9\u5904\u7406 OLAP \u4e1a\u52a1\u3002\u7136\u540e\uff0c\u5728\u6708\u672b\u7b49\u5206\u6790\u9700\u6c42\u9ad8\u5cf0\u65f6\u671f\uff0c\u5219\u53ef\u4ee5\u8c03\u6574\u4e3a 1 \u4e2a\u8ba1\u7b97\u8282\u70b9\u5904\u7406 OLTP \u4e1a\u52a1\uff0c3 \u4e2a\u8ba1\u7b97\u8282\u70b9\u5904\u7406 OLAP \u4e1a\u52a1\uff1b\u9ad8\u5cf0\u8fc7\u540e\u518d\u6062\u590d\u539f\u59cb\u914d\u7f6e\uff0c\u8fd9\u6837\u53ef\u63d0\u9ad8\u673a\u5668\u8d44\u6e90\u4f7f\u7528\u7387 40%\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#_3","title":"\u9ad8\u6548\u4f4e\u6210\u672c\u7684\u5bf9\u8c61\u5b58\u50a8","text":"\u5728\u5b58\u50a8\u5c42\u9762\uff0cMatrixOne \u4e3b\u8981\u91c7\u7528\u5bf9\u8c61\u5b58\u50a8\uff0c\u8be5\u5b58\u50a8\u901a\u8fc7\u4f7f\u7528\u7ea0\u5220\u7801\u539f\u7406\uff0c\u4ec5\u9700\u8981\u4f4e\u81f3 33% \u7684\u5197\u4f59\u5ea6\u5373\u53ef\u4fdd\u8bc1\u6570\u636e\u7684\u9ad8\u53ef\u7528\u6027\u3002\u4e0e\u884c\u4e1a\u5185\u5e38\u89c1\u7684\u901a\u8fc7\u591a\u526f\u672c\u6765\u4fdd\u8bc1\u9ad8\u53ef\u7528\u6027\u7684\u65b9\u6848\u76f8\u6bd4\uff0c\u7ea0\u5220\u7801\u5728\u4fdd\u6301\u540c\u7b49\u53ef\u9760\u6027\u7684\u524d\u63d0\u4e0b\uff0c\u5176\u7a7a\u95f4\u5229\u7528\u7387\u4f18\u4e8e\u591a\u526f\u672c\u65b9\u6848\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u4ee5\u79c1\u6709\u5316\u90e8\u7f72\u7684 Minio \u5b98\u65b9\u63a8\u8350\u7684\u6700\u5c0f\u914d\u7f6e\uff084 \u8282\u70b9 \u00d7 4 \u78c1\u76d8\uff09\u4e3a\u4f8b\uff0cMatrixOne \u6700\u5c11\u53ef\u4ee5\u652f\u6301 4 \u5757\u78c1\u76d8\u4f5c\u4e3a\u7ea0\u5220\u7801\u78c1\u76d8\uff0c\u4ee5\u53ca 12 \u5757\u78c1\u76d8\u4f5c\u4e3a\u6570\u636e\u78c1\u76d8\u7684\u67b6\u6784\uff0c\u5176\u5197\u4f59\u5ea6\u4e3a 1.33\u3002
\u6b64\u5916\uff0c\u5bf9\u8c61\u5b58\u50a8\u8fd8\u652f\u6301 HDD \u78c1\u76d8\u7b49\u4f4e\u6210\u672c\u5b58\u50a8\u4ecb\u8d28\u3002\u5bf9\u4e8e\u96c6\u7fa4\u8ba1\u7b97\u6027\u80fd\u8981\u6c42\u4e0d\u9ad8\uff0c\u4ee5\u5b58\u50a8\u4e3a\u4e3b\u7684\u4f7f\u7528\u573a\u666f\u4e2d\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u964d\u4f4e\u4f7f\u7528\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#_4","title":"\u5217\u5f0f\u5b58\u50a8\u5e26\u6765\u7684\u9ad8\u6570\u636e\u538b\u7f29\u6bd4","text":"\u7ed3\u6784\u5316\u6570\u636e\u5728\u5b58\u50a8\u65f6\uff0c\u6bcf\u4e00\u5217\u7684\u6570\u636e\u7ed3\u6784\u76f8\u540c\u3002\u5728 MatrixOne \u5b58\u50a8\u5c42\uff0c\u6570\u636e\u4ee5\u5217\u5f0f\u5b58\u50a8\uff0c\u8fd9\u6837\u7684\u7279\u6027\u8ba9\u6570\u636e\u5177\u6709\u66f4\u597d\u7684\u538b\u7f29\u7279\u6027\uff1a
MatrixOne \u603b\u4f53\u7684\u6570\u636e\u538b\u7f29\u7387\u6700\u4f4e\u53ef\u8fbe 1%\uff0c\u5177\u4f53\u538b\u7f29\u7387\u53d7\u5b9e\u9645\u6570\u636e\u7684\u6570\u636e\u7ed3\u6784\u3001\u6570\u636e\u5197\u4f59\u7a0b\u5ea6\u7b49\u591a\u56e0\u7d20\u5f71\u54cd\u3002
\u603b\u7684\u6765\u8bf4\uff0cMatrixOne \u7684\u5217\u5f0f\u5b58\u50a8\u65b9\u5f0f\u5c06\u6781\u5927\u7684\u538b\u7f29\u60a8\u7684\u5b9e\u9645\u5b58\u50a8\u7a7a\u95f4\uff0c\u6781\u5927\u7684\u964d\u4f4e\u60a8\u7684\u5b58\u50a8\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#mysql","title":"\u4e0e MySQL \u7684\u517c\u5bb9\u6027","text":"MatrixOne \u5728\u8bed\u6cd5\u3001\u534f\u8bae\u4ee5\u53ca\u751f\u6001\u5de5\u5177\u65b9\u9762\u90fd\u4fdd\u6301\u4e86\u4e0e\u5e02\u573a\u4e0a\u6700\u6d41\u884c\u7684\u5f00\u6e90\u6570\u636e\u5e93 MySQL \u7684\u517c\u5bb9\u6027\uff0c\u8fd9\u4f7f\u5f97\u719f\u6089 MySQL \u6216\u8005\u4ee5\u524d\u4f7f\u7528 MySQL \u7684\u7528\u6237\u80fd\u591f\u4ee5\u6781\u4f4e\u7684\u6210\u672c\u8fdb\u884c\u8fc1\u79fb\u548c\u5b66\u4e60\u3002
\u5173\u4e8e MatrixOne \u4e0e MySQL \u517c\u5bb9\u6027\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/","title":"MatrixOne \u529f\u80fd\u7279\u6027","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#matrixone_1","title":"MatrixOne \u7279\u6027","text":"\u5728 MatrixOne \u7248\u672c 1.2.1 \u4e2d\uff0c\u5177\u6709\u5982\u4e0b\u7279\u6027\uff0c\u8ba9\u4f60\u5728\u4f7f\u7528 MatrixOne \u7684\u8fc7\u7a0b\u4e2d\u66f4\u52a0\u9ad8\u6548\uff1a
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_1","title":"\u5206\u5e03\u5f0f\u67b6\u6784","text":"\u5728 MatrixOne \u4e2d\uff0c\u91c7\u7528\u4e86\u5206\u5e03\u5f0f\u5b58\u7b97\u5206\u79bb\u7684\u5206\u5e03\u5f0f\u67b6\u6784\uff0c\u5b58\u50a8\u5c42\u3001\u6570\u636e\u5c42\u3001\u8ba1\u7b97\u5c42\u7684\u5206\u79bb\uff0c\u4f7f\u5f97 MatrixOne \u5728\u9047\u5230\u7cfb\u7edf\u8d44\u6e90\u74f6\u9888\u65f6\uff0c\u80fd\u591f\u7075\u6d3b\u5b9e\u73b0\u8282\u70b9\u7684\u6269\u5bb9\u3002\u540c\u65f6\uff0c\u591a\u8282\u70b9\u7684\u67b6\u6784\u4e0b\uff0c\u8d44\u6e90\u53ef\u4ee5\u8fdb\u884c\u66f4\u52a0\u6709\u6548\u7387\u5730\u5206\u914d\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u907f\u514d\u4e86\u70ed\u70b9\u4e0e\u8d44\u6e90\u5f81\u7528\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_2","title":"\u4e8b\u52a1\u4e0e\u9694\u79bb","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e8b\u52a1\u91c7\u7528\u4e86\u4e50\u89c2\u4e8b\u52a1\u4e0e\u5feb\u7167\u9694\u79bb\u3002
\u5728\u5206\u5e03\u5f0f\u67b6\u6784\u4e0b\uff0c\u4e50\u89c2\u4e8b\u52a1\u53ef\u4ee5\u901a\u8fc7\u8f83\u5c11\u7684\u51b2\u7a81\u83b7\u5f97\u66f4\u4f18\u7684\u6027\u80fd\u3002\u540c\u65f6\u5728\u5b9e\u73b0\u65b9\u5f0f\u4e0a\uff0c\u80fd\u591f\u5b9e\u73b0\u9694\u79bb\u7ea7\u522b\u66f4\u9ad8\u7684\u5feb\u7167\u9694\u79bb\u3002\u4e3a\u4e86\u4fdd\u8bc1\u4e8b\u52a1\u7684 ACID \u56db\u4e2a\u8981\u7d20\uff0cMatrixOne \u76ee\u524d\u652f\u6301\u4e14\u4ec5\u652f\u6301\u5feb\u7167\u9694\u79bb\u4e00\u79cd\u9694\u79bb\u7ea7\u522b\u3002\u8be5\u9694\u79bb\u7ea7\u522b\u8f83\u5e38\u89c1\u7684\u8bfb\u5df2\u63d0\u4ea4\u76f8\u6bd4\uff0c\u9694\u79bb\u7ea7\u522b\u66f4\u52a0\u4e25\u683c\uff0c\u65e2\u53ef\u4ee5\u6709\u6548\u9632\u6b62\u810f\u8bfb\uff0c\u53c8\u80fd\u591f\u66f4\u597d\u5730\u9002\u914d\u5206\u5e03\u5f0f\u4e50\u89c2\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_3","title":"\u4e91\u539f\u751f","text":"MatrixOne \u662f\u4e00\u6b3e\u4e91\u539f\u751f\u7684\u6570\u636e\u5e93\uff0c\u4ece\u5b58\u50a8\u5c42\uff0c\u9002\u914d\u672c\u5730\u78c1\u76d8\u3001AWS S3\u3001NFS \u7b49\u591a\u79cd\u5b58\u50a8\u65b9\u5f0f\uff0c\u901a\u8fc7 File service \u5b9e\u73b0\u4e86\u5bf9\u591a\u79cd\u4e0d\u540c\u7c7b\u578b\u5b58\u50a8\u7684\u65e0\u611f\u77e5\u7ba1\u7406\u3002MatrixOne \u96c6\u7fa4\u53ef\u4ee5\u5728\u591a\u79cd\u57fa\u7840\u8bbe\u65bd\u73af\u5883\u4e0b\u7a33\u5b9a\u8fd0\u884c\uff0c\u65e2\u53ef\u4ee5\u9002\u914d\u4f01\u4e1a\u79c1\u6709\u4e91\uff0c\u53c8\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u516c\u6709\u4e91\u5382\u5546\u73af\u5883\u4e0b\u63d0\u4f9b\u670d\u52a1\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_4","title":"\u8d1f\u8f7d\u5747\u8861","text":"\u5728\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u7684\u67b6\u6784\u4e0b\uff0c\u4e0d\u540c\u8282\u70b9\u4e4b\u95f4\u4e0d\u53ef\u907f\u514d\u5730\u5b58\u5728\u8d1f\u8f7d\u5dee\u5f02\uff0c\u53ef\u80fd\u5bfc\u81f4\u67d0\u4e9b\u4e1a\u52a1\u573a\u666f\u7684\u6027\u80fd\u74f6\u9888\u6216\u90e8\u5206\u8ba1\u7b97\u8d44\u6e90\u95f2\u7f6e\u3002\u56e0\u6b64\uff0cMatrixOne \u4e3a\u786e\u4fdd\u4e0d\u540c\u8282\u70b9\u5728\u8d44\u6e90\u5206\u914d\u4e0a\u5c3d\u91cf\u4fdd\u6301\u63a5\u8fd1\uff0c\u5b9e\u73b0\u4e86\u8ba1\u7b97\u8d44\u6e90\u7684\u8d1f\u8f7d\u5747\u8861\u529f\u80fd\u7279\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#sql","title":"SQL \u8def\u7531","text":"SQL \u8def\u7531\u5e38\u7528\u4e8e\u65e9\u671f\u7684\u5206\u5e93\u5206\u8868\u6570\u636e\u5e93\u573a\u666f\uff0c\u7528\u4e8e\u5728\u6536\u5230\u4e00\u6761 SQL \u8bf7\u6c42\u540e\uff0c\u6839\u636e\u6570\u636e\u5206\u5e03\u60c5\u51b5\uff0c\u786e\u5b9a\u5c06\u8be5\u8bf7\u6c42\u53d1\u9001\u5230\u54ea\u4e2a\u5b9e\u4f8b/\u5e93/\u8868\u3002
\u5728 MatrixOne \u4e2d\uff0c\u867d\u7136\u5b58\u50a8\u5f15\u64ce\u7684\u80fd\u529b\u4e0d\u518d\u9650\u5236\u6570\u636e\u5e93\u89c4\u6a21\uff0c\u4f46\u5728\u591a CN \u7684\u67b6\u6784\u4e0b\uff0c\u4ecd\u7136\u5b58\u5728\u7740\u591a CN \u4e4b\u95f4\u8d1f\u8f7d\u5747\u8861\u548c\u4e0d\u540c\u79df\u6237\u4e4b\u95f4\u8d44\u6e90\u9694\u79bb\u7684\u573a\u666f\u9700\u6c42\u3002\u56e0\u6b64\uff0c\u5728 MatrixOne \u4e2d\uff0c\u5b9e\u73b0\u4e86 SQL \u8def\u7531\u5c06 SQL \u8bf7\u6c42\u6309\u7167\u9884\u5b9a\u4e49\u7684\u89c4\u5219\u53d1\u9001\u5230\u4e0d\u540c CN \u8282\u70b9\u6267\u884c\uff0c\u89e3\u51b3\u4e86\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u65e0\u6cd5\u8d1f\u8f7d\u5927\u91cf\u6570\u636e\u8bbf\u95ee\u8981\u6c42\u7684\u60c5\u51b5\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_5","title":"\u767d\u540d\u5355","text":"\u767d\u540d\u5355\u662f\u4e00\u9879\u5b89\u5168\u7b56\u7565\uff0c\u7528\u4e8e\u63a7\u5236\u53d7\u9650\u5236\u7684\u8d44\u6e90\u3001\u7cfb\u7edf\u6216\u7f51\u7edc\u7684\u8bbf\u95ee\u3002\u5b83\u57fa\u4e8e\u4e00\u4e2a\u6838\u5fc3\u601d\u60f3\uff0c\u5373\u53ea\u5141\u8bb8\u88ab\u6388\u6743\u548c\u4fe1\u4efb\u7684\u5b9e\u4f53\u8fdb\u884c\u8bbf\u95ee\uff0c\u800c\u62d2\u7edd\u5176\u4ed6\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u5c1d\u8bd5\u3002\u8fd9\u4e9b\u88ab\u6388\u6743\u7684\u5b9e\u4f53\u53ef\u80fd\u5305\u62ec\u7279\u5b9a\u7528\u6237\u3001IP \u5730\u5740\u3001\u7a0b\u5e8f\u6216\u5176\u4ed6\u5b9e\u4f53\u3002\u4e0e\u767d\u540d\u5355\u76f8\u5bf9\u7684\u662f\u9ed1\u540d\u5355\uff0c\u9ed1\u540d\u5355\u7b56\u7565\u6307\u5b9a\u4e00\u7cfb\u5217\u88ab\u7981\u6b62\u7684\u5b9e\u4f53\uff0c\u8fd9\u4e9b\u5b9e\u4f53\u5c06\u88ab\u963b\u6b62\u8bbf\u95ee\u53d7\u9650\u5236\u7684\u8d44\u6e90\u3001\u7cfb\u7edf\u6216\u7f51\u7edc\u3002\u5728\u9ed1\u540d\u5355\u7b56\u7565\u4e0b\uff0c\u672a\u88ab\u5217\u5165\u9ed1\u540d\u5355\u7684\u5b9e\u4f53\u53ef\u4ee5\u8fdb\u884c\u8bbf\u95ee\u3002
\u767d\u540d\u5355\u5177\u6709\u4ee5\u4e0b\u7279\u6027\uff1a
\u5355\u4e00\u96c6\u7fa4\u591a\u79df\u6237\u7684\u65b9\u5f0f\u53ef\u4ee5\u63d0\u4f9b\u8d44\u6e90\u5171\u4eab\u3001\u7b80\u5316\u7ba1\u7406\u3001\u63d0\u9ad8\u53ef\u4f38\u7f29\u6027\u3001\u63d0\u4f9b\u5b89\u5168\u9694\u79bb\u7b49\u597d\u5904\uff0c\u5bf9\u4e8e\u9700\u8981\u540c\u65f6\u4e3a\u591a\u4e2a\u79df\u6237\u63d0\u4f9b\u6570\u636e\u5e93\u670d\u52a1\u7684\u573a\u666f\u975e\u5e38\u6709\u4ef7\u503c\u3002
MatrixOne \u7684\u591a\u79df\u6237\u6a21\u5f0f\u80fd\u591f\u4e3a\u4e0d\u540c\u7684\u79df\u6237\u63d0\u4f9b\u72ec\u7acb\u7684\u6570\u636e\u5e93\u5b9e\u4f8b\uff0c\u5e76\u91c7\u7528\u903b\u8f91\u9694\u79bb\u7684\u65b9\u5f0f\u786e\u4fdd\u5404\u79df\u6237\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u72ec\u7acb\u6027\uff0c\u6709\u6548\u9632\u6b62\u6570\u636e\u6cc4\u9732\u548c\u7be1\u6539\u7684\u98ce\u9669\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#matrixone_2","title":"MatrixOne \u6027\u80fd\u4f18\u52bf","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#_7","title":"\u9ad8\u6548\u5b58\u50a8","text":"MatrixOne \u9009\u62e9 AWS S3 \u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u6548\u7684\u5b58\u50a8\u65b9\u6848\uff0c\u6ee1\u8db3\u4e86\u4f4e\u6210\u672c\u548c\u51b7\u70ed\u6570\u636e\u5206\u79bb\u8fd9\u4e24\u4e2a\u6838\u5fc3\u9700\u6c42\u3002\u5176\u53ef\u9760\u7684\u53ef\u7528\u6027\u4fdd\u8bc1\u4e86\u516c\u6709\u4e91\u4e2d\u7684\u4f4e\u98ce\u9669\uff0c\u5e76\u63d0\u4f9b\u79c1\u6709\u5316\u90e8\u7f72\u7684\u517c\u5bb9\u7248\u672c\u3002
\u4f5c\u4e3a HTAP \u6570\u636e\u5e93\uff0c\u5b9e\u73b0\u4e86\u4e0d\u540c\u7c7b\u578b\u7684\u5de5\u4f5c\u8d1f\u8f7d\u9694\u79bb\uff1a
\u4f5c\u4e3a HTAP \u6570\u636e\u5e93\uff0c\u4e0d\u540c\u4e1a\u52a1\u573a\u666f\u7684\u6bd4\u4f8b\u5728\u4e0d\u65ad\u52a8\u6001\u53d8\u5316\uff0c\u5bf9\u8d44\u6e90\u7684\u914d\u6bd4\u4e5f\u6709\u7740\u66f4\u9ad8\u7684\u8981\u6c42\u3002\u65e7\u67b6\u6784\u4e0b\u7684\u8d44\u6e90\u5206\u914d\u6a21\u5f0f\u6ce8\u5b9a\u65e0\u6cd5\u5b9e\u73b0\u7075\u6d3b\u8c03\u6574\uff0c\u9700\u8981\u5bf9\u5404\u4e2a\u8282\u70b9\u5b9e\u73b0\u66f4\u52a0\u7cbe\u7ec6\u5316\u7684\u7ba1\u7406\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a
\u6570\u636e\u5e93\u7684\u9ad8\u53ef\u7528\u6027\u662f\u4f01\u4e1a\u5173\u952e\u9700\u6c42\uff0c\u5b83\u4fdd\u8bc1\u4e86\u7cfb\u7edf\u7684\u6301\u7eed\u53ef\u7528\u6027\u3001\u6570\u636e\u7684\u5b89\u5168\u6027\uff0c\u4ee5\u53ca\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002MatrixOne \u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u53ef\u7528\u6027\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u80fd\u6ee1\u8db3\u4f01\u4e1a\u7684\u9700\u6c42\u3002\u672c\u6587\u6863\u65e8\u5728\u4ecb\u7ecd MatrixOne \u7684\u9ad8\u53ef\u7528\u6027\u7279\u6027\uff0c\u5305\u62ec\u6545\u969c\u6062\u590d\u3001\u6570\u636e\u5197\u4f59\u3001\u8d1f\u8f7d\u5747\u8861\u7b49\u5173\u952e\u529f\u80fd\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_2","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u4f01\u4e1a\u5bf9\u6570\u636e\u5e93\u9ad8\u53ef\u7528\u6027\u7684\u9700\u6c42\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
\u6301\u7eed\u53ef\u7528\u6027\uff1a\u4f01\u4e1a\u9700\u8981\u786e\u4fdd\u5176\u5173\u952e\u4e1a\u52a1\u6570\u636e\u5e93\u7684\u6301\u7eed\u8fd0\u884c\uff0c\u4ee5\u9632\u6b62\u957f\u65f6\u95f4\u7684\u7cfb\u7edf\u4e2d\u65ad\u6216\u670d\u52a1\u4e0d\u53ef\u7528\uff0c\u8fd9\u6837\u53ef\u4ee5\u4fdd\u8bc1\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u548c\u7528\u6237\u6ee1\u610f\u5ea6\u3002
\u6545\u969c\u6062\u590d\uff1a\u5f53\u6570\u636e\u5e93\u53d1\u751f\u6545\u969c\u65f6\uff0c\u80fd\u5feb\u901f\u5e76\u81ea\u52a8\u5730\u8fdb\u884c\u6545\u969c\u68c0\u6d4b\u548c\u5207\u6362\uff0c\u4ece\u800c\u51cf\u5c11\u7cfb\u7edf\u7684\u4e2d\u65ad\u65f6\u95f4\uff0c\u786e\u4fdd\u670d\u52a1\u7684\u8fde\u7eed\u6027\u548c\u53ef\u9760\u6027\u3002
\u6570\u636e\u4fdd\u62a4\u548c\u6062\u590d\uff1a\u6570\u636e\u662f\u4f01\u4e1a\u7684\u91cd\u8981\u8d44\u4ea7\uff0c\u56e0\u6b64\u9700\u8981\u5b9a\u671f\u5907\u4efd\u6570\u636e\u5e93\uff0c\u5e76\u80fd\u591f\u5feb\u901f\u6062\u590d\u6570\u636e\uff0c\u4ee5\u5e94\u5bf9\u610f\u5916\u7684\u6570\u636e\u4e22\u5931\u6216\u635f\u574f\u3002
\u8de8\u5730\u57df\u5bb9\u707e\uff1a\u5bf9\u4e8e\u5173\u952e\u4e1a\u52a1\uff0c\u53ef\u80fd\u9700\u8981\u5728\u4e0d\u540c\u7684\u5730\u7406\u533a\u57df\u8bbe\u7acb\u6570\u636e\u4e2d\u5fc3\uff0c\u5b9e\u73b0\u8de8\u5730\u57df\u5bb9\u707e\uff0c\u4ee5\u5e94\u5bf9\u81ea\u7136\u707e\u5bb3\u3001\u7f51\u7edc\u4e2d\u65ad\u6216\u533a\u57df\u6027\u6545\u969c\u3002
MatrixOne \u901a\u8fc7\u7ea0\u5220\u7801\u8fdb\u884c\u6570\u636e\u5197\u4f59\u6821\u9a8c\uff0c\u540c\u6b65\u4e8b\u52a1\u65e5\u5fd7\u91c7\u7528 Raft \u534f\u8bae\uff0c\u53ea\u6709\u591a\u6570\u6d3e\u5199\u5165\u6210\u529f\uff0c\u4e8b\u52a1\u624d\u80fd\u63d0\u4ea4\uff0c\u8fd9\u786e\u4fdd\u4e86\u6570\u636e\u7684\u5f3a\u4e00\u81f4\u6027\uff0c\u5373\u4f7f\u5c11\u6570\u526f\u672c\u53d1\u751f\u6545\u969c\u4e5f\u4e0d\u5f71\u54cd\u6570\u636e\u7684\u53ef\u7528\u6027\u3002MatrixOne \u7684\u9ad8\u53ef\u7528\u6027\u6ee1\u8db3\u91d1\u878d\u884c\u4e1a 4 \u7ea7\u6807\u51c6\uff08RPO=0\uff0cRTO<30min\uff09\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_4","title":"\u6280\u672f\u67b6\u6784","text":"MatrixOne \u7684\u6574\u4f53\u6280\u672f\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6211\u4eec\u4f1a\u6839\u636e\u4e0d\u540c\u7684\u7ec4\u4ef6\u6a21\u5757\uff0c\u5206\u522b\u4ecb\u7ecd\u5b83\u4eec\u7684\u9ad8\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_5","title":"\u8d44\u6e90\u8c03\u5ea6\u5c42","text":"MatrixOne \u7684\u6280\u672f\u67b6\u6784\u662f\u5b8c\u5168\u4e91\u539f\u751f\u5316\u7684\uff0c\u6240\u6709\u7684\u6280\u672f\u7ec4\u4ef6\u90fd\u4ee5\u5bb9\u5668\u5316\u7684\u5f62\u5f0f\u8fd0\u884c\u5728 Kubernetes \u4e0a\u3002\u901a\u8fc7\u91c7\u7528\u591a\u4e3b\u591a\u4ece\u7684\u90e8\u7f72\u65b9\u6848\uff0cKubernetes \u96c6\u7fa4\u53ef\u4ee5\u4fdd\u8bc1\u8fde\u7eed\u53ef\u7528\u6027\u3002\u5177\u4f53\u7684\u90e8\u7f72\u62d3\u6251\u53ca\u65b9\u6848\u53ef\u53c2\u8003 Kubernetes \u5b98\u65b9\u65b9\u6848\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_6","title":"\u5b58\u50a8\u5c42","text":"\u5728\u5b58\u50a8\u5c42\uff0cMatrixOne \u91c7\u7528\u5bf9\u8c61\u5b58\u50a8\uff0c\u63a8\u8350\u4f7f\u7528 Minio \u8fdb\u884c\u90e8\u7f72\u3002MinIO \u4f5c\u4e3a\u4e00\u6b3e\u6210\u719f\u7684\u5206\u5e03\u5f0f\u5bf9\u8c61\u5b58\u50a8\u65b9\u6848\uff0c\u9700\u8981\u4fdd\u8bc1\u6570\u636e\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u548c\u6570\u636e\u6587\u4ef6\u7684\u5b8c\u6574\u4e00\u81f4\u6027\u3002MinIO \u96c6\u7fa4\u7684\u67b6\u6784\u662f\u5206\u5e03\u5f0f\u7684\uff0c\u5c06\u6570\u636e\u5b58\u50a8\u5728\u591a\u4e2a\u8282\u70b9\u4e0a\uff0c\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u5bb9\u9519\u6027\u3002\u540c\u65f6\uff0cMinIO \u96c6\u7fa4\u4f7f\u7528 Erasure Coding \u6280\u672f\u4fdd\u8bc1\u6570\u636e\u7684\u53ef\u9760\u6027\u548c\u53ef\u7528\u6027\u3002\u5f53\u67d0\u4e2a\u8282\u70b9\u53d1\u751f\u6545\u969c\u65f6\uff0c\u5176\u4ed6\u8282\u70b9\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u7f16\u7801\u526f\u672c\u6062\u590d\u4e22\u5931\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_7","title":"\u5171\u4eab\u65e5\u5fd7","text":"\u5171\u4eab\u65e5\u5fd7\u7ec4\u4ef6 LogService \u662f MatrixOne \u4e2d\u552f\u4e00\u62e5\u6709\u5206\u5e03\u5f0f\u4e8b\u52a1\u72b6\u6001\u7684\u7ec4\u4ef6\u3002\u8fd9\u662f\u4e00\u4e2a\u7531\u4e09\u4e2a\u8282\u70b9\u7ec4\u6210\uff0c\u9075\u5faa Raft \u534f\u8bae\u7684\u67b6\u6784\uff0c\u5373\u4f7f\u4e00\u4e2a\u8282\u70b9\u5931\u6548\uff0c\u4e5f\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\u5b83\u8d1f\u8d23\u5bf9\u6574\u4e2a MatrixOne \u96c6\u7fa4\u7684\u670d\u52a1\u8fdb\u884c\u6700\u7ec8\u4e00\u81f4\u6027\u7684\u4fdd\u969c\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_8","title":"\u4e8b\u52a1\u5c42","text":"\u4e8b\u52a1\u5c42\u7ec4\u4ef6 Transaction node \u8d1f\u8d23\u5bf9\u4e8b\u52a1\u64cd\u4f5c\u8fdb\u884c\u51b2\u7a81\u68c0\u6d4b\u4ee5\u53ca\u4ef2\u88c1\uff0c\u5b83\u662f\u4e00\u4e2a\u65e0\u72b6\u6001\u7684\u8282\u70b9\u3002\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0cKubernetes \u53ef\u4ee5\u968f\u65f6\u62c9\u8d77\uff0c\u5728\u79d2\u7ea7\u65f6\u95f4\u5185\u5c31\u80fd\u6062\u590d\u6b63\u5e38\uff0c\u4fdd\u8bc1\u6301\u7eed\u53ef\u7528\u6027\u3002\u76ee\u524d\u7248\u672c\u7684 Transaction node \u4ec5\u652f\u6301\u5355\u8282\u70b9\u8fd0\u884c\uff0c\u540e\u7eed\u4f1a\u589e\u52a0\u591a Transaction node \u65b9\u6848\uff0c\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_9","title":"\u8ba1\u7b97\u5c42","text":"\u8ba1\u7b97\u5c42\u7ec4\u4ef6 Compute Node \u8d1f\u8d23\u524d\u7aef Query \u7684\u89e3\u6790\uff0c\u4ee5\u53ca\u6267\u884c\u8ba1\u5212\u7684\u751f\u6210\u548c\u6267\u884c\u3002\u5b83\u4e5f\u662f\u4e00\u4e2a\u65e0\u72b6\u6001\u7684\u8282\u70b9\uff0c\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0cKubernetes \u53ef\u4ee5\u968f\u65f6\u62c9\u8d77\uff0c\u5728\u79d2\u7ea7\u65f6\u95f4\u5185\u6062\u590d\u6b63\u5e38\uff0c\u4fdd\u8bc1\u6301\u7eed\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#proxy","title":"Proxy","text":"\u8d44\u6e90\u8c03\u5ea6\u5c42\u4e2d\u7684 Proxy \u7ec4\u4ef6\u8d1f\u8d23\u5bf9\u8ba1\u7b97\u8282\u70b9 CN \u8fdb\u884c\u5206\u7ec4\uff0c\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb\uff0c\u4ee5\u53ca\u5728 CN \u7ec4\u5185\u5b9e\u73b0\u7528\u6237\u8fde\u63a5\u7ea7\u522b\u7684\u8d1f\u8f7d\u5747\u8861\u3002Proxy \u8fd0\u884c\u65f6\u4ee5\u591a\u526f\u672c\u4e92\u4e3a\u5907\u4efd\u7684\u5f62\u5f0f\u4fdd\u8bc1\u9ad8\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/","title":"\u6df7\u5408\u8d1f\u8f7d HTAP","text":"MatrixOne \u662f\u4e00\u6b3e\u80fd\u591f\u652f\u6301 HTAP\uff08Hybrid Transaction Analytical Processing\uff09\u6df7\u5408\u8d1f\u8f7d\u5904\u7406\u7684\u6570\u636e\u5e93\uff0c\u65e8\u5728\u63d0\u4f9b\u6ee1\u8db3\u5355\u4e00\u6570\u636e\u5e93\u5185\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u548c\u5206\u6790\u5904\u7406\uff08AP\uff09\u6240\u6709\u9700\u6c42\u7684\u89e3\u51b3\u65b9\u6848\u3002\u51ed\u501f\u5176\u5b58\u50a8\u548c\u8ba1\u7b97\u4e8b\u52a1\u7684\u89e3\u8026\u67b6\u6784\uff0cMatrixOne \u80fd\u591f\u5728\u540c\u4e00\u6570\u636e\u5f15\u64ce\u4e2d\u540c\u65f6\u652f\u6301\u5728\u7ebf\u4ea4\u6613\u548c\u5b9e\u65f6\u7edf\u8ba1\u5206\u6790\uff0c\u540c\u65f6\u63d0\u4f9b\u9ad8\u6548\u7684\u8d44\u6e90\u9694\u79bb\u673a\u5236\u3002\u8fd9\u79cd\u8bbe\u8ba1\u5927\u5927\u4fdd\u7559\u4e86\u6570\u636e\u7684\u65b0\u9c9c\u5ea6\uff0c\u7701\u53bb\u4e86\u5728\u8bb8\u591a\u4e1a\u52a1\u573a\u666f\u4e2d\u6784\u5efa\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u7684\u6b65\u9aa4\uff0c\u4ece\u800c\u5e2e\u52a9\u5ba2\u6237\u5b9e\u73b0\u5176\u4e1a\u52a1\u4ef7\u503c\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_1","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u968f\u7740\u4f01\u4e1a\u4e1a\u52a1\u89c4\u6a21\u7684\u6269\u5927\uff0c\u6570\u636e\u91cf\u7684\u4e0d\u65ad\u589e\u957f\uff0c\u4ee5\u53ca\u4e1a\u52a1\u7cfb\u7edf\u7684\u65e5\u76ca\u590d\u6742\uff0c\u4f20\u7edf\u7684\u5728\u7ebf\u6570\u636e\u5e93\u4e0d\u5f97\u4e0d\u9762\u5bf9\u62c6\u5206\u7684\u95ee\u9898\u3002\u7136\u800c\uff0c\u62c6\u5206\u540e\u7684\u67b6\u6784\u5e76\u4e0d\u80fd\u6ee1\u8db3\u4e00\u4e9b\u9700\u8981\u5173\u8054\u7edf\u8ba1\u548c\u5b9e\u65f6\u5206\u6790\u7684\u9700\u6c42\u3002\u6b64\u65f6\uff0c\u7c7b\u4f3c\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u7684\u4ea7\u54c1\u5e94\u8fd0\u800c\u751f\u3002\u7136\u800c\uff0c\u7531\u4e8e\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u7684\u67b6\u6784\u590d\u6742\uff0c\u6210\u672c\u9ad8\u6602\uff0c\u5e76\u975e\u6240\u6709\u7684\u4f01\u4e1a\u90fd\u80fd\u6784\u5efa\u4e00\u6574\u5957\u751f\u6001\u94fe\u8def\u3002MatrixOne \u7684 HTAP \u6a21\u5f0f\u5e94\u8fd0\u800c\u751f\uff0c\u5b83\u53ef\u4ee5\u4f7f\u7528\u4e00\u5957\u5f15\u64ce\u5728\u652f\u6301\u9ad8\u5e76\u53d1\u5728\u7ebf\u541e\u5410\u7684\u540c\u65f6\uff0c\u63d0\u4f9b\u6d77\u91cf\u6570\u636e\u7684\u5b9e\u65f6\u5728\u7ebf\u5206\u6790\u80fd\u529b\uff0c\u4e3a\u4f01\u4e1a\u63d0\u5347\u6548\u7387\u3001\u6301\u7eed\u521b\u65b0\u63d0\u4f9b\u4e86\u52a8\u529b\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_2","title":"\u529f\u80fd\u4f18\u52bf","text":"MatrixOne \u901a\u8fc7\u6a21\u5757\u5316\u7684\u5b58\u50a8\u3001\u8ba1\u7b97\u548c\u4e8b\u52a1\u67b6\u6784\uff0c\u591a\u7ea7\u5b58\u50a8\u4f53\u7cfb\uff0c\u4ee5\u53ca\u8d1f\u8f7d\u5904\u7406\u94fe\u8def\u9694\u79bb\u7684\u6a21\u5f0f\u6765\u5b9e\u73b0 HTAP\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_4","title":"\u5b58\u50a8\u3001\u8ba1\u7b97\u3001\u4e8b\u52a1\u6a21\u5757\u5316\u5206\u79bb","text":"MatrixOne \u7684\u6574\u4f53\u6280\u672f\u67b6\u6784\u91c7\u7528\u5b8c\u5168\u7684\u5b58\u50a8\u548c\u8ba1\u7b97\u5206\u79bb\u67b6\u6784\u3002\u901a\u8fc7\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u5c06\u6570\u636e\u5e93\u7684\u8ba1\u7b97\u3001\u5b58\u50a8\u3001\u4e8b\u52a1\u5904\u7406\u5206\u79bb\u4e3a\u5355\u72ec\u7684\u6a21\u5757\uff0c\u4ece\u800c\u7ec4\u5efa\u51fa\u4e00\u5957\u5404\u7ec4\u4ef6\u90fd\u5177\u6709\u72ec\u7acb\u4f38\u7f29\u80fd\u529b\u7684\u6570\u636e\u5e93\u7cfb\u7edf\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0cMatrixOne \u7531\u4e09\u4e2a\u72ec\u7acb\u5c42\u7ea7\u6784\u6210\uff1a
\u5982\u4e0a\u4e00\u7ae0\u8282\u4e2d\u56fe\u793a\u6240\u793a\uff0cMatrixOne \u7684\u5b58\u50a8\u4f53\u7cfb\u7531\u5168\u91cf\u6570\u636e\u5171\u4eab\u5b58\u50a8\u3001\u5c11\u91cf\u5171\u4eab\u65e5\u5fd7\u548c\u8ba1\u7b97\u8282\u70b9\u7684\u65e0\u72b6\u6001\u7f13\u5b58\u7ec4\u6210\u3002
\u7528\u6237\u8bf7\u6c42\u9996\u5148\u4f1a\u8fdb\u5165 MatrixOne \u96c6\u7fa4\u5e76\u901a\u8fc7 Proxy \u6a21\u5757\u3002Proxy \u662f\u7528\u4e8e\u5b9e\u73b0\u8ba1\u7b97\u8282\u70b9\u5206\u7ec4\u548c\u9694\u79bb\u7684\u6a21\u5757\u3002\u8be5\u6a21\u5757\u901a\u8fc7\u914d\u7f6e\u5c06\u8ba1\u7b97\u8282\u70b9 CN \u5206\u4e3a\u82e5\u5e72\u7ec4\uff0c\u5e76\u7528\u6807\u7b7e\u533a\u5206\u5404\u79cd\u79df\u6237\u6216\u8d1f\u8f7d\uff0c\u8ba9\u7528\u6237\u80fd\u591f\u6839\u636e\u4e0d\u540c\u7684\u4e1a\u52a1\u9700\u6c42\u8bbe\u5b9a\u4e0d\u540c\u7684 CN \u7ec4\u5904\u7406\u4e0d\u540c\u7684\u4e1a\u52a1\u3002
\u6709\u5173 Proxy \u5bf9 CN \u5206\u7ec4\u4f7f\u7528\u7684\u5177\u4f53\u64cd\u4f5c\uff0c\u53ef\u4ee5\u53c2\u8003\u4f7f\u7528 Proxy \u7ba1\u7406 CN \u7ec4\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#tpap","title":"TP/AP \u8d1f\u8f7d\u94fe\u8def\u9694\u79bb","text":"\u5728\u6267\u884c\u5c42\u9762\uff0cMatrixOne \u4f1a\u6839\u636e\u8bf7\u6c42\u7c7b\u578b\u5c06\u5176\u8def\u7531\u5230\u4e0d\u540c\u7684\u5904\u7406\u94fe\u8def\uff0c\u4ece\u800c\u5b9e\u73b0 OLTP \u548c OLAP \u7684\u9694\u79bb\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u6839\u636e\u8bfb\u5199\u8bf7\u6c42\u7684\u5904\u7406\u65b9\u5f0f\u6765\u8be6\u7ec6\u89e3\u91ca\u5982\u4f55\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_8","title":"\u5199\u8bf7\u6c42\u5904\u7406","text":"\u5982\u56fe\u6240\u793a\uff0c\u5904\u7406\u5199\u8bf7\u6c42\uff08INSERT/UPDATE/DELETE\uff09\u65f6\uff1a
CN \u8282\u70b9\u4f1a\u542f\u52a8\u4e00\u4e2a\u4e8b\u52a1\uff0c\u5e76\u68c0\u67e5\u5199\u5165\u8bf7\u6c42\u662f\u5426\u6709\u4e3b\u952e\u51b2\u7a81\u6216\u5176\u4ed6\u4e8b\u52a1\u76f8\u5173\u95ee\u9898\uff0c\u5982\u679c\u6709\uff0c\u5219\u76f4\u63a5\u5411\u7528\u6237\u8fd4\u56de\u9519\u8bef\u3002
\u63a5\u4e0b\u6765\uff0cCN \u4f1a\u6839\u636e\u5199\u8bf7\u6c42\u7684\u6570\u636e\u91cf\u5927\u5c0f\u6765\u51b3\u5b9a\u64cd\u4f5c\u7684\u94fe\u8def\u3002\u5982\u679c\u6570\u636e\u91cf\u6ca1\u6709\u8d85\u8fc7\u8bbe\u5b9a\u7684\u9608\u503c\uff08\u901a\u5e38\u4e3a 10MB\uff09\uff0c\u5219 CN \u8282\u70b9\u4f1a\u5c06\u6570\u636e\u53d1\u9001\u7ed9 TN \u8282\u70b9\uff0cTN \u8282\u70b9\u4f1a\u8fdb\u884c\u5199\u5199\u51b2\u7a81\u68c0\u6d4b\u548c\u4e8b\u52a1\u4ef2\u88c1\u7b49\u64cd\u4f5c\uff0c\u786e\u4fdd\u65e0\u8bef\u540e\uff0c\u5c06\u8fd9\u4e9b\u6570\u636e\u4ee5\u65e5\u5fd7\u5f62\u5f0f\u5199\u5165 LogService\uff0c\u5f62\u6210 Logtail\u3002
\u66f4\u65b0\u7684 Logtail \u5c06\u5373\u65f6\u63a8\u9001\u7ed9\u8ba2\u9605\u4e86 Logtail \u6570\u636e\u7684 CN \u8282\u70b9\uff0c\u4ee5\u4fbf\u67e5\u8be2\u3002\u5982\u679c\u6570\u636e\u91cf\u8d85\u8fc7\u9608\u503c\uff0c\u5219 CN \u8282\u70b9\u4f1a\u76f4\u63a5\u5c06\u6570\u636e\u5199\u5165\u5bf9\u8c61\u5b58\u50a8\uff0c\u5e76\u5c06\u63d0\u4ea4 commit \u4fe1\u606f\u53d1\u9001\u7ed9 TN\uff0cTN \u8282\u70b9\u4f1a\u8fdb\u884c\u5199\u5199\u51b2\u7a81\u68c0\u6d4b\u548c\u4e8b\u52a1\u4ef2\u88c1\u7b49\u64cd\u4f5c\uff0c\u5728\u786e\u8ba4\u65e0\u8bef\u540e\uff0c\u63d0\u4ea4\u4e8b\u52a1\u3002
\u4ece\u4e0a\u56fe\u53ef\u77e5\uff0c\u5c11\u91cf\u6570\u636e\u7684 OLTP \u7c7b\u578b\u5199\u5165\u8bf7\u6c42\u4f1a\u7ecf\u8fc7 CN \u81f3 TN \u518d\u81f3 LogService \u7684\u5904\u7406\u94fe\u8def\uff0c\u800c\u5927\u6570\u636e\u91cf\u7684\u5199\u5165\u8bf7\u6c42\uff0c\u5982 Load \u7b49\uff0c\u5219\u4f1a\u4e3b\u8981\u7ecf\u8fc7 CN \u81f3 S3\uff0c\u4ee5\u53ca\u5c11\u91cf\u7684 CN \u81f3 TN\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_9","title":"\u8bfb\u8bf7\u6c42\u5904\u7406","text":"\u5982\u56fe\u6240\u793a\uff0c\u5904\u7406\u8bfb\u8bf7\u6c42\u65f6\uff0cCN \u8282\u70b9\u4f1a\u9996\u5148\u67e5\u770b\u5df2\u8ba2\u9605\u7684 Logtail \u6570\u636e\uff0c\u5982\u679c\u6570\u636e\u76f4\u63a5\u547d\u4e2d Logtail\uff0c\u5219\u8bf4\u660e\u6570\u636e\u4f4d\u4e8e\u6700\u65b0\u7684\u4e00\u90e8\u5206\u5199\u5165\u6570\u636e\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56de\u3002\u5982\u679c\u6ca1\u6709\u547d\u4e2d Logtail\uff0cCN \u4f1a\u68c0\u67e5\u81ea\u5df1\u53ca\u5176\u4ed6\u53ef\u89c1 CN \u7684\u7f13\u5b58\uff0c\u5982\u679c\u547d\u4e2d\u7f13\u5b58\uff0c\u5c06\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u3002\u5982\u679c\u6ca1\u6709\u547d\u4e2d\u7f13\u5b58\uff0cCN \u4f1a\u901a\u8fc7\u5206\u6790\u6267\u884c\u8ba1\u5212\u5224\u65ad\u662f\u5426\u9700\u8981\u5927\u91cf\u8bfb\u53d6\u6570\u636e\uff0c\u5982\u679c\u8d85\u8fc7\u4e00\u5b9a\u7684\u9608\u503c\uff08\u5982 200 \u4e2a block size\uff09\u5219\u7531\u591a\u4e2a CN \u8282\u70b9\u5e76\u884c\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u8bfb\u53d6\uff0c\u5982\u679c\u672a\u8d85\u8fc7\u9608\u503c\u5219\u7531\u5355\u4e2a CN \u8282\u70b9\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u8bfb\u53d6\u3002
\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u65e0\u8bba\u662f OLTP \u8fd8\u662f OLAP \u7684\u8bfb\u8bf7\u6c42\uff0c\u90fd\u4f1a\u7ecf\u8fc7 CN \u81f3 S3 \u7684\u5904\u7406\u94fe\u8def\u3002\u901a\u8fc7 Proxy \u5bf9 CN \u8282\u70b9\u7684\u9694\u79bb\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5b9e\u73b0 CN \u7684\u9694\u79bb\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_10","title":"\u5e94\u7528\u573a\u666f","text":"\u65e0\u8bba\u5728\u91d1\u878d\u3001\u7535\u4fe1\u3001\u5236\u9020\u4e1a\u8fd8\u662f\u4e92\u8054\u7f51\u3001\u79d1\u6280\u7b49\u65b0\u5174\u884c\u4e1a\uff0cHTAP \u90fd\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\u3002
\u4f8b\u5982\uff0c\u5728\u91d1\u878d\u9886\u57df\uff0cHTAP \u6570\u636e\u5e93\u53ef\u4ee5\u6ee1\u8db3\u9ad8\u901f\u4ea4\u6613\u5904\u7406\u548c\u5b9e\u65f6\u98ce\u9669\u7ba1\u7406\u7684\u9700\u6c42\uff0c\u652f\u6301\u91d1\u878d\u4ea4\u6613\u7684\u9ad8\u541e\u5410\u91cf\u548c\u4f4e\u5ef6\u8fdf\u8981\u6c42\uff0c\u540c\u65f6\u63d0\u4f9b\u5b9e\u65f6\u6570\u636e\u5206\u6790\u529f\u80fd\uff0c\u4ee5\u652f\u6301\u51b3\u7b56\u5236\u5b9a\u548c\u98ce\u9669\u76d1\u63a7\u3002
\u5728\u7535\u4fe1\u884c\u4e1a\uff0cHTAP \u6570\u636e\u5e93\u53ef\u7528\u4e8e\u5b9e\u65f6\u8ba1\u8d39\u548c\u7f51\u7edc\u4f18\u5316\uff0c\u80fd\u5904\u7406\u5927\u91cf\u5b9e\u65f6\u6570\u636e\uff0c\u8ffd\u8e2a\u7528\u6237\u901a\u4fe1\u548c\u7f51\u7edc\u6d3b\u52a8\uff0c\u540c\u65f6\u652f\u6301\u5b9e\u65f6\u5206\u6790\u548c\u667a\u80fd\u51b3\u7b56\uff0c\u4ee5\u6539\u5584\u670d\u52a1\u8d28\u91cf\u3001\u7f51\u7edc\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002
\u5728\u7269\u8054\u7f51\u9886\u57df\uff0cHTAP \u6570\u636e\u5e93\u53ef\u7528\u4e8e\u8bbe\u5907\u7ba1\u7406\u548c\u5b9e\u65f6\u76d1\u63a7\uff0c\u80fd\u5904\u7406\u5927\u91cf\u4f20\u611f\u5668\u6570\u636e\u548c\u8bbe\u5907\u72b6\u6001\u4fe1\u606f\uff0c\u5e76\u63d0\u4f9b\u5b9e\u65f6\u8bbe\u5907\u76d1\u63a7\u548c\u7ba1\u7406\u529f\u80fd\uff0c\u8fd9\u5bf9\u4e8e\u7269\u8054\u7f51\u7cfb\u7edf\u7684\u5b9e\u65f6\u51b3\u7b56\u3001\u8fdc\u7a0b\u6545\u969c\u8bca\u65ad\u548c\u9884\u6d4b\u7ef4\u62a4\u5177\u6709\u91cd\u8981\u610f\u4e49\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_11","title":"\u91d1\u878d\u5b9e\u65f6\u98ce\u63a7\u7cfb\u7edf","text":"\u67d0\u94f6\u884c\u4f5c\u4e3a\u4e00\u5bb6\u9886\u5148\u7684\u57ce\u5e02\u5546\u4e1a\u94f6\u884c\uff0c\u5176\u4fe1\u7528\u5361\u4e1a\u52a1\u62e5\u6709\u4e00\u5957\u5b9e\u65f6\u98ce\u63a7\u7cfb\u7edf\uff0c\u8be5\u7cfb\u7edf\u4e3b\u8981\u8d1f\u8d23\u76d1\u63a7\u548c\u8bc4\u4f30\u4fe1\u7528\u5361\u4ea4\u6613\uff0c\u8bc6\u522b\u4ea4\u6613\u98ce\u9669\u5e76\u53ca\u65f6\u91c7\u53d6\u9650\u5236\u63aa\u65bd\u3002
\u4ee5\u4e0b\u8868\u683c\u5c55\u793a\u4e86\u8fd9\u5957\u7cfb\u7edf\u7684\u6838\u5fc3\u4e1a\u52a1\u9700\u6c42\u573a\u666f\u4ee5\u53ca MatrixOne \u7684 HTAP \u5982\u4f55\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\uff1a
\u6838\u5fc3\u4e1a\u52a1\u9700\u6c42 \u4e1a\u52a1\u7c7b\u578b MatrixOne \u7684 HTAP \u80fd\u529b \u5b9e\u65f6\u83b7\u53d6\u4ea4\u6613\u6570\u636e \u5feb\u901f\u4e14\u4f4e\u5ef6\u8fdf\u7684\u6570\u636e\u5199\u5165 MatrixOne \u80fd\u591f\u9ad8\u6548\u5e76\u53d1\u5730\u5199\u5165\u6d77\u91cf\u6570\u636e\uff0c\u901a\u8fc7\u6269\u5c55\u591a CN \u8282\u70b9\u548c\u5bf9\u8c61\u5b58\u50a8\u6765\u8fdb\u4e00\u6b65\u63d0\u5347\u6027\u80fd\u3002 \u79bb\u7ebf\u8ba1\u7b97\u5927\u91cf\u6570\u636e\u6307\u6807\uff0c\u5206\u6790\u7528\u6237\u884c\u4e3a\u53ca\u98ce\u9669\u56e0\u7d20 \u590d\u6742\u7684\u5206\u6790\u67e5\u8be2\uff0c\u9700\u8981\u5904\u7406 TB \u7ea7\u522b\u7684\u6570\u636e MatrixOne \u5177\u5907\u5904\u7406\u6d77\u91cf\u661f\u578b\u548c\u96ea\u82b1\u578b\u6570\u636e\u5206\u6790\u7684\u80fd\u529b\uff0c\u901a\u8fc7\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u53ef\u4ee5\u7ebf\u6027\u63d0\u5347\u5206\u6790\u80fd\u529b\u3002 \u5b9e\u65f6\u5206\u6790\u4ea4\u6613\u6570\u636e\uff0c\u8ba1\u7b97\u98ce\u9669\u6307\u6807 \u5178\u578b\u7684 AP \u4e1a\u52a1\uff0c\u9700\u8981\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u8ba1\u7b97\u6570\u636e\u7ed3\u679c MatrixOne \u7684\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\u80fd\u591f\u6ee1\u8db3\u5927\u89c4\u6a21\u6570\u636e\u62a5\u8868\u7684\u8ba1\u7b97\u9700\u6c42\uff0c\u540c\u65f6\u63d0\u4f9b\u5feb\u901f\u7684\u6570\u636e\u8bfb\u53d6\u6027\u80fd\u3002 \u9762\u5bf9\u9891\u7e41\u4e14\u5267\u70c8\u7684\u4e1a\u52a1\u6ce2\u52a8 \u9700\u8981\u7075\u6d3b\u7684\u6269\u5c55\u6027\u67b6\u6784\u6765\u5e94\u5bf9\u5927\u7684\u8d1f\u8f7d\u6ce2\u52a8 MatrixOne \u7684\u5b58\u50a8\u548c\u8ba1\u7b97\u5206\u79bb\u67b6\u6784\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u80fd\u5728\u4e1a\u52a1\u6ce2\u52a8\u65f6\u5feb\u901f\u6269\u7f29\u5bb9\u4ee5\u5339\u914d\u4e1a\u52a1\u9700\u6c42\u3002"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_12","title":"\u7535\u4fe1\u4e1a\u52a1\u7ba1\u7406\u7cfb\u7edf","text":"\u67d0\u4f01\u4e1a\u662f\u4e00\u5bb6\u7701\u7ea7\u7535\u4fe1\u8fd0\u8425\u5546\uff0c\u670d\u52a1\u7528\u6237\u6570\u91cf\u8fbe\u6570\u5343\u4e07\uff0c\u4e3b\u8981\u63d0\u4f9b\u7535\u8bdd\u901a\u4fe1\u670d\u52a1\uff0c\u9700\u8981\u540c\u65f6\u652f\u6491\u6d77\u91cf\u7528\u6237\u7684\u4f7f\u7528\u548c\u7edf\u8ba1\u5206\u6790\u3002
\u4ee5\u4e0b\u8868\u683c\u5c55\u793a\u4e86\u8fd9\u5957\u7cfb\u7edf\u7684\u6838\u5fc3\u4e1a\u52a1\u573a\u666f\u4ee5\u53ca MatrixOne \u7684 HTAP \u5982\u4f55\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\uff1a
\u6838\u5fc3\u4e1a\u52a1\u573a\u666f \u4e1a\u52a1\u7c7b\u578b MatrixOne \u7684 HTAP \u89e3\u51b3\u65b9\u6848 \u67e5\u8be2\u7528\u6237\u8bdd\u8d39\u7f34\u5b58\u60c5\u51b5\u5e76\u5b9e\u65f6\u505c\u673a \u9ad8\u5e76\u53d1\u7684\u77ed\u5c0f\u4e8b\u52a1\uff0c\u9700\u8981\u4f4e\u5ef6\u8fdf MatrixOne \u5177\u5907 OLTP \u80fd\u529b\uff0c\u591a CN \u8282\u70b9\u5206\u5e03\u5f0f\u67b6\u6784\u53ef\u4ee5\u786e\u4fdd\u5728\u9ad8\u5e76\u53d1\u4e0b\u7684\u7a33\u5b9a\u6027\u80fd\uff0c\u540c\u65f6\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u3002 \u7528\u6237\u5145\u503c\u540e\u5b9e\u65f6\u66f4\u65b0\u8d26\u6237\u4f59\u989d \u9ad8\u5e76\u53d1\u7684\u77ed\u5c0f\u4e8b\u52a1\uff0c\u9700\u8981\u4f4e\u5ef6\u8fdf MatrixOne \u7684 TP \u80fd\u529b\u53ef\u4ee5\u6ee1\u8db3\u9ad8\u5e76\u53d1\u4e14\u4f4e\u5ef6\u8fdf\u7684 TP \u9700\u6c42\uff0c\u540c\u65f6\u5206\u5e03\u5f0f\u591a CN \u8282\u70b9\u67b6\u6784\u63d0\u4f9b\u8d1f\u8f7d\u5747\u8861\u7279\u6027\u3002 \u6279\u91cf\u8c03\u6574\u7528\u6237\u5957\u9910\u5e76\u5728\u4e0b\u6708\u751f\u6548 \u8d85\u5927\u4e8b\u52a1\uff0c\u9700\u8981\u9ad8\u6027\u80fd MatrixOne \u53ef\u76f4\u63a5\u5199\u5165 S3\uff0c\u907f\u514d\u4e86 Logservice \u5728\u9ad8\u5e76\u53d1\u4e0b\u7684\u4e89\u7528\uff0c\u4ece\u800c\u5b9e\u73b0\u5feb\u901f\u6279\u91cf\u7684\u6570\u636e\u5199\u5165\u3002 \u5bf9\u7528\u6237\u6570\u636e\u8fdb\u884c\u65e5\u3001\u5468\u3001\u6708\u3001\u5b63\u5ea6\u548c\u5e74\u5ea6\u7edf\u8ba1 \u5178\u578b\u7684 AP \u4e1a\u52a1\uff0c\u9700\u8981\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u8ba1\u7b97\u6570\u636e\u7ed3\u679c MatrixOne \u7684\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\u80fd\u6ee1\u8db3\u5927\u89c4\u6a21\u6570\u636e\u62a5\u8868\u7684\u8ba1\u7b97\u9700\u6c42\uff0c\u540c\u65f6\u63d0\u4f9b\u5feb\u901f\u7684\u6570\u636e\u8bfb\u53d6\u6027\u80fd\u3002"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_13","title":"\u5236\u9020\u751f\u4ea7\u6267\u884c\u7cfb\u7edf","text":"\u67d0\u4f01\u4e1a\u662f\u4e00\u5bb6\u7535\u5b50\u4ea7\u54c1\u5236\u9020\u5546\uff0c\u62e5\u6709\u6570\u5341\u6761\u5404\u7c7b\u6d88\u8d39\u7535\u5b50\u4ea7\u54c1\u7684\u751f\u4ea7\u7ebf\u3002\u5176\u751f\u4ea7\u5236\u9020\u6267\u884c\uff08MES\uff09\u7cfb\u7edf\u9700\u8981\u5bf9\u751f\u4ea7\u7ebf\u4e0a\u7684\u4eba\u5458\u3001\u673a\u5668\u3001\u7269\u6599\u548c\u6d41\u7a0b\u8fdb\u884c\u7ba1\u7406\uff0c\u540c\u65f6\u5b9a\u671f\u5206\u6790\u751f\u4ea7\u6548\u7387\u548c\u80fd\u8017\u7b49\u95ee\u9898\u3002
\u4ee5\u4e0b\u8868\u683c\u5c55\u793a\u4e86\u8fd9\u5957\u7cfb\u7edf\u7684\u6838\u5fc3\u4e1a\u52a1\u573a\u666f\u4ee5\u53ca MatrixOne \u7684 HTAP \u5982\u4f55\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\uff1a
\u6838\u5fc3\u4e1a\u52a1\u573a\u666f \u4e1a\u52a1\u7c7b\u578b MatrixOne \u7684 HTAP \u89e3\u51b3\u65b9\u6848 \u7ba1\u7406\u751f\u4ea7\u3001\u4ed3\u50a8\u548c\u8d28\u91cf \u9ad8\u5e76\u53d1\u77ed\u5c0f\u4e8b\u52a1\uff0c\u9700\u8981\u4f4e\u5ef6\u8fdf MatrixOne \u5177\u5907 OLTP \u80fd\u529b\uff0c\u5206\u5e03\u5f0f\u591a CN \u8282\u70b9\u53ef\u4ee5\u786e\u4fdd\u5728\u9ad8\u5e76\u53d1\u4e0b\u7684\u7a33\u5b9a\u6027\u80fd\uff0c\u540c\u65f6\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u3002 \u5b9e\u65f6\u91c7\u96c6\u5927\u91cf\u673a\u5668\u751f\u4ea7\u6570\u636e \u9ad8\u5e76\u53d1\u591a\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u5199\u5165 MatrixOne \u80fd\u591f\u9ad8\u6548\u5e76\u53d1\u5730\u5199\u5165\u6d77\u91cf\u6570\u636e\uff0c\u901a\u8fc7\u6269\u5c55\u591a CN \u8282\u70b9\u548c\u5bf9\u8c61\u5b58\u50a8\u6765\u8fdb\u4e00\u6b65\u63d0\u5347\u6027\u80fd\u3002 \u5206\u6790\u6d77\u91cf\u5386\u53f2\u751f\u4ea7\u8bb0\u5f55\u7684\u6eaf\u6e90 \u9700\u8981\u5bf9\u6d77\u91cf\u79bb\u7ebf\u6570\u636e\u8fdb\u884c\u591a\u7ef4\u67e5\u8be2\u5206\u6790 MatrixOne \u5177\u5907\u5904\u7406\u6d77\u91cf\u661f\u578b\u548c\u96ea\u82b1\u578b\u6570\u636e\u5206\u6790\u7684\u80fd\u529b\uff0c\u901a\u8fc7\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u53ef\u4ee5\u7ebf\u6027\u63d0\u5347\u5206\u6790\u80fd\u529b\u3002 \u5b9e\u65f6\u67e5\u8be2\u751f\u4ea7\u6548\u7387\u3001\u80fd\u8017\u548c\u8bbe\u5907\u72b6\u6001 \u6781\u5feb\u7684 Ad-hoc \u4ea4\u4e92\u5f0f\u5206\u6790 MatrixOne \u652f\u6301\u5404\u79cd\u590d\u6742 SQL \u67e5\u8be2\uff0c\u901a\u8fc7\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u53ef\u4ee5\u5b9e\u73b0\u5b9e\u65f6\u5206\u6790\u3002"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/","title":"\u591a\u79df\u6237","text":"MatrixOne \u7684\u8bbe\u8ba1\u91c7\u7528\u4e86\u5355\u4e00\u96c6\u7fa4\u591a\u79df\u6237\u7684\u65b9\u5f0f\u3002\u5728\u8fd9\u4e2a\u8bbe\u8ba1\u4e2d\uff0c\u79df\u6237\uff08Account\uff09\u662f\u4e00\u4e2a\u903b\u8f91\u6982\u5ff5\uff0c\u4f5c\u4e3a\u8d44\u6e90\u5206\u914d\u548c\u6570\u636e\u5e93\u7ba1\u7406\u7684\u5355\u4f4d\u3002MatrixOne \u7684\u591a\u79df\u6237\u6a21\u5f0f\u80fd\u591f\u4e3a\u4e0d\u540c\u7684\u79df\u6237\u63d0\u4f9b\u72ec\u7acb\u7684\u6570\u636e\u5e93\u5b9e\u4f8b\uff0c\u5e76\u91c7\u7528\u903b\u8f91\u9694\u79bb\u7684\u65b9\u5f0f\u786e\u4fdd\u5404\u79df\u6237\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u72ec\u7acb\u6027\uff0c\u6709\u6548\u9632\u6b62\u6570\u636e\u6cc4\u9732\u548c\u7be1\u6539\u7684\u98ce\u9669\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_2","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u5728\u4f01\u4e1a\u7684\u4e1a\u52a1\u53d1\u5c55\u5230\u4e00\u5b9a\u89c4\u6a21\uff0c\u6570\u636e\u91cf\u4e0d\u65ad\u589e\u957f\u7684\u540c\u65f6\uff0c\u4e1a\u52a1\u90e8\u95e8\u6216\u9879\u76ee\u7ec4\u589e\u52a0\uff0c\u4f01\u4e1a\u53ef\u4ee5\u6839\u636e\u5404\u81ea\u7684\u4e1a\u52a1\u9700\u6c42\u548c\u89c4\u6a21\uff0c\u8fdb\u884c\u7075\u6d3b\u7684\u79df\u6237\u7ba1\u7406\uff0c\u6ee1\u8db3\u4e0d\u540c\u7684\u4e1a\u52a1\u90e8\u95e8\u6216\u9879\u76ee\u7ec4\u7684\u72ec\u7acb\u6027\u8981\u6c42\u3002\u5728 MatrixOne \u7684\u591a\u79df\u6237\u6a21\u5f0f\u4e0b\uff0c\u4f01\u4e1a\u53ef\u4ee5\u8f7b\u677e\u7ba1\u7406\u5404\u79df\u6237\u7684\u6570\u636e\u8d44\u6e90\uff0c\u4ece\u800c\u4f7f\u5f97\u6570\u636e\u5206\u6790\u3001\u62a5\u544a\u7b49\u4e1a\u52a1\u6d41\u7a0b\u66f4\u52a0\u6d41\u7545\u548c\u51c6\u786e\u3002\u540c\u65f6\uff0c\u8fd9\u79cd\u65b9\u5f0f\u8fd8\u6709\u52a9\u4e8e\u4f01\u4e1a\u63d0\u9ad8\u4e1a\u52a1\u6548\u7387\uff0c\u964d\u4f4e\u7ba1\u7406\u6210\u672c\uff0c\u5b9e\u73b0\u4f01\u4e1a\u8d44\u6e90\u7684\u6700\u5927\u5316\u5229\u7528\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_3","title":"\u529f\u80fd\u4f18\u52bf","text":"\u964d\u4f4e\u8fd0\u8425\u6210\u672c\uff1a\u591a\u4e2a\u7528\u6237\u53ef\u4ee5\u5171\u4eab\u4e00\u4e2a\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u907f\u514d\u4e86\u591a\u5957\u96c6\u7fa4\u7684\u90e8\u7f72\u548c\u7ba1\u7406\uff0c\u4ece\u800c\u51cf\u5c11\u786c\u4ef6\u548c\u8f6f\u4ef6\u7684\u6295\u5165\u6210\u672c\u3002
\u8d44\u6e90\u53ca\u8d1f\u8f7d\u9694\u79bb\uff1a\u591a\u79df\u6237\u6a21\u5f0f\u63d0\u9ad8\u4e86\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u53ef\u9760\u6027\uff0c\u4e0d\u540c\u7528\u6237\u7684\u6570\u636e\u548c\u8d1f\u8f7d\u76f8\u4e92\u9694\u79bb\uff0c\u5373\u4f7f\u67d0\u4e2a\u7528\u6237\u7684\u6570\u636e\u51fa\u73b0\u95ee\u9898\u6216\u8d1f\u8f7d\u8fc7\u9ad8\uff0c\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u7528\u6237\u3002
\u52a8\u6001\u8d44\u6e90\u5206\u914d\uff1a\u591a\u79df\u6237\u8fd8\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u53ef\u6269\u5c55\u6027\uff0c\u6bcf\u4e2a\u79df\u6237\u53ef\u4ee5\u72ec\u7acb\u6269\u5c55\u6216\u6536\u7f29\u81ea\u5df1\u7684\u8d44\u6e90\uff0c\u9762\u5bf9\u4e0d\u540c\u7ea7\u522b\u7684\u8d1f\u8f7d\u53ef\u4ee5\u5b9e\u73b0\u8d44\u6e90\u4f7f\u7528\u7684\u6700\u5927\u5316\u3002
\u79df\u6237\u7edf\u4e00\u7ba1\u7406\uff1a\u867d\u7136\u6bcf\u4e2a\u79df\u6237\u4e4b\u95f4\u662f\u9694\u79bb\u4e14\u72ec\u7acb\u8fd0\u884c\u7684\uff0c\u4f46\u7ba1\u7406\u4eba\u5458\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u79df\u6237\u5bf9\u5176\u4ed6\u79df\u6237\u8fdb\u884c\u7edf\u4e00\u7684\u7ba1\u7406\uff0c\u6bd4\u5982\u5feb\u901f\u521b\u5efa\u65b0\u79df\u6237\uff0c\u6279\u91cf\u5220\u9664\u8001\u79df\u6237\u7b49\u3002
\u79df\u6237\u6570\u636e\u5171\u4eab\uff1a\u5728\u67d0\u4e9b\u8054\u90a6\u7edf\u8ba1\u67e5\u8be2\u7684\u573a\u666f\u4e0b\uff0c\u79df\u6237\u4e4b\u95f4\u9700\u8981\u8fdb\u884c\u6570\u636e\u5171\u4eab\u3002MatrixOne \u63d0\u4f9b\u5b8c\u6574\u7684\u79df\u6237\u6570\u636e\u5206\u4eab\u53ca\u8ba2\u9605\u7684\u673a\u5236\uff0c\u6ee1\u8db3\u66f4\u7075\u6d3b\u7684\u4e1a\u52a1\u5206\u6790\u9700\u6c42\u3002
\u8de8\u5730\u57df\u90e8\u7f72\uff1a\u5728\u4e00\u4e9b\u4e1a\u52a1\u8de8\u5f88\u591a\u5730\u57df\u7684\u573a\u666f\u4e0b\uff0c\u79df\u6237\u9700\u8981\u4e0e\u5730\u57df\u8fdb\u884c\u5173\u8054\uff0c\u63d0\u4f9b\u5c31\u8fd1\u7684\u670d\u52a1\u3002MatrixOne \u652f\u6301\u540c\u4e00\u4e2a\u96c6\u7fa4\u4e0b\u4e0d\u540c\u7684\u79df\u6237\u5206\u5e03\u5728\u4e0d\u540c\u7684\u5730\u57df\u4e0a\uff0c\u5c31\u8fd1\u5bf9\u4e1a\u52a1\u8fdb\u884c\u670d\u52a1\u3002
MatrixOne \u7684\u591a\u79df\u6237\u7cfb\u7edf\u5305\u542b\u4e24\u79cd\u7c7b\u578b\u4e0d\u540c\u7684\u79df\u6237\uff1a\u7cfb\u7edf\uff08sys\uff09\u79df\u6237\u548c\u666e\u901a\u79df\u6237\u3002\u7cfb\u7edf\u79df\u6237\u662f\u7531 MatrixOne \u96c6\u7fa4\u5185\u7f6e\u7684\uff0c\u96c6\u7fa4\u542f\u52a8\u540e\u7cfb\u7edf\u4f1a\u9ed8\u8ba4\u767b\u5f55\u8be5\u79df\u6237\u3002\u8be5\u79df\u6237\u7684\u4e3b\u8981\u804c\u8d23\u5305\u62ec\uff1a
\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u666e\u901a\u79df\u6237\u5219\u662f\u7531\u7cfb\u7edf\u79df\u6237\u521b\u5efa\u7684\u3002\u5728\u4f7f\u7528\u65f6\uff0c\u666e\u901a\u79df\u6237\u53ef\u4ee5\u88ab\u89c6\u4e3a\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\uff0c\u9700\u8981\u6307\u5b9a\u79df\u6237\u540d\u79f0\u624d\u80fd\u8fde\u63a5\u3002\u666e\u901a\u79df\u6237\u5177\u5907\u5982\u4e0b\u7279\u6027\uff1a
MatrixOne \u7684\u5206\u5e03\u5f0f\u96c6\u7fa4\u91c7\u7528 Proxy \u6a21\u5757\u548c CN \u8d44\u6e90\u7ec4\u6280\u672f\u67b6\u6784\u5b9e\u73b0\u4e86\u591a\u79df\u6237\u8d44\u6e90\u9694\u79bb\u3002
\u5f53\u7528\u6237\u8fde\u63a5\u65f6\uff0c\u8fde\u63a5\u4f1a\u7ecf\u8fc7 Proxy \u6a21\u5757\uff0cProxy \u4f1a\u6839\u636e CN \u7684\u79df\u6237\u6807\u7b7e\u4fe1\u606f\u5c06\u8fde\u63a5\u8f6c\u53d1\u5230\u5bf9\u5e94 CN \u8d44\u6e90\u7ec4\u4e0a\u7684\u67d0\u4e2a CN \u4e0a\uff0c\u6839\u636e\u8d1f\u8f7d\u5747\u8861\u7684\u539f\u5219\u9009\u62e9\u8d1f\u8f7d\u6700\u8f7b\u7684 CN\u3002\u5728 MatrixOne \u96c6\u7fa4\u67b6\u6784\u4e2d\uff0cCN \u662f\u4ee5\u5bb9\u5668\u5316\u90e8\u7f72\u7684\uff0c\u56e0\u6b64 CN \u4e4b\u95f4\u5177\u6709\u9694\u79bb\u6027\u3002\u4e00\u4e2a\u79df\u6237\u4f7f\u7528\u7684 CN \u8d44\u6e90\u7ec4\u662f\u4e00\u7ec4\u6253\u4e0a\u8be5\u79df\u6237\u6807\u7b7e\u7684 CN\u3002\u5982\u679c\u8d44\u6e90\u4e0d\u8db3\uff0c\u9700\u8981\u8fdb\u884c\u6269\u5c55\uff0c\u53ef\u4ee5\u901a\u8fc7\u6c34\u5e73\u6269\u5c55\u8be5 CN \u8d44\u6e90\u7ec4\u6765\u6ee1\u8db3\u9700\u6c42\uff0c\u800c\u4e0d\u4f1a\u62a2\u5360\u5176\u4ed6 CN \u8d44\u6e90\u7ec4\u7684\u8d44\u6e90\u3002
\u8be5\u67b6\u6784\u56fe\u5982\u4e0b\u6240\u793a\uff1a
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_6","title":"\u5e94\u7528\u573a\u666f","text":"MatrixOne \u7684\u591a\u79df\u6237\u80fd\u529b\u53ef\u5728\u4ee5\u4e0b\u591a\u4e2a\u5e94\u7528\u573a\u666f\u4e2d\u4f53\u73b0\u4f18\u52bf\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#saas","title":"\u591a\u79df\u6237 SaaS \u5e94\u7528","text":"\u5728\u4e3a\u5927\u91cf\u4f01\u4e1a\u5ba2\u6237\u63d0\u4f9b\u670d\u52a1\u7684 SaaS \u5e94\u7528\u4e2d\uff0c\u591a\u79df\u6237\u6a21\u578b\u8bbe\u8ba1\u662f\u975e\u5e38\u5173\u952e\u7684\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_7","title":"\u4f20\u7edf\u67b6\u6784","text":"\u4f20\u7edf\u7684\u591a\u79df\u6237\u67b6\u6784\u5728\u6570\u636e\u5e93\u5c42\u9762\u4e3a\u6bcf\u4e2a\u79df\u6237\u5b58\u50a8\u548c\u7ba1\u7406\u6570\u636e\u3002\u901a\u5e38\u6709\u591a\u79cd\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5982\u5171\u4eab\u6570\u636e\u5e93\u6a21\u5f0f\uff08\u6bcf\u4e2a\u79df\u6237\u5171\u4eab\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u4f46\u62e5\u6709\u81ea\u5df1\u7684\u6570\u636e\u8868/\u5217\uff09\u6216\u72ec\u7acb\u6570\u636e\u5e93\u6a21\u5f0f\uff08\u6bcf\u4e2a\u79df\u6237\u62e5\u6709\u81ea\u5df1\u7684\u6570\u636e\u5e93\uff09\u3002
\u8fd9\u4e24\u79cd\u4f20\u7edf\u6a21\u5f0f\u90fd\u5b58\u5728\u4e00\u5b9a\u6311\u6218\uff1a
MatrixOne \u7684\u591a\u79df\u6237\u80fd\u529b\u5e26\u6765\u4e86\u5168\u65b0\u7684\u67b6\u6784\u65b9\u5f0f\u3002\u79df\u6237\u4ecd\u7136\u5171\u4eab\u4e00\u4e2a MatrixOne \u96c6\u7fa4\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u79df\u6237\u8fdb\u884c\u7edf\u4e00\u7684\u79df\u6237\u8fd0\u7ef4\u548c\u7ba1\u7406\u3002\u53e6\u5916\uff0c\u901a\u8fc7\u81ea\u5e26\u7684\u591a\u79df\u6237\u80fd\u529b\u5b9e\u73b0\u6570\u636e\u53ca\u8d44\u6e90\u7684\u9694\u79bb\uff0c\u540c\u65f6\u6bcf\u4e2a\u79df\u6237\u53ef\u4ee5\u72ec\u7acb\u8fdb\u884c\u8d44\u6e90\u6269\u7f29\u5bb9\uff0c\u8fdb\u4e00\u6b65\u964d\u4f4e\u8fd0\u7ef4\u96be\u5ea6\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e0d\u4ec5\u6ee1\u8db3\u5bf9\u9694\u79bb\u6027\u7684\u9700\u6c42\uff0c\u8fd8\u80fd\u6ee1\u8db3\u4f4e\u8d44\u6e90\u548c\u8fd0\u7ef4\u6210\u672c\u7684\u9700\u6c42\u3002
\u591a\u79df\u6237\u6a21\u5f0f \u6570\u636e\u9694\u79bb\u7a0b\u5ea6 \u8d44\u6e90\u6210\u672c \u8d44\u6e90\u9694\u79bb\u7a0b\u5ea6 \u8fd0\u7ef4\u590d\u6742\u5ea6 \u79df\u6237\u5171\u4eab\u6570\u636e\u5e93\u6a21\u5f0f \u4f4e \u4f4e \u4f4e \u4f4e \u79df\u6237\u72ec\u7acb\u6570\u636e\u5e93\u6a21\u5f0f \u9ad8 \u9ad8 \u9ad8 \u9ad8 MatrixOne \u6a21\u5f0f \u9ad8 \u4f4e \u9ad8 \u4f4e"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_8","title":"\u5fae\u670d\u52a1\u5e94\u7528\u67b6\u6784","text":"\u5fae\u670d\u52a1\u5e94\u7528\u67b6\u6784\u662f\u4e00\u79cd\u901a\u8fc7\u5f00\u53d1\u4e00\u7cfb\u5217\u5c0f\u578b\u670d\u52a1\u6765\u5b9e\u73b0\u4e00\u4e2a\u5e94\u7528\u7684\u8f6f\u4ef6\u67b6\u6784\u6a21\u5f0f\u3002\u6bcf\u4e2a\u5c0f\u578b\u670d\u52a1\u901a\u5e38\u5728\u81ea\u5df1\u7684\u8fdb\u7a0b\u4e2d\u8fd0\u884c\uff0c\u5e76\u901a\u8fc7\u8f7b\u91cf\u7ea7\u7684 HTTP API \u8fdb\u884c\u901a\u8baf\u3002\u8fd9\u4e9b\u670d\u52a1\u901a\u5e38\u4ee5\u4e1a\u52a1\u6a21\u5757\u4e3a\u754c\u9650\uff0c\u53ef\u4ee5\u5355\u72ec\u5f00\u53d1\u90e8\u7f72\uff0c\u5e76\u4f7f\u7528\u81ea\u52a8\u5316\u7684\u90e8\u7f72\u5de5\u5177\u8fdb\u884c\u53d1\u5e03\u3002\u5fae\u670d\u52a1\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f01\u4e1a\u66f4\u5feb\u5730\u63a8\u51fa\u65b0\u4ea7\u54c1\u548c\u670d\u52a1\uff0c\u4f7f\u5f97\u5f00\u53d1\u56e2\u961f\u4e0e\u4e1a\u52a1\u76ee\u6807\u4fdd\u6301\u4e00\u81f4\u3002
\u4e0e SaaS \u5e94\u7528\u4e0d\u540c\uff0c\u5fae\u670d\u52a1\u5e94\u7528\u540c\u6837\u4f1a\u9762\u4e34\u6570\u636e\u5e93\u5171\u4eab\u6216\u72ec\u7acb\u7684\u95ee\u9898\u3002\u901a\u5e38\u5efa\u8bae\u4e3a\u6bcf\u4e2a\u5fae\u670d\u52a1\u51c6\u5907\u4e00\u4e2a\u5355\u72ec\u7684\u6570\u636e\u5e93\uff0c\u8fd9\u79cd\u6a21\u5f0f\u66f4\u9002\u5408\u5fae\u670d\u52a1\u67b6\u6784\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u670d\u52a1\u90fd\u662f\u72ec\u7acb\u5f00\u53d1\u3001\u90e8\u7f72\u548c\u6269\u5c55\u7684\u3002\u5f53\u9700\u8981\u5347\u7ea7\u6216\u66f4\u6539\u6570\u636e\u67b6\u6784\u65f6\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u670d\u52a1\u3002\u5f53\u9700\u8981\u5bf9\u67d0\u4e2a\u670d\u52a1\u8fdb\u884c\u6269\u5c55\u65f6\uff0c\u4e5f\u53ef\u4ee5\u5bf9\u8be5\u670d\u52a1\u8fdb\u884c\u5c40\u90e8\u6269\u5bb9\u3002\u6b64\u5916\uff0c\u5982\u679c\u67d0\u4e9b\u670d\u52a1\u9700\u8981\u7279\u6b8a\u7684\u6570\u636e\u5e93\u80fd\u529b\uff0c\u5982 Elastic Search \u6216\u5411\u91cf\u641c\u7d22\u7b49\uff0c\u8fd9\u79cd\u6a21\u5f0f\u4e5f\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u7684\u53ef\u80fd\u6027\u3002
\u7136\u800c\uff0c\u5fae\u670d\u52a1\u6700\u7ec8\u670d\u52a1\u4e8e\u540c\u4e00\u4e2a\u4e1a\u52a1\uff0c\u4e0d\u540c\u670d\u52a1\u4e4b\u95f4\u5fc5\u7136\u9700\u8981\u5171\u4eab\u6570\u636e\uff0c\u56e0\u6b64\u4e5f\u4f1a\u9047\u5230\u4e0e SaaS \u5e94\u7528\u591a\u79df\u6237\u76f8\u540c\u7684\u56f0\u5883\u3002
MatrixOne \u63d0\u4f9b\u7684\u591a\u79df\u6237\u80fd\u529b\u53ef\u4ee5\u5f88\u597d\u5730\u5e73\u8861\u8fd9\u4e24\u4e2a\u77db\u76fe\u70b9\uff0c\u65e2\u53ef\u4ee5\u4fdd\u8bc1\u6bcf\u4e2a\u5fae\u670d\u52a1\u7684\u6570\u636e\u548c\u8d44\u6e90\u6269\u5c55\u72ec\u7acb\u6027\uff0c\u53c8\u53ef\u4ee5\u4fdd\u6301\u4e00\u5b9a\u7684\u5171\u4eab\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_9","title":"\u96c6\u56e2\u5b50\u516c\u53f8/\u4e1a\u52a1\u90e8\u95e8","text":"\u8bb8\u591a\u96c6\u56e2\u516c\u53f8\u91c7\u7528\u533a\u57df\u5b50\u516c\u53f8\u6216\u4e1a\u52a1\u90e8\u95e8\u6765\u5206\u79bb\u4e1a\u52a1\uff0c\u8fd9\u4e9b\u5b50\u516c\u53f8\u548c\u4e1a\u52a1\u90e8\u95e8\u901a\u5e38\u90fd\u662f\u72ec\u7acb\u8fd0\u4f5c\u7684\uff0c\u62e5\u6709\u5b8c\u6574\u7684\u751f\u4ea7\u3001\u9500\u552e\u548c\u6280\u672f\u652f\u6301\u56e2\u961f\uff0c\u8fd8\u4f1a\u4f7f\u7528\u81ea\u5df1\u7684 IT \u7cfb\u7edf\u3002\u7136\u800c\uff0c\u96c6\u56e2\u516c\u53f8\u9700\u8981\u5168\u9762\u638c\u63e1\u5b50\u516c\u53f8\u7684\u4e1a\u52a1\u72b6\u51b5\uff0c\u56e0\u6b64\u9700\u8981\u5b50\u516c\u53f8\u5b9a\u671f\u4e0a\u62a5\u5927\u91cf\u4e1a\u52a1\u6570\u636e\u3002
\u8fd9\u79cd IT \u67b6\u6784\u5728\u6570\u636e\u5e93\u8bbe\u8ba1\u65b9\u9762\u9762\u4e34\u4e0e\u524d\u4e24\u79cd\u573a\u666f\u5b8c\u5168\u76f8\u540c\u7684\u95ee\u9898\uff0c\u5373\u5171\u4eab\u548c\u9694\u79bb\u4e4b\u95f4\u9700\u8981\u6743\u8861\u3002\u6b64\u5916\uff0c\u5728\u8fd9\u79cd\u573a\u666f\u4e2d\u8fd8\u9700\u8981\u8003\u8651\u5730\u7406\u4f4d\u7f6e\u56e0\u7d20\uff0c\u5b50\u516c\u53f8\u901a\u5e38\u6709\u81ea\u5df1\u7684\u533a\u57df\u5c5e\u6027\uff0c\u9700\u8981\u5728\u9644\u8fd1\u63d0\u4f9b\u670d\u52a1\u3002\u4f8b\u5982\uff0c\u5236\u9020\u4f01\u4e1a\u901a\u5e38\u4f4d\u4e8e\u5317\u4e0a\u5e7f\u6df1\u7b49\u5927\u57ce\u5e02\uff0c\u4f46\u662f\u5404\u4e2a\u5de5\u5382\u53ef\u80fd\u5206\u6563\u5728\u4e0d\u540c\u7684\u4e8c\u4e09\u7ebf\u57ce\u5e02\uff0c\u8fd9\u4e9b\u5de5\u5382\u9700\u8981\u4e0e ERP\u3001MES \u7b49\u7cfb\u7edf\u7d27\u5bc6\u914d\u5408\u3002\u56e0\u6b64\uff0c\u8fd9\u4e9b\u7cfb\u7edf\u5f80\u5f80\u9700\u8981\u5728\u5de5\u5382\u672c\u5730\u90e8\u7f72\uff0c\u800c\u603b\u90e8\u9700\u8981\u6e05\u695a\u5730\u638c\u63e1\u5404\u4e2a\u5de5\u5382\u7684\u60c5\u51b5\uff0c\u56e0\u6b64\u8fd9\u4e9b\u7cfb\u7edf\u9700\u8981\u5411\u96c6\u56e2\u516c\u53f8\u4e0a\u62a5\u6570\u636e\u3002\u4f20\u7edf\u7684\u90e8\u7f72\u67b6\u6784\u901a\u5e38\u91c7\u7528\u72ec\u7acb\u90e8\u7f72\u6570\u636e\u5e93\u7684\u65b9\u6cd5\uff0c\u800c\u6570\u636e\u540c\u6b65\u548c\u4e0a\u62a5\u5219\u7531\u5e94\u7528\u5c42\u5b9e\u73b0\u3002
MatrixOne \u7684\u591a\u79df\u6237\u80fd\u529b\u53ef\u4ee5\u5f88\u597d\u5730\u89e3\u51b3\u6570\u636e\u5e93\u5171\u4eab/\u9694\u79bb\u7684\u56f0\u5883\u3002\u7531\u4e8e\u53ef\u4ee5\u5c06\u79df\u6237\u9700\u8981\u7684 CN \u8282\u70b9\u5c31\u8fd1\u90e8\u7f72\u5230\u5b50\u516c\u53f8\u6240\u5728\u5730\u533a\uff0c\u5728\u7f51\u7edc\u8fde\u901a\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4e0e\u96c6\u56e2\u516c\u53f8\u7684\u5176\u4ed6\u7ec4\u4ef6\u5929\u7136\u5f62\u6210\u4e00\u4e2a\u96c6\u7fa4\uff0c\u65e2\u65b9\u4fbf\u672c\u5730\u5316\u4e1a\u52a1\u4f7f\u7528\uff0c\u4e5f\u6ee1\u8db3\u9ad8\u6548\u6570\u636e\u4e0a\u62a5\u548c\u7edf\u8ba1\u7684\u9700\u6c42\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_10","title":"\u53c2\u8003\u6587\u6863","text":"\u66f4\u591a\u5173\u4e8e\u591a\u79df\u6237\u7684\u6587\u6863\u53ef\u4ee5\u53c2\u89c1\uff1a
\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u5bf9\u6bd4\u5e76\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u7684 MySQL \u6a21\u5f0f\u4ee5\u53ca\u539f\u751f MySQL \u6570\u636e\u5e93\u7684\u517c\u5bb9\u6027\u4fe1\u606f\u3002
MatrixOne \u4e0e MySQL 8.0 \u7684\u534f\u8bae\uff0c\u4ee5\u53ca MySQL 8.0 \u5e38\u7528\u7684\u529f\u80fd\u548c\u8bed\u6cd5\u90fd\u5177\u6709\u9ad8\u5ea6\u7684\u517c\u5bb9\u6027\u3002\u6b64\u5916\uff0cMatrixOne \u4e5f\u5bf9\u5e38\u89c1\u7684 MySQL \u5468\u8fb9\u5de5\u5177\u63d0\u4f9b\u4e86\u652f\u6301\uff0c\u5982 Navicat\uff0cMySQL Workbench\uff0cJDBC \u7b49\u3002\u7136\u800c\uff0c\u7531\u4e8e MatrixOne \u7684\u6280\u672f\u67b6\u6784\u4e0d\u540c\uff0c\u4e14\u4ecd\u5904\u4e8e\u53d1\u5c55\u548c\u5b8c\u5584\u9636\u6bb5\uff0c\u56e0\u6b64\u6709\u4e00\u4e9b\u529f\u80fd\u5c1a\u672a\u5f97\u5230\u652f\u6301\u3002\u672c\u8282\u5c06\u4e3b\u8981\u4ece\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\u8be6\u8ff0 MatrixOne \u6570\u636e\u5e93\u7684 MySQL \u6a21\u5f0f\u4e0e\u539f\u751f MySQL \u6570\u636e\u5e93\u7684\u533a\u522b\uff1a
ENCRYPTION
\u76ee\u524d\u8bed\u6cd5\u652f\u6301\u4f46\u4e0d\u751f\u6548\u3002ALTER DATABASE
\u3002utf8mb4
\u5b57\u7b26\u96c6\u548c utf8mb4_bin
\u6392\u5e8f\u89c4\u5219\uff0c\u65e0\u6cd5\u66f4\u6539\u3002ENGINE=
\uff0c\u4f46 MatrixOne \u4f1a\u76f4\u63a5\u5ffd\u7565 ENGINE=
\u3002CHANGE [COLUMN]
\uff0cMODIFY [COLUMN]
\uff0cRENAME COLUMN
\uff0cADD [CONSTRAINT [symbol]] PRIMARY KEY
\uff0cDROP PRIMARY KEY
\u548c ALTER COLUMN ORDER BY
\u53ef\u4ee5\u5728 ALTER TABLE \u8bed\u53e5\u4e2d\u81ea\u7531\u7ec4\u5408\u4f7f\u7528\uff0c\u4f46\u4e0d\u652f\u6301\u4e0e\u5176\u4ed6\u5b50\u53e5\u4e00\u8d77\u4f7f\u7528\u3002ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002CREATE TABLE ... CLUSTER BY...
\u6240\u5efa\u7684\u8868\uff0c\u4e0d\u652f\u6301\u4f7f\u7528 ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002PARTITION
\u76f8\u5173\u7684\u64cd\u4f5c\u3002Cluster by column
\u5b57\u53e5\uff0c\u5bf9\u67d0\u5217\u8fdb\u884c\u9884\u6392\u5e8f\u52a0\u901f\u67e5\u8be2\u3002with check option
\u5b50\u53e5\u3002DEFINER
\u4e0e SQL SECURITY
\u5b50\u53e5\u3002auto_increment
\u4e0e sequence
\u4e0d\u80fd\u4e00\u8d77\u7528\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002TRIGGER
\uff0cFUNCTION
\uff0cEVENT
\uff0cPROCEDURE
\uff0cENGINE
\u7b49\u3002SHOW STATUS/PRIVILEGES
\u7b49\u3002SHOW GRANTS
\uff0cSHOW ERRORS
\uff0cSHOW VARIABLES
\uff0cSHOW PROCESSLIST
\u3002SHOW BACKEND SERVERS
\uff0cSHOW ACCOUNTS
\uff0cSHOW ROLES
\uff0cSHOW NODE LIST
\u7b49\u3002ROLE
\uff0cSQL_MODE
\uff0cTIME_ZONE
\u3002SELECT...FOR UPDATE
\u5f53\u524d\u4ec5\u652f\u6301\u5355\u8868\u67e5\u8be2\u3002
LOW_PRIORITY
\uff0cDELAYED
\uff0cHIGH_PRIORITY
\u7b49\u4fee\u9970\u7b26\u3002LOW_PRIORITY
\u548c IGNORE
\u4fee\u9970\u7b26\u3002LOW_PRIORITY
\uff0cQUICK
\uff0cIGNORE
\u7b49\u4fee\u9970\u7b26\u3002IN
\u7684\u591a\u5c42\u5173\u8054\u5b50\u67e5\u8be2\u3002SET
\uff0c\u4f46\u53ea\u652f\u6301 SET columns_name=nullif(expr1,expr2)
\u7684\u5f62\u5f0f\u3002LOAD DATA LOCAL
\uff0c\u4f46\u5728\u8fde\u63a5\u65f6\u5fc5\u987b\u52a0\u5165 --local-infile
\u53c2\u6570\u3002JSONlines
\u6587\u4ef6\uff0c\u4f46\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u7279\u6b8a\u7684\u8bed\u6cd5\u3002Explain
\u548c Explain Analyze
\u6253\u5370\u683c\u5f0f\u5747\u53c2\u7167 PostgreSQL\uff0c\u4e0e MySQL \u6709\u8f83\u5927\u4e0d\u540c\u3002REPLACE
\u8bed\u53e5\u4e0d\u652f\u6301\u4f7f\u7528 VALUES row_constructor_list
\u53c2\u6570\u63d2\u5165\u7684\u4e00\u7ec4\u503c\u6784\u6210\u7684\u884c\u3002'1000-01-01 00:00:00'
\u5230 '9999-12-31 23:59:59'
\uff0cMatrixOne \u7684\u6700\u5927\u8303\u56f4\u4e3a '0001-01-01 00:00:00'
\u5230 '9999-12-31 23:59:59'
\u3002'1970-01-01 00:00:01.000000'
UTC \u5230 '2038-01-19 03:14:07.999999'
UTC\uff0cMatrixOne \u7684\u6700\u5927\u8303\u56f4 '0001-01-01 00:00:00'
UTC \u5230 '9999-12-31 23:59:59'
UTC\u3002IN
, Between and
\u53ca Like
\u8bed\u53e5\u4e2d\u6682\u65f6\u4e0d\u751f\u6548\u3002ON CASCADE DELETE
\u7ea7\u8054\u5220\u9664\u3002KEY
\uff0cHASH
\uff0cRANGE
\uff0cRANGE COLUMNS
\uff0cLIST
\uff0cLIST COLUMNS
\u516d\u79cd\u5206\u533a\u7c7b\u578b\u3002KEY
\uff0cHASH
\u4e24\u79cd\u5206\u533a\u88c1\u526a\uff0c\u5176\u4ed6\u56db\u79cd\u6682\u672a\u5b9e\u73b0\u3002ADD/DROP/TRUNCATE PARTITION
\u6682\u672a\u652f\u6301\u3002RANK
\uff0cDENSE_RANK
\uff0cROW_NUMBER
\u3002JSON_UNQUOTE
\uff0cJSON_QUOTE
\uff0cJSON_EXTRACT
\u3002CURRENT_ROLE_NAME()
\uff0cCURRENT_ROLE()
\uff0cCURRENT_USER_NAME()
\uff0cCURRENT_USER
\uff0cPURGE_LOG()
\u3002ENGINE=XXX
\u6765\u66f4\u6362\u5f15\u64ce\u3002ALTER USER
\u65b9\u6cd5\u4fee\u6539\u5bc6\u7801\u3002LOAD
\u6587\u4ef6\u6388\u6743\u7ba1\u7406\u3002CREATE STAGE
\u90e8\u5206\u652f\u6301 SELECT INTO
\u6587\u4ef6\u6388\u6743\u7ba1\u7406\u3002LOCK/UNLOCK TABLE
\u3002lower_case_table_names
\u6709 2 \u79cd\u6a21\u5f0f\uff0c\u9ed8\u8ba4\u4e3a 1\u3002sql_mode
\u53ea\u652f\u6301 ONLY_FULL_GROUP_BY
\u4e00\u79cd\u6a21\u5f0fmysql
\u548c information_schema
\u8fd9\u4e24\u4e2a\u7cfb\u7edf\u5e93\u6574\u4f53\u517c\u5bb9\u4e86 MySQL \u7684\u4f7f\u7528\u6a21\u5f0f\u3002system_metrics
\u7cfb\u7edf\u5e93\u6536\u96c6\u548c\u5b58\u50a8\u4e86\u4e00\u7cfb\u5217 MatrixOne \u670d\u52a1\u7684\u8fd0\u884c\u65f6\u72b6\u6001\u76d1\u63a7\u6570\u636e\u3002system
\u7cfb\u7edf\u5e93\u6536\u96c6\u4e86 MatrixOne \u4e2d\u7528\u6237\u548c\u7cfb\u7edf\u6267\u884c\u7684\u5404\u7c7b\u8bed\u53e5\u548c\u7cfb\u7edf\u8fd0\u884c\u65e5\u5fd7\u3002mo_catalog
\u7cfb\u7edf\u5e93\u5b58\u50a8\u4e86 MatrixOne \u4e2d\u7684\u5404\u79cd\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u5143\u6570\u636e\u3002MatrixOne \u662f\u4e00\u6b3e\u8d85\u7ea7\u6574\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0c\u5176\u6574\u4f53\u57fa\u4e8e\u5b58\u50a8\u3001\u8ba1\u7b97\u548c\u4e8b\u52a1\u5206\u79bb\u7684\u67b6\u6784\uff0c\u62e5\u6709\u6781\u81f4\u7684\u5f39\u6027\u6269\u5c55\u80fd\u529b\uff0c\u80fd\u591f\u8fc5\u901f\u5e94\u5bf9\u7528\u6237\u8d1f\u8f7d\u7684\u53d8\u52a8\u3002\u968f\u7740\u6570\u636e\u91cf\u548c\u4e1a\u52a1\u7684\u6269\u5927\uff0c\u4f01\u4e1a\u5bf9\u6570\u636e\u5e93\u6269\u5c55\u6027\u7684\u9700\u6c42\u65e5\u76ca\u589e\u5f3a\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u65e0\u8bba\u7528\u6237\u6570\u636e\u4ece 0 \u589e\u957f\u5230 100TB \u7ea7\u522b\uff0c\u6216\u8005\u5e76\u53d1\u91cf\u4ece\u6570\u767e\u589e\u957f\u5230\u6570\u5341\u4e07\u7ea7\u522b\uff0cMatrixOne \u90fd\u80fd\u901a\u8fc7\u5176\u65e0\u6bd4\u7684\u6269\u5c55\u80fd\u529b\u6ee1\u8db3\u6027\u80fd\u9700\u6c42\u3002
"},{"location":"MatrixOne/Overview/feature/scalability/#_2","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u4f01\u4e1a\u5bf9\u6570\u636e\u5e93\u6269\u5c55\u6027\u7684\u9700\u6c42\u4e3b\u8981\u6e90\u4e8e\u4ee5\u4e0b\u75db\u70b9\uff1a
\u5982\u679c\u6570\u636e\u5e93\u5177\u6709\u826f\u597d\u7684\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f01\u4e1a\u63d0\u9ad8\u6570\u636e\u5904\u7406\u80fd\u529b\uff0c\u4ece\u800c\u6709\u6548\u5e94\u5bf9\u6570\u636e\u91cf\u7684\u589e\u957f\uff0c\u5904\u7406\u5e76\u53d1\u8bf7\u6c42\u7684\u589e\u52a0\uff0c\u5e76\u4fdd\u8bc1\u7cfb\u7edf\u7684\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/scalability/#_3","title":"\u6280\u672f\u67b6\u6784","text":"MatrixOne \u5168\u9762\u91c7\u7528\u4e91\u539f\u751f\u67b6\u6784\uff0c\u6240\u6709\u7684\u7ec4\u4ef6\u90fd\u4ee5\u5bb9\u5668\u5f62\u5f0f\u5b58\u5728\uff0c\u7531 Kubernetes \u8fdb\u884c\u7edf\u4e00\u7ba1\u7406\u3002Kubernetes \u672c\u8eab\u5177\u6709\u5f3a\u5927\u7684\u5bb9\u5668\u7f16\u6392\u548c\u7ba1\u7406\u80fd\u529b\uff0c\u5728 MatrixOne \u4e2d\uff0c\u624b\u52a8\u6269\u5c55\u4ec5\u9700\u8981\u4fee\u6539 Kubernetes \u7684\u914d\u7f6e\u3002
"},{"location":"MatrixOne/Overview/feature/scalability/#_4","title":"\u529f\u80fd\u4f18\u52bf","text":"\u4ece\u4e0a\u56fe\u6280\u672f\u67b6\u6784\u89d2\u5ea6\u770b\uff0cMatrixOne \u7684\u6781\u81f4\u6269\u5c55\u6027\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
\u5206\u5e03\u5f0f\u67b6\u6784\u7684\u7075\u6d3b\u6269\u5c55\uff1aMatrixOne \u91c7\u7528\u4e86\u5206\u5e03\u5f0f\u5b58\u50a8\u548c\u8ba1\u7b97\u5206\u79bb\u7684\u67b6\u6784\uff0c\u5b58\u50a8\u5c42\u3001\u4e8b\u52a1\u5c42\u3001\u8ba1\u7b97\u5c42\u7684\u5206\u79bb\uff0c\u4f7f\u5f97 MatrixOne \u5728\u9047\u5230\u7cfb\u7edf\u8d44\u6e90\u74f6\u9888\u65f6\uff0c\u80fd\u591f\u7075\u6d3b\u5b9e\u73b0\u8282\u70b9\u7684\u6269\u5c55\u3002\u5b58\u50a8\u5c42\u4e3b\u8981\u57fa\u4e8e\u5bf9\u8c61\u5b58\u50a8\uff0c\u90e8\u5206\u57fa\u4e8e\u8ba1\u7b97\u8282\u70b9 CN \u4e0a\u7684\u7f13\u5b58\u3002\u4e8b\u52a1\u5c42\u57fa\u4e8e\u65e0\u72b6\u6001\u7684\u4e8b\u52a1\u8282\u70b9 TN\u3002\u8ba1\u7b97\u5c42\u57fa\u4e8e\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9 CN\u3002\u591a\u8282\u70b9\u7684\u67b6\u6784\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u5206\u914d\u8d44\u6e90\uff0c\u907f\u514d\u70ed\u70b9\u548c\u8d44\u6e90\u4e89\u62a2\u3002
S3 \u5bf9\u8c61\u5b58\u50a8\u7684\u65e0\u9650\u6269\u5c55\u80fd\u529b\uff1aMatrixOne \u7684\u6838\u5fc3\u5b58\u50a8\u5b8c\u5168\u57fa\u4e8e S3 \u5bf9\u8c61\u5b58\u50a8\u3002S3 \u5bf9\u8c61\u5b58\u50a8\u5177\u6709\u5929\u7136\u7684\u9ad8\u53ef\u7528\u6027\u548c\u65e0\u9650\u6269\u5c55\u6027\uff0c\u4f7f\u5f97 MatrixOne \u5728\u6570\u636e\u5b58\u50a8\u65b9\u9762\u5177\u6709\u6781\u9ad8\u7684\u6269\u5c55\u6027\u3002\u65e0\u8bba\u6570\u636e\u89c4\u6a21\u5982\u4f55\u589e\u957f\uff0cMatrixOne \u90fd\u53ef\u4ee5\u901a\u8fc7\u6269\u5c55 S3 \u5b58\u50a8\u6765\u6ee1\u8db3\u9700\u6c42\u3002\u5728\u79c1\u6709\u5316\u90e8\u7f72\u73af\u5883\u4e2d\uff0cMatrixOne \u57fa\u4e8e\u5f00\u6e90\u7684 MinIO \u7ec4\u4ef6\u642d\u5efa S3 \u670d\u52a1\u3002\u5728\u516c\u6709\u4e91\u73af\u5883\u4e2d\uff0cMatrixOne \u53ef\u4ee5\u65e0\u7f1d\u5229\u7528\u516c\u6709\u4e91\u63d0\u4f9b\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u548c\u4e8b\u52a1\u8282\u70b9\uff1aMatrixOne \u7684\u8ba1\u7b97\u8282\u70b9\uff08CN\uff09\u548c\u4e8b\u52a1\u8282\u70b9\uff08TN\uff09\u662f\u65e0\u72b6\u6001\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u53ef\u4ee5\u968f\u65f6\u8fdb\u884c\u6a2a\u5411\u6269\u5c55\u3002\u65e0\u72b6\u6001\u7684\u8bbe\u8ba1\u4f7f\u5f97\u8ba1\u7b97\u548c\u4e8b\u52a1\u8282\u70b9\u4e0d\u9700\u8981\u5b58\u50a8\u4efb\u4f55\u6301\u4e45\u5316\u6570\u636e\uff0c\u4ece\u800c\u53ef\u4ee5\u8f7b\u677e\u6dfb\u52a0\u6216\u5220\u9664\uff0c\u4ee5\u5e94\u5bf9\u4e0d\u540c\u7684\u8d1f\u8f7d\u9700\u6c42\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4f7f\u5f97 MatrixOne \u5728\u5904\u7406\u5927\u89c4\u6a21\u5e76\u53d1\u8bf7\u6c42\u65f6\u5177\u6709\u6781\u9ad8\u7684\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\u3002\uff08\u5f53\u524d 0.8 \u7248\u672c TN \u8282\u70b9\u5c1a\u4e0d\u5177\u5907\u6269\u5c55\u80fd\u529b\uff0c\u4f46\u662f TN \u4e3b\u8981\u5904\u7406\u4e8b\u52a1\u7684\u63d0\u4ea4\u4fe1\u606f\uff0c\u8d1f\u8f7d\u8f83\u4f4e\uff0c\u56e0\u6b64\u5355 TN \u5df2\u8db3\u591f\u5904\u7406\u8f83\u5927\u89c4\u6a21\u7684\u96c6\u7fa4\uff0c\u540e\u7eed\u7248\u672c\u4f1a\u5b8c\u5584 TN \u7684\u6269\u5c55\u6027\uff09\u3002
\u4e0d\u540c\u8d1f\u8f7d\u53ca\u79df\u6237\u7684\u72ec\u7acb\u6269\u7f29\uff1aMatrixOne \u901a\u8fc7 Proxy \u6a21\u5757\u53ef\u4ee5\u5c06\u591a\u4e2a\u8ba1\u7b97\u8282\u70b9\uff08CN\uff09\u8fdb\u884c\u5206\u7ec4\u7ba1\u7406\uff0c\u7ec4\u6210 CN Set\uff0c\u901a\u8fc7\u6807\u7b7e\u6765\u5b9e\u73b0\u6bcf\u7ec4 CN Set \u7684\u72ec\u7acb\u6269\u7f29\u3002\u7528\u6237\u53ef\u4ee5\u5bf9\u4e0d\u540c\u79df\u6237\u6307\u5b9a\u4e0d\u540c\u7684 CN Set\uff0c\u4f7f\u79df\u6237\u4e4b\u95f4\u8d1f\u8f7d\u9694\u79bb\u5e76\u72ec\u7acb\u6269\u5c55\u3002\u4e5f\u53ef\u4ee5\u5bf9\u4e0d\u540c\u8d1f\u8f7d\u6307\u5b9a\u4e0d\u540c\u7684 CN Set\uff0c\u6bd4\u5982\u8bfb\u8d1f\u8f7d\u548c\u5199\u8d1f\u8f7d\uff0c\u6216\u8005\u4e8b\u52a1\u578b\u8d1f\u8f7d\u548c\u5206\u6790\u578b\u8d1f\u8f7d\uff0c\u5b9e\u73b0\u5b83\u4eec\u4e4b\u95f4\u7684\u9694\u79bb\u548c\u72ec\u7acb\u6269\u7f29\u3002
\u968f\u7740\u5b9e\u65f6\u6570\u636e\u5206\u6790\u7684\u5174\u8d77\uff0c\u6d41\u5f0f\u6570\u636e\u5728\u591a\u4e2a\u9886\u57df\u4e2d\u53d8\u5f97\u8d8a\u6765\u8d8a\u91cd\u8981\u3002\u8fd9\u4e9b\u6570\u636e\u6e90\u4e3b\u8981\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u793e\u4ea4\u5a92\u4f53\u5b9e\u65f6\u52a8\u6001\u3001\u5728\u7ebf\u96f6\u552e\u4ea4\u6613\u3001\u5b9e\u65f6\u5e02\u573a\u5206\u6790\u3001\u7f51\u7edc\u5b89\u5168\u76d1\u63a7\u3001\u5373\u65f6\u901a\u8baf\u8bb0\u5f55\uff0c\u4ee5\u53ca\u667a\u80fd\u57ce\u5e02\u57fa\u7840\u8bbe\u65bd\u7684\u5b9e\u65f6\u6570\u636e\u3002\u6d41\u5f0f\u6570\u636e\u7684\u5e94\u7528\u573a\u666f\u5e7f\u6cdb\uff0c\u4f8b\u5982\uff1a
\u6d41\u5f0f\u6570\u636e\u7684\u663e\u8457\u7279\u70b9\u5728\u4e8e\u5176\u5b9e\u65f6\u6027\u548c\u8fde\u7eed\u6027\u3002\u8fd9\u610f\u5473\u7740\u6570\u636e\u662f\u4e0d\u65ad\u751f\u6210\u5e76\u5373\u65f6\u4f20\u8f93\u7684\uff0c\u6bcf\u65f6\u6bcf\u523b\u90fd\u5728\u53cd\u6620\u6700\u65b0\u7684\u60c5\u51b5\u3002\u6b64\u5916\uff0c\u7531\u4e8e\u6570\u636e\u6d41\u7684\u4f53\u91cf\u5e9e\u5927\u4e14\u53d8\u5316\u8fc5\u901f\uff0c\u4f20\u7edf\u7684\u6570\u636e\u5904\u7406\u65b9\u6cd5\u5f80\u5f80\u96be\u4ee5\u5e94\u5bf9\uff0c\u9700\u8981\u66f4\u52a0\u9ad8\u6548\u7684\u5904\u7406\u548c\u5206\u6790\u6280\u672f\u3002\u56e0\u6b64\uff0c\u6d41\u5f0f\u6570\u636e\u5904\u7406\u901a\u5e38\u9700\u8981\uff1a
\u8fd9\u4e9b\u7279\u6027\u4f7f\u5f97\u6d41\u5f0f\u6570\u636e\u5728\u73b0\u4ee3\u6570\u636e\u9a71\u52a8\u7684\u51b3\u7b56\u8fc7\u7a0b\u4e2d\u53d1\u6325\u7740\u65e5\u76ca\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u5feb\u901f\u54cd\u5e94\u548c\u5b9e\u65f6\u6d1e\u5bdf\u7684\u573a\u666f\u4e2d\u3002
"},{"location":"MatrixOne/Overview/feature/stream/#matrixone","title":"MatrixOne \u5728\u6d41\u4e0a\u7684\u80fd\u529b","text":""},{"location":"MatrixOne/Overview/feature/stream/#source","title":"Source","text":"MatrixOne \u901a\u8fc7 Source \u540c\u6b65\u5916\u90e8\u6570\u636e\u6d41\u4e0e MatrixOne \u6570\u636e\u5e93\u8868\u4e4b\u95f4\u7684\u6570\u636e\uff0c\u901a\u8fc7\u5b9e\u73b0\u7cbe\u786e\u7684\u8fde\u63a5\u4e0e\u6570\u636e\u6620\u5c04\u673a\u5236\uff0cSource \u4e0d\u4ec5\u786e\u4fdd\u4e86\u6570\u636e\u6d41\u7684\u65e0\u7f1d\u5bf9\u63a5\uff0c\u800c\u4e14\u4fdd\u969c\u4e86\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/stream/#dynamic-table","title":"\u52a8\u6001\u8868 Dynamic Table","text":"\u52a8\u6001\u8868\uff08Dynamic Table\uff09\u662f MatrixOne \u5728\u6d41\u4e0a\u80fd\u529b\u7684\u6838\u5fc3\u4f53\u73b0\u3002\u52a8\u6001\u8868\u80fd\u591f\u5b9e\u65f6\u6355\u6349\u3001\u5904\u7406\u5e76\u8f6c\u6362\u6d41\u5165\u5305\u62ec Source \u548c\u666e\u901a\u7684\u6570\u636e\u8868\u7684\u6570\u636e\uff0c\u4ece\u800c\u4fdd\u8bc1\u4fe1\u606f\u6d41\u5728\u6574\u4e2a\u7cfb\u7edf\u4e2d\u7684\u5373\u65f6\u66f4\u65b0\u548c\u51c6\u786e\u8868\u8fbe\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4e0d\u4ec5\u63d0\u5347\u4e86\u6570\u636e\u5904\u7406\u7684\u7075\u6d3b\u6027\u548c\u6548\u7387\uff0c\u8fd8\u4f18\u5316\u4e86\u6574\u4e2a\u7cfb\u7edf\u5bf9\u4e8e\u590d\u6742\u6570\u636e\u573a\u666f\u7684\u54cd\u5e94\u80fd\u529b\u548c\u5904\u7406\u6027\u80fd\u3002
"},{"location":"MatrixOne/Overview/feature/time-series/","title":"\u65f6\u5e8f\u80fd\u529b","text":""},{"location":"MatrixOne/Overview/feature/time-series/#_2","title":"\u65f6\u5e8f\u6570\u636e\u7684\u7279\u70b9","text":"\u968f\u7740\u7269\u8054\u7f51\u7684\u53d1\u5c55\uff0c\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u9700\u6c42\u8d8a\u6765\u8d8a\u591a\uff0c\u6bd4\u5982\u667a\u80fd\u6c7d\u8f66\u4ea7\u751f\u7684\u6570\u636e\uff0c\u5de5\u5382\u7684\u8bbe\u5907\u76d1\u63a7\u3001\u91d1\u878d\u884c\u4e1a\u7684\u4ea4\u6613\u884c\u60c5\u6307\u6807\u6570\u636e\u7b49\u3002\u5e38\u89c1\u7684\u4e1a\u52a1\u573a\u666f\u5305\u62ec\uff1a
\u76d1\u63a7\u8f6f\u4ef6\u7cfb\u7edf\uff1a\u865a\u62df\u673a\u3001\u5bb9\u5668\u3001\u670d\u52a1\u3001\u5e94\u7528\uff1b \u76d1\u63a7\u7269\u7406\u7cfb\u7edf\uff1a\u6c34\u6587\u76d1\u63a7\u3001\u5236\u9020\u4e1a\u5de5\u5382\u4e2d\u7684\u8bbe\u5907\u76d1\u63a7\u3001\u56fd\u5bb6\u5b89\u5168\u76f8\u5173\u7684\u6570\u636e\u76d1\u63a7\u3001\u901a\u8baf\u76d1\u63a7\u3001\u4f20\u611f\u5668\u6570\u636e\u3001\u8840\u7cd6\u4eea\u3001\u8840\u538b\u53d8\u5316\u3001\u5fc3\u7387\u7b49\uff1b \u8d44\u4ea7\u8ddf\u8e2a\u5e94\u7528\uff1a\u6c7d\u8f66\u3001\u5361\u8f66\u3001\u7269\u7406\u5bb9\u5668\u3001\u8fd0\u8d27\u6258\u76d8\uff1b \u91d1\u878d\u4ea4\u6613\u7cfb\u7edf\uff1a\u4f20\u7edf\u8bc1\u5238\u3001\u65b0\u5174\u7684\u52a0\u5bc6\u6570\u5b57\u8d27\u5e01\uff1b \u4e8b\u4ef6\u5e94\u7528\u7a0b\u5e8f\uff1a\u8ddf\u8e2a\u7528\u6237\u3001\u5ba2\u6237\u7684\u4ea4\u4e92\u6570\u636e\uff1b \u5546\u4e1a\u667a\u80fd\u5de5\u5177\uff1a\u8ddf\u8e2a\u5173\u952e\u6307\u6807\u548c\u4e1a\u52a1\u7684\u603b\u4f53\u5065\u5eb7\u60c5\u51b5\uff1b \u4e92\u8054\u7f51\u884c\u4e1a\uff1a\u4e5f\u6709\u7740\u975e\u5e38\u591a\u7684\u65f6\u5e8f\u6570\u636e\uff0c\u4f8b\u5982\u7528\u6237\u8bbf\u95ee\u7f51\u7ad9\u7684\u884c\u4e3a\u8f68\u8ff9\uff0c\u5e94\u7528\u7a0b\u5e8f\u4ea7\u751f\u7684\u65e5\u5fd7\u6570\u636e\u7b49\u3002
\u4e00\u65b9\u9762\u7531\u4e8e\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u65f6\u95f4\u5c5e\u6027\uff0c\u5373\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u4e0d\u65ad\u5730\u4ea7\u751f\u65b0\u7684\u6570\u636e\uff1b\u53e6\u4e00\u65b9\u9762\uff0c\u65f6\u5e8f\u7684\u6570\u636e\u91cf\u5de8\u5927\uff0c\u6bcf\u79d2\u949f\u53ef\u80fd\u8981\u5199\u5165\u5343\u4e07\u3001\u4e0a\u4ebf\u6761\u6570\u636e\u3002\u8fd9\u4e24\u65b9\u9762\u7684\u7279\u6027\u4f7f\u5f97\u65f6\u5e8f\u6570\u636e\u5e93\u5728\u4e00\u4e9b\u4e1a\u52a1\u9700\u6c42\u4e2d\u4f1a\u51fa\u73b0\uff0c\u5e38\u89c1\u7684\u4e1a\u52a1\u9700\u6c42\u6709\uff1a
\u76ee\u524d\u884c\u4e1a\u4e2d\u5df2\u7ecf\u6709\u4e00\u4e9b\u4e13\u7528\u7684 NoSQL \u65f6\u5e8f\u6570\u636e\u5e93\uff0c\u5982 InfluxDB, OpenTSDB, TDEngine \u7b49\uff0c\u800c MatrixOne \u4e0e\u5b83\u4eec\u4e0d\u4e00\u6837\u7684\u5730\u65b9\u5728\u4e8e MatrixOne \u4ecd\u7136\u662f\u4e00\u4e2a\u901a\u7528\u6570\u636e\u5e93\uff0c\u4ee5\u6ee1\u8db3\u5e94\u7528\u5f00\u53d1\u7684\u589e\u5220\u6539\u67e5\u53ca\u6570\u636e\u5206\u6790\u7684 HTAP \u4e3a\u6838\u5fc3\uff0c\u540c\u65f6\u4e5f\u4ecd\u7136\u662f\u4e00\u4e2a\u5173\u7cfb\u578b\u6570\u636e\u7684\u5efa\u6a21\u5f62\u5f0f\uff0c\u4f7f\u7528\u7684\u67e5\u8be2\u8bed\u8a00\u4e5f\u4ecd\u7136\u662f\u7ecf\u5178\u7684 SQL \u8bed\u8a00\uff0cMatrixOne \u662f\u5728\u901a\u7528\u6570\u636e\u5e93\u80fd\u529b\u7684\u57fa\u7840\u589e\u52a0\u4e86\u4e00\u4e9b\u65f6\u5e8f\u76f8\u5173\u7684\u80fd\u529b\uff0c\u5b9a\u4f4d\u4e0a\u6765\u8bf4\u6709\u70b9\u7c7b\u4f3c\u4e8e TimeScaleDB\u3002MatrixOne \u5728\u529f\u80fd\u4e0a\u652f\u6301\u65f6\u95f4\u7a97\u53e3\uff0c\u964d\u91c7\u6837\uff0c\u63d2\u503c\uff0c\u5206\u533a\u7b49\u65f6\u5e8f\u5e38\u89c1\u7684\u80fd\u529b\uff0c\u6027\u80fd\u4e0a\u53ef\u4ee5\u6ee1\u8db3\u65f6\u5e8f\u573a\u666f\u4e2d\u5bf9\u9ad8\u541e\u5410\uff0c\u9ad8\u538b\u7f29\uff0c\u5b9e\u65f6\u5206\u6790\uff0c\u540c\u65f6\u6574\u4f53\u67b6\u6784\u4e0a\u7684\u5f3a\u6269\u5c55\u6027\uff0c\u51b7\u70ed\u5206\u79bb\uff0c\u8bfb\u5199\u5206\u79bb\u7b49\u7279\u70b9\u4e5f\u975e\u5e38\u9002\u5408\u65f6\u5e8f\u76f8\u5173\u7684\u573a\u666f\u4f7f\u7528\uff0c\u540c\u65f6\u4fdd\u6301\u4e86\u4f20\u7edf\u6570\u636e\u5e93\u4e2d\u5bf9\u66f4\u65b0\uff0c\u4e8b\u52a1\u7684\u652f\u6301\u3002\u56e0\u6b64\uff0cMatrixOne \u66f4\u9002\u5408\u9700\u8981\u7528\u666e\u901a\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u8fdb\u884c\u4e1a\u52a1\u5f00\u53d1\uff0c\u4f46\u662f\u540c\u65f6\u6709\u9700\u8981\u6709\u4e00\u5b9a\u65f6\u5e8f\u5904\u7406\u80fd\u529b\u7684\u6df7\u5408\u573a\u666f\u3002
MatrixOne \u7684\u65f6\u5e8f\u80fd\u529b\u4f53\u73b0\u5728\u4ee5\u4e0b\u65b9\u9762\uff1a
\u60a8\u53ef\u4ee5\u7f16\u5199\u7528\u6237\u5b9a\u4e49\u51fd\u6570 (UDF) \u6765\u6269\u5c55\u7cfb\u7edf\uff0c\u4ee5\u6267\u884c MatrixOne \u63d0\u4f9b\u7684\u5185\u7f6e\u7cfb\u7edf\u5b9a\u4e49\u51fd\u6570\u65e0\u6cd5\u6267\u884c\u7684\u64cd\u4f5c\uff0c\u521b\u5efa UDF \u540e\uff0c\u60a8\u53ef\u4ee5\u591a\u6b21\u91cd\u590d\u4f7f\u7528\u5b83\u3002
"},{"location":"MatrixOne/Overview/feature/udf/#udf_1","title":"\u4ec0\u4e48\u662f UDF?","text":"\u5728\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u5b9a\u4e49\u51fd\u6570\uff08UDF\uff09\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u5141\u8bb8\u7528\u6237\u6839\u636e\u7279\u5b9a\u9700\u6c42\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u3002\u8fd9\u4e9b\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u6267\u884c\u590d\u6742\u7684\u8ba1\u7b97\u3001\u6570\u636e\u8f6c\u6362\u7b49\u53ef\u80fd\u8d85\u51fa\u4e86\u6807\u51c6 SQL \u51fd\u6570\u7684\u8303\u56f4\u7684\u51fd\u6570\u3002
"},{"location":"MatrixOne/Overview/feature/udf/#udf_2","title":"UDF \u7684\u6838\u5fc3\u80fd\u529b","text":"\u5728\u5f53\u524d\u7248\u672c\u4e2d\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 Python \u8bed\u8a00\u7684 UDF\u3002
\u6709\u5173 MatrixOne \u4e2d UDF-python \u7684\u57fa\u7840\u7528\u6cd5\uff0c\u53c2\u89c1 UDF-python \u57fa\u7840\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u4e2d UDF-python \u7684\u8fdb\u9636\u7528\u6cd5\uff0c\u53c2\u89c1 UDF-python \u8fdb\u9636\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u521b\u5efa\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u521b\u5efa UDF\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u5220\u9664\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u5220\u9664 UDF\u3002
"},{"location":"MatrixOne/Overview/matrixone-vs-other_databases/matrixone-positioning/","title":"MatrixOne \u7684\u5b9a\u4f4d","text":"\u5728\u5e9e\u5927\u800c\u590d\u6742\u7684\u6570\u636e\u6280\u672f\u6808\u548c\u5404\u7c7b\u6570\u636e\u5e93\u4ea7\u54c1\u4e2d\uff0cMatrixOne \u7684\u5b9a\u4f4d\u662f\u4e00\u6b3e\u4e3b\u6253\u4e00\u7ad9\u5f0f\u878d\u5408\u80fd\u529b\u548c\u7075\u6d3b\u6269\u5c55\u6027\u7684 SQL \u5173\u7cfb\u578b\u6570\u636e\u5e93\u3002MatrixOne \u7684\u8bbe\u8ba1\u76ee\u6807\u662f\u63d0\u4f9b\u4e00\u4e2a\u4f7f\u7528\u4f53\u9a8c\u5982 MySQL \u4e00\u6837\u7b80\u5355\u7684\u6570\u636e\u5e93\u4ea7\u54c1\uff0c\u53ef\u4ee5\u5904\u7406\u5305\u62ec OLTP \u548c OLAP \u7b49\u5404\u7c7b\u4e1a\u52a1\u8d1f\u8f7d\u548c\u6570\u636e\u7c7b\u578b\uff0c\u540c\u65f6\u80fd\u611f\u77e5\u7528\u6237\u7684\u8d1f\u8f7d\u548c\u6570\u636e\u91cf\u53d8\u5316\u81ea\u52a8\u5316\u7684\u8fdb\u884c\u5feb\u901f\u5f39\u6027\u4f38\u7f29\uff0c\u4ee5\u7b80\u5316\u7528\u6237\u5f53\u524d\u590d\u6742\u7684\u591a\u6570\u636e\u5e93\u4ea7\u54c1+ETL \u7684\u4f20\u7edf\u6570\u636e\u67b6\u6784\u3002
\u5728\u884c\u4e1a\u73b0\u6709\u7684\u6570\u636e\u5e93\u4ea7\u54c1\u4e2d\u6765\u8bf4\u4e0e MatrixOne \u6700\u63a5\u8fd1\u7684\u6570\u636e\u5e93\u4ea7\u54c1\u662f SingleStore\uff0c\u4e24\u8005\u90fd\u91c7\u7528\u7edf\u4e00\u5b58\u50a8\u6a21\u578b\uff0c\u652f\u6301 OLTP\uff0cOLAP \u4ee5\u53ca\u5176\u4ed6\u4e00\u7cfb\u5217\u6570\u636e\u8d1f\u8f7d\u548c\u6570\u636e\u7c7b\u578b\u7684\u878d\u5408\uff0c\u540c\u65f6\u4e5f\u90fd\u4ee5\u4e91\u539f\u751f\u548c\u53ef\u7075\u6d3b\u6269\u5c55\u4f5c\u4e3a\u81ea\u5df1\u7684\u6838\u5fc3\u67b6\u6784\u80fd\u529b\u3002
\u4ece\u67b6\u6784\u4e0a\u6765\u8bf4\uff0cMatrixOne \u662f\u4e00\u6b3e\u5b8c\u5168\u4e91\u539f\u751f\u548c\u5bb9\u5668\u5316\u7684\u6570\u636e\u5e93\uff0cMatrixOne \u501f\u9274\u4e86 Snowflake \u5bf9\u4e91\u539f\u751f\u6570\u636e\u4ed3\u5e93\u7684\u5b58\u7b97\u5206\u79bb\u8bbe\u8ba1\uff0c\u5b8c\u5168\u5c06\u5b58\u50a8\u4ea4\u4e8e\u4e91\u4e0a\u7684\u5171\u4eab\u5b58\u50a8\uff0c\u540c\u65f6\u5c06\u8ba1\u7b97\u5c42\u5b8c\u5168\u6784\u5efa\u6210\u4e86\u65e0\u72b6\u6001\u5316\u7684\u5bb9\u5668\u3002\u540c\u65f6\uff0c\u4e3a\u4e86\u80fd\u9002\u5e94 OLTP \u7c7b\u578b\u8d1f\u8f7d\u5bf9\u5feb\u901f\u5199\u5165\u8bf7\u6c42\u7684\u5904\u7406\uff0cMatrixOne \u589e\u52a0\u4e86 TN \u53ca LogService \u7684\u6982\u5ff5\uff0c\u4ee5\u5757\u5b58\u50a8\u6765\u652f\u6491\u9ad8\u9891\u5199\u5165\uff0c\u901a\u8fc7 Raft \u4e09\u526f\u672c\u4e00\u81f4\u6027\u4fdd\u8bc1\u6765\u786e\u4fdd\u5199\u5165\u65e5\u5fd7 WAL \u7684\u9ad8\u53ef\u7528\uff0c\u540c\u65f6\u518d\u5f02\u6b65\u7684\u5c06 WAL \u843d\u76d8\u5230\u5171\u4eab\u5b58\u50a8\u4e2d\u3002\u4e0e SingleStore \u4e0d\u540c\u4e4b\u5904\u5728\u4e8e SingleStore \u662f\u4ece Share-nothing \u67b6\u6784\u4e0a\u6269\u5c55\u5230\u4e86\u4e91\u539f\u751f\u7684\u5b58\u7b97\u5206\u79bb\u4e0a\uff0c\u5176\u4ec5\u5c06\u51b7\u6570\u636e\u653e\u5165\u5171\u4eab\u5b58\u50a8\uff08\u53ef\u53c2\u8003 SingleStore \u67b6\u6784\u8bba\u6587\uff09\uff0c\u4f9d\u7136\u9700\u8981\u505a\u6570\u636e\u5206\u7247\u548c\u518d\u5e73\u8861\u3002\u800c MatrixOne \u4e0e Snowflake \u4e00\u81f4\uff0c\u5219\u662f\u5b8c\u5168\u57fa\u4e8e\u5171\u4eab\u5b58\u50a8\uff0c\u6ca1\u6709\u4efb\u4f55\u6570\u636e\u5206\u7247\u3002
\u4ece\u8d1f\u8f7d\u7c7b\u578b\u4e0a\u6765\u8bf4\uff0cMatrixOne \u4ee5 HTAP \u4e3a\u57fa\u672c\u6838\u5fc3\uff0c\u9010\u6b65\u6269\u5c55\u81f3\u6d41\u8ba1\u7b97\uff0c\u65f6\u5e8f\u5904\u7406\uff0c\u673a\u5668\u5b66\u4e60\uff0c\u641c\u7d22\u7b49\u591a\u79cd\u8d1f\u8f7d\u7c7b\u578b\u3002\u5728 HTAP \u7684\u6280\u672f\u8def\u7ebf\u4e0a\uff0cMatrixOne \u4e0e\u4ee5 TiDB \u4e3a\u4e3b\u7684\u53cc\u5b58\u50a8\u548c\u8ba1\u7b97\u5f15\u64ce\u8def\u7ebf\u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u662f\u76f4\u63a5\u5728\u5355\u5b58\u50a8\u5f15\u64ce\u548c\u8ba1\u7b97\u5f15\u64ce\u4e0a\u5b9e\u73b0 HTAP\uff0c\u5b58\u50a8\u5f15\u64ce\u4e5f\u662f\u4ee5\u843d\u76d8\u5217\u5b58\u4e3a\u4e3b\uff0c\u5185\u5b58\u884c\u5b58\u4e3a\u8f85\u7684\u67b6\u6784\uff0c\u8fd9\u70b9\u4e0e SingleStore \u4e5f\u8f83\u4e3a\u4e00\u81f4\u3002TiDB \u4e00\u7c7b\u7684\u6280\u672f\u8def\u7ebf\u9700\u8981\u5185\u90e8\u8fdb\u884c\u53cc\u5f15\u64ce\u6570\u636e\u540c\u6b65\uff0c\u540c\u65f6 TP \u4e0e AP \u6570\u636e\u9700\u8981\u5355\u72ec\u5b58\u50a8\uff0c\u800c MatrixOne \u4e0d\u9700\u8981\u505a\u6b64\u540c\u6b65\u53ca\u591a\u4efd\u5b58\u50a8\u3002\u76f8\u6bd4 SingleStore \u5df2\u7ecf\u5bf9\u6d41\u8ba1\u7b97\uff0c\u641c\u7d22\uff0cGIS\uff0c\u673a\u5668\u5b66\u4e60\u7b49 HTAP \u4ee5\u5916\u7684\u5176\u4ed6\u591a\u79cd\u4e1a\u52a1\u7c7b\u578b\u90fd\u6709\u826f\u597d\u652f\u6301\uff0cMatrixOne \u672c\u8eab\u53d1\u5c55\u65f6\u95f4\u8f83\u665a\uff0c\u76ee\u524d\u9664\u4e86 HTAP \u4ee5\u5916\u5bf9\u5176\u4ed6\u8d1f\u8f7d\u7c7b\u578b\u7684\u652f\u6301\u7a0b\u5ea6\u4e0d\u591f\u5b8c\u5584\u3002
OLTP \u662f\u6307\u4e00\u79cd\u9762\u5411\u4e1a\u52a1\u4ea4\u6613\u7684\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u3002OLTP \u6570\u636e\u5e93\u7528\u4e8e\u5904\u7406\u5927\u91cf\u7684\u77ed\u671f\u4ea4\u6613\uff0c\u8fd9\u4e9b\u4ea4\u6613\u901a\u5e38\u662f\u4e00\u4e9b\u65e5\u5e38\u4e1a\u52a1\u64cd\u4f5c\uff0c\u4f8b\u5982\u8ba2\u5355\u5904\u7406\u3001\u5e93\u5b58\u7ba1\u7406\u3001\u94f6\u884c\u4ea4\u6613\u7b49\u3002\u5b83\u53ef\u4ee5\u63d0\u4f9b\u9ad8\u5e76\u53d1\u6027\u80fd\u548c\u5b9e\u65f6\u6570\u636e\u5904\u7406\uff0c\u4ee5\u6ee1\u8db3\u4f01\u4e1a\u5bf9\u5373\u65f6\u6570\u636e\u8bbf\u95ee\u7684\u9700\u6c42\u3002
OLTP \u6570\u636e\u5e93\u7684\u4e3b\u8981\u7279\u5f81\u5982\u4e0b\uff1a
\u7ec6\u7c92\u5ea6\u6570\u636e\u8bbf\u95ee\uff1aOLTP \u6570\u636e\u5e93\u901a\u5e38\u4ee5\u8bb0\u5f55\u4e3a\u5355\u4f4d\u8fdb\u884c\u6570\u636e\u8bbf\u95ee\uff0c\u5b83\u652f\u6301\u9ad8\u6548\u7684\u589e\u3001\u5220\u3001\u6539\u64cd\u4f5c\uff0c\u5e76\u63d0\u4f9b\u5feb\u901f\u7684\u4e8b\u52a1\u63d0\u4ea4\u548c\u56de\u6eda\u529f\u80fd\u3002
\u9ad8\u53ef\u9760\uff1aOLTP \u7cfb\u7edf\u5fc5\u987b\u5728\u53d1\u751f\u4efb\u4f55\u786c\u4ef6\u6216\u8f6f\u4ef6\u6545\u969c\u65f6\u5177\u6709\u6062\u590d\u80fd\u529b\u3002
OLTP \u6570\u636e\u5e93\u6839\u636e\u67b6\u6784\u548c\u6280\u672f\u8def\u7ebf\u7684\u4e0d\u540c\u8fd8\u53ef\u4ee5\u88ab\u5206\u4e3a\u96c6\u4e2d\u5f0f\u6570\u636e\u5e93\uff0c\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u548c\u4e91\u539f\u751f\u6570\u636e\u5e93\u3002
\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e09\u79cd\u5206\u7c7b\u5e76\u6ca1\u6709\u4e25\u683c\u7684\u5212\u5206\u6807\u51c6\uff0c\u5728\u5b9e\u9645\u7684\u53d1\u5c55\u8fc7\u7a0b\u4e2d\u6bcf\u5bb6\u6570\u636e\u5e93\u4e5f\u90fd\u5f00\u59cb\u9010\u6b65\u878d\u5408\u5176\u4ed6\u8def\u7ebf\u4ea7\u54c1\u7684\u80fd\u529b\u3002\u6bd4\u5982 Oracle \u7684 RAC \u67b6\u6784\u5c31\u662f\u5178\u578b\u7684\u5171\u4eab\u5b58\u50a8\u67b6\u6784\uff0c\u5177\u5907\u4e00\u5b9a\u7684\u6269\u5c55\u6027\u3002CockroachDB \u548c TiDB \u7b49\u4ea7\u54c1\u4e5f\u90fd\u5728\u9010\u6b65\u5f80\u4e91\u539f\u751f\u548c\u5171\u4eab\u5b58\u50a8\u65b9\u5411\u6f14\u8fdb\u3002\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0cOLTP \u4f5c\u4e3a\u9700\u6c42\u6700\u5e7f\u6cdb\u7684\u6570\u636e\u5e93\u573a\u666f\uff0c\u4e09\u79cd\u6280\u672f\u8def\u7ebf\u7684\u4ea7\u54c1\u4e5f\u90fd\u6709\u5927\u91cf\u7684\u7528\u6237\u5728\u4f7f\u7528\u3002
"},{"location":"MatrixOne/Overview/matrixone-vs-other_databases/matrixone-vs-oltp/#matrixone-oltp_1","title":"MatrixOne \u7684 OLTP \u7279\u70b9","text":"MatrixOne \u7684\u57fa\u672c\u80fd\u529b\u6ee1\u8db3\u4e00\u822c OLTP \u6570\u636e\u5e93\u7684\u7279\u70b9\u3002
\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u4ece\u67b6\u6784\u548c\u6280\u672f\u8def\u7ebf\u5206\u7c7b\u6765\u8bf4\uff0cMatrixOne \u5c5e\u4e8e\u4e91\u539f\u751f\u6280\u672f\u8def\u7ebf\uff0c\u4e0e Aurora \u66f4\u4e3a\u63a5\u8fd1\uff0c\u76f8\u6bd4\u4e8e Share-nothing \u67b6\u6784\u6700\u5927\u7684\u4f18\u52bf\u662f\u5b58\u50a8\u8ba1\u7b97\u5206\u79bb\u540e\uff0c\u5b58\u50a8\u548c\u8ba1\u7b97\u90fd\u53ef\u4ee5\u6309\u9700\u4f7f\u7528\u3002
\u4e0e Aurora \u4e0d\u540c\u7684\u5730\u65b9\u6709\u4e24\u70b9\uff1a
\u5f53\u7136\uff0cMatrixOne \u5e76\u4e0d\u4ec5\u5c40\u9650\u4e8e OLTP \u80fd\u529b\uff0cMatrixOne \u9002\u914d\u5176\u4ed6\u8d1f\u8f7d\u7684\u80fd\u529b\u4e5f\u4e0e Aurora \u7684\u5b9a\u4f4d\u6709\u663e\u8457\u5dee\u522b\u3002
"},{"location":"MatrixOne/Overview/matrixone-vs-other_databases/matrixone-vs-oltp/#matrixone-mysql","title":"MatrixOne \u4e0e MySQL \u7684\u5bf9\u6bd4","text":"\u7531\u4e8e MatrixOne \u4ee5\u517c\u5bb9 MySQL \u4e3a\u4e3b\u8981\u76ee\u6807\uff0cMySQL \u672c\u8eab\u4e5f\u662f\u4e16\u754c\u4e0a\u6d41\u884c\u5ea6\u6700\u9ad8\u7684\u5f00\u6e90\u6570\u636e\u5e93\u3002MatrixOne \u7684\u7528\u6237\u5f88\u5927\u4e00\u90e8\u5206\u662f\u7531\u4ece\u5f00\u6e90 MySQL \u8fc1\u79fb\u5230 MatrixOne \u7684\uff0c\u56e0\u6b64\u8fd9\u91cc\u6211\u4eec\u5c06 MatrixOne \u4e0e MySQL \u505a\u4e00\u4e2a\u8be6\u7ec6\u7684\u5bf9\u6bd4\u3002
MySQL MatrixOne \u7248\u672c 8.0.37 \u6700\u65b0\u7248\u672c License GPL License Apache License 2.0 \u67b6\u6784 \u96c6\u4e2d\u5f0f\u6570\u636e\u5e93 \u5206\u5e03\u5f0f\u4e91\u539f\u751f\u6570\u636e\u5e93 \u8d1f\u8f7d\u7c7b\u578b OLTP, \u5206\u6790\u578b\u8d1f\u8f7d\u4f9d\u8d56\u4e8e\u4f01\u4e1a\u7248\u7684 Heatwave HTAP\uff0c\u65f6\u5e8f \u5b58\u50a8\u683c\u5f0f \u884c\u5b58 \u5217\u5b58 \u5b58\u50a8\u5f15\u64ce InnoDB/MyIsam TAE \u4ea4\u4e92\u65b9\u5f0f SQL SQL \u90e8\u7f72\u65b9\u5f0f \u5355\u673a\u90e8\u7f72/\u4e3b\u4ece\u90e8\u7f72 \u5355\u673a\u90e8\u7f72/\u4e3b\u4ece\u90e8\u7f72/\u5206\u5e03\u5f0f\u90e8\u7f72/K8s\u90e8\u7f72 \u6a2a\u5411\u6269\u5c55\u80fd\u529b \u4f9d\u8d56\u5206\u5e93\u5206\u8868\u4e2d\u95f4\u4ef6\u5b9e\u73b0 \u5929\u7136\u652f\u6301 \u4e8b\u52a1\u80fd\u529b \u60b2\u89c2\u4e8b\u52a1/\u4e50\u89c2\u4e8b\u52a1+ANSI 4 \u79cd\u9694\u79bb\u7ea7\u522b\uff08InnoDB \u5f15\u64ce\uff09 \u60b2\u89c2\u4e8b\u52a1/\u4e50\u89c2\u4e8b\u52a1+RC/SI \u6570\u636e\u7c7b\u578b \u57fa\u7840\u6570\u503c\uff0c\u65f6\u95f4\u65e5\u671f\uff0c\u5b57\u7b26\uff0cJSON\uff0c\u7a7a\u95f4 \u57fa\u7840\u6570\u503c\uff0c\u65f6\u95f4\u65e5\u671f\uff0c\u5b57\u7b26\uff0cJSON\uff0c\u5411\u91cf \u7d22\u5f15\u548c\u7ea6\u675f \u4e3b\u952e\uff0c\u6b21\u7ea7\u952e\uff0c\u552f\u4e00\u952e\uff0c\u5916\u952e \u4e3b\u952e\uff0c\u6b21\u7ea7\u952e\uff0c\u552f\u4e00\u952e\uff0c\u5916\u952e \u8bbf\u95ee\u63a7\u5236 \u57fa\u4e8e RBAC \u57fa\u4e8e RBAC \u7a97\u53e3\u51fd\u6570 \u57fa\u7840\u7a97\u53e3\u51fd\u6570 \u57fa\u7840\u7a97\u53e3\u51fd\u6570\uff0c\u65f6\u95f4\u6ed1\u52a8\u7a97\u53e3 \u9ad8\u7ea7 SQL \u80fd\u529b \u89e6\u53d1\u5668\uff0c\u5b58\u50a8\u8fc7\u7a0b \u4e0d\u652f\u6301 \u6d41\u8ba1\u7b97 \u4e0d\u652f\u6301 \u6d41\u5f0f\u5199\u5165/kafka\u8fde\u63a5\u5668/\u52a8\u6001\u8868 UDF \u652f\u6301 SQL \u53ca C \u8bed\u8a00\u7684 UDF \u652f\u6301 SQL \u53ca Python \u7684 UDF \u591a\u79df\u6237 \u4e0d\u652f\u6301 \u652f\u6301 \u6570\u636e\u5171\u4eab \u4e0d\u652f\u6301 \u652f\u6301\u79df\u6237\u95f4\u6570\u636e\u5171\u4eab \u7f16\u7a0b\u8bed\u8a00 \u7edd\u5927\u90e8\u5206\u8bed\u8a00 Java\uff0cPython\uff0cGolang \u8fde\u63a5\u5668\u548c ORM \u57fa\u672c\u652f\u6301 \u5e38\u89c1\u53ef\u89c6\u5316\u7ba1\u7406\u5de5\u5177 Navicat\uff0cDBeaver\uff0cMySQL Workbench\uff0cDataGrip\uff0cHeidiSQL \u7b49 \u4e0e MySQL \u4e00\u81f4 \u5907\u4efd\u5de5\u5177 \u903b\u8f91\u5907\u4efd\uff0c\u7269\u7406\u5907\u4efd \u903b\u8f91\u5907\u4efd\uff0c\u7269\u7406\u5907\u4efd\uff0c\u5feb\u7167\u5907\u4efd CDC \u80fd\u529b \u5177\u5907 \u4e0d\u5177\u5907 OLTP \u6027\u80fd \u5355\u673a\u4f18\u79c0\uff0c\u4e0d\u53ef\u6269\u5c55 \u5355\u673a\u826f\u597d\uff0c\u53ef\u6269\u5c55 OLAP \u6027\u80fd \u8f83\u5dee \u4f18\u79c0\uff0c\u53ef\u6269\u5c55 \u5927\u6279\u91cf\u5199\u5165\u6027\u80fd \u8f83\u5dee \u4f18\u79c0\uff0c\u53ef\u6269\u5c55 \u5b58\u50a8\u7a7a\u95f4 \u53d7\u9650\u4e8e\u78c1\u76d8 \u65e0\u9650\u6269\u5c55\u5176\u4ed6\u7ec6\u8282\u53ef\u4ee5\u53c2\u7167 MatrixOne \u7684 MySQL \u517c\u5bb9\u6027\u8be6\u7ec6\u8bf4\u660e\u3002
\u6574\u4f53\u6765\u8bf4\uff0cMatrixOne \u662f\u4e00\u4e2a\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684\u4e91\u539f\u751f HTAP \u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u65e0\u7f1d\u517c\u5bb9\u7edd\u5927\u90e8\u5206\u57fa\u4e8e MySQL \u5f00\u53d1\u7684\u5e94\u7528\u3002\u4e0e\u6b64\u540c\u65f6\uff0cMatrixOne \u5929\u7136\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u4ee5\u53ca\u652f\u6491\u5176\u4ed6\u7c7b\u578b\u4e1a\u52a1\u8d1f\u8f7d\u7684\u80fd\u529b\u3002\u53e6\u5916\uff0c\u57fa\u4e8e MatrixOne \u5b58\u7b97\u5206\u79bb\u548c\u591a\u79df\u6237\u7684\u7279\u6027\uff0c\u7528\u6237\u5728\u8bbe\u8ba1\u5e94\u7528\u67b6\u6784\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u975e\u5e38\u7075\u6d3b\u7684\u5c06\u8fc7\u53bb\u7531\u5e94\u7528\uff0c\u4e2d\u95f4\u4ef6\uff0c\u6216\u8005\u5176\u4ed6\u6570\u636e\u5e93\u6765\u89e3\u51b3\u7684\u8d1f\u8f7d\u9694\u79bb\u95ee\u9898\u6765\u901a\u8fc7 MatrixOne \u4e00\u7ad9\u5f0f\u5b9e\u73b0\u3002
\u5bf9\u4e8e MySQL \u7528\u6237\u800c\u8a00\uff0c\u5982\u679c\u78b0\u5230\u4ee5\u4e0b\u95ee\u9898\u74f6\u9888\u7684\u8bdd\uff0cMatrixOne \u4f1a\u662f\u4e00\u4e2a\u66f4\u5408\u9002\u7684\u9009\u62e9\uff1a
\u5728 MatrixOne \u7684\u6280\u672f\u535a\u5ba2\u4e2d\uff0c\u6211\u4eec\u4e5f\u6709\u8f83\u591a\u5173\u4e8e MySQL \u4e0e MatrixOne \u7684\u5bf9\u6bd4\u548c\u8fc1\u79fb\u4e4b\u7c7b\u7684\u6587\u7ae0\u4f9b\u53c2\u8003\u3002
MatrixOne \u4e0e MySQL \u5168\u9762\u5bf9\u6bd4--\u90e8\u7f72\u7bc7
MatrixOne \u4e0e MySQL \u5168\u9762\u5bf9\u6bd4--\u591a\u79df\u6237\u7bc7
MatrixOne \u4e0e MySQL \u5168\u9762\u5bf9\u6bd4--\u8fc1\u79fb\u7bc7
"},{"location":"MatrixOne/Performance-Tuning/performance-tuning-overview/","title":"SQL \u6027\u80fd\u8c03\u4f18\u65b9\u6cd5\u6982\u8ff0","text":"SQL \u6027\u80fd\u8c03\u4f18\u662f\u4e00\u79cd\u4f18\u5316\u6570\u636e\u5e93\u67e5\u8be2\u548c\u64cd\u4f5c\u7684\u8fc7\u7a0b\uff0c\u65e8\u5728\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u54cd\u5e94\u65f6\u95f4\u3002\u5e38\u89c1\u7684\u51e0\u79cd\u6027\u80fd\u8c03\u4f18\u65b9\u5f0f\u5982\u4e0b\uff1a
\u7d22\u5f15\u4f18\u5316\uff1a\u7d22\u5f15\u53ef\u4ee5\u52a0\u901f\u67e5\u8be2\uff0c\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u3002\u901a\u8fc7\u4f7f\u7528\u6b63\u786e\u7684\u7d22\u5f15\u7c7b\u578b\u3001\u9009\u62e9\u6b63\u786e\u7684\u7d22\u5f15\u5217\u3001\u907f\u514d\u4f7f\u7528\u8fc7\u591a\u7684\u7d22\u5f15\u4ee5\u53ca\u5b9a\u671f\u91cd\u65b0\u6784\u5efa\u7d22\u5f15\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6700\u5927\u5316\u5730\u5229\u7528\u7d22\u5f15\u6765\u63d0\u9ad8\u6027\u80fd\u3002
\u4f18\u5316\u67e5\u8be2\u8bed\u53e5\uff1a\u901a\u8fc7\u4f18\u5316\u67e5\u8be2\u8bed\u53e5\u7684\u7ed3\u6784\u3001\u907f\u514d\u4f7f\u7528\u4e0d\u5fc5\u8981\u7684\u5b50\u67e5\u8be2\u3001\u4f7f\u7528\u66f4\u6709\u6548\u7684 JOIN
\u8bed\u53e5\u3001\u907f\u514d\u4f7f\u7528 OR
\u64cd\u4f5c\u7b26\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u51cf\u5c11\u67e5\u8be2\u6240\u9700\u7684\u65f6\u95f4\u548c\u8d44\u6e90\u3002
\u4f18\u5316\u8868\u7ed3\u6784\uff1a\u4f18\u5316\u8868\u7ed3\u6784\uff0c\u5982\u9009\u62e9\u6b63\u786e\u7684\u6570\u636e\u7c7b\u578b\u3001\u907f\u514d NULL \u503c\u3001\u4f7f\u7528\u5408\u9002\u7684\u7ea6\u675f\u548c\u9ed8\u8ba4\u503c\u3001\u5f52\u4e00\u5316\u548c\u53cd\u5f52\u4e00\u5316\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u51cf\u5c11\u8868\u7684\u5b58\u50a8\u7a7a\u95f4\u548c\u51cf\u5c11\u67e5\u8be2\u7684\u65f6\u95f4\u3002
\u63a7\u5236\u6570\u636e\u91cf\uff1a\u901a\u8fc7\u9650\u5236\u8fd4\u56de\u7684\u6570\u636e\u91cf\u3001\u5206\u9875\u3001\u7f13\u5b58\u3001\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u51cf\u5c11\u67e5\u8be2\u6240\u9700\u7684\u65f6\u95f4\u548c\u8d44\u6e90\u3002
\u4f18\u5316\u670d\u52a1\u5668\u914d\u7f6e\uff1a\u901a\u8fc7\u589e\u52a0\u670d\u52a1\u5668\u7684\u5185\u5b58\u3001\u8c03\u6574\u6570\u636e\u5e93\u53c2\u6570\u3001\u5b9a\u671f\u6e05\u7406\u65e5\u5fd7\u548c\u7f13\u5b58\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u54cd\u5e94\u65f6\u95f4\u3002
\u76d1\u63a7\u548c\u8c03\u8bd5\uff1a\u4f7f\u7528\u6570\u636e\u5e93\u6027\u80fd\u76d1\u63a7\u5de5\u5177\u3001\u8c03\u8bd5 SQL \u67e5\u8be2\u8bed\u53e5\u3001\u67e5\u770b\u6570\u636e\u5e93\u7684\u65e5\u5fd7\u548c\u9519\u8bef\u4fe1\u606f\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u53d1\u73b0\u5e76\u89e3\u51b3\u6027\u80fd\u95ee\u9898\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cSQL \u6027\u80fd\u8c03\u4f18\u662f\u4e00\u79cd\u590d\u6742\u7684\u8fc7\u7a0b\uff0c\u9700\u8981\u7efc\u5408\u8003\u8651\u6570\u636e\u5e93\u7684\u7ed3\u6784\u3001\u6570\u636e\u91cf\u3001\u67e5\u8be2\u6a21\u5f0f\u7b49\u591a\u4e2a\u56e0\u7d20\uff0c\u540c\u65f6\u9700\u8981\u4e0d\u65ad\u6d4b\u8bd5\u548c\u9a8c\u8bc1\u4f18\u5316\u7ed3\u679c\uff0c\u624d\u80fd\u6700\u7ec8\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u54cd\u5e94\u65f6\u95f4\u3002
MatrixOne \u5728\u6267\u884c SQL \u8bed\u53e5\u65f6\uff0c\u4f1a\u81ea\u52a8\u89c4\u5212\u5e76\u9009\u62e9\u6700\u4f18\u7684\u6267\u884c\u65b9\u6848\uff0c\u5e76\u975e\u6309\u7167 SQL \u8bed\u53e5\u8fdb\u884c\u67e5\u8be2\uff0c\u5f53\u524d MatrixOne \u652f\u6301\u901a\u8fc7 EXPLAIN \u89e3\u8bfb\u6267\u884c\u8ba1\u5212\u9009\u62e9\u6700\u4f18\u6267\u884c\u65b9\u6848\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff0c\u4e5f\u652f\u6301\u901a\u8fc7\u4f18\u5316\u8868\u7684\u7269\u7406\u6392\u5217\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u3002\u4e3a\u5e2e\u52a9\u4f60\u66f4\u597d\u7684 MatrixOne \u5bf9\u4e8e SQL \u8bed\u53e5\u67e5\u8be2\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u4ee5\u4e0b\u6587\u6863\uff1a
Cluster by
\u8fbe\u5230\u6027\u80fd\u8c03\u4f18\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u5b66\u4e60\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u7684\u65b9\u6cd5\u3002\u5f53\u4f60\u786e\u5b9a\u4e86\u6267\u884c\u8ba1\u5212\u6240\u5b58\u5728\u7684\u95ee\u9898\u65f6\uff0c\u6bd4\u5982\u4f18\u5316\u5668\u9009\u62e9\u7684\u4e0d\u662f\u6700\u4f18\u67e5\u8be2\u8ba1\u5212\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 Optimizer Hints \u6765\u63a7\u5236\u6267\u884c\u8ba1\u5212\u7684\u751f\u6210\u3002
Hint
\u63d0\u793a\u6307\u4ee4\u544a\u8bc9\u67e5\u8be2\u4f18\u5316\u5668\u5982\u4f55\u6267\u884c\u67e5\u8be2\u8bed\u53e5\u3002\u901a\u8fc7\u4f7f\u7528\u63d0\u793a\uff0c\u53ef\u4ee5\u4e3a\u67e5\u8be2\u63d0\u4f9b\u6709\u5173\u5982\u4f55\u8bbf\u95ee\u6570\u636e\u7684\u4fe1\u606f\uff0c\u4ee5\u63d0\u9ad8\u67e5\u8be2\u7684\u6027\u80fd\u3002Hint
\u63d0\u793a\u6307\u4ee4\u901a\u5e38\u7528\u4e8e\u8c03\u4f18\u5927\u578b\u6216\u590d\u6742\u7684\u67e5\u8be2\u3002
\u63d0\u793a\u53ef\u4ee5\u7528\u4e8e\u4fee\u6539\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u5305\u62ec\u9009\u62e9\u4e0d\u540c\u7684\u7d22\u5f15\u3001\u4f7f\u7528\u4e0d\u540c\u7684 JOIN
\u7b97\u6cd5\u6216\u6539\u53d8\u8fde\u63a5\u987a\u5e8f\u7b49\u3002
SQL \u4e2d\u7684\u63d0\u793a\u4f7f\u7528\u6ce8\u91ca\u8bed\u6cd5\uff0c\u53ef\u4ee5\u5728\u67e5\u8be2\u8bed\u53e5\u4e2d\u6dfb\u52a0\u7279\u5b9a\u7684\u6ce8\u91ca\u6765\u6307\u5b9a\u63d0\u793a\u3002
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_1","title":"\u8bed\u6cd5\u683c\u5f0f","text":"{DELETE|INSERT|SELECT|UPDATE} /*+ hint [text] [hint[text]]... */\n
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_2","title":"\u8bed\u6cd5\u89e3\u91ca","text":"DELETE
\u3001INSERT
\u3001SELECT
\u3001UPDATE
\u662f SQL \u8bed\u53e5\u7684\u5173\u952e\u5b57\u3002
/*+ */
\u662f SQL \u8bed\u53e5\u4e2d\u7684\u6ce8\u91ca\u7b26\u53f7\u3002
hint
\u662f\u63d0\u793a\u7684\u5177\u4f53\u6307\u4ee4\u3002
text
\u662f\u63d0\u793a\u6307\u4ee4\u7684\u53c2\u6570\u3002
\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 SQL \u63d0\u793a\uff1a
/*+ INDEX (table index) */
\uff1a\u6307\u5b9a\u4f7f\u7528\u7279\u5b9a\u7684\u7d22\u5f15\u6765\u6267\u884c\u67e5\u8be2\u3002
/*+ FULL (table) */
\uff1a\u6307\u5b9a\u6267\u884c\u5168\u8868\u626b\u63cf\u800c\u4e0d\u662f\u4f7f\u7528\u7d22\u5f15\u3002
\u67e5\u8be2\u4f18\u5316\u5668\u9009\u62e9\u4e0d\u5408\u9002\u7684\u6267\u884c\u8ba1\u5212\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 hint
\u63d0\u793a\u6765\u6307\u5b9a\u4e00\u4e2a\u66f4\u597d\u7684\u6267\u884c\u8ba1\u5212\u3002\u4f8b\u5982\uff0c\u5f53\u67e5\u8be2\u6d89\u53ca\u591a\u4e2a\u8868\u65f6\uff0c\u4f18\u5316\u5668\u53ef\u80fd\u4f1a\u9009\u62e9\u9519\u8bef\u7684\u8fde\u63a5\u7b97\u6cd5\u6216\u8fde\u63a5\u987a\u5e8f\uff0c\u4ece\u800c\u5bfc\u81f4\u67e5\u8be2\u7684\u6027\u80fd\u4e0b\u964d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u63d0\u793a\u6765\u6307\u5b9a\u4e00\u4e2a\u66f4\u597d\u7684\u8fde\u63a5\u7b97\u6cd5\u6216\u8fde\u63a5\u987a\u5e8f\u3002
\u5f53\u67e5\u8be2\u5305\u542b\u590d\u6742\u7684\u5b50\u67e5\u8be2\u6216\u805a\u5408\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 hint
\u63d0\u793a\u6765\u4f18\u5316\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002\u7531\u4e8e\u4f18\u5316\u5668\u65e0\u6cd5\u5206\u6790\u590d\u6742\u7684\u5b50\u67e5\u8be2\u6216\u805a\u5408\u51fd\u6570\uff0c\u56e0\u6b64\u53ef\u80fd\u4f1a\u9009\u62e9\u9519\u8bef\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ece\u800c\u5bfc\u81f4\u67e5\u8be2\u7684\u6027\u80fd\u4e0b\u964d\u3002
\u5f53\u67e5\u8be2\u8bbf\u95ee\u7684\u6570\u636e\u91cf\u975e\u5e38\u5927\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 hint
\u63d0\u793a\u6765\u4f18\u5316\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u63d0\u793a\u6765\u6307\u5b9a\u4f7f\u7528\u7279\u5b9a\u7684\u7d22\u5f15\u6216\u8fde\u63a5\u7b97\u6cd5\uff0c\u4ee5\u63d0\u9ad8\u67e5\u8be2\u7684\u6027\u80fd\u3002
MatrixOne \u652f\u6301\u4f7f\u7528 hint
\u63d0\u793a\u7528\u4e8e\u9009\u62e9\u5168\u8868\u626b\u63cf\u6216\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\uff0c\u4ee5\u53ca\u4f18\u5316\u591a\u8868\u8fde\u63a5\u7684\u987a\u5e8f\u3002
\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u53ef\u4ee5\u52a0\u5feb\u67e5\u8be2\u7684\u901f\u5ea6\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5168\u8868\u626b\u63cf\u53ef\u80fd\u6bd4\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u66f4\u5feb\u3002\u4f8b\u5982\uff0c\u5f53\u67e5\u8be2\u6761\u4ef6\u8fc7\u4e8e\u5bbd\u6cdb\u65f6\uff0c\u4f7f\u7528\u7d22\u5f15\u53ef\u80fd\u4f1a\u53d8\u5f97\u6bd4\u8f83\u7f13\u6162\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u63d0\u793a\u8bed\u6cd5\u6765\u9009\u62e9\u4f7f\u7528\u5168\u8868\u626b\u63cf\u6216\u7d22\u5f15\u626b\u63cf\uff1a
SELECT /*+ INDEX(table_name index_name) */ column_name FROM table_name WHERE ...\n
\u5176\u4e2d\uff0ctable_name \u662f\u8868\u540d\uff0cindex_name \u662f\u7d22\u5f15\u540d\uff0ccolumn_name \u662f\u5217\u540d\u3002\u5982\u679c\u6307\u5b9a\u4e86\u7d22\u5f15\u540d\uff0c\u5219\u67e5\u8be2\u5c06\u4f7f\u7528\u8be5\u7d22\u5f15\u8fdb\u884c\u626b\u63cf\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u7d22\u5f15\u540d\uff0c\u5219\u67e5\u8be2\u5c06\u4f7f\u7528\u5168\u8868\u626b\u63cf\u3002
\u5f53\u67e5\u8be2\u6d89\u53ca\u591a\u4e2a\u8868\u65f6\uff0c\u67e5\u8be2\u4f18\u5316\u5668\u5c06\u5c1d\u8bd5\u9009\u62e9\u6700\u4f18\u7684\u8fde\u63a5\u987a\u5e8f\u3002\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f18\u5316\u5668\u53ef\u80fd\u65e0\u6cd5\u9009\u62e9\u6700\u4f18\u7684\u8fde\u63a5\u987a\u5e8f\uff0c\u4ece\u800c\u5bfc\u81f4\u67e5\u8be2\u7684\u6027\u80fd\u4e0b\u964d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u63d0\u793a\u8bed\u6cd5\u6765\u4f18\u5316\u591a\u8868\u8fde\u63a5\u7684\u987a\u5e8f\uff1a
SELECT /*+ ORDERED */ column_name FROM table1, table2 WHERE table1.column1 = table2.column2;\n
\u5176\u4e2d\uff0cORDERED \u6307\u5b9a\u4e86\u67e5\u8be2\u5e94\u6309\u7167\u8868\u7684\u987a\u5e8f\u8fde\u63a5\uff0c\u5373\u5148\u8fde\u63a5 table1\uff0c\u518d\u8fde\u63a5 table2\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4f18\u5316\u5668\u9009\u62e9\u9519\u8bef\u7684\u8fde\u63a5\u987a\u5e8f\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u7684\u6027\u80fd\u3002
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_4","title":"\u793a\u4f8b","text":"-- \u65b0\u5efa\u4e00\u4e2a \u540d\u4e3a orders \u7684\u8868\nCREATE TABLE order (\norder_id INT PRIMARY KEY,\ncustomer_id INT,\norder_date DATE,\norder_total DECIMAL(10, 2)\n);\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO order (order_id, customer_id, order_date, order_total)\nVALUES\n(1, 101, '2022-05-10', 100.00),\n(2, 102, '2022-05-09', 150.00),\n(3, 103, '2022-05-08', 200.00),\n(4, 104, '2022-05-07', 50.00);\n-- \u67e5\u8be2\u67d0\u4e2a\u5ba2\u6237\u7684\u6240\u6709\u8ba2\u5355\uff0c\u5e76\u6309\u8ba2\u5355\u65e5\u671f\u964d\u5e8f\u6392\u5217\nSELECT order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n
\u4e3a\u4e86\u4f18\u5316\u8fd9\u4e2a\u67e5\u8be2\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b hint
\u63d0\u793a\uff1a
-- \u4f7f\u7528\u540d\u4e3a idx_customer_id \u7684\u7d22\u5f15\u6765\u6267\u884c\u67e5\u8be2\uff0c\u8fd9\u4e2a\u7d22\u5f15\u662f\u57fa\u4e8e customer_id \u5b57\u6bb5\u521b\u5efa\u7684\nSELECT /*+ INDEX(orders idx_customer_id) */ order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_5","title":"\u9650\u5236","text":"\u5f53\u524d /*+ HINT_NAME(t1, t2) */
\u4ec5\u8bed\u6cd5\u5b9e\u73b0\uff0c\u6682\u65e0\u6cd5\u63a7\u5236\u6267\u884c\u8ba1\u5212\u3002
SQL \u67e5\u8be2\u4e2d\u53ef\u80fd\u4f1a\u4f7f\u7528\u805a\u5408\u8ba1\u7b97\uff0c\u53ef\u4ee5\u901a\u8fc7 EXPLAIN \u8bed\u53e5\u6765\u67e5\u770b\u805a\u5408\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#_1","title":"\u793a\u4f8b","text":"\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u805a\u5408\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#hash-aggregation","title":"Hash Aggregation","text":"Hash Aggregation \u7b97\u6cd5\u5728\u6267\u884c\u805a\u5408\u65f6\u4f7f\u7528 Hash \u8868\u5b58\u50a8\u4e2d\u95f4\u7ed3\u679c\u3002\u6b64\u7b97\u6cd5\u91c7\u7528\u591a\u7ebf\u7a0b\u5e76\u53d1\u4f18\u5316\uff0c\u6267\u884c\u901f\u5ea6\u5feb\uff0c\u4f46\u4e0e Stream Aggregation \u7b97\u6cd5\u76f8\u6bd4\u4f1a\u6d88\u8017\u8f83\u591a\u5185\u5b58\u3002
\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528 Hash Aggregation \u7684\u4f8b\u5b50\uff1a
> SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+----------+\n| count(*) |\n+----------+\n| 9 |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+-------------------------------------------------+\n| QUERY PLAN |\n+-------------------------------------------------+\n| Project |\n| -> Aggregate |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on db1.t1 |\n| Aggregate Functions: starcount(1) |\n+-------------------------------------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/","title":"\u7528 EXPLAIN \u67e5\u770b JOIN \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212","text":"SQL \u67e5\u8be2\u4e2d\u53ef\u80fd\u4f1a\u4f7f\u7528 JOIN \u8fdb\u884c\u8868\u8fde\u63a5\uff0c\u53ef\u4ee5\u901a\u8fc7 EXPLAIN \u8bed\u53e5\u6765\u67e5\u770b JOIN \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#_1","title":"\u793a\u4f8b","text":"\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb JOIN \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#hash-join","title":"Hash Join","text":"\u5728 Hash Join
\u64cd\u4f5c\u4e2d\uff0cMatrixOne \u9996\u5148\u8bfb\u53d6\u8868 t1 \u4e0e t2 \u4e2d\u76f8\u5bf9\u8f83\u5c0f\u7684\u4e00\u4e2a\u8868\u5bf9\u5176\u4e2d\u6bcf\u4e2a\u9700\u8981\u88ab\u8fde\u63a5\u7684\u503c\u4f7f\u7528\u54c8\u5e0c\u51fd\u6570\uff0c\u5f97\u5230\u4e00\u4e2a\u54c8\u5e0c\u8868\uff1b\u7136\u540e\u5bf9\u53e6\u4e00\u4e2a\u8868\u7684\u6bcf\u4e00\u884c\u8fdb\u884c\u626b\u63cf\u5e76\u8ba1\u7b97\u54c8\u5e0c\u503c\uff0c\u4e0e\u4e0a\u4e00\u6b65\u751f\u6210\u7684\u54c8\u5e0c\u8868\u8fdb\u884c\u6bd4\u5bf9\uff0c\u5982\u679c\u6709\u7b26\u5408\u8fde\u63a5\u6807\u51c6\u7684\u503c\uff0c\u5219\u6839\u636e\u8fde\u63a5\u8c13\u8bcd\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\u8868\u3002
MatrixOne \u4e2d\u7684 Hash Join \u7b97\u5b50\u662f\u591a\u7ebf\u7a0b\u7684\uff0c\u5e76\u4e14\u53ef\u4ee5\u5e76\u53d1\u6267\u884c\u3002
\u4e0b\u9762\u662f\u4e00\u4e2a Hash Join
\u793a\u4f8b\uff1a
> SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt | id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 1 | 1 | 4 | 3 | 1113.32 | 111332 | 1113 | hello | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 1 | 1 | 4 | 3 | 1113.32 | 111332 | 1113 | hello | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 2 | 2 | 5 | 2 | 2252.05 | 225205 | 2252 | bye | sub query | 2022-04-28 | 2022-04-28 22:40:11 | 2 | 2 | 5 | 2 | 2252.05 | 225205 | 2252 | bye | sub query | 2022-04-28 | 2022-04-28 22:40:11 |\n| 3 | 6 | 6 | 3 | 3663.21 | 366321 | 3663 | hi | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 3 | 6 | 6 | 3 | 3663.21 | 366321 | 3663 | hi | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 | 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 | 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 | 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 | 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n9 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------------------------------------+\n| QUERY PLAN |\n+------------------------------------+\n| Project |\n| -> Join |\n| Join Type: INNER |\n| Join Cond: (t1.id = t2.id) |\n| -> Table Scan on db1.t1 |\n| -> Table Scan on db1.t2 |\n+------------------------------------+\n6 rows in set (0.01 sec)\n
MatrixOne \u4f1a\u6309\u7167\u4ee5\u4e0b\u987a\u5e8f\u6267\u884c Hash Join
\u7b97\u5b50\uff1a
(t1.id = t2.id)
\u3002\u6267\u884c\u8ba1\u5212\uff08execution plan\uff0c\u4e5f\u53eb\u67e5\u8be2\u8ba1\u5212\u6216\u8005\u89e3\u91ca\u8ba1\u5212\uff09\u662f\u6570\u636e\u5e93\u6267\u884c SQL \u8bed\u53e5\u7684\u5177\u4f53\u6b65\u9aa4\uff0c\u4f8b\u5982\u901a\u8fc7\u7d22\u5f15\u8fd8\u662f\u5168\u8868\u626b\u63cf\u8bbf\u95ee\u8868\u4e2d\u7684\u6570\u636e\uff0c\u8fde\u63a5\u67e5\u8be2\u7684\u5b9e\u73b0\u65b9\u5f0f\u548c\u8fde\u63a5\u7684\u987a\u5e8f\u7b49\uff1b\u6267\u884c\u8ba1\u5212\u6839\u636e\u4f60\u7684\u8868\u3001\u5217\u3001\u7d22\u5f15\u548c WHERE
\u5b50\u53e5\u4e2d\u7684\u6761\u4ef6\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53ef\u4ee5\u544a\u8bc9\u4f60\u8fd9\u4e2a\u67e5\u8be2\u5c06\u4f1a\u88ab\u5982\u4f55\u6267\u884c\u6216\u8005\u5df2\u7ecf\u88ab\u5982\u4f55\u6267\u884c\u8fc7\uff0c\u53ef\u4ee5\u5728\u4e0d\u8bfb\u53d6\u6240\u6709\u884c\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u5bf9\u5de8\u5927\u8868\u7684\u67e5\u8be2\uff1b\u53ef\u4ee5\u5728\u4e0d\u6bd4\u8f83\u884c\u7684\u6bcf\u4e2a\u7ec4\u5408\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u6d89\u53ca\u591a\u4e2a\u8868\u7684\u8fde\u63a5\u3002\u5982\u679c SQL \u8bed\u53e5\u6027\u80fd\u4e0d\u591f\u7406\u60f3\uff0c\u9996\u5148\u5e94\u8be5\u67e5\u770b\u5b83\u7684\u6267\u884c\u8ba1\u5212\u3002\u548c\u5927\u591a\u6570\u6210\u719f\u7684\u6570\u636e\u5e93\u4ea7\u54c1\u4e00\u6837\uff0cMatrixOne \u6570\u636e\u5e93\u4e5f\u63d0\u4f9b\u4e86\u8fd9\u4e00\u5206\u6790\u67e5\u8be2\u8bed\u53e5\u6027\u80fd\u7684\u529f\u80fd\u3002
MatrixOne \u67e5\u8be2\u4f18\u5316\u5668\u5bf9\u8f93\u5165\u7684 SQL \u67e5\u8be2\u8bed\u53e5\u901a\u8fc7\u6267\u884c\u8ba1\u5212\u800c\u9009\u62e9\u51fa\u6548\u7387\u6700\u9ad8\u7684\u4e00\u79cd\u6267\u884c\u65b9\u6848\u3002\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6267\u884c\u8ba1\u5212\u770b\u5230 SQL \u4ee3\u7801\u4e2d\u90a3\u4e9b\u6548\u7387\u6bd4\u8f83\u4f4e\u7684\u5730\u65b9\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#explain","title":"\u4f7f\u7528EXPLAIN
\u67e5\u8be2\u6267\u884c\u8ba1\u5212","text":"\u4f7f\u7528 EXPLAIN
\u53ef\u67e5\u770b MatrixOne \u6267\u884c\u67d0\u6761 SQL \u8bed\u53e5\u65f6\u7684\u6267\u884c\u8ba1\u5212\u3002
EXPLAIN
\u53ef\u4ee5\u548c SELECT
\u3001DELETE
\u3001INSERT
\u3001REPLACE
\u3001UPDATE
\u8bed\u53e5\u7ed3\u5408\u4f7f\u7528\u3002\u5f53 EXPLAIN
\u4e0e\u53ef\u89e3\u91ca\u7684\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u65f6\uff0cMatrixOne \u4f1a\u89e3\u91ca\u5b83\u5c06\u5982\u4f55\u5904\u7406\u8be5\u8bed\u53e5\uff0c\u5305\u62ec\u6709\u5173\u8868\u5982\u4f55\u8fde\u63a5\u4ee5\u53ca\u8fde\u63a5\u987a\u5e8f\u7684\u4fe1\u606f\u3002
Note
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u65f6\uff0c\u4e3a\u907f\u514d\u8f93\u51fa\u7ed3\u679c\u5728\u7ec8\u7aef\u4e2d\u6362\u884c\uff0c\u53ef\u5148\u6267\u884c pager less -S
\u547d\u4ee4\u3002\u6267\u884c\u547d\u4ee4\u540e\uff0c\u65b0\u7684 EXPLAIN
\u7684\u8f93\u51fa\u7ed3\u679c\u4e0d\u518d\u6362\u884c\uff0c\u53ef\u6309\u53f3\u7bad\u5934 \u2192 \u952e\u6c34\u5e73\u6eda\u52a8\u9605\u8bfb\u8f93\u51fa\u7ed3\u679c\u3002
\u4e0b\u9762\u7684\u4f8b\u5b50\u5e2e\u52a9\u4f60\u4e86\u89e3 EXPLAIN
\u3002
\u6570\u636e\u51c6\u5907\uff1a
CREATE TABLE t (id INT NOT NULL PRIMARY KEY auto_increment, a INT NOT NULL, pad1 VARCHAR(255), INDEX(a));\nINSERT INTO t VALUES (1, 1, 'aaa'),(2,2, 'bbb');\nEXPLAIN SELECT * FROM t WHERE a = 1;\n
\u8fd4\u56de\u7ed3\u679c\uff1a
+--------------------------------+\n| QUERY PLAN |\n+--------------------------------+\n| Project |\n| -> Table Scan on db1.t |\n| Filter Cond: (t.a = 1) |\n+--------------------------------+\n3 rows in set (0.01 sec)\n
EXPLAIN
\u5b9e\u9645\u4e0d\u4f1a\u6267\u884c\u67e5\u8be2\u3002EXPLAIN ANALYZE
\u53ef\u7528\u4e8e\u5b9e\u9645\u6267\u884c\u67e5\u8be2\u5e76\u663e\u793a\u6267\u884c\u8ba1\u5212\u3002\u5982\u679c MatrixOne \u6240\u9009\u7684\u6267\u884c\u8ba1\u5212\u975e\u6700\u4f18\uff0c\u53ef\u7528 EXPLAIN
\u6216 EXPLAIN ANALYZE
\u6765\u8fdb\u884c\u8bca\u65ad\u3002
EXPLAIN \u8f93\u51fa\u5206\u6790
QUERY PLAN\uff0c\u5373\u672c\u6b21\u6267\u884c\u7684\u4e3b\u9898\uff0c\u67e5\u8be2\u8ba1\u5212
Filter Cond\uff1a\u8fc7\u6ee4\u6761\u4ef6
Table Scan\uff1a\u5bf9\u67d0\u4e2a\u5168\u8868\u8fdb\u884c\u626b\u63cf
Project \u4e3a\u8fd9\u6b21\u67e5\u8be2\u8fc7\u7a0b\u4e2d\u7684\u6267\u884c\u987a\u5e8f\u7684\u7236\u8282\u70b9\uff0cProject \u7684\u7ed3\u6784\u662f\u6811\u72b6\u7684\uff0c\u5b50\u8282\u70b9\u8ba1\u7b97\u5b8c\u6210\u540e\u201c\u6d41\u5165\u201d\u7236\u8282\u70b9\u3002\u7236\u8282\u70b9\u3001\u5b50\u8282\u70b9\u548c\u540c\u7ea7\u8282\u70b9\u53ef\u80fd\u5e76\u884c\u6267\u884c\u67e5\u8be2\u7684\u4e00\u90e8\u5206\u3002
\u8303\u56f4\u67e5\u8be2
\u5728 WHERE/HAVING/ON
\u6761\u4ef6\u4e2d\uff0cMatrixOne \u4f18\u5316\u5668\u4f1a\u5206\u6790\u4e3b\u952e\u6216\u7d22\u5f15\u952e\u7684\u67e5\u8be2\u8fd4\u56de\u3002\u5982\u6570\u5b57\u3001\u65e5\u671f\u7c7b\u578b\u7684\u6bd4\u8f83\u7b26\uff0c\u5982\u5927\u4e8e\u3001\u5c0f\u4e8e\u3001\u7b49\u4e8e\u4ee5\u53ca\u5927\u4e8e\u7b49\u4e8e\u3001\u5c0f\u4e8e\u7b49\u4e8e\uff0c\u5b57\u7b26\u7c7b\u578b\u7684 LIKE
\u7b26\u53f7\u7b49\u3002
MatrixOne \u4f1a\u6267\u884c\u591a\u79cd\u5b50\u67e5\u8be2\u76f8\u5173\u7684\u4f18\u5316\uff0c\u4ee5\u63d0\u5347\u5b50\u67e5\u8be2\u7684\u6267\u884c\u6027\u80fd\u3002\u672c\u6587\u6863\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u89c1\u5b50\u67e5\u8be2\u7684\u4f18\u5316\u65b9\u5f0f\uff0c\u4ee5\u53ca\u5982\u4f55\u89e3\u8bfb EXPLAIN \u8bed\u53e5\u8fd4\u56de\u7684\u6267\u884c\u8ba1\u5212\u4fe1\u606f\u3002
\u4ece SQL \u8bed\u53e5\u6267\u884c\u60c5\u51b5\u4e0a\uff0c\u5b50\u67e5\u8be2\u8bed\u53e5\u4e00\u822c\u6709\u4ee5\u4e0b\u4e24\u79cd\u5f62\u5f0f\uff1a
\u65e0\u5173\u8054\u5b50\u67e5\u8be2 (Self-contained Subquery)\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u662f\u5b8c\u5168\u72ec\u7acb\u4e8e\u5916\u5c42\u67e5\u8be2\u7684\u3002
\u4f8b\u5982\uff1aselect * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);
\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u5148\u6267\u884c\u5185\u5c42\u67e5\u8be2\uff1a(select t2.id from t2 where t2.id>=3)
\u3002
\u5f97\u5230\u5185\u5c42\u67e5\u8be2\u7684\u7ed3\u679c\u540e\u5e26\u5165\u5916\u5c42\uff0c\u518d\u6267\u884c\u5916\u5c42\u67e5\u8be2\u3002
\u5173\u8054\u5b50\u67e5\u8be2\uff08Correlated Subquery\uff09\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u548c\u5916\u5c42\u67e5\u8be2\u4e0d\u76f8\u4e92\u72ec\u7acb\uff0c\u5185\u5c42\u67e5\u8be2\u4e5f\u4f9d\u8d56\u4e8e\u5916\u5c42\u67e5\u8be2\u3002
\u4f8b\u5982\uff1aSELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u5148\u4ece\u5916\u5c42\u67e5\u8be2\u4e2d\u67e5\u8be2\u4e2d\u4e00\u6761\u8bb0\u5f55\uff1aSELECT * FROM t1 WHERE id
\u3002
\u518d\u5c06\u67e5\u8be2\u5230\u7684\u8bb0\u5f55\u653e\u5230\u5185\u5c42\u67e5\u8be2\u4e2d\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u518d\u653e\u5230\u5916\u5c42\u4e2d\u67e5\u8be2\u3002
\u91cd\u590d\u4ee5\u4e0a\u6b65\u9aa4
\u4f46\u662f MatrixOne \u5728\u5904\u7406\u8be5 SQL \u8bed\u53e5\u65f6\u4f1a\u5c06\u5176\u6539\u5199\u4e3a\u7b49\u4ef7\u7684 JOIN
\u67e5\u8be2\uff1aselect t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;
\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u5b50\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#_2","title":"\u65e0\u5173\u8054\u5b50\u67e5\u8be2","text":"> select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 3 | 6 | 6 | 3 | 3663.21 | 366321 | 3663 | hi | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n7 rows in set (0.02 sec)\n\n> explain select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Join |\n| Join Type: SEMI |\n| Join Cond: (t1.id = t2.id) |\n| -> Table Scan on db1.t1 |\n| -> Table Scan on db1.t2 |\n| Filter Cond: (t2.id >= 3) |\n+-----------------------------------------+\n7 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u6267\u884c\u8ba1\u5212\u7684\u6267\u884c\u987a\u5e8f\u662f\uff1a
\u5148\u6267\u884c\u5185\u5c42\u67e5\u8be2\uff1a(select t2.id from t2 where t2.id>=3)
\u3002
\u5f97\u5230\u5185\u5c42\u67e5\u8be2\u7684\u7ed3\u679c\u540e\u5e26\u5165\u5916\u5c42\uff0c\u518d\u6267\u884c\u5916\u5c42\u67e5\u8be2\u3002
> SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n6 rows in set (0.01 sec)\n\nmysql> explain SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+---------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------+\n| Project |\n| -> Join |\n| Join Type: SEMI |\n| Join Cond: ((t1.ti = t2.ti) IS TRUE), (t1.id = t2.id) |\n| -> Table Scan on db1.t1 |\n| -> Table Scan on db1.t2 |\n| Filter Cond: (t2.id >= 4) |\n+---------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
MatrixOne \u5728\u5904\u7406\u8be5 SQL \u8bed\u53e5\u65f6\u4f1a\u5c06\u5176\u6539\u5199\u4e3a\u7b49\u4ef7\u7684 JOIN
\u67e5\u8be2\uff1aselect t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;
\uff0c\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u6267\u884c\u8ba1\u5212\u7684\u6267\u884c\u987a\u5e8f\u662f\uff1a
\u5148\u6267\u884c\u8fc7\u6ee4\u67e5\u8be2 where t2.id>=4;
\u3002
\u518d\u626b\u63cf\u8868 Table Scan on db1.t2
\uff0c\u5c06\u7ed3\u679c\u201c\u6d41\u5165\u201d\u7236\u8282\u70b9\u540e\uff0c
\u626b\u63cf\u8868 Table Scan on db1.t1
\u3002
\u6700\u540e\u6267\u884c JOIN
\u67e5\u8be2\u3002
EXPLAIN
\u8bed\u53e5\u8fd4\u56de\u7684\u7ed3\u679c\u4f1a\u663e\u793a\u89c6\u56fe\u5f15\u7528\u7684\u8868\uff0c\u800c\u4e0d\u662f\u89c6\u56fe\u672c\u8eab\u7684\u540d\u79f0\u3002\u8fd9\u662f\u56e0\u4e3a\u89c6\u56fe\u662f\u4e00\u5f20\u865a\u62df\u8868\uff0c\u672c\u8eab\u5e76\u4e0d\u5b58\u50a8\u4efb\u4f55\u6570\u636e\u3002\u89c6\u56fe\u7684\u5b9a\u4e49\u4f1a\u548c\u67e5\u8be2\u8bed\u53e5\u7684\u5176\u4f59\u90e8\u5206\u5728 SQL \u4f18\u5316\u8fc7\u7a0b\u4e2d\u8fdb\u884c\u5408\u5e76\u3002
\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb VIEW \u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> create view v1 as select * from (select * from t1) sub where id > 4;\n> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n
\u5982\u4e0a\u8ff0\u793a\u4f8b\u6240\u793a\uff0c\u65b0\u5efa\u4e86\u4e00\u4e2a\u547d\u540d\u4e3a v1 \u7684 VIEW\uff0c\u5e76\u67e5\u8be2 v1 \u7684\u7ed3\u679c\u3002\u90a3\u4e48\u6211\u4eec\u770b\u4e00\u4e0b\u8fd9\u4e2a\u89c6\u56fe\u7684\u6267\u884c\u8fc7\u7a0b\uff1a
> explain select * from v1;\n+----------------------------------+\n| QUERY PLAN |\n+----------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Filter Cond: (t1.id > 4) |\n+----------------------------------+\n3 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230 Project \u4e3a\u8fd9\u6b21\u67e5\u8be2\u8fc7\u7a0b\u4e2d\u7684\u6267\u884c\u987a\u5e8f\u7684\u7236\u8282\u70b9\uff0c\u9996\u5148\u662f\u4ece\u7f29\u8fdb\u6700\u591a\u7684\u5b50\u8282\u70b9\u5f00\u59cb\u8ba1\u7b97\uff0c\u5b8c\u6210\u540e\u201c\u6d41\u5165\u201d\u5b83\u7684\u4e0a\u5c42\u7236\u8282\u70b9\uff0c\u6700\u7ec8\u201c\u6d41\u5165\u201dProject \u7236\u8282\u70b9\u3002
\u5148\u6267\u884c\uff1a
\u518d\u6267\u884c\uff1a
\u4e0b\u9762\u7684\u67e5\u8be2\u7684\u6267\u884c\u65b9\u5f0f\u4e0e\u4e0a\u8ff0\u6267\u884c\u65b9\u5f0f\u7c7b\u4f3c\uff1a
> explain select * from (select * from t1) sub where id > 4;\n+----------------------------------+\n| QUERY PLAN |\n+----------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Filter Cond: (t1.id > 4) |\n+----------------------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/","title":"\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u6267\u884c\u8ba1\u5212","text":"SQL \u662f\u4e00\u79cd\u58f0\u660e\u6027\u8bed\u8a00\uff0c\u56e0\u6b64\u65e0\u6cd5\u901a\u8fc7 SQL \u8bed\u53e5\u76f4\u63a5\u5224\u65ad\u4e00\u6761\u67e5\u8be2\u7684\u6267\u884c\u662f\u5426\u6709\u6548\u7387\uff0c\u4f46\u662f\u53ef\u4ee5\u4f7f\u7528 EXPLAIN
\u8bed\u53e5\u67e5\u770b\u5f53\u524d\u7684\u6267\u884c\u8ba1\u5212\u3002
\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists a;\n> create table a(a int);\n> insert into a values(1),(2),(3),(4),(5),(6),(7),(8);\n> select count(*) from a where a>=2 and a<=8;\n+----------+\n| count(*) |\n+----------+\n| 7 |\n+----------+\n1 row in set (0.00 sec)\n\n> explain select count(*) from a where a>=2 and a<=8;\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Aggregate |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on db1.a |\n| Filter Cond: (a.a >= 2), (a.a <= 8) |\n+---------------------------------------------------+\n5 rows in set (0.01 sec)\n
\u4ee5\u4e0a\u662f\u8be5\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u7ed3\u679c\u3002\u4ece Filter Cond
\u7b97\u5b50\u5f00\u59cb\u5411\u4e0a\u770b\uff0c\u67e5\u8be2\u7684\u6267\u884c\u8fc7\u7a0b\u5982\u4e0b\uff1a
Filter Cond
\uff1a\u5373\u8fc7\u6ee4\u51fa\u6570\u636e\u5b57\u6bb5\u4e3a a
\u4e14\u5927\u4e8e\u7b49\u4e8e 2\uff0c\u5c0f\u4e8e\u7b49\u4e8e 8 \u7684\u6574\u6570\uff0c\u6309\u7167\u8ba1\u7b97\u63a8\u7406\uff0c\u5e94\u8be5\u4e3a (2),(3),(4),(5),(6),(7),(8)
\u3002\u6700\u7ec8\uff0c\u5f97\u5230\u67e5\u8be2\u7ed3\u679c\u4e3a 7\uff0c\u5373 count(*)
= 7\u3002
EXPLAIN \u8bed\u53e5\u53ea\u8fd4\u56de\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u5e76\u4e0d\u6267\u884c\u8be5\u67e5\u8be2\u3002\u82e5\u8981\u83b7\u53d6\u5b9e\u9645\u7684\u6267\u884c\u65f6\u95f4\uff0c\u53ef\u6267\u884c\u8be5\u67e5\u8be2\uff0c\u6216\u4f7f\u7528 EXPLAIN ANALYZE \u8bed\u53e5\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#explain-analyze","title":"\u4ec0\u4e48\u662f EXPLAIN ANALYZE","text":"EXPLAIN ANALYZE \u662f\u4e00\u4e2a\u7528\u4e8e\u67e5\u8be2\u7684\u5206\u6790\u5de5\u5177\uff0c\u5b83\u5c06\u5411\u4f60\u663e\u793a SQL \u5728\u67e5\u8be2\u4e0a\u82b1\u8d39\u7684\u65f6\u95f4\u4ee5\u53ca\u539f\u56e0\u3002\u5b83\u5c06\u8ba1\u5212\u67e5\u8be2\u3001\u68c0\u6d4b\u5b83\u5e76\u6267\u884c\u5b83\uff0c\u540c\u65f6\u8ba1\u7b97\u884c\u6570\u5e76\u6d4b\u91cf\u5728\u6267\u884c\u8ba1\u5212\u7684\u5404\u4e2a\u70b9\u82b1\u8d39\u7684\u65f6\u95f4\u3002\u6267\u884c\u5b8c\u6210\u540e\uff0cEXPLAIN ANALYZE \u5c06\u6253\u5370\u8ba1\u5212\u548c\u6d4b\u91cf\u7ed3\u679c\uff0c\u800c\u4e0d\u662f\u67e5\u8be2\u7ed3\u679c\u3002
\u9664\u4e86\u6b63\u5e38 EXPLAIN \u5c06\u6253\u5370\u7684\u67e5\u8be2\u8ba1\u5212\u548c\u4f30\u8ba1\u6210\u672c\u4e4b\u5916\uff0cEXPLAIN ANALYZE \u8fd8\u6253\u5370\u6267\u884c\u8ba1\u5212\u4e2d\u5404\u4e2a\u8fed\u4ee3\u5668\u7684\u5b9e\u9645\u6210\u672c\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#_3","title":"\u5982\u4f55\u4f7f\u7528\u5b83\uff1f","text":"\u8fd9\u91cc\u8fd8\u662f\u7ee7\u7eed\u4f7f\u7528\u4e0a\u8ff0\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff1a
> explain analyze select count(*) from a where a>=2 and a<=8;\n+---------------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------------------------------------------------------------------------------+\n| Project |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=8bytes OutputSize=8bytes MemorySize=8bytes |\n| -> Aggregate |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=7 outputRows=1 InputSize=28bytes OutputSize=8bytes MemorySize=16bytes |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on db1.a |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=8 outputRows=7 InputSize=32bytes OutputSize=28bytes MemorySize=75bytes |\n| Filter Cond: (a.a >= 2), (a.a <= 8) |\n+---------------------------------------------------------------------------------------------------------------------------------------+\n8 rows in set (0.00 sec)\n
\u4ece\u6253\u5370\u7684\u6267\u884c\u7ed3\u679c\u6765\u770b\uff0c\u5f53\u5206\u522b\u6267\u884c\u805a\u5408\u8ba1\u7b97\u548c\u626b\u63cf\u8868\u65f6\uff0c\u90fd\u4f1a\u5f97\u51fa\u4ee5\u4e0b\u51e0\u4e2a\u6d4b\u91cf\u503c\uff0c\u8fd9\u4e9b\u6d4b\u91cf\u503c\u53ef\u4ee5\u4f5c\u4e3a\u53c2\u8003\u9879\uff1a
\u901a\u8fc7\u5728\u8fd9\u4e9b\u4fe1\u606f\uff0c\u4f60\u53ef\u4ee5\u5206\u6790\u67e5\u8be2\u5e76\u7406\u89e3\u5b83\u4eec\u4e3a\u4f55\u662f\u8fd9\u6837\u7684\u8868\u73b0\uff0c\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\u8fdb\u884c\u63a2\u7d22\uff1a
\u6267\u884c\u8fd9\u4e9b\u67e5\u8be2\uff0c\u9700\u8981\u82b1\u8d39\u591a\u4e45\uff1f\u4f60\u53ef\u4ee5\u67e5\u770b\u603b\u8017\u65f6\u3002
\u4e3a\u4ec0\u4e48\u6267\u884c\u5f53\u524d\u7684\u67e5\u8be2\u8ba1\u5212\uff0c\u800c\u4e0d\u662f\u5176\u4ed6\u7684\u6267\u884c\u8ba1\u5212\uff1f\u4f60\u53ef\u4ee5\u67e5\u770b\u884c\u8ba1\u6570\u5668\u3002\u5f53\u4f30\u8ba1\u884c\u6570\u4e0e\u5b9e\u9645\u884c\u6570\u4e4b\u95f4\u7684\u5de8\u5927\u5dee\u5f02\uff08\u5373\uff0c\u51e0\u4e2a\u6570\u91cf\u7ea7\u6216\u66f4\u591a\uff09\u65f6\uff0c\u8bf4\u660e\u4f18\u5316\u5668\u6839\u636e\u4f30\u8ba1\u9009\u62e9\u8ba1\u5212\uff0c\u4f46\u67e5\u770b\u5b9e\u9645\u6267\u884c\u53ef\u4ee5\u65b9\u4fbf\u4f60\u5f97\u77e5\u5230\u5e95\u54ea\u4e2a\u6267\u884c\u8ba1\u5212\u66f4\u597d\u3002
\u6240\u4ee5\u4f7f\u7528 EXPLAIN ANALYZE \u5c31\u662f\u5206\u6790\u67e5\u8be2\u6267\u884c\u3002
\u4ece\u4e0a\u9762\u7684\u8f93\u51fa\u7ed3\u679c\u6765\u770b\uff0c\u6267\u884c\u4ee5\u4e0a\u793a\u4f8b\u67e5\u8be2\u8017\u65f6 0.00 \u79d2\uff0c\u8bf4\u660e\u6267\u884c\u6027\u80fd\u8f83\u4e3a\u7406\u60f3\u3002\u4e5f\u7531\u4e8e\u6211\u4eec\u8fd9\u6b21\u793a\u4f8b\u4e2d\u6267\u884c\u7684\u67e5\u8be2\u7b80\u5355\uff0c\u6ee1\u8db3\u8f83\u9ad8\u7684\u6267\u884c\u6027\u80fd\u3002
\u66f4\u591a\u5173\u4e8e EXPLAIN ANALYZE \u7684\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 EXPLAIN ANALYZE\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/","title":"\u901a\u8fc7\u6269\u5c55 CN \u63d0\u5347\u6027\u80fd","text":"MatrixOne \u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u6700\u663e\u8457\u7684\u7279\u70b9\u662f\u53ef\u4ee5\u901a\u8fc7\u8282\u70b9\u6269\u5c55\u6765\u63d0\u5347\u7cfb\u7edf\u6574\u4f53\u6027\u80fd\u3002\u5728 MatrixOne \u7684\u5b58\u7b97\u5206\u79bb\u67b6\u6784\u4e2d\uff0cCN \u662f\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9\uff0c\u5feb\u901f\u6269\u5c55 CN \u8282\u70b9\u662f\u6574\u4e2a\u96c6\u7fa4\u6027\u80fd\u63d0\u5347\u7684\u6838\u5fc3\u3002
\u901a\u5e38\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u6cd5\u5bf9 CN \u8fdb\u884c\u6269\u5c55\uff1a
\u5782\u76f4\u6269\u5c55 CN \u8282\u70b9\uff1a\u901a\u8fc7\u8c03\u6574\u5355\u4e2a CN \u8282\u70b9\u7684\u8d44\u6e90\u6765\u63d0\u5347\u6027\u80fd\u3002\u8fd9\u5305\u62ec\u5bf9\u6574\u4e2a CN \u8d44\u6e90\u548c\u7f13\u5b58\u7684\u63d0\u5347\u3002
\u6c34\u5e73\u6269\u5c55 CN \u8282\u70b9\uff1a\u901a\u8fc7\u589e\u52a0 CN \u8282\u70b9\u6570\u91cf\u6765\u63d0\u5347\u6027\u80fd\u3002
\u4e00\u4e2a\u6700\u5c0f\u578b\u7684 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u7528\u6237\u7684\u67e5\u8be2\u8bf7\u6c42\u4e3b\u8981\u7531 CN \u627f\u62c5\u8ba1\u7b97\u5de5\u4f5c\uff0c\u56e0\u6b64 CN \u8282\u70b9\u7684\u8d44\u6e90\u5927\u5c0f\u4e0e\u7b97\u529b\u6210\u6b63\u6bd4\uff0c\u6700\u76f4\u63a5\u7684\u6269\u5c55\u65b9\u6cd5\u5c31\u662f\u5782\u76f4\u6269\u5c55\u5355\u4e2a CN \u8282\u70b9\u7684\u8d44\u6e90\u3002\u540c\u65f6\uff0c\u67e5\u8be2\u7684\u6570\u636e\u7f13\u5b58\u5728 CN \u7684\u7f13\u5b58\u4e2d\uff0c\u4f5c\u4e3a\u70ed\u6570\u636e\u3002\u5982\u679c\u547d\u4e2d\u7f13\u5b58\uff0c\u67e5\u8be2\u5c31\u53ef\u4ee5\u76f4\u63a5\u4ece\u7f13\u5b58\u4e2d\u8fd4\u56de\uff0c\u800c\u4e0d\u5fc5\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u83b7\u53d6\u51b7\u6570\u636e\u3002\u7f13\u5b58\u53ea\u6709\u5728\u8d85\u8fc7\u5bb9\u91cf\u4e0a\u9650\u540e\u624d\u4f1a\u4ee5 LRU \u7b97\u6cd5\u66ff\u6362\u5176\u4e2d\u6570\u636e\uff0c\u56e0\u6b64\u7f13\u5b58\u5927\u5c0f\u5bf9\u63d0\u5347\u6027\u80fd\u4e5f\u6709\u5e2e\u52a9\u3002
\u6b64\u5916\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6c34\u5e73\u6269\u5c55 CN \u8282\u70b9\u6765\u63d0\u5347\u6027\u80fd\u3002\u6c34\u5e73\u6269\u5c55\u6709\u4e24\u4e2a\u6280\u672f\u7279\u6027\u53ef\u4ee5\u63d0\u5347\u6027\u80fd\u3002\u9996\u5148\uff0c\u591a\u4e2a\u7528\u6237\u8fde\u63a5\u8bf7\u6c42\u53ef\u4ee5\u5206\u6563\u5230\u4e0d\u540c CN \u8282\u70b9\uff0c\u4ece\u800c\u5206\u6563\u6bcf\u4e2a CN \u7684\u8d1f\u8f7d\u3002\u5176\u6b21\uff0c\u4e0d\u540c CN \u8282\u70b9\u4e5f\u6709\u4e0d\u540c\u7684\u7f13\u5b58\u3002\u5f53\u6536\u5230\u67e5\u8be2\u8bf7\u6c42\u7684 CN \u8282\u70b9\u53d1\u73b0\u8bf7\u6c42\u6570\u636e\u4e0d\u5728\u5176\u7f13\u5b58\u4e2d\u65f6\uff0c\u4f1a\u901a\u8fc7\u5143\u6570\u636e\u627e\u5230\u542b\u6709\u8bf7\u6c42\u6570\u636e\u7f13\u5b58\u7684 CN \u8282\u70b9\uff0c\u5e76\u5c06\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u5b83\u8fdb\u884c\u5904\u7406\uff0c\u63d0\u9ad8\u7f13\u5b58\u547d\u4e2d\u7387\u3002
MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7ec4\u4ef6\u7684\u6269\u5c55\u53ef\u4ee5\u901a\u8fc7 Operator \u5b8c\u6210\uff0c\u64cd\u4f5c\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003 MatrixOne \u96c6\u7fa4\u7684\u6269\u7f29\u5bb9\u7ae0\u8282\u3002\u8bf7\u6ce8\u610f\uff0c\u5782\u76f4\u6269\u5c55 CN \u8282\u70b9\u9700\u8981\u5728\u5355\u4e2a\u8282\u70b9\u4e0a\u8fdb\u884c\uff0c\u800c\u6c34\u5e73\u6269\u5c55 CN \u8282\u70b9\u9700\u8981\u5728\u591a\u4e2a\u8282\u70b9\u4e0a\u8fdb\u884c\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/#_1","title":"\u64cd\u4f5c\u65b9\u6cd5","text":"MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7ec4\u4ef6\u7684\u6269\u5c55\u90fd\u53ef\u4ee5\u901a\u8fc7 Operator \u6765\u5b8c\u6210\uff0c\u5177\u4f53\u7684\u64cd\u4f5c\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003 MatrixOne \u96c6\u7fa4\u7684\u6269\u7f29\u5bb9\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/","title":"\u4f7f\u7528 Cluster by \u8bed\u53e5\u8c03\u4f18","text":"Cluster by
\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6027\u80fd\u8c03\u4f18\u6280\u672f\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f18\u5316\u67e5\u8be2\u7684\u6267\u884c\u6548\u7387\u3002\u672c\u6587\u5c06\u89e3\u91ca\u5982\u4f55\u4f7f\u7528 Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u3002
Cluster by
\uff1f","text":"Cluster by
\u662f\u4e00\u79cd\u7528\u4e8e\u4f18\u5316\u8868\u7684\u7269\u7406\u6392\u5217\u65b9\u5f0f\u7684\u547d\u4ee4\u3002\u5728\u5efa\u8868\u65f6\u4f7f\u7528 Cluster by
\u547d\u4ee4\uff0c\u5bf9\u4e8e\u65e0\u4e3b\u952e\u7684\u8868\uff0c\u53ef\u4ee5\u6309\u7167\u6307\u5b9a\u7684\u5217\u5bf9\u8868\u8fdb\u884c\u7269\u7406\u6392\u5e8f\uff0c\u5e76\u5c06\u6570\u636e\u884c\u91cd\u65b0\u6392\u5217\u6210\u4e0e\u8be5\u5217\u7684\u503c\u7684\u987a\u5e8f\u76f8\u540c\u7684\u987a\u5e8f\u3002\u8fd9\u79cd\u7269\u7406\u6392\u5e8f\u6709\u52a9\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002
\u4ee5\u4e0b\u662f\u4f7f\u7528 Cluster by
\u7684\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\uff1a
Cluster by
\u4e0d\u80fd\u548c\u4e3b\u952e\u540c\u65f6\u5b58\u5728\uff0c\u5426\u5219\u4f1a\u8bed\u6cd5\u62a5\u9519\u3002
Cluster by
\u53ea\u80fd\u5728\u5efa\u8868\u65f6\u6307\u5b9a\uff0c\u4e0d\u652f\u6301\u52a8\u6001\u521b\u5efa\u3002
\u4e0b\u9762\u662f Cluster by
\u7684\u4f7f\u7528\u8bed\u6cd5\uff1a
create table() cluster by col;
create table() cluster by (col1, col2);
Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff1f","text":"\u4f7f\u7528 Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a
\u786e\u5b9a\u9700\u8981\u6392\u5e8f\u7684\u5217\u3002
\u9996\u5148\u9700\u8981\u786e\u5b9a\u9700\u8981\u6392\u5e8f\u7684\u5217\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u53ef\u4ee5\u9009\u62e9\u90a3\u4e9b\u7ecf\u5e38\u7528\u4e8e\u8fc7\u6ee4\u7684\u5217\u3002\u5bf9\u4e8e\u5177\u6709\u65f6\u95f4\u5e8f\u5217\u7279\u5f81\u7684\u6570\u636e\uff0c\u65f6\u95f4\u5217\u662f\u5e38\u7528\u7684\u6392\u5e8f\u5217\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6709\u4e00\u4e2a\u8ba2\u5355\u8868\uff0c\u53ef\u4ee5\u5c06\u8ba2\u5355\u6309\u7167\u65f6\u95f4\u8fdb\u884c\u6392\u5e8f\u3002
\u6267\u884c Cluster by
\u547d\u4ee4\u3002
\u4e00\u65e6\u786e\u5b9a\u4e86\u6392\u5e8f\u5217\uff0c\u5c31\u53ef\u4ee5\u5728\u5efa\u8868\u65f6\u6267\u884c Cluster by
\u547d\u4ee4\u5bf9\u8868\u8fdb\u884c\u6392\u5e8f\u3002
\u4e0b\u9762\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u793a\u4f8b\uff1a
create table t1(a int, b int, c varchar(10)) cluster by(a,b,c);\ndesc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | NULL | | |\n| b | INT(32) | YES | | NULL | | |\n| c | VARCHAR(10) | YES | | NULL | | |\n+-------+-------------+------+------+---------+-------+---------+\n3 rows in set (0.02 sec)\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a t1 \u7684\u8868\u3002\u7136\u540e\uff0c\u4f7f\u7528 CLUSTER \u547d\u4ee4\u6309\u7167 a\uff0cb\uff0cc \u5217\u5bf9\u8868\u8fdb\u884c\u7269\u7406\u6392\u5e8f\u3002\u8fd9\u6837\uff0c\u6240\u6709\u7684\u6570\u636e\u884c\u5c06\u6309\u7167 a\uff0cb\uff0cc \u5217\u7684\u503c\u7684\u987a\u5e8f\u6392\u5217\u3002
\u5bf9\u4e8e Cluster by
\u591a\u5217\u7684\u60c5\u51b5\uff0c\u7b2c\u4e00\u5217\u5c06\u53d6\u5f97\u6700\u597d\u7684\u67e5\u8be2\u52a0\u901f\u6548\u679c\uff0c\u56e0\u4e3a\u7b2c\u4e00\u5217\u7684\u6570\u636e\u5206\u5e03\u662f\u5b8c\u5168\u6709\u5e8f\u7684\u3002\u53ea\u6709\u5728\u7b2c\u4e00\u5217\u76f8\u540c\u7684\u60c5\u51b5\u4e0b\uff0c\u5269\u4e0b\u7684\u6570\u636e\u4f1a\u6309\u7167\u7b2c\u4e8c\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u6240\u4ee5\u7b2c\u4e8c\u5217\u7684\u67e5\u8be2\u52a0\u901f\u6548\u679c\u4f1a\u5f31\u4e8e\u7b2c\u4e00\u5217\uff0c\u4e4b\u540e\u7684\u5217\u4f1a\u4f9d\u6b21\u9012\u51cf\u3002\u6240\u4ee5 Cluster by
\u901a\u5e38\u4e0d\u63a8\u8350\u6307\u5b9a\u592a\u591a\u5217\uff0c\u4e00\u822c 3-4 \u5217\u5373\u53ef\u3002
\u9996\u5148\u57fa\u6570\u662f\u6307\u67d0\u4e00\u5217\u4e0a\u4e0d\u540c\u503c\u7684\u6570\u91cf\u3002\u4f8b\u5982\u6027\u522b\uff0c\u7531\u4e8e\u53ea\u6709\u4e24\u4e2a\u503c\uff0c\u5c31\u662f\u5f88\u5178\u578b\u7684\u4f4e\u57fa\u6570\u5217\u3002\u4f8b\u5982\u8eab\u4efd\u8bc1\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u90fd\u4e0d\u4f1a\u91cd\u590d\uff0c\u5c31\u662f\u9ad8\u57fa\u6570\u5217\u3002\u5982\u679c\u5c06\u9ad8\u57fa\u6570\u5217\u653e\u5728 Cluster by
\u7b2c\u4e00\u5217\uff0c\u6574\u5f20\u8868\u7684\u6570\u636e\u5206\u5e03\u5df2\u7ecf\u5b8c\u5168\u5728\u7b2c\u4e00\u5217\u4e0a\u6392\u597d\u5e8f\u4e86\uff0c\u5bfc\u81f4\u540e\u7eed\u7684\u5217\u4e0d\u8d77\u4f5c\u7528\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5efa\u8bae\u4f7f\u7528 Cluster by
\u5355\u5217\uff0c\u6216\u8005\u5c06\u9ad8\u57fa\u6570\u5217\u5355\u72ec\u5efa\u7d22\u5f15\uff0c\u4e0d\u8981\u653e\u5728 Cluster by
\u4e2d\u3002
Cluster by
\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879","text":"Cluster by
\u53ef\u80fd\u9700\u8981\u5f88\u957f\u65f6\u95f4\u5f53\u5bf9\u5927\u8868\u8fdb\u884c Cluster by
\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u5f88\u957f\u65f6\u95f4\u624d\u80fd\u5b8c\u6210\u3002\u8fd9\u662f\u56e0\u4e3a\u8be5\u64cd\u4f5c\u9700\u8981\u91cd\u65b0\u7ec4\u7ec7\u8868\u4e2d\u7684\u6570\u636e\uff0c\u91cd\u65b0\u6392\u5e8f\u5e76\u5b58\u50a8\u3002\u56e0\u6b64\uff0c\u5728\u6267\u884c Cluster by
\u547d\u4ee4\u65f6\uff0c\u9700\u8981\u8003\u8651\u8868\u7684\u5927\u5c0f\u548c\u786c\u4ef6\u914d\u7f6e\u3002
Cluster by
\u53ef\u80fd\u4f1a\u5f71\u54cd\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u7684\u6027\u80fd\u7531\u4e8e\u4f7f\u7528 Cluster by
\u4f1a\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u7269\u7406\u6392\u5e8f\uff0c\u56e0\u6b64\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u7684\u6027\u80fd\u53ef\u80fd\u4f1a\u53d7\u5230\u5f71\u54cd\u3002\u5f53\u8868\u4e2d\u7684\u6570\u636e\u6309\u7167\u67d0\u4e9b\u5217\u6392\u5e8f\u65f6\uff0c\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u79fb\u52a8\u8bb8\u591a\u884c\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528 Cluster by
\u65f6\uff0c\u9700\u8981\u8003\u8651\u8fd9\u79cd\u5f71\u54cd\u3002
Cluster by
\u9700\u8981\u5b9a\u671f\u6267\u884c\u4ee5\u4fdd\u6301\u6027\u80fd\u7531\u4e8e\u6570\u636e\u7684\u589e\u957f\u548c\u53d8\u5316\uff0c\u8868\u4e2d\u7684\u6570\u636e\u7269\u7406\u6392\u5e8f\u53ef\u80fd\u4f1a\u5931\u53bb\u6548\u679c\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5b9a\u671f\u6267\u884c Cluster by
\u547d\u4ee4\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u7269\u7406\u6392\u5e8f\u4ecd\u7136\u6709\u6548\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cCluster by
\u547d\u4ee4\u7684\u4f7f\u7528\u9700\u8981\u8c28\u614e\uff0c\u5efa\u8bae\u5728\u6d4b\u8bd5\u73af\u5883\u4e0b\u5148\u8fdb\u884c\u9a8c\u8bc1\uff0c\u4ee5\u786e\u4fdd\u4e0d\u4f1a\u5bf9\u8868\u7684\u6570\u636e\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\u3002
\u5b9a\u4e49\uff1a \u552f\u4e00\u7d22\u5f15\u4e0d\u4ec5\u786e\u4fdd\u4e86\u6570\u636e\u7684\u552f\u4e00\u6027\uff0c\u8fd8\u63d0\u4f9b\u4e86\u67e5\u8be2\u4f18\u5316\u7684\u673a\u4f1a\u3002\u5728\u6709\u552f\u4e00\u6027\u8981\u6c42\u7684\u5217\u4e0a\u521b\u5efa\u7d22\u5f15\u53ef\u4ee5\u52a0\u901f\u67e5\u627e\u548c\u6392\u5e8f\u64cd\u4f5c\u3002
\u4f8b\u5b50\uff1a
users
\u7684\u8868\uff0c\u5176\u4e2d email
\u5217\u9700\u8981\u4fdd\u6301\u552f\u4e00\u3002\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u53ef\u4ee5\u52a0\u5feb\u57fa\u4e8e email
\u7684\u67e5\u627e\u901f\u5ea6\uff1aCREATE UNIQUE INDEX idx_email ON users(email);\n
\u5f53\u901a\u8fc7 email
\u8fdb\u884c\u67e5\u8be2\u65f6\uff0cMatrixOne \u53ef\u4ee5\u5feb\u901f\u5b9a\u4f4d\u5230\u552f\u4e00\u7684\u8bb0\u5f55\u3002
orders
\u8868\u4e2d\uff0c\u8ba2\u5355\u53f7 order_id
\u5e94\u8be5\u662f\u552f\u4e00\u7684\u3002\u5728\u8fd9\u4e2a\u5217\u4e0a\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u5c06\u52a0\u5feb\u57fa\u4e8e\u8ba2\u5355\u53f7\u7684\u641c\u7d22\uff1aCREATE UNIQUE INDEX idx_order_id ON orders(order_id);\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_3","title":"\u6b21\u7ea7\u7d22\u5f15","text":"\u5b9a\u4e49\uff1a \u6b21\u7ea7\u7d22\u5f15\uff08\u975e\u552f\u4e00\u7d22\u5f15\uff09\u5728\u6ca1\u6709\u552f\u4e00\u6027\u8981\u6c42\u7684\u5217\u4e0a\u4f7f\u7528\uff0c\u53ef\u4ee5\u52a0\u901f\u5bf9\u8fd9\u4e9b\u5217\u7684\u67e5\u8be2\u3002
\u4f8b\u5b50\uff1a
products
\u8868\uff0c\u4ea7\u54c1\u53ef\u4ee5\u6309\u7c7b\u522b category
\u5206\u7c7b\u3002\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\u53ef\u4ee5\u52a0\u901f\u57fa\u4e8e\u7c7b\u522b\u7684\u67e5\u8be2\uff1aCREATE INDEX idx_category ON products(category);\n
\u8fd9\u6837\uff0c\u67e5\u8be2\u7279\u5b9a\u7c7b\u522b\u7684\u4ea7\u54c1\u65f6\uff0cMatrixOne \u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u6765\u5feb\u901f\u8fc7\u6ee4\u7ed3\u679c\u3002
events
\u8868\u4e2d\uff0c\u5982\u679c\u7ecf\u5e38\u9700\u8981\u57fa\u4e8e\u65e5\u671f\u8303\u56f4\u8fdb\u884c\u67e5\u8be2\uff0c\u6bd4\u5982\u67e5\u8be2\u67d0\u4e2a\u6708\u7684\u4e8b\u4ef6\uff0c\u53ef\u4ee5\u5728\u65e5\u671f\u5217 event_date
\u4e0a\u521b\u5efa\u7d22\u5f15\uff1aCREATE INDEX idx_event_date ON events(event_date);\n
\u8fd9\u6837\uff0c\u5bf9\u4e8e\u6d89\u53ca\u65e5\u671f\u8303\u56f4\u7684\u67e5\u8be2\uff0cMatrixOne \u53ef\u4ee5\u9ad8\u6548\u5730\u5b9a\u4f4d\u548c\u7b5b\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u884c\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_4","title":"\u7d22\u5f15\u7b56\u7565","text":"\u9009\u62e9\u6b63\u786e\u7684\u5217\u521b\u5efa\u7d22\u5f15\uff1a \u901a\u5e38\u5728\u7ecf\u5e38\u7528\u4e8e WHERE
\u5b50\u53e5\u3001JOIN
\u6761\u4ef6\u6216\u6392\u5e8f\uff08ORDER BY
\uff09\u7684\u5217\u4e0a\u521b\u5efa\u7d22\u5f15\u3002
\u7ec4\u5408\u7d22\u5f15\uff1a \u5728\u591a\u4e2a\u5217\u4e0a\u7ecf\u5e38\u4e00\u8d77\u67e5\u8be2\u65f6\uff0c\u53ef\u4ee5\u521b\u5efa\u7ec4\u5408\u7d22\u5f15\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7ecf\u5e38\u6839\u636e last_name
\u548c first_name
\u67e5\u8be2 users
\u8868\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u7ec4\u5408\u7d22\u5f15\uff1a
CREATE INDEX idx_name ON users(last_name, first_name);\n
\u6ce8\u610f\u7d22\u5f15\u7684\u7ef4\u62a4\uff1a \u7d22\u5f15\u53ef\u4ee5\u63d0\u5347\u67e5\u8be2\u6027\u80fd\uff0c\u4f46\u8fc7\u591a\u6216\u4e0d\u5fc5\u8981\u7684\u7d22\u5f15\u4f1a\u964d\u4f4e\u66f4\u65b0\u8868\u65f6\u7684\u6027\u80fd\uff0c\u56e0\u4e3a\u7d22\u5f15\u4e5f\u9700\u8981\u66f4\u65b0\u3002\u5408\u7406\u7ef4\u62a4\u548c\u5b9a\u671f\u5ba1\u67e5\u7d22\u5f15\u5f88\u91cd\u8981\u3002
\u4f7f\u7528 EXPLAIN \u5206\u6790\u67e5\u8be2\uff1a \u4f7f\u7528 EXPLAIN
\u8bed\u53e5\u6765\u5206\u6790\u60a8\u7684\u67e5\u8be2\u5982\u4f55\u4f7f\u7528\u7d22\u5f15\u3002\u8fd9\u6709\u52a9\u4e8e\u7406\u89e3\u67e5\u8be2\u7684\u6027\u80fd\u5e76\u4f18\u5316\u7d22\u5f15\u7b56\u7565\u3002
\u4f7f\u7528\u552f\u4e00\u7d22\u5f15\u548c\u6b21\u7ea7\u7d22\u5f15\u53ef\u4ee5\u663e\u8457\u63d0\u5347 MatrixOne \u6570\u636e\u5e93\u7684\u67e5\u8be2\u6548\u7387\u3002\u6b63\u786e\u7406\u89e3\u5e76\u5b9e\u65bd\u7d22\u5f15\u7b56\u7565\uff0c\u662f\u4f18\u5316\u6570\u636e\u5e93\u6027\u80fd\u7684\u5173\u952e\u6b65\u9aa4\u3002\u7d22\u5f15\u4e5f\u5e94\u6839\u636e\u5177\u4f53\u7684\u4f7f\u7528\u573a\u666f\u548c\u67e5\u8be2\u6a21\u5f0f\u6765\u8bbe\u8ba1\u548c\u4f18\u5316\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_6","title":"\u573a\u666f\u4e00\uff1a\u7535\u5546\u7f51\u7ad9\u7684\u4ea7\u54c1\u641c\u7d22","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_7","title":"\u6848\u4f8b\u9700\u6c42","text":"CREATE INDEX idx_product_name ON products(name);\nCREATE INDEX idx_product_category_price ON products(category, price);\n\n-- \u6839\u636e\u4ea7\u54c1\u540d\u79f0\u641c\u7d22\nSELECT * FROM products WHERE name LIKE '%\u67e5\u8be2\u5173\u952e\u5b57%';\n\n-- \u6839\u636e\u7c7b\u522b\u548c\u4ef7\u683c\u8fc7\u6ee4\nSELECT * FROM products WHERE category = '\u7279\u5b9a\u7c7b\u522b' AND price BETWEEN \u4ef7\u683c\u4e0b\u9650 AND \u4ef7\u683c\u4e0a\u9650;\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_9","title":"\u573a\u666f\u4e8c\uff1a\u793e\u4ea4\u5a92\u4f53\u5e73\u53f0\u7684\u7528\u6237\u767b\u5f55","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_10","title":"\u6848\u4f8b\u9700\u6c42","text":"CREATE UNIQUE INDEX idx_username ON users(username);\nCREATE INDEX idx_password ON users(password);\n\n-- \u68c0\u67e5\u7528\u6237\u540d\u548c\u5bc6\u7801\u7684\u5339\u914d\nSELECT * FROM users WHERE username = '\u7528\u6237\u8f93\u5165\u7684\u7528\u6237\u540d' AND password = '\u7528\u6237\u8f93\u5165\u7684\u5bc6\u7801';\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_12","title":"\u573a\u666f\u4e09\uff1a\u8d22\u52a1\u62a5\u544a\u7cfb\u7edf\u7684\u4ea4\u6613\u6570\u636e\u5206\u6790","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_13","title":"\u6848\u4f8b\u9700\u6c42","text":"CREATE INDEX idx_transaction_date ON transactions(transaction_date);\nCREATE INDEX idx_region_date ON transactions(region, transaction_date);\n\n-- \u6309\u6708\u4efd\u67e5\u8be2\u4ea4\u6613\nSELECT * FROM transactions WHERE transaction_date BETWEEN '\u6708\u4efd\u5f00\u59cb\u65e5\u671f' AND '\u6708\u4efd\u7ed3\u675f\u65e5\u671f';\n\n-- \u6309\u533a\u57df\u548c\u6708\u4efd\u67e5\u8be2\u4ea4\u6613\nSELECT * FROM transactions WHERE region = '\u7279\u5b9a\u533a\u57df' AND transaction_date BETWEEN '\u6708\u4efd\u5f00\u59cb\u65e5\u671f' AND '\u6708\u4efd\u7ed3\u675f\u65e5\u671f';\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/","title":"\u4f7f\u7528\u5206\u533a\u8868\u8c03\u4f18","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_2","title":"\u4ec0\u4e48\u662f\u5206\u533a\u8868\uff1f","text":"\u5206\u533a\u8868\u662f\u6570\u636e\u5e93\u4e2d\u7684\u4e00\u79cd\u6570\u636e\u7ec4\u7ec7\u65b9\u6cd5\uff0c\u5373\u662f\u4e00\u79cd\u8868\u5206\u5272\u65b9\u6cd5\uff0c\u5b83\u5c06\u8868\u6570\u636e\u5206\u6563\u5230\u591a\u4e2a\u5206\u533a\u4e2d\uff0c\u6bcf\u4e2a\u5206\u533a\u76f8\u5f53\u4e8e\u4e00\u4e2a\u72ec\u7acb\u7684\u5c0f\u8868\u3002
MatrixOne \u5c06\u8868\u4e2d\u7684\u6570\u636e\u6839\u636e\u8868\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u7684\u952e\u503c\u5212\u5206\u5230\u4e0d\u540c\u7684\u5b58\u50a8\u5bf9\u8c61\u4e2d\u3002\u8fd9\u4e9b\u5217\u5bf9\u5e94\u7684\u952e\u503c\u79f0\u4e3a\u6570\u636e\u5206\u533a\u6216\u8303\u56f4\u3002
\u6570\u636e\u5206\u533a\u6216\u8303\u56f4\u662f\u8868\u7684\u4e00\u90e8\u5206\uff0c\u5305\u542b\u8868\u884c\u7684\u5b50\u96c6\uff0c\u5e76\u4e0e\u5176\u4ed6\u884c\u96c6\u5206\u5f00\u5b58\u50a8\u3002\u6839\u636e CREATE TABLE
\u8bed\u53e5\u7684 PARTITION BY
\u5b50\u53e5\u4e2d\u63d0\u4f9b\u7684\u89c4\u8303\uff0c\u7ed9\u8868\u4e2d\u7684\u6570\u636e\u5212\u5206\u4e3a\u591a\u4e2a\u6570\u636e\u5206\u533a\u6216\u8303\u56f4\u3002
\u5206\u533a\u8868\u7b80\u5316\u4e86\u8868\u6570\u636e\u7684\u8bfb\u4e0e\u5199\uff0c\u5728\u5206\u533a\u8868\u4e2d\uff0cSQL \u6267\u884c\u7684\u65f6\u5019\uff0c\u4f1a\u4f18\u5148\u5224\u65ad\u6570\u636e\u5bf9\u5e94\u54ea\u4e2a\u5206\u533a\uff0c\u518d\u5bf9\u5bf9\u5e94\u5206\u533a\u8fdb\u884c\u8bfb\u5199\uff0c\u907f\u514d\u4e86\u5bf9\u8868\u5185\u6240\u6709\u6570\u636e\u8fdb\u884c\u64cd\u4f5c\u3002\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u5e26\u6765\u5f88\u591a\u597d\u5904\uff0c\u4f8b\u5982\u52a0\u5feb\u67e5\u8be2\u901f\u5ea6\u3001\u4f18\u5316\u6570\u636e\u7ef4\u62a4\u3001\u63d0\u9ad8\u6570\u636e\u53ef\u7528\u6027\u7b49\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_3","title":"\u5206\u533a\u8868\u7684\u5e94\u7528\u573a\u666f","text":"\u67e5\u8be2\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u4f7f\u67e5\u8be2\u53ea\u9488\u5bf9\u7279\u5b9a\u5206\u533a\u8fdb\u884c\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8868\u662f\u6309\u7167\u65e5\u671f\u5206\u533a\u7684\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u67e5\u8be2\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u5185\u7684\u6570\u636e\uff0c\u800c\u65e0\u9700\u626b\u63cf\u6574\u4e2a\u8868\u3002
\u6570\u636e\u7ef4\u62a4\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u52a0\u5feb\u6570\u636e\u7ef4\u62a4\u7684\u901f\u5ea6\uff0c\u4f8b\u5982\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u3002\u5206\u533a\u8868\u53ef\u4ee5\u901a\u8fc7\u66f4\u6709\u6548\u5730\u5229\u7528 I/O \u548c CPU \u8d44\u6e90\u6765\u51cf\u5c11\u9700\u8981\u5904\u7406\u7684\u6570\u636e\u91cf\uff0c\u4ece\u800c\u63d0\u9ad8\u7ef4\u62a4\u6027\u80fd\u3002
\u5b58\u50a8\u7a7a\u95f4\u4f7f\u7528\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u66f4\u597d\u5730\u7ba1\u7406\u8868\u6570\u636e\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5b58\u50a8\u7a7a\u95f4\u4f7f\u7528\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8868\u6309\u7167\u65f6\u95f4\u5206\u533a\uff0c\u5219\u65e7\u7684\u5206\u533a\u53ef\u4ee5\u8f7b\u677e\u5730\u5220\u9664\u6216\u5f52\u6863\uff0c\u800c\u65e0\u9700\u5f71\u54cd\u5176\u4ed6\u5206\u533a\u7684\u6570\u636e\u3002
\u53ef\u7528\u6027\u548c\u53ef\u9760\u6027\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u63d0\u9ad8\u7cfb\u7edf\u7684\u53ef\u7528\u6027\u548c\u53ef\u9760\u6027\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u5907\u4efd\u6216\u590d\u5236\u7279\u5b9a\u5206\u533a\u6765\u589e\u52a0\u7cfb\u7edf\u7684\u6062\u590d\u80fd\u529b\uff0c\u4ece\u800c\u51cf\u5c11\u7cfb\u7edf\u51fa\u73b0\u6545\u969c\u7684\u98ce\u9669\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u968f\u7740\u8868\u5185\u6570\u636e\u7684\u4e0d\u65ad\u589e\u52a0\uff0c\u8868\u7684\u6027\u80fd\u4f1a\u9010\u6e10\u4e0b\u964d\u3002\u4f46\u5982\u679c\u5c06\u540c\u6837\u6570\u636e\u5b58\u50a8\u5728\u5206\u533a\u8868\u4e2d\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u5c06\u4e0d\u540c\u8303\u56f4\u7684\u6570\u636e\u5212\u5206\u5230\u4e0d\u540c\u7684\u5b58\u50a8\u5bf9\u8c61\u4e2d\u6765\u5b9e\u73b0\u6570\u636e\u8bbf\u95ee\u65b9\u5f0f\u7684\u4f18\u5316\u3002
\u4e0e\u5168\u8868\u8bbf\u95ee\u76f8\u6bd4\uff0c\u4f18\u5316\u540e\u7684\u8bbf\u95ee\u65b9\u5f0f\u5c06\u66f4\u4f18\u5148\u8bbf\u95ee\u7279\u5b9a\u5206\u533a\uff0c\u4ece\u800c\u4f7f\u5f97\u6570\u636e\u7684\u589e\u5220\u6539\u67e5\u8bf7\u6c42\u80fd\u591f\u66f4\u6709\u6548\u5730\u5206\u6d41\u5230\u4e0d\u540c\u7684\u5206\u533a\u4e2d\uff0c\u540c\u65f6\u907f\u514d IO \u70ed\u70b9\u7684\u51fa\u73b0\uff0c\u6700\u7ec8\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u63d0\u5347\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_6","title":"\u5982\u4f55\u4f7f\u7528\u5206\u533a\u8868\u8fdb\u884c\u8c03\u4f18","text":"\u4f7f\u7528\u5206\u533a\u8868\u65f6\uff0c\u9700\u8981\u8003\u8651\u4ee5\u4e0b\u524d\u63d0\u6761\u4ef6\u662f\u5426\u6ee1\u8db3\uff1a
\u5206\u533a\u952e\u662f\u7269\u7406\u5212\u5206\u8868\u7684\u5173\u952e\u56e0\u7d20\uff0c\u6b63\u786e\u9009\u62e9\u5206\u533a\u952e\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u8bfb\u5199\u6027\u80fd\u3002
\u5728\u9009\u62e9\u5206\u533a\u952e\u65f6\uff0c\u9700\u8981\u8003\u8651\u4ee5\u4e0b\u56e0\u7d20\uff1a
\u5373\u4f7f\u9009\u62e9\u4e86\u5177\u6709\u9ad8\u57fa\u6570\u548c\u72ec\u7279\u6027\u7684\u5217\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u5982\u679c\u5206\u533a\u7684\u8303\u56f4\u4e0d\u5408\u9002\uff0c\u4ecd\u6709\u53ef\u80fd\u51fa\u73b0\u70ed\u70b9\u5206\u533a\u3002\u56e0\u6b64\uff0c\u5728\u5206\u533a\u7b56\u7565\u4e0a\u9700\u8981\u66f4\u7cbe\u7ec6\u5316\u7684\u7ba1\u7406\u3002
\u5728 MatrixOne \u4e2d\uff0c\u53ef\u4ee5\u652f\u6301\u591a\u79cd\u5bf9\u8868\u7684\u5206\u533a\u6a21\u5f0f\uff0c\u6bcf\u4e2a\u6a21\u5f0f\u5bf9\u5e94\u7684\u5206\u533a\u65b9\u6cd5\u5747\u6709\u4e0d\u540c\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#range","title":"Range \u5206\u533a","text":"\u8303\u56f4\u5206\u533a\u662f\u4e00\u79cd\u57fa\u4e8e\u8fde\u7eed\u503c\u7684\u5206\u533a\u65b9\u5f0f\uff0c\u5206\u533a\u4e4b\u95f4\u5fc5\u987b\u662f\u4e92\u4e0d\u91cd\u53e0\u7684\uff0c\u5206\u533a\u7684\u5b9a\u4e49\u4f7f\u7528 VALUES LESS THAN
\u8fd0\u7b97\u7b26\u3002
\u793a\u4f8b
\u5982\u4e0b\u4e24\u5f20\u8868\uff0c\u5c31\u662f\u5206\u522b\u4ee5\u6574\u6570\u5217\u4e0e\u65e5\u671f\u5217\u4f5c\u4e3a\u5206\u533a\u5217\u4f7f\u7528\uff1a
CREATE TABLE members (\nfirstname VARCHAR(25) NOT NULL,\nlastname VARCHAR(25) NOT NULL,\nusername VARCHAR(16) NOT NULL,\nemail VARCHAR(35),\njoined DATE NOT NULL\n)\nPARTITION BY RANGE COLUMNS(joined) (\nPARTITION p0 VALUES LESS THAN ('1960-01-01'),\nPARTITION p1 VALUES LESS THAN ('1970-01-01'),\nPARTITION p2 VALUES LESS THAN ('1980-01-01'),\nPARTITION p3 VALUES LESS THAN ('1990-01-01')\n)\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u4e2d\uff0c\u5206\u533a\u5217\u7684\u503c\u6ca1\u6709\u5bf9\u5e94\u7684\u5206\u533a\uff0c\u90a3\u4e48\u76f8\u5e94\u7684\u63d2\u5165\u6216\u66f4\u65b0\u64cd\u4f5c\u5c06\u4f1a\u5931\u8d25\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u63d2\u5165\u4e00\u884c joined
\u65e5\u671f\u4e3a 2000-01-01 \u7684\u6570\u636e\uff0c\u4f46\u662f\u56e0\u4e3a\u627e\u4e0d\u5230\u76f8\u5e94\u7684\u5206\u533a\uff0c\u8be5\u64cd\u4f5c\u5c06\u4f1a\u56e0\u4e3a\u65e0\u6cd5\u5b9a\u4f4d\u5206\u533a\u800c\u5931\u8d25\u3002\u56e0\u6b64\uff0c\u5728\u6267\u884c\u63d2\u5165\u6216\u66f4\u65b0\u64cd\u4f5c\u65f6\uff0c\u4e00\u5b9a\u8981\u786e\u4fdd\u5206\u533a\u5217\u7684\u503c\u5c5e\u4e8e\u5bf9\u5e94\u7684\u5206\u533a\u3002
\u8303\u56f4\u5217\u5206\u533a\u53ef\u4ee5\u88ab\u89c6\u4e3a\u8303\u56f4\u5206\u533a\u7684\u4e00\u4e2a\u6269\u5c55\u6216\u53d8\u4f53\uff0c\u5b83\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a\u5217\u7684\u7ec4\u5408\u8303\u56f4\u8fdb\u884c\u66f4\u590d\u6742\u7684\u6570\u636e\u5206\u5272\u3002
\u793a\u4f8b
CREATE TABLE e_orders (\norder_id INT NOT NULL,\ncustomer_id INT NOT NULL,\norder_date DATE NOT NULL,\ncustomer_level INT,\ntotal_amount DECIMAL(10, 2),\nproduct_id INT\n)\nPARTITION BY RANGE COLUMNS(order_date, customer_level) (\nPARTITION p0 VALUES LESS THAN ('2023-01-01', 2),\nPARTITION p1 VALUES LESS THAN ('2023-01-01', 5),\nPARTITION p2 VALUES LESS THAN ('2023-06-01', 2),\nPARTITION p3 VALUES LESS THAN ('2023-06-01', 5),\nPARTITION p4 VALUES LESS THAN (MAXVALUE, MAXVALUE)\n);\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#list","title":"List \u5206\u533a","text":"\u5217\u8868\u5206\u533a\u8981\u6c42\u6bcf\u4e2a\u5206\u533a\u5fc5\u987b\u7531\u660e\u786e\u5b9a\u4e49\u7684\u503c\u5217\u8868\u7ec4\u6210\uff0c\u4e14\u6bcf\u4e2a\u5206\u533a\u7684\u5217\u8868\u6210\u5458\u4e0d\u80fd\u6709\u91cd\u590d\u503c\u3002\u5206\u533a\u952e\u7684\u503c\u5e94\u8be5\u662f\u79bb\u6563\u7684\uff0c\u5373\u5206\u533a\u5b9a\u4e49\u80fd\u591f\u6e05\u6670\u5730\u5217\u51fa\u6240\u6709\u53ef\u80fd\u7684\u503c\u6216\u503c\u7684\u96c6\u5408\u3002
\u793a\u4f8b
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY LIST(store_id) (\nPARTITION pNorth VALUES IN (3,5,6,9,17),\nPARTITION pEast VALUES IN (1,2,10,11,19,20),\nPARTITION pWest VALUES IN (4,12,13,14,18),\nPARTITION pCentral VALUES IN (7,8,15,16)\n);\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u4e2d\uff0c\u5206\u533a\u5217\u7684\u503c\u6ca1\u6709\u5bf9\u5e94\u5206\u533a\uff0c\u5219\u4f1a\u63d2\u5165\u5931\u8d25\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#list-columns","title":"List Columns \u5206\u533a","text":"\u5217\u8868\u5217\u5206\u533a\u53ef\u4ee5\u88ab\u89c6\u4e3a\u5217\u8868\u5206\u533a\u7684\u6269\u5c55\uff0c\u5b83\u5141\u8bb8\u4f7f\u7528\u591a\u5217\u7684\u7ec4\u5408\u503c\u8fdb\u884c\u66f4\u7ec6\u81f4\u7684\u6570\u636e\u5206\u5272\u3002
\u793a\u4f8b
CREATE TABLE orders (\norder_id INT NOT NULL,\norder_date DATE NOT NULL,\ncustomer_id INT NOT NULL,\nregion VARCHAR(10), -- \u5317\u533a\u6216\u5357\u533a\nproduct_type VARCHAR(15), -- \u7535\u5b50\u4ea7\u54c1\u3001\u5bb6\u5c45\u7528\u54c1\namount DECIMAL(10, 2)\n)\nPARTITION BY LIST COLUMNS(region, product_type) (\nPARTITION pNorthElectronics VALUES IN (('\u5317\u533a', '\u7535\u5b50\u4ea7\u54c1')),\nPARTITION pNorthHomeGoods VALUES IN (('\u5317\u533a', '\u5bb6\u5c45\u7528\u54c1')),\nPARTITION pSouthElectronics VALUES IN (('\u5357\u533a', '\u7535\u5b50\u4ea7\u54c1')),\nPARTITION pSouthHomeGoods VALUES IN (('\u5357\u533a', '\u5bb6\u5c45\u7528\u54c1'))\n);\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#hash","title":"Hash \u5206\u533a","text":"\u54c8\u5e0c\u5206\u533a\u901a\u5e38\u7528\u4e8e\u5c06\u6570\u636e\u5747\u5300\u5206\u5e03\u5728\u4e0d\u540c\u7684\u5206\u533a\u4e2d\u3002\u5e38\u89c1\u7684\u54c8\u5e0c\u5206\u533a\u6709 HASH \u51fd\u6570\u5206\u533a\u548c KEY \u51fd\u6570\u5206\u533a\u3002
\u5728 HASH \u51fd\u6570\u5206\u533a\u4e2d\uff0c\u5fc5\u987b\u660e\u786e\u6307\u5b9a\u7528\u4e8e\u5206\u533a\u7684\u5217\u6216\u8868\u8fbe\u5f0f\uff0c\u8be5\u5217\u6216\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u5fc5\u987b\u662f\u6574\u6570\uff0c\u5e76\u4e14\u5efa\u8bae\u660e\u786e\u6307\u5b9a\u5206\u533a\u6570\u91cf\uff0c\u8be5\u6570\u91cf\u5fc5\u987b\u662f\u6b63\u6574\u6570\u3002
\u793a\u4f8b
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH( YEAR(hired) )\nPARTITIONS 4;\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#key","title":"Key \u5206\u533a","text":"\u5728\u4f7f\u7528 KEY \u51fd\u6570\u5206\u533a\u65f6\uff0c\u6570\u636e\u5e93\u670d\u52a1\u5185\u90e8\u63d0\u4f9b\u4e86\u81ea\u6709\u7684\u54c8\u5e0c\u65b9\u5f0f\u8fdb\u884c\u5206\u533a\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u663e\u5f0f\u5b9a\u4e49\u5206\u533a\u6570\u91cf\u3002\u4e0e HASH \u51fd\u6570\u5206\u533a\u4e0d\u540c\u7684\u662f\uff0cKEY \u51fd\u6570\u5206\u533a\u652f\u6301\u9664\u5927\u5bf9\u8c61\u7c7b\u578b\uff08TEXT/BLOB\uff09\u4e4b\u5916\u7684\u6240\u6709\u7c7b\u578b\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u800c\u4e14\u4e0d\u4e00\u5b9a\u9700\u8981\u6307\u5b9a\u5206\u533a\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u8bed\u53e5\u521b\u5efa\u4e00\u4e2a\u5206\u533a\u952e\u4e3a s1 \u7684\u8868\uff1a
\u793a\u4f8b
CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY(s1);\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u5206\u533a\u952e\u662f\u8be5\u8868\u7684\u4e3b\u952e\u5217\uff0c\u90a3\u4e48\u5728\u4e0d\u663e\u5f0f\u6307\u5b9a\u5206\u533a\u952e\u65f6\uff0c\u7cfb\u7edf\u4f1a\u9ed8\u8ba4\u4ee5\u4e3b\u952e\u5217\u4f5c\u4e3a\u5206\u533a\u952e\u3002\u4f8b\u5982\uff1a
CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY();\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_9","title":"\u9650\u5236","text":"List / List column \u6682\u4e0d\u652f\u6301\u5206\u533a\u88c1\u526a\u3002
Range/ Range Columns \u6682\u4e0d\u652f\u6301\u5206\u533a\u88c1\u526a\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/","title":"\u5206\u533a\u88c1\u526a","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_1","title":"\u5206\u533a\u88c1\u526a","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_2","title":"\u6982\u8ff0","text":"\u5206\u533a\u88c1\u526a\uff08Partition Pruning\uff09\u662f\u6570\u636e\u5e93\u67e5\u8be2\u4f18\u5316\u7684\u4e00\u4e2a\u8fc7\u7a0b\uff0c\u5b83\u80fd\u591f\u8bc6\u522b\u5e76\u6392\u9664\u90a3\u4e9b\u4e0d\u5fc5\u8981\u7684\u5206\u533a\uff0c\u4ece\u800c\u51cf\u5c11\u67e5\u8be2\u9700\u8981\u626b\u63cf\u7684\u6570\u636e\u91cf\u3002\u5f53\u6267\u884c\u4e00\u4e2a\u67e5\u8be2\u65f6\uff0c\u5982\u679c\u67e5\u8be2\u6761\u4ef6\u4e0e\u8868\u7684\u5206\u533a\u952e\u76f8\u5173\u8054\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u80fd\u591f\u81ea\u52a8\u786e\u5b9a\u5e76\u4ec5\u8bbf\u95ee\u5305\u542b\u76f8\u5173\u6570\u636e\u7684\u5206\u533a\uff0c\u800c\u5ffd\u7565\u5176\u5b83\u5206\u533a\u4ee5\u5927\u5e45\u51cf\u5c11\u6240\u9700\u8ba1\u7b97\u7684\u6570\u636e\u91cf\u3002
\u4f8b\u5982\uff1a
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\nPRIMARY KEY(col1, col3)\n) PARTITION BY KEY(col1, col3) PARTITIONS 4;\n\nINSERT INTO t1 VALUES\n(1, '1980-12-17', 7369),\n(2, '1981-02-20', 7499),\n(3, '1981-02-22', 7521),\n(4, '1981-04-02', 7566),\n(5, '1981-09-28', 7654),\n(6, '1981-05-01', 7698),\n(7, '1981-06-09', 7782),\n(8, '0087-07-13', 7788),\n(9, '1981-11-17', 7839),\n(10, '1981-09-08', 7844),\n(11, '2007-07-13', 7876),\n(12, '1981-12-03', 7900),\n(13, '1987-07-13', 7980),\n(14, '2001-11-17', 7981),\n(15, '1951-11-08', 7982),\n(16, '1927-10-13', 7983),\n(17, '1671-12-09', 7984),\n(18, '1981-11-06', 7985),\n(19, '1771-12-06', 7986),\n(20, '1985-10-06', 7987),\n(21, '1771-10-06', 7988),\n(22, '1981-10-05', 7989),\n(23, '2001-12-04', 7990),\n(24, '1999-08-01', 7991),\n(25, '1951-11-08', 7992),\n(26, '1927-10-13', 7993),\n(27, '1971-12-09', 7994),\n(28, '1981-12-09', 7995),\n(29, '2001-11-17', 7996),\n(30, '1981-12-09', 7997),\n(31, '2001-11-17', 7998),\n(32, '2001-11-17', 7999);\n\nmysql> EXPLAIN VERBOSE SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);\n+-----------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| -> Table Scan on db1.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| Table: 't1' (0:'col1', 1:'col2', 2:'col3') |\n| Hit Partition: p0, p2 |\n| Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |\n+-----------------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
\u8be5\u67e5\u8be2\u901a\u8fc7\u88c1\u526a\u5206\u533a\uff0c\u4ec5\u626b\u63cf\u4e86 p0 \u548c p2 \u5206\u533a\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#key","title":"\u5206\u533a\u88c1\u526a\u5728 KEY \u5206\u533a\u8868\u4e0a\u7684\u5e94\u7528","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#key_1","title":"\u9002\u7528\u7684 KEY \u5206\u533a\u8868\u573a\u666f","text":"\u53ea\u6709\u4e0e\u5206\u533a\u952e\u5339\u914d\u7684\u7b49\u503c\u6bd4\u8f83\u67e5\u8be2\u6761\u4ef6\u624d\u80fd\u652f\u6301 KEY \u5206\u533a\u8868\u7684\u88c1\u526a\u3002
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT PRIMARY KEY\n) PARTITION BY KEY(col3) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM t1 WHERE col3 = 7990 OR col3 = 7988;\n+-------------------------------------------------------------+\n| QUERY PLAN |\n+-------------------------------------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Hit Partition: p0, p1 |\n| Filter Cond: ((t1.col3 = 7990) or (t1.col3 = 7988)) |\n+-------------------------------------------------------------+\n4 rows in set (0.01 sec)\n
\u5728\u8fd9\u4e2a SQL \u4e2d\uff0c\u6761\u4ef6 col3 = 7990
\u53ef\u4ee5\u786e\u5b9a\u6240\u6709\u7ed3\u679c\u90fd\u4f4d\u4e8e\u5206\u533a p0 \u4e0a\u3002\u6761\u4ef6 col3 = 7988
\u53ef\u4ee5\u786e\u5b9a\u6240\u6709\u7ed3\u679c\u90fd\u4f4d\u4e8e\u5206\u533a p1 \u4e0a\u3002\u7531\u4e8e\u8fd9\u4e24\u4e2a\u6761\u4ef6\u7684\u5173\u7cfb\u662f OR\uff0c\u56e0\u6b64\u53ea\u9700\u8981\u626b\u63cf p0 \u548c p1 \u4e24\u4e2a\u5206\u533a\uff0c\u5206\u533a\u88c1\u526a\u7684\u7ed3\u679c\u662f p0 \u548c p1\u3002
Key \u5206\u533a\u7531\u4e8e\u5185\u90e8\u4f7f\u7528\u54c8\u5e0c\u7b97\u6cd5\u9020\u6210\u7684\u65e0\u5e8f\u6027\uff0c\u4e0d\u9002\u7528\u4e8e\u8fde\u7eed\u67e5\u8be2\uff0c\u5982 between
\u3001> < >= <=
\u7b49\u6761\u4ef6\uff0c\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col3 >= 7782;\n+----------------------------------------+\n| QUERY PLAN |\n+----------------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| Filter Cond: (t1.col3 >= 7782) |\n+----------------------------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_4","title":"\u573a\u666f\u4e8c","text":"\u5bf9\u4e8e\u53ea\u80fd\u5728\u6267\u884c\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u83b7\u53d6\u8fc7\u6ee4\u6761\u4ef6\u7684\u573a\u666f\uff0c\u65e0\u6cd5\u5229\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col3 = (SELECT col3 FROM t2 WHERE t1.col3 = t2.col3 AND t2.col1 < 5);\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Filter |\n| Filter Cond: (t1.col3 = t2.col3) |\n| -> Join |\n| Join Type: SINGLE |\n| Join Cond: (t1.col3 = t2.col3) |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| -> Table Scan on db1.t2 |\n| Hit Partition: all partitions |\n| Filter Cond: (t2.col1 < 5) |\n+---------------------------------------------------+\n11 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u6bcf\u8bfb\u53d6\u4e00\u884c\u6570\u636e\uff0c\u90fd\u4f1a\u4ece\u5b50\u67e5\u8be2\u4e2d\u83b7\u53d6\u7ed3\u679c\u5e76\u6784\u5efa\u7b49\u503c\u8fc7\u6ee4\u6761\u4ef6 col3 = ?
\u3002\u7136\u800c\uff0c\u5206\u533a\u88c1\u526a\u53ea\u5728\u67e5\u8be2\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u751f\u6548\uff0c\u800c\u4e0d\u662f\u6267\u884c\u9636\u6bb5\uff0c\u56e0\u6b64\u65e0\u6cd5\u8fdb\u884c\u5206\u533a\u88c1\u526a\u3002
Hash \u5206\u533a\u8868\u7684\u4f7f\u7528\u65b9\u5f0f\u4e0e Key \u5206\u533a\u8868\u57fa\u672c\u76f8\u540c\uff0c\u53ea\u6709\u7b49\u503c\u6bd4\u8f83\u67e5\u8be2\u6761\u4ef6\u624d\u80fd\u652f\u6301 Hash \u5206\u533a\u8868\u7684\u88c1\u526a\u3002
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH(store_id) PARTITIONS 4;\n\nINSERT INTO employees VALUES\n(10001, 'Georgi', 'Facello', '1953-09-02','1986-06-26',120, 1),\n(10002, 'Bezalel', 'Simmel', '1964-06-02','1985-11-21',150, 7),\n(10003, 'Parto', 'Bamford', '1959-12-03','1986-08-28',140, 3),\n(10004, 'Chirstian', 'Koblick', '1954-05-01','1986-12-01',150, 3),\n(10005, 'Kyoichi', 'Maliniak', '1955-01-21','1989-09-12',150, 18),\n(10006, 'Anneke', 'Preusig', '1953-04-20','1989-06-02',150, 15),\n(10007, 'Tzvetan', 'Zielinski', '1957-05-23','1989-02-10',110, 6),\n(10008, 'Saniya', 'Kalloufi', '1958-02-19','1994-09-15',170, 10),\n(10009, 'Sumant', 'Peac', '1952-04-19','1985-02-18',110, 13),\n(10010, 'Duangkaew', 'Piveteau', '1963-06-01','1989-08-24',160, 10),\n(10011, 'Mary', 'Sluis', '1953-11-07','1990-01-22',120, 8),\n(10012, 'Patricio', 'Bridgland', '1960-10-04','1992-12-18',120, 7),\n(10013, 'Eberhardt', 'Terkki', '1963-06-07','1985-10-20',160, 17),\n(10014, 'Berni', 'Genin', '1956-02-12','1987-03-11',120, 15),\n(10015, 'Guoxiang', 'Nooteboom', '1959-08-19','1987-07-02',140, 8),\n(10016, 'Kazuhito', 'Cappelletti', '1961-05-02','1995-01-27',140, 2),\n(10017, 'Cristinel', 'Bouloucos', '1958-07-06','1993-08-03',170, 10),\n(10018, 'Kazuhide', 'Peha', '1954-06-19','1987-04-03',170, 2),\n(10019, 'Lillian', 'Haddadi', '1953-01-23','1999-04-30',170, 13),\n(10020, 'Mayuko', 'Warwick', '1952-12-24','1991-01-26',120, 1),\n(10021, 'Ramzi', 'Erde', '1960-02-20','1988-02-10',120, 9),\n(10022, 'Shahaf', 'Famili', '1952-07-08','1995-08-22',130, 10),\n(10023, 'Bojan', 'Montemayor', '1953-09-29','1989-12-17',120, 5),\n(10024, 'Suzette', 'Pettey', '1958-09-05','1997-05-19',130, 4),\n(10025, 'Prasadram', 'Heyers', '1958-10-31','1987-08-17',180, 8),\n(10026, 'Yongqiao', 'Berztiss', '1953-04-03','1995-03-20',170, 4),\n(10027, 'Divier', 'Reistad', '1962-07-10','1989-07-07',180, 10),\n(10028, 'Domenick', 'Tempesti', '1963-11-26','1991-10-22',110, 11),\n(10029, 'Otmar', 'Herbst', '1956-12-13','1985-11-20',110, 12),\n(10030, 'Elvis', 'Demeyer', '1958-07-14','1994-02-17',110, 1),\n(10031, 'Karsten', 'Joslin', '1959-01-27','1991-09-01',110, 10),\n(10032, 'Jeong', 'Reistad', '1960-08-09','1990-06-20',120, 19),\n(10033, 'Arif', 'Merlo', '1956-11-14','1987-03-18',120, 14),\n(10034, 'Bader', 'Swan', '1962-12-29','1988-09-21',130, 16),\n(10035, 'Alain', 'Chappelet', '1953-02-08','1988-09-05',130, 3),\n(10036, 'Adamantios', 'Portugali', '1959-08-10','1992-01-03',130, 14),\n(10037, 'Pradeep', 'Makrucki', '1963-07-22','1990-12-05',140, 12),\n(10038, 'Huan', 'Lortz', '1960-07-20','1989-09-20',140, 7),\n(10039, 'Alejandro', 'Brender', '1959-10-01','1988-01-19',110, 20),\n(10040, 'Weiyi', 'Meriste', '1959-09-13','1993-02-14',140, 17);\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: p0 |\n| Filter Cond: (employees.store_id = 10) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a SQL \u4e2d\uff0c\u7531\u4e8e\u5206\u533a\u8868\u7684\u5206\u533a\u952e\u4e3a store_id
\uff0c\u6761\u4ef6 store_id = 10
\u53ef\u4ee5\u786e\u5b9a\u6240\u6709\u7ed3\u679c\u90fd\u5728\u4e00\u4e2a\u5206\u533a\u4e2d\u3002\u6570\u503c 10 \u7ecf\u8fc7 Hash \u540e\u786e\u5b9a\u4f4d\u4e8e\u5206\u533a p0 \u4e2d\u3002\u56e0\u6b64\u53ea\u9700\u8981\u626b\u63cf\u5206\u533a p0\uff0c\u65e0\u9700\u8bbf\u95ee\u7edd\u5bf9\u4e0d\u5305\u542b\u76f8\u5173\u7ed3\u679c\u7684 p1\u3001p2\u3001p3 \u5206\u533a\u3002\u4ece\u6267\u884c\u8ba1\u5212\u4e2d\u53ef\u89c1\uff0c\u53ea\u51fa\u73b0\u4e00\u4e2a TableScan
\u7b97\u5b50\uff0c\u5176\u4e2d\u6307\u5b9a\u4e86 Hit Partition
\u4e3a p0\uff0c\u786e\u4fdd\u4e86\u5206\u533a\u88c1\u526a\u7684\u751f\u6548\u3002
HASH \u5206\u533a\u7531\u4e8e\u5185\u90e8\u4f7f\u7528\u54c8\u5e0c\u7b97\u6cd5\u9020\u6210\u7684\u65e0\u5e8f\u6027\uff0c\u4e0d\u9002\u7528\u4e8e\u8fde\u7eed\u67e5\u8be2\uff0c\u5982 between
\u3001> < >= <=
\u7b49\u6761\u4ef6\uff0c\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH(store_id) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id > 15;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: all partitions |\n| Filter Cond: (employees.store_id > 15) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a SQL \u4e2d\uff0c\u6761\u4ef6 store_id > 15
\u65e0\u6cd5\u786e\u5b9a\u5bf9\u5e94\u7684 Hash \u5206\u533a\uff0c\u56e0\u6b64\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
\u5bf9\u4e8e\u53ea\u80fd\u5728\u6267\u884c\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u83b7\u53d6\u8fc7\u6ee4\u6761\u4ef6\u7684\u573a\u666f\uff0c\u65e0\u6cd5\u5229\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col1 = (SELECT store_id FROM employees WHERE employees.store_id = t1.col1 AND employees.id = 10010);\n+---------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------+\n| Project |\n| -> Filter |\n| Filter Cond: (t1.col1 = employees.store_id) |\n| -> Join |\n| Join Type: SINGLE |\n| Join Cond: (t1.col1 = employees.store_id) |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| -> Table Scan on db1.employees |\n| Hit Partition: all partitions |\n| Filter Cond: (employees.id = 10010) |\n+---------------------------------------------------------+\n11 rows in set (0.01 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u6bcf\u8bfb\u53d6\u4e00\u884c\u6570\u636e\uff0c\u90fd\u4f1a\u4ece\u5b50\u67e5\u8be2\u4e2d\u83b7\u53d6\u7ed3\u679c\u5e76\u6784\u5efa\u7b49\u503c\u8fc7\u6ee4\u6761\u4ef6 col3 = ?
\uff0c\u7136\u800c\uff0c\u5206\u533a\u88c1\u526a\u4ec5\u5728\u67e5\u8be2\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u751f\u6548\uff0c\u800c\u4e0d\u662f\u6267\u884c\u9636\u6bb5\uff0c\u56e0\u6b64\u65e0\u6cd5\u8fdb\u884c\u5206\u533a\u88c1\u526a\u3002
\u76ee\u524d\uff0c\u4e0d\u652f\u6301\u5c06\u51fd\u6570\u8868\u8fbe\u5f0f\u7528\u4f5c Hash \u5206\u533a\u8868\u8fbe\u5f0f\u7684\u5206\u533a\u88c1\u526a\u3002
CREATE TABLE t3 (\ncol1 INT,\ncol2 CHAR(10),\ncol3 DATETIME\n) PARTITION BY HASH (YEAR(col3)) PARTITIONS 4;\n\nINSERT INTO t3 VALUES\n(10001, 'Georgi', '1999-04-05 11:01:02'),\n(10002, 'Bezalel', '2004-04-03 13:11:10'),\n(10003, 'Parto', '1997-04-05 11:01:02'),\n(10004, 'Chirstian', '2004-04-03 13:11:10'),\n(10005, 'Mary', '1998-04-05 11:01:02'),\n(10006, 'Patricio', '2004-04-03 13:11:10'),\n(10007, 'Eberhardt', '1953-09-02 13:11:10'),\n(10008, 'Kazuhide', '1986-06-26 19:21:10'),\n(10009, 'Tempesti', '1956-11-14 08:11:10'),\n(10010, 'Nooteboom', '1987-03-18 23:11:10');\n\nmysql> EXPLAIN SELECT * FROM t3 WHERE YEAR(col3) = 1999;\n+---------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------+\n| Project |\n| -> Table Scan on db1.t3 |\n| Hit Partition: all partitions |\n| Filter Cond: (YEAR(t3.col3) = 1999) |\n+---------------------------------------------+\n4 rows in set (0.00 sec)\n\nmysql> SELECT * FROM t3 WHERE YEAR(col3) = 1999;\n+-------+--------+---------------------+\n| col1 | col2 | col3 |\n+-------+--------+---------------------+\n| 10001 | Georgi | 1999-04-05 11:01:02 |\n+-------+--------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_8","title":"\u5206\u533a\u526a\u88c1\u7684\u6027\u80fd\u8c03\u4f18\u793a\u4f8b","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#1-key","title":"\u793a\u4f8b 1: KEY \u5206\u533a\u8868\u7684\u7b49\u503c\u6761\u4ef6","text":"CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\nPRIMARY KEY(col1, col3)\n) PARTITION BY KEY(col1, col3) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col3 = 7369;\n+------------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------------+\n| Project |\n| -> Table Scan on db2.t1 |\n| Hit Partition: p0 |\n| Filter Cond: (t1.col3 = 7369), (t1.col1 = 1) |\n+------------------------------------------------------+\n5 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u7ecf\u8fc7\u5206\u533a\u88c1\u526a\u540e\uff0c\u53ea\u4f1a\u8bbf\u95ee\u5206\u533a p0\uff0c\u56e0\u4e3a\u67e5\u8be2\u6761\u4ef6\u4e0e p0 \u4e2d\u7684\u6570\u636e\u5339\u914d\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#2-key-or","title":"\u793a\u4f8b 2: KEY \u5206\u533a\u8868\u7684 OR \u6761\u4ef6","text":"mysql> EXPLAIN SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);\n+-----------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| -> Table Scan on db2.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| Table: 't1' (0:'col1', 1:'col2', 2:'col3') |\n| Hit Partition: p0, p2 |\n| Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |\n+-----------------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u88c1\u526a\u4e86\u5206\u533a p0 \u548c p2\uff0c\u56e0\u4e3a\u67e5\u8be2\u6761\u4ef6\u4e0e\u8fd9\u4e24\u4e2a\u5206\u533a\u4e2d\u7684\u6570\u636e\u5339\u914d\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#3-hash","title":"\u793a\u4f8b 3: HASH \u5206\u533a\u8868\u7684\u7b49\u503c\u6761\u4ef6","text":"CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n) PARTITION BY HASH(store_id) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: p0 |\n| Filter Cond: (employees.store_id = 10) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a\u67e5\u8be2\u4e2d\uff0c\u53ea\u6709\u5206\u533a p0 \u5305\u542b\u4e0e\u6761\u4ef6 store_id = 10
\u5339\u914d\u7684\u6570\u636e\uff0c\u56e0\u6b64\u53ea\u626b\u63cf\u4e86 p0 \u5206\u533a\u3002
mysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10 OR store_id = 15;\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: p0, p3 |\n| Filter Cond: ((employees.store_id = 10) or (employees.store_id = 15)) |\n+---------------------------------------------------+\n5 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u88c1\u526a\u4e86 p0 \u548c p3 \u5206\u533a\uff0c\u56e0\u4e3a\u8fd9\u4e24\u4e2a\u5206\u533a\u4e2d\u5305\u542b\u4e86\u4e0e\u6761\u4ef6 store_id = 10 OR store_id = 15
\u5339\u914d\u7684\u6570\u636e\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col1 > 5;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| Filter Cond: (t1.col1 > 5) |\n| Block Filter Cond: (t1.col1 > 5) |\n+------------------------------------------------+\n5 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a\u67e5\u8be2\u4e2d\uff0c\u6761\u4ef6 col1 > 5
\u65e0\u6cd5\u786e\u5b9a\u5bf9\u5e94\u7684\u5206\u533a\uff0c\u56e0\u6b64\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u3002
MatrixOne \u7684\u5206\u533a\u8868\u652f\u6301\u56db\u79cd\u5206\u533a\u5f62\u5f0f\uff1aKey\u3001Hash\u3001Range\u3001List\uff1a
MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u662f MatrixOne \u5b58\u50a8\u7cfb\u7edf\u4fe1\u606f\u7684\u5730\u65b9\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b83\u4eec\u8bbf\u95ee\u7cfb\u7edf\u4fe1\u606f\u3002MatrixOne \u5728\u521d\u59cb\u5316\u65f6\u521b\u5efa\u4e86 6 \u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\uff1amo_catalog
\u3001information_schema
\u3001system_metrcis
\u3001system
\u3001mysql
\u548c mo_task
\u3002mo_task
\u5f53\u524d\u6b63\u5728\u5f00\u53d1\u4e2d\uff0c\u6682\u65f6\u5bf9\u4f60\u6240\u8fdb\u884c\u7684\u64cd\u4f5c\u4e0d\u4f1a\u4ea7\u751f\u76f4\u63a5\u5f71\u54cd\u3002\u672c\u6587\u6863\u4e2d\u63cf\u8ff0\u4e86\u5176\u4ed6\u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u51fd\u6570\u3002
\u7cfb\u7edf\u53ea\u80fd\u4fee\u6539\u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\uff0c\u4f60\u4ec5\u80fd\u4ece\u4e2d\u8fdb\u884c\u8bfb\u53d6\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Reference/System-tables/#mo_catalog","title":"mo_catalog
\u6570\u636e\u5e93","text":"mo_catalog
\u7528\u4e8e\u5b58\u50a8 MatrixOne \u5bf9\u8c61\u7684\u5143\u6570\u636e\uff0c\u5982\uff1a\u6570\u636e\u5e93\u3001\u8868\u3001\u5217\u3001\u7cfb\u7edf\u53d8\u91cf\u3001\u79df\u6237\u3001\u7528\u6237\u548c\u89d2\u8272\u3002
\u4ece MatrixOne 0.6 \u7248\u672c\u5373\u5f15\u5165\u4e86\u591a\u79df\u6237\u7684\u6982\u5ff5\uff0c\u9ed8\u8ba4\u7684 sys
\u79df\u6237\u548c\u5176\u4ed6\u79df\u6237\u7684\u884c\u4e3a\u7565\u6709\u4e0d\u540c\u3002\u670d\u52a1\u4e8e\u591a\u79df\u6237\u7ba1\u7406\u7684\u7cfb\u7edf\u8868 mo_account
\u4ec5\u5bf9 sys
\u79df\u6237\u53ef\u89c1\uff1b\u5176\u4ed6\u79df\u6237\u770b\u4e0d\u5230\u6b64\u8868\u3002
mo_indexes
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 id BIGINT UNSIGNED(64) \u7d22\u5f15 ID table_id BIGINT UNSIGNED(64) \u7d22\u5f15\u6240\u5728\u8868\u7684 ID database_id BIGINT UNSIGNED(64) \u7d22\u5f15\u6240\u5728\u6570\u636e\u5e93\u7684 ID name VARCHAR(64) \u7d22\u5f15\u7684\u540d\u5b57 type VARCHAR(11) \u7d22\u5f15\u7684\u7c7b\u578b\uff0c\u5305\u62ec\u4e3b\u952e\u7d22\u5f15\uff08PRIMARY\uff09\uff0c\u552f\u4e00\u7d22\u5f15\uff08UNIQUE\uff09\uff0c\u6b21\u7ea7\u7d22\u5f15\uff08MULTIPLE algo VARCHAR(11) \u521b\u5efa\u7d22\u5f15\u7684\u7b97\u6cd5 algo_table_type VARCHAR(11) \u591a\u8868\u7d22\u5f15\u7684\u9690\u85cf\u8868\u7c7b\u578b algo_params VARCHAR(2048) \u7d22\u5f15\u7b97\u6cd5\u53c2\u6570 is_visible TINYINT(8) \u7d22\u5f15\u662f\u5426\u53ef\u89c1\uff0c1 \u4e3a\u53ef\u89c1\uff0c0 \u4e0d\u53ef\u89c1\uff08\u76ee\u524d MatrixOne \u7684\u7d22\u5f15\u5168\u90e8\u4e3a\u53ef\u89c1\u7d22\u5f15\uff09 hidden TINYINT(8) \u7d22\u5f15\u662f\u5426\u4e3a\u9690\u85cf\u7d22\u5f15\uff0c1 \u4e3a\u9690\u85cf\u7d22\u5f15\uff0c0 \u4e3a\u975e\u9690\u85cf\u7d22\u5f15 comment VARCHAR(2048) \u7d22\u5f15\u7684\u6ce8\u91ca\u4fe1\u606f column_name VARCHAR(256) \u7d22\u5f15\u7684\u7ec4\u6210\u5217\u7684\u5217\u540d ordinal_position INT UNSIGNED(32) \u7d22\u5f15\u4e2d\u7684\u5217\u5e8f\u53f7\uff0c\u4ece 1 \u5f00\u59cb options TEXT(0) \u7d22\u5f15\u7684 options \u9009\u9879\u4fe1\u606f index_table_name VARCHAR(5000) \u8be5\u7d22\u5f15\u5bf9\u5e94\u7684\u7d22\u5f15\u8868\u7684\u8868\u540d\uff0c\u76ee\u524d\u53ea\u6709\u552f\u4e00\u7d22\u5f15\u542b\u6709\u7d22\u5f15\u8868"},{"location":"MatrixOne/Reference/System-tables/#mo_table_partitions","title":"mo_table_partitions
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 table_id BIGINT UNSIGNED(64) \u5f53\u524d\u5206\u533a\u8868\u7684 ID database_id BIGINT UNSIGNED(64) \u5f53\u524d\u5206\u533a\u8868\u6240\u5c5e\u7684\u6570\u636e\u5e93\u7684 ID number SMALLINT UNSIGNED(16) \u5f53\u524d\u5206\u533a\u7f16\u53f7\u3002\u6240\u6709\u5206\u533a\u90fd\u6309\u7167\u5b9a\u4e49\u7684\u987a\u5e8f\u8fdb\u884c\u7d22\u5f15\uff0c\u5176\u4e2d 1 \u662f\u5206\u914d\u7ed9\u7b2c\u4e00\u4e2a\u5206\u533a\u7684\u6570\u5b57 name VARCHAR(64) \u5206\u533a\u7684\u540d\u79f0 partition_type VARCHAR(50) \u5b58\u653e\u8868\u7684\u5206\u533a\u7c7b\u578b\u4fe1\u606f\uff0c\u5982\u679c\u662f\u5206\u533a\u8868\uff0c\u5176\u503c\u679a\u4e3e\u4e3a\"KEY\"\uff0c \"LINEAR_KEY\"\uff0c\"HASH\"\uff0c\"LINEAR_KEY_51\"\uff0c\"RANGE\"\uff0c\"RANGE_COLUMNS\"\uff0c\"LIST\"\uff0c\"LIST_COLUMNS\"\uff1b\u5982\u679c\u4e0d\u662f\u5206\u533a\u8868\uff0cpartition_type \u7684\u503c\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\u3002 partition_expression VARCHAR(2048) \u521b\u5efa\u5206\u533a\u8868\u7684\u7684 CREATE TABLE
\u6216 ALTER TABLE
\u8bed\u53e5\u4e2d\u4f7f\u7528\u7684\u5206\u533a\u51fd\u6570\u7684\u8868\u8fbe\u5f0f\u3002 description_utf8 TEXT(0) \u6b64\u5217\u7528\u4e8e RANGE
\u548c LIST
\u5206\u533a\u3002\u5bf9\u4e8e RANGE
\u5206\u533a\uff0c\u5b83\u5305\u542b\u5206\u533a\u7684 VALUES LESS THAN
\u5b50\u53e5\u4e2d\u8bbe\u7f6e\u7684\u503c\uff0c\u8be5\u503c\u53ef\u4ee5\u662f\u6574\u6570\u6216 MAXVALUE
\u3002\u5bf9\u4e8e LIST
\u5206\u533a\uff0c\u6b64\u5217\u5305\u542b\u5206\u533a\u7684 values in
\u5b50\u53e5\u4e2d\u5b9a\u4e49\u7684\u503c\uff0c\u8be5\u5b50\u53e5\u662f\u9017\u53f7\u5206\u9694\u7684\u6574\u6570\u503c\u5217\u8868\u3002\u5bf9\u4e8e\u4e0d\u662f RANGE
\u6216 LIST
\u7684\u5206\u533a\uff0c\u6b64\u5217\u59cb\u7ec8\u4e3a NULL\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\uff0c\u6b64\u5217\u4e3a NULL comment VARCHAR(2048) \u6ce8\u91ca\u7684\u6587\u672c\u3002\u5426\u5219\uff0c\u6b64\u503c\u4e3a\u7a7a\u3002 options TEXT(0) \u5206\u533a\u7684\u9009\u9879\u4fe1\u606f\uff0c\u6682\u4e3a NULL
partition_table_name VARCHAR(1024) \u5f53\u524d\u5206\u533a\u5bf9\u5e94\u7684\u5206\u533a\u5b50\u8868\u540d\u5b57"},{"location":"MatrixOne/Reference/System-tables/#mo_user","title":"mo_user
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 user_id int \u7528\u6237 ID\uff0c\u4e3b\u952e user_host varchar(100) \u7528\u6237\u4e3b\u673a\u5730\u5740 user_name varchar(100) \u7528\u6237\u540d authentication_string varchar(100) \u5bc6\u7801\u52a0\u5bc6\u7684\u8ba4\u8bc1\u5b57\u7b26\u4e32 status varchar(8) \u5f00\u542f\u3001\u9501\u5b9a\u3001\u5931\u6548 created_time timestamp \u7528\u6237\u521b\u5efa\u65f6\u95f4 expired_time timestamp \u7528\u6237\u8fc7\u671f\u65f6\u95f4 login_type varchar(16) ssl/\u5bc6\u7801/\u5176\u4ed6 creator int \u521b\u5efa\u6b64\u7528\u6237\u7684\u521b\u5efa\u8005 ID owner int \u6b64\u7528\u6237\u7684\u7ba1\u7406\u5458 ID default_role int \u6b64\u7528\u6237\u7684\u9ed8\u8ba4\u89d2\u8272 ID"},{"location":"MatrixOne/Reference/System-tables/#mo_account-sys","title":"mo_account
\u8868 (\u4ec5 sys
\u79df\u6237\u53ef\u89c1)","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 account_id int unsigned \u79df\u6237 ID\uff0c\u4e3b\u952e account_name varchar(100) \u79df\u6237\u540d status varchar(100) \u5f00\u542f/\u6682\u505c/\u9650\u5236 created_time timestamp \u521b\u5efa\u65f6\u95f4 comments varchar(256) \u6ce8\u91ca suspended_time TIMESTAMP \u4fee\u6539\u79df\u6237\u72b6\u6001\u7684\u65f6\u95f4 version bigint unsigned \u5f53\u524d\u79df\u6237\u7248\u672c\u72b6\u6001"},{"location":"MatrixOne/Reference/System-tables/#mo_database","title":"mo_database
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 dat_id bigint unsigned \u4e3b\u952e ID datname varchar(100) \u6570\u636e\u5e93\u540d\u79f0 dat_catalog_name varchar(100) \u6570\u636e\u5e93 catalog \u540d\u79f0\uff0c\u9ed8\u8ba4def
dat_createsql varchar(100) \u521b\u5efa\u6570\u636e\u5e93 SQL \u8bed\u53e5 owner int unsigned \u89d2\u8272 ID creator int unsigned \u7528\u6237 ID created_time timestamp \u521b\u5efa\u65f6\u95f4 account_id int unsigned \u79df\u6237 ID dat_type varchar(23) \u6570\u636e\u5e93\u7c7b\u578b\uff0c\u666e\u901a\u5e93\u6216\u8ba2\u9605\u5e93"},{"location":"MatrixOne/Reference/System-tables/#mo_role","title":"mo_role
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 role_id int unsigned \u89d2\u8272 ID\uff0c\u4e3b\u952e role_name varchar(100) \u89d2\u8272\u540d\u79f0 creator int unsigned \u7528\u6237 ID owner int unsigned MatrixOne \u7ba1\u7406\u5458/\u79df\u6237\u7ba1\u7406\u5458\u62e5\u6709\u8005 ID created_time timestamp \u521b\u5efa\u65f6\u95f4 comments text \u6ce8\u91ca"},{"location":"MatrixOne/Reference/System-tables/#mo_user_grant","title":"mo_user_grant
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 role_id int unsigned \u88ab\u6388\u6743\u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e user_id int unsigned \u83b7\u5f97\u6388\u6743\u89d2\u8272\u7684\u7528\u6237 ID\uff0c\u8054\u5408\u4e3b\u952e granted_time timestamp \u6388\u6743\u65f6\u95f4 with_grant_option bool \u662f\u5426\u5141\u8bb8\u83b7\u5f97\u6388\u6743\u7528\u6237\u518d\u6388\u6743\u7ed9\u5176\u4ed6\u7528\u6237\u6216\u89d2\u8272"},{"location":"MatrixOne/Reference/System-tables/#mo_role_grant","title":"mo_role_grant
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 granted_id int \u88ab\u6388\u4e88\u7684\u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e grantee_id int \u8981\u6388\u4e88\u5176\u4ed6\u89d2\u8272\u7684\u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e operation_role_id int \u64cd\u4f5c\u89d2\u8272 ID operation_user_id int \u64cd\u4f5c\u7528\u6237 ID granted_time timestamp \u6388\u6743\u65f6\u95f4 with_grant_option bool \u662f\u5426\u5141\u8bb8\u83b7\u5f97\u6388\u6743\u89d2\u8272\u518d\u6388\u6743\u7ed9\u5176\u4ed6\u7528\u6237\u6216\u89d2\u8272"},{"location":"MatrixOne/Reference/System-tables/#mo_role_privs","title":"mo_role_privs
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 role_id int unsigned \u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e role_name varchar(100) \u89d2\u8272\u540d\uff1aaccountadmin/public obj_type varchar(16) \u5bf9\u8c61\u7c7b\u578b\uff1aaccount/database/table\uff0c\u8054\u5408\u4e3b\u952e obj_id bigint unsigned \u5bf9\u8c61 ID\uff0c\u8054\u5408\u4e3b\u952e privilege_id int \u6743\u9650 ID\uff0c\u8054\u5408\u4e3b\u952e privilege_name varchar(100) \u6743\u9650\u540d\uff1a\u6743\u9650\u5217\u8868 privilege_level varchar(100) \u6743\u9650\u7ea7\u522b\uff0c\u8054\u5408\u4e3b\u952e operation_user_id int unsigned \u64cd\u4f5c\u7528\u6237 ID granted_time timestamp \u6388\u6743\u65f6\u95f4 with_grant_option bool \u662f\u5426\u5141\u8bb8\u6388\u6743"},{"location":"MatrixOne/Reference/System-tables/#mo_user_defined_function","title":"mo_user_defined_function
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 function_id INT(32) \u51fd\u6570\u7684 ID\uff0c\u4e3b\u952e name VARCHAR(100) \u51fd\u6570\u7684\u540d\u79f0 owner INT UNSIGNED(32) \u521b\u5efa\u51fd\u6570\u7684\u89d2\u8272 ID args TEXT(0) \u51fd\u6570\u7684\u53c2\u6570\u5217\u8868 rettype VARCHAR(20) \u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b body TEXT(0) \u51fd\u6570\u7684\u51fd\u6570\u4f53 language VARCHAR(20) \u51fd\u6570\u6240\u4f7f\u7528\u7684\u8bed\u8a00 db VARCHAR(100) \u51fd\u6570\u6240\u5728\u7684\u6570\u636e\u5e93 definer VARCHAR(50) \u5b9a\u4e49\u51fd\u6570\u7684\u7528\u6237\u540d\u79f0 modified_time TIMESTAMP(0) \u51fd\u6570\u6700\u540e\u4e00\u6b21\u4fee\u6539\u7684\u65f6\u95f4 created_time TIMESTAMP(0) \u51fd\u6570\u7684\u521b\u5efa\u65f6\u95f4 type VARCHAR(10) \u51fd\u6570\u7684\u7c7b\u578b\uff0c\u9ed8\u8ba4 FUNCTION security_type VARCHAR(10) \u5b89\u5168\u5904\u7406\u65b9\u5f0f\uff0c\u7edf\u4e00\u503c DEFINER comment VARCHAR(5000) \u521b\u5efa\u51fd\u6570\u7684\u6ce8\u91ca character_set_client VARCHAR(64) \u5ba2\u6237\u7aef\u5b57\u7b26\u96c6\uff1autf8mb4 collation_connection VARCHAR(64) \u8fde\u63a5\u6392\u5e8f\uff1autf8mb4_0900_ai_ci database_collation VARCHAR(64) \u6570\u636e\u5e93\u8fde\u63a5\u6392\u5e8f\uff1autf8mb4_0900_ai_ci"},{"location":"MatrixOne/Reference/System-tables/#mo_mysql_compatibility_mode","title":"mo_mysql_compatibility_mode
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 configuration_id INT(32) \u914d\u7f6e\u9879 id\uff0c\u81ea\u589e\u5217\uff0c\u4f5c\u4e3a\u4e3b\u952e\u533a\u5206\u4e0d\u540c\u7684\u914d\u7f6e account_id INT(32) \u914d\u7f6e\u6240\u5728\u7684\u79df\u6237 id account_name VARCHAR(300) \u914d\u7f6e\u6240\u5728\u7684\u79df\u6237\u540d\u79f0 dat_name VARCHAR(5000) \u914d\u7f6e\u6240\u5728\u7684\u6570\u636e\u5e93\u540d\u79f0 variable_name VARCHAR(300) \u53d8\u91cf\u7684\u540d\u5b57 variable_value VARCHAR(5000) \u53d8\u91cf\u7684\u503c system_variables BOOL(0) \u662f\u5426\u4e3a\u7cfb\u7edf\u53d8\u91cf (\u9664\u4e86\u7cfb\u7edf\u53d8\u91cf\uff0c\u8fd8\u6dfb\u52a0\u7684\u6709\u517c\u5bb9\u6027\u53d8\u91cf\uff09"},{"location":"MatrixOne/Reference/System-tables/#mo_pubs","title":"mo_pubs
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 pub_name VARCHAR(64) \u53d1\u5e03\u540d\u79f0 database_name VARCHAR(5000) \u53d1\u5e03\u6570\u636e\u7684\u540d\u79f0 database_id BIGINT UNSIGNED(64) \u53d1\u5e03\u6570\u636e\u5e93\u7684 ID\uff0c\u4e0e mo_database \u8868\u4e2d\u7684 dat_id \u5bf9\u5e94 all_table BOOL(0) \u53d1\u5e03\u5e93\u662f\u5426\u5305\u542b database_id \u5bf9\u5e94\u6570\u636e\u5e93\u5185\u7684\u6240\u6709\u8868 table_list TEXT(0) \u5728\u975e all table \u65f6\uff0c\u53d1\u5e03\u5e93\u5185\u5305\u542b\u7684\u8868\u6e05\u5355\uff0c\u8868\u540d\u4e0e database_id \u5bf9\u5e94\u6570\u636e\u5e93\u4e0b\u7684\u8868\u4e00\u4e00\u5bf9\u5e94 account_list TEXT(0) \u5728\u975e all account \u65f6\uff0c\u5141\u8bb8\u8ba2\u9605\u8be5\u53d1\u5e03\u5e93\u7684 account \u6e05\u5355 created_time TIMESTAMP(0) \u521b\u5efa\u53d1\u5e03\u5e93\u7684\u65f6\u95f4 owner INT UNSIGNED(32) \u521b\u5efa\u53d1\u5e03\u5e93\u5bf9\u5e94\u7684\u89d2\u8272 ID creator INT UNSIGNED(32) \u521b\u5efa\u53d1\u5e03\u5e93\u5bf9\u5e94\u7684\u7528\u6237 ID comment TEXT(0) \u521b\u5efa\u53d1\u5e03\u5e93\u7684\u5907\u6ce8\u4fe1\u606f"},{"location":"MatrixOne/Reference/System-tables/#mo_stages","title":"mo_stages
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 stage_id INT UNSIGNED(32) \u6570\u636e\u9636\u6bb5 ID stage_name VARCHAR(64) \u6570\u636e\u9636\u6bb5\u540d\u79f0 url TEXT(0) \u5bf9\u8c61\u5b58\u50a8\u7684\u8def\u5f84\uff08\u4e0d\u542b\u8ba4\u8bc1\uff09\u3001\u6587\u4ef6\u7cfb\u7edf\u7684\u8def\u5f84 stage_credentials TEXT(0) \u8ba4\u8bc1\u4fe1\u606f\uff0c\u52a0\u5bc6\u540e\u4fdd\u5b58 stage_status VARCHAR(64) ENABLED/DISABLED \u9ed8\u8ba4\uff1aDISABLED created_time TIMESTAMP(0) \u521b\u5efa\u65f6\u95f4 comment TEXT(0) \u6ce8\u91ca"},{"location":"MatrixOne/Reference/System-tables/#mo_sessions","title":"mo_sessions
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 node_id VARCHAR(65535) MatrixOne \u8282\u70b9\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002\u4e00\u7ecf\u542f\u52a8\uff0c\u4e0d\u53ef\u66f4\u6539\u3002 conn_id INT UNSIGNED \u5728 MatrixOne \u4e2d\u4e0e\u5ba2\u6237\u7aef TCP \u8fde\u63a5\u76f8\u5173\u7684\u552f\u4e00\u7f16\u53f7\uff0c\u7531 Hakeeper \u81ea\u52a8\u751f\u6210\u3002 session_id VARCHAR(65535) \u7528\u4e8e\u6807\u8bc6\u4f1a\u8bdd\u7684\u552f\u4e00 UUID\u3002\u6bcf\u4e2a\u65b0\u4f1a\u8bdd\u90fd\u4f1a\u751f\u6210\u4e00\u4e2a\u65b0\u7684 UUID\u3002 account VARCHAR(65535) \u79df\u6237\u7684\u540d\u79f0\u3002 user VARCHAR(65535) \u7528\u6237\u7684\u540d\u79f0\u3002 host VARCHAR(65535) CN \u8282\u70b9\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u3002 db VARCHAR(65535) \u6267\u884c SQL \u65f6\u4f7f\u7528\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002 session_start VARCHAR(65535) \u4f1a\u8bdd\u521b\u5efa\u7684\u65f6\u95f4\u6233\u3002 command VARCHAR(65535) MySQL \u547d\u4ee4\u7684\u7c7b\u578b\uff0c\u5982 COM_QUERY\u3001COM_STMT_PREPARE\u3001COM_STMT_EXECUTE \u7b49\u3002 info VARCHAR(65535) \u6267\u884c\u7684 SQL \u8bed\u53e5\u3002\u4e00\u4e2a SQL \u4e2d\u53ef\u80fd\u5305\u542b\u591a\u4e2a\u8bed\u53e5\u3002 txn_id VARCHAR(65535) \u76f8\u5173\u4e8b\u52a1\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 statement_id VARCHAR(65535) SQL \u8bed\u53e5\u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff08UUID\uff09\u3002 statement_type VARCHAR(65535) SQL \u8bed\u53e5\u7684\u7c7b\u578b\uff0c\u5982 SELECT\u3001INSERT\u3001UPDATE \u7b49\u3002 query_type VARCHAR(65535) SQL \u8bed\u53e5\u7684\u79cd\u7c7b\uff0c\u5982 DQL\uff08\u6570\u636e\u67e5\u8be2\u8bed\u8a00\uff09\u3001TCL\uff08\u4e8b\u52a1\u63a7\u5236\u8bed\u8a00\uff09\u7b49\u3002 sql_source_type VARCHAR(65535) SQL \u8bed\u53e5\u7684\u6765\u6e90\uff0c\u5982\u5916\u90e8\u6216\u5185\u90e8\u3002 query_start VARCHAR(65535) SQL \u8bed\u53e5\u5f00\u59cb\u6267\u884c\u7684\u65f6\u95f4\u6233\u3002 client_host VARCHAR(65535) \u5ba2\u6237\u7aef\u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u53f7\u3002 role VARCHAR(65535) \u7528\u6237\u7684\u89d2\u8272\u540d\u79f0\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_configurations","title":"mo_configurations
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 node_type VARCHAR(65535) \u8282\u70b9\u7684\u7c7b\u578b\uff1acn\uff08\u8ba1\u7b97\u8282\u70b9\uff09\u3001tn\uff08\u4e8b\u52a1\u8282\u70b9\uff09\u3001log\uff08\u65e5\u5fd7\u8282\u70b9\uff09\u3001proxy\uff08\u4ee3\u7406\uff09\u3002 node_id VARCHAR(65535) \u8282\u70b9\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 name VARCHAR(65535) \u914d\u7f6e\u9879\u7684\u540d\u79f0\uff0c\u53ef\u80fd\u4f1a\u9644\u5e26\u5d4c\u5957\u7ed3\u6784\u524d\u7f00\u3002 current_value VARCHAR(65535) \u914d\u7f6e\u9879\u7684\u5f53\u524d\u6570\u503c\u3002 default_value VARCHAR(65535) \u914d\u7f6e\u9879\u7684\u9ed8\u8ba4\u6570\u503c\u3002 internal VARCHAR(65535) \u8868\u793a\u914d\u7f6e\u53c2\u6570\u662f\u5426\u4e3a\u5185\u90e8\u53c2\u6570\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_locks","title":"mo_locks
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 cn_id VARCHAR(65535) cn \u7684 uuid txn_id VARCHAR(65535) \u6301\u6709\u9501\u7684\u4e8b\u52a1\u3002 table_id VARCHAR(65535) \u52a0\u9501\u7684\u8868\u3002 lock_key VARCHAR(65535) \u9501\u7c7b\u578b\u3002\u53ef\u4ee5\u662f point
\u6216 range
\u3002 lock_content VARCHAR(65535) \u9501\u5b9a\u7684\u5185\u5bb9\uff0c\u4ee5 16 \u8fdb\u5236\u8868\u793a\u3002\u5bf9\u4e8e range
\u9501\uff0c\u8868\u793a\u4e00\u4e2a\u533a\u95f4\uff1b\u5bf9\u4e8e point
\u9501\uff0c\u8868\u793a\u5355\u4e2a\u503c\u3002 lock_mode VARCHAR(65535) \u9501\u6a21\u5f0f\u3002\u53ef\u4ee5\u662f shared
\u6216 exclusive
\u3002 lock_status VARCHAR(65535) \u9501\u72b6\u6001\uff0c\u53ef\u80fd\u4e3a wait
\u3001acquired
\u6216 none
\u3002wait\u3002\u6ca1\u6709\u4e8b\u52a1\u6301\u6709\u9501\uff0c\u4f46\u6709\u4e8b\u52a1\u7b49\u5728\u9501\u4e0a\u3002acquired\u3002\u6709\u4e8b\u52a1\u6301\u6709\u9501\u3002none\u3002\u6ca1\u6709\u4e8b\u52a1\u6301\u6709\u9501\uff0c\u4e5f\u6ca1\u6709\u4e8b\u52a1\u7b49\u5728\u9501\u4e0a\u3002 lock_wait VARCHAR(65535) \u5728\u6b64\u9501\u4e0a\u7b49\u5f85\u7684\u4e8b\u52a1\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_variables","title":"mo_variables
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 configuration_id INT(32) \u81ea\u589e\u5217\uff0c\u7528\u4e8e\u552f\u4e00\u6807\u8bc6\u6bcf\u4e2a\u914d\u7f6e\u9879\u3002 account_id INT(32) \u6807\u8bc6\u79df\u6237\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 account_name VARCHAR(300) \u79df\u6237\u7684\u540d\u79f0\u3002 dat_name VARCHAR(5000) \u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 variable_name VARCHAR(300) \u914d\u7f6e\u53d8\u91cf\u7684\u540d\u79f0\u3002 variable_value VARCHAR(5000) \u914d\u7f6e\u53d8\u91cf\u7684\u6570\u503c\u3002 system_variables BOOL(0) \u6307\u793a\u914d\u7f6e\u53d8\u91cf\u662f\u5426\u4e3a\u7cfb\u7edf\u7ea7\u522b\u7684\u53d8\u91cf\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_transactions","title":"mo_transactions
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 cn_id VARCHAR(65535) \u552f\u4e00\u6807\u8bc6 CN\uff08Compute Node\uff09\u7684 ID\u3002 txn_id VARCHAR(65535) \u552f\u4e00\u6807\u8bc6\u4e8b\u52a1\u7684 ID\u3002 create_ts VARCHAR(65535) \u8bb0\u5f55\u4e8b\u52a1\u521b\u5efa\u65f6\u95f4\u6233\uff0c\u9075\u5faa RFC3339Nano \u683c\u5f0f (\"2006-01-02T15:04:05.999999999Z07:00\")\u3002 snapshot_ts VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684\u5feb\u7167\u65f6\u95f4\u6233\uff0c\u4ee5\u7269\u7406\u65f6\u95f4\u548c\u903b\u8f91\u65f6\u95f4\u7684\u5f62\u5f0f\u8868\u793a\u3002 prepared_ts VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684 prepared \u65f6\u95f4\u6233\uff0c\u4ee5\u7269\u7406\u65f6\u95f4\u548c\u903b\u8f91\u65f6\u95f4\u7684\u5f62\u5f0f\u8868\u793a\u3002 commit_ts VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684 commit \u65f6\u95f4\u6233\uff0c\u4ee5\u7269\u7406\u65f6\u95f4\u548c\u903b\u8f91\u65f6\u95f4\u7684\u5f62\u5f0f\u8868\u793a\u3002 txn_mode VARCHAR(65535) \u6807\u8bc6\u4e8b\u52a1\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u60b2\u89c2\u4e8b\u52a1\u6216\u4e50\u89c2\u4e8b\u52a1\u3002 isolation VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684\u9694\u79bb\u7ea7\u522b\uff0c\u53ef\u4ee5\u662f SI\uff08Snapshot Isolation\uff09\u6216 RC\uff08Read Committed\uff09\u3002 user_txn VARCHAR(65535) \u6307\u793a\u7528\u6237\u4e8b\u52a1\uff0c\u5373\u7528\u6237\u901a\u8fc7\u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u5e76\u6267\u884c\u7684 SQL \u64cd\u4f5c\u6240\u521b\u5efa\u7684\u4e8b\u52a1\u3002 txn_status VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684\u5f53\u524d\u72b6\u6001\uff0c\u53ef\u80fd\u7684\u53d6\u503c\u5305\u62ec active\uff08\u6d3b\u8dc3\uff09\u3001committed\uff08\u5df2\u63d0\u4ea4\uff09\u3001aborting\uff08\u4e2d\u6b62\u4e2d\uff09\u3001aborted\uff08\u5df2\u4e2d\u6b62\uff09\u3002\u5728\u5206\u5e03\u5f0f\u4e8b\u52a1 2PC \u6a21\u5f0f\u4e0b\uff0c\u8fd8\u4f1a\u5305\u62ec prepared\uff08\u5df2\u51c6\u5907\uff09\u548c committing\uff08\u63d0\u4ea4\u4e2d\uff09\u3002 table_id VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u6240\u6d89\u53ca\u7684\u8868\u7684 ID\u3002 lock_key VARCHAR(65535) \u8868\u793a\u9501\u7684\u7c7b\u578b\uff0c\u53ef\u4ee5\u662f range\uff08\u8303\u56f4\u9501\uff09\u6216 point\uff08\u70b9\u9501\uff09\u3002 lock_content VARCHAR(65535) point \u9501\u65f6\u8868\u793a\u5355\u4e2a\u503c\uff0crange \u9501\u65f6\u8868\u793a\u8303\u56f4\uff0c\u901a\u5e38\u4ee5 \"low - high\" \u5f62\u5f0f\u8868\u793a\u3002\u8bf7\u6ce8\u610f\uff0c\u4e8b\u52a1\u53ef\u80fd\u6d89\u53ca\u591a\u4e2a\u9501\uff0c\u4f46\u6b64\u5904\u4ec5\u5c55\u793a\u7b2c\u4e00\u4e2a\u9501\u3002 lock_mode VARCHAR(65535) \u8868\u793a\u9501\u7684\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u4e92\u65a5\u9501\uff08exclusive\uff09\u6216\u5171\u4eab\u9501\uff08shared\uff09\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_columns","title":"mo_columns
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 att_uniq_name varchar(256) \u4e3b\u952e\u3002\u9690\u85cf\u7684\u590d\u5408\u4e3b\u952e\uff0c\u683c\u5f0f\u7c7b\u4f3c\u4e8e \"${att_relname_id}-${attname}\" account_id int unsigned \u79df\u6237 ID att_database_id bigint unsigned \u6570\u636e\u5e93 ID att_database varchar(256) \u6570\u636e Name att_relname_id bigint unsigned \u8868 ID att_relname varchar(256) \u6b64\u5217\u6240\u5c5e\u7684\u8868\u3002\uff08\u53c2\u8003 mo_tables.relname\uff09 attname varchar(256) \u5217\u540d atttyp varchar(256) \u6b64\u5217\u7684\u6570\u636e\u7c7b\u578b (\u5220\u9664\u7684\u5217\u4e3a 0 )\u3002 attnum int \u5217\u6570\u3002\u666e\u901a\u5217\u4ece 1 \u5f00\u59cb\u7f16\u53f7\u3002 att_length int \u7c7b\u578b\u7684\u5b57\u8282\u6570 attnotnull tinyint(1) \u8868\u793a\u4e00\u4e2a\u975e\u7a7a\u7ea6\u675f\u3002 atthasdef tinyint(1) \u6b64\u5217\u6709\u9ed8\u8ba4\u8868\u8fbe\u5f0f\u6216\u751f\u6210\u8868\u8fbe\u5f0f\u3002 att_default varchar(1024) \u9ed8\u8ba4\u8868\u8fbe\u5f0f attisdropped tinyint(1) \u6b64\u5217\u5df2\u5220\u9664\uff0c\u4e0d\u518d\u6709\u6548\u3002\u5220\u9664\u7684\u5217\u4ecd\u7136\u7269\u7406\u4e0a\u5b58\u5728\u4e8e\u8868\u4e2d\uff0c\u4f46\u89e3\u6790\u5668\u4f1a\u5ffd\u7565\u5b83\uff0c\u56e0\u6b64\u4e0d\u80fd\u901a\u8fc7 SQL \u8bbf\u95ee\u5b83\u3002 att_constraint_type char(1) p = \u4e3b\u952e\u7ea6\u675fn=\u65e0\u7ea6\u675f att_is_unsigned tinyint(1) \u662f\u5426\u672a\u7f72\u540d att_is_auto_increment tinyint(1) \u662f\u5426\u81ea\u589e att_comment varchar(1024) \u6ce8\u91ca att_is_hidden tinyint(1) \u662f\u5426\u9690\u85cf attr_has_update tinyint(1) \u6b64\u5217\u542b\u6709\u66f4\u65b0\u8868\u8fbe\u5f0f attr_update varchar(1024) \u66f4\u65b0\u8868\u8fbe\u5f0f attr_is_clusterby tinyint(1) \u6b64\u5217\u662f\u5426\u4f5c\u4e3a cluster by \u5173\u952e\u5b57\u6765\u5efa\u8868 attr_seqnum SMALLINT UNSIGNED(0) \u6bcf\u4e2a\u5217\u7684\u5e8f\u5217\u53f7 attr_enum varchar(65535) \u82e5\u8fd9\u4e2a\u5217\u7684\u7c7b\u578b\u4e3a ENUM\uff0c\u5219\u8868\u793a\u8be5\u5217\u4ee3\u8868\u7684 ENUM \u7c7b\u578b\u7684\u503c\uff0c\u5426\u5219\u4e3a\u7a7a"},{"location":"MatrixOne/Reference/System-tables/#mo_tables","title":"mo_tables
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 rel_id bigint unsigned \u4e3b\u952e\uff0c\u8868 ID relname varchar(100) \u8868\u3001\u7d22\u5f15\u3001\u89c6\u56fe\u7b49\u7684\u540d\u79f0 reldatabase varchar(100) \u5305\u542b\u6b64\u5173\u7cfb\u7684\u6570\u636e\u5e93\uff0c\u53c2\u8003 mo_database.datname reldatabase_id bigint unsigned \u5305\u542b\u6b64\u5173\u7cfb\u7684\u6570\u636e\u5e93 ID\uff0c\u53c2\u8003 mo_database.datid relpersistence varchar(100) p = \u6c38\u4e45\u8868 t = \u4e34\u65f6\u8868 relkind varchar(100) r = \u666e\u901a\u8868 e = \u5916\u90e8\u8868 i = \u7d22\u5f15 S = \u5e8f\u5217 v = \u89c6\u56fe m = \u7269\u5316\u89c6\u56fe rel_comment varchar(100) \u8868\u6ce8\u91ca rel_createsql varchar(100) \u521b\u5efa\u8868 SQL \u8bed\u53e5 created_time timestamp \u521b\u5efa\u65f6\u95f4 creator int unsigned \u521b\u5efa\u8005 ID owner int unsigned \u521b\u5efa\u8005\u7684\u9ed8\u8ba4\u89d2\u8272 ID account_id int unsigned \u79df\u6237 id partitioned blob \u6309\u8bed\u53e5\u5206\u533a partition_info blob \u5206\u533a\u4fe1\u606f viewdef blob \u89c6\u56fe\u5b9a\u4e49\u8bed\u53e5 constraint varchar(5000) \u4e0e\u8868\u76f8\u5173\u7684\u7ea6\u675f rel_version INT UNSIGNED(0) \u4e3b\u952e\uff0c\u8868\u7684\u7248\u672c\u53f7 catalog_version INT UNSIGNED(0) \u7cfb\u7edf\u8868\u7684\u7248\u672c\u53f7"},{"location":"MatrixOne/Reference/System-tables/#system_metrics","title":"system_metrics
\u6570\u636e\u5e93","text":"system_metrics
\u6536\u96c6 SQL \u8bed\u53e5\u3001CPU \u548c\u5185\u5b58\u8d44\u6e90\u4f7f\u7528\u7684\u72b6\u6001\u548c\u7edf\u8ba1\u4fe1\u606f\u3002
metrics
\u8868\u4e00\u4e9b\u76f8\u540c\u7684\u5217\u7c7b\u578b\uff0c\u8fd9\u4e9b\u8868\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
collecttime\uff1a\u6536\u96c6\u65f6\u95f4\u3002
value\uff1a\u91c7\u96c6 metrics
\u7684\u503c\u3002
node\uff1a\u8868\u793a MatrixOne \u8282\u70b9\u7684 uuid\u3002
role\uff1aMatrixOne \u8282\u70b9\u89d2\u8272\uff0c\u5305\u62ec CN\u3001TN \u548c Log\u3002
account\uff1a\u9ed8\u8ba4\u4e3a\u201csys\u201d\u79df\u6237\uff0c\u5373\u89e6\u53d1 SQL \u8bf7\u6c42\u7684\u8d26\u6237\u3002
type\uff1aSQL \u7c7b\u578b\uff0c\u53ef\u4ee5\u662f select
\uff0cinsert
\uff0cupdate
\uff0cdelete
\uff0cother
\u7c7b\u578b\u3002
metric
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 metric_name VARCHAR(128) \u6307\u6807\u540d\u79f0\uff0c\u4f8b\u5982\uff1asql_statement_total\uff0cserver_connections\uff0cprocess_cpu_percent\uff0csys_memory_used \u7b49 collecttime DATETIME \u6307\u6807\u6570\u636e\u6536\u96c6\u65f6\u95f4 value DOUBLE \u6307\u6807\u503c node VARCHAR(36) MatrixOne \u8282\u70b9 uuid role VARCHAR(32) MatrixOne \u8282\u70b9\u89d2\u8272 account VARCHAR(128) \u79df\u6237\u540d\u79f0\uff0c\u9ed8\u8ba4 sys
type VARCHAR(32) SQL \u7c7b\u578b\uff0c\u4f8b\u5982\uff1aINSERT\uff0cSELECT\uff0cUPDATE \u4ee5\u4e0b\u8868\u4e3a metric
\u8868\u7684\u89c6\u56fe\uff1a
sql_statement_total
\u8868\uff1a\u6267\u884c SQL \u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002sql_statement_errors
\u8868\uff1a\u6267\u884c\u9519\u8bef\u7684 SQL \u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002sql_transaction_total
\u8868\uff1a\u4e8b\u52a1\u6027 SQL \u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002sql_transaction_errors
\u8868\uff1a\u9519\u8bef\u6267\u884c\u7684\u4e8b\u52a1\u6027\u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002server_connections
\u8868\uff1a\u670d\u52a1\u5668\u8fde\u63a5\u6570\u3002server_storage_usage
\uff1a\u670d\u52a1\u5668\u5b58\u50a8\u4f7f\u7528\u60c5\u51b5\u3002process_cpu_percent
\u8868\uff1aCPU \u8fdb\u7a0b\u7e41\u5fd9\u767e\u5206\u6bd4\u3002process_resident_memory_bytes
\u8868\uff1a\u9a7b\u7559\u5185\u5b58\u91cf\uff0c\u5355\u4f4d\u4e3a\u5b57\u8282\u3002process_open_fds
\u8868\uff1a\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6570\u91cf\u3002sys_cpu_seconds_total
\u8868\uff1a\u7cfb\u7edf CPU \u65f6\u95f4\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7531\u6838\u6570\u6807\u51c6\u5316\u3002sys_cpu_combined_percent
\u8868\uff1a\u7cfb\u7edf CPU \u7e41\u5fd9\u767e\u5206\u6bd4\uff0c\u6240\u6709\u903b\u8f91\u6838\u7684\u5e73\u5747\u503c\u3002sys_memory_used
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u5df2\u4f7f\u7528\u7684\u7cfb\u7edf\u5185\u5b58\u3002sys_memory_available
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u7684\u53ef\u7528\u7cfb\u7edf\u5185\u5b58\u3002sys_disk_read_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u8bfb\u53d6\u7cfb\u7edf\u76d8\u3002sys_disk_write_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u5199\u5165\u7cfb\u7edf\u76d8\u3002sys_net_recv_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u63a5\u6536\u7684\u7cfb\u7edf\u7f51\u7edc\u3002sys_net_sent_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u53d1\u9001\u7684\u7cfb\u7edf\u7f51\u7edc\u3002system
\u6570\u636e\u5e93","text":"System
\u6570\u636e\u5e93\u5b58\u50a8 MatrixOne \u5386\u53f2 SQL \u8bed\u53e5\u3001\u7cfb\u7edf\u65e5\u5fd7\u3001\u9519\u8bef\u4fe1\u606f\u3002
statement_info
\u8868","text":"statement_info
\u8868\u8bb0\u5f55\u7528\u6237\u548c\u7cfb\u7edf\u7684 SQL \u8bed\u53e5\u548c\u8be6\u7ec6\u4fe1\u606f\u3002
rawlog
\u8868","text":"rawlog
\u8868\u8bb0\u5f55\u4e86\u975e\u5e38\u8be6\u7ec6\u7684\u7cfb\u7edf\u65e5\u5fd7\u3002
\u5176\u4ed6 3 \u4e2a\u8868\uff08log_info
\u3001span_info
\u548c error_info
\uff09\u662f statement_info
\u548c rawlog
\u8868\u7684\u89c6\u56fe\u3002
information_schema
\u6570\u636e\u5e93","text":"Information Schema \u63d0\u4f9b\u4e86\u4e00\u79cd ANSI \u6807\u51c6\u65b9\u5f0f\uff0c\u7528\u4e8e\u67e5\u770b\u7cfb\u7edf\u7684\u5143\u6570\u636e\u3002MatrixOne \u9664\u4e86\u4e3a MySQL \u517c\u5bb9\u6027\u800c\u5305\u542b\u7684\u8868\u4e4b\u5916\uff0c\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u81ea\u5b9a\u4e49\u7684 information_schema
\u8868\u3002
\u8bb8\u591a INFORMATION_SCHEMA
\u8868\u90fd\u6709\u76f8\u5e94\u7684 SHOW
\u547d\u4ee4\u3002\u67e5\u8be2 INFORMATION_SCHEMA
\u53ef\u4ee5\u5728\u8868\u4e4b\u95f4\u8fdb\u884c\u8fde\u63a5\u3002
SHOW PROCESSLIST
\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002 USER_PRIVILEGES \u5217\u4e3e\u4e86\u4e0e\u5f53\u524d\u7528\u6237\u5173\u8054\u7684\u6743\u9650\u3002 SCHEMATA \u63d0\u4f9b\u4e86\u4e0e\u6267\u884c SHOW DATABASES
\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002 CHARACTER_SETS \u63d0\u4f9b\u4e86\u670d\u52a1\u5668\u652f\u6301\u7684\u5b57\u7b26\u96c6\u5217\u8868\u3002 TRIGGERS \u63d0\u4f9b\u4e86\u4e0e\u6267\u884c SHOW TRIGGERS
\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002 TABLES \u63d0\u4f9b\u4e86\u5f53\u524d\u7528\u6237\u53ef\u4ee5\u67e5\u770b\u7684\u8868\u5217\u8868\u3002\u7c7b\u4f3c\u4e8e\u6267\u884cSHOW TABLES
\u3002 PARTITIONS \u63d0\u4f9b\u4e86\u8868\u7684\u5206\u533a\u4fe1\u606f\u3002 VIEWS \u63d0\u4f9b\u6709\u5173\u6570\u636e\u5e93\u4e2d\u89c6\u56fe\u7684\u4fe1\u606f\u3002 ENGINES \u63d0\u4f9b\u4e86\u652f\u6301\u7684\u5b58\u50a8\u5f15\u64ce\u5217\u8868\u3002 ROUTINES \u63d0\u4f9b\u6709\u5173\u5b58\u50a8\u5b58\u50a8\u8fc7\u7a0b\u7684\u4e00\u4e9b\u4fe1\u606f\u3002 PARAMETERS \u8868\u63d0\u4f9b\u4e86\u5b58\u50a8\u8fc7\u7a0b\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u7684\u4fe1\u606f\u3002 KEYWORDS \u63d0\u4f9b\u6709\u5173\u6570\u636e\u5e93\u4e2d\u5173\u952e\u5b57\u4fe1\u606f\uff0c\u8be6\u60c5\u53c2\u89c1\u5173\u952e\u5b57\u3002"},{"location":"MatrixOne/Reference/System-tables/#character_sets","title":"CHARACTER_SETS
\u8868","text":"CHARACTER_SETS
\u8868\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
CHARACTER_SET_NAME
\uff1a\u5b57\u7b26\u96c6\u7684\u540d\u79f0\u3002DEFAULT_COLLATE_NAME
\uff1a\u5b57\u7b26\u96c6\u7684\u9ed8\u8ba4\u6392\u5e8f\u89c4\u5219\u540d\u79f0\u3002DESCRIPTION
\uff1a\u5b57\u7b26\u96c6\u7684\u63cf\u8ff0\u3002MAXLEN
\uff1a\u5728\u6b64\u5b57\u7b26\u96c6\u4e2d\u5b58\u50a8\u5b57\u7b26\u6240\u9700\u7684\u6700\u5927\u957f\u5ea6\u3002COLUMNS
\u89c6\u56fe","text":"COLUMNS
\u89c6\u56fe\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
TABLE_CATALOG
\uff1a\u542b\u6709\u8be5\u5217\u7684\u8868\u6240\u5c5e\u7684\u76ee\u5f55\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a def
\u3002TABLE_SCHEMA
\uff1a\u542b\u6709\u5217\u7684\u8868\u6240\u5728\u7684\u6a21\u5f0f\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u5305\u542b\u5217\u7684\u8868\u7684\u540d\u79f0\u3002COLUMN_NAME
\uff1a\u5217\u7684\u540d\u79f0\u3002ORDINAL_POSITION
\uff1a\u8868\u4e2d\u5217\u7684\u4f4d\u7f6e\u3002COLUMN_DEFAULT
\uff1a\u5217\u7684\u9ed8\u8ba4\u503c\u3002\u5982\u679c\u663e\u5f0f\u9ed8\u8ba4\u503c\u4e3a NULL
\uff0c\u6216\u8005\u5982\u679c\u5217\u5b9a\u4e49\u4e0d\u5305\u542b default
\u5b50\u53e5\uff0c\u5219\u6b64\u503c\u4e3a NULL
\u3002IS_NULLABLE
\uff1a\u5217\u662f\u5426\u53ef\u4ee5\u4e3a\u7a7a\u3002\u5982\u679c\u8be5\u5217\u53ef\u4ee5\u5b58\u50a8\u7a7a\u503c\uff0c\u5219\u8be5\u503c\u4e3a YES
\uff1b\u5426\u5219\u4e3a NO
\u3002DATA_TYPE
\uff1a\u5217\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u3002CHARACTER_MAXIMUM_LENGTH
\uff1a\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5217\uff0c\u5b57\u7b26\u7684\u6700\u5927\u957f\u5ea6\u3002CHARACTER_OCTET_LENGTH
\uff1a\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5217\uff0c\u6700\u5927\u957f\u5ea6\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\u3002NUMERIC_PRECISION
\uff1a\u6570\u5b57\u7c7b\u578b\u5217\u7684\u6570\u5b57\u7cbe\u5ea6\u3002NUMERIC_SCALE
\uff1a\u6570\u5b57\u7c7b\u578b\u5217\u7684\u6570\u5b57\u6bd4\u4f8b\u3002DATETIME_PRECISION
\uff1a\u5bf9\u4e8e\u65f6\u95f4\u7c7b\u578b\u5217\uff0c\u5c0f\u6570\u79d2\u7cbe\u5ea6\u3002CHARACTER_SET_NAME
\uff1a\u5b57\u7b26\u4e32\u5217\u7684\u5b57\u7b26\u96c6\u540d\u79f0\u3002COLLATION_NAME
\uff1a\u5b57\u7b26\u4e32\u5217\u7684\u6392\u5e8f\u89c4\u5219\u7684\u540d\u79f0\u3002COLUMN_TYPE
\uff1a\u5217\u7c7b\u578b\u3002COLUMN_KEY
\uff1a\u8be5\u5217\u662f\u5426\u88ab\u7d22\u5f15\u3002\u8be5\u5b57\u6bb5\u53ef\u80fd\u5177\u6709\u4ee5\u4e0b\u503c\uff1aEmpty
\uff1a\u6b64\u5217\u672a\u7f16\u5165\u7d22\u5f15\uff0c\u6216\u8005\u6b64\u5217\u5df2\u7f16\u5165\u7d22\u5f15\u5e76\u4e14\u662f\u591a\u5217\u975e\u552f\u4e00\u7d22\u5f15\u4e2d\u7684\u7b2c\u4e8c\u5217\u3002PRI
\uff1a\u6b64\u5217\u662f\u4e3b\u952e\u6216\u591a\u4e2a\u4e3b\u952e\u4e4b\u4e00\u3002UNI
\uff1a\u6b64\u5217\u662f\u552f\u4e00\u7d22\u5f15\u7684\u7b2c\u4e00\u5217\u3002MUL
\uff1a\u8be5\u5217\u662f\u975e\u552f\u4e00\u7d22\u5f15\u7684\u7b2c\u4e00\u5217\uff0c\u5176\u4e2d\u5141\u8bb8\u7ed9\u5b9a\u503c\u591a\u6b21\u51fa\u73b0\u3002EXTRA
\uff1a\u7ed9\u5b9a\u5217\u7684\u4efb\u4f55\u9644\u52a0\u4fe1\u606f\u3002PRIVILEGES
\uff1a\u5f53\u524d\u7528\u6237\u6240\u62e5\u6709\u7684\u5bf9\u8be5\u5217\u7684\u6743\u9650\u3002COLUMN_COMMENT
\uff1a\u5217\u5b9a\u4e49\u4e2d\u5305\u542b\u7684\u63cf\u8ff0\u3002GENERATION_EXPRESSION
\uff1a\u5bf9\u4e8e\u751f\u6210\u7684\u5217\uff0c\u6b64\u503c\u663e\u793a\u7528\u4e8e\u8ba1\u7b97\u5217\u503c\u7684\u8868\u8fbe\u5f0f\u3002\u5bf9\u4e8e\u975e\u751f\u6210\u5217\uff0c\u8be5\u503c\u4e3a\u7a7a\u3002SRS_ID
\uff1a\u6b64\u503c\u9002\u7528\u4e8e\u7a7a\u95f4\u5217\u3002\u5b83\u5305\u542b\u5217 SRID
\u503c\uff0c\u8be5\u503c\u8868\u793a\u4e3a\u5b58\u50a8\u5728\u8be5\u5217\u4e2d\u7684\u503c\u63d0\u4f9b\u4e00\u4e2a\u7a7a\u95f4\u53c2\u8003\u7cfb\u7edf\u3002ENGINES
\u8868","text":"ENGINES
\u8868\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
ENGINE
\uff1a\u5b58\u50a8\u5f15\u64ce\u7684\u540d\u79f0\u3002SUPPORT
\uff1a\u670d\u52a1\u5668\u5bf9\u5b58\u50a8\u5f15\u64ce\u7684\u652f\u6301\u7ea7\u522b\u3002COMMENT
\uff1a\u5bf9\u5b58\u50a8\u5f15\u64ce\u7684\u7b80\u77ed\u8bc4\u8bba\u3002TRANSACTIONS
\uff1a\u5b58\u50a8\u5f15\u64ce\u662f\u5426\u652f\u6301\u4e8b\u52a1\u3002XA
\uff1a\u5b58\u50a8\u5f15\u64ce\u662f\u5426\u652f\u6301 XA \u4e8b\u52a1\u3002SAVEPOINTS
\uff1a\u5b58\u50a8\u5f15\u64ce\u662f\u5426\u652f\u6301 savepoints
\u3002PARTITIONS
\u89c6\u56fe","text":"PARTITIONS
\u89c6\u56fe\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
TABLE_CATALOG
\uff1a\u542b\u6709\u8be5\u5217\u7684\u8868\u6240\u5c5e\u7684\u76ee\u5f55\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a def\u3002TABLE_SCHEMA
\uff1a\u542b\u6709\u5217\u7684\u8868\u6240\u5728\u7684\u6a21\u5f0f\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u5305\u542b\u5217\u7684\u8868\u7684\u540d\u79f0\u3002PARTITION_NAME
\uff1a\u5206\u533a\u540d\u79f0\u3002SUBPARTITION_NAME
\uff1a\u5982\u679c PARTITIONS
\u8868\u4e2d\u7684\u884c\u8868\u793a\u4e00\u4e2a\u5b50\u5206\u533a\uff0c\u5219\u4e3a\u8be5\u5b50\u5206\u533a\u7684\u540d\u79f0\uff1b\u5426\u5219\u4e3a\u7a7a\u3002PARTITION_ORDINAL_POSITION
\uff1a\u6240\u6709\u5206\u533a\u6309\u7167\u5b83\u4eec\u88ab\u5b9a\u4e49\u7684\u987a\u5e8f\u8fdb\u884c\u7d22\u5f15\uff0c\u5176\u4e2d 1 \u8868\u793a\u5206\u914d\u7ed9\u7b2c\u4e00\u4e2a\u5206\u533a\u7684\u7f16\u53f7\u3002\u968f\u7740\u5206\u533a\u7684\u589e\u52a0\u3001\u5220\u9664\u548c\u91cd\u65b0\u7ec4\u7ec7\uff0c\u7d22\u5f15\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\uff1b\u8be5\u5217\u4e2d\u663e\u793a\u7684\u7f16\u53f7\u53cd\u6620\u4e86\u5f53\u524d\u7684\u987a\u5e8f\uff0c\u8003\u8651\u4e86\u4efb\u4f55\u7d22\u5f15\u53d8\u5316\u3002SUBPARTITION_ORDINAL_POSITION
\uff1a\u5728\u7ed9\u5b9a\u5206\u533a\u5185\uff0c\u5b50\u5206\u533a\u7684\u7d22\u5f15\u548c\u91cd\u65b0\u7d22\u5f15\u65b9\u5f0f\u4e0e\u8868\u5185\u5206\u533a\u7684\u65b9\u5f0f\u76f8\u540c\u3002PARTITION_METHOD
\uff1a\u53d6\u503c\u4e4b\u4e00\u4e3a RANGE
\u3001LIST
\u3001HASH
\u3001LINEAR HASH
\u3001KEY
\u6216 LINEAR KEY
\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\u3002SUBPARTITION_METHOD
\uff1a\u53d6\u503c\u4e4b\u4e00\u4e3a HASH
\u3001LINEAR HASH
\u3001KEY
\u6216 LINEAR KEY
\u3002PARTITION_EXPRESSION
\uff1a\u5728\u521b\u5efa\u8868\u7684 CREATE TABLE
\u6216 ALTER TABLE
\u8bed\u53e5\u4e2d\u4f7f\u7528\u7684\u5206\u533a\u51fd\u6570\u8868\u8fbe\u5f0f\uff0c\u7528\u4e8e\u521b\u5efa\u8868\u7684\u5f53\u524d\u5206\u533a\u65b9\u6848\u3002SUBPARTITION_EXPRESSION
\uff1a\u8fd9\u4e0e PARTITION_EXPRESSION
\u7c7b\u4f3c\uff0c\u7528\u4e8e\u5b9a\u4e49\u8868\u7684\u5b50\u5206\u533a\u65b9\u5f0f\uff0c\u5982\u679c\u8868\u6ca1\u6709\u5b50\u5206\u533a\uff0c\u5219\u8be5\u5217\u4e3a\u7a7a\u3002PARTITION_DESCRIPTION
\uff1a\u6b64\u5217\u9002\u7528\u4e8e RANGE
\u548c LIST
\u5206\u533a\u3002\u5bf9\u4e8e RANGE
\u5206\u533a\uff0c\u5b83\u5305\u542b\u5728\u5206\u533a\u7684 VALUES LESS THAN
\u5b50\u53e5\u4e2d\u8bbe\u7f6e\u7684\u503c\uff0c\u53ef\u4ee5\u662f\u6574\u6570\u6216 MAXVALUE
\u3002\u5bf9\u4e8e LIST
\u5206\u533a\uff0c\u6b64\u5217\u5305\u542b\u5728\u5206\u533a\u7684 VALUES IN
\u5b50\u53e5\u4e2d\u5b9a\u4e49\u7684\u503c\uff0c\u8fd9\u662f\u4e00\u7ec4\u9017\u53f7\u5206\u9694\u7684\u6574\u6570\u503c\u3002\u5bf9\u4e8e PARTITION_METHOD
\u4e0d\u662f RANGE
\u6216 LIST
\u7684\u5206\u533a\uff0c\u6b64\u5217\u59cb\u7ec8\u4e3a\u7a7a\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\u3002TABLE_ROWS
\uff1a\u5206\u533a\u4e2d\u7684\u8868\u884c\u6570\u3002AVG_ROW_LENGTH
\uff1a\u5b58\u50a8\u5728\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u4e2d\u7684\u884c\u7684\u5e73\u5747\u957f\u5ea6\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3002\u8fd9\u4e0e DATA_LENGTH
\u9664\u4ee5 TABLE_ROWS
\u5f97\u5230\u7684\u7ed3\u679c\u76f8\u540c\u3002DATA_LENGTH
\uff1a\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u4e2d\u5b58\u50a8\u7684\u6240\u6709\u884c\u7684\u603b\u957f\u5ea6\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff1b\u5373\u5b58\u50a8\u5728\u5206\u533a\u6216\u5b50\u5206\u533a\u4e2d\u7684\u5b57\u8282\u603b\u6570\u3002MAX_DATA_LENGTH
: \u5206\u533a\u4e2d\u6570\u636e\u7684\u6700\u5927\u957f\u5ea6INDEX_LENGTH
\uff1a\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u7684\u7d22\u5f15\u6587\u4ef6\u957f\u5ea6\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3002DATA_FREE
\uff1a\u5206\u914d\u7ed9\u5206\u533a\u6216\u5b50\u5206\u533a\u4f46\u672a\u4f7f\u7528\u7684\u5b57\u8282\u6570\u3002CREATE_TIME
\uff1a\u5206\u533a\u6216\u5b50\u5206\u533a\u521b\u5efa\u7684\u65f6\u95f4\u3002UPDATE_TIME
\uff1a\u5206\u533a\u6216\u5b50\u5206\u533a\u4e0a\u6b21\u4fee\u6539\u7684\u65f6\u95f4\u3002CHECK_TIME
\uff1a\u5c5e\u4e8e\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u7684\u8868\u6700\u540e\u4e00\u6b21\u68c0\u67e5\u7684\u65f6\u95f4\u3002CHECKSUM
\uff1a\u6821\u9a8c\u548c\u503c\uff0c\u5982\u679c\u6709\u7684\u8bdd\uff1b\u5426\u5219\u4e3a\u7a7a\u3002PARTITION_COMMENT
\uff1a\u5982\u679c\u5206\u533a\u6709\u6ce8\u91ca\uff0c\u5219\u4e3a\u6ce8\u91ca\u7684\u6587\u672c\u3002\u5982\u679c\u6ca1\u6709\uff0c\u5219\u8be5\u503c\u4e3a\u7a7a\u3002\u5206\u533a\u6ce8\u91ca\u7684\u6700\u5927\u957f\u5ea6\u5b9a\u4e49\u4e3a 1024 \u4e2a\u5b57\u7b26\uff0cPARTITION_COMMENT
\u5217\u7684\u663e\u793a\u5bbd\u5ea6\u4e5f\u4e3a 1024 \u4e2a\u5b57\u7b26\uff0c\u4ee5\u4e0e\u6b64\u9650\u5236\u76f8\u7b26\u3002NODEGROUP
\uff1a\u8be5\u5206\u533a\u6240\u5c5e\u7684\u8282\u70b9\u7ec4\u3002TABLESPACE_NAME
\uff1a\u8be5\u5206\u533a\u6240\u5c5e\u7684\u8868\u7a7a\u95f4\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a DEFAULT
\u3002PROCESSLIST
\u89c6\u56fe","text":"PROCESSLIST
\u89c6\u56fe\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
NODE_ID
\uff1aCN \u8282\u70b9 UUIDCONN_ID
\uff1a\u7528\u6237\u8fde\u63a5\u7684 IDSESSION_ID
\uff1a\u4f1a\u8bdd\u7684 IDACCOUNT
\uff1a\u79df\u6237\u540dUSER
\uff1a\u7528\u6237\u540dHOST
\uff1aCN \u8282\u70b9\u7684\u76d1\u542c\u5730\u5740DB
\uff1a\u5f53\u524d\u8fde\u63a5\u7684\u6570\u636e\u5e93SESSION_START
\uff1asession \u521b\u5efa\u65f6\u95f4COMMAND
\uff1a\u8bed\u53e5\u7684 MySQL \u534f\u8bae CommandINFO
\uff1a\u6b63\u5728\u5904\u7406\u7684 SQL \u8bed\u53e5TXN_ID
\uff1a\u4e8b\u52a1 IDSTATEMENT_ID
\uff1a\u8bed\u53e5 IDSTATEMENT_TYPE
\uff1a\u8bed\u53e5\u7c7b\u578b\uff0cSelect/Update/Delete \u7b49QUERY_TYPR
\uff1a\u67e5\u8be2\u7c7b\u578b\uff0cDQL/DDL/DML \u7b49SQL_SOURCE_TYPE
\uff1aSQL \u8bed\u53e5\u6e90\u7c7b\u578b\uff0c\u5916\u90e8\u6216\u8005\u5185\u90e8 SQL\uff1aexternal_sql/internal_sqlQUERY_START
\uff1a\u67e5\u8be2\u5f00\u59cb\u65f6\u95f4CLIENT_HOST
\uff1a\u5ba2\u6237\u7aef\u5730\u5740SCHEMATA
\u89c6\u56fe","text":"SCHEMATA
\u89c6\u56fe\u63d0\u4f9b\u6709\u5173\u6570\u636e\u5e93\u7684\u4fe1\u606f\uff0c\u6570\u636e\u7b49\u540c\u4e8e SHOW DATABASES
\u8bed\u53e5\u7684\u7ed3\u679c\u3002SCHEMATA
\u89c6\u56fe\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
CATALOG_NAME
\uff1a\u6570\u636e\u5e93\u6240\u5c5e\u7684\u76ee\u5f55\u3002SCHEMA_NAME
\uff1a\u6570\u636e\u5e93\u540d\u79f0\u3002DEFAULT_CHARACTER_SET_NAME
\uff1a\u6570\u636e\u5e93\u7684\u9ed8\u8ba4\u5b57\u7b26\u96c6\u3002DEFAULT_COLLATION_NAME
\uff1a\u6570\u636e\u5e93\u7684\u9ed8\u8ba4\u6392\u5e8f\u89c4\u5219\u3002SQL_PATH
\uff1a\u6b64\u9879\u7684\u503c\u59cb\u7ec8\u4e3a NULL
\u3002DEFAULT_TABLE_ENCRYPTION
\uff1a\u5b9a\u4e49\u6570\u636e\u5e93\u548c\u901a\u7528\u8868\u7a7a\u95f4\u7684 default encryption \u8bbe\u7f6e\u3002TABLES
\u89c6\u56fe","text":"TABLES
\u89c6\u56fe\u4e2d\u5217\u7684\u63cf\u8ff0\u5982\u4e0b\uff1a
TABLE_CATALOG
\uff1a\u8868\u6240\u5c5e\u76ee\u5f55\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a def
\u3002TABLE_SCHEMA
\uff1a\u8868\u6240\u5c5e\u7684\u6a21\u5f0f\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u8868\u7684\u540d\u79f0\u3002TABLE_TYPE
\uff1a\u8868\u7684\u7c7b\u578b\u3002\u57fa\u672c\u8868\u7c7b\u578b\u4e3a BASE TABLE
\uff0c\u89c6\u56fe\u8868\u7c7b\u578b\u4e3a VIEW
\uff0cINFORMATION_SCHEMA
\u8868\u7c7b\u578b\u4e3a SYSTEM VIEW
\u3002ENGINE
\uff1a\u5b58\u50a8\u5f15\u64ce\u7684\u7c7b\u578b\u3002VERSION
\uff1a\u7248\u672c\u3002\u9ed8\u8ba4\u503c\u4e3a 10
\u3002ROW_FORMAT
\uff1a\u884c\u5b58\u50a8\u683c\u5f0f\u3002\u503c\u4e3a Fixed
\uff0cDynamic
\uff0cCompressed
\uff0cRedundant
\uff0cCompact
\u3002TABLE_ROWS
\uff1a\u7edf\u8ba1\u8868\u4e2d\u7684\u884c\u6570\u3002\u5bf9\u4e8e INFORMATION_SCHEMA
\u8868\uff0cTABLE_ROWS
\u4e3a NULL
\u3002AVG_ROW_LENGTH
\uff1a\u8868\u7684\u5e73\u5747\u884c\u957f\u5ea6\u3002AVG_ROW_LENGTH
= DATA_LENGTH
/ TABLE_ROWS
\u3002DATA_LENGTH
\uff1a\u6570\u636e\u957f\u5ea6\u3002DATA_LENGTH
= TABLE_ROWS
* \u5143\u7ec4\u4e2d\u5217\u7684\u5b58\u50a8\u957f\u5ea6\u4e4b\u548c\u3002MAX_DATA_LENGTH
\uff1a\u6700\u5927\u6570\u636e\u957f\u5ea6\u3002\u8be5\u503c\u5f53\u524d\u4e3a 0
\uff0c\u8868\u793a\u6570\u636e\u957f\u5ea6\u6ca1\u6709\u4e0a\u9650\u3002INDEX_LENGTH
\uff1a\u7d22\u5f15\u957f\u5ea6\u3002INDEX_LENGTH
= TABLE_ROWS
* \u7d22\u5f15\u5143\u7ec4\u4e2d\u5217\u7684\u957f\u5ea6\u603b\u548c\u3002DATA_FREE
\uff1a\u6570\u636e\u7247\u6bb5\u3002\u8be5\u503c\u5f53\u524d\u4e3a 0
\u3002AUTO_INCREMENT
\uff1a\u81ea\u589e\u4e3b\u952e\u7684\u5f53\u524d\u6b65\u957f\u3002CREATE_TIME
\uff1a\u521b\u5efa\u8868\u7684\u65f6\u95f4\u3002UPDATE_TIME
\uff1a\u8868\u66f4\u65b0\u7684\u65f6\u95f4\u3002CHECK_TIME
\uff1a\u68c0\u67e5\u8868\u7684\u65f6\u95f4\u3002TABLE_COLLATION
\uff1a\u8868\u4e2d\u5b57\u7b26\u4e32\u7684\u6392\u5e8f\u89c4\u5219\u3002CHECKSUM
\uff1a\u6821\u9a8c\u548c\u3002CREATE_OPTIONS
\uff1a\u521b\u5efa\u9009\u9879\u3002TABLE_COMMENT
\uff1a\u8868\u683c\u7684\u6ce8\u91ca\u548c\u6ce8\u91ca\u3002USER_PRIVILEGES
\u8868","text":"USER_PRIVILEGES
\u8868\u63d0\u4f9b\u4e86\u5173\u4e8e\u5168\u5c40\u6743\u9650\u7684\u4fe1\u606f\u3002
USER_PRIVILEGES
\u8868\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
GRANTEE
\uff1a\u6388\u6743\u7528\u6237\u540d\uff0c\u683c\u5f0f\u4e3a 'user_name'@'host_name'
\u3002TABLE_CATALOG
\uff1a\u8868\u6240\u5c5e\u7684\u76ee\u5f55\u7684\u540d\u79f0\u3002\u503c\u4e3a def
\u3002PRIVILEGE_TYPE
\uff1a\u8981\u6388\u4e88\u7684\u6743\u9650\u7c7b\u578b\u3002\u6bcf\u884c\u53ea\u663e\u793a\u4e00\u79cd\u6743\u9650\u7c7b\u578b\u3002IS_GRANTABLE
\uff1a\u5982\u679c\u4f60\u6709 GRANT OPTION
\u6743\u9650\uff0c\u8be5\u503c\u4e3a YES
\uff0c\u6ca1\u6709 GRANT OPTION
\u6743\u9650\uff0c\u8be5\u503c\u4e3a NO
\u3002VIEWS
\u89c6\u56fe","text":"TABLE_CATALOG
\uff1a\u89c6\u56fe\u6240\u5c5e\u76ee\u5f55\u7684\u540d\u79f0\u3002\u503c\u4e3a def
\u3002TABLE_SCHEMA
\uff1a\u89c6\u56fe\u6240\u5c5e\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u89c6\u56fe\u7684\u540d\u79f0\u3002VIEW_DEFINITION
\uff1a\u63d0\u4f9b\u89c6\u56fe\u5b9a\u4e49\u7684 SELECT
\u8bed\u53e5\u3002\u5305\u542b\u4e86\u5728 SHOW Create VIEW
\u751f\u6210\u7684\u521b\u5efa\u8868\u5217\u4e2d\u770b\u5230\u7684\u5927\u90e8\u5206\u5185\u5bb9\u3002CHECK_OPTION
\uff1aCHECK_OPTION
\u5c5e\u6027\u7684\u503c\u3002\u503c\u4e3a NONE
\u3001CASCADE
\u6216 LOCAL
\u3002IS_UPDATABLE
\uff1a\u5728 CREATE VIEW
\u65f6\u8bbe\u7f6e\u4e00\u4e2a\u540d\u4e3a\u89c6\u56fe\u53ef\u66f4\u65b0\u6027\u6807\u5fd7\u7684\u6807\u5fd7\uff0c\u5982\u679c UPDATE \u548c DELETE\uff08\u4ee5\u53ca\u7c7b\u4f3c\u7684\u64cd\u4f5c\uff09\u5bf9\u89c6\u56fe\u5408\u6cd5\uff0c\u5219\u6807\u5fd7\u8bbe\u7f6e\u4e3a YES\uff08true\uff09
\u3002\u5426\u5219\uff0c\u6807\u5fd7\u8bbe\u7f6e\u4e3a NO\uff08false\uff09
\u3002DEFINER
\uff1a\u521b\u5efa\u89c6\u56fe\u7684\u7528\u6237\u7684\u5e10\u6237\uff0c\u683c\u5f0f\u4e3a username@hostname
\u3002SECURITY_TYPE
\uff1a\u89c6\u56fe SQL SECURITY
\u7279\u6027\u3002\u503c\u4e3a DEFINER
\u6216 INVOKER
\u3002CHARACTER_SET_CLIENT
\uff1a\u521b\u5efa\u89c6\u56fe\u65f6 character_set_client
\u7cfb\u7edf\u53d8\u91cf\u7684\u4f1a\u8bdd\u503c\u3002COLLATION_CONNECTION
\uff1a\u521b\u5efa\u89c6\u56fe\u65f6\uff0ccollation_connection
\u7cfb\u7edf\u53d8\u91cf\u7684\u4f1a\u8bdd\u503c\u3002INDEX_COMMENT
\uff1a\u521b\u5efa\u7d22\u5f15\u65f6\u4e3a\u5177\u6709 comment \u5c5e\u6027\u7684\u7d22\u5f15\u63d0\u4f9b\u7684\u4efb\u4f55\u6ce8\u91ca\u3002IS_VISIBLE
\uff1a\u7d22\u5f15\u5bf9\u4f18\u5316\u5668\u662f\u5426\u53ef\u89c1\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49 EXPRESSION
\uff1a\u8868\u793a\u7d22\u5f15\u4e2d\u7684\u8868\u8fbe\u5f0f\u6216\u51fd\u6570\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49STATISTICS
\u89c6\u56fe","text":"\u83b7\u53d6\u6709\u5173\u6570\u636e\u5e93\u8868\u7d22\u5f15\u548c\u7edf\u8ba1\u4fe1\u606f\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u68c0\u67e5\u7d22\u5f15\u662f\u5426\u552f\u4e00\uff0c\u4e86\u89e3\u7d22\u5f15\u4e2d\u7684\u5217\u987a\u5e8f\uff0c\u4ee5\u53ca\u4f30\u8ba1\u7d22\u5f15\u4e2d\u7684\u552f\u4e00\u503c\u6570\u91cf\u3002
TABLE_CATALOG
\uff1a\u8868\u7684\u76ee\u5f55\u540d\u79f0\uff08\u59cb\u7ec8\u4e3a 'def'\uff09\u3002TABLE_SCHEMA
\uff1a\u8868\u6240\u5c5e\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002TABLE_NAME
\uff1a\u8868\u7684\u540d\u79f0\u3002NON_UNIQUE
\uff1a\u6307\u793a\u7d22\u5f15\u662f\u5426\u5141\u8bb8\u91cd\u590d\u503c\u3002\u5982\u679c\u4e3a 0\uff0c\u5219\u7d22\u5f15\u662f\u552f\u4e00\u7d22\u5f15\u3002INDEX_SCHEMA
\uff1a\u7d22\u5f15\u6240\u5c5e\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002INDEX_NAME
\uff1a\u7d22\u5f15\u7684\u540d\u79f0\u3002SEQ_IN_INDEX
\uff1a\u5217\u5728\u7d22\u5f15\u4e2d\u7684\u4f4d\u7f6e\u3002COLUMN_NAME
\uff1a\u5217\u7684\u540d\u79f0\u3002COLLATION
\uff1a\u5217\u7684\u6392\u5e8f\u89c4\u5219\u3002CARDINALITY
\uff1a\u7d22\u5f15\u4e2d\u552f\u4e00\u503c\u7684\u6570\u91cf\u4f30\u8ba1\u3002SUB_PART
\uff1a\u7d22\u5f15\u90e8\u5206\u957f\u5ea6\u3002\u5bf9\u4e8e\u6574\u4e2a\u5217\uff0c\u8be5\u503c\u4e3a NULL\u3002PACKED
\uff1a\u6307\u793a\u662f\u5426\u4f7f\u7528\u538b\u7f29\u5b58\u50a8\u7684\u503c\u3002NULLABLE
\uff1a\u6307\u793a\u5217\u662f\u5426\u5141\u8bb8 NULL \u503c\u3002INDEX_TYPE
\uff1a\u7d22\u5f15\u7684\u7c7b\u578b\uff08\u5982 BTREE\u3001HASH \u7b49\uff09\u3002COMMENT
\uff1a\u7d22\u5f15\u7684\u6ce8\u91ca\u4fe1\u606f\u3002INDEX_COMMENT
\uff1a\u521b\u5efa\u7d22\u5f15\u65f6\u4e3a\u5177\u6709 comment \u5c5e\u6027\u7684\u7d22\u5f15\u63d0\u4f9b\u7684\u4efb\u4f55\u6ce8\u91ca\u3002IS_VISIBLE
\uff1a\u7d22\u5f15\u5bf9\u4f18\u5316\u5668\u662f\u5426\u53ef\u89c1\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49 EXPRESSION
\uff1a\u8868\u793a\u7d22\u5f15\u4e2d\u7684\u8868\u8fbe\u5f0f\u6216\u51fd\u6570\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49mysql
\u6570\u636e\u5e93","text":""},{"location":"MatrixOne/Reference/System-tables/#_1","title":"\u6388\u6743\u7cfb\u7edf\u8868","text":"\u6388\u6743\u7cfb\u7edf\u8868\u5305\u542b\u4e86\u5173\u4e8e\u7528\u6237\u5e10\u6237\u53ca\u5176\u6743\u9650\u4fe1\u606f\uff1a
user
\u7528\u6237\u5e10\u6237\u3001\u5168\u5c40\u6743\u9650\u548c\u5176\u4ed6\u975e\u6743\u9650\u5217\u3002
db
\uff1a\u6570\u636e\u5e93\u7ea7\u6743\u9650\u3002
tables_priv
\uff1a\u8868\u7ea7\u6743\u9650\u3002
columns_priv
\uff1a\u5217\u7ea7\u6743\u9650\u3002
procs_priv
\uff1a\u5b58\u50a8\u8fc7\u7a0b\u548c\u5b58\u50a8\u51fd\u6570\u7684\u6743\u9650\u3002
\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd MatrixOne \u4e2d\u7684\u6743\u9650\u5206\u7c7b\u3002
MatrixOne \u7684\u8bbf\u95ee\u63a7\u5236\u6743\u9650\u5206\u4e3a\u7cfb\u7edf\u6743\u9650\u548c\u5bf9\u8c61\u6743\u9650\uff0c\u5728\u6388\u4e88\u89d2\u8272\u6743\u9650\u65f6\u53ef\u505a\u53c2\u8003\u3002
"},{"location":"MatrixOne/Reference/access-control-type/#_1","title":"\u7cfb\u7edf\u6743\u9650","text":"\u7cfb\u7edf\u6743\u9650\u4e3a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u7528\u6237\u540d\u4e3a root\uff09\u7684\u6743\u9650\uff0c\u5b83\u53ef\u4ee5\u521d\u59cb\u5316\u6240\u62e5\u6709\u7684\u6743\u9650\u3002\u96c6\u7fa4\u7ba1\u7406\u5458\u53ef\u4ee5\u521b\u5efa\u3001\u5220\u9664\u5176\u4ed6\u79df\u6237\uff0c\u5e76\u7ba1\u7406\u79df\u6237\uff1b\u96c6\u7fa4\u7ba1\u7406\u5458\u4e0d\u80fd\u7ba1\u7406\u5176\u4ed6\u79df\u6237\u4e0b\u7684\u5176\u4ed6\u8d44\u6e90\u3002
\u6743\u9650 \u542b\u4e49 CREATE ACCOUNT \u521b\u5efa\u79df\u6237\uff0c\u4ec5\u96c6\u7fa4\u7ba1\u7406\u5458\u62e5\u6709 DROP ACCOUNT \u5220\u9664\u79df\u6237\uff0c\u4ec5\u96c6\u7fa4\u7ba1\u7406\u5458\u62e5\u6709 ALTER ACCOUNT \u7ba1\u7406\u79df\u6237\u8d44\u6e90\uff0c\u4ec5\u96c6\u7fa4\u7ba1\u7406\u5458\u62e5\u6709"},{"location":"MatrixOne/Reference/access-control-type/#_2","title":"\u5bf9\u8c61\u6743\u9650","text":"\u5bf9\u8c61\u6743\u9650\u53ef\u4ee5\u6309\u7167\u8d4b\u6743\u7684\u5bf9\u8c61\u7ec6\u5206\u4e3a\u79df\u6237\u6743\u9650\u3001\u7528\u6237\u6743\u9650\u3001\u89d2\u8272\u6743\u9650\u3001\u6570\u636e\u5e93\u6743\u9650\u3001\u8868\u6743\u9650\u3001\u53d1\u5e03\u8ba2\u9605\u6743\u9650\u3002
"},{"location":"MatrixOne/Reference/access-control-type/#_3","title":"\u79df\u6237\u6743\u9650","text":"\u62e5\u6709\u79df\u6237\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 CREATE USER \u521b\u5efa\u7528\u6237 DROP USER \u5220\u9664\u7528\u6237 ALTER USER \u4fee\u6539\u7528\u6237 CREATE ROLE \u521b\u5efa\u89d2\u8272 DROP ROLE \u5220\u9664\u89d2\u8272 CREATE DATABASE \u521b\u5efa\u6570\u636e\u5e93 DROP DATABASE \u5220\u9664\u6570\u636e\u5e93 SHOW DATABASES \u67e5\u770b\u5f53\u524d\u79df\u6237\u4e0b\u6240\u6709\u6570\u636e\u5e93 CONNECT \u5141\u8bb8\u4f7f\u7528use [database | role]
\uff0c\u53ef\u6267\u884c\u4e0d\u6d89\u53ca\u5177\u4f53\u5bf9\u8c61\u7684 SELECT
MANAGE GRANTS \u6743\u9650\u7ba1\u7406\u3002\u5305\u62ec\u89d2\u8272\u6388\u6743\u3001\u89d2\u8272\u7ee7\u627f\u7684\u6743\u9650 ALL [PRIVILEGES] Account \u7684\u6240\u6709\u6743\u9650 OWNERSHIP Account \u7684\u6240\u6709\u6743\u9650\uff0c\u53ef\u4ee5\u901a\u8fc7 WITH GRANT OPTION
\u8bbe\u7f6e\u6743\u9650"},{"location":"MatrixOne/Reference/access-control-type/#_4","title":"\u7528\u6237\u6743\u9650","text":"\u62e5\u6709\u7528\u6237\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 Ownership \u7ba1\u7406\u7528\u6237\u6240\u6709\u7684\u6743\u9650\uff0c\u5305\u62ec\u4fee\u6539\u7528\u6237\u4fe1\u606f\u3001\u5bc6\u7801\u3001\u5220\u9664\u7528\u6237\uff0c\u4e14\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u6743\u9650\u4f20\u9012\u7ed9\u5176\u4ed6\u89d2\u8272\u3002"},{"location":"MatrixOne/Reference/access-control-type/#_5","title":"\u89d2\u8272\u6743\u9650","text":"\u62e5\u6709\u89d2\u8272\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 Ownership \u7ba1\u7406\u89d2\u8272\u7684\u6240\u6709\u6743\u9650\uff0c\u5305\u62ec\u4fee\u6539\u89d2\u8272\u540d\u79f0\u3001\u63cf\u8ff0\u3001\u5220\u9664\u89d2\u8272\uff0c\u4e14\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u6743\u9650\u4f20\u9012\u7ed9\u5176\u4ed6\u89d2\u8272\u3002"},{"location":"MatrixOne/Reference/access-control-type/#_6","title":"\u6570\u636e\u5e93\u6743\u9650","text":"\u62e5\u6709\u6570\u636e\u5e93\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 SHOW TABLES \u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u4e0b\u6240\u6709\u8868 CREATE TABLE \u5efa\u8868\u6743\u9650 DROP TABLE \u5220\u8868\u6743\u9650 CREATE VIEW \u521b\u5efa\u89c6\u56fe\u6743\u9650\uff0c\u65e0\u5bf9\u5e94\u6743\u9650\u65f6\u521b\u5efa\u89c6\u56fe\u65e0\u6cd5\u67e5\u8be2 DROP VIEW \u5220\u9664\u89c6\u56fe ALTER TABLE \u4fee\u6539\u8868\u6743\u9650 ALTER VIEW \u4fee\u6539\u89c6\u56fe\u6743\u9650\uff0c\u65e0\u5bf9\u5e94\u6743\u9650\u65f6\u65e0\u6cd5\u4fee\u6539\u89c6\u56fe ALL [PRIVILEGES] \u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650 OWNERSHIP \u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\uff0c\u9644\u52a0WITH GRANT OPTION
"},{"location":"MatrixOne/Reference/access-control-type/#_7","title":"\u8868\u6743\u9650","text":"\u62e5\u6709\u8868\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 SELECT \u5bf9\u8868\u6267\u884cSELECT
\u547d\u4ee4 INSERT \u5bf9\u8868\u6267\u884c INSERT
\u547d\u4ee4 UPDATE \u5bf9\u8868\u6267\u884c UPDATE
\u547d\u4ee4 TRUNCATE \u5bf9\u8868\u6267\u884c TRUNCATE TABLE
\u547d\u4ee4 DELETE \u5bf9\u8868\u6267\u884c DELETE
\u547d\u4ee4 REFERENCE \u5141\u8bb8\u5c06\u8868\u5f15\u7528\u4e3a\u5916\u952e\u7ea6\u675f\u7684\u552f\u4e00/\u4e3b\u952e\u8868\u3002\u901a\u8fc7 DESCRIBE
\u6216 SHOW
\u547d\u4ee4\u67e5\u770b\u8868\u7684\u7ed3\u6784 INDEX \u521b\u5efa\u5220\u9664 INDEX ALL \u6307\u5b9a\u8868\u7684\u6240\u6709\u6743\u9650 OWNERSHIP \u6307\u5b9a\u8868\u7684\u6240\u6709\u6743\u9650\uff0c\u9644\u52a0 WITH GRANT OPTION
"},{"location":"MatrixOne/Reference/access-control-type/#_8","title":"\u8868\u6267\u884c\u6743\u9650","text":"\u62e5\u6709\u8868\u6267\u884c\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 EXECUTE \u5141\u8bb8\u6267\u884c\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\u7684\u6743\u9650"},{"location":"MatrixOne/Reference/access-control-type/#_9","title":"\u53d1\u5e03\u8ba2\u9605\u6743\u9650","text":"\u5728 MatrixOne \u4e2d\uff0c\u53d1\u5e03\u8ba2\u9605\u662f\u5bf9 MatrixOne \u4e2d\u6307\u5b9a\u6570\u636e\u5e93\u53d1\u8d77\u7684\u6570\u636e\u5171\u4eab\u8bbf\u95ee\u3002
Note: \u5f53\u524d MatrixOne \u4e2d\u4ec5\u652f\u6301 moadmin \u548c accountadmin \u89d2\u8272\u624d\u53ef\u4ee5\u8fdb\u884c\u53d1\u5e03\u8ba2\u9605\u64cd\u4f5c\u3002
\u53d1\u5e03\u7aef\uff0c\u5373\u53d1\u5e03\u5171\u4eab\u3001\u540c\u6b65\u6570\u636e\u7684\u4e00\u65b9\u3002
\u6743\u9650 \u542b\u4e49 CREATE PUBLICATION \u521b\u5efa\u53d1\u5e03 ALTER PUBLICATION \u4fee\u6539\u53d1\u5e03 DROP PUBLICATION \u5220\u9664\u53d1\u5e03 SHOW PUBLICATION \u67e5\u770b\u53d1\u5e03 SHOW CREATE PUBLICATION \u67e5\u770b\u521b\u5efa\u53d1\u5e03\u8bed\u53e5\u8ba2\u9605\u7aef\uff0c\u5373\u83b7\u53d6\u5df2\u5171\u4eab\u3001\u540c\u6b65\u6570\u636e\u7684\u4e00\u65b9\u3002
\u6743\u9650 \u542b\u4e49 CREATE DATABASE db_name FROM account_name PUBLICATION \u521b\u5efa\u8ba2\u9605 SHOW SUBSCRIPTIONS \u67e5\u770b\u8ba2\u9605"},{"location":"MatrixOne/Reference/Data-Types/blob-text-type/","title":"BLOB \u548c TEXT \u6570\u636e\u7c7b\u578b","text":"BLOB
BLOB
\u662f\u53ef\u4ee5\u5b58\u50a8\u53ef\u53d8\u6570\u91cf\u7684\u5927\u6570\u636e\u4e8c\u8fdb\u5236\u5bf9\u8c61\u3002
BLOB
\u503c\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff08\u5b57\u8282\u5b57\u7b26\u4e32\uff09\uff0c\u5bf9\u5e94\u4e8c\u8fdb\u5236\u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u89c4\u5219\uff0c\u6bd4\u8f83\u548c\u6392\u5e8f\u57fa\u4e8e\u5217\u503c\u4e2d\u5b57\u8282\u7684\u6570\u503c\u3002
TEXT
TEXT
\u4e3a\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff08\u5b57\u7b26\u4e32\uff09\uff0c\u7528\u4e8e\u5b58\u50a8\u6240\u6709\u7c7b\u578b\u7684\u6587\u672c\u6570\u636e\u3002\u5b83\u4eec\u5177\u6709\u4e8c\u8fdb\u5236\u4ee5\u5916\u7684\u5b57\u7b26\u96c6\uff0c\u5e76\u4e14\u57fa\u4e8e\u5b57\u7b26\u96c6\u7684\u6392\u5e8f\u89c4\u5219\u5bf9\u503c\u8fdb\u884c\u6392\u5e8f\u548c\u6bd4\u8f83\u3002\u5173\u4e8e BLOB \u548c TEXT
\u5982\u679c\u4e3a BLOB
\u6216 TEXT
\u5217\u5206\u914d\u7684\u503c\u8d85\u8fc7\u8be5\u5217\u7684\u6700\u5927\u957f\u5ea6\uff0c\u5219\u8be5\u503c\u8d85\u51fa\u957f\u5ea6\u7684\u90e8\u5206\u5c06\u88ab\u622a\u65ad\u5e76\u751f\u6210\u544a\u8b66\u3002\u5982\u679c\u622a\u65ad\u7684\u662f\u975e\u7a7a\u683c\u5b57\u7b26\uff0c\u4f1a\u53d1\u751f\u9519\u8bef\uff08\u800c\u4e0d\u662f\u544a\u8b66\uff09\u5e76\u7981\u6b62\u63d2\u5165\u503c\u3002\u5bf9\u4e8e TEXT
\uff0c\u622a\u65ad\u63d2\u5165\u5230 TEXT
\u5217\u7684\u503c\u4e2d\u591a\u4f59\u7684\u5c3e\u90e8\u7a7a\u683c\u65f6\uff0c\u603b\u662f\u4f1a\u751f\u6210\u544a\u8b66\u3002
MatrixOne \u652f\u6301\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362\uff0c\u4e0b\u8868\u5217\u51fa\u4e86\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u652f\u6301\u60c5\u51b5\uff1a
cast
\u51fd\u6570\uff0c\u8fdb\u884c\u663e\u5f0f\u8f6c\u6362\u3002cast
\u51fd\u6570\uff0c\u8fdb\u884c\u9690\u5f0f\u8f6c\u6362\uff0c\u5373\u5f3a\u5236\u8f6c\u6362\u3002MatrixOne \u7684\u6570\u636e\u7c7b\u578b\u4e0e MySQL \u6570\u636e\u7c7b\u578b\u7684\u5b9a\u4e49\u4e00\u81f4\uff0c\u53ef\u53c2\u8003\uff1a https://dev.mysql.com/doc/refman/8.0/en/data-types.html
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_2","title":"\u6574\u6570\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u6700\u5c0f\u503c \u6700\u5927\u503c TINYINT 1 byte -128 127 SMALLINT 2 byte -32768 32767 INT 4 byte -2147483648 2147483647 BIGINT 8 byte -9223372036854775808 9223372036854775807 TINYINT UNSIGNED 1 byte 0 255 SMALLINT UNSIGNED 2 byte 0 65535 INT UNSIGNED 4 byte 0 4294967295 BIGINT UNSIGNED 8 byte 0 18446744073709551615"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_3","title":"\u793a\u4f8b","text":"-- Create a table named \"inttable\" with 2 attributes of a \"tinyint\", a \"tinyint unsigned\",\ncreate table inttable ( a tinyint not null default 1, tinyint8 tinyint unsigned primary key);\ninsert into inttable (tinyint8) values (0),(255), (0xFE), (253);\n\nmysql> select * from inttable order by 2 asc;\n+------+----------+\n| a | tinyint8 |\n+------+----------+\n| 1 | 0 |\n| 1 | 253 |\n| 1 | 254 |\n| 1 | 255 |\n+------+----------+\n4 rows in set (0.03 sec)\n
-- Create a table named \"inttable\" with 2 attributes of a \"smallint\", a \"smallint unsigned\",\ndrop table inttable;\ncreate table inttable ( a smallint not null default 1, smallint16 smallint unsigned);\ninsert into inttable (smallint16) values (0),(65535), (0xFFFE), (65534), (65533);\n\nmysql> select * from inttable;\n+------+------------+\n| a | smallint16 |\n+------+------------+\n| 1 | 0 |\n| 1 | 65535 |\n| 1 | 65534 |\n| 1 | 65534 |\n| 1 | 65533 |\n+------+------------+\n5 rows in set (0.01 sec)\n
-- Create a table named \"inttable\" with 2 attributes of a \"int\", a \"int unsigned\",\ndrop table inttable;\ncreate table inttable ( a int not null default 1, int32 int unsigned primary key);\ninsert into inttable (int32) values (0),(4294967295), (0xFFFFFFFE), (4294967293), (4294967291);\n\nmysql> select * from inttable order by a desc, 2 asc;\n+------+------------+\n| a | int32 |\n+------+------------+\n| 1 | 0 |\n| 1 | 4294967291 |\n| 1 | 4294967293 |\n| 1 | 4294967294 |\n| 1 | 4294967295 |\n+------+------------+\n5 rows in set (0.01 sec)\n
-- Create a table named \"inttable\" with 2 attributes of a \"bigint\", a \"bigint unsigned\",\ndrop table inttable;\ncreate table inttable ( a bigint, big bigint unsigned primary key );\ninsert into inttable values (122345515, 0xFFFFFFFFFFFFE), (1234567, 0xFFFFFFFFFFFF0);\n\nmysql> select * from inttable;\n+-----------+------------------+\n| a | big |\n+-----------+------------------+\n| 122345515 | 4503599627370494 |\n| 1234567 | 4503599627370480 |\n+-----------+------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_4","title":"\u6d6e\u70b9\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u7cbe\u5ea6 \u6700\u5c0f\u503c \u6700\u5927\u503c \u8bed\u6cd5\u8868\u793a FLOAT32 4 bytes 23 bits -3.40282e+038 3.40282e+038 FLOAT(M, D) M \u8868\u793a\u7684\u662f\u6700\u5927\u957f\u5ea6\uff0cD \u8868\u793a\u7684\u663e\u793a\u7684\u5c0f\u6570\u4f4d\u6570\u3002M \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< M <=255\uff09\u3002 D \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< D <=30\uff09\uff0c\u4e14 M >= D\u3002 \u5e26\u7cbe\u5ea6\u7684\u6d6e\u70b9\u6570\u5c55\u793a\u51fa\u8981\u6c42\u7cbe\u5ea6\u7684\u4f4d\u6570\uff0c\u5728\u4f4d\u6570\u4e0d\u8db3\u65f6\uff0c\u4f1a\u8fdb\u884c\u672b\u5c3e\u8865 0\u3002 FLOAT64 8 bytes 53 bits -1.79769e+308 1.79769e+308 DOUBLE(M, D) M \u8868\u793a\u7684\u662f\u6700\u5927\u957f\u5ea6\uff0cD \u8868\u793a\u7684\u663e\u793a\u7684\u5c0f\u6570\u4f4d\u6570\u3002M \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< M <=255\uff09\u3002 D \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< D <=30\uff09\uff0c\u4e14 M >= D\u3002 \u5e26\u7cbe\u5ea6\u7684\u6d6e\u70b9\u6570\u5c55\u793a\u51fa\u8981\u6c42\u7cbe\u5ea6\u7684\u4f4d\u6570\uff0c\u5728\u4f4d\u6570\u4e0d\u8db3\u65f6\uff0c\u4f1a\u8fdb\u884c\u672b\u5c3e\u8865 0\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_5","title":"\u793a\u4f8b","text":"-- Create a table named \"floatt1\" with precision, a trailing zero is added when the number of bits falls short\ncreate table floatt1(a float(5, 2));\ninsert into floatt1 values(1), (2.5), (3.56), (4.678);\n\nmysql> select * from floatt1;\n+------+\n| a |\n+------+\n| 1.00 |\n| 2.50 |\n| 3.56 |\n| 4.68 |\n+------+\n4 rows in set (0.00 sec)\n\n-- Create a table named \"floattable\" with 1 attributes of a \"float\"\ncreate table floattable ( a float not null default 1, big float(20,5) primary key);\ninsert into floattable (big) values (-1),(12345678.901234567),(92233720368547.75807);\n\nmysql> select * from floattable order by a desc, big asc;\n+------+----------------------+\n| a | big |\n+------+----------------------+\n| 1 | -1.00000 |\n| 1 | 12345679.00000 |\n| 1 | 92233718038528.00000 |\n+------+----------------------+\n3 rows in set (0.01 sec)\n\nmysql> select min(big),max(big),max(big)-1 from floattable;\n+----------+----------------------+----------------+\n| min(big) | max(big) | max(big) - 1 |\n+----------+----------------------+----------------+\n| -1.00000 | 92233718038528.00000 | 92233718038527 |\n+----------+----------------------+----------------+\n1 row in set (0.05 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_6","title":"\u4e8c\u8fdb\u5236\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u6700\u5c0f\u503c \u6700\u5927\u503c \u8bed\u6cd5\u8868\u793a \u63cf\u8ff0 BIT 1bytes 0 18446744073709551615 BIT(M) \u5b58\u50a8 bit \u6570\u636e\u7684\u6570\u636e\u7c7b\u578b\uff0cM \u652f\u6301\u7684\u8303\u56f4\uff1a1 \u5230 64\u3002M \u9ed8\u8ba4\u4e3a 1\uff0c\u5982\u679c\u5b58\u50a8\u7684\u6570\u636e\u4e0d\u8db3 M bits\uff0c\u5219\u9760\u5de6\u8865 0 \u8865\u9f50\u957f\u5ea6"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_7","title":"\u793a\u4f8b","text":"create table t1 (a bit);\nmysql> desc t1;--bit(M) \u9ed8\u8ba4 M \u4e3a 1\n+-------+--------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+--------+------+------+---------+-------+---------+\n| a | BIT(1) | YES | | NULL | | |\n+-------+--------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\ncreate table t2 (a bit(8));\n\n-- \u7528 bit-value literal \u8bed\u6cd5\u8d4b\u503c\ninsert into t2 values (0b1);\ninsert into t2 values (b'1');\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x01 |\n| 0x01 |\n+------------+\n2 rows in set (0.00 sec)\n\ntruncate table t2;\n\n--\u7528 hex-value literal \u8bed\u6cd5\u8d4b\u503c\ninsert into t2 values (0x10);\ninsert into t2 values (x'10');\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x10 |\n| 0x10 |\n+------------+\n2 rows in set (0.00 sec)\n\ntruncate table t2;\n\n--\u652f\u6301\u7528 int \u7c7b\u578b\u8d4b\u503c\uff0c\u4f46\u662f int \u7684\u4e8c\u8fdb\u5236\u8868\u793a\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7 bit \u7c7b\u578b\u7684\u957f\u5ea6\ninsert into t2 values (255);--a = b'11111111'\nmysql> insert into t2 values (256);--256 \u7684 2 \u8fdb\u5236\u8868\u793a\u957f\u5ea6\u8d85\u8fc7 8\nERROR 20301 (HY000): invalid input: data too long, type width = 8, val = 100000000\n\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0xFF |\n+------------+\n1 row in set (0.00 sec)\n\ntruncate table t2;\n\n--\u6d6e\u70b9\u578b\u6570\u636e\uff0c\u4f1a\u5148\u5c06\u6d6e\u70b9\u578b\u56db\u820d\u4e94\u5165\u8f6c\u6210 int \u578b\uff0c\u7136\u540e\u6309\u7167 int \u7c7b\u578b\u8d4b\u503c\ninsert into t2 values (2.1);--a = b'00000010'\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x02 |\n+------------+\n1 row in set (0.00 sec)\n\ntruncate table t2;\n\n--\u5b57\u7b26\u578b\u6570\u636e\u5b58\u50a8\u7684\u662f\u5176\u7f16\u7801\u503c\uff0c\u540c\u6837\u6574\u4e2a\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u7684\u7f16\u7801\u603b\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7 bit \u7c7b\u578b\ninsert into t2 values ('a');--a = b'01100001' \nmysql> insert into t2 values ('\u554a');--utf8('\u554a') = 0xe5958a\uff1b\nERROR 20301 (HY000): invalid input: data too long, type width = 8, val = 111001011001010110001010\n\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x61 |\n+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_8","title":"\u5b57\u7b26\u4e32\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u957f\u5ea6 \u8bed\u6cd5\u8868\u793a \u63cf\u8ff0 char 24 bytes 0 ~ 4294967295 CHAR \u5b9a\u957f\u5b57\u7b26\u4e32 varchar 24 bytes 0 ~ 4294967295 VARCHAR \u53d8\u957f\u5b57\u7b26\u4e32 binary 255 bytes 0 ~ 65535 BINARY(M) \u7c7b\u4f3c\u4e8e CHAR\uff0c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32 varbinary 255 bytes 0 ~ 65535 VARBINARY(M) \u7c7b\u4f3c\u4e8e VARCHAR\uff0c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32 text 1 GB other types mapping TEXT \u957f\u6587\u672c\u6570\u636e\uff0c\u4e0d\u533a\u5206 TINY TEXT\u3001MEDIUM TEXT \u548c LONG TEXT blob 1 GB other types mapping BLOB \u4e8c\u8fdb\u5236\u7684\u957f\u6587\u672c\u6570\u636e\uff0c\u4e0d\u533a\u5206 TINY BLOB\u3001MEDIUM BLOB \u548c LONGBLOB enum 1 byte \u6216 2 bytes 0 ~ 65535 enum \u4e00\u4e2a\u679a\u4e3e\u7c7b\u578b\u3002\u5b83\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u5bf9\u8c61\uff0c\u53ea\u80fd\u4ece value1
\u3001value2
\u7b49\u503c\u5217\u8868\u4e2d\u9009\u62e9\u4e00\u4e2a\u503c\uff0c\u6216\u8005\u662f NULL
\u6216\u7279\u6b8a\u7684 '' \u9519\u8bef\u503c\u3002\u679a\u4e3e\u503c\u5728\u5185\u90e8\u8868\u793a\u4e3a\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_9","title":"\u793a\u4f8b","text":"-- Create a table named \"names\" with 2 attributes of a \"varchar\" and a \"char\"\ncreate table names(name varchar(255),age char(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+-------+------+\n| name | age |\n+-------+------+\n| Abby | 24 |\n| Bob | 25 |\n| Carol | 23 |\n| Dora | 29 |\n+-------+------+\n4 rows in set (0.00 sec)\n
-- Create a table named \"names\" with 2 attributes of a \"VARBINARY\" and a \"BINARY\"\ncreate table names(name varbinary(255),age binary(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| name | age |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| 0x41626279 | 0x323400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x426F62 | 0x323500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x4361726F6C | 0x323300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x446F7261 | 0x323900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n4 rows in set (0.01 sec)\n
-- Create a table named \"texttest\" with 1 attribute of a \"text\"\ncreate table texttest (a text);\ninsert into texttest values('abcdef');\ninsert into texttest values('_bcdef');\ninsert into texttest values('a_cdef');\ninsert into texttest values('ab_def');\ninsert into texttest values('abc_ef');\ninsert into texttest values('abcd_f');\ninsert into texttest values('abcde_');\n\nmysql> select * from texttest where a like 'ab\\_def' order by 1 asc;\n+--------+\n| a |\n+--------+\n| ab_def |\n+--------+\n1 row in set (0.01 sec)\n
-- Create a table named \"blobtest\" with 1 attribute of a \"blob\"\ncreate table blobtest (a blob);\ninsert into blobtest values('abcdef');\ninsert into blobtest values('_bcdef');\ninsert into blobtest values('a_cdef');\ninsert into blobtest values('ab_def');\ninsert into blobtest values('abc_ef');\ninsert into blobtest values('abcd_f');\ninsert into blobtest values('abcde_');\n\nmysql> select * from blobtest where a like 'ab\\_def' order by 1 asc;\n+----------------+\n| a |\n+----------------+\n| 0x61625F646566 |\n+----------------+\n1 row in set (0.01 sec)\n
-- Create a table named \"enumtest\" with 1 attribute of a \"enum\"\nCREATE TABLE enumtest (color ENUM('red', 'green', 'blue'));\nINSERT INTO enumtest (color) VALUES ('red');\nmysql> SELECT * FROM enumtest WHERE color = 'green';\n+-------+\n| color |\n+-------+\n| green |\n+-------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#json","title":"JSON \u6570\u636e\u7c7b\u578b","text":"JSON \u6570\u636e\u7c7b\u578b \u89e3\u91ca \u5bf9\u8c61 \u5bf9\u8c61\u4f7f\u7528 {}
\u62ec\u8d77\u6765\uff0c\u5143\u7d20\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002JSON \u5bf9\u8c61\u4e2d\u7684\u503c/\u952e\u53ef\u4ee5\u4e3a String\u3001Nubmber\u3001Bool\u3001\u65f6\u95f4\u3002 \u6570\u7ec4 \u6570\u7ec4\u4f7f\u7528 []
\u62ec\u8d77\u6765\uff0c\u5143\u7d20\u4e4b\u95f4\u7528\u9017\u53f7 ,
\u5206\u9694\u3002JSON \u6570\u7ec4\u4e2d\u503c\u53ef\u4ee5\u4e3a String\u3001Nubmber\u3001Bool\u3001\u65f6\u95f4\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_10","title":"\u793a\u4f8b","text":"-- Create a table named \"jsontest\" with 1 attribute of a \"json\"\ncreate table jsontest (a json,b int);\ninsert into jsontest values ('{\"t1\":\"a\"}',1),('{\"t1\":\"b\"}',2);\n\nmysql> select * from jsontest;\n+-------------+------+\n| a | b |\n+-------------+------+\n| {\"t1\": \"a\"} | 1 |\n| {\"t1\": \"b\"} | 2 |\n+-------------+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_11","title":"\u65f6\u95f4\u4e0e\u65e5\u671f\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u7cbe\u5ea6 \u6700\u5c0f\u503c \u6700\u5927\u503c \u8bed\u6cd5\u8868\u793a Time 8 byte microsecond -2562047787:59:59.999999 2562047787:59:59.999999 hh:mm:ss.ssssss Date 4 byte day 0001-01-01 9999-12-31 YYYY-MM-DD/YYYYMMDD DateTime 8 byte microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYY-MM-DD hh:mi:ssssss TIMESTAMP 8 byte microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYYMMDD hh:mi:ss.ssssss \u65f6\u95f4\u4e0e\u65e5\u671f\u90e8\u5206\u7c7b\u578b\u652f\u6301\u5728\u63d2\u5165\u6570\u636e\u65f6\u6dfb\u52a0\u4ee5\u4e0b hint \u503c\uff1a
Time
\uff1a{t 'xx'}\uff0c{time 'xx'}
Date
\uff1a{d 'xx'}\uff0c{date 'xx'}
TIMESTAMP
\uff1a{ts 'xx'}\uff0c{timestamp 'xx'}
-- Create a table named \"timetest\" with 1 attributes of a \"time\"\ncreate table time_02(t1 time);\ninsert into time_02 values(200),(time'23:29:30'),({t'12:11:12'}),('');\n\nmysql> select * from time_02;\n+----------+\n| t1 |\n+----------+\n| 00:02:00 |\n| 23:29:30 |\n| 12:11:12 |\n| NULL |\n+----------+\n4 rows in set (0.01 sec)\n
-- Create a table named \"datetest\" with 1 attributes of a \"date\"\ncreate table datetest (a date not null, primary key(a));\ninsert into datetest values ({d'2022-01-01'}), ('20220102'),(date'2022-01-03'),({d now()});\nmysql> select * from datetest;\n+------------+\n| a |\n+------------+\n| 2022-01-01 |\n| 2022-01-02 |\n| 2022-01-03 |\n| 2024-03-19 |\n+------------+\n4 rows in set (0.00 sec)\n
-- Create a table named \"datetimetest\" with 1 attributes of a \"datetime\"\ncreate table datetimetest (a datetime(0) not null, primary key(a));\ninsert into datetimetest values ('20200101000000'), ('2022-01-02'), ('2022-01-02 00:00:01'), ('2022-01-02 00:00:01.512345');\n\nmysql> select * from datetimetest order by a asc;\n+---------------------+\n| a |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 00:00:00 |\n| 2022-01-02 00:00:01 |\n| 2022-01-02 00:00:02 |\n+---------------------+\n4 rows in set (0.02 sec)\n
-- Create a table named \"timestamptest\" with 1 attribute of a \"timestamp\"\ncreate table timestamptest (a timestamp(0) not null, primary key(a));\ninsert into timestamptest values ('20200101000000'), (timestamp'2022-01-02 11:30:40'), ({ts'2022-01-02 00:00:01'}), ({ts current_timestamp});\n\nmysql> select * from timestamptest;\n+---------------------+\n| a |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 11:30:40 |\n| 2022-01-02 00:00:01 |\n| 2024-03-19 17:22:08 |\n+---------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#bool","title":"Bool \u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 True 1 byte False 1 byte"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_13","title":"\u793a\u4f8b","text":"-- Create a table named \"booltest\" with 2 attribute of a \"boolean\" and b \"bool\"\ncreate table booltest (a boolean,b bool);\ninsert into booltest values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from booltest;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#decimal","title":"\u5b9a\u70b9\u7c7b\u578b Decimal","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u7cbe\u5ea6 \u8bed\u6cd5\u8868\u793a Decimal64 8 byte 18 \u4f4d Decimal(N,S) N \u8868\u793a\u6570\u5b57\u4f4d\u6570\u7684\u603b\u6570\uff0c\u8303\u56f4\u662f (1 ~ 18)\uff0c\u5c0f\u6570\u70b9\u548c -\uff08\u8d1f\u6570\uff09\u7b26\u53f7\u4e0d\u5305\u62ec\u5728 N \u4e2d\u3002\u5982\u679c N \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u503c\u5e94\u8be5\u53d6\u6700\u5927\uff0c\u5373\u53d6\u503c 18\u3002S \u8868\u793a\u662f\u5c0f\u6570\u70b9\uff08\u6807\u5ea6\uff09\u540e\u9762\u7684\u4f4d\u6570\uff0c\u8303\u56f4\u662f (0 ~ N)\u5982\u679c S \u662f 0\uff0c\u5219\u503c\u6ca1\u6709\u5c0f\u6570\u70b9\u6216\u5206\u6570\u90e8\u5206\u3002\u5982\u679c S \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u662f 0\uff0c\u4f8b\u5982 Decimal(10)\uff0c\u7b49\u540c\u4e8e Decimal(10, 0) \u4f8b\u5982 Decimal(10,8)\uff0c\u5373\u8868\u793a\u6570\u5b57\u603b\u957f\u5ea6\u4e3a 10\uff0c\u5c0f\u6570\u4f4d\u4e3a 8\u3002 Decimal128 16 byte 38 \u4f4d Decimal(N,S) N \u8868\u793a\u6570\u5b57\u4f4d\u6570\u7684\u603b\u6570\uff0c\u8303\u56f4\u662f (18 ~ 38)\uff0c\u5c0f\u6570\u70b9\u548c -\uff08\u8d1f\u6570\uff09\u7b26\u53f7\u4e0d\u5305\u62ec\u5728 N \u4e2d\u3002\u5982\u679c N \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u503c\u5e94\u8be5\u53d6\u6700\u5927\uff0c\u5373\u53d6\u503c 38\u3002S \u8868\u793a\u662f\u5c0f\u6570\u70b9\uff08\u6807\u5ea6\uff09\u540e\u9762\u7684\u4f4d\u6570\uff0c\u8303\u56f4\u662f (0 ~ N)\u5982\u679c S \u662f 0\uff0c\u5219\u503c\u6ca1\u6709\u5c0f\u6570\u70b9\u6216\u5206\u6570\u90e8\u5206\u3002\u5982\u679c S \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u662f 0\uff0c\u4f8b\u5982 Decimal(20)\uff0c\u7b49\u540c\u4e8e Decimal(20, 0)\u3002\u4f8b\u5982 Decimal(20,19)\uff0c\u5373\u8868\u793a\u6570\u5b57\u603b\u957f\u5ea6\u4e3a 20\uff0c\u5c0f\u6570\u4f4d\u4e3a 19\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_14","title":"\u793a\u4f8b","text":"-- Create a table named \"decimalTest\" with 2 attribute of a \"decimal\" and b \"decimal\"\ncreate table decimalTest(a decimal(6,3), b decimal(24,18));\ninsert into decimalTest values(123.4567, 123456.1234567891411241355);\n\nmysql> select * from decimalTest;\n+---------+---------------------------+\n| a | b |\n+---------+---------------------------+\n| 123.457 | 123456.123456789141124136 |\n+---------+---------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#uuid","title":"UUID \u7c7b\u578b","text":"UUID \u7c7b\u578b \u89e3\u91ca UUID \u7531 32 \u4e2a 16 \u8fdb\u5236\u6570\u5b57\u548c 4 \u4e2a\u8fde\u5b57\u7b26\u2018-\u2019\u7ec4\u6210 UUID \u503c\uff0c\u5f62\u5f0f\u4e3a 8-4-4-4-12\uff0c\u6807\u51c6\u7684 UUID \u793a\u4f8b\uff1aa0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_15","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 't1' \u7684\u65b0\u8868\uff0c\u5e76\u8bbe\u7f6e 'a' \u5217\u4e3a UUID \u7c7b\u578b\uff0c\u540c\u65f6\u5c06 'a' \u5217\u8bbe\u7f6e\u4e3a\u4e3b\u952e\ncreate table t1(a uuid primary key);\n\n-- \u5411 't1' \u8868\u7684 'a' \u5217\u63d2\u5165\u4e00\u4e2a\u65b0\u7684 UUID \u503c\ninsert into t1 values (uuid());\n\n-- \u67e5\u8be2 't1' \u8868\u4e2d 'a' \u5217\u7684\u503c\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u540e\u7684\u957f\u5ea6\nmysql> select length(cast(a as varchar)) from t1;\n+----------------------------+\n| length(cast(a as varchar)) |\n+----------------------------+\n| 36 |\n+----------------------------+\n1 row in set (0.01 sec)\n\n-- \u67e5\u8be2 t1 \u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u5176\u503c\u662f\u4e00\u4e2a UUID\nmysql> select * from t1;\n+--------------------------------------+\n| a |\n+--------------------------------------+\n| 948d8e4e-1b00-11ee-b656-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_16","title":"\u5411\u91cf\u6570\u636e\u7c7b\u578b","text":"\u7c7b\u578b \u89e3\u91ca vecf32 \u5411\u91cf\u5217\u7c7b\u578b\u4e3a float32 vecf64 \u5411\u91cf\u5217\u7c7b\u578b\u4e3a float64"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_17","title":"\u793a\u4f8b","text":"create table t1(n1 vecf32(3), n2 vecf64(2));\ninsert into t1 values(\"[1,2,3]\",'[4,5]');\n\nmysql> select * from t1;\n+-----------+--------+\n| n1 | n2 |\n+-----------+--------+\n| [1, 2, 3] | [4, 5] |\n+-----------+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/enum-type/","title":"ENUM \u7c7b\u578b","text":"ENUM
\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u5217\u8868\uff0cENUM
\u7528\u4e8e\u5b58\u50a8\u4e00\u7ec4\u9884\u5b9a\u4e49\u7684\u79bb\u6563\u503c\u3002\u5b83\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u5177\u6709\u79bb\u6563\u503c\u7684\u7c7b\u578b\uff0c\u6bcf\u4e2a\u679a\u4e3e\u5e38\u91cf\u90fd\u4ee3\u8868\u4e86\u4e00\u4e2a\u7279\u5b9a\u7684\u503c\u3002
ENUM
\u6570\u636e\u7c7b\u578b\u5217\u9002\u5408\u5b58\u50a8\u72b6\u6001\u548c\u6807\u8bc6\u7b49\u6709\u9650\u6570\u91cf\u7684\u56fa\u5b9a\u503c\u7684\u6570\u636e\u3002
ENUM
\u6570\u636e\u7c7b\u578b\u5177\u6709\u4ee5\u4e0b\u4f18\u70b9\uff1a
ENUM ('value1', 'value2', ..., 'valuen')\n
\u4f8b\u5982\uff0c\u5b9a\u4e49 ENUM \u5217\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
CREATE TABLE table_name (\n...\ncol ENUM ('value1','value2','value3'),\n...\n);\n
"},{"location":"MatrixOne/Reference/Data-Types/enum-type/#_2","title":"\u8bed\u6cd5\u89e3\u91ca","text":"ENUM
\u662f\u4e00\u4e2a\u5173\u952e\u5b57\uff0c\u7528\u6765\u58f0\u660e\u4e00\u4e2a\u679a\u4e3e\u7c7b\u578b\u3002ENUM
\u7c7b\u578b\u7684\u53ef\u9009\u9879\u5217\u8868\uff0c\u4f7f\u7528 ENUM \u7c7b\u578b\u7684\u5217\u7684\u503c\u53ea\u80fd\u662f\u4e0a\u9762\u503c\u4e2d\u7684\u5176\u4e2d\u4e00\u4e2a\u3002Note: \u5728 ENUM
\u6570\u636e\u7c7b\u578b\u4e2d\uff0c\u4f60\u53ef\u4ee5\u62e5\u6709\u591a\u4e2a\u679a\u4e3e\u503c\u3002\u4f46\u662f\uff0c\u5efa\u8bae\u5c06\u679a\u4e3e\u503c\u7684\u6570\u91cf\u4fdd\u6301\u5728 20 \u4ee5\u4e0b\u3002
ENUM
\u7c7b\u578b\u7684\u503c\u5fc5\u987b\u4ece\u4e00\u4e2a\u9884\u5b9a\u4e49\u7684\u503c\u5217\u8868\u4e2d\u9009\u62e9\uff0c\u4e0b\u9762\u7684\u4f8b\u5b50\u5c06\u5e2e\u52a9\u4f60\u7406\u89e3\uff1a
CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue'),\nPRIMARY KEY (id)\n);\n
\u4e0a\u8ff0\u8bed\u53e5\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a enumtable
\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u540d\u4e3a color
\u7684\u679a\u4e3e\u7c7b\u578b\u5b57\u6bb5\u3002color
\u5b57\u6bb5\u7684\u503c\u5fc5\u987b\u4e3a red
\u3001green
\u6216 blue
\u4e2d\u7684\u4e00\u4e2a\u3002\u540c\u65f6\uff0c\u6309\u7167\u5217\u5b9a\u4e49\u65f6\u7684\u987a\u5e8f\uff0cred
\u3001green
\u548c blue
\u7684\u7d22\u5f15\u5206\u522b\u4e3a 1\uff0c2\uff0c3\u3002
\u5f53\u5411\u679a\u4e3e\u7c7b\u578b\u7684\u5b57\u6bb5\u4e2d\u63d2\u5165\u6570\u636e\u65f6\uff0c\u53ea\u80fd\u63d2\u5165\u9884\u5b9a\u4e49\u7684\u679a\u4e3e\u503c\u6216\u8005 NULL
\u3002\u5982\u679c\u63d2\u5165\u7684\u503c\u4e0d\u5728\u9884\u5b9a\u4e49\u7684\u5217\u8868\u4e2d\uff0c\u5219\u4ea7\u751f\u62a5\u9519\u3002\u4f8b\u5982\uff1a
INSERT INTO enumtable (id, color) VALUES ('01', 'red');\n-- 'red' \u5728\u9884\u5b9a\u4e49\u7684\u5217\u8868\u4e2d\uff0c\u63d2\u5165\u6210\u529f\nINSERT INTO enumtable (id, color) VALUES ('02', 'yellow');\n-- 'yellow' \u4e0d\u5728\u9884\u5b9a\u4e49\u7684\u5217\u8868\u4e2d\uff0c\u5219\u4f1a\u4ea7\u751f\u62a5\u9519\nINSERT INTO enumtable (id, color) VALUES ('03', NULL);\n-- \u679a\u4e3e\u6210\u5458\u5e76\u6ca1\u6709\u5b9a\u4e49 not null\uff0c\u63d2\u5165\u6210\u529f\n
\u9664\u4e86\u679a\u4e3e\u503c\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u679a\u4e3e\u6210\u5458\u7684\u6570\u5b57\u7d22\u5f15\u5c06\u6570\u636e\u63d2\u5165\u5230 ENUM \u5217\u4e2d\u3002\u4f8b\u5982\uff1a
INSERT INTO enumtable (id, color) VALUES ('04', 2);\n-- \u7531\u4e8e `green` \u7684\u7d22\u5f15\u662f 2\uff0c\u6240\u4ee5\u8fd9\u6761\u6570\u636e\u63d2\u5165\u6210\u529f\n
\u5047\u5982\u5efa\u8868\u65f6\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86 color
\u5217 NOT NULL
\uff1a
CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue') NOT NULL,\nPRIMARY KEY (id)\n);\n
\u5f53\u63d2\u5165\u4e00\u4e2a\u65b0\u884c\u800c\u4e0d\u6307\u5b9a color \u5217\u7684\u503c\u65f6\uff0cMatrixOne \u5c06\u4f7f\u7528\u7b2c\u4e00\u4e2a\u679a\u4e3e\u6210\u5458\u4f5c\u4e3a\u9ed8\u8ba4\u503c\uff1a
INSERT INTO enumtable (id) VALUES ('05');\n-- \u8fd9\u91cc\u5c06\u7ed9 id \u4e3a 05 \u7684\u5217\u6307\u5b9a\u7b2c\u4e00\u4e2a\u679a\u4e3e\u6210\u5458 `red` \u4e3a\u9ed8\u8ba4\u503c\n
"},{"location":"MatrixOne/Reference/Data-Types/enum-type/#mysql","title":"\u4e0e MySQL \u7684\u5dee\u5f02","text":"\u4e0e MySQL \u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u7684 ENUM \u7c7b\u578b\u5728 WHERE \u6761\u4ef6\u91cc\u53ea\u80fd\u8ddf\u5b57\u7b26\u4e32\u7c7b\u578b\u8fdb\u884c\u6bd4\u8f83\u3002
\u53ef\u4ee5\u770b\u8fd9\u4e2a\u4f8b\u5b50\uff1a
update orders set status= 2 where status='Processing';`\n
\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u4f60\u9700\u8981\u5c06 status
\u4e3a Processing
\u7684\u884c\u7684 status
\u66f4\u65b0\u4e3a 2\u3002\u7531\u4e8e ENUM \u7c7b\u578b\u7684\u7279\u6027\uff0c\u5728 WHERE \u6761\u4ef6\u4e2d\uff0cMatrixOne \u5c06 2 \u9690\u5f0f\u5730\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32 2
\uff0c\u7136\u540e\u4e0e Processing
\u8fdb\u884c\u6bd4\u8f83\u3002
ALTER TABLE
\u8bed\u53e5\u91cd\u5efa\u8868\u3002Decimal \u6570\u636e\u7c7b\u578b\u7528\u6765\u5b58\u50a8\u7cbe\u786e\u7684\u6570\u503c\u3002\u7cbe\u786e\u6570\u503c\u7c7b\u578b\u5728\u9700\u8981\u7528\u5230\u975e\u5e38\u51c6\u786e\u7684\u6570\u503c\u7cbe\u5ea6\u7684\u573a\u666f\u4e0b\u4f7f\u7528\uff0c\u6bd4\u5982\u94f6\u884c\u8d26\u6237\u6570\u5b57\uff0c\u6216\u8005\u4e25\u8c28\u7684\u79d1\u5b66\u8ba1\u7b97\u7b49\u3002 \u5728 Decimal \u7684\u5217\u540d\u58f0\u660e\u4e2d\uff0c\u6574\u6570\u548c\u5c0f\u6570\u90e8\u5206\u4e00\u822c\u90fd\u4f1a\u8fdb\u884c\u58f0\u660e\u3002\u6bd4\u5982\u4ee5\u4e0b\u4f8b\u5b50\uff1a
salary DECIMAL(5,2)\n
\u5728\u8fd9\u4e2a\u6848\u4f8b\u4e2d\uff0c5 \u662f\u6709\u6548\u6570\u5b57\u4f4d\u6570\uff0c2 \u662f\u5c0f\u6570\u4f4d\u3002\u6574\u6570\u7cbe\u5ea6\u8868\u793a\u6570\u503c\u90e8\u5206\u5b58\u50a8\u7684\u6709\u6548\u4f4d\u6570\uff0c\u5c0f\u6570\u7cbe\u5ea6\u8868\u793a\u5c0f\u6570\u90e8\u5206\u5b58\u50a8\u7684\u6709\u6548\u4f4d\u6570\u3002 \u6807\u51c6 SQL \u8981\u6c42 DECIMAL(5,2) \u9700\u8981\u5b58\u50a8 5 \u4f4d\u6570\u5b57\uff0c2 \u4f4d\u5c0f\u6570\uff0c\u56e0\u6b64\u5982\u679c\u4ee5\u8be5\u5f62\u5f0f\u8868\u793a\u7684\u5de5\u8d44\u5217\u6570\u5b57\u53d6\u503c\u8303\u56f4\u5e94\u8be5\u5728 -999.99 \u5230 999.99 \u4e4b\u95f4\u3002 \u5728 MatrixOne \u7684\u8bed\u6cd5\u4e2d\uff0cDECIMAL(M) \u4e0e DECIMAL(M,0) \u662f\u76f8\u540c\u7684\u3002\u5982\u679c\u76f4\u63a5\u53ea\u58f0\u660e DECIMAL \u7684\u8bdd\uff0c\u8bed\u6cd5\u4e5f\u5c06\u89e3\u6790\u6210 DECIMAL(M,0) \u7684\u5f62\u5f0f\uff0cM \u7684\u9ed8\u8ba4\u503c\u4e3a 10\u3002 \u5982\u679c\u5c0f\u6570\u7cbe\u5ea6\u4e3a 0 \u7684\u8bdd\uff0cDECIMAL \u76f8\u5f53\u4e8e\u7eaf\u6574\u6570\uff0c\u4e0d\u542b\u4efb\u4f55\u5c0f\u6570\u3002 MatrixOne \u4e2d DECIMAL \u7c7b\u578b\u7684\u6700\u5927\u4f4d\u6570\u4e3a 38 \u4f4d\u3002\u53e6\u5916 DECIMAL \u4e2d\u6307\u5b9a\u7684\u6574\u6570\u6216\u5c0f\u6570\u4f4d\u6570\u5728\u5b9e\u9645\u5217\u88ab\u8d4b\u503c\u7684\u65f6\u5019\u8d85\u51fa\u6307\u5b9a\u8303\u56f4\uff0c\u5b9e\u9645\u6570\u503c\u5c06\u4f1a\u88ab\u81ea\u52a8\u8f6c\u6362\u6210\u76f8\u5e94\u7cbe\u5ea6\u3002
"},{"location":"MatrixOne/Reference/Data-Types/fixed-point-types/#decimal","title":"Decimal \u6570\u636e\u7c7b\u578b\u7279\u70b9","text":"\u8be5\u90e8\u5206\u5185\u5bb9\u4e3b\u8981\u4ecb\u7ecd Decimal \u6570\u636e\u7c7b\u578b\u7684\u4e00\u4e9b\u7279\u70b9\uff0c\u5c24\u5176\u662f\u5728\u4f4d\u6570\u7cbe\u5ea6\u548c\u5b58\u50a8\u5f62\u5f0f\u4e0a\u7684\u3002
DECIMAL \u5217\u7684\u58f0\u660e\u8bed\u6cd5\u662f DECIMAL(M, D)\uff0cM \u662f\u6709\u6548\u6570\u5b57\u7684\u4f4d\u6570\uff0c\u53d6\u503c\u8303\u56f4\u662f 1 \u5230 38\uff0cD \u662f\u5c0f\u6570\u4f4d\u6570\uff0c\u53d6\u503c\u8303\u56f4\u662f 1 \u5230 38\uff0c\u4f46\u662f\u4e0d\u80fd\u5927\u4e8e M\u3002 \u5982\u679c\u4e0d\u6307\u5b9a D\uff0c\u9ed8\u8ba4\u4e3a 0\u3002\u5982\u679c\u4e0d\u6307\u5b9a M\uff0c\u9ed8\u8ba4\u4e3a 10\u3002
DECIMAL \u5217\u7684\u6570\u503c\u4ee5\u4e8c\u8fdb\u5236\u7684\u5f62\u5f0f\u8fdb\u884c\u5b58\u50a8\uff0c\u5728 MatrixOne \u5185\u90e8\uff0c\u53ea\u6709 decimal64 \u548c decimal128 \u8fd9\u4e24\u79cd\u8868\u793a\u5f62\u5f0f\u3002\u5728 0-18 \u4f4d\u7cbe\u5ea6\u5185\uff0c\u4e00\u4e2a Decimal \u6570\u503c\u5360\u7528 8 \u4e2a\u5b57\u8282\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5728 19-38 \u4f4d\u7cbe\u5ea6\u5185\uff0c\u4e00\u4e2a Decimal \u6570\u503c\u5360\u7528 16 \u4e2a\u5b57\u8282\u7684\u5b58\u50a8\u7a7a\u95f4\u3002
\u4f4d\u6570 \u5b57\u8282\u6570 0-18 8 \u4e2a\u5b57\u8282 19-38 16 \u4e2a\u5b57\u8282\u5bf9\u4e8e\u8be6\u7ec6\u7684 Decimal \u7c7b\u578b\u5b9e\u73b0\u65b9\u6cd5\uff0c\u53ef\u4ee5\u53c2\u8003 Decimal \u7684\u8bbe\u8ba1\u6587\u6863\u3002
"},{"location":"MatrixOne/Reference/Data-Types/json-type/","title":"JSON \u6570\u636e\u7c7b\u578b","text":"MatrixOne \u652f\u6301\u7531 RFC 7159 \u5b9a\u4e49\u7684\u539f\u751f JSON \u6570\u636e\u7c7b\u578b\uff0c\u53ef\u4ee5\u6709\u6548\u8bbf\u95ee JSON\uff08JavaScript \u5bf9\u8c61\u8868\u793a\u6cd5\uff09\u6587\u6863\u4e2d\u7684\u6570\u636e\u3002\u4e0e\u5c06 JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u5b58\u50a8\u5728\u5b57\u7b26\u4e32\u5217\u4e2d\u76f8\u6bd4\uff0cJSON \u6570\u636e\u7c7b\u578b\u5177\u6709\u4ee5\u4e0b\u4f18\u52bf\uff1a
\u81ea\u52a8\u9a8c\u8bc1\u5b58\u50a8\u5728 JSON \u5217\u4e2d\u7684 JSON \u6587\u6863\u3002\u65e0\u6548\u7684\u6587\u6863\u4f1a\u4ea7\u751f\u62a5\u9519\u3002
\u81ea\u52a8\u4f18\u5316\u5b58\u50a8\u683c\u5f0f\u3002\u5b58\u50a8\u5728 JSON \u5217\u4e2d\u7684 JSON \u6587\u6863\u8f6c\u6362\u4e3a\u5141\u8bb8\u5bf9\u6587\u6863\u5143\u7d20\u8fdb\u884c\u5feb\u901f\u8bfb\u53d6\u8bbf\u95ee\u7684\u5185\u90e8\u683c\u5f0f\u3002\u5f53\u670d\u52a1\u5668\u5fc5\u987b\u8bfb\u53d6\u4ee5\u8fd9\u79cd\u4e8c\u8fdb\u5236\u683c\u5f0f\u5b58\u50a8\u7684 JSON \u503c\u65f6\uff0c\u4e0d\u9700\u8981\u4ece\u6587\u672c\u4e2d\u89e3\u6790\u8be5\u503c\u3002\u4e8c\u8fdb\u5236\u683c\u5f0f\u7684\u7ed3\u6784\u4f7f\u670d\u52a1\u5668\u80fd\u591f\u76f4\u63a5\u901a\u8fc7\u952e\u6216\u6570\u7ec4\u7d22\u5f15\u67e5\u627e\u5b50\u5bf9\u8c61\u6216\u5d4c\u5957\u503c\u3002
\u5b58\u50a8 JSON \u6587\u6863\u6240\u9700\u7684\u5b58\u50a8\u7a7a\u95f4\u4e0e BLOB
\u6216 TEXT
\u5927\u81f4\u76f8\u540c\u3002
JSON \u7c7b\u578b\u6709 JSON \u6570\u7ec4\u548c JSON \u5bf9\u8c61\u3002
[]
\u5b57\u7b26\u5185\u7684\u503c\u5217\u8868\uff0c\u5982\uff1a[\"abc\", 10, null, true, false]\n
{}
\u5b57\u7b26\u5185\uff0c\u5982\uff1a{\"k1\": \"value\", \"k2\": 10}\n
JSON \u6570\u7ec4\u548c\u5bf9\u8c61\u53ef\u4ee5\u5305\u542b\u6807\u91cf\u503c\uff0c\u5373\u5b57\u7b26\u4e32\u6216\u6570\u5b57\u3001JSON \u7a7a\u5b57\u9762\u91cf\u6216 JSON \u5e03\u5c14\u771f\u6216\u5047\u5b57\u9762\u91cf\u3002JSON \u5bf9\u8c61\u4e2d\u7684\u952e\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u3002JSON \u4e5f\u5141\u8bb8\u65f6\u95f4\uff08\u65e5\u671f\uff0c\u65e5\u671f\u65f6\u95f4\uff09\u6807\u91cf\u503c\u3002\u5982\uff1a
[\"12:18:29.000000\", \"2015-07-29\", \"2015-07-29 12:18:29.000000\"]\n
\u5728 JSON \u6570\u7ec4\u5143\u7d20\u548c JSON \u5bf9\u8c61\u952e\u503c\u4e2d\u53ef\u5d4c\u5957\uff0c\u5982\uff1a
[99, {\"id\": \"HK500\", \"cost\": 75.99}, [\"hot\", \"cold\"]]\n{\"k1\": \"value\", \"k2\": [10, 20]}\n
"},{"location":"MatrixOne/Reference/Data-Types/json-type/#json_2","title":"JSON \u503c\u7684\u89c4\u8303\u5316","text":"\u5f53\u4e00\u4e2a\u5b57\u7b26\u4e32\u88ab\u89e3\u6790\u4e3a\u6709\u6548\u7684 JSON \u6587\u6863\u65f6\uff0c\u5b83\u4e5f\u4f1a\u88ab\u89c4\u8303\u5316\u3002\u8fd9\u8868\u793a\u610f\u5473\u7740\u5177\u6709\u4e0e\u7a0d\u540e\u5728\u6587\u6863\u4e2d\u627e\u5230\u7684\u952e\u91cd\u590d\u7684\u952e\u7684\u6210\u5458\uff0c\u4ece\u5de6\u5230\u53f3\u8bfb\u53d6\uff0c\u5c06\u88ab\u4e22\u5f03\u3002\u8fd9\u610f\u5473\u7740\u4ece\u5de6\u5f80\u53f3\u8bfb\u53d6\u65f6\uff0c\u540e\u9762\u51fa\u73b0\u7684\u91cd\u590d\u7684\u7684\u952e\u503c\u5c06\u88ab\u5ffd\u7565\u3002
\u5c06\u503c\u63d2\u5165 JSON \u5217\u65f6\u6267\u884c\u89c4\u8303\u5316\uff0c\u5982\u4e0b\u6240\u793a\uff1a
CREATE TABLE t1 (c1 JSON);\nINSERT INTO t1 VALUES\n('{\"x\": 17, \"x\": \"red\"}'),\n('{\"x\": 17, \"x\": \"red\", \"x\": [3, 5, 7]}');\n\nmysql> SELECT c1 FROM t1;\n+------------------+\n| c1 |\n+------------------+\n| {\"x\": \"red\"} |\n| {\"x\": [3, 5, 7]} |\n+------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/uuid-type/","title":"UUID \u7c7b\u578b","text":"UUID \u662f\u4e00\u79cd\u901a\u7528\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u5b83\u7531 32 \u4f4d\u5341\u516d\u8fdb\u5236\u6570\u5b57\u4ee5\u53ca 4 \u4f4d\u8fde\u5b57\u7b26\u7ec4\u6210\u3002UUID \u5177\u6709\u5168\u5c40\u7684\u552f\u4e00\u6027\uff0c\u800c\u4e0d\u662f\u6570\u636e\u5e93\u4e2d\u7684\u552f\u4e00\u6027\uff0c\u5373\u4f7f\u662f\u5728\u4e24\u4e2a\u672a\u8fde\u63a5\u7684\u72ec\u7acb\u8fd0\u884c\u7684\u8bbe\u5907\u4e0a\u6267\u884c UUID \u8c03\u7528\uff0c\u9884\u8ba1\u4f1a\u751f\u6210\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u3002UUID \u5e38\u5e38\u88ab\u7528\u6765\u4e3a\u5bf9\u5e94\u884c\u751f\u6210\u7684\u4e00\u4e2a\u968f\u673a\u503c\uff0c\u4ee5\u786e\u4fdd\u6bcf\u6761\u8bb0\u5f55\u7684\u552f\u4e00\u6027\u3002UUID \u9002\u5408\u5728\u96c6\u7fa4\u73af\u5883\u4e2d\u4f5c\u4e3a\u552f\u4e00\u6807\u8bc6\u7b26\u3002
Info
\u5c3d\u7ba1 UUID()
\u503c\u552f\u4e00\uff0c\u4f46\u5b83\u4eec\u5e76\u975e\u662f\u4e0d\u53ef\u731c\u6d4b\u6216\u4e0d\u53ef\u9884\u6d4b\u7684\u3002\u5982\u679c\u9700\u8981\u4e0d\u53ef\u9884\u6d4b\u6027\uff0c\u5219\u5e94\u4ee5\u5176\u4ed6\u65b9\u5f0f\u751f\u6210 UUID \u503c\u3002
UUID()
\u8fd4\u56de\u4e00\u4e2a\u7b26\u5408 RFC 4122 \u6807\u51c6\u7684\u7248\u672c 1 UUID \u7684\u503c\uff0c\u4e3a 128 \u4f4d\u6570\u5b57\uff0c\u5b83\u8868\u793a\u662f\u4e00\u4e2a utf8mb3 \u7531\u4e94\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u5373 aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\uff0c\u683c\u5f0f\u89e3\u91ca\u5982\u4e0b\uff1a
\u524d\u4e09\u4e2a\u6570\u5b57\u662f\u4ece\u65f6\u95f4\u6233\u7684\u4f4e\u3001\u4e2d\u548c\u9ad8\u90e8\u5206\u751f\u6210\u7684\u3002\u9ad8\u4f4d\u90e8\u5206\u8fd8\u5305\u62ec UUID \u7248\u672c\u53f7\u3002
\u7b2c\u56db\u4e2a\u6570\u5b57\u4fdd\u7559\u65f6\u95f4\u552f\u4e00\u6027\uff0c\u4ee5\u9632\u65f6\u95f4\u6233\u503c\u5931\u53bb\u5355\u4e00\u6027\uff08\u4f8b\u5982\uff0c\u590f\u4ee4\u65f6\uff09\u3002
\u7b2c\u4e94\u4e2a\u6570\u5b57\u662f\u7a7a\u95f4\u552f\u4e00\u6027\u7684 IEEE 802 \u8282\u70b9\u53f7\u3002\u5982\u679c\u540e\u8005\u4e0d\u53ef\u7528\uff08\u4f8b\u5982\uff0c\u56e0\u4e3a\u4e3b\u673a\u8bbe\u5907\u6ca1\u6709\u4ee5\u592a\u7f51\u5361\uff0c\u6216\u8005\u4e0d\u77e5\u9053\u5982\u4f55\u5728\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u627e\u5230\u63a5\u53e3\u7684\u786c\u4ef6\u5730\u5740\uff09\uff0c\u5219\u7528\u968f\u673a\u6570\u4ee3\u66ff\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e0\u6cd5\u4fdd\u8bc1\u7a7a\u95f4\u552f\u4e00\u6027\u3002\u7136\u800c\uff0c\u7b2c\u4e94\u4f4d\u6570\u5b57\u91cd\u5408\u7684\u6982\u7387\u5f88\u4f4e\u3002
UUID \u7c7b\u578b\u652f\u6301\u7684 SQL \u8bed\u53e5\uff1a
CREATE
\u8bed\u53e5\uff1a\u53ef\u4ee5\u521b\u5efa\u5177\u6709 UUID \u7c7b\u578b\u5b57\u6bb5\u7684\u8868\u3002INSERT
/UPDATE
/DELETE
\u8bed\u53e5\uff1a\u5141\u8bb8\u5bf9 UUID \u7c7b\u578b\u7684\u6570\u636e\u8fdb\u884c\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u3002SELECT
\u8bed\u53e5\uff1a\u53ef\u4ee5\u67e5\u8be2 UUID \u7c7b\u578b\u5b57\u6bb5\uff0c\u67e5\u8be2\u7ed3\u679c\u5728\u5ba2\u6237\u7aef\u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u5c55\u793a\u3002UUID \u7c7b\u578b\u652f\u6301\u7684 SQL \u8bed\u53e5\u5b50\u53e5\uff1a
ORDER BY
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u4f5c\u6392\u5e8f\u6761\u4ef6\u3002WHERE
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u5728 WHERE
\u5b50\u53e5\u4e2d\uff0c\u652f\u6301\u6bd4\u8f83\u64cd\u4f5c\u3002HAVING
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u5728 HAVING
\u5b50\u53e5\u4e2d\uff0c\u652f\u6301\u6bd4\u8f83\u64cd\u4f5c\u3002GROUP BY
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u4f5c GROUP BY
\u7684\u5206\u7ec4\u6761\u4ef6\u3002\u5176\u4ed6\u652f\u6301\u7684 UUID \u7c7b\u578b\u529f\u80fd\uff1a
mysql> select uuid();\n+--------------------------------------+\n| uuid() |\n+--------------------------------------+\n| 4aa4f4de-1b00-11ee-b656-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\n-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868 't1'\uff0c\u5305\u542b\u4e24\u4e2a\u5217 'a' \u548c 'b'\uff0c\u5217 'a' \u7684\u7c7b\u578b\u4e3a INT\uff0c\u5217 'b' \u7684\u7c7b\u578b\u4e3a float\ncreate table t1(a INT, b float);\n\n-- \u5411\u8868 't1' \u63d2\u5165\u4e24\u884c\u6570\u636e\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\n-- \u67e5\u8be2 't1' \u8868\u7684\u884c\u6570\uff0c\u5e76\u751f\u6210\u6bcf\u4e00\u884c\u7684 uuid() \u51fd\u6570\u7684\u957f\u5ea6\uff0c\u6ce8\u610f\u8fd9\u91cc uuid() \u51fd\u6570\u751f\u6210\u7684\u662f\u4e00\u4e2a\u65b0\u7684 UUID\uff0c\n-- \u4e0d\u4f9d\u8d56\u4e8e 't1' \u8868\u7684\u4efb\u4f55\u6570\u636e\uff0c\u8fd4\u56de\u7684\u957f\u5ea6\u4e3a 36\uff0c\u56e0\u4e3a UUID \u662f\u4e00\u4e2a\u5305\u542b 32 \u4e2a\u5b57\u7b26\u548c 4 \u4e2a\u77ed\u5212\u7ebf\u7684 36 \u4e2a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\nmysql> SELECT length(uuid()) FROM t1;\n\n+----------------+\n| length(uuid()) |\n+----------------+\n| 36 |\n| 36 |\n+----------------+\n2 rows in set (0.00 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 't1' \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u540d\u4e3a 'a' \u7684\u5217\uff0c\u6570\u636e\u7c7b\u578b\u4e3a VARCHAR\uff0c\u6700\u5927\u957f\u5ea6\u4e3a 20\ncreate table t1(a varchar(20));\n\n-- \u5728 't1' \u8868\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0c 'a' \u5217\u7684\u503c\u4e3a '123123sdafsdf'\ninsert into t1 values('123123sdafsdf');\n\n-- \u4ece 't1' \u8868\u4e2d\u9009\u62e9\u6240\u6709\u7684\u884c\uff0c\u5e76\u8fd4\u56de\u6bcf\u4e00\u884c\u7684 'a' \u5217\u7684\u503c\uff0c\u4ee5\u53ca\u4e00\u4e2a\u65b0\u751f\u6210\u7684 UUID \u503c\nmysql> select uuid(),a from t1;\n+--------------------------------------+---------------+\n| uuid() | a |\n+--------------------------------------+---------------+\n| 664f1a96-1981-11ee-a041-5ad2460dea50 | 123123sdafsdf |\n+--------------------------------------+---------------+\n1 row in set (0.01 sec)\n
-- \u521b\u5efa\u540d\u4e3a namelists \u7684\u8868\uff0c\u5305\u542b id \u548c name \u4e24\u4e2a\u5b57\u6bb5\nCREATE TABLE namelists (\nid UUID DEFAULT uuid() PRIMARY KEY, -- id \u5b57\u6bb5\u662f UUID \u7c7b\u578b\uff0c\u9ed8\u8ba4\u503c\u4e3a uuid() \u51fd\u6570\u751f\u6210\u7684 UUID \u503c\uff0c\u4f5c\u4e3a\u4e3b\u952e\nname VARCHAR NOT NULL -- name \u5b57\u6bb5\u662f VARCHAR \u7c7b\u578b\uff0c\u4e0d\u80fd\u4e3a\u7a7a\n);\nINSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');\nmysql> select * from namelists;\n+--------------------------------------+--------+\n| id | name |\n+--------------------------------------+--------+\n| 61400e9c-1bbc-11ee-b512-5ad2460dea50 | Tom |\n| 61400ea6-1bbc-11ee-b512-5ad2460dea50 | Jane |\n| 61400ea6-1bbc-11ee-b513-5ad2460dea50 | Bob |\n+--------------------------------------+--------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/","title":"\u5411\u91cf\u7c7b\u578b","text":"\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u5411\u91cf\u901a\u5e38\u662f\u4e00\u7ec4\u6570\u5b57\uff0c\u5b83\u4eec\u4ee5\u7279\u5b9a\u7684\u65b9\u5f0f\u6392\u5217\uff0c\u4ee5\u8868\u793a\u67d0\u79cd\u6570\u636e\u6216\u7279\u5f81\u3002\u8fd9\u4e9b\u5411\u91cf\u53ef\u4ee5\u662f\u4e00\u7ef4\u6570\u7ec4\u3001\u591a\u7ef4\u6570\u7ec4\u6216\u5177\u6709\u66f4\u9ad8\u7ef4\u5ea6\u7684\u6570\u636e\u7ed3\u6784\u3002MatrixOne \u652f\u6301\u5411\u91cf\u6570\u636e\u7c7b\u578b\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5411\u91cf\u88ab\u8bbe\u8ba1\u6210\u4e00\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u7c7b\u4f3c\u4e8e\u7f16\u7a0b\u8bed\u8a00\u4e2d\u7684 Array \u6570\u7ec4 (MatrixOne \u76ee\u524d\u8fd8\u4e0d\u652f\u6301\u6570\u7ec4\u7c7b\u578b)\uff0c\u4f46\u662f\u662f\u4e00\u79cd\u8f83\u4e3a\u7279\u6b8a\u7684\u6570\u7ec4\u7c7b\u578b\u3002\u9996\u5148\uff0c\u5b83\u662f\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\u7c7b\u578b\uff0c\u610f\u5473\u7740\u5b83\u4e0d\u80fd\u7528\u6765\u6784\u5efa Matrix \u77e9\u9635\u3002\u53e6\u5916\u76ee\u524d\u4ec5\u652f\u6301 float32
\u53ca float64
\u7c7b\u578b\u7684\u5411\u91cf\uff0c\u5206\u522b\u79f0\u4e4b\u4e3a vecf32
\u4e0e vecf64
\u800c\u4e0d\u652f\u6301\u5b57\u7b26\u4e32\u7c7b\u578b\u548c\u6574\u578b\u7c7b\u578b\u7684\u6570\u5b57\u3002
\u521b\u5efa\u4e00\u4e2a\u5411\u91cf\u5217\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u5411\u91cf\u5217\u7684\u7ef4\u5ea6\u5927\u5c0f\uff0c\u5982 vecf32(3)\uff0c\u8fd9\u4e2a\u7ef4\u5ea6\u5373\u5411\u91cf\u7684\u6570\u7ec4\u7684\u957f\u5ea6\u5927\u5c0f\uff0c\u6700\u5927\u53ef\u652f\u6301\u5230 65,535 \u7ef4\u5ea6\u3002
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#sql","title":"\u5982\u4f55\u5728 SQL \u4e2d\u4f7f\u7528\u5411\u91cf\u7c7b\u578b","text":"\u4f7f\u7528\u5411\u91cf\u7684\u8bed\u6cd5\u4e0e\u5e38\u89c4\u5efa\u8868\u3001\u63d2\u5165\u6570\u636e\u3001\u67e5\u8be2\u6570\u636e\u76f8\u540c\u3002
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#_2","title":"\u521b\u5efa\u5411\u91cf\u5217","text":"\u4f60\u53ef\u4ee5\u6309\u7167\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u521b\u5efa\u4e86\u4e24\u4e2a\u5411\u91cf\u5217\uff0c\u4e00\u4e2a\u662f Float32 \u7c7b\u578b\uff0c\u53e6\u4e00\u4e2a\u662f Float64 \u7c7b\u578b\uff0c\u5e76\u4e14\u53ef\u4ee5\u5c06\u4e24\u4e2a\u5411\u91cf\u5217\u7684\u7ef4\u5ea6\u90fd\u8bbe\u7f6e\u4e3a 3\u3002
\u76ee\u524d\u5411\u91cf\u7c7b\u578b\u4e0d\u80fd\u4f5c\u4e3a\u4e3b\u952e\u6216\u8005\u552f\u4e00\u952e\u3002
create table t1(a int, b vecf32(3), c vecf64(3));\n
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#_3","title":"\u63d2\u5165\u5411\u91cf","text":"MatrixOne \u652f\u6301\u4ee5\u4e24\u79cd\u683c\u5f0f\u63d2\u5165\u5411\u91cf\u3002
\u6587\u672c\u683c\u5f0f
insert into t1 values(1, \"[1,2,3]\", \"[4,5,6]\");\n
\u4e8c\u8fdb\u5236\u683c\u5f0f
\u5982\u679c\u4f60\u60f3\u4f7f\u7528 Python NumPy \u6570\u7ec4\uff0c\u53ef\u4ee5\u901a\u8fc7\u5bf9\u6570\u7ec4\u8fdb\u884c\u5341\u516d\u8fdb\u5236\u7f16\u7801\uff0c\u800c\u4e0d\u662f\u5c06\u5176\u8f6c\u6362\u4e3a\u9017\u53f7\u5206\u9694\u7684\u6587\u672c\u683c\u5f0f\uff0c\u76f4\u63a5\u5c06\u8be5 NumPy \u6570\u7ec4\u63d2\u5165 MatrixOne\u3002\u5728\u63d2\u5165\u7ef4\u5ea6\u8f83\u9ad8\u7684\u5411\u91cf\u65f6\uff0c\u8fd9\u79cd\u65b9\u5f0f\u901f\u5ea6\u66f4\u5feb\u3002
insert into t1 (a, b) values (2, cast(unhex(\"7e98b23e9e10383b2f41133f\") as blob));\n-- \"7e98b23e9e10383b2f41133f\" \u8868\u793a []float32{0.34881967, 0.0028086076, 0.5752134}\u7684\u5c0f\u7aef\u5341\u516d\u8fdb\u5236\u7f16\u7801\n
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#_4","title":"\u67e5\u8be2\u5411\u91cf","text":"\u5411\u91cf\u5217\u540c\u6837\u53ef\u4ee5\u4ee5\u4e24\u79cd\u683c\u5f0f\u8bfb\u53d6\u3002
\u6587\u672c\u683c\u5f0f
mysql> select a, b from t1;\n+------+---------------------------------------+\n| a | b |\n+------+---------------------------------------+\n| 1 | [1, 2, 3] |\n| 2 | [0.34881967, 0.0028086076, 0.5752134] |\n+------+---------------------------------------+\n2 rows in set (0.00 sec)\n
\u4e8c\u8fdb\u5236\u683c\u5f0f
\u5982\u679c\u4f60\u9700\u8981\u5c06\u5411\u91cf\u7ed3\u679c\u96c6\u76f4\u63a5\u8bfb\u53d6\u5230 NumPy \u6570\u7ec4\u4e2d\uff0c\u4ee5\u6700\u5c0f\u7684\u8f6c\u6362\u6210\u672c\uff0c\u4e8c\u8fdb\u5236\u683c\u5f0f\u975e\u5e38\u6709\u7528\u3002
mysql> select hex(b) from t1;\n+--------------------------+\n| hex(b) |\n+--------------------------+\n| 0000803f0000004000004040 |\n| 7e98b23e9e10383b2f41133f |\n+--------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/","title":"TIMESTAMP \u548c DATETIME \u7684\u81ea\u52a8\u521d\u59cb\u5316\u548c\u66f4\u65b0","text":"TIMESTAMP
\u548c DATETIME
\u5217\u53ef\u4ee5\u81ea\u52a8\u521d\u59cb\u5316\u5e76\u66f4\u65b0\u4e3a\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\uff08\u5373\u5f53\u524d\u65f6\u95f4\u6233\uff09\u3002
\u5bf9\u4e8e\u8868\u4e2d\u7684\u4efb\u4f55 TIMESTAMP
\u6216 DATETIME
\u5217\uff0c\u4f60\u53ef\u4ee5\u5c06\u5f53\u524d\u65f6\u95f4\u6233\u6307\u5b9a\u4e3a\u9ed8\u8ba4\u503c\u3001\u81ea\u52a8\u66f4\u65b0\u503c\u6216\u4e24\u8005\u5747\u53ef\uff1a
\u5bf9\u4e8e\u672a\u4e3a\u5217\u6307\u5b9a\u503c\u7684\u63d2\u5165\u884c\uff0c\u5c06\u81ea\u52a8\u521d\u59cb\u5316\u7684\u5217\u8bbe\u7f6e\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002
\u5f53\u884c\u4e2d\u4efb\u4f55\u5176\u4ed6\u5217\u7684\u503c\u4ece\u5f53\u524d\u503c\u8fdb\u884c\u66f4\u6539\u65f6\uff0c\u81ea\u52a8\u66f4\u65b0\u5217\u5c06\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002\u5982\u679c\u6240\u6709\u5176\u4ed6\u5217\u90fd\u8bbe\u7f6e\u4e3a\u5f53\u524d\u503c\uff0c\u5219\u81ea\u52a8\u66f4\u65b0\u7684\u5217\u4fdd\u6301\u4e0d\u53d8\u3002\u82e5\u8981\u9632\u6b62\u81ea\u52a8\u66f4\u65b0\u7684\u5217\u5728\u5176\u4ed6\u5217\u66f4\u6539\u65f6\u66f4\u65b0\uff0c\u8bf7\u663e\u5f0f\u5c06\u5176\u8bbe\u7f6e\u4e3a\u5f53\u524d\u503c\u3002\u8981\u66f4\u65b0\u81ea\u52a8\u66f4\u65b0\u7684\u5217\uff0c\u5373\u4f7f\u5176\u4ed6\u5217\u6ca1\u6709\u66f4\u6539\uff0c\u4e5f\u8981\u663e\u5f0f\u5730\u5c06\u5176\u8bbe\u7f6e\u4e3a\u5b83\u5e94\u8be5\u5177\u6709\u7684\u503c (\u4f8b\u5982\uff0c\u5c06\u5176\u8bbe\u7f6e\u4e3a CURRENT_TIMESTAMP
)\u3002
\u8981\u6307\u5b9a\u81ea\u52a8\u5c5e\u6027\uff0c\u8bf7\u5728\u5217\u5b9a\u4e49\u4e2d\u4f7f\u7528 DEFAULT CURRENT_TIMESTAMP
\u548c ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\u3002\u4e24\u4e2a\u5b50\u53e5\u5982\u679c\u540c\u65f6\u5b9a\u4e49\u4e00\u4e2a\u5217\uff0c\u5b83\u4eec\u7684\u987a\u5e8f\u53ef\u4e92\u6362\uff0c\u4e0d\u5f71\u54cd\u903b\u8f91\u8ba1\u7b97\u3002\u53e6\u5916\uff0cCURRENT_TIMESTAMP
\u4e0e CURRENT_TIMESTAMP()
\u6216\u8005 NOW()
\u610f\u4e49\u4e00\u81f4\u3002
DEFAULT CURRENT_TIMESTAMP
\u548c ON UPDATE CURRENT_TIMESTAMP
\u7684\u4f7f\u7528\u662f\u7279\u5b9a\u4e8e TIMESTAMP
\u548c DATETIME
\u7684\u3002DEFAULT
\u5b50\u53e5\u8fd8\u53ef\u7528\u4e8e\u6307\u5b9a\u5e38\u91cf\uff08\u975e\u81ea\u52a8\uff09\u9ed8\u8ba4\u503c\uff08\u4f8b\u5982\uff0cDEFAULT 0
\u6216 DEFAULT '2000-01-01 00:00:00'
\uff09\u3002
TIMESTAMP
\u6216 DATETIME
\u5217\u5b9a\u4e49\u53ef\u4ee5\u4e3a\u9ed8\u8ba4\u503c\u548c\u81ea\u52a8\u66f4\u65b0\u503c\u6307\u5b9a\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u4ec5\u6307\u5b9a\u5176\u4e2d\u4e00\u4e2a\uff0c\u6216\u8005\u4e24\u8005\u90fd\u4e0d\u6307\u5b9a\u3002\u4e0d\u540c\u7684\u5217\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u81ea\u52a8\u5c5e\u6027\u7ec4\u5408\u3002\u4ee5\u4e0b\u89c4\u5219\u63cf\u8ff0\u4e86\u8fd9\u4e9b\u53ef\u80fd\u6027\uff1a
DEFAULT CURRENT_TIMESTAMP
\u548c ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\u65f6\uff0c\u5217\u7684\u9ed8\u8ba4\u503c\u662f\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u5e76\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n
DEFAULT
\u5b50\u53e5\uff0c\u4e0d\u4f7f\u7528 ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\uff0c\u8be5\u5217\u5177\u6709\u7ed9\u5b9a\u7684\u9ed8\u8ba4\u503c\uff0c\u4f46\u4e0d\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002\u9ed8\u8ba4\u503c\u53d6\u51b3\u4e8e DEFAULT
\u5b50\u53e5\u662f\u6307\u5b9a CURRENT_TIMESTAMP
\u8fd8\u662f\u5e38\u91cf\u503c\u3002\u4f7f\u7528 CURRENT_TIMESTAMP
\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002
CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n dt DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n
\u5bf9\u4e8e\u5e38\u91cf\uff0c\u9ed8\u8ba4\u503c\u662f\u7ed9\u5b9a\u503c\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8be5\u5217\u6ca1\u6709\u81ea\u52a8\u5c5e\u6027\u3002
CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT 0,\n dt DATETIME DEFAULT 0\n);\n
ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\u548c\u5e38\u91cf DEFAULT
\u5b50\u53e5\uff0c\u8be5\u5217\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u5e76\u4f7f\u7528\u7ed9\u5b9a\u7684\u5e38\u91cf\u9ed8\u8ba4\u503c\u3002CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP,\n dt DATETIME DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP\n);\n
ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\uff0c\u4f46\u4e0d\u4f7f\u7528 DEFAULT
\u5b50\u53e5\u65f6\uff0c\u5217\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u4f46\u5176\u9ed8\u8ba4\u503c\u6ca1\u6709\u5f53\u524d\u65f6\u95f4\u6233\u3002TIMESTAMP
\u7684\u9ed8\u8ba4\u503c\u4e3a 0\uff1b\u82e5\u4f7f\u7528 NULL
\u5c5e\u6027\u5b9a\u4e49\uff0c\u5219\u9ed8\u8ba4\u503c\u4e3a NULL
\u3002
CREATE TABLE t1 (\n ts1 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- default 0\n ts2 TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP -- default NULL\n);\n
DATETIME
\u7684\u9ed8\u8ba4\u503c\u4e3a NULL
\uff1b\u82e5\u4f7f\u7528 NOT NULL
\u5c5e\u6027\u5b9a\u4e49\uff0c\u5219\u9ed8\u8ba4\u503c\u4e3a 0\u3002
CREATE TABLE t1 (\n dt1 DATETIME ON UPDATE CURRENT_TIMESTAMP, -- default NULL\n dt2 DATETIME NOT NULL ON UPDATE CURRENT_TIMESTAMP -- default 0\n);\n
"},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/year-type/","title":"YEAR \u7c7b\u578b","text":"YEAR \u7c7b\u578b\u662f\u7528\u4e8e\u8868\u793a\u5e74\u4efd\u503c\u7684 1 \u5b57\u8282\u7c7b\u578b\u3002\u53ef\u4ee5\u58f0\u660e\u4e3a YEAR\uff0c\u5176\u9690\u5f0f\u663e\u793a\u5bbd\u5ea6\u4e3a 4 \u4e2a\u5b57\u7b26\uff0c\u6216\u7b49\u6548\u5730\u58f0\u660e\u4e3a YEAR(4)
\uff0c\u663e\u5f0f\u6307\u5b9a\u663e\u793a\u5bbd\u5ea6\u4e3a 4\u3002
MatrixOne \u4ee5 YYYY \u683c\u5f0f\u663e\u793a YEAR \u503c\uff0c\u8303\u56f4\u4ece 0001 \u5e74\u5230 9999 \u5e74\u3002
YEAR \u63a5\u53d7\u5404\u79cd\u683c\u5f0f\u7684\u8f93\u5165\u503c\uff1a
NOW()
\u3002\u7531\u4e8e\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\u7f3a\u4e4f\u4e16\u7eaa\u6570\u503c\uff0c\u5176\u542b\u4e49\u4e0d\u591f\u660e\u786e\u3002\u4e3a\u4e86\u5185\u90e8\u5b58\u50a8\u7684\u4e00\u81f4\u6027\uff0cMatrixOne \u5fc5\u987b\u5c06\u8fd9\u4e9b\u65e5\u671f\u503c\u89e3\u91ca\u4e3a 4 \u4f4d\u6570\u5b57\u5f62\u5f0f\u3002
\u5bf9\u4e8e DATETIME\u3001DATE \u548c TIMESTAMP \u7c7b\u578b\uff0cMatrixOne \u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\u89e3\u91ca\u5177\u6709\u4e0d\u660e\u786e\u5e74\u4efd\u503c\u7684\u65e5\u671f\uff1a
\u4e0b\u9762\u662f\u5173\u4e8e\u6d89\u53ca 2 \u4f4d\u5e74\u4efd\u65e5\u671f\u7684\u4f8b\u5b50\uff1a
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a event_date
\u7684 DATETIME \u7c7b\u578b\u7684\u5217\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u65e5\u671f\u503c\uff1a
\u6839\u636e\u89c4\u5219\uff0c\u65e5\u671f\u503c\u4e2d\u7684 2 \u4f4d\u5e74\u4efd\u88ab\u89e3\u91ca\u4e3a\uff1a
23-05-06 \u88ab\u89e3\u91ca\u4e3a 0023 \u5e74 5 \u6708 6 \u65e5\u3002
\u89e3\u91ca DATE \u7c7b\u578b\u7684\u65e5\u671f\uff1a
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a birth_date
\u7684 DATE \u7c7b\u578b\u7684\u5217\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u65e5\u671f\u503c\uff1a
\u6839\u636e\u89c4\u5219\uff0c\u65e5\u671f\u503c\u4e2d\u7684 2 \u4f4d\u5e74\u4efd\u88ab\u89e3\u91ca\u4e3a\uff1a
88-03-17 \u88ab\u89e3\u91ca\u4e3a 0088 \u5e74 3 \u6708 17 \u65e5\u3002
\u89e3\u91ca YEAR \u7c7b\u578b\u7684\u65e5\u671f\uff1a
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a graduation_year
\u7684 YEAR \u7c7b\u578b\u7684\u5217\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u5e74\u4efd\u503c\uff1a
\u6839\u636e\u89c4\u5219\uff0c\u5e74\u4efd\u503c\u4e2d\u7684 2 \u4f4d\u5e74\u4efd\u88ab\u89e3\u91ca\u4e3a\uff1a
\u672c\u6587\u6863\u5217\u51fa\u4e86 MatrixOne \u6700\u65b0\u7248\u672c\u6240\u652f\u6301\u7684\u51fd\u6570\u6e05\u5355\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_2","title":"\u805a\u5408\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 ANY_VALUE() \u5728\u53c2\u6570\u8303\u56f4\u5185\u4efb\u9009\u4e00\u4e2a\u503c\u8fd4\u56de AVG() \u8ba1\u7b97\u53c2\u6570\u5217\u7684\u7b97\u672f\u5e73\u5747\u503c\u3002 BITMAP \u4e00\u7ec4\u7528\u4e8e\u5904\u7406\u4f4d\u56fe\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u4e3b\u8981\u7528\u4e8e\u8ba1\u7b97\u4e0d\u540c\u503c BIT_AND() \u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u4e0e BIT_OR() \u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u6216 BIT_XOR() \u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u5f02\u6216 COUNT() \u8ba1\u7b97\u4e86\u67e5\u8be2\u7ed3\u679c\u7684\u8bb0\u5f55\u6570 GROUP_CONCAT() \u5c06\u901a\u8fc7\u5217\u6216\u8005\u8868\u8fbe\u5f0f\u6307\u5b9a\u7684\u5185\u5bb9\u8fde\u63a5\u8d77\u6765 MAX() \u8fd4\u56de\u4e00\u7ec4\u503c\u7684\u6700\u5927\u503c MEDIAN() \u8fd4\u56de\u4e00\u7ec4\u6570\u503c\u7684\u4e2d\u503c MIN() \u8fd4\u56de\u4e00\u7ec4\u503c\u7684\u6700\u5c0f\u503c STDDEV_POP() \u7528\u4e8e\u8ba1\u7b97\u603b\u4f53\u6807\u51c6\u5dee SUM() \u7528\u4e8e\u8ba1\u7b97\u4e00\u7ec4\u503c\u7684\u548c VARIANCE() \u7528\u4e8e\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee VAR_POP() \u7528\u4e8e\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_3","title":"\u65e5\u671f\u65f6\u95f4\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 CONVERT_TZ() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u65e5\u671f\u65f6\u95f4\u4ece\u4e00\u4e2a\u65f6\u533a\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u65f6\u533a\u3002 CURDATE() \u8fd4\u56de\u5f53\u524d\u65e5\u671f\u7684 YYYY-MM-DD \u683c\u5f0f\u7684\u503c CURRENT_TIMESTAMP() \u5c06\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss \u6216 YYYYMMDDhhmmss \u7684\u683c\u5f0f\u8fd4\u56de DATE() \u5c06 DATE \u6216\u8005 DATETIME \u683c\u5f0f\u7684\u8f93\u5165\u4e2d\u7684\u65e5\u671f\u90e8\u5206\u622a\u53d6\u51fa\u6765\u3002 DATE_ADD() \u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1a\u4ece\u6307\u5b9a\u65e5\u671f\u4e2d\u52a0\u4e0a\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694 DATE_FORMAT() \u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65e5\u671f\u503c DATE_SUB() \u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1a\u4ece\u6307\u5b9a\u65e5\u671f\u4e2d\u51cf\u53bb\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694 DATEDIFF() \u8fd4\u56de\u4e24\u4e2a\u65e5\u671f\u4e4b\u95f4\u7684\u5929\u6570 DAY() \u8fd4\u56de\u67d0\u65e5\u671f\u4e3a\u5f53\u6708\u7684\u7b2c\u51e0\u53f7 DAYOFYEAR() \u8fd4\u56de\u65e5\u671f\u6240\u5bf9\u5e94\u5728\u4e00\u5e74\u4e2d\u7684\u5929\u6570 EXTRACT() \u4ece\u65e5\u671f\u4e2d\u63d0\u53d6\u90e8\u5206\u5185\u5bb9 HOUR() \u8fd4\u56de\u65f6\u95f4\u7684\u5c0f\u65f6\u6570 FROM_UNIXTIME() \u628a\u5185\u90e8 UNIX \u65f6\u95f4\u6233\u503c\u8f6c\u6362\u4e3a\u666e\u901a\u683c\u5f0f\u7684\u65e5\u671f\u65f6\u95f4\u503c\uff0c\u4ee5 YYYY-MM-DD HH:MM:SS \u6216 YYYYMMDDHHMMSS \u683c\u5f0f\u6765\u663e\u793a MINUTE() \u8fd4\u56de\u65f6\u95f4\u53c2\u6570\u7684\u5206\u949f MONTH() \u8fd4\u56de\u65e5\u671f\u53c2\u6570\u7684\u6708\u4efd NOW() \u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002 SECOND() \u8fd4\u56de\u65f6\u95f4\u53c2\u6570\u7684\u79d2\u6570 STR_TO_DATE() \u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b SYSDATE() \u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002 TIME() \u63d0\u53d6\u65f6\u95f4\u6216\u65e5\u671f\u65f6\u95f4\u7684\u65f6\u95f4\u90e8\u5206\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de TIMEDIFF() \u8fd4\u56de\u4e24\u4e2a\u65f6\u95f4\u53c2\u6570\u4e4b\u95f4\u7684\u5dee\u503c TIMESTAMP() \u5c06\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u53c2\u6570\u4f5c\u4e3a\u65e5\u671f\u65f6\u95f4\u503c\u8fd4\u56de TIMESTAMPDIFF() \u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u5728\u7ed9\u5b9a\u7684\u65f6\u95f4\u5355\u4f4d\u5185\uff0c\u4ece\u7b2c\u4e00\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u5230\u7b2c\u4e8c\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694 TO_DATE() \u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b TO_DAYS() \u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u4e0e\u516c\u5386\u65e5\u5386\u7684\u5f00\u59cb\u65e5\u671f\uff080000 \u5e74 1 \u6708 1 \u65e5\uff09\u4e4b\u95f4\u7684\u5929\u6570\u5dee TO_SECONDS() \u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4 expr \u4e0e\u516c\u5143 0 \u5e74 1 \u6708 1 \u65e5 0 \u65f6 0 \u5206 0 \u79d2\u4e4b\u95f4\u7684\u79d2\u6570\u5dee UNIX_TIMESTAMP \u8fd4\u56de\u81ea 1970-01-01 00:00:00 UTC \u81f3\u6307\u5b9a\u65f6\u95f4\u7684\u79d2\u6570 UTC_TIMESTAMP() \u5c06\u5f53\u524d UTC \u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss \u6216 YYYYMMDDhhmmss \u7684\u683c\u5f0f\u8fd4\u56de WEEK() \u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u7684\u5468\u6570 WEEKDAY() \u8fd4\u56de\u65e5\u671f\u7684\u5de5\u4f5c\u65e5\u7d22\u5f15\uff080 = \u661f\u671f\u4e00\uff0c1 = \u661f\u671f\u4e8c\uff0c... 6 = \u661f\u671f\u65e5\uff09 YEAR() \u8fd4\u56de\u4e86\u7ed9\u5b9a\u65e5\u671f\u7684\u5e74\u4efd"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_4","title":"\u6570\u5b66\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 ABS() \u7528\u4e8e\u6c42\u53c2\u6570\u7684\u7edd\u5bf9\u503c ACOS() \u7528\u4e8e\u6c42\u7ed9\u5b9a\u6570\u503c\u7684\u4f59\u5f26\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09 ATAN() \u7528\u4e8e\u6c42\u7ed9\u5b9a\u6570\u503c\u7684\u53cd\u6b63\u5207\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09 CEIL() \u7528\u4e8e\u6c42\u4e0d\u5c0f\u4e8e\u53c2\u6570\u7684\u6700\u5c0f\u6574\u6570\u3002 COS() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5f26\u503c\u3002 COT() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5207\u503c\u3002 EXP() \u7528\u4e8e\u6c42\u4ee5\u81ea\u7136\u5e38\u6570 e \u4e3a\u5e95\u7684 number \u7684\u6307\u6570\u3002 FLOOR() \u7528\u4e8e\u6c42\u4e0d\u5927\u4e8e\u67d0\u4e2a\u6570\u5b57\u7684\u76f8\u5e94\u6570\u4f4d\u7684\u6570\u3002 LN() \u7528\u4e8e\u6c42\u53c2\u6570\u7684\u81ea\u7136\u5bf9\u6570 LOG() \u7528\u4e8e\u6c42\u53c2\u6570\u7684\u81ea\u7136\u5bf9\u6570 LOG2() \u7528\u4e8e\u6c42\u4ee5 2 \u4e3a\u5e95\u53c2\u6570\u7684\u5bf9\u6570 LOG10() \u7528\u4e8e\u6c42\u4ee5 10 \u4e3a\u5e95\u53c2\u6570\u7684\u5bf9\u6570 PI() \u7528\u4e8e\u6c42\u6570\u5b66\u5e38\u91cf \u03c0 (pi) POWER() POWER(X, Y) \u7528\u4e8e\u6c42 X \u7684 Y \u6b21\u65b9\u6307\u6570\u503c ROUND() \u7528\u4e8e\u6c42\u67d0\u4e2a\u6570\u5b57\u5728\u7279\u5b9a\u4f4d\u6570\u56db\u820d\u4e94\u5165\u540e\u7684\u6570\u503c RAND() \u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684 Float64 \u7c7b\u578b\u7684\u968f\u673a\u6570 SIN() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5f26\u503c SINH() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u53cc\u66f2\u6b63\u5f26\u503c TAN() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5207\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_5","title":"\u5b57\u7b26\u4e32\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 BIN() \u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u7684\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002 BIT_LENGTH() \u8fd4\u56de\u5b57\u7b26\u4e32 str \u7684\u957f\u5ea6\uff0c\u5355\u4f4d\u4e3a bit\u3002 CHAR_LENGTH() \u4ee5\u5b57\u7b26\u4e3a\u5355\u4f4d\u8fd4\u56de\u5b57\u7b26\u4e32 str \u7684\u957f\u5ea6 CONCAT() \u5c06\u591a\u4e2a\u5b57\u7b26\u4e32\uff08\u6216\u4ec5\u542b\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\uff09\u8fde\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32 CONCAT_WS() \u4ee3\u8868 Concatenate With Separator\uff0c\u662f CONCAT() \u7684\u4e00\u79cd\u7279\u6b8a\u5f62\u5f0f\u3002 EMPTY() \u5224\u65ad\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u3002 ENDSWITH() \u68c0\u67e5\u662f\u5426\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e\u3002 FIELD() \u8fd4\u56de\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e32 str \u5728\u5b57\u7b26\u4e32\u5217\u8868 (str1,str2,str3,...) \u4e2d\u7684\u4f4d\u7f6e FIND_IN_SET() \u5728\u9017\u53f7\u5206\u9694\u7684\u5b57\u7b26\u4e32\u5217\u8868\u4e2d\u67e5\u627e\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e\u3002 FORMAT() \u7528\u4e8e\u5c06\u6570\u5b57\u683c\u5f0f\u8bbe\u7f6e\u4e3a \"#,###,###.##\" \u683c\u5f0f\uff0c\u5e76\u56db\u820d\u4e94\u5165\u5230\u5c0f\u6570\u70b9\u540e\u4e00\u4f4d\u3002 FROM_BASE64() \u7528\u4e8e\u5c06 Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u56de\u539f\u59cb\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff08\u6216\u6587\u672c\u6570\u636e\uff09\u3002 HEX() \u8fd4\u56de\u53c2\u6570\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u5f62\u5f0f INSTR() \u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u5728\u7ed9\u5b9a\u5b57\u7b26\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u3002 LCASE() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\u3002 LEFT() \u8fd4\u56de str \u5b57\u7b26\u4e32\u4e2d\u6700\u5de6\u8fb9\u7684\u957f\u5ea6\u5b57\u7b26\u3002 LENGTH() \u8fd4\u56de\u4e86\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002 LOCATE() \u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u6240\u5728\u4f4d\u7f6e\u7684\u51fd\u6570\u3002 LOWER() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\u3002 LPAD() \u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u5de6\u4fa7\u586b\u5145\u3002 LTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u524d\u90e8\u7a7a\u683c\u53bb\u9664\uff0c\u8fd4\u56de\u5904\u7406\u540e\u7684\u5b57\u7b26\u3002 MD5() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u751f\u6210\u4e00\u4e2a 32 \u5b57\u7b26\u957f\u7684\u5341\u516d\u8fdb\u5236 MD5 \u54c8\u5e0c\u503c\u3002 OCT() \u8fd4\u56de\u53c2\u6570\u7684\u516b\u8fdb\u5236\u503c\u7684\u5b57\u7b26\u4e32 REPEAT() \u7528\u4e8e\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u91cd\u590d n \u6b21\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32 REVERSE() \u5c06 str \u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u987a\u5e8f\u7ffb\u8f6c\u8f93\u51fa\u3002 RPAD() \u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u53f3\u4fa7\u586b\u5145 RTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u540e\u65b9\u7a7a\u683c\u53bb\u9664 SHA1()/SHA() \u7528\u4e8e\u8ba1\u7b97\u5e76\u8fd4\u56de\u7ed9\u5b9a\u5b57\u7b26\u4e32\u7684 SHA-1 \u54c8\u5e0c\u503c\u3002 SHA2() \u8fd4\u56de\u8f93\u5165\u5b57\u7b26\u4e32\u7684 SHA2 \u54c8\u5e0c\u503c\u3002 SPACE() \u8fd4\u56de N \u4e2a\u7a7a\u683c\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u3002 SPLIT_PART() \u7528\u4e8e\u5728\u7ed9\u5b9a\u7684\u5206\u9694\u7b26\u57fa\u7840\u4e0a\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u5206\u89e3\u6210\u591a\u4e2a\u90e8\u5206 STARTSWITH() \u5b57\u7b26\u4e32\u5982\u679c\u4ee5\u6307\u5b9a\u524d\u7f00\u5f00\u59cb\u8fd4\u56de 1\uff0c\u5426\u5219\u5219\u8fd4\u56de 0\u3002 SUBSTRING() \u8fd4\u56de\u4e00\u4e2a\u4ece\u6307\u5b9a\u4f4d\u7f6e\u5f00\u59cb\u7684\u5b50\u5b57\u7b26\u4e32 SUBSTRING_INDEX() \u4ee5\u5206\u9694\u7b26\u4e3a\u7d22\u5f15\uff0c\u83b7\u53d6\u4e0d\u540c\u7d22\u5f15\u4f4d\u7684\u5b57\u7b26\u3002 TO_BASE64() \u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32 TRIM() \u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5220\u9664\u4e0d\u9700\u8981\u7684\u5b57\u7b26\u3002 UCASE() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\u3002 UNHEX() \u7528\u4e8e\u5c06\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u76f8\u5e94\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002 UPPER() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_6","title":"\u6b63\u5219\u8868\u8fbe\u5f0f","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 NOT REGEXP() \u7528\u4e8e\u6d4b\u8bd5\u4e00\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e0d\u5339\u914d\u6307\u5b9a\u7684\u6b63\u5219\u8868\u8fbe\u5f0f REGEXP_INSTR() \u8fd4\u56de\u5339\u914d\u5230\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002 REGEXP_LIKE() \u7528\u4e8e\u5224\u65ad\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e0e\u63d0\u4f9b\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5339\u914d REGEXP_REPLACE() \u7528\u4e8e\u5c06\u5339\u914d\u7ed9\u5b9a\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u65b0\u5b57\u7b26\u4e32 REGEXP_SUBSTR() \u7528\u4e8e\u8fd4\u56de\u5b57\u7b26\u4e32\u53c2\u6570\u4e2d\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u53c2\u6570\u7684\u5b50\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_7","title":"\u5411\u91cf\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 \u57fa\u672c\u64cd\u4f5c\u7b26 \u5411\u91cf\u7684\u52a0\u6cd5 (+)\u3001\u51cf\u6cd5 (-)\u3001\u4e58\u6cd5 (*) \u548c\u9664\u6cd5 (/) SQRT() \u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u6839 ABS() \u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u7684\u7edd\u5bf9\u503c CAST() \u7528\u4e8e\u663e\u5f0f\u5c06\u4e00\u4e2a\u5411\u91cf\u4ece\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b SUMMATION() \u8fd4\u56de\u5411\u91cf\u4e2d\u6240\u6709\u5143\u7d20\u7684\u603b\u548c INNER_PRODUCT() \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u5185\u79ef/\u70b9\u79ef CLUSTER_CENTERS() \u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u5217\u7684 K \u4e2a\u805a\u7c7b\u4e2d\u5fc3 COSINE_DISTANCE() \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u8ddd\u79bb\u3002 COSINE_SIMILARITY() \u8861\u91cf\u4e86\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u5939\u89d2\u7684\u4f59\u5f26\u503c\uff0c\u901a\u8fc7\u5b83\u4eec\u5728\u591a\u7ef4\u7a7a\u95f4\u4e2d\u7684\u63a5\u8fd1\u7a0b\u5ea6\u6765\u8868\u793a\u5b83\u4eec\u7684\u76f8\u4f3c\u6027 L2_DISTANCE() \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb L1_NORM() \u7528\u4e8e\u8ba1\u7b97 l1/\u66fc\u54c8\u987f/TaxiCab \u8303\u6570 L2_NORM() \u7528\u4e8e\u8ba1\u7b97 l2/\u6b27\u51e0\u91cc\u5f97\u8303\u6570 NORMALIZE_L2() \u7528\u4e8e\u6267\u884c\u6b27\u51e0\u91cc\u5f97\u5f52\u4e00\u5316 SUBVECTOR() \u7528\u4e8e\u4ece\u5411\u91cf\u4e2d\u63d0\u53d6\u5b50\u5411\u91cf VECTOR_DIMS() \u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u7684\u7ef4\u5ea6"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_8","title":"\u8868\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 UNNEST() \u7528\u4e8e\u5c06 JSON \u7c7b\u578b\u6570\u636e\u5185\u7684\u6570\u7ec4\u7c7b\u578b\u7684\u5217\u6216\u53c2\u6570\u5c55\u5f00\u4e3a\u4e00\u4e2a\u8868"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_9","title":"\u7a97\u53e3\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 DENSE_RANK() \u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d RANK() \u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d ROW_UNMBER() \u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u5e8f\u53f7"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#json","title":"JSON \u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 JSON_EXTRACT() \u4ece JSON \u6587\u6863\u8fd4\u56de\u6570\u636e JSON_QUOTE() \u5f15\u7528 JSON \u6587\u6863 JSON_UNQUOTE() \u53d6\u6d88\u5f15\u7528 JSON \u6587\u6863"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_10","title":"\u7cfb\u7edf\u8fd0\u7ef4\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 CURRENT_ROLE_NAME() \u7528\u4e8e\u67e5\u8be2\u5f53\u524d\u767b\u5f55\u7684\u7528\u6237\u6240\u62e5\u6709\u7684\u89d2\u8272\u7684\u540d\u79f0\u3002 CURRENT_ROLE() \u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u7684\u89d2\u8272\u3002 CURRENT_USER_NAME() \u7528\u4e8e\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u767b\u5f55\u7684\u7528\u6237\u540d\u79f0\u3002 CURRENT_USER() \u8fd4\u56de\u5f53\u524d\u7528\u6237\u8d26\u6237 PURGE_LOG() \u7528\u4e8e\u5220\u9664\u8bb0\u5f55\u4e8e MatrixOne \u6570\u636e\u5e93\u7cfb\u7edf\u8868\u4e2d\u7684\u65e5\u5fd7\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_11","title":"\u5176\u4ed6\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 SAMPLE() \u4e3b\u8981\u7528\u4e8e\u5feb\u901f\u7f29\u51cf\u67e5\u8be2\u8303\u56f4 SERIAL_EXTRACT() \u7528\u4e8e\u63d0\u53d6\u5e8f\u5217/\u5143\u7ec4\u503c\u4e2d\u7684\u5404\u4e2a\u5143\u7d20 SLEEP() \u5c06\u5f53\u524d\u67e5\u8be2\u6682\u505c\uff08\u7761\u7720\uff09\u6307\u5b9a\u7684\u79d2\u6570 UUID() \u8fd4\u56de\u6839\u636e RFC 4122 \u751f\u6210\u56fd\u9645\u901a\u7528\u552f\u4e00\u6807\u8bc6\u7b26"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/","title":"ANY_VALUE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ANY_VALUE
\u5728\u8303\u56f4\u5185\u4efb\u9009\u4e00\u4e2a\u503c\u8fd4\u56de\u3002
> ANY_VALUE(arg)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e arg \u53ef\u4e3a\u4efb\u610f\u7c7b\u578b\u3002\u5f53 arg \u4e3a NULL \u65f6\uff0c\u8be5\u884c\u4e0d\u53c2\u4e0e\u8ba1\u7b97\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de\u7c7b\u578b\u548c\u8f93\u5165\u7c7b\u578b\u76f8\u540c\u3002
\u8bf4\u660e\uff1aANY_VALUE
\u7684\u6267\u884c\u7ed3\u679c\u5177\u6709\u4e0d\u786e\u5b9a\u6027\uff0c\u76f8\u540c\u7684\u8f93\u5165\u53ef\u80fd\u5f97\u5230\u4e0d\u540c\u7684\u6267\u884c\u7ed3\u679c\u3002
> create table t1(\n-> a int,\n-> b int,\n-> c int\n-> );\n> create table t2(\n-> a int,\n-> b int,\n-> c int\n-> );\n> insert into t1 values(1,10,34),(2,20,14);\n> insert into t2 values(1,-10,-45);\n> select ANY_VALUE(t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+-----------------+\n| any_value(t1.b) |\n+-----------------+\n| 10 |\n| 20 |\n+-----------------+\n2 rows in set (0.01 sec)\n> select 3+(5*ANY_VALUE(t1.b)) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+---------------------------+\n| 3 + (5 * any_value(t1.b)) |\n+---------------------------+\n| 53 |\n| 103 |\n+---------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/","title":"AVG","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"AVG()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u7528\u4e8e\u8ba1\u7b97\u53c2\u6570\u5217\u7684\u7b97\u672f\u5e73\u5747\u503c\u3002
> AVG(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#_4","title":"\u8fd4\u56de\u503c","text":"\u4ee5 Double
\u7c7b\u578b\u8fd4\u56de\u8be5\u5217\u7684\u7b97\u672f\u5e73\u5747\u503c\u3002 \u82e5\u8f93\u5165\u53c2\u6570\u4e3a\u7a7a\uff0c\u5219\u8fd4\u56de NaN
\u503c\u3002
> drop table if exists tbl1;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select avg(col_1c) from tbl1;\n+-------------+\n| avg(col_1c) |\n+-------------+\n| 3.5 |\n+-------------+\n\n> select sum(col_1d) as s1,avg(col_1d) as a3 from tbl1 group by col_1e order by s1 desc;\n+------+------+\n| s1 | a3 |\n+------+------+\n| 21 | 10.5 |\n| 18 | 9 |\n| 10 | 10 |\n| 8 | 8 |\n+------+------+\n\n> select avg(col_1d) as a1 from tbl1 where col_1d < 13 group by col_1e order by a1;\n+------+\n| a1 |\n+------+\n| 8 |\n| 9 |\n| 10 |\n| 10.5 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/","title":"BIT_AND","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BIT_AND() \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u4e0e\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> BIT_AND(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr UINT \u7c7b\u578b\u7684\u5217"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_AND(number) FROM t1 GROUP BY id;\n+------+-----------------+\n| id | bit_and(number) |\n+------+-----------------+\n| a | 0 |\n| b | 1 |\n+------+-----------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/","title":"BIT_OR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BIT_OR() \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u6216\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> BIT_OR(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr UINT \u7c7b\u578b\u7684\u5217"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_OR(number) FROM t1 GROUP BY id;\n+------+----------------+\n| id | bit_or(number) |\n+------+----------------+\n| a | 111 |\n| b | 11 |\n+------+----------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/","title":"BIT_XOR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BIT_XOR() \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u5f02\u6216\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> BIT_XOR(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr UINT \u7c7b\u578b\u7684\u5217"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, bit_xor(number) from t1 group by id;\n+------+-----------------+\n| id | bit_xor(number) |\n+------+-----------------+\n| a | 101 |\n| b | 10 |\n+------+-----------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/","title":"BITMAP \u51fd\u6570","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BITMAP
\u51fd\u6570\u662f\u4e00\u7ec4\u7528\u4e8e\u5904\u7406\u4f4d\u56fe\uff08bitmap\uff09\u7684\u5185\u7f6e\u51fd\u6570\uff0cbitmap \u662f\u5b58\u50a8\u4e3a\u4e8c\u8fdb\u5236\u6570\u636e\u7c7b\u578b\u7684\u8fde\u7eed\u5185\u5b58\u7247\u6bb5\u3002\u8fd9\u4e9b\u51fd\u6570\u7279\u522b\u9002\u7528\u4e8e\u5904\u7406\u5c42\u6b21\u5316\u805a\u5408\uff08\u5982\u591a\u4e2a\u5206\u7ec4\u96c6\u5408\uff09\u65f6\u7684\u4e0d\u540c\u503c\uff08distinct values\uff09\u7684\u8ba1\u6570\uff0c\u8fd4\u56de\u7ed3\u679c\u4e0e count(distinct)
\u4e00\u81f4\uff0c\u4f46\u66f4\u9ad8\u6548\u3002
\u6211\u4eec\u53ef\u4ee5\u53ea\u4f7f\u7528\u4e00\u4e2a bit \u4f4d\u6807\u8bc6\u4e00\u4e2a\u5143\u7d20\u7684\u5b58\u5728\u4e0e\u5426\uff0c\u5b58\u5728\u4e3a 1\uff0c\u4e0d\u5b58\u5728\u5219\u4e3a 0\uff0c\u7528 bitmap \u7684\u7b2c n \u4e2a bit \u6765\u8bb0\u5f55\u8fd9\u4e2a\u5143\u7d20\u662f\u5426\u5b58\u5728\u3002
\u6211\u4eec\u89c4\u5b9a bitmap \u6700\u5927\u5bbd\u5ea6\u4e3a 32768(2^15 = 4K)\uff0c\u5bf9\u4e8e\u975e\u8d1f\u6574\u6570 n\uff0c\u53d6\u5176\u4f4e 15 \u4f4d\uff08\u4e8c\u8fdb\u5236\uff09\u4f5c\u4e3a\u5728 bitmap \u7684\u4f4d\u7f6e\uff0c\u5176\u5b83\u9ad8\u4f4d\u4f5c\u4e3a\u4f4d\u56fe\u6876 (bitmap bucket) \u7684\u7f16\u53f7\u3002\u4e0b\u56fe\u4e3a bitmap \u7684\u903b\u8f91\u56fe\uff1a
\u6bcf\u4e2a bucket \u662f\u4e00\u4e2a bitmap\uff0c\u7531\u4e8e\u5404\u4e2a bucket \u662f\u6b63\u4ea4\u7684\uff0c\u6bcf\u4e2a bucket \u505a\u8fd0\u7b97 (or\uff0cbit_count) \u53ef\u4ee5\u53ea\u5728\u5f53\u524d bucket \u4e2d\u8fdb\u884c\uff0c\u800c\u4e0d\u5fc5\u5173\u5fc3\u5176\u5b83 bucket\u3002
\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 BITMAP
\u51fd\u6570\u53ca\u5176\u7528\u6cd5\uff1a
BITMAP_BUCKET_NUMBER()
\u51fd\u6570\u7684\u76ee\u7684\u662f\u786e\u5b9a\u7ed9\u5b9a\u503c\u6240\u5c5e\u7684 bucket \u7684\u7f16\u53f7\u3002bucket \u662f\u4e00\u4e2a\u66f4\u5927\u7684\u4f4d\u96c6\u5408\uff0c\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u4f4d\uff0c\u6bcf\u4e2a\u4f4d\u4ee3\u8868\u6570\u636e\u96c6\u4e2d\u7684\u4e00\u4e2a\u7279\u5b9a\u503c\u3002\u8fd9\u4e2a\u51fd\u6570\u8fd4\u56de bucket \u7684\u7f16\u53f7\u3002\u4e00\u4e2a bucket \u7f16\u53f7\u901a\u5e38\u7528\u4e8e\u5728\u6267\u884c\u805a\u5408\u64cd\u4f5c\u65f6\u5bf9 bitmap \u8fdb\u884c\u5206\u7ec4\u3002
> BITMAP_BUCKET_NUMBER(numeric_expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e numeric_expr \u5fc5\u9700\u7684\u3002\u53ef\u4ee5 cast \u6210\u975e\u8d1f\u6574\u578b\u7684\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT bitmap_bucket_number(0);-- \u8fd4\u56de 0\uff0c\u8868\u793a\u5c5e\u4e8e\u7b2c\u4e00\u4e2a bucket\uff0c\u7b2c\u4e00\u4e2a bucket \u8bb0\u5f55 0-32767 \u7684\u4f4d\u7f6e\n+-------------------------+\n| bitmap_bucket_number(0) |\n+-------------------------+\n| 0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bucket_number(32767);-- \u8fd4\u56de 0\uff0c\u56e0\u4e3a 32767 \u5c5e\u4e8e\u7b2c\u4e00\u4e2a bucket \u7684\u672b\u5c3e\u4f4d\u7f6e\n+-----------------------------+\n| bitmap_bucket_number(32767) |\n+-----------------------------+\n| 0 |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bucket_number(32768);-- \u8fd4\u56de 1\uff0c\u56e0\u4e3a 32768 \u5c5e\u4e8e\u7b2c\u4e8c\u4e2a bucket \u7684\u8d77\u59cb\u4f4d\u7f6e\n+-----------------------------+\n| bitmap_bucket_number(32768) |\n+-----------------------------+\n| 1 |\n+-----------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#bitmap_bit_position","title":"BITMAP_BIT_POSITION","text":"BITMAP_BIT_POSITION()
\u51fd\u6570\u7528\u4e8e\u8fd4\u56de\u7ed9\u5b9a\u503c\u5728 bucket \u4e2d\u7684\u76f8\u5bf9\u4f4d\u4f4d\u7f6e\uff08\u4ece 0 \u5f00\u59cb\u7d22\u5f15\u5230 32767 \u7ed3\u675f\uff09\u3002\u4e0e BITMAP_BUCKET_NUMBER()
\u914d\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u552f\u4e00\u6807\u8bc6 bitmap \u4e2d\u7684\u4efb\u4f55\u6570\u5b57\u3002\u56e0\u4e3a\u5b9e\u9645 BITMAP_BIT_POSITION()
\u6807\u8bb0\u53c2\u6570\u7684\u4f4e 15 \u4f4d\uff08\u4ee5\u4e8c\u8fdb\u5236\u8868\u793a\uff09\uff0cBITMAP_BUCKET_NUMBER()
\u6807\u8bb0\u53c2\u6570\u7684\u9ad8\u4f4d\u3002
BITMAP_BIT_POSITION(numeric_expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_6","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e numeric_expr \u5fc5\u9700\u7684\u3002\u53ef\u4ee5 cast \u6210\u975e\u8d1f\u6574\u578b\u7684\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_7","title":"\u793a\u4f8b","text":"mysql> SELECT bitmap_bit_position(0);-- \u8fd4\u56de 0\uff0c\u56e0\u4e3a 0 \u5728\u7b2c\u4e00\u4e2a bucket \u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\n+------------------------+\n| bitmap_bit_position(0) |\n+------------------------+\n| 0 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bit_position(32767);-- \u8fd4\u56de 32767\uff0c\u56e0\u4e3a 32767 \u5728\u7b2c\u4e00\u4e2a bucket \u4e2d\u7684\u4f4d\u7f6e\u662f\u6700\u540e\u4e00\u4e2a\n+----------------------------+\n| bitmap_bit_position(32767) |\n+----------------------------+\n| 32767 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bit_position(32768);-- \u8fd4\u56de 0\uff0c\u56e0\u4e3a 32768 \u5728\u7b2c\u4e8c\u4e2a bucket \u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\n+----------------------------+\n| bitmap_bit_position(32768) |\n+----------------------------+\n| 0 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n--40000 \u7684\u4e8c\u8fdb\u5236\u4e3a\uff1a1001110001000000\uff0cbitmap_bit_position \u8bb0\u5f55\u4f4e 15 \u4f4d\uff1a001110001000000\uff0cbitmap_bucket_number \u8bb0\u5f55\u9ad8\u4f4d\uff1a1\nmysql> select bin(bitmap_bucket_number(40000)), bin(bitmap_bit_position(40000)),bin(40000);\n+----------------------------------+---------------------------------+------------------+\n| bin(bitmap_bucket_number(40000)) | bin(bitmap_bit_position(40000)) | bin(40000) |\n+----------------------------------+---------------------------------+------------------+\n| 1 | 1110001000000 | 1001110001000000 |\n+----------------------------------+---------------------------------+------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#bitmap_count","title":"BITMAP_COUNT","text":"BITMAP_COUNT()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97 bitmap \u4e2d\u8bbe\u7f6e\u4e3a 1 \u7684\u4f4d\u7684\u6570\u91cf\uff0c\u4ece\u800c\u5f97\u5230\u4e0d\u540c\u503c\u7684\u603b\u6570\u3002\u8fd9\u76f8\u5f53\u4e8e\u5bf9 bitmap \u6267\u884c COUNT(DISTINCT)
\u64cd\u4f5c\uff0c\u4f46\u901a\u5e38\u6bd4\u4f20\u7edf\u7684 COUNT(DISTINCT)
\u67e5\u8be2\u66f4\u5feb\u3002
BITMAP_COUNT()
\u51fd\u6570\u4e00\u822c\u7ed3\u5408\u4e0b\u8ff0\u7684 BITMAP_CONSTRUCT_AGG()
\u3001BITMAP_OR_AGG()
\u51fd\u6570\u4f7f\u7528\u3002
BITMAP_CONSTRUCT_AGG()
\u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u5b83\u5728\u6570\u636e\u5e93\u4e2d\u7528\u4e8e\u6784\u5efa bitmap\u3002
\u5f53\u9700\u8981\u5bf9\u4e00\u7ec4\u5bc6\u96c6\u7684\u975e\u91cd\u590d\u6574\u6570\u503c\u8fdb\u884c\u8ba1\u6570\u65f6\uff0cBITMAP_CONSTRUCT_AGG()
\u51fd\u6570\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u9ad8\u6548\u5730\u5c06\u8fd9\u4e9b\u503c\u8f6c\u6362\u4e3a bitmap \u5f62\u5f0f\u3002
BITMAP_CONSTRUCT_AGG( <bit_position> )\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_9","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e bit_position \u5fc5\u9700\u7684\u3002\u5728 bitmap \u4e2d\u7684\u4f4d\u7f6e\uff08BITMAP_BIT_POSITION \u51fd\u6570\u8fd4\u56de\uff09"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_10","title":"\u793a\u4f8b","text":"CREATE TABLE t1 ( n1 int);\nINSERT INTO t1 VALUES(0),(1),(1),(32767);--\u63d2\u5165 [0,32767] \u5185\u7684\u6570\u636e\n\nmysql> select * from t1;\n+-------+\n| n1 |\n+-------+\n| 0 |\n| 1 |\n| 1 |\n| 32767 |\n+-------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1)) AS bitmap FROM t1;\n+------------------------+\n| bitmap |\n+------------------------+\n| :0 ? |\n+------------------------+\n1 row in set (0.00 sec)\n
Note
bitmap \u5217\u5305\u542b bitmap \u7684\u7269\u7406\u8868\u793a\u5f62\u5f0f\uff0c\u4e0d\u53ef\u8bfb\u3002\u4e3a\u4e86\u786e\u5b9a\u54ea\u4e9b\u4f4d\u88ab\u8bbe\u7f6e\uff0c\u6211\u4eec\u5e94\u7ed3\u5408\u4f7f\u7528 BITMAP
\u51fd\u6570\uff08\u800c\u4e0d\u662f\u81ea\u5df1\u68c0\u67e5\u4e8c\u8fdb\u5236\u503c\uff09\u3002
mysql> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS n1_discnt FROM t1;--bitmap \u4e2d\u8bbe\u7f6e\u4e3a 1 \u7684\u6570\u91cf\n+-----------+\n| n1_discnt |\n+-----------+\n| 3 |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT count(DISTINCT n1) AS n1_discnt FROM t1;--\u8fd4\u56de\u4e00\u81f4\n+-----------+\n| n1_discnt |\n+-----------+\n| 3 |\n+-----------+\n1 row in set (0.01 sec)\n\nINSERT INTO t1 VALUES(32768),(32769),(65535);--\u63d2\u5165\u5927\u4e8e 32767 \u7684\u6570\u636e\n\nmysql> select * from t1;\n+-------+\n| n1 |\n+-------+\n| 0 |\n| 1 |\n| 1 |\n| 32767 |\n| 32768 |\n| 32769 |\n| 65535 |\n+-------+\n7 rows in set (0.01 sec)\n\n--\u7ed3\u679c\u4e0e\u7b2c\u4e00\u6b21\u63d2\u5165\u4e00\u6837\uff0c\u56e0\u4e3a bucket_bit_position = n1 % 32768\uff0c\u7b2c\u4e8c\u6b21\u63d2\u5165\u7684\u6570\u636e\u4e0e\u7b2c\u4e00\u6b21\u63d2\u5165\u7684\u6570\u636e\u4f4d\u4e8e\u4e0d\u540c bucket \u7684\u76f8\u540c\u4f4d\u7f6e\uff0c\u6240\u4ee5\u88ab\u53bb\u91cd\u4e86\u3002\nmysql> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS n1_discnt FROM t1;\n+-----------+\n| t1_bitmap |\n+-----------+\n| 3 |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bit_position(0),bitmap_bit_position(1),bitmap_bit_position(32767),bitmap_bit_position(32768),bitmap_bit_position(65535);\n+------------------------+------------------------+----------------------------+----------------------------+----------------------------+\n| bitmap_bit_position(0) | bitmap_bit_position(1) | bitmap_bit_position(32767) | bitmap_bit_position(32768) | bitmap_bit_position(65535) |\n+------------------------+------------------------+----------------------------+----------------------------+----------------------------+\n| 0 | 1 | 32767 | 0 | 32767 |\n+------------------------+------------------------+----------------------------+----------------------------+----------------------------+\n1 row in set (0.00 sec)\n
\u56e0\u6b64\u5982\u679c\u8981\u5bf9\u5927\u4e8e 32767 \u7684\u6570\u636e\u53bb\u91cd\u9700\u7ed3\u5408 BITMAP_BUCKET_NUMBER()
\u51fd\u6570\u3002
--\u4ee5 bucket \u5206\u7ec4\uff0c\u7b2c\u4e00\u4e2a bucket \u91cc\u9762\u6709\u4e09\u4e2a\u975e\u91cd\u590d\u6570\uff080,1,32767),\u7b2c\u4e8c\u4e2a bucket \u91cc\u6709\u4e09\u4e2a\u975e\u91cd\u590d\u6570 (32768,32769,65535)\u3002\nmysql> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS t1_bitmap FROM t1 GROUP BY BITMAP_BUCKET_NUMBER(n1);\n+-----------+\n| t1_bitmap |\n+-----------+\n| 3 |\n| 3 |\n+-----------+\n2 rows in set (0.01 sec)\n\n--\u7ed3\u5408 sum() \u51fd\u6570\u8ba1\u7b97 n1 \u7684\u975e\u91cd\u590d\u503c\nmysql> SELECT SUM(t1_bitmap) FROM (\n-> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS t1_bitmap\n-> FROM t1 -> GROUP BY BITMAP_BUCKET_NUMBER(n1)\n-> );\n+----------------+\n| sum(t1_bitmap) |\n+----------------+\n| 6 |\n+----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#bitmap_or_agg","title":"BITMAP_OR_AGG","text":"BITMAP_OR_AGG()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u591a\u4e2a bitmap \u7684\u6309\u4f4d\u6216\uff08OR\uff09\u7ed3\u679c\u3002\u901a\u5e38\u7528\u4e8e\u5408\u5e76\u591a\u4e2a bitmap\uff0c\u4ee5\u4fbf\u5728\u4e00\u4e2a bitmap \u4e2d\u8868\u793a\u6240\u6709\u8f93\u5165 bitmap \u7684\u7ec4\u5408\u4fe1\u606f\u3002
\u5f53\u9700\u8981\u5bf9\u4e0d\u540c\u7ef4\u5ea6\u7684\u6570\u636e\u8fdb\u884c\u96c6\u5408\u5e76\u96c6\u64cd\u4f5c\u65f6\uff0cBITMAP_OR_AGG()
\u5341\u5206\u6709\u7528\uff0c\u5c24\u5176\u662f\u5728\u6570\u636e\u4ed3\u5e93\u548c\u5206\u6790\u578b\u67e5\u8be2\u4e2d\u3002
BITMAP_OR_AGG( bitmap )\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_12","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e bitmap \u5fc5\u9700\u7684\u3002\u6240\u6709 bitmap \u6309\u4f4d\u6216\u5408\u5e76\u5f97\u5230\u7684 bitmap\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_13","title":"\u793a\u4f8b","text":"--\u521b\u5efa\u4e00\u5f20\u8868\uff0c\u7528\u6765\u5b58\u50a8\u4f5c\u8005\u51fa\u7248\u4e66\u7c4d\u7684\u4fe1\u606f\uff0c\u5305\u542b\u4f5c\u8005\u540d\u79f0\uff0c\u51fa\u7248\u5e74\u4efd\u548c\u4e66\u7c4d id\nCREATE TABLE book_table(\nid int auto_increment primary key,\nauthor varchar(100),\npub_year varchar(100),\nbook_id int\n);\nINSERT INTO book_table(author,pub_year,book_id) VALUES\n('A \u4f5c\u8005','2020',1),('A \u4f5c\u8005','2020',1),('A \u4f5c\u8005','2020',32768),\n('A \u4f5c\u8005','2021',32767),('A \u4f5c\u8005','2021',32768),('A \u4f5c\u8005','2021',65536),\n('B \u4f5c\u8005','2020',2),('B \u4f5c\u8005','2020',10),('B \u4f5c\u8005','2020',32769),\n('B \u4f5c\u8005','2021',5),('B \u4f5c\u8005','2021',65539);\n\nmysql> select * from book_table;\n+------+----------+----------+---------+\n| id | author | pub_year | book_id |\n+------+----------+----------+---------+\n| 1 | A \u4f5c\u8005 | 2020 | 1 |\n| 2 | A \u4f5c\u8005 | 2020 | 1 |\n| 3 | A \u4f5c\u8005 | 2020 | 32768 |\n| 4 | A \u4f5c\u8005 | 2021 | 32767 |\n| 5 | A \u4f5c\u8005 | 2021 | 32768 |\n| 6 | A \u4f5c\u8005 | 2021 | 65536 |\n| 7 | B \u4f5c\u8005 | 2020 | 2 |\n| 8 | B \u4f5c\u8005 | 2020 | 10 |\n| 9 | B \u4f5c\u8005 | 2020 | 32769 |\n| 10 | B \u4f5c\u8005 | 2021 | 5 |\n| 11 | B \u4f5c\u8005 | 2021 | 65539 |\n+------+----------+----------+---------+\n11 rows in set (0.00 sec)\n\n--\u5b9a\u4e49\u4e00\u5f20\u9884\u8ba1\u7b97\u8868\uff0c\u628a\u7c97\u7c92\u5ea6\u7684\u8ba1\u7b97\u7ed3\u679c\u4fdd\u5b58\u5728\u8868\u4e2d\uff0c\u540e\u7eed\u5404\u79cd\u4e0d\u540c\u7ef4\u5ea6\u805a\u5408\u53ef\u4ee5\u4f7f\u7528\u9884\u8ba1\u7b97\u8868\u4e2d\u7684\u7ed3\u679c\uff0c\u7ecf\u8fc7\u7b80\u5355\u7684\u8ba1\u7b97\u5c31\u53ef\u4ee5\u5f97\u5230\u7ed3\u679c\uff0c\u52a0\u901f\u67e5\u8be2\u3002\nCREATE TABLE precompute AS\nSELECT\nauthor,\npub_year,\nBITMAP_BUCKET_NUMBER(book_id) as bucket,\nBITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(book_id)) as bitmap FROM book_table\nGROUP BY author,pub_year,bucket;\n\nmysql> select * from precompute;\n+---------+----------+--------+----------------------+\n| author | pub_year | bucket | bitmap |\n+---------+----------+--------+----------------------+\n| A\u4f5c\u8005 | 2020 | 0 | :0 |\n| A\u4f5c\u8005 | 2020 | 1 | :0 |\n| A\u4f5c\u8005 | 2021 | 0 | :0 ? |\n| A\u4f5c\u8005 | 2021 | 1 | :0 |\n| A\u4f5c\u8005 | 2021 | 2 | :0 |\n| B\u4f5c\u8005 | 2020 | 0 | :0 |\n| B\u4f5c\u8005 | 2020 | 1 | :0 |\n| B\u4f5c\u8005 | 2021 | 0 | :0 |\n| B\u4f5c\u8005 | 2021 | 2 | :0 |\n+---------+----------+--------+----------------------+\n\n--\u8ba1\u7b97\u5728\u4f5c\u8005\u548c\u51fa\u7248\u5e74\u4efd\u805a\u5408\u60c5\u51b5\u4e0b book_id \u7684\u53bb\u91cd\u6570\u91cf\uff0c\u53cd\u5e94\u7684\u662f\u4f5c\u8005\u5728\u4e0d\u540c\u5e74\u4efd\u51fa\u7248\u4e66\u7c4d\u7c7b\u578b\u7684\u6570\u91cf\u3002\n--sum() \u51fd\u6570\u7d2f\u52a0\u4e0d\u540c bucket \u7684 bitmap \u4e2d 1 \u7684\u6570\u91cf\u3002\n--\u4f8b\u5982\u5f53 author=A \u4f5c\u8005\uff0cpub_year=2020 \u65f6\uff0cbook_id=(1,1,32768)\uff0c\u53bb\u91cd\u540e\u4e3a book_id=(1,32768)\uff0c\u4f46\u662f 1 \u4f4d\u4e8e\u7b2c\u4e00\u4e2a bucket,32768 \u4f4d\u4e8e\u7b2c\u4e8c\u4e2a bucket\uff0c\u6240\u4ee5\u9700\u8981 sum \u4f5c\u7d2f\u52a0\u3002\nmysql> SELECT\n-> author,\n-> pub_year,\n-> SUM(BITMAP_COUNT(bitmap))\n-> FROM precompute\n-> GROUP BY author,pub_year;\n+---------+----------+---------------------------+\n| author | pub_year | sum(bitmap_count(bitmap)) |\n+---------+----------+---------------------------+\n| A\u4f5c\u8005 | 2020 | 2 |\n| A\u4f5c\u8005 | 2021 | 3 |\n| B\u4f5c\u8005 | 2020 | 3 |\n| B\u4f5c\u8005 | 2021 | 2 |\n+---------+----------+---------------------------+\n4 rows in set (0.00 sec)\n\nmysql> SELECT author,pub_year,count( DISTINCT book_id) FROM book_table group by author,pub_year;--\u8fd4\u56de\u4e00\u81f4\n+----------+----------+-------------------------+\n| author | pub_year | count(distinct book_id) |\n+----------+----------+-------------------------+\n| A \u4f5c\u8005 | 2020 | 2 |\n| A \u4f5c\u8005 | 2021 | 3 |\n| B \u4f5c\u8005 | 2020 | 3 |\n| B \u4f5c\u8005 | 2021 | 2 |\n+----------+----------+-------------------------+\n4 rows in set (0.00 sec)\n\n--\u8ba1\u7b97\u5728\u4f5c\u8005\u805a\u5408\u60c5\u51b5\u4e0b book_id \u7684\u53bb\u91cd\u6570\u91cf\uff0c\u53cd\u5e94\u7684\u662f\u4f5c\u8005\u4e00\u5171\u51fa\u7248\u4e66\u7c4d\u7c7b\u578b\u7684\u6570\u91cf\u3002\n--BITMAP_OR_AGG() \u51fd\u6570\u5408\u5e76\u4e0d\u540c\u7ef4\u5ea6\uff08\u76f8\u540c\u4f5c\u8005\u4e0d\u540c\u5e74\u4efd\uff09\u7684 bitmap\u3002\n--\u4f8b\u5982\u5f53 author=A \u4f5c\u8005\uff0cpub_date=2020 \u65f6\uff0cbook_id \u53bb\u91cd\u540e\u4e3a (1,32768)\uff0cpub_date=2021 \u65f6\uff0cbook_id \u53bb\u91cd\u540e\u4e3a (32767,32768,65536)\uff0cBITMAP_OR_AGG \u5bf9\u4e24\u4e2a\u4e0d\u540c\u5e74\u4efd\u7684 bitmap \u505a\u6216\u8fd0\u7b97\u5f97\u5230 book_id=(1,32767,32768,65536)\uff0c\u6700\u540e sum() \u7d2f\u52a0\u4e0d\u540c bucktet \u7684 book_id\u3002\nmysql> SELECT author, SUM(cnt) FROM (\n-> SELECT\n-> author,\n-> BITMAP_COUNT(BITMAP_OR_AGG(bitmap)) cnt\n-> FROM precompute\n-> GROUP BY author,bucket\n-> )\n-> GROUP BY author;\n+---------+----------+\n| author | sum(cnt) |\n+---------+----------+\n| A\u4f5c\u8005 | 4 |\n| B\u4f5c\u8005 | 5 |\n+---------+----------+\n2 rows in set (0.01 sec)\n\nmysql> SELECT author,count(DISTINCT book_id) FROM book_table GROUP BY author;--\u8fd4\u56de\u4e00\u81f4\n+----------+-------------------------+\n| author | count(distinct book_id) |\n+----------+-------------------------+\n| A \u4f5c\u8005 | 4 |\n| B \u4f5c\u8005 | 5 |\n+----------+-------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/","title":"COUNT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#n","title":"\u51fd\u6570\u8bf4\u660e n","text":"COUNT()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u8ba1\u7b97\u4e86\u67e5\u8be2\u7ed3\u679c\u7684\u8bb0\u5f55\u6570\uff0c\u7ed3\u679c\u662f\u4e00\u4e2a BIGINT \u503c\u3002\u5f53\u6ca1\u6709\u5339\u914d\u7684\u884c\u6216 COUNT(NULL)
\u65f6\u8fd4\u56de 0\u3002
> COUNT(expr)\n
> COUNT(distinct column)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#_2","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u67e5\u8be2\u7ed3\u679c\uff0c\u65e2\u53ef\u4ee5\u662f\u5217\u540d\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u51fd\u6570\u6216\u8005\u6570\u5b66\u8fd0\u7b97\u7684\u7ed3\u679c\u3002\u5f53\u4e0d\u5e26 distinct \u53c2\u6570\u65f6\u4e5f\u53ef\u4ee5\u4f7f\u7528`*`\uff0c\u76f4\u63a5\u7edf\u8ba1\u884c\u6570 distinct column \u5bf9\u5217\u4e2d\u91cd\u590d\u503c\u53bb\u91cd\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#_3","title":"\u793a\u4f8b","text":"drop table if exists tbl1,tbl2;\ncreate table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\ninsert into tbl1 values (0,1,1,7,\"a\");\ninsert into tbl1 values (0,1,2,8,\"b\");\ninsert into tbl1 values (0,1,3,9,\"c\");\ninsert into tbl1 values (0,1,4,10,\"D\");\ninsert into tbl1 values (0,1,5,11,\"a\");\ninsert into tbl1 values (0,1,6,12,\"c\");\n\n> select count(col_1b) from tbl1;\n+---------------+\n| count(col_1b) |\n+---------------+\n| 6 |\n+---------------+\n\n> select count(*) from tbl1 where col_1d<10;\n+----------+\n| count(*) |\n+----------+\n| 3 |\n+----------+\n\nmysql> select count(distinct col_1b) from tbl1;\n+------------------------+\n| count(distinct col_1b) |\n+------------------------+\n| 1 |\n+------------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/","title":"GROUP_CONCAT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"GROUP_CONCAT
\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5b83\u5c06\u901a\u8fc7\u5217\u6216\u8005\u8868\u8fbe\u5f0f\u6307\u5b9a\u7684\u5185\u5bb9\u8fde\u63a5\u8d77\u6765\u3002
\u5982\u679c\u7ed3\u679c\u96c6\u6ca1\u6709\u4efb\u4f55\u884c\uff0c\u6b64\u51fd\u6570\u5c06\u8fd4\u56de NULL
\u3002
> GROUP_CONCAT(expr)\n
\u5b8c\u6574\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a
GROUP_CONCAT([DISTINCT] expr [,expr ...]\n [ORDER BY {unsigned_integer | col_name | expr}\n [ASC | DESC] [,col_name ...]]\n [SEPARATOR str_val])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u987b\u53c2\u6570\u3002\u5b83\u6307\u5b9a\u4e86\u8981\u8fde\u63a5\u7684\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5217\u6216\u8868\u8fbe\u5f0f\u3002 DISTINCT \u53ef\u9009\u53c2\u6570\u3002\u5b83\u7528\u4e8e\u6d88\u9664\u91cd\u590d\u503c\u3002 ORDER BY \u53ef\u9009\u53c2\u6570\u3002\u5b83\u7528\u4e8e\u5bf9\u8981\u8fde\u63a5\u7684\u5185\u5bb9\u6392\u5e8f\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u6309\u5347\u5e8f\u6392\u5e8f\u503c\u3002\u5982\u679c\u8981\u6309\u964d\u5e8f\u5bf9\u503c\u8fdb\u884c\u6392\u5e8f\uff0c\u5219\u9700\u8981\u660e\u786e\u6307\u5b9a DESC
\u9009\u9879\u3002 SEPARATOR \u53ef\u9009\u53c2\u6570\u3002\u8fde\u63a5\u7b26\u3002\u9ed8\u8ba4\u662f ,
\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de\u503c\u662f\u4e00\u4e2a\u975e\u4e8c\u8fdb\u5236\u6216\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u8fd9\u53d6\u51b3\u4e8e\u53c2\u6570 expr
\u662f\u975e\u4e8c\u8fdb\u5236\u8fd8\u662f\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002
\u5982\u679c\u7ed3\u679c\u96c6\u6ca1\u6709\u4efb\u4f55\u884c\uff0c\u6b64\u51fd\u6570\u5c06\u8fd4\u56de NULL
\u3002
create table t1(a int,b text,c text);\ninsert into t1 values(1,\"a\",\"bc\"),(2,\"ab\",\"c\"),(3,\"aa\",\"bb\"),(3,\"aa\",\"bb\");\n\nmysql> select group_concat(distinct a,b,c separator '|') from t1;\n+-----------------------------------+\n| group_concat(distinct a, b, c, |) |\n+-----------------------------------+\n| 1abc|2abc|3aabb |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1 group by a;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc |\n| abc |\n| aabb |\n+--------------------------------+\n3 rows in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc|abc|aabb |\n+--------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/","title":"MAX","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MAX()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u8ba1\u7b97\u4e86\u4e00\u7ec4\u503c\u7684\u6700\u5927\u503c\u3002
> MAX(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de expr
\u5217\u4e2d\u7684\u6700\u5927\u503c\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u5728 MAX()
\u4e2d\u4f7f\u7528\u5b57\u7b26\u4e32\uff0c\u5982\u6b64\u4f1a\u8fd4\u56de\u6700\u5927\u7684\u5b57\u7b26\u4e32\u503c\u3002
> drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select max(col_1d) from tbl1;\n+-------------+\n| max(col_1d) |\n+-------------+\n| 12 |\n+-------------+\n\n> select max(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1 |\n+------+\n| 5 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/","title":"MEDIAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MEDIAN()
\u7528\u4e8e\u8fd4\u56de\u4e00\u7ec4\u6570\u503c\u7684\u4e2d\u503c\uff0c\u5373\u5c06\u4e00\u7ec4\u6570\u503c\u6392\u5e8f\u540e\u8fd4\u56de\u5c45\u4e8e\u4e2d\u95f4\u7684\u6570\u503c\u3002\u5982\u679c\u53c2\u6570\u96c6\u5408\u4e2d\u5305\u542b\u5076\u6570\u4e2a\u6570\u503c\uff0c\u8be5\u51fd\u6570\u5c06\u8fd4\u56de\u4f4d\u4e8e\u4e2d\u95f4\u7684\u4e24\u4e2a\u6570\u7684\u5e73\u5747\u503c\u3002\u53ef\u4ee5\u5c06\u5176\u7528\u4f5c\u805a\u5408\u6216\u5206\u6790\u51fd\u6570\u3002
> MEDIAN(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u6307\u5b9a\u8981\u6c42\u4e2d\u503c\u7684\u6570\u7ec4\u540d\u79f0\uff0c\u53c2\u6570\u7c7b\u578b\u5c5e\u4e8e\u6570\u503c\u6570\u636e\u7c7b\u578b\u6216\u53ef\u4ee5\u9690\u5f0f\u8f6c\u6362\u4e3a\u6570\u5b57\u6570\u636e\u7c7b\u578b\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_4","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8be5\u51fd\u6570\u8fd4\u56de\u4e0e\u53c2\u6570\u7684\u6570\u503c\u6570\u636e\u7c7b\u578b\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_5","title":"\u793a\u4f8b","text":"mysql> select median(null);\n+--------------+\n| median(null) |\n+--------------+\n| NULL |\n+--------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1 (a int,b int);\ninsert into t1 values (1,null);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,1);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n| 1 |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,2);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n| 1.5 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n| 1.5 |\n+-----------+\n1 row in set (0.00 sec)\n\ninsert into t1 values (2,1),(2,2),(2,3),(2,4);\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n| 1.5 |\n| 2.5 |\n+-----------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/","title":"MIN","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MIN()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u8ba1\u7b97\u4e86\u4e00\u7ec4\u503c\u7684\u6700\u5c0f\u503c\u3002
> MIN(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de expr
\u5217\u4e2d\u7684\u6700\u5c0f\u503c\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u5728 MIN()
\u4e2d\u4f7f\u7528\u5b57\u7b26\u4e32\uff0c\u5982\u6b64\u4f1a\u8fd4\u56de\u6700\u5c0f\u7684\u5b57\u7b26\u4e32\u503c\u3002
> drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select min(col_1d) from tbl1;\n+-------------+\n| min(col_1d) |\n+-------------+\n| 7 |\n+-------------+\n\n> select min(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1 |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/","title":"STDDEV_POP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"STDDEV_POP(expr) \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u603b\u4f53\u6807\u51c6\u5dee\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> STDDEV_POP(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\n> INSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ), ('Mitchell Starc', 0, 3);\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n> SELECT STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n\n\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n+------------------------+\n| Pop_Standard_Deviation |\n+------------------------+\n| 16.8762 |\n+------------------------+\n1 row in set (0.02 sec)\n\n> SELECT STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Dev_Wickets |\n+---------------------+\n| 0.9574 |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/","title":"SUM","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SUM()
\u805a\u5408\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e00\u7ec4\u503c\u7684\u548c\uff08NULL \u503c\u88ab\u5ffd\u7565\uff09\u3002
> SUM(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de expr
\u5217\u7684\u6570\u503c\u7684\u548c\uff0c\u82e5\u8f93\u5165\u53c2\u6570\u4e3a Double
\u7c7b\u578b\uff0c\u5219\u8fd4\u56de\u503c\u4e3a Double
\uff0c\u5426\u5219\u4e3a\u6574\u6570\u7c7b\u578b\u3002 \u5982\u679c\u6ca1\u6709\u5339\u914d\u7684\u884c\uff0c\u5219\u8fd4\u56de NULL
\u503c\u3002
> drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select sum(col_1c) from tbl1;\n+-------------+\n| sum(col_1c) |\n+-------------+\n| 21 |\n+-------------+\n\n> select sum(col_1d) as c1 from tbl1 where col_1d < 13 group by col_1e order by c1;\n+------+\n| c1 |\n+------+\n| 8 |\n| 10 |\n| 18 |\n| 21 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/","title":"VAR_POP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"VAR_POP()
\u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee\u3002\u4e0e VARIANCE()
\u4e3a\u540c\u4e49\u8bcd\u3002
> VAR_POP(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\nINSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ), ('Mitchell Starc', 0, 3);\n\n-- \u8ba1\u7b97 RunScored \u5217\u7684\u65b9\u5dee\nmysql> SELECT VAR_POP(RunScored) as Pop_Standard_Variance FROM t1;\n+-----------------------+\n| Pop_Standard_Variance |\n+-----------------------+\n| 284.8055555555555 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n-- \u8ba1\u7b97 WicketsTaken \u5217\u7684\u65b9\u5dee\nmysql> SELECT VAR_POP(WicketsTaken) as Pop_Std_Var_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Var_Wickets |\n+---------------------+\n| 0.9166666666666665 |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/","title":"VARIANCE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"VARIANCE(expr)
\u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee\u3002\u65b9\u5dee\u662f\u7edf\u8ba1\u5b66\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u6982\u5ff5\uff0c\u7528\u4e8e\u8861\u91cf\u4e00\u7ec4\u6570\u636e\u503c\u7684\u79bb\u6563\u7a0b\u5ea6\uff0c\u5373\u6570\u636e\u503c\u4e0e\u5176\u5e73\u5747\u503c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u5982\u679c\u65b9\u5dee\u503c\u8f83\u5927\uff0c\u8bf4\u660e\u6570\u636e\u503c\u4e4b\u95f4\u7684\u5dee\u5f02\u8f83\u5927\uff1b\u53cd\u4e4b\uff0c\u5982\u679c\u65b9\u5dee\u503c\u8f83\u5c0f\uff0c\u8bf4\u660e\u6570\u636e\u503c\u4e4b\u95f4\u7684\u5dee\u5f02\u8f83\u5c0f\u3002
> VARIANCE(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\nINSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ), ('Mitchell Starc', 0, 3);\n\n-- \u8ba1\u7b97 RunScored \u5217\u7684\u65b9\u5dee\n> SELECT VARIANCE(RunScored) as Pop_Standard_Variance FROM t1;\n+-----------------------+\n| Pop_Standard_Variance |\n+-----------------------+\n| 284.8055555555555 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n-- \u8ba1\u7b97 WicketsTaken \u5217\u7684\u65b9\u5dee\nmysql> SELECT VARIANCE(WicketsTaken) as Pop_Std_Var_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Var_Wickets |\n+---------------------+\n| 0.9166666666666665 |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/","title":"CONVERT_TZ()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CONVERT_TZ()
\u51fd\u6570\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u65e5\u671f\u65f6\u95f4\u4ece\u4e00\u4e2a\u65f6\u533a\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u65f6\u533a\u3002\u5982\u679c\u53c2\u6570\u65e0\u6548\uff0c\u5219\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002
> CONVERT_TZ(dt,from_tz,to_tz)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e dt \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u7684\u7ed9\u5b9a\u65e5\u671f\u65f6\u95f4\u3002 from_tz \u5fc5\u8981\u53c2\u6570\u3002\u5f53\u524d\u65f6\u533a\u7684\u6807\u8bc6 to_tz \u5fc5\u8981\u53c2\u6570\u3002\u65b0\u7684\u65f6\u533a\u7684\u6807\u8bc6"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');\n+-------------------------------------------+\n| convert_tz(2004-01-01 12:00:00, GMT, MET) |\n+-------------------------------------------+\n| 2004-01-01 13:00:00 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','+00:00','+10:00');\n+-------------------------------------------------+\n| convert_tz(2004-01-01 12:00:00, +00:00, +10:00) |\n+-------------------------------------------------+\n| 2004-01-01 22:00:00 |\n+-------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select convert_tz('2023-12-31 10:28:00','+08:00', 'America/New_York') as dtime;\n+---------------------+\n| dtime |\n+---------------------+\n| 2023-12-30 21:28:00 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> select convert_tz(NULL,'-05:00', '+05:30') as dtime;\n+-------+\n| dtime |\n+-------+\n| NULL |\n+-------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/","title":"CURDATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURDATE()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u7684 YYYY-MM-DD
\u683c\u5f0f\u7684\u503c\u3002
Note
\u4e0e MySQL \u884c\u4e3a\u4e0d\u540c\u7684\u662f\uff1acurdate()+int
\u8868\u793a\u5f53\u524d\u65e5\u671f\u81f3 1970-01-01 \u518d\u52a0\u4e0a int
\uff08\u5929\u6570\uff09\u7684\u603b\u5929\u6570\u3002\u6bd4\u5982\uff0ccurdate()+1
\u8868\u793a\u5f53\u524d\u65e5\u671f\u51cf\u53bb 1970-01-01 \u518d\u52a0 1 \u5929\u3002
> CURDATE()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT CURDATE();\n+------------+\n| curdate() |\n+------------+\n| 2023-02-02 |\n+------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT CURDATE() + 0;\n+---------------+\n| curdate() + 0 |\n+---------------+\n| 19390 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select cast(now() as date)=curdate() q;\n+------+\n| q |\n+------+\n| true |\n+------+\n1 row in set (0.01 sec)\n\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(3);\n\nmysql> select cast(now() as date)=curdate() q from t1;\n+------+\n| q |\n+------+\n| true |\n| true |\n| true |\n+------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/","title":"CURRENT_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURRENT_TIMESTAMP
\u548c CURRENT_TIMESTAMP()
\u662f NOW()
\u7684\u540c\u4e49\u8bcd\u3002
\u5c06\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss
\u6216 YYYYMMDDhhmmss
\u7684\u683c\u5f0f\u8fd4\u56de\uff0c\u8fd4\u56de\u683c\u5f0f\u53d6\u51b3\u4e8e\u51fd\u6570\u662f\u5b57\u7b26\u4e32\u8fd8\u662f\u6570\u5b57\u3002\u53d6\u503c\u4e3a\u5f53\u524d\u4f1a\u8bdd\u6240\u5728\u7684\u65f6\u533a\u3002
> CURRENT_TIMESTAMP([fsp])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u53ef\u9009\u3002\u53c2\u6570 fsp
\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u5206\u79d2\u7cbe\u5ea6\uff0c\u6709\u6548\u503c\u4e3a 0 \u5230 6 \u4e4b\u95f4\u7684\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT CURRENT_TIMESTAMP();\n+----------------------------+\n| current_timestamp() |\n+----------------------------+\n| 2022-09-21 11:46:44.153777 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT NOW();\n+----------------------------+\n| now() |\n+----------------------------+\n| 2022-09-21 12:56:36.915961 |\n+----------------------------+\n1 row in set (0.01 sec)\n
create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);\ninsert into t1 select 1,1,1,now();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a | b | c | year(d) |\n+------+------+------+---------+\n| 1 | 1 | 1 | 2022 |\n| 2 | 0 | 0 | NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_5","title":"\u9650\u5236","text":"\u8fd0\u7b97\u7b26 +
\u6216 -
\u73b0\u5728\u4e0d\u652f\u6301\u4e0e CURRENT_TIMESTAMP
\u4e00\u8d77\u4f7f\u7528\u3002
DATE_ADD()
\u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1aDATE_ADD()
\u51fd\u6570\u5411\u65e5\u671f\u6dfb\u52a0\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u51fd\u6570\u8fd4\u56de NULL
\u3002
> DATE_ADD(date,INTERVAL expr unit)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 expr \u5fc5\u8981\u53c2\u6570\u3002expr \u53c2\u6570\u662f\u9700\u8981\u6dfb\u52a0\u8fdb date \u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982\u679c expr \u4e3a\u8d1f\u6570\uff0c\u90a3\u4e48\u53ef\u4ee5\u4ee5\u201c-\u201d\u5f00\u5934\u3002 unit \u5fc5\u8981\u53c2\u6570\u3002unit \u53c2\u6570\u53ef\u4ee5\u662f\u4e0b\u5217\u503c\uff1aMICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#_4","title":"\u793a\u4f8b","text":"create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_ADD(OrderDate,INTERVAL 45 DAY) AS OrderPayDate FROM t2;\n+---------+---------------------+\n| orderid | orderpaydate |\n+---------+---------------------+\n| 1 | 2008-12-26 13:23:45 |\n+---------+---------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65e5\u671f\u503c\u3002\u5982\u679c\u4efb\u4e00\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u51fd\u6570\u8fd4\u56de NULL
\u3002
DATE_FORMAT()
\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d\u5305\u542b\u7531 character_set_connection
\u548c collat\u200b\u200bion_connection
\u7ed9\u51fa\u7684\u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u89c4\u5219\uff0c\u4ee5\u4fbf\u5b83\u53ef\u4ee5\u8fd4\u56de\u5305\u542b\u975e ASCII \u5b57\u7b26\u7684\u6708\u4efd\u548c\u5de5\u4f5c\u65e5\u540d\u79f0\u3002
> DATE_FORMAT(date,format)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 format \u5fc5\u8981\u53c2\u6570\u3002Required. format \u53ef\u7528\u7684\u8bf4\u660e\u7b26\u53ef\u4ee5\u53c2\u52a0\u4e0b\u8868\u8be6\u60c5\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#format","title":"Format \u8bf4\u660e\u7b26","text":"Info
\u4e0b\u8868\u4e2d\u663e\u793a\u7684\u8bf4\u660e\u7b26\u53ef\u7528\u4e8e\u683c\u5f0f\u5b57\u7b26\u4e32\u3002\u5728\u683c\u5f0f\u8bf4\u660e\u7b26\u5b57\u7b26\u4e4b\u524d\u9700\u8981\u52a0 %
\u5b57\u7b26\u3002\u8bf4\u660e\u7b26\u4e5f\u9002\u7528\u4e8e\u51fd\u6570 UNIX_TIMESTAMP()
\u3002
mysql> SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');\n+--------------------------------------------+\n| date_format(2009-10-04 22:23:00, %W %M %Y) |\n+--------------------------------------------+\n| Sunday October 2009 |\n+--------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');\n+--------------------------------------------+\n| date_format(2007-10-04 22:23:00, %H:%i:%s) |\n+--------------------------------------------+\n| 22:23:00 |\n+--------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT Date_format('1900-10-04 22:23:00', '%D %y %a %d %m %b %j');\n+--------------------------------------------------------+\n| date_format(1900-10-04 22:23:00, %D %y %a %d %m %b %j) |\n+--------------------------------------------------------+\n| 4th 00 Thu 04 10 Oct 277 |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%H %k %I %r %T %S %w');\n+--------------------------------------------------------+\n| date_format(1997-10-04 22:23:00, %H %k %I %r %T %S %w) |\n+--------------------------------------------------------+\n| 22 22 10 10:23:00 PM 22:23:00 00 6 |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1999-01-01', '%X %V');\n+--------------------------------+\n| date_format(1999-01-01, %X %V) |\n+--------------------------------+\n| 1998 52 |\n+--------------------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t2 (f1 DATETIME);\nINSERT INTO t2 (f1) VALUES ('2005-01-01');\nINSERT INTO t2 (f1) VALUES ('2005-02-01');\n\nmysql> SELECT Date_format(f1, \"%m\") AS d1,\nDate_format(f1, \"%m\") AS d2\nFROM t2\nORDER BY Date_format(f1, \"%m\");\n+------+------+\n| d1 | d2 |\n+------+------+\n| 01 | 01 |\n| 02 | 02 |\n+------+------+\n2 rows in set (0.00 sec)\n
CREATE TABLE t5 (a int, b date);\nINSERT INTO t5\nVALUES (1,\n'2000-02-05'),\n(2,\n'2000-10-08'),\n(3,\n'2005-01-03'),\n(4,\n'2007-09-01'),\n(5,\n'2022-01-01');\n\nmysql> SELECT * FROM t5\nWHERE b = Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a | b |\n+------+------------+\n| 1 | 2000-02-05 |\n+------+------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT * FROM t5\nWHERE b != Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a | b |\n+------+------------+\n| 2 | 2000-10-08 |\n| 3 | 2005-01-03 |\n| 4 | 2007-09-01 |\n| 5 | 2022-01-01 |\n+------+------------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT(\"2009-01-01\",'%W %d %M %Y') as valid_date;\n+--------------------------+\n| valid_date |\n+--------------------------+\n| Thursday 01 January 2009 |\n+--------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
DATE_SUB()
\u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1aDATE_SUB()
\u51fd\u6570\u4ece date \u65e5\u671f\u4e2d\u51cf\u53bb\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u51fd\u6570\u8fd4\u56de NULL
\u3002
DATE_SUB(date,INTERVAL expr unit)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 expr \u5fc5\u8981\u53c2\u6570\u3002expr \u53c2\u6570\u662f\u9700\u8981\u6dfb\u52a0\u8fdb date \u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982\u679c expr \u4e3a\u8d1f\u6570\uff0c\u90a3\u4e48\u53ef\u4ee5\u4ee5\u201c-\u201d\u5f00\u5934\u3002 unit \u5fc5\u8981\u53c2\u6570\u3002unit \u53c2\u6570\u53ef\u4ee5\u662f\u4e0b\u5217\u503c\uff1aMICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#_4","title":"\u793a\u4f8b","text":"create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_SUB(OrderDate,INTERVAL 5 DAY) AS SubtractDate FROM t2;\n+---------+---------------------+\n| orderid | subtractdate |\n+---------+---------------------+\n| 1 | 2008-11-06 13:23:45 |\n+---------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u5c06 DATE
\u6216\u8005 DATETIME
\u683c\u5f0f\u7684\u8f93\u5165\u4e2d\u7684\u65e5\u671f\u90e8\u5206\u622a\u53d6\u51fa\u6765\u3002
> DATE(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u63d0\u53d6\u65e5\u671f\u7684 date \u6216\u8005 datetime \u683c\u5f0f\u7684\u8f93\u5165\u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values('20220101','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59');\n\nmysql> select date(a),date(b) from t1;\n+------------+------------+\n| date(a) | date(b) |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-30 |\n| 2022-06-30 | 2021-12-30 |\n+------------+------------+\n5 rows in set (0.01 sec)\n\nmysql> select date(a),date(date(a)) as dda from t1;\n+------------+------------+\n| date(a) | dda |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-31 |\n| 2022-06-30 | 2022-06-30 |\n+------------+------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
DATEDIFF()
\u51fd\u6570\u8fd4\u56de\u4e24\u4e2a\u65e5\u671f\u4e4b\u95f4\u7684\u5929\u6570\u3002
> DATEDIFF(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr1, expr2 \u5fc5\u8981\u53c2\u6570\u3002expr1 \u548c expr2 \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u6216\u65e5\u671f/\u65f6\u95f4\u8868\u8fbe\u5f0f\u3002\u53ea\u6709\u503c\u7684\u65e5\u671f\u90e8\u5206\u53c2\u4e0e\u8ba1\u7b97\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30');\n+-------------------------------------------+\n| datediff(2007-12-31 23:59:59, 2007-12-30) |\n+-------------------------------------------+\n| 1 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATEDIFF('2010-11-30 23:59:59','2010-12-31');\n+-------------------------------------------+\n| datediff(2010-11-30 23:59:59, 2010-12-31) |\n+-------------------------------------------+\n| -31 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n
create table t1(a INT, b date);\ninsert into t1 values(1, \"2012-10-11\");\ninsert into t1 values(2, \"2004-04-24\");\ninsert into t1 values(3, \"2008-12-04\");\ninsert into t1 values(4, \"2012-03-23\");\ninsert into t1 values(5, \"2000-03-23\");\ninsert into t1 values(6, \"2030-03-23\");\ninsert into t1 values(7, \"2040-03-23\");\n\nmysql> SELECT a, DATEDIFF('2022-10-9', b) from t1;\n+------+------------------------+\n| a | datediff(2022-10-9, b) |\n+------+------------------------+\n| 1 | 3650 |\n| 2 | 6742 |\n| 3 | 5057 |\n| 4 | 3852 |\n| 5 | 8235 |\n| 6 | -2722 |\n| 7 | -6375 |\n+------+------------------------+\n7 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/","title":"DAY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u67d0\u65e5\u671f\u4e3a\u5f53\u6708\u7684\u7b2c\u51e0\u53f7\uff0c\u8303\u56f4\u4e3a 1 \u5230 31\uff1b\u5bf9\u4e8e\u8bf8\u5982 0000-00-00
\u6216 2008-00-00
\u7b49\u5305\u542b 0 \u90e8\u5206\u7684\u65e5\u671f\uff0c\u5219\u8fd4\u56de 0\u3002\u5982\u679c\u65e5\u671f\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> DAY(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT day('2007-02-03');\n+-----------------+\n| day(2007-02-03) |\n+-----------------+\n| 3 |\n+-----------------+\n1 row in set (0.01 sec)\n
CREATE TABLE t3(c1 TIMESTAMP NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\n\nmysql> SELECT day(c1) from t3;\n+---------+\n| day(c1) |\n+---------+\n| 1 |\n| 31 |\n| 1 |\n| 25 |\n| 29 |\n+---------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/","title":"DAYOFYEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u65e5\u671f\u6240\u5bf9\u5e94\u5728\u4e00\u5e74\u4e2d\u7684\u5929\u6570\uff0c\u8fd4\u56de\u503c\u5728 1-366 \u4e4b\u95f4\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> DAYOFYEAR(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u63d0\u53d6\u5929\u6570\u7684 date \u683c\u5f0f\u7684\u8f93\u5165\u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a date, b datetime,c varchar(30));\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values('20220101','2022-01-01 01:01:01','2022-13-13 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01','2022-01-01 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59','2021-12-30 23:59:59');\n\nmysql> select distinct dayofyear(a) as dya from t1;\n+------+\n| dya |\n+------+\n| 1 |\n| 2 |\n| 365 |\n| 181 |\n+------+\n4 rows in set (0.00 sec)\n\nmysql> select * from t1 where dayofyear(a)>120;\n+------------+---------------------+---------------------+\n| a | b | c |\n+------------+---------------------+---------------------+\n| 2021-12-31 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1 where dayofyear(a) between 1 and 184;\n+------------+---------------------+---------------------+\n| a | b | c |\n+------------+---------------------+---------------------+\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-13-13 01:01:01 |\n| 2022-01-02 | 2022-01-02 23:01:01 | 2022-01-01 23:01:01 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_5","title":"\u9650\u5236","text":"DAYOFYEAR()
\u53ea\u652f\u6301 date
\u7c7b\u578b\u3002date
\u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002 EXTRACT()
\u51fd\u6570\u662f\u4ece\u65e5\u671f\u4e2d\u63d0\u53d6\u90e8\u5206\u5185\u5bb9\u3002\u5982\u679c\u65e5\u671f\u662f NULL
\u5219\u8fd4\u56de NULL\u3002
> EXTRACT(unit FROM date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 unit \u5fc5\u8981\u53c2\u6570\u3002unit \u53c2\u6570\u53ef\u4ee5\u662f\u4e0b\u5217\u503c\uff1aMICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#_4","title":"\u793a\u4f8b","text":"create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT EXTRACT(YEAR FROM OrderDate) AS OrderYear, EXTRACT(MONTH FROM OrderDate) AS OrderMonth FROM t2 WHERE OrderId=1;\n+-----------+------------+\n| orderyear | ordermonth |\n+-----------+------------+\n| 2008 | 11 |\n+-----------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
FROM_UNIXTIME()
\u51fd\u6570\u628a\u5185\u90e8 UNIX \u65f6\u95f4\u6233\u503c\u8f6c\u6362\u4e3a\u666e\u901a\u683c\u5f0f\u7684\u65e5\u671f\u65f6\u95f4\u503c\uff0c\u4ee5 YYYY-MM-DD HH:MM:SS \u6216 YYYYMMDDHHMMSS \u683c\u5f0f\u6765\u663e\u793a\u3002\u4e0e UNIX_TIMESTAMP ()
\u51fd\u6570\u4e92\u4e3a\u53cd\u51fd\u6570\u3002
> FROM_UNIXTIME(unix_timestamp[,format])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e format \u53ef\u9009\u53c2\u6570\u3002\u8868\u793a\u8fd4\u56de\u503c\u683c\u5f0f\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\u3002 \u5982\u679c\u7701\u7565 format\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a DATETIME
\u503c\u3002 \u5982\u679c format \u4e3a\u7a7a\uff0c\u5219\u8fd4\u56de NULL
\u3002format \u7528\u4e8e\u683c\u5f0f\u5316\u7ed3\u679c\uff0c\u5176\u65b9\u5f0f\u4e0e DATE_FORMAT()
\u51fd\u6570\u4f7f\u7528\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\u76f8\u540c\u3002\u5982\u679c format \u5df2\u5b58\u5728\u6307\u5b9a\u683c\u5f0f\uff0c\u5219\u8fd4\u56de\u503c\u4e3a VARCHAR
\u3002 unix_timestamp \u5fc5\u8981\u53c2\u6570\u3002\u65f6\u95f4\u6233\uff0c\u53ef\u4ee5\u7528\u6570\u636e\u5e93\u91cc\u7684\u5b58\u50a8\u65f6\u95f4\u6570\u636e\u7684\u5b57\u6bb5\u3002\u5982\u679c unix_timestamp \u4e3a\u7a7a\uff0c\u5219\u8fd4\u56de NULL
\u3002 \u5982\u679c unix_timestamp \u662f\u4e00\u4e2a\u6574\u6570\uff0c\u5219 DATETIME
\u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\u4e3a\u96f6\u3002\u5f53 unix_timestamp \u662f\u5341\u8fdb\u5236\u503c\u65f6\uff0cDATETIME
\u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\u4e0e\u5341\u8fdb\u5236\u503c\u7684\u7cbe\u5ea6\u76f8\u540c\uff0c\u6700\u591a\u53ef\u8fbe 6 \u79d2\u3002\u5f53 unix_timestamp
\u662f\u6d6e\u70b9\u6570\u65f6\uff0cdatetime
\u7684\u5206\u79d2\u7cbe\u5ea6\u4e3a 6\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT FROM_UNIXTIME(1447430881);\n+---------------------------+\n| from_unixtime(1447430881) |\n+---------------------------+\n| 2015-11-14 00:08:01 |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1447430881, '%Y %D %M %h:%i:%s %x');\n+-------------------------------------------------+\n| from_unixtime(1447430881, %Y %D %M %h:%i:%s %x) |\n+-------------------------------------------------+\n| 2015 14th November 12:08:01 2015 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u8fd4\u56de\u65f6\u95f4\u7684\u5c0f\u65f6\u3002\u5bf9\u4e8e\u65f6\u95f4\u503c\uff0c\u8fd4\u56de\u503c\u7684\u8303\u56f4\u662f 0 \u5230 23\u3002\u4f46\u662f\uff0ctime
\u503c\u7684\u8303\u56f4\u5b9e\u9645\u4e0a\u8981\u5927\u5f97\u591a\uff0c\u56e0\u6b64 HOUR
\u53ef\u4ee5\u8fd4\u56de\u5927\u4e8e 23 \u7684\u503c\u3002\u5982\u679c time
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> HOUR(time)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e time \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u65f6\u95f4\u6216\u65f6\u95f4\u6233\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select hour(a),hour(b) from t1;\n+---------+---------+\n| hour(a) | hour(b) |\n+---------+---------+\n| 0 | 12 |\n| 12 | 0 |\n| NULL | 23 |\n| 0 | NULL |\n| 14 | 0 |\n| 0 | 12 |\n| 0 | 0 |\n+---------+---------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where hour(a)>hour(b);\n+---------------------+---------------------+\n| a | b |\n+---------------------+---------------------+\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/","title":"MINUTE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de time
\u7684\u5206\u949f\uff0c\u53d6\u503c\u8303\u56f4\u4e3a 0 \u5230 59\uff0c\u5982\u679c time
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> MINUTE(time)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e time \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u65f6\u95f4\u6216\u65f6\u95f4\u6233\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT MINUTE('2008-02-03 10:05:03');\n+-----------------------------+\n| minute(2008-02-03 10:05:03) |\n+-----------------------------+\n| 5 |\n+-----------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select minute(a),minute(b) from t1;\n+-----------+-----------+\n| minute(a) | minute(b) |\n+-----------+-----------+\n| 0 | 0 |\n| 32 | 0 |\n| NULL | 10 |\n| 0 | NULL |\n| 11 | 0 |\n| 0 | 0 |\n| 0 | 0 |\n+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where minute(a)<=minute(b);\n+---------------------+---------------------+\n| a | b |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/","title":"MONTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u65e5\u671f\u7684\u6708\u4efd\uff0c\u5bf9\u4e8e 1 \u6708\u5230 12 \u6708\uff0c\u8fd4\u56de\u8303\u56f4\u4e3a 1 \u5230 12\uff1b\u5bf9\u4e8e\u201c0000-00-00\u201d\u6216\u201c2008-00-00\u201d\u7b49\u65e5\u671f\uff0c\u8fd4\u56de 0 \u6708\u4efd\u3002\u5982\u679c date
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> MONTH(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT MONTH('2008-02-03');\n+-------------------+\n| month(2008-02-03) |\n+-------------------+\n| 2 |\n+-------------------+\n1 row in set (0.02 sec)\n
drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select month(d),month(dt) from t1;\n+----------+-----------+\n| month(d) | month(dt) |\n+----------+-----------+\n| 1 | 1 |\n| 1 | 1 |\n| 2 | 2 |\n| 2 | 2 |\n| 2 | 2 |\n| 3 | 2 |\n| 4 | 4 |\n| 5 | 5 |\n| 6 | 6 |\n| 7 | 7 |\n| 8 | 8 |\n| 9 | 9 |\n| 10 | 10 |\n| 11 | 11 |\n| 12 | 12 |\n| NULL | NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n\nmysql> select month(c),month(vc) from t1;\n+----------+-----------+\n| month(c) | month(vc) |\n+----------+-----------+\n| 12 | 12 |\n| 12 | 12 |\n| 2 | 2 |\n| 2 | 2 |\n| 2 | 2 |\n| 3 | 3 |\n| 4 | 4 |\n| 5 | 5 |\n| 6 | 6 |\n| 7 | 7 |\n| 8 | 8 |\n| 9 | 9 |\n| 10 | 10 |\n| 11 | 11 |\n| 12 | 12 |\n| NULL | NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/","title":"NOW()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"NOW()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002
NOW()
\u8fd4\u56de\u8bed\u53e5\u5f00\u59cb\u6267\u884c\u7684\u65f6\u95f4\u3002\u8fd9\u4e0e SYSDATE()
\u7684\u884c\u4e3a\u4e0d\u540c\uff0c\u540e\u8005\u8fd4\u56de\u6267\u884c\u8fc7\u7a0b\u4e2d\u52a8\u6001\u7684\u5b9e\u65f6\u65f6\u95f4\u3002
> NOW(fsp)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u975e\u5fc5\u8981\u53c2\u6570\u3002\u5982\u679c\u7ed9\u5b9a fsp \u53c2\u6570\u4ee5\u6307\u5b9a\u4ece 0 \u5230 6 \u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\uff0c\u5219\u8fd4\u56de\u503c\u5305\u62ec\u8be5\u6570\u5b57\u7684\u5c0f\u6570\u79d2\u90e8\u5206\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/#_4","title":"\u793a\u4f8b","text":"mysql> select now();\n+----------------------------+\n| now() |\n+----------------------------+\n| 2024-04-29 08:03:50.479238 |\n+----------------------------+\n1 row in set (0.03 sec)\n\nmysql> select now(6);\n+----------------------------+\n| now(6) |\n+----------------------------+\n| 2024-04-29 08:05:26.528629 |\n+----------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT NOW(), SLEEP(2), NOW();\n+----------------------------+----------+----------------------------+\n| now() | sleep(2) | now() |\n+----------------------------+----------+----------------------------+\n| 2024-04-29 08:17:23.876546 | 0 | 2024-04-29 08:17:23.876546 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.06 sec)\n\nmysql> SELECT SYSDATE(), SLEEP(2), SYSDATE();\n+----------------------------+----------+----------------------------+\n| sysdate() | sleep(2) | sysdate() |\n+----------------------------+----------+----------------------------+\n| 2024-04-29 16:19:21.439725 | 0 | 2024-04-29 16:19:23.440187 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/","title":"SECOND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de time
\u4e2d\u79d2\u7684\u503c\uff0c\u53d6\u503c\u8303\u56f4\u4e3a 0 \u5230 59\uff0c\u5982\u679c time
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> SECOND(time)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e time \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u65f6\u95f4\u6216\u65f6\u95f4\u6233\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select second(a),second(b) from t1;\n+-----------+-----------+\n| second(a) | second(b) |\n+-----------+-----------+\n| 0 | 0 |\n| 11 | 0 |\n| NULL | 11 |\n| 0 | NULL |\n| 9 | 0 |\n| 0 | 0 |\n| 0 | 0 |\n+-----------+-----------+\n7 rows in set (0.01 sec)\n\nmysql> select * from t1 where second(a)>=second(b);\n+---------------------+---------------------+\n| a | b |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/","title":"STR_TO_DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"STR_TO_DATE()
\u51fd\u6570\u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b\uff0c\u4e0e TO_DATE()
\u540c\u4e49\u3002
\u683c\u5f0f\u5b57\u7b26\u4e32\u53ef\u4ee5\u5305\u542b\u6587\u5b57\u5b57\u7b26\u548c\u4ee5%\u5f00\u5934\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\u3002format \u4e2d\u7684\u5b57\u9762\u5b57\u7b26\u4e0e\u683c\u5f0f\u8bf4\u660e\u7b26\u5fc5\u987b\u4e0e str \u5339\u914d\uff0c\u652f\u6301\u8868\u8fbe\u5f0f\u3002\u5982\u679c\u4e0d\u80fd\u6309\u7167 format \u89e3\u6790 str \u6216\u8005\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL\uff0cSTR_TO_DATE
\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002
\u6709\u5173\u53ef\u4ee5\u4f7f\u7528\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\uff0c\u8bf7\u53c2\u9605 DATE_FORMAT()
\u51fd\u6570\u63cf\u8ff0\u3002
> STR_TO_DATE(str,format)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u8981\u683c\u5f0f\u5316\u4e3a\u65e5\u671f\u7684\u5b57\u7b26\u4e32 (\u8f93\u5165\u5b57\u7b26\u4e32) format \u8981\u4f7f\u7528\u7684\u683c\u5f0f\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT STR_TO_DATE('2022-01-06 10:20:30','%Y-%m-%d %H:%i:%s') as result;\n+---------------------+\n| result |\n+---------------------+\n| 2022-01-06 10:20:30 |\n+---------------------+\n1 row in set (0.00 sec) mysql> SELECT STR_TO_DATE('09:30:17','%h:%i:%s');\n+---------------------------------+\n| str_to_date(09:30:17, %h:%i:%s) |\n+---------------------------------+\n| 09:30:17 |\n+---------------------------------+\n1 row in set (0.00 sec)\n\n-- format \u53c2\u6570\u652f\u6301\u8868\u8fbe\u5f0f\nmysql> SELECT str_to_date('2008-01-01',replace('yyyy-MM-dd','yyyy-MM-dd','%Y-%m-%d')) as result;\n+------------+\n| result |\n+------------+\n| 2008-01-01 |\n+------------+\n1 row in set (0.00 sec)\n\n--STR_TO_DATE \u51fd\u6570\u5728\u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32 format \u89e3\u6790\u8f93\u5165\u5b57\u7b26\u4e32 str \u65f6\uff0c\u5ffd\u7565\u8f93\u5165\u5b57\u7b26\u4e32 str \u672b\u5c3e\u7684\u989d\u5916\u5b57\u7b26\nmysql> SELECT STR_TO_DATE('25,5,2022 extra characters','%d,%m,%Y'); +---------------------------------------------------+\n| str_to_date(25,5,2022 extra characters, %d,%m,%Y) |\n+---------------------------------------------------+\n| 2022-05-25 |\n+---------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT STR_TO_DATE('2022','%Y');\n+-----------------------+\n| str_to_date(2022, %Y) |\n+-----------------------+\n| NULL |\n+-----------------------\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/","title":"SYSDATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SYSDATE()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002
SYSDATE()
\u8fd4\u56de\u6267\u884c\u8fc7\u7a0b\u4e2d\u52a8\u6001\u7684\u5b9e\u65f6\u65f6\u95f4\u3002\u8fd9\u4e0e NOW()
\u7684\u884c\u4e3a\u4e0d\u540c\uff0c\u540e\u8005\u8fd4\u56de\u8bed\u53e5\u5f00\u59cb\u6267\u884c\u7684\u65f6\u95f4\u3002
> SYSDATE(fsp)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u975e\u5fc5\u8981\u53c2\u6570\u3002\u5982\u679c\u7ed9\u5b9a fsp \u53c2\u6570\u4ee5\u6307\u5b9a\u4ece 0 \u5230 6 \u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\uff0c\u5219\u8fd4\u56de\u503c\u5305\u62ec\u8be5\u6570\u5b57\u7684\u5c0f\u6570\u79d2\u90e8\u5206\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/#_4","title":"\u793a\u4f8b","text":"mysql> select sysdate();\n+----------------------------+\n| sysdate() |\n+----------------------------+\n| 2024-04-30 10:49:39.554807 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sysdate(6);\n+----------------------------+\n| sysdate(6) |\n+----------------------------+\n| 2024-04-30 10:50:08.452370 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT SYSDATE(), SLEEP(2), SYSDATE();\n+----------------------------+----------+----------------------------+\n| sysdate() | sleep(2) | sysdate() |\n+----------------------------+----------+----------------------------+\n| 2024-04-30 10:50:30.004912 | 0 | 2024-04-30 10:50:32.005203 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.00 sec)\n\nmysql> SELECT NOW(), SLEEP(2), NOW();\n+----------------------------+----------+----------------------------+\n| now() | sleep(2) | now() |\n+----------------------------+----------+----------------------------+\n| 2024-04-30 10:50:47.904309 | 0 | 2024-04-30 10:50:47.904309 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/","title":"TIME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u63d0\u53d6\u65f6\u95f4\u6216\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f expr
\u7684\u65f6\u95f4\u90e8\u5206\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u5982\u679c expr
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> TIME(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u63d0\u53d6\u65f6\u95f4\u7684 date \u6216\u8005 datetime \u683c\u5f0f\u7684\u8f93\u5165\u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TIME('2003-12-31 01:02:03');\n+---------------------------+\n| time(2003-12-31 01:02:03) |\n+---------------------------+\n| 01:02:03 |\n+---------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/","title":"TIMEDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TIMEDIFF()
\u8fd4\u56de\u4e24\u4e2a TIME
\u6216 DATETIME
\u503c\u4e4b\u95f4\u7684\u5dee\u503c\u3002TIMEDIFF()
\u51fd\u6570\u7684\u4e24\u4e2a\u8868\u8fbe\u5f0f\u5fc5\u987b\u4e3a\u76f8\u540c\u7c7b\u578b\u7684\u53c2\u6570\uff0c\u5373 TIME
\u6216 DATETIME
\u3002TIMEDIFF
\u51fd\u6570\u8fd4\u56de\u8868\u793a\u4e3a\u65f6\u95f4\u503c\u7684 expr1 - expr2
\u7684\u7ed3\u679c\u3002
> TIMEDIFF(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr1, expr2 \u5fc5\u8981\u53c2\u6570\u3002expr1 \u548c expr2 \u8868\u8fbe\u5f0f\u9700\u8981\u5177\u6709\u76f8\u540c\u7684\u7c7b\u578b\u3002expr1 \u548c expr2 \u662f\u8f6c\u6362\u4e3a TIME \u6216 DATETIME \u8868\u8fbe\u5f0f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c expr1 \u6216 expr2 \u4e3a NULL \u5219\u8fd4\u56de NULL\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#_4","title":"\u793a\u4f8b","text":"mysql> select timediff(\"22:22:22\", \"11:00:00\");\n+------------------------------+\n| timediff(22:22:22, 11:00:00) |\n+------------------------------+\n| 11:22:22.000000 |\n+------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select timediff(cast('22:22:22' as time), null);\n+--------------------------------------------+\n| timediff(cast(22:22:22 as time(26)), null) |\n+--------------------------------------------+\n| NULL |\n+--------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select timediff(CAST('2017-08-08 22:22:22' as datetime), CAST('2000-01-02 11:00:00' as datetime));\n+------------------------------------------------------------------------------------------------+\n| timediff(cast(2017-08-08 22:22:22 as datetime(26)), cast(2000-01-02 11:00:00 as datetime(26))) |\n+------------------------------------------------------------------------------------------------+\n| 154283:22:22 |\n+------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
create table time_01(t1 time,t2 time,t3 time);\ninsert into time_01 values(\"-838:59:59.0000\",\"838:59:59.00\",\"22:00:00\");\ninsert into time_01 values(\"0:00:00.0000\",\"0\",\"0:00\");\ninsert into time_01 values(null,NULL,null);\ninsert into time_01 values(\"23\",\"1122\",\"-1122\");\ninsert into time_01 values(\"101412\",\"4\",\"-101219\");\ninsert into time_01 values(\"24:59:09.932823\",\"24:02:00.93282332424\",\"24:20:34.00000000\");\ninsert into time_01 values(\"2022-09-08 12:00:01\",\"019\",\"23403\");\n\nmysql> select * from time_01;\n+------------+-----------+-----------+\n| t1 | t2 | t3 |\n+------------+-----------+-----------+\n| -838:59:59 | 838:59:59 | 22:00:00 |\n| 00:00:00 | 00:00:00 | 00:00:00 |\n| NULL | NULL | NULL |\n| 00:00:23 | 00:11:22 | -00:11:22 |\n| 10:14:12 | 00:00:04 | -10:12:19 |\n| 24:59:10 | 24:02:01 | 24:20:34 |\n| 12:00:01 | 00:00:19 | 02:34:03 |\n+------------+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select timediff(t1,t2) from time_01;\n+------------------+\n| timediff(t1, t2) |\n+------------------+\n| -1677:59:58 |\n| 00:00:00 |\n| NULL |\n| -00:10:59 |\n| 10:14:08 |\n| 00:57:09 |\n| 11:59:42 |\n+------------------+\n7 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/","title":"TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5355\u4e2a\u53c2\u6570\u65f6\uff0cTIMESTAMP()
\u5c06\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f expr \u4f5c\u4e3a\u65e5\u671f\u65f6\u95f4\u503c\u8fd4\u56de\u3002\u4e24\u4e2a\u53c2\u6570\u65f6\uff0cTIMESTAMP()
\u5c06\u65f6\u95f4\u8868\u8fbe\u5f0f expr2 \u6dfb\u52a0\u5230\u65e5\u671f\u6216 datetime \u8868\u8fbe\u5f0f expr1 \u4e2d\uff0c\u5e76\u5c06\u7ed3\u679c\u4f5c\u4e3a datetime \u503c\u8fd4\u56de\u3002\u5982\u679c expr\u3001expr1 \u6216 expr2 \u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> TIMESTAMP(expr), TIMESTAMP(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002expr \u53c2\u6570\u662f\u9700\u8981\u6dfb\u52a0\u8fdb date \u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982\u679c expr \u4e3a\u8d1f\u6570\uff0c\u90a3\u4e48\u53ef\u4ee5\u4ee5\u201c-\u201d\u5f00\u5934\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TIMESTAMP('2003-12-31');\n+----------------------------+\n| timestamp(2003-12-31) |\n+----------------------------+\n| 2003-12-31 00:00:00.000000 |\n+----------------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t1(c1 DATE NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT TIMESTAMP(c1) FROM t1;\n+----------------------------+\n| timestamp(c1) |\n+----------------------------+\n| 2000-01-01 00:00:00.000000 |\n| 1999-12-31 00:00:00.000000 |\n| 2000-01-01 00:00:00.000000 |\n| 2006-12-25 00:00:00.000000 |\n| 2008-02-29 00:00:00.000000 |\n+----------------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_5","title":"\u9650\u5236","text":"TIMESTAMP()
\u6682\u4e0d\u652f\u6301\u53cc\u53c2\u6570\uff0c\u5373\u6682\u4e0d\u652f\u6301 TIMESTAMP(expr1,expr2)
\u3002
TIMESTAMPEDIFF()
\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u5728\u7ed9\u5b9a\u7684\u65f6\u95f4\u5355\u4f4d\u5185\uff0c\u4ece\u7b2c\u4e00\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u5230\u7b2c\u4e8c\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5373 datetime_expr2
\u4e0e datetime_expr1
\u7684\u5dee\u503c\u3002datetime_expr1
\u548c datetime_expr2
\u662f\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\uff1b\u4e00\u4e2a\u8868\u8fbe\u5f0f\u53ef\u4ee5\u662f\u65e5\u671f\uff0c\u53e6\u4e00\u4e2a\u8868\u8fbe\u5f0f\u53ef\u4ee5\u662f\u65e5\u671f\u65f6\u95f4\uff0c\u65e5\u671f\u503c\u88ab\u89c6\u4e3a\u5177\u6709\u65f6\u95f4\u90e8\u5206 00:00:00
\u7684\u65e5\u671f\u65f6\u95f4\u3002
\u5982\u679c datetime_expr1
\u6216 datetime_expr2
\u4e3a NULL
\uff0c\u5219\u6b64\u51fd\u6570\u8fd4\u56de NULL
\u3002
> TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e unit \u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u65f6\u95f4\u95f4\u9694\u7684\u5355\u4f4d\u3002\u8fd9\u53ef\u4ee5\u662f MICROSECOND
\u3001SECOND
\u3001MINUTE
\u3001HOUR
\u3001DAY
\u3001WEEK
\u3001MONTH
\u6216 YEAR
\u7b49\u3002 datetime_expr1,datetime_expr2 \u5fc5\u8981\u53c2\u6570\u3002datetime_expr1 \u548c datetime_expr2 \u8868\u8fbe\u5f0f\u9700\u8981\u5177\u6709\u76f8\u540c\u7684\u7c7b\u578b\u3002datetime_expr1 \u548c datetime_expr2 \u662f\u8f6c\u6362\u4e3a TIME
\u6216 DATETIME
\u8868\u8fbe\u5f0f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c datetime_expr1 \u6216 datetime_expr2 \u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TIMESTAMPDIFF( MICROSECOND, '2017-12-01 12:15:12','2018-01-01 7:18:20');\n+---------------------------------------------------------------------+\n| timestampdiff(microsecond, 2017-12-01 12:15:12, 2018-01-01 7:18:20) |\n+---------------------------------------------------------------------+\n| 2660588000000 |\n+---------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a date, b date);\ninsert into t1 values('2019-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2019-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2020-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2021-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2022-01-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2018-01-01 12:15:12', '2019-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2019-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2020-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2021-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2022-01-01 12:15:12');\n\nmysql> SELECT a, b, TIMESTAMPDIFF(MICROSECOND, a, b) from t1;\n+------------+------------+----------------------------------+\n| a | b | timestampdiff(microsecond, a, b) |\n+------------+------------+----------------------------------+\n| 2019-11-01 | 2018-01-01 | -57801600000000 |\n| 2019-10-01 | 2018-01-01 | -55123200000000 |\n| 2020-10-01 | 2018-01-01 | -86745600000000 |\n| 2021-11-01 | 2018-01-01 | -120960000000000 |\n| 2022-01-01 | 2018-01-01 | -126230400000000 |\n| 2018-01-01 | 2019-11-01 | 57801600000000 |\n| 2018-01-01 | 2019-10-01 | 55123200000000 |\n| 2018-01-01 | 2020-10-01 | 86745600000000 |\n| 2018-01-01 | 2021-11-01 | 120960000000000 |\n| 2018-01-01 | 2022-01-01 | 126230400000000 |\n+------------+------------+----------------------------------+\n10 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/","title":"TO_DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_DATE()
\u51fd\u6570\u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b\uff0c\u4e0e STR_TO_DATE()
\u540c\u4e49\u3002
\u683c\u5f0f\u5b57\u7b26\u4e32\u53ef\u4ee5\u5305\u542b\u6587\u5b57\u5b57\u7b26\u548c\u4ee5%\u5f00\u5934\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\u3002format \u4e2d\u7684\u5b57\u9762\u5b57\u7b26\u4e0e\u683c\u5f0f\u8bf4\u660e\u7b26\u5fc5\u987b\u4e0e str \u5339\u914d\uff0c\u5982\u679c\u4e0d\u80fd\u6309\u7167 format \u89e3\u6790 str \u6216\u8005\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL\uff0cTO_DATE
\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002
\u6709\u5173\u53ef\u4ee5\u4f7f\u7528\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\uff0c\u8bf7\u53c2\u9605 DATE_FORMATE()
\u51fd\u6570\u63cf\u8ff0\u3002
> TO_DATE(str,format)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u8981\u683c\u5f0f\u5316\u4e3a\u65e5\u671f\u7684\u5b57\u7b26\u4e32 (\u8f93\u5165\u5b57\u7b26\u4e32) format \u8981\u4f7f\u7528\u7684\u683c\u5f0f\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TO_DATE('2022-01-06 10:20:30','%Y-%m-%d %H:%i:%s') as result;\n+---------------------+\n| result |\n+---------------------+\n| 2022-01-06 10:20:30 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DATE('2022/11/01','%Y/%m/%d');\n+-------------------------------+\n| to_date(2022/11/01, %Y/%m/%d) |\n+-------------------------------+\n| 2022-11-01 |\n+-------------------------\n\n-- format \u53c2\u6570\u652f\u6301\u8868\u8fbe\u5f0f\nmysql> SELECT to_date('2008-01-01',replace('yyyy-MM-dd','yyyy-MM-dd','%Y-%m-%d')) as result;\n+------------+\n| result |\n+------------+\n| 2008-01-01 |\n+------------+\n1 row in set (0.01 sec)\n\n--TO_DATE \u51fd\u6570\u5728\u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32 format \u89e3\u6790\u8f93\u5165\u5b57\u7b26\u4e32 str \u65f6\uff0c\u5ffd\u7565\u8f93\u5165\u5b57\u7b26\u4e32 str \u672b\u5c3e\u7684\u989d\u5916\u5b57\u7b26\nmysql> SELECT TO_DATE('25,5,2022 extra characters','%d,%m,%Y'); +-----------------------------------------------+\n| to_date(25,5,2022 extra characters, %d,%m,%Y) |\n+-----------------------------------------------+\n| 2022-05-25 |\n+-----------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DATE('2022','%Y');\n+-------------------+\n| to_date(2022, %Y) |\n+-------------------+\n| NULL |\n+-------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/","title":"TO_DAYS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_DAYS()
\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u4e0e\u516c\u5386\u65e5\u5386\u7684\u5f00\u59cb\u65e5\u671f\uff080000 \u5e74 1 \u6708 1 \u65e5\uff09\u4e4b\u95f4\u7684\u5929\u6570\u5dee\u3002\u5982\u679c date
\u662f NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
Note
0000-00-00
\u548c 0000-01-01
\u8be5\u65e5\u671f\u672c\u8eab\u88ab\u89c6\u4e3a\u65e0\u6548\u3002MatrixOne \u5e74\u4efd\u67e5\u8be2\u5e94\u8be5\u4ece 0001
\u5e74\u5f00\u59cb\u3002\u67e5\u8be2 0000-00-00
\u548c 0000-01-01
\uff0cTO_DAYS()
\u8fd4\u56de\u62a5\u9519\u4fe1\u606f\uff1a
mysql> SELECT TO_DAYS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-00-00\nmysql> SELECT TO_DAYS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-01-01\n
\u5bf9\u4e8e\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\uff0c\u4f8b\u5982\u67e5\u8be2 SELECT TO_DAYS('08-10-07');
\uff0cMatrixOne \u5c06\u5e74\u4efd 08 \u81ea\u52a8\u8865\u5168\u4e3a 0008\uff0c\u4e0e MySQL \u4e0d\u540c\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\u3002
> TO_DAYS(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#_3","title":"\u793a\u4f8b","text":"-- \u67e5\u8be2\u5c06\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u65e5\u671f'2023-07-12'\u4e0e\u516c\u5386\u65e5\u5386\u5f00\u59cb\u65e5\u671f\u4e4b\u95f4\u7684\u5929\u6570\u5dee\u3002\nmysql> SELECT TO_DAYS('2023-07-12');\n+---------------------+\n| to_days(2023-07-12) |\n+---------------------+\n| 739078 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DAYS('2008-10-07'), TO_DAYS('08-10-07');\n+---------------------+-------------------+\n| to_days(2008-10-07) | to_days(08-10-07) |\n+---------------------+-------------------+\n| 733687 | 3202 |\n+---------------------+-------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/","title":"TO_SECONDS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_SECONDS(expr)
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4 expr \u4e0e\u516c\u5143 0 \u5e74 1 \u6708 1 \u65e5 0 \u65f6 0 \u5206 0 \u79d2\u4e4b\u95f4\u7684\u79d2\u6570\u5dee\u3002\u5982\u679c expr
\u662f NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
Note
0000-00-00
\u548c 0000-01-01
\u65e5\u671f\u672c\u8eab\u88ab\u89c6\u4e3a\u65e0\u6548\u3002MatrixOne \u5e74\u4efd\u67e5\u8be2\u5e94\u8be5\u4ece 0001
\u5e74\u5f00\u59cb\u3002\u67e5\u8be2 0000-00-00
\u548c 0000-01-01
\uff0cTO_SECONDS()
\u8fd4\u56de\u62a5\u9519\u4fe1\u606f\uff1a
mysql> SELECT TO_SECONDS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-00-00\nmysql> SELECT TO_SECONDS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-01-01\n
\u4e0e TO_DAYS()
\u51fd\u6570\u76f8\u4f3c\uff0c\u4f8b\u5982\u67e5\u8be2 SELECT TO_SECONDS('08-10-07');
\uff0cMatrixOne \u5c06\u5e74\u4efd 08 \u81ea\u52a8\u8865\u5168\u4e3a 0008\uff0c\u4e0e MySQL \u4e0d\u540c\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\u3002
> TO_SECONDS(expr)\n
expr
\u662f\u65e5\u671f\u65f6\u95f4\u503c\uff0c\u53ef\u4ee5\u662f DATETIME
\u3001DATE
\u6216 TIMESTAMP
\u7c7b\u578b\u3002
mysql> SELECT TO_SECONDS('0001-01-01');\n+------------------------+\n| to_seconds(0001-01-01) |\n+------------------------+\n| 31622400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2023-07-12 08:30:00');\n+---------------------------------+\n| to_seconds(2023-07-12 08:30:00) |\n+---------------------------------+\n| 63856369800 |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2007-10-07');\n+------------------------+\n| to_seconds(2007-10-07) |\n+------------------------+\n| 63358934400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('97-10-07');\n+----------------------+\n| to_seconds(97-10-07) |\n+----------------------+\n| 3085257600 |\n+----------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/","title":"UNIX_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UNIX_TIMESTAMP()
\u8fd4\u56de\u81ea 1970-01-01 00:00:00 UTC \u81f3\u5f53\u524d\u65f6\u95f4\u7684\u79d2\u6570\u3002
UNIX_TIMESTAMP(date)
\u5c06\u53c2\u6570\u7684\u503c\u8fd4\u56de\u4e3a 1970-01-01 00:00:00 UTC \u81f3 date \u6307\u5b9a\u65f6\u95f4\u7684\u79d2\u6570\u3002
\u5982\u679c\u65e5\u671f\u8d85\u51fa\u8303\u56f4\u4f20\u9012\u7ed9 UNIX_TIMESTAMP()
\uff0c\u5b83\u5c06\u8fd4\u56de 0\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
\u5982\u679c\u6ca1\u6709\u7ed9\u51fa\u53c2\u6570\u6216\u53c2\u6570\u4e0d\u5305\u542b\u5c0f\u6570\u79d2\u90e8\u5206\uff0c\u5219\u8fd4\u56de\u503c\u4e3a\u6574\u6570\uff1b\u5982\u679c\u7ed9\u51fa\u53c2\u6570\u5305\u542b\u5c0f\u6570\u79d2\u90e8\u5206\uff0c\u5219\u8fd4\u56de\u503c\u4e3a DECIMAL
\u3002
> UNIX_TIMESTAMP([date])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u53ef\u9009\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 date \u53c2\u6570\u53ef\u4ee5\u662f DATE
\u3001DATETIME
\u6216 TIMESTAMP
\u5b57\u7b26\u4e32\uff0c\u4e5f\u53ef\u4ee5\u662f YYMMDD\u3001YYMMDDhhmmss\u3001YYYYMMDD \u6216 YYYYMMDDhhmmss \u683c\u5f0f\u7684\u6570\u5b57\u3002\u5982\u679c date \u53c2\u6570\u5305\u542b\u65f6\u95f4\u90e8\u5206\uff0c\u5219\u5b83\u6709\u9009\u62e9\u5730\u5305\u542b\u79d2\u7684\u5c0f\u6570\u90e8\u5206\u3002 \u5f53 date \u53c2\u6570\u662f TIMESTAMP
\u65f6\uff0cUNIX_TIMESTAMP()
\u76f4\u63a5\u8fd4\u56de\u5185\u90e8\u65f6\u95f4\u6233\u503c\uff0c\u800c\u4e0d\u8fdb\u884c\u9690\u542b\u7684 string-to-Unix-timestamp \u8f6c\u6362\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#utc-unix","title":"\u975e UTC \u65f6\u533a\u7684\u503c\u548c Unix \u65f6\u95f4\u6233\u503c\u4e4b\u95f4\u7684\u8f6c\u6362","text":"\u5982\u679c\u4f7f\u7528 UNIX_TIMESTAMP()
\u548c FROM_UNIXTIME()
\u5728\u975e UTC\uff08Coordinated Universal Time\uff0c\u534f\u8c03\u4e16\u754c\u65f6\uff09\u65f6\u533a\u7684\u503c\u548c Unix \u65f6\u95f4\u6233\u503c\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\uff0c\u5219\u8f6c\u6362\u662f\u6709\u635f\u7684\uff0c\u56e0\u4e3a\u6620\u5c04\u5728\u4e24\u4e2a\u65b9\u5411\u4e0a\u4e0d\u662f\u4e00\u5bf9\u4e00\u7684\u3002\u4f8b\u5982\uff0c\u7531\u4e8e\u8bf8\u5982\u590f\u4ee4\u65f6 (DST) \u7b49\u672c\u5730\u65f6\u533a\u66f4\u6539\u7684\u7ea6\u5b9a\uff0cUNIX_TIMESTAMP()
\u53ef\u4ee5\u5c06\u5728\u975e UTC \u65f6\u533a\u4e2d\u4e0d\u540c\u7684\u4e24\u4e2a\u503c\u6620\u5c04\u5230\u76f8\u540c\u7684 Unix \u65f6\u95f4\u6233\u503c\u3002FROM_UNIXTIME()
\u5c06\u8be5\u503c\u4ec5\u6620\u5c04\u56de\u539f\u59cb\u503c\u4e4b\u4e00\u3002\u4e0b\u9762\u7684\u793a\u4f8b\uff0c\u5373\uff0c\u4f7f\u7528\u5728 MET
\u65f6\u533a\u4e0d\u540c\u7684\u503c\uff1a
mysql> SET time_zone = 'MET';\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 03:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 03:00:00) |\n+-------------------------------------+\n| 1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 02:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 02:00:00) |\n+-------------------------------------+\n| 1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1111885200);\n+---------------------------+\n| from_unixtime(1111885200) |\n+---------------------------+\n| 2005-03-27 03:00:00 |\n+---------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT UNIX_TIMESTAMP(\"2016-07-11\");\n+----------------------------+\n| unix_timestamp(2016-07-11) |\n+----------------------------+\n| 1468188000 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19');\n+-------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19) |\n+-------------------------------------+\n| 1447406419 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19.012');\n+-----------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19.012) |\n+-----------------------------------------+\n| 1447406419.012000 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u5c06\u5f53\u524d UTC \u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss
\u6216 YYYYMMDDhhmmss
\u7684\u683c\u5f0f\u8fd4\u56de\uff0c\u8fd4\u56de\u683c\u5f0f\u53d6\u51b3\u4e8e\u51fd\u6570\u662f\u5728\u5b57\u7b26\u4e32\u8fd8\u662f\u6570\u5b57\u3002
> UTC_TIMESTAMP, UTC_TIMESTAMP([fsp])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u53ef\u9009\u3002\u53c2\u6570 fsp
\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u5206\u79d2\u7cbe\u5ea6\uff0c\u6709\u6548\u503c\u4e3a 0 \u5230 6 \u4e4b\u95f4\u7684\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT UTC_TIMESTAMP();\n+---------------------+\n| utc_timestamp() |\n+---------------------+\n| 2022-09-16 03:37:40 |\n+---------------------+\n1 row in set (0.01 sec)\n\nmysql> select unix_timestamp(utc_timestamp());\n+---------------------------------+\n| unix_timestamp(utc_timestamp()) |\n+---------------------------------+\n| 1663282842 |\n+---------------------------------+\n1 row in set (0.02 sec)\n
create table t1 (ts timestamp);\nset time_zone='+00:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n| 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='+10:30';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n| 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='-10:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());\n+-----------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(current_timestamp()) |\n+-----------------------------------------------------------------------+\n| 36000 |\n+-----------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\n\nmysql> select * from t1;\n+---------------------+\n| ts |\n+---------------------+\n| 2003-03-29 16:30:00 |\n| 2003-03-29 06:00:00 |\n| 2003-03-30 02:30:00 |\n+---------------------+\n3 rows in set (0.00 sec)\n
DROP TABLE IF EXISTS t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT year(a) FROM t1 WHERE a > '2008-01-01';\n+---------+\n| year(a) |\n+---------+\n| 2022 |\n| 2022 |\n| 2022 |\n+---------+\n3 rows in set (0.04 sec)\n
DROP TABLE if exists t1;\ncreate table t1 (a int primary key, b int, c int, d timestamp);\ninsert into t1 select 1,1,1,utc_timestamp();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a | b | c | year(d) |\n+------+------+------+---------+\n| 1 | 1 | 1 | 2022 |\n| 2 | 0 | 0 | NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
DROP TABLE if exists t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT 1 FROM t1 ORDER BY 1;\n+------+\n| 1 |\n+------+\n| 1 |\n| 1 |\n+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#_5","title":"\u9650\u5236","text":"\u6682\u4e0d\u652f\u6301\u64cd\u4f5c\u7b26 +
\u6216 -
\u5bf9 DATETIME BIGINT
\u53c2\u6570\u8fdb\u884c\u8fd0\u7b97\u3002
\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u7684\u5468\u6570\u3002\u8be5\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u6307\u5b9a\u65e5\u671f\u6240\u5728\u7684\u5468\u6570\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> WEEK(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u8981\u8ba1\u7b97\u5468\u6570\u7684\u65e5\u671f\u3002MatrixOne \u9ed8\u8ba4\u4e00\u5468\u7684\u8d77\u59cb\u65e5\u4e3a\u661f\u671f\u4e00\uff0c\u8fd4\u56de\u503c\u7684\u8303\u56f4\u4e3a 0 \u5230 53\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT WEEK('2008-02-20');\n+------------------+\n| week(2008-02-20) |\n+------------------+\n| 8 |\n+------------------+\n1 row in set (0.01 sec)\n
drop table if exists t1;\nCREATE TABLE t1(c1 DATETIME NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT WEEK(c1) FROM t1;\n+----------+\n| week(c1) |\n+----------+\n| 52 |\n| 52 |\n| 52 |\n| 52 |\n| 9 |\n+----------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#_5","title":"\u9650\u5236","text":"MatrixOne \u7684 WEEK()
\u51fd\u6570\u4ec5\u652f\u6301 date
\u53c2\u6570\uff0c\u4e0d\u652f\u6301\u53ef\u9009\u53c2\u6570 [, mode]
\uff0c\u8fd9\u4e00\u70b9\u662f\u4e0e MySQL \u662f\u4e0d\u540c\u7684\u3002
\u8fd4\u56de\u65e5\u671f\u7684\u5de5\u4f5c\u65e5\u7d22\u5f15\uff080 = \u661f\u671f\u4e00\uff0c1 = \u661f\u671f\u4e8c\uff0c... 6 = \u661f\u671f\u65e5\uff09\u3002\u5982\u679c\u65e5\u671f\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> WEEKDAY(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT WEEKDAY('2008-02-03 22:23:00');\n+------------------------------+\n| weekday(2008-02-03 22:23:00) |\n+------------------------------+\n| 6 |\n+------------------------------+\n1 row in set (0.03 sec)\n
drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select weekday(d),weekday(dt) from t1;\n+------------+-------------+\n| weekday(d) | weekday(dt) |\n+------------+-------------+\n| 2 | 2 |\n| 6 | 6 |\n| 1 | 1 |\n| 0 | 0 |\n| 1 | 1 |\n| 4 | 2 |\n| 3 | 3 |\n| 2 | 2 |\n| 3 | 3 |\n| 6 | 5 |\n| 6 | 3 |\n| 3 | 3 |\n| 6 | 6 |\n| 6 | 6 |\n| 6 | 6 |\n| NULL | NULL |\n+------------+-------------+\n16 rows in set (0.01 sec)\n\nmysql> select weekday(c),weekday(vc) from t1;\n+------------+-------------+\n| weekday(c) | weekday(vc) |\n+------------+-------------+\n| 2 | 3 |\n| 2 | 3 |\n| 0 | 0 |\n| 0 | 0 |\n| 0 | 0 |\n| 2 | 2 |\n| 3 | 3 |\n| 2 | 2 |\n| 3 | 3 |\n| 6 | 6 |\n| 6 | 6 |\n| 3 | 3 |\n| 6 | 6 |\n| 6 | 6 |\n| 6 | 6 |\n| NULL | NULL |\n+------------+-------------+\n16 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/","title":"YEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"YEAR()
\u548c TOYEAR()
\u51fd\u6570\u8fd4\u56de\u4e86\u7ed9\u5b9a\u65e5\u671f\u7684\u5e74\u4efd\uff08\u4ece 1000 \u5230 9999\uff09\u3002
> YEAR(date)\n> TOYEAR(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\uff0c\u9700\u8981\u63d0\u53d6\u5e74\u4efd\u7684\u65e5\u671f"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('20211223','2021-10-22 09:23:23');\ninsert into t1 values('2021-12-23','2021-10-22 00:23:23');\n\nmysql> select year(a) from t1;\n+---------+\n| year(a) |\n+---------+\n| 2021 |\n| 2021 |\n+---------+\n2 rows in set (0.00 sec)\n
DROP TABLE IF EXISTS t3;\nCREATE TABLE t3(c1 DATE NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\nmysql> SELECT YEAR(c1) FROM t3;\n+----------+\n| year(c1) |\n+----------+\n| 2000 |\n| 1999 |\n| 2000 |\n| 2006 |\n| 2008 |\n+----------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_5","title":"\u9650\u5236","text":"\u76ee\u524d\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
MatrixOne \u652f\u6301\u4ee5\u4e0b JSON \u51fd\u6570\uff1a
\u540d\u79f0 \u63cf\u8ff0 JSON_EXTRACT() \u4ece JSON \u6587\u6863\u8fd4\u56de\u6570\u636e JSON_QUOTE() \u5f15\u7528 JSON \u6587\u6863 JSON_UNQUOTE() \u53d6\u6d88\u5f15\u7528 JSON \u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_extract","title":"JSON_EXTRACT() \u51fd\u6570","text":"JSON EXTRACT
\u662f\u4e00\u4e2a JSON \u67e5\u8be2\u51fd\u6570\uff0c\u53ef\u7528\u4e8e\u67e5\u8be2 JSON \u6587\u6863\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1aselect json_extract(jsonDoc, pathExpression);
pathExpression
\u662f JSON \u8def\u5f84\u8868\u8fbe\u5f0f\uff0c\u5373\u5728 JSON \u6587\u6863\u4e2d\u9009\u62e9\u4e00\u4e2a\u503c\u3002
\u8def\u5f84\u8868\u8fbe\u5f0f\u5bf9\u4e8e\u63d0\u53d6\u90e8\u5206 JSON \u6587\u6863\u6216\u4fee\u6539 JSON \u6587\u6863\u7684\u51fd\u6570\u5f88\u6709\u7528\uff0c\u6307\u5b9a\u5728\u8be5\u6587\u6863\u4e2d\u7684\u54ea\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u67e5\u8be2\u4ece JSON \u6587\u6863\u4e2d\u63d0\u53d6\u5177\u6709 name \u952e\u7684\u6210\u5458\u7684\u503c\uff1a
mysql> SELECT JSON_EXTRACT('{\"id\": 14, \"name\": \"Aztalan\"}', '$.name');\n+-----------------------------------------------------+\n| json_extract({\"id\": 14, \"name\": \"Aztalan\"}, $.name) |\n+-----------------------------------------------------+\n| \"Aztalan\" |\n+-----------------------------------------------------+\n1 row in set (0.00 sec)\n
\u8def\u5f84\u8868\u8fbe\u5f0f\u5fc5\u987b\u4ee5 $
\u5b57\u7b26\u5f00\u5934\uff1a
,
\u540e\u8ddf\u952e\u540d\uff0c\u4f7f\u7528\u7ed9\u5b9a\u952e\u547d\u540d\u5bf9\u8c61\u4e2d\u7684\u6210\u5458\u3002\u952e\u540d\u9700\u8981\u4f7f\u7528\u53cc\u5f15\u53f7\u5305\u542b\u3002
[N]
\uff1a\u9009\u62e9\u6570\u7ec4\u7684 path \u540e\uff0c\u5c06\u6570\u7ec4\u4e2d\u4f4d\u7f6e N
\u5904\u7684\u503c\u547d\u540d\u3002\u6570\u7ec4\u4f4d\u7f6e\u662f\u4ece\u96f6\u5f00\u59cb\u7684\u6574\u6570\u3002\u5982\u679c\u6570\u7ec4\u662f\u8d1f\u6570\uff0c\u5219\u4ea7\u751f\u62a5\u9519\u3002
\u8def\u5f84\u53ef\u4ee5\u5305\u542b *
\u6216 **
\u901a\u914d\u7b26\uff1a
.[*]
\u8ba1\u7b97 JSON \u5bf9\u8c61\u4e2d\u6240\u6709\u6210\u5458\u7684\u503c\u3002
[*]
\u8ba1\u7b97 JSON \u6570\u7ec4\u4e2d\u6240\u6709\u5143\u7d20\u7684\u503c\u3002
prefix**suffix
\uff1a\u8ba1\u7b97\u4ee5\u547d\u540d\u524d\u7f00\u5f00\u5934\u5e76\u4ee5\u547d\u540d\u540e\u7f00\u7ed3\u5c3e\u7684\u6240\u6709\u8def\u5f84\u3002
\u6587\u6863\u4e2d\u4e0d\u5b58\u5728\u7684\u8def\u5f84\uff08\u6216\u4e0d\u5b58\u5728\u7684\u6570\u636e\uff09\u8bc4\u4f30\u4e3a NULL
\u3002
\u793a\u4f8b\uff1a
\u5982\u4e0b\u4e00\u7ec4 JSON \u6570\u7ec4\uff1a
[3, {\"a\": [5, 6], \"b\": 10}, [99, 100]]\n
$[0]
\u8868\u793a 3\u3002
$[1]
\u8868\u793a {\"a\": [5, 6], \"b\": 10}\u3002
$[2]
\u8868\u793a [99, 100]\u3002
$[3]
\u4e3a NULL (\u6570\u7ec4\u8def\u5f84\u4ece $[0]
\u5f00\u59cb\uff0c\u800c $[3]
\u8868\u793a\u7b2c\u56db\u7ec4\u6570\u636e\uff0c\u8fd9\u7ec4\u6570\u636e\u4e0d\u5b58\u5728)\u3002
\u7531\u4e8e $[1]
\u4e0e $[2]
\u8ba1\u7b97\u4e3a\u975e\u6807\u91cf\u503c\uff0c\u90a3\u4e48\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5d4c\u5957\u3002\u4f8b\u5982\uff1a
$[1].a
\u8868\u793a [5, 6]\u3002
$[1].a[1]
\u8868\u793a 6\u3002
$[1].b
\u8868\u793a 10\u3002
$[2][0]
\u8868\u793a 99\u3002
\u952e\u540d\u5728\u8def\u5f84\u8868\u8fbe\u5f0f\u4e2d\u9700\u8981\u4f7f\u7528\u53cc\u5f15\u53f7\u3002$
\u5f15\u7528\u8fd9\u4e2a\u952e\u503c\uff0c\u4e5f\u9700\u8981\u52a0\u53cc\u5f15\u53f7\uff1a
{\"a fish\": \"shark\", \"a bird\": \"sparrow\"}\n
\u8fd9\u4e24\u4e2a\u952e\u90fd\u5305\u542b\u4e00\u4e2a\u7a7a\u683c\uff0c\u5fc5\u987b\u7528\u5f15\u53f7\u5f15\u8d77\u6765\uff1a
$.\"a fish\"
\u8868\u793a shark
\u3002
$.\"a bird\"
\u8868\u793a sparrow
\u3002
\u4f7f\u7528\u901a\u914d\u7b26 $
\u7684\u8def\u5f84\u53ef\u4ee5\u4e3a\u5305\u542b\u591a\u4e2a\u503c\u7684\u6570\u7ec4\uff1a
mysql> select JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*') |\n+---------------------------------------------------------+\n| [1, 2, [3, 4, 5]] |\n+---------------------------------------------------------+\n\nmysql> SELECT JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]');\n+------------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]') |\n+------------------------------------------------------------+\n| [3, 4, 5] |\n+------------------------------------------------------------+\n
\u5728\u4e0b\u8ff0\u793a\u4f8b\u4e2d\uff0c\u8def\u5f84 $**.b
\u8ba1\u7b97\u4e3a\u591a\u4e2a\u8def\u5f84 ($.a.b
\u548c $.c.b
) \u5e76\u751f\u6210\u5339\u914d\u8def\u5f84\u503c\u7684\u6570\u7ec4\uff1a
mysql> select JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b') |\n+---------------------------------------------------------+\n| [null, 1, 2] |\n+---------------------------------------------------------+\n
\u5728\u4e0b\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5c06\u5c55\u793a\u4ece\u5217\u4e2d\u67e5\u8be2 JSON \u503c\uff1a
create table t1 (a json,b int);\ninsert into t1(a,b) values ('{\"a\":1,\"b\":2,\"c\":3}',1);\n\nmysql> select json_extract(t1.a,'$.a') from t1 where t1.b=1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1 |\n+-------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1(a,b) values ('{\"a\":4,\"b\":5,\"c\":6}',2);\n\nmysql> select json_extract(t1.a,'$.b') from t1 where t1.b=2;\n+-------------------------+\n| json_extract(t1.a, $.b) |\n+-------------------------+\n| 5 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> select json_extract(t1.a,'$.a') from t1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1 |\n| 4 |\n+-------------------------+\n2 rows in set (0.00 sec)\n\ninsert into t1(a,b) values ('{\"a\":{\"q\":[1,2,3]}}',3);\n\nmysql> select json_extract(t1.a,'$.a.q[1]') from t1 where t1.b=3;\n+------------------------------+\n| json_extract(t1.a, $.a.q[1]) |\n+------------------------------+\n| 2 |\n+------------------------------+\n1 row in set (0.01 sec)\n\ninsert into t1(a,b) values ('[{\"a\":1,\"b\":2,\"c\":3},{\"a\":4,\"b\":5,\"c\":6}]',4);\n\nmysql> select json_extract(t1.a,'$[1].a') from t1 where t1.b=4;\n+----------------------------+\n| json_extract(t1.a, $[1].a) |\n+----------------------------+\n| 4 |\n+----------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_quote","title":"JSON_QUOTE() \u51fd\u6570","text":"JSON_QUOTE
\u51fd\u6570\u7528\u4e8e\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u503c\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\u4e2d\u7684\u5b57\u7b26\u4e32\u3002\u901a\u8fc7\u4f7f\u7528\u53cc\u5f15\u53f7\u5305\u88c5\u5b57\u7b26\u4e32\u5e76\u8f6c\u4e49\u5185\u5f15\u53f7\u548c\u5176\u4ed6\u5b57\u7b26\uff0c\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3a JSON \u503c\u5f15\u7528\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u4f5c\u4e3a utf8mb4
\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002
JSON_QUOTE
\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u751f\u6210\u6709\u6548\u7684 JSON \u5b57\u7b26\u4e32\uff0c\u4ee5\u5305\u542b\u5728 JSON \u6587\u6863\u4e2d\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1aselect JSON_QUOTE(string_value);
string_value
\u662f\u8981\u8f6c\u6362\u4e3a JSON \u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u4e32\u3002\u8be5\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d\u539f\u59cb\u5b57\u7b26\u4e32\u5df2\u88ab\u5f15\u53f7\u5305\u56f4\u5e76\u8fdb\u884c\u4e86\u9002\u5f53\u7684\u8f6c\u4e49\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
mysql> SELECT JSON_QUOTE('null'), JSON_QUOTE('\"null\"');\n+------------------+--------------------+\n| json_quote(null) | json_quote(\"null\") |\n+------------------+--------------------+\n| \"null\" | \"\\\"null\\\"\" |\n+------------------+--------------------+\n1 row in set (0.00 sec)\nmysql> SELECT JSON_QUOTE('[1, 2, 3]');\n+-----------------------+\n| json_quote([1, 2, 3]) |\n+-----------------------+\n| \"[1, 2, 3]\" |\n+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_QUOTE('hello world');\n+-------------------------+\n| json_quote(hello world) |\n+-------------------------+\n| \"hello world\" |\n+-------------------------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u539f\u59cb\u5b57\u7b26\u4e32\u88ab\u5f15\u53f7\u5305\u56f4\u5e76\u4e14\u5b57\u7b26\u4e32\u4e2d\u7684\u53cc\u5f15\u53f7\u4e5f\u88ab\u8f6c\u4e49\u4e86\u3002\u8fd9\u6837\uff0c\u53ef\u4ee5\u5c06\u5176\u7528\u4f5c JSON \u683c\u5f0f\u7684\u503c\uff0c\u4f8b\u5982\uff0c\u5c06\u5176\u4f5c\u4e3a JSON \u5bf9\u8c61\u7684\u5c5e\u6027\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_unquote","title":"JSON_UNQUOTE() \u51fd\u6570","text":"JSON_UNQUOTE()
\u51fd\u6570\u7528\u4e8e\u4ece\u4e00\u4e2a JSON \u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u4e00\u4e2a\u6ca1\u6709\u5f15\u53f7\u7684 JSON \u503c\uff0c\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002
\u5177\u4f53\u6765\u8bf4\uff0cJSON_UNQUOTE()
\u51fd\u6570\u9700\u8981\u4e00\u4e2a JSON
\u5b57\u7b26\u4e32\u4f5c\u4e3a\u8f93\u5165\uff0c\u7136\u540e\u4ece\u4e2d\u63d0\u53d6\u4e00\u4e2a JSON
\u503c\uff0c\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u5982\u679c\u8f93\u5165\u7684 JSON
\u5b57\u7b26\u4e32\u4e0d\u5305\u542b\u6709\u6548\u7684 JSON
\u503c\u6216\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u51fd\u6570\u8fd4\u56de NULL
\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002\u5982\u679c\u503c\u4ee5\u53cc\u5f15\u53f7\u5f00\u59cb\u548c\u7ed3\u675f\uff0c\u4f46\u4e0d\u662f\u6709\u6548\u7684 JSON
\u5b57\u7b26\u4e32\u6587\u5b57\uff0c\u5219\u4f1a\u53d1\u751f\u9519\u8bef\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1aselect JSON_UNQUOTE(string_value);
\u5728\u5b57\u7b26\u4e32\u4e2d\uff0c\u67d0\u4e9b\u5e8f\u5217\u5177\u6709\u7279\u6b8a\u542b\u4e49\uff0c\u8fd9\u4e9b\u5e8f\u5217\u90fd\u4ee5\u53cd\u659c\u6760 () \u5f00\u59cb\uff0c\u79f0\u4e3a\u8f6c\u4e49\u5b57\u7b26\uff0c\u89c4\u5219\u5982\u4e0b\u8868\u3002\u5bf9\u4e8e\u6240\u6709\u5176\u4ed6\u8f6c\u4e49\u5e8f\u5217\uff0c\u53cd\u659c\u6760\u5c06\u88ab\u5ffd\u7565\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8f6c\u4e49\u5b57\u7b26\u88ab\u89e3\u91ca\u4e3a\u6ca1\u6709\u8f6c\u4e49\u3002\u4f8b\u5982\uff0c\\x \u5c31\u662f x\u3002\u8fd9\u4e9b\u5e8f\u5217\u533a\u5206\u5927\u5c0f\u5199\u3002\u4f8b\u5982\uff0c\\b \u88ab\u89e3\u91ca\u4e3a\u9000\u683c\uff0c\u800c \\B \u88ab\u89e3\u91ca\u4e3a B\u3002
\u8f6c\u4e49\u5e8f\u5217 \u6240\u4ee3\u8868\u7684\u5b57\u7b26 \\\" \u53cc\u5f15\u53f7 (\") \\b \u9000\u683c\u7b26 \\f \u6362\u9875\u7b26 \\n \u6362\u884c\u7b26 \\r \u56de\u8f66\u7b26 \\t \u5236\u8868\u7b26 \\ \u53cd\u659c\u6760 () \\uXXXX Unicode \u503c\u4e3a XXXX \u7684 UTF-8 \u5b57\u8282\u793a\u4f8b\u5982\u4e0b\uff1a
mysql> SET @j = '\"abc\"';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-------+------------------+\n| @j | json_unquote(@j) |\n+-------+------------------+\n| \"abc\" | abc |\n+-------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SET @j = '[1, 2, 3]';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-----------+------------------+\n| @j | json_unquote(@j) |\n+-----------+------------------+\n| [1, 2, 3] | [1, 2, 3] |\n+-----------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_UNQUOTE('\"\\\\t\\\\u0032\"');\n+----------------------------+\n| json_unquote(\"\\\\t\\\\u0032\") |\n+----------------------------+\n| 2 |\n+----------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/","title":"ABS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ABS(X) \u8fd4\u56de X \u7684\u7edd\u5bf9\u503c\uff0c\u6216\u8005 NULL \u5982\u679c X \u662f NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ABS(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b \u8fd4\u56de\u503c\u7c7b\u578b\u4e0e\u8f93\u5165\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,-3.1416);\ninsert into t1 values(-1,1.57);\n\nmysql> select abs(a),abs(b) from t1;\n+--------+--------------------+\n| abs(a) | abs(b) |\n+--------+--------------------+\n| 1 | 3.1415998935699463 |\n| 1 | 1.5700000524520874 |\n+--------+--------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/","title":"ACOS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ACOS() \u51fd\u6570\u8fd4\u56de\u7ed9\u5b9a\u6570\u503c\u7684\u4f59\u5f26\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ACOS(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float,b int);\ninsert into t1 values(0.5,1);\ninsert into t1 values(-0.5,-1);\n\nmysql> select acos(a),acos(b) from t1;\n+--------------------+-------------------+\n| acos(a) | acos(b) |\n+--------------------+-------------------+\n| 1.0471975511965976 | 0 |\n| 2.0943951023931957 | 3.141592653589793 |\n+--------------------+-------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/","title":"ATAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ATAN() \u51fd\u6570\u8fd4\u56de\u7ed9\u5b9a\u6570\u503c\u7684\u53cd\u6b63\u5207\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ATAN(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(0,1);\n\nmysql> select atan(a),atan(tan(b)) from t1;\n+--------------------+--------------------------+\n| atan(a) | atan(tan(b)) |\n+--------------------+--------------------------+\n| 0.7853981633974483 | -0.000002535181590113463 |\n| 0 | 1 |\n+--------------------+--------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/","title":"CEIL()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CEIL(X) \u51fd\u6570\u8fd4\u56de\u4e0d\u5c0f\u4e8e X \u7684\u6700\u5c0f\u6574\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> CEIL(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b \u5bf9 int \u7c7b\u7684\u7edd\u5bf9\u6570\u503c\u7c7b\u578b\uff0c\u8fd4\u56de\u503c\u4e5f\u662f\u76f8\u540c\u7684\u7edd\u5bf9\u6570\u503c\u7c7b\u578b\u3002\u5bf9\u6d6e\u70b9\u6570\u6765\u8bf4\uff0c\u8fd4\u56de\u503c\u4e5f\u662f\u6d6e\u70b9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,ceil(b) from t1;\n+------+---------+\n| a | ceil(b) |\n+------+---------+\n| 1 | 1 |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 21 |\n| 5 | 21 |\n| 6 | 14 |\n| 7 | -0 |\n| 8 | -0 |\n| 9 | -0 |\n| 10 | -20 |\n| 11 | -20 |\n| 12 | -13 |\n+------+---------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(ceil(b)) from t1;\n+--------------+\n| sum(ceil(b)) |\n+--------------+\n| 6 |\n+--------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/","title":"COS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COS() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5f26\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> COS(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select cos(a),cos(b) from t1;\n+--------------------+----------------------+\n| cos(a) | cos(b) |\n+--------------------+----------------------+\n| 0.5403023058681398 | -0.9999999999967865 |\n| 0.5403023058681398 | 0.000796274258662553 |\n+--------------------+----------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/","title":"COT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COT() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5207\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> COT(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT COT(12);\n+---------------------+\n| cot(12) |\n+---------------------+\n| -1.5726734063976895 |\n+---------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,12);\n\nmysql> select cot(a), cot(b) from t1;\n+---------------------+---------------------+\n| cot(a) | cot(b) |\n+---------------------+---------------------+\n| 0.6420926159343306 | -394449.0619219334 |\n| -0.6420926159343308 | -1.5726734063976895 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/","title":"EXP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"EXP(number) \u51fd\u6570\u8fd4\u56de\u4ee5\u81ea\u7136\u5e38\u6570 e \u4e3a\u5e95\u7684 number \u7684\u6307\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> EXP(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(-4, 2.45);\ninsert into t1 values(6, -3.62);\n\nmysql> select exp(a), exp(b) from t1;\n+---------------------+----------------------+\n| exp(a) | exp(b) |\n+---------------------+----------------------+\n| 0.01831563888873418 | 11.588347271798835 |\n| 403.4287934927351 | 0.026782679557672436 |\n+---------------------+----------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/","title":"FLOOR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FLOOR()
\u51fd\u6570\u8fd4\u56de\u4e0d\u5927\u4e8e\u67d0\u4e2a\u6570\u5b57\u7684\u76f8\u5e94\u6570\u4f4d\u7684\u6570\u3002
> FLOOR(number, decimals)\n> FLOOR(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e decimals \u53ef\u9009\u53c2\u6570\uff0c\u4ee3\u8868\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570\u3002\u9ed8\u8ba4\u503c\u4e3a 0\uff0c\u4ee3\u8868\u56db\u820d\u4e94\u5165\u4e3a\u6574\u6570\uff0c\u5f53\u4e3a\u8d1f\u6570\u65f6\u56db\u820d\u4e94\u5165\u5230\u5c0f\u6570\u70b9\u524d\u7684\u6570\u4f4d\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,floor(b) from t1;\n+------+----------+\n| a | floor(b) |\n+------+----------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 0 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 13 |\n| 7 | -1 |\n| 8 | -1 |\n| 9 | -1 |\n| 10 | -21 |\n| 11 | -21 |\n| 12 | -14 |\n+------+----------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(floor(b)) from t1;\n+---------------+\n| sum(floor(b)) |\n+---------------+\n| -6 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select a,sum(floor(b)) from t1 group by a order by a;\n+------+---------------+\n| a | sum(floor(b)) |\n+------+---------------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 0 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 13 |\n| 7 | -1 |\n| 8 | -1 |\n| 9 | -1 |\n| 10 | -21 |\n| 11 | -21 |\n| 12 | -14 |\n+------+---------------+\n12 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/","title":"LN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LN(X) \u8fd4\u56de X \u7684\u81ea\u7136\u5bf9\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u662f LOG(X) \u7684\u540c\u4e49\u51fd\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LN(X)\n
\u5176\u4ed6\u8bf7\u53c2\u8003 LOG(X)\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/","title":"LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOG(X) \u51fd\u6570\u8fd4\u56de X \u7684\u81ea\u7136\u5bf9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LOG(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(2,8);\n\nmysql> select log(a), log(b) from t1;\n+--------------------+--------------------+\n| log(a) | log(b) |\n+--------------------+--------------------+\n| 0.6931471805599453 | 2.0794415416798357 |\n+--------------------+--------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_5","title":"\u9650\u5236","text":"LOG(X) \u76ee\u524d\u4ec5\u652f\u6301\u5355\u53c2\u6570\u8f93\u5165\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/","title":"LOG10()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOG10(X) \u51fd\u6570\u8fd4\u56de\u4ee5 10 \u4e3a\u5e95 X \u7684\u5bf9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LOG10(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(10000,3784.159);\ninsert into t1 values(2738,682.325);\n\nmysql> select log10(a),log10(b) from t1;\n+-------------------+--------------------+\n| log10(a) | log10(b) |\n+-------------------+--------------------+\n| 4 | 3.577969368581086 |\n| 3.437433443797971 | 2.8339912916439594 |\n+-------------------+--------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/","title":"LOG2()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOG2(X) \u51fd\u6570\u8fd4\u56de\u4ee5 2 \u4e3a\u5e95 X \u7684\u5bf9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LOG2(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(1024,17.231);\ninsert into t1 values(4096,23.331);\n\nmysql>select log2(a),log2(b) from t1;\n+---------+-------------------+\n| log2(a) | log2(b) |\n+---------+-------------------+\n| 10 | 4.106934600972237 |\n| 12 | 4.544176200820541 |\n+---------+-------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/","title":"PI()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"PI() \u8fd4\u56de\u6570\u5b66\u5e38\u91cf \u03c0 (pi)\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> PI()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(0,0),(-15,-20),(-22,-12.5);\ninsert into t1 values(0,360),(30,390),(90,450),(180,270),(180,180);\n\nmysql> select acos(a*pi()/180) as acosa,acos(b*pi()/180) acosb from t1;\n+--------------------+--------------------+\n| acosa | acosb |\n+--------------------+--------------------+\n| 1.5707963267948966 | 1.5707963267948966 |\n| 1.8356824738191324 | 1.927370391646567 |\n| 1.9648910192076245 | 1.7907312931992256 |\n| 1.5707963267948966 | NULL |\n| 1.0197267436954502 | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n+--------------------+--------------------+\n8 rows in set (0.01 sec)\n\nmysql> select acos(a*pi()/180)*acos(b*pi()/180) as acosab,acos(acos(a*pi()/180)) as c from t1;\n+--------------------+------+\n| acosab | c |\n+--------------------+------+\n| 2.4674011002723395 | NULL |\n| 3.5380400485035204 | NULL |\n| 3.518591835821214 | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n+--------------------+------+\n8 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/","title":"POWER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"POWER(X, Y) \u8fd4\u56de X \u7684 Y \u6b21\u65b9\u6307\u6570\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> POWER(X, Y)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e Y \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b int);\ninsert into t1 values(5,-2),(10,3),(100,0),(4,3),(6,-3);\n\nmysql> select power(a,b) from t1;\n+----------------------+\n| power(a, b) |\n+----------------------+\n| 0.04 |\n| 1000 |\n| 1 |\n| 64 |\n| 0.004629629629629629 |\n+----------------------+\n5 rows in set (0.01 sec)\n\nmysql> select power(a,2) as a1, power(b,2) as b1 from t1 where power(a,2) > power(b,2) order by a1 asc;\n+-------+------+\n| a1 | b1 |\n+-------+------+\n| 16 | 9 |\n| 25 | 4 |\n| 36 | 9 |\n| 100 | 9 |\n| 10000 | 0 |\n+-------+------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/","title":"RAND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"RAND()
\u51fd\u6570\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684 Float64 \u7c7b\u578b\u7684\u968f\u673a\u6570\u3002\u5b83\u4e0d\u63a5\u53d7\u4efb\u4f55\u53c2\u6570\uff0c\u6bcf\u6b21\u8c03\u7528\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u4e0d\u53ef\u9884\u6d4b\u4e14\u4e0d\u91cd\u590d\u7684\u968f\u673a\u6570\u3002
\u5982\u679c\u9700\u8981\u4ece\u8868\u4e2d\u968f\u673a\u9009\u62e9\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528 RAND()
\u51fd\u6570\u751f\u6210\u4e00\u4e2a\u968f\u673a\u6570\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u968f\u673a\u6570\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u4f7f\u7528 ORDER BY
\u8fdb\u884c\u6392\u5e8f\u3002\u4f8b\u5982\uff1a
-- \u4ece\u8868\u4e2d\u968f\u673a\u83b7\u53d6\u6240\u6709\u6570\u636e\uff0c\u5e76\u6309\u7167\u968f\u673a\u987a\u5e8f\u8fdb\u884c\u6392\u5e8f\uff0c\u6bcf\u6b21\u67e5\u8be2\u7ed3\u679c\u7684\u987a\u5e8f\u53ef\u80fd\u90fd\u4e0d\u540c\nSELECT * FROM table ORDER BY RAND();\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> RAND([seed])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e seed \u53ef\u9009\u53c2\u6570\u3002\u662f\u4e00\u4e2a\u6574\u6570\u503c\uff0c\u7528\u4e8e\u6307\u5b9a\u751f\u6210\u968f\u673a\u6570\u65f6\u7684\u79cd\u5b50\u503c\u3002\u5982\u679c\u4e0d\u6307\u5b9a seed
\u53c2\u6570\uff0c\u5219\u9ed8\u8ba4\u4ee5\u5f53\u524d\u65f6\u95f4\u4e3a\u79cd\u5b50\u503c\u3002\u8fd4\u56de\u503c\u7c7b\u578b\u4e0e\u8f93\u5165\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\u3002 MatrixOne \u6682\u4e0d\u652f\u6301\u6307\u5b9a\u79cd\u5b50\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT RAND();\n+---------------------+\n| rand() |\n+---------------------+\n| 0.25193285156620004 |\n+---------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE Users (\nID INT PRIMARY KEY AUTO_INCREMENT,\nUserName VARCHAR(255) NOT NULL,\nEmail VARCHAR(255));\n\nINSERT INTO Users (UserName, Email) VALUES\n('John', 'john@example.com'),\n('Jane', 'jane@example.com'),\n('Alice', 'alice@example.com'),\n('Bob', 'bob@example.com');\n\n-- \u4ece Users \u8868\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u7528\u6237\u7684\u4fe1\u606f\nmysql> SELECT * FROM Users ORDER BY RAND() LIMIT 1;\n+------+----------+-----------------+\n| id | username | email |\n+------+----------+-----------------+\n| 4 | Bob | bob@example.com | -- Bob \u7684\u4fe1\u606f\u88ab\u968f\u673a\u9009\u4e2d\n+------+----------+-----------------+\n1 row in set (0.01 sec)\n\n-- \u518d\u6b21\u6267\u884c\u4e0a\u8ff0\u67e5\u8be2\uff0c\u9009\u4e2d\u7684\u53ef\u80fd\u4f1a\u662f\u53e6\u4e00\u4e2a\u7528\u6237\nmysql> SELECT * FROM Users ORDER BY RAND() LIMIT 1;\n+------+----------+-------------------+\n| id | username | email |\n+------+----------+-------------------+\n| 3 | Alice | alice@example.com | -- Alice \u7684\u4fe1\u606f\u88ab\u968f\u673a\u9009\u4e2d\n+------+----------+-------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_5","title":"\u9650\u5236","text":"MatrixOne \u6682\u4e0d\u652f\u6301\u6307\u5b9a RAND(seed)
\u51fd\u6570\u7684\u79cd\u5b50\u503c\uff08\u5373 seed
\u53c2\u6570\uff09\u3002
ROUND()
\u51fd\u6570\u8fd4\u56de\u4e86\u67d0\u4e2a\u6570\u5b57\u5728\u7279\u5b9a\u4f4d\u6570\u56db\u820d\u4e94\u5165\u540e\u7684\u6570\u503c\u3002 \u8be5\u51fd\u6570\u8fd4\u56de\u6307\u5b9a\u4f4d\u6570\u4e0a\u6700\u63a5\u8fd1\u7684\u6570\u5b57\u3002\u5982\u679c\u7ed9\u5b9a\u7684\u6570\u5b57\u4e0e\u5468\u56f4\u7684\u6570\u5b57\u8ddd\u79bb\u76f8\u7b49\uff08\u6bd4\u5982\u4e3a 5\uff09\uff0c\u90a3\u4e48\u5c06\u91c7\u7528\u201cbanker's rounding\u201d\uff08\u94f6\u884c\u8fdb\u4f4d\u6cd5\uff09\u7684\u65b9\u5f0f\u8fdb\u884c\u820d\u5165\u3002
> ROUND(number, decimals)\n> ROUND(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8fdb\u884c\u820d\u5165\u7684\u6570\u503c\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b decimals \u53ef\u9009\u53c2\u6570\uff0c\u8868\u793a\u5c06\u8981\u820d\u5165\u7684\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570\u3002\u9ed8\u8ba4\u503c\u4e3a 0\uff0c\u4ee3\u8868\u820d\u5165\u5230\u6574\u6570\u3002 decimals>0 \u51fd\u6570\u5c06\u820d\u5165\u5230\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570 decimals<0 \u51fd\u6570\u5c06\u820d\u5165\u5230\u5c0f\u6570\u70b9\u524d\u7684\u4f4d\u6570 decimals=0 \u51fd\u6570\u5c06\u820d\u5165\u5230\u6574\u6570"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,round(b) from t1;\n+------+----------+\n| a | round(b) |\n+------+----------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 1 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 14 |\n| 7 | -0 |\n| 8 | -0 |\n| 9 | -1 |\n| 10 | -20 |\n| 11 | -20 |\n| 12 | -14 |\n+------+----------+\n12 rows in set (0.00 sec)\n\nmysql> select a,round(b,-1) from t1;\n+------+--------------+\n| a | round(b, -1) |\n+------+--------------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 0 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 10 |\n| 7 | -0 |\n| 8 | -0 |\n| 9 | -0 |\n| 10 | -20 |\n| 11 | -20 |\n| 12 | -10 |\n+------+--------------+\n12 rows in set (0.01 sec)\n\nmysql> select round(a*b) from t1;\n+--------------+\n| round(a * b) |\n+--------------+\n| 0 |\n| 1 |\n| 2 |\n| 82 |\n| 102 |\n| 81 |\n| -4 |\n| -4 |\n| -5 |\n| -205 |\n| -226 |\n| -162 |\n+--------------+\n12 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/","title":"SIN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SIN() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5f26\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SIN(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select sin(a),sin(b) from t1;\n+---------------------+--------------------------+\n| sin(a) | sin(b) |\n+---------------------+--------------------------+\n| 0.8414709848078965 | 0.0000025351815901107472 |\n| -0.8414709848078965 | 0.9999996829736023 |\n+---------------------+--------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/","title":"SINH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SINH() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u53cc\u66f2\u6b63\u5f26\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SINH(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159), (-1,-3.14159);\n\nmysql> select sinh(a), sinh(b) from t1;\n+---------------------+---------------------+\n| sinh(a) | sinh(b) |\n+---------------------+---------------------+\n| 1.1752011936438014 | 11.548709969588323 |\n| -1.1752011936438014 | -11.548709969588323 |\n+---------------------+---------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/","title":"TAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TAN() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5207\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> TAN(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,-3.14159);\n\nmysql> select tan(a),tan(b) from t1;\n+--------------------+--------------------------+\n| tan(a) | tan(b) |\n+--------------------+--------------------------+\n| 1.557407724654902 | -0.000002535181590118894 |\n| -1.557407724654902 | 0.000002535181590118894 |\n+--------------------+--------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sample/","title":"SAMPLE \u91c7\u6837\u51fd\u6570","text":"SAMPLE \u91c7\u6837\u51fd\u6570\u529f\u80fd\u662f\u5904\u7406\u5927\u91cf\u6570\u636e\u5206\u6790\u7684\u5173\u952e\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5feb\u901f\u7f29\u51cf\u67e5\u8be2\u8303\u56f4\u3002
SELECT SAMPLE(<column_list>, <N ROWS>/<K PERCENT>) FROM <table> [WHERE ...] [GROUP BY ...] [ORDER BY ...] [LIMIT ...] [OFFSET ...]\n
<column_list>
: \u9009\u62e9\u7684\u5217\u540d\u5217\u8868\u3002<N ROWS>/<K PERCENT>
: \u6307\u5b9a\u8fd4\u56de\u7684\u6837\u672c\u6570\u91cf\uff08N \u884c\uff09\u6216\u767e\u5206\u6bd4\uff08K%\uff09\u3002
\u529f\u80fd\u7279\u70b9
SAMPLE \u51fd\u6570\u4f1a\u5728\u8868\u8fc7\u6ee4\u518d\u6267\u884c\u91c7\u6837\u3002
\u53ef\u4e0e WHERE \u5b50\u53e5\u3001GROUP BY \u5b50\u53e5\u7b49\u7ed3\u5408\u4f7f\u7528\u3002
\u5e94\u7528\u793a\u4f8b
SELECT SAMPLE(a, 100 ROWS) FROM t1; -- \u8fd4\u56de 100 \u4e2a\u968f\u673a\u6837\u672c\nSELECT SAMPLE(a, 0.2 PERCENT) FROM t1; -- \u8fd4\u56de\u7ea6 0.2% \u7684\u6837\u672c\nSELECT SAMPLE(a, 100 ROWS) FROM t1 WHERE a > 1; -- \u5148\u8fc7\u6ee4\u540e\u91c7\u6837\nSELECT a, SAMPLE(b, 100 ROWS) FROM t1 GROUP BY a; -- \u5206\u7ec4\u540e\u91c7\u6837\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/","title":"SERIAL_EXTRACT \u51fd\u6570","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SERIAL_EXTRACT()
\u51fd\u6570\u7528\u4e8e\u63d0\u53d6\u5e8f\u5217/\u5143\u7ec4\u503c\u4e2d\u7684\u5404\u4e2a\u5143\u7d20\uff0c\u9700\u7ed3\u5408\u51fd\u6570 MAX()
\uff0cMIN()
\uff0cSERIAL()
\uff0cSERIAL_NULL()
\u4f7f\u7528\u3002
>SERIAL_EXTRACT(serial_col, pos as type)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e serial_col \u5fc5\u8981\u53c2\u6570\u3002\u4fdd\u5b58 serial/serial_full \u51fd\u6570\u503c\u7684\u4e32\u884c\u5217\u3002\u5982\u9700\u66f4\u6362\u8f93\u51fa\u7c7b\u578b\u53ef\u7ed3\u5408CAST()
\u51fd\u6570\u4f7f\u7528\u3002 pos \u5fc5\u8981\u53c2\u6570\u3002\u8981\u63d0\u53d6\u7684\u5b57\u6bb5\u7684\u4f4d\u7f6e\uff0c0 \u4e3a\u7b2c\u4e00\u4e2a\u3002 type \u5fc5\u8981\u53c2\u6570\u3002\u5bfc\u51fa\u7684\u5143\u7d20\u7684\u539f\u59cb\u7c7b\u578b\u3002\u9700\u8981\u4e0e\u63d0\u53d6\u7684\u5143\u7d20\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/#_4","title":"\u793a\u4f8b","text":"drop table if exists vtab64;\ncreate table vtab64(id int primary key auto_increment,`vecf64_3` vecf64(3),`vecf64_5` vecf64(5));\ninsert into vtab64(vecf64_3,vecf64_5) values(\"[1,NULL,2]\",NULL);\ninsert into vtab64(vecf64_3,vecf64_5) values(NULL,NULL);\ninsert into vtab64(vecf64_3,vecf64_5) values(\"[2,3,4]\",NULL);\ninsert into vtab64(vecf64_3,vecf64_5) values (\"[4,5,6]\",\"[1,2,3,4,5]\");\ninsert into vtab64(vecf64_3,vecf64_5) values (\"[7,8,9]\",\"[2,3,4,5,6]\");\n\nmysql> select * from vtab64;\n+------+-----------+-----------------+\n| id | vecf64_3 | vecf64_5 |\n+------+-----------+-----------------+\n| 1 | NULL | NULL |\n| 2 | [2, 3, 4] | NULL |\n| 3 | [4, 5, 6] | [1, 2, 3, 4, 5] |\n| 4 | [7, 8, 9] | [2, 3, 4, 5, 6] |\n+------+-----------+-----------------+\n4 rows in set (0.01 sec)\n\n--max(max(serial(id, `vecf64_3`, `vecf64_5`)) \u5f97\u5230\u4e00\u4e2a\u6700\u5927\u7684\u5e8f\u5217\u5316\u503c\uff0c\u7136\u540e\u6b63\u5e38\u83b7\u53d6\u5230\u7684 max \u5e94\u8be5\u662f (4,[7, 8, 9],[2, 3, 4, 5, 6]) \u8fd9\u4e00\u6761\u8bb0\u5f55\uff0c\u4f46\u662f 1 \u4ee3\u8868\u7684\u662f\u7b2c\u4e8c\u4e2a\u4f4d\u7f6e\u7684\u503c\uff0c\u6240\u4ee5\u5c31\u662f [7, 8, 9]\nmysql> select serial_extract(max(serial(id, `vecf64_3`, `vecf64_5`)), 1 as vecf64(3)) as a from vtab64;\n+-----------+\n| a |\n+-----------+\n| [7, 8, 9] |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select serial_extract(min(serial(id, `vecf64_3`, `vecf64_5`)), 2 as vecf64(5)) as a from vtab64;\n+-----------------+\n| a |\n+-----------------+\n| [1, 2, 3, 4, 5] |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> select serial_extract(max(serial_full(cast(id as decimal), `vecf64_3`)), 0 as decimal) as a from vtab64;\n+------+\n| a |\n+------+\n| 4 |\n+------+\n1 row in set (0.01 sec)\n\nmysql> select serial_extract(min(serial_full(cast(id as decimal), `vecf64_3`)), 1 as vecf64(3)) as a from vtab64;\n+------+\n| a |\n+------+\n| NULL |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/","title":"SLEEP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SLEEP()
\u51fd\u6570\u5c06\u5f53\u524d\u67e5\u8be2\u6682\u505c\uff08\u7761\u7720\uff09\u6307\u5b9a\u7684\u79d2\u6570\u3002\u7ed3\u679c\u5c06\u8fd4\u56de 0\u3002
>\nSLEEP(duration)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e duration \u5fc5\u9700\u7684\u3002\u4ee5\u79d2\u4e3a\u5355\u4f4d\u7684\u7761\u7720\u65f6\u957f\u3002\u5b83\u5e94\u8be5\u5927\u4e8e\u6216\u7b49\u4e8e 0\uff0c\u5e76\u4e14\u53ef\u4ee5\u5e26\u6709\u5c0f\u6570\u90e8\u5206\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_4","title":"\u8fd4\u56de\u503c","text":"\u5f53 SLEEP()
\u6b63\u5e38\u8fd4\u56de\u65f6\uff08\u6ca1\u6709\u4e2d\u65ad\uff09\uff0c\u5b83\u8fd4\u56de 0\u3002
\u5f53 SLEEP()
\u88ab\u4e2d\u65ad\u7684\u67e5\u8be2\u8c03\u7528\u552f\u4e00\u7684\u7ed3\u679c\u65f6\uff0c\u5b83\u8fd4\u56de 1 \u5e76\u4e14\u67e5\u8be2\u672c\u8eab\u4e0d\u8fd4\u56de\u9519\u8bef\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
\u5728\u4f1a\u8bdd 1 \u4e2d\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u67e5\u8be2\u5f53\u524d\u7684 connection_id\uff0c\u5e76\u6267\u884c SLEEP()
\u51fd\u6570\uff1a
mysql> select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n| 1476 |\n+-----------------+\n1 row in set (0.03 sec)\nmysql> select sleep(200);\n
\u6b64\u65f6\uff0c\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\uff0c\u4e2d\u65ad\u4f1a\u8bdd 1\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a
mysql> kill 1476;\nQuery OK, 0 rows affected (0.00 sec)\n
\u67e5\u770b\u4f1a\u8bdd 1 \u7684\u7ed3\u679c\uff1a
mysql> select sleep(200);\n+------------+\n| sleep(200) |\n+------------+\n| 1 |\n+------------+\n1 row in set (26.50 sec)\n
\u90e8\u5206\u67e5\u8be2\u88ab\u6253\u65ad\u65f6\uff0cSLEEP() \u8fd4\u56de\u9519\u8bef\uff0c\u4f8b\u5982\uff1a
mysql> SELECT 1 FROM t1 WHERE SLEEP(1000);\nERROR 20101 (HY000): internal error: pipeline closed unexpectedly\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_5","title":"\u793a\u4f8b","text":"-- without interruption\nmysql> SELECT SLEEP(1);\n+----------+\n| sleep(1) |\n+----------+\n| 0 |\n+----------+\n1 row in set (1.01 sec)\n\n-- without interruption\nmysql> SELECT SLEEP(1000);\n+-------------+\n| sleep(1000) |\n+-------------+\n| 0 |\n+-------------+\n1 row in set (18 min 20.87 sec)\n\ncreate table t1 (a int,b int);\ninsert into t1 values (1,1),(1,null);\nmysql> select sleep(a) from t1;\n+----------+\n| sleep(a) |\n+----------+\n| 0 |\n| 0 |\n+----------+\n2 rows in set (2.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/","title":"UUID()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UUID()
\u8fd4\u56de\u6839\u636e RFC 4122 \u751f\u6210\u56fd\u9645\u901a\u7528\u552f\u4e00\u6807\u8bc6\u7b26 UUID(Universally Unique IDentifier)\u3002
UUID \u5728\u7a7a\u95f4\u548c\u65f6\u95f4\u4e0a\u662f\u5168\u7403\u552f\u4e00\u7684\u6570\u5b57\u3002\u5373\u4f7f\u662f\u5728\u4e24\u4e2a\u672a\u8fde\u63a5\u7684\u72ec\u7acb\u8fd0\u884c\u7684\u8bbe\u5907\u4e0a\u6267\u884c UUID \u8c03\u7528\uff0c\u9884\u8ba1\u4f1a\u751f\u6210\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u3002
Info
\u5c3d\u7ba1 UUID()
\u503c\u552f\u4e00\uff0c\u4f46\u5b83\u4eec\u5e76\u975e\u662f\u4e0d\u53ef\u731c\u6d4b\u6216\u4e0d\u53ef\u9884\u6d4b\u7684\u3002\u5982\u679c\u9700\u8981\u4e0d\u53ef\u9884\u6d4b\u6027\uff0c\u5219\u5e94\u4ee5\u5176\u4ed6\u65b9\u5f0f\u751f\u6210 UUID \u503c\u3002
UUID()
\u8fd4\u56de\u4e00\u4e2a\u7b26\u5408 RFC 4122 \u6807\u51c6\u7684\u7248\u672c 1 UUID \u7684\u503c\uff0c\u4e3a 128 \u4f4d\u6570\u5b57\uff0c\u5b83\u8868\u793a\u662f\u4e00\u4e2a utf8mb3 \u7531\u4e94\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u5373 aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\uff0c\u683c\u5f0f\u89e3\u91ca\u5982\u4e0b\uff1a
\u524d\u4e09\u4e2a\u6570\u5b57\u662f\u4ece\u65f6\u95f4\u6233\u7684\u4f4e\u3001\u4e2d\u548c\u9ad8\u90e8\u5206\u751f\u6210\u7684\u3002\u9ad8\u4f4d\u90e8\u5206\u8fd8\u5305\u62ec UUID \u7248\u672c\u53f7\u3002
\u7b2c\u56db\u4e2a\u6570\u5b57\u4fdd\u7559\u65f6\u95f4\u552f\u4e00\u6027\uff0c\u4ee5\u9632\u65f6\u95f4\u6233\u503c\u5931\u53bb\u5355\u4e00\u6027\uff08\u4f8b\u5982\uff0c\u590f\u4ee4\u65f6\uff09\u3002
\u7b2c\u4e94\u4e2a\u6570\u5b57\u662f\u7a7a\u95f4\u552f\u4e00\u6027\u7684 IEEE 802 \u8282\u70b9\u53f7\u3002\u5982\u679c\u540e\u8005\u4e0d\u53ef\u7528\uff08\u4f8b\u5982\uff0c\u56e0\u4e3a\u4e3b\u673a\u8bbe\u5907\u6ca1\u6709\u4ee5\u592a\u7f51\u5361\uff0c\u6216\u8005\u4e0d\u77e5\u9053\u5982\u4f55\u5728\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u627e\u5230\u63a5\u53e3\u7684\u786c\u4ef6\u5730\u5740\uff09\uff0c\u5219\u7528\u968f\u673a\u6570\u4ee3\u66ff\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e0\u6cd5\u4fdd\u8bc1\u7a7a\u95f4\u552f\u4e00\u6027\u3002\u7136\u800c\uff0c\u7b2c\u4e94\u4f4d\u6570\u5b57\u91cd\u5408\u7684\u6982\u7387\u5f88\u4f4e\u3002
UUID \u65e2\u662f\u6570\u636e\u7c7b\u578b\uff0c\u4e5f\u662f\u51fd\u6570\uff0c\u5982\u9700\u4e86\u89e3\u66f4\u591a UUID \u6570\u636e\u7c7b\u578b\uff0c\u53c2\u89c1 UUID \u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> UUID()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a INT, b float);\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\nmysql> SELECT length(uuid()) FROM t1;\n+----------------+\n| length(uuid()) |\n+----------------+\n| 36 |\n| 36 |\n+----------------+\n2 rows in set (0.00 sec)\n\nmysql> SELECT UUID();\n+--------------------------------------+\n| uuid() |\n+--------------------------------------+\n| b293b688-70a7-11ed-a25a-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_4","title":"\u9650\u5236","text":"UUID()
\u6682\u65f6\u4e0d\u652f\u6301\u53ef\u9009\u53c2\u6570\uff0c\u5373\u6682\u4e0d\u652f\u6301 UUID([number])
\u3002
BIN()
\u5c06 N \u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u7684\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002\u5176\u4e2d N \u662f\u4e00\u4e2a longlong (BIGINT)
\u6570\u5b57\u3002\u5982\u679c N \u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL
\u3002
> BIN(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002UINT \u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#_4","title":"\u793a\u4f8b","text":"> SELECT bin(1314);\n+-------------+\n| bin(1314) |\n+-------------+\n| 10100100010 |\n+-------------+\n1 row in set (0.01 sec)\n\n> select bin(2e5);\n+--------------------+\n| bin(2e5) |\n+--------------------+\n| 110000110101000000 |\n+--------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/","title":"BIT_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u5b57\u7b26\u4e32 str \u7684\u957f\u5ea6\uff0c\u5355\u4f4d\u4e3a bit\u3002\u5982\u679c str \u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> BIT_LENGTH(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8ba1\u7b97\u957f\u5ea6\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#_4","title":"\u793a\u4f8b","text":"> SELECT BIT_LENGTH('text');\n+------------------+\n| bit_length(text) |\n+------------------+\n| 32 |\n+------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/","title":"CHAR_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CHAR_LENGTH
\u4ee5\u5b57\u7b26\u4e3a\u5355\u4f4d\u8fd4\u56de\u5b57\u7b26\u4e32 str
\u7684\u957f\u5ea6\uff0c\u4e00\u4e2a\u591a\u5b57\u8282\u5b57\u7b26\u7b97\u4f5c\u4e00\u4e2a\u5b57\u7b26\u3002\u4e00\u4e2a\u6c49\u5b57\u6240\u5bf9\u5e94\u7684\u5b57\u7b26\u957f\u5ea6\u662f 1\u3002
> CHAR_LENGTH(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8ba1\u7b97\u957f\u5ea6\u7684\u5b57\u7b26\u4e32 note
CHAR_LENGTH
\u4e5f\u53ef\u4ee5\u5199\u4e3a lengthUTF8()
\u3002
> drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('nihao','\u4f60\u597d');\n> select char_length(a), char_length(b) from t1;\n+---------------+---------------+\n| lengthutf8(a) | lengthutf8(b) |\n+---------------+---------------+\n| 5 | 2 |\n+---------------+---------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/","title":"CONCAT_WS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CONCAT_WS()
\u4ee3\u8868 Concatenate With Separator\uff0c\u662f CONCAT()
\u7684\u4e00\u79cd\u7279\u6b8a\u5f62\u5f0f\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5176\u5b83\u53c2\u6570\u7684\u5206\u9694\u7b26\u3002\u5206\u9694\u7b26\u7684\u4f4d\u7f6e\u653e\u5728\u8981\u8fde\u63a5\u7684\u4e24\u4e2a\u5b57\u7b26\u4e32\u4e4b\u95f4\u3002\u5206\u9694\u7b26\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\uff0c\u4e5f\u53ef\u4ee5\u662f\u5176\u4ed6\u53c2\u6570\u3002\u5982\u679c\u5206\u9694\u7b26\u4e3a NULL
\uff0c\u5219\u7ed3\u679c\u4e3a NULL
\u3002\u51fd\u6570\u4f1a\u5ffd\u7565\u4efb\u4f55\u5206\u9694\u7b26\u53c2\u6570\u540e\u7684 NULL
\u503c\u3002
> CONCAT_WS(separator,str1,str2,...)\n
> CONCAT_WS(separator,str1,NULL,str1,...);\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e Str \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u7ffb\u8f6c\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#_4","title":"\u793a\u4f8b","text":"SELECT CONCAT_WS(',','First name','Second name','Last Name');\n+--------------------------------------------------+\n| concat_ws(,, First name, Second name, Last Name) |\n+--------------------------------------------------+\n| First name,Second name,Last Name |\n+--------------------------------------------------+\n1 row in set (0.01 sec)\n> SELECT CONCAT_WS(',','First name',NULL,'Last Name');\n+-------------------------------------------+\n| concat_ws(,, First name, null, Last Name) |\n+-------------------------------------------+\n| First name,Last Name |\n+-------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/","title":"CONCAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CONCAT()
\u5c06\u591a\u4e2a\u5b57\u7b26\u4e32\uff08\u6216\u4ec5\u542b\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\uff09\u8fde\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u6240\u6709\u53c2\u6570\u90fd\u662f\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u662f\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u5305\u542b\u4efb\u4f55\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002
CONCAT()
\u4e2d\u5982\u679c\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
>\nCONCAT(str1,str2,...)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str1,str2,... \u5fc5\u8981\u53c2\u6570\u3002\u5c06 str1,str2,..
\u8fde\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002 \u8bf4\u660e\uff1a\u5982\u679c\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT CONCAT('My', 'S', 'QL');\n+-------------------+\n| concat(My, S, QL) |\n+-------------------+\n| MySQL |\n+-------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CONCAT('My', NULL, 'QL');\n+----------------------+\n| concat(My, null, QL) |\n+----------------------+\n| NULL |\n+----------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_5","title":"\u9650\u5236","text":"CONCAT()
\u5f53\u524d\u8fd8\u4e0d\u652f\u6301\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32\u53c2\u6570\u548c\u6570\u5b57\u53c2\u6570\u3002
\u5224\u65ad\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u5b57\u8282\u5219\u4e0d\u4e3a\u7a7a\uff0c\u5373\u4f7f\u662f\u4e00\u4e2a\u7a7a\u683c\u6216\u8005 NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> EMPTY(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0cCHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_4","title":"\u8fd4\u56de\u503c","text":"\u7a7a\u5b57\u7b26\u4e32\u8fd4\u56de 1\uff0c\u975e\u7a7a\u5b57\u7b26\u4e32\u8fd4\u56de 0\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_5","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('', 'abcd');\n> insert into t1 values('1111', '');\n> select empty(a),empty(b) from t1;\n+----------+----------+\n| empty(a) | empty(b) |\n+----------+----------+\n| 1 | 0 |\n| 0 | 1 |\n+----------+----------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/","title":"ENDSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u68c0\u67e5\u662f\u5426\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e\u3002\u5b57\u7b26\u4e32\u5982\u679c\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e\u8fd4\u56de 1\uff0c\u5426\u5219\u5219\u8fd4\u56de 0\u3002\u8be5\u51fd\u6570\u662f\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ENDSWITH(str,suffix)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002 suffix \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_4","title":"\u8fd4\u56de\u503c","text":"> drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'XI'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'XI');\n> select a,endsWith(b,'a') from t1;\n+------+----------------+\n| a | endswith(b, a) |\n+------+----------------+\n| 1 | 0 |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 0 |\n| 5 | 0 |\n| 6 | 1 |\n+------+----------------+\n> select a,b,c from t1 where endswith(b,'a')=1 and endswith(c,'I')=1;\n+------+---------------+------+\n| a | b | c |\n+------+---------------+------+\n| 3 | Aniket Sharma | XI |\n| 6 | Tapan Samanta | XI |\n+------+---------------+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/","title":"FIELD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FIELD()
\u51fd\u6570\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e32 str
\u5728\u5b57\u7b26\u4e32\u5217\u8868 (str1,str2,str3,...) \u4e2d\u7684\u4f4d\u7f6e\u3002
> FIELD(str,str1,str2,str3,...)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u5728\u5217\u8868\u4e2d\u67e5\u627e\u7684\u503c\uff0c\u4e14\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002 str1,str2,str3,... \u5fc5\u8981\u53c2\u6570\u3002\u88ab\u641c\u7d22\u7684\u5217\u8868\u4e2d\u7684\u5404\u4e2a\u5143\u7d20\uff0c\u4e14\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#_4","title":"\u8fd4\u56de\u503c","text":"\u5982\u679c FIELD()
\u7684\u6240\u6709\u53c2\u6570\u90fd\u662f string \u7c7b\u578b\uff0c\u5219\u6240\u6709\u53c2\u6570\u90fd\u4f5c\u4e3a string \u7c7b\u578b\u8fdb\u884c\u6bd4\u8f83\u3002\u5982\u679c\u6240\u6709\u53c2\u6570\u90fd\u662f\u6570\u5b57\uff0c\u5219\u5c06\u5b83\u4eec\u4f5c\u4e3a\u6570\u5b57\u8fdb\u884c\u6bd4\u8f83\u3002\u5982\u679c\u6240\u6709\u53c2\u6570\u90fd\u662f double \u7c7b\u578b\uff0c\u5219\u5c06\u5b83\u4eec\u4f5c\u4e3a double \u7c7b\u578b\u8fdb\u884c\u6bd4\u8f83\u3002
\u5982\u679c\u5728\u5217\u8868\u4e2d\u627e\u5230\u6307\u5b9a\u7684\u503c\uff0cFIELD()
\u51fd\u6570\u8fd4\u56de\u5bf9\u5e94\u7684\u4f4d\u7f6e\u7d22\u5f15\u3002FIELD()
\u51fd\u6570\u8fd4\u56de\u7684\u7d22\u5f15\u7684\u503c\u4ece 1 \u5f00\u59cb\u3002
\u5982\u679c\u5728\u5217\u8868\u4e2d\u627e\u5230\u591a\u4e2a\u6307\u5b9a\u7684\u503c\uff0cFIELD()
\u51fd\u6570\u53ea\u8fd4\u56de\u7b2c\u4e00\u4e2a\u7684\u7d22\u5f15\u503c\u3002
\u5982\u679c\u5728\u5217\u8868\u4e2d\u627e\u4e0d\u5230\u6307\u5b9a\u7684\u503c\uff0cFIELD()
\u51fd\u6570\u8fd4\u56de 0\u3002
\u5982\u679c\u8981\u67e5\u627e\u7684\u503c\u4e3a NULL
\uff0cFIELD()
\u51fd\u6570\u8fd4\u56de 0\u3002
mysql> SELECT FIELD('Bb', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Bb, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n| 2 |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FIELD('Gg', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Gg, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n| 0 |\n+-------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t;\ncreate table t(\ni int,\nf float,\nd double\n);\ninsert into t() values (1, 1.1, 2.2), (2, 3.3, 4.4), (0, 0, 0), (0, null, 0);\n\nmysql> select * from t;\n+------+------+------+\n| i | f | d |\n+------+------+------+\n| 1 | 1.1 | 2.2 |\n| 2 | 3.3 | 4.4 |\n| 0 | 0 | 0 |\n| 0 | NULL | 0 |\n+------+------+------+\n4 rows in set (0.01 sec)\n\nmysql> select field(1, i, f, d) from t;\n+-------------------+\n| field(1, i, f, d) |\n+-------------------+\n| 1 |\n| 0 |\n| 0 |\n| 0 |\n+-------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field(i, f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(i, f, d, 0, 1, 2) |\n+-------------------------+\n| 4 |\n| 5 |\n| 1 |\n| 2 |\n+-------------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field('1', f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(1, f, d, 0, 1, 2) |\n+-------------------------+\n| 4 |\n| 4 |\n| 4 |\n| 4 |\n+-------------------------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/","title":"FIND_IN_SET()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5982\u679c\u5b57\u7b26\u4e32 str \u5728\u7531 N \u4e2a\u5b50\u5b57\u7b26\u4e32\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u5217\u8868 strlist \u4e2d\uff0c\u5219\u8fd4\u56de\u503c\u7684\u8303\u56f4\u5728 1 \u5230 N \u4e4b\u95f4\u3002\u4e00\u4e2a\u5b57\u7b26\u4e32\u5217\u8868\u5c31\u662f\u7531 ,
\u7b26\u53f7\u5206\u5f00\u7684\u5b50\u5b57\u7b26\u4e32\u7ec4\u6210\u3002\u5982\u679c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5e38\u91cf\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f SET
\u7c7b\u578b\u7684\u5217\uff0c\u90a3\u4e48 FIND_IN_SET()
\u51fd\u6570\u5c06\u4f18\u5316\u4e3a\u4f7f\u7528\u4f4d\u8fd0\u7b97\u3002\u5982\u679c str \u4e0d\u5728 strlist \u4e2d\u6216\u8005 strlist \u662f\u7a7a\u5b57\u7b26\u4e32\uff0c\u5219\u8fd4\u56de 0\u3002\u5982\u679c\u4efb\u4e00\u53c2\u6570\u4e3a NULL \u5219\u8fd4\u56de NULL
\u3002\u5982\u679c\u7b2c\u4e00\u4e2a\u53c2\u6570\u5305\u542b\u9017\u53f7 (,)
\u5b57\u7b26\uff0c\u6b64\u51fd\u6570\u5c06\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u3002
> FIND_IN_SET(str,strlist)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002 strlist \u5fc5\u8981\u53c2\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#_4","title":"\u793a\u4f8b","text":"select find_in_set('b','a,b,c,d');\n+-------------------------+\n| find_in_set(b, a,b,c,d) |\n+-------------------------+\n| 2 |\n+-------------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/","title":"FORMAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FORMAT
\u51fd\u6570\u7528\u4e8e\u5c06\u6570\u5b57\u683c\u5f0f\u8bbe\u7f6e\u4e3a \"#,###,###.##\" \u683c\u5f0f\uff0c\u5e76\u56db\u820d\u4e94\u5165\u5230\u5c0f\u6570\u70b9\u540e\u4e00\u4f4d\u3002\u683c\u5f0f\u5316\u6570\u5b57\u540e\uff0c\u5b83\u5c06\u4ee5\u5b57\u7b26\u4e32\u7684\u5f62\u5f0f\u8fd4\u56de\u503c\u3002
> FORMAT(X,D[,locale])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\u3002X \u662f\u8981\u683c\u5f0f\u5316\u7684\u6570\u5b57\u3002\u5982\u679c X \u662f NULL\uff0c\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002 D \u5fc5\u8981\u53c2\u6570\u3002D \u662f\u8981\u820d\u5165\u5c0f\u6570\u4f4d\u6570 \u5982\u679c D \u662f 0\uff0c\u5219\u7ed3\u679c\u6ca1\u6709\u5c0f\u6570\u70b9\u6216\u6ca1\u6709\u5c0f\u6570\u90e8\u5206\u3002 \u5982\u679c D \u4e3a NULL\uff0c\u51fd\u6570\u8fd4\u56de NULL\u3002 [,locale] \u53ef\u9009\u53c2\u6570\u3002\u53ef\u9009\u53c2\u6570 [,locale] \u6307\u5b9a\u8981\u4f7f\u7528\u7684\u8bed\u8a00\u73af\u5883\uff0c\u5e76\u4e14\u7528\u4e8e\u786e\u5b9a\u5343\u4e2a\u5206\u9694\u7b26\u548c\u5206\u9694\u7b26\u4e4b\u95f4\u7684\u5206\u7ec4\u3002\u5982\u679c [locale] \u8bbe\u7f6e\u4e3a NULL \u6216\u672a\u6307\u5b9a\uff0c\u5219\u9ed8\u8ba4\u8bed\u8a00\u73af\u5883\u4e3a 'en_US'\u3002[,locale]
\u652f\u6301\u8bed\u8a00\u73af\u5883\u53c2\u6570\u4e0e MySQL \u4e00\u81f4\uff0c\u53c2\u89c1MySQL Server Locale Support\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT FORMAT(12332.123456, 4);\n+-------------------------+\n| format(12332.123456, 4) |\n+-------------------------+\n| 12,332.1235 |\n+-------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(12332.1,4);\n+--------------------+\n| format(12332.1, 4) |\n+--------------------+\n| 12,332.1000 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,0);\n+--------------------+\n| format(12332.2, 0) |\n+--------------------+\n| 12,332 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,2,'de_DE');\n+---------------------------+\n| format(12332.2, 2, de_DE) |\n+---------------------------+\n| 12.332,20 |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(19999999.999999999,4);\n+-------------------------------+\n| format(19999999.999999999, 4) |\n+-------------------------------+\n| 20,000,000.0000 |\n+-------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"en_US\");\n+-----------------------------+\n| format(-.12334.2, 2, en_US) |\n+-----------------------------+\n| -0.12 |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"de_CH\");\n+-----------------------------+\n| format(-.12334.2, 2, de_CH) |\n+-----------------------------+\n| -0.12 |\n+-----------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/","title":"FROM_BASE64()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FROM_BASE64()
\u7528\u4e8e\u5c06 Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u56de\u539f\u59cb\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff08\u6216\u6587\u672c\u6570\u636e\uff09\u3002\u53ef\u4ee5\u89e3\u7801\u4f7f\u7528 TO_BASE64()
\u51fd\u6570\u8fdb\u884c Base64 \u7f16\u7801\u7684\u6570\u636e\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u7ed3\u679c\u4e3a NULL\u3002
> FROM_BASE64(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u7684 Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/#_4","title":"\u793a\u4f8b","text":"mysql> select from_base64('MjU1');\n+-------------------+\n| from_base64(MjU1) |\n+-------------------+\n| 255 |\n+-------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_BASE64('abc'), FROM_BASE64(TO_BASE64('abc'));\n+----------------+-----------------------------+\n| to_base64(abc) | from_base64(to_base64(abc)) |\n+----------------+-----------------------------+\n| YWJj | abc |\n+----------------+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> select from_base64(null);\n+-------------------+\n| from_base64(null) |\n+-------------------+\n| NULL |\n+-------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/","title":"HEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5bf9\u4e8e\u5b57\u7b26\u4e32\u53c2\u6570 str\uff0cHEX()
\u8fd4\u56de str \u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002\u5176\u4e2d\uff0cstr \u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u7684\u6bcf\u4e2a\u5b57\u8282\u90fd\u8f6c\u6362\u4e3a\u4e24\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57 (\u591a\u5b57\u8282\u5b57\u7b26\u8f6c\u6362\u6210\u4e24\u4e2a\u4ee5\u4e0a\u7684\u6570\u5b57)\u3002
\u5bf9\u4e8e\u6570\u503c\u53c2\u6570 N\uff0cHEX()
\u8fd4\u56de N \u503c\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u5f62\u5f0f\uff0c\u4e14\u6309\u7167\u6574\u6570\u8fdb\u884c\u8f6c\u6362\u3002\u8fd9\u7b49\u540c\u4e8e CONV(N,10,16)
\uff0c\u76f8\u53cd\u7684\u64cd\u4f5c\u6267\u884c CONV(HEX(N),16,10)
\u3002
\u5bf9\u4e8e NULL
\u53c2\u6570\uff0c\u6b64\u51fd\u6570\u8fd4\u56de NULL
\u3002
> HEX(str), HEX(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u4e3a\u5341\u516d\u8fdb\u5236\u7684\u6570\u5b57\u3002 str \u5fc5\u8981\u53c2\u6570\u3002\u5b57\u7b26\u4e32\uff0c\u5176\u6bcf\u4e2a\u5b57\u7b26\u90fd\u8981\u8f6c\u6362\u4e3a\u4e24\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#_4","title":"\u793a\u4f8b","text":"> SELECT HEX('abc');\n+----------+\n| hex(abc) |\n+----------+\n| 616263 |\n+----------+\n1 row in set (0.00 sec)\n\n> SELECT HEX(255);\n+----------+\n| hex(255) |\n+----------+\n| FF |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/","title":"INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"INSTR()
\u51fd\u6570\u4e5f\u662f\u7528\u6765\u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u5728\u7ed9\u5b9a\u5b57\u7b26\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u3002\u8fd9\u4e2a\u51fd\u6570\u662f\u591a\u5b57\u8282\u5b89\u5168\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u9002\u7528\u4e8e\u5404\u79cd\u5b57\u7b26\u7f16\u7801\uff0c\u5e76\u4e14\u80fd\u6b63\u786e\u5904\u7406\u591a\u5b57\u8282\u5b57\u7b26\uff08\u4f8b\u5982 UTF-8 \u7f16\u7801\u7684\u5b57\u7b26\uff09\u3002
INSTR()
\u51fd\u6570\u4e3b\u8981\u662f\u8fdb\u884c\u6570\u636e\u6e05\u6d17\u548c\u8f6c\u6362\uff0c\u4f8b\u5982\u5f53\u4f60\u9700\u8981\u5728\u6587\u672c\u5b57\u6bb5\u4e2d\u67e5\u627e\u7279\u5b9a\u7684\u5b50\u5b57\u7b26\u4e32\u6216\u6839\u636e\u7279\u5b9a\u7684\u5b57\u7b26\u5206\u5272\u6587\u672c\u5b57\u6bb5\u65f6\u3002\u8fd9\u5bf9\u4e8e\u5904\u7406\u5305\u542b\u67d0\u79cd\u6a21\u5f0f\u6216\u683c\u5f0f\u7684\u6570\u636e\uff08\u5982\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3001\u7535\u8bdd\u53f7\u7801\u7b49\uff09\u975e\u5e38\u6709\u7528\u3002
\u5173\u4e8e\u5927\u5c0f\u5199\u7684\u5904\u7406\uff0cINSTR()
\u51fd\u6570\u53ea\u6709\u5728\u81f3\u5c11\u6709\u4e00\u4e2a\u53c2\u6570\u662f\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u4e0b\u624d\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u4e8e\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0cINSTR()
\u51fd\u6570\u662f\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u8fdb\u884c\u5927\u5c0f\u5199\u654f\u611f\u7684\u6bd4\u8f83\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 BINARY
\u5173\u952e\u5b57\u6765\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u683c\u5f0f\u3002
\u4f8b\u5982\uff1a
SELECT INSTR(BINARY 'abc', 'A');\n
\u4e0a\u8ff0\u67e5\u8be2\u5c06\u8fd4\u56de 0\uff0c\u56e0\u4e3a\u5728\u4e8c\u8fdb\u5236\u683c\u5f0f\u4e0b\uff0c'A' \u548c 'a' \u88ab\u8ba4\u4e3a\u662f\u4e0d\u540c\u7684\u5b57\u7b26\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> INSTR(str,substr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002string
\u662f\u8981\u5728\u5176\u4e2d\u641c\u7d22\u7684\u5b57\u7b26\u4e32\u3002 substr \u5fc5\u8981\u53c2\u6570\u3002substring
\u662f\u4f60\u6b63\u5728\u67e5\u627e\u7684\u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT INSTR('foobarbar', 'bar');\n+-----------------------+\n| instr(foobarbar, bar) |\n+-----------------------+\n| 4 |\n+-----------------------+\n1 row in set (0.01 sec)\n
-- -- \u5728\u5b57\u7b26\u4e32 'Hello World' \u4e2d\u67e5\u627e 'o' \u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\uff0cINSTR \u51fd\u6570\u5c06\u8fd4\u56de 5\uff0c\u56e0\u4e3a 'o' \u9996\u6b21\u51fa\u73b0\u5728 'Hello World' \u4e2d\u7684\u7b2c 5 \u4e2a\u4f4d\u7f6e\nmysql> SELECT INSTR('Hello World', 'o');\n+-----------------------+\n| instr(Hello World, o) |\n+-----------------------+\n| 5 |\n+-----------------------+\n1 row in set (0.01 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a t1 \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e24\u4e2a VARCHAR \u7c7b\u578b\u7684\u5217 a \u548c b\nCREATE TABLE t1(a VARCHAR, b VARCHAR);\n\n-- \u5411\u8868 t1 \u63d2\u5165\u4e09\u884c\u6570\u636e\nINSERT INTO t1 VALUES('axa','x'),('abababa','qq'),('qwer','er');\n\n-- \u4ece\u8868 t1 \u4e2d\u9009\u62e9\u6bcf\u4e00\u884c\uff0c\u7136\u540e\u4f7f\u7528 INSTR \u51fd\u6570\u627e\u51fa\u5217 a \u4e2d\u5217 b \u7684\u5b57\u7b26\u4e32\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\nmysql> select instr(a,b) from t1;\n+-------------+\n| instr(a, b) |\n+-------------+\n| 2 |\n| 0 |\n| 3 |\n+-------------+\n3 rows in set (0.01 sec)\n\n-- \u4ece\u8868 t1 \u4e2d\u9009\u62e9\u6bcf\u4e00\u884c\uff0c\u7136\u540e\u4f7f\u7528 INSTR \u51fd\u6570\u627e\u51fa\u5217 a \u4e2d NULL \u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\n-- \u7531\u4e8e NULL \u662f\u672a\u77e5\u503c\uff0c\u6240\u4ee5\u8fd9\u4e2a\u67e5\u8be2\u4f1a\u8fd4\u56de NULL\nmysql> select instr(a,null) from t1;\n+----------------+\n| instr(a, null) |\n+----------------+\n| NULL |\n| NULL |\n| NULL |\n+----------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/","title":"LCASE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LCASE()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\uff0c\u4e3a LOWER()
\u7684\u8fd1\u4e49\u8bcd\u3002
> LCASE(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/#_4","title":"\u793a\u4f8b","text":"mysql> select lcase('HELLO');\n+--------------+\n| lcase(HELLO) |\n+--------------+\n| hello |\n+--------------+\n1 row in set (0.02 sec)\n\nmysql> select lcase('A'),lcase('B'),lcase('C');\n+----------+----------+----------+\n| lcase(A) | lcaser(B) | lcase(C) |\n+----------+----------+----------+\n| a | b | c |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/","title":"LEFT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LEFT()
\u51fd\u6570\u8fd4\u56de str \u5b57\u7b26\u4e32\u4e2d\u6700\u5de6\u8fb9\u7684\u957f\u5ea6\u5b57\u7b26\u3002\u5982\u679c str \u6216 len \u53c2\u6570\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u503c\u3002
> LEFT(str,len)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u4e32\u3002 len \u5fc5\u8981\u53c2\u6570\u3002\u662f\u4e00\u4e2a\u6b63\u6574\u6570\uff0c\u6307\u5b9a\u5c06\u4ece\u5de6\u8fb9\u8fd4\u56de\u7684\u5b57\u7b26\u6570\u3002\u5982\u679c len \u4e3a 0 \u6216\u4e3a\u8d1f\uff0c\u5219 LEFT \u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u3002\u5982\u679c len \u5927\u4e8e str \u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff0c\u5219 LEFT \u51fd\u6570\u8fd4\u56de\u6574\u4e2a str \u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#_4","title":"\u793a\u4f8b","text":"mysql> select left('abcde', 3) from dual;\n+----------------+\n| left(abcde, 3) |\n+----------------+\n| abc |\n+----------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\nCREATE TABLE t1 (str VARCHAR(100) NOT NULL, len INT);\ninsert into t1 values('abcdefghijklmn',3);\ninsert into t1 values(' ABCDEFGH123456', 3);\ninsert into t1 values('ABCDEF GHIJKLMN', 20);\ninsert into t1 values('ABCDEFGHijklmn ', -1);\ninsert into t1 values('ABCDEFGH123456', -35627164);\ninsert into t1 values('', 3);\nmysql> select left(str, len) from t1;\n+------------------+\n| left(str, len) |\n+------------------+\n| abc |\n| A |\n| ABCDEF GHIJKLMN |\n| |\n| |\n| |\n+------------------+\n6 rows in set (0.01 sec)\n\nmysql> select left('sdfsdfsdfsdf', len) from t1;\n+-------------------------+\n| left(sdfsdfsdfsdf, len) |\n+-------------------------+\n| sdf |\n| sdf |\n| sdfsdfsdfsdf |\n| |\n| |\n| sdf |\n+-------------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/","title":"LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"length()
\u51fd\u6570\u8fd4\u56de\u4e86\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002
> LENGTH(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8ba1\u7b97\u957f\u5ea6\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#_4","title":"\u793a\u4f8b","text":"> select a,length(a) from t1;\na length(a)\na 1\nab 2\nabc 3\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/","title":"LOCATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOCATE()
\u51fd\u6570\u662f\u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u6240\u5728\u4f4d\u7f6e\u7684\u51fd\u6570\u3002\u5b83\u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u4f4d\u7f6e\uff0c\u5982\u679c\u672a\u627e\u5230\uff0c\u5219\u8fd4\u56de 0\u3002
\u7531\u4e8e LOCATE()
\u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u6574\u6570\u503c\uff0c\u6240\u4ee5\u5b83\u53ef\u4ee5\u5d4c\u5957\u5728\u5176\u4ed6\u51fd\u6570\u91cc\u9762\u4f7f\u7528\uff0c\u6bd4\u5982\u53ef\u4ee5\u7528 substring \u51fd\u6570\u622a\u53d6\u5b57\u7b26\u4e32\u3002
\u5173\u4e8e\u5927\u5c0f\u5199\uff0cLOCATE()
\u51fd\u6570\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
> LOCATE(subtr,str,pos)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e substr \u5fc5\u8981\u53c2\u6570\u3002substring
\u662f\u4f60\u6b63\u5728\u67e5\u627e\u7684\u5b57\u7b26\u4e32\u3002 str \u5fc5\u8981\u53c2\u6570\u3002string
\u662f\u8981\u5728\u5176\u4e2d\u641c\u7d22\u7684\u5b57\u7b26\u4e32\u3002 pos \u975e\u5fc5\u8981\u53c2\u6570\u3002position
\u662f\u8868\u793a\u5f00\u59cb\u67e5\u8be2\u7684\u4f4d\u7f6e\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT LOCATE('bar', 'footbarbar');\n+-------------------------+\n| locate(bar, footbarbar) |\n+-------------------------+\n| 5 |\n+-------------------------+\n1 row in set (0.00 sec)\n
mysql>SELECT LOCATE('bar', 'footbarbar',6);\n+----------------------------+\n| locate(bar, footbarbar, 6) |\n+----------------------------+\n| 8 |\n+----------------------------+\n1 row in set (0.00 sec)\n
mysql>SELECT SUBSTRING('hello world',LOCATE('o','hello world'),5);\n+---------------------------------------------------+\n| substring(hello world, locate(o, hello world), 5) |\n+---------------------------------------------------+\n| o wor |\n+---------------------------------------------------+\n1 row in set (0.00 sec)\n
mysql>select locate('a','ABC');\n+----------------+\n| locate(a, ABC) |\n+----------------+\n| 1 |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/","title":"LOWER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOWER()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\u3002
> LOWER(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/#_4","title":"\u793a\u4f8b","text":"mysql> select lower('HELLO');\n+--------------+\n| lower(HELLO) |\n+--------------+\n| hello |\n+--------------+\n1 row in set (0.02 sec)\n\nmysql> select lower('A'),lower('B'),lower('C');\n+----------+----------+----------+\n| lower(A) | lower(B) | lower(C) |\n+----------+----------+----------+\n| a | b | c |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/","title":"LPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u51fd\u6570 LPAD(str,len,padstr) \u5728\u5b57\u7b26\u4e32 str \u5de6\u4fa7\u4f7f\u7528 padstr \u8fdb\u884c\u586b\u5145\uff0c\u76f4\u81f3\u603b\u957f\u5ea6\u4e3a len \u7684\u5b57\u7b26\u4e32\uff0c\u6700\u540e\u8fd4\u56de\u586b\u5145\u540e\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c str \u7684\u957f\u5ea6\u5927\u4e8e len\uff0c\u90a3\u4e48\u6700\u540e\u7684\u957f\u5ea6\u5c06\u7f29\u51cf\u81f3 len\u3002 \u82e5 len \u4e3a\u8d1f\u6570\uff0c\u5219\u8fd4\u56de NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LPAD(str,len,padstr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u88ab\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002 len \u5fc5\u8981\u53c2\u6570\uff0c\u9700\u8981\u586b\u5145\u5230\u7684\u603b\u957f\u5ea6\u3002 padstr \u5fc5\u8981\u53c2\u6570\uff0c\u7528\u4e8e\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,LPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name | LeftPaddedString |\n+------------+-----------------+------------------+\n| 1 | Ananya Majumdar | _ _ _ _IX |\n| 2 | Anushka Samanta | _ _ _ _ X |\n| 3 | Aniket Sharma | _ _ _ _XI |\n| 4 | Anik Das | _ _ _ _ X |\n| 5 | Riya Jain | _ _ _ _IX |\n| 6 | Tapan Samanta | _ _ _ _ X |\n+------------+-----------------+------------------+\n> SELECT Student_id, lpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | Anan |\n| 2 | Anus |\n| 3 | Anik |\n| 4 | Anik |\n| 5 | Riya |\n| 6 | Tapa |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | NULL |\n| 2 | NULL |\n| 3 | NULL |\n| 4 | NULL |\n| 5 | NULL |\n| 6 | NULL |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | |\n| 2 | |\n| 3 | |\n| 4 | |\n| 5 | |\n| 6 | |\n+------------+------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/","title":"LTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u524d\u90e8\u7a7a\u683c\u53bb\u9664\uff0c\u8fd4\u56de\u5904\u7406\u540e\u7684\u5b57\u7b26\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LTRIM(char)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e char \u5fc5\u8981\u53c2\u6570\uff0cCHAR \u4e0e VARCHAR \u5747\u53ef"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values(' matrix',' matrixone');\n> select ltrim(a),ltrim(b) from t1;\n\n+----------+-----------+\n| ltrim(a) | ltrim(b) |\n+----------+-----------+\n| matrix | matrixone |\n+----------+-----------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/","title":"MD5()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MD5()
\u51fd\u6570\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u54c8\u5e0c\u51fd\u6570\uff0c\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684 32 \u5b57\u7b26\u957f\u7684\u5341\u516d\u8fdb\u5236 MD5 \u54c8\u5e0c\u503c\uff0c\u5b83\u53ef\u4ee5\u5c06\u4efb\u610f\u957f\u5ea6\u7684\u8f93\u5165\u6d88\u606f\u8f6c\u6362\u4e3a\u4e00\u4e2a 128 \u4f4d\uff0816 \u5b57\u8282\uff09\u7684\u54c8\u5e0c\u503c\uff0c\u901a\u5e38\u8868\u793a\u4e3a 32 \u4f4d\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002
> MD5(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/#_4","title":"\u793a\u4f8b","text":"mysql> select md5(\"hello world\");\n+----------------------------------+\n| md5(hello world) |\n+----------------------------------+\n| 5eb63bbbe01eeed093cb22bb8f5acdc3 |\n+----------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select md5(null);\n+-----------+\n| md5(null) |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/","title":"OCT(N)","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u51fd\u6570 OCT(N)
\u8fd4\u56de N \u7684\u516b\u8fdb\u5236\u503c\u7684\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d N \u662f\u4e00\u4e2a longlong(BIGINT) \u7c7b\u578b\u7684\u6570\u5b57\uff0c\u5373\u5c06\u4e00\u4e2a\u6570\u5b57\u4ece\u5341\u8fdb\u5236\u6570\u5b57\u57fa\u6570\u7cfb\u7edf\u8f6c\u6362\u5230\u516b\u8fdb\u5236\u6570\u5b57\u57fa\u6570\u7cfb\u7edf\u3002 \u82e5 N \u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL
\u3002
> OCT(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002UINT \u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#_4","title":"\u793a\u4f8b","text":"SELECT OCT(12);\n+---------+\n| oct(12) |\n+---------+\n| 14.0000 |\n+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/","title":"REPEAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REPEAT()
\u7528\u4e8e\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32 str
\u91cd\u590d count
\u6b21\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c count
\u5c0f\u4e8e 1\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u3002\u5982\u679c str
\u6216 count
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> REPEAT(str,count)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u91cd\u590d\u7684\u5b57\u7b26\u4e32\u3002 count \u5fc5\u8981\u53c2\u6570\u3002\u8981\u91cd\u590d\u7684\u6b21\u6570"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT repeat('abc', -1);\n+-----------------+\n| repeat(abc, -1) |\n+-----------------+\n| |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT repeat('abc', 1), repeat('abc', 2), repeat('abc', 3);\n+----------------+----------------+----------------+\n| repeat(abc, 1) | repeat(abc, 2) | repeat(abc, 3) |\n+----------------+----------------+----------------+\n| abc | abcabc | abcabcabc |\n+----------------+----------------+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/","title":"REVERSE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5c06 str \u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u987a\u5e8f\u7ffb\u8f6c\u8f93\u51fa\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> REVERSE(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e Str \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u7ffb\u8f6c\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a varchar(12),c char(30));\n> insert into t1 values('sdfad ','2022-02-02 22:22:22');\n> insert into t1 values(' sdfad ','2022-02-02 22:22:22');\n> insert into t1 values('adsf sdfad','2022-02-02 22:22:22');\n> insert into t1 values(' sdfad','2022-02-02 22:22:22');\n> select reverse(a),reverse(c) from t1;\n+-------------+---------------------+\n| reverse(a) | reverse(c) |\n+-------------+---------------------+\n| dafds | 22:22:22 20-20-2202 |\n| dafds | 22:22:22 20-20-2202 |\n| dafds fsda | 22:22:22 20-20-2202 |\n| dafds | 22:22:22 20-20-2202 |\n+-------------+---------------------+\n> select a from t1 where reverse(a) like 'daf%';\n+-------------+\n| a |\n+-------------+\n| adsf sdfad |\n| sdfad |\n+-------------+\n> select reverse(a) reversea,reverse(reverse(a)) normala from t1;\n+-------------+-------------+\n| reversea | normala |\n+-------------+-------------+\n| dafds | sdfad |\n| dafds | sdfad |\n| dafds fsda | adsf sdfad |\n| dafds | sdfad |\n+-------------+-------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/","title":"RPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u51fd\u6570 RPAD(str,len,padstr) \u5728\u5b57\u7b26\u4e32 str \u53f3\u4fa7\u4f7f\u7528 padstr \u8fdb\u884c\u586b\u5145\uff0c\u76f4\u81f3\u603b\u957f\u5ea6\u4e3a len \u7684\u5b57\u7b26\u4e32\uff0c\u6700\u540e\u8fd4\u56de\u586b\u5145\u540e\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c str \u7684\u957f\u5ea6\u5927\u4e8e len\uff0c\u90a3\u4e48\u6700\u540e\u7684\u957f\u5ea6\u5c06\u7f29\u51cf\u81f3 len\u3002 \u82e5 len \u4e3a\u8d1f\u6570\uff0c\u5219\u8fd4\u56de NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> RPAD(str,len,padstr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u88ab\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002 len \u5fc5\u8981\u53c2\u6570\uff0c\u9700\u8981\u586b\u5145\u5230\u7684\u603b\u957f\u5ea6\u3002 padstr \u5fc5\u8981\u53c2\u6570\uff0c\u7528\u4e8e\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,RPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name | LeftPaddedString |\n+------------+-----------------+------------------+\n| 1 | Ananya Majumdar | IX _ _ _ _ |\n| 2 | Anushka Samanta | X _ _ _ _ |\n| 3 | Aniket Sharma | XI _ _ _ _ |\n| 4 | Anik Das | X _ _ _ _ |\n| 5 | Riya Jain | IX _ _ _ _ |\n| 6 | Tapan Samanta | X _ _ _ _ |\n+------------+-----------------+------------------+\n> SELECT Student_id, rpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | Anan |\n| 2 | Anus |\n| 3 | Anik |\n| 4 | Anik |\n| 5 | Riya |\n| 6 | Tapa |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | NULL |\n| 2 | NULL |\n| 3 | NULL |\n| 4 | NULL |\n| 5 | NULL |\n| 6 | NULL |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | |\n| 2 | |\n| 3 | |\n| 4 | |\n| 5 | |\n| 6 | |\n+------------+------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/","title":"RTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"RTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u540e\u65b9\u7a7a\u683c\u53bb\u9664\uff0c\u8fd4\u56de\u5904\u7406\u540e\u7684\u5b57\u7b26\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> RTRIM(char)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e char \u5fc5\u8981\u53c2\u6570\uff0cCHAR \u4e0e VARCHAR \u5747\u53ef"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values('matrix ','matrixone ');\n> select rtrim(a),rtrim(b) from t1;\n\n+----------+-----------+\n| rtrim(a) | rtrim(b) |\n+----------+-----------+\n| matrix | matrixone |\n+----------+-----------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/","title":"SHA1()/SHA()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SHA1()/SHA()
\u51fd\u6570\u662f\u4e00\u79cd\u52a0\u5bc6\u54c8\u5e0c\u51fd\u6570\uff0c\u7528\u4e8e\u8ba1\u7b97\u5e76\u8fd4\u56de\u7ed9\u5b9a\u5b57\u7b26\u4e32\u7684 SHA-1 \u54c8\u5e0c\u503c\uff0c\u5b83\u5c06\u4efb\u610f\u957f\u5ea6\u7684\u8f93\u5165\u6d88\u606f\u8f6c\u6362\u4e3a\u4e00\u4e2a\u56fa\u5b9a\u957f\u5ea6\uff08160 \u4f4d\uff0c\u5373 20 \u5b57\u8282\uff09\u7684\u54c8\u5e0c\u503c\uff0c\u901a\u5e38\u8868\u793a\u4e3a 40 \u4e2a\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002
> SHA1/SHA(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u52a0\u5bc6\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/#_4","title":"\u793a\u4f8b","text":"mysql> select sha1(\"hello world\");\n+------------------------------------------+\n| sha1(hello world) |\n+------------------------------------------+\n| 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed |\n+------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sha(\"hello world\");\n+------------------------------------------+\n| sha(hello world) |\n+------------------------------------------+\n| 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed |\n+------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sha1(null);\n+------------+\n| sha1(null) |\n+------------+\n| NULL |\n+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/","title":"SHA2()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SHA2()
\u52a0\u5bc6\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u8f93\u5165\u5b57\u7b26\u4e32\u7684 SHA2 \u54c8\u5e0c\u503c\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u8981\u6563\u5217\u7684\u660e\u6587\u5b57\u7b26\u4e32\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570\u6307\u793a\u7ed3\u679c\u7684\u6240\u9700\u4f4d\u957f\uff0c\u5176\u503c\u5fc5\u987b\u4e3a 224\u3001256\u3001384\u3001512 \u6216 0\uff08\u76f8\u5f53\u4e8e 256\uff09\uff0c\u5206\u522b\u5bf9\u5e94\u4e86 SHA-224, SHA-256, SHA-384 \u548c SHA-512 \u7b97\u6cd5\u3002\u5982\u679c\u53c2\u6570\u662f NULL \u6216\u8005\u4e0d\u662f\u4e00\u4e2a\u5408\u6cd5\u503c\u5c06\u8fd4\u56de NULL\u3002
> SHA2(str, hash_length)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8ba1\u7b97\u54c8\u5e0c\u503c\u7684\u5b57\u7b26\u4e32 hash_length \u5fc5\u8981\u53c2\u6570\u3002\u54c8\u5e0c\u957f\u5ea6\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/#_4","title":"\u793a\u4f8b","text":"mysql> select sha2(\"hello world\", 384);\n+--------------------------------------------------------------------------------------------------+\n| sha2(hello world, 384) |\n+--------------------------------------------------------------------------------------------------+\n| fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd |\n+--------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sha2(null, 512);\n+-----------------+\n| sha2(null, 512) |\n+-----------------+\n| NULL |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> select sha2(\"abc\", 99);\n+---------------+\n| sha2(abc, 99) |\n+---------------+\n| NULL |\n+---------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/","title":"SPACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SPACE(N) \u8fd4\u56de N \u4e2a\u7a7a\u683c\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_2","title":"\u8bed\u6cd5","text":"> SPACE(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002UINT \u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1\n(\nEmployee_name VARCHAR(100) NOT NULL,\nJoining_Date DATE NOT NULL\n);\n> INSERT INTO t1\n(Employee_name, Joining_Date )\nVALUES\n(' Ananya Majumdar', '2000-01-11'),\n(' Anushka Samanta', '2002-11-10' ),\n(' Aniket Sharma ', '2005-06-11' ),\n(' Anik Das', '2008-01-21' ),\n(' Riya Jain', '2008-02-01' ),\n(' Tapan Samanta', '2010-01-11' ),\n(' Deepak Sharma', '2014-12-01' ),\n(' Ankana Jana', '2018-08-17'),\n(' Shreya Ghosh', '2020-09-10') ;\n> INSERT INTO t1\n(Employee_name, Joining_Date ) values(' ','2014-12-01');\n> select * from t1 where Employee_name=space(5);\n+---------------+--------------+\n| Employee_name | Joining_Date |\n+---------------+--------------+\n| | 2014-12-01 |\n+---------------+--------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/","title":"SPLIT_PART()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SPLIT_PART()
\u7528\u4e8e\u5728\u7ed9\u5b9a\u7684\u5206\u9694\u7b26\u57fa\u7840\u4e0a\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u5206\u89e3\u6210\u591a\u4e2a\u90e8\u5206\uff0c\u5e76\u8fd4\u56de\u6307\u5b9a\u7684\u90e8\u5206\u3002
\u5982\u679c\u6307\u5b9a\u7684\u90e8\u5206\uff08\u7531 unsigned_integer
\u53c2\u6570\u6307\u5b9a\uff09\u8d85\u51fa\u4e86\u5b9e\u9645\u5b58\u5728\u7684\u90e8\u5206\u6570\u91cf\uff0cSPLIT_PART()
\u5c06\u8fd4\u56de NULL
\u3002
SPLIT_PART()
\u53ea\u4f1a\u4ece\u5de6\u5230\u53f3\u5f00\u59cb\u8ba1\u6570\u90e8\u5206\uff0c\u5982\u679c unsigned_integer
\u4e3a\u8d1f\u6570\uff0c\u5c06\u4f1a\u62a5\u9519\u3002
> SPLIT_PART(expr, delimiter, unsigned_integer)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u8981\u88ab\u62c6\u5206\u7684\u5b57\u7b26\u4e32\u3002 delimiter \u5fc5\u8981\u53c2\u6570\u3002\u7528\u4e8e\u5206\u5272\u5b57\u7b26\u4e32\u7684\u5206\u9694\u7b26\u3002 unsigned_integer \u5fc5\u8981\u53c2\u6570\u3002\u8fd9\u662f\u4e00\u4e2a\u6574\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u54ea\u4e2a\u90e8\u5206\u3002\u7b2c\u4e00\u4e2a\u90e8\u5206\u662f 1\uff0c\u7b2c\u4e8c\u4e2a\u90e8\u5206\u662f 2\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#_4","title":"\u793a\u4f8b","text":"-- \u62c6\u5206\u5b57\u7b26\u4e32 'axbxc'\uff0c\u5e76\u4f7f\u7528'x'\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u8be5\u51fd\u6570\u5c06\u8fd4\u56de\u5b57\u7b26\u4e32'axbxc'\u7684\u7b2c\u4e00\u90e8\u5206\u3002\u6240\u4ee5\u6267\u884c\u8fd9\u6761 SQL \u8bed\u53e5\u7684\u7ed3\u679c\u662f 'a'\uff0c\u56e0\u4e3a\u5728'x'\u5206\u9694\u7b26\u7684\u57fa\u7840\u4e0a\u5206\u5272\u5b57\u7b26\u4e32'axbxc'\u540e\u7684\u7b2c\u4e00\u90e8\u5206\u662f 'a'\u3002\nmysql> select split_part('axbxc','x',1);\n+-------------------------+\n| split_part(axbxc, x, 1) |\n+-------------------------+\n| a |\n+-------------------------+\n1 row in set (0.00 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868't1'\uff0c\u5b83\u6709\u4e09\u4e2a\u5217\uff1a'a'\uff08varchar \u7c7b\u578b\uff09\uff0c'b'\uff08varchar \u7c7b\u578b\uff09\uff0c\u548c'c'\uff08int \u7c7b\u578b\uff09\u3002\ncreate table t1(a varchar,b varchar,c int);\n-- \u5411't1'\u8868\u4e2d\u63d2\u5165\u591a\u884c\u6570\u636e\ninsert into t1 values('axbxc','x',1),('axbxcxd','x',2),('axbxcxd','x',3),('axbxcxd','xc',1),('axbxcxd','xc',2),('axbxcxd','xc',3),('axbxcxd','asas',1),('axbxcxd','asas',2),(null,'asas',3),('axbxcxd',null,3),('axbxcxd','asas',null),('axxx','x',1),('axxx','x',2);\n-- \u67e5\u8be2\u4f7f\u7528 split_part \u51fd\u6570\u5904\u7406't1'\u8868\u4e2d\u7684\u6bcf\u884c\u6570\u636e\u3002\u5bf9\u4e8e\u6bcf\u884c\uff0c\u5b83\u90fd\u4f1a\u628a'a'\u5217\u7684\u503c\u5206\u5272\u6210\u591a\u4e2a\u90e8\u5206\uff08\u4f7f\u7528'b'\u5217\u7684\u503c\u4f5c\u4e3a\u5206\u9694\u7b26\uff09\uff0c\u7136\u540e\u8fd4\u56de\u6307\u5b9a\u7684\u90e8\u5206\uff08\u7531'c'\u5217\u7684\u503c\u6307\u5b9a\uff09\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u7b2c\u4e00\u884c\u6570\u636e\uff08'axbxc', 'x', 1\uff09\uff0c\u5b83\u4f1a\u8fd4\u56de'a'\uff0c\u56e0\u4e3a'a'\u662f\u5728'x'\u5206\u9694\u7b26\u7684\u57fa\u7840\u4e0a\u5206\u5272\u5b57\u7b26\u4e32'axbxc'\u540e\u7684\u7b2c\u4e00\u90e8\u5206\u3002\nmysql> select split_part(a,b,c) from t1;\n+---------------------+\n| split_part(a, b, c) |\n+---------------------+\n| a |\n| b |\n| c |\n| axb |\n| xd |\n| NULL |\n| axbxcxd |\n| NULL |\n| NULL |\n| NULL |\n| NULL |\n| a |\n| NULL |\n+---------------------+\n13 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/","title":"STARTSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5b57\u7b26\u4e32\u5982\u679c\u4ee5\u6307\u5b9a\u524d\u7f00\u5f00\u59cb\u8fd4\u56de 1\uff0c\u5426\u5219\u5219\u8fd4\u56de 0\u3002\u8be5\u51fd\u6570\u662f\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> STARTSWITH(str,prefix)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002 prefix \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_4","title":"\u8fd4\u56de\u503c","text":"> drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> select a,startswith(b,'An') from t1;\n+------+-------------------+\n| a | startswith(b, An) |\n+------+-------------------+\n| 1 | 1 |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 1 |\n| 5 | 0 |\n| 6 | 0 |\n+------+-------------------+\n> select a,b,c from t1 where startswith(b,'An')=1 and startswith(c,'I')=1;\n+------+-----------------+------+\n| a | b | c |\n+------+-----------------+------+\n| 1 | Ananya Majumdar | IX |\n+------+-----------------+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/","title":"SUBSTRING_INDEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u6b64\u51fd\u6570 SUBSTRING_INDEX()
\u4ee5\u5206\u9694\u7b26\u4e3a\u7d22\u5f15\uff0c\u83b7\u53d6\u4e0d\u540c\u7d22\u5f15\u4f4d\u7684\u5b57\u7b26\u3002
\u5982\u679c count \u4e3a\u6b63\uff0c\u5219\u8fd4\u56de\u6700\u540e\u4e00\u4e2a\u5206\u9694\u7b26\u5de6\u4fa7\uff08\u4ece\u5de6\u4fa7\u5f00\u59cb\u8ba1\u6570\uff09\u7684\u6240\u6709\u5185\u5bb9\u3002
\u5982\u679c count \u4e3a\u8d1f\u6570\uff0c\u5219\u8fd4\u56de\u6700\u540e\u4e00\u4e2a\u5206\u9694\u7b26\u53f3\u4fa7\uff08\u4ece\u53f3\u4fa7\u5f00\u59cb\u8ba1\u6570\uff09\u7684\u6240\u6709\u5185\u5bb9\u3002
\u5982\u679c\u53c2\u6570\u4e3a NULL
\uff0cSUBSTRING_INDEX()
\u5c06\u8fd4\u56de NULL
\u3002
> SUBSTRING_INDEX(str,delim,count)\n
\u5373\uff0csubstring_index\uff08\u201c\u5f85\u622a\u53d6\u6709\u7528\u90e8\u5206\u7684\u5b57\u7b26\u4e32\u201d\uff0c\u201c\u622a\u53d6\u6570\u636e\u4f9d\u636e\u7684\u5b57\u7b26\u201d\uff0c\u622a\u53d6\u5b57\u7b26\u7684\u4f4d\u7f6e N\uff09
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5b57\u7b26\u4e32 delim \u5206\u9694\u7b26 count \u8868\u793a delim \u51fa\u73b0\u6b21\u6570\u7684\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);\n+--------------------------------------+\n| substring_index(www.mysql.com, ., 2) |\n+--------------------------------------+\n| www.mysql |\n+--------------------------------------+\n1 row in set (0.03 sec)\n\nmysql> select substring_index('xyz', 'abc', 9223372036854775808);\n+------------------------------------------------+\n| substring_index(xyz, abc, 9223372036854775808) |\n+------------------------------------------------+\n| xyz |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);\n+---------------------------------------+\n| substring_index(www.mysql.com, ., -2) |\n+---------------------------------------+\n| mysql.com |\n+---------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('192,168,8,203', ',', 2), ',',-1);\n+--------------------------------------------------------------+\n| substring_index(substring_index(192,168,8,203, ,, 2), ,, -1) |\n+--------------------------------------------------------------+\n| 168 |\n+--------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ncreate table test(a varchar(100), b varchar(20), c int);\ninsert into test values('www.mysql.com', '.', 0);\ninsert into test values('www.mysql.com', '.', 1);\ninsert into test values('www.mysql.com', '.', 2);\ninsert into test values('www.mysql.com', '.', 3);\ninsert into test values('www.mysql.com', '.', 9223372036854775808);\ninsert into test values('www.mysql.com', '.', -1);\ninsert into test values('www.mysql.com', '.', -2);\ninsert into test values('www.mysql.com', '.', -3);\nmysql> select SUBSTRING_INDEX(a, b, c) from test;\n+--------------------------+\n| substring_index(a, b, c) |\n+--------------------------+\n| |\n| www |\n| www.mysql |\n| www.mysql.com |\n| com |\n| mysql.com |\n| www.mysql.com |\n+--------------------------+\n7 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/","title":"SUBSTRING()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SUBSTR()
\u548c MID()
\u90fd\u662f SUBSTRING()
\u7684\u540c\u4e49\u8bcd\u3002 \u4e0d\u5e26 len \u53c2\u6570\u7684\u5199\u6cd5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u4ece pos \u4f4d\u7f6e\u5f00\u59cb\u7684\u5b50\u5b57\u7b26\u4e32\u3002\u5e26 len \u53c2\u6570\u7684\u5199\u6cd5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u4ece pos \u4f4d\u7f6e\u5f00\u59cb\u7684\u957f\u5ea6\u4e3a len \u7684\u5b50\u5b57\u7b26\u4e32\u3002
> SUBSTRING(str,pos)\n> SUBSTR(str,pos,len)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u6bcd\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002 pos \u5fc5\u8981\u53c2\u6570\uff0c\u5f00\u59cb\u4f4d\u7f6e len \u53ef\u9009\u53c2\u6570\uff0c\u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u957f\u5ea6"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE IF NOT EXISTS t1 (\npub_id varchar(8) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_name varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_city varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry_office varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\nno_of_branch int NOT NULL DEFAULT 0,\nestd date NOT NULL DEFAULT '2000-01-01'\n);\n\n> INSERT INTO t1 (pub_id, pub_name, pub_city, country, country_office, no_of_branch, estd) VALUES\n('P001', 'Jex Max Publication', 'New York', 'USA', 'New York', 15, '1969-12-25'),\n('P002', 'BPP Publication', 'Mumbai', 'India', 'New Delhi', 10, '1985-10-01'),\n('P003', 'New Harrold Publication', 'Adelaide', 'Australia', 'Sydney', 6, '1975-09-05'),\n('P004', 'Ultra Press Inc.', 'London', 'UK', 'London', 8, '1948-07-10'),\n('P005', 'Mountain Publication', 'Houstan', 'USA', 'Sun Diego', 25, '1975-01-01'),\n('P006', 'Summer Night Publication', 'New York', 'USA', 'Atlanta', 10, '1990-12-10'),\n('P007', 'Pieterson Grp. of Publishers', 'Cambridge', 'UK', 'London', 6, '1950-07-15'),\n('P008', 'Novel Publisher Ltd.', 'New Delhi', 'India', 'Bangalore', 10, '2000-01-01');\n\n> SELECT pub_name, SUBSTR(pub_name,4,5) FROM t1 WHERE country='USA';\n+--------------------------+------------------------+\n| pub_name | substr(pub_name, 4, 5) |\n+--------------------------+------------------------+\n| Jex Max Publication | Max |\n| Mountain Publication | ntain |\n| Summer Night Publication | mer N |\n+--------------------------+------------------------+\n3 rows in set (0.04 sec)\n\n> SELECT pub_name, SUBSTR(pub_name,5) FROM t1 WHERE country='USA';\n+--------------------------+----------------------+\n| pub_name | substr(pub_name, 5) |\n+--------------------------+----------------------+\n| Jex Max Publication | Max Publication |\n| Mountain Publication | tain Publication |\n| Summer Night Publication | er Night Publication |\n+--------------------------+----------------------+\n3 rows in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/","title":"TO_BASE64()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_BASE64()
\u51fd\u6570\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u4e0d\u662f\u5b57\u7b26\u4e32\uff0c\u5219\u4f1a\u5728\u8f6c\u6362\u4e4b\u524d\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u7ed3\u679c\u4e3a NULL\u3002
\u53ef\u4ee5\u4f7f\u7528 FROM_BASE64()
\u51fd\u6570\u5bf9 Base64 \u7f16\u7801\u5b57\u7b26\u4e32\u8fdb\u884c\u89e3\u7801\u3002
> TO_BASE64(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u4e3a Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TO_BASE64('abc');\n+----------------+\n| to_base64(abc) |\n+----------------+\n| YWJj |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_BASE64(255);\n+----------------+\n| to_base64(255) |\n+----------------+\n| MjU1 |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_BASE64(null);\n+-----------------+\n| to_base64(null) |\n+-----------------+\n| NULL |\n+-----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/","title":"TRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TRIM()
\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5220\u9664\u4e0d\u9700\u8981\u7684\u5b57\u7b26\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 LEADING
\uff0cTRAILING
\u6216 BOTH
\u9009\u9879\u660e\u786e\u6307\u793a TRIM()
\u51fd\u6570\u4ece\u5b57\u7b26\u4e32\u4e2d\u5220\u9664\u524d\u5bfc\uff0c\u5c3e\u968f\u6216\u524d\u5bfc\u548c\u5c3e\u968f\u7684\u4e0d\u5fc5\u8981\u7684\u5b57\u7b26\u3002
\u5982\u679c\u4f60\u6ca1\u6709\u6307\u5b9a\u4efb\u4f55\u5185\u5bb9\uff0cTRIM()
\u51fd\u6570\u9ed8\u8ba4\u4f7f\u7528 BOTH
\u9009\u9879\u3002
[remstr]
\u662f\u8981\u5220\u9664\u7684\u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u662f\u4e00\u4e2a\u7a7a\u683c\u3002\u5373\u5982\u679c\u4e0d\u6307\u5b9a\u7279\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u5219 TRIM()
\u51fd\u6570\u4ec5\u5220\u9664\u7a7a\u683c\u3002
> TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u662f\u8981\u5220\u9664\u5b50\u5b57\u7b26 remstr
\u7684\u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#_4","title":"\u793a\u4f8b","text":"mysql> select trim(' abc '), trim('abc '), trim(' abc'), trim('abc');\n+-------------+------------+------------+-----------+\n| trim( abc ) | trim(abc ) | trim( abc) | trim(abc) |\n+-------------+------------+------------+-----------+\n| abc | abc | abc | abc |\n+-------------+------------+------------+-----------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1(a varchar(100), b varchar(100));\ninsert into t1 values('abc', 'abc');\ninsert into t1 values('\u554aabc\u54e6', '\u554aabc\u54e6');\ninsert into t1 values('\u554a\u554ao', 'o');\ninsert into t1 values('\u554a\u554ao', '\u554a');\ninsert into t1 values('\u554a\u554ao', 'o\u554a');\nmysql> select trim(both a from b) from t1;\n+---------------------+\n| trim(both a from b) |\n+---------------------+\n| |\n| |\n| o |\n| \u554a |\n| o\u554a |\n+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select trim(leading a from b) from t1;\n+------------------------+\n| trim(leading a from b) |\n+------------------------+\n| |\n| |\n| o |\n| \u554a |\n| o\u554a |\n+------------------------+\n5 rows in set (0.01 sec)\n\nmysql> select trim(trailing a from b) from t1;\n+-------------------------+\n| trim(trailing a from b) |\n+-------------------------+\n| |\n| |\n| o |\n| \u554a |\n| o\u554a |\n+-------------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/","title":"UCASE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UCASE()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\uff0c\u4e3a UPPER()
\u7684\u8fd1\u4e49\u8bcd\u3002
> UCASE(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/#_4","title":"\u793a\u4f8b","text":"mysql> select ucase('hello');\n+--------------+\n| ucase(hello) |\n+--------------+\n| HELLO |\n+--------------+\n1 row in set (0.03 sec)\n\nmysql> select ucase('a'),ucase('b'),ucase('c');\n+----------+----------+----------+\n| ucase(a) | ucase(b) | ucase(c) |\n+----------+----------+----------+\n| A | B | C |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/","title":"UNHEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UNHEX()
\u51fd\u6570\u7528\u4e8e\u5c06\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u76f8\u5e94\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5bf9\u4e8e NULL
\u53c2\u6570\uff0c\u6b64\u51fd\u6570\u8fd4\u56de NULL
\u3002
> UNHEX(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u5fc5\u987b\u4e3a\u5408\u6cd5\u7684\u5341\u516d\u8fdb\u5236\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT UNHEX('4d6174726978204f726967696e');\n+-----------------------------------+\n| unhex(4d6174726978204f726967696e) |\n+-----------------------------------+\n| Matrix Origin |\n+-----------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select unhex(NULL);\n+-------------+\n| unhex(null) |\n+-------------+\n| NULL |\n+-------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/","title":"UPPER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UPPER()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\u3002
> UPPER(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/#_4","title":"\u793a\u4f8b","text":"mysql> select upper('hello');\n+--------------+\n| upper(hello) |\n+--------------+\n| HELLO |\n+--------------+\n1 row in set (0.03 sec)\n\nmysql> select upper('a'),upper('b'),upper('c');\n+----------+----------+----------+\n| upper(a) | upper(b) | upper(c) |\n+----------+----------+----------+\n| A | B | C |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/","title":"\u6b63\u5219\u8868\u8fbe\u5f0f\u6982\u8ff0","text":"\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u5339\u914d\u6587\u672c\u6a21\u5f0f\u7684\u65b9\u6cd5\u3002\u4f60\u53ef\u4ee5\u5728 LIKE \u8bed\u53e5\u4e2d\u4f7f\u7528\u7b80\u5355\u7684\u901a\u914d\u7b26\uff08\u5982 %\uff0c_\uff09\uff0c\u4f46\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\u4e3a\u4f60\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u7075\u6d3b\u6027\u548c\u5339\u914d\u9009\u9879\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#_2","title":"\u4f7f\u7528\u573a\u666f","text":"\u6b63\u5219\u8868\u8fbe\u5f0f\u80fd\u8fdb\u884c\u590d\u6742\u7684\u5b57\u7b26\u4e32\u5339\u914d\u548c\u64cd\u4f5c\uff0c\u4ee5\u4e0b\u5217\u4e3e\u4e00\u4e9b\u5e38\u89c1\u7684\u4f7f\u7528\u573a\u666f\uff1a
\u6570\u636e\u9a8c\u8bc1\uff1a\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u7528\u6765\u9a8c\u8bc1\u6570\u636e\u662f\u5426\u7b26\u5408\u7279\u5b9a\u7684\u683c\u5f0f\uff0c\u4f8b\u5982\u68c0\u67e5\u4e00\u4e2a\u5b57\u6bb5\u662f\u5426\u5305\u542b\u6709\u6548\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3001\u7535\u8bdd\u53f7\u7801\u6216\u8005\u793e\u4f1a\u4fdd\u969c\u53f7\u7b49\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u627e\u51fa\u6240\u6709\u683c\u5f0f\u4e0d\u7b26\u5408\u89c4\u8303\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff1a
SELECT email\nFROM users\nWHERE email NOT REGEXP '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2,}$';\n
\u6570\u636e\u7b5b\u9009\uff1a\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u7528\u6765\u641c\u7d22\u5305\u542b\u6216\u4e0d\u5305\u542b\u7279\u5b9a\u6a21\u5f0f\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u8981\u627e\u51fa\u6240\u6709\u4ee5\u7279\u5b9a\u524d\u7f00\u5f00\u59cb\u7684\u7535\u8bdd\u53f7\u7801\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5339\u914d\u8fd9\u4e9b\u53f7\u7801\uff1a
SELECT phone_number\nFROM users\nWHERE phone_number REGEXP '^180';\n
\u6570\u636e\u6e05\u6d17\uff1a\u5728\u6570\u636e\u6e05\u6d17\u4e2d\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u4e5f\u975e\u5e38\u6709\u7528\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6e05\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u3001\u7a7a\u683c\u6216\u8005\u63d0\u53d6\u5b57\u7b26\u4e32\u4e2d\u7684\u6570\u5b57\u7b49\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5b9e\u73b0\u8fd9\u4e9b\u529f\u80fd\uff1a
SELECT REGEXP_REPLACE(name, '[^a-zA-Z]', '')\nFROM users;\n
\u8fd9\u6bb5 SQL \u5c06\u4f1a\u8fd4\u56de name
\u5b57\u6bb5\u4e2d\u6240\u6709\u975e\u5b57\u6bcd\u7684\u5b57\u7b26\u88ab\u66ff\u6362\u6389\u7684\u7ed3\u679c\u3002
\u6587\u672c\u5206\u6790\uff1a\u5982\u679c\u4f60\u6b63\u5728\u8fdb\u884c\u6587\u672c\u5206\u6790\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u4f60\u627e\u51fa\u6587\u672c\u4e2d\u7684\u7279\u5b9a\u8bcd\u6c47\u6216\u77ed\u8bed\uff0c\u751a\u81f3\u53ef\u4ee5\u7528\u6765\u8fdb\u884c\u67d0\u4e9b\u5f62\u5f0f\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3002
\u6b63\u5219\u8868\u8fbe\u5f0f\u4f7f\u7528 POSIX\uff08Portable Operating System Interface\uff09\u6269\u5c55\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u9700\u8981\u6ce8\u610f\u7684\u7279\u6b8a\u5b57\u7b26\uff1a
\u5b57\u7b26 \u8bf4\u660e.
\u5339\u914d\u4efb\u4f55\u5355\u4e2a\u5b57\u7b26\uff08\u9664\u4e86\u6362\u884c\u7b26\uff09 *
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d\u4efb\u610f\u6b21\uff08\u5305\u62ec\u96f6\u6b21\uff09 +
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d\u4e00\u6b21\u6216\u591a\u6b21\u3002 ?
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d\u96f6\u6b21\u6216\u4e00\u6b21\u3002 {n}
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d n \u6b21\u3002 {n,}
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d n \u6b21\u6216\u66f4\u591a\u6b21\u3002 {n,m}
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d n \u6b21\u5230 m \u6b21\u3002 ^
\u8868\u793a\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u3002 $
\u8868\u793a\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u3002 [abc]
\u8868\u793a\u5339\u914d a\u3001b \u6216 c\u3002 [^abc]
\u8868\u793a\u5339\u914d\u4efb\u4f55\u4e0d\u662f a\u3001b \u6216 c \u7684\u5b57\u7b26\u3002 (abc|def)
\u8868\u793a\u5339\u914d abc \u6216 def\u3002 \\d
\u8868\u793a\u5339\u914d\u6570\u5b57 \\s
\u8868\u793a\u5339\u914d\u7a7a\u767d\u5b57\u7b26 \\w
\u8868\u793a\u5339\u914d\u5355\u8bcd\u5b57\u7b26 \\D
\u3001\\S
\u548c \\W
\u8868\u793a\u5339\u914d\u76f8\u53cd\u7684\u5b57\u7b26\u96c6 Note
\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\uff0c\u8fd9\u4e9b\u7279\u6b8a\u5b57\u7b26\u9700\u8981\u4f7f\u7528 \\
\u8fdb\u884c\u8f6c\u4e49\uff0c\u4f8b\u5982 \\\\.
\u8868\u793a\u5339\u914d\u4e00\u4e2a\u5b9e\u9645\u7684 .
\u5b57\u7b26\uff0c\u800c\u4e0d\u662f\u4efb\u4f55\u5b57\u7b26\u3002
MatrixOne \u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u9ed8\u8ba4\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\u3002\u5982\u679c\u4f60\u5e0c\u671b\u8fdb\u884c\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u5339\u914d\uff0c\u53ef\u4ee5\u4f7f\u7528 REGEXP_LIKE(column, pattern, 'i')
\u8fd9\u6837\u7684\u8bed\u6cd5\u3002\u5176\u4e2d i
\u8868\u793a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
\u6b63\u5219\u8868\u8fbe\u5f0f\u51fd\u6570\u5217\u8868
\u540d\u79f0 \u91ca\u4e49 NOT REGEXP REGEXP \u7684\u5426\u5b9a\u8868\u8fbe\u5f0f REGEXP_INSTR() \u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b50\u4e32\u8d77\u59cb\u7d22\u5f15 REGEXP_LIKE() \u5b57\u7b26\u4e32\u662f\u5426\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f REGEXP_REPLACE() \u66ff\u6362\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b50\u5b57\u7b26\u4e32 REGEXP_SUBSTR() \u8fd4\u56de\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b50\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/","title":"NOT REGEXP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"NOT REGEXP
\u7528\u4e8e\u6d4b\u8bd5\u4e00\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e0d\u5339\u914d\u6307\u5b9a\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
\u5982\u679c column_name
\u4e0d\u5339\u914d pattern
\uff0c\u5219\u8fd4\u56de TRUE
\u3002\u5982\u679c\u5339\u914d\uff0c\u5219\u8fd4\u56de FALSE
\u3002
> column_name NOT REGEXP pattern\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"column_name
\u662f\u8981\u5339\u914d\u7684\u5b57\u6bb5\u3002
pattern
\u662f\u8981\u5e94\u7528\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
CREATE TABLE example (\nid INT AUTO_INCREMENT,\ntext VARCHAR(255),\nPRIMARY KEY(id)\n);\n\n\nINSERT INTO example (text)\nVALUES ('Hello1'),\n('Hello2'),\n('World'),\n('HelloWorld'),\n('Hello_World'),\n('example'),\n('example1'),\n('example2');\n\nmysql> SELECT * FROM example WHERE text NOT REGEXP '[0-9]';\n+------+-------------+\n| id | text |\n+------+-------------+\n| 3 | World |\n| 4 | HelloWorld |\n| 5 | Hello_World |\n| 6 | example |\n+------+-------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/","title":"REGEXP_INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_INSTR()
\u8fd4\u56de\u5339\u914d\u5230\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002\u5982\u679c\u6ca1\u6709\u627e\u5230\u5339\u914d\u9879\uff0c\u8be5\u51fd\u6570\u5c06\u8fd4\u56de 0\u3002
> REGEXP_INSTR(expr, pat[, pos[, occurrence[, return_option[, match_type]]]])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\u662f\u8981\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002
pat
\u662f\u8981\u5728\u5b57\u7b26\u4e32\u4e2d\u5339\u914d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
pos
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u4ece\u54ea\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u4ece\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002
occurrence
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u7b2c\u51e0\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u8fd4\u56de\u7b2c\u4e00\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002
return_option
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u7684\u4f4d\u7f6e\u662f\u6a21\u5f0f\u5f00\u59cb\u7684\u4f4d\u7f6e\u8fd8\u662f\u7ed3\u675f\u7684\u4f4d\u7f6e\u3002\u5982\u679c\u4e3a 0 \u6216\u7701\u7565\uff0c\u51fd\u6570\u8fd4\u56de\u6a21\u5f0f\u5f00\u59cb\u7684\u4f4d\u7f6e\u3002\u5982\u679c\u4e3a 1\uff0c\u51fd\u6570\u8fd4\u56de\u6a21\u5f0f\u7ed3\u675f\u7684\u4f4d\u7f6e\u4e4b\u540e\u7684\u4f4d\u7f6e\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_INSTR('Hello, my number is 12345.', '[0-9]+');\n+--------------------------------------------------+\n| regexp_instr(Hello, my number is 12345., [0-9]+) |\n+--------------------------------------------------+\n| 21 |\n+--------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('apple', 'z+');\n+-------------------------+\n| regexp_instr(apple, z+) |\n+-------------------------+\n| 0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World!', 'World');\n+------------------------------------+\n| regexp_instr(Hello, World!, World) |\n+------------------------------------+\n| 8 |\n+------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World! World!', 'World', 1, 2);\n+-------------------------------------------------+\n| regexp_instr(Hello, World! World!, World, 1, 2) |\n+-------------------------------------------------+\n| 15 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/","title":"REGEXP_LIKE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_LIKE()
\u7528\u4e8e\u5224\u65ad\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e0e\u63d0\u4f9b\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5339\u914d\u3002\u5982\u679c\u5b57\u7b26\u4e32\u7b26\u5408\u6a21\u5f0f\uff0c\u51fd\u6570\u8fd4\u56de TRUE
\uff0c\u5426\u5219\u8fd4\u56de FALSE
\u3002\u5b83\u7684\u5de5\u4f5c\u65b9\u5f0f\u7c7b\u4f3c\u4e8e REGEXP
\u64cd\u4f5c\u7b26\uff0c\u4f46\u662f\u5b83\u53ef\u4ee5\u63a5\u53d7\u7b2c\u4e09\u4e2a\u53ef\u9009\u53c2\u6570 match_type
\uff0c\u7528\u4e8e\u5b9a\u4e49\u5339\u914d\u7684\u884c\u4e3a\u3002
REGEXP \u548c RLIKE \u662f REGEXP_LIKE()
\u7684\u540c\u4e49\u8bcd\u3002
> REGEXP_LIKE(expr, pat[, match_type])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\u662f\u8981\u641c\u7d22\u7684\u5b57\u7b26\u4e32\u3002
pat
\u662f\u8981\u5728\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE');\n+-----------------------------------+\n| regexp_like(CamelCase, CAMELCASE) |\n+-----------------------------------+\n| false |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE', 'i');\n+--------------------------------------+\n| regexp_like(CamelCase, CAMELCASE, i) |\n+--------------------------------------+\n| true |\n+--------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/","title":"REGEXP_REPLACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_REPLACE()
\u7528\u4e8e\u5c06\u5339\u914d\u7ed9\u5b9a\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u65b0\u5b57\u7b26\u4e32\u3002
> REGEXP_REPLACE(expr, pat, repl[, pos[, occurrence[, match_type]]])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\u662f\u8981\u66ff\u6362\u7684\u5b57\u7b26\u4e32\u3002
pat
\u8fd9\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u51fd\u6570\u4f1a\u67e5\u627e\u4e0e\u6b64\u6a21\u5f0f\u5339\u914d\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002
repl
\u662f\u66ff\u6362\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u66ff\u6362\u627e\u5230\u7684\u5339\u914d\u5b57\u7b26\u4e32\u3002
pos
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u4ece\u54ea\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u4ece\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002
occurrence
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u66ff\u6362\u7b2c\u51e0\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u8fd4\u56de\u7b2c\u4e00\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_REPLACE('Hello, World!', 'World', 'Universe');\n+------------------------------------------------+\n| regexp_replace(Hello, World!, World, Universe) |\n+------------------------------------------------+\n| Hello, Universe! |\n+------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat','Cat', 'Tiger') 'Result';\n+---------------------------+\n| Result |\n+---------------------------+\n| Tiger Dog Tiger Dog Tiger |\n+---------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/","title":"REGEXP_SUBSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_SUBSTR()
\u7528\u4e8e\u8fd4\u56de\u5b57\u7b26\u4e32 expr
\u4e2d\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f pat
\u7684\u5b50\u5b57\u7b26\u4e32\u3002
> REGEXP_SUBSTR(expr, pat[, pos[, occurrence[, match_type]]])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\uff1a\u8fd9\u662f\u539f\u59cb\u7684\u5b57\u7b26\u4e32\uff0c\u5728\u6b64\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u5339\u914d\u9879\u3002
pat
\uff1a\u8fd9\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\uff0c\u51fd\u6570\u4f1a\u67e5\u627e\u4e0e\u6b64\u6a21\u5f0f\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002
pos
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u4ece\u54ea\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u4ece\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002
occurrence
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u7b2c\u51e0\u6b21\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u8fd4\u56de\u7b2c\u4e00\u6b21\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u6b64\u503c\u4e3a\u975e\u96f6\u503c n\uff0c\u5c06\u8fd4\u56de\u7b2c n \u6b21\u51fa\u73b0\u7684\u5339\u914d\u5b57\u7b26\u4e32\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_SUBSTR('1a 2b 3c', '[0-9]a');\n+---------------------------------+\n| regexp_substr(1a 2b 3c, [0-9]a) |\n+---------------------------------+\n| 1a |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_SUBSTR('Lend for land', '^C') Result;\n+--------+\n| Result |\n+--------+\n| NULL |\n+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/","title":"UNNEST()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UNNEST
\u51fd\u6570\u7528\u4e8e\u5c06 JSON \u7c7b\u578b\u6570\u636e\u5185\u7684\u6570\u7ec4\u7c7b\u578b\u7684\u5217\u6216\u53c2\u6570\u5c55\u5f00\u4e3a\u4e00\u4e2a\u8868\u3002\u5b83\u5c06 JSON \u7c7b\u578b\u6570\u636e\u4e2d\u7684\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u62c6\u5206\u6210\u5355\u72ec\u7684\u884c\uff0c\u4f7f\u5f97\u53ef\u4ee5\u5bf9\u6570\u7ec4\u5143\u7d20\u8fdb\u884c\u5355\u72ec\u7684\u5904\u7406\u6216\u4e0e\u5176\u4ed6\u8868\u8fdb\u884c\u8fde\u63a5\u64cd\u4f5c\u3002
\u5f53\u8f93\u5165\u7a7a\u6570\u7ec4\u65f6\uff0cUNNEST
\u51fd\u6570\u8fd4\u56de\u7a7a\u8868\uff0c\u56e0\u4e3a\u6ca1\u6709\u5143\u7d20\u53ef\u4ee5\u5c55\u5f00\u3002
\u5f53\u8f93\u5165 NULL
\u503c\u65f6\uff0cUNNEST
\u51fd\u6570\u8fd4\u56de\u7a7a\u8868\uff0c\u56e0\u4e3a NULL
\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684\u6570\u7ec4\u3002
> UNNEST(array_expression)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e array_expression \u5fc5\u8981\u53c2\u6570\u3002\u662f\u4e00\u4e2a JSON \u6570\u636e\u5185\u7684\u6570\u7ec4\uff0c\u53ef\u4ee5\u662f\u6570\u7ec4\u5217\u3001\u6570\u7ec4\u5e38\u91cf\u6216\u6570\u7ec4\u51fd\u6570\u7684\u8fd4\u56de\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#_4","title":"\u793a\u4f8b","text":"-- \u5c06\u4e00\u4e2a\u5305\u542b JSON \u5bf9\u8c61\u7684\u5b57\u7b26\u4e32\u6570\u7ec4\u8fdb\u884c\u5c55\u5f00\uff0c'{\"a\":1}' \u662f\u4e00\u4e2a\u5305\u542b\u5355\u4e2a\u5143\u7d20\u7684\u5b57\u7b26\u4e32\u6570\u7ec4\u3002\u8fd9\u4e2a\u5143\u7d20\u662f\u4e00\u4e2a\u8868\u793a JSON \u5bf9\u8c61\u7684\u5b57\u7b26\u4e32\u3002\n> select * from unnest('{\"a\":1}') u;\n+----------------+------+------+------+-------+-------+----------+\n| col | seq | key | path | index | value | this |\n+----------------+------+------+------+-------+-------+----------+\n| UNNEST_DEFAULT | 0 | a | $.a | NULL | 1 | {\"a\": 1} |\n+----------------+------+------+------+-------+-------+----------+\n1 row in set (0.00 sec)\n\n-- \u5bf9\u4e00\u4e2a\u5305\u542b\u6574\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4 '[1,2,3]' \u8fdb\u884c\u5c55\u5f00\uff0c\u5e76\u4f7f\u7528\u522b\u540d u \u4ee3\u8868\u5c55\u5f00\u540e\u7684\u5217\u3002\n> select * from unnest('[1,2,3]') u;\n+----------------+------+------+------+-------+-------+-----------+\n| col | seq | key | path | index | value | this |\n+----------------+------+------+------+-------+-------+-----------+\n| UNNEST_DEFAULT | 0 | NULL | $[0] | 0 | 1 | [1, 2, 3] |\n| UNNEST_DEFAULT | 0 | NULL | $[1] | 1 | 2 | [1, 2, 3] |\n| UNNEST_DEFAULT | 0 | NULL | $[2] | 2 | 3 | [1, 2, 3] |\n+----------------+------+------+------+-------+-------+-----------+\n3 rows in set (0.00 sec)\n\n-- \u5bf9\u4e00\u4e2a\u5305\u542b\u6574\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4 '[1,2,3]' \u8fdb\u884c\u5c55\u5f00\uff0c\u5e76\u9009\u62e9\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u4f5c\u4e3a\u7ed3\u679c\u96c6\u7684\u4e00\u90e8\u5206\u8fd4\u56de\u3002'$[0]' \u662f\u4e00\u4e2a\u6307\u5b9a\u8981\u9009\u62e9\u7684\u6570\u7ec4\u5143\u7d20\u7684\u8def\u5f84\u8868\u8fbe\u5f0f\uff0ctrue \u662f\u4e00\u4e2a\u6307\u793a\u662f\u5426\u8fd4\u56de\u8def\u5f84\u7684\u5e03\u5c14\u503c\uff0c\u5e76\u4f7f\u7528\u522b\u540d u \u4ee3\u8868\u5c55\u5f00\u540e\u7684\u5217\u3002\n> select * from unnest('[1,2,3]','$[0]',true) u;\n+----------------+------+------+------+-------+-------+------+\n| col | seq | key | path | index | value | this |\n+----------------+------+------+------+-------+-------+------+\n| UNNEST_DEFAULT | 0 | NULL | $[0] | NULL | NULL | 1 |\n+----------------+------+------+------+-------+-------+------+\n1 row in set (0.00 sec)\n
create table t1 (a json,b int);\ninsert into t1 values ('{\"a\":1,\"b\":[{\"c\":2,\"d\":3},false,4],\"e\":{\"f\":true,\"g\":[null,true,1.1]}}',1);\ninsert into t1 values ('[1,true,false,null,\"aaa\",1.1,{\"t\":false}]',2);\n> select * from t1;\n+---------------------------------------------------------------------------------------+------+\n| a | b |\n+---------------------------------------------------------------------------------------+------+\n| {\"a\": 1, \"b\": [{\"c\": 2, \"d\": 3}, false, 4], \"e\": {\"f\": true, \"g\": [null, true, 1.1]}} | 1 |\n| [1, true, false, null, \"aaa\", 1.1, {\"t\": false}] | 2 |\n+---------------------------------------------------------------------------------------+------+\n2 rows in set (0.00 sec)\n\n-- \u4ece\u8868 t1 \u4e2d\u5c55\u5f00\u6570\u7ec4 t1.a \u7684\u5143\u7d20\uff0c\u5e76\u9009\u62e9\u5c55\u5f00\u540e\u7684\u5143\u7d20\u4f5c\u4e3a\u7ed3\u679c\u96c6\u7684\u4e00\u90e8\u5206\u8fd4\u56de\u3002\"$a\" \u662f\u4e00\u4e2a\u6307\u5b9a\u8981\u9009\u62e9\u7684\u6570\u7ec4\u5143\u7d20\u7684\u8def\u5f84\u8868\u8fbe\u5f0f\uff1btrue \u662f\u4e00\u4e2a\u6307\u793a\u662f\u5426\u8fd4\u56de\u8def\u5f84\u7684\u5e03\u5c14\u503c\uff1b\u4f7f\u7528 f.* \u8868\u793a\u9009\u62e9\u5c55\u5f00\u540e\u7684\u6240\u6709\u5217\uff1bf \u662f UNNEST \u51fd\u6570\u7684\u522b\u540d\uff0c\u4ee3\u8868\u5c55\u5f00\u540e\u7684\u7ed3\u679c\nmysql> select f.* from t1,unnest(t1.a, \"$.a\", true) as f;\n+------+------+------+------+-------+-------+------+\n| col | seq | key | path | index | value | this |\n+------+------+------+------+-------+-------+------+\n| t1.a | 0 | NULL | $.a | NULL | NULL | 1 |\n| t1.a | 0 | NULL | $.a | NULL | NULL | 1 |\n+------+------+------+------+-------+-------+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/","title":"\u7b97\u672f\u8fd0\u7b97\u7b26","text":"MatrixOne \u652f\u6301\u57fa\u672c\u7684\u7b97\u672f\u8fd0\u7b97\u7b26\uff0c\u5982\u5411\u91cf\u95f4\u6216\u5411\u91cf\u548c\u6807\u91cf\u95f4\u7684\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u4e58\u6cd5\u548c\u9664\u6cd5\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u6267\u884c\u9010\u5143\u7d20\u7684\u7b97\u672f\u64cd\u4f5c\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5411\u91cf\u3002
Note
\u51cf\u6cd5\uff08-
\uff09\u3001\u4e58\u6cd5\uff08*
\uff09\u548c\u9664\u6cd5\uff08/
\uff09\u90fd\u4e0e\u52a0\u6cd5\u793a\u4f8b\u7c7b\u4f3c\uff0c\u4e0d\u4f5c\u8d58\u8ff0\u3002
+
\u7528\u4e8e\u5c06\u4e24\u4e2a\u5143\u7d20\u76f8\u52a0\u3002
> SELECT para1 + para2\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_4","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b + \"[1,2,3]\" from vec_table;\n+-------------+\n| b + [1,2,3] |\n+-------------+\n| [2, 4, 6] |\n+-------------+\n1 row in set (0.00 sec)\n\nmysql> select b + 1 from vec_table;\n+-----------+\n| b + 1 |\n+-----------+\n| [2, 3, 4] |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select cast(\"[1,2,3]\" as vecf32(3)) + 5.0;\n+----------------------------------+\n| cast([1,2,3] as vecf32(3)) + 5.0 |\n+----------------------------------+\n| [6, 7, 8] |\n+----------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_5","title":"\u9650\u5236","text":"/
\u7528\u4e8e\u5c06\u4e24\u4e2a\u5411\u91cf\u5143\u7d20\u76f8\u9664\u3002
> SELECT para1 / para2\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_8","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b/b from vec_table;\n+-----------+\n| b / b |\n+-----------+\n| [1, 1, 1] |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> select cast(\"[1,2,3]\" as vecf32(3)) / b from vec_table;;\n+--------------------------------+\n| cast([1,2,3] as vecf32(3)) / b |\n+--------------------------------+\n| [1, 1, 1] |\n+--------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select b/2 from vec_table;\n+---------------+\n| b / 2 |\n+---------------+\n| [0.5, 1, 1.5] |\n+---------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_9","title":"\u9650\u5236","text":"CLUSTER_CENTERS()
\u51fd\u6570\u53ef\u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u5217\u7684 K \u4e2a\u805a\u7c7b\u4e2d\u5fc3\u3002\u8fd4\u56de\u4e00\u884c JSON \u6570\u7ec4\u5b57\u7b26\u4e32\uff0c\u5305\u542b\u6240\u6709\u805a\u7c7b\u4e2d\u5fc3\u3002
SELECT cluster_centers(col kmeans 'k, op_type, init_type, normalize') FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cluster_centers/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e col \u5fc5\u9700\u7684\u3002\u8981\u786e\u5b9a\u805a\u7c7b\u4e2d\u5fc3\u7684\u5411\u91cf\u5217\u3002 k \u5fc5\u9700\u7684\u3002\u8981\u5c06\u6570\u636e\u96c6\u5206\u6210\u7684\u7c07\u7684\u6570\u91cf\uff0c\u5927\u4e8e 0\uff0c\u5c0f\u4e8e\u7b49\u4e8e\u603b\u884c\u6570\u3002 op_type \u5fc5\u9700\u7684\u3002\u5728\u805a\u7c7b\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7684\u8ddd\u79bb\u51fd\u6570\u3002\u76ee\u524d\u652f\u6301 vector_l2_ops\u3002 init_type \u5fc5\u9700\u7684\u3002\u8981\u4f7f\u7528\u7684\u521d\u59cb\u5316\u805a\u7c7b\u4e2d\u5fc3\u7b97\u6cd5\u3002\u76ee\u524d\u6211\u4eec\u652f\u6301 random \u548c kmeanspluspus(K-means++)\u3002 normalize \u5fc5\u9700\u7684\u3002\u5e03\u5c14\u503c\uff0c\u8981\u4f7f\u7528\u7684\u805a\u7c7b\u7b97\u6cd5\uff0ctrue \u4ee3\u8868 Spherical Kmeans\uff0cfalse \u4ee3\u8868 Regular Kmeans\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cluster_centers/#_4","title":"\u793a\u4f8b","text":"drop table if exists points;\nCREATE TABLE points (id int auto_increment PRIMARY KEY,coordinate vecf32(2));\ninsert into points(coordinate) VALUES\n(\"[-7.68905443,6.62034649]\"),\n(\"[-9.57651383,-6.93440446]\"),\n(\"[6.82968177,1.1648714]\"),\n(\"[-2.90130578,7.55077118]\"),\n(\"[-5.67841327,-7.28818497]\"),\n(\"[-6.04929137,-7.73619342]\"),\n(\"[-6.27824322,7.22746302]\");\nSET GLOBAL experimental_ivf_index = 1;--\u9700\u8bbe\u7f6e\u53c2\u6570 experimental_ivf_index \u503c\u4e3a 1\uff08\u9ed8\u8ba4 0\uff09\u624d\u80fd\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\n--create index idx_t1 using ivfflat on points(coordinate) lists=1 op_type \"vector_l2_ops\";\n\n-- \u6bcf\u4e2a\u70b9\u4ee3\u8868\u5176\u5728 x \u548c y \u8f74\u4e0a\u7684\u5750\u6807\uff0c\u67e5\u8be2\u805a\u7c7b\u4e2d\u5fc3\uff0c\u4f7f\u7528 Regular Kmeans\n--K-means++\nmysql> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,kmeansplusplus,false') AS centers FROM points;\n+----------------------------------------------------+\n| centers |\n+----------------------------------------------------+\n| [ [-2.5097303, 5.640863],[-7.101406, -7.3195944] ] |\n+----------------------------------------------------+\n1 row in set (0.01 sec)\n\n--KMeans\nmysql> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,random,false') AS centers FROM points;\n+----------------------------------------------------+\n| centers |\n+----------------------------------------------------+\n| [ [-6.362137, -0.09336702],[6.829682, 1.1648715] ] |\n+----------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u6bcf\u4e2a\u70b9\u4ee3\u8868\u7ecf\u7eac\u5ea6\u5750\u6807\uff0c\u67e5\u8be2\u805a\u7c7b\u4e2d\u5fc3\uff0c\u4f7f\u7528 Spherical Kmeans\nmysql> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,kmeansplusplus,true') AS centers FROM points;\n+------------------------------------------------------+\n| centers |\n+------------------------------------------------------+\n| [ [0.70710677, 0.70710677],[0.83512634, 0.5500581] ] |\n+------------------------------------------------------+\n1 row in set (0.00 sec)\n\n--\u53ef\u7ed3\u5408 CROSS JOIN \u548c UNNEST \u8bed\u6cd5\u5c06 JSON \u7c7b\u578b\u6570\u636e\u5185\u7684\u805a\u7c7b\u4e2d\u5fc3\u53d6\u51fa\u6765\u3002\nmysql> SELECT value FROM (\n-> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,kmeansplusplus,false') AS centers FROM points\n-> ) AS subquery -> CROSS JOIN UNNEST(subquery.centers) AS u;\n+-------------------------+\n| value |\n+-------------------------+\n| [-2.5097303, 5.640863] |\n| [-7.101406, -7.3195944] |\n+-------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/","title":"COSINE_DISTANCE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COSINE_DISTANCE()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u8ddd\u79bb\u3002
\u4f59\u5f26\u8ddd\u79bb\uff08Cosine Distance\uff09\u662f\u4e00\u79cd\u8861\u91cf\u4e24\u4e2a\u5411\u91cf\u5728\u65b9\u5411\u4e0a\u7684\u5dee\u5f02\u7684\u5ea6\u91cf\u65b9\u5f0f\uff0c\u901a\u5e38\u5b9a\u4e49\u4e3a 1 \u51cf\u53bb\u4f59\u5f26\u76f8\u4f3c\u5ea6 (Cosine Similarity)\u3002\u4f59\u5f26\u8ddd\u79bb\u7684\u503c\u8303\u56f4\u5728 0 \u5230 2 \u4e4b\u95f4\u30020 \u8868\u793a\u4e24\u4e2a\u5411\u91cf\u7684\u65b9\u5411\u5b8c\u5168\u76f8\u540c\uff08\u8ddd\u79bb\u6700\u5c0f\uff09\u30022 \u8868\u793a\u4e24\u4e2a\u5411\u91cf\u7684\u65b9\u5411\u5b8c\u5168\u76f8\u53cd\uff08\u8ddd\u79bb\u6700\u5927\uff09\u3002\u5728\u6587\u672c\u5206\u6790\u4e2d\uff0c\u4f59\u5f26\u8ddd\u79bb\u53ef\u4ee5\u7528\u6765\u8861\u91cf\u6587\u6863\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\u3002\u7531\u4e8e\u5b83\u53ea\u8003\u8651\u5411\u91cf\u7684\u65b9\u5411\u800c\u4e0d\u8003\u8651\u957f\u5ea6\uff0c\u56e0\u6b64\u5bf9\u4e8e\u957f\u6587\u672c\u548c\u77ed\u6587\u672c\u4e4b\u95f4\u7684\u6bd4\u8f83\u662f\u516c\u5e73\u7684\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT COSINE_DISTANCE(vector1, vector2) FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.01 sec)\n\nmysql> select cosine_distance(b,c) from vec_table;\n+-----------------------+\n| cosine_distance(b, c) |\n+-----------------------+\n| 0.0253681538029239 |\n+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> select cosine_distance(b,\"[1,2,3]\") from vec_table;\n+-----------------------------+\n| cosine_distance(b, [1,2,3]) |\n+-----------------------------+\n| 0 |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> select cosine_distance(b,\"[-1,-2,-3]\") from vec_table;\n+--------------------------------+\n| cosine_distance(b, [-1,-2,-3]) |\n+--------------------------------+\n| 2 |\n+--------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_4","title":"\u9650\u5236","text":"\u5728\u4f7f\u7528 COSINE_DISTANCE()
\u51fd\u6570\u65f6\uff0c\u8f93\u5165\u5411\u91cf\u4e0d\u5141\u8bb8\u4e3a 0 \u5411\u91cf\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u51fa\u73b0\u9664\u4ee5\u96f6\u7684\u60c5\u51b5\uff0c\u8fd9\u5728\u6570\u5b66\u4e0a\u662f\u672a\u5b9a\u4e49\u7684\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u8ba4\u4e3a\u96f6\u5411\u91cf\u4e0e\u4efb\u4f55\u5176\u4ed6\u5411\u91cf\u7684\u4f59\u5f26\u76f8\u4f3c\u5ea6\u4e3a 0\uff0c\u56e0\u4e3a\u5b83\u4eec\u4e4b\u95f4\u6ca1\u6709\u4efb\u4f55\u65b9\u5411\u4e0a\u7684\u76f8\u4f3c\u6027\u3002
cosine_similarity()
\u662f\u4f59\u5f26\u76f8\u4f3c\u5ea6\uff0c\u5b83\u8861\u91cf\u4e86\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u5939\u89d2\u7684\u4f59\u5f26\u503c\uff0c\u901a\u8fc7\u5b83\u4eec\u5728\u591a\u7ef4\u7a7a\u95f4\u4e2d\u7684\u63a5\u8fd1\u7a0b\u5ea6\u6765\u8868\u793a\u5b83\u4eec\u7684\u76f8\u4f3c\u6027\uff0c\u5176\u4e2d 1 \u8868\u793a\u5b8c\u5168\u76f8\u4f3c\uff0c-1 \u8868\u793a\u5b8c\u5168\u4e0d\u76f8\u4f3c\u3002\u4f59\u5f26\u76f8\u4f3c\u5ea6\u7684\u8ba1\u7b97\u662f\u901a\u8fc7\u5c06\u4e24\u4e2a\u5411\u91cf\u7684\u5185\u79ef\u9664\u4ee5\u5b83\u4eec\u7684 l2 \u8303\u6570\u7684\u4e58\u79ef\u6765\u5b9e\u73b0\u7684\u3002
> SELECT cosine_similarity(vector1, vector2) AS similarity FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_similarity/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select cosine_similarity(b,\"[1,2,3]\") from vec_table;\n+-------------------------------+\n| cosine_similarity(b, [1,2,3]) |\n+-------------------------------+\n| 1 |\n+-------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_similarity/#_4","title":"\u9650\u5236","text":"INNER PRODUCT
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u5185\u79ef/\u70b9\u79ef\uff0c\u5b83\u662f\u4e24\u4e2a\u5411\u91cf\u7684\u5bf9\u5e94\u5143\u7d20\u76f8\u4e58\u7136\u540e\u76f8\u52a0\u7684\u7ed3\u679c\u3002
> SELECT inner_product(vector1, vector2) AS result FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/inner_product/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select inner_product(b,\"[1,2,3]\") from vec_table;\n+---------------------------+\n| inner_product(b, [1,2,3]) |\n+---------------------------+\n| 14 |\n+---------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/inner_product/#_4","title":"\u9650\u5236","text":"\u4e24\u4e2a\u53c2\u6570\u5411\u91cf\u5fc5\u987b\u5177\u6709\u76f8\u540c\u7684\u7ef4\u5ea6\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm/","title":"l1_norm()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"l1_norm
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97 l1
/\u66fc\u54c8\u987f/TaxiCab \u8303\u6570\u3002l1
\u8303\u6570\u901a\u8fc7\u5bf9\u5411\u91cf\u5143\u7d20\u7684\u7edd\u5bf9\u503c\u6c42\u548c\u5f97\u5230\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 l1
\u8303\u6570\u6765\u8ba1\u7b97 l1
\u8ddd\u79bb\u3002
l1_distance(a,b) = l1_norm(a-b)\n
\u8fd9\u6837\u7684\u8ba1\u7b97\u65b9\u5f0f\u540c\u6837\u9002\u7528\u4e8e\u4ece l2_Norm
\u8ba1\u7b97 l2
\u8ddd\u79bb\u3002
> SELECT l1_norm(vector) AS result FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select l1_norm(b) from vec_table;\n+------------+\n| l1_norm(b) |\n+------------+\n| 6 |\n+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/","title":"L2_DISTANCE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"L2_DISTANCE()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb\u3002\u8fd4\u56de\u4e00\u4e2a FLOAT64 \u7c7b\u578b\u7684\u503c\u3002
L2 \u8ddd\u79bb (l2 distance)\uff0c\u4e5f\u88ab\u79f0\u4e3a\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb\uff08Euclidean Distance\uff09\uff0c\u662f\u5411\u91cf\u7a7a\u95f4\u4e2d\u6700\u5e38\u7528\u7684\u8ddd\u79bb\u5ea6\u91cf\u65b9\u5f0f\u4e4b\u4e00\u3002\u5b83\u6d4b\u91cf\u7684\u662f\u591a\u7ef4\u7a7a\u95f4\u4e2d\u4e24\u70b9\u4e4b\u95f4\u7684\u76f4\u7ebf\u8ddd\u79bb\u3002l2 distance \u8ddd\u79bb\u5177\u6709\u8bb8\u591a\u5b9e\u9645\u5e94\u7528\uff0c\u5305\u62ec\u673a\u5668\u5b66\u4e60\u3001\u8ba1\u7b97\u673a\u89c6\u89c9\u548c\u7a7a\u95f4\u5206\u6790\u7b49\u9886\u57df\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT L2_DISTANCE(vector, const_vector) FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\"),(2, \"[1,1,1]\", \"[2,2,2]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n| 2 | [1, 1, 1] | [2, 2, 2] |\n+------+-----------+-----------+\n2 rows in set (0.00 sec)\n\nmysql> select l2_distance(b,c) from vec_table;\n+--------------------+\n| l2_distance(b, c) |\n+--------------------+\n| 5.196152422706632 |\n| 1.7320508075688772 |\n+--------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm/","title":"l2_norm()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"l2_norm
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97 l2
/\u6b27\u51e0\u91cc\u5f97\u8303\u6570\u3002l2
\u8303\u6570\u901a\u8fc7\u5bf9\u5411\u91cf\u5143\u7d20\u7684\u5e73\u65b9\u548c\u8fdb\u884c\u5e73\u65b9\u6839\u8fd0\u7b97\u5f97\u5230\u3002
> SELECT l2_norm(vector) AS result FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select l2_norm(b) from vec_table;\n+--------------------+\n| l2_norm(b) |\n+--------------------+\n| 3.7416573867739413 |\n+--------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/","title":"\u6570\u5b66\u7c7b\u51fd\u6570","text":"\u5411\u91cf\u652f\u6301\u4ee5\u4e0b\u6570\u5b66\u7c7b\u51fd\u6570\uff1a
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#sqrt","title":"SQRT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_2","title":"\u51fd\u6570\u8bf4\u660e","text":"sqrt
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u6839\u3002
> SELECT sqrt(vector_column) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_4","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684 vecf64 \u7c7b\u578b\u7684\u5411\u91cf\uff0c\u5176\u4e2d\u5305\u542b\u539f\u59cb\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u6839\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_5","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select sqrt(b) from vec_table;\n+---------------------------------------------+\n| sqrt(b) |\n+---------------------------------------------+\n| [1, 1.4142135623730951, 1.7320508075688772] |\n+---------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_6","title":"\u9650\u5236","text":"abs
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u7684\u7edd\u5bf9\u503c\u3002
> SELECT ABS(vector_column) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_9","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8fd4\u56de\u4e00\u4e2a\u76f8\u540c\u7c7b\u578b\u7684\u65b0\u5411\u91cf\uff0c\u5176\u4e2d\u5305\u542b\u539f\u59cb\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u7edd\u5bf9\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_10","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[-1,-2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-------------+-----------+\n| a | b | c |\n+------+-------------+-----------+\n| 1 | [-1, -2, 3] | [4, 5, 6] |\n+------+-------------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select abs(b) from vec_table;\n+-----------+\n| abs(b) |\n+-----------+\n| [1, 2, 3] |\n+-----------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#cast","title":"CAST","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_11","title":"\u51fd\u6570\u8bf4\u660e","text":"cast \u51fd\u6570\u7528\u4e8e\u663e\u5f0f\u5c06\u4e00\u4e2a\u5411\u91cf\u4ece\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_12","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT CAST(vector AS vector_type) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_13","title":"\u53c2\u6570","text":"vector
\uff1a\u8f93\u5165\u5411\u91cf\u3002vector_type
\uff1a\u65b0\u7684\u5411\u91cf\u7c7b\u578b\u3002\u65b0\u7684 vector_type
\u5411\u91cf\u3002
drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b + cast(\"[1,2,3]\" as vecf32(3)) from vec_table;\n+--------------------------------+\n| b + cast([1,2,3] as vecf32(3)) |\n+--------------------------------+\n| [2, 4, 6] |\n+--------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#summation","title":"SUMMATION","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_16","title":"\u51fd\u6570\u8bf4\u660e","text":"summation
\u51fd\u6570\u8fd4\u56de\u5411\u91cf\u4e2d\u6240\u6709\u5143\u7d20\u7684\u603b\u548c\u3002
> SELECT SUMMATION(vector_column) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_18","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8fd4\u56de\u4e00\u4e2a FLOAT64 \u503c\uff0c\u5373\u5411\u91cf\u4e2d\u6240\u6709\u5143\u7d20\u7684\u603b\u548c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_19","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select summation(b) from vec_table;\n+--------------+\n| summation(b) |\n+--------------+\n| 6 |\n+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/","title":"NORMALIZE_L2()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"NORMALIZE_L2()
\u51fd\u6570\u5bf9\u5411\u91cf\u6267\u884c\u6b27\u51e0\u91cc\u5f97\u5f52\u4e00\u5316 (L2 normalization)\u3002
L2 \u8303\u6570\u662f\u5411\u91cf\u5143\u7d20\u5e73\u65b9\u548c\u7684\u5e73\u65b9\u6839\uff0c\u56e0\u6b64 L2 normalization \u7684\u76ee\u7684\u662f\u4f7f\u5411\u91cf\u7684\u957f\u5ea6\uff08\u6216\u8303\u6570\uff09\u4e3a 1\uff0c\u8fd9\u901a\u5e38\u88ab\u79f0\u4e3a\u5355\u4f4d\u5411\u91cf\u3002\u8fd9\u79cd\u5f52\u4e00\u5316\u65b9\u6cd5\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7279\u522b\u6709\u7528\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u7279\u5f81\u5411\u91cf\u65f6\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6807\u51c6\u5316\u7279\u5f81\u7684\u5c3a\u5ea6\uff0c\u4ece\u800c\u63d0\u9ad8\u7b97\u6cd5\u7684\u6027\u80fd\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT NORMALIZE_L2(vector_column) FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select normalize_l2(b) from vec_table;\n+-------------------------------------+\n| normalize_l2(b) |\n+-------------------------------------+\n| [0.26726124, 0.5345225, 0.80178374] |\n+-------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/","title":"SUBVECTOR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SUBVECTOR()
\u51fd\u6570\u7528\u4e8e\u4ece\u5411\u91cf\u4e2d\u63d0\u53d6\u5b50\u5411\u91cf\u3002
> SUBVECTOR(vec, pos, len)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e vec \u5fc5\u9700\u53c2\u6570\u3002\u4ece\u4e2d\u63d0\u53d6\u5b50\u5411\u91cf\u7684\u6e90\u5411\u91cf pos \u5fc5\u9700\u53c2\u6570\u3002\u5f00\u59cb\u63d0\u53d6\u7684\u4f4d\u7f6e\u3002\u5411\u91cf\u4e2d\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u662f 1\uff0c\u5982\u679c pos \u4e3a\u6b63\uff0c\u5219\u51fd\u6570\u4ece\u5411\u91cf\u7684\u5f00\u5934\u63d0\u53d6\u3002\u5982\u679c pos \u4e3a\u8d1f\uff0c\u5219\u63d0\u53d6\u662f\u4ece\u5411\u91cf\u7684\u672b\u5c3e\u5f00\u59cb\u3002 len \u53ef\u9009\u53c2\u6570\u3002\u8981\u63d0\u53d6\u7684\u7ef4\u5ea6\u6570\u3002\u9ed8\u8ba4\u4ece\u4f4d\u7f6e pos \u5f00\u59cb\u5230\u5411\u91cf\u672b\u5c3e\u7684\u5b50\u5411\u91cf\u3002\u5982\u679c len \u5c0f\u4e8e 1\uff0c\u5219\u8fd4\u56de\u7a7a\u5411\u91cf\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT SUBVECTOR(\"[1,2,3]\", 2);\n+-----------------------+\n| subvector([1,2,3], 2) |\n+-----------------------+\n| [2, 3] |\n+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT SUBVECTOR(\"[1,2,3]\",-1,1);\n+---------------------------+\n| subvector([1,2,3], -1, 1) |\n+---------------------------+\n| [3] |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT SUBVECTOR(\"[1,2,3]\",-1,0);\n+---------------------------+\n| subvector([1,2,3], -1, 0) |\n+---------------------------+\n| [] |\n+---------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims/","title":"vector_dims()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"vector_dims
\u51fd\u6570\u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u7684\u7ef4\u5ea6\u3002
> SELECT vector_dims(vector) AS dimension_count FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\ninsert into vec_table values(2, \"[7,8,9]\", \"[1,2,3]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n| 2 | [7, 8, 9] | [1, 2, 3] |\n+------+-----------+-----------+\n2 row in set (0.00 sec)\n\nmysql> select vector_dims(b) from vec_table;\n+----------------+\n| vector_dims(b) |\n+----------------+\n| 3 |\n| 3 |\n+----------------+\n2 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/","title":"DENSE_RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"DENSE_RANK()
\u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\uff0c\u4e0e RANK() \u51fd\u6570\u975e\u5e38\u76f8\u4f3c\u3002DENSE_RANK()
\u51fd\u6570\u9996\u5148\u6839\u636e ORDER BY \u5b50\u53e5\u4e2d\u6307\u5b9a\u7684\u5217\u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\u3002
DENSE_RANK()
\u51fd\u6570\u5904\u7406\u5e73\u5c40\uff08\u5373\u4e24\u884c\u6216\u66f4\u591a\u884c\u5177\u6709\u76f8\u540c\u7684\u503c\uff09\u7684\u65b9\u5f0f\u4e0e RANK()
\u51fd\u6570\u7565\u6709\u4e0d\u540c\u3002\u5728\u5b58\u5728\u5e73\u5c40\u7684\u60c5\u51b5\u4e0b\uff0cDENSE_RANK()
\u4f1a\u4e3a\u5177\u6709\u76f8\u540c\u503c\u7684\u6240\u6709\u884c\u8d4b\u4e88\u76f8\u540c\u7684\u6392\u540d\uff0c\u4f46\u662f\u4e0d\u4f1a\u8df3\u8fc7\u7d27\u968f\u5176\u540e\u7684\u4efb\u4f55\u6392\u540d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e24\u884c\u83b7\u5f97\u6392\u540d 1\uff0c\u90a3\u4e48\u4e0b\u4e00\u884c\u5c06\u83b7\u5f97\u6392\u540d 2\uff0c\u800c\u4e0d\u662f 3\u3002
> DENSE_RANK() OVER (\n [PARTITION BY column_1, column_2, ... ]\n ORDER BY column_3, column_4, ...\n)\n
PARTITION BY
\u5b50\u53e5\u662f\u53ef\u9009\u7684\uff0c\u5b83\u5c06\u6570\u636e\u96c6\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u5355\u72ec\u8ba1\u7b97\u6392\u540d\u3002ORDER BY
\u5b50\u53e5\u5b9a\u4e49\u4e86\u6570\u636e\u96c6\u7684\u6392\u5e8f\u65b9\u5f0f\uff0c\u5373\u6839\u636e\u54ea\u4e00\u5217\u6216\u54ea\u4e9b\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a'SalesTable'\u7684\u8868\uff0c\u5b83\u6709\u4e09\u4e2a\u5b57\u6bb5\uff1a'Department'\uff0c'Employee'\u548c'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- \u5411'SalesTable'\u8868\u63d2\u5165\u6570\u636e\uff0c\u6bcf\u4e00\u884c\u90fd\u5305\u542b\u4e00\u4e2a\u90e8\u95e8\uff08'Department'\uff09\u3001\u4e00\u4e2a\u5458\u5de5\u59d3\u540d\uff08'Employee'\uff09\u548c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff08'Sales'\uff09\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- \u67e5\u8be2'SalesTable'\u8868\uff0c\u8fd4\u56de\u5458\u5de5\u7684\u540d\u5b57\uff0c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff0c\u4ee5\u53ca\u4ed6\u4eec\u7684\u9500\u552e\u6392\u540d\uff08\u4f7f\u7528'DENSE_RANK()'\u51fd\u6570\uff09\n-- \u5728\u8fd9\u4e2a\u67e5\u8be2\u4e2d\uff0c'DENSE_RANK()'\u51fd\u6570\u6839\u636e\u9500\u552e\u989d\u7684\u964d\u5e8f\uff08\u7531'ORDER BY Sales DESC'\u6307\u5b9a\uff09\u5bf9\u6240\u6709\u5458\u5de5\u8fdb\u884c\u6392\u540d\n-- \u5982\u679c\u591a\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u76f8\u540c\uff0c\u4ed6\u4eec\u4f1a\u5f97\u5230\u76f8\u540c\u7684\u6392\u540d\uff0c\u5e76\u4e14\u4e0b\u4e00\u4e2a\u9500\u552e\u989d\u7684\u6392\u540d\u4e0d\u4f1a\u8df3\u8fc7\u3002\u6240\u4ee5\uff0c\u5982\u679c\u6709\u4e24\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u90fd\u662f\u7b2c\u4e00\uff0c\u90a3\u4e48\u4e0b\u4e00\u4e2a\u5458\u5de5\u7684\u6392\u540d\u5c31\u662f\u7b2c\u4e8c\uff0c\u800c\u4e0d\u662f\u7b2c\u4e09\u3002\nmysql> SELECT\nEmployee,\nSales,\nDENSE_RANK() OVER(ORDER BY Sales DESC) FROM\nSalesTable;\n+----------+-------+-----------------------------------------+\n| employee | sales | dense_rank() over (order by sales desc) |\n+----------+-------+-----------------------------------------+\n| Jane | 1200 | 1 |\n| Bob | 1100 | 2 |\n| John | 1000 | 3 |\n| Alex | 900 | 4 |\n| Charlie | 850 | 5 |\n| Alice | 800 | 6 |\n+----------+-------+-----------------------------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/","title":"RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"RANK()
\u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\u3002RANK()
\u9996\u5148\u6839\u636e ORDER BY
\u5b50\u53e5\u4e2d\u6307\u5b9a\u7684\u5217\u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\u3002
RANK()
\u51fd\u6570\u5728\u5904\u7406\u76f8\u540c\u503c\uff08\u5373\u5e73\u5c40\uff09\u7684\u60c5\u51b5\u65f6\uff0c\u6709\u4e00\u4e2a\u7279\u6b8a\u7684\u884c\u4e3a\uff1a\u5f53\u4e24\u884c\u6216\u66f4\u591a\u884c\u5177\u6709\u76f8\u540c\u7684\u503c\u65f6\uff0c\u5b83\u4eec\u5c06\u83b7\u5f97\u76f8\u540c\u7684\u6392\u540d\u3002\u7136\u540e\uff0c\u5b83\u5c06\u8df3\u8fc7\u7d27\u968f\u5176\u540e\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u6392\u540d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e24\u884c\u83b7\u5f97\u6392\u540d 1\uff0c\u90a3\u4e48\u4e0b\u4e00\u884c\u5c06\u83b7\u5f97\u6392\u540d 3\uff0c\u800c\u4e0d\u662f 2\u3002
> RANK() OVER (\n [PARTITION BY column_1, column_2, ... ]\n ORDER BY column_3, column_4, ...\n)\n
PARTITION BY
\u5b50\u53e5\u662f\u53ef\u9009\u7684\uff0c\u5b83\u5c06\u6570\u636e\u96c6\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u5355\u72ec\u8ba1\u7b97\u6392\u540d\u3002ORDER BY
\u5b50\u53e5\u5b9a\u4e49\u4e86\u6570\u636e\u96c6\u7684\u6392\u5e8f\u65b9\u5f0f\uff0c\u5373\u6839\u636e\u54ea\u4e00\u5217\u6216\u54ea\u4e9b\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868 'SalesTable'\uff0c\u8be5\u8868\u5177\u6709\u4e09\u4e2a\u5b57\u6bb5\uff1a'Department', 'Employee'\u548c 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- \u5411'SalesTable'\u8868\u4e2d\u63d2\u5165\u6570\u636e\uff0c\u6bcf\u884c\u5305\u542b\u4e00\u4e2a\u90e8\u95e8\uff08Department\uff09\u3001\u4e00\u4e2a\u5458\u5de5\uff08Employee\uff09\u548c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff08Sales\uff09\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- \u67e5\u8be2'SalesTable'\u8868\uff0c\u5e76\u8fd4\u56de\u6bcf\u4e2a\u90e8\u95e8\u7684\u6bcf\u4e2a\u5458\u5de5\uff0c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff0c\u4ee5\u53ca\u4ed6\u4eec\u6240\u5728\u90e8\u95e8\u7684\u603b\u9500\u552e\u989d\uff08DepartmentSales\uff09\n-- \u8fd8\u5c06\u8fd4\u56de\u6bcf\u4e2a\u5458\u5de5\u5728\u5176\u6240\u5728\u90e8\u95e8\u7684\u9500\u552e\u989d\u6392\u540d\uff08SalesRank\uff09\n-- \u5bf9\u4e8e\u603b\u9500\u552e\u989d\uff0c\u4f7f\u7528\u7a97\u53e3\u51fd\u6570 SUM()\uff0c\u5e76\u7528'OVER(PARTITION BY Department)'\u5bf9\u6bcf\u4e2a\u90e8\u95e8\u5206\u522b\u8fdb\u884c\u8ba1\u7b97\n-- \u5bf9\u4e8e\u9500\u552e\u989d\u6392\u540d\uff0c\u4f7f\u7528\u7a97\u53e3\u51fd\u6570 RANK()\uff0c\u5e76\u7528'OVER(PARTITION BY Department ORDER BY Sales DESC)'\u5bf9\u6bcf\u4e2a\u90e8\u95e8\u7684\u5458\u5de5\u6839\u636e\u9500\u552e\u989d\u8fdb\u884c\u964d\u5e8f\u6392\u540d\n-- \u5728RANK()\u51fd\u6570\u4e2d\uff0c\u5982\u679c\u4e24\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u76f8\u540c\uff0c\u4ed6\u4eec\u4f1a\u83b7\u5f97\u76f8\u540c\u7684\u6392\u540d\uff0c\u5e76\u4e14\u4e0b\u4e00\u4e2a\u9500\u552e\u989d\u7684\u6392\u540d\u4f1a\u8df3\u8fc7\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6709\u4e24\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u90fd\u662f\u7b2c\u4e00\uff0c\u90a3\u4e48\u4e0b\u4e00\u4e2a\u9500\u552e\u989d\u7684\u6392\u540d\u5c31\u662f\u7b2c\u4e09\uff0c\u800c\u4e0d\u662f\u7b2c\u4e8c\u3002\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR | Charlie | 850 | 1650 | 1 |\n| HR | Alice | 800 | 1650 | 2 |\n| Marketing | Jane | 1200 | 2200 | 1 |\n| Marketing | John | 1000 | 2200 | 2 |\n| Sales | Bob | 1100 | 2000 | 1 |\n| Sales | Alex | 900 | 2000 | 2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/","title":"ROW_NUMBER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ROW_NUMBER()
\u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u5e8f\u53f7\uff0c\u4ece 1 \u5f00\u59cb\uff0c\u76f4\u5230\u7ed3\u679c\u96c6\u7684\u6700\u540e\u4e00\u884c\u3002\u5b83\u9996\u5148\u4f1a\u6839\u636e ORDER BY
\u5b50\u53e5\u4e2d\u6307\u5b9a\u7684\u5217\u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u884c\u53f7\u3002
\u4e0e RANK()
\u548c DENSE_RANK()
\u51fd\u6570\u4e0d\u540c\uff0cROW_NUMBER()
\u5728\u5904\u7406\u5e73\u5c40\uff08\u5373\u4e24\u884c\u6216\u66f4\u591a\u884c\u5177\u6709\u76f8\u540c\u7684\u503c\uff09\u65f6\u4f1a\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e0d\u540c\u7684\u884c\u53f7\u3002
> ROW_NUMBER() OVER (\n [PARTITION BY column_1, column_2, ... ]\n ORDER BY column_3, column_4, ...\n)\n
PARTITION BY
\u5b50\u53e5\u662f\u53ef\u9009\u7684\uff0c\u5b83\u5c06\u6570\u636e\u96c6\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u5355\u72ec\u8ba1\u7b97\u884c\u53f7\u3002ORDER BY
\u5b50\u53e5\u5b9a\u4e49\u4e86\u6570\u636e\u96c6\u7684\u6392\u5e8f\u65b9\u5f0f\uff0c\u5373\u6839\u636e\u54ea\u4e00\u5217\u6216\u54ea\u4e9b\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868 'SalesTable'\uff0c\u8be5\u8868\u5177\u6709\u4e09\u4e2a\u5b57\u6bb5\uff1a'Department', 'Employee'\u548c 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- \u5411'SalesTable'\u8868\u4e2d\u63d2\u5165\u6570\u636e\uff0c\u6bcf\u884c\u5305\u542b\u4e00\u4e2a\u90e8\u95e8\uff08Department\uff09\u3001\u4e00\u4e2a\u5458\u5de5\uff08Employee\uff09\u548c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff08Sales\uff09\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- \u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u5458\u5de5\u7684\u9500\u552e\u989d\u6392\u540d\n-- \u4f7f\u7528 ROW_NUMBER() \u51fd\u6570\u6309\u90e8\u95e8\uff08Department\uff09\u5bf9\u5458\u5de5\u7684\u9500\u552e\u989d\uff08Sales\uff09\u8fdb\u884c\u6392\u540d\n-- ROW_NUMBER() \u51fd\u6570\u5c06\u6570\u636e\u96c6\u6309\u7167\u90e8\u95e8\uff08Department\uff09\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u7136\u540e\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u6309\u7167\u9500\u552e\u989d\uff08Sales\uff09\u7684\u964d\u5e8f\u6392\u5217\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u884c\u53f7\uff08SalesRank\uff09\n-- \u6240\u4ee5\uff0c\u6bcf\u4e2a\u90e8\u95e8\u9500\u552e\u989d\u6700\u9ad8\u7684\u5458\u5de5\u5c06\u83b7\u5f97\u884c\u53f7 1\uff0c\u9500\u552e\u989d\u7b2c\u4e8c\u9ad8\u7684\u5458\u5de5\u5c06\u83b7\u5f97\u884c\u53f7 2\uff0c\u4ee5\u6b64\u7c7b\u63a8\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nROW_NUMBER() OVER (PARTITION BY Department ORDER BY Sales DESC) as SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------+\n| department | employee | sales | SalesRank |\n+------------+----------+-------+-----------+\n| HR | Charlie | 850 | 1 |\n| HR | Alice | 800 | 2 |\n| Marketing | Jane | 1200 | 1 |\n| Marketing | John | 1000 | 2 |\n| Sales | Bob | 1100 | 1 |\n| Sales | Alex | 900 | 2 |\n+------------+----------+-------+-----------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/","title":"CURRENT_ROLE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u7684\u89d2\u8272\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SELECT CURRENT_ROLE();\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#_3","title":"\u793a\u4f8b","text":"mysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin |\n+----------------+\n1 row in set (0.00 sec)\n\n-- \u65b0\u5efa\u4e00\u4e2a\u89d2\u8272\uff0c\u5e76\u4e14\u5207\u6362\u5230\u65b0\u89d2\u8272\ncreate role use_role_1;\ngrant all on database * to use_role_1;\ngrant use_role_1 to root;\nset role use_role_1;\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| use_role_1 |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/","title":"CURRENT_ROLE_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURRENT_ROLE_NAME()
\u7528\u4e8e\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u767b\u5f55\u7684\u7528\u6237\u6240\u62e5\u6709\u7684\u89d2\u8272\u7684\u540d\u79f0\u3002
> CURRENT_ROLE_NAME()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#_3","title":"\u793a\u4f8b","text":"mysql> select current_role_name();\n+---------------------+\n| current_role_name() |\n+---------------------+\n| moadmin |\n+---------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/","title":"CURRENT_USER, CURRENT_USER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u5f53\u524d\u7528\u6237\u8d26\u6237\uff0c\u8fd4\u56de\u7684\u8d26\u6237\u5f62\u5f0f\u4e3a\uff1a\u7528\u6237\u540d@hostname\u3002\u8fd4\u56de\u503c\u662f utf8mb3 \u5b57\u7b26\u96c6\u7684\u5b57\u7b26\u4e32\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SELECT CURRENT_USER();\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#_3","title":"\u793a\u4f8b","text":"mysql> select current_user();\n+----------------+\n| current_user() |\n+----------------+\n| root@0.0.0.0 |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/","title":"CURRENT_USER_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURRENT_USER_NAME()
\u7528\u4e8e\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u767b\u5f55\u7684\u7528\u6237\u540d\u79f0\u3002
> CURRENT_USER_NAME()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#_3","title":"\u793a\u4f8b","text":"mysql> select current_user_name();\n+---------------------+\n| current_user_name() |\n+---------------------+\n| root |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/","title":"PURGE_LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"PURGE_LOG()
\u7528\u4e8e\u5220\u9664\u8bb0\u5f55\u4e8e MatrixOne \u6570\u636e\u5e93\u7cfb\u7edf\u8868\u4e2d\u7684\u65e5\u5fd7\u3002\u8fd4\u56de 0 \u8868\u793a\u5220\u9664\u6210\u529f\uff1b\u5220\u9664\u5931\u8d25\u5219\u8fd4\u56de\u62a5\u9519\u4fe1\u606f\u3002
Note
\u76ee\u524d\uff0c\u4ec5\u6709 root \u7528\u6237\uff08\u5373\u96c6\u7fa4\u7ba1\u7406\u5458\uff0c\u5177\u6709 MOADMIN
\u6743\u9650\uff09\u62e5\u6709\u6267\u884c PURGE_LOG()
\u51fd\u6570\u4ee5\u8fdb\u884c\u65e5\u5fd7\u5220\u9664\u64cd\u4f5c\u7684\u6743\u9650\u3002
> PURGE_LOG('sys_table_name', 'date')\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e 'sys_table_name' \u5f53\u524d\u53ef\u8fdb\u884c\u5220\u9664\u7684\u7cfb\u7edf\u8868\u4ec5\u4e09\u4e2a\uff1ametric\uff0crawlog\uff0cstatement_info\u3002 Note: 'sys_table_name' \u5fc5\u987b\u7528\u5f15\u53f7\u5305\u88f9\u3002 'date' \u9009\u62e9\u65e5\u671f\uff0c\u5220\u9664\u8be5\u65e5\u671f\u4e4b\u524d\u4ea7\u751f\u7684\u65e5\u5fd7\u3002 Note: 'date' \u5fc5\u987b\u7528\u5355\u5f15\u53f7\u5305\u88f9\u3002 Note
MatrixOne \u6709\u4e14\u4ec5\u6709 metric\uff0crawlog\uff0cstatement_info \u4e09\u5f20\u7cfb\u7edf\u65e5\u5fd7\u8868\uff0c\u6709\u5173\u8fd9\u4e09\u5f20\u8868\u7684\u8be6\u7ec6\u4fe1\u606f\u8bf7\u53c2\u8003 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#_4","title":"\u793a\u4f8b","text":"-- \u5220\u9664 2023-06-30 \u8fd9\u4e00\u5929\u4e4b\u524d\u7684 statement_info \u7c7b\u578b\u7684\u65e5\u5fd7\nmysql> select purge_log('statement_info', '2023-06-30') a;\n+------+\n| a |\n+------+\n| 0 |\n+------+\n1 row in set (0.01 sec)\n
-- \u67e5\u8be2 metric \u65e5\u5fd7\u91c7\u96c6\u7684\u65f6\u95f4\u548c\u6570\u91cf\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-07 | 20067 |\n| 2023-07-06 | 30246 |\n| 2023-07-05 | 27759 |\n+-------------------+----------+\n3 rows in set (0.04 sec)\n\n-- \u5220\u9664 2023-07-06 \u8fd9\u4e00\u5929\u4e4b\u524d\u7684 rawlog\uff0cstatement_info\uff0c\u548c metric \u4e09\u79cd\u7c7b\u578b\u7684\u65e5\u5fd7\nmysql> select purge_log('rawlog, statement_info, metric', '2023-07-06');\n+-------------------------------------------------------+\n| purge_log(rawlog, statement_info, metric, 2023-07-06) |\n+-------------------------------------------------------+\n| 0 |\n+-------------------------------------------------------+\n1 row in set (0.33 sec)\n\n-- \u518d\u6b21\u67e5\u8be2 2023-07-05\uff0c2023-07-06 \u548c 2023-07-07 \u8fd9\u4e09\u5929\u7684 metric \u65e5\u5fd7\u6570\u91cf\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-06 | 30246 |\n| 2023-07-07 | 20121 |\n+-------------------+----------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/","title":"VERSION","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"VERSION()
\u51fd\u6570\u7528\u4e8e\u83b7\u53d6\u5f53\u524d MatrixOne \u7684\u7248\u672c\u4fe1\u606f\u3002\u8fd9\u4e2a\u51fd\u6570\u901a\u5e38\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5305\u542b\u4e86 MatrixOne \u7684\u7248\u672c\u53f7\u3002\u5982 8.0.30-MatrixOne-v1.2.1\uff0c\u8868\u793a MatrixOn \u7684\u7248\u672c\u53f7\u662f 8.0.30-MatrixOne-v1.2.1, \u5b83\u7684\u5b9a\u4e49\u662f MySQL \u517c\u5bb9\u7248\u672c\u53f7 (8.0.30) + MatrixOne + MatrixOne \u5185\u6838\u7248\u672c (v1.2.1)\u3002
> VERSION()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#_3","title":"\u793a\u4f8b","text":"mysql> select version();\n+-------------------------+\n| version() |\n+-------------------------+\n| 8.0.30-MatrixOne-v1.2.1 |\n+-------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Language-Structure/comment/","title":"\u6ce8\u91ca","text":"\u672c\u6587\u6863\u4ecb\u7ecd MatrixOne \u652f\u6301\u7684\u6ce8\u91ca\u8bed\u6cd5\u3002
MatrixOne \u652f\u6301\u4ee5\u4e0b\u6ce8\u91ca\u683c\u5f0f\uff1a
#
\u6ce8\u91ca\uff1amysql> select 100-99; # \u6ce8\u91ca\u5185\u5bb9\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
--
\u6765\u6ce8\u91ca\u4e00\u884c\u3002--
\uff08\u53cc\u7834\u6298\u53f7\uff09\u6ce8\u91ca\u6837\u5f0f\u8981\u6c42\u7b2c\u4e8c\u4e2a\u7834\u6298\u53f7\u540e\u8ddf\u81f3\u5c11\u4e00\u4e2a\u7a7a\u683c\u6216\u63a7\u5236\u5b57\u7b26\uff08\u4f8b\u5982\u7a7a\u683c\u3001\u5236\u8868\u7b26\u3001\u6362\u884c\u7b26\u7b49\uff09\u3002mysql> select 100-99; -- \u6ce8\u91ca\u5185\u5bb9\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
/*
\u5f00\u5934\uff0c\u4ee5 */
\u7ed3\u675f\uff0c\u4e0e C \u8bed\u8a00\u4e2d\u4f7f\u7528\u65b9\u5f0f\u4e00\u6837\u3002\u6b64\u8bed\u6cd5\u4f7f\u6ce8\u91ca\u53ef\u4ee5\u6269\u5c55\u5230\u591a\u884c\u3002mysql> select 100 /* \u6ce8\u91ca\u5185\u5bb9 */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
\u6216\uff1a
mysql> select 100\n/*\n\u6ce8\u91ca\u5185\u5bb9\n*/\n-99;\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Language-Structure/comment/#matrixone","title":"MatrixOne \u53ef\u6267\u884c\u7684\u6ce8\u91ca\u8bed\u6cd5","text":"mysql> select 100-99; // This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.03 sec)\n
\u6216\uff1a
mysql> // This comment continues to the line\n-> select 100-99;\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n
mysql> select 100 /*! Specific code */ -99;\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 28 near \" code */ -99\";\n
\u6216\uff1a
mysql> select 100 /*!50110 Specific code */ -99;\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 33 near \" code */ -99\";\n
"},{"location":"MatrixOne/Reference/Language-Structure/comment/#_2","title":"\u9650\u5236","text":"\u672c\u7ae0\u4ecb\u7ecd MatrixOne \u7684\u5173\u952e\u5b57\uff0c\u5728 MatrixOne \u4e2d\u5bf9\u4fdd\u7559\u5173\u952e\u5b57\u548c\u975e\u4fdd\u7559\u5173\u952e\u5b57\u8fdb\u884c\u4e86\u5206\u7c7b\uff0c\u4f60\u5728\u4f7f\u7528 SQL \u8bed\u53e5\u65f6\uff0c\u53ef\u4ee5\u67e5\u9605\u4fdd\u7559\u5173\u952e\u5b57\u548c\u975e\u4fdd\u7559\u5173\u952e\u5b57\u3002
\u5173\u952e\u5b57\u662f SQL \u8bed\u53e5\u4e2d\u5177\u6709\u7279\u6b8a\u542b\u4e49\u7684\u5355\u8bcd\uff0c\u4f8b\u5982 SELECT
\uff0cUPDATE
\uff0cDELETE
\u7b49\u7b49\u3002
\u5c06\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\uff0c\u5426\u5219\u5c06\u4ea7\u751f\u62a5\u9519\uff1a
\\\\\u672a\u5c06\u4fdd\u7559\u5173\u952e\u5b57 select \u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\uff0c\u4ea7\u751f\u62a5\u9519\nmysql> CREATE TABLE select (a INT);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 19 near \" select (a INT)\";\n\n\\\\\u6b63\u786e\u5c06\u4fdd\u7559\u5173\u952e\u5b57 select \u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\nmysql> CREATE TABLE `select` (a INT);\nQuery OK, 0 rows affected (0.02 sec)\n
\u5c06\u975e\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u65e0\u9700\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\u3002
\\\\ACCOUNT \u4e3a\u975e\u4fdd\u7559\u5173\u952e\u5b57\uff0c\u53ef\u4ee5\u65e0\u9700\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\nmysql> CREATE TABLE `select` (ACCOUNT int);\nQuery OK, 0 rows affected (0.01 sec)\n
Note
\u4e0e MySQL \u4e0d\u540c\uff0c\u5728 MatrixOne \u4e2d\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u9650\u5b9a\u7b26.\uff0c\u4fdd\u7559\u5173\u952e\u5b57\u5982\u679c\u4e0d\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\u4e5f\u4f1a\u4ea7\u751f\u62a5\u9519\uff0c\u5efa\u8bae\u5728\u521b\u5efa\u8868\u548c\u6570\u636e\u5e93\u65f6\uff0c\u907f\u514d\u4f7f\u7528\u4fdd\u7559\u5173\u952e\u5b57\uff1a
mysql> CREATE TABLE test.select (ACCOUNT int);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 24 near \"select (ACCOUNT int)\";\n
\u4e0b\u9762\u7684\u5217\u8868\u663e\u793a\u4e86 Matrixone \u4e2d\u7684\u4fdd\u7559\u5173\u952e\u5b57\u548c\u975e\u4fdd\u7559\u5173\u952e\u5b57\uff0c\u5176\u4e2d\uff0c\u5728 MySQL \u4e2d\u4e0d\u4e3a\u5173\u952e\u5b57\u7684\u7528 (M) \u6807\u8bb0\u3002
"},{"location":"MatrixOne/Reference/Language-Structure/keywords/#_2","title":"\u4fdd\u7559\u5173\u952e\u5b57","text":""},{"location":"MatrixOne/Reference/Language-Structure/keywords/#a","title":"A","text":"MySQL 8.0 \u7684\u5b8c\u6574\u8bed\u6cd5\u5982\u4e0b\u6240\u793a\uff1a
LOAD DATA\n [LOW_PRIORITY | CONCURRENT] [LOCAL]\n INFILE 'file_name'\n [REPLACE | IGNORE]\n INTO TABLE tbl_name\n [PARTITION (partition_name [, partition_name] ...)]\n [CHARACTER SET charset_name]\n [{FIELDS | COLUMNS}\n [TERMINATED BY 'string']\n [[OPTIONALLY] ENCLOSED BY 'char']\n [ESCAPED BY 'char']\n ]\n [LINES\n [STARTING BY 'string']\n [TERMINATED BY 'string']\n ]\n [IGNORE number {LINES | ROWS}]\n [(col_name_or_user_var\n [, col_name_or_user_var] ...)]\n [SET col_name={expr | DEFAULT}\n [, col_name={expr | DEFAULT}] ...]\n
"},{"location":"MatrixOne/Reference/Limitations/load-data-support/#matrixone","title":"MatrixOne \u6682\u4e0d\u652f\u6301\u7684\u5b57\u6bb5","text":"\u4e0a\u8ff0\u5b8c\u6574\u7684\u8bed\u6cd5\u7ed3\u6784\u4e2d\uff0cMatrixOne \u6682\u8fd8\u4e0d\u652f\u6301\u4ee5\u4e0b\u5b57\u6bb5\uff1a
\"
\u3002\\r\\n
.ignore
, \u8868\u793a\u5b57\u6bb5\u8f6c\u5230\u8868\u4e2d\u5217\u51fa\u9519\u65f6\uff0c\u4e0d\u4f1a\u7ec8\u6b62\u6574\u4e2a load
\uff0c\u4f1a\u8bb0\u5f55 warnings
\u4e2a\u6570\uff0c\u4f46\u4e0d\u8bb0\u5f55 warings
\u5185\u5bb9\uff1b\u4e0d\u52a0 ignore
, \u5b57\u6bb5\u8f6c\u5230\u8868\u4e2d\u5217\u51fa\u9519\u65f6\uff0c\u4f1a\u7ec8\u6b62\u6574\u4e2a load
INTO TABLE tableA FIELDS TERMINATED BY ',' \u5fc5\u987b\uff0c\u8868\u793a\u5b57\u6bb5\u5206\u5272\u7b26\u3002\u901a\u5e38\u662f','\u3002\u800c ssb \u7684\u662f' IGNORE number LINES \u53ef\u9009\uff0c\u8868\u793a\u5ffd\u7565\u6389\u6587\u4ef6\u5f00\u5934\u7684 number \u884c (col0,col1,...,coln); \u53ef\u9009\uff0c\u8868\u793a \u8868\u4e2d\u7684\u5217\u540d\u5217\u8868\u3002\u4f8b\u5982\uff0ccoli
\u5bf9\u5e94\u8868\u4e2d\u7b2c i
\u4e2a\u5217\u3002 \u4f8b\u5982\uff0c\u6570\u636e\u884c field0 field1 field2 ... fieldN
\uff0c\u5bf9\u5e94\u63d2\u5165\u5230\u8868\u5217 (col0, col1, col2 ,...,colN)
\u5982\u679c\u5217 coli \u4ee5'@'\u5f00\u5934\uff0c\u90a3\u4e48 fieldi \u88ab\u4e22\u5f03\uff1b(col0,col1,...,coln) \u53ef\u4ee5\u4e0d\u4e0e\u8868\u4e2d\u7684\u5217\u540d\u987a\u5e8f\u76f8\u540c\u3002fieldi \u7ed1\u5b9a\u5230\u5bf9\u5e94\u7684\u5217\u540d\u3002\u5982\u679c\u6570\u636e\u884c\u7684\u5b57\u6bb5 \u5c11\u4e8e (col0,col1,...,coln) \u6216\u8868\u4e2d\u7684\u5217\u6570\uff0c\u591a\u4f59\u7684\u5b57\u6bb5\u88ab\u4e22\u5f03\u3002\u5982\u679c\u6570\u636e\u884c\u7684\u5b57\u6bb5 \u5c11\u4e8e (col0,col1,...,coln) \u6216\u8868\u4e2d\u7684\u5217\u6570\uff0c\u5c11\u7684\u5217\u8865 NULL\u3002\u5982\u679c load data \u8bed\u6cd5\u4e2d\u6ca1\u6709 (col0,col1,...,coln)\uff0c\u76f8\u5f53\u4e8e \u52a0\u8f7d\u5230\u8868\u4e2d\u7684\u5168\u90e8\u5217\u3002"},{"location":"MatrixOne/Reference/Limitations/load-data-support/#csv","title":"csv \u7684\u683c\u5f0f\u8981\u6c42","text":"\u5b57\u7b26 \u63cf\u8ff0 \u5b57\u6bb5\u5206\u5272\u7b26 \u901a\u5e38\u662f','\uff0c\u4e5f\u53ef\u4ee5\u662f\u5176\u5b83\u5b57\u7b26\uff08\u4e0d\u662f\"
,'\\r','\\n')\u3002\u4f8b\u5982\uff1aSSB \u6570\u636e\u96c6\u5c31\u662f' \u5b57\u6bb5\u5305\u542b\u7b26 \"
\u884c\u7ed3\u675f\u7b26 \\r\\n
\u6216'\\n' \u5b57\u6bb5 NULL \u503c \u5bf9\u4e8e\u503c \\N , \u8868\u793a\u8be5\u5b57\u6bb5\u4e3a NULL\uff0c\u5176\u4ed6\u4efb\u4f55\u60c5\u51b5\u5747\u89c6\u4e3a\u5b57\u7b26\u4e32\u8f93\u5165 \u6ce8\u91ca\u7b26\u53f7 '#' \u4f5c\u4e3a\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7684\u884c\u90fd\u4f1a\u88ab\u8fc7\u6ee4\u6389"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/","title":"MatrixOne \u7684 JDBC \u529f\u80fd\u652f\u6301\u5217\u8868","text":"\u4f7f\u7528 JDBC \u5f00\u53d1\u5e94\u7528\uff0cMatrixOne \u652f\u6301\u4ee5\u4e0b\u7c7b\u548c\u5bf9\u8c61\uff1a
"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#1-connection","title":"1. Connection\uff08\u7c7b\uff09\uff1a\u83b7\u53d6\u6570\u636e\u5e93\u8fde\u63a5\u5bf9\u8c61","text":""},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#_1","title":"\u7c7b\u4e2d\u7684\u65b9\u6cd5","text":"\u83b7\u53d6\u6267\u884c Sql \u5bf9\u8c61 Statement
\u7ba1\u7406\u4e8b\u52a1
INTERVAL
\u7528\u4e8e\u65e5\u671f\u548c\u65f6\u95f4\u8ba1\u7b97\u3002
INTERVAL
\u53ef\u4ee5\u7528\u4e8e\u51fd\u6570\u8fd0\u7b97 DATE_ADD()
\u548c DATE_SUB()
\u3002
INTERVAL
\u53ef\u4ee5\u518d\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528 +
\u6216 -
\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u8fd0\u7b97\u3002
date + INTERVAL expr unit\ndate - INTERVAL expr unit\n
+
\u8fd0\u7b97\u7b26\u7684\u5de6\u8fb9\u6216\u8005\u53f3\u8fb9\uff0c\u53ea\u8981\u5b83\u5176\u4e2d\u4e00\u8fb9\u7684\u8868\u8fbe\u5f0f\u662f\u4e00\u4e2a date
\u6216 datetime
\u503c\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528 INTERVAL expr
\u3002-
\u8fd0\u7b97\u7b26\uff0c\u4ec5\u4ec5\u53ef\u4ee5\u5728 -
\u7684\u53f3\u8fb9\u4f7f\u7528 INTERVAL expr
\u3002> INTERVAL (expr,unit)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d unit \u8bf4\u660e\u7b26\uff0c\u4f8b\u5982 HOUR\u3001DAY \u6216 WEEK Note
INTERVAL
\u5173\u952e\u5b57\u548c unit
\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
\u4f60\u53ef\u4ee5\u5728 expr
\u4e2d\u4f7f\u7528\u4efb\u4f55\u6807\u70b9\u5206\u9694\u7b26\u3002\u4e0a\u8868\u6240\u793a\u4e3a\u5efa\u8bae\u7684\u5206\u9694\u7b26\u3002
DATE_ADD()
\u548c DATE_SUB()
\u4e00\u8d77\u4f7f\u7528\uff1amysql> SELECT DATE_SUB('2018-05-01',INTERVAL 1 YEAR);\n+-----------------------------------------+\n| date_sub(2018-05-01, interval(1, year)) |\n+-----------------------------------------+\n| 2017-05-01 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2020-12-31 23:59:59', INTERVAL 1 SECOND);\n+----------------------------------------------------+\n| date_add(2020-12-31 23:59:59, interval(1, second)) |\n+----------------------------------------------------+\n| 2021-01-01 00:00:00 |\n+----------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_ADD('2018-12-31 23:59:59', INTERVAL 1 DAY);\n+-------------------------------------------------+\n| date_add(2018-12-31 23:59:59, interval(1, day)) |\n+-------------------------------------------------+\n| 2019-01-01 23:59:59 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2100-12-31 23:59:59', INTERVAL '1:1' MINUTE_SECOND);\n+-------------------------------------------------------------+\n| date_add(2100-12-31 23:59:59, interval(1:1, minute_second)) |\n+-------------------------------------------------------------+\n| 2101-01-01 00:01:00 |\n+-------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('2025-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND);\n+--------------------------------------------------------------+\n| date_sub(2025-01-01 00:00:00, interval(1 1:1:1, day_second)) |\n+--------------------------------------------------------------+\n| 2024-12-30 22:58:59 |\n+--------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1900-01-01 00:00:00', INTERVAL '-1 10' DAY_HOUR);\n+----------------------------------------------------------+\n| date_add(1900-01-01 00:00:00, interval(-1 10, day_hour)) |\n+----------------------------------------------------------+\n| 1899-12-30 14:00:00.000000 |\n+----------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY);\n+-----------------------------------------+\n| date_sub(1998-01-02, interval(31, day)) |\n+-----------------------------------------+\n| 1997-12-02 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1992-12-31 23:59:59.000002', INTERVAL '1.999999' SECOND_MICROSECOND);\n+------------------------------------------------------------------------------+\n| date_add(1992-12-31 23:59:59.000002, interval(1.999999, second_microsecond)) |\n+------------------------------------------------------------------------------+\n| 1993-01-01 00:00:01.000001 |\n+------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#2","title":"\u793a\u4f8b 2","text":"+
\u6216 -
\u4e00\u8d77\u4f7f\u7528\uff1amysql> SELECT '2018-12-31 23:59:59' + INTERVAL 1 SECOND;\n+-------------------------------------------+\n| 2018-12-31 23:59:59 + interval(1, second) |\n+-------------------------------------------+\n| 2019-01-01 00:00:00 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT INTERVAL 1 DAY + '2018-12-31';\n+-------------------------------+\n| interval(1, day) + 2018-12-31 |\n+-------------------------------+\n| 2019-01-01 |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT '2025-01-01' - INTERVAL 1 SECOND;\n+----------------------------------+\n| 2025-01-01 - interval(1, second) |\n+----------------------------------+\n| 2024-12-31 23:59:59 |\n+----------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#3","title":"\u793a\u4f8b 3","text":"\u5982\u679c\u4f60\u5728\u4e00\u4e2a date
\u503c\u4e0a\u52a0\u4e0a\u6216\u51cf\u53bb\u4e00\u4e2a\u5305\u542b\u65f6\u95f4\u90e8\u5206\u7684\u503c\uff0c\u6267\u884c\u7ed3\u679c\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a\u4e00\u4e2a datetime
\u503c\uff1a
mysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 DAY);\n+----------------------------------------+\n| date_add(2023-01-01, interval(1, day)) |\n+----------------------------------------+\n| 2023-01-02 |\n+----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 HOUR);\n+-----------------------------------------+\n| date_add(2023-01-01, interval(1, hour)) |\n+-----------------------------------------+\n| 2023-01-01 01:00:00 |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#4","title":"\u793a\u4f8b 4","text":"\u5982\u679c\u6dfb\u52a0\u4e86 MONTH
\u3001YEAR_MONTH
\u6216 YEAR
\uff0c\u5e76\u4e14\u6267\u884c\u7ed3\u679c\u7684\u65e5\u671f\u7684\u67d0\u4e00\u5929\u6bd4\u5f53\u6708\u7684\u6700\u5927\u5929\u6570\u5927\uff0c\u5219\u8be5\u5929\u5c06\u88ab\u8c03\u6574\u4e3a\u5f53\u6708\u7684\u6700\u5927\u5929\u6570\uff1a
mysql> SELECT DATE_ADD('2019-01-30', INTERVAL 1 MONTH);\n+------------------------------------------+\n| date_add(2019-01-30, interval(1, month)) |\n+------------------------------------------+\n| 2019-02-28 |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#5","title":"\u793a\u4f8b 5","text":"date
\u4e0d\u80fd\u7528\u9519\u8bef\u7684\u65e5\u671f\uff0c\u5982\u6267\u884c 2016-07-00 \u6216\u683c\u5f0f\u4e25\u91cd\u9519\u8bef\u7684\u65e5\u671f\uff0c\u5219\u6267\u884c\u4f1a\u62a5\u9519\u3002
mysql> SELECT DATE_ADD('2016-07-00', INTERVAL 1 DAY);\nERROR 20301 (HY000): invalid input: invalid datatime value 2016-07-00\n\nmysql> SELECT '2005-03-32' + INTERVAL 1 MONTH;\nERROR 20301 (HY000): invalid input: invalid datatime value 2005-03-32\n
"},{"location":"MatrixOne/Reference/Operators/operators/operator-precedence/","title":"\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7","text":"\u8fd0\u7b97\u7b26\u4ece\u9ad8\u5230\u4f4e\u7684\u4f18\u5148\u7ea7\u5982\u4e0b\u6240\u793a\u3002\u5728\u540c\u4e00\u884c\u4e2d\u7684\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u76f8\u7b49\u3002
\u4f18\u5148\u7ea7\u4ece\u9ad8\u5230\u4f4e\u6392\u5e8f \u8fd0\u7b97\u7b26 1 INTERVAL 2 BINARY, COLLATE 3 ! 4 - (unary minus), ~ (unary bit inversion) 5 ^ 6 *, /, DIV, %, MOD 7 -, + 8 <<, >> 9 & 10 | 11 = (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, , IN, MEMBER OF 12 BETWEEN, CASE, WHEN, THEN, ELSE 13 NOT 14 AND, && 15 XOR 16 OR, || 17 = (assignment)\u8fd0\u7b97\u7b26 =
\u7684\u4f18\u5148\u7ea7\u53d6\u51b3\u4e8e\u5b83\u662f\u7528\u4f5c\u6bd4\u8f83\u64cd\u4f5c\u7b26\u8fd8\u662f\u8d4b\u503c\u64cd\u4f5c\u7b26\u3002\u5f53\u7528\u4f5c\u6bd4\u8f83\u64cd\u4f5c\u7b26\u65f6\uff0c\u5b83\u4e0e >=
\uff0c>
\uff0c<=
\uff0c<
\uff0c<>
\uff0c!=
\uff0cIS
\uff0cLIKE
\u548c IN()
\u5177\u6709\u76f8\u540c\u7684\u4f18\u5148\u7ea7\u3002
\u5bf9\u4e8e\u5728\u8868\u8fbe\u5f0f\u4e2d\u5177\u6709\u76f8\u540c\u4f18\u5148\u7ea7\u7684\u8fd0\u7b97\u7b26\uff0c\u6c42\u503c\u5c06\u4ece\u5de6\u5230\u53f3\u8fdb\u884c\u8ba1\u7b97\uff0c\u4f46\u8d4b\u503c\u5c06\u4ece\u53f3\u5230\u5de6\u8fdb\u884c\u8ba1\u7b97\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/operators/","title":"\u8fd0\u7b97\u7b26\u6982\u8ff0","text":""},{"location":"MatrixOne/Reference/Operators/operators/operators/#_2","title":"\u7b97\u6570\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 %,MOD \u53d6\u4f59 * \u4e58\u6cd5 + \u52a0\u6cd5 - \u51cf\u6cd5 - \u8d1f\u53f7 / \u9664\u6cd5 DIV \u7528\u4e8e\u6574\u6570\u76f8\u9664"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_3","title":"\u8d4b\u503c\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 = \u7b49\u4e8e\u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u8d4b\u503c"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_4","title":"\u4e8c\u8fdb\u5236\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 & \u4f4d\u8fd0\u7b97\u7b26\u4e0e\uff0c\u6309\u4f4d\u4e0e >> \u4f4d\u79fb\u8fd0\u7b97\u7b26\u53f3\u79fb << \u4f4d\u79fb\u8fd0\u7b97\u7b26\u5de6\u79fb ^ \u6309\u4f4d\u5f02\u6216 | \u4f4d\u8fd0\u7b97\u7b26\u6216\uff0c\u6309\u4f4d\u6216 ~ \u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u4e8c\u8fdb\u5236\u53d6\u53cd"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_5","title":"\u5f3a\u5236\u8f6c\u6362\u51fd\u6570\u548c\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 BINARY() \u5c06\u503c\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u51fd\u6570 CAST() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u5c0f\u6570\u8f6c\u6570\u503c\u548c\u5b57\u7b26\u578b CONVERT() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u65e5\u671f\u548c\u65f6\u95f4\u503c\u3001\u5c0f\u6570\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_6","title":"\u6bd4\u8f83\u51fd\u6570\u548c\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 > \u5927\u4e8e >= \u5927\u4e8e\u7b49\u4e8e < \u5c0f\u4e8e <>,!= \u4e0d\u7b49\u4e8e <= \u5c0f\u4e8e\u7b49\u4e8e = \u7b49\u4e8e BETWEEN ... AND ... \u5728\u4e24\u503c\u4e4b\u95f4 IN() \u5728\u96c6\u5408\u4e2d IS \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0c\u82e5\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u201ctrue\u201d IS NOT \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0cIS \u7684\u5426\u5b9a\u7528\u6cd5 IS NOT NULL \u4e0d\u4e3a\u7a7a IS NULL \u4e3a\u7a7a ISNULL \u4ee3\u66ff=
\u6765\u6d4b\u8bd5\u503c\u662f\u5426\u4e3a NULL
\u3002 LIKE \u6a21\u7cca\u5339\u914d ILIKE \u6a21\u7cca\u5339\u914d\uff0c\u540c LIKE\u3002\u4f46\u5bf9\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002 NOT BETWEEN ... AND ... \u4e0d\u5728\u4e24\u503c\u4e4b\u95f4 NOT IN \u591a\u4e2a XOR
\u6761\u4ef6\u7684\u7b80\u5199 NOT LIKE \u6a21\u7cca\u5339\u914d\uff0cLike \u7684\u5426\u5b9a\u7528\u6cd5 COALESCE \u8fd4\u56de\u7b2c\u4e00\u4e2a\u975e\u7a7a\u503c"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_7","title":"\u63a7\u5236\u6d41\u51fd\u6570","text":"\u540d\u79f0 \u63cf\u8ff0 CASE Case when \u8fd0\u7b97\u7b26 IF() If/else \u8bed\u53e5 IFNULL() If null/else \u8bed\u53e5 NULLIF() expr1 = expr2 \u65f6\u8fd4\u56de NULL\uff0c\u5426\u5219\u8fd4\u56de expr1"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_8","title":"\u903b\u8f91\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 AND,&& \u903b\u8f91\u4e0e NOT,! \u903b\u8f91\u975e OR \u903b\u8f91\u6216 XOR \u903b\u8f91\u5f02\u6216"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/","title":"+","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"+
\u8fd0\u7b97\u7b26\u7528\u4e8e\u52a0\u6cd5\u8fd0\u7b97\u3002
> SELECT value1+value2;\n
> SELECT column1+column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#_4","title":"\u793a\u4f8b","text":"mysql> select 1123.2333+1233.3331;\n+-----------------------+\n| 1123.2333 + 1233.3331 |\n+-----------------------+\n| 2356.5664 |\n+-----------------------+\n1 row in set (0.01 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1+5 from t2;\n+--------+\n| c1 + 5 |\n+--------+\n| 2 |\n| 6 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1+c2 from t2;\n+---------+\n| c1 + c2 |\n+---------+\n| -1 |\n| 3 |\n+---------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/","title":"\u7b97\u6570\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 %,MOD \u53d6\u4f59 * \u4e58\u6cd5 + \u52a0\u6cd5 - \u51cf\u6cd5 - \u8d1f\u53f7 / \u9664\u6cd5 DIV \u6574\u6570\u76f8\u9664 \u2014 \u5bf9\u4e8e -
\u3001+
\u548c *
\uff0c\u5982\u679c\u4e24\u4e2a\u8fd0\u7b97\u6570\u503c\u90fd\u662f\u6574\u6570\uff0c\u8ba1\u7b97\u7ed3\u679c\u5c06\u4ee5 BIGINT (64 \u4f4d) \u7cbe\u5ea6\u8ba1\u7b97\u3002
\u2014 \u5982\u679c\u4e24\u4e2a\u8fd0\u7b97\u6570\u503c\u90fd\u662f\u6574\u6570\u4e14\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u90fd\u662f\u65e0\u7b26\u53f7\u7684\uff0c\u5219\u7ed3\u679c\u4e3a\u65e0\u7b26\u53f7\u6574\u6570\u3002
\u2014 \u5982\u679c +
\u3001-
\u3001/
\u3001*
\u3001%
\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\u8fd0\u7b97\u6570\u503c\u662f\u4e00\u4e2a\u5b9e\u503c\u6216\u5b57\u7b26\u4e32\u503c\uff0c\u5219\u7ed3\u679c\u7684\u7cbe\u5ea6\u4e3a\u8fd0\u7b97\u6570\u7684\u6700\u5927\u7cbe\u5ea6\u3002
\u5728\u4f7f\u7528 /
\u8fdb\u884c\u9664\u6cd5\u65f6\uff0c\u5f53\u4f7f\u7528\u4e24\u4e2a\u7cbe\u786e\u503c\u8fd0\u7b97\u6570\u65f6\uff0c\u7ed3\u679c\u7684\u7cbe\u5ea6\u8303\u56f4\u662f\u7b2c\u4e00\u4e2a\u8fd0\u7b97\u6570\u503c\u7684\u7cbe\u5ea6\u8303\u56f4\u52a0\u4e0a div_precision_increment
\u7cfb\u7edf\u53d8\u91cf\u7684\u503c\u3002\u4f8b\u5982\uff0c\u8868\u8fbe\u5f0f 5.05 / 0.014 \u7684\u7ed3\u679c\u6709\u4e00\u4e2a\u5c0f\u6570 8 \u4f4d\u7684\u7cbe\u5ea6 (360.71428571)\u3002
\u8fd9\u4e9b\u89c4\u5219\u9002\u7528\u4e8e\u6bcf\u4e2a\u64cd\u4f5c\uff0c\u4f8b\u5982\u5d4c\u5957\u8ba1\u7b97\u53d6\u6bcf\u4e2a\u7ec4\u4ef6\u7684\u7cbe\u5ea6\u3002\u56e0\u6b64\uff0c(14620 / 9432456)/(24250 / 9432456) \u9996\u5148\u89e3\u6790\u4e3a (0.0014)/(0.0026)\uff0c\u6700\u7ec8\u7ed3\u679c\u6709 16 \u4f4d\u5c0f\u6570 (0.6028865979381443)\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/#_2","title":"\u9650\u5236","text":"DIV
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6574\u6570\u9664\u6cd5\u3002
\u5982\u679c\u4e24\u4e2a\u8fd0\u7b97\u6570\u503c\u90fd\u662f\u975e\u6574\u6570\u7c7b\u578b\uff0c\u5219\u4f1a\u5c06\u8fd0\u7b97\u6570\u503c\u8f6c\u6362\u4e3a DECIMAL
\uff0c\u5e76\u5728\u5c06\u7ed3\u679c\u8f6c\u6362\u4e3a BIGINT
\u4e4b\u524d\u4f7f\u7528 DECIMAL
\u7b97\u6cd5\u8fdb\u884c\u9664\u6cd5\u3002\u5982\u679c\u7ed3\u679c\u8d85\u51fa BIGINT
\u8303\u56f4\uff0c\u5219\u4f1a\u53d1\u751f\u9519\u8bef\u3002
> SELECT value1 DIV value2;\n
> SELECT column1 DIV column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 5 DIV 2, -5 DIV 2, 5 DIV -2, -5 DIV -2;\n+---------+----------+----------+-----------+\n| 5 div 2 | -5 div 2 | 5 div -2 | -5 div -2 |\n+---------+----------+----------+-----------+\n| 2 | -2 | -2 | 2 |\n+---------+----------+----------+-----------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 DIV 3 from t2;\n+----------+\n| c1 div 3 |\n+----------+\n| -1 |\n| 0 |\n+----------+\n2 rows in set (0.00 sec)\n\nmysql> select c1 DIV c2 from t2;\n+-----------+\n| c1 div c2 |\n+-----------+\n| -1 |\n| 0 |\n+-----------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/","title":"/","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"/
\u8fd0\u7b97\u7b26\u7528\u4e8e\u9664\u6cd5\u8fd0\u7b97\u3002
> SELECT value1/value2;\n
> SELECT column1/column2... FROM table_name;\n
\u9664\u6cd5\u8fd0\u7b97\u4e0d\u53ef\u4ee5\u9664\u4ee5 O\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#_4","title":"\u793a\u4f8b","text":"mysql> select 1123.2333/1233.3331;\n+-----------------------+\n| 1123.2333 / 1233.3331 |\n+-----------------------+\n| 0.9107298750 |\n+-----------------------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1/2 from t2;\n+--------+\n| c1 / 2 |\n+--------+\n| -1.5 |\n| 0.5 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1/c2 from t2;\n+---------+\n| c1 / c2 |\n+---------+\n| -1.5 |\n| 0.5 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"-
\u8fd0\u7b97\u7b26\u7528\u4e8e\u51cf\u6cd5\u8fd0\u7b97\u3002
> SELECT value1-value2;\n
> SELECT column1-column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#_3","title":"\u793a\u4f8b","text":"mysql> select 1123.2333-1233.3331;\n+-----------------------+\n| 1123.2333 - 1233.3331 |\n+-----------------------+\n| -110.09979999999996 |\n+-----------------------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1-5 from t2;\n+--------+\n| c1 - 5 |\n+--------+\n| -8 |\n| -4 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1-c2 from t2;\n+---------+\n| c1 - c2 |\n+---------+\n| -5 |\n| -1 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/","title":"%,MOD","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"%,MOD
\u8fd0\u7b97\u7b26\u7528\u4e8e\u53d6\u4f59\u8fd0\u7b97\u3002\u8fd4\u56de\u7ed3\u679c\u4e3a N \u9664\u4ee5 M \u7684\u4f59\u6570\u3002
> SELECT N % M, N MOD M;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#_3","title":"\u793a\u4f8b","text":"mysql> select 12 mod 5;\n+--------+\n| 12 % 5 |\n+--------+\n| 2 |\n+--------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 mod 2 from t2;\n+--------+\n| c1 % 2 |\n+--------+\n| -1 |\n| 1 |\n+--------+\n2 rows in set (0.01 sec)\n\nmysql> select c1 mod c2 from t2;\n+---------+\n| c1 % c2 |\n+---------+\n| -1 |\n| 1 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/","title":"*","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"*
\u8fd0\u7b97\u7b26\u7528\u4e8e\u4e58\u6cd5\u8fd0\u7b97\u3002
> SELECT value1*value2;\n
> SELECT column1*column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#_4","title":"\u793a\u4f8b","text":"mysql> select 1123.2333*1233.3331;\n+-----------------------+\n| 1123.2333 * 1233.3331 |\n+-----------------------+\n| 1385320.80791223 |\n+-----------------------+\n1 row in set (0.01 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1*2 from t2;\n+--------+\n| c1 * 2 |\n+--------+\n| -6 |\n| 2 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1*c2 from t2;\n+---------+\n| c1 * c2 |\n+---------+\n| -6 |\n| 2 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"-
\u4e3a\u8d1f\u53f7\u8fd0\u7b97\u7b26\u3002\u8d1f\u53f7\u8fd0\u7b97\u7b26\u5c06\u8868\u8fbe\u5f0f\u7684\u7b26\u53f7\u4ece\u6b63\u6570\u53cd\u8f6c\u4e3a\u8d1f\u6570\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002
> SELECT -column1, -column2, ...\nFROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#_3","title":"\u793a\u4f8b","text":"mysql> select -2;\n+------+\n| -2 |\n+------+\n| -2 |\n+------+\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select -c1 from t2;\n+------+\n| -c1 |\n+------+\n| 3 |\n| -1 |\n+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/","title":"\u8d4b\u503c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/#_1","title":"\u8d4b\u503c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 = \u7b49\u4e8e\u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u8d4b\u503c"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"=
\u8fd0\u7b97\u7b26\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u7528\u4e8e\u8d4b\u503c\uff1a
\u5728 SET
\u8bed\u53e5\u4e2d\uff0c=
\u88ab\u89c6\u4e3a\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0c\u5373\u8fd0\u7b97\u7b26 =
\u5de6\u4fa7\u7684\u7528\u6237\u53d8\u91cf\u53d6\u5176\u53f3\u4fa7\u7684\u503c\u3002=
\u53f3\u8fb9\u7684\u503c\u53ef\u4ee5\u662f\u6587\u672c\u503c\u3001\u53e6\u4e00\u4e2a\u5b58\u50a8\u503c\u7684\u53d8\u91cf\uff0c\u6216\u8005\u4efb\u4f55\u4ea7\u751f\u6807\u91cf\u503c\u7684\u5408\u6cd5\u8868\u8fbe\u5f0f\uff0c\u4e5f\u53ef\u5305\u62ec\u67e5\u8be2\u7684\u7ed3\u679c (\u524d\u63d0\u662f\u8fd9\u4e2a\u503c\u662f\u6807\u91cf\u503c)\u3002\u53ef\u4ee5\u5728\u540c\u4e00\u4e2a SET
\u8bed\u53e5\u4e2d\u6267\u884c\u591a\u4e2a\u8d4b\u503c\u3002
\u5728 UPDATE
\u8bed\u53e5\u7684 SET
\u5b50\u53e5\u4e2d\uff0c=
\u4e5f\u5145\u5f53\u8d4b\u503c\u8fd0\u7b97\u7b26\u3002\u4f60\u53ef\u4ee5\u5728\u4e00\u4e2a UPDATE
\u8bed\u53e5\u7684\u540c\u4e00\u4e2a SET
\u5b50\u53e5\u4e2d\u8fdb\u884c\u591a\u4e2a\u8d4b\u503c\u3002
\u5728\u5176\u4ed6\u60c5\u51b5\u4e0b\u4e2d\uff0c=
\u4f5c\u4e3a\u6bd4\u8f83\u8fd0\u7b97\u7b26\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN = value1;\n
"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#_4","title":"\u793a\u4f8b","text":"create table t1 (a bigint(3), b bigint(5) primary key);\ninsert into t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 1 |\n| 1 | 2 |\n+------+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/","title":"\u4e8c\u8fdb\u5236\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 & \u4f4d\u8fd0\u7b97\u7b26\u4e0e\uff0c\u6309\u4f4d\u4e0e >> \u4f4d\u79fb\u8fd0\u7b97\u7b26\u53f3\u79fb << \u4f4d\u79fb\u8fd0\u7b97\u7b26\u5de6\u79fb ^ \u6309\u4f4d\u5f02\u6216 | \u4f4d\u8fd0\u7b97\u7b26\u6216\uff0c\u6309\u4f4d\u6216 ~ \u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u4e8c\u8fdb\u5236\u53d6\u53cd \u4f4d\u51fd\u6570\u548c\u8fd0\u7b97\u7b26\u901a\u5e38\u4e0e\u6574\u6570\u6570\u636e\u7c7b\u578b\u4e00\u8d77\u4f7f\u7528\uff0c\u4e0d\u80fd\u76f4\u63a5\u5e94\u7528\u4e8e\u5176\u4ed6\u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982\uff0cfloat\uff0cdouble \u7b49\u3002\u5373\uff0c\u9700\u8981\u4e0e BIGINT(64 \u4f4d\u6574\u6570) \u53c2\u6570\u4e00\u8d77\u4f7f\u7528\u5e76\u8fd4\u56de BIGINT \u503c\uff0c\u56e0\u6b64\u5b83\u4eec\u7684\u6700\u5927\u8303\u56f4\u4e3a 64 \u4f4d\u3002\u975e BIGINT \u53c2\u6570\u5728\u6267\u884c\u64cd\u4f5c\u4e4b\u524d\u88ab\u8f6c\u6362\u4e3a BIGINT\uff0c\u53ef\u80fd\u6574\u6570\u4f4d\u6570\u4f1a\u88ab\u622a\u65ad\uff0c\u4f8b\u5982\uff0c10.6496 \u548c -10.6496 \u5728\u8f6c\u6362\u5230 INT \u7c7b\u578b\u671f\u95f4\u53ef\u80fd\u4f1a\u88ab\u622a\u65ad\u6216\u8005\u88ab\u820d\u5165\u3002
\u4f4d\u51fd\u6570\u548c\u64cd\u4f5c\u7b26\u5141\u8bb8\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\u5b9e\u53c2 (BINARY\u3001VARBINARY \u548c BLOB \u7c7b\u578b) \u5e76\u8fd4\u56de\u5176\u540c\u7c7b\u578b\u7684\u503c\uff0c\u8fd9\u4f7f\u5b83\u4eec\u80fd\u591f\u63a5\u53d7\u5b9e\u53c2\u5e76\u4ea7\u751f\u5927\u4e8e 64 \u4f4d\u7684\u8fd4\u56de\u503c\u3002\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u53c2\u6570\u5219\u88ab\u8f6c\u6362\u4e3a BIGINT \u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/","title":"&","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"Bitwise AND
\u8fd0\u7b97\u7b26\uff0c\u5bf9\u6bcf\u5bf9\u6bd4\u7279\u4f4d\u6267\u884c\u4e0e\uff08AND\uff09\u64cd\u4f5c\u3002\u53ea\u6709 a \u548c b \u90fd\u662f 1 \u65f6\uff0ca AND b \u624d\u662f 1\u3002Bitwise AND
\u8fd4\u56de\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT value1 & value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 29 & 15;\n+---------+\n| 29 & 15 |\n+---------+\n| 13 |\n+---------+\n1 row in set (0.06 sec)\n\nCREATE TABLE bitwise (a_int_value INT NOT NULL,b_int_value INT NOT NULL);\nINSERT bitwise VALUES (170, 75); mysql> SELECT a_int_value & b_int_value FROM bitwise; +---------------------------+\n| a_int_value & b_int_value |\n+---------------------------+\n| 10 |\n+---------------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/","title":"~","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u4e8c\u8fdb\u5236\u53d6\u53cd\u3002\u5bf9\u6bcf\u4e00\u4e2a\u6bd4\u7279\u4f4d\u6267\u884c\u975e\uff08NOT\uff09\u64cd\u4f5c\u3002NOT a \u7ed3\u679c\u4e3a a \u7684\u53cd\u8f6c\uff08\u5373\u53cd\u7801\uff09\uff0c\u53c2\u6570\u53ea\u80fd\u662f\u6570\u5b57\u6216 NULL\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT ~value1;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#_4","title":"\u793a\u4f8b","text":"mysql> select ~-5;\n+--------+\n| ~ (-5) |\n+--------+\n| 4 |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select ~null;\n+-------+\n| ~null |\n+-------+\n| NULL |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> select ~a, ~b from t1;\n+------+----------------------+\n| ~a | ~b |\n+------+----------------------+\n| 0 | 18446744073709551614 |\n| 4 | 18446744073709551610 |\n+------+----------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/","title":"|","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u4f4d\u8fd0\u7b97\u7b26\u6216\uff0c\u6309\u4f4d\u6216\u3002\u5bf9\u6bcf\u4e00\u5bf9\u6bd4\u7279\u4f4d\u6267\u884c\u6216\uff08OR\uff09\u64cd\u4f5c\u3002\u5982\u679c a \u6216 b \u4e3a 1\uff0c\u5219 a OR b \u7ed3\u679c\u4e3a 1\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT value1 | value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 29 | 15;\n+---------+\n| 29 | 15 |\n+---------+\n| 31 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n| NULL |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n| NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a | 2, b | 2 from t1;\n+-------+-------+\n| a | 2 | b | 2 |\n+-------+-------+\n| -1 | 3 |\n| -5 | 7 |\n+-------+-------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/","title":"^","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u6309\u4f4d\u5f02\u6216\u3002\u5bf9\u6bcf\u4e00\u5bf9\u6bd4\u7279\u4f4d\u6267\u884c\u5f02\u6216\uff08XOR\uff09\u64cd\u4f5c\u3002\u5f53 a \u548c b \u4e0d\u76f8\u540c\u65f6\uff0ca XOR b \u7684\u7ed3\u679c\u4e3a 1\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT value1 ^ value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 1 ^ 1;\n+-------+\n| 1 ^ 1 |\n+-------+\n| 0 |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> SELECT 1 ^ 0;\n+-------+\n| 1 ^ 0 |\n+-------+\n| 1 |\n+-------+\n1 row in set (0.01 sec)\n\nmysql> SELECT 11 ^ 3;\n+--------+\n| 11 ^ 3 |\n+--------+\n| 8 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select null ^ 2;\n+----------+\n| null ^ 2 |\n+----------+\n| NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a ^ 2, b ^ 2 from t1;\n+-------+-------+\n| a ^ 2 | b ^ 2 |\n+-------+-------+\n| -3 | 3 |\n| -7 | 7 |\n+-------+-------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/","title":"<<","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u8be5\u64cd\u4f5c\u7b26\u4f1a\u5c06\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u5411\u5de6\u79fb\u52a8\u6307\u5b9a\u7684\u4f4d\u6570\u3002\u5411\u5de6\u88ab\u79fb\u51fa\u7684\u4f4d\u88ab\u4e22\u5f03\uff0c\u53f3\u4fa7\u7528 0 \u8865\u5145\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
\u65e0\u8bba\u53c2\u6570\u7c7b\u578b\u5982\u4f55\uff0c\u79fb\u51fa\u503c\u672b\u5c3e\u7684\u4f4d\u90fd\u4f1a\u5728\u6ca1\u6709\u8b66\u544a\u7684\u60c5\u51b5\u4e0b\u4e22\u5931\u3002\u7279\u522b\u662f\uff0c\u5982\u679c\u79fb\u4f4d\u8ba1\u6570\u5927\u4e8e\u6216\u7b49\u4e8e\u4f4d\u53c2\u6570\u4e2d\u7684\u4f4d\u6570\uff0c\u5219\u7ed3\u679c\u4e2d\u7684\u6240\u6709\u4f4d\u5747\u4e3a 0\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SELECT value1 << value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 1 << 2;\n+--------+\n| 1 << 2 |\n+--------+\n| 4 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select -1 << 2;\n+---------+\n| -1 << 2 |\n+---------+\n| -4 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null << 2;\n+-----------+\n| null << 2 |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a << 2, b << 2 from t1;\n+--------+--------+\n| a << 2 | b << 2 |\n+--------+--------+\n| -4 | 4 |\n| -20 | 20 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/","title":">>","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u8be5\u64cd\u4f5c\u7b26\u4f1a\u5c06\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u5411\u53f3\u79fb\u52a8\u6307\u5b9a\u7684\u4f4d\u6570\u3002\u5411\u53f3\u88ab\u79fb\u51fa\u7684\u4f4d\u88ab\u4e22\u5f03\uff0c\u5de6\u4fa7\u7528 0 \u8865\u5145\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
\u65e0\u8bba\u53c2\u6570\u7c7b\u578b\u5982\u4f55\uff0c\u79fb\u51fa\u503c\u672b\u5c3e\u7684\u4f4d\u90fd\u4f1a\u5728\u6ca1\u6709\u8b66\u544a\u7684\u60c5\u51b5\u4e0b\u4e22\u5931\u3002\u7279\u522b\u662f\uff0c\u5982\u679c\u79fb\u4f4d\u8ba1\u6570\u5927\u4e8e\u6216\u7b49\u4e8e\u4f4d\u53c2\u6570\u4e2d\u7684\u4f4d\u6570\uff0c\u5219\u7ed3\u679c\u4e2d\u7684\u6240\u6709\u4f4d\u5747\u4e3a 0\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SELECT value1 >> value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#_4","title":"\u793a\u4f8b","text":"mysql> select 1024 >> 2;\n+-----------+\n| 1024 >> 2 |\n+-----------+\n| 256 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select -5 >> 2;\n+---------+\n| -5 >> 2 |\n+---------+\n| -2 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null >> 2;\n+-----------+\n| null >> 2 |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.00 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a >> 2, b >> 2 from t1;\n+--------+--------+\n| a >> 2 | b >> 2 |\n+--------+--------+\n| -1 | 0 |\n| -2 | 1 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/","title":"BINARY","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BINARY()
\u51fd\u6570\u662f\u4e00\u4e2a\u7528\u4e8e\u5c06\u503c\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u51fd\u6570\u3002\u5b83\u901a\u5e38\u7528\u4e8e\u6bd4\u8f83\u6587\u672c\u6216\u5b57\u7b26\u6570\u636e\u65f6\uff0c\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u4e8c\u8fdb\u5236\u6570\u636e\u800c\u4e0d\u662f\u666e\u901a\u7684\u5b57\u7b26\u6570\u636e\u3002\u8fd9\u6837\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u5b57\u7b26\u6570\u636e\u7684\u4e8c\u8fdb\u5236\u6bd4\u8f83\uff0c\u800c\u4e0d\u53d7\u5b57\u7b26\u96c6\u6216\u7f16\u7801\u7684\u5f71\u54cd\u3002
BINARY()
\u51fd\u6570\u5b9e\u73b0\u5bf9\u5b57\u7b26\u6570\u636e\u7684\u4e8c\u8fdb\u5236\u6bd4\u8f83\uff0c\u7528\u4e8e\u5904\u7406\u5927\u5c0f\u5199\u654f\u611f\u7684\u5b57\u7b26\u4e32\u6bd4\u8f83\u7b49\u573a\u666f\u3002
> BINARY value\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#_3","title":"\u76f8\u5173\u53c2\u6570","text":"\u53c2\u6570 \u8bf4\u660e value \u5fc5\u8981\u53c2\u6570\u3002\u5f85\u8f6c\u5316\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, password VARCHAR(100) NOT NULL);\n\nINSERT INTO users (username, password) VALUES ('JohnDoe', 'Abcd123'), ('AliceSmith', 'Efgh456'), ('BobJohnson', 'ijkl789');\n\n-- \u4f7f\u7528 BINARY() \u64cd\u4f5c\u7b26\u8fdb\u884c\u5bc6\u7801\u9a8c\u8bc1\uff0cBINARY password = 'Abcd123'\u90e8\u5206\u5c06\u5bc6\u7801\u503c\u89c6\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u8fd9\u6837\u8fdb\u884c\u7684\u6bd4\u8f83\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002\u5982\u679c\u8f93\u5165\u7684\u5bc6\u7801\u4e0e\u6570\u636e\u5e93\u4e2d\u7684\u8bb0\u5f55\u5339\u914d\uff0c\u67e5\u8be2\u5c06\u8fd4\u56de\u76f8\u5e94\u7684\u7528\u6237 id \u548c username\uff0c\u5426\u5219\u5c06\u8fd4\u56de\u7a7a\u7ed3\u679c\u3002\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'Abcd123';\n+------+----------+\n| id | username |\n+------+----------+\n| 1 | JohnDoe |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'abcd123';\nEmpty set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/","title":"\u5f3a\u5236\u8f6c\u6362\u51fd\u6570\u548c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 BINARY() \u5c06\u503c\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u51fd\u6570 CAST() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u5c0f\u6570\u8f6c\u6570\u503c\u548c\u5b57\u7b26\u578b CONVERT() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u65e5\u671f\u548c\u65f6\u95f4\u503c\u3001\u5c0f\u6570\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362 SERIAL() \u5c06\u8fde\u63a5\u4e32\u5e8f\u5217\u5316\uff0c\u4e0d\u5904\u7406 NULL \u503c SERIAL_FULL() \u5c06\u8fde\u63a5\u4e32\u5e8f\u5217\u5316\uff0c\u5904\u7406 NULL \u503c"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/","title":"CAST","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CAST()
\u51fd\u6570\u53ef\u4ee5\u5c06\u4efb\u4f55\u7c7b\u578b\u7684\u4e00\u4e2a\u503c\u8f6c\u5316\u4e3a\u53e6\u4e00\u4e2a\u7279\u5b9a\u7c7b\u578b\u3002
> CAST(value AS datatype)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_3","title":"\u76f8\u5173\u53c2\u6570","text":"\u53c2\u6570 \u8bf4\u660e value \u5fc5\u8981\u53c2\u6570\uff0c\u5f85\u8f6c\u5316\u7684\u503c datatype \u5fc5\u8981\u53c2\u6570\uff0c\u76ee\u6807\u6570\u636e\u7c7b\u578b \u76ee\u524d\uff0ccast
\u53ef\u4ee5\u8fdb\u884c\u5982\u4e0b\u8f6c\u6362\uff1a
\u8be6\u7ec6\u7684\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u89c4\u5219\uff0c\u8bf7\u53c2\u89c1\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\nCREATE TABLE t1 (a int,b float,c char(1),d varchar(15));\nINSERT INTO t1 VALUES (1,1.5,'1','-2');\n\nmysql> SELECT CAST(a AS FLOAT) a_cast,CAST(b AS UNSIGNED) b_cast,CAST(c AS SIGNED) c_cast, CAST(d AS SIGNED) d_cast from t1;\n+--------+--------+--------+--------+\n| a_cast | b_cast | c_cast | d_cast |\n+--------+--------+--------+--------+\n| 1.0000 | 1 | 1 | -2 |\n+--------+--------+--------+--------+\n\nmysql> SELECT CAST(a AS CHAR) a_cast, CAST(b AS CHAR) b_cast,CAST(c AS DOUBLE) c_cast, CAST(d AS FLOAT) d_cast from t1;\n+--------+--------+--------+---------+\n| a_cast | b_cast | c_cast | d_cast |\n+--------+--------+--------+---------+\n| 1 | 1.5 | 1.0000 | -2.0000 |\n+--------+--------+--------+---------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_5","title":"\u9650\u5236","text":"CONVERT()
\u51fd\u6570\u5c06\u4e00\u4e2a\u503c\u8f6c\u6362\u4e3a\u6307\u5b9a\u7684\u6570\u636e\u7c7b\u578b\u6216\u5b57\u7b26\u96c6\u3002
> CONVERT(value, type)\n
\u6216\uff1a
> CONVERT(value USING charset)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#_3","title":"\u76f8\u5173\u53c2\u6570","text":"\u53c2\u6570 \u8bf4\u660e value \u5fc5\u8981\u53c2\u6570\uff0c\u5f85\u8f6c\u5316\u7684\u503c datatype \u5fc5\u8981\u53c2\u6570\uff0c\u76ee\u6807\u6570\u636e\u7c7b\u578b charset \u5fc5\u8981\u53c2\u6570\uff0c\u76ee\u6807\u5b57\u7b26\u96c6 \u76ee\u524d\uff0cconvert
\u53ef\u4ee5\u8fdb\u884c\u5982\u4e0b\u8f6c\u6362\uff1a
mysql> select convert(150,char);\n+-------------------+\n| cast(150 as char) |\n+-------------------+\n| 150 |\n+-------------------+\n1 row in set (0.01 sec)\n
CREATE TABLE t1(a tinyint);\nINSERT INTO t1 VALUES (127);\n\nmysql> SELECT 1 FROM\n-> (SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1) AS s LIMIT 1;\n+------+\n| 1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#_5","title":"\u9650\u5236","text":"SERIAL()
\u51fd\u6570\u7528\u4e8e\u5e8f\u5217\u5316\u8fde\u63a5\u4e32\uff0c\u5c06\u5355\u4e2a\u6216\u591a\u4e2a\u5217/\u503c\u7ec4\u5408\u6210\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u8fd4\u56de\u7c7b\u578b\u4e3a VARCHAR
\u3002\u5b83\u7c7b\u4f3c\u4e8e CONCAT()
\uff0c\u4f46\u5728 CONCAT()
\u4e2d\u4e0d\u80fd\u6355\u83b7\u503c\u7684\u7c7b\u578b\u4fe1\u606f\u3002\u4e00\u822c\u642d\u914d SERIAL_EXTRACT()
\u51fd\u6570\u4f7f\u7528\u3002
SERIAL()
\u4e2d\u5982\u679c\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002\u5982\u9700\u5904\u7406 NULL \u503c\uff0c\u53ef\u4f7f\u7528 SERIAL_FULL()
\u3002
> SERIAL(para)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e para \u8981\u5e8f\u5217\u5316\u7684\u5217/\u503c"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial/#_4","title":"\u793a\u4f8b","text":"create table t1(a varchar(3), b int);\ninsert into t1 values(\"ABC\",1);\ninsert into t1 values(\"DEF\",NULL);\n\nmysql> select serial(a,b) from t1;--\u67e5\u8be2\u8fd4\u56de\u4e3a a \u5217\u548c b \u5217\u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\uff0c\u5f53\u6709 NULL \u503c\u65f6\u8f93\u51fa\u4e3a NULL\n+--------------+\n| serial(a, b) |\n+--------------+\n| FABC : |\n| NULL |\n+--------------+\n2 rows in set (0.00 sec)\n\nmysql> select serial(a,'hello') from t1;--\u67e5\u8be2\u8fd4\u56de\u4e3a a \u5217\u548c\u503c hello \u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\n+------------------+\n| serial(a, hello) |\n+------------------+\n| FABC Fhello |\n| FDEF Fhello |\n+------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/","title":"SERIAL_FULL()","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SERIAL_FULL()
\u7528\u4e8e\u7528\u4e8e\u5e8f\u5217\u5316\u8fde\u63a5\u4e32\uff0c\u5c06\u5355\u4e2a\u6216\u8005\u591a\u4e2a\u5217/\u503c\u7ec4\u5408\u8f6c\u6362\u6210\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u8fd4\u56de\u7c7b\u578b\u4e3a VARCHAR
\uff0c\u4e00\u822c\u642d\u914d SERIAL_EXTRACT()
\u51fd\u6570\u4f7f\u7528\u3002SERIAL_FULL()
\u7c7b\u4f3c\u4e8e SERIAL()
\uff0c\u4f46 SERIAL_FULL()
\u4f1a\u4fdd\u7559 NULL \u503c\u3002
> SERIAL_FULL(para)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e para \u8981\u5e8f\u5217\u5316\u7684\u5217/\u503c"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/#_4","title":"\u793a\u4f8b","text":"create table t1(a varchar(3), b int);\ninsert into t1 values(\"ABC\",1);\ninsert into t1 values(\"DEF\",NULL);\n\nmysql> select serial_full(a,b) from t1;--\u67e5\u8be2\u8fd4\u56de\u4e3a a \u5217\u548c b \u5217\u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\uff0c\u5f53\u6709 NULL \u503c\u65f6\u4fdd\u7559 NULL \u503c\n+-------------------+\n| serial_full(a, b) |\n+-------------------+\n| FABC : |\n| FDEF |\n+-------------------+\n2 rows in set (0.00 sec)\n\nmysql> select serial_full(1.2,'world') ;--\u67e5\u8be2\u8fd4\u56de\u4e3a\u503c 1.2 \u548c\u503c hello \u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\n+-------------------------+\n| serial_full(1.2, world) |\n+-------------------------+\n| D? Fworld |\n+-------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"=
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 =
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u7b49\u4e8e =
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c=
\u8fd0\u7b97\u7b26\u7684\u7ed3\u679c\u8fd4\u56de true
\u3002
> SELECT x = y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 = 2;\n+-------+\n| 2 = 2 |\n+-------+\n| true |\n+-------+\n1 row in set (0.01 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID=score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n| 3 | 3 | 3 |\n+--------+------+-------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/","title":"BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"BETWEEN ... AND ...
\u64cd\u4f5c\u7b26\u9009\u53d6\u4ecb\u4e8e\u4e24\u4e2a\u503c\u4e4b\u95f4\u7684\u6570\u636e\u8303\u56f4\u5185\u7684\u503c\u3002\u8fd9\u4e9b\u503c\u53ef\u4ee5\u662f\u6570\u503c\u3001\u6587\u672c\u6216\u8005\u65e5\u671f\u3002\u5982\u679c\u53d6\u503c\u4ecb\u4e8e\u4e24\u503c\u4e4b\u95f4\uff0c\u90a3\u4e48\u8fd4\u56de true
\uff0c\u5426\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
> expr BETWEEN min AND max\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 2 BETWEEN 1 AND 3, 2 BETWEEN 3 and 1;\n+-------------------+-------------------+\n| 2 between 1 and 3 | 2 between 3 and 1 |\n+-------------------+-------------------+\n| true | false |\n+-------------------+-------------------+\n1 row in set (0.01 sec)\n
create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from t where id between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n| 3 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/","title":"COALESCE()","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COALESCE (expression_1, expression_2, ...,expression_n)
\u4f9d\u6b21\u53c2\u8003\u5404\u53c2\u6570\u8868\u8fbe\u5f0f\uff0c\u9047\u5230\u975e null
\u503c\u5373\u505c\u6b62\u5e76\u8fd4\u56de\u8be5\u503c\u3002\u5982\u679c\u6240\u6709\u7684\u8868\u8fbe\u5f0f\u90fd\u662f\u7a7a\u503c\uff0c\u6700\u7ec8\u5c06\u8fd4\u56de\u4e00\u4e2a\u7a7a\u503c\u3002
\u4f7f\u7528 COALESCE
\u5728\u4e8e\u5927\u90e8\u5206\u5305\u542b\u7a7a\u503c\u7684\u8868\u8fbe\u5f0f\u6700\u7ec8\u5c06\u8fd4\u56de\u7a7a\u503c\u3002
> COALESCE(value1, value2, ...., value_n)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"Arguments Description value1, value2, value_n Required. The values to test"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT COALESCE(1)+COALESCE(1);\n+---------------------------+\n| coalesce(1) + coalesce(1) |\n+---------------------------+\n| 2 |\n+---------------------------+\n
drop table if exists t2;\ncreate table t2(a float, b datetime);\ninsert into t2 values (12.345, '2022-02-20 10:10:10.999999');\ninsert into t2 values (3.45646, NULL);\ninsert into t2 values(NULL, '2023-04-03 22:10:29.999999');\ninsert into t2 values (NULL, NULL);\n\nmysql> select * from t2;\n+---------+---------------------+\n| a | b |\n+---------+---------------------+\n| 12.345 | 2022-02-20 10:10:11 |\n| 3.45646 | NULL |\n| NULL | 2023-04-03 22:10:30 |\n| NULL | NULL |\n+---------+---------------------+\nmysql> select coalesce(a, 1.0) from t2;\n+--------------------+\n| coalesce(a, 1.0) |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n| 1 |\n| 1 |\n+--------------------+\nmysql> select coalesce(a, 1) from t2;\n+--------------------+\n| coalesce(a, 1) |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n| 1 |\n| 1 |\n+--------------------+\nmysql> select coalesce(b, 2022-01-01) from t2;\n+---------------------------+\n| coalesce(b, 2022 - 1 - 1) |\n+---------------------------+\n| 2022-02-20 10:10:11 |\n| 2020 |\n| 2023-04-03 22:10:30 |\n| 2020 |\n+---------------------------+\n
ORDER BY
\u5b50\u53e5CREATE TABLE t1 ( a INTEGER, b varchar(255) );\nINSERT INTO t1 VALUES (1,'z');\nINSERT INTO t1 VALUES (2,'y');\nINSERT INTO t1 VALUES (3,'x');\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a');\n+-------+\n| min_b |\n+-------+\n| x |\n| y |\n| z |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(min_b, 'a');\n+-------+\n| min_b |\n+-------+\n| x |\n| y |\n| z |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a') DESC;\n+-------+\n| min_b |\n+-------+\n| z |\n| y |\n| x |\n+-------+\n
Case When
\u5b50\u53e5mysql> select if(1, cast(1111111111111111111 as unsigned), 1) i,case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, coalesce(cast(1111111111111111111 as unsigned), 1) co;\n+---------------------+---------------------+---------------------+\n| i | c | co |\n+---------------------+---------------------+---------------------+\n| 1111111111111111111 | 1111111111111111111 | 1111111111111111111 |\n+---------------------+---------------------+---------------------+\n
IN Subquery
CREATE TABLE ot (col_int_nokey int(11), col_varchar_nokey varchar(1));\nINSERT INTO ot VALUES (1,'x');\nCREATE TABLE it (col_int_key int(11), col_varchar_key varchar(1));\nINSERT INTO it VALUES (NULL,'x'), (NULL,'f');\n\nmysql> SELECT col_int_nokey FROM ot WHERE col_varchar_nokey IN(SELECT col_varchar_key FROM it WHERE coalesce(col_int_nokey, 1) );\n+---------------+\n| col_int_nokey |\n+---------------+\n| 1 |\n+---------------+\n
WHERE
\u5b50\u53e5CREATE TABLE ot1(a INT);\nCREATE TABLE ot2(a INT);\nCREATE TABLE ot3(a INT);\nCREATE TABLE it1(a INT);\nCREATE TABLE it2(a INT);\nCREATE TABLE it3(a INT);\nINSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO ot2 VALUES(0),(2),(4),(6);\nINSERT INTO ot3 VALUES(0),(3),(6);\nINSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO it2 VALUES(0),(2),(4),(6);\nINSERT INTO it3 VALUES(0),(3),(6);\n\nmysql> SELECT * FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);\n+------+------+\n| a | a |\n+------+------+\n| 0 | 0 |\n| 1 | NULL |\n| 3 | NULL |\n| 5 | NULL |\n| 6 | 6 |\n| 7 | NULL |\n+------+------+\n
HAVING
drop table if exists t1;\ncreate table t1(a datetime);\nINSERT INTO t1 VALUES (NULL), ('2001-01-01 00:00:00.12'), ('2002-01-01 00:00:00.567');\n\nmysql> select a from t1 group by a having COALESCE(a)<\"2002-01-01\";\n+---------------------+\n| a |\n+---------------------+\n| 2001-01-01 00:00:00 |\n+---------------------+\n
ON CONDITION
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1(a INT, b varchar(255));\ncreate table t2(a INT, b varchar(255));\ninsert into t1 values(1, \"\u4f60\u597d\"), (3, \"\u518d\u89c1\");\ninsert into t2 values(2, \"\u65e5\u671f\u65f6\u95f4\"), (4, \"\u660e\u5929\");\n> SELECT t1.a, t2.a FROM t1 JOIN t2 ON (length(COALESCE(t1.b)) = length(COALESCE(t2.b)));\n+------+------+\n| a | a |\n+------+------+\n| 1 | 4 |\n| 3 | 4 |\n+------+------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/","title":"\u6bd4\u8f83\u51fd\u6570\u548c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 > \u5927\u4e8e >= \u5927\u4e8e\u7b49\u4e8e < \u5c0f\u4e8e <>,!= \u4e0d\u7b49\u4e8e <= \u5c0f\u4e8e\u7b49\u4e8e = \u7b49\u4e8e BETWEEN ... AND ... \u5728\u4e24\u503c\u4e4b\u95f4 COALESCE \u8fd4\u56de\u7b2c\u4e00\u4e2a\u975e\u7a7a\u503c IN() \u5728\u96c6\u5408\u4e2d IS \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0c\u82e5\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u201ctrue\u201d IS NOT \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0cIS \u7684\u5426\u5b9a\u7528\u6cd5 IS NOT NULL \u4e0d\u4e3a\u7a7a IS NULL \u4e3a\u7a7a ISNULL \u4ee3\u66ff =
\u6765\u6d4b\u8bd5\u503c\u662f\u5426\u4e3a NULL
\u3002 LIKE \u6a21\u7cca\u5339\u914d ILIKE \u6a21\u7cca\u5339\u914d\uff0c\u540c LIKE\u3002\u4f46\u5bf9\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002 NOT BETWEEN ... AND ... \u4e0d\u5728\u4e24\u503c\u4e4b\u95f4 NOT IN \u591a\u4e2a XOR
\u6761\u4ef6\u7684\u7b80\u5199 NOT LIKE N \u6a21\u7cca\u5339\u914d\uff0cLike \u7684\u5426\u5b9a\u7528\u6cd5 \u6bd4\u8f83\u8fd0\u7b97\u7684\u7ed3\u679c\u4e3a TRUE
\u3001FALSE
\u6216 NULL
\u3002\u8fd9\u4e9b\u8fd0\u7b97\u5bf9\u6570\u5b57\u548c\u5b57\u7b26\u4e32\u5747\u6709\u6548\u3002\u5b57\u7b26\u4e32\u53ef\u4ee5\u81ea\u52a8\u8f6c\u6362\u4e3a\u6570\u5b57\uff0c\u6570\u5b57\u6839\u636e\u9700\u8981\u81ea\u52a8\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002
\u4ee5\u4e0b\u6bd4\u8f83\u8fd0\u7b97\u7b26\u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u6bd4\u8f83\u6807\u91cf\u8fd0\u7b97\u6570\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6bd4\u8f83\u884c\u8fd0\u7b97\u6570\uff1a
= > < >= <= <> !=\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/","title":"INTERVAL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"The INTERVAL
operator returns 0 if N < N1, 1 if N < N2 and so on or -1 if N is NULL. All arguments are treated as integers. It is required that N1 < N2 < N3 < ... < Nn for this function to work correctly. This is because a binary search is used (very fast).
> INTERVAL(N,N1,N2,N3,...)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#_3","title":"\u793a\u4f8b","text":">\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/","title":"ISNULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u53ef\u4ee5\u4f7f\u7528 ISNULL()
\u51fd\u6570\u4ee3\u66ff =
\u6765\u6d4b\u8bd5\u503c\u662f\u5426\u4e3a NULL
\u3002\uff08\u4f7f\u7528 =
\u5c06\u503c\u4e0e NULL
\u8fdb\u884c\u6bd4\u8f83\u59cb\u7ec8\u4f1a\u4ea7\u751f NULL
\u3002\uff09
\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a NULL
\uff0c\u5219\u8be5\u51fd\u6570\u8fd4\u56de true
\u3002\u5426\u5219\uff0c\u5b83\u8fd4\u56de false
\u3002
ISNULL()
\u51fd\u6570\u4e0e IS NULL
\u6bd4\u8f83\u8fd0\u7b97\u7b26\u5171\u4eab\u4e00\u4e9b\u7279\u6b8a\u884c\u4e3a\u3002\u53c2\u89c1 IS NULL
\u7684\u63cf\u8ff0\u3002
> ISNULL(expr)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT ISNULL(1+1);\n+---------------+\n| isnull(1 + 1) |\n+---------------+\n| false |\n+---------------+\n1 row in set (0.01 sec)\n
CREATE TABLE students (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, birth_date DATE );\n\nINSERT INTO students (name, birth_date) VALUES ('John Doe', '2000-05-15'), ('Alice Smith', NULL), ('Bob Johnson', '1999-10-20');\n\n-- \u4f7f\u7528 ISNULL() \u51fd\u6570\u67e5\u627e\u6ca1\u6709\u586b\u5199\u51fa\u751f\u65e5\u671f\u7684\u5b66\u751f\uff1a\nmysql> SELECT * FROM students WHERE ISNULL(birth_date);\n+------+-------------+------------+\n| id | name | birth_date |\n+------+-------------+------------+\n| 2 | Alice Smith | NULL |\n+------+-------------+------------+\n1 row in set (0.00 sec)\n\n-- ISNULL() \u51fd\u6570\u4e5f\u53ef\u4ee5\u7528 IS NULL \u6765\u5b9e\u73b0\u76f8\u540c\u7684\u529f\u80fd\uff0c\u6240\u4ee5\u4ee5\u4e0b\u67e5\u8be2\u4e5f\u662f\u7b49\u6548\u7684\uff1a\nmysql> SELECT * FROM students WHERE birth_date IS NULL;\n+------+-------------+------------+\n| id | name | birth_date |\n+------+-------------+------------+\n| 2 | Alice Smith | NULL |\n+------+-------------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/","title":"STRCMP","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"The STRCMP()
returns 0 if the strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and NULL if either argument is NULL. It returns 1 otherwise.
> STRCMP(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#_3","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/","title":">=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":">=
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 >=
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5927\u4e8e\u6216\u7b49\u4e8e >=
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c>=
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x >= y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 >= 2;\n+--------+\n| 2 >= 2 |\n+--------+\n| true |\n+--------+\n1 row in set (0.01 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where spID>=userID*score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n| 1 | 1 | 1 |\n+--------+------+-------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/","title":">","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":">
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 >
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5927\u4e8e >
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c>
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x > y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 > 2;\n+-------+\n| 2 > 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where spID>(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n| 2 | 1 | 4 |\n| 3 | 3 | 3 |\n| 1 | 1 | 5 |\n+------+--------+-------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/","title":"ILIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ILIKE
\u64cd\u4f5c\u7b26\u4e0e LIKE
\u64cd\u4f5c\u7b26\u7528\u6cd5\u76f8\u4f3c\uff0c\u7528\u4e8e\u5728 WHERE \u5b50\u53e5\u4e2d\u641c\u7d22\u5217\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\u3002
ILIKE
\u64cd\u4f5c\u7b26\u4e0e LIKE
\u64cd\u4f5c\u7b26\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u5927\u5c0f\u5199\u654f\u611f\u6027\u3002\u4f7f\u7528 ILIKE
\u65f6\uff0c\u4e0d\u8bba\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u662f\u5927\u5199\u8fd8\u662f\u5c0f\u5199\uff0c\u5b83\u4eec\u90fd\u4f1a\u88ab\u89c6\u4e3a\u76f8\u540c\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN ILIKE pattern;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#_3","title":"\u793a\u4f8b","text":"drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a ilike '%abC%';\n\nmysql> select * from t1 where a ilike '%abC%';\n+------+\n| a |\n+------+\n| abc |\n| ABC |\n| abC |\n+------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/","title":"IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IN
\u8fd0\u7b97\u7b26\u53ef\u4ee5\u5728 WHERE
\u8bed\u53e5\u4e2d\u6307\u5b9a\u7279\u5b9a\u7684\u591a\u4e2a\u503c\uff0c\u672c\u8d28\u4e0a\u662f\u591a\u4e2a OR
\u6761\u4ef6\u7684\u7b80\u5199\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE column_name IN (value1, value2, ...);\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#_3","title":"\u793a\u4f8b","text":"create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a in (2,4);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 2 | b | 2.001 | 2022-02-09 | 2022-02-09 12:00:00 |\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n\nmysql> select * from t2 where a not in (2,4);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n+------+------+-------+------------+---------------------+\n\nmysql> select * from t2 where b not in ('e',\"f\");\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 2 | b | 2.001 | 2022-02-09 | 2022-02-09 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#_4","title":"\u9650\u5236","text":"IN
\u5de6\u4fa7\u53ea\u652f\u6301\u5e38\u6570\u5217\u8868\u3002IN
\u5de6\u4fa7\u53ea\u652f\u6301\u5355\u5217\u6570\u636e\uff0c\u4e0d\u652f\u6301\u591a\u5217\u7ec4\u6210\u7684\u5143\u7ec4\u3002IN
\u76ee\u524d\u672a\u5bf9 NULL
\u503c\u8fdb\u884c\u5f88\u597d\u5730\u5904\u7406\uff0c\u53f3\u4fa7\u4e0d\u80fd\u4f7f\u7528 NULL
\u503c\u3002IS NOT NULL
\u8fd0\u7b97\u7b26\u7528\u4e8e\u5224\u65ad\u5217\u7684\u503c\u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u503c\u4e0d\u4e3a\u7a7a\uff0c\u5373\u4e0d\u4e3a NULL
\uff0c\u5219\u8fd4\u56de true
\uff0c\u5426\u5219\u8fd4\u56de false
\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e SELECT
\u3001INSERT
\u3001UPDATE
\u6216 DELETE
\u8bed\u53e5\u3002
> expression IS NOT NULL\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;\n+---------------+---------------+------------------+\n| 1 is not null | 0 is not null | null is not null |\n+---------------+---------------+------------------+\n| true | true | false |\n+---------------+---------------+------------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\nmysql> select * from t1 where b is NOT NULL;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n+-------+-------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/","title":"IS NOT","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IS NOT
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6d4b\u8bd5\u6570\u503c\u662f\u5426\u4e3a\u5e03\u5c14\u503c\uff0c\u82e5\u4e0d\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002\u5176\u4e2d boolean_value
\u53ef\u4ee5\u4e3a TRUE
\u3001FALSE
\u6216 UNKNOWN
\u3002
> IS NOT boolean_value\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS NOT TRUE, 0 IS NOT FALSE, NULL IS NOT UNKNOWN;\n+---------------+----------------+---------------------+\n| 1 is not true | 0 is not false | null is not unknown |\n+---------------+----------------+---------------------+\n| false | false | false |\n+---------------+----------------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/","title":"IS NULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IS NULL
\u8fd0\u7b97\u7b26\u7528\u4e8e\u5224\u65ad\u5217\u7684\u503c\u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u503c\u4e3a\u7a7a\uff0c\u5373\u4e3a NULL
\uff0c\u5219\u8fd4\u56de true
\uff0c\u5426\u5219\u8fd4\u56de false
\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e SELECT
\u3001INSERT
\u3001UPDATE
\u6216 DELETE
\u8bed\u53e5\u3002
> expression IS NULL\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;\n+-----------+-----------+--------------+\n| 1 is null | 0 is null | null is null |\n+-----------+-----------+--------------+\n| false | false | true |\n+-----------+-----------+--------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\nmysql> select * from t1 where a IS NULL;\n+------+------+\n| a | b |\n+------+------+\n| NULL | NULL |\n+------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/","title":"IS","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IS
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6d4b\u8bd5\u6570\u503c\u662f\u5426\u4e3a\u5e03\u5c14\u503c\uff0c\u82e5\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002\u5176\u4e2d boolean_value
\u53ef\u4ee5\u4e3a TRUE
\u3001FALSE
\u6216 UNKNOWN
\u3002
> IS boolean_value\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN;\n+-----------+------------+-----------------+\n| 1 is true | 0 is false | null is unknown |\n+-----------+------------+-----------------+\n| true | true | true |\n+-----------+------------+-----------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\nmysql> select * from t1 where a<=b and a is not NULL;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | true |\n| false | false |\n+-------+-------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/","title":"<=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"<=
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 <=
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5c0f\u4e8e\u6216\u7b49\u4e8e <=
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c<=
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x <= y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 <= 2;\n+--------+\n| 2 <= 2 |\n+--------+\n| true |\n+--------+\n1 row in set (0.00 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,score,spID from t1 where userID<=score/spID;\n+--------+-------+------+\n| userid | score | spid |\n+--------+-------+------+\n| 1 | 1 | 1 |\n| 1 | 4 | 2 |\n| 1 | 5 | 1 |\n| 11 | 99 | 5 |\n+--------+-------+------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/","title":"<","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"<
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 <
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5c0f\u4e8e <
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c<
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x < y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 < 2;\n+-------+\n| 2 < 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where (userID-1)<spID;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n| 2 | 1 | 4 |\n| 3 | 3 | 3 |\n| 1 | 1 | 5 |\n+------+--------+-------+\n5 rows in set (0.00 sec)\nmysql> select spID,userID,score from t1 where spID<(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 4 | 6 | 10 |\n| 5 | 11 | 99 |\n+------+--------+-------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/","title":"LIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"LIKE
\u64cd\u4f5c\u7b26\u7528\u4e8e\u5728 WHERE
\u5b50\u53e5\u4e2d\u641c\u7d22\u5217\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\u3002
\u6709\u4e24\u4e2a\u901a\u914d\u7b26\u7ecf\u5e38\u4e0e LIKE
\u64cd\u4f5c\u7b26\u4e00\u8d77\u4f7f\u7528\uff1a
\u767e\u5206\u53f7 %
\u901a\u914d\u7b26\uff1a\u8868\u793a\u5339\u914d\u4efb\u610f\u5b57\u7b26\u5e8f\u5217\uff08\u5305\u62ec\u7a7a\u5b57\u7b26\u5e8f\u5217\uff09\u3002
\u4e0b\u5212\u7ebf _
\u901a\u914d\u7b26\uff1a\u8868\u793a\u5339\u914d\u5355\u4e2a\u5b57\u7b26\u3002
te_t
\uff1a\u53ef\u4ee5\u5339\u914d \"text\"\u3001\"test\" \u7b49\u3002\u5176\u4ed6\u5b57\u7b26\uff1aLIKE
\u64cd\u4f5c\u7b26\u5bf9\u5176\u4ed6\u5b57\u7b26\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN LIKE pattern;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#_3","title":"\u793a\u4f8b","text":"drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a like '%abC%';\n\nmysql> select * from t1 where a like '%abC%';\n+------+\n| a |\n+------+\n| abC |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/","title":"NOT BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NOT BETWEEN ... AND ...
\u64cd\u4f5c\u7b26\u9009\u53d6\u4ecb\u4e8e\u4e24\u4e2a\u503c\u4e4b\u95f4\u7684\u6570\u636e\u8303\u56f4\u5916\u7684\u503c\u3002\u8fd9\u4e9b\u503c\u53ef\u4ee5\u662f\u6570\u503c\u3001\u6587\u672c\u6216\u8005\u65e5\u671f\u3002\u5982\u679c\u53d6\u503c\u4ecb\u4e8e\u4e24\u503c\u4e4b\u95f4\uff0c\u90a3\u4e48\u8fd4\u56de false
\uff0c\u5426\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> expr NOT BETWEEN min AND max\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 2 NOT BETWEEN 1 AND 3, 2 NOT BETWEEN 3 and 1;\n+-----------------------+-----------------------+\n| 2 not between 1 and 3 | 2 not between 3 and 1 |\n+-----------------------+-----------------------+\n| false | true |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n
create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from t where id not between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n| 0 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/","title":"<>,!=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"<>, !=
\u8fd0\u7b97\u7b26\u4ec5\u5f53\u5de6\u64cd\u4f5c\u6570\u4e0d\u7b49\u4e8e\u53f3\u64cd\u4f5c\u6570\u65f6\u8fd4\u56de true
\u3002
> SELECT x <> y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 <> 2;\n+--------+\n| 2 != 2 |\n+--------+\n| false |\n+--------+\n1 row in set (0.01 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID<>score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n| 1 | 1 | 5 |\n+--------+------+-------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/","title":"NOT IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NOT IN
\u8fd0\u7b97\u7b26\u53ef\u4ee5\u5728 WHERE
\u8bed\u53e5\u4e2d\u6307\u5b9a\u7279\u5b9a\u7684\u591a\u4e2a\u503c\uff0c\u672c\u8d28\u4e0a\u662f\u591a\u4e2a XOR
\u6761\u4ef6\u7684\u7b80\u5199\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE column_name NOT IN (value1, value2, ...);\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#_3","title":"\u793a\u4f8b","text":"create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a not in (2,4);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n+------+------+-------+------------+---------------------+\n2 rows in set (0.05 sec)\n\nmysql> select * from t2 where b not in ('e',\"f\");\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 2 | b | 2.001 | 2022-02-09 | 2022-02-09 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n4 rows in set (0.09 sec)\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n1 row in set (0.05 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#_4","title":"\u9650\u5236","text":"NOT IN
\u5de6\u4fa7\u7684\u5e38\u91cf\u5217\u8868\u3002NOT IN
\u5de6\u8fb9\u53ea\u80fd\u6709\u5355\u5217\uff0c\u4e0d\u80fd\u662f\u591a\u5217\u3002NULL
\u503c\u4e0d\u80fd\u51fa\u73b0\u5728 NOT IN
\u53f3\u4fa7\u7684\u5217\u8868\u4e2d\u3002NOT LIKE
\u64cd\u4f5c\u7b26\u7528\u4e8e\u5728 WHERE
\u4ece\u53e5\u4e2d\u641c\u7d22\u5217\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\uff0c\u662f LIKE
\u7684\u5426\u5b9a\u7528\u6cd5\u3002
\u6709\u4e24\u4e2a\u901a\u914d\u7b26\u7ecf\u5e38\u4e0e LIKE
\u64cd\u4f5c\u7b26\u4e00\u8d77\u4f7f\u7528\uff1a
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN NOT LIKE pattern;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#_3","title":"\u793a\u4f8b","text":"create table t1 (a char(10));\ninsert into t1 values('abcdef');\ninsert into t1 values('_bcdef');\ninsert into t1 values('a_cdef');\ninsert into t1 values('ab_def');\ninsert into t1 values('abc_ef');\ninsert into t1 values('abcd_f');\ninsert into t1 values('abcde_');\n\nmysql> select * from t1 where a not like 'a%';\n+--------+\n| a |\n+--------+\n| _bcdef |\n+--------+\nmysql> select * from t1 where a not like \"%d_\\_\";\n+--------+\n| a |\n+--------+\n| abcdef |\n| _bcdef |\n| a_cdef |\n| ab_def |\n| abc_ef |\n| abcd_f |\n+--------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/","title":"CASE WHEN","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CASE WHEN
\u8bed\u53e5\u7528\u4e8e\u8ba1\u7b97\u6761\u4ef6\u5217\u8868\u5e76\u8fd4\u56de\u591a\u4e2a\u53ef\u80fd\u7ed3\u679c\u8868\u8fbe\u5f0f\u4e4b\u4e00\uff0cCASE WHEN
\u53ef\u4ee5\u6bd4\u8f83\u7b49\u4e8e\u3001\u8303\u56f4\u7684\u6761\u4ef6\u3002\u9047\u5230\u7b2c\u4e00\u4e2a\u6ee1\u8db3\u6761\u4ef6\u7684\u5373\u8fd4\u56de\uff0c\u4e0d\u518d\u5f80\u4e0b\u6bd4\u8f83\uff0c\u5982\u679c\u6ca1\u6709\u6ee1\u8db3\u7684\u6761\u4ef6\u5219\u8fd4\u56de else
\u91cc\u7684\u7ed3\u679c\uff0c\u5982\u679c\u6ca1\u6709 else
\u5219\u8fd4\u56de NULL
\u3002
CASE \u6709\u4e24\u79cd\u683c\u5f0f\uff0c\u4e24\u79cd\u683c\u5f0f\u90fd\u652f\u6301\u53ef\u9009\u7684 ELSE
\u53c2\u6570\u3002\uff1a
CASE
\u51fd\u6570\u5c06\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e0e\u4e00\u7ec4\u7b80\u5355\u8868\u8fbe\u5f0f\u8fdb\u884c\u6bd4\u8f83\u4ee5\u786e\u5b9a\u7ed3\u679c\u3002CASE
\u641c\u7d22\u51fd\u6570\u8ba1\u7b97\u4e00\u7ec4\u5e03\u5c14\u8868\u8fbe\u5f0f\u6765\u786e\u5b9a\u7ed3\u679c\u3002CASE value WHEN compare_value THEN result [WHEN compare_value THEN result ...] [ELSE result] END\n
\u8fd9\u91cc\u7684 CASE
\u8bed\u6cd5\u8fd4\u56de\u7684\u662f\u7b2c\u4e00\u4e2a value=compare_value
\u4e3a true
\u7684\u5206\u652f\u7684\u7ed3\u679c\u3002
CASE WHEN condition THEN result [WHEN condition THEN result ...] [ELSE result] END\n
\u8fd9\u91cc\u7684 CASE
\u8bed\u6cd5\u8fd4\u56de\u7684\u662f\u7b2c\u4e00\u4e2a condition
\u4e3a true
\u7684\u5206\u652f\u7684\u7ed3\u679c\u3002
\u5982\u679c\u6ca1\u6709\u4e00\u4e2a value=compare_value
\u6216\u8005 condition
\u4e3a true
\uff0c\u90a3\u4e48\u5c31\u4f1a\u8fd4\u56de ELSE
\u5bf9\u5e94\u7684\u7ed3\u679c\uff0c\u5982\u679c\u6ca1\u6709 ELSE
\u5206\u652f\uff0c\u90a3\u4e48\u8fd4\u56de NULL
\u3002
note
CASE
\u8bed\u53e5\u4e0d\u80fd\u6709 ELSE NULL
\u4ece\u53e5, \u5e76\u4e14 CASE
\u8bed\u53e5\u5fc5\u987b\u4ee5 END
\u7ed3\u5c3e\u3002
mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;\n+------------------------------------------+\n| case when 1 > 0 then true else false end |\n+------------------------------------------+\n| true |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t1 (a INT, b INT);\nQuery OK, 0 rows affected (0.01 sec)\n\nINSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3);\nQuery OK, 6 rows affected (0.01 sec)\n\nmysql> SELECT CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END FROM t1 GROUP BY b;\n+-------------------------------------------------------+\n| case when avg(a) >= 0 then Positive else Negative end |\n+-------------------------------------------------------+\n| Positive |\n| Positive |\n| Positive |\n+-------------------------------------------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/","title":"\u63a7\u5236\u6d41\u51fd\u6570\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 CASE Case \u8fd0\u7b97\u7b26 IF() If/else \u8bed\u53e5 IFNULL() null if/else \u8bed\u53e5 NULLIF() expr1 = expr2 \u65f6\u8fd4\u56de NULL"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/","title":"IF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IF()
\u65e2\u53ef\u4ee5\u4f5c\u4e3a\u8868\u8fbe\u5f0f\u7528\uff0c\u4e5f\u53ef\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u4f5c\u4e3a\u6d41\u7a0b\u63a7\u5236\u8bed\u53e5\u4f7f\u7528\u3002
> IF(expr1,expr2,expr3)\n
TRUE
(expr1 <> 0 and expr1 IS NOT NULL)\uff0c\u5219\u7ed3\u679c\u8fd4\u56de expr2\uff1b\u5426\u5219\uff0c\u8fd4\u56de expr3\u3002\u2014 \u5982\u679c expr2 \u6216 expr3 \u4e2d\u53ea\u6709\u4e00\u4e2a\u663e\u5f0f\u4e3a NULL
\uff0c\u5219 If()
\u51fd\u6570\u7684\u7ed3\u679c\u7c7b\u578b\u4e3a\u975e NULL \u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u3002
IF()
\u7684\u9ed8\u8ba4\u8fd4\u56de\u7c7b\u578b (\u5b58\u50a8\u5230\u4e34\u65f6\u8868\u65f6\u53ef\u80fd\u4f1a\u6709\u5f71\u54cd) \u8ba1\u7b97\u5982\u4e0b\uff1a
\u5982\u679c expr2 \u6216 expr3 \u751f\u6210\u7684\u662f\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u4e3a\u5b57\u7b26\u4e32\u3002
\u5982\u679c expr2 \u548c expr3 \u90fd\u662f\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u6709\u4e00\u4e2a\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\uff0c\u5219\u7ed3\u679c\u4e5f\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\u3002
\u5982\u679c expr2 \u6216 expr3 \u751f\u6210\u7684\u662f\u6d6e\u70b9\u503c\uff0c\u5219\u7ed3\u679c\u4e3a\u6d6e\u70b9\u503c\u3002
mysql> SELECT IF(1>2,2,3);\n+-----------------+\n| if(1 > 2, 2, 3) |\n+-----------------+\n| 3 |\n+-----------------+\n1 row in set (0.01 sec)\nmysql> SELECT IF(1<2,'yes','no');\n+--------------------+\n| if(1 < 2, yes, no) |\n+--------------------+\n| yes |\n+--------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL);\nINSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0);\n\nmysql> select if(u=1,st,st) s from t1 order by s;\n+------+\n| s |\n+------+\n| A |\n| AA |\n| BBB |\n| a |\n| a |\n| aa |\n| aaa |\n+------+\n7 rows in set (0.00 sec)\n\nmysql> select if(u=1,st,st) s from t1 where st like \"%a%\" order by s;\n+------+\n| s |\n+------+\n| a |\n| a |\n| aa |\n| aaa |\n+------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#_4","title":"\u9650\u5236","text":"\u51fd\u6570 IF
\u6682\u4e0d\u652f\u6301\u53c2\u6570 BIGINT
\u548c VARCHAR
\u3002
\u5982\u679c expr1
\u4e0d\u4e3a NULL
\uff0c\u5219 IFNULL()
\u8fd4\u56de expr1
\uff1b\u5426\u5219\u8fd4\u56de expr2
\u3002
> IFNULL(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT IFNULL(NULL,10);\n+------------------+\n| ifnull(null, 10) |\n+------------------+\n| 10 |\n+------------------+\n1 row in set (0.01 sec)\n
mysql> SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL);\n+-----------------------------------------+\n| cast(ifnull(null, null) as decimal(38)) |\n+-----------------------------------------+\n| NULL |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/","title":"NULLIF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NULLIF()
\u51fd\u6570\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c\u3002\u5982\u679c expr1
\u548c expr2
\u7684\u503c\u76f8\u7b49\uff0c\u90a3\u4e48 NULLIF()
\u51fd\u6570\u8fd4\u56de NULL
\uff1b\u5426\u5219\uff0c\u8fd4\u56de expr1
\u7684\u503c\u3002\u8fd9\u4e2a\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u5904\u7406\u907f\u514d\u9664\u4ee5\u96f6\u6216\u907f\u514d\u5728\u8ba1\u7b97\u4e2d\u4f7f\u7528\u65e0\u6548\u7684\u503c\u65f6\u4ea7\u751f\u9519\u8bef\u3002
> NULLIF(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE employees ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, salary DECIMAL(10, 2) );\n\nINSERT INTO employees (name, salary) VALUES ('John Doe', 1000), ('Alice Smith', 2000), ('Bob Johnson', 1500);\n\n-- \u4f7f\u7528 NULLIF() \u51fd\u6570\u5c06\u5de5\u8d44\u4e3a\u7279\u5b9a\u503c\u7684\u5458\u5de5\u7684\u5de5\u8d44\u8bbe\u4e3a NULL\u3002NULLIF(salary, 1500) \u51fd\u6570\u5c06\u6bd4\u8f83 salary \u5b57\u6bb5\u7684\u503c\u548c 1500\u3002\u5982\u679c salary \u7684\u503c\u7b49\u4e8e 1500\uff0c\u5219\u8fd4\u56de NULL\uff0c\u5426\u5219\u8fd4\u56de salary \u7684\u503c\u3002\nmysql> SELECT name, salary, NULLIF(salary, 1500) AS adjusted_salary FROM employees;\n+-------------+---------+-----------------+\n| name | salary | adjusted_salary |\n+-------------+---------+-----------------+\n| John Doe | 1000.00 | 1000.00 |\n| Alice Smith | 2000.00 | 2000.00 |\n| Bob Johnson | 1500.00 | |\n+-------------+---------+-----------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/","title":"AND,&&","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"AND,&&
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u4e8e\u903b\u8f91\u4e0e\u8fd0\u7b97\u3002\u5982\u679c\u6240\u6709\u64cd\u4f5c\u6570\u90fd\u975e\u96f6\u4e14\u4e0d\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff1b\u5982\u679c\u4e00\u4e2a\u6216\u591a\u4e2a\u64cd\u4f5c\u6570\u4e3a 0\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\uff1b\u5982\u679c\u4e00\u4e2a\u6216\u591a\u4e2a\u64cd\u4f5c\u6570\u975e\u96f6\u4e14\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> SELECT column_1 AND column_2 FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#_3","title":"\u793a\u4f8b","text":"mysql> select 1 and 1;\n+---------+\n| 1 and 1 |\n+---------+\n| true |\n+---------+\nmysql> select 1 and 0;\n+---------+\n| 1 and 0 |\n+---------+\n| false |\n+---------+\nmysql> select 1 and null;\n+------------+\n| 1 and null |\n+------------+\n| NULL |\n+------------+\nmysql> select null and 0;\n+------------+\n| null and 0 |\n+------------+\n| false |\n+------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\nmysql> select a and b from t1;\n+---------+\n| a and b |\n+---------+\n| false |\n| false |\n| true |\n| false |\n| NULL |\n+---------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/","title":"\u903b\u8f91\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 AND,&& \u903b\u8f91\u4e0e NOT,! \u903b\u8f91\u975e OR \u903b\u8f91\u6216 XOR \u903b\u8f91\u5f02\u6216"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/","title":"NOT,!","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"NOT,!
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u4e8e\u903b\u8f91\u975e\u8fd0\u7b97\u3002\u5982\u679c\u64cd\u4f5c\u6570\u4e3a\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff1b\u5982\u679c\u64cd\u4f5c\u6570\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\uff1b\u5982\u679c\u64cd\u4f5c\u6570\u4e3a NOT NUL
\u5219\u8fd4\u56de NULL
\u3002
> NOT|! value\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#_3","title":"\u793a\u4f8b","text":"mysql> select not 0;\n+-------+\n| not 0 |\n+-------+\n| true |\n+-------+\n1 row in set (0.02 sec)\n\nmysql> select ! null;\n+-------+\n| !null |\n+-------+\n| NULL |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> select ! 1;\n+-------+\n| !1 |\n+-------+\n| false |\n+-------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\nmysql> SELECT * FROM T1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\n5 rows in set (0.01 sec)\n\nmysql> select not a and not b from t1;\n+-----------------+\n| not a and not b |\n+-----------------+\n| false |\n| false |\n| false |\n| true |\n| NULL |\n+-----------------+\n5 rows in set (0.00 sec)\n\nmysql> select * from t1 where !(a=false);\n+------+-------+\n| a | b |\n+------+-------+\n| true | false |\n| true | true |\n+------+-------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/","title":"OR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"OR,||
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u903b\u8f91\u6216\u8fd0\u7b97\u3002\u5f53\u4e24\u4e2a\u64cd\u4f5c\u6570\u90fd\u975e null
\u65f6\uff0c\u5982\u679c\u64cd\u4f5c\u6570\u540c\u65f6\u4e5f\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff0c\u5426\u5219\u4e3a false
\uff1b\u5bf9\u4e8e NULL
\u64cd\u4f5c\u6570\uff0c\u5982\u679c\u53e6\u4e00\u4e2a\u64cd\u4f5c\u6570\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff0c\u5426\u5219\u4e3a NULL
\uff1b\u5982\u679c\u4e24\u4e2a\u64cd\u4f5c\u6570\u90fd\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a NULL
\u3002
> SELECT column_1 OR column_2 FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#_3","title":"\u793a\u4f8b","text":"mysql> select 1 or 1;\n+--------+\n| 1 or 1 |\n+--------+\n| true |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 1 or 0;\n+--------+\n| 1 or 0 |\n+--------+\n| true |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select 0 or 0;\n+--------+\n| 0 or 0 |\n+--------+\n| false |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 0 or null;\n+-----------+\n| 0 or null |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> select 1 or null;\n+-----------+\n| 1 or null |\n+-----------+\n| true |\n+-----------+\n1 row in set (0.00 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a or b from t1;\n+--------+\n| a or b |\n+--------+\n| true |\n| true |\n| true |\n| false |\n| NULL |\n+--------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/","title":"XOR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"XOR
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u4e8e\u903b\u8f91\u5f02\u6216\u8fd0\u7b97\u3002\u5982\u679c\u4efb\u610f\u4e00\u4e2a\u64cd\u4f5c\u6570\u4e3a NULL
\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a NULL
\uff1b\u5bf9\u4e8e\u975e NULL
\u64cd\u4f5c\u6570\uff0c\u5982\u679c\u6709\u5947\u6570\u4e2a\u64cd\u4f5c\u6570\u662f\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff0c\u5426\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
a XOR b
\u5728\u6570\u5b66\u8fd0\u7b97\u4e0a\u7b49\u4e8e (a AND (NOT b)) OR ((NOT a) and b)
\u3002
> SELECT column_1 XOR column_2 FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#_3","title":"\u793a\u4f8b","text":"mysql> select 1 xor 1;\n+---------+\n| 1 xor 1 |\n+---------+\n| false |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 0;\n+---------+\n| 1 xor 0 |\n+---------+\n| true |\n+---------+\n1 row in set (0.00 sec)\n\nmysql> select 1 xor null;\n+------------+\n| 1 xor null |\n+------------+\n| NULL |\n+------------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 1 xor 1;\n+---------------+\n| 1 xor 1 xor 1 |\n+---------------+\n| true |\n+---------------+\n1 row in set (0.00 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a xor b from t1;\n+---------+\n| a xor b |\n+---------+\n| true |\n| true |\n| false |\n| false |\n| NULL |\n+---------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/","title":"SQL \u8bed\u53e5\u7684\u5206\u7c7b","text":"\u5728 MatrixOne \u4e2d\uff0cSQL \u8bed\u53e5\u5305\u542b\u591a\u79cd\u5206\u7c7b\uff0c\u6bcf\u4e00\u79cd\u5206\u7c7b\u7684\u5b9a\u4e49\u4e0e\u5305\u542b\u5185\u5bb9\u6309\u7167\u5982\u4e0b\u63cf\u8ff0\u7684\u6bcf\u4e2a\u90e8\u5206\u6240\u5c55\u793a\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#ddl-","title":"DDL - \u6570\u636e\u5b9a\u4e49\u8bed\u8a00","text":"\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff08Data Definition Language\uff0cDDL\uff09\u662f DBMS \u8bed\u8a00\u7684\u4e00\u79cd\uff0c\u7528\u4e8e\u660e\u786e\u5b9a\u4e49\u6570\u636e\u5bf9\u8c61\u3002\u5728 MatrixOne \u4e2d\uff0cDDL \u8bed\u53e5\u5206\u4e3a\u4e94\u4e2a\u7c7b\u522b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#create-matrixone","title":"CREATE \u8bed\u53e5\uff0c\u521b\u5efa MatrixOne \u4e2d\u5404\u7c7b\u5bf9\u8c61","text":"\u6570\u636e\u4fee\u6539\u8bed\u8a00\uff08Data Manipulation Language, DML\uff09\u7528\u4e8e\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u5305\u62ec\u5bf9\u6570\u636e\u5e93\u4e2d\u7684\u5bf9\u8c61\u548c\u8d44\u6599\u6267\u884c\u8bbf\u95ee\u5de5\u4f5c\u7684\u7f16\u7a0b\u8bed\u53e5\u3002\u5728 MatrixOne \u4e2d\uff0cDML \u5305\u542b\u5982\u4e0b\u5206\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#insert","title":"INSERT \u8bed\u53e5\uff0c\u7528\u4e8e\u5728\u8868\u4e2d\u63d2\u5165\u65b0\u884c","text":"\u67e5\u8be2\u7c7b\u8bed\u53e5\uff08Data Query Language, DQL\uff09\u7528\u4e8e\u68c0\u7d22 MatrixOne \u4e2d\u73b0\u6709\u6570\u636e\u3002\u4ee5 SELECT \u8bed\u53e5\u4e3a\u6838\u5fc3\uff0c\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#_1","title":"\u5355\u8868\u67e5\u8be2\uff0c\u67e5\u8be2\u5c42\u7ea7\u53ea\u6709\u4e00\u5c42\uff0c\u53ea\u6d89\u53ca\u5230\u5355\u8868\u7684\u67e5\u8be2","text":"\u4e8b\u52a1\u8bed\u8a00\u662f MatrixOne \u4e2d\u63d0\u4f9b\u4e8b\u52a1\u7ba1\u63a7\u4e13\u7528\u7684\u8bed\u8a00\uff0c\u5305\u62ec\u5982\u4e0b\u51e0\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#start-transaction-matrixone-begin","title":"START TRANSACTION\uff0c\u5f00\u542f\u4e8b\u52a1\uff0c\u5728 MatrixOne \u4e2d\u53ef\u4ee5\u4f7f\u7528\u5176\u65b9\u8a00 BEGIN \u5b9e\u73b0\u66ff\u4ee3","text":"START TRANSACTION;\n TRANSACTION STATEMENTS\n ```\n\n### COMMIT\uff0c\u63d0\u4ea4\u4e8b\u52a1\uff0c\u7528\u4e8e\u5728 START TRANSACTION \u6216\u975e\u81ea\u52a8\u63d0\u4ea4\u573a\u666f\u4e0b\u5bf9\u4e8b\u52a1\u7684\u663e\u5f0f\u63d0\u4ea4\n
START TRANSACTION; TRANSACTION STATEMENTS COMMIT; OR SET AUTOCOMMIT=0; TRANSACTION STATEMENTS COMMIT; ### ROLLBACK\uff0c\u56de\u6eda\u4e8b\u52a1\uff0c\u7528\u4e8e\u5728 START TRANSACTION \u6216\u975e\u81ea\u52a8\u63d0\u4ea4\u573a\u666f\u4e0b\u5bf9\u4e8b\u52a1\u7684\u663e\u5f0f\u56de\u6eda\n
START TRANSACTION; TRANSACTION STATEMENTS ROLLBACK; OR SET AUTOCOMMIT=0; TRANSACTION STATEMENTS ROLLBACK; ```"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#dcl-","title":"DCL - \u6570\u636e\u63a7\u5236\u8bed\u8a00","text":"\u6570\u636e\u63a7\u5236\u8bed\u8a00\uff08Data Control Language, DCL\uff09\u5305\u62ec\u8d44\u6e90\u7684\u5206\u914d\u4e0e\u56de\u6536\u3001\u7528\u6237\u4e0e\u89d2\u8272\u7684\u521b\u5efa\u4e0e\u5220\u9664\u3001\u6743\u9650\u7684\u6388\u6743\u4e0e\u56de\u6536\uff0c\u5206\u4e3a\u5982\u4e0b\u5206\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#create","title":"CREATE \u8bed\u53e5\uff0c\u7528\u4e8e\u521b\u5efa\u79df\u6237\u3001\u7528\u6237\u4e0e\u89d2\u8272","text":"\u7ba1\u7406\u8bed\u8a00\u5305\u542b\u4e0e\u6570\u636e\u65e0\u76f4\u63a5\u5173\u8054\u7684\u6570\u636e\u5e93\u53c2\u6570\u3001\u8d44\u6e90\u5206\u914d\u7684\u83b7\u53d6\u4e0e\u4fee\u6539\uff0c\u5305\u62ec\u5982\u4e0b\u8bed\u53e5\u79cd\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#show","title":"SHOW \u8bed\u53e5","text":"\u901a\u8fc7 SHOW \u8bed\u53e5\uff0c\u83b7\u53d6\u4fe1\u606f\uff1a
\u901a\u8fc7 SET \u8bed\u53e5\u7528\u6237\u53ef\u4ee5\u5bf9\u5404\u7c7b\u6570\u636e\u5e93\u53c2\u6570\u8fdb\u884c\u8c03\u6574\uff0c\u5e76\u901a\u8fc7 SHOW \u547d\u4ee4\u5448\u73b0
\u4e2d\u6b62\u67d0\u4e2a\u6570\u636e\u5e93\u8fde\u63a5\u7684\u8bed\u53e5\uff1a
\u7528\u4e8e\u8fde\u63a5\u67d0\u4e2a\u5df2\u5b58\u5728\u7684\u6570\u636e\u5e93\uff1a
\u7528\u4e8e\u67e5\u770b SQL \u6267\u884c\u8ba1\u5212\uff1a
\u51c6\u5907\u4e00\u6761 SQL \u8bed\u53e5\u5e76\u7ed9\u5b83\u5206\u914d\u4e00\u4e2a\u540d\u79f0\uff1a
\u4f7f\u7528 PREPARE \u51c6\u5907\u597d\u7684\u8bed\u53e5\u540d\u79f0\u5e76\u6267\u884c\uff1a
\u91ca\u653e\u4f7f\u7528 PREPARE \u751f\u6210\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u3002\u5728\u91ca\u653e\u9884\u7f16\u8bd1\u8bed\u53e5\u540e\uff0c\u518d\u6b21\u6267\u884c\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u4f1a\u5bfc\u81f4\u9519\u8bef\uff1a
\u4fee\u6539\u79df\u6237\u4fe1\u606f\u3002
Note
> ALTER ACCOUNT [IF EXISTS]\naccount auth_option [COMMENT 'comment_string']\n\nauth_option: {\nADMIN_NAME [=] 'admin_name'\nIDENTIFIED BY 'auth_string'\n}\n\nstatus_option: {\nOPEN\n| SUSPEND\n| RESTRICTED\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#auth_option","title":"auth_option","text":"\u4fee\u6539\u79df\u6237\u7684\u5e10\u53f7\u540d\u548c\u6388\u6743\u65b9\u5f0f\uff0cauth_string
\u8868\u793a\u663e\u5f0f\u8fd4\u56de\u6307\u5b9a\u5bc6\u7801\u3002
\u8bbe\u7f6e\u79df\u6237\u7684\u72b6\u6001\u3002\u4f5c\u4e3a VARCHAR \u7c7b\u578b\u5b58\u50a8\u5728\u7cfb\u7edf\u6570\u636e\u5e93 mo_catalog \u4e0b\u7684 mo_account \u8868\u4e2d\u3002
RESTRICTED
\u72b6\u6001\u4ee5\u540e\uff0c\u8fd9\u4e2a\u79df\u6237\u53ea\u80fd\u5bf9\u6570\u636e\u5e93\u8fdb\u884c SHOW
/DELETE
/SELECT
/USE
/SET
\u64cd\u4f5c\uff0c\u5176\u4ed6\u64cd\u4f5c\u4e0d\u53ef\u4ee5\u4f7f\u7528\u3002RESTRICTED
\u72b6\u6001\u540e\uff0c\u5373\u4f7f\u79df\u6237\u6b63\u5728\u8bbf\u95ee\uff0c\u8bbf\u95ee\u884c\u4e3a\u4e5f\u5c06\u53d7\u5230\u9650\u5236\u3002OPEN
\u5373\u53ef\u89e3\u9664\u9650\u5236\uff0c\u5373\u4f7f\u7528 ALTER ACCOUNT account_name OPEN
\u89e3\u9664\u9650\u5236\u3002\u79df\u6237\u6ce8\u91ca\u4f5c\u4e3a VARCHAR \u7c7b\u578b\u5b58\u50a8\u5728\u7cfb\u7edf\u6570\u636e\u5e93 mo_catalog \u4e0b\u7684 mo_account \u8868\u4e2d\u3002
COMMENT \u53ef\u4ee5\u662f\u4efb\u610f\u5f15\u7528\u7684\u6587\u672c\uff0c\u65b0\u7684 COMMENT \u66ff\u6362\u4efb\u4f55\u73b0\u6709\u7684\u7528\u6237\u6ce8\u91ca\u3002\u5982\u4e0b\u6240\u793a\uff1a
mysql> desc mo_catalog.mo_account;\n+----------------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+----------------+--------------+------+------+---------+-------+---------+\n| account_id | INT | YES | | NULL | | |\n| account_name | VARCHAR(300) | YES | | NULL | | |\n| status | VARCHAR(300) | YES | | NULL | | |\n| created_time | TIMESTAMP | YES | | NULL | | |\n| comments | VARCHAR(256) | YES | | NULL | | |\n| suspended_time | TIMESTAMP | YES | | null | | |\n+----------------+--------------+------+------+---------+-------+---------+\n6 rows in set (0.06 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#_4","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"root1\" \u5bc6\u7801\u4e3a \"111\" \u79df\u6237\nmysql> create account acc1 admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.42 sec)\n-- \u5c06\u79df\u6237\u7684\u521d\u59cb\u5bc6\u7801 \"111\" \u4fee\u6539\u4e3a \"Abcd_1234@1234\"\nmysql> alter account acc1 admin_name \"root1\" identified by \"Abcd_1234@1234\";\nQuery OK, 0 rows affected (0.01 sec)\n-- \u4fee\u6539\u79df\u6237 \"root1\" \u7684\u5907\u6ce8\nmysql> alter account acc1 comment \"new accout\";\nQuery OK, 0 rows affected (0.02 sec)\n-- \u67e5\u770b\u9a8c\u8bc1\u662f\u5426\u7ed9\u79df\u6237 \"root1\" \u589e\u52a0\u4e86 \"new accout\" \u7684\u5907\u6ce8\nmysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| acc1 | root1 | 2023-02-15 06:26:51 | open | NULL | 5 | 34 | 787 | 0.036 | new accout |\n| sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 3767 | 0.599 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n3 rows in set (0.19 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"root1\" \u5bc6\u7801\u4e3a \"111\" \u79df\u6237\nmysql> create account accx admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.27 sec)\n-- \u4fee\u6539\u79df\u6237\u72b6\u6001\u4e3a \"suspend\"\uff0c\u5373\u6682\u505c\u7528\u6237\u8bbf\u95ee MatrixOne\nmysql> alter account accx suspend;\nQuery OK, 0 rows affected (0.01 sec)\n-- \u67e5\u770b\u4e00\u4e0b\u662f\u5426\u4fee\u6539\u72b6\u6001\u6210\u529f\nmysql> show accounts;\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| accx | root1 | 2023-02-15 06:26:51 | suspend | 2023-02-15 06:27:15 | 5 | 34 | 787 | 0.036 | new accout |\n| sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 3767 | 0.599 | system account |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n2 rows in set (0.15 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/","title":"ALTER USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4fee\u6539\u6570\u636e\u5e93\u7528\u6237\u7684\u5c5e\u6027\u548c\u5bc6\u7801\u3002
Note
ALTER USER [IF EXISTS]\n user auth_option\n\nauth_option: {\n IDENTIFIED BY 'auth_string'}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#auth_option","title":"auth_option","text":"\u4fee\u6539\u7528\u6237\u7684\u5e10\u53f7\u540d\u548c\u6388\u6743\u65b9\u5f0f\uff0cauth_string
\u8868\u793a\u663e\u5f0f\u8fd4\u56de\u6307\u5b9a\u5bc6\u7801\u3002
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"admin_1\" \u5bc6\u7801\u4e3a \"123456\" \u7528\u6237\nmysql> create user admin_1 identified by '123456';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u5c06\u7528\u6237\u7684\u521d\u59cb\u5bc6\u7801 \"123456\" \u4fee\u6539\u4e3a \"111111\"\nmysql> alter user 'admin_1' identified by '111111';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u67e5\u770b\u662f\u5426\u4fee\u6539\u5bc6\u7801\u6210\u529f\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| 0 | localhost | root | 111 | unlock | 2023-04-19 06:37:58 | NULL | PASSWORD | 0 | 0 | 0 |\n| 1 | localhost | root | 111 | unlock | 2023-04-19 06:37:58 | NULL | PASSWORD | 0 | 0 | 0 |\n| 2 | localhost | admin_1 | 111111 | unlock | 2023-04-21 06:21:31 | NULL | PASSWORD | 1 | 0 | 1 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/","title":"CREATE ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4e3a\u5176\u4e2d\u4e00\u4e2a\u96c6\u7fa4\u6210\u5458\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u79df\u6237\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE ACCOUNT [IF NOT EXISTS]\naccount auth_option\n[COMMENT 'comment_string']\n\nauth_option: {\n ADMIN_NAME [=] 'admin_name'\n IDENTIFIED BY 'auth_string'\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#auth_option","title":"auth_option","text":"\u6307\u5b9a\u79df\u6237\u9ed8\u8ba4\u7684\u5e10\u53f7\u540d\u548c\u6388\u6743\u65b9\u5f0f\uff0cauth_string
\u8868\u793a\u663e\u5f0f\u8fd4\u56de\u6307\u5b9a\u5bc6\u7801\u3002
> create account tenant_test admin_name = 'root' identified by '111' comment 'tenant_test';\nQuery OK, 0 rows affected (0.08 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/","title":"CREATE ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u7cfb\u7edf\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u89d2\u8272\u3002
\u521b\u5efa\u89d2\u8272\u540e\uff0c\u53ef\u4ee5\u5c06\u6743\u9650\u6388\u4e88\u8be5\u89d2\u8272\uff0c\u7136\u540e\u518d\u5c06\u8be5\u89d2\u8272\u6388\u4e88\u5176\u4ed6\u89d2\u8272\u6216\u5355\u4e2a\u7528\u6237\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE ROLE [IF NOT EXISTS] role [, role ] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#_3","title":"\u793a\u4f8b","text":"> create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/","title":"CREATE USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u7cfb\u7edf\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7528\u6237\u3002
\u4f7f\u7528 CREATE USER
\uff0c\u4f60\u9700\u8981\u62e5\u6709 CREATE USER
\u6743\u9650\u3002
CREATE USER
\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002> CREATE USER [IF NOT EXISTS]\n user auth_option [, user auth_option] ...\n [DEFAULT ROLE role] \n [COMMENT 'comment_string' | ATTRIBUTE 'json_object']\nauth_option: {\n IDENTIFIED BY 'auth_string'\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u9996\u6b21\u521b\u5efa\u7684\u7528\u6237\u6ca1\u6709\u6743\u9650\uff0c\u9ed8\u8ba4\u89d2\u8272\u4e3a NONE
\u3002\u8981\u5206\u914d\u6743\u9650\u6216\u89d2\u8272\uff0c\u8bf7\u4f7f\u7528 GRANT \u8bed\u53e5\u3002
CREAT USER
\u7684\u57fa\u672c SQL \u8bed\u53e5\u5982\u4e0b\uff1a
create user user_name identified by 'password';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#identified-by-auth_string","title":"IDENTIFIED BY auth_string","text":"CREATE USER
\u5141\u8bb8\u8fd9\u4e9b auth_option
\uff1a
DEFAULT ROLE
\u5b50\u53e5\u5b9a\u4e49\u5f53\u7528\u6237\u8fde\u63a5\u5230 MatrixOne \u5e76\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u65f6\uff0c\u6216\u8005\u5f53\u7528\u6237\u5728\u4f1a\u8bdd\u671f\u95f4\u6267\u884c SET ROLE
\u8bed\u53e5\u65f6\uff0c\u89d2\u8272\u4f1a\u53d8\u4e3a\u6fc0\u6d3b/\u4f7f\u7528\u72b6\u6001\u3002
create user user_name identified by 'password' default role role_rolename;\n
DEFAULT ROLE
\u5b50\u53e5\u5141\u8bb8\u5217\u51fa\u4e00\u4e2a\u6216\u591a\u4e2a\u4ee5\u9017\u53f7\u5206\u9694\u7684\u89d2\u8272\u540d\u79f0\u3002\u8fd9\u4e9b\u89d2\u8272\u5fc5\u987b\u5728\u6267\u884c CREATE USER
\u524d\u5c31\u5df2\u7ecf\u88ab\u521b\u5efa\u597d\uff1b\u5426\u5219\u8be5\u8bed\u53e5\u4f1a\u5f15\u53d1\u9519\u8bef\uff0c\u5e76\u4e14\u521b\u5efa\u7528\u6237\u5931\u8d25\u3002
> create user userx identified by '111';\nQuery OK, 0 rows affected (0.04 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#_5","title":"\u9650\u5236","text":"MatrxiOne \u6682\u4e0d\u652f\u6301 CREAT USER COMMENT
\u548c CREAT USER ATTRIBUTE
\u3002
\u5c06\u6307\u5b9a\u7684\u79df\u6237\u4ece\u67d0\u4e2a\u96c6\u7fa4\u6210\u5458\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP ACCOUNT [IF EXISTS] account\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#_3","title":"\u793a\u4f8b","text":"> drop account if exists tenant_test;\nQuery OK, 0 rows affected (0.12 sec)\n
Note
\u5982\u679c\u79df\u6237\u6b63\u5728\u4f1a\u8bdd\u4e2d\uff0c\u5f53\u79df\u6237\u88ab\u79fb\u9664\uff0c\u4f1a\u8bdd\u968f\u5373\u65ad\u5f00\uff0c\u65e0\u6cd5\u518d\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/","title":"DROP ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5c06\u6307\u5b9a\u7684\u89d2\u8272\u4ece\u7cfb\u7edf\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP ROLE [IF EXISTS] role [, role ] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#_3","title":"\u793a\u4f8b","text":"> drop role if exists rolex;\nQuery OK, 0 rows affected (0.02 sec)\n
Note
\u5982\u679c\u4f7f\u7528\u8fd9\u4e2a\u89d2\u8272\u7684\u7528\u6237\u6b63\u5728\u4f1a\u8bdd\u4e2d\uff0c\u5f53\u89d2\u8272\u88ab\u79fb\u9664\uff0c\u4f1a\u8bdd\u968f\u5373\u65ad\u5f00\uff0c\u65e0\u6cd5\u518d\u4f7f\u7528\u8fd9\u4e2a\u89d2\u8272\u8fdb\u884c\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/","title":"DROP USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5c06\u6307\u5b9a\u7684\u7528\u6237\u4ece\u7cfb\u7edf\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP USER [IF EXISTS] user [, user] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#_3","title":"\u793a\u4f8b","text":"> drop user if exists userx;\nQuery OK, 0 rows affected (0.02 sec)\n
Note
\u5982\u679c\u7528\u6237\u6b63\u5728\u4f1a\u8bdd\u4e2d\uff0c\u5f53\u7528\u6237\u88ab\u79fb\u9664\uff0c\u4f1a\u8bdd\u968f\u5373\u65ad\u5f00\uff0c\u65e0\u6cd5\u518d\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/","title":"GRANT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"GRANT
\u8bed\u53e5\u5c06\u6743\u9650\u548c\u89d2\u8272\u5206\u914d\u7ed9 MatrixOne \u7528\u6237\u548c\u89d2\u8272\u3002
\u7cfb\u7edf\u6743\u9650\u662f\u521d\u59cb\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\uff08\u5bf9\u5e94\u7684\u662f root \u7528\u6237\uff09\u7684\u6743\u9650\u3002\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\u53ef\u4ee5\u521b\u5efa\u548c\u5220\u9664\u5176\u4ed6\u79df\u6237\uff08Accounts\uff09\uff0c\u7ba1\u7406\u79df\u6237\uff08Accounts\uff09\u3002\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\u4e0d\u80fd\u7ba1\u7406\u5176\u4ed6\u79df\u6237\uff08Accounts\uff09\u540d\u4e0b\u7684\u8d44\u6e90\u3002
\u8981\u4f7f\u7528 GRANT
\u6388\u4e88\u5176\u4ed6\u7528\u6237\u6216\u89d2\u8272\u6743\u9650\uff0c\u4f60\u9996\u5148\u5fc5\u987b\u5177\u6709 WITH GRANT OPTION
\u6743\u9650\uff0c\u5e76\u4e14\u4f60\u5fc5\u987b\u5177\u6709\u4f60\u6b63\u5728\u6388\u4e88\u7684\u6743\u9650\u3002\u4e86\u89e3\u4f60\u5f53\u524d\u89d2\u8272\u7684\u6388\u6743\u60c5\u51b5\u6216\u5176\u4ed6\u89d2\u8272\u7684\u6388\u6743\u60c5\u51b5\uff0c\u8bf7\u4f7f\u7528 SHOW GRANTS
\u8bed\u53e5\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 SHOW GRANTS\u3002
REVOKE
\u8bed\u53e5\u4e0e GRANT
\u76f8\u5173\uff0c\u5141\u8bb8\u79df\u6237\u5220\u9664\u7528\u6237\u6743\u9650\u3002\u6709\u5173 REVOKE
\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 REVOKE\u3002
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u96c6\u7fa4\u9ed8\u8ba4\u6709\u4e00\u4e2a root\uff0croot \u9996\u5148\u4f7f\u7528 CREATE ACCOUNT
\u521b\u5efa\u4e00\u4e2a\u65b0\u8d26\u6237\uff0c\u5e76\u5b9a\u4e49\u5b83\u7684\u975e\u7279\u6743\u6743\u9650\uff0c\u4f8b\u5982\u5b83\u7684\u5bc6\u7801\uff0c\u7136\u540e\u79df\u6237\u4f7f\u7528 CREATE USER
\u521b\u5efa\u7528\u6237\u5e76\u4f7f\u7528 GRANT
\u5bf9\u5176\u8d4b\u6743\u3002ALTER ACCOUNT
\u53ef\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u79df\u6237\u7684\u975e\u7279\u6743\u7279\u5f81\u3002REVOKE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u7528\u6237\u7684\u6743\u9650\u7279\u5f81\u3002\u5982\u9700\u4e86\u89e3 MatrixOne \u652f\u6301\u7684\u6743\u9650\u4ee5\u53ca\u4e0d\u540c\u5c42\u7ea7\u7684\u6743\u9650\uff0c\u8bf7\u53c2\u9605 MatrixOne \u6743\u9650\u5206\u7c7b\u3002
GRANT
\u5728\u6210\u529f\u6267\u884c\u540e\uff0c\u5f97\u5230\u7ed3\u679c Query OK, 0 rows affected
\u3002\u8981\u67e5\u770b\u64cd\u4f5c\u4ea7\u751f\u7684\u6743\u9650\uff0c\u8bf7\u4f7f\u7528 SHOW GRANTS
> GRANT\n priv_type [(column_list)]\n [, priv_type [(column_list)]] ...\n ON [object_type] priv_level\n TO user_or_role [, user_or_role] ...\n\nGRANT role [, role] ...\n TO user_or_role [, user_or_role] ...\n [WITH ADMIN OPTION]\n\nobject_type: {\n TABLE\n | FUNCTION\n | PROCEDURE\n}\n\npriv_level: {\n *\n | *.*\n | db_name.*\n | db_name.tbl_name\n | tbl_name\n | db_name.routine_name\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"GRANT
\u8bed\u53e5\u5141\u8bb8\u79df\u6237\uff08Accounts\uff09\u6388\u4e88\u6743\u9650\u548c\u89d2\u8272\uff0c\u8fd9\u4e9b\u6743\u9650\u548c\u89d2\u8272\u53ef\u4ee5\u6388\u4e88\u7528\u6237\u548c\u89d2\u8272\u3002\u8bed\u6cd5\u4f7f\u7528\u8bf4\u660e\u5982\u4e0b\uff1a
GRANT
\u4e0d\u80fd\u5728\u540c\u4e00\u8bed\u53e5\u4e2d\u540c\u65f6\u6388\u4e88\u6743\u9650\u548c\u89d2\u8272\u3002
ON
\u5b50\u53e5\u533a\u5206\u8bed\u53e5\u662f\u5426\u6388\u4e88\u6743\u9650\u6216\u89d2\u8272\uff1a
\u4f7f\u7528 ON
\uff0c\u8be5\u8bed\u53e5\u6388\u4e88\u6743\u9650\u3002
\u5982\u679c\u6ca1\u6709 ON
\uff0c\u5219\u8be5\u8bed\u53e5\u6388\u4e88\u89d2\u8272\u3002
\u5fc5\u987b\u4f7f\u7528\u5355\u72ec\u7684 GRANT
\u8bed\u53e5\u5c06\u6743\u9650\u548c\u89d2\u8272\u5206\u914d\u7ed9\u4e00\u4e2a\u7528\u6237\uff0c\u6bcf\u4e2a GRANT
\u8bed\u53e5\u7684\u8bed\u6cd5\u90fd\u4e0e\u8981\u6388\u4e88\u7684\u5185\u5bb9\u76f8\u9002\u5e94\u3002
\u6570\u636e\u5e93\u6743\u9650\u9002\u7528\u4e8e\u7ed9\u5b9a\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u5bf9\u8c61\u3002\u8981\u5206\u914d\u6570\u636e\u5e93\u7ea7\u6743\u9650\uff0c\u8bf7\u4f7f\u7528 ON db_name *
\u8bed\u6cd5\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
grant all on database * to role1;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_5","title":"\u8868\u6743\u9650","text":"\u8868\u6743\u9650\u9002\u7528\u4e8e\u7ed9\u5b9a\u8868\u4e2d\u7684\u6240\u6709\u5217\u3002\u8981\u5206\u914d\u8868\u7ea7\u6743\u9650\uff0c\u8bf7\u4f7f\u7528 ON db_name.tbl_name
\u8bed\u6cd5\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
grant all on table *.* to role1;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_6","title":"\u6388\u6743\u89d2\u8272","text":"\u4e0d\u643a\u5e26 ON
\u5b50\u53e5\u7684 GRANT
\u8bed\u6cd5\u5c06\u8d4b\u6743\u7ed9\u89d2\u8272\uff0c\u800c\u4e0d\u662f\u8d4b\u6743\u7ed9\u4e2a\u4eba\u3002\u89d2\u8272\u662f\u6743\u9650\u7684\u547d\u540d\u96c6\u5408\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
grant role3 to role_user;\n
\u8981\u6388\u6743\u7ed9\u89d2\u8272\u6216\u8005\u8981\u6388\u6743\u7ed9\u7528\u6237\uff0c\u5fc5\u987b\u786e\u4fdd\u7528\u6237\u548c\u89d2\u8272\u90fd\u5b58\u5728\u3002
\u6388\u4e88\u89d2\u8272\u9700\u8981\u8fd9\u4e9b\u6743\u9650\uff1a
> drop user if exists user_prepare_01;\n> drop role if exists role_prepare_1;\n> create user user_prepare_01 identified by '123456';\n> create role role_prepare_1;\n> create database if not exists p_db;\n> grant create table ,drop table on database *.* to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant connect on account * to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant insert,select on table *.* to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant role_prepare_1 to user_prepare_01;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/","title":"REVOKE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5c06\u67d0\u4e2a\u7528\u6237\u6216\u8005\u89d2\u8272\u4e0a\u88ab\u8d4b\u4e88\u7684\u6743\u9650\u6536\u56de\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> REVOKE [IF EXISTS]\n priv_type [(column_list)]\n [, priv_type [(column_list)]] ...\n ON object_type priv_level\n\n> REVOKE [IF EXISTS] role [, role ] ...\n FROM user_or_role [, user_or_role ] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#_3","title":"\u793a\u4f8b","text":"> CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n\n> CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n\n> GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> GRANT create table on database * to role_r1;\nQuery OK, 0 rows affected (0.03 sec)\n\n> SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account `mouser`@`localhost` |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n\n> REVOKE role_r1 from mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> SHOW GRANT for mouser@localhost;\n+------------------------------------------------+\n| Grants for mouser@localhost |\n+------------------------------------------------+\n| GRANT connect ON account `mouser`@`localhost` |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/","title":"ALTER PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER PUBLICATION
\u4fee\u6539\u53d1\u5e03\u5185\u5bb9\u3002
ALTER PUBLICATION pubname \n [ACCOUNT \n { ALL\n | account_name, [, ... ]\n | ADD account_name, [, ... ]\n | DROP account_name, [, ... ]]\n [COMMENT 'string']\n [DATABASE database_name]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nalter publication pub3 account add accx;--\u4fee\u6539\u53d1\u5e03\u8303\u56f4\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication |\n+-------------+-----------------------------------------------------------------------+\n| pub3 | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+----------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+----------------+----------+\n| pub3 | t | 2024-04-24 11:17:37 | 2024-04-24 11:17:44 | acc0,acc1,accx | |\n+-------------+----------+---------------------+---------------------+----------------+----------+\n1 row in set (0.01 sec)\n\nalter publication pub3 comment \"this is pubs\";--\u4fee\u6539\u53d1\u5e03\u5907\u6ce8\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| pub3 | t | 2024-04-24 11:17:37 | 2024-04-24 11:41:43 | acc0,acc1,accx | this is pubs |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n1 row in set (0.00 sec)\n\ncreate database new_pub3;\nalter publication pub3 database new_pub3;--\u4fee\u6539\u53d1\u5e03\u6570\u636e\u5e93\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| pub3 | new_pub3 | 2024-04-24 11:17:37 | 2024-04-24 11:43:36 | acc0,acc1,accx | this is pubs |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-reindex/","title":"ALTER REINDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-reindex/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER TABLE ... ALTER REINDEX
\u7528\u4e8e\u5bf9\u5411\u91cf\u8868\u4e2d\u7684\u6570\u636e\u91cd\u65b0\u8fdb\u884c\u5206\u533a\u3002
\u5f53\u5411\u91cf\u8868\u5185\u7684\u6570\u636e\u8bb0\u5f55\u5927\u5e45\u589e\u957f\u65f6\uff0c\u539f\u6709\u7684\u805a\u7c7b\u4e2d\u5fc3\u96c6\u5408\u53ef\u80fd\u4e0d\u518d\u9002\u7528\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u5fc5\u987b\u5bf9\u6570\u636e\u91cd\u65b0\u8fdb\u884c\u7d22\u5f15\u5904\u7406\uff0c\u65e8\u5728\u8bc6\u522b\u51fa\u65b0\u7684\u805a\u7c7b\u4e2d\u5fc3\uff0c\u5e76\u636e\u6b64\u91cd\u65b0\u5212\u5206\u6570\u636e\u96c6\u3002
Note
\u5728\u91cd\u6784\u7d22\u5f15\u671f\u95f4\uff0c\u65e0\u6cd5\u5bf9\u8be5\u8868\u8fdb\u884c\u6570\u636e\u63d2\u5165\u64cd\u4f5c\u3002
LISTS \u7684\u7406\u60f3\u503c\u4e3a\uff1a
> ALTER TABLE table_name ALTER REINDEX index_name LISTS=XX\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-reindex/#_3","title":"\u793a\u4f8b","text":"SET GLOBAL experimental_ivf_index = 1;--\u9700\u8bbe\u7f6e\u53c2\u6570 experimental_ivf_index \u503c\u4e3a 1\uff08\u9ed8\u8ba4 0\uff09\u624d\u80fd\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\ndrop table if exists t1;\ncreate table t1(n1 int,n2 vecf32(3));\ninsert into t1 values(1,\"[1,2,3]\"),(2,\"[2,3,4]\"),(3,\"[3,4,5]\");\ncreate index idx_t1 using ivfflat on t1(n2) lists=2 op_type \"vector_l2_ops\";\n\nmysql> show create table t1;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`n1` INT DEFAULT NULL,\n`n2` VECF32(3) DEFAULT NULL,\nKEY `idx_t1` USING ivfflat (`n2`) lists = 2 op_type 'vector_l2_ops' ) |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show index from t1;\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Index_params | Visible | Expression |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| t1 | 1 | idx_t1 | 1 | n2 | A | 0 | NULL | NULL | YES | ivfflat | | | {\"lists\":\"2\",\"op_type\":\"vector_l2_ops\"} | YES | NULL |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n1 row in set (0.00 sec)\n\nmysql> alter table t1 alter reindex idx_t1 ivfflat lists=100;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> show create table t1;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`n1` INT DEFAULT NULL,\n`n2` VECF32(3) DEFAULT NULL,\nKEY `idx_t1` USING ivfflat (`n2`) lists = 100 op_type 'vector_l2_ops' ) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> show index from t1;\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-------------------------------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Index_params | Visible | Expression |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-------------------------------------------+---------+------------+\n| t1 | 1 | idx_t1 | 1 | n2 | A | 0 | NULL | NULL | YES | ivfflat | | | {\"lists\":\"100\",\"op_type\":\"vector_l2_ops\"} | YES | NULL |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-------------------------------------------+---------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-sequence/","title":"ALTER SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-sequence/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER SEQUENCE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u5e8f\u5217\u3002
> ALTER SEQUENCE [ IF EXISTS ] SEQUENCE_NAME\n[ AS data_type ]\n[ INCREMENT [ BY ] increment ]\n[ MINVALUE minvalue] [ MAXVALUE maxvalue]\n[ START [ WITH ] start ] [ [ NO ] CYCLE ]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-sequence/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"[ IF EXISTS ]
\uff1a\u53ef\u9009\u7684\u5b50\u53e5\uff0c\u8868\u793a\u5982\u679c\u6307\u5b9a\u7684\u5e8f\u5217\u4e0d\u5b58\u5728\uff0c\u4e5f\u4e0d\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\u5982\u679c\u4f7f\u7528\u4e86\u6b64\u5b50\u53e5\uff0c\u7cfb\u7edf\u5c06\u68c0\u67e5\u5e8f\u5217\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5c06\u5ffd\u7565\u4fee\u6539\u8bf7\u6c42\u3002
SEQUENCE_NAME
\uff1a\u8981\u4fee\u6539\u7684\u5e8f\u5217\u7684\u540d\u79f0\u3002
[ AS data_type ]
\uff1a\u53ef\u9009\u5b50\u53e5\uff0c\u5b83\u5141\u8bb8\u60a8\u4e3a\u5e8f\u5217\u6307\u5b9a\u6570\u636e\u7c7b\u578b\u3002\u901a\u5e38\uff0c\u5e8f\u5217\u7684\u6570\u636e\u7c7b\u578b\u662f\u6574\u6570\u3002
[ INCREMENT [ BY ] increment ]
\uff1a\u8fd9\u662f\u6307\u5b9a\u5e8f\u5217\u7684\u589e\u91cf\u503c\u3002\u5e8f\u5217\u7684\u589e\u91cf\u503c\u662f\u5728\u6bcf\u6b21\u9012\u589e\u6216\u9012\u51cf\u65f6\u8981\u6dfb\u52a0\u5230\u5f53\u524d\u503c\u7684\u6570\u91cf\u3002\u5982\u679c\u672a\u6307\u5b9a\u589e\u91cf\u503c\uff0c\u901a\u5e38\u9ed8\u8ba4\u4e3a 1\u3002
[ MINVALUE minvalue ]
\uff1a\u8fd9\u662f\u5e8f\u5217\u7684\u6700\u5c0f\u503c\uff0c\u5b83\u6307\u5b9a\u4e86\u5e8f\u5217\u5141\u8bb8\u7684\u6700\u5c0f\u503c\u3002\u5982\u679c\u6307\u5b9a\u4e86\u6700\u5c0f\u503c\uff0c\u5e8f\u5217\u7684\u5f53\u524d\u503c\u4e0d\u80fd\u4f4e\u4e8e\u6b64\u503c\u3002
[ MAXVALUE maxvalue ]
\uff1a\u8fd9\u662f\u5e8f\u5217\u7684\u6700\u5927\u503c\uff0c\u5b83\u6307\u5b9a\u4e86\u5e8f\u5217\u5141\u8bb8\u7684\u6700\u5927\u503c\u3002\u5982\u679c\u6307\u5b9a\u4e86\u6700\u5927\u503c\uff0c\u5e8f\u5217\u7684\u5f53\u524d\u503c\u4e0d\u80fd\u8d85\u8fc7\u6b64\u503c\u3002
[ START [ WITH ] start ]
\uff1a\u8fd9\u662f\u5e8f\u5217\u7684\u8d77\u59cb\u503c\uff0c\u5b83\u6307\u5b9a\u5e8f\u5217\u7684\u521d\u59cb\u503c\u3002\u5982\u679c\u672a\u6307\u5b9a\u8d77\u59cb\u503c\uff0c\u901a\u5e38\u9ed8\u8ba4\u4e3a 1\u3002
[ [ NO ] CYCLE ]
\uff1a\u53ef\u9009\u5b50\u53e5\uff0c\u7528\u4e8e\u6307\u5b9a\u662f\u5426\u5faa\u73af\u4f7f\u7528\u5e8f\u5217\u503c\u3002\u5982\u679c\u6307\u5b9a\u4e86 NO CYCLE
\uff0c\u5219\u5728\u8fbe\u5230\u6700\u5927\u503c\u6216\u6700\u5c0f\u503c\u540e\uff0c\u5e8f\u5217\u5c06\u505c\u6b62\u9012\u589e\u6216\u9012\u51cf\u3002\u5982\u679c\u672a\u6307\u5b9a\u6b64\u5b50\u53e5\uff0c\u901a\u5e38\u9ed8\u8ba4\u4e3a\u4e0d\u5faa\u73af\u3002
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a alter_seq_01 \u7684\u5e8f\u5217\uff0c\u5c06\u5e8f\u5217\u7684\u589e\u91cf\u8bbe\u7f6e\u4e3a 2\uff0c\u8bbe\u7f6e\u5e8f\u5217\u7684\u6700\u5c0f\u503c\u4e3a 30\uff0c\u6700\u5927\u503c\u4e3a 100\uff0c\u5e76\u542f\u7528\u5faa\u73af\ncreate sequence alter_seq_01 as smallint increment by 2 minvalue 30 maxvalue 100 cycle;\n\nmysql> show sequences;\n+--------------+-----------+\n| Names | Data Type |\n+--------------+-----------+\n| alter_seq_01 | SMALLINT |\n+--------------+-----------+\n1 row in set (0.00 sec)\n\nmysql> alter sequence alter_seq_01 as bigint;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show sequences;\n+--------------+-----------+\n| Names | Data Type |\n+--------------+-----------+\n| alter_seq_01 | BIGINT |\n+--------------+-----------+\n1 row in set (0.00 sec)\n\n-- \u53d6\u6d88\u5e8f\u5217 alter_seq_01 \u7684\u5faa\u73af\nmysql> alter sequence alter_seq_01 no cycle;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 30 | 30 |\n+-----------------------+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 32 | 32 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\n-- \u5c06\u5e8f\u5217 alter_seq_01 \u7684\u8d77\u59cb\u503c\u8bbe\u7f6e\u4e3a 40\nmysql> alter sequence alter_seq_01 start with 40;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 40 | 40 |\n+-----------------------+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 42 | 42 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\n-- \u5c06\u5e8f\u5217 alter_seq_01 \u7684\u589e\u91cf\u503c\u8bbe\u7f6e\u4e3a 3\nmysql> alter sequence alter_seq_01 increment by 3;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 40 | 40 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 43 | 43 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/","title":"ALTER STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER STAGE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u5df2\u547d\u540d\u7684\u5185\u90e8\u6216\u5916\u90e8\u9636\u6bb5\u7684\u5c5e\u6027\u3002
Note
\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u5373 root \u7528\u6237\uff09\u548c\u79df\u6237\u7ba1\u7406\u5458\u53ef\u4ee5\u4fee\u6539\u6570\u636e\u9636\u6bb5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> ALTER STAGE [ IF EXISTS ] { stage_name }\n { StageParams }\n [ directoryTableParams ]\n [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"IF EXISTS
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u5728\u4fee\u6539 Stage \u65f6\u68c0\u67e5\u662f\u5426\u5df2\u5b58\u5728\u8981\u4fee\u6539\u7684 Stage\u3002
stage_name
\uff1a\u8981\u4fee\u6539\u7684 Stage \u7684\u540d\u79f0\u3002
StageParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u914d\u7f6e\u53c2\u6570\u3002
endpoint
\uff1aStage \u7684\u8fde\u63a5 URL\uff0c\u6307\u5b9a\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684\u4f4d\u7f6e\u3002\u5bf9\u4e8e\u4e0d\u540c\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff08\u5982 Amazon S3\u3001Aliyun OSS\u3001\u6587\u4ef6\u7cfb\u7edf\u7b49\uff09\uff0c\u8fd9\u4e2a URL \u7684\u5185\u5bb9\u53ef\u80fd\u6709\u6240\u4e0d\u540c\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com
CREDENTIALS
\uff1a\u8fd9\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\uff0c\u5305\u542b\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u6240\u9700\u7684\u51ed\u8bc1\u4fe1\u606f\uff0c\u5982 access_key_id
\u3001secret_access_key
\u7b49\u3002
directoryTableParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u76ee\u5f55\u8868\uff08directory table\uff09\u7684\u914d\u7f6e\u3002
ENABLE
\uff1a\u662f\u5426\u4fee\u6539\u542f\u7528\u76ee\u5f55\u8868\uff0c\u503c\u4e3a TRUE
\u6216 FALSE
\u3002CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL | STATUS | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1 | /Users/Prinz/03testrepo/csv | ENABLED | |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.01 sec)\n\n-- \u4fee\u6539 stage\nmysql> ALTER STAGE stage1 SET COMMENT 'user stage';\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+------------+\n| STAGE_NAME | URL | STATUS | COMMENT |\n+------------+-----------------------------+---------+------------+\n| stage1 | /Users/Prinz/03testrepo/csv | ENABLED | user stage |\n+------------+-----------------------------+---------+------------+\n1 row in set (0.00 sec)\n\n-- \u7981\u7528\u540d\u4e3a 'stage1' \u7684\u6570\u636e\u9636\u6bb5\nmysql> ALTER STAGE stage1 SET ENABLE = FALSE;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- \u5c1d\u8bd5\u5c06 user \u8868\u7684\u6570\u636e\u5bfc\u51fa\u5230\u540d\u4e3a 'stage1:/user.csv' \u7684\u6570\u636e\u9636\u6bb5\u4e2d\uff0c\u4f46 stage1 \u5df2\u7ecf\u88ab\u7981\u7528\uff0c\u6240\u4ee5\u5df2\u4e0d\u53ef\u7528\uff0c\u4ea7\u751f\u62a5\u9519\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is invalid, please check\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/","title":"ALTER TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER TABLE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u6570\u636e\u8868\u7ed3\u6784\u3002
ALTER TABLE tbl_name\n [alter_option [, alter_option] ...]\n\nalter_option: {\n table_options\n | ADD [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | ADD [COLUMN] (col_name column_definition,...)\n | ADD {[INDEX | KEY] [index_name]\n [index_option] ...\n | ADD [CONSTRAINT] UNIQUE [INDEX | KEY]\n [index_name][index_option] ...\n | ADD [CONSTRAINT] FOREIGN KEY\n [index_name] (col_name,...)\n reference_definition\n | ADD [CONSTRAINT [symbol]] PRIMARY KEY\n [index_type] (key_part,...)\n | CHANGE [COLUMN] old_col_name new_col_name column_definition\n [FIRST | AFTER col_name]\n | ALTER INDEX index_name {VISIBLE | INVISIBLE}\n | DROP [COLUMN] col_name\n | DROP {INDEX | KEY} index_name\n | DROP FOREIGN KEY fk_symbol\n | DROP PRIMARY KEY\n | RENAME [TO | AS] new_tbl_name\n | MODIFY [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | RENAME COLUMN old_col_name TO new_col_name\n }\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\nindex_option: {\n COMMENT[=]'string'\n}\ntable_options:\n table_option [[,] table_option] ...\ntable_option: {\n COMMENT [=] 'string'\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"\u4e0b\u9762\u662f\u5404\u4e2a\u53c2\u6570\u7684\u91ca\u4e49\uff1a
ALTER TABLE tbl_name
\uff1a\u8868\u793a\u4fee\u6539\u540d\u4e3a tbl_name
\u7684\u8868\u3002alter_option
\uff1a\u8868\u793a\u53ef\u4ee5\u6267\u884c\u4e00\u4e2a\u6216\u591a\u4e2a\u66f4\u6539\u9009\u9879\uff0c\u7528\u9017\u53f7\u5206\u9694\u3002
table_options
\uff1a\u7528\u4e8e\u8bbe\u7f6e\u6216\u4fee\u6539\u8868\u7684\u9009\u9879\uff0c\u4f8b\u5982\u8868\u7684\u6ce8\u91ca\uff08COMMENT\uff09\u3002ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name]
\uff1a\u5728\u8868\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u65b0\u5217\uff0c\u53ef\u4ee5\u6307\u5b9a\u65b0\u5217\u63d2\u5165\u7684\u4f4d\u7f6e\uff08\u5728\u67d0\u5217\u4e4b\u524d\u6216\u4e4b\u540e\uff09\u3002ADD [COLUMN] (col_name column_definition,...)
\uff1a\u540c\u65f6\u6dfb\u52a0\u591a\u4e2a\u65b0\u5217\u3002ADD {[INDEX | KEY] [index_name] [index_option] ...
\uff1a\u6dfb\u52a0\u4e00\u4e2a\u7d22\u5f15\uff0c\u53ef\u4ee5\u6307\u5b9a\u7d22\u5f15\u540d\u548c\u7d22\u5f15\u9009\u9879\uff08\u4f8b\u5982\uff0c\u6ce8\u91ca\uff09\u3002ADD [CONSTRAINT] UNIQUE [INDEX | KEY] [index_name][index_option] ...
\uff1a\u6dfb\u52a0\u4e00\u4e2a UNIQUE \u7ea6\u675f\u6216 UNIQUE \u7d22\u5f15\u3002ADD [CONSTRAINT] FOREIGN KEY [index_name] (col_name,...) reference_definition
\uff1a\u6dfb\u52a0\u4e00\u4e2a FOREIGN KEY \u7ea6\u675f\u3002ADD [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (key_part,...)
\uff1a\u6dfb\u52a0\u4e3b\u952e\u7ea6\u675f\u3002CHANGE [COLUMN] old_col_name new_col_name column_definition [FIRST | AFTER col_name]
\uff1a\u4fee\u6539\u5217\u5b9a\u4e49\u3001\u5217\u540d\u4e0e\u987a\u5e8f\u3002ALTER INDEX index_name {VISIBLE | INVISIBLE}
\uff1a\u66f4\u6539\u7d22\u5f15\u7684\u53ef\u89c1\u6027\u3002DROP [COLUMN] col_name
\uff1a\u5220\u9664\u4e00\u4e2a\u5217\u3002DROP {INDEX | KEY} index_name
\uff1a\u5220\u9664\u4e00\u4e2a\u7d22\u5f15\u3002DROP FOREIGN KEY fk_symbol
\uff1a\u5220\u9664\u4e00\u4e2a FOREIGN KEY \u7ea6\u675f\u3002DROP PRIMARY KEY
\uff1a\u5220\u9664\u4e3b\u952e\u3002RENAME [TO | AS] new_tbl_name
\uff1a\u91cd\u547d\u540d\u6574\u4e2a\u8868\u3002MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name]
\uff1a\u4fee\u6539\u5217\u5b9a\u4e49\u4e0e\u987a\u5e8f\u3002RENAME COLUMN old_col_name TO new_col_name
\uff1a\u91cd\u547d\u540d\u5217\u3002key_part
\uff1a\u8868\u793a\u7d22\u5f15\u7684\u7ec4\u6210\u90e8\u5206\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u540d\uff08\u5728\u521b\u5efa\u4e00\u4e2a\u6587\u672c\u5217\u7684\u7d22\u5f15\u65f6\uff0c\u4f60\u53ef\u4ee5\u4e3a\u7d22\u5f15\u6307\u5b9a\u4e00\u4e2a\u957f\u5ea6\uff0c\u5b57\u7b26\u957f\u5ea6\u53ef\u53d8\u3002\u5982\u679c\u60a8\u5728\u521b\u5efa\u7d22\u5f15\u65f6\u4f7f\u7528\u5217\u540d\u4e14\u4e0d\u6307\u5b9a\u957f\u5ea6\uff0c\u7d22\u5f15\u5c06\u4f1a\u4f7f\u7528\u6574\u4e2a\u5217\u7684\u503c\u4f5c\u4e3a\u7d22\u5f15\u7ec4\u6210\u90e8\u5206\u3002\u8fd9\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u5bfc\u81f4\u6027\u80fd\u964d\u4f4e\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u8f83\u5927\u6587\u672c\u5217\u6216\u4e8c\u8fdb\u5236\u6570\u636e\u5217\u65f6\u3002\u5bf9\u4e8e\u8f83\u5c0f\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982\u6574\u6570\u6216\u65e5\u671f\uff0c\u901a\u5e38\u4e0d\u9700\u8981\u6307\u5b9a\u957f\u5ea6\uff09\u3002
index_option
\uff1a\u8868\u793a\u7d22\u5f15\u7684\u9009\u9879\uff0c\u4f8b\u5982\u6ce8\u91ca\uff08COMMENT\uff09\u3002table_options
\uff1a\u8868\u793a\u8868\u7684\u9009\u9879\uff0c\u5982\u8868\u7684\u6ce8\u91ca\uff08COMMENT\uff09\u3002table_option
\uff1a\u5177\u4f53\u7684\u8868\u9009\u9879\uff0c\u4f8b\u5982\u6ce8\u91ca\uff08COMMENT\uff09\u3002-- \u521b\u5efa f1 \u8868\uff0c\u5305\u542b\u4e24\u4e2a\u6574\u6570\u5217\uff1afa\uff08\u4e3b\u952e\uff09\u548c fb\uff08\u5177\u6709\u552f\u4e00\u7ea6\u675f\u7684\u952e\uff09\nCREATE TABLE f1(fa INT PRIMARY KEY, fb INT UNIQUE KEY);\n-- \u521b\u5efa c1 \u8868\uff0c\u5305\u542b\u4e24\u4e2a\u6574\u6570\u5217\uff1aca \u548c cb\nCREATE TABLE c1 (ca INT, cb INT);\n-- \u4e3a c1 \u8868\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a ffa \u7684\u5916\u952e\u7ea6\u675f\uff0c\u5c06 c1 \u8868\u7684 ca \u5217\u4e0e f1 \u8868\u7684 fa \u5217\u76f8\u5173\u8054\nALTER TABLE c1 ADD CONSTRAINT ffa FOREIGN KEY (ca) REFERENCES f1(fa);\n-- \u5411 f1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(2, 2)\nINSERT INTO f1 VALUES (2, 2);\n-- \u5411 c1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- \u5411 c1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(2, 2)\nINSERT INTO c1 VALUES (2, 2);\n-- \u4ece c1 \u8868\u4e2d\u9009\u62e9\u6240\u6709\u8bb0\u5f55\uff0c\u5e76\u6309 ca \u5217\u6392\u5e8f\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca | cb |\n+------+------+\n| 2 | 2 |\n+------+------+\n1 row in set (0.01 sec)\n-- \u4ece c1 \u8868\u4e2d\u5220\u9664\u540d\u4e3a ffa \u7684\u5916\u952e\u7ea6\u675f\nALTER TABLE c1 DROP FOREIGN KEY ffa;\n-- \u5411 c1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- \u4ece c1 \u8868\u4e2d\u9009\u62e9\u6240\u6709\u8bb0\u5f55\uff0c\u5e76\u6309 ca \u5217\u6392\u5e8f\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca | cb |\n+------+------+\n| 1 | 1 |\n| 2 | 2 |\n+------+------+\n2 rows in set (0.01 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 't1' \u7684\u65b0\u8868\uff0c\u5305\u542b\u5217 a\u3001b\u3001c \u548c d\u3002\u5217 'a' \u7684\u6570\u636e\u7c7b\u578b\u4e3a INTEGER\uff0c'b' \u7684\u6570\u636e\u7c7b\u578b\u4e3a CHAR(10)\uff0c'c' \u7684\u6570\u636e\u7c7b\u578b\u4e3a DATE\uff0c'd' \u7684\u6570\u636e\u7c7b\u578b\u4e3a DECIMAL(7,2)\u3002\u5728\u5217 'a' \u548c 'b' \u4e0a\u6dfb\u52a0\u4e86\u4e00\u4e2a\u552f\u4e00\u952e\u3002\nCREATE TABLE t1(a INTEGER, b CHAR(10), c DATE, d DECIMAL(7,2), UNIQUE KEY(a, b));\n\n-- \u67e5\u770b\u8868 't1' \u7684\u7ed3\u6784\u3002\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | NULL | | |\n| b | CHAR(10) | YES | | NULL | | |\n| c | DATE(0) | YES | | NULL | | |\n| d | DECIMAL64(7) | YES | | NULL | | |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- \u5411\u8868 't1' \u63d2\u5165\u4e09\u884c\u6570\u636e\u3002\nINSERT INTO t1 VALUES(1, 'ab', '1980-12-17', 800);\nINSERT INTO t1 VALUES(2, 'ac', '1981-02-20', 1600);\nINSERT INTO t1 VALUES(3, 'ad', '1981-02-22', 500);\n\n-- \u663e\u793a\u8868 't1' \u4e2d\u7684\u6240\u6709\u884c\u3002\nmysql> select * from t1;\n+------+------+------------+---------+\n| a | b | c | d |\n+------+------+------------+---------+\n| 1 | ab | 1980-12-17 | 800.00 |\n| 2 | ac | 1981-02-20 | 1600.00 |\n| 3 | ad | 1981-02-22 | 500.00 |\n+------+------+------------+---------+\n3 rows in set (0.01 sec)\n\n-- \u4fee\u6539\u8868 't1'\uff0c\u5728\u5217 'a' \u548c 'b' \u4e0a\u6dfb\u52a0\u4e3b\u952e 'pk1'\u3002\nmysql> alter table t1 add primary key pk1(a, b);\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u518d\u6b21\u67e5\u770b\u4fee\u6539\u540e\u7684\u8868 't1' \u7684\u7ed3\u6784\u3002\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a | INT(32) | NO | PRI | null | | |\n| b | CHAR(10) | NO | PRI | null | | |\n| c | DATE(0) | YES | | null | | |\n| d | DECIMAL64(7) | YES | | null | | |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- \u6dfb\u52a0\u4e3b\u952e\u540e\uff0c\u518d\u6b21\u663e\u793a\u8868 't1' \u4e2d\u7684\u6240\u6709\u884c\u3002\nmysql> select * from t1;\n+------+------+------------+---------+\n| a | b | c | d |\n+------+------+------------+---------+\n| 1 | ab | 1980-12-17 | 800.00 |\n| 2 | ac | 1981-02-20 | 1600.00 |\n| 3 | ad | 1981-02-22 | 500.00 |\n+------+------+------------+---------+\n3 rows in set (0.00 sec)\n
CREATE TABLE t1 (a INTEGER PRIMARY KEY, b CHAR(10));\nmysql> desc t1;\n+-------+----------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+----------+------+------+---------+-------+---------+\n| a | INT(32) | NO | PRI | NULL | | |\n| b | CHAR(10) | YES | | NULL | | |\n+-------+----------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\ninsert into t1 values(1, 'ab');\ninsert into t1 values(2, 'ac');\ninsert into t1 values(3, 'ad');\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | ab |\n| 2 | ac |\n| 3 | ad |\n+------+------+\n3 rows in set (0.01 sec)\n\n-- \u4fee\u6539\u8868 't1'\uff0c\u5c06\u5217 'a' \u7684\u540d\u79f0\u6539\u4e3a 'x'\uff0c\u5e76\u5c06\u6570\u636e\u7c7b\u578b\u4fee\u6539\u4e3a VARCHAR(20)\u3002\nmysql> alter table t1 change a x VARCHAR(20);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> desc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| x | VARCHAR(20) | NO | PRI | null | | |\n| b | CHAR(10) | YES | | null | | |\n+-------+-------------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1;\n+------+------+\n| x | b |\n+------+------+\n| 1 | ab |\n| 2 | ac |\n| 3 | ad |\n+------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#_5","title":"\u9650\u5236","text":"CHANGE [COLUMN]
\uff0cMODIFY [COLUMN]
\uff0cRENAME COLUMN
\uff0cADD [CONSTRAINT [symbol]] PRIMARY KEY
\uff0cDROP PRIMARY KEY
\u548c ALTER COLUMN ORDER BY
\u53ef\u4ee5\u5728 ALTER TABLE \u8bed\u53e5\u4e2d\u81ea\u7531\u7ec4\u5408\u4f7f\u7528\uff0c\u4f46\u6682\u65f6\u4e0d\u652f\u6301\u4e0e\u5176\u4ed6\u5b50\u53e5\u4e00\u8d77\u4f7f\u7528\u3002ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002CREATE TABLE ... CLUSTER BY...
\u6240\u5efa\u7684\u8868\uff0c\u4e0d\u652f\u6301\u4f7f\u7528 ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002ALTER VIEW
\u7528\u4e8e\u66f4\u6539\u89c6\u56fe\u3002
\u5982\u679c\u8bed\u6cd5\u53c2\u6570\u5217\u8868\u4e2d\u547d\u540d\u7684\u89c6\u56fe\u4e0d\u5b58\u5728\uff0c\u5219\u8bed\u53e5\u62a5\u9519\uff1a\u8be5\u89c6\u56fe\u65e0\u6548\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> ALTER VIEW view_name [(column_list)]\n AS select_statement\n [WITH [CASCADED | LOCAL] CHECK OPTION]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1),(2),(3),(4);\ncreate view v5 as select * from t1;\n\nmysql> select * from v5;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n4 rows in set (0.01 sec)\n\nalter view v5 as select * from t1 where a=1;\n\nmysql> select * from v5;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n\nalter view v5 as select * from t1 where a > 2;\n\nmysql> select * from v5;\n+------+\n| a |\n+------+\n| 3 |\n| 4 |\n+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/","title":"CREATE CLUSTER TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u96c6\u7fa4\u8868\u662f\u6307\u5728\u7cfb\u7edf\u79df\u6237\u4e0b\u7684\u7cfb\u7edf\u5e93 mo_catalog
\u521b\u5efa\u7684\u8868\uff0c\u8be5\u8868\u4f1a\u5728\u5176\u5b83\u79df\u6237\u4e0b\u540c\u65f6\u751f\u6548\u3002\u7cfb\u7edf\u79df\u6237\u4e0b\u53ef\u5bf9\u8be5\u8868\u8fdb\u884c DDL \u4e0e DML \u64cd\u4f5c\uff0c\u5176\u5b83\u79df\u6237\u53ea\u80fd\u8fdb\u884c\u67e5\u8be2\u6216\u57fa\u4e8e\u8be5\u8868\u521b\u5efa\u89c6\u56fe\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u8bb2\u8ff0\u5982\u4f55\u5728 MatrixOne \u6570\u636e\u5e93\u5efa\u7acb\u96c6\u7fa4\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE CLUSTER TABLE [IF NOT EXISTS] tbl_name\n (create_definition,...)\n [table_options]\n [partition_options]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/#_3","title":"\u4f7f\u7528\u8bf4\u660e","text":"\u521b\u5efa\u96c6\u7fa4\u8868\u4ec5\u9650\u4e8e sys \u79df\u6237\u7ba1\u7406\u5458\u89d2\u8272\u624d\u80fd\u521b\u5efa\u3002
sys \u79df\u6237\u7684\u96c6\u7fa4\u8868\u5305\u542b\u6240\u6709\u6570\u636e\uff0c\u5176\u5b83\u79df\u6237\u4e0b\u53ef\u80fd\u53ea\u4f1a\u770b\u5230\u90e8\u5206\u6570\u636e\u3002
\u5728\u96c6\u7fa4\u8868\u4e2d\uff0caccount_id
\u5b57\u6bb5\u662f\u81ea\u52a8\u751f\u6210\u7684\uff0c\u8868\u793a\u5728\u63d2\u5165\u6216 LOAD DATA \u65f6\u6307\u5b9a\u6570\u636e\u7684\u53ef\u89c1\u79df\u6237\u7684 id\uff0c\u6bcf\u6761\u6570\u636e\u53ea\u80fd\u9009\u62e9\u4e00\u4e2a\u53ef\u89c1\u79df\u6237\uff0c\u82e5\u60a8\u60f3\u591a\u4e2a\u79df\u6237\u90fd\u80fd\u67e5\u770b\u8be5\u6570\u636e\uff0c\u9700\u8981\u591a\u6b21\u63d2\u5165\u6307\u5b9a\u4e0d\u540c\u79df\u6237 id\uff0c\u8be5\u5b57\u6bb5\u6570\u636e\u5728\u5176\u5b83\u79df\u6237\u4e2d\u67e5\u8be2\u4e0d\u4f1a\u8fd4\u56de\u3002
\u96c6\u7fa4\u8868\u4e0d\u80fd\u4e3a\u5916\u8868\u6216\u4e34\u65f6\u8868\uff0c\u5728\u6240\u6709\u79df\u6237\u4e0b\u7684\u8868\u7ed3\u6784\u5b8c\u5168\u76f8\u540c\u3002
--\u521b\u5efa\u4e24\u4e2a\u79df\u6237 test1 \u548c test2\nmysql> create account test1 admin_name = 'root' identified by '111' open comment 'tenant_test';\nQuery OK, 0 rows affected (0.44 sec)\n\nmysql> create account test2 admin_name = 'root' identified by '111' open comment 'tenant_test';\nQuery OK, 0 rows affected (0.51 sec)\n\n--\u5728 sys \u79df\u6237\u4e0b\u521b\u5efa\u96c6\u7fa4\u8868\nmysql> use mo_catalog;\nDatabase changed\nmysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> create cluster table t1(a int);\nQuery OK, 0 rows affected (0.01 sec)\n\n--\u67e5\u770b\u79df\u6237 id\nmysql> select * from mo_account;\n+------------+--------------+--------+---------------------+----------------+---------+----------------+\n| account_id | account_name | status | created_time | comments | version | suspended_time |\n+------------+--------------+--------+---------------------+----------------+---------+----------------+\n| 0 | sys | open | 2024-01-11 08:56:57 | system account | 1 | NULL |\n| 6 | test1 | open | 2024-01-15 03:15:40 | tenant_test | 7 | NULL |\n| 7 | test2 | open | 2024-01-15 03:15:48 | tenant_test | 8 | NULL |\n+------------+--------------+--------+---------------------+----------------+---------+----------------+\n3 rows in set (0.01 sec)\n\n--\u5728\u96c6\u7fa4\u8868 t1 \u4e2d\u63d2\u5165\u6570\u636e\u53ea\u5bf9 test1 \u79df\u6237\u53ef\u89c1\nmysql> insert into t1 values(1,6),(2,6),(3,6);\nQuery OK, 3 rows affected (0.01 sec)\n\n--\u5728 sys \u79df\u6237\u4e2d\u67e5\u770b t1 \u7684\u6570\u636e\uff0c\u53ef\u770b\u5230\u5305\u542b`account_id`\u5b57\u6bb5\u5728\u5185\u7684\u6240\u6709\u6570\u636e\nmysql> select * from t1;\n+------+------------+\n| a | account_id |\n+------+------------+\n| 1 | 6 |\n| 2 | 6 |\n| 3 | 6 |\n+------+------------+\n3 rows in set (0.00 sec)\n\n--\u5728 test1 \u79df\u6237\u4e2d\u67e5\u770b t1 \u7684\u6570\u636e\uff0c\u53ef\u4ee5\u770b\u5230\u975e`account_id`\u5b57\u6bb5\u7684\u6570\u636e\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.01 sec)\n\n--\u5728 test2 \u79df\u6237\u4e2d\u67e5\u770b t1 \u7684\u6570\u636e\uff0c\u4e0d\u4f1a\u770b\u5230\u6709\u6570\u636e\nmysql> select * from t1;\nEmpty set (0.01 sec)\n\n--\u5728 test1 \u79df\u6237\u4e2d\u521b\u5efa\u57fa\u4e8e t1 \u7684\u89c6\u56fe\nmysql> create view t1_view as select * from mo_catalog.t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select * from t1_view;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.00 sec)\n\n--\u5728 test2 \u79df\u6237\u4e2d\u521b\u5efa\u57fa\u4e8e t1 \u7684\u89c6\u56fe\nmysql> create view t1_view as select * from mo_catalog.t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select * from t1_view;\nEmpty set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/","title":"CREATE DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE DATABASE
\u8bed\u53e5\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u3002
> CREATE DATABASE [IF NOT EXISTS] <database_name> [create_option] ...\n\n> create_option: [DEFAULT] {\n CHARACTER SET [=] charset_name\n | COLLATE [=] collation_name\n | ENCRYPTION [=] {'Y' | 'N'}\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#_3","title":"\u793a\u4f8b","text":"CREATE DATABASE IF NOT EXISTS test01;\n
\u9884\u671f\u7ed3\u679c
\u4f60\u53ef\u4ee5\u4f7f\u7528 SHOW DATABASES
\u68c0\u67e5\u6570\u636e\u5e93\u662f\u5426\u5df2\u521b\u5efa\u3002
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| mo_task |\n| information_schema |\n| mysql |\n| system_metrics |\n| system |\n| test01 |\n| mo_catalog |\n+--------------------+\n10 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u9664\u4e86\u5df2\u5b58\u5728\u7684 6 \u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\u4ee5\u5916\uff0c\u65b0\u7684\u6570\u636e\u5e93 test01 \u5df2\u7ecf\u521b\u5efa\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#_4","title":"\u9650\u5236","text":"UTF-8
\u5b57\u7b26\u96c6\u3002CHARACTER SET
\uff0cCOLLATE
\uff0cENCRYPTION
\u76ee\u524d\u53ef\u4ee5\u4f7f\u7528\u4f46\u65e0\u6cd5\u751f\u6548\u3002CREATE DYNAMIC TABLE
\u5c06\u4e00\u4e2a\u65b0\u7684\u52a8\u6001\u8868\u6dfb\u52a0\u5230\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u3002
CREATE DYNAMIC TABLE [IF NOT EXISTS] table_name AS SELECT ... from stream_name ;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-dynamic-table/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create dynamic table dt_test as select * from stream_test;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-dynamic-table/#_5","title":"\u9650\u5236","text":"\u521b\u5efa\u52a8\u6001\u8868\u65f6\u6682\u4e0d\u652f\u6301\u4f7f\u7528\u805a\u96c6\u51fd\u6570\u3001\u6570\u5b66\u51fd\u6570\u3001\u5b57\u7b26\u4e32\u51fd\u6570\u3001\u65e5\u671f\u51fd\u6570\u4ee5\u53ca limit\u3001offset
\u3001from subquery
\u3001not in/in subquery
\u3001group by
\u3001order by``\u3001having
\u8bed\u53e5\u3002
\u521b\u5efa\u52a8\u6001\u8868\u65f6\u6682\u4e0d\u652f\u6301\u5bf9\u4e24\u4e2a SOURCE \u8868\u7684 join\u3001\u53ef\u4ee5 join SOURCE \u8868\u548c\u666e\u901a\u6570\u636e\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/","title":"CREATE EXTERNAL TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5916\u90e8\u8868\u662f\u6307\u4e0d\u5728\u6570\u636e\u5e93\u91cc\u7684\u8868\uff0c\u662f\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u7684\u4e00\u4e2a\u6309\u7167\u4e00\u5b9a\u683c\u5f0f\u5206\u5272\u7684\u6587\u672c\u6587\u4ef6\uff0c\u6216\u662f\u5176\u4ed6\u7c7b\u578b\u7684\u8868\uff0c\u5bf9 MatrixOne \u6765\u8bf4\u7c7b\u4f3c\u4e8e\u89c6\u56fe\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u4e2d\u50cf\u89c6\u56fe\u4e00\u6837\u8fdb\u884c\u67e5\u8be2\u7b49\u64cd\u4f5c\uff0c\u4f46\u662f\u5916\u90e8\u8868\u5728\u6570\u636e\u5e93\u4e2d\u53ea\u6709\u8868\u7ed3\u6784\uff0c\u800c\u6570\u636e\u5b58\u653e\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u8bb2\u8ff0\u5982\u4f55\u5728 MatrixOne \u6570\u636e\u5e93\u5916\u5efa\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_3","title":"\u901a\u7528\u8bed\u6cd5","text":"> CREATE EXTERNAL TABLE [IF NOT EXISTS] [db.]table_name;\n(\n name1 type1,\n name2 type2,\n ...\n)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_4","title":"\u8bed\u6cd5\u793a\u4f8b","text":"## \u521b\u5efa\u6307\u5411\u672c\u5730\u6587\u4ef6\u7684\u5916\u8868\uff08\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff09\ncreate external table t(...) localfile{\"filepath\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## \u521b\u5efa\u6307\u5411\u672c\u5730\u6587\u4ef6\u7684\u5916\u8868\uff08\u4e0d\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff0c\u5219\u4e3aauto\u683c\u5f0f\uff0c\u81ea\u52a8\u68c0\u67e5\u6587\u4ef6\u7684\u683c\u5f0f\uff09\ncreate external table t(...) localfile{\"filepath\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n\n## \u521b\u5efa\u6307\u5411S3\u6587\u4ef6\u7684\u5916\u8868\uff08\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff09\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## \u521b\u5efa\u6307\u5411S3\u6587\u4ef6\u7684\u5916\u8868\uff08\u4e0d\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff0c\u5219\u4e3aauto\u683c\u5f0f\uff0c\u81ea\u52a8\u68c0\u67e5\u6587\u4ef6\u7684\u683c\u5f0f\uff09\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_5","title":"\u8bed\u6cd5\u8bf4\u660e","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_6","title":"\u53c2\u6570\u8bf4\u660e","text":"\u53c2\u6570 \u63cf\u8ff0 endpoint \u7ec8\u7aef\u8282\u70b9\u662f\u4f5c\u4e3a AWS Web \u670d\u52a1\u7684\u5165\u53e3\u70b9\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id S3 \u7684 Access key ID secret_access_key S3 \u7684 Secret access key bucket \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u8bbf\u95ee\u6587\u4ef6\u7684\u76f8\u5bf9\u8def\u5f84 region s3 \u6240\u5728\u7684\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\uff0c\u4e3a\u7a7a\u8868\u793a\u975e\u538b\u7f29\u6587\u4ef6\uff0c\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\"auto\", \"none\", \"gzip\", \"bzip2\", \"flate\", \"zlib\", \"lz4\" auto \u538b\u7f29\u683c\u5f0f\uff0c\u8868\u793a\u901a\u8fc7\u6587\u4ef6\u540e\u7f00\u540d\u81ea\u52a8\u68c0\u67e5\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f none \u538b\u7f29\u683c\u5f0f\uff0c\u8868\u793a\u4e3a\u975e\u538b\u7f29\u683c\u5f0f\uff0c\u5176\u4f59\u8868\u793a\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_7","title":"\u793a\u4f8b","text":"create external table ex_table_cpk(clo1 tinyint,clo2 smallint,clo3 int,clo4 bigint,clo5 tinyint unsigned,clo6 smallint unsigned,clo7 int unsigned,clo8 bigint unsigned,col9 float,col10 double,col11 varchar(255),col12 Date,col13 DateTime,col14 timestamp,col15 bool,col16 decimal(5,2),col17 text,col18 varchar(255),col19 varchar(255),col20 varchar(255))infile{\"filepath\"='$resources/external_table_file/cpk_table_1.csv'} ;\n
\u66f4\u591a\u5173\u4e8e\u4f7f\u7528\u5916\u8868\u6307\u5b9a S3 \u6587\u4ef6\uff0c\u53c2\u89c1\u4ece S3 \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u8bfb\u53d6\u6570\u636e\u5e76\u5bfc\u5165 MatrixOne\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_8","title":"\u9650\u5236","text":"\u5f53\u524d MatrixOne \u4ec5\u652f\u6301\u5bf9\u5916\u90e8\u8868\u8fdb\u884c select
\u64cd\u4f5c\uff0c\u6682\u65f6\u8fd8\u4e0d\u652f\u6301\u4f7f\u7528 delete
\u3001insert
\u3001update
\u5bf9\u5916\u90e8\u8868\u63d2\u5165\u6570\u636e\u3002
CREATE FUNCTION...LANGUAGE PYTHON AS
\u7528\u4e8e\u521b\u5efa\u7528\u6237\u81ea\u5b9a\u4e49 Python \u51fd\u6570\u3002\u7528\u6237\u901a\u8fc7\u81ea\u5df1\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u6ee1\u8db3\u5b9a\u5236\u5316\u9700\u6c42\uff0c\u7b80\u5316\u67e5\u8be2\u7684\u7f16\u5199\u3002\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5bfc\u5165\u5916\u90e8 Python \u6587\u4ef6\u6216\u5916\u90e8 whl \u5305\u6765\u521b\u5efa UDF\u3002
\u5728\u90e8\u5206\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u4f1a\u5e0c\u671b python \u51fd\u6570\u4e00\u6b21\u6027\u63a5\u6536\u591a\u4e2a\u5143\u7ec4\u6765\u63d0\u9ad8\u8fd0\u884c\u6548\u7387\uff0cMatrixOne \u63d0\u4f9b\u51fd\u6570\u7684 vector \u9009\u9879\u6765\u5904\u7406\u8fd9\u79cd\u60c5\u51b5\u3002
MatrixOne Python UDF \u76ee\u524d\u4e0d\u652f\u6301\u91cd\u8f7d\uff0c\u51fd\u6570\u540d\u5728\u4e00\u4e2a matrixone \u96c6\u7fa4\u8981\u6c42\u662f\u552f\u4e00\u7684\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-python/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE [ OR REPLACE ] FUNCTION <name> (\n[ <arg_name> <arg_data_type> ] [ , ... ] )\nRETURNS <result_data_type> LANGUAGE PYTHON AS\n$$\n<function_body>\n[ add.vector = True ]\n$$\nHANDLER = '<function_name>'\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-python/#_3","title":"\u7ed3\u6784\u8bf4\u660e","text":"<name>
\uff1a\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u540d\u79f0\u3002
<arg_name> <arg_data_type>
\uff1a\u7528\u4e8e\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u53c2\u6570\uff0c\u8fd9\u91cc\u7684\u53c2\u6570\u53ea\u6709\u540d\u79f0\u548c\u7c7b\u578b\u3002
RETURNS <result_data_type>
\uff1a\u7528\u4e8e\u58f0\u660e\u81ea\u5b9a\u4e49\u51fd\u6570\u8fd4\u56de\u503c\u7684\u6570\u636e\u7c7b\u578b\u3002
<function_body>
\uff1a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u4e3b\u4f53\u90e8\u5206\uff0c\u5fc5\u987b\u5305\u542b\u4e00\u4e2a RETURN \u8bed\u53e5\uff0c\u5176\u4e2d\u7528\u4e8e\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u8fd4\u56de\u503c\u3002
[ add.vector = True ]
\uff1a\u6807\u5fd7 python \u51fd\u6570\u4e00\u6b21\u6027\u63a5\u6536\u591a\u4e2a\u5143\u7ec4\u3002
HANDLIER <function_name>:
\u6307\u5b9a\u8c03\u7528\u7684 python \u51fd\u6570\u540d\u79f0\u3002
\u4e3a\u786e\u4fdd\u7f16\u5199 Python UDF \u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u7c7b\u578b\u4e0e MatrixOne \u652f\u6301\u7684\u6570\u636e\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\uff0c\u60a8\u9700\u8981\u5173\u6ce8\u4e8c\u8005\u95f4\u7684\u6570\u636e\u7c7b\u578b\u6620\u5c04\u5173\u7cfb\uff0c\u5177\u4f53\u6620\u5c04\u5173\u7cfb\u5982\u4e0b\uff1a
MatrixOne \u7c7b\u578b Python \u7c7b\u578b bool bool int8, int16, int32, int64, uint8, uint16, uint32, uint64 int float32, float64 float char, varchar, text, uuid str json str, int, float, list, dict time datetime.timedelta date datetime.date datetime, timestamp datetime.datetime decimal64, decimal128 decimal.Decimal binary, varbinary, blob bytes"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-python/#_5","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
--\u7528 python UDF \u5b9e\u73b0\u4e24\u6570\u4e4b\u548c\ncreate or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\n\n--\u8c03\u7528\u51fd\u6570\nmysql> select py_add(1,2);\n+--------------+\n| py_add(1, 2) |\n+--------------+\n| 3 |\n+--------------+\n1 row in set (0.01 sec)\n
\u793a\u4f8b 2
create or replace function py_helloworld() returns varchar(255) language python as $$\ndef helloworld():\nreturn \"helloworld!\"\n$$\nhandler 'helloworld';\n\nmysql> select py_helloworld();\n+-----------------+\n| py_helloworld() |\n+-----------------+\n| helloworld! |\n+-----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/","title":"CREATE FUNCTION...LANGUAGE SQL AS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE FUNCTION...LANGUAGE SQL AS
\u7528\u4e8e\u521b\u5efa SQL UDF\u3002
SQL \u81ea\u5b9a\u4e49\u51fd\u6570\u662f\u4e00\u79cd\u7528\u6237\u81ea\u5df1\u7f16\u5199\u7684 SQL \u51fd\u6570\uff0c\u53ef\u4ee5\u6839\u636e\u7279\u5b9a\u9700\u6c42\u6267\u884c\u81ea\u5b9a\u4e49\u64cd\u4f5c\u3002\u8fd9\u4e9b\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u67e5\u8be2\u3001\u6570\u636e\u8f6c\u6362\u7b49\u4efb\u52a1\uff0c\u4f7f\u5f97 sQL \u4ee3\u7801\u66f4\u52a0\u6a21\u5757\u5316\u548c\u53ef\u7ef4\u62a4\u3002
MatrixOne SQL UDF \u76ee\u524d\u4e0d\u652f\u6301\u91cd\u8f7d\uff0c\u51fd\u6570\u540d\u5728\u4e00\u4e2a matrixone \u96c6\u7fa4\u8981\u6c42\u662f\u552f\u4e00\u7684\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE [ OR REPLACE ] FUNCTION <name> (\n[ <arg_name> <arg_data_type> ] [ , ... ] )\nRETURNS <result_data_type> LANGUAGE SQL AS 'function_body'\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/#_3","title":"\u7ed3\u6784\u8bf4\u660e","text":"<name>
\uff1a\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u540d\u79f0\u3002
<arg_name> <arg_data_type>
\uff1a\u7528\u4e8e\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u53c2\u6570\uff0c\u8fd9\u91cc\u7684\u53c2\u6570\u53ea\u6709\u540d\u79f0\u548c\u7c7b\u578b\u3002
RETURNS <result_data_type>
\uff1a\u7528\u4e8e\u58f0\u660e\u81ea\u5b9a\u4e49\u51fd\u6570\u8fd4\u56de\u503c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b8c\u6574\u7684\u6570\u636e\u7c7b\u578b\u8bf7\u67e5\u770b\u6570\u636e\u7c7b\u578b\u6982\u89c8
function_body
\uff1a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u4e3b\u4f53\u90e8\u5206\u3002\u7528\u6237\u5fc5\u987b\u4f7f\u7528$1\u3001$2,...\u4ee5\u5f15\u7528\u53c2\u6570\uff0c\u800c\u4e0d\u662f\u5b9e\u9645\u7684\u53c2\u6570\u540d\u79f0\u3002\u51fd\u6570\u4f53\u652f\u6301 select \u8bed\u53e5\uff0c\u4e14\u8fd4\u56de\u503c\u552f\u4e00\uff0c\u5982\u679c sql \u51fd\u6570\u4f53\u4e0d\u662f\u8868\u8fbe\u5f0f\uff0c\u5e76\u4e14\u662f\u8868\u4e0a\u7684 select \u8bed\u53e5\uff0c\u5219\u67e5\u8be2\u5e94\u4f7f\u7528 limit 1 \u6216\u4e0d\u5e26 group by \u5b50\u53e5\u7684\u805a\u5408\u51fd\u6570\u5c06\u5176\u7ed3\u679c\u9650\u5236\u4e3a 1\u3002
\u793a\u4f8b 1
--\u521b\u5efa\u65e0\u53c2 sql \u81ea\u5b9a\u4e49\u51fd\u6570\n\nmysql> create table t1(n1 int);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t1 values(1),(2),(3);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> CREATE FUNCTION t1_fun () RETURNS VARCHAR LANGUAGE SQL AS 'select n1 from t1 limit 1' ;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select t1_fun();\n+----------+\n| t1_fun() |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
\u793a\u4f8b 2
--\u521b\u5efa sql \u81ea\u5b9a\u4e49\u51fd\u6570\u8fd4\u56de\u4e24\u4e2a\u53c2\u6570\u7684\u548c\nmysql> CREATE FUNCTION twoadd (x int, y int) RETURNS int LANGUAGE SQL AS 'select $1 + $2' ;\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> select twoadd(1,2);\n+--------------+\n| twoadd(1, 2) |\n+--------------+\n| 3 |\n+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/","title":"CREATE INDEX USING IVFFLAT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5411\u91cf\u7d22\u5f15\u53ef\u7528\u4e8e\u52a0\u901f\u5bf9\u5305\u542b\u5411\u91cf\u5217\u7684\u8868\u7684 KNN(K-Nearest Neighbors\uff09\u67e5\u8be2\u3002Matrixone \u76ee\u524d\u652f\u6301\u5177\u6709 l2_distance
\u5ea6\u91cf\u7684 IVFFLAT \u5411\u91cf\u7d22\u5f15\u3002
\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a PROBE_LIMIT \u6765\u51b3\u5b9a\u8981\u67e5\u8be2\u7684\u805a\u7c7b\u4e2d\u5fc3\u6570\u91cf\u3002PROBE_LIMIT \u9ed8\u8ba4\u4e3a 1\uff0c\u5373\u4ec5\u626b\u63cf 1 \u4e2a\u805a\u7c7b\u4e2d\u5fc3\u3002\u4f46\u5982\u679c\u60a8\u5c06\u5176\u8bbe\u7f6e\u4e3a\u66f4\u9ad8\u7684\u503c\uff0c\u5b83\u4f1a\u626b\u63cf\u66f4\u591a\u6570\u91cf\u7684\u805a\u7c7b\u4e2d\u5fc3\u548c\u5411\u91cf\uff0c\u8fd9\u4f7f\u5f97\u6027\u80fd\u53ef\u80fd\u4f1a\u4e0b\u964d\u4e00\u70b9\uff0c\u4f46\u51c6\u786e\u7387\u4f1a\u4e0a\u5347\u3002\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u9002\u5f53\u7684\u63a2\u9488\u6570\u91cf\u6765\u5e73\u8861\u67e5\u8be2\u901f\u5ea6\u548c\u53ec\u56de\u7387\u3002PROBE_LIMIT \u7684\u7406\u60f3\u503c\u4e3a\uff1a
> CREATE INDEX index_name\nUSING IVFFLAT\nON tbl_name (col,...)\nLISTS=lists \nOP_TYPE \"vector_l2_ops\"\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"index_name
\uff1a\u7d22\u5f15\u540d\u79f0IVFFLAT
\uff1a\u5411\u91cf\u7d22\u5f15\u7c7b\u578b\uff0c\u76ee\u524d\u652f\u6301 vector_l2_opslists
\uff1a\u7d22\u5f15\u4e2d\u6240\u9700\u7684\u5206\u533a\u6570\uff0c\u5fc5\u987b\u5927\u4e8e 0OP_TYPE
\uff1a\u8981\u4f7f\u7528\u7684\u8ddd\u79bb\u5ea6\u91cfNOTE:
--\u9700\u8bbe\u7f6e\u53c2\u6570 experimental_ivf_index \u503c\u4e3a 1\uff08\u9ed8\u8ba4 0\uff09\u624d\u80fd\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\nSET GLOBAL experimental_ivf_index = 1;\ndrop table if exists t1;\ncreate table t1(coordinate vecf32(2),class char);\n-- \u6709\u4e03\u4e2a\u70b9\uff0c\u6bcf\u4e2a\u70b9\u4ee3\u8868\u5176\u5728 x \u548c y \u8f74\u4e0a\u7684\u5750\u6807\uff0c\u5e76\u4e14\u6bcf\u4e2a\u70b9\u7684 class \u88ab\u6807\u8bb0\u4e3a A \u6216 B\u3002\ninsert into t1 values(\"[2,4]\",\"A\"),(\"[3,5]\",\"A\"),(\"[5,7]\",\"B\"),(\"[7,9]\",\"B\"),(\"[4,6]\",\"A\"),(\"[6,8]\",\"B\"),(\"[8,10]\",\"B\");\n--\u521b\u5efa\u5411\u91cf\u7d22\u5f15\ncreate index idx_t1 using ivfflat on t1(coordinate) lists=1 op_type \"vector_l2_ops\";\n\nmysql> show create table t1;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`coordinate` VECF32(2) DEFAULT NULL,\n`class` CHAR(1) DEFAULT NULL,\nKEY `idx_t1` USING ivfflat (`coordinate`) lists = 1 op_type 'vector_l2_ops' ) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show index from t1;\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Index_params | Visible | Expression |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| t1 | 1 | idx_t1 | 1 | coordinate | A | 0 | NULL | NULL | YES | ivfflat | | | {\"lists\":\"1\",\"op_type\":\"vector_l2_ops\"} | YES | NULL |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n1 row in set (0.01 sec)\n\n--\u8bbe\u7f6e\u626b\u63cf\u7684\u805a\u7c7b\u4e2d\u5fc3\u6570\u91cf\nSET @PROBE_LIMIT=1;\n--\u73b0\u5728\uff0c\u6211\u4eec\u6709\u4e00\u4e2a\u65b0\u70b9\uff0c\u5176\u5750\u6807\u4e3a (4, 4)\uff0c\u6211\u4eec\u60f3\u8981\u4f7f\u7528 KNN \u67e5\u8be2\u6765\u9884\u6d4b\u8fd9\u4e2a\u70b9\u7684\u7c7b\u522b\u3002\nmysql> select * from t1 order by l2_distance(coordinate,\"[4,4]\") asc;\n+------------+-------+\n| coordinate | class |\n+------------+-------+\n| [3, 5] | A |\n| [2, 4] | A |\n| [4, 6] | A |\n| [5, 7] | B |\n| [6, 8] | B |\n| [7, 9] | B |\n| [8, 10] | B |\n+------------+-------+\n7 rows in set (0.01 sec)\n\n--\u6839\u636e\u67e5\u8be2\u7ed3\u679c\u53ef\u9884\u6d4b\u8fd9\u4e2a\u70b9\u7684\u7c7b\u522b\u4e3a A\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/#_5","title":"\u9650\u5236","text":"\u4e00\u6b21\u53ea\u652f\u6301\u5728\u4e00\u4e2a\u5411\u91cf\u5217\u4e0a\u5efa\u7acb\u5411\u91cf\u7d22\u5f15\uff0c\u5982\u9700\u5728\u591a\u4e2a\u5411\u91cf\u5217\u4e0a\u5efa\u7acb\u5411\u91cf\u7d22\u5f15\uff0c\u53ef\u591a\u6b21\u6267\u884c\u521b\u5efa\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/","title":"CREATE INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u8868\u4e2d\u521b\u5efa\u7d22\u5f15\uff0c\u4ee5\u4fbf\u66f4\u52a0\u5feb\u901f\u9ad8\u6548\u5730\u67e5\u8be2\u6570\u636e\u3002
\u4f60\u65e0\u6cd5\u770b\u5230\u7d22\u5f15\uff0c\u7d22\u5f15\u53ea\u80fd\u88ab\u7528\u6765\u52a0\u901f\u641c\u7d22/\u67e5\u8be2\u3002
\u66f4\u65b0\u4e00\u4e2a\u5305\u542b\u7d22\u5f15\u7684\u8868\u9700\u8981\u6bd4\u66f4\u65b0\u4e00\u4e2a\u6ca1\u6709\u7d22\u5f15\u7684\u8868\u82b1\u8d39\u66f4\u591a\u7684\u65f6\u95f4\uff0c\u8fd9\u662f\u7531\u4e8e\u7d22\u5f15\u672c\u8eab\u4e5f\u9700\u8981\u66f4\u65b0\u3002\u56e0\u6b64\uff0c\u7406\u60f3\u7684\u505a\u6cd5\u662f\u4ec5\u4ec5\u5728\u5e38\u5e38\u88ab\u641c\u7d22\u7684\u5217\uff08\u4ee5\u53ca\u8868\uff09\u4e0a\u9762\u521b\u5efa\u7d22\u5f15\u3002
\u7d22\u5f15\u6709\u51e0\u79cd\u5e38\u89c1\u7684\u7c7b\u578b\uff0c\u5206\u522b\u4e3a\uff1a
> CREATE [UNIQUE] INDEX index_name\nON tbl_name (key_part,...)\nCOMMENT 'string'\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#create-unique-index","title":"CREATE UNIQUE INDEX \u8bed\u6cd5","text":"\u5728\u8868\u4e0a\u521b\u5efa\u4e00\u4e2a\u552f\u4e00\u7684\u7d22\u5f15\u3002\u4e0d\u5141\u8bb8\u4f7f\u7528\u91cd\u590d\u7684\u503c\uff1a\u552f\u4e00\u7684\u7d22\u5f15\u610f\u5473\u7740\u4e24\u4e2a\u884c\u4e0d\u80fd\u62e5\u6709\u76f8\u540c\u7684\u7d22\u5f15\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#create-index_1","title":"CREATE INDEX \u8bed\u6cd5","text":"\u5728\u8868\u4e0a\u521b\u5efa\u4e00\u4e2a\u6b21\u7ea7\u7d22\u5f15\u3002\u53ef\u4ee5\u4f7f\u7528\u91cd\u590d\u503c\u548c Null \u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(id int PRIMARY KEY,name VARCHAR(255),age int);\ninsert into t1 values(1,\"Abby\", 24);\ninsert into t1 values(2,\"Bob\", 25);\ninsert into t1 values(3,\"Carol\", 23);\ninsert into t1 values(4,\"Dora\", 29);\ncreate unique index idx on t1(name);\nmysql> select * from t1;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Abby | 24 |\n| 2 | Bob | 25 |\n| 3 | Carol | 23 |\n| 4 | Dora | 29 |\n+------+-------+------+\n4 rows in set (0.00 sec)\n\nmysql> show create table t1;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`id` INT NOT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`),\nUNIQUE KEY `idx` (`name`)\n) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n\ncreate table t2 (\ncol1 bigint primary key,\ncol2 varchar(25),\ncol3 float,\ncol4 varchar(50)\n);\ncreate unique index idx on t2(col2) comment 'create varchar index';\ninsert into t2 values(1,\"Abby\", 24,'zbcvdf');\ninsert into t2 values(2,\"Bob\", 25,'zbcvdf');\ninsert into t2 values(3,\"Carol\", 23,'zbcvdf');\ninsert into t2 values(4,\"Dora\", 29,'zbcvdf');\nmysql> select * from t2;\n+------+-------+------+--------+\n| col1 | col2 | col3 | col4 |\n+------+-------+------+--------+\n| 1 | Abby | 24 | zbcvdf |\n| 2 | Bob | 25 | zbcvdf |\n| 3 | Carol | 23 | zbcvdf |\n| 4 | Dora | 29 | zbcvdf |\n+------+-------+------+--------+\n4 rows in set (0.00 sec)\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t2 | CREATE TABLE `t2` (\n`col1` BIGINT NOT NULL,\n`col2` VARCHAR(25) DEFAULT NULL,\n`col3` FLOAT DEFAULT NULL,\n`col4` VARCHAR(50) DEFAULT NULL,\nPRIMARY KEY (`col1`),\nUNIQUE KEY `idx` (`col2`) COMMENT `create varchar index`\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
CREATE TABLE Employees (\nEmployeeID INT PRIMARY KEY,\nFirstName VARCHAR(50),\nLastName VARCHAR(50),\nDepartment VARCHAR(50),\nSalary INT\n);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (1, 'John', 'Doe', 'HR', 50000);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (2, 'Jane', 'Smith', 'IT', 60000);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (3, 'Mark', 'Johnson', 'IT', 55000);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (4, 'Mary', 'Brown', 'Sales', 48000);\n\nmysql> CREATE INDEX DepartmentIndex ON Employees (Department);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> SELECT * FROM Employees WHERE Department = 'IT';\n+------------+-----------+----------+------------+--------+\n| employeeid | firstname | lastname | department | salary |\n+------------+-----------+----------+------------+--------+\n| 2 | Jane | Smith | IT | 60000 |\n| 3 | Mark | Johnson | IT | 55000 |\n+------------+-----------+----------+------------+--------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/","title":"CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE PUBLICATION
\u5c06\u4e00\u4e2a\u65b0\u7684\u53d1\u5e03\u6dfb\u52a0\u5230\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u3002
CREATE PUBLICATION pubname\n DATABASE database_name ACCOUNT\n [ { ALL\n | account_name, [, ... ] }]\n [ COMMENT 'string']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create database t;\ncreate account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\nmysql> create publication pub1 database t account acc0,acc1;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#_5","title":"\u9650\u5236","text":"MatrxiOne \u5f53\u524d\u4ec5\u652f\u6301\u4e00\u6b21\u53d1\u5e03\u4e00\u4e2a\u6570\u636e\u5e93\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-replace-view/","title":"CREATE OR REPLACE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-replace-view/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE OR REPLACE VIEW
\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u89c6\u56fe\uff0c\u4e5f\u53ef\u4ee5\u7528\u4f5c\u5f53\u89c6\u56fe\u5df2\u7ecf\u5b58\u5728\u65f6\uff0c\u5219\u66ff\u6362\u5df2\u6709\u7684\u89c6\u56fe\u3002\u8fd9\u8868\u793a\u5728\u89c6\u56fe\u5df2\u7ecf\u5b58\u5728\u65f6\u66f4\u65b0\u89c6\u56fe\u7684\u5b9a\u4e49\uff0c\u800c\u4e0d\u9700\u8981\u5220\u9664\u5df2\u6709\u7684\u89c6\u56fe\u3002
> CREATE OR REPLACE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-replace-view/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"view_name
\uff1a\u8981\u521b\u5efa\u6216\u66ff\u6362\u7684\u89c6\u56fe\u7684\u540d\u79f0\uff0c\u9700\u8981\u4e3a\u89c6\u56fe\u6307\u5b9a\u4e00\u4e2a\u552f\u4e00\u7684\u540d\u79f0\u3002
AS
\uff1a\u7528\u4e8e\u6307\u793a\u4ee5\u4e0b\u7684\u67e5\u8be2\u8bed\u53e5\u662f\u89c6\u56fe\u7684\u67e5\u8be2\u5b9a\u4e49\u3002
SELECT column1, column2, ...
\uff1a\u5728 AS \u5173\u952e\u5b57\u4e4b\u540e\uff0c\u4f60\u9700\u8981\u6307\u5b9a\u89c6\u56fe\u7684\u67e5\u8be2\u5b9a\u4e49\u3002\u8fd9\u662f\u4e00\u4e2a SELECT \u8bed\u53e5\uff0c\u53ef\u4ee5\u9009\u62e9\u8868\u4e2d\u7684\u7279\u5b9a\u5217\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u8ba1\u7b97\u5b57\u6bb5\u3001\u8868\u8fbe\u5f0f\u7b49\u7b49\u3002\u89c6\u56fe\u4f1a\u5c06\u8fd9\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u4f5c\u4e3a\u5176\u81ea\u8eab\u7684\u6570\u636e\u3002
FROM table_name
\uff1aFROM
\u5b50\u53e5\uff0c\u7528\u4e8e\u6307\u5b9a\u8981\u67e5\u8be2\u7684\u8868\u540d\u3002\u4f60\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\uff0c\u5e76\u5728\u89c6\u56fe\u4e2d\u8fdb\u884c\u76f8\u5173\u64cd\u4f5c\u3002
WHERE condition
\uff1a\u53ef\u9009\u7684 WHERE
\u5b50\u53e5\uff0c\u7528\u4e8e\u7b5b\u9009\u67e5\u8be2\u7ed3\u679c\u3002
-- \u521b\u5efa\u8868 t1 \u5305\u62ec\u4e24\u5217 a \u548c b\ncreate table t1 (a int, b int);\n\n-- \u5411\u8868 t1 \u63d2\u5165\u4e09\u884c\u6570\u636e\ninsert into t1 values (1, 11), (2, 22), (3, 33);\n\n-- \u521b\u5efa\u89c6\u56fe v1\uff0c\u8be5\u89c6\u56fe\u5305\u542b\u8868 t1 \u4e2d\u7684\u6240\u6709\u6570\u636e\ncreate view v1 as select * from t1;\n\n-- \u67e5\u8be2\u89c6\u56fe v1 \u7684\u6240\u6709\u6570\u636e\nmysql> select * from v1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 11 |\n| 2 | 22 |\n| 3 | 33 |\n+------+------+\n3 rows in set (0.01 sec)\n\n-- \u67e5\u8be2\u89c6\u56fe v1 \u4e2d\u5217 a \u5927\u4e8e 1 \u7684\u6570\u636e\nmysql> select * from v1 where a > 1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 22 |\n| 3 | 33 |\n+------+------+\n2 rows in set (0.00 sec)\n\n-- \u66ff\u6362\u89c6\u56fe v1\uff0c\u65b0\u7684\u89c6\u56fe\u4ec5\u5305\u542b\u8868 t1 \u4e2d\u5217 a \u5c0f\u4e8e 2 \u7684\u6570\u636e\ncreate or replace view v1 as select * from t1 where a < 2;\n\n-- \u518d\u6b21\u67e5\u8be2\u89c6\u56fe v1\uff0c\u73b0\u5728\u53ea\u5305\u542b\u6ee1\u8db3\u65b0\u6761\u4ef6\u7684\u6570\u636e\nmysql> select * from v1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 11 |\n+------+------+\n1 row in set (0.08 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/","title":"CREATE SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE SEQUENCE
\u7528\u6237\u521b\u5efa\u4e00\u4e2a\u5e8f\u5217\u5bf9\u8c61\u3002\u5e8f\u5217\uff08Sequence\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5b83\u53ef\u4ee5\u88ab\u7528\u6765\u81ea\u52a8\u751f\u6210\u552f\u4e00\u7684\u6570\u5b57\u5e8f\u5217\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5e8f\u5217\u88ab\u7528\u6765\u4e3a\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\u5b57\u6bb5\u81ea\u52a8\u751f\u6210\u552f\u4e00\u7684\u503c\u3002
CREATE SEQUENCE
\u662f\u4e00\u79cd\u7528\u4e8e\u521b\u5efa\u81ea\u589e\u6570\u5b57\u5e8f\u5217\u7684\u547d\u4ee4\uff0c\u7528\u4e8e\u751f\u6210\u552f\u4e00\u7684\u3001\u8fde\u7eed\u7684\u6570\u5b57\u503c\uff0c\u901a\u5e38\u7528\u4e8e\u4e3a\u4e3b\u952e\u5217\u6216\u5176\u4ed6\u9700\u8981\u81ea\u589e\u6570\u5b57\u7684\u5217\u751f\u6210\u503c\u3002
> CREATE SEQUENCE [ IF NOT EXISTS ] SEQUENCE_NAME\n [ AS data_type ]\n [ INCREMENT [ BY ] increment ]\n [ MINVALUE minvalue] [ MAXVALUE maxvalue]\n [ START [ WITH ] start ] [ [ NO ] CYCLE ]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#data_type","title":"data_type","text":"\u53ef\u9009\u5b50\u53e5 AS data_type
\u6307\u5b9a\u5e8f\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002\u652f\u6301\u6570\u636e\u7c7b\u578b\u4e3a smallint [unsigned]
\u3001integer [unsigned]
\u548c bigint [unsigned]
\uff0c\u9ed8\u8ba4 bigint
\u662f\u9ed8\u8ba4\u503c\u3002\u6570\u636e\u7c7b\u578b\u51b3\u5b9a\u4e86\u5e8f\u5217\u7684\u9ed8\u8ba4\u6700\u5c0f\u503c\u548c\u6700\u5927\u503c\u3002
\u53ef\u9009\u5b50\u53e5 INCREMENT [ BY ] increment
\u6307\u5b9a\u5c06\u54ea\u4e2a\u503c\u6dfb\u52a0\u5230\u5f53\u524d\u5e8f\u5217\u503c\u4ee5\u521b\u5efa\u65b0\u503c\u3002\u6b63\u503c\u5c06\u751f\u6210\u5347\u5e8f\uff0c\u8d1f\u503c\u5c06\u751f\u6210\u964d\u5e8f\uff1b\u9ed8\u8ba4\u503c\u4e3a 1\u3002
\u53ef\u9009\u5b50\u53e5 MINVALUE minvalue
\u786e\u5b9a\u5e8f\u5217\u53ef\u4ee5\u751f\u6210\u7684\u6700\u5c0f\u503c\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6b64\u5b50\u53e5\u6216\u672a\u6307\u5b9a MINVALUE
\uff0c\u5219\u5c06\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002\u5347\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u662f 1\u3002\u964d\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u662f\u6570\u636e\u7c7b\u578b\u7684\u6700\u5c0f\u503c\u3002
\u53ef\u9009\u5b50\u53e5 MAXVALUE maxvalue
\u786e\u5b9a\u5e8f\u5217\u7684\u6700\u5927\u503c\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6b64\u5b50\u53e5\u6216\u672a\u6307\u5b9a MAXVALUE
\uff0c\u5219\u5c06\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002\u5347\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u662f\u6570\u636e\u7c7b\u578b\u7684\u6700\u5927\u503c\u3002\u964d\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u4e3a -1\u3002
\u53ef\u9009\u5b50\u53e5 START [ WITH ] start
\u5141\u8bb8\u5e8f\u5217\u4ece\u4efb\u4f55\u5730\u65b9\u5f00\u59cb\u3002\u9ed8\u8ba4\u8d77\u59cb\u503c\u662f\u5347\u5e8f\u5e8f\u5217\u7684\u6700\u5c0f\u503c\u548c\u964d\u5e8f\u5e8f\u5217\u7684\u6700\u5927\u503c\u3002
CYCLE
\u9009\u9879\u5141\u8bb8\u5e8f\u5217\u5728\u5347\u5e8f\u6216\u964d\u5e8f\u5e8f\u5217\u5206\u522b\u8fbe\u5230\u6700\u5927\u503c\u6216\u6700\u5c0f\u503c\u65f6\u56de\u7ed5\u3002\u5982\u679c\u8fbe\u5230\u9650\u5236\uff0c\u5219\u751f\u6210\u7684\u4e0b\u4e00\u4e2a\u6570\u5b57\u5c06\u5206\u522b\u662f\u6700\u5c0f\u503c\u6216\u6700\u5927\u503c\u3002
\u5bf9\u5e8f\u5217\u7684\u503c\u8fdb\u884c\u64cd\u4f5c\uff0c\u4f7f\u7528\u7684\u51fd\u6570\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#nextvalsequence_name","title":"NEXTVAL(sequence_name)
","text":"\u5c06\u5f53\u524d\u503c\u8bbe\u7f6e\u6210\u9012\u589e\u540e\u7684\u503c\uff0c\u5e76\u8fd4\u56de\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#currvalsequence_name","title":"CURRVAL(sequence_name)
","text":"\u8fd4\u56de\u5f53\u524d\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#setvalsequence_name-n-b","title":"SETVAL(sequence_name, n [,b])
","text":"\u8bbe\u7f6e\u5f53\u524d\u503c\uff1b
LASTVAL()
","text":"\u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u4e2d\uff0c\u6700\u8fd1\u4e00\u6b21\u7528 NEXTVAL
\u83b7\u53d6\u7684\u4efb\u4f55\u5e8f\u5217\u7684\u503c\uff0c\u4e14 LASTVAL()
\u53ea\u80fd\u88ab NEXTVAL
\u521d\u59cb\u5316\u3002
LASTVAL()
\u53d7 SETVAL(sequence_name, n [,true])
\u6539\u53d8\u5f53\u524d\u503c\u7684\u5f71\u54cd\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
\u5047\u8bbe\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a seq_id
\u7684 Sequence\uff0c\u8d77\u59cb\u503c\u4e3a 1\uff0c\u6bcf\u6b21\u589e\u52a0 1\uff0c\u6700\u5927\u503c\u4e3a 1000\uff1a
CREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n
\u7136\u540e\u53ef\u4ee5\u4f7f\u7528 NEXTVAL()
\u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff0c\u5e76\u81ea\u52a8\u5c06\u5e8f\u5217\u7684\u8ba1\u6570\u5668\u589e\u52a0 1\uff1a
SELECT NEXTVAL('seq_id');\n
\u63a5\u7740\uff0c\u53ef\u4ee5\u4f7f\u7528 LASTVAL()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d Sequence \u7684\u5f53\u524d\u503c\uff1a
SELECT LASTVAL();\n
\u4e5f\u53ef\u4ee5\u4f7f\u7528 SETVAL()
\u51fd\u6570\u5c06\u5f53\u524d\u503c\u8bbe\u7f6e\u4e3a 30\uff0c\u53c2\u6570 [,b]
\u4e3a true\uff1a
SELECT SETVAL('seq_id', 30);\n
\u7136\u540e\uff0c\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528 NEXTVAL()
\u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff1a
SELECT NEXTVAL('seq_id');\n
\u6b64\u65f6\u5c06\u8fd4\u56de 31\uff0c\u56e0\u4e3a\u5f53\u524d\u503c\u5df2\u7ecf\u88ab\u8bbe\u7f6e\u4e3a 30\uff0cNEXTVAL()
\u51fd\u6570\u5c06\u8fd4\u56de\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c 31\u3002
SELECT LASTVAL();\n
\u4f7f\u7528 LASTVAL()
\u8fd4\u56de\u5f53\u524d Sequence \u7684\u5f53\u524d\u503c\uff0c\u6b64\u65f6\u5c06\u8fd4\u56de 31\u3002
\u4e0a\u8ff0\u793a\u4f8b\u8868\u793a\uff0c\u5982\u679c\u5148\u901a\u8fc7 SETVAL(sequence_name, n [,true])
\u8bbe\u7f6e\u4e86\u5f53\u524d\u503c\uff0c\u518d\u4f7f\u7528 NEXTVAL
\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff0c\u90a3\u4e48\u518d\u6b21\u4f7f\u7528 LASTVAL()
\uff0c\u5219\u8fd4\u56de NEXTVAL
\u83b7\u53d6\u7684\u5e8f\u5217\u7684\u503c\u3002
SEQUENCE
","text":"\u8981\u5728\u8868\u683c\u4e2d\u4f7f\u7528\u5e8f\u5217\uff0c\u9700\u8981\u5b8c\u6210\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u521b\u5efa\u4e00\u4e2a\u5e8f\u5217\u5bf9\u8c61\uff1a\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"my_sequence\" \u7684\u5e8f\u5217\uff1a
CREATE SEQUENCE my_sequence;\n
\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e8f\u5217\u5bf9\u8c61\uff0c\u5b83\u5c06\u4ece 1 \u5f00\u59cb\uff0c\u4ee5 1 \u9012\u589e\u3002
\u5c06\u5e8f\u5217\u5e94\u7528\u5230\u8868\u683c\u4e2d\u7684\u5b57\u6bb5\uff1a\u4e3a\u4e86\u5c06\u5e8f\u5217\u5e94\u7528\u5230\u8868\u683c\u4e2d\u7684\u5b57\u6bb5\uff0c\u9700\u8981\u5728\u8868\u683c\u5b9a\u4e49\u4e2d\u6307\u5b9a\u4e00\u4e2a\u9ed8\u8ba4\u503c\u4e3a\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\uff0c\u5982\u4e0b\u6240\u793a\uff1a
CREATE TABLE my_table (\nid INTEGER DEFAULT nextval('my_sequence'),\nname VARCHAR(50));\n
\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\"id\" \u5b57\u6bb5\u5c06\u81ea\u52a8\u4ece\u5e8f\u5217\u4e2d\u83b7\u53d6\u4e0b\u4e00\u4e2a\u552f\u4e00\u7684\u503c\u4f5c\u4e3a\u5176\u9ed8\u8ba4\u503c\u3002
\u63d2\u5165\u6570\u636e\uff1a\u8868\u683c\u548c\u5e8f\u5217\u90fd\u5df2\u7ecf\u5b9a\u4e49\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 INSERT
\u8bed\u53e5\u6765\u5411\u8868\u683c\u4e2d\u63d2\u5165\u6570\u636e\u3002\u5f53\u63d2\u5165\u4e00\u884c\u6570\u636e\u65f6\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a \"id\" \u5b57\u6bb5\u7684\u503c\uff0c\u90a3\u4e48 MatrixOne \u5c06\u4f1a\u81ea\u52a8\u4ece\u5e8f\u5217\u4e2d\u83b7\u53d6\u4e0b\u4e00\u4e2a\u552f\u4e00\u7684\u503c\u4f5c\u4e3a\u5176\u9ed8\u8ba4\u503c\u3002
\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u8bed\u53e5\u5c06\u4f1a\u5411 \"my_table\" \u8868\u683c\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0c\u5e76\u4e14\u81ea\u52a8\u4e3a \"id\" \u5b57\u6bb5\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u503c\uff1a
INSERT INTO my_table (name) VALUES ('John');\nINSERT INTO my_table (name) VALUES ('Tom');\n
\u901a\u8fc7\u4f7f\u7528\u5e8f\u5217\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5728\u8868\u683c\u4e2d\u81ea\u52a8\u5206\u914d\u552f\u4e00\u7684\u6807\u8bc6\u7b26\uff0c\u4ece\u800c\u907f\u514d\u4e86\u624b\u52a8\u5206\u914d\u6807\u8bc6\u7b26\u53ef\u80fd\u5e26\u6765\u7684\u9519\u8bef\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u8bed\u53e5\u8fdb\u884c\u67e5\u8be2\u9a8c\u8bc1\uff1a
mysql> select * from my_table;\n+------+------+\n| id | name |\n+------+------+\n| 1 | John |\n| 2 | Tom |\n+------+------+\n2 rows in set (0.01 sec)\n
Note
\u5728\u8868\u4e2d\u4f7f\u7528 SEQUENCE \u65f6\uff0c\u9700\u8981\u6ce8\u610f auto_increment
\u4e0e sequence
\u4e0d\u80fd\u4e00\u8d77\u7528\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002
-- \u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a \"seq_id\" \u7684\u5e8f\u5217\uff0c\u5b83\u4ece 1 \u5f00\u59cb\uff0c\u6bcf\u6b21\u589e\u52a0 1\uff0c\u6700\u5927\u503c\u4e3a 1000\uff1a\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n-- \u5728\u521b\u5efa\u5e8f\u5217\u4e4b\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 NEXTVAL \u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff0c\u5982\u4e0b\u6240\u793a\uff1a\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 1 |\n+-----------------+\n1 row in set (0.02 sec)\n-- \u6b64\u547d\u4ee4\u5c06\u8fd4\u56de\u5e8f\u5217\u4e2d\u7684\u4e0b\u4e00\u4e2a\u503c\uff08\u4f8b\u5982 1\uff09\uff0c\u5e76\u81ea\u52a8\u5c06\u5e8f\u5217\u7684\u8ba1\u6570\u5668\u589e\u52a0 1\u3002\n\n-- CURRVAL \u51fd\u6570\u8fd4\u56de\u5f53\u524d\u503c\u3002\nmysql> SELECT CURRVAL('seq_id');\n+-----------------+\n| currval(seq_id) |\n+-----------------+\n| 1 |\n+-----------------+\n1 row in set (0.01 sec)\n\n-- \u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u4e2d\uff0c\u6700\u8fd1\u4e00\u6b21\u7528 NEXTVAL \u83b7\u53d6\u7684\u4efb\u4f55\u5e8f\u5217\u7684\u503c\u3002\nmysql> SELECT LASTVAL();\n+-----------+\n| lastval() |\n+-----------+\n| 1 |\n+-----------+\n1 row in set (0.00 sec)\n\n-- \u8bbe\u7f6e\u5f53\u524d\u503c\u4e3a 30\u3002\nmysql> SELECT SETVAL('seq_id', 30);\n+--------------------+\n| setval(seq_id, 30) |\n+--------------------+\n| 30 |\n+--------------------+\n1 row in set (0.02 sec)\n\n-- NEXTVAL \u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\u3002\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 31 |\n+-----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/","title":"CREATE SNAPSHOT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE SNAPSHOT
\u547d\u4ee4\u7528\u4e8e\u521b\u5efa\u5feb\u7167\u3002\u7cfb\u7edf\u79df\u6237\u53ef\u4ee5\u7ed9\u81ea\u5df1\u4e5f\u53ef\u4ee5\u7ed9\u666e\u901a\u79df\u6237\u521b\u5efa\u5feb\u7167\uff0c\u4f46\u662f\u666e\u901a\u79df\u6237\u53ea\u80fd\u7ed9\u81ea\u5df1\u521b\u5efa\u5feb\u7167\u3002\u79df\u6237\u521b\u5efa\u7684\u5feb\u7167\u4ec5\u672c\u79df\u6237\u53ef\u89c1\u3002
> CREATE SNAPSHOT snapshot_name FOR ACCOUNT account_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/#_3","title":"\u793a\u4f8b","text":"--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate snapshot sp1 for account sys;\ncreate snapshot sp2 for account acc1;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp2 | 2024-05-10 09:49:08.925908 | account | acc1 | | |\n| sp1 | 2024-05-10 09:48:50.271707 | account | sys | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n2 rows in set (0.00 sec)\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nmysql> create snapshot sp3 for account acc2;--\u666e\u901a\u79df\u6237\u53ea\u80fd\u4e3a\u81ea\u5df1\u5efa\u7acb\u5feb\u7167\nERROR 20101 (HY000): internal error: only sys tenant can create tenant level snapshot for other tenant\n\ncreate snapshot sp3 for account acc1;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp3 | 2024-05-10 09:53:09.948762 | account | acc1 | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/#_4","title":"\u9650\u5236","text":"CREATE SOURCE
\u521b\u5efa\u4e00\u4e2a\u5bf9\u6d41\u5f0f\u6570\u636e\u7684\u8fde\u63a5\uff0c\u5e76\u5c06\u4e00\u4e2a\u65b0\u7684 SOURCE \u8868\u6dfb\u52a0\u5230\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u3002
CREATE [OR REPLACE] SOURCE [IF NOT EXISTS] stream_name ( { column_name data_type [KEY | HEADERS | HEADER(key)] } [, ...] )\nWITH ( property_name = expression [, ...]);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-source/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create source stream_test(c1 char(25),c2 varchar(500),c3 text,c4 tinytext,c5 mediumtext,c6 longtext )with(\n\"type\"='kafka',\n\"topic\"= 'test',\n\"partition\" = '0',\n\"value\"= 'json',\n\"bootstrap.servers\"='127.0.0.1:9092' )\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-source/#_5","title":"\u9650\u5236","text":"SOURCE \u8868\u76ee\u524d\u4e0d\u652f\u6301 drop \u548c alter\u3002
\u521b\u5efa SOURCE \u8868\u65f6\u76ee\u524d\u4ec5\u652f\u6301\u8fde\u63a5 kafka\uff0c\u4e14\u4ec5\u652f\u6301\u4f20\u8f93\u6570\u636e\u683c\u5f0f\u4e3a json\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/","title":"CREATE STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE STAGE
\u7528\u4e8e\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u7684\u5185\u90e8\u6216\u5916\u90e8\u6570\u636e\u9636\u6bb5\uff08Stage\uff09\uff0c\u7528\u4e8e\u6570\u636e\u5bfc\u51fa\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u9636\u6bb5\uff0c\u901a\u8fc7\u5c06\u6570\u636e\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\uff0c\u4f60\u53ef\u4ee5\u5c06\u6570\u636e\u6587\u4ef6\u4e0b\u8f7d\u5230\u672c\u5730\u6216\u5c06\u5176\u5b58\u50a8\u5728\u4e91\u5b58\u50a8\u670d\u52a1\u4e2d\u3002
\u5185\u90e8\u9636\u6bb5\uff08Internal Stage\uff09\uff1a\u5185\u90e8\u9636\u6bb5\u5c06\u6570\u636e\u6587\u4ef6\u5b58\u50a8\u5728 MatrixOne \u5185\u90e8\u3002\u5185\u90e8\u9636\u6bb5\u53ef\u4ee5\u662f\u6c38\u4e45\u6027\u7684\u6216\u4e34\u65f6\u6027\u7684\u3002
\u5916\u90e8\u9636\u6bb5\uff08External Stage\uff09\uff1a\u5916\u90e8\u9636\u6bb5\u5f15\u7528\u5b58\u50a8\u5728 MatrixOne \u4e4b\u5916\u4f4d\u7f6e\u7684\u6570\u636e\u6587\u4ef6\u3002\u76ee\u524d\uff0c\u652f\u6301\u4ee5\u4e0b\u4e91\u5b58\u50a8\u670d\u52a1\uff1a
\u5b58\u50a8\u4f4d\u7f6e\u53ef\u4ee5\u662f\u79c1\u6709/\u53d7\u4fdd\u62a4\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u516c\u5f00\u7684\u3002\u4f46\u662f\uff0c\u65e0\u6cd5\u8bbf\u95ee\u9700\u8981\u6062\u590d\u624d\u80fd\u68c0\u7d22\u7684\u5b58\u6863\u4e91\u5b58\u50a8\u7c7b\u522b\u4e2d\u7684\u6570\u636e\u3002
\u5185\u90e8\u6216\u5916\u90e8\u9636\u6bb5\u53ef\u4ee5\u5305\u62ec\u4e00\u4e2a\u76ee\u5f55\u8868\u3002\u76ee\u5f55\u8868\u5728\u4e91\u5b58\u50a8\u4e2d\u5b58\u50a8\u5206\u9636\u6bb5\u6587\u4ef6\u7684\u76ee\u5f55\u3002
\u914d\u7f6e\u4e00\u4e2a\u6307\u5b9a\u8def\u5f84\uff0c\u63a7\u5236\u7528\u6237 SELECT INTO
\u7684\u5199\u5165\u6743\u9650\uff0c\u5728\u521b\u5efa\u4e4b\u540e\uff0c\u7528\u6237\u53ea\u80fd\u5199\u5165\u6307\u5b9a\u7684 STAGE
\u8def\u5f84
\u5982\u679c\u4e0d\u521b\u5efa STAGE
\u6216\u5168\u90e8 STAGE
\u90fd\u5728 DISABLED
\u72b6\u6001\u4e0b\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u64cd\u4f5c\u7cfb\u7edf\u6216\u5bf9\u8c61\u5b58\u50a8\u7684\u6743\u9650\u5141\u8bb8\u60c5\u51b5\u4e0b\uff0c\u5199\u5165\u4efb\u4f55\u8def\u5f84\u3002
\u5982\u679c\u4e0d\u4f7f\u7528 STAGE
\uff0c\u7528\u6237 SELECT INTO
\u65f6\u5fc5\u987b\u5f3a\u884c\u52a0\u5165 credential
\u4fe1\u606f\u3002
Note
> CREATE STAGE [ IF NOT EXISTS ] { stage_name }\n { StageParams }\u0005\n [ directoryTableParams ]\n [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"filepath\"='<string>', \"region\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"IF NOT EXISTS
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u5728\u521b\u5efa Stage \u65f6\u68c0\u67e5\u662f\u5426\u5df2\u5b58\u5728\u540c\u540d\u7684 Stage\uff0c\u907f\u514d\u91cd\u590d\u521b\u5efa\u3002
stage_name
\uff1a\u8981\u521b\u5efa\u7684 Stage \u7684\u540d\u79f0\u3002
StageParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u914d\u7f6e\u53c2\u6570\u3002
endpoint
\uff1aStage \u7684\u8fde\u63a5 URL\uff0c\u6307\u5b9a\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684\u4f4d\u7f6e\u3002\u5bf9\u4e8e\u4e0d\u540c\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff08\u5982 Amazon S3\u3001Aliyun OSS\u3001\u6587\u4ef6\u7cfb\u7edf\u7b49\uff09\uff0c\u8fd9\u4e2a URL \u7684\u5185\u5bb9\u53ef\u80fd\u6709\u6240\u4e0d\u540c\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com
CREDENTIALS
\uff1a\u8fd9\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\uff0c\u5305\u542b\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u6240\u9700\u7684\u51ed\u8bc1\u4fe1\u606f\uff0c
access_key_id
\uff1a\u7528\u4e8e\u8eab\u4efd\u9a8c\u8bc1\u7684\u8bbf\u95ee\u5bc6\u94a5 ID\u3002secret_access_key
\uff1a\u4e0e\u8bbf\u95ee\u5bc6\u94a5 ID \u76f8\u5173\u8054\u7684\u5bc6\u94a5\u3002\"filepath\"='<string>
\uff1a\u6307\u5b9a S3 \u5b58\u50a8\u4e2d\u7684\u6587\u4ef6\u8def\u5f84\u6216\u76ee\u5f55\u3002\"region\"='<string>'
\uff1a\u6307\u5b9a Amazon S3 \u5b58\u50a8\u6240\u5728\u7684 AWS \u533a\u57df\u3002directoryTableParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u76ee\u5f55\u8868\uff08directory table\uff09\u7684\u914d\u7f6e\u3002
ENABLE
\uff1a\u662f\u5426\u542f\u7528\u76ee\u5f55\u8868\uff0c\u503c\u4e3a TRUE
\u6216 FALSE
\u3002CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\n-- \u5f53\u8bbe\u7f6e\u597d\u6570\u636e\u9636\u6bb5\u4ee5\u540e\uff0c\u6570\u636e\u8868\u53ea\u80fd\u5bfc\u51fa\u5230\u6307\u5b9a\u8def\u5f84\uff0c\u5bfc\u51fa\u5230\u5176\u4ed6\u8def\u5f84\u5c06\u62a5\u9519\nmysql> SELECT * FROM user INTO OUTFILE '~/tmp/csv2/user.txt';\nERROR 20101 (HY000): internal error: stage exists, please try to check and use a stage instead\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/","title":"CREATE...FROM...PUBLICATION...","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE...FROM...PUBLICATION...
\u662f\u8ba2\u9605\u65b9\u8ba2\u9605\u4e00\u4e2a\u7531\u53d1\u5e03\u65b9\u521b\u5efa\u7684\u53d1\u5e03\uff0c\u7528\u6765\u83b7\u53d6\u53d1\u5e03\u65b9\u7684\u5171\u4eab\u6570\u636e\u3002
CREATE DATABASE database_name\nFROM account_name\nPUBLICATION pubname;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"-- \u5047\u8bbe\u7cfb\u7edf\u7ba1\u7406\u5458\u521b\u5efa\u4e86\u4e00\u4e2a\u79df\u6237 acc1 \u4e3a\u8ba2\u9605\u65b9\ncreate account acc1 admin_name 'root' identified by '111';\n\n-- \u5047\u8bbe\u4f1a\u8bdd 1 \u4e3a\u53d1\u5e03\u65b9\uff0c\u7531\u53d1\u5e03\u65b9\u5148\u53d1\u5e03\u4e00\u4e2a\u6570\u636e\u5e93\u7ed9\u79df\u6237\ncreate database sys_db_1;\nuse sys_db_1;\ncreate table sys_tbl_1(a int primary key );\ninsert into sys_tbl_1 values(1),(2),(3);\ncreate view v1 as (select * from sys_tbl_1);\ncreate publication sys_pub_1 database sys_db_1;\nmysql> show publications;\n+-------------+----------+---------------------+-------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+-------------+-------------+----------+\n| sys_pub_1 | sys_db_1 | 2024-04-24 11:54:36 | NULL | * | |\n+-------------+----------+---------------------+-------------+-------------+----------+\n1 row in set (0.01 sec)\n\n-- \u518d\u5f00\u542f\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\uff0c\u5047\u8bbe\u4f1a\u8bdd 2 \u4e3a\u8ba2\u9605\u65b9\uff0c\u7531\u8ba2\u9605\u65b9\u8ba2\u9605\u5df2\u53d1\u5e03\u7684\u6570\u636e\u5e93\nmysql -h 127.0.0.1 -P 6001 -u acc1:root -p --\u767b\u5f55\u79df\u6237\u8d26\u53f7\n\ncreate database sub1 from sys publication sys_pub_1;\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| sub1 |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\nmysql> show subscriptions;\n+-----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+-----------+-------------+--------------+---------------------+----------+---------------------+\n| sys_pub_1 | sys | sys_db_1 | 2024-04-24 11:54:36 | sub1 | 2024-04-24 11:56:05 |\n+-----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.01 sec)\n\nmysql> use sub1;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| Tables_in_sub1 |\n+----------------+\n| sys_tbl_1 |\n| v1 |\n+----------------+\n2 rows in set (0.01 sec)\n\nmysql> desc sys_tbl_1;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | NO | PRI | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\nmysql> select * from sys_tbl_1 order by a;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.01 sec)\n-- \u8ba2\u9605\u6210\u529f\n
Note
\u5982\u679c\u9700\u8981\u53d6\u6d88\u8ba2\u9605\uff0c\u53ef\u4ee5\u76f4\u63a5\u5220\u9664\u5df2\u8ba2\u9605\u7684\u6570\u636e\u5e93\u540d\u79f0\uff0c\u4f7f\u7528 DROP DATABASE
\u3002
CREATE TABLE AS SELECT
\u547d\u4ee4\u901a\u8fc7\u590d\u5236 SELECT
\u67e5\u8be2\u4e2d\u6307\u5b9a\u7684\u73b0\u6709\u8868\u4e2d\u7684\u5217\u5b9a\u4e49\u548c\u5217\u6570\u636e\u6765\u521b\u5efa\u65b0\u8868\u3002\u7136\u800c\uff0c\u5b83\u4e0d\u4f1a\u590d\u5236\u539f\u8868\u7684\u7ea6\u675f\u3001\u7d22\u5f15\u3001\u89c6\u56fe\u6216\u5176\u4ed6\u975e\u6570\u636e\u5c5e\u6027\u3002
> CREATE [TEMPORARY] TABLE [ IF NOT EXISTS ] table_name\n[ (column_name [, ...] ) ] AS {query}\n\nQuery can be any select statement in MO syntax.\n\nSELECT\n[ALL | DISTINCT ]\nselect_expr [, select_expr] [[AS] alias] ...\n[INTO variable [, ...]]\n[FROM table_references\n[WHERE where_condition]\n[GROUP BY {col_name | expr | position}\n[ASC | DESC]]\n[HAVING where_condition]\n[ORDER BY {col_name | expr | position}\n[ASC | DESC]] [ NULLS { FIRST | LAST } ]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-as-select/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"ALL\uff1a\u9ed8\u8ba4\u9009\u9879\uff0c\u8868\u793a\u8fd4\u56de\u6240\u6709\u5339\u914d\u7684\u884c\uff0c\u5305\u62ec\u91cd\u590d\u884c\u3002
DISTINCT\uff1a\u8868\u793a\u53ea\u8fd4\u56de\u552f\u4e00\u7684\u884c\uff0c\u5373\u53bb\u9664\u91cd\u590d\u884c\u3002
select_expr\uff1a\u8868\u793a\u8981\u9009\u62e9\u7684\u5217\u6216\u8868\u8fbe\u5f0f\u3002
AS alias\uff1a\u4e3a\u9009\u62e9\u7684\u5217\u6216\u8868\u8fbe\u5f0f\u6307\u5b9a\u4e00\u4e2a\u522b\u540d\u3002
[INTO variable[, ...]\uff1a\u7528\u4e8e\u5c06\u67e5\u8be2\u7ed3\u679c\u5b58\u50a8\u5728\u4e00\u4e2a\u53d8\u91cf\u4e2d\uff0c\u800c\u4e0d\u662f\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002
[FROM table_references]\uff1a\u6307\u5b9a\u4ece\u54ea\u4e2a\u8868\u6216\u54ea\u4e9b\u8868\u4e2d\u68c0\u7d22\u6570\u636e\u3002table_references \u53ef\u4ee5\u662f\u4e00\u4e2a\u8868\u540d\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u5305\u542b\u591a\u4e2a\u8868\u7684\u590d\u6742\u8868\u8fbe\u5f0f\uff08\u5982\u8fde\u63a5\uff09\u3002
[WHERE where_condition]\uff1a\u7528\u4e8e\u8fc7\u6ee4\u7ed3\u679c\u96c6\uff0c\u53ea\u8fd4\u56de\u6ee1\u8db3 where_condition \u6761\u4ef6\u7684\u884c\u3002
[GROUP BY {col_name | expr | position} [ASC | DESC]]\uff1a\u7528\u4e8e\u5c06\u7ed3\u679c\u96c6\u6309\u7167\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u6216\u8868\u8fbe\u5f0f\u8fdb\u884c\u5206\u7ec4\uff1bASC \u548c DESC \u7528\u4e8e\u6307\u5b9a\u5206\u7ec4\u5185\u884c\u7684\u6392\u5e8f\u65b9\u5f0f\u3002
[HAVING where_condition]\uff1a\u5728\u5206\u7ec4\u540e\u5bf9\u5206\u7ec4\u8fdb\u884c\u8fc7\u6ee4\u3002\u901a\u5e38\u4e0e GROUP BY \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u8fc7\u6ee4\u6389\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u5206\u7ec4\u3002
[ORDER BY {col_name | expr | position} [ASC | DESC] [NULLS {FIRST | LAST}]]\uff1a\u7528\u4e8e\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u6392\u5e8f; ASC \u548c DESC \u7528\u4e8e\u6307\u5b9a\u6392\u5e8f\u65b9\u5f0f\u3002
[NULLS {FIRST | LAST}]\uff1a\u7528\u4e8e\u6307\u5b9a\u5982\u4f55\u5904\u7406 NULL \u503c\u5728\u6392\u5e8f\u4e2d\u7684\u4f4d\u7f6e\u3002
[LIMIT {[offset,] row_count | row_count OFFSET offset}]\uff1a\u7528\u4e8e\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570\u3002offset \u6307\u5b9a\u4ece\u7ed3\u679c\u96c6\u7684\u54ea\u4e00\u884c\u5f00\u59cb\u8fd4\u56de\uff0c0 \u4e3a\u7b2c\u4e00\u884c\u3002row_count \u6307\u5b9a\u8fd4\u56de\u7684\u884c\u6570\u3002
\u5728 Matrixone
\u4e2d\uff0c\u6267\u884c CREATE TABLE AS SELECT
\u8bed\u53e5\u9700\u8981\u5177\u6709\u81f3\u5c11\u4ee5\u4e0b\u6743\u9650\uff1a
CREATE
\u6743\u9650\uff1a\u7528\u6237\u9700\u8981\u5177\u6709\u521b\u5efa\u8868\u7684\u6743\u9650\uff0c\u8fd9\u53ef\u4ee5\u901a\u8fc7 CREATE
\u6743\u9650\u6765\u5b9e\u73b0\u3002
INSERT
\u6743\u9650\uff1a\u7531\u4e8e CREATE TABLE AS SELECT
\u8bed\u53e5\u5c06\u9009\u62e9\u7684\u6570\u636e\u63d2\u5165\u5230\u65b0\u8868\u4e2d\uff0c\u56e0\u6b64\u7528\u6237\u8fd8\u9700\u8981\u5177\u6709\u5411\u76ee\u6807\u8868\u63d2\u5165\u6570\u636e\u7684\u6743\u9650\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7 INSERT
\u6743\u9650\u6765\u5b9e\u73b0\u3002
SELECT
\u6743\u9650\uff1a\u7528\u6237\u9700\u8981\u80fd\u591f\u9009\u62e9\u6e90\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff0c\u56e0\u6b64\u9700\u8981\u5177\u6709 SELECT \u6743\u9650\u3002
\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6743\u9650\u76f8\u5173\u7684\u64cd\u4f5c\uff0c\u8bf7\u67e5\u770b Matrixone \u6743\u9650\u5206\u7c7b\u5217\u8868\u548c grant \u8bf4\u660e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-as-select/#_5","title":"\u793a\u4f8b","text":"create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> create table t2 as select *from t1;--\u6574\u8868\u590d\u5236\nQuery OK, 3 rows affected (0.02 sec)\n\nmysql> desc t2;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | 123 | | |\n| b | CHAR(5) | YES | | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t2;\n+------------+------+\n| a | b |\n+------------+------+\n| 1 | 1 |\n| 2 | 2 |\n| 2147483647 | max |\n+------------+------+\n3 rows in set (0.00 sec)\n
create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> CREATE table test as select a as alias_a from t1;--\u4e3a\u9009\u62e9\u5217\u6307\u5b9a\u522b\u540d\nQuery OK, 3 rows affected (0.02 sec)\n\nmysql> desc test;\n+---------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+---------+---------+------+------+---------+-------+---------+\n| alias_a | INT(32) | YES | | 123 | | |\n+---------+---------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\nmysql> select * from test;\n+------------+\n| alias_a |\n+------------+\n| 1 |\n| 2 |\n| 2147483647 |\n+------------+\n3 rows in set (0.01 sec)\n
create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> create table t3 as select * from t1 where 1=2;--\u53ea\u590d\u5236\u5b57\u6bb5\uff0c\u4e0d\u590d\u5236\u6570\u636e\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> desc t3;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | 123 | | |\n| b | CHAR(5) | YES | | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t3;\nEmpty set (0.00 sec)\n
create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> CREATE table t4(n1 int unique) as select max(a) from t1;--\u4ee5\u539f\u8868\u6570\u636e\u805a\u5408\u503c\u4f5c\u4e3a\u65b0\u8868\u7684\u5217\nQuery OK, 1 row affected (0.03 sec)\n\nmysql> desc t4;\n+--------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+--------+---------+------+------+---------+-------+---------+\n| n1 | INT(32) | YES | UNI | NULL | | |\n| max(a) | INT(32) | YES | | NULL | | |\n+--------+---------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t4;\n+------+------------+\n| n1 | max(a) |\n+------+------------+\n| NULL | 2147483647 |\n+------+------------+\n1 row in set (0.00 sec)\n
create table t5(n1 int,n2 int,n3 int);\ninsert into t5 values(1,1,1),(1,1,1),(3,3,3);\n\nmysql> create table t5_1 as select distinct n1 from t5;--\u53bb\u9664\u91cd\u590d\u884c\nQuery OK, 2 rows affected (0.02 sec)\n\nmysql> select * from t5_1;\n+------+\n| n1 |\n+------+\n| 1 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n
create table t6(n1 int,n2 int,n3 int);\ninsert into t6 values(1,1,3),(2,2,2),(3,3,1);\n\nmysql> create table t6_1 as select * from t6 order by n3;--\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u6392\u5e8f\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> select * from t6_1;\n+------+------+------+\n| n1 | n2 | n3 |\n+------+------+------+\n| 3 | 3 | 1 |\n| 2 | 2 | 2 |\n| 1 | 1 | 3 |\n+------+------+------+\n3 rows in set (0.01 sec)\n
create table t7(n1 int,n2 int,n3 int);\ninsert into t7 values(1,1,3),(1,2,2),(2,3,1),(2,3,1),(3,3,1);\n\nmysql> CREATE TABLE t7_1 AS SELECT n1 FROM t7 GROUP BY n1 HAVING count(n1)>1;--\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u5206\u7ec4\nQuery OK, 2 rows affected (0.02 sec)\n\nmysql> mysql> select * from t7_1;\n+------+\n| n1 |\n+------+\n| 1 |\n| 2 |\n+------+\n2 rows in set (0.01 sec)\n
create table t8(n1 int,n2 int,n3 int);\ninsert into t8 values(1,1,1),(2,2,2),(3,3,3);\n\nmysql> CREATE TABLE t8_1 AS SELECT * FROM t8 limit 1 offset 1;--\u6307\u5b9a\u4ece\u7ed3\u679c\u96c6\u7684\u7b2c\u4e8c\u884c\u5f00\u59cb\u8fd4\u56de\uff0c\u8fd4\u56de\u884c\u6570\u4e3a 1\n\nmysql> select * from t8_1;\n+------+------+------+\n| n1 | n2 | n3 |\n+------+------+------+\n| 2 | 2 | 2 |\n+------+------+------+\n1 row in set (0.00 sec)\n
create table t9 (a int primary key, b varchar(5) unique key);\ncreate table t9_1 (\na int primary key,\nb varchar(5) unique,\nc int , d int,\nforeign key(c) references t9(a),\nINDEX idx_d(d)\n);\ninsert into t9 values (101,'abc'),(102,'def');\ninsert into t9_1 values (1,'zs1',101,1),(2,'zs2',102,1);\n\nmysql> create table t9_2 as select * from t9_1;\n\nmysql> show create table t9_1;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t9_1 | CREATE TABLE `t9_1` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` INT DEFAULT NULL,\n`d` INT DEFAULT NULL,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nKEY `idx_d` (`d`),\nCONSTRAINT `018f27eb-0b33-7289-a3c2-af479b1833b1` FOREIGN KEY (`c`) REFERENCES `t9` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show create table t9_2;--\u6e90\u8868\u5e26\u7ea6\u675f\u6216\u8005\u7d22\u5f15\uff0cCTAS \u521b\u5efa\u7684\u65b0\u8868\u9ed8\u8ba4\u4e0d\u4f1a\u5e26\u6709\u539f\u8868\u7684\u7ea6\u675f\u548c\u7d22\u5f15\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| t9_2 | CREATE TABLE `t9_2` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` INT DEFAULT NULL,\n`d` INT DEFAULT NULL\n) |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n--\u5982\u679c\u5e0c\u671b\u65b0\u8868\u5e26\u6709\u539f\u8868\u5e26\u7ea6\u675f\u548c\u7d22\u5f15\uff0c\u5219\u53ef\u4ee5\u5728\u5efa\u8868\u540e\u6dfb\u52a0\nALTER TABLE t9_2 ADD PRIMARY KEY (a);\nALTER TABLE t9_2 ADD UNIQUE KEY (b);\nALTER TABLE t9_2 ADD FOREIGN KEY (c) REFERENCES t9 (a);\nALTER TABLE t9_2 ADD INDEX idx_d3 (d);\n\nmysql> show create table t9_2;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t9_2 | CREATE TABLE `t9_2` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` INT DEFAULT NULL,\n`d` INT DEFAULT NULL,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nKEY `idx_d3` (`d`),\nCONSTRAINT `018f282d-4563-7e9d-9be5-79c0d0e8136d` FOREIGN KEY (`c`) REFERENCES `t9` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-like/","title":"CREATE TABLE ... LIKE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-like/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE TABLE ... LIKE
\u6839\u636e\u53e6\u4e00\u4e2a\u8868\u7684\u5b9a\u4e49\u521b\u5efa\u4e00\u4e2a\u7a7a\u8868\uff0c\u5b83\u4f1a\u590d\u5236\u539f\u59cb\u8868\u7684\u7ed3\u6784\uff0c\u4f46\u4e0d\u4f1a\u590d\u5236\u539f\u59cb\u8868\u4e2d\u5b58\u50a8\u7684\u6570\u636e\u3002
CREATE TABLE new_tbl LIKE orig_tbl;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-like/#_3","title":"\u793a\u4f8b","text":"create table test1 (a int primary key, b varchar(5) unique key);\ncreate table test2 (a int primary key,b varchar(5) unique key,c double DEFAULT 0, d char,e int, foreign key(e) references foreign01(a), unique index(c,d));\ninsert into test1 values (101,'abc'),(102,'def');\ninsert into test2 values (1,'zs1',1,'a',101),(2,'zs2',2,'b',102);\n\nmysql> create table test3 like test2;\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> show CREATE TABLE test2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| test2 | CREATE TABLE `test2` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` DOUBLE DEFAULT 0,\n`d` CHAR(1) DEFAULT NULL,\n`e` INT DEFAULT NULL,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nUNIQUE KEY `c` (`c`,`d`),\nCONSTRAINT `018eb74f-38f3-7eb4-80c1-95d9c65de706` FOREIGN KEY (`e`) REFERENCES `foreign01` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> show CREATE TABLE test3;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| test3 | CREATE TABLE `test3` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT null,\n`c` DOUBLE DEFAULT 0,\n`d` CHAR(1) DEFAULT null,\n`e` INT DEFAULT null,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nUNIQUE KEY `c` (`c`,`d`),\nCONSTRAINT `018eb74f-38f3-7eb4-80c1-95d9c65de706` FOREIGN KEY (`e`) REFERENCES `foreign01` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from test2;\n+------+------+------+------+------+\n| a | b | c | d | e |\n+------+------+------+------+------+\n| 1 | zs1 | 1 | a | 101 |\n| 2 | zs2 | 2 | b | 102 |\n+------+------+------+------+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from test3;\nEmpty set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/","title":"CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE TABLE
\u8bed\u53e5\u7528\u4e8e\u5728\u5f53\u524d\u6240\u9009\u6570\u636e\u5e93\u521b\u5efa\u4e00\u5f20\u65b0\u8868\u3002
> CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n (create_definition,...)\n [table_options]\n [partition_options]\n\ncreate_definition: {\n col_name column_definition\n | [CONSTRAINT [symbol]] PRIMARY KEY\n [index_type] (key_part,...)\n [index_option] ...\n | [CONSTRAINT [symbol]] FOREIGN KEY\n [index_name] (col_name,...)\n reference_definition\n}\n\ncolumn_definition: {\n data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]\n [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]\n [COMMENT 'string']\n [reference_definition]\n | data_type\n [[PRIMARY] KEY]\n [COMMENT 'string']\n [reference_definition]\n}\n\nreference_definition:\n REFERENCES tbl_name (key_part,...)\n [ON DELETE reference_option]\n [ON UPDATE reference_option]\n\nreference_option:\n RESTRICT | CASCADE | SET NULL | NO ACTION\n\ntable_options:\n table_option [[,] table_option] ...\n\ntable_option: {\n | AUTO_INCREMENT [=] value\n | COMMENT [=] 'string'\n | START TRANSACTION\n}\n\npartition_options:\n PARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)}\n | RANGE{(expr) | COLUMNS(column_list)}\n | LIST{(expr) | COLUMNS(column_list)} }\n [PARTITIONS num]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n [VALUES\n {LESS THAN {(expr | value_list) | MAXVALUE}\n |\n IN (value_list)}]\n [COMMENT [=] 'string' ]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"\u521b\u5efa\u8868\u65f6\u53ef\u4ee5\u4f7f\u7528\u7684\u5404\u79cd\u53c2\u6570\u548c\u9009\u9879\uff0c\u5305\u62ec\u8868\u7684\u521b\u5efa\u3001\u5217\u7684\u5b9a\u4e49\u3001\u7ea6\u675f\u3001\u9009\u9879\u548c\u5206\u533a\u7b49\u3002
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
\uff1a\u8fd9\u662f\u521b\u5efa\u8868\u7684\u57fa\u672c\u8bed\u6cd5\u3002TEMPORARY
\u5173\u952e\u5b57\u8868\u793a\u521b\u5efa\u4e34\u65f6\u8868\uff0cIF NOT EXISTS
\u8868\u793a\u5982\u679c\u8868\u4e0d\u5b58\u5728\u5219\u521b\u5efa\uff0ctbl_name
\u662f\u8981\u521b\u5efa\u7684\u8868\u7684\u540d\u79f0\u3002
(create_definition,...)
\uff1a\u8fd9\u662f\u5217\u5b9a\u4e49\u7684\u90e8\u5206\uff0c\u7528\u6765\u5b9a\u4e49\u8868\u7684\u5404\u4e2a\u5217\u4ee5\u53ca\u76f8\u5173\u5c5e\u6027\u3002
[table_options]
\uff1a\u8fd9\u662f\u8868\u7ea7\u522b\u7684\u9009\u9879\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u8868\u7684\u5b58\u50a8\u5f15\u64ce\u3001\u5b57\u7b26\u96c6\u7b49\u53c2\u6570\u3002
[partition_options]
\uff1a\u8fd9\u662f\u7528\u4e8e\u5206\u533a\u8868\u7684\u9009\u9879\uff0c\u7528\u6765\u5b9a\u4e49\u5206\u533a\u65b9\u5f0f\u548c\u5206\u533a\u952e\u3002
create_definition
\u90e8\u5206\u7528\u4e8e\u5b9a\u4e49\u6bcf\u4e00\u5217\u7684\u5c5e\u6027\uff0c\u5b83\u53ef\u4ee5\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1a
col_name column_definition
\uff1a\u5b9a\u4e49\u5177\u4f53\u5217\u540d\u4ee5\u53ca\u5217\u7684\u5c5e\u6027\uff0c\u5305\u62ec\u6570\u636e\u7c7b\u578b\u3001\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a\u3001\u9ed8\u8ba4\u503c\u7b49\u3002
[CONSTRAINT [symbol]] PRIMARY KEY
\uff1a\u5b9a\u4e49\u4e3b\u952e\u7ea6\u675f\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u7ea6\u675f\u540d\u79f0\u548c\u4e3b\u952e\u7684\u5217\u3002
[CONSTRAINT [symbol]] FOREIGN KEY
\uff1a\u5b9a\u4e49\u5916\u952e\u7ea6\u675f\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u7ea6\u675f\u540d\u79f0\u3001\u5916\u952e\u7684\u5217\u4ee5\u53ca\u53c2\u8003\u7684\u8868\u3002
column_definition
\u90e8\u5206\u7528\u4e8e\u5177\u4f53\u5217\u7684\u5b9a\u4e49\uff0c\u53ef\u4ee5\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1a
data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]
\uff1a\u5b9a\u4e49\u5217\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4ee5\u53ca\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a\u548c\u9ed8\u8ba4\u503c\u3002
[AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]
\uff1a\u8bbe\u7f6e\u81ea\u589e\u3001\u552f\u4e00\u548c\u4e3b\u952e\u7ea6\u675f\u3002
[COMMENT 'string']
\uff1a\u8bbe\u7f6e\u5217\u7684\u6ce8\u91ca\u3002
[reference_definition]
\uff1a\u53ef\u9009\u7684\u5f15\u7528\u5b9a\u4e49\uff0c\u7528\u4e8e\u5b9a\u4e49\u5916\u952e\u7ea6\u675f\u3002
reference_definition
\u90e8\u5206\u7528\u4e8e\u5b9a\u4e49\u5916\u952e\u5f15\u7528\uff0c\u5305\u62ec\u4ee5\u4e0b\u5185\u5bb9\uff1a
REFERENCES tbl_name (key_part,...)
\uff1a\u6307\u5b9a\u5916\u952e\u5f15\u7528\u7684\u8868\u548c\u5217\u3002
[ON DELETE reference_option]
\uff1a\u8bbe\u7f6e\u5728\u5220\u9664\u65f6\u7684\u5916\u952e\u64cd\u4f5c\u3002
[ON UPDATE reference_option]
\uff1a\u8bbe\u7f6e\u5728\u66f4\u65b0\u65f6\u7684\u5916\u952e\u64cd\u4f5c\u3002
reference_option
\u8868\u793a\u5916\u952e\u64cd\u4f5c\u7684\u9009\u9879\uff0c\u53ef\u4ee5\u662f RESTRICT
\u3001CASCADE
\u3001SET NULL
\u6216 NO ACTION
\u3002
table_options
\u90e8\u5206\u7528\u4e8e\u8bbe\u7f6e\u8868\u7ea7\u522b\u7684\u9009\u9879\uff0c\u5305\u62ec\u81ea\u589e\u7684\u521d\u59cb\u503c\u3001\u8868\u7684\u6ce8\u91ca\u7b49\u3002
partition_options
\u90e8\u5206\u7528\u4e8e\u5b9a\u4e49\u5206\u533a\u8868\u7684\u9009\u9879\uff0c\u5305\u62ec\u5206\u533a\u65b9\u5f0f\u3001\u5206\u533a\u952e\u4ee5\u53ca\u5206\u533a\u6570\u7b49\u3002
\u66f4\u8be6\u7ec6\u7684\u53c2\u6570\u8bed\u6cd5\u91ca\u4e49\u8bf7\u53c2\u89c1\u4e0b\u6587\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#temporary","title":"TEMPORARY","text":"\u5728\u521b\u5efa\u8868\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 TEMPORARY
\u5173\u952e\u5b57\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u8868\u3002TEMPORARY
\u8868\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u53ef\u89c1\uff0c\u5728\u4f1a\u8bdd\u5173\u95ed\u65f6\u81ea\u52a8\u5220\u9664\u3002\u8fd9\u8868\u793a\u4e24\u4e2a\u4e0d\u540c\u7684\u4f1a\u8bdd\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u4e34\u65f6\u8868\u540d\uff0c\u800c\u4e0d\u4f1a\u5f7c\u6b64\u51b2\u7a81\u6216\u4e0e\u540c\u540d\u7684\u73b0\u6709\u975e\u4e34\u65f6\u8868\u51b2\u7a81\u3002(\u5728\u5220\u9664\u4e34\u65f6\u8868\u4e4b\u524d\uff0c\u4f1a\u9690\u85cf\u73b0\u6709\u8868\u3002)
\u5220\u9664\u6570\u636e\u5e93\u4f1a\u81ea\u52a8\u5220\u9664\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u7684\u6240\u6709 TEMPORARY
\u8868\u3002
\u521b\u5efa\u4f1a\u8bdd\u53ef\u4ee5\u5bf9\u8868\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u4f8b\u5982 DROP table
\u3001INSERT
\u3001UPDATE
\u6216 SELECT
\u3002
\u53ef\u4ee5\u4f7f\u7528 comment
\u9009\u9879\u6307\u5b9a\u5217\u6216\u6574\u5f20\u8868\u7684\u6ce8\u91ca\uff1a
CREATE TABLE [IF NOT EXISTS] [db.]table_name [comment = \"comment of table\"];
\u4e2d\u7684 comment
\u4e3a\u6574\u5f20\u8868\u7684\u6ce8\u91ca\uff0c\u6700\u957f 2049 \u4e2a\u5b57\u7b26\u3002(name1 type1 [comment 'comment of column'],...)
\u4e2d\u7684 comment
\u4e3a\u6307\u5b9a\u5217\u7684\u6ce8\u91ca\uff1a\u6700\u957f 1024 \u4e2a\u5b57\u7b26\u3002\u4f7f\u7528 SHOW CREATE TABLE
\u548c SHOW FULL COLUMNS
\u8bed\u53e5\u663e\u793a\u6ce8\u91ca\u5185\u5bb9\u3002\u6ce8\u91ca\u5185\u5bb9\u4e5f\u663e\u793a\u5728 INFORMATION_SCHEMA.COLUMN_COMMENT
\u5217\u4e2d\u3002
AUTO_INCREMENT
\uff1a\u8868\u7684\u521d\u59cb\u503c\uff0c\u521d\u59cb\u503c\u9ed8\u8ba4\u4ece 1 \u5f00\u59cb\uff0c\u6bcf\u6761\u65b0\u7eaa\u5f55\u9012\u589e 1\uff0c\u4e14\u6570\u636e\u5217\u7684\u503c\u5fc5\u987b\u552f\u4e00\u3002
AUTO_INCREMENT
\u7684\u5217\uff0c\u9700\u4e3a\u6574\u6570\u6216\u8005\u6d6e\u70b9\u6570\u636e\u7c7b\u578b\u3002\u81ea\u589e\u5217\u9700\u8981\u8bbe\u7f6e\u4e3a NOT NULL
\uff0c\u5426\u5219\u4f1a\u76f4\u63a5\u5b58\u50a8 NULL
\u3002\u5f53\u4f60\u5c06 NULL\uff08\u63a8\u8350\uff09\u6216 0 \u503c\u63d2\u5165\u7d22\u5f15\u7684 AUTO_INCREMENT
\u5217\u65f6\uff0c\u8be5\u5217\u5c06\u8bbe\u7f6e\u4e3a\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\u3002\u901a\u5e38\u8fd9\u662f value+1\uff0c\u5176\u4e2d value \u662f\u8868\u4e2d\u5f53\u524d\u5217\u7684\u6700\u5927\u503c\u3002
\u6bcf\u4e2a\u8868\u53ea\u80fd\u6709\u4e00\u4e2a AUTO_INCREMENT
\u5217\uff0c\u5b83\u5fc5\u987b\u53ef\u4ee5\u88ab\u7d22\u5f15\uff0c\u4e14\u4e0d\u80fd\u8bbe\u7f6e\u9ed8\u8ba4\u503c\u3002AUTO_INCREMENT
\u5217\u9700\u8981\u542b\u6709\u6b63\u6570\u503c\uff0c\u5982\u679c\u63d2\u5165\u4e00\u4e2a\u8d1f\u6570\u88ab\u5224\u65ad\u4e3a\u63d2\u5165\u4e00\u4e2a\u975e\u5e38\u5927\u7684\u6b63\u6570\uff0c\u8fd9\u6837\u505a\u662f\u4e3a\u4e86\u907f\u514d\u6570\u5b57\u51fa\u73b0\u7cbe\u5ea6\u95ee\u9898\uff0c\u5e76\u786e\u4fdd\u4e0d\u4f1a\u610f\u5916\u51fa\u73b0\u5305\u542b 0 \u7684 AUTO_INCREMENT
\u5217\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 AUTO_INCREMENT
\u5c5e\u6027\u6765\u5b9a\u4e49\u81ea\u589e\u5217\u7684\u8d77\u59cb\u503c\u3002\u5982\u679c\u8981\u8bbe\u7f6e\u81ea\u589e\u5217\u7684\u8d77\u59cb\u503c\u4e3a 10\uff0c\u53ef\u4ee5\u5728\u521b\u5efa\u8868\u65f6\u4f7f\u7528 AUTO_INCREMENT
\u5173\u952e\u5b57\uff0c\u5e76\u5728\u540e\u9762\u6307\u5b9a\u8d77\u59cb\u503c\u3002
\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u8868\u5e76\u5b9a\u4e49\u81ea\u589e\u5217\u7684\u8d77\u59cb\u503c\u4e3a 10\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\uff1a
-- \u8bbe\u7f6e\ncreate table t1(id int auto_increment primary key) auto_increment = 10;\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cid
\u5217\u662f\u81ea\u589e\u5217\uff0c\u5176\u8d77\u59cb\u503c\u4e3a 10\uff0c\u5f53\u5411\u8868\u4e2d\u63d2\u5165\u65b0\u8bb0\u5f55\u65f6\uff0cid
\u5217\u7684\u503c\u5c06\u4ece 10 \u5f00\u59cb\uff0c\u6bcf\u6b21\u81ea\u52a8\u9012\u589e 1\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a AUTO_INCREMENT
\u7684\u8d77\u59cb\u503c\uff0c\u9ed8\u8ba4\u8d77\u59cb\u503c\u4e3a 1\uff0c\u6bcf\u6b21\u81ea\u52a8\u9012\u589e 1\u3002
Note
set @@auto_increment_offset=n
\u6765\u8bbe\u7f6e\u81ea\u589e\u5217\u521d\u59cb\u503c\uff0c\u5b9e\u9645\u5e76\u4e0d\u751f\u6548\u3002PRIMARY KEY
\u5373\u4e3b\u952e\u7ea6\u675f\uff0c\u7528\u4e8e\u552f\u4e00\u6807\u793a\u8868\u4e2d\u7684\u6bcf\u6761\u6570\u636e\u3002 \u4e3b\u952e\u5fc5\u987b\u5305\u542b UNIQUE
\u503c\uff0c\u4e0d\u80fd\u5305\u542b NULL
\u503c\u3002 \u5f53\u524d\u7248\u672c\u4e00\u4e2a\u8868\u53ea\u80fd\u6709\u4e00\u4e2a\u4e3b\u952e\uff0c\u8fd9\u4e2a\u4e3b\u952e\u53ef\u4ee5\u7531\u4e00\u4e2a\u5217\u7ec4\u6210\uff0c\u4e5f\u53ef\u4ee5\u7531\u591a\u4e2a\u5217\u7ec4\u6210\u3002
\u4ee5\u4e0b SQL \u8bed\u53e5\u5728\u521b\u5efa Persons
\u8868\u65f6\uff0c\u5728\u5176\u4e2d\u7684 ID
\u5217\u521b\u5efa\u4e3b\u952e\uff1a
> CREATE TABLE Persons (\n ID int NOT NULL,\n LastName varchar(255) NOT NULL,\n FirstName varchar(255),\n Age int,\n PRIMARY KEY (ID)\n);\n
Note
\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u53ea\u6709\u4e00\u4e2a\u4e3b\u952e\uff0c\u5e76\u4e14\u5176\u4e2d\u4ec5\u5305\u542b\u4e86\u4e00\u5217\uff08ID
\uff09
\u800c\u4e0b\u9762 SQL \u8bed\u53e5\u5728\u521b\u5efa Students
\u8868\u65f6\uff0c\u5728\u5176\u4e2d\u7684 ID
\u548c LastName
\u5217\u521b\u5efa\u4e3b\u952e\uff1a
> CREATE TABLE Students (\n ID int NOT NULL,\n LastName varchar(255) NOT NULL,\n FirstName varchar(255),\n Age int,\n PRIMARY KEY (ID,LastName)\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#foreign-key","title":"FOREIGN KEY","text":"FOREIGN KEY \u7ea6\u675f\uff0c\u5373\u5916\u952e\u7ea6\u675f\uff0c\u662f\u8868\u7684\u4e00\u4e2a\u7279\u6b8a\u5b57\u6bb5\uff0c\u7ecf\u5e38\u4e0e\u4e3b\u952e\u7ea6\u675f\u4e00\u8d77\u4f7f\u7528\u3002\u5916\u952e\u7ea6\u675f\u662f\u7528\u4e8e\u9632\u6b62\u7834\u574f\u8868\u4e4b\u95f4\u94fe\u63a5\u7684\u884c\u4e3a\u3002\u5bf9\u4e8e\u4e24\u4e2a\u5177\u6709\u5173\u8054\u5173\u7cfb\u7684\u8868\u800c\u8a00\uff0c\u76f8\u5173\u8054\u5b57\u6bb5\u4e2d\u4e3b\u952e\u6240\u5728\u7684\u8868\u5c31\u662f\u4e3b\u8868\uff08\u7236\u8868\uff09\uff0c\u5916\u952e\u6240\u5728\u7684\u8868\u5c31\u662f\u4ece\u8868\uff08\u5b50\u8868\uff09\u3002\u5916\u952e\u7528\u6765\u5efa\u7acb\u4e3b\u8868\u4e0e\u4ece\u8868\u7684\u5173\u8054\u5173\u7cfb\uff0c\u4e3a\u4e24\u4e2a\u8868\u7684\u6570\u636e\u5efa\u7acb\u8fde\u63a5\uff0c\u7ea6\u675f\u4e24\u4e2a\u8868\u4e2d\u6570\u636e\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\u3002
FOREIGN KEY \u7ea6\u675f\u4e5f\u80fd\u9632\u6b62\u975e\u6cd5\u6570\u636e\u63d2\u5165\u5916\u952e\u5217\uff0c\u56e0\u4e3a\u5b83\u5fc5\u987b\u662f\u5b83\u6307\u5411\u7684\u90a3\u4e2a\u8868\u4e2d\u7684\u503c\u4e4b\u4e00\u3002
\u5b9a\u4e49\u5916\u952e\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e0b\u5217\u89c4\u5219\uff1a
\u5fc5\u987b\u4e3a\u4e3b\u8868\u5b9a\u4e49\u4e3b\u952e\u3002
\u5728\u4e3b\u8868\u7684\u8868\u540d\u540e\u9762\u6307\u5b9a\u5217\u540d\u6216\u5217\u540d\u7684\u7ec4\u5408\u3002\u8fd9\u4e2a\u5217\u6216\u5217\u7684\u7ec4\u5408\u5fc5\u987b\u662f\u4e3b\u8868\u7684\u4e3b\u952e\u6216\u5019\u9009\u952e\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u76ee\u5fc5\u987b\u548c\u4e3b\u8868\u7684\u4e3b\u952e\u4e2d\u5217\u7684\u6570\u76ee\u76f8\u540c\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u548c\u4e3b\u8868\u4e3b\u952e\u4e2d\u5bf9\u5e94\u5217\u7684\u6570\u636e\u7c7b\u578b\u76f8\u540c\u3002
\u4e0b\u9762\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u8fdb\u884c\u8bf4\u660e\u901a\u8fc7 FOREIGN KEY \u548c PRIMARY KEY \u5173\u8054\u7236\u8868\u4e0e\u5b50\u8868\uff1a
\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u7236\u8868\uff0c\u5b57\u6bb5 a \u4e3a\u4e3b\u952e\uff1a
create table t1(a int primary key,b varchar(5));\ninsert into t1 values(101,'abc'),(102,'def');\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 101 | abc |\n| 102 | def |\n+------+------+\n2 rows in set (0.00 sec)\n
\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u5b50\u8868\uff0c\u5b57\u6bb5 c \u4e3a\u5916\u952e\uff0c\u5173\u8054\u7236\u8868\u5b57\u6bb5 a\uff1a
create table t2(a int ,b varchar(5),c int, foreign key(c) references t1(a));\ninsert into t2 values(1,'zs1',101),(2,'zs2',102);\ninsert into t2 values(3,'xyz',null);\nmysql> select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | zs1 | 101 |\n| 2 | zs2 | 102 |\n| 3 | xyz | NULL |\n+------+------+------+\n3 rows in set (0.00 sec)\n
\u53e6\u5916\uff0c[ON DELETE reference_option]
\u548c [ON UPDATE reference_option]
\u5728\u5b9a\u4e49\u5916\u952e\u5173\u7cfb\u65f6\u7528\u4e8e\u6307\u5b9a\u5728\u5220\u9664\u7236\u8868\u4e2d\u7684\u8bb0\u5f55\u65f6\u6267\u884c\u7684\u64cd\u4f5c\u3002\u8fd9\u4e24\u4e2a\u53c2\u6570\u4e3b\u8981\u7528\u4e8e\u7ef4\u62a4\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\uff1a
ON DELETE reference_option
\uff1a\u8fd9\u4e2a\u53c2\u6570\u6307\u5b9a\u4e86\u5728\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5e94\u8be5\u5982\u4f55\u5904\u7406\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u5e38\u89c1\u7684\u9009\u9879\u5305\u62ec\uff1a
RESTRICT
\uff1a\u5982\u679c\u5728\u5f15\u7528\u8868\u4e2d\u6709\u76f8\u5173\u7684\u5916\u952e\u6570\u636e\u5b58\u5728\uff0c\u4e0d\u5141\u8bb8\u5220\u9664\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u6765\u9632\u6b62\u8bef\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u7ef4\u62a4\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
CASCADE
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u540c\u65f6\u5220\u9664\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u7ea7\u8054\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002
SET NULL
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5c06\u5916\u952e\u5217\u7684\u503c\u8bbe\u7f6e\u4e3a NULL\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u5728\u5220\u9664\u5f15\u7528\u6570\u636e\u65f6\u4fdd\u7559\u5916\u952e\u6570\u636e\uff0c\u4f46\u65ad\u5f00\u4e0e\u5f15\u7528\u6570\u636e\u7684\u5173\u8054\u3002
NO ACTION
\uff1a\u8868\u793a\u4e0d\u91c7\u53d6\u4efb\u4f55\u64cd\u4f5c\uff0c\u53ea\u662f\u68c0\u67e5\u662f\u5426\u6709\u5173\u8054\u6570\u636e\u5b58\u5728\u3002\u8fd9\u7c7b\u4f3c\u4e8e RESTRICT
\uff0c\u4f46\u53ef\u80fd\u5728\u67d0\u4e9b\u6570\u636e\u5e93\u4e2d\u6709\u5fae\u5c0f\u7684\u5dee\u5f02\u3002
ON UPDATE reference_option
\uff1a\u8fd9\u4e2a\u53c2\u6570\u6307\u5b9a\u4e86\u5728\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u66f4\u65b0\u65f6\uff0c\u5e94\u8be5\u5982\u4f55\u5904\u7406\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u5e38\u89c1\u7684\u9009\u9879\u7c7b\u4f3c\u4e8e ON DELETE reference_option
\uff0c\u7528\u6cd5\u4e5f\u7c7b\u4f3c\uff0c\u53ea\u662f\u9488\u5bf9\u6570\u636e\u66f4\u65b0\u64cd\u4f5c\u3002
\u53c2\u89c1\u4e0b\u9762\u7684\u793a\u4f8b\uff1a
\u5047\u8bbe\u6709\u4e24\u5f20\u8868 Orders
\u548c Customers
\uff0cOrders
\u8868\u4e2d\u6709\u4e00\u4e2a\u5916\u952e\u5217 customer_id
\u5f15\u7528 Customers
\u8868\u4e2d\u7684 id
\u5217\u3002\u5982\u679c\u5728 Customers
\u8868\u4e2d\u7684\u67d0\u4e2a\u5ba2\u6237\u88ab\u5220\u9664\uff0c\u540c\u65f6\u4e5f\u5e0c\u671b\u5220\u9664\u5173\u8054\u7684\u8ba2\u5355\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528 ON DELETE CASCADE
\u3002
CREATE TABLE Customers (\nid INT PRIMARY KEY,\nname VARCHAR(50)\n);\n\nCREATE TABLE Orders (\nid INT PRIMARY KEY,\norder_number VARCHAR(10),\ncustomer_id INT,\nFOREIGN KEY (customer_id) REFERENCES Customers(id) ON DELETE CASCADE\n);\n
\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5f53 Customers
\u8868\u4e2d\u7684\u67d0\u4e2a\u5ba2\u6237\u88ab\u5220\u9664\u65f6\uff0c\u5173\u8054\u7684\u8ba2\u5355\u6570\u636e\u4e5f\u4f1a\u88ab\u7ea7\u8054\u5220\u9664\uff0c\u4ee5\u7ef4\u62a4\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002\u540c\u6837\u7684\uff0cON UPDATE
\u53c2\u6570\u4e5f\u53ef\u4ee5\u7528\u7c7b\u4f3c\u7684\u65b9\u5f0f\u6765\u5904\u7406\u66f4\u65b0\u64cd\u4f5c\u3002
\u6709\u5173\u6570\u636e\u5b8c\u6574\u6027\u7ea6\u675f\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u6570\u636e\u5b8c\u6574\u6027\u7ea6\u675f\u6982\u8ff0\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#cluster-by","title":"Cluster by","text":"Cluster by
\u662f\u4e00\u79cd\u7528\u4e8e\u4f18\u5316\u8868\u7684\u7269\u7406\u6392\u5217\u65b9\u5f0f\u7684\u547d\u4ee4\u3002\u5728\u5efa\u8868\u65f6\u4f7f\u7528 Cluster by
\u547d\u4ee4\uff0c\u5bf9\u4e8e\u65e0\u4e3b\u952e\u7684\u8868\uff0c\u53ef\u4ee5\u6309\u7167\u6307\u5b9a\u7684\u5217\u5bf9\u8868\u8fdb\u884c\u7269\u7406\u6392\u5e8f\uff0c\u5e76\u5c06\u6570\u636e\u884c\u91cd\u65b0\u6392\u5217\u6210\u4e0e\u8be5\u5217\u7684\u503c\u7684\u987a\u5e8f\u76f8\u540c\u7684\u987a\u5e8f\u3002\u4f7f\u7528 Cluster by
\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002
create table() cluster by col;
create table() cluster by (col1, col2);
Note: Cluster by
\u4e0d\u80fd\u548c\u4e3b\u952e\u540c\u65f6\u5b58\u5728\uff0c\u5426\u5219\u4f1a\u8bed\u6cd5\u62a5\u9519\uff1bCluster by
\u53ea\u80fd\u5728\u5efa\u8868\u65f6\u6307\u5b9a\uff0c\u4e0d\u652f\u6301\u52a8\u6001\u521b\u5efa\u3002
\u66f4\u591a\u5173\u4e8e\u4f7f\u7528 Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff0c\u53c2\u89c1\u4f7f\u7528 Cluster by \u8bed\u53e5\u8c03\u4f18.
partition_options:\n PARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)\n [PARTITIONS num]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n [VALUES\n {LESS THAN {(expr | value_list) | MAXVALUE}\n |\n IN (value_list)}]\n [COMMENT [=] 'string' ]\n
\u5206\u533a\u53ef\u4ee5\u88ab\u4fee\u6539\u3001\u5408\u5e76\u3001\u6dfb\u52a0\u5230\u8868\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u4ece\u8868\u4e2d\u5220\u9664\u3002
\u00b7 \u548c\u5355\u4e2a\u78c1\u76d8\u6216\u6587\u4ef6\u7cfb\u7edf\u5206\u533a\u76f8\u6bd4\uff0c\u53ef\u4ee5\u5b58\u50a8\u66f4\u591a\u7684\u6570\u636e\u3002
\u00b7 \u4f18\u5316\u67e5\u8be2\u3002
\u00b7 \u5bf9\u4e8e\u5df2\u7ecf\u8fc7\u671f\u6216\u8005\u4e0d\u9700\u8981\u4fdd\u5b58\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5220\u9664\u4e0e\u8fd9\u4e9b\u6570\u636e\u6709\u5173\u7684\u5206\u533a\u6765\u5feb\u901f\u5220\u9664\u6570\u636e\u3002
\u00b7 \u8de8\u591a\u4e2a\u78c1\u76d8\u6765\u5206\u6563\u6570\u636e\u67e5\u8be2\uff0c\u4ee5\u83b7\u5f97\u66f4\u5927\u7684\u67e5\u8be2\u541e\u5410\u91cf\u3002
\u5206\u533a\u8bed\u6cd5\u4ee5 PARTITION BY
\u5f00\u5934\u3002\u8be5\u5b50\u53e5\u5305\u542b\u7528\u4e8e\u786e\u5b9a\u5206\u533a\u7684\u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u4ece 1 \u5230 num \u7684\u6574\u6570\u503c\uff0c\u5176\u4e2d num \u662f\u5206\u533a\u7684\u6570\u76ee\u3002
\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u50cf\u4f1a\u5458\u8868\u8fd9\u79cd\u6ca1\u6709\u660e\u663e\u53ef\u4ee5\u5206\u533a\u7684\u7279\u5f81\u5b57\u6bb5\u7684\u5927\u8868\u3002\u4e3a\u4e86\u628a\u8fd9\u7c7b\u7684\u6570\u636e\u8fdb\u884c\u5206\u533a\u6253\u6563\uff0cMatrixOne \u63d0\u4f9b\u4e86 HASH
\u5206\u533a\u3002\u57fa\u4e8e\u7ed9\u5b9a\u7684\u5206\u533a\u4e2a\u6570\uff0c\u5c06\u6570\u636e\u5206\u914d\u5230\u4e0d\u540c\u7684\u5206\u533a\uff0cHASH
\u5206\u533a\u53ea\u80fd\u9488\u5bf9\u6574\u6570\u8fdb\u884c HASH
\uff0c\u5bf9\u4e8e\u975e\u6574\u5f62\u7684\u5b57\u6bb5\u5219\u901a\u8fc7\u8868\u8fbe\u5f0f\u5c06\u5176\u8f6c\u6362\u6210\u6574\u6570\u3002
\u00b7 HASH \u5206\u533a\uff0c\u57fa\u4e8e\u7ed9\u5b9a\u7684\u5206\u533a\u4e2a\u6570\uff0c\u628a\u6570\u636e\u5206\u914d\u5230\u4e0d\u540c\u7684\u5206\u533a\u3002
\u00b7 Expr \u662f\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u5217\u7684\u8868\u8fbe\u5f0f\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE t1 (col1 INT, col2 CHAR(5))\n PARTITION BY HASH(col1);\n\nCREATE TABLE t1 (col1 INT, col2 CHAR(5), col3 DATETIME)\n PARTITION BY HASH ( YEAR(col3) );\n
\u00b7 KEY \u5206\u533a\uff0c\u6309\u7167\u67d0\u4e2a\u5b57\u6bb5\u53d6\u4f59\u3002\u5206\u533a\u5bf9\u8c61\u5fc5\u987b\u4e3a\u5217\uff0c\u4e0d\u80fd\u662f\u57fa\u4e8e\u5217\u7684\u8868\u8fbe\u5f0f\uff0c\u4e14\u5141\u8bb8\u591a\u5217\u3002KEY \u5206\u533a\u5217\u53ef\u4ee5\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u4e3a\u4e3b\u952e\u5217\u6216\u8005\u552f\u4e00\u952e\u5217\uff0c\u65e0\u4e3b\u952e\u548c\u552f\u4e00\u952e\u7684\u60c5\u51b5\u4e0b\uff0c\u5219\u5fc5\u987b\u663e\u6027\u6307\u5b9a\u5217\u3002
\u7c7b\u4f3c\u4e8e HASH
\u3002column_list
\u53c2\u6570\u53ea\u662f\u4e00\u4e2a\u5305\u542b 1 \u4e2a\u6216\u591a\u4e2a\u8868\u5217\u7684\u5217\u8868\uff08\u6700\u5927\u503c\uff1a16\uff09\u3002\u4e0b\u9762\u7684\u793a\u4f8b\u4e3a\u4e00\u4e2a\u6309 KEY
\u5206\u533a\u7684\u7b80\u5355\u8868\uff0c\u6709 4 \u4e2a\u5206\u533a\uff1a
CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n PARTITION BY KEY(col3)\n PARTITIONS 4;\n
\u5bf9\u4e8e\u6309 KEY
\u5206\u533a\u7684\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528 LINEAR KEY
\u6765\u8fdb\u884c\u7ebf\u6027\u5206\u533a\u3002\u8fd9\u4e0e\u4f7f\u7528 HASH
\u5206\u533a\u7684\u8868\u5177\u6709\u76f8\u540c\u7684\u6548\u679c\u3002\u4e0b\u9762\u7684\u793a\u4f8b\u4e3a\u4f7f\u7528 LINEAR KEY
\u7ebf\u6027\u5206\u533a\u5728 5 \u4e2a\u5206\u533a\u4e4b\u95f4\u5206\u914d\u6570\u636e\uff1a
CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n PARTITION BY LINEAR KEY(col3)\n PARTITIONS 5;\n
RANGE
\u5206\u533a\uff1a\u57fa\u4e8e\u4e00\u4e2a\u7ed9\u5b9a\u8fde\u7eed\u533a\u95f4\u8303\u56f4\uff0c\u628a\u6570\u636e\uff08\u6216\u8005\u53ef\u4ee5\u8bf4\u662f\u591a\u884c\uff09\u5206\u914d\u5230\u4e0d\u540c\u7684\u5206\u533a\u3002\u6700\u5e38\u89c1\u7684\u662f\u57fa\u4e8e\u65f6\u95f4\u5b57\u6bb5\u3002\u57fa\u4e8e\u5206\u533a\u7684\u5217\u6700\u597d\u662f\u6574\u578b\uff0c\u5982\u679c\u65e5\u671f\u578b\u7684\u53ef\u4ee5\u4f7f\u7528\u51fd\u6570\u8f6c\u6362\u4e3a\u6574\u578b\u3002
\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cexpr \u4f7f\u7528\u4e00\u7ec4 VALUES LESS THAN
\u8fd0\u7b97\u7b26\u663e\u793a\u4e00\u7cfb\u5217\u503c\u3002\u4f7f\u7528\u8303\u56f4\u5206\u533a\u65f6\uff0c\u4f60\u5fc5\u987b\u4f7f\u7528 VALUES LESS THAN
\u5b9a\u4e49\u81f3\u5c11\u4e00\u4e2a\u5206\u533a\uff0c\u4e14\u4e0d\u80fd\u5c06 VALUES IN
\u4e0e\u8303\u56f4\u5206\u533a\u4e00\u8d77\u4f7f\u7528\u3002
VALUES LESS THAN MAXVALUE
\u7528\u4e8e\u6307\u5b9a\u5c0f\u4e8e\u6307\u5b9a\u6700\u5927\u503c\u7684\u201c\u5269\u4f59\u201d\u503c\u3002
\u5b50\u53e5\u6392\u5217\u65b9\u5f0f\u4e3a\uff1a\u6bcf\u4e2a\u8fde\u7eed\u7684 VALUES LESS THAN
\u4e2d\u6307\u5b9a\u7684\u4e0a\u9650\u5927\u4e8e\u524d\u4e00\u4e2a\u7684\u4e0a\u9650\uff0c\u5f15\u7528 MAXVALUE
\u7684\u90a3\u4e2a\u5728\u5217\u8868\u4e2d\u6392\u5728\u6700\u540e\u3002
RANGE COLUMNS(column_list)
\u4e3a RANGE
\u7684\u53e6\u4e00\u79cd\u5f62\u5f0f\uff0c\u5e38\u7528\u4f5c\u4e3a\u4f7f\u7528\u591a\u4e2a\u5217\u4e0a\u7684\u8303\u56f4\u6761\u4ef6\uff08\u5373\uff0c\u8bf8\u5982 WHERE a = 1 AND b < 10 \u6216 WHERE a = 1 AND b = 10 AND c < 10
\uff09\u4e4b\u7c7b\u7684\u6761\u4ef6\u5bf9\u67e5\u8be2\u8fdb\u884c\u5206\u533a\u4fee\u526a\u3002\u5b83\u4f7f\u4f60\u80fd\u591f\u901a\u8fc7\u4f7f\u7528 COLUMNS
\u5b50\u53e5\u4e2d\u7684\u5217\u5217\u8868\u548c\u6bcf\u4e2a PARTITION ... VALUES LESS THAN (value_list)
\u5206\u533a\u5b9a\u4e49\u5b50\u53e5\u4e2d\u7684\u4e00\u7ec4\u5217\u503c\u6765\u6307\u5b9a\u591a\u4e2a\u5217\u4e2d\u7684\u503c\u8303\u56f4\u3002\uff08\u5728\u6700\u7b80\u5355\u7684\u60c5\u51b5\u4e0b\uff0c\u8be5\u96c6\u5408\u7531\u5355\u4e2a\u5217\u7ec4\u6210\u3002\uff09column_list
\u548c value_list
\u4e2d\u53ef\u4ee5\u5f15\u7528\u7684\u6700\u5927\u5217\u6570\u4e3a 16\u3002
column_list
\u4f7f\u7528\uff1a
column_list
\u53ef\u4ee5\u53ea\u5305\u542b\u5217\u540d\u3002BLOB
\u3001TEXT
\u3001SET
\u3001ENUM
\u3001BIT
\u6216\u7a7a\u95f4\u6570\u636e\u7c7b\u578b\u7684\u5217\uff1b\u4e5f\u4e0d\u5141\u8bb8\u4f7f\u7528\u6d6e\u70b9\u6570\u7c7b\u578b\u7684\u5217\u3002\u4e5f\u4e0d\u53ef\u4ee5\u5728 COLUMNS
\u5b50\u53e5\u4e2d\u4f7f\u7528\u51fd\u6570\u6216\u7b97\u672f\u8868\u8fbe\u5f0f\u3002\u5206\u533a\u5b9a\u4e49\u8bf4\u660e\uff1a
VALUES LESS THAN
\u5b50\u53e5\u7684\u503c\u5217\u8868\u5fc5\u987b\u5305\u542b\u4e0e COLUMNS
\u5b50\u53e5\u4e2d\u5217\u51fa\u7684\u5217\u76f8\u540c\u6570\u91cf\u7684\u503c\u3002NULL
\u4e0d\u80fd\u51fa\u73b0\u5728 VALUES LESS THAN
\u4e2d\u7684\u4efb\u4f55\u503c\u3002\u53ef\u4ee5\u5bf9\u9664\u7b2c\u4e00\u5217\u4ee5\u5916\u7684\u7ed9\u5b9a\u5217\u591a\u6b21\u4f7f\u7528 MAXVALUE
\uff0c\u5982\u4e0b\u4f8b\u6240\u793a\uff1aCREATE TABLE rc (\n a INT NOT NULL,\n b INT NOT NULL\n)\nPARTITION BY RANGE COLUMNS(a,b) (\n PARTITION p0 VALUES LESS THAN (10,5),\n PARTITION p1 VALUES LESS THAN (20,10),\n PARTITION p2 VALUES LESS THAN (50,MAXVALUE),\n PARTITION p3 VALUES LESS THAN (65,MAXVALUE),\n PARTITION p4 VALUES LESS THAN (MAXVALUE,MAXVALUE)\n);\n
LIST
\u5206\u533a\u548c RANGE
\u5206\u533a\u7c7b\u4f3c\uff0c\u533a\u522b\u5728\u4e8e LIST
\u662f\u679a\u4e3e\u503c\u5217\u8868\u7684\u96c6\u5408\uff0cRANGE
\u662f\u8fde\u7eed\u7684\u533a\u95f4\u503c\u7684\u96c6\u5408\u3002\u4e8c\u8005\u5728\u8bed\u6cd5\u65b9\u9762\u975e\u5e38\u7684\u76f8\u4f3c\u3002
\u5206\u533a\u4f7f\u7528\uff1a
LIST
\u5206\u533a\u5217\u662f\u975e null \u5217\uff0c\u5426\u5219\u63d2\u5165 null \u503c\u5982\u679c\u679a\u4e3e\u5217\u8868\u91cc\u9762\u4e0d\u5b58\u5728 null \u503c\u4f1a\u63d2\u5165\u5931\u8d25\uff0c\u8fd9\u70b9\u548c\u5176\u5b83\u7684\u5206\u533a\u4e0d\u4e00\u6837\uff0cRANGE
\u5206\u533a\u4f1a\u5c06\u5176\u4f5c\u4e3a\u6700\u5c0f\u5206\u533a\u503c\u5b58\u50a8\uff0cHASH
\u6216 KEY
\u5206\u4e3a\u4f1a\u5c06\u5176\u8f6c\u6362\u6210 0 \u5b58\u50a8\uff0c\u56e0\u4e3a LIST
\u5206\u533a\u53ea\u652f\u6301\u6574\u578b\uff0c\u975e\u6574\u578b\u5b57\u6bb5\u9700\u8981\u901a\u8fc7\u51fd\u6570\u8f6c\u6362\u6210\u6574\u5f62\u3002LIST
\u5206\u533a\u65f6\uff0c\u4f60\u5fc5\u987b\u4f7f\u7528 VALUES IN
\u5b9a\u4e49\u81f3\u5c11\u4e00\u4e2a\u5206\u533a\uff0c\u4e14\u4e0d\u80fd\u5c06 VALUES LESS THAN
\u4e0e PARTITION BY LIST
\u4e00\u8d77\u4f7f\u7528\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE client_firms (\n id INT,\n name VARCHAR(35)\n)\nPARTITION BY LIST (id) (\n PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21),\n PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22),\n PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23),\n PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24)\n);\n
LIST COLUMNS(column_list)
\u662f LIST
\u7684\u53e6\u4e00\u79cd\u4e66\u5199\u5f62\u5f0f\uff0c\u7528\u4e8e\u591a\u5217\u4e0a\u7684\u6bd4\u8f83\u6761\u4ef6\uff08\u5373\uff0c\u5177\u6709\u8bf8\u5982 WHERE a = 5 AND b = 5 \u6216 WHERE a = 1 AND b = 10 AND c = 5
\u4e4b\u7c7b\u7684\u6761\u4ef6\uff09\u5bf9\u67e5\u8be2\u8fdb\u884c\u5206\u533a\u4fee\u526a\u3002\u901a\u8fc7\u4f7f\u7528 COLUMNS
\u5b50\u53e5\u4e2d\u7684\u5217\u5217\u8868\u548c\u6bcf\u4e2a PARTITION ... VALUES IN
(value_list) \u5206\u533a\u5b9a\u4e49\u5b50\u53e5\u4e2d\u7684\u4e00\u7ec4\u5217\u503c\u6765\u6307\u5b9a\u591a\u4e2a\u5217\u4e2d\u7684\u503c\u3002
LIST COLUMNS(column_list)
\u4e2d\u4f7f\u7528\u7684\u5217\u5217\u8868\u548c VALUES IN(value_list)
\u4e2d\u4f7f\u7528\u7684\u503c\u5217\u8868\u7684\u6570\u636e\u7c7b\u578b\u89c4\u5219\u4e0e RANGE COLUMNS(column_list)
\u4e2d\u4f7f\u7528\u7684\u5217\u5217\u8868\u7684\u89c4\u5219 VALUES LESS THAN(value_list)
\u4e2d\u4f7f\u7528\u7684\u503c\u5217\u8868\u89c4\u5219\u76f8\u540c\uff0c\u4f46\u5728 VALUES IN
\u5b50\u53e5\u4e2d\uff0c\u4e0d\u5141\u8bb8\u4f7f\u7528 MAXVALUE
\uff0c\u53ef\u4ee5\u4f7f\u7528 NULL
\u3002
\u4e0e PARTITION BY LIST COLUMNS
\u4e00\u8d77\u4f7f\u7528\u7684 VALUES IN
\u503c\u5217\u8868\u4e0e\u4e0e PARTITION BY LIST
\u4e00\u8d77\u4f7f\u7528\u65f6\u7684\u503c\u5217\u8868\u6709\u4e00\u4e2a\u91cd\u8981\u533a\u522b\u3002\u5f53\u4e0e PARTITION BY LIST COLUMNS
\u4e00\u8d77\u4f7f\u7528\u65f6\uff0cVALUES IN
\u5b50\u53e5\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u5fc5\u987b\u662f\u4e00\u7ec4\u5217\u503c\uff1b\u6bcf\u4e2a\u96c6\u5408\u4e2d\u7684\u503c\u7684\u6570\u91cf\u5fc5\u987b\u4e0e COLUMNS
\u5b50\u53e5\u4e2d\u4f7f\u7528\u7684\u5217\u6570\u76f8\u540c\uff0c\u5e76\u4e14\u8fd9\u4e9b\u503c\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u4e0e\u5217\u7684\u6570\u636e\u7c7b\u578b\u5339\u914d\uff08\u5e76\u4e14\u4ee5\u76f8\u540c\u7684\u987a\u5e8f\u51fa\u73b0\uff09\u3002\u5728\u6700\u7b80\u5355\u7684\u60c5\u51b5\u4e0b\uff0c\u8be5\u96c6\u5408\u7531\u4e00\u5217\u7ec4\u6210\u3002\u5728 column_list
\u548c\u7ec4\u6210 value_list
\u7684\u5143\u7d20\u4e2d\u53ef\u4ee5\u4f7f\u7528\u7684\u6700\u5927\u5217\u6570\u662f 16\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE lc (\n a INT NULL,\n b INT NULL\n)\nPARTITION BY LIST COLUMNS(a,b) (\n PARTITION p0 VALUES IN( (0,0), (NULL,NULL) ),\n PARTITION p1 VALUES IN( (0,1), (0,2), (0,3), (1,1), (1,2) ),\n PARTITION p2 VALUES IN( (1,0), (2,0), (2,1), (3,0), (3,1) ),\n PARTITION p3 VALUES IN( (1,3), (2,2), (2,3), (3,2), (3,3) )\n);\n
\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 PARTITIONS num
\u5b50\u53e5\u6307\u5b9a\u5206\u533a\u6570\uff0c\u5176\u4e2d num
\u662f\u5206\u533a\u6570\u3002\u5982\u679c\u4f7f\u7528\u6b64\u5b50\u53e5\u7684\u540c\u65f6\uff0c\u4e5f\u4f7f\u7528\u4e86\u5176\u4ed6 PARTITION
\u5b50\u53e5\uff0c\u90a3\u4e48 num
\u5fc5\u987b\u7b49\u4e8e\u4f7f\u7528 PARTITION
\u5b50\u53e5\u58f0\u660e\u7684\u5206\u533a\u7684\u603b\u6570\u3002
CREATE TABLE test(a int, b varchar(10));\nINSERT INTO test values(123, 'abc');\n\nmysql> SELECT * FROM test;\n+------+---------+\n| a | b |\n+------+---------+\n| 123 | abc |\n+------+---------+\n
create table t2 (a int, b int) comment = \"\u4e8b\u5b9e\u8868\";\n\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------+\n| t2 | CREATE TABLE `t2` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL\n) COMMENT='\u4e8b\u5b9e\u8868', |\n+-------+---------------------------------------------------------------------------------------+\n
create table t3 (a int comment '\u5217\u7684\u6ce8\u91ca', b int) comment = \"table\";\n\nmysql> SHOW CREATE TABLE t3;\n+-------+----------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------+\n| t3 | CREATE TABLE `t3` (\n`a` INT DEFAULT NULL COMMENT '\u5217\u7684\u6ce8\u91ca',\n`b` INT DEFAULT NULL\n) COMMENT='table', |\n+-------+----------------------------------------------------------------------------------------------------------+\n
CREATE TABLE tp1 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp1;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp1 | CREATE TABLE `tp1` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u4e0d\u6307\u5b9a\u5206\u533a\u6570\nCREATE TABLE tp2 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3);\n\nmysql> SHOW CREATE TABLE tp2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp2 | CREATE TABLE `tp2` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u6307\u5b9a\u5206\u533a\u7b97\u6cd5\nCREATE TABLE tp3\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY ALGORITHM = 1 (col3);\n\n\nmysql> show create table tp3;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp3 | CREATE TABLE `tp3` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 1 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u6307\u5b9a\u5206\u533a\u7b97\u6cd5\u53ca\u5206\u533a\u6570\nCREATE TABLE tp4 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY LINEAR KEY ALGORITHM = 1 (col3) PARTITIONS 5;\n\nmysql> SHOW CREATE TABLE tp4;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp4 | CREATE TABLE `tp4` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear key algorithm = 1 (col3) partitions 5 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u591a\u5217\u5206\u533a\nCREATE TABLE tp5\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY(col1, col2) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp5;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp5 | CREATE TABLE `tp5` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col1, col2) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa\u4e3b\u952e\u5217\u5206\u533a\nCREATE TABLE tp6\n(\ncol1 INT NOT NULL PRIMARY KEY,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL\n) PARTITION BY KEY(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp6;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp6 | CREATE TABLE `tp6` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by key algorithm = 2 (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa HASH \u5206\u533a\nCREATE TABLE tp7\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1);\n\nmysql> SHOW CREATE TABLE tp7;\n+-------+------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------+\n| tp7 | CREATE TABLE `tp7` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) |\n+-------+------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa HASH \u5206\u533a\u65f6\u6307\u5b9a\u5206\u533a\u6570\nCREATE TABLE tp8\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp8;\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| tp8 | CREATE TABLE `tp8` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa\u5206\u533a\u65f6\uff0c\u6307\u5b9a\u5206\u533a\u7c92\u5ea6\nCREATE TABLE tp9\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATETIME\n) PARTITION BY HASH (YEAR(col3));\n\nmysql> SHOW CREATE TABLE tp9;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| tp9 | CREATE TABLE `tp9` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATETIME DEFAULT NULL\n) partition by hash (year(col3)) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa\u5206\u533a\u65f6\uff0c\u6307\u5b9a\u5206\u533a\u7c92\u5ea6\u548c\u5206\u533a\u6570\u91cf\nCREATE TABLE tp10\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY LINEAR HASH( YEAR(col3)) PARTITIONS 6;\n\nmysql> SHOW CREATE TABLE tp10;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp10 | CREATE TABLE `tp10` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear hash (year(col3)) partitions 6 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa\u5206\u533a\u65f6\uff0c\u4f7f\u7528\u4e3b\u952e\u5217\u4f5c\u4e3a HASH \u5206\u533a\nCREATE TABLE tp12 (col1 INT NOT NULL PRIMARY KEY, col2 DATE NOT NULL, col3 INT NOT NULL, col4 INT NOT NULL) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp12;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp12 | CREATE TABLE `tp12` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa RANGE \u5206\u533a\uff0c\u5e76\u5212\u5206\u5206\u533a\u8303\u56f4\nCREATE TABLE tp13 (id INT NOT NULL PRIMARY KEY, fname VARCHAR(30), lname VARCHAR(30), hired DATE NOT NULL DEFAULT '1970-01-01', separated DATE NOT NULL DEFAULT '9999-12-31', job_code INT NOT NULL, store_id INT NOT NULL) PARTITION BY RANGE (id) (PARTITION p0 VALUES LESS THAN (6), PARTITION p1 VALUES LESS THAN (11), PARTITION p2 VALUES LESS THAN (16), PARTITION p3 VALUES LESS THAN (21));\n\nmysql> SHOW CREATE TABLE tp13;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp13 | CREATE TABLE `tp13` (\n`id` INT NOT NULL,\n`fname` VARCHAR(30) DEFAULT NULL,\n`lname` VARCHAR(30) DEFAULT NULL,\n`hired` DATE DEFAULT '1970-01-01',\n`separated` DATE DEFAULT '9999-12-31',\n`job_code` INT NOT NULL,\n`store_id` INT NOT NULL,\nPRIMARY KEY (`id`)\n) partition by range(id) (partition p0 values less than (6), partition p1 values less than (11), partition p2 values less than (16), partition p3 values less than (21)) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nCREATE TABLE tp14 (id INT NOT NULL, fname VARCHAR(30), lname VARCHAR(30), hired DATE NOT NULL DEFAULT '1970-01-01', separated DATE NOT NULL DEFAULT '9999-12-31', job_code INT, store_id INT) PARTITION BY RANGE ( YEAR(separated) ) ( PARTITION p0 VALUES LESS THAN (1991), PARTITION p1 VALUES LESS THAN (1996), PARTITION p2 VALUES LESS THAN (2001), PARTITION p3 VALUES LESS THAN MAXVALUE);\n\nmysql> SHOW CREATE TABLE tp14;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp14 | CREATE TABLE `tp14` (\n`id` INT NOT NULL,\n`fname` VARCHAR(30) DEFAULT NULL,\n`lname` VARCHAR(30) DEFAULT NULL,\n`hired` DATE DEFAULT '1970-01-01',\n`separated` DATE DEFAULT '9999-12-31',\n`job_code` INT DEFAULT NULL,\n`store_id` INT DEFAULT NULL\n) partition by range(year(separated)) (partition p0 values less than (1991), partition p1 values less than (1996), partition p2 values less than (2001), partition p3 values less than (MAXVALUE)) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u4f7f\u7528\u591a\u5217\u4f5c\u4e3a RANGE \u5206\u533a\uff0c\u5e76\u6307\u5b9a\u5206\u533a\u8303\u56f4\nCREATE TABLE tp15 (a INT NOT NULL, b INT NOT NULL) PARTITION BY RANGE COLUMNS(a,b) PARTITIONS 4 (PARTITION p0 VALUES LESS THAN (10,5), PARTITION p1 VALUES LESS THAN (20,10), PARTITION p2 VALUES LESS THAN (50,20), PARTITION p3 VALUES LESS THAN (65,30));\n\nmysql> SHOW CREATE TABLE tp15;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp15 | CREATE TABLE `tp15` (\n`a` INT NOT NULL,\n`b` INT NOT NULL\n) partition by range columns (a, b) partitions 4 (partition p0 values less than (10, 5), partition p1 values less than (20, 10), partition p2 values less than (50, 20), partition p3 values less than (65, 30)) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa LIST \u5206\u533a\nCREATE TABLE tp16 (id INT PRIMARY KEY, name VARCHAR(35), age INT unsigned) PARTITION BY LIST (id) (PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21), PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22), PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23), PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24));\n\nmysql> SHOW CREATE TABLE tp16;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp16 | CREATE TABLE `tp16` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(35) DEFAULT NULL,\n`age` INT UNSIGNED DEFAULT NULL,\nPRIMARY KEY (`id`)\n) partition by list(id) (partition r0 values in (1, 5, 9, 13, 17, 21), partition r1 values in (2, 6, 10, 14, 18, 22), partition r2 values in (3, 7, 11, 15, 19, 23), partition r3 values in (4, 8, 12, 16, 20, 24)) |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nCREATE TABLE tp17 (id INT, name VARCHAR(35), age INT unsigned) PARTITION BY LIST (id) (PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21), PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22), PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23), PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24));\n\nmysql> SHOW CREATE TABLE tp17;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp17 | CREATE TABLE `tp17` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(35) DEFAULT NULL,\n`age` INT UNSIGNED DEFAULT NULL\n) partition by list(id) (partition r0 values in (1, 5, 9, 13, 17, 21), partition r1 values in (2, 6, 10, 14, 18, 22), partition r2 values in (3, 7, 11, 15, 19, 23), partition r3 values in (4, 8, 12, 16, 20, 24)) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u4f7f\u7528\u591a\u5217\u4f5c\u4e3a LIST \u5206\u533a\nCREATE TABLE tp18 (a INT NULL,b INT NULL) PARTITION BY LIST COLUMNS(a,b) (PARTITION p0 VALUES IN( (0,0), (NULL,NULL) ), PARTITION p1 VALUES IN( (0,1), (0,2), (0,3), (1,1), (1,2) ), PARTITION p2 VALUES IN( (1,0), (2,0), (2,1), (3,0), (3,1) ), PARTITION p3 VALUES IN( (1,3), (2,2), (2,3), (3,2), (3,3) ));\n\nmysql> SHOW CREATE TABLE tp18;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp18 | CREATE TABLE `tp18` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL\n) partition by list columns (a, b) (partition p0 values in ((0, 0), (null, null)), partition p1 values in ((0, 1), (0, 2), (0, 3), (1, 1), (1, 2)), partition p2 values in ((1, 0), (2, 0), (2, 1), (3, 0), (3, 1)), partition p3 values in ((1, 3), (2, 2), (2, 3), (3, 2), (3, 3))) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a bigint primary key auto_increment, b varchar(10));\ninsert into t1(b) values ('bbb');\ninsert into t1 values (3, 'ccc');\ninsert into t1(b) values ('bbb1111');\n\nmysql> select * from t1 order by a;\n+------+---------+\n| a | b |\n+------+---------+\n| 1 | bbb |\n| 3 | ccc |\n| 4 | bbb1111 |\n+------+---------+\n3 rows in set (0.01 sec)\n\ninsert into t1 values (2, 'aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a | b |\n+------+----------+\n| 1 | bbb |\n| 2 | aaaa1111 |\n| 3 | ccc |\n| 4 | bbb1111 |\n+------+----------+\n4 rows in set (0.00 sec)\n\ninsert into t1(b) values ('aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a | b |\n+------+----------+\n| 1 | bbb |\n| 2 | aaaa1111 |\n| 3 | ccc |\n| 4 | bbb1111 |\n| 5 | aaaa1111 |\n+------+----------+\n5 rows in set (0.01 sec)\n\ninsert into t1 values (100, 'xxxx');\ninsert into t1(b) values ('xxxx');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a | b |\n+------+----------+\n| 1 | bbb |\n| 2 | aaaa1111 |\n| 3 | ccc |\n| 4 | bbb1111 |\n| 5 | aaaa1111 |\n| 100 | xxxx |\n| 101 | xxxx |\n+------+----------+\n7 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#_5","title":"\u9650\u5236","text":"ALTER TABLE table_name DROP PRIMARY KEY
\u8bed\u53e5\u5220\u9664\u8868\u4e2d\u7684\u4e3b\u952e\u3002ALTER TABLE table_name AUTO_INCREMENT = n;
\u8bed\u53e5\u4fee\u6539\u81ea\u589e\u5217\u521d\u59cb\u503c\u3002set @@auto_increment_increment=n
\u6765\u8bbe\u7f6e\u9012\u589e\u6b65\u957f\uff0c\u4e5f\u4ec5\u8bed\u6cd5\u652f\u6301\u4f7f\u7528\u7cfb\u7edf\u53d8\u91cf set @@auto_increment_offset=n
\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u81ea\u589e\u5217\u521d\u59cb\u503c\uff0c\u4f46\u5b9e\u9645\u4e0a\u5e76\u4e0d\u751f\u6548\uff1b\u5f53\u524d\u652f\u6301\u8bbe\u7f6e\u81ea\u589e\u5217\u7684\u521d\u59cb\u503c AUTO_INCREMENT=n
\uff0c\u4f46\u6b65\u957f\u4ecd\u7136\u9ed8\u8ba4\u4e3a 1\u3002\u89c6\u56fe\u662f\u57fa\u4e8e SQL \u8bed\u53e5\u7684\u7ed3\u679c\u96c6\u7684\u53ef\u89c6\u5316\u7684\u8868\u3002
\u89c6\u56fe\u5305\u542b\u884c\u548c\u5217\uff0c\u5c31\u50cf\u4e00\u4e2a\u771f\u5b9e\u7684\u8868\u3002\u89c6\u56fe\u4e2d\u7684\u5b57\u6bb5\u5c31\u662f\u6765\u81ea\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5e93\u4e2d\u7684\u771f\u5b9e\u7684\u8868\u4e2d\u7684\u5b57\u6bb5\u3002
\u60a8\u53ef\u4ee5\u5411\u89c6\u56fe\u6dfb\u52a0 SQL \u51fd\u6570\uff0cWHERE
\u6216\u8005 JOIN
\u8bed\u53e5\uff0c\u4e5f\u540c\u6837\u53ef\u4ee5\u5448\u73b0\u6570\u636e\uff0c\u7c7b\u4f3c\u4e8e\u8fd9\u4e9b\u6570\u636e\u6765\u81ea\u4e8e\u67d0\u4e2a\u5355\u4e00\u7684\u8868\u4e00\u6837\u3002
CREATE VIEW
\u8bed\u53e5\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u89c6\u56fe\u3002
> CREATE [ OR REPLACE ] VIEW view_name AS\n SELECT column1, column2, ...\n FROM table_name\n WHERE condition;\n
Note
\u89c6\u56fe\u603b\u662f\u663e\u793a\u6700\u65b0\u7684\u6570\u636e\u3002\u6bcf\u5f53\u4f60\u67e5\u8be2\u89c6\u56fe\u65f6\uff0c\u6570\u636e\u5e93\u5f15\u64ce\u901a\u8fc7\u4f7f\u7528\u89c6\u56fe\u7684 SQL \u8bed\u53e5\u91cd\u5efa\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\nCREATE OR REPLACE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n\nmysql> SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n| 2 | NULL |\n+------+------+\n2 rows in set (0.01 sec)\n\nmysql> SELECT * FROM v0 WHERE b >= 0;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> SHOW CREATE VIEW v0;\n+------+---------------------------------------------------------------------------------------+\n| View | Create View |\n+------+---------------------------------------------------------------------------------------+\n| v0 | CREATE OR REPLACE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+---------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\ndrop table if exists t2;\ncreate table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\nmysql> select * from (select * from t1) sub where id > 4;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n\ncreate view v1 as select * from (select * from t1) sub where id > 4;\ncreate view v2 as select ti as t,fl as f from (select * from t1) sub where dl <> 4;\ncreate view v3 as select * from (select ti as t,fl as f from t1 where dl <> 4) sub;\ncreate view v4 as select id,min(ti) from (select * from t1) sub group by id;\ncreate view v5 as select * from (select id,min(ti) from (select * from t1) t1 group by id) sub;\n\nmysql> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select * from v2;\n+------+----------+\n| t | f |\n+------+----------+\n| 1 | 1113.32 |\n| 2 | 2252.05 |\n| 6 | 3663.21 |\n| 7 | 4715.22 |\n| 1 | 51.26 |\n| 3 | 632.1 |\n| 4 | 7443.11 |\n| 7 | 8758 |\n| 8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v3;\n+------+----------+\n| t | f |\n+------+----------+\n| 1 | 1113.32 |\n| 2 | 2252.05 |\n| 6 | 3663.21 |\n| 7 | 4715.22 |\n| 1 | 51.26 |\n| 3 | 632.1 |\n| 4 | 7443.11 |\n| 7 | 8758 |\n| 8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v4;\n+------+---------+\n| id | min(ti) |\n+------+---------+\n| 1 | 1 |\n| 2 | 2 |\n| 3 | 6 |\n| 4 | 7 |\n| 5 | 1 |\n| 6 | 3 |\n| 7 | 4 |\n| 8 | 7 |\n| 9 | 8 |\n+------+---------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v5;\n+------+---------+\n| id | min(ti) |\n+------+---------+\n| 1 | 1 |\n| 2 | 2 |\n| 3 | 6 |\n| 4 | 7 |\n| 5 | 1 |\n| 6 | 3 |\n| 7 | 4 |\n| 8 | 7 |\n| 9 | 8 |\n+------+---------+\n9 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/","title":"DROP DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8be5\u8bed\u53e5\u7528\u4e8e\u5220\u9664\u4e00\u4e2a\u6570\u636e\u5e93\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP DATABASE [IF EXISTS] <database_name>\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#_3","title":"\u793a\u4f8b","text":"CREATE DATABASE test01;\n\nmysql> DROP DATABASE test01;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function/","title":"DROP FUNCTION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP FUNCTION
\u8bed\u53e5\u8868\u793a\u5220\u9664\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\u3002
> DROP FUNCTION <name> ([<arg_data_type> ]\u2026 )\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function/#_3","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
--\u5220\u9664\u6709\u53c2\u51fd\u6570\n\ncreate or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\n\nmysql> select py_add(1,2);\n+--------------+\n| py_add(1, 2) |\n+--------------+\n| 3 |\n+--------------+\n1 row in set (0.01 sec)\n\n--\u5f53\u6211\u4eec\u4e0d\u518d\u9700\u8981\u8be5\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u5c06\u5176\u5220\u9664\ndrop function py_add(int, int);\n
\u793a\u4f8b 2
--\u5220\u9664\u65e0\u53c2\u51fd\u6570\nmysql> CREATE FUNCTION t1_fun () RETURNS VARCHAR LANGUAGE SQL AS 'select n1 from t1 limit 1' ;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> drop function t1_fun();\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/","title":"DROP INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8be5\u8bed\u53e5\u7528\u4e8e\u4ece\u5f53\u524d\u6240\u9009\u7684\u8868\u4e2d\u5220\u9664\u7d22\u5f15\uff0c\u5982\u679c\u7d22\u5f15\u4e0d\u5b58\u5728\u5219\u4f1a\u62a5\u9519\uff0c\u9664\u975e\u4f7f\u7528 IF EXISTS
\u4fee\u9970\u7b26\u3002
> DROP INDEX index_name ON tbl_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#_3","title":"\u793a\u4f8b","text":"create table t5(a int, b int, unique key(a));\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------+\n| t5 | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ncreate index b on t5(b);\nmysql> show create table t5;\n+-------+-------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------+\n| t5 | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`),\nKEY `b` (`b`)\n) |\n+-------+-------------------------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ndrop index b on t5;\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------+\n| t5 | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/","title":"DROP PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP PUBLICATION
\u5c06\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u53d1\u5e03\u5220\u9664\u3002
DROP PUBLICATION pubname;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> drop publication pub3;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show publications;\nEmpty set (0.00 sec)
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/","title":"DROP SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP SEQUENCE
\u7528\u4e8e\u5220\u9664\u5e8f\u5217\u3002\u5b83\u5141\u8bb8\u4f60\u5220\u9664\u5148\u524d\u4f7f\u7528 CREATE SEQUENCE
\u547d\u4ee4\u521b\u5efa\u7684\u5e8f\u5217\u3002
\u5220\u9664\u5e8f\u5217\u4f1a\u5c06\u5e8f\u5217\u7684\u6240\u6709\u5c5e\u6027\u548c\u503c\u90fd\u5220\u9664\u3002\u56e0\u6b64\uff0c\u5728\u5220\u9664\u5e8f\u5217\u4e4b\u524d\uff0c\u5fc5\u987b\u786e\u4fdd\u6ca1\u6709\u4efb\u4f55\u8868\u4ecd\u5728\u4f7f\u7528\u8be5\u5e8f\u5217\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP SEQUENCE [ IF EXISTS ] SEQUENCE_NAME [, ...]\n [IF EXISTS]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#_3","title":"\u793a\u4f8b","text":"-- \u5220\u9664\u4e86\u540d\u4e3a \"seq_id\" \u7684\u5e8f\u5217\nDROP SEQUENCE seq_id;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-snapshot/","title":"DROP SNAPSHOT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-snapshot/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP SNAPSHOT
\u7528\u4e8e\u5220\u9664\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u7684\u5feb\u7167\u3002
> DROP SNAPSHOT snapshot_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-snapshot/#_3","title":"\u793a\u4f8b","text":"create snapshot sp1 for account sys;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp1 | 2024-05-10 09:55:11.601605 | account | sys | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n1 row in set (0.01 sec)\n\ndrop snapshot sp1;\n\nmysql> show snapshots;\nEmpty set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/","title":"DROP STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP STAGE
\u7528\u4e8e\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664\u4e00\u4e2a\u5df2\u547d\u540d\u7684\u5185\u90e8\u6216\u5916\u90e8\u6570\u636e\u9636\u6bb5\u3002\u6570\u636e\u9636\u6bb5\u662f\u7528\u4e8e\u52a0\u8f7d\u6570\u636e\u4ece\u6587\u4ef6\u5230\u6570\u636e\u5e93\u8868\u4e2d\uff0c\u6216\u5c06\u6570\u636e\u4ece\u6570\u636e\u5e93\u8868\u5bfc\u51fa\u5230\u6587\u4ef6\u7684\u4e34\u65f6\u5b58\u50a8\u533a\u57df\u3002\u4f7f\u7528 DROP STAGE
\u547d\u4ee4\u53ef\u4ee5\u5c06\u4e0d\u518d\u9700\u8981\u7684\u6570\u636e\u9636\u6bb5\u4ece\u6570\u636e\u5e93\u4e2d\u79fb\u9664\uff0c\u4ece\u800c\u91ca\u653e\u5b58\u50a8\u7a7a\u95f4\u5e76\u907f\u514d\u4ea7\u751f\u989d\u5916\u7684\u5b58\u50a8\u8d39\u7528\u3002
Note
\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u5373 root \u7528\u6237\uff09\u548c\u79df\u6237\u7ba1\u7406\u5458\u53ef\u4ee5\u5220\u9664\u6570\u636e\u9636\u6bb5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"-- \u5220\u9664\u5185\u90e8\u9636\u6bb5\n> DROP STAGE [IF EXISTS] {internal_stage_name};\n\n-- \u5220\u9664\u5916\u90e8\u9636\u6bb5\n> DROP STAGE [IF EXISTS] {external_stage_name};\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\n-- \u5220\u9664 stage1\nmysql> drop stage stage1;\nQuery OK, 0 rows affected (0.01 sec)\n\n-- stage1 \u5df2\u7ecf\u88ab\u5220\u9664\uff0c\u6570\u636e\u9636\u6bb5\u4e0d\u53ef\u7528\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is not exists, please check\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/","title":"DROP TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8be5\u8bed\u53e5\u7528\u4e8e\u4ece\u5f53\u524d\u6240\u9009\u7684\u6570\u636e\u5e93\u4e2d\u5220\u9664\u8868\uff0c\u5982\u679c\u8868\u4e0d\u5b58\u5728\u5219\u4f1a\u62a5\u9519\uff0c\u9664\u975e\u4f7f\u7528 IF EXISTS
\u4fee\u9970\u7b26\u3002
> DROP TABLE [IF EXISTS] [db.]name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE table01(a int);\n\nmysql> DROP TABLE table01;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/","title":"DROP VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP VIEW
\u8bed\u53e5\u8868\u793a\u5220\u9664\u89c6\u56fe\u3002
\u5982\u679c\u8bed\u6cd5\u53c2\u6570\u5217\u8868\u4e2d\u547d\u540d\u7684\u4efb\u4f55\u89c6\u56fe\u90fd\u4e0d\u5b58\u5728\uff0c\u5219\u8bed\u53e5\u62a5\u9519\uff0c\u5e76\u63d0\u793a\u65e0\u6cd5\u5220\u9664\u8fd9\u4e9b\u4e0d\u5b58\u5728\u7684\u89c6\u56fe\uff0c\u5e76\u4e14\u4e0d\u505a\u4efb\u4f55\u66f4\u6539\u3002
IF EXISTS
\u5b50\u53e5\u8868\u793a\u9632\u6b62\u56e0\u4e0d\u5b58\u5728\u7684\u89c6\u56fe\u800c\u53d1\u751f\u9519\u8bef\u3002\u7ed9\u51fa\u8be5\u5b50\u53e5\u65f6\uff0c\u5c06\u4e3a\u6bcf\u4e2a\u4e0d\u5b58\u5728\u7684\u89c6\u56fe\u751f\u6210\u4e00\u4e2a NOTE
\u3002
> DROP VIEW [IF EXISTS]\n view_name [, view_name] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT);\nCREATE VIEW v1 AS SELECT * FROM t1;\n\nmysql> DROP VIEW v1;\nQuery OK, 0 rows affected (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/","title":"RESTORE ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"RESTORE ACCOUNT
\u6839\u636e\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u7684\u5feb\u7167\u5c06\u79df\u6237/\u6570\u636e\u5e93/\u8868\u6062\u590d\u5230\u67d0\u4e2a\u65f6\u95f4\u6233\u5bf9\u5e94\u7684\u72b6\u6001\u3002
> RESTORE ACCOUNT account_name [DATABASE database_name [TABLE table_name]] FROM SNAPSHOT snapshot_name [TO ACCOUNT account_name];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/#_3","title":"\u793a\u4f8b","text":"--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nCREATE database db1;\nCREATE database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.00 sec)\n\ncreate snapshot acc1_snap1 for account acc1;--\u521b\u5efa\u5feb\u7167\ndrop database db1;--\u5220\u9664\u6570\u636e\u5e93 db1,db2\ndrop database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n5 rows in set (0.01 sec)\n\nrestore account acc1 FROM snapshot acc1_snap1;--\u6062\u590d\u79df\u6237\u7ea7\u522b\u5feb\u7167\n\nmysql> show databases;--\u6062\u590d\u6210\u529f\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.01 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nCREATE database db1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.00 sec)\n\ncreate snapshot acc1_db_snap1 for account acc1;--\u521b\u5efa\u5feb\u7167\ndrop database db1;--\u5220\u9664\u6570\u636e\u5e93 db1\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\nrestore account acc1 database db1 FROM snapshot acc1_db_snap1;--\u6062\u590d\u6570\u636e\u5e93\u7ea7\u522b\u5feb\u7167\n\nmysql> show databases;--\u6062\u590d\u6210\u529f\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.00 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nCREATE TABLE t1(n1 int);\nINSERT INTO t1 values(1);\n\nmysql> SELECT * FROM t1;\n+------+\n| n1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n\ncreate snapshot acc1_tab_snap1 for account acc1;--\u521b\u5efa\u5feb\u7167\ntruncate TABLE t1;--\u6e05\u7a7a t1\n\nmysql> SELECT * FROM t1;\nEmpty set (0.01 sec)\n\nrestore account acc1 database db1 TABLE t1 FROM snapshot acc1_tab_snap1;--\u6062\u590d\u5feb\u7167\n\nmysql> SELECT * FROM t1;--\u6062\u590d\u6210\u529f\n+------+\n| n1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ncreate database db1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate snapshot acc1_snap1 for account acc1;--\u4e3a acc1 \u521b\u5efa\u5feb\u7167\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ndrop database db1;--\u5220\u9664\u6570\u636e\u5e93 db1\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\nrestore account acc1 FROM snapshot acc1_snap1 TO account acc1;--\u5728\u7cfb\u7edf\u79df\u6237\u4e0b\u5bf9 acc1 \u8fdb\u884c\u5feb\u7167\u6062\u590d\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nmysql> show databases;--\u6062\u590d\u6210\u529f\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ncreate database db1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate snapshot acc1_snap1 for account acc1;--\u4e3a acc1 \u521b\u5efa\u5feb\u7167\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ndrop database db1;--\u5220\u9664 db1\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate account acc2 ADMIN_NAME admin IDENTIFIED BY '111';--\u9700\u8981\u63d0\u524d\u521b\u5efa\u8981\u76ee\u6807\u65b0\u79df\u6237\nrestore account acc1 FROM snapshot acc1_snap1 TO account acc2;--\u5728\u7cfb\u7edf\u79df\u6237\u4e0b\u5bf9 acc1 \u8fdb\u884c\u5feb\u7167\u6062\u590d\uff0c\u6062\u590d\u81f3 acc2\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n5 rows in set (0.00 sec)\n\n--\u5728\u79df\u6237 acc2 \u4e0b\u6267\u884c\nmysql> show databases;--\u6062\u590d\u81f3 acc2\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/#_4","title":"\u9650\u5236","text":"\u76ee\u524d\u53ea\u652f\u6301\u79df\u6237/\u6570\u636e\u5e93/\u8868\u7ea7\u522b\u7684\u6062\u590d\uff0c\u6682\u4e0d\u652f\u6301\u96c6\u7fa4\u7684\u3002
\u7cfb\u7edf\u79df\u6237\u6062\u590d\u666e\u901a\u79df\u6237\u5230\u65b0\u79df\u6237\u53ea\u5141\u8bb8\u79df\u6237\u7ea7\u522b\u7684\u6062\u590d\u3002
\u53ea\u6709\u7cfb\u7edf\u79df\u6237\u624d\u53ef\u4ee5\u6267\u884c\u6062\u590d\u6570\u636e\u5230\u65b0\u79df\u6237\uff0c\u4e14\u53ea\u5141\u8bb8\u79df\u6237\u7ea7\u522b\u7684\u6062\u590d\u3002\u65b0\u79df\u6237\u9700\u63d0\u524d\u521b\u5efa\uff0c\u4e3a\u4e86\u907f\u514d\u5bf9\u8c61\u51b2\u7a81\uff0c\u65b0\u79df\u6237\u6700\u597d\u4e3a\u65b0\u5efa\u79df\u6237\u3002
TRUNCATE TABLE
\u8bed\u53e5\u7528\u4e8e\u7528\u4e8e\u5220\u9664\u8868\u4e2d\u7684\u6240\u6709\u884c\uff0c\u800c\u4e0d\u8bb0\u5f55\u5355\u4e2a\u884c\u5220\u9664\u64cd\u4f5c\u3002TRUNCATE TABLE
\u4e0e\u6ca1\u6709 WHERE
\u5b50\u53e5\u7684 DELETE
\u8bed\u53e5\u7c7b\u4f3c\uff1b\u4f46\u662f\uff0cTRUNCATE TABLE
\u901f\u5ea6\u66f4\u5feb\uff0c\u4f7f\u7528\u7684\u7cfb\u7edf\u8d44\u6e90\u548c\u4e8b\u52a1\u65e5\u5fd7\u8d44\u6e90\u66f4\u5c11\u3002
TRUNCATE TABLE
\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a
TRUNCATE TABLE
\u5220\u9664\u4e4b\u540e\uff0c\u4e0d\u53ef\u6062\u590d\u3002
\u5982\u679c\u8868\u5177\u6709 AUTO_INCREMENT
\u5217\uff0c\u5219 TRUNCATE TABLE
\u8bed\u53e5\u5c06\u81ea\u52a8\u9012\u589e\u503c\u91cd\u7f6e\u4e3a\u96f6\u3002
\u5982\u679c\u8868\u5177\u6709\u4efb\u4f55\u5916\u952e\u7ea6\u675f\uff08FOREIGN KEY
\uff09\uff0c\u5219 TRUNCATE TABLE
\u8bed\u53e5\u4f1a\u9010\u4e2a\u5220\u9664\u884c\u3002
\u5982\u679c\u8868\u6ca1\u6709\u4efb\u4f55\u5916\u952e\u7ea6\u675f\uff08FOREIGN KEY
\uff09\uff0c\u5219 TRUNCATE TABLE
\u8bed\u53e5\u5c06\u5220\u9664\u8be5\u8868\u5e76\u91cd\u65b0\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u76f8\u540c\u7ed3\u6784\u7684\u65b0\u8868
DROP TABLE
\u3001TRUNCATE TABLE
\u548c DELETE TABLE
\u7684\u533a\u522b\uff1a
DROP TABLE
\uff1a\u5f53\u4f60\u4e0d\u518d\u9700\u8981\u8be5\u8868\u65f6\uff0c\u7528 DROP TABLE
\u3002TRUNCATE TABLE
\uff1a\u5f53\u4f60\u8981\u5220\u9664\u6240\u6709\u8bb0\u5f55\uff0c\u4f46\u4ecd\u8981\u4fdd\u7559\u8be5\u8868\u65f6\uff0c\u7528 TRUNCATE TABLE
\u3002DELETE TABLE
\uff1a\u5f53\u4f60\u8981\u5220\u9664\u90e8\u5206\u8bb0\u5f55\u65f6\uff0c\u7528 DELETE TABLE
\u3002> TRUNCATE [TABLE] table_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#table","title":"TABLE","text":"TABLE \u5173\u952e\u5b57\u662f\u53ef\u9009\u7684\u3002\u4f7f\u7528\u5b83\u6765\u533a\u5206 TRUNCATE TABLE
\u8bed\u53e5\u548c TRUNCATE
\u51fd\u6570\u3002
create table index_table_05 (col1 bigint not null auto_increment,col2 varchar(25),col3 int,col4 varchar(50),primary key (col1),unique key col2(col2),key num_id(col4));\ninsert into index_table_05(col2,col3,col4) values ('apple',1,'10'),('store',2,'11'),('bread',3,'12');\nmysql> select * from index_table_05;\n+------+-------+------+------+\n| col1 | col2 | col3 | col4 |\n+------+-------+------+------+\n| 1 | apple | 1 | 10 |\n| 2 | store | 2 | 11 |\n| 3 | bread | 3 | 12 |\n+------+-------+------+------+\n3 rows in set (0.00 sec)\n\nmysql> truncate table index_table_05;\nQuery OK, 0 rows affected (0.12 sec)\n\nmysql> select * from index_table_05;\nEmpty set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/","title":"CASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CASE
\u8bed\u53e5\u7528\u4e8e\u5b58\u50a8\u8fc7\u7a0b\u7684\u590d\u5408\u8bed\u53e5\u4e2d\u3002
\u5982\u679c\u6ca1\u6709 when_value
\u6216 search_condition
\u5339\u914d\u7684\u503c\uff0c\u5e76\u4e14 CASE
\u8bed\u53e5\u4e0d\u5305\u542b ELSE
\u4ece\u53e5\uff0c\u90a3\u4e48 CASE
\u8bed\u53e5\u62a5\u9519\u3002
\u6bcf\u4e2a statement_list
\u53ef\u4ee5\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u8bed\u53e5\u7ec4\u6210\uff0c\u4f46\u4e0d\u5141\u8bb8\u4f7f\u7528\u7a7a\u3002
\u8fd8\u6709\u4e00\u4e2a CASE
\u64cd\u4f5c\u7b26\uff0c\u5b83\u4e0e\u672c\u7ae0 CASE
\u8bed\u53e5\u4e0d\u540c\u3002\u53c2\u89c1\u6d41\u63a7\u5236\u51fd\u6570\u3002CASE
\u8bed\u53e5\u4e0d\u80fd\u6709 ELSE NULL
\u4ece\u53e5\uff0c\u5e76\u4e14 CASE
\u8bed\u53e5\u5fc5\u987b\u4ee5 END CASE
\u7ed3\u5c3e\u3002
CASE case_value\n WHEN when_value THEN statement_list\n [WHEN when_value THEN statement_list] ...\n [ELSE statement_list]\nEND CASE\n
\u5728\u8fd9\u4e2a\u8bed\u6cd5\u7ed3\u6784\u4e2d\uff0ccase_value
\u662f\u4e00\u4e2a\u8868\u8fbe\u5f0f\u3002\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u4f1a\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u67e5\u627e when_value
\uff0c\u76f4\u5230\u627e\u5230\u548c\u8868\u8fbe\u5f0f\u76f8\u7b49\u7684 when_value
\uff0c\u5e76\u8fd4\u56de\u5bf9\u5e94\u7684\u7ed3\u679c\uff0c\u75c5\u6267\u884c\u76f8\u5e94\u7684 THEN
\u4ece\u53e5 statement_list
\uff1b\u5982\u679c\u6ca1\u6709\u627e\u5230\u76f8\u7b49\u7684 when_value
\uff0c\u5219\u8fd4\u56de ELSE
\u8bed\u53e5\u540e\u7684 statement_list
\u7ed3\u679c\u3002
\u4f46\u662f\u8fd9\u4e2a\u8bed\u6cd5\u4e0d\u80fd\u7528\u4e8e\u6d4b\u8bd5\u662f\u5426\u4e0e NULL
\u76f8\u7b49\uff0c\u56e0\u4e3a NULL = NULL
\u4e3a false
\u3002
CASE\n WHEN search_condition THEN statement_list\n [WHEN search_condition THEN statement_list] ...\n [ELSE statement_list]\nEND CASE\n
\u5728\u8fd9\u4e2a\u8bed\u6cd5\u4e2d\uff0cCASE
\u8868\u8fbe\u5f0f\u4f1a\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u8ba1\u7b97 search_condition
\uff0c\u76f4\u5230\u7b2c\u4e00\u4e2a\u4e3a true
\uff0c\u7136\u540e\u6267\u884c THEN
\u4ece\u53e5 statement_list
\u5e76\u8fd4\u56de\u5bf9\u5e94\u7ed3\u679c\u3002\u5982\u679c\u6ca1\u6709\u4e3a true
\u7684 search_condition
\uff0c\u5219\u6267\u884c ELSE
\u4ece\u53e5 statement_list
\u5e76\u8fd4\u56de\u7ed3\u679c\u3002
CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER);\nINSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1);\n\nmysql> SELECT CASE AVG (c0) WHEN any_value(c1) * any_value(c2) THEN 1 END FROM t1;\n+------------------------------------------------------------+\n| case avg(c0) when any_value(c1) * any_value(c2) then 1 end |\n+------------------------------------------------------------+\n| 1 |\n+------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) * any_value(c2) WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1;\n+--------------------------------------------------------------------------------+\n| case any_value(c1) * any_value(c2) when sum(c0) then 1 when avg(c0) then 2 end |\n+--------------------------------------------------------------------------------+\n| 2 |\n+--------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) WHEN any_value(c1) + 1 THEN 1 END, ABS(AVG(c0)) FROM t1;\n+------------------------------------------------------+--------------+\n| case any_value(c1) when any_value(c1) + 1 then 1 end | abs(avg(c0)) |\n+------------------------------------------------------+--------------+\n| NULL | 1 |\n+------------------------------------------------------+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/","title":"DELETE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DELETE
\u7528\u4e8e\u5220\u9664\u5355\u8868\u6216\u591a\u8868\u4e2d\u7684\u8bb0\u5f55\u3002
DELETE FROM tbl_name [[AS] tbl_alias]\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
DELETE
\u8bed\u53e5\u4ece tbl_name
\u4e2d\u5220\u9664\u884c\uff0c\u5e76\u8fd4\u56de\u5df2\u5220\u9664\u7684\u884c\u6570\u3002
WHERE
\u4ece\u53e5\u7528\u4e8e\u6307\u5b9a\u7528\u4e8e\u6807\u8bc6\u8981\u5220\u9664\u54ea\u4e9b\u884c\u7684\u6761\u4ef6\u3002\u82e5\u65e0 WHERE
\u4ece\u53e5\uff0c\u5219\u5220\u9664\u6240\u6709\u884c\u3002
ORDER BY
\u4ece\u53e5\uff0c\u6307\u6309\u7167\u6307\u5b9a\u7684\u987a\u5e8f\u5220\u9664\u884c\u3002
LIMIT
\u4ece\u53e5\u7528\u4e8e\u9650\u5236\u53ef\u5220\u9664\u7684\u884c\u6570\u3002
CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\ndelete from t1 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 2 |\n+------+------+\n
\u540c\u65f6\u4e5f\u652f\u6301\u591a\u8868 JOIN \u8bed\u53e5\u3002
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (5);\ndelete t1 from t1 join t2 where t1.a = 2;\n\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n| 4 |\n+------+\n2 rows in set (0.00 sec)\n
drop database if exists db1;\ndrop database if exists db2;\ncreate database db1;\ncreate database db2;\nuse db2;\ndrop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(4);\nuse db1;\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1),(2),(3);\ndelete from db1.t2, db2.t1 using db1.t2 join db2.t1 on db1.t2.b = db2.t1.a where 2 > 1;\n\nmysql> select * from db1.t2;\n+------+\n| b |\n+------+\n| 3 |\n+------+\nmysql> select * from db2.t1;\n+------+\n| a |\n+------+\n| 4 |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/","title":"INSERT INTO SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"INSERT INTO SELECT
\u8bed\u53e5\u4ece\u4e00\u4e2a\u8868\u590d\u5236\u6570\u636e\uff0c\u7136\u540e\u628a\u6570\u636e\u63d2\u5165\u5230\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u8868\u4e2d\u3002\u4e14\u76ee\u6807\u8868\u4e2d\u4efb\u4f55\u5df2\u5b58\u5728\u7684\u884c\u90fd\u4e0d\u4f1a\u53d7\u5f71\u54cd\u3002
INSERT INTO table2 (column1, column2, column3, ...)\nSELECT column1, column2, column3, ...\nFROM table1\nWHERE condition;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#_3","title":"\u793a\u4f8b","text":"create table t1(id int, name varchar(10));\ninsert into t1 values(1, 'a');\ninsert into t1 values(2, 'b');\ninsert into t1 values(3, 'c');\ncreate table t2(id int, appname varchar(10), country varchar(10));\ninsert into t2 values(1, 'appone', 'CN');\ninsert into t2 values(2, 'apptwo', 'CN');\nINSERT INTO t1 (name) SELECT appname FROM t2;\n\nmysql> select * from t1;\n+------+--------+\n| id | name |\n+------+--------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n| NULL | appone |\n| NULL | apptwo |\n+------+--------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/","title":"INSERT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"INSERT
\u7528\u4e8e\u5728\u8868\u4e2d\u63d2\u5165\u65b0\u884c\u3002
> INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int default (1+12), b int);\ninsert into t1(b) values(1), (1);\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 13 | 1 |\n| 13 | 1 |\n+------+------+\n2 rows in set (0.01 sec)\n\ndrop table if exists t1;\ncreate table t1 (a date);\ninsert into t1 values(DATE(\"2017-06-15 09:34:21\")),(DATE(\"2019-06-25 10:12:21\")),(DATE(\"2019-06-25 18:20:49\"));\n\nmysql> select * from t1;\n+------------+\n| a |\n+------------+\n| 2017-06-15 |\n| 2019-06-25 |\n| 2019-06-25 |\n+------------+\n3 rows in set (0.00 sec)\n\ndrop table if exists t;\nCREATE TABLE t (i1 INT, d1 DOUBLE, e2 DECIMAL(5,2));\nINSERT INTO t VALUES ( 6, 6.0, 10.0/3), ( null, 9.0, 10.0/3), ( 1, null, 10.0/3), ( 2, 2.0, null );\n\nmysql> select * from t;\n+------+------+------+\n| i1 | d1 | e2 |\n+------+------+------+\n| 6 | 6 | 3.33 |\n| NULL | 9 | 3.33 |\n| 1 | NULL | 3.33 |\n| 2 | 2 | NULL |\n+------+------+------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data-inline/","title":"LOAD DATA INLINE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data-inline/#_1","title":"\u6982\u8ff0","text":"LOAD DATA INLINE
\u8bed\u6cd5\u53ef\u4ee5\u5c06 csv \u683c\u5f0f\u7ec4\u7ec7\u7684\u5b57\u7b26\u4e32\u5bfc\u5165\u6570\u636e\u8868\u4e2d\uff0c\u5bfc\u5165\u901f\u5ea6\u8f83 INSERT INTO
\u64cd\u4f5c\u66f4\u5feb\u3002LOAD DATA INLINE
\u7684\u529f\u80fd\u9002\u5408\u65e0\u4e3b\u952e\u7684\u6d41\u5f0f\u5feb\u901f\u6570\u636e\u5199\u5165\uff0c\u5982 IoT \u7c7b\u7684\u573a\u666f\u3002
mysql> LOAD DATA INLINE FORMAT='csv' ,\nDATA=$XXX$\ncsv_string $XXX$\nINTO TABLE tbl_name;\n
\u53c2\u6570\u89e3\u91ca
FORMAT='csv'
\u8868\u793a\u540e\u9762 DATA
\u4e2d\u7684\u5b57\u7b26\u4e32\u6570\u636e\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u7684\u3002
DATA=$XXX$ csv_string $XXX$
\u4e2d\u7684 $XXX$
\u662f\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\u3002csv_string
\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u5b57\u7b26\u4e32\u6570\u636e\uff0c\u4ee5 \\n
\u6216\u8005 \\r\\n
\u4f5c\u4e3a\u6362\u884c\u7b26\u3002
Note
$XXX$
\u4e3a\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\uff0c\u6ce8\u610f\u6570\u636e\u7ed3\u675f\u5904\u7684 $XXX$
\u9700\u8981\u548c\u6700\u540e\u4e00\u884c\u6570\u636e\u653e\u5728\u540c\u4e00\u884c\uff0c\u6362\u884c\u53ef\u80fd\u5bfc\u81f4 ERROR 20101
LOAD DATA INLINE
\u5bfc\u5165\u6570\u636e","text":"\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MatrixOne \u4e2d\u6267\u884c LOAD DATA INLINE
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868 user
:
CREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n)\n
\u5728 MySQL \u5ba2\u6237\u7aef\u6267\u884c LOAD DATA INLINE
\u8fdb\u884c\u6570\u636e\u5bfc\u5165\uff0c\u4ee5 csv \u683c\u5f0f\u5bfc\u5165\u6570\u636e\uff1a
mysql> LOAD DATA INLINE FORMAT='csv',\nDATA=$XXX$\nLihua,23,Shanghai\nBob,25,Beijing $XXX$ INTO TABLE user;\n
LOAD DATA INFILE
\u8bed\u53e5\u53ef\u4ee5\u6781\u5feb\u5730\u5c06\u6587\u672c\u6587\u4ef6\u4e2d\u7684\u884c\u8bfb\u5165\u8868\u4e2d\u3002\u4f60\u53ef\u4ee5\u4ece\u670d\u52a1\u5668\u4e3b\u673a\u6216 S3 \u517c\u5bb9\u5bf9\u8c61\u5b58\u50a8\u8bfb\u53d6\u8be5\u6587\u4ef6\u3002LOAD DATA INFILE
\u662f SELECT ... INTO OUTFILE
\u76f8\u53cd\u7684\u64cd\u4f5c\u3002
LOAD DATA INFILE
\u3002SELECT ... INTO OUTFILE
\u3002FIELDS
\u548c LINES
\u5b50\u53e5\u7684\u8bed\u6cd5\u5bf9\u4e8e LOAD DATA INFILE
\u548c SELECT ... INTO OUTFILE
\u8fd9\u4e24\u4e2a\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u5f0f\u4e00\u81f4\uff0c\u4f7f\u7528 Fields \u548c Lines \u53c2\u6570\u6765\u6307\u5b9a\u5982\u4f55\u5904\u7406\u6570\u636e\u683c\u5f0f\u3002> LOAD DATA [LOCAL]\n INFILE 'file_name'\n INTO TABLE tbl_name\n [CHARACTER SET charset_name]\n [{FIELDS | COLUMNS}\n [TERMINATED BY 'string']\n [[OPTIONALLY] ENCLOSED BY 'char']\n [ENCASPED BY 'char']\n ]\n [LINES\n [STARTING BY 'string']\n [TERMINATED BY 'string']\n ]\n [IGNORE number {LINES | ROWS}]\n [SET column_name_1=nullif(column_name_1, expr1), column_name_2=nullif(column_name_2, expr2)...]\n [PARALLEL {'TRUE' | 'FALSE'}]\n [STRICT {'TRUE' | 'FALSE'}]\n
\u53c2\u6570\u89e3\u91ca
\u4e0a\u8ff0\u8bed\u6cd5\u7ed3\u6784\u4e2d\u7684\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#infile","title":"INFILE","text":"LOAD DATA INFILE 'file_name'
\uff1a\u547d\u4ee4\u884c\u4f7f\u7528\u573a\u666f\uff1a\u9700\u8981\u52a0\u8f7d\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u4e3b\u673a\u670d\u52a1\u5668\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u3002 file_name
\u53ef\u4ee5\u662f\u6587\u4ef6\u7684\u5b58\u653e\u4f4d\u7f6e\u7684\u76f8\u5bf9\u8def\u5f84\u540d\u79f0\uff0c\u4e5f\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84\u540d\u79f0\u3002
LOAD DATA LOCAL INFILE 'file_name'
\uff1a\u547d\u4ee4\u884c\u4f7f\u7528\u573a\u666f\uff1a\u9700\u8981\u52a0\u8f7d\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u4e3b\u673a\u670d\u52a1\u5668\u4e0d\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\uff0c\u5373\uff0c\u6570\u636e\u6587\u4ef6\u5728\u5ba2\u6237\u673a\u4e0a\u3002 file_name
\u53ef\u4ee5\u662f\u6587\u4ef6\u7684\u5b58\u653e\u4f4d\u7f6e\u7684\u76f8\u5bf9\u8def\u5f84\u540d\u79f0\uff0c\u4e5f\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84\u540d\u79f0\u3002
\u5982\u679c\u6587\u4ef6\u5185\u5bb9\u4f7f\u7528\u4e0e\u9ed8\u8ba4\u503c\u4e0d\u540c\u7684\u5b57\u7b26\u96c6\uff0c\u53ef\u4f7f\u7528 CHARACTER SET
\u6307\u5b9a\u5b57\u7b26\u96c6\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 CHARACTER SET utf8
\u6307\u5b9a\u5bfc\u5165\u5185\u5bb9\u5b57\u7b26\u96c6\u4e3a utf8\uff1a
LOAD DATA INFILE 'yourfilepath' INTO TABLE xx CHARACTER SET utf8;\n
Note
\u9664\u4e86 utf8 \u5916\uff0cLOAD DATA
\u8fd8\u652f\u6301\u6307\u5b9a utf_8\u3001UTF_16\u3001UTF_xx\u3001gbk\u3001abcd \u7b49\u5b57\u7b26\u96c6\u3002\u6682\u4e0d\u652f\u6301\u6307\u5b9a\u5e26\u6709 -\uff08\u5982 utf-8,UTF-16) \u7684\u5b57\u7b26\u96c6\u3002
IGNORE number LINES
\u5b50\u53e5\u53ef\u7528\u4e8e\u5ffd\u7565\u6587\u4ef6\u5f00\u5934\u7684\u884c\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 IGNORE 1 LINES
\u8df3\u8fc7\u5305\u542b\u5217\u540d\u7684\u521d\u59cb\u6807\u9898\u884c\uff1a
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1 IGNORE 1 LINES;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#fields-lines","title":"FIELDS \u548c LINES \u53c2\u6570\u8bf4\u660e","text":"\u4f7f\u7528 FIELDS
\u548c LINES
\u53c2\u6570\u6765\u6307\u5b9a\u5982\u4f55\u5904\u7406\u6570\u636e\u683c\u5f0f\u3002
\u5bf9\u4e8e LOAD DATA
\u548c SELECT ... INTO OUTFILE
\u8bed\u53e5\uff0cFIELDS
\u548c LINES
\u5b50\u53e5\u7684\u8bed\u6cd5\u662f\u76f8\u540c\u7684\u3002\u8fd9\u4e24\u4e2a\u5b50\u53e5\u90fd\u662f\u53ef\u9009\u7684\uff0c\u4f46\u5982\u679c\u4e24\u8005\u90fd\u6307\u5b9a\uff0c\u5219 FIELDS
\u5fc5\u987b\u5728 LINES
\u4e4b\u524d\u3002
\u5982\u679c\u6307\u5b9a FIELDS
\u5b50\u53e5\uff0c\u90a3\u4e48 FIELDS
\u7684\u6bcf\u4e2a\u5b50\u53e5\uff08TERMINATED BY
\u3001[OPTIONALLY] ENCLOSED BY
\uff09\u4e5f\u662f\u53ef\u9009\u7684\uff0c\u9664\u975e\u4f60\u5fc5\u987b\u81f3\u5c11\u6307\u5b9a\u5176\u4e2d\u4e00\u4e2a\u3002
LOAD DATA
\u4e5f\u652f\u6301\u4f7f\u7528\u5341\u516d\u8fdb\u5236 ASCII
\u5b57\u7b26\u8868\u8fbe\u5f0f\u6216\u4e8c\u8fdb\u5236 ASCII
\u5b57\u7b26\u8868\u8fbe\u5f0f\u4f5c\u4e3a FIELDS ENCLOSED BY
\u548c FIELDS TERMINATED BY
\u7684\u53c2\u6570\u3002
\u5982\u679c\u4e0d\u6307\u5b9a\u5904\u7406\u6570\u636e\u7684\u53c2\u6570\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u503c\u5982\u4e0b\uff1a
FIELDS TERMINATED BY '\\t' ENCLOSED BY '\"' ESCAPED BY '\\\\' LINES TERMINATED BY '\\n'\n
Note
FIELDS TERMINATED BY '\\t'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \\t
\u4f5c\u4e3a\u5206\u9694\u7b26\u3002ENCLOSED BY '\"'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \"
\u4f5c\u4e3a\u5305\u62ec\u7b26\u3002ESCAPED BY '\\\\'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \\
\u4f5c\u4e3a\u8f6c\u4e49\u7b26\u3002LINES TERMINATED BY '\\n'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \\n
\u6216 \\r\\n
\u4f5c\u4e3a\u884c\u95f4\u5206\u9694\u7b26\u3002FIELDS TERMINATED BY
FIELDS TERMINATED BY
\u8868\u793a\u5b57\u6bb5\u4e0e\u5b57\u6bb5\u4e4b\u95f4\u7684\u5206\u9694\u7b26\uff0c\u4f7f\u7528 FIELDS TERMINATED BY
\u5c31\u53ef\u4ee5\u6307\u5b9a\u6bcf\u4e2a\u6570\u636e\u7684\u5206\u9694\u7b26\u53f7\u3002
FIELDS TERMINATED BY
\u6307\u5b9a\u7684\u503c\u53ef\u4ee5\u8d85\u8fc7\u4e00\u4e2a\u5b57\u7b26\u3002
\u793a\u4f8b\uff1a
\u4f8b\u5982\uff0c\u8bfb\u53d6\u4f7f\u7528\u9017\u53f7\u5206\u9694\u7684\u6587\u4ef6\uff0c\u8bed\u6cd5\u662f\uff1a
LOAD DATA INFILE 'data.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',';\n
FIELDS ENCLOSED BY
FIELDS TERMINATED BY
\u6307\u5b9a\u7684\u503c\u5305\u542b\u8f93\u5165\u503c\u7684\u5b57\u7b26\u3002ENCLOSED BY
\u6307\u5b9a\u7684\u503c\u5fc5\u987b\u662f\u5355\u4e2a\u5b57\u7b26\uff1b\u5982\u679c\u8f93\u5165\u503c\u4e0d\u4e00\u5b9a\u5305\u542b\u5728\u5f15\u53f7\u4e2d\uff0c\u9700\u8981\u5728 ENCLOSED BY
\u9009\u9879\u4e4b\u524d\u4f7f\u7528 OPTIONALLY
\u3002
\u5982\u4e0b\u9762\u7684\u4f8b\u5b50\u6240\u793a\uff0c\u5373\u8868\u793a\u4e00\u90e8\u5206\u8f93\u5165\u503c\u7528\u53ef\u4ee5\u7528\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u53e6\u4e00\u4e9b\u53ef\u4ee5\u4e0d\u7528\u5f15\u53f7\u62ec\u8d77\u6765\uff1a
LOAD DATA INFILE 'data.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n
\u5982\u679c ENCLOSED BY
\u524d\u4e0d\u52a0 OPTIONALLY
\uff0c\u6bd4\u5982\u8bf4\uff0cENCLOSED BY '\"'
\u5c31\u8868\u793a\u4f7f\u7528\u53cc\u5f15\u53f7\u628a\u5404\u4e2a\u5b57\u6bb5\u90fd\u62ec\u8d77\u6765\u3002
FIELDS ESCAPED BY
FIELDS ESCAPED BY
\u5141\u8bb8\u4f60\u6307\u5b9a\u4e00\u4e2a\u8f6c\u4e49\u5b57\u7b26\uff0c\u9ed8\u8ba4\u503c \\\\
\uff0c\u4ee3\u8868 \\
\u662f\u4e2a\u8f6c\u4e49\u7b26\u53f7\uff0c\u5982\u679c FIELDS ESCAPED BY
\u5b57\u7b26\u4e0d\u4e3a\u7a7a\uff0c\u5219\u5220\u9664\u8be5\u5b57\u7b26\uff0c\u5e76\u4e14\u540e\u7eed\u5b57\u7b26\u5c06\u6309\u5b57\u9762\u610f\u601d\u4f5c\u4e3a\u5b57\u6bb5\u503c\u7684\u4e00\u90e8\u5206\u3002
\u4f46\u4e00\u4e9b\u53cc\u5b57\u7b26\u5e8f\u5217\u6709\u7740\u7279\u6b8a\u542b\u4e49\uff0c\u5982\u4e0b\u8868\uff1a
\u8f6c\u4e49\u5e8f\u5217 \u5e8f\u5217\u8868\u793a\u7684\u5b57\u7b26 \\0 \u7a7a\u683c\u7b26 \\b \u9000\u683c\u7b26 \\n \u6362\u884c\u7b26 \\r \u56de\u8f66\u7b26 \\t \u5236\u8868\u7b26 \\z \u7ed3\u675f\u7b26\uff08Ctl+Z\uff09\u793a\u4f8b
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\\\b\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t1\uff1a
create table t1(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t1;\n\nmysql> select * from t1;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | a\\b |\n+------+------+\n1 row in set (0.00 sec)\n
n2 \u7684\u7ed3\u679c\u4e3a a\\b
\uff0c\u56e0\u4e3a\u7b2c\u4e00\u4e2a \\
\u4e3a\u8f6c\u4e49\u7b26\uff0c\u88ab\u5220\u9664\u4e86\u3002
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\\\b\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t2\uff1a
create table t2(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t2 fields escaped by 'a';\n\nmysql> select * from t2;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | \\\\b |\n+------+------+\n1 row in set (0.00 sec)\n
n2 \u7684\u7ed3\u679c\u4e3a \\\\b
\uff0c\u56e0\u4e3a\u5728\u8fd9\u91cc\u6211\u4eec\u6307\u5b9a\u4e86\u8f6c\u4e49\u7b26\u4e3a a
\uff0c\u6240\u4ee5 a
\u88ab\u5220\u9664\u4e86\u3002
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\\\ b\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t1\uff1a
create table t3(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t3 fields escaped by '';\n\nmysql> SELECT * FROM t3;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | a\\\\b |\n+------+------+\n1 row in set (0.01 sec)\n
n2 \u7684\u7ed3\u679c\u4e3a a\\\\b
\uff0c\u5f53 ESCAPED BY \u4e3a\u7a7a\u65f6\uff0c\u539f\u6837\u8bfb\u53d6\u4e0d\u5bf9\u5b57\u7b26\u505a\u8f6c\u4e49\u5904\u7406\u3002
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\0b\n2 c\\bd\n3 a\\nb\n4 a\\rb\n5 a\\tb\n6 a\\Zb\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t4\uff1a
create table t3(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t4;\n\nmysql> select * from t1;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | a b |\n| 2 | d |\n| 3 | a\nb |\nb | 4 | a\n| 5 | a b |\n| 6 | ab |\n+------+------+\n6 rows in set (0.01 sec)\n
n1=1 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a b
\uff0c\u56e0\u4e3a \\0
\u4e3a\u7a7a\u683c\u7b26\uff1b
n=2 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a d
\uff0c\u56e0\u4e3a \\b
\u4e3a\u9000\u683c\u7b26\uff0ca
\u88ab\u5220\u9664\uff1b
n=3 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a
\u52a0\u6362\u884c\u540e\u7684 b
\uff0c\u56e0\u4e3a \\n
\u4e3a\u6362\u884c\u7b26\uff1b
n=4 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a
\u52a0\u6362\u56de\u8f66\u540e\u7684 b
\uff0c\u56e0\u4e3a \\r
\u4e3a\u56de\u8f66\u7b26\uff1b
n=5 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a b
\u7684 b\uff0c\u56e0\u4e3a \\t
\u4e3a\u5236\u8868\uff1b
n=6 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a ab
\uff0c\u56e0\u4e3a \\z
\u4e3a\u7ed3\u675f\u7b26\u3002
LINES TERMINATED BY
LINES TERMINATED BY
\u7528\u4e8e\u6307\u5b9a\u4e00\u884c\u7684\u7ed3\u675f\u7b26\u3002LINES TERMINATED BY
\u503c\u53ef\u4ee5\u8d85\u8fc7\u4e00\u4e2a\u5b57\u7b26\u3002
\u4f8b\u5982\uff0ccsv \u6587\u4ef6\u4e2d\u7684\u884c\u4ee5\u56de\u8f66\u7b26/\u6362\u884c\u7b26\u5bf9\u7ed3\u675f\uff0c\u4f60\u5728\u52a0\u8f7d\u5b83\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 LINES TERMINATED BY '\\r\\n'
\u6216 LINES TERMINATED BY '\\n'
\uff1a
LOAD DATA INFILE 'data.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n LINES TERMINATED BY '\\r\\n';\n
LINE STARTING BY
\u5982\u679c\u6240\u6709\u8f93\u5165\u884c\u90fd\u6709\u4e00\u4e2a\u4f60\u60f3\u5ffd\u7565\u7684\u516c\u5171\u524d\u7f00\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 LINES STARTING BY
'prefix_string' \u6765\u5ffd\u7565\u524d\u7f00\u548c\u524d\u7f00\u4e4b\u524d\u7684\u4efb\u4f55\u5185\u5bb9\u3002
\u5982\u679c\u4e00\u884c\u4e0d\u5305\u542b\u524d\u7f00\uff0c\u5219\u8df3\u8fc7\u6574\u884c\u3002\u5982\u4e0b\u8bed\u53e5\u6240\u793a\uff1a
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx';\n
\u5982\u679c\u6570\u636e\u6587\u4ef6\u662f\u5982\u4e0b\u6837\u5f0f\uff1a
xxx\"abc\",1\nsomething xxx\"def\",2\n\"ghi\",3\n
\u5219\u8f93\u51fa\u7684\u7ed3\u679c\u884c\u662f (\"abc\"\uff0c1) \u548c (\"def\"\uff0c2)\u3002\u6587\u4ef6\u4e2d\u7684\u7b2c\u4e09\u884c\u7531\u4e8e\u6ca1\u6709\u524d\u7f00\uff0c\u5219\u88ab\u5ffd\u7565\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#set","title":"SET","text":"MatrixOne \u5f53\u524d\u4ec5\u652f\u6301 SET column_name=nullif(column_name,expr)
\u3002\u5373\uff0c\u5f53 column_name = expr
\uff0c\u8fd4\u56de NULL
\uff1b\u5426\u5219\uff0c\u5219\u8fd4\u56de column_name
\u3002\u4f8b\u5982\uff0cSET a=nullif(a, 1)
\uff0c\u5f53 a=1 \u65f6\uff0c\u8fd4\u56de NULL
\uff1b\u5426\u5219\uff0c\u8fd4\u56de a \u5217\u539f\u59cb\u7684\u503c\u3002
\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u52a0\u8f7d\u6587\u4ef6\u65f6\uff0c\u8bbe\u7f6e\u53c2\u6570 SET column_name=nullif(column_name,\"null\")
\uff0c\u7528\u4e8e\u8fd4\u56de\u5217\u4e2d\u7684 NULL
\u503c\u3002
\u793a\u4f8b
\u672c\u5730\u6587\u4ef6 test.txt
\u8be6\u60c5\u5982\u4e0b\uff1a
id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\nnull,wederTom,\"man\"\n
\u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u8868 user
\uff1a
create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\n
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u5c06 test.txt
\u5bfc\u5165\u81f3\u8868 user
\uff1a
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE user SET id=nullif(id,\"null\");\n
\u5bfc\u5165\u540e\u7684\u8868\u5185\u5bb9\u5982\u4e0b\uff1a
select * from user;\n+------+-----------+------+\n| id | user_name | sex |\n+------+-----------+------+\n| 1 | weder | man |\n| 2 | tom | man |\n| null | wederTom | man |\n+------+-----------+------+\n
\u5bf9\u4e8e\u4e00\u4e2a\u683c\u5f0f\u826f\u597d\u7684\u5927\u6587\u4ef6\uff0c\u4f8b\u5982 JSONLines \u6587\u4ef6\uff0c\u6216\u8005\u4e00\u884c\u6570\u636e\u4e2d\u6ca1\u6709\u6362\u884c\u7b26\u7684 CSV \u6587\u4ef6\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528 PARALLEL
\u5bf9\u8be5\u6587\u4ef6\u8fdb\u884c\u5e76\u884c\u52a0\u8f7d\uff0c\u4ee5\u52a0\u5feb\u52a0\u8f7d\u901f\u5ea6\u3002
\u4f8b\u5982\uff0c\u5bf9\u4e8e 2 \u4e2a G \u7684\u5927\u6587\u4ef6\uff0c\u4f7f\u7528\u4e24\u4e2a\u7ebf\u7a0b\u53bb\u8fdb\u884c\u52a0\u8f7d\uff0c\u7b2c 2 \u4e2a\u7ebf\u7a0b\u5148\u62c6\u5206\u5b9a\u4f4d\u5230 1G \u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u4e00\u76f4\u5f80\u540e\u8bfb\u53d6\u5e76\u8fdb\u884c\u52a0\u8f7d\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u505a\u5230\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u53d6\u5927\u6587\u4ef6\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u8bfb\u53d6 1G \u7684\u6570\u636e\u3002
\u793a\u4f8b\uff1a
-- \u6253\u5f00\u5e76\u884c\u52a0\u8f7d\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'TRUE';\n\n-- \u5173\u95ed\u5e76\u884c\u52a0\u8f7d\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'FALSE';\n\n-- \u9ed8\u8ba4\u5173\u95ed\u5e76\u884c\u52a0\u8f7d\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES;\n
Note
[PARALLEL {'TRUE' | 'FALSE'}]
\u5185\u5b57\u6bb5\uff0c\u5f53\u524d\u4ec5\u652f\u6301 TRUE
\u6216 FALSE
\uff0c\u4e14\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002
Note: LOAD
\u8bed\u53e5\u4e2d\u5982\u679c\u4e0d\u52a0 PARALLEL
\u5b57\u6bb5\uff0c\u5bf9\u4e8e CSV \u6587\u4ef6\uff0c\u662f\u9ed8\u8ba4\u5173\u95ed\u5e76\u884c\u52a0\u8f7d\uff1b\u5bf9\u4e8e JSONLines \u6587\u4ef6\uff0c\u9ed8\u8ba4\u5f00\u542f\u5e76\u884c\u52a0\u8f7d\u3002\u5982\u679c CSV \u6587\u4ef6\u4e2d\u6709\u884c\u7ed3\u675f\u7b26\uff0c\u6bd4\u5982 '\\n'\uff0c\u90a3\u4e48\u6709\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6587\u4ef6\u52a0\u8f7d\u65f6\u6570\u636e\u51fa\u9519\u3002\u5982\u679c\u6587\u4ef6\u8fc7\u5927\uff0c\u5efa\u8bae\u4ece\u6362\u884c\u7b26\u4e3a\u8d77\u6b62\u70b9\u624b\u52a8\u62c6\u5206\u6587\u4ef6\u540e\u518d\u5f00\u542f\u5e76\u884c\u52a0\u8f7d\u3002
MO \u652f\u6301\u4f7f\u7528 STRICT
\u53c2\u6570\u6307\u5b9a\u6587\u4ef6\u5e76\u884c\u5207\u5272\u7684\u65b9\u5f0f\uff0c\u53ea\u6709\u5728 PARALLEL
\u4e3a TRUE
\u65f6\u6709\u6548\u3002STRICT
\u7684\u9ed8\u8ba4\u503c\u4e3a FALSE
\uff0c\u8868\u660e\u5728\u5207\u5206\u6587\u4ef6\u5e76\u884c\u5bfc\u5165\u65f6\u5229\u7528\u6362\u884c\u7b26\uff08\u9ed8\u8ba4\u4e3a\\n\uff09\u8fdb\u884c\u5207\u5272\uff0c\u5728\u6570\u636e\u6709\u6362\u884c\u7b26\u60c5\u51b5\u4e0b\uff0c\u5c31\u6709\u53ef\u80fd\u4f1a\u5207\u5206\u51fa\u9519\u3002\u800c\u5f53\u53c2\u6570\u4e3a TRUE
\u65f6\uff0c\u5219\u4f7f\u7528\u9884\u8bfb\u68c0\u6d4b\u7684\u65b9\u5f0f\u5207\u5272\uff0c\u5b83\u4e0d\u4ec5\u4f9d\u8d56\u4e8e\u6362\u884c\u7b26\u8fdb\u884c\u5206\u5272\uff0c\u8fd8\u4f1a\u8fdb\u884c\u9884\u8bfb\uff0c\u4ee5\u9a8c\u8bc1\u5176\u662f\u5426\u4e0e\u8868\u7684\u5217\u5b9a\u4e49\u76f8\u5339\u914d\uff0c\u53ea\u6709\u5f53\u6570\u636e\u7b26\u5408\u5217\u5b9a\u4e49\u65f6\uff0c\u624d\u4f1a\u5c06\u5176\u4f5c\u4e3a\u6709\u6548\u7684\u5206\u5272\u70b9\u8fdb\u884c\u5904\u7406\u3002
\u793a\u4f8b\uff1a
-- \u5f00\u542f\u9884\u8bfb\u6a21\u5f0f\nload data infile 'file_name' into table tbl_name PARALLEL 'TRUE' STRICT 'TRUE';\n\n-- \u5173\u95ed\u9884\u8bfb\u6a21\u5f0f\nload data infile 'file_name' into table tbl_name PARALLEL 'TRUE' STRICT 'FALSE';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_3","title":"\u652f\u6301\u7684\u6587\u4ef6\u683c\u5f0f","text":"\u5728 MatrixOne \u5f53\u524d\u7248\u672c\u4e2d\uff0cLOAD DATA
\u652f\u6301 CSV \u683c\u5f0f\u548c JSONLines \u683c\u5f0f\u6587\u4ef6\u3002
\u6709\u5173\u5bfc\u5165\u8fd9\u4e24\u79cd\u683c\u5f0f\u7684\u6587\u6863\uff0c\u53c2\u89c1\u5bfc\u5165. csv \u683c\u5f0f\u6570\u636e\u548c\u5bfc\u5165 JSONLines \u6570\u636e\u3002
Note
LOAD DATA
\u652f\u6301\u5bfc\u5165\u538b\u7f29\u6587\u4ef6\u7684\u7c7b\u578b\u6709 lz4
\uff0cgz
\uff0cbz2
\uff0czlib
\uff0cflate
\uff0c\u6682\u4e0d\u652f\u6301\u5bfc\u5165\u4ee5 .tar
\u6216\u8005 .tar.xx
\u7ed3\u5c3e\u7684\u538b\u7f29\u6587\u4ef6\u3002
MatrixOne \u52a0\u8f7d CSV \u683c\u5f0f\u7b26\u5408 RFC4180 \u6807\u51c6\uff0c\u89c4\u5b9a CSV \u683c\u5f0f\u5982\u4e0b\uff1a
\u6bcf\u6761\u8bb0\u5f55\u4f4d\u4e8e\u5355\u72ec\u7684\u4e00\u884c\uff0c\u7531\u6362\u884c\u7b26\uff08CRLF\uff09\u5206\u9694\uff1a
aaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | b bb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u6587\u4ef6\u4e2d\u6700\u540e\u4e00\u6761\u8bb0\u5f55\u53ef\u4ee5\u6709\u7ed3\u675f\u6362\u884c\u7b26\uff0c\u4e5f\u53ef\u4ee5\u65e0\u7ed3\u675f\u6362\u884c\u7b26\uff08CRLF\uff09\uff1a
aaa,bbb,ccc CRLF\nzzz,yyy,xxx\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | b bb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u53ef\u9009\u7684\u6807\u9898\u884c\u4f5c\u4e3a\u6587\u4ef6\u7684\u7b2c\u4e00\u884c\u51fa\u73b0\uff0c\u5176\u683c\u5f0f\u4e0e\u666e\u901a\u8bb0\u5f55\u884c\u76f8\u540c\u3002\u4f8b\u5982\uff1a
field_name,field_name,field_name CRLF\naaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+------------+------------+------------+\n| field_name | field_name | field_name |\n+------------+------------+------------+\n| aaa | bbb | ccc |\n| zzz | yyy | xxx |\n+------------+------------+------------+\n
\u5728\u6807\u9898\u548c\u6bcf\u6761\u8bb0\u5f55\u4e2d\uff0c\u53ef\u80fd\u6709\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u6bb5\uff0c\u5b57\u6bb5\u4e4b\u95f4\u4ee5\u9017\u53f7\u5206\u9694\u3002\u5b57\u6bb5\u5185\u7684\u7a7a\u683c\u5c5e\u4e8e\u5b57\u6bb5\u7684\u4e00\u90e8\u5206\uff0c\u4e0d\u5e94\u5ffd\u7565\u3002\u6bcf\u6761\u8bb0\u5f55\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u5b57\u6bb5\u540e\u9762\u4e0d\u80fd\u8ddf\u9017\u53f7\u3002\u4f8b\u5982\uff1a
aaa,bbb,ccc\n
\u6216\uff1a
a aa, bbb,cc c\n
\u8fd9\u4e24\u4e2a\u4f8b\u5b50\u90fd\u662f\u5408\u6cd5\u7684\u3002
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | bbb | ccc |\n+---------+---------+---------+\n
\u6216\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| a aa | bbb | cc c |\n+---------+---------+---------+\n
\u6bcf\u4e2a\u5b57\u6bb5\u53ef\u4ee5\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u3002\u5982\u679c\u5b57\u6bb5\u6ca1\u6709\u7528\u53cc\u5f15\u53f7\u5f15\u8d77\u6765\uff0c\u90a3\u4e48\u53cc\u5f15\u53f7\u4e0d\u80fd\u51fa\u73b0\u5728\u5b57\u6bb5\u5185\u3002\u4f8b\u5982\uff1a
\"aaa\",\"bbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n
\u6216\uff1a
\"aaa\",\"bbb\",ccc CRLF\nzzz,yyy,xxx\n
\u8fd9\u4e24\u4e2a\u4f8b\u5b50\u90fd\u662f\u5408\u6cd5\u7684\u3002
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | bbb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u5305\u542b\u6362\u884c\u7b26\uff08CRLF\uff09\u3001\u53cc\u5f15\u53f7\u548c\u9017\u53f7\u7684\u5b57\u6bb5\u5e94\u8be5\u7528\u53cc\u5f15\u53f7\u5f15\u8d77\u6765\u3002\u4f8b\u5982\uff1a
\"aaa\",\"b CRLF\nbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | b bb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u5982\u679c\u4f7f\u7528\u53cc\u5f15\u53f7\u5c06\u5b57\u6bb5\u62ec\u8d77\u6765\uff0c\u90a3\u4e48\u51fa\u73b0\u5728\u5b57\u6bb5\u5185\u7684\u591a\u4e2a\u53cc\u5f15\u53f7\u4e5f\u5fc5\u987b\u4f7f\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u5426\u5219\u5b57\u6bb5\u5185\u4e24\u4e2a\u53cc\u5f15\u53f7\u7684\u7b2c\u4e00\u4e2a\u5f15\u53f7\u5c06\u88ab\u89e3\u6790\u4e3a\u8f6c\u4e49\u5b57\u7b26\uff0c\u4ece\u800c\u53ea\u4fdd\u7559\u4e00\u4e2a\u53cc\u5f15\u53f7\u3002\u4f8b\u5982\uff1a
\"aaa\",\"b\"\"bb\",\"ccc\"\n
\u4e0a\u9762\u8fd9\u4e2a CSV \u4f1a\u628a \"b\"\"bb\"
\u89e3\u6790\u4e3a b\"bb
\uff0c\u5982\u679c\u6b63\u786e\u7684\u5b57\u6bb5\u4e3a b\"\"bb
\uff0c\u90a3\u4e48\u5e94\u8be5\u5199\u6210\uff1a
\"aaa\",\"b\"\"\"\"bb\",\"ccc\"\n
\u6216\uff1a
\"aaa\",b\"\"bb,\"ccc\"\n
\u4f60\u53ef\u4ee5\u5728 SSB \u6d4b\u8bd5\u4e2d\u4e86\u89e3 LOAD DATA
\u8bed\u53e5\u7684\u7528\u6cd5\uff0c\u53c2\u89c1\u5b8c\u6210 SSB \u6d4b\u8bd5\u3002
\u8bed\u6cd5\u793a\u4f8b\u5982\u4e0b\uff1a
> LOAD DATA INFILE '/ssb-dbgen-path/lineorder_flat.tbl ' INTO TABLE lineorder_flat;\n
\u4e0a\u9762\u8fd9\u884c\u8bed\u53e5\u8868\u793a\uff1a\u5c06 /ssb-dbgen-path/ \u8fd9\u4e2a\u76ee\u5f55\u8def\u5f84\u4e0b\u7684 lineorder_flat.tbl \u6570\u636e\u96c6\u52a0\u8f7d\u5230 MatrixOne \u7684\u6570\u636e\u8868 lineorder_flat \u4e2d\u3002
\u4f60\u4e5f\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u8bed\u6cd5\u793a\u4f8b\uff0c\u6765\u5feb\u901f\u4e86\u89e3 LOAD DATA
\uff1a
\u672c\u5730\u547d\u540d\u4e3a char_varchar.csv \u6587\u4ef6\u5185\u6570\u636e\u5982\u4e0b\uff1a
a|b|c|d\n\"a\"|\"b\"|\"c\"|\"d\"\n'a'|'b'|'c'|'d'\n\"'a'\"|\"'b'\"|\"'c'\"|\"'d'\"\n\"aa|aa\"|\"bb|bb\"|\"cc|cc\"|\"dd|dd\"\n\"aa|\"|\"bb|\"|\"cc|\"|\"dd|\"\n\"aa|||aa\"|\"bb|||bb\"|\"cc|||cc\"|\"dd|||dd\"\n\"aa'|'||aa\"|\"bb'|'||bb\"|\"cc'|'||cc\"|\"dd'|'||dd\"\naa\"aa|bb\"bb|cc\"cc|dd\"dd\n\"aa\"aa\"|\"bb\"bb\"|\"cc\"cc\"|\"dd\"dd\"\n\"aa\"\"aa\"|\"bb\"\"bb\"|\"cc\"\"cc\"|\"dd\"\"dd\"\n\"aa\"\"\"aa\"|\"bb\"\"\"bb\"|\"cc\"\"\"cc\"|\"dd\"\"\"dd\"\n\"aa\"\"\"\"aa\"|\"bb\"\"\"\"bb\"|\"cc\"\"\"\"cc\"|\"dd\"\"\"\"dd\"\n\"aa\"\"|aa\"|\"bb\"\"|bb\"|\"cc\"\"|cc\"|\"dd\"\"|dd\"\n\"aa\"\"\"\"|aa\"|\"bb\"\"\"\"|bb\"|\"cc\"\"\"\"|cc\"|\"dd\"\"\"\"|dd\"\n|||\n||||\n\"\"|\"\"|\"\"|\n\"\"\"\"|\"\"\"\"|\"\"\"\"|\"\"\"\"\n\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"\n
\u5728 MatrixOne \u4e2d\u5efa\u8868\uff1a
mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(\n-> col1 char(225),\n-> col2 varchar(225),\n-> col3 text,\n-> col4 varchar(225)\n-> );\nQuery OK, 0 rows affected (0.02 sec)\n
\u5c06\u6570\u636e\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u8868 t1\uff1a
load data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|';\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa|aa | bb|bb | cc|cc | dd|dd |\n| aa| | bb| | cc| | dd| |\n| aa|||aa | bb|||bb | cc|||cc | dd|||dd |\n| aa'|'||aa | bb'|'||bb | cc'|'||cc | dd'|'||dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"|aa | bb\"|bb | cc\"|cc | dd\"|dd |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n| | | | |\n| | | | |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n20 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_6","title":"\u589e\u52a0\u6761\u4ef6\u5bfc\u5165\u793a\u4f8b","text":"\u6cbf\u7528\u4e0a\u9762\u7684\u7b80\u5355\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539\u4e00\u4e0b LOAD DATA \u8bed\u53e5\uff0c\u5728\u672b\u5c3e\u589e\u52a0\u6761\u4ef6 LINES STARTING BY 'aa' ignore 10 lines;
\uff1a
delete from t1;\nload data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|' LINES STARTING BY 'aa' ignore 10 lines;\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+---------+---------+---------+---------+\n| col1 | col2 | col3 | col4 |\n+---------+---------+---------+---------+\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"|aa | bb\"|bb | cc\"|cc | dd\"|dd |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n| | | | |\n| | | | |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+---------+---------+---------+---------+\n10 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u67e5\u8be2\u7ed3\u679c\u5ffd\u7565\u4e86\u524d 10 \u884c\uff0c\u5e76\u4e14\u5ffd\u7565\u4e86\u516c\u5171\u524d\u7f00 aa\u3002
\u6709\u5173\u5982\u4f55\u5bfc\u5165 CSV \u683c\u5f0f\u6587\u4ef6\u7684\u8be6\u7ec6\u6b65\u9aa4\uff0c\u53c2\u89c1\u5bfc\u5165. csv \u683c\u5f0f\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#2load-jsonlines","title":"\u793a\u4f8b 2\uff1aLOAD JSONLines","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_7","title":"\u7b80\u5355\u5bfc\u5165\u793a\u4f8b","text":"\u672c\u5730\u547d\u540d\u4e3a jsonline_array.jl \u6587\u4ef6\u5185\u6570\u636e\u5982\u4e0b\uff1a
[true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11,[\"1\",2,null,false,true,{\"q\":1}],\"1qaz\",null,null]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\",{\"c\":1,\"b\":[\"a\",\"b\",{\"q\":4}]},\"1aza\",null,null]\n
\u5728 MatrixOne \u4e2d\u5efa\u8868\uff1a
mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(col1 bool,col2 int,col3 varchar(100), col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float,col9 json,col10 text,col11 json,col12 bool);\nQuery OK, 0 rows affected (0.03 sec)\n
\u5c06\u6570\u636e\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u8868 t1\uff1a
load data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1;\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| true | 1 | var | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 | 18 | 121.11 | [\"1\", 2, null, false, true, {\"q\": 1}] | 1qaz | NULL | NULL |\n| true | 1 | var | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 | 18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza | NULL | NULL |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_8","title":"\u589e\u52a0\u6761\u4ef6\u5bfc\u5165\u793a\u4f8b","text":"\u6cbf\u7528\u4e0a\u9762\u7684\u7b80\u5355\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539\u4e00\u4e0b LOAD DATA \u8bed\u53e5\uff0c\u589e\u52a0 ignore 1 lines
\u5728\u8bed\u53e5\u7684\u672b\u5c3e\uff0c\u4f53\u9a8c\u4e00\u4e0b\u533a\u522b\uff1a
delete from t1;\nload data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1 ignore 1 lines;\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| true | 1 | var | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 | 18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza | NULL | NULL |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u67e5\u8be2\u7ed3\u679c\u5ffd\u7565\u6389\u4e86\u7b2c\u4e00\u884c\u3002
\u6709\u5173\u5982\u4f55\u5bfc\u5165 JSONLines \u683c\u5f0f\u6587\u4ef6\u7684\u8be6\u7ec6\u6b65\u9aa4\uff0c\u53c2\u89c1\u5bfc\u5165 JSONLines \u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_9","title":"\u9650\u5236","text":"REPLACE
\u548c IGNORE
\u4fee\u9970\u7b26\u7528\u6765\u89e3\u51b3\u552f\u4e00\u7d22\u5f15\u7684\u51b2\u7a81\uff1aREPLACE
\u8868\u793a\u82e5\u8868\u4e2d\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u7528\u65b0\u7684\u6570\u636e\u66ff\u6362\u6389\u65e7\u7684\u6570\u636e\uff1bIGNORE
\u5219\u8868\u793a\u4fdd\u7559\u65e7\u7684\u6570\u636e\uff0c\u5ffd\u7565\u6389\u65b0\u6570\u636e\u3002\u8fd9\u4e24\u4e2a\u4fee\u9970\u7b26\u5728 MatrixOne \u4e2d\u5c1a\u4e0d\u652f\u6301\u3002SET
\uff0c\u4ec5\u652f\u6301 SET columns_name=nullif(col_name,expr2)
\u3002LOAD DATA LOCAL
\u8fdb\u884c\u672c\u5730\u52a0\u8f7d\uff0c\u5219\u9700\u8981\u4f7f\u7528\u547d\u4ee4\u884c\u8fde\u63a5 MatrixOne \u670d\u52a1\u4e3b\u673a\uff1amysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile
\u3002UPDATE
\u7528\u4e8e\u4fee\u6539\u8868\u4e2d\u7684\u73b0\u6709\u8bb0\u5f55\u3002
UPDATE table_reference\n SET assignment_list\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#_4","title":"\u53c2\u6570\u91ca\u4e49","text":"UPDATE
\u5c06\u65b0\u503c\u66f4\u65b0\u5230\u6307\u5b9a\u8868\u4e2d\u73b0\u6709\u884c\u7684\u5217\u4e2d\u3002SET
\u4ece\u53e5\u6307\u51fa\u8981\u4fee\u6539\u54ea\u4e9b\u5217\u4ee5\u53ca\u5b83\u4eec\u5e94\u8be5\u88ab\u8d4b\u4e88\u7684\u503c\u3002\u6bcf\u4e2a\u503c\u53ef\u4ee5\u4f5c\u4e3a\u8868\u8fbe\u5f0f\u7ed9\u51fa\uff0c\u6216\u8005\u901a\u8fc7 DEFAULT
\u660e\u786e\u5c06\u5217\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u503c\u3002WHERE
\u4ece\u53e5\uff0c\u7528\u4e8e\u6307\u5b9a\u7528\u4e8e\u6807\u8bc6\u8981\u66f4\u65b0\u54ea\u4e9b\u884c\u7684\u6761\u4ef6\u3002\u82e5\u65e0 WHERE
\u4ece\u53e5\uff0c\u5219\u66f4\u65b0\u6240\u6709\u884c\u3002ORDER BY
\u4ece\u53e5\uff0c\u6307\u6309\u7167\u6307\u5b9a\u7684\u987a\u5e8f\u66f4\u65b0\u884c\u3002LIMIT
\u4ece\u53e5\u7528\u4e8e\u9650\u5236\u53ef\u66f4\u65b0\u7684\u884c\u6570\u3002CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 1 |\n| 1 | 2 |\n+------+------+\n
drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (3);\nupdate t1, t2 set a = 1, b =2;\n\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n| 1 |\n| 1 |\n+------+\n\nupdate t1, t2 set a = null, b =null;\n\nmysql> select * from t2;\n+------+\n| b |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\n
\u652f\u6301\u591a\u8868 JOIN \u8bed\u53e5\u3002
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int, b int, c int);\ninsert into t1 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\ncreate table t2 (a int, b int, c int);\ninsert into t2 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\nupdate t1 join t2 on t1.a = t2.a set t1.b = 222, t1.c = 333, t2.b = 222, t2.c = 333;\n\nmysql> select * from t1;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 222 | 333 |\n| 4 | 222 | 333 |\n| 7 | 222 | 333 |\n+------+------+------+\n\nmysql> with t11 as (select * from (select * from t1) as t22) update t11 join t2 on t11.a = t2.a set t2.b = 666;\n\nmysql> select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 666 | 333 |\n| 4 | 666 | 333 |\n| 7 | 666 | 333 |\n+------+------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/","title":"LAST_INSERT_ID()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u82e5\u8868\u4e2d\u542b\u81ea\u589e\u5b57\u6bb5 AUTO_INCREMENT
\uff0c\u5219\u5411\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\u540e\uff0c\u53ef\u4ee5\u8c03\u7528 LAST_INSERT_ID()
\u6765\u83b7\u5f97\u6700\u8fd1\u63d2\u5165\u7684\u90a3\u884c\u8bb0\u5f55\u7684\u81ea\u589e\u5b57\u6bb5\u503c\u3002
\u5982\u679c\u6ca1\u6709\u63d2\u5165\u53c2\u6570\uff0cLAST_INSERT_ID() \u8fd4\u56de\u4e00\u4e2a BIGINT UNSIGNED\uff0864 \u4f4d\uff09\u503c\uff0c\u8be5\u503c\u8868\u793a\u4f5c\u4e3a\u6700\u8fd1\u6267\u884c\u7684 INSERT \u8bed\u53e5\u7684\u7ed3\u679c\u6210\u529f\u63d2\u5165\u5230 AUTO_INCREMENT
\u5217\u7684\u7b2c\u4e00\u4e2a\u81ea\u52a8\u751f\u6210\u7684\u503c\u3002\u8fd4\u56de\u503c\u53d6\u51b3\u4e8e\u4e4b\u524d AUTO_INCREMENT
\u5217\u7684\u503c\uff0c\u5982\u679c\u4f60\u4e4b\u524d\u6ca1\u6709\u63d2\u5165\u4e00\u4e2a\u5217\uff0c\u90a3\u4e48\u8fd4\u56de\u503c\u4ece 1 \u5f00\u59cb\uff0c\u5982\u679c\u4f60\u4e4b\u524d\u63d2\u5165\u4e86\u4e00\u4e2a\u5217\uff0c\u90a3\u4e48\u8fd4\u56de\u503c\u4e3a AUTO_INCREMENT
\u5217\u7684\u503c\u589e\u52a0 1\u3002
\u5982\u679c\u6ca1\u6709\u6210\u529f\u63d2\u5165\u53c2\u6570\uff0cLAST_INSERT_ID()
\u7684\u503c\u4fdd\u6301\u4e0d\u53d8\u3002
\u5728 MySQL \u4e2d\uff0c\u5982\u679c\u4f7f\u7528\u5355\u4e2a INSERT
\u8bed\u53e5\u63d2\u5165\u591a\u884c\uff0c\u5219 LAST_INSERT_ID()
\u4ec5\u8fd4\u56de\u4e3a\u7b2c\u4e00\u4e2a\u63d2\u5165\u884c\u751f\u6210\u7684\u503c\u3002\u4f8b\u5982\uff1a
mysql> CREATE TABLE t (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, name VARCHAR(10) NOT NULL);\nmysql> INSERT INTO t VALUES (NULL, 'Bob');\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n| 1 | Bob |\n+----+------+\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 1 |\n+------------------+\nmysql> INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n| 1 | Bob |\n| 2 | Mary |\n| 3 | Jane |\n| 4 | Lisa |\n+----+------+\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 2 |\n+------------------+\n
\u4f46\u662f\u5728 MatrixOne \u4e2d\uff0c\u6211\u4eec\u6709\u4e0d\u540c\u7684\u884c\u4e3a\uff1b\u5982\u679c\u4f7f\u7528\u5355\u4e2a INSERT
\u8bed\u53e5\u63d2\u5165\u591a\u884c\uff0c\u5219 LAST_INSERT_ID()
\u8fd4\u56de\u4e3a\u6700\u540e\u63d2\u5165\u7684\u884c\u751f\u6210\u7684\u503c\u3002\u4e0e\u4e0a\u9762\u7684\u793a\u4f8b\u4e00\u6837\uff0c\u5f53\u60a8\u6267\u884c INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');
\u65f6\uff0cLAST_INSERT_ID()
\u5c06\u8fd4\u56de 4\u3002
LAST_INSERT_ID(), LAST_INSERT_ID(expr)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#_3","title":"\u793a\u4f8b","text":"create table t1(a int auto_increment primary key);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(11);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 12 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(null);\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 13 |\n+------------------+\n1 row in set (0.02 sec)\n\ncreate table t2(a int auto_increment primary key);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t2 values(100);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 101 |\n+------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/","title":"LAST_QUERY_ID()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u4e2d\u6307\u5b9a\u67e5\u8be2\u7684 ID\u3002\u5982\u679c\u672a\u6307\u5b9a\u67e5\u8be2\uff0c\u5219\u8fd4\u56de\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> LAST_QUERY_ID([ <num> ])\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"num \u4e3a\u6b63\u6570\uff0c\u5373\u4ece\u4f1a\u8bdd\u4e2d\u6267\u884c\u7684\u7b2c\u4e00\u4e2a\u67e5\u8be2\u5f00\u59cb\u3002\u4f8b\u5982\uff1a
LAST_QUERY_ID(1)
\uff1a\u8fd4\u56de\u7b2c\u4e00\u4e2a\u67e5\u8be2\u3002
LAST_QUERY_ID(2)
\uff1a\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u3002
LAST_QUERY_ID(6)
\uff1a\u8fd4\u56de\u7b2c\u516d\u4e2a\u67e5\u8be2\u3002
num \u4e3a\u8d1f\u6570\uff0c\u5373\u4ece\u4f1a\u8bdd\u4e2d\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2\u5f00\u59cb\u3002\u4f8b\u5982\uff1a
LAST_QUERY_ID(-1)
\uff1a\u8fd4\u56de\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2\uff08\u76f8\u5f53\u4e8e LAST_QUERY_ID()\uff09\u3002
LAST_QUERY_ID(-2)
\uff1a\u8fd4\u56de\u6700\u8fd1\u6267\u884c\u7684\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u3002
mysql> SELECT LAST_QUERY_ID(-1);\n+--------------------------------------+\n| last_query_id(-1) |\n+--------------------------------------+\n| af974680-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT LAST_QUERY_ID();\n+--------------------------------------+\n| last_query_id() |\n+--------------------------------------+\n| 550e4d44-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/","title":"INSERT IGNORE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"INSERT IGNORE
\u7528\u4e8e\u5728\u5411\u5177\u6709\u76f8\u540c\u552f\u4e00\u7d22\u5f15\u6216\u4e3b\u952e\u7684\u6570\u636e\u5e93\u8868\u4e2d\u63d2\u5165\u6570\u636e\u65f6\uff0c\u5982\u679c\u6570\u636e\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u5ffd\u7565\u8be5\u6570\u636e\uff0c\u800c\u4e0d\u662f\u8fd4\u56de\u62a5\u9519\uff0c\u5426\u5219\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002
\u4e0e MySQL \u4e0d\u540c\u7684\u662f\uff0c\u5728\u5bf9\u552f\u4e00\u7d22\u5f15\u6216\u4e3b\u952e\u63d2\u5165\u91cd\u590d\u503c\u65f6\uff0cMatrixOne \u4f1a\u5ffd\u7565\u62a5\u9519\uff0c\u800c MySQL \u4f1a\u6709\u544a\u8b66\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> INSERT IGNORE INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE user (\nid INT(11) NOT NULL PRIMARY KEY,\nname VARCHAR(50) NOT NULL,\nage INT(3) NOT NULL\n);\n-- \u63d2\u5165\u4e00\u6761\u65b0\u6570\u636e\uff0cid \u4e0d\u5b58\u5728\uff0c\u4e8e\u662f\u5f55\u5165\u65b0\u6570\u636e\nmysql> INSERT IGNORE INTO user VALUES (1, 'Tom', 18);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> SELECT * FROM USER;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 18 |\n+------+------+------+\n1 row in set (0.01 sec)\n\n-- \u518d\u63d2\u5165\u4e00\u6761\u65b0\u6570\u636e\uff0cid \u5b58\u5728\uff0c\u4e8e\u662f\u6570\u636e\u5ffd\u7565\nmysql> INSERT IGNORE INTO user VALUES (1, 'Jane', 16);\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT * FROM USER;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 18 |\n+------+------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_4","title":"\u9650\u5236","text":"INSERT IGNORE
\u4e0d\u652f\u6301\u5bf9 NOT NULL
\u5217\u5199\u5165 NULL
\u3002INSERT IGNORE
\u4e0d\u652f\u6301\u5bf9\u9519\u8bef\u7684\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u3002INSERT IGNORE
\u4e0d\u652f\u6301\u5904\u7406\u5206\u533a\u8868\u4e2d\u63d2\u5165\u6570\u636e\u5305\u542b\u4e0d\u5339\u914d\u5206\u533a\u503c\u7684\u64cd\u4f5c\u3002INSERT ... ON DUPLICATE KEY UPDATE
\u7528\u4e8e\u5728\u5411\u6570\u636e\u5e93\u8868\u4e2d\u63d2\u5165\u6570\u636e\u65f6\uff0c\u5982\u679c\u6570\u636e\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u66f4\u65b0\u8be5\u6570\u636e\uff0c\u5426\u5219\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002
INSERT INTO
\u8bed\u53e5\u662f\u7528\u4e8e\u5411\u6570\u636e\u5e93\u8868\u4e2d\u63d2\u5165\u6570\u636e\u7684\u6807\u51c6\u8bed\u53e5\uff1bON DUPLICATE KEY UPDATE
\u8bed\u53e5\u7528\u4e8e\u5728\u8868\u4e2d\u6709\u91cd\u590d\u8bb0\u5f55\u65f6\u8fdb\u884c\u66f4\u65b0\u64cd\u4f5c\u3002\u5982\u679c\u8868\u4e2d\u5b58\u5728\u5177\u6709\u76f8\u540c\u552f\u4e00\u7d22\u5f15\u6216\u4e3b\u952e\u7684\u8bb0\u5f55\uff0c\u5219\u4f7f\u7528 UPDATE
\u5b50\u53e5\u6765\u66f4\u65b0\u76f8\u5e94\u7684\u5217\u503c\uff0c\u5426\u5219\u4f7f\u7528 INSERT
\u5b50\u53e5\u63d2\u5165\u65b0\u8bb0\u5f55\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4f7f\u7528\u8be5\u8bed\u6cd5\u7684\u524d\u63d0\u662f\u9700\u8981\u5728\u8868\u4e2d\u5efa\u7acb\u4e3b\u952e\u7ea6\u675f\uff0c\u4ee5\u4fbf\u5224\u65ad\u662f\u5426\u6709\u91cd\u590d\u8bb0\u5f55\u3002\u540c\u65f6\uff0c\u66f4\u65b0\u64cd\u4f5c\u548c\u63d2\u5165\u64cd\u4f5c\u90fd\u9700\u8981\u8bbe\u7f6e\u5bf9\u5e94\u7684\u5217\u503c\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-on-duplicate/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-on-duplicate/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE user (\nid INT(11) NOT NULL PRIMARY KEY,\nname VARCHAR(50) NOT NULL,\nage INT(3) NOT NULL\n);\n-- \u63d2\u5165\u4e00\u6761\u65b0\u6570\u636e\uff0cid \u4e0d\u5b58\u5728\uff0c\u4e8e\u662f\u5f55\u5165\u65b0\u6570\u636e\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE name='Tom', age=18;\n\nmysql> select * from user;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 18 |\n+------+------+------+\n1 row in set (0.01 sec)\n\n-- \u5c06\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u8bb0\u5f55\u7684 age \u5b57\u6bb5\u589e\u52a0 1\uff0c\u540c\u65f6 name \u5b57\u6bb5\u4fdd\u6301\u4e0d\u53d8\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE age=age+1;\n\nmysql> select * from user;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 19 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- \u63d2\u5165\u4e00\u6761\u65b0\u8bb0\u5f55\uff0c\u5c06 name \u548c age \u5b57\u6bb5\u66f4\u65b0\u4e3a\u6307\u5b9a\u503c\nINSERT INTO user (id, name, age) VALUES (2, 'Lucy', 20)\nON DUPLICATE KEY UPDATE name='Lucy', age=20;\n\nmysql> select * from user;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 19 |\n| 2 | Lucy | 20 |\n+------+------+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-on-duplicate/#_4","title":"\u9650\u5236","text":"INSERT ... ON DUPLICATE KEY UPDATE
\u5f53\u524d\u8fd8\u4e0d\u652f\u6301\u552f\u4e00\u952e\uff08Unique key\uff09\uff0c\u7531\u4e8e\u552f\u4e00\u952e\u53ef\u4ee5\u4e3a NULL
\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u672a\u77e5\u9519\u8bef\u3002
REPLACE
\u4e0d\u4ec5\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u51fd\u6570\uff0c\u8fd8\u662f\u4e00\u4e2a\u66ff\u6362\u64cd\u4f5c\u7684\u6570\u636e\u64cd\u4f5c\u8bed\u53e5\u3002REPLACE
\u8bed\u53e5\u7684\u4f5c\u7528\u662f\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e\uff0c\u5982\u679c\u8868\u4e2d\u5df2\u7ecf\u5b58\u5728\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u5219\u4f1a\u5148\u5220\u9664\u8be5\u8bb0\u5f55\uff0c\u7136\u540e\u518d\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002\u5982\u679c\u8868\u4e2d\u4e0d\u5b58\u5728\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u5219\u76f4\u63a5\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002
REPLACE
\u901a\u5e38\u5728\u5177\u6709\u552f\u4e00\u7ea6\u675f\u7684\u8868\u4e2d\u4f7f\u7528\u3002
REPLACE
\u8bed\u53e5\u8981\u6c42\u8868\u4e2d\u5fc5\u987b\u5b58\u5728\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\uff0c\u7528\u4e8e\u5224\u65ad\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u76f8\u540c\u7684\u8bb0\u5f55\u3002REPLACE
\u8bed\u53e5\u63d2\u5165\u65b0\u8bb0\u5f55\u65f6\uff0c\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u76f8\u540c\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\u7684\u8bb0\u5f55\uff0c\u65e7\u8bb0\u5f55\u5c06\u88ab\u5220\u9664\uff0c\u7136\u540e\u63d2\u5165\u65b0\u8bb0\u5f55\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u81ea\u589e\u5217\u7684\u503c\u53d1\u751f\u53d8\u5316\u3002REPLACE\n [INTO] tbl_name\n [(col_name [, col_name] ...)]\n { VALUES(value_list)\n |\n VALUES row_constructor_list\n }\n\nREPLACE\n [INTO] tbl_name\n SET assignment_list\n\nvalue:\n {expr | DEFAULT}\n\nvalue_list:\n value [, value] ...\n\nrow_constructor_list:\n ROW(value_list)\n\nassignment:\n col_name = value\n\nassignment_list:\n assignment [, assignment] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/replace/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"REPLACE
\u8bed\u53e5\u7528\u4e8e\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e\u6216\u66f4\u65b0\u5df2\u5b58\u5728\u7684\u6570\u636e\u3002\u5b83\u7684\u8bed\u6cd5\u6709\u4e24\u79cd\u5f62\u5f0f\uff1a\u4e00\u79cd\u662f\u57fa\u4e8e\u5217\u540d\u7684\u63d2\u5165\u5f62\u5f0f\uff0c\u53e6\u4e00\u79cd\u662f\u57fa\u4e8e SET \u5b50\u53e5\u7684\u66f4\u65b0\u5f62\u5f0f\u3002
\u4ee5\u4e0b\u662f\u5404\u4e2a\u53c2\u6570\u7684\u89e3\u91ca\uff1a
INTO
: \u53ef\u9009\u5173\u952e\u5b57\uff0c\u8868\u793a\u5411\u54ea\u5f20\u8868\u63d2\u5165\u6570\u636e\u6216\u66f4\u65b0\u6570\u636e\u3002
tbl_name
: \u8868\u793a\u8981\u63d2\u5165\u6216\u66f4\u65b0\u6570\u636e\u7684\u8868\u7684\u540d\u79f0\u3002
col_name
: \u53ef\u9009\u53c2\u6570\uff0c\u8868\u793a\u8981\u63d2\u5165\u6216\u66f4\u65b0\u7684\u5217\u540d\u3002\u5728\u63d2\u5165\u5f62\u5f0f\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5217\u540d\u6307\u5b9a\u8981\u63d2\u5165\u7684\u5217\uff1b\u5728\u66f4\u65b0\u5f62\u5f0f\u4e2d\uff0c\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u3002
value
: \u8868\u793a\u8981\u63d2\u5165\u6216\u66f4\u65b0\u7684\u503c\u3002\u53ef\u4ee5\u662f\u5177\u4f53\u7684\u8868\u8fbe\u5f0f\uff08expr\uff09\u6216\u9ed8\u8ba4\u503c\uff08DEFAULT\uff09\u3002
value_list
: \u8868\u793a\u4e00\u7ec4\u8981\u63d2\u5165\u7684\u503c\u3002\u591a\u4e2a\u503c\u4e4b\u95f4\u7528\u9017\u53f7\u5206\u9694\u3002
\uff08\u6682\u4e0d\u652f\u6301\uff09row_constructor_list
: \u8868\u793a\u7528\u4e8e\u63d2\u5165\u7684\u4e00\u7ec4\u503c\u6784\u6210\u7684\u884c\u3002\u6bcf\u4e00\u884c\u7684\u503c\u4f7f\u7528\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u7528\u9017\u53f7\u5206\u9694\u3002
assignment
: \u8868\u793a\u4e00\u4e2a\u5217\u540d\u548c\u5176\u5bf9\u5e94\u7684\u503c\u7684\u5173\u8054\uff0c\u7528\u4e8e\u66f4\u65b0\u5f62\u5f0f\u3002
assignment_list
: \u8868\u793a\u591a\u4e2a\u5217\u540d\u548c\u5bf9\u5e94\u503c\u7684\u5173\u8054\uff0c\u7528\u4e8e\u66f4\u65b0\u5f62\u5f0f\u3002\u591a\u4e2a\u5217\u540d\u548c\u503c\u4e4b\u95f4\u7528\u9017\u53f7\u5206\u9694\u3002
Note
VALUES
\u5173\u952e\u5b57\u540e\u8ddf value_list
\u6216 row_constructor_list
\u6765\u63d2\u5165\u6570\u636e\u3002VALUES
\u540e\u8ddf value_list
\u8868\u793a\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0cVALUES
\u540e\u8ddf row_constructor_list
\u8868\u793a\u63d2\u5165\u591a\u884c\u6570\u636e\u3002SET
\u5173\u952e\u5b57\u540e\u8ddf assignment_list
\u6765\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u5bf9\u5e94\u7684\u503c\u3002create table names(id int PRIMARY KEY,name VARCHAR(255),age int);\n\n-- \u63d2\u5165\u4e00\u884c\u6570\u636e\uff0cid=1\uff0cname=\"Abby\"\uff0cage=24\nreplace into names(id, name, age) values(1,\"Abby\", 24);\nmysql> select name, age from names where id = 1;\n+------+------+\n| name | age |\n+------+------+\n| Abby | 24 |\n+------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Abby | 24 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- \u4f7f\u7528 replace \u8bed\u53e5\u66f4\u65b0 id=1 \u7684\u8bb0\u5f55\u7684 name \u548c age \u5217\u7684\u503c\u4e3a\"Bob\"\u548c 25\nreplace into names(id, name, age) values(1,\"Bobby\", 25);\n\nmysql> select name, age from names where id = 1;\n+-------+------+\n| name | age |\n+-------+------+\n| Bobby | 25 |\n+-------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Bobby | 25 |\n+------+-------+------+\n1 row in set (0.01 sec)\n\n-- \u4f7f\u7528 replace \u8bed\u53e5\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0cid=2\uff0cname=\"Ciro\"\uff0cage \u4e3a NULL\nreplace into names set id = 2, name = \"Ciro\";\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age |\n+------+------+\n| Ciro | NULL |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Bobby | 25 |\n| 2 | Ciro | NULL |\n+------+-------+------+\n2 rows in set (0.00 sec)\n\n-- \u4f7f\u7528 replace \u8bed\u53e5\u66f4\u65b0 id=2 \u7684\u8bb0\u5f55\u7684 name \u5217\u7684\u503c\u4e3a \"Ciro\"\uff0cage \u5217\u7684\u503c\u4e3a 17\nreplace into names set id = 2, name = \"Ciro\", age = 17;\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age |\n+------+------+\n| Ciro | 17 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Bobby | 25 |\n| 2 | Ciro | 17 |\n+------+-------+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/replace/#_5","title":"\u9650\u5236","text":"MatrixOne \u5f53\u524d\u4e0d\u652f\u6301\u4f7f\u7528 VALUES row_constructor_list
\u53c2\u6570\u63d2\u5165\u7684\u4e00\u7ec4\u503c\u6784\u6210\u7684\u884c\u3002
UPSERT
\u662f\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u7ba1\u7406\u6570\u636e\u5e93\u7684\u57fa\u672c\u529f\u80fd\u4e4b\u4e00\uff0c\u662f UPDATE
\u548c INSERT
\u7684\u7ec4\u5408\uff0c\u5b83\u5141\u8bb8\u6570\u636e\u5e93\u64cd\u4f5c\u8bed\u8a00\u5728\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u65b0\u7684\u6570\u636e\u6216\u66f4\u65b0\u5df2\u6709\u7684\u6570\u636e\u3002\u5f53 UPSERT
\u64cd\u4f5c\u7684\u662f\u4e00\u6761\u65b0\u6570\u636e\u65f6\uff0c\u4f1a\u89e6\u53d1 INSERT
\u64cd\u4f5c\uff0c\u82e5\u8bb0\u5f55\u5df2\u7ecf\u5b58\u5728\u4e8e\u8868\u4e2d\uff0c\u5219 UPSERT
\u7c7b\u4f3c\u4e8e UPDATE
\u8bed\u53e5\u3002
\u4f8b\u5982\uff0c\u6211\u4eec\u6709\u4e00\u4e2a student
\u8868\uff0cid
\u5217\u4f5c\u4e3a\u4e3b\u952e\uff1a
> desc student;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| id | INT(32) | NO | PRI | NULL | | |\n| name | VARCHAR(50) | YES | | NULL | | |\n+-------+-------------+------+------+---------+-------+---------+\n
\u5728\u66f4\u6539\u6b64\u8868\u4e2d\u7684\u5b66\u751f\u4fe1\u606f\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 upsert
\u3002\u4ece\u903b\u8f91\u4e0a\u8bb2\u662f\u8fd9\u6837\u7684\uff1a
\u5982\u679c\u8868\u4e2d\u5b58\u5728\u5b66\u751f id\uff0c\u8bf7\u4f7f\u7528\u65b0\u4fe1\u606f\u66f4\u65b0\u8be5\u884c\u3002
\u5982\u679c\u8868\u4e2d\u4e0d\u5b58\u5728\u5b66\u751f\uff0c\u8bf7\u5c06\u5176\u6dfb\u52a0\u4e3a\u65b0\u884c\u3002
\u7136\u800c\uff0cUPSERT
\u547d\u4ee4\u5728 Matrixone \u4e2d\u4e0d\u5b58\u5728\uff0c\u4f46\u4ecd\u7136\u53ef\u4ee5\u5b9e\u73b0 UPSERT
\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cMatrixone \u63d0\u4f9b\u4e86\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0 Matrixone UPSERT \u64cd\u4f5c\uff1a
INSERT IGNORE
INSERT ON DUPLICATE KEY UPDATE
REPLACE
\u5f53\u6211\u4eec\u5411\u8868\u4e2d\u63d2\u5165\u975e\u6cd5\u884c\u65f6\uff0cINSERT IGNORE
\u8bed\u53e5\u4f1a\u5ffd\u7565\u6267\u884c\u65f6\u7684 error\u3002\u6bd4\u5982\uff0c\u4e3b\u952e\u5217\u4e0d\u5141\u8bb8\u6211\u4eec\u5b58\u50a8\u91cd\u590d\u503c\u3002\u5f53\u6211\u4eec\u4f7f\u7528 INSERT \u5411\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u6570\u636e\uff0c\u800c\u8fd9\u6761\u6570\u636e\u7684\u4e3b\u952e\u5df2\u7ecf\u5728\u8868\u4e2d\u5b58\u5728\u4e86\uff0c\u6b64\u65f6 Matrixone \u670d\u52a1\u5668\u751f\u6210 error\uff0c\u8bed\u53e5\u6267\u884c\u5931\u8d25\u3002\u7136\u800c\uff0c\u5f53\u6211\u4eec\u4f7f\u7528 INSERT IGNORE
\u6765\u6267\u884c\u6b64\u8bed\u53e5\u65f6\uff0cMatrixone \u670d\u52a1\u5668\u5c06\u4e0d\u4f1a\u751f\u6210 error\u3002
\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u66f4\u65b0\u5df2\u7ecf\u5b58\u5728\u7684\u6570\u636e\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 REPLACE
\uff0c\u5f53\u6211\u4eec\u4f7f\u7528 REPLACE \u547d\u4ee4\u65f6\uff0c\u53ef\u80fd\u4f1a\u6709\u4e0b\u5217\u4e24\u79cd\u60c5\u51b5\u53d1\u751f\uff1a
\u5982\u679c\u6570\u636e\u5e93\u4e2d\u6ca1\u6709\u5bf9\u5e94\u7684\u8bb0\u5f55\uff0c\u5219\u6267\u884c\u6807\u51c6\u7684 INSERT
\u8bed\u53e5\u3002
\u5982\u679c\u6570\u636e\u5e93\u4e2d\u6709\u5bf9\u5e94\u7684\u8bb0\u5f55\uff0c\u5219 REPLACE
\u8bed\u53e5\u4f1a\u5148\u5220\u9664\u6570\u636e\u5e93\u4e2d\u7684\u5bf9\u5e94\u8bb0\u5f55\uff0c\u518d\u6267\u884c\u6807\u51c6\u7684 INSERT \u8bed\u53e5\uff08\u5f53\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\u91cd\u590d\u65f6\uff0c\u4f1a\u6267\u884c\u6b64\u66f4\u65b0\u64cd\u4f5c\uff09
\u5728 REPLACE
\u8bed\u53e5\u4e2d\uff0c\u66f4\u65b0\u6570\u636e\u5206\u4e3a\u4e24\u6b65\uff1a\u5148\u5220\u9664\u539f\u6709\u8bb0\u5f55\uff0c\u518d\u63d2\u5165\u8981\u66f4\u65b0\u7684\u8bb0\u5f55\u3002
\u76ee\u524d\u4e3a\u6b62\uff0c\u6211\u4eec\u5df2\u7ecf\u770b\u8fc7\u4e24\u79cd UPSERT
\u547d\u4ee4\u4e86\uff0c\u4f46\u5b83\u4eec\u90fd\u6709\u4e00\u4e9b\u9650\u5236\u3002INSERT ON DUPLICATE KEY IGNORE
\u53ea\u662f\u7b80\u5355\u5ffd\u7565\u4e86 duplicate error
\u3002REPLACE
\u4f1a\u68c0\u6d4b INSERT error
\uff0c\u4f46\u662f\u5b83\u5728\u6dfb\u52a0\u65b0\u6570\u636e\u524d\u4f1a\u5220\u9664\u539f\u6709\u6570\u636e\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u4ecd\u7136\u9700\u8981\u4e00\u79cd\u66f4\u597d\u7684\u89e3\u51b3\u65b9\u6848\u3002
INSERT ON DUPLICATE KEY UPDATE
\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5b83\u4e0d\u4f1a\u5220\u9664\u91cd\u590d\u7684\u884c\uff0c\u5f53\u6211\u4eec\u5728 SQL \u8bed\u53e5\u4e2d\u4f7f\u7528 ON DUPLICATE KEY UPDATE\u5b50
\u53e5\u5e76\u4e14\u6709\u4e00\u884c\u6570\u636e\u5728\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\u4e0a\u4ea7\u751f duplicate error
\u65f6\uff0c\u4f1a\u5728\u5df2\u6709\u7684\u6570\u636e\u4e0a\u505a\u66f4\u65b0\u3002
INTERSECT
\u8fd0\u7b97\u7b26\u662f\u4e00\u4e2a\u96c6\u5408\u8fd0\u7b97\u7b26\u4ec5\u8fd4\u56de\u4e24\u4e2a\u67e5\u8be2\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u4e0d\u540c\u884c\u3002
SELECT column_list FROM table_1\nINTERSECT\nSELECT column_list FROM table_2;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 intersect select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 2 | 3 |\n| 3 | 4 | 5 |\n+------+------+------+\n2 rows in set (0.01 sec)\n\nmysql> select a, b from t1 intersect select b, c from t2;\n+------+------+\n| a | b |\n+------+------+\n| 4 | 5 |\n+------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/","title":"MINUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"MINUS
\u6bd4\u8f83\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\uff0c\u5e76\u8fd4\u56de\u7b2c\u4e00\u4e2a\u67e5\u8be2\u4e2d\u4e0d\u662f\u7531\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u8f93\u51fa\u7684\u4e0d\u540c\u884c\u3002
SELECT column_list_1 FROM table_1\nMINUS\nSELECT columns_list_2 FROM table_2;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 MINUS SELECT id FROM t2;\n+------+\n| id |\n+------+\n| 1 |\n+------+\n
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 minus select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 1 | 2 |\n| 4 | 5 | 6 |\n+------+------+------+\n\nmysql> select a, b from t1 minus select b, c from t2;\n+------+------+\n| a | b |\n+------+------+\n| 3 | 4 |\n| 1 | 1 |\n| 1 | 2 |\n+------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/","title":"SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"SELECT
\u8bed\u53e5\u7528\u4e8e\u4ece\u8868\u4e2d\u68c0\u7d22\u6570\u636e\u3002
SELECT\n[ALL | DISTINCT ]\nselect_expr [, select_expr] [[AS] alias] ...\n[INTO variable [, ...]]\n[FROM table_references\n[WHERE where_condition]\n[GROUP BY {col_name | expr | position}\n[ASC | DESC]]\n[HAVING where_condition]\n[ORDER BY {col_name | expr | position}\n[ASC | DESC]] [ NULLS { FIRST | LAST } ]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n[FOR {UPDATE}]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"SELECT
\u8bed\u53e5\u4e2d\u6700\u5e38\u7528\u7684\u5b50\u53e5\u6216\u6761\u4ef6\u91ca\u4e49\u5982\u4e0b\uff1a
all
& distinct
","text":"all
\u548c distinct
\u4fee\u9970\u7b26\u6307\u5b9a\u662f\u5426\u5e94\u8fd4\u56de\u91cd\u590d\u7684\u884c\u3002all
\uff08\u9ed8\u8ba4\u503c\uff09\u6307\u5b9a\u5e94\u8fd4\u56de\u6240\u6709\u5339\u914d\u7684\u884c\uff0c\u5305\u62ec\u91cd\u590d\u884c\u3002distinct
\u6307\u5b9a\u4ece\u7ed3\u679c\u96c6\u4e2d\u5220\u9664\u91cd\u590d\u7684\u884c\u3002
select_expr
","text":"\u6bcf\u4e2a select_expr
\u8868\u8fbe\u5f0f\u8868\u793a\u4f60\u9700\u8981\u67e5\u8be2\u7684\u5217\uff0c\u5e76\u4e14\u5fc5\u987b\u81f3\u5c11\u6709\u4e00\u4e2a select_expr
\u3002
select_expr
\u5217\u8868\u5305\u542b\u6307\u793a\u8981\u67e5\u8be2\u6240\u9009\u5217\u8868\u7684\u54ea\u4e9b\u5217\u3002select_expr
\u6307\u5b9a\u5217\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 * \u6307\u5b9a\u5168\u90e8\u67e5\u8be2\u5217\uff1a
SELECT * FROM t1\n
tbl_name.*
\u53ef\u7528\u4f5c\u4ee5\u4ece\u8868\u4e2d\u9009\u62e9\u6240\u6709\u5217\uff1aSELECT t1.*, t2.* FROM t1\n
select_expr
\u53ef\u4ee5\u4f7f\u7528 AS
\u4e3a\u8868\u6307\u5b9a\u522b\u540d\u3002table_references
","text":"\u4f60\u53ef\u4ee5\u5c06\u9ed8\u8ba4\u6570\u636e\u5e93\u4e2d\u7684\u8868\u79f0\u4e3a tbl_name
\u6216 db_name.tbl_name
\uff0c\u4e3b\u8981\u7528\u4e8e\u660e\u786e\u6307\u5b9a\u6570\u636e\u5e93\u3002\u60a8\u53ef\u4ee5\u5c06\u5217\u79f0\u4e3a col_name
\u3001tbl_name.col_name
\u6216 db_name.tbl_name.col_name
\u3002\u4f60\u4e0d\u9700\u8981\u4e3a\u5217\u6307\u5b9a tbl_name
\u6216 db_name.tbl_name
\uff0c\u5982\u679c\u9700\u8981\u660e\u786e\u6307\u5b9a\uff0c\u53ef\u4ee5\u6dfb\u52a0 tbl_name
\u6216 db_name.tbl_name
\u3002
\u53ef\u4ee5\u4f7f\u7528 tbl_name AS alias_name
\u6216 tbl_name alias_name
\u4e3a\u8868\u8d77\u522b\u540d\u3002
WHERE
","text":"WHERE
\u5b50\u53e5\uff08\u5982\u679c\u7ed9\u5b9a\uff09\u6307\u793a\u8981\u9009\u62e9\u884c\u5fc5\u987b\u6ee1\u8db3\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u6761\u4ef6\u3002where_condition
\u8868\u8fbe\u5f0f\uff0c\u5bf9\u4e8e\u8981\u9009\u62e9\u7684\u6bcf\u4e00\u884c\u8ba1\u7b97\u7ed3\u679c\u4e3a\u771f\u3002\u5982\u679c\u6ca1\u6709 WHERE
\u5b50\u53e5\uff0c\u8be5\u8bed\u53e5\u5c06\u9009\u62e9\u6240\u6709\u884c\u3002
GROUP BY
","text":"\u53ef\u4ee5\u4f7f\u7528\u5217\u540d\u3001\u5217\u522b\u540d\u6216\u5217\u4f4d\u7f6e\u5728 ORDER BY
\u548c GROUP BY
\u5b50\u53e5\u4e2d\u5f15\u7528\u9009\u62e9\u7684\u5217\u3002
Note
GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\uff0c\u4e0d\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u522b\u540d\u6765\u5b9a\u4e49\u53e6\u4e00\u4e2a\u522b\u540d\u3002GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\uff0c\u9996\u5148\u4f1a\u5c1d\u8bd5\u4f7f\u7528\u5217\u540d\u8fdb\u884c\u5206\u7ec4\u6216\u6761\u4ef6\u8fc7\u6ee4\u3002\u5982\u679c\u5728\u8fd9\u4e24\u4e2a\u5b50\u53e5\u4e2d\u627e\u4e0d\u5230\u76f8\u5e94\u7684\u5217\u540d\uff0c\u90a3\u4e48\u5b83\u4eec\u4f1a\u68c0\u67e5\u662f\u5426\u6709\u522b\u540d\u4e0e\u4e4b\u5339\u914d\uff0c\u7136\u540e\u518d\u4f7f\u7528\u8fd9\u4e2a\u522b\u540d\u3002GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\u4f7f\u7528\u522b\u540d\u65f6\u5e94\u5f53\u907f\u514d\u51fa\u73b0\u5217\u5f15\u7528\u6a21\u7cca\u4e0d\u6e05\u7684\u60c5\u51b5\uff0c\u56e0\u4e3a\u5f53\u5728 GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\u4f7f\u7528\u522b\u540d\u65f6\uff0c\u5b83\u4f1a\u67e5\u627e\u4e0e\u522b\u540d\u5339\u914d\u7684\u5217\uff0c\u5982\u679c\u627e\u5230\u591a\u4e2a\u5339\u914d\u7684\u5217\uff0c\u5219\u4f1a\u4ea7\u751f\u62a5\u9519\u3002ORDER BY
\u5b50\u53e5\u9996\u5148\u4f1a\u5c1d\u8bd5\u4f7f\u7528\u522b\u540d\u6392\u5e8f\uff0c\u5982\u679c\u627e\u4e0d\u5230\u522b\u540d\uff0c\u5219\u518d\u5c1d\u8bd5\u4f7f\u7528\u5217\u540d\u8fdb\u884c\u6392\u5e8f\u3002HAVING
","text":"HAVING
\u5b50\u53e5\u4e0e WHERE
\u5b50\u53e5\u4e00\u6837\uff0c\u6307\u5b9a\u9009\u62e9\u6761\u4ef6\u3002
ORDER BY
","text":"ORDER BY
\u9ed8\u8ba4\u4e3a\u5347\u5e8f\uff1b\u53ef\u4ee5\u4f7f\u7528 ASC \u5173\u952e\u5b57\u660e\u786e\u6307\u5b9a\u3002\u8981\u4ee5\u76f8\u53cd\u7684\u987a\u5e8f\u6392\u5e8f\uff0c\u8bf7\u5c06\uff08\u964d\u5e8f\uff09\u5173\u952e\u5b57\u6dfb\u52a0\u5230\u4f60\u4f5c\u4e3a\u6392\u5e8f\u4f9d\u636e DESC \u7684\u5b50\u53e5\u4e2d\u7684\u5217\u7684\u540d\u79f0\u3002
LIMIT
","text":"LIMIT
\u5b50\u53e5\u53ef\u7528\u4e8e\u9650\u5236 SELECT
\u8bed\u53e5\u8fd4\u56de\u7684\u884c\u6570\u3002
FOR UPDATE
","text":"SELECT...FOR UPDATE
\u4e3b\u8981\u7528\u4e8e\u5728\u4e8b\u52a1\u5904\u7406\u4e2d\u9501\u5b9a\u4e00\u7ec4\u6570\u636e\u884c\uff0c\u4ee5\u9632\u6b62\u88ab\u5176\u4ed6\u5e76\u53d1\u7684\u4e8b\u52a1\u4fee\u6539\u3002\u8fd9\u4e2a\u8bed\u53e5\u6700\u5e38\u7528\u4e8e\u5904\u7406\u8bfb\u2014\u6539\u2014\u5199\u573a\u666f\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5f53\u4f60\u9700\u8981\u8bfb\u53d6\u4e00\u7ec4\u6570\u636e\uff0c\u5bf9\u5176\u8fdb\u884c\u66f4\u6539\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u5199\u56de\u6570\u636e\u5e93\uff0c\u800c\u5728\u6b64\u8fc7\u7a0b\u4e2d\u4f60\u4e0d\u5e0c\u671b\u5176\u4ed6\u4e8b\u52a1\u4fee\u6539\u8fd9\u7ec4\u6570\u636e\u3002
\u5728\u4e00\u4e2a\u4e8b\u52a1\u4e2d\u4f7f\u7528 SELECT FOR UPDATE
\u53ef\u4ee5\u9501\u5b9a\u6240\u9009\u7684\u884c\uff0c\u76f4\u5230\u4e8b\u52a1\u7ed3\u675f\uff08\u901a\u8fc7\u63d0\u4ea4\u6216\u56de\u6eda\uff09\u624d\u91ca\u653e\u9501\u3002\u8fd9\u6837\uff0c\u5176\u4ed6\u5c1d\u8bd5\u4fee\u6539\u8fd9\u4e9b\u884c\u7684\u4e8b\u52a1\u5c06\u88ab\u963b\u585e\uff0c\u76f4\u5230\u7b2c\u4e00\u4e2a\u4e8b\u52a1\u5b8c\u6210\u3002
\u53c2\u89c1\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a
START TRANSACTION;\n\nSELECT * FROM Orders\nWHERE OrderID = 1\nFOR UPDATE;\n
\u5728\u4e0a\u9762\u7684\u4e8b\u52a1\u4e2d\uff0c\u4f7f\u7528 SELECT FOR UPDATE
\u8bed\u53e5\u9009\u53d6\u4e86 Orders
\u8868\u4e2d OrderID
\u4e3a 1 \u7684\u884c\uff0c\u5e76\u4e14\u9501\u5b9a\u4e86\u8fd9\u4e00\u884c\u3002\u5728\u4e8b\u52a1\u7ed3\u675f\u524d\uff0c\u5176\u4ed6\u4e8b\u52a1\u4e0d\u80fd\u4fee\u6539\u8fd9\u4e00\u884c\u3002\u5f53\u4f60\u5b8c\u6210\u5bf9\u8fd9\u4e00\u884c\u7684\u4fee\u6539\u540e\uff0c\u53ef\u4ee5\u63d0\u4ea4\u4e8b\u52a1\u6765\u91ca\u653e\u9501\uff1a
UPDATE Orders\nSET Quantity = Quantity - 1\nWHERE OrderID = 1;\n\nCOMMIT;\n
\u4e0a\u9762\u7684 UPDATE
\u8bed\u53e5\u66f4\u6539\u4e86\u9009\u53d6\u884c\u7684 Quantity
\u503c\uff0c\u7136\u540e COMMIT
\u8bed\u53e5\u63d0\u4ea4\u4e86\u4e8b\u52a1\u5e76\u91ca\u653e\u4e86\u9501\u3002\u6b64\u65f6\uff0c\u5176\u4ed6\u88ab\u963b\u585e\u7684\u4e8b\u52a1\u5c31\u53ef\u4ee5\u7ee7\u7eed\u6267\u884c\u4e86\u3002\u5982\u679c\u4f60\u51b3\u5b9a\u4e0d\u505a\u4efb\u4f55\u66f4\u6539\uff0c\u53ef\u4ee5\u4f7f\u7528 ROLLBACK
\u8bed\u53e5\u6765\u7ed3\u675f\u4e8b\u52a1\u5e76\u91ca\u653e\u9501\u3002
create table t1 (spID int,userID int,score smallint);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\ninsert into t1 values (null,0,99);\n\nmysql> SELECT spID FROM t1;\n+------+\n| spid |\n+------+\n| 1 |\n| 2 |\n| 2 |\n| 3 |\n| 1 |\n| 4 |\n| 5 |\n| NULL |\n+------+\n\nmysql> SELECT DISTINCT spID FROM t1;\n+------+\n| spid |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n| 5 |\n| NULL |\n+------+\n\nmysql> SELECT * FROM t1 WHERE spID>2 AND userID <2 || userID >=2 OR userID < 2 LIMIT 3;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| NULL | 0 | 99 |\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n+------+--------+-------+\n\nmysql> SELECT userID,MAX(score) max_score FROM t1 WHERE userID <2 || userID > 3 GROUP BY userID ORDER BY max_score;\n+--------+-----------+\n| userid | max_score |\n+--------+-----------+\n| 1 | 5 |\n| 6 | 10 |\n| 0 | 99 |\n| 11 | 99 |\n+--------+-----------+\n\nmysql> select userID,count(score) from t1 group by userID having count(score)>1 order by userID;\n+--------+--------------+\n| userid | count(score) |\n+--------+--------------+\n| 1 | 3 |\n+--------+--------------+\n\nmysql> select userID,count(score) from t1 where userID>2 group by userID having count(score)>1 order by userID;\nEmpty set (0.01 sec)s\n\nmysql> select * from t1 order by spID asc nulls last;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 1 | 1 | 1 |\n| 1 | 1 | 5 |\n| 2 | 2 | 2 |\n| 2 | 1 | 4 |\n| 3 | 3 | 3 |\n| 4 | 6 | 10 |\n| 5 | 11 | 99 |\n| NULL | 0 | 99 |\n+------+--------+-------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#_5","title":"\u9650\u5236","text":"SELECT...FOR UPDATE
\u5f53\u524d\u4ec5\u652f\u6301\u5355\u8868\u67e5\u8be2\u3002INTO OUTFILE
\u3002\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u53ef\u4ee5\u4f7f\u7528 UNION
\uff0cINTERSECT
\u548c MINUS
\u8bed\u6cd5\u8fdb\u884c\u7ec4\u5408\u67e5\u8be2\u3002
\u793a\u4f8b\u8bed\u6cd5\u5982\u4e0b\uff1a
query1 UNION [ALL] query2\nquery1 INTERSECT [ALL] query2\nquery1 MINUS [ALL] query2\n
Tips: query1 \u548c query2 \u662f\u53ef\u4ee5\u4f7f\u7528\u5230\u76ee\u524d\u4e3a\u6b62\u8ba8\u8bba\u7684\u4efb\u4f55\u529f\u80fd\u7684\u67e5\u8be2\u3002
UNION
\u6709\u6548\u5730\u5c06 query2 \u7684\u7ed3\u679c\u5408\u5e76\u5230 query1 \u7684\u7ed3\u679c\u4e2d\uff08\u4f46\u4e0d\u80fd\u4fdd\u8bc1\u8fd9\u662f\u8fd4\u56de\u884c\u7684\u987a\u5e8f\uff09\u3002\u6b64\u5916\uff0c\u5b83\u4e0e DISTINCT
\u8bed\u6cd5\u76f8\u540c\uff0c\u5373\u4ece\u7ed3\u679c\u4e2d\u6d88\u9664\u91cd\u590d\u884c\uff1b\u4f7f\u7528\u4e86 UNION ALL
\uff0c\u5373\u4ece\u7ed3\u679c\u4e2d\u4e0d\u6d88\u9664\u91cd\u590d\u884c\u3002
INTERSECT
\u8fd4\u56de query1 \u548c query2 \u76f8\u4ea4\u7684\u7ed3\u679c\u4e2d\u7684\u6240\u6709\u884c\u3002\u4e0d\u4f7f\u7528 INTERSECT ALL
\uff0c\u5219\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\uff1b\u4f7f\u7528 INTERSECT ALL
\uff0c\u4e0d\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\u3002
MINUS
\u8fd4\u56de query1 \u7ed3\u679c\uff0c\u4f46\u4e0d\u5728 query2 \u4e2d\u7684\u6240\u6709\u884c\u3002\u5373 query1 \u548c query2 \u7684\u7ed3\u679c\u7684\u5dee\u96c6\u3002\u540c\u6837\uff0c\u4e0d\u4f7f\u7528 MINUS ALL
\uff0c\u5219\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\uff1b\u4f7f\u7528 MINUS ALL
\uff0c\u4e0d\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\u3002
\u8981\u8ba1\u7b97\u4e24\u4e2a\u67e5\u8be2\u7684\u5e76\u96c6\u3001\u4ea4\u96c6\u6216\u5dee\u96c6\uff0c\u8fd9\u4e24\u4e2a\u67e5\u8be2\u5fc5\u987b\u662f\u201c\u5e76\u96c6\u517c\u5bb9\u7684\u201d\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u8fd4\u56de\u76f8\u540c\u6570\u91cf\u7684\u5217\u5e76\u4e14\u5bf9\u5e94\u7684\u5217\u5177\u6709\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3002
UNION
\uff0cINTERSECT
\u548c MINUS
\u64cd\u4f5c\u53ef\u4ee5\u7ec4\u5408\uff0c\u4f8b\u5982\uff1a
query1 UNION query2 MINUS query3\n
\u5b83\u4e5f\u7b49\u4ef7\u4e8e\uff1a
(query1 UNION query2) MINUS query3\n
\u5982\u4e0a\u8ff0\u4ee3\u7801\u884c\u6240\u793a\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u62ec\u53f7\u6765\u63a7\u5236\u8ba1\u7b97\u987a\u5e8f\u3002\u5982\u679c\u6ca1\u6709\u62ec\u53f7\uff0cUNION
\u548c MINUS
\u4ece\u5de6\u5230\u53f3\u5173\u8054\u3002\u4f46 INTERSECT
\u6bd4\u8fd9\u4e24\u4e2a\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u66f4\u9ad8\uff0c\u56e0\u6b64\u53c2\u89c1\u4e0b\u9762\u7684\u4ee3\u7801\u884c\uff1a
query1 UNION query2 INTERSECT query3\n
\u8868\u793a\uff1a
query1 UNION (query2 INTERSECT query3)\n
\u4f60\u8fd8\u53ef\u4ee5\u7528\u62ec\u53f7\u5c06\u5355\u4e2a\u67e5\u8be2\u62ec\u8d77\u6765\u3002\u5982\u679c\u67e5\u8be2\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u793a\u4f8b\u4e2d\u7684\u5b50\u53e5\uff08\u4f8b\u5982 LIMIT
\u5b50\u53e5\uff09\uff0c\u5982\u679c\u6ca1\u6709\u62ec\u53f7\uff0c\u5c06\u4f1a\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef\uff0c\u8be5\u5b50\u53e5\u5728\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u5c06\u88ab\u7406\u89e3\u4e3a\u5e94\u7528\u4e8e\u7ec4\u5408\u64cd\u4f5c\u7684\u8f93\u51fa\u800c\u4e0d\u662f\u5176\u8f93\u5165\u4e4b\u4e00\u3002\u5982\u4e0b\u8ff0\u4f8b\u5b50\u6240\u793a\uff1a
SELECT a FROM b UNION SELECT x FROM y LIMIT 10\n
\u5b83\u53ef\u88ab\u63a5\u53d7\uff0c\u4f46\u662f\u5b83\u8868\u793a\u7684\u8ba1\u7b97\u987a\u5e8f\u5982\u4e0b\uff1a
(SELECT a FROM b UNION SELECT x FROM y) LIMIT 10\n
\u800c\u4e0d\u662f\u4e0b\u9762\u7684\u8ba1\u7b97\u987a\u5e8f\uff1a
SELECT a FROM b UNION (SELECT x FROM y LIMIT 10)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/#_1","title":"\u53c2\u8003","text":"\u5173\u4e8e UNION
\uff0cINTERSECT
\u548c MINUS
\u5355\u4e2a\u8bed\u6cd5\u7684\u6587\u6863\uff0c\u53ef\u4ee5\u53c2\u89c1\u5982\u4e0b\uff1a
UNION
\u8fd0\u7b97\u7b26\u5141\u8bb8\u60a8\u5c06\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7ed3\u679c\u96c6\u5408\u5e76\u5230\u4e00\u4e2a\u7ed3\u679c\u96c6\u4e2d\u3002
SELECT column_list\nUNION [DISTINCT | ALL]\nSELECT column_list\nUNION [DISTINCT | ALL]\nSELECT column_list ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#union-union-all","title":"UNION
\u548c UNION ALL
","text":"\u4f7f\u7528 UNION
\u8fd0\u7b97\u7b26\u7ec4\u5408\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\uff0c\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a
SELECT
\u8bed\u53e5\u4e2d\u51fa\u73b0\u7684\u5217\u7684\u6570\u91cf\u548c\u987a\u5e8f\u5fc5\u987b\u76f8\u540c\u3002\u4f7f\u7528 UNION ALL
\uff0c\u5219\u91cd\u590d\u884c\uff08\u5982\u679c\u53ef\u7528\uff09\u5c06\u4fdd\u7559\u5728\u7ed3\u679c\u4e2d\u3002\u56e0\u4e3a UNION ALL
\u4e0d\u9700\u8981\u5904\u7406\u91cd\u590d\u9879\u3002
UNION
\u4e0e ORDER BY
\uff0cLIMIT
","text":"\u4f7f\u7528 ORDER BY
\u6216 LIMIT
\u5b50\u53e5\u5bf9\u5168\u90e8 UNION \u7ed3\u679c\u8fdb\u884c\u5206\u7c7b\u6216\u9650\u5236\u65f6\uff0c\u5e94\u5bf9\u5355\u4e2a\u7684 SELECT
\u8bed\u53e5\u52a0\u5706\u62ec\u53f7\uff0c\u5e76\u628a ORDER BY
\u6216 LIMIT
\u653e\u5230\u6700\u540e\u4e00\u4e2a\u7684\u540e\u9762\u3002
\u4f8b\u5982\uff1a
(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n
\u6216\uff1a
(SELECT a FROM t1 WHERE a=10 AND B=1)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2)\nORDER BY a LIMIT 10;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 UNION SELECT id FROM t2;\n+------+\n| id |\n+------+\n| 4 |\n| 1 |\n| 2 |\n| 3 |\n+------+\n\nmysql> SELECT id FROM t1 UNION ALL SELECT id FROM t2;\n+------+\n| id |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n
drop table t1;\nCREATE TABLE t1 (a INT, b INT);\nINSERT INTO t1 VALUES ROW(4,-2),ROW(5,9),ROW(10,1),ROW(11,2),ROW(13,5);\ndrop table t2;\nCREATE TABLE t2 (a INT, b INT);\nINSERT INTO t2 VALUES ROW(1,2),ROW(3,4),ROW(11,2),ROW(10,3),ROW(15,8);\n\nmysql> (SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10) UNION (SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n+------+\n| a |\n+------+\n| 10 |\n| 11 |\n+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/","title":"WITH (Common Table Expressions)","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u516c\u5171\u8868\u8fbe\u5f0f\uff08CTE\uff0ccommon table expression\uff09\uff0c\u5b83\u662f\u5728\u5355\u4e2a\u8bed\u53e5\u7684\u6267\u884c\u8303\u56f4\u5185\u5b9a\u4e49\u7684\u4e34\u65f6\u7ed3\u679c\u96c6\uff0c\u53ea\u5728\u67e5\u8be2\u671f\u95f4\u6709\u6548\u3002\u5b83\u53ef\u4ee5\u81ea\u5f15\u7528\uff0c\u4e5f\u53ef\u5728\u540c\u4e00\u67e5\u8be2\u4e2d\u591a\u6b21\u5f15\u7528\u3002\u4f5c\u7528\u662f\u7b80\u5316\u590d\u6742\u7684\u67e5\u8be2\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u516c\u5171\u8868\u8fbe\u5f0f\u53ef\u4ee5\u88ab\u89c6\u4e3a\u4e00\u4e2a\u4e34\u65f6\u89c6\u56fe\uff0c\u53ea\u5728\u67e5\u8be2\u7684\u6267\u884c\u5468\u671f\u5185\u5b58\u5728\uff0c\u5bf9\u4e8e\u5916\u90e8\u67e5\u8be2\u662f\u4e0d\u53ef\u89c1\u7684\u3002
\u5b9a\u4e49 CTE
\u540e\uff0c\u53ef\u4ee5\u50cf SELECT
\uff0cINSERT
\uff0cUPDATE
\uff0cDELETE
\u6216 CREATE VIEW
\u8bed\u53e5\u4e00\u6837\u5f15\u7528\u5b83\u3002
\u4f7f\u7528 WITH
\u4ece\u53e5\u6307\u5b9a\u901a\u7528\u8868\u8868\u8fbe\u5f0f\uff0cWITH
\u4ece\u53e5\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u9017\u53f7\u5206\u9694\u3002\u6bcf\u4e2a\u4ece\u53e5\u63d0\u4f9b\u4e00\u4e2a\u5b50\u67e5\u8be2\uff0c\u8be5\u5b50\u67e5\u8be2\u751f\u6210\u4e00\u4e2a\u7ed3\u679c\u96c6\uff0c\u5e76\u5c06\u540d\u79f0\u4e0e\u5b50\u67e5\u8be2\u5173\u8054\u8d77\u6765\u3002
\u5e94\u7528\u573a\u666f\uff1a
\u901a\u7528\u8868\u8868\u8fbe\u5f0f\u5206\u4e3a\u975e\u9012\u5f52\u548c\u9012\u5f52\u4e24\u79cd\u7c7b\u578b\uff1a
\u975e\u9012\u5f52\u516c\u5171\u8868\u8fbe\u5f0f\uff1a\u662f\u6307 CTE \u4e2d\u4e0d\u5f15\u7528\u81ea\u8eab\u7684\u8868\u8fbe\u5f0f\uff0c\u5b83\u53ea\u7528\u4e8e\u6784\u5efa\u4e00\u6b21\u6027\u7684\u4e34\u65f6\u7ed3\u679c\u96c6\uff0c\u4e0d\u6d89\u53ca\u9012\u5f52\u64cd\u4f5c\u3002
\u9012\u5f52\u516c\u5171\u8868\u8fbe\u5f0f\uff1a\u662f\u6307 CTE \u4e2d\u5f15\u7528\u81ea\u8eab\u7684\u8868\u8fbe\u5f0f\uff0c\u7528\u4e8e\u5904\u7406\u5177\u6709\u9012\u5f52\u7ed3\u6784\u7684\u6570\u636e\uff0c\u4f8b\u5982\u6811\u5f62\u7ed3\u6784\u3001\u56fe\u5f62\u7b49\u3002\u9012\u5f52 CTE \u5728\u5b9a\u4e49\u4e2d\u5305\u542b\u4e00\u4e2a\u57fa\u672c\u67e5\u8be2\uff08\u8d77\u59cb\u6761\u4ef6\uff09\uff0c\u7136\u540e\u5728\u8be5\u57fa\u672c\u67e5\u8be2\u7684\u7ed3\u679c\u4e0a\u8fdb\u884c\u9012\u5f52\u64cd\u4f5c\uff0c\u76f4\u5230\u6ee1\u8db3\u505c\u6b62\u6761\u4ef6\u4e3a\u6b62\u3002
WITH <query_name> AS (\n <query_definition>\n)\nSELECT ... FROM <query_name>;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"<query_name>
\uff1a\u4e3a CTE \u7ed3\u679c\u96c6\u6307\u5b9a\u7684\u4e34\u65f6\u540d\u79f0\u3002\u5b83\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684\u6807\u8bc6\u7b26\uff0c\u7c7b\u4f3c\u4e8e\u8868\u540d\u6216\u5217\u540d\u3002
<query_definition>
\uff1a\u8fd9\u662f\u5b9a\u4e49 CTE \u7ed3\u679c\u96c6\u7684\u67e5\u8be2\u8bed\u53e5\u3002\u5b83\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684 SELECT
\u67e5\u8be2\uff0c\u7528\u4e8e\u521b\u5efa CTE \u7684\u7ed3\u679c\u96c6\u3002
SELECT ... FROM <query_name>
\uff1a\u8fd9\u662f\u5728 CTE \u4e0a\u6267\u884c\u7684\u67e5\u8be2\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u4f7f\u7528 CTE \u7684\u540d\u79f0\u3002
WITH RECURSIVE <query_name> AS (\n <query_definition>\n)\nSELECT ... FROM <query_name>;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_5","title":"\u53c2\u6570\u91ca\u4e49","text":"WITH RECURSIVE
\uff1a\u7528\u4e8e\u6307\u793a\u8fd9\u662f\u4e00\u4e2a\u9012\u5f52 CTE\u3002
<query_name>
\uff1a\u4e3a\u9012\u5f52 CTE \u7ed3\u679c\u96c6\u6307\u5b9a\u7684\u4e34\u65f6\u540d\u79f0\u3002\u5b83\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684\u6807\u8bc6\u7b26\uff0c\u7c7b\u4f3c\u4e8e\u8868\u540d\u6216\u5217\u540d\u3002
<query_definition>
\uff1a\u8fd9\u662f\u5b9a\u4e49\u9012\u5f52 CTE \u7ed3\u679c\u96c6\u7684\u67e5\u8be2\u8bed\u53e5\u3002\u5b83\u5305\u542b\u4e24\u90e8\u5206\uff1a
SELECT ... FROM <query_name>
\uff1a\u5728\u9012\u5f52 CTE \u4e0a\u4f7f\u7528\u9012\u5f52 CTE \u7684\u540d\u79f0\u8fdb\u884c\u67e5\u8be2\u3002
\u9012\u5f52 CTE \u5fc5\u987b\u5305\u542b\u81f3\u5c11\u4e24\u4e2a\u67e5\u8be2\u5b9a\u4e49\uff0c\u4e00\u4e2a\u662f\u951a\u5b9a\u6210\u5458\uff08anchor member\uff09\uff0c\u4e00\u4e2a\u662f\u9012\u5f52\u6210\u5458\uff08recursive member\uff09\u3002\u951a\u5b9a\u6210\u5458\u5fc5\u987b\u4f4d\u4e8e\u7b2c\u4e00\u4e2a\u9012\u5f52\u6210\u5458\u4e4b\u524d\uff0c\u53ef\u4ee5\u5b9a\u4e49\u591a\u4e2a\u951a\u5b9a\u548c\u9012\u5f52\u6210\u5458\u3002\u6240\u6709 CTE \u67e5\u8be2\u5b9a\u4e49\u90fd\u88ab\u89c6\u4e3a\u951a\u5b9a\u6210\u5458\uff0c\u9664\u975e\u5b83\u4eec\u5f15\u7528 CTE \u672c\u8eab\u3002
\u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a Employee
\u7684\u8868\uff0c\u5305\u542b\u5458\u5de5\u7684\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec EmployeeID
\u3001Name
\u548c ManagerID
\u5b57\u6bb5\uff0c\u8868\u793a\u5458\u5de5\u7684 ID\u3001\u59d3\u540d\u548c\u4e0a\u7ea7\u7ecf\u7406\u7684 ID\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u9012\u5f52 CTE \u6765\u67e5\u8be2\u5458\u5de5\u53ca\u5176\u4e0b\u5c5e\u7684\u5c42\u7ea7\u5173\u7cfb\u3002
\u5047\u8bbe\u8868\u4e2d\u7684\u6570\u636e\u5982\u4e0b\uff1a
EmployeeID Name ManagerID 1 Alice NULL 2 Bob 1 3 Charlie 1 4 David 2 5 Eve 2 6 Frank 3\u4ee5\u4e0b\u662f\u4f7f\u7528\u9012\u5f52 CTE \u6765\u67e5\u8be2\u5458\u5de5\u53ca\u5176\u4e0b\u5c5e\u7684\u5c42\u7ea7\u5173\u7cfb\u7684\u793a\u4f8b\uff1a
WITH RECURSIVE EmployeeHierarchy AS (\n-- \u951a\u5b9a\u6210\u5458\uff1a\u67e5\u627e\u9876\u5c42\u5458\u5de5\nSELECT EmployeeID, Name, ManagerID, 0 AS Level\nFROM Employee\nWHERE ManagerID IS NULL\n\nUNION ALL\n\n-- \u9012\u5f52\u6210\u5458\uff1a\u9012\u5f52\u67e5\u8be2\u4e0b\u5c5e\u5458\u5de5\nSELECT e.EmployeeID, e.Name, e.ManagerID, eh.Level + 1\nFROM Employee AS e\nJOIN EmployeeHierarchy AS eh ON e.ManagerID = eh.EmployeeID\n)\nSELECT Name, Level\nFROM EmployeeHierarchy;\n
\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff1a
ManagerID
\u4e3a NULL\uff09\u5e76\u5c06\u5176\u7ea7\u522b\uff08Level\uff09\u8bbe\u7f6e\u4e3a 0\u3002EmployeeHierarchy
\uff09\u67e5\u8be2\u4e0b\u5c5e\u5458\u5de5\uff0c\u5e76\u5c06\u7ea7\u522b\u9012\u589e\u3002SELECT
\u4ece\u9012\u5f52 CTE \u4e2d\u68c0\u7d22\u5458\u5de5\u59d3\u540d\u548c\u5c42\u7ea7\u3002\u6267\u884c\u6b64\u67e5\u8be2\u540e\uff0c\u5c06\u83b7\u5f97\u5458\u5de5\u53ca\u5176\u4e0b\u5c5e\u7684\u5c42\u7ea7\u5173\u7cfb\u4fe1\u606f\uff0c\u5176\u4e2d\u951a\u5b9a\u6210\u5458\u548c\u9012\u5f52\u6210\u5458\u5171\u540c\u6784\u6210\u4e86\u9012\u5f52\u67e5\u8be2\u7684\u7ed3\u6784\u3002\u975e\u9012\u5f52 CTE \u7528\u4e8e\u521b\u5efa\u4e34\u65f6\u7684\u67e5\u8be2\u7ed3\u679c\u96c6\uff0c\u4f60\u53ea\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a\u67e5\u8be2\u5b9a\u4e49\uff0c\u7136\u540e\u5728\u67e5\u8be2\u4e2d\u5f15\u7528\u8fd9\u4e2a CTE\uff0c\u800c\u65e0\u9700\u5173\u5fc3\u951a\u5b9a\u6210\u5458\u548c\u9012\u5f52\u6210\u5458\u7684\u95ee\u9898\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_7","title":"\u8fd0\u7b97\u7b26\u4e0e\u8bed\u53e5\u8981\u6c42","text":"\u96c6\u5408\u8fd0\u7b97\u7b26\uff1a\u951a\u5b9a\u6210\u5458\u5fc5\u987b\u4f7f\u7528\u96c6\u5408\u8fd0\u7b97\u7b26\uff08\u5982 UNION ALL
\u3001UNION
\u3001INTERSECT
\u6216 EXCEPT
\uff09\u8fdb\u884c\u7ec4\u5408\u3002\u53ea\u6709\u5728\u6700\u540e\u4e00\u4e2a\u951a\u5b9a\u6210\u5458\u4e0e\u7b2c\u4e00\u4e2a\u9012\u5f52\u6210\u5458\u4e4b\u95f4\uff0c\u4ee5\u53ca\u5728\u7ec4\u5408\u591a\u4e2a\u9012\u5f52\u6210\u5458\u65f6\uff0c\u5141\u8bb8\u4f7f\u7528 UNION ALL\u3002
\u5217\u5339\u914d\uff1a\u951a\u5b9a\u6210\u5458\u548c\u9012\u5f52\u6210\u5458\u4e2d\u7684\u5217\u6570\u91cf\u5fc5\u987b\u76f8\u540c\u3002
\u6570\u636e\u7c7b\u578b\uff1a\u9012\u5f52\u6210\u5458\u4e2d\u7684\u5217\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u4e0e\u951a\u5b9a\u6210\u5458\u4e2d\u76f8\u5e94\u5217\u7684\u6570\u636e\u7c7b\u578b\u76f8\u5339\u914d\u3002
FROM \u5b50\u53e5\uff1a\u9012\u5f52\u6210\u5458\u7684 FROM \u5b50\u53e5\u53ea\u80fd\u4e00\u6b21\u5f15\u7528 CTE expression_name\u3002
\u4e0d\u652f\u6301\u7684\u7279\u6027\uff1a\u5728\u9012\u5f52\u6210\u5458\u7684 CTE_query_definition \u4e2d\u4e0d\u5141\u8bb8\u4f7f\u7528\u67d0\u4e9b\u7279\u6027\uff0c\u5305\u62ec\uff1a
SELECT DISTINCT
\u5173\u952e\u5b57\u8fdb\u884c\u53bb\u91cd\u67e5\u8be2\u3002GROUP BY
\u5bf9\u7ed3\u679c\u8fdb\u884c\u5206\u7ec4\u3002HAVING
\u7b5b\u9009\u5206\u7ec4\u540e\u7684\u7ed3\u679c\u3002SUM
\u3001AVG
\u7b49\uff09\u5f97\u5230\u4e00\u4e2a\u5355\u4e00\u7684\u503c\u3002LEFT
\u3001RIGHT
\u3001OUTER JOIN
\u7b49\u5916\u8fde\u63a5\u64cd\u4f5c\uff08\u4f46\u662f INNER JOIN
\u662f\u5141\u8bb8\u7684\uff09\u3002CREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nsalary INT\n);\n\nINSERT INTO employees (id, name, salary) VALUES\n(1, 'Alice', 50000),\n(2, 'Bob', 60000),\n(3, 'Charlie', 75000),\n(4, 'David', 55000),\n(5, 'Eve', 80000);\n\n-- \u67e5\u627e\u5de5\u8d44\u9ad8\u4e8e\u5e73\u5747\u5de5\u8d44\u7684\u5458\u5de5\nmysql> WITH avg_salary AS (\nSELECT AVG(salary) AS avg_salary FROM employees)\nSELECT name, salary\nFROM employees\nJOIN avg_salary ON salary > avg_salary.avg_salary;\n+---------+--------+\n| name | salary |\n+---------+--------+\n| Charlie | 75000 |\n| Eve | 80000 |\n+---------+--------+\n2 rows in set (0.00 sec)\n
CREATE TABLE employees_hierarchy (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nmanager_id INT\n);\n\nINSERT INTO employees_hierarchy (id, name, manager_id) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Charlie', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3);\n\n-- \u67e5\u627e\u67d0\u4e2a\u5458\u5de5\u53ca\u5176\u6240\u6709\u4e0b\u5c5e\u5458\u5de5\nmysql> WITH RECURSIVE employee_hierarchy_cte (id, name, manager_id, level) AS (\nSELECT id, name, manager_id, 0\nFROM employees_hierarchy\nWHERE name = 'Alice'\nUNION ALL\nSELECT e.id, e.name, e.manager_id, eh.level + 1\nFROM employees_hierarchy AS e\nJOIN employee_hierarchy_cte AS eh ON e.manager_id = eh.id\n)\nSELECT name, level\nFROM employee_hierarchy_cte;\n+---------+-------+\n| name | level |\n+---------+-------+\n| Alice | 0 |\n| Bob | 1 |\n| Charlie | 1 |\n| David | 2 |\n| Eve | 2 |\n| Frank | 2 |\n+---------+-------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/","title":"FULL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"FULL JOIN
\u5173\u952e\u5b57\u53ea\u8981\u5de6\u8868\uff08table1\uff09\u548c\u53f3\u8868\uff08table2\uff09\u5176\u4e2d\u4e00\u4e2a\u8868\u4e2d\u5b58\u5728\u5339\u914d\uff0c\u5219\u8fd4\u56de\u884c\u3002
FULL JOIN
\u5173\u952e\u5b57\u7ed3\u5408\u4e86 LEFT JOIN
\u548c RIGHT JOIN
\u7684\u7ed3\u679c\u3002
\u8bf4\u660e\uff1a\u5728\u4e00\u4e9b\u6570\u636e\u5e93\u4e2d\uff1aFULL JOIN
\u7b49\u540c\u4e8e FULL OUTER JOIN
\u3002
> SELECT column_name(s)\nFROM table1\nFULL OUTER JOIN table2\nON table1.column_name=table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 full join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/","title":"INNER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"INNER JOIN
\u9009\u53d6\u4e24\u4e2a\u8868\u4e2d\u5177\u6709\u5339\u914d\u503c\u7684\u6570\u636e\u8bb0\u5f55\u3002\uff08\u7b49\u540c\u4e8e JOIN
\uff09
> SELECT column_name(s)\nFROM table1\nINNER JOIN table2\nON table1.column_name = table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/","title":"JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"JOIN
\u7528\u4e8e\u628a\u6765\u81ea\u4e24\u4e2a\u6216\u591a\u4e2a\u8868\u7684\u884c\u7ed3\u5408\u8d77\u6765\u3002
\u4e0b\u56fe\u5c55\u793a\u4e86 LEFT JOIN
\u3001RIGHT JOIN
\u3001INNER JOIN
\u3001\u548c OUTER JOIN
\u3002
LEFT JOIN
SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key\n
SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL\n
\u56fe\u793a
RIGHT JOIN
SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key\n
SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL\n
\u56fe\u793a
INNER JOIN
select_list] FROM TableA A INNER JOIN TableB B ON A.Key=B.Key\n
\u56fe\u793a
FULL JOIN
SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key\n
SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL OR B.Key IS NULL\n
\u56fe\u793a
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u8003\uff1a
LEFT JOIN
\u5173\u952e\u5b57\u4ece\u5de6\u8868\uff08table1\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\uff0c\u5373\u4f7f\u53f3\u8868\uff08table2\uff09\u4e2d\u6ca1\u6709\u5339\u914d\u3002\u5982\u679c\u53f3\u8868\u4e2d\u6ca1\u6709\u5339\u914d\uff0c\u5219\u7ed3\u679c\u4e3a NULL
\u3002
\u8bf4\u660e\uff1a\u5728\u4e00\u4e9b\u6570\u636e\u5e93\u4e2d\uff1aLEFT JOIN
\u7b49\u540c\u4e8e LEFT OUTER JOIN
\u3002
> SELECT column_name(s)\nFROM table1\nLEFT JOIN table2\nON table1.column_name=table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 left join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n| NULL | NULL | 0 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/","title":"NATURAL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NATURAL JOIN
\u76f8\u5f53\u4e8e INNER JOIN
\uff0c\u4f5c\u7528\u662f\u5c06\u4e24\u4e2a\u8868\u4e2d\u5177\u6709\u76f8\u540c\u540d\u79f0\u7684\u5217\u8fdb\u884c\u5339\u914d\u3002
> SELECT table_column1, table_column2...\nFROM table_name1\nNATURAL JOIN table_name2;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#_3","title":"\u793a\u4f8b","text":"create table t1(id int,desc1 varchar(50),desc2 varchar(50));\ncreate table t2(id int,desc3 varchar(50),desc4 varchar(50));\nINSERT INTO t1(id,desc1,desc2) VALUES(100,'desc11','desc12'),(101,'desc21','desc22'),(102,'desc31','desc32');\nINSERT INTO t2(id,desc3,desc4) VALUES(101,'desc41','desc42'),(103,'desc51','desc52'),(105,'desc61','desc62');\n\nmysql> SELECT t1.id,t2.id,desc1,desc2,desc3,desc4 FROM t1 NATURAL JOIN t2;\n+------+------+--------+--------+--------+--------+\n| id | id | desc1 | desc2 | desc3 | desc4 |\n+------+------+--------+--------+--------+--------+\n| 101 | 101 | desc21 | desc22 | desc41 | desc42 |\n+------+------+--------+--------+--------+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/","title":"OUTER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728 OUTER JOIN
\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u6216\u4e24\u4e2a\u8868\u4e2d\u7684\u4e0d\u5339\u914d\u884c\u3002OUT JOIN
\u8bf7\u53c2\u8003\uff1a
LEFT JOIN
\u5173\u952e\u5b57\u4ece\u5de6\u8868\uff08table1\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\u3002\u53c2\u89c1 LEFT JOIN.RIGHT JOIN
\u5173\u952e\u5b57\u4ece\u53f3\u8868\uff08table2\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\u3002\u53c2\u89c1 RIGHT JOIN.FULL OUTER JOIN
\u5173\u952e\u5b57\u53ea\u8981\u5de6\u8868\uff08table1\uff09\u548c\u53f3\u8868\uff08table2\uff09\u5176\u4e2d\u4e00\u4e2a\u8868\u4e2d\u5b58\u5728\u5339\u914d\uff0c\u5219\u8fd4\u56de\u884c\u3002\u53c2\u89c1 FULL JOIN.create table t1 (a1 int, a2 char(3));\ninsert into t1 values(10,'aaa'), (10,null), (10,'bbb'), (20,'zzz');\ncreate table t2(a1 char(3), a2 int, a3 real);\ninsert into t2 values('AAA', 10, 0.5);\ninsert into t2 values('BBB', 20, 1.0);\n\nmysql> select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10;\n+------+------+------+------+\n| a1 | a2 | a1 | a2 |\n+------+------+------+------+\n| 10 | aaa | AAA | 10 |\n| 10 | aaa | BBB | 20 |\n| 10 | NULL | AAA | 10 |\n| 10 | NULL | BBB | 20 |\n| 10 | bbb | AAA | 10 |\n| 10 | bbb | BBB | 20 |\n| 20 | zzz | NULL | NULL |\n+------+------+------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/","title":"RIGHT JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"RIGHT JOIN
\u5173\u952e\u5b57\u4ece\u53f3\u8868\uff08table2\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\uff0c\u5373\u4f7f\u5de6\u8868\uff08table1\uff09\u4e2d\u6ca1\u6709\u5339\u914d\u3002\u5982\u679c\u5de6\u8868\u4e2d\u6ca1\u6709\u5339\u914d\uff0c\u5219\u7ed3\u679c\u4e3a NULL
\u3002
\u8bf4\u660e\uff1a\u5728\u4e00\u4e9b\u6570\u636e\u5e93\u4e2d\uff1aRIGHT JOIN
\u7b49\u540c\u4e8e RIGHT OUTER JOIN
\u3002
> SELECT column_name(s)\nFROM table1\nRIGHT JOIN table2\nON table1.column_name=table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 right join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/","title":"\u5b50\u67e5\u8be2\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u7684\u4f7f\u7528","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#_2","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5b50\u67e5\u8be2\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u6700\u5e38\u89c1\u7684\u7528\u6cd5\u5982\u4e0b\uff1a
non_subquery_operand comparison_operator (subquery)\n
\u5176\u4e2d\uff0ccomparison_operator
\u6307\u4ee5\u4e0b\u64cd\u4f5c\u7b26\uff1a
= > < >= <= <> != <=>\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SELECT column_name(s) FROM table_name WHERE 'a' = (SELECT column1 FROM t1)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#_4","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where a = (select b from t2);\nERROR 1105 (HY000): scalar subquery returns more than 1 row\nmysql> select * from t3 where a = (select distinct b from t2);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 rows in set (0.01 sec)\n\nmysql> select a,b from t4 where a > ( select a ,b from t2 where a>1);\nERROR 1105 (HY000): Internal error: Unknow type TUPLE\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/","title":"Derived Tables","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5f53 SELECT
\u8bed\u53e5\u7684 FROM
\u4ece\u53e5\u4e2d\u4f7f\u7528\u72ec\u7acb\u5b50\u67e5\u8be2\u65f6\uff0c\u6211\u4eec\u4e5f\u7ecf\u5e38\u5c06\u5176\u79f0\u4e3a\u6d3e\u751f\u8868\uff0c\u56e0\u4e3a\u5b9e\u9645\u4e0a\u5916\u90e8\u67e5\u8be2\u5c06\u5b50\u67e5\u8be2\u7684\u7ed3\u679c\u5f53\u4f5c\u4e86\u4e00\u4e2a\u6570\u636e\u6e90\u3002
\u6bcf\u4e2a FROM \u5b50\u67e5\u8be2\u7684\u8868\u90fd\u5fc5\u987b\u8981\u6709\u4e00\u4e2a\u540d\u5b57\uff0c\u56e0\u6b64 [AS] \u64cd\u4f5c\u7b26\u662f\u5fc5\u987b\u7684\u3002\u5b50\u67e5\u8be2\u7684 SELECT \u5217\u8868\u4e2d\u6bcf\u4e2a\u5217\u4e5f\u5fc5\u987b\u8981\u6709\u4e00\u4e2a\u552f\u4e00\u7684\u540d\u5b57\u3002
> SELECT ... FROM (subquery) [AS] name ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#_3","title":"\u793a\u4f8b","text":"> CREATE TABLE tb1 (c1 INT, c2 CHAR(5), c3 FLOAT);\n> INSERT INTO tb1 VALUES (1, '1', 1.0);\n> INSERT INTO tb1 VALUES (2, '2', 2.0);\n> INSERT INTO tb1 VALUES (3, '3', 3.0);\n> select * from tb1;\n+------+------+--------+\n| c1 | c2 | c3 |\n+------+------+--------+\n| 1 | 1 | 1.0000 |\n| 2 | 2 | 2.0000 |\n| 3 | 3 | 3.0000 |\n+------+------+--------+\n3 rows in set (0.03 sec)\n\n> SELECT sc1, sc2, sc3 FROM (SELECT c1 AS sc1, c2 AS sc2, c3*3 AS sc3 FROM tb1) AS sb WHERE sc1 > 1;\n+------+------+--------+\n| sc1 | sc2 | sc3 |\n+------+------+--------+\n| 2 | 2 | 6.0000 |\n| 3 | 3 | 9.0000 |\n+------+------+--------+\n2 rows in set (0.02 sec)\n``````sql\nCREATE TABLE tb1 (c1 INT, c2 CHAR(5), c3 FLOAT);\nINSERT INTO tb1 VALUES (1, '1', 1.0);\nINSERT INTO tb1 VALUES (2, '2', 2.0);\nINSERT INTO tb1 VALUES (3, '3', 3.0);\n\nmysql> select * from tb1;\n+------+------+--------+\n| c1 | c2 | c3 |\n+------+------+--------+\n| 1 | 1 | 1.0000 |\n| 2 | 2 | 2.0000 |\n| 3 | 3 | 3.0000 |\n+------+------+--------+\n3 rows in set (0.03 sec)\n\nmysql> SELECT sc1, sc2, sc3 FROM (SELECT c1 AS sc1, c2 AS sc2, c3*3 AS sc3 FROM tb1) AS sb WHERE sc1 > 1;\n+------+------+--------+\n| sc1 | sc2 | sc3 |\n+------+------+--------+\n| 2 | 2 | 6.0000 |\n| 3 | 3 | 9.0000 |\n+------+------+--------+\n2 rows in set (0.02 sec)\n
> create table t1 (libname1 varchar(21) not null primary key, city varchar(20));\n> create table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\n> create table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\n> insert into t2 values ('001','Daffy','Aducklife');\n> insert into t2 values ('002','Bugs','Arabbitlife');\n> insert into t2 values ('003','Cowboy','Lifeontherange');\n> insert into t2 values ('000','Anonymous','Wannabuythisbook?');\n> insert into t2 values ('004','BestSeller','OneHeckuvabook');\n> insert into t2 values ('005','EveryoneBuys','Thisverybook');\n> insert into t2 values ('006','SanFran','Itisasanfranlifestyle');\n> insert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\n> insert into t3 values('000','NewYorkPublicLibra',1);\n> insert into t3 values('001','NewYorkPublicLibra',2);\n> insert into t3 values('002','NewYorkPublicLibra',3);\n> insert into t3 values('003','NewYorkPublicLibra',4);\n> insert into t3 values('004','NewYorkPublicLibra',5);\n> insert into t3 values('005','NewYorkPublicLibra',6);\n> insert into t3 values('006','SanFransiscoPublic',5);\n> insert into t3 values('007','BerkeleyPublic1',3);\n> insert into t3 values('007','BerkeleyPublic2',3);\n> insert into t3 values('001','NYC Lib',8);\n> insert into t1 values ('NewYorkPublicLibra','NewYork');\n> insert into t1 values ('SanFransiscoPublic','SanFran');\n> insert into t1 values ('BerkeleyPublic1','Berkeley');\n> insert into t1 values ('BerkeleyPublic2','Berkeley');\n> insert into t1 values ('NYCLib','NewYork');\n> select * from (select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1) sub ;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n4 rows in set (0.00 sec)\n``````sql\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values('000','NewYorkPublicLibra',1);\ninsert into t3 values('001','NewYorkPublicLibra',2);\ninsert into t3 values('002','NewYorkPublicLibra',3);\ninsert into t3 values('003','NewYorkPublicLibra',4);\ninsert into t3 values('004','NewYorkPublicLibra',5);\ninsert into t3 values('005','NewYorkPublicLibra',6);\ninsert into t3 values('006','SanFransiscoPublic',5);\ninsert into t3 values('007','BerkeleyPublic1',3);\ninsert into t3 values('007','BerkeleyPublic2',3);\ninsert into t3 values('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select * from (select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1) sub ;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/","title":"Subqueries with ALL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5173\u952e\u8bcd ALL
\u5fc5\u987b\u8ddf\u5728\u6bd4\u8f83\u64cd\u4f5c\u7b26\u540e\u9762\uff0c\u6307\u5982\u679c\u5b50\u67e5\u8be2\u8fd4\u56de\u7684\u5217\u4e2d\u503c\u7684 ALL
\u7684\u6bd4\u8f83\u662f TRUE
\uff0c\u5219\u8fd4\u56de TRUE
\u3002
operand comparison_operator ALL (subquery)\n
\u793a\u4f8b\u5982\u4e0b\uff1a
SELECT s1 FROM t1 WHERE s1 > ALL (SELECT s1 FROM t2);\n
\u5982\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5047\u8bbe\u8868 t1 \u4e2d\u6709\u4e00\u884c\u5305\u542b (10)\uff0c\u8868 t2 \u5305\u542b (-5,0\uff0c+5)\uff0c\u5219\u8868\u8fbe\u5f0f\u4e3a TRUE
\uff0c\u56e0\u4e3a 10 \u5927\u4e8e t2 \u4e2d\u7684\u6240\u6709\u4e09\u4e2a\u503c\u3002\u5982\u679c\u8868 t2 \u5305\u542b (12,6,NULL\uff0c-100)\uff0c\u5219\u8868\u8fbe\u5f0f\u4e3a FALSE
\uff0c\u56e0\u4e3a\u5728\u8868 t2 \u4e2d\u6709\u4e00\u4e2a\u5927\u4e8e 10 \u7684\u503c 12\u3002\u5982\u679c\u8868 t2 \u5305\u542b (0,NULL,1)\uff0c\u5219\u8868\u8fbe\u5f0f\u4e3a NULL
\u3002
TRUE
\u3002\u4f8b\u5982\uff0c\u5f53\u4e0b\u8868 t2 \u4e3a\u7a7a\u65f6\uff0c\u8868\u8fbe\u5f0f\u662f TRUE
\uff1aSELECT * FROM t1 WHERE 1 > ALL (SELECT s1 FROM t2);\n
NULL
\uff1aSELECT * FROM t1 WHERE 1 > (SELECT s1 FROM t2);\n
\u6216\uff1a
SELECT * FROM t1 WHERE 1 > ALL (SELECT MAX(s1) FROM t2);\n
\u8bf4\u660e\uff1a\u5728\u4e66\u5199\u5b50\u67e5\u8be2\u8bed\u6cd5\u65f6\uff0c\u8981\u6ce8\u610f\u8003\u8651\u5230\u542b\u6709 NULL
\u503c\u7684\u8868\u548c\u7a7a\u8868\u7684\u60c5\u51b5\u3002
> SELECT column_name(s) FROM table_name {WHERE | HAVING} [not] expression comparison_operator ALL (subquery)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#_3","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> all (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t4 where 5 > all (select a from t5);\n+------+------+\n| a | b |\n+------+------+\n| 4 | 8 |\n| 3 | 8 |\n| 5 | 9 |\n+------+------+\n3 rows in set (0.01 sec)\n\nmysql> select * from t3 where 10 > all (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 7 |\n| 3 |\n+------+\n3 rows in set (0.00 sec)\n\nmysql> select a,b from t6 where a > all ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/","title":"Subqueries with ANY or SOME","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u7531\u4e8e\u5217\u5b50\u67e5\u8be2\u8fd4\u56de\u7684\u7ed3\u679c\u96c6\u662f\u591a\u884c\u4e00\u5217\uff0c\u56e0\u6b64\u4e0d\u80fd\u76f4\u63a5\u4f7f\u7528\uff08=\uff0c>\uff0c<\uff0c>=\uff0c<=\uff0c<>\uff09\u8fd9\u4e9b\u6bd4\u8f83\u64cd\u4f5c\u7b26\u3002\u5728\u5217\u5b50\u67e5\u8be2\u4e2d\u53ef\u4ee5\u4f7f\u7528 ANY
\u3001SOME
\u64cd\u4f5c\u7b26\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u8054\u5408\u4f7f\u7528\uff1a
ANY
\uff1a\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u8054\u5408\u4f7f\u7528\uff0c\u8868\u793a\u4e0e\u5b50\u67e5\u8be2\u8fd4\u56de\u7684\u4efb\u4f55\u503c\u6bd4\u8f83\u4e3a TRUE
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002SOME
\uff1aANY
\u7684\u522b\u540d\uff0c\u4e0e ANY
\u610f\u4e49\u76f8\u540c\uff0c\u4f46\u8f83\u5c11\u4f7f\u7528\u3002> SELECT column_name(s) FROM table_name WHERE column_name ANY (subquery);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#_3","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> any (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a <> some (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a = some (select b from t2);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select * from t3 where a = any (select b from t2);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select a,b from t6 where a > any ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/","title":"Subqueries with EXISTS or NOT EXISTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"EXISTS
\u7528\u4e8e\u68c0\u67e5\u5b50\u67e5\u8be2\u662f\u5426\u81f3\u5c11\u4f1a\u8fd4\u56de\u4e00\u884c\u6570\u636e\u3002\u5373\u5c06\u4e3b\u67e5\u8be2\u7684\u6570\u636e\uff0c\u653e\u5230\u5b50\u67e5\u8be2\u4e2d\u505a\u6761\u4ef6\u9a8c\u8bc1\uff0c\u6839\u636e\u9a8c\u8bc1\u7ed3\u679c\uff08TRUE \u6216 FALSE\uff09\u6765\u51b3\u5b9a\u4e3b\u67e5\u8be2\u7684\u6570\u636e\u7ed3\u679c\u662f\u5426\u5f97\u4ee5\u4fdd\u7559\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u8fd4\u56de\u4efb\u4f55\u884c\uff0cEXISTS
\u5b50\u67e5\u8be2\u6761\u4ef6\u4e3a TRUE
\uff0cNOT EXISTS
\u5b50\u67e5\u8be2\u6761\u4ef6\u4e3a FALSE
\u3002
> SELECT column_name(s)\nFROM table_name\nWHERE EXISTS\n(SELECT column_name FROM table_name WHERE condition);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#_3","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where exists (select * from t2 where t2.b=t3.a);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 row in set (0.00 sec)\nmysql> select * from t3 where not exists (select * from t2 where t2.b=t3.a);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/","title":"Subqueries with IN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5b50\u67e5\u8be2\u53ef\u4ee5\u4e0e IN
\u64cd\u4f5c\u7b26\u4e00\u8d77\u4f7f\u7528\uff0c\u4f5c\u4e3a\u201c\u8868\u8fbe\u5f0f IN (\u5b50\u67e5\u8be2)\u201d\uff0c\u67e5\u8be2\u67d0\u4e2a\u8303\u56f4\u5185\u7684\u6570\u636e\u3002\u5b50\u67e5\u8be2\u5e94\u8be5\u8fd4\u56de\u5e26\u6709\u4e00\u884c\u6216\u591a\u884c\u7684\u5355\u4e2a\u5217\uff0c\u4ee5\u5f62\u6210 IN
\u64cd\u4f5c\u4f7f\u7528\u7684\u503c\u5217\u8868\u3002
\u5bf9\u591a\u8bb0\u5f55\u3001\u5355\u5217\u5b50\u67e5\u8be2\u4f7f\u7528 IN
\u5b50\u53e5\u3002\u5b50\u67e5\u8be2\u8fd4\u56de IN
\u6216 NOT IN
\u5f15\u5165\u7684\u7ed3\u679c\u540e\uff0c\u5916\u90e8\u67e5\u8be2\u4f7f\u7528\u5b83\u4eec\u8fd4\u56de\u6700\u7ec8\u7ed3\u679c\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e2d\u6709\u5339\u914d\u7684\u884c\uff0c\u5219\u7ed3\u679c\u4e3a TRUE
\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e2d\u6ca1\u6709\u5339\u914d\u7684\u884c\uff0c\u7ed3\u679c\u4e5f\u662f FALSE
\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e2d\u6240\u6709\u7684\u503c\u90fd\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
> SELECT ... FROM table_name WHERE column_name IN (subquery)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#_3","title":"\u793a\u4f8b","text":"create table t1(val varchar(10));\ninsert into t1 values ('aaa'), ('bbb'),('eee'),('mmm'),('ppp');\n\nmysql> select count(*) from t1 as w1 where w1.val in (select w2.val from t1 as w2 where w2.val like 'm%') and w1.val in (select w3.val from t1 as w3 where w3.val like 'e%');\n+----------+\n| count(*) |\n+----------+\n| 0 |\n+----------+\n1 row in set (0.01 sec)\n
create table t1 (id int not null, text varchar(20) not null default '', primary key (id));\ninsert into t1 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text11'), (12, 'text12');\n\nmysql> select * from t1 where id not in (select id from t1 where id < 8);\n+------+--------+\n| id | text |\n+------+--------+\n| 8 | text8 |\n| 9 | text9 |\n| 10 | text10 |\n| 11 | text11 |\n| 12 | text12 |\n+------+--------+\n5 rows in set (0.00 sec)\n
CREATE TABLE t1 (a int);\nCREATE TABLE t2 (a int, b int);\nCREATE TABLE t3 (b int NOT NULL);\nINSERT INTO t1 VALUES (1), (2), (3), (4);\nINSERT INTO t2 VALUES (1,10), (3,30);\n\nmysql> select * from t1 where t1.a in (SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.a=t1.a);\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10;\nEmpty set (0.01 sec)\nmysql> SELECT * FROM t1 WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10);\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n4 rows in set (0.00 sec)\n
create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select a,b from t6 where (a,b) in ( select a,b from t4 where a>3);\nEmpty set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/","title":"\u5b50\u67e5\u8be2","text":"\u5b50\u67e5\u8be2\uff0c\u4e5f\u79f0\u4e3a\u5d4c\u5957\u67e5\u8be2\u6216\u5b50\u9009\u62e9\uff0c\u662f SELECT
\u5b50\u67e5\u8be2\u8bed\u53e5\u5d4c\u5165\u5728\u53e6\u4e00\u4e2a SQL
\u67e5\u8be2\u7684\u67e5\u8be2\u65b9\u5f0f\u3002
\u53c2\u89c1\u4e0b\u9762\u7684\u5b50\u67e5\u8be2\u793a\u4f8b\uff1a
SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);\n
\u5728\u793a\u4f8b\u4e2d\uff0cSELECT * FROM t1 WHERE column1
\u662f\u5916\u90e8\u67e5\u8be2\uff08\u6216\u5916\u90e8\u8bed\u53e5\uff09\uff0c(SELECT column1 FROM t2)
\u662f\u5b50\u67e5\u8be2\u3002\u5b50\u67e5\u8be2\u8bed\u53e5\u5fc5\u987b\u5199\u5728\u62ec\u53f7\u5185\uff0c\u7136\u540e\u5d4c\u5957\u5728\u5916\u90e8\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u5d4c\u5957\u5728\u5176\u4ed6\u5b50\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u5f62\u6210\u591a\u5c42\u5d4c\u5957\u3002
\u5b50\u67e5\u8be2\u7684\u4e3b\u8981\u4f18\u70b9\uff1a
\u5b50\u67e5\u8be2\u53ef\u4ee5\u5212\u5206\u8bed\u53e5\uff0c\u63d0\u4f9b\u7ed3\u6784\u5316\u67e5\u8be2\u3002
\u5b50\u67e5\u8be2\u53ef\u66ff\u4ee3\u590d\u6742\u7684 JOIN
\u548c UNIONS
\u8bed\u53e5\u3002
\u5b50\u67e5\u8be2\u6bd4\u590d\u6742\u7684 JOIN
\u548c UNIONS
\u53ef\u8bfb\u6027\u5f3a\u3002
\u4e00\u4e2a\u5b50\u67e5\u8be2\u6709\u4ee5\u4e0b\u51e0\u7c7b\uff1a
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\uff1a
MatrixOne \u6682\u4e0d\u652f\u6301\u9009\u62e9\u591a\u5217\u8fdb\u884c\u5b50\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/","title":"KILL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"KILL
\u8bed\u53e5\u7528\u4e8e\u7ec8\u6b62\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u6216\u8fdb\u7a0b\u3002
Info
\u7ec8\u6b62\u8fdb\u7a0b\u6216\u67e5\u8be2\u53ef\u80fd\u4f1a\u5bfc\u81f4\u672a\u4fdd\u5b58\u7684\u6570\u636e\u4e22\u5931\uff1b\u7ec8\u6b62\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u53ef\u80fd\u4f1a\u5360\u7528\u7cfb\u7edf\u8d44\u6e90\uff0c\u5e76\u4e14\u53ef\u80fd\u4f1a\u5f71\u54cd\u5176\u4ed6\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> KILL [CONNECTION | QUERY] process_id;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"process_id
\u662f\u6307\u8981\u7ec8\u6b62\u7684\u8fdb\u7a0b\u6216\u67e5\u8be2\u7684\u6807\u8bc6\u7b26\u3002\u5982\u679c\u4f7f\u7528 CONNECTION
\u5173\u952e\u5b57\uff0c\u5219 process_id
\u662f\u8fde\u63a5\u6807\u8bc6\u7b26\uff0c\u800c\u5982\u679c\u4f7f\u7528 QUERY
\u5173\u952e\u5b57\uff0c\u5219 process_id
\u662f\u67e5\u8be2\u6807\u8bc6\u7b26\u3002
select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n| 1008 |\n+-----------------+\n1 row in set (0.00 sec)\n\n-- \u7ec8\u6b62\u67e5\u8be2\u8fdb\u7a0b\nmysql> kill query 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- \u7ec8\u6b62\u8fde\u63a5\u8fdb\u7a0b\nmysql> kill connection 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- \u6d4b\u8bd5\u662f\u5426\u65ad\u5f00\u4e86\u8fde\u63a5\nmysql> show databases;\nERROR 2013 (HY000): Lost connection to MySQL server during query\nNo connection. Trying to reconnect...\nConnection id: 1180\n-- \u5df2\u7ecf\u65ad\u5f00\u4e86\u8fde\u63a5\uff0c\u670d\u52a1\u53c8\u5f00\u59cb\u91cd\u65b0\u8fde\u63a5\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/","title":"USE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"USE
\u8bed\u53e5\u7528\u4e8e\u9009\u62e9\u5f53\u524d\u6570\u636e\u5e93\uff0c\u5728\u6b64\u6570\u636e\u5e93\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\u3002
> USE db_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#_3","title":"\u793a\u4f8b","text":"> USE db1;\n> SELECT COUNT(*) FROM mytable; \n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/","title":"\u901a\u8fc7 EXPLAIN ANALYZE
\u83b7\u53d6\u4fe1\u606f","text":"EXPLAIN ANALYZE
\u662f\u4e00\u4e2a\u7528\u4e8e\u67e5\u8be2\u7684\u5206\u6790\u5de5\u5177\uff0c\u5b83\u5c06\u5411\u4f60\u663e\u793a SQL \u5728\u67e5\u8be2\u4e0a\u82b1\u8d39\u7684\u65f6\u95f4\u4ee5\u53ca\u539f\u56e0\u3002\u5b83\u5c06\u8ba1\u5212\u67e5\u8be2\u3001\u68c0\u6d4b\u5b83\u5e76\u6267\u884c\u5b83\uff0c\u540c\u65f6\u8ba1\u7b97\u884c\u6570\u5e76\u6d4b\u91cf\u5728\u6267\u884c\u8ba1\u5212\u7684\u5404\u4e2a\u70b9\u82b1\u8d39\u7684\u65f6\u95f4\u3002\u6267\u884c\u5b8c\u6210\u540e\uff0cEXPLAIN ANALYZE
\u5c06\u6253\u5370\u8ba1\u5212\u548c\u6d4b\u91cf\u7ed3\u679c\uff0c\u800c\u4e0d\u662f\u67e5\u8be2\u7ed3\u679c\u3002
EXPLAIN ANALYZE
\uff0c\u5b83\u8fd0\u884c SQL \u8bed\u53e5\u4ea7\u751f EXPLAIN
\u8f93\u51fa\uff0c\u6b64\u5916\uff0c\u8fd8\u4ea7\u751f\u5176\u4ed6\u4fe1\u606f\uff0c\u4f8b\u5982\u65f6\u95f4\u548c\u57fa\u4e8e\u8fed\u4ee3\u5668\u7684\u9644\u52a0\u4fe1\u606f\uff0c\u4ee5\u53ca\u5173\u4e8e\u4f18\u5316\u5668\u7684\u9884\u671f\u4e0e\u5b9e\u9645\u6267\u884c\u7684\u5339\u914d\u60c5\u51b5\u3002
\u5bf9\u4e8e\u6bcf\u4e2a\u8fed\u4ee3\u5668\uff0c\u63d0\u4f9b\u4ee5\u4e0b\u4fe1\u606f\uff1a
\u6210\u672c\u6a21\u578b\u6ca1\u6709\u8003\u8651\u4e00\u4e9b\u8fed\u4ee3\u5668\uff0c\u56e0\u6b64\u4e0d\u5305\u62ec\u5728\u4f30\u7b97\u4e2d\u3002
\u4f30\u8ba1\u7684\u8fd4\u56de\u7684\u884c\u6570
\u8fd4\u56de\u7b2c\u4e00\u884c\u7684\u65f6\u95f4
\u6267\u884c\u6b64\u8fed\u4ee3\u5668\uff08\u4ec5\u5305\u62ec\u5b50\u8fed\u4ee3\u5668\uff0c\u4f46\u4e0d\u5305\u62ec\u7236\u8fed\u4ee3\u5668\uff09\u6240\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\u3002
\u8fed\u4ee3\u5668\u8fd4\u56de\u7684\u884c\u6570
\u5faa\u73af\u6570
\u67e5\u8be2\u6267\u884c\u4fe1\u606f\u4f7f\u7528 TREE
\u8f93\u51fa\u683c\u5f0f\u663e\u793a\uff0c\u5176\u4e2d\u8282\u70b9\u4ee3\u8868\u8fed\u4ee3\u5668\u3002EXPLAIN ANALYZE
\u59cb\u7ec8\u4f7f\u7528 TREE
\u8f93\u51fa\u683c\u5f0f\u3002
EXPLAIN ANALYZE
\u53ef\u4ee5\u4e0e SELECT
\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u4e0e\u591a\u8868 UPDATE
\u548c DELETE
\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 KILL QUERY
\u6216 CTRL-C
\u7ec8\u6b62\u6b64\u8bed\u53e5\u3002
EXPLAIN ANALYZE
\u4e0d\u80fd\u4e0e FOR CONNECTION
\u4e00\u8d77\u4f7f\u7528\u3002
\u5efa\u8868
CREATE TABLE t1 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t2 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t3 (\npk INTEGER NOT NULL PRIMARY KEY,\ni INTEGER DEFAULT NULL\n);\n
\u8868\u8f93\u51fa\u7ed3\u679c\uff1a
> mysql> EXPLAIN ANALYZE SELECT * FROM t1 JOIN t2 ON (t1.c1 = t2.c2)\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN: -> Join\n*************************** 4. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=16441bytes\n*************************** 5. row ***************************\nQUERY PLAN: Join Type: INNER\n*************************** 6. row ***************************\nQUERY PLAN: Join Cond: (t1.c1 = t2.c2)\n*************************** 7. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t1\n*************************** 8. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 9. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t2\n*************************** 10. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n10 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE i > 8\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t3\n*************************** 4. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN: Filter Cond: (t3.i > 8)\n5 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE pk > 17\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t3\n*************************** 4. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN: Filter Cond: (t3.pk > 17)\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-prepared/","title":"EXPLAIN PREPARED","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-prepared/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728 MatrixOne \u4e2d\uff0cEXPLAIN \u662f\u4e00\u4e2a\u7528\u4e8e\u83b7\u53d6 SQL \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u7684\u547d\u4ee4\uff0c\u800c PREPARE \u662f\u4e00\u4e2a\u7528\u6765\u521b\u5efa\u4e00\u4e2a\u51c6\u5907\u597d\u7684\u8bed\u53e5\uff08prepared statement\uff09\u7684\u547d\u4ee4\u3002\u5c06\u8fd9\u4e24\u4e2a\u547d\u4ee4\u4e00\u8d77\u4f7f\u7528\uff0c\u53ef\u4ee5\u5e26\u6765\u4ee5\u4e0b\u4f18\u52bf\uff1a
\u6027\u80fd\u8c03\u4f18\uff1a\u901a\u8fc7\u67e5\u770b\u6267\u884c\u8ba1\u5212\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u67e5\u8be2\u7684\u6548\u7387\uff0c\u8bc6\u522b\u6f5c\u5728\u7684\u6027\u80fd\u74f6\u9888\u3002
\u5b89\u5168\uff1a\u56e0\u4e3a PREPARE \u5206\u79bb\u4e86 SQL \u8bed\u53e5\u7684\u7ed3\u6784\u548c\u6570\u636e\uff0c\u5b83\u6709\u52a9\u4e8e\u9632\u6b62 SQL \u6ce8\u5165\u653b\u51fb\u3002
\u91cd\u7528\uff1a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u53ef\u4ee5\u88ab\u91cd\u590d\u4f7f\u7528\uff0c\u8fd9\u5728\u9700\u8981\u591a\u6b21\u6267\u884c\u76f8\u540c\u67e5\u8be2\u4f46\u4f7f\u7528\u4e0d\u540c\u53c2\u6570\u7684\u60c5\u51b5\u4e0b\u975e\u5e38\u6709\u7528\u3002
PREPARE stmt_name FROM preparable_stmt\n
EXPLAIN\n\nwhere option can be one of:\n ANALYZE [ boolean ]\n VERBOSE [ boolean ]\n (FORMAT=TEXT)\n\nFORCE EXECUTE stmt_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-prepared/#_3","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
create table t1(n1 int);\ninsert into t1 values(1);\nprepare st_t1 from 'select * from t1';\n\nmysql> explain force execute st_t1;\n+----------------------------+\n| QUERY PLAN |\n+----------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n+----------------------------+\n2 rows in set (0.01 sec)\n
\u793a\u4f8b 2
create table t2 (col1 int, col2 decimal);\ninsert into t2 values (1,2);\nprepare st from 'select * from t2 where col1 = ?';\nset @A = 1;\n\nmysql> explain force execute st using @A;\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Table Scan on db1.t2 |\n| Filter Cond: (t2.col1 = cast('1' AS INT)) |\n+---------------------------------------------------+\n3 rows in set (0.00 sec)\n\nmysql> explain verbose force execute st using @A;\n+----------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+----------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| -> Table Scan on db1.t2 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| Table: 't2' (0:'col1', 1:'col2') |\n| Filter Cond: (t2.col1 = cast('1' AS INT)) |\n+----------------------------------------------------------------------------------------+\n6 rows in set (0.00 sec)\n\nmysql> explain analyze force execute st using @A;\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| Project |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=0bytes |\n| -> Table Scan on db1.t2 |\n| Analyze: timeConsumed=0ms waitTime=0ms inputBlocks=1 inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=21bytes |\n| Filter Cond: (t2.col1 = 1) |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n5 rows in set (0.00 sec)\n\nmysql> explain analyze verbose force execute st using @A;\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=0bytes |\n| -> Table Scan on db1.t2 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| Table: 't2' (0:'col1', 1:'col2') |\n| Analyze: timeConsumed=0ms waitTime=0ms inputBlocks=1 inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=21bytes |\n| Filter Cond: (t2.col1 = 1) |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n8 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/","title":"EXPLAIN \u8f93\u51fa\u683c\u5f0f","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#_1","title":"\u8f93\u51fa\u7ed3\u6784","text":"\u8bed\u6cd5\u7ed3\u6784\u6267\u884c\u7ed3\u679c\u662f\u4e3a statement
\u9009\u62e9\u7684\u8ba1\u5212\u7684\u6587\u672c\u63cf\u8ff0\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u6267\u884c\u7edf\u8ba1\u4fe1\u606f\u8fdb\u884c\u6ce8\u91ca\u3002
\u4ee5\u4e0b\u4ee5 TPCH \u4e2d\u6570\u636e\u96c6\u7684\u67e5\u8be2\u5206\u6790\u4e3a\u4f8b\uff0c\u6f14\u793a\u8f93\u51fa\u7ed3\u6784\uff1a
explain SELECT * FROM customer WHERE c_nationkey = (SELECT n_nationkey FROM nation\nWHERE customer.c_nationkey = nation.n_nationkey AND nation.n_nationkey > 5);\n
mysql> explain SELECT * FROM customer WHERE c_nationkey = (SELECT n_nationkey FROM nation\n -> WHERE customer.c_nationkey = nation.n_nationkey AND nation.n_nationkey > 5);\n+----------------------------------------------------------------------+\n| QUERY PLAN |\n+----------------------------------------------------------------------+\n| Project |\n| -> Filter |\n| Filter Cond: (customer.c_nationkey = nation.n_nationkey) |\n| -> Join |\n| Join Type: SINGLE hashOnPK |\n| Join Cond: (customer.c_nationkey = nation.n_nationkey) |\n| -> Table Scan on tpch.customer |\n| -> Table Scan on tpch.nation |\n| Filter Cond: (nation.n_nationkey > 5) |\n| Block Filter Cond: (nation.n_nationkey > 5) |\n+----------------------------------------------------------------------+\n10 rows in set (0.01 sec)\n
EXPLAIN \u8f93\u51fa\u4e00\u4e2a\u540d\u79f0\u4e3a QUERY PLAN
\u6811\u5f62\u7ed3\u6784\uff0c\u6bcf\u4e2a\u53f6\u5b50\u8282\u70b9\u90fd\u5305\u542b\u8282\u70b9\u7c7b\u578b\u3001\u53d7\u5f71\u54cd\u7684\u5bf9\u8c61\u3002\u6211\u4eec\u73b0\u5728\u53ea\u4f7f\u7528\u8282\u70b9\u7c7b\u578b\u4fe1\u606f\u6765\u7b80\u5316\u5c55\u793a\u4e0a\u9762\u7684\u793a\u4f8b\u3002QUERY PLAN
\u6811\u5f62\u7ed3\u6784\u53ef\u4ee5\u53ef\u89c6\u5316 SQL \u67e5\u8be2\u7684\u6574\u4e2a\u8fc7\u7a0b\uff0c\u663e\u793a\u5b83\u6240\u7ecf\u8fc7\u7684\u64cd\u4f5c\u8282\u70b9\u3002
Project\n\u2514\u2500\u2500 Filter\n \u2514\u2500\u2500 Join\n \u2514\u2500\u2500 Table Scan\n \u2514\u2500\u2500 Table Scan\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#_2","title":"\u8282\u70b9\u7c7b\u578b","text":"MatrixOne \u652f\u6301\u4ee5\u4e0b\u8282\u70b9\u7c7b\u578b\u3002
\u8282\u70b9\u540d\u79f0 \u542b\u4e49 Values Scan \u5904\u7406\u503c\u7684\u626b\u63cf Table Scan \u4ece\u8868\u4e2d\u626b\u63cf\u6570\u636e External Scan \u5904\u7406\u5916\u90e8\u7684\u6570\u636e\u626b\u63cf Source Scan \u5904\u7406 source \u8868\u7684\u6570\u636e\u626b\u63cf Project \u5bf9\u6570\u636e\u8fdb\u884c\u6295\u5f71\u8fd0\u7b97 Sink \u5206\u53d1\u540c\u4e00\u4efd\u6570\u636e\u7ed9\u4e00\u4e2a / \u591a\u4e2a\u5bf9\u8c61 Sink Scan \u8bfb\u53d6\u5176\u4ed6\u5bf9\u8c61\u5206\u53d1\u8fc7\u6765\u7684\u6570\u636e Recursive Scan \u5faa\u73af CTE \u8bed\u6cd5\u4e2d\uff0c\u5904\u7406\u6bcf\u6b21\u5faa\u73af\u7ed3\u675f\u65f6\u7684\u6570\u636e\uff0c\u5224\u65ad\u662f\u5426\u5f00\u542f\u4e0b\u4e00\u8f6e\u5faa\u73af CTE Scan \u5faa\u73af CTE \u8bed\u6cd5\u4e2d\uff0c\u8bfb\u6bcf\u6b21\u5faa\u73af\u5f00\u59cb\u65f6\u7684\u6570\u636e Aggregate \u5bf9\u6570\u636e\u8fdb\u884c\u805a\u5408 Filter \u5bf9\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4 Join \u5bf9\u6570\u636e\u8fdb\u884c\u8fde\u63a5\u8fd0\u7b97 Sample SAMPLE \u91c7\u6837\u51fd\u6570\uff0c\u5bf9\u6570\u636e\u8fdb\u884c\u62bd\u6837 Sort \u5bf9\u6570\u636e\u8fdb\u884c\u6392\u5e8f Partition \u8303\u56f4\u7a97\u53e3\u4e2d\u5bf9\u6570\u636e\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u6309\u503c\u5207\u5206 Union \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u7ec4\u5408 Union All \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u7ec4\u5408\uff0c\u5305\u62ec\u91cd\u590d\u884c Window \u5bf9\u6570\u636e\u8fdb\u884c\u8303\u56f4\u7a97\u53e3\u8ba1\u7b97 Time Window \u5bf9\u6570\u636e\u8fdb\u884c\u65f6\u95f4\u7a97\u53e3\u8ba1\u7b97 Fill \u5904\u7406\u65f6\u95f4\u7a97\u53e3\u4e2d\u7684 NULL \u503c Insert \u5bf9\u6570\u636e\u8fdb\u884c\u63d2\u5165 Delete \u5bf9\u6570\u636e\u8fdb\u884c\u5220\u9664 Intersect \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u90fd\u5b58\u5728\u7684\u884c\u7ec4\u5408 Intersect All \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u90fd\u5b58\u5728\u7684\u884c\u7ec4\u5408\uff0c\u5305\u62ec\u91cd\u590d\u884c Minus \u6bd4\u8f83\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\uff0c\u8fd4\u56de\u5b58\u5728\u4e8e\u7b2c\u4e00\u4e2a\u67e5\u8be2\u800c\u5728\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u4e2d\u4e0d\u5b58\u5728\u7684\u884c Table Function \u901a\u8fc7\u8868\u51fd\u6570\u8bfb\u53d6\u6570\u636e PreInsert \u6574\u7406\u8981\u5199\u5165\u7684\u6570\u636e PreInsert UniqueKey \u6574\u7406\u8981\u5199\u5165\u5230\u552f\u4e00\u952e\u9690\u85cf\u8868\u7684\u6570\u636e PreInsert SecondaryKey \u6574\u7406\u8981\u5199\u5165\u5230\u6b21\u7ea7\u7d22\u5f15\u9690\u85cf\u8868\u7684\u6570\u636e PreDelete \u6574\u7406\u5206\u533a\u8868\u6240\u9700\u8981\u5220\u9664\u7684\u6570\u636e\u3002 On Duplicate Key \u5bf9\u91cd\u590d\u7684\u6570\u636e\u8fdb\u884c\u66f4\u65b0 Fuzzy Filter for duplicate key \u5bf9\u5199\u5165/\u66f4\u65b0\u7684\u6570\u636e\u8fdb\u884c\u53bb\u91cd Lock \u5bf9\u64cd\u4f5c\u7684\u6570\u636e\u4e0a\u9501"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#_3","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#values-scan-project","title":"VALUES Scan & Project","text":"mysql> explain select abs(-1);\n+-------------------------------+\n| QUERY PLAN |\n+-------------------------------+\n| Project |\n| -> Values Scan \"*VALUES*\" |\n+-------------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#table-scan","title":"Table Scan","text":"mysql> explain select * from customer;\n+-----------------------------------+\n| QUERY PLAN |\n+-----------------------------------+\n| Project |\n| -> Table Scan on tpch.customer |\n+-----------------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#external-scan","title":"External Scan","text":"mysql> create external table extable(n1 int)infile{\"filepath\"='yourpath/xx.csv'} ;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> explain select * from extable;\n+------------------------------------+\n| QUERY PLAN |\n+------------------------------------+\n| Project |\n| -> External Scan on db1.extable |\n+------------------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sink-lock-delete-insert-preinsert-sink-scan","title":"Sink & Lock & Delete & Insert & PreInsert & Sink Scan","text":"mysql> create table t3(n1 int);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t3 values(1);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> explain update t3 set n1=2;\n+-----------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> Lock |\n| -> Project |\n| -> Project |\n| -> Table Scan on tpch.t3 |\n| Plan 1: |\n| Delete on tpch.t3 |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n| Plan 2: |\n| Insert on tpch.t3 |\n| -> Project |\n| -> PreInsert on tpch.t3 |\n| -> Project |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n+-----------------------------------------------+\n17 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#recursive-scan-cte-scan-filter","title":"Recursive Scan & CTE Scan & Filter","text":"mysql> create table t4(n1 int,n2 int);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t4 values(1,1),(2,2),(3,3);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> explain WITH RECURSIVE t4_1(n1_1) AS (\n-> SELECT n1 FROM t4 -> UNION all\n-> SELECT n1_1 FROM t4_1 WHERE n1_1=1\n-> )\n-> SELECT * FROM t4_1;\n+---------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> Project |\n| -> Table Scan on tpch.t4 |\n| Plan 1: |\n| Sink |\n| -> Project |\n| -> Filter |\n| Filter Cond: (t4_1.n1_1 = 1), mo_check_level((t4_1.__mo_recursive_level_col < 100)) |\n| -> Recursive Scan |\n| DataSource: Plan 2 |\n| Plan 2: |\n| Sink |\n| -> CTE Scan |\n| DataSource: Plan 0, Plan 1 |\n| Plan 3: |\n| Project |\n| -> Sink Scan |\n| DataSource: Plan 2 |\n+---------------------------------------------------------------------------------------------------+\n19 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#aggregate","title":"Aggregate","text":"mysql> explain SELECT count(*) FROM NATION group by N_NAME;\n+-------------------------------------------+\n| QUERY PLAN |\n+-------------------------------------------+\n| Project |\n| -> Aggregate |\n| Group Key: nation.n_name |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on tpch.nation |\n+-------------------------------------------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#join","title":"Join","text":"mysql> create table t5(n1 int);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> insert into t5 values(1),(2),(3);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> create table t6(n1 int);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> insert into t5 values(3),(4),(5);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> explain SELECT * FROM t5 LEFT JOIN t6 ON t5.n1 = t6.n1;\n+------------------------------------+\n| QUERY PLAN |\n+------------------------------------+\n| Project |\n| -> Join |\n| Join Type: LEFT |\n| Join Cond: (t5.n1 = t6.n1) |\n| -> Table Scan on tpch.t5 |\n| -> Table Scan on tpch.t6 |\n+------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sample","title":"Sample","text":"mysql> explain SELECT SAMPLE(c_address, 90 percent) FROM customer;\n+-----------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------+\n| Project |\n| -> Sample |\n| Sample 90.00 Percent by: customer.c_address |\n| -> Table Scan on tpch.customer |\n+-----------------------------------------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sort","title":"SORT","text":"mysql> explain select * from customer order by c_custkey;\n+-----------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------+\n| Project |\n| -> Sort |\n| Sort Key: customer.c_custkey INTERNAL |\n| -> Table Scan on tpch.customer |\n+-----------------------------------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#partition-window","title":"Partition & Window","text":"mysql>CREATE TABLE t7(n1 int,n2 int);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> INSERT INTO t7 values(1,3),(2,2),(3,1);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> explain SELECT SUM(n1) OVER(PARTITION BY n2) AS sn1 FROM t7;\n+----------------------------------------------------------+\n| QUERY PLAN |\n+----------------------------------------------------------+\n| Project |\n| -> Window |\n| Window Function: sum(t7.n1); Partition By: t7.n2 |\n| -> Partition |\n| Sort Key: t7.n2 INTERNAL |\n| -> Table Scan on tpch.t7 |\n+----------------------------------------------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#time-window-fill","title":"Time window & Fill","text":"mysql> CREATE TABLE sensor_data (ts timestamp(3) primary key, temperature FLOAT);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> INSERT INTO sensor_data VALUES('2023-08-01 00:00:00', 25.0);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> INSERT INTO sensor_data VALUES('2023-08-01 00:05:00', 26.0);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> explain select _wstart, _wend from sensor_data interval(ts, 10, minute) fill(prev);\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Fill |\n| Fill Columns: |\n| Fill Mode: Prev |\n| -> Time window |\n| Sort Key: sensor_data.ts |\n| Aggregate Functions: _wstart, _wend |\n| -> Table Scan on db2.sensor_data |\n+---------------------------------------------------+\n8 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#intersect","title":"Intersect","text":"mysql> explain select * from t5 intersect select * from t6;\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Intersect |\n| -> Project |\n| -> Table Scan on tpch.t5 |\n| -> Project |\n| -> Table Scan on tpch.t6 |\n+-----------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#intersect-all","title":"Intersect All","text":"mysql> explain select * from t5 intersect all select * from t6;\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Intersect All |\n| -> Project |\n| -> Table Scan on tpch.t5 |\n| -> Project |\n| -> Table Scan on tpch.t6 |\n+-----------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#minus","title":"Minus","text":"mysql> explain select * from t5 minus select * from t6;\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Minus |\n| -> Project |\n| -> Table Scan on tpch.t5 |\n| -> Project |\n| -> Table Scan on tpch.t6 |\n+-----------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#table-function","title":"Table Function","text":"mysql> explain select * from unnest('{\"a\":1}') u;\n+-------------------------------------+\n| QUERY PLAN |\n+-------------------------------------+\n| Project |\n| -> Table Function on unnest |\n| -> Values Scan \"*VALUES*\" |\n+-------------------------------------+\n3 rows in set (0.10 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#preinsert-uniquekey-fuzzy-filter-for-duplicate-key","title":"PreInsert UniqueKey & Fuzzy Filter for duplicate key","text":"mysql> CREATE TABLE t8(n1 int,n2 int UNIQUE key);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> explain INSERT INTO t8(n2) values(1);\n+---------------------------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> PreInsert on tpch.t8 |\n| -> Project |\n| -> Project |\n| -> Values Scan \"*VALUES*\" |\n| Plan 1: |\n| Sink |\n| -> Lock |\n| -> PreInsert UniqueKey |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n| Plan 2: |\n| Insert on tpch.__mo_index_unique_018e2d16-6629-719d-82b5-036222e9658a |\n| -> Sink Scan |\n| DataSource: Plan 1 |\n| Plan 3: |\n| Fuzzy Filter for duplicate key |\n| -> Table Scan on tpch.__mo_index_unique_018e2d16-6629-719d-82b5-036222e9658a |\n| Filter Cond: (__mo_index_idx_col = 1) |\n| Block Filter Cond: (__mo_index_idx_col = 1) |\n| -> Sink Scan |\n| DataSource: Plan 1 |\n| Plan 4: |\n| Insert on tpch.t8 |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n+---------------------------------------------------------------------------------+\n27 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#preinsert-secondarykey","title":"PreInsert SecondaryKey","text":"mysql> CREATE TABLE t9 ( n1 int , n2 int, KEY key2 (n2) USING BTREE);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> explain INSERT INTO t9(n2) values(2);\n+--------------------------------------------------------------------------+\n| QUERY PLAN |\n+--------------------------------------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> PreInsert on tpch.t9 |\n| -> Project |\n| -> Project |\n| -> Values Scan \"*VALUES*\" |\n| Plan 1: |\n| Insert on tpch.__mo_index_secondary_018e2d14-6f20-7db0-babb-c1fd505fd3c5 |\n| -> Lock |\n| -> PreInsert SecondaryKey |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n| Plan 2: |\n| Insert on tpch.t9 |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n+--------------------------------------------------------------------------+\n16 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/","title":"EXPLAIN","text":"EXPLAIN \u2014 \u5c55\u793a\u4e00\u4e2a\u8bed\u53e5\u7684\u6267\u884c\u8ba1\u5212\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#_1","title":"\u8bed\u6cd5\u7ed3\u6784","text":"EXPLAIN [ ( option [, ...] ) ] statement\n\nwhere option can be one of:\n ANALYZE [ boolean ]\n VERBOSE [ boolean ]\n (FORMAT=TEXT)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#_2","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u6b64\u547d\u4ee4\u4e3b\u8981\u4f5c\u7528\u662f\u663e\u793a\u51fa MatrixOne \u8ba1\u5212\u7a0b\u5e8f\u4e3a\u63d0\u4f9b\u7684\u8bed\u53e5\u751f\u6210\u7684\u6267\u884c\u8ba1\u5212\u3002\u6267\u884c\u8ba1\u5212\u663e\u793a\u4e86\u5982\u4f55\u901a\u8fc7\u666e\u901a\u987a\u5e8f\u626b\u63cf\u3001\u7d22\u5f15\u626b\u63cf\u7b49\u65b9\u5f0f\u626b\u63cf\u8bed\u53e5\u5f15\u7528\u7684\u8868\uff0c\u5982\u679c\u5f15\u7528\u4e86\u591a\u4e2a\u8868\uff0c\u5c06\u4f7f\u7528\u4ec0\u4e48\u8fde\u63a5\u7b97\u6cd5\u5c06\u6bcf\u4e2a\u8f93\u5165\u8868\u4e2d\u6240\u9700\u7684\u884c\u805a\u96c6\u5728\u4e00\u8d77\u3002
\u663e\u793a\u7684\u6700\u5173\u952e\u90e8\u5206\u662f\u4f30\u8ba1\u8bed\u53e5\u6267\u884c\u6210\u672c\uff0c\u5373\u8ba1\u5212\u7a0b\u5e8f\u5c06\u4f30\u8ba1\u8fd0\u884c\u8bed\u53e5\u6240\u9700\u65f6\u95f4 (\u4ee5\u4efb\u610f\u4e00\u79cd\u6210\u672c\u5355\u4f4d\u8861\u91cf\uff0c\u4f46\u901a\u5e38\u662f\u901a\u8fc7\u78c1\u76d8\u9875\u83b7\u53d6)\u3002\u5b9e\u9645\u4e0a\u8fd9\u91cc\u663e\u793a\u4e86\u4e24\u4e2a\u6570\u5b57\uff1a\u8fd4\u56de\u7b2c\u4e00\u884c\u4e4b\u524d\u7684\u542f\u52a8\u6210\u672c\uff0c\u4ee5\u53ca\u8fd4\u56de\u6240\u6709\u884c\u7684\u603b\u6210\u672c\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u67e5\u8be2\u6765\u8bf4\uff0c\u603b\u6210\u672c\u662f\u6700\u91cd\u8981\u7684\uff0c\u4f46\u5728 EXISTS
\u4e2d\u7684\u5b50\u67e5\u8be2\u4e2d\uff0c\u8ba1\u5212\u7a0b\u5e8f\u4f1a\u9009\u62e9\u6700\u5c0f\u7684\u542f\u52a8\u6210\u672c\uff0c\u800c\u4e0d\u662f\u6700\u5c0f\u7684\u603b\u6210\u672c (\u56e0\u4e3a\u6267\u884c\u8005\u5728\u83b7\u5f97\u4e00\u884c\u4e4b\u540e\u5c31\u4f1a\u505c\u6b62)\u3002\u6b64\u5916\uff0c\u5982\u679c\u60a8\u4f7f\u7528 LIMIT
\u4ece\u53e5\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570\uff0c\u8ba1\u5212\u7a0b\u5e8f\u5c06\u5728\u7aef\u70b9\u6210\u672c\u4e4b\u95f4\u8fdb\u884c\u9002\u5f53\u7684\u63d2\u503c\uff0c\u4ee5\u4fbf\u4f30\u8ba1\u54ea\u4e2a\u8ba1\u5212\u771f\u6b63\u662f\u6700\u4fbf\u5b9c\u7684\u3002
ANALYZE
\u5b50\u53e5\u8bed\u6cd5\u9009\u9879\u4e3a\u8bed\u53e5\u5b9e\u9645\u6267\u884c\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u8ba1\u5212\u6267\u884c\uff0c\u7136\u540e\u5c06\u5b9e\u9645\u8fd0\u884c\u65f6\u7edf\u8ba1\u4fe1\u606f\u6dfb\u52a0\u5230\u663e\u793a\u4e2d\uff0c\u5305\u62ec\u6bcf\u4e2a\u8ba1\u5212\u8282\u70b9\u4e2d\u82b1\u8d39\u7684\u603b\u8fd0\u884c\u65f6\u95f4 (\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d) \u548c\u5b9e\u9645\u8fd4\u56de\u7684\u884c\u603b\u6570\u3002\u8fd9\u6709\u52a9\u4e8e\u4e86\u89e3\u89c4\u5212\u8005\u7684\u671f\u671b\u662f\u5426\u63a5\u8fd1\u5b9e\u9645\u3002
\u6267\u884c\u8be5\u547d\u4ee4\u5e76\u663e\u793a\u5b9e\u9645\u8fd0\u884c\u65f6\u548c\u5176\u4ed6\u7edf\u8ba1\u6570\u636e\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a FALSE
\u3002
VERBOSE
\u7528\u4f5c\u663e\u793a\u6709\u5173\u8ba1\u5212\u7684\u5176\u4ed6\u4fe1\u606f\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5305\u62ec\u8ba1\u5212\u6811\u4e2d\u6bcf\u4e2a\u8282\u70b9\u7684\u8f93\u51fa\u5217\u5217\u8868\u3001\u6a21\u5f0f\u9650\u5b9a\u8868\u548c\u51fd\u6570\u540d\u79f0\uff0c\u59cb\u7ec8\u4f7f\u7528\u8303\u56f4\u8868\u522b\u540d\u6807\u8bb0\u8868\u8fbe\u5f0f\u4e2d\u7684\u53d8\u91cf\uff0c\u5e76\u4e14\u59cb\u7ec8\u6253\u5370\u663e\u793a\u7edf\u8ba1\u4fe1\u606f\u7684\u6bcf\u4e2a\u89e6\u53d1\u5668\u7684\u540d\u79f0\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a FALSE
\u3002
FORMAT
\u7528\u4f5c\u6307\u5b9a\u8f93\u51fa\u683c\u5f0f\uff0c\u8bed\u6cd5\u4e3a explain ( format xx )
\uff0c\u6682\u53ea\u652f\u6301 TEXT
\u683c\u5f0f\u3002\u975e\u6587\u672c\u8f93\u51fa\u5305\u542b\u4e0e\u6587\u672c\u8f93\u51fa\u683c\u5f0f\u76f8\u540c\u7684\u4fe1\u606f\uff0c\u4e14\u5bb9\u6613\u88ab\u7a0b\u5e8f\u89e3\u6790\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a TEXT
\u3002
BOOLEAN
\u6307\u5b9a\u6240\u9009\u9009\u9879\u662f\u6253\u5f00\u8fd8\u662f\u5173\u95ed\u3002\u4f60\u53ef\u4ee5\u5199 TRUE
\u6765\u542f\u7528\u8be5\u9009\u9879\uff0c\u6216\u8005\u5199 FALSE
\u6765\u7981\u7528\u5b83\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a TRUE
\u3002
MatrixOne \u652f\u6301\u4efb\u4f55 SELECT
\uff0cINSERT
\uff0cUPDATE
\uff0cDELETE
\u8bed\u53e5\u6267\u884c\u8ba1\u5212\u3002
\u76ee\u524d MatrixOne \u7684 DDL \u8bed\u53e5\u652f\u6301\u7684 6 \u79cd\u5206\u533a\u7c7b\u578b\uff0c\u4e0e MySQL \u5b98\u7f51\u57fa\u672c\u4e00\u81f4\uff0c\u5177\u4f53\u5982\u4e0b\uff1a
\u5206\u533a\u952e\uff08Partition Keys\uff09\u3001\u4e3b\u952e\uff08Primary Keys\uff09\u548c\u552f\u4e00\u952e\uff08Unique Keys\uff09\u7684\u5173\u7cfb\u89c4\u5219\u53ef\u4ee5\u6982\u62ec\u4e3a\uff1a
\u5206\u533a\u8868\u7684\u5206\u533a\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u7684\u6240\u6709\u5217\u5fc5\u987b\u662f\u8be5\u8868\u53ef\u80fd\u5177\u6709\u7684\u6bcf\u4e2a\u552f\u4e00\u952e\u7684\u4e00\u90e8\u5206\u3002
Note
\u552f\u4e00\u952e\u5305\u62ec PrimaryKey \u548c Unique KEY\u3002
\u200b \u4e5f\u5c31\u662f\u8bf4\uff0c\u8868\u4e0a\u7684\u6bcf\u4e2a\u552f\u4e00\u952e\u5fc5\u987b\u4f7f\u7528\u8868\u7684\u5206\u533a\u8868\u8fbe\u5f0f\u4e2d\u7684\u6bcf\u4e00\u5217\u3002\u552f\u4e00\u952e\u4e5f\u5305\u62ec\u8868\u7684\u4e3b\u952e\uff0c\u56e0\u4e3a\u6839\u636e\u5b9a\u4e49\uff0c\u8868\u7684\u4e3b\u952e\u4e5f\u662f\u552f\u4e00\u952e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#_1","title":"\u793a\u4f8b\u8bf4\u660e","text":"\u4f8b\u5982\uff0c\u4ee5\u4e0b\u6bcf\u4e2a\u8868\u521b\u5efa\u8bed\u53e5\u90fd\u65e0\u6548\uff1a
> CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY HASH(col3)\nPARTITIONS 4;\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n
> CREATE TABLE t2 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1),\nUNIQUE KEY (col3)\n)\nPARTITION BY HASH(col1 + col3)\nPARTITIONS 4;\n\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#key-null","title":"\u5173\u4e8e KEY \u5206\u533a\u952e\u4e3a NULL","text":"KEY \u53ea\u63a5\u53d7\u96f6\u4e2a\u6216\u591a\u4e2a\u5217\u540d\u7684\u5217\u8868\u3002\u5728\u8868\u6709\u4e3b\u952e\u7684\u60c5\u51b5\u4e0b\uff0c\u7528\u4f5c\u5206\u533a\u952e\u7684\u4efb\u4f55\u5217\u5fc5\u987b\u5305\u542b\u8868\u4e3b\u952e\u7684\u4e00\u90e8\u5206\u6216\u5168\u90e8\u3002
\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u5217\u540d\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u5219\u4f7f\u7528\u8868\u7684\u4e3b\u952e\uff08\u5982\u679c\u6709\uff09\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b CREATE TABLE
\u8bed\u53e5\u5728 MySQL \u4e2d\u6709\u6548\u3002
\u5982\u679c\u6ca1\u6709\u4e3b\u952e\uff0c\u4f46\u6709 UNIQUE KEY\uff0c\u90a3\u4e48 UNIQUE KEY \u7528\u4e8e\u5206\u533a\u952e\u3002
\u200b \u4f8b\u5982\uff0c\u4ee5\u4e0b\u5efa\u8868\u8bed\u53e5\u4e2d\uff0cKEY \u5206\u533a\u5206\u533a\u952e\u4e3a NULL\uff0c\u6ca1\u6709\u5b9a\u4e49\u4e3b\u952e\uff0c\u4f46\u662f\u542b\u6709\u552f\u4e00\u952e\uff0c\u6784\u5efa\u5206\u533a\u8868\u8fbe\u5f0f\u65f6\u5219\u4f7f\u7528\u552f\u4e00\u952e\u4f5c\u4e3a\u5206\u533a\u952e\uff1a
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY KEY()\nPARTITIONS 4;\n
Note
\u5176\u4ed6\u5206\u533a\u89c4\u5219\u4e0e MySQL \u57fa\u672c\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#3-matrixone","title":"3. \u5173\u4e8e MatrixOne \u5206\u533a\u8868\u8fbe\u5f0f\u7684\u8bf4\u660e","text":"\u200b \u5728 DDL \u8bed\u53e5\u6784\u5efa\u5206\u533a\u8868\u65f6\uff0c\u4f1a\u9488\u5bf9\u6bcf\u4e00\u79cd\u5206\u533a\u5b9a\u4e49\u751f\u6210\u4e00\u4e2a\u5206\u533a\u8868\u8fbe\u5f0f\uff0c\u8be5\u5206\u533a\u8868\u8fbe\u5f0f\u53ef\u7528\u4e8e\u8ba1\u7b97\u6570\u636e\u7684\u6240\u5c5e\u7684\u5206\u533a\u3002
\u5728\u8ba1\u5212\u6784\u5efa\u9636\u6bb5\u5bf9 DDL \u8bed\u53e5\u4e2d\u7684\u5206\u533a\u4fe1\u606f\u6570\u636e\u7ed3\u6784\u4e3a plan.PartitionInfo\uff1a
type PartitionInfo struct {\nType PartitionType\nExpr *Expr\nPartitionExpression *Expr\nColumns []*Expr\nPartitionColumns []string\nPartitionNum uint64\nPartitions []*PartitionItem\nAlgorithm int64\nIsSubPartition bool\nPartitionMsg string\n}\n
\u5176\u4e2d PartitionExpression
\u5373\u4e3a\u5206\u533a\u8868\u8fbe\u5f0f\u3002\u5206\u533a\u8868\u8fbe\u5f0f\u4e3a MatrixOne \u628a\u5206\u533a\u5b50\u53e5\u8f6c\u6362\u4e3a\u4e00\u4e2a\u8868\u8fbe\u5f0f\u8fdb\u884c\u5904\u7406\u7684\u65b9\u5f0f\uff0c\u5bf9\u6bcf\u4e00\u79cd\u5206\u533a\u8868\u8fbe\u5f0f\u7684\u6784\u5efa\u65b9\u5f0f\u5982\u4e0b\uff1a
KEY \u5206\u533a\u4f1a\u6839\u636e\u5206\u533a\u952e\u548c\u5206\u533a\u6570\u91cf\uff0c\u6784\u5efa\u4e00\u4e2a\u5206\u533a\u8868\u8fbe\u5f0f\uff0c\u5206\u533a\u8868\u8fbe\u5f0f\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a\u4e00\u4e2a\u5927\u4e8e\u7b49\u4e8e 0 \u7684\u6574\u6570\uff0c\u4ee3\u8868\u5206\u533a\u5e8f\u53f7\uff0c\u4ece\u96f6\u5f00\u59cb\u4f9d\u6b21\u9012\u589e\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nPRIMARY KEY (col1, col2)\n)\nPARTITION BY KEY(col1)\nPARTITIONS 4;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#hash-partitioning","title":"HASH Partitioning","text":"\u200b \u4e0e KEY \u5206\u533a\u7c7b\u4f3c\uff0cHASH \u5206\u533a\u4f1a\u6839\u636e\u5206\u533a\u51fd\u6570\u548c\u5206\u533a\u6570\u91cf\uff0c\u6784\u5efa\u4e00\u4e2a\u5206\u533a\u8868\u8fbe\u5f0f\uff0c\u5206\u533a\u8868\u8fbe\u5f0f\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a\u4e00\u4e2a\u5927\u4e8e\u7b49\u4e8e 0 \u7684\u6574\u6570\uff0c\u4ee3\u8868\u5206\u533a\u5e8f\u53f7\uff0c\u4ece\u96f6\u5f00\u59cb\u4f9d\u6b21\u9012\u589e\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE t1 (\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n)\nPARTITION BY LINEAR HASH( YEAR(col3))\nPARTITIONS 6;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#range-partitioning","title":"RANGE Partitioning","text":"\u200bRANGE \u5206\u533a\u662f\u57fa\u4e8e\u5217\u503c\u7684\u8303\u56f4\u5c06\u8868\u7684\u6570\u636e\u5212\u5206\u5230\u4e0d\u540c\u7684\u5206\u533a\u4e2d\u7684\u4e00\u79cd\u65b9\u6cd5\u3002\u8fd9\u79cd\u5206\u533a\u7c7b\u578b\u975e\u5e38\u9002\u5408\u4e8e\u90a3\u4e9b\u53ef\u4ee5\u6839\u636e\u7279\u5b9a\u5217\u7684\u503c\u8303\u56f4\u8fdb\u884c\u5206\u6bb5\u7684\u6570\u636e\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT NOT NULL,\nstore_id INT NOT NULL\n)\nPARTITION BY RANGE (store_id) (\nPARTITION p0 VALUES LESS THAN (6),\nPARTITION p1 VALUES LESS THAN (11),\nPARTITION p2 VALUES LESS THAN (16),\nPARTITION p3 VALUES LESS THAN MAXVALUE\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#range-columns-partitioning","title":"RANGE COLUMNS partitioning","text":"\u200bRANGE COLUMNS \u5206\u533a\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u7684\u7ec4\u5408\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u6bcf\u4e2a\u5206\u533a\u5b9a\u4e49\u4e86\u4e00\u4e2a\u503c\u8303\u56f4\uff0c\u5bf9\u5e94\u4e8e\u5206\u533a\u952e\u5217\u7684\u7ec4\u5408\u503c\uff0c\u5f53\u63d2\u5165\u6570\u636e\u65f6\uff0c\u6839\u636e\u8fd9\u4e9b\u5217\u7684\u503c\u786e\u5b9a\u884c\u6240\u5c5e\u7684\u5206\u533a\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE rc (\na INT NOT NULL,\nb INT NOT NULL\n)\nPARTITION BY RANGE COLUMNS(a,b) (\nPARTITION p0 VALUES LESS THAN (10,5) COMMENT = 'Data for LESS THAN (10,5)',\nPARTITION p1 VALUES LESS THAN (20,10) COMMENT = 'Data for LESS THAN (20,10)',\nPARTITION p2 VALUES LESS THAN (50,MAXVALUE) COMMENT = 'Data for LESS THAN (50,MAXVALUE)',\nPARTITION p3 VALUES LESS THAN (65,MAXVALUE) COMMENT = 'Data for LESS THAN (65,MAXVALUE)',\nPARTITION p4 VALUES LESS THAN (MAXVALUE,MAXVALUE) COMMENT = 'Data for LESS THAN (MAXVALUE,MAXVALUE)'\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#list-partitioning","title":"LIST Partitioning","text":"\u200bLIST \u5206\u533a\u662f\u57fa\u4e8e\u5355\u4e2a\u5217\u7684\u79bb\u6563\u503c\u6765\u5212\u5206\u6570\u636e\uff0c\u6bcf\u4e2a\u5206\u533a\u5305\u542b\u4e86\u5217\u503c\u7684\u4e00\u4e2a\u7279\u5b9a\u5217\u8868\uff0c\u5f53\u63d2\u5165\u6570\u636e\u65f6\uff0c\u884c\u6839\u636e\u8be5\u5217\u7684\u503c\u88ab\u5206\u914d\u5230\u76f8\u5e94\u7684\u5206\u533a\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE client_firms (\nid INT,\nname VARCHAR(35)\n)\nPARTITION BY LIST (id) (\nPARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21),\nPARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22),\nPARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23),\nPARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24)\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#list-columns-partitioning","title":"LIST COLUMNS partitioning","text":"\u200bLIST COLUMNS \u5206\u533a\u7c7b\u4f3c\u4e8e LIST \u5206\u533a\uff0c\u4f46\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u7684\u7ec4\u5408\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u5206\u533a\u662f\u57fa\u4e8e\u5217\u503c\u7ec4\u5408\u7684\u7279\u5b9a\u5217\u8868\uff0c\u63d2\u5165\u884c\u65f6\uff0c\u6839\u636e\u8fd9\u4e9b\u5217\u7684\u7ec4\u5408\u503c\u6765\u786e\u5b9a\u5176\u5206\u533a\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE lc (\na INT NULL,\nb INT NULL\n)\nPARTITION BY LIST COLUMNS(a,b) (\nPARTITION p0 VALUES IN( (0,0), (NULL,NULL) ),\nPARTITION p1 VALUES IN( (0,1), (0,2) ),\nPARTITION p2 VALUES IN( (1,0), (2,0) )\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/","title":"DEALLOCATE PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DEALLOCATE PREPARE
\u8bed\u53e5\u7684\u4f5c\u7528\u662f\u91ca\u653e\u4f7f\u7528 PREPARE
\u751f\u6210\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u3002\u5728\u91ca\u653e\u9884\u7f16\u8bd1\u8bed\u53e5\u540e\uff0c\u518d\u6b21\u6267\u884c\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002\u82e5\u521b\u5efa\u4e86\u8fc7\u591a\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u5e76\u4e14\u6ca1\u6709\u4f7f\u7528 DEALLOCATE PREPARE
\u8bed\u53e5\u8fdb\u884c\u91ca\u653e\uff0c\u90a3\u4e48\u7cfb\u7edf\u53d8\u91cf\u4f1a\u5f3a\u5236\u6267\u884c\u9884\u7f16\u8bd1\u8bed\u53e5\u4e0a\u9650 max_prepared_stmt_count
\u63d0\u793a\u3002
{DEALLOCATE | DROP} PREPARE stmt_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk | ui | si |\n+------+------+----------------------+\n| 0 | 0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk | ui | si |\n+------+----------------------+---------------------+\n| 1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/","title":"EXECUTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"EXECUTE
\u8bed\u53e5\u7684\u4f5c\u7528\u662f\uff1a\u4f7f\u7528 PREPARE
\u51c6\u5907\u597d\u4e00\u6761\u8bed\u53e5\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 EXECUTE
\u8bed\u53e5\u5f15\u7528\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u540d\u79f0\u5e76\u6267\u884c\u3002\u5982\u679c\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u5305\u542b\u4efb\u4f55\u53c2\u6570\u6807\u8bb0\uff0c\u5219\u5fc5\u987b\u63d0\u4f9b\u4e00\u4e2a USING
\u5b50\u53e5\uff0c\u8be5\u5b50\u53e5\u5217\u51fa\u5305\u542b\u8981\u7ed1\u5b9a\u5230\u53c2\u6570\u7684\u503c\u7684\u7528\u6237\u53d8\u91cf\u3002\u53c2\u6570\u503c\u53ea\u80fd\u7531\u7528\u6237\u53d8\u91cf\u63d0\u4f9b\uff0c\u5e76\u4e14 USING
\u5b50\u53e5\u5fc5\u987b\u547d\u540d\u4e0e\u8bed\u53e5\u4e2d\u53c2\u6570\u6807\u8bb0\u7684\u6570\u91cf\u4e00\u6837\u591a\u7684\u53d8\u91cf\u3002
\u4f60\u53ef\u4ee5\u591a\u6b21\u6267\u884c\u7ed9\u5b9a\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u5c06\u4e0d\u540c\u7684\u53d8\u91cf\u4f20\u9012\u7ed9\u5b83\uff0c\u6216\u8005\u5728\u6bcf\u6b21\u6267\u884c\u4e4b\u524d\u5c06\u53d8\u91cf\u8bbe\u7f6e\u4e3a\u4e0d\u540c\u7684\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"EXECUTE stmt_name\n [USING @var_name [, @var_name] ...]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk | ui | si |\n+------+------+----------------------+\n| 0 | 0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk | ui | si |\n+------+----------------------+---------------------+\n| 1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/","title":"PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"PREPARE
\u8bed\u53e5\u51c6\u5907\u4e00\u6761 SQL \u8bed\u53e5\u5e76\u7ed9\u5b83\u5206\u914d\u4e00\u4e2a\u540d\u79f0\u3002
\u51c6\u5907\u597d\u7684\u8bed\u53e5\u7528 EXECUTE
\u6267\u884c\uff0c\u7528 DEALLOCATE PREPARE
\u91ca\u653e\u3002
SQL \u8bed\u53e5\u7684\u547d\u540d\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"PREPARE stmt_name FROM preparable_stmt\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0 preparable_stmt \u5305\u542b SQL \u8bed\u53e5\u6587\u672c\u7684\u5b57\u7b26\u4e32\u6587\u5b57\u6216\u7528\u6237\u53d8\u91cf\u3002\u6587\u672c\u5fc5\u987b\u4ee3\u8868\u5355\u4e2a\u8bed\u53e5\uff0c\u800c\u4e0d\u662f\u591a\u4e2a\u8bed\u53e5\u3002\u5728\u58f0\u660e\u4e2d\uff0c? \u5b57\u7b26\u53ef\u7528\u4f5c\u53c2\u6570\u6807\u8bb0\uff0c\u4ee5\u6307\u793a\u7a0d\u540e\u5728\u6267\u884c\u67e5\u8be2\u65f6\u5c06\u6570\u636e\u503c\u7ed1\u5b9a\u5230\u67e5\u8be2\u7684\u4f4d\u7f6e\u3002? \u5b57\u7b26\u4e0d\u5305\u542b\u5728\u5f15\u53f7\u5185\uff0c\u5373\u4f7f\u4f60\u6253\u7b97\u5c06\u5b83\u4eec\u7ed1\u5b9a\u5230\u5b57\u7b26\u4e32\u503c\u3002\u53c2\u6570\u6807\u8bb0\u53ea\u80fd\u7528\u4e8e\u5e94\u51fa\u73b0\u6570\u636e\u503c\u7684\u5730\u65b9\uff0c\u4e0d\u80fd\u7528\u4e8e SQL \u5173\u952e\u5b57\u3001\u6807\u8bc6\u7b26\u7b49\u3002 \u5982\u679c\u5df2\u5b58\u5728\u5177\u6709\u7ed9\u5b9a\u540d\u79f0\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u5219\u5728\u51c6\u5907\u65b0\u7684\u8bed\u53e5\u4e4b\u524d\u9700\u8981\u5c06\u5176\u9690\u5f0f\u91ca\u653e\u3002
\u9884\u7f16\u8bd1\u8bed\u53e5\u521b\u5efa\u65f6\u9700\u8981\u4e86\u89e3\u4ee5\u4e0b\u51e0\u70b9\uff1a
\u5728\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u521b\u5efa\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u4e0d\u53ef\u7528\u4e8e\u5176\u4ed6\u4f1a\u8bdd\u3002
\u5728\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u521b\u5efa\u7684\u51c6\u5907\u597d\u7684\u8bed\u53e5\u4e0d\u9002\u7528\u4e8e\u5176\u4ed6\u4f1a\u8bdd\u3002
\u5f53\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u65e0\u8bba\u662f\u6b63\u5e38\u8fd8\u662f\u5f02\u5e38\uff0c\u5176\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u90fd\u4e0d\u518d\u5b58\u5728\u3002\u5982\u679c\u542f\u7528\u4e86\u81ea\u52a8\u91cd\u65b0\u8fde\u63a5\uff0c\u4e5f\u4e0d\u4f1a\u901a\u77e5\u5ba2\u6237\u7aef\u8fde\u63a5\u4e22\u5931\u3002\u56e0\u6b64\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\u7981\u7528\u81ea\u52a8\u91cd\u65b0\u8fde\u63a5\u3002
\u5728\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u4e2d\u4f7f\u7528\u7684\u53c2\u6570\u9700\u8981\u518d\u9996\u6b21\u51c6\u5907\u8bed\u53e5\u65f6\u786e\u5b9a\u5176\u7c7b\u578b\uff0c\u5e76\u4e14\u5728\u4f7f\u7528 EXECUTE
\u8fd0\u884c\u9884\u7f16\u8bd1\u8bed\u53e5\u65f6\u4fdd\u7559\u53c2\u6570\u7c7b\u578b\u3002\u4ee5\u4e0b\u5185\u5bb9\u5217\u51fa\u4e86\u786e\u5b9a\u53c2\u6570\u7c7b\u578b\u7684\u89c4\u5219\uff1a
\u4e8c\u5143\u7b97\u672f\u8fd0\u7b97\u7b26\u7684\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u53c2\u6570\u6570\u636e\u7c7b\u578b\u9700\u4e00\u81f4\u3002
\u5982\u679c\u4e8c\u5143\u7b97\u672f\u8fd0\u7b97\u7b26\u7684\u4e24\u4e2a\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u7531\u8fd0\u7b97\u7b26\u7684\u4e0a\u4e0b\u6587\u51b3\u5b9a\u3002
\u5982\u679c\u4e00\u5143\u7b97\u672f\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u7531\u8fd0\u7b97\u7b26\u7684\u4e0a\u4e0b\u6587\u51b3\u5b9a\u3002
\u5982\u679c\u7b97\u672f\u8fd0\u7b97\u7b26\u6ca1\u6709\u4e0a\u4e0b\u6587\u6765\u786e\u5b9a\u64cd\u4f5c\u6570\u53c2\u6570\u7c7b\u578b\uff0c\u5219\u76f8\u5173\u53c2\u6570\u7684\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f DOUBLE PRECISION
\u3002\u4f8b\u5982\uff0c\u5f53\u53c2\u6570\u662f SELECT
\u5217\u8868\u4e2d\u7684\u9876\u7ea7\u8282\u70b9\uff0c\u6216\u8005\u5f53\u5b83\u662f\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u4e00\u90e8\u5206\u65f6\uff0c\u90a3\u4e48\u5b83\u76f8\u5173\u53c2\u6570\u7684\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f DOUBLE PRECISION
\u3002
\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\u5177\u6709\u4e0e\u5176\u4ed6\u64cd\u4f5c\u6570\u7684\u805a\u5408\u7c7b\u578b\u76f8\u540c\u7684\u6d3e\u751f\u7c7b\u578b\u3002\u5982\u679c\u8fd0\u7b97\u7b26\u7684\u6240\u6709\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u5219\u6d3e\u751f\u7c7b\u578b\u4e3a VARCHAR
\uff0c\u5176\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u51b3\u5b9a\u3002
\u53c2\u6570\u4e3a\u65f6\u95f4\u64cd\u4f5c\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\uff0c\u5982\u679c\u64cd\u4f5c\u7b26\u8fd4\u56de DATETIME
\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u4e3a DATETIME
\uff1b\u5982\u679c\u64cd\u4f5c\u7b26\u8fd4\u56de TIME
\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u4e3a TIME
\uff1b\u5982\u679c\u64cd\u4f5c\u7b26\u8fd4\u56de DATE
\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u4e3a DATE
\u3002
\u4e8c\u5143\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u4e24\u4e2a\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e00\u81f4\u3002
\u53c2\u6570\u4e3a\u4e09\u5143\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\uff0c\u4f8b\u5982 BETWEEN
\u8fd0\u7b97\u4e2d\u7684\u53c2\u6570\uff0c\u5b83\u4eec\u7684\u6d3e\u751f\u7c7b\u578b\u4e0e\u5176\u4ed6\u64cd\u4f5c\u6570\u7684\u805a\u5408\u7c7b\u578b\u76f8\u540c\u3002
\u5982\u679c\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u6240\u6709\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u90a3\u4e48\u6bcf\u4e2a\u64cd\u4f5c\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f VARCHAR
\uff0c\u4ed6\u4eec\u7684\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u786e\u5b9a\u3002
CASE
\u3001COALESCE
\u3001IF
\u3001IFNULL
\u6216 NULLIF
\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u8f93\u51fa\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\uff0c\u5176\u6d3e\u751f\u7c7b\u578b\u4e0e\u64cd\u4f5c\u7b26\u7684\u5176\u4ed6\u8f93\u51fa\u64cd\u4f5c\u6570\u7684\u805a\u5408\u7c7b\u578b\u76f8\u540c\u3002
\u5982\u679c CASE
\u3001COALESCE
\u3001IF
\u3001IFNULL
\u6216 NULLIF
\u7684\u6240\u6709\u8f93\u51fa\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u6216\u8005\u5b83\u4eec\u90fd\u662f NULL
\uff0c\u5219\u53c2\u6570\u7684\u7c7b\u578b\u7531\u64cd\u4f5c\u7b26\u7684\u4e0a\u4e0b\u6587\u51b3\u5b9a\u3002
\u2014 \u5982\u679c\u53c2\u6570\u662f CASE
\u3001COALESCE()
\u3001IF
\u6216 IFNULL
\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u64cd\u4f5c\u6570\uff0c\u5e76\u4e14\u64cd\u4f5c\u7b26\u4e0a\u4e0b\u6587\u4e0d\u80fd\u786e\u5b9a\u5176\u53c2\u6570\u7c7b\u578b\uff0c\u5219\u6bcf\u4e2a\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f VARCHAR
\uff0c\u5176\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u51b3\u5b9a\u3002
\u2014 CAST()
\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\u4e0e CAST()
\u6307\u5b9a\u7684\u7c7b\u578b\u76f8\u540c\u3002
\u2014 \u5982\u679c\u4e00\u4e2a\u5f62\u5f0f\u53c2\u6570\u662f SELECT
\u5217\u8868\u7684\u76f4\u63a5\u6210\u5458\uff0c\u800c\u4e0d\u662f INSERT
\u8bed\u53e5\u7684\u4e00\u90e8\u5206\uff0c\u5219\u5f62\u5f0f\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a VARCHAR
\uff0c\u5176\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u51b3\u5b9a\u3002
\u2014 \u5982\u679c\u5f62\u5f0f\u53c2\u6570\u662f INSERT
\u8bed\u53e5\u7684\u4e00\u90e8\u5206 SELECT
\u5217\u8868\u7684\u76f4\u63a5\u6210\u5458\uff0c\u5219\u5f62\u5f0f\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a\u63d2\u5165\u5f62\u5f0f\u53c2\u6570\u7684\u5bf9\u5e94\u5217\u7684\u7c7b\u578b\u3002
\u5982\u679c\u4e00\u4e2a\u5f62\u5f0f\u53c2\u6570\u88ab\u7528\u4f5c UPDATE
\u8bed\u53e5\u7684 SET
\u5b50\u53e5\u6216 INSERT
\u8bed\u53e5\u7684 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u4e2d\u7684\u8d4b\u503c\u6e90\uff0c\u5f62\u5f0f\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u662f\u7531 SET
\u6216 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u66f4\u65b0\u7684\u5bf9\u5e94\u5217\u7684\u7c7b\u578b\u3002
\u5982\u679c\u5f62\u5f0f\u53c2\u6570\u662f\u51fd\u6570\u7684\u5b9e\u9645\u53c2\u6570\uff0c\u5219\u5176\u6d3e\u751f\u7c7b\u578b\u53d6\u51b3\u4e8e\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u3002
\u5bf9\u4e8e\u5b9e\u9645\u7c7b\u578b\u548c\u6d3e\u751f\u7c7b\u578b\u7684\u67d0\u4e9b\u7ec4\u5408\uff0c\u4f1a\u89e6\u53d1\u81ea\u52a8\u91cd\u65b0\u51c6\u5907\u9884\u7f16\u8bd1\u8bed\u53e5\u3002\u4ee5\u4e0b\u60c5\u51b5\uff0c\u65e0\u9700\u91cd\u65b0\u51c6\u5907\u9884\u7f16\u8bd1\u8bed\u53e5\uff1a
NULL
\u4e3a\u5b9e\u9645\u53c2\u6570\u3002
\u5f62\u5f0f\u53c2\u6570\u662f CAST()
\u7684\u64cd\u4f5c\u6570\u3002(CAST()
\u4f1a\u5c1d\u8bd5\u5c06\u53c2\u6570\u8f6c\u6362\u5230\u6d3e\u751f\u7c7b\u578b\uff0c\u5982\u679c\u8f6c\u6362\u5931\u8d25\u5219\u4f1a\u5f15\u53d1\u5f02\u5e38\u3002)
\u53c2\u6570\u7c7b\u578b\u4e3a\u5b57\u7b26\u4e32\u3002(\u5728\u672c\u4f8b\u4e2d\uff0c\u9690\u5f0f\u6267\u884c CAST(? AS derived_type)
)\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u548c\u5b9e\u9645\u7c7b\u578b\u5747\u4e3a INTEGER
\uff0c\u4e14\u5177\u6709\u76f8\u540c\u7684\u7b26\u53f7\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a DECIMAL
\uff0c\u5b9e\u9645\u7c7b\u578b\u4e3a DECIMAL
\u6216 INTEGER
\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a DOUBLE
\uff0c\u5b9e\u9645\u7c7b\u578b\u4e3a\u4efb\u610f\u6570\u5b57\u7c7b\u578b\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u548c\u5b9e\u9645\u7c7b\u578b\u90fd\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\u3002
\u53c2\u6570\u6d3e\u751f\u7c7b\u578b\u662f\u65f6\u6001\u7c7b\u578b\uff0c\u5b9e\u9645\u7c7b\u578b\u662f\u65f6\u6001\u7c7b\u578b\u3002\u5f02\u5e38\u60c5\u51b5\uff1a\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u662f TIME
\uff0c\u800c\u5b9e\u9645\u7c7b\u578b\u4e0d\u662f TIME
\uff1b\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u662f DATE
\uff0c\u800c\u5b9e\u9645\u7c7b\u578b\u4e0d\u662f DATE
\u3002
\u6d3e\u751f\u7c7b\u578b\u662f\u65f6\u95f4\u7c7b\u578b\uff0c\u5b9e\u9645\u7c7b\u578b\u662f\u6570\u5b57\u7c7b\u578b\u3002
\u9664\u4e0a\u8ff0\u60c5\u51b5\u4ee5\u5916\uff0c\u9700\u8981\u91cd\u65b0\u51c6\u5907\u9884\u7f16\u8bd1\u8bed\u53e5\u5e76\u4f7f\u7528\u5b9e\u9645\u53c2\u6570\u7c7b\u578b\uff0c\u4e0d\u80fd\u4f7f\u7528\u6d3e\u751f\u53c2\u6570\u7c7b\u578b\u3002
\u8fd9\u4e9b\u89c4\u5219\u4e5f\u9002\u7528\u4e8e\u5728\u9884\u7f16\u8bd1\u8bed\u53e5\u4e2d\u5f15\u7528\u7684\u7528\u6237\u53d8\u91cf\u3002
\u5728\u9884\u7f16\u8bd1\u8bed\u53e5\u4e2d\u4e3a\u7ed9\u5b9a\u53c2\u6570\u6216\u7528\u6237\u53d8\u91cf\u65f6\uff0c\u5982\u679c\u5728\u7b2c\u4e00\u6b21\u6267\u884c\u65f6\u4f7f\u7528\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5219\u4f1a\u5bfc\u81f4\u91cd\u65b0\u51c6\u5907\u8be5\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u4e0d\u4f46\u8fd0\u884c\u6548\u7387\u4f4e\uff0c\u800c\u4e14\u8fd8\u53ef\u80fd\u5bfc\u81f4\u53c2\u6570\uff08\u6216\u53d8\u91cf\uff09\u7684\u5b9e\u9645\u7c7b\u578b\u53d1\u751f\u53d8\u5316\uff0c\u5b9e\u9645\u6267\u884c\u7ed3\u679c\u4e0e\u8bed\u53e5\u7684\u9884\u671f\u7ed3\u679c\u4e0d\u4e00\u81f4\u3002\u5efa\u8bae\u5728\u9884\u7f16\u8bd1\u8bed\u53e5\u4e2d\u5bf9\u7ed9\u5b9a\u53c2\u6570\u4f7f\u7528\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_4","title":"\u793a\u4f8b","text":"> create table t13 (a int primary key);\n> insert into t13 values (1);\n> select * from t13 where 3 in (select (1+1) union select 1);\nEmpty set (0.01 sec)\n\n> select * from t13 where 3 in (select (1+2) union select 1);\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n\n> prepare st_18492 from 'select * from t13 where 3 in (select (1+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18492;\nEmpty set (0.01 sec)\n\n> prepare st_18493 from 'select * from t13 where 3 in (select (2+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18493;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n\n> deallocate prepare st_18492;\nQuery OK, 0 rows affected (0.00 sec)\n\n> deallocate prepare st_18493;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/","title":"SHOW ACCOUNTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5217\u51fa\u4e3a\u4f60\u7684\u8d26\u6237\u4e0b\u521b\u5efa\u7684\u79df\u6237\u7528\u6237\u7684\u5143\u4fe1\u606f\u548c\u7edf\u8ba1\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SHOW ACCOUNTS;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_3","title":"\u79df\u6237\u7528\u6237\u4fe1\u606f\u8be6\u60c5","text":"\u5217\u540d \u4fe1\u606f \u7c7b\u578b \u6570\u636e\u6e90\u5934 ACCOUNT_NAME \u79df\u6237\u540d\u79f0 varchar mo_account ADMIN_NAME \u521b\u5efa\u65f6\u9ed8\u8ba4\u8d85\u7ea7\u7ba1\u7406\u5458\u540d\u79f0 varchar \u6bcf\u4e2a\u79df\u6237\u4e0b\u7684 mo_user \u8868\u4e2d CREATED \u521b\u5efa\u65f6\u95f4 timestamp mo_account STATUS \u5f53\u524d\u72b6\u6001\uff0cOPEN \u6216 SUSPENDED varchar mo_account SUSPENDED_TIME \u505c\u7528\u65f6\u95f4 timestamp mo_account DB_COUNT \u6570\u636e\u5e93\u6570\u91cf bigint unsigned mo_tables TABLE_COUNT \u8868\u6570\u91cf bigint unsigned mo_tables ROW_COUNT \u603b\u884c\u6570 bigint unsigned sum(mo_table_rows()) SIZE \u4f7f\u7528\u7a7a\u95f4\u603b\u91cf\uff08MB\uff09 decimal(29,3) sum(mo_table_size(mt.reldatabase,mt.relname) COMMENT \u521b\u5efa\u65f6\u7684 COMMENT \u4fe1\u606f varchar mo_account"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_4","title":"\u793a\u4f8b","text":"mysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 2681 | 0.351 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n1 row in set (0.14 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/","title":"SHOW COLLATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u663e\u793a MatrixOne \u652f\u6301\u5b57\u7b26\u96c6\u7684\u6392\u5e8f\u89c4\u5219\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cSHOW COLLATION
\u7684\u8f93\u51fa\u5305\u62ec\u6240\u6709\u53ef\u7528\u7684\u6392\u5e8f\u89c4\u5219\u3002LIKE
\u5b50\u53e5\uff08\u5982\u679c\u5b58\u5728\uff09\u6307\u793a\u8981\u5339\u914d\u7684\u6392\u5e8f\u89c4\u5219\u540d\u79f0\u3002WHERE
\u5b50\u53e5\u53ef\u4ee5\u4f7f\u7528\u66f4\u4e00\u822c\u7684\u6761\u4ef6\u6765\u9009\u62e9\u884c\u3002
> SHOW COLLATION\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#_3","title":"\u793a\u4f8b","text":"mysql> show collation;\n+-------------+---------+------+----------+---------+\n| Collation | Charset | Id | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 | 46 | Yes | 1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation like '%';\n+-------------+---------+------+----------+---------+\n| Collation | Charset | Id | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 | 46 | Yes | 1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation where 'Charset'='utf8mb4';\n+-------------+---------+------+----------+---------+\n| Collation | Charset | Id | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 | 46 | Yes | 1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/","title":"SHOW COLUMNS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW COLUMNS
\u7528\u4e8e\u663e\u793a\u6307\u5b9a\u8868\u4e2d\u6709\u5173\u5217\u7684\u4fe1\u606f\u3002
> SHOW [FULL] {COLUMNS}\n {FROM | IN} tbl_name\n [{FROM | IN} db_name]\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show columns from t1;\n+-------+----------------+------+------+---------+-------+-------------------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+----------------+------+------+---------+-------+-------------------+\n| col1 | INT | YES | | NULL | | First column |\n| col2 | FLOAT | YES | | NULL | | \"%$^&*()_+@! |\n| col3 | VARCHAR(65535) | YES | | NULL | | ZD5lTndyuEzw49gxR |\n| col4 | BOOL | YES | | NULL | | |\n+-------+----------------+------+------+---------+-------+-------------------+\n4 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/","title":"SHOW CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de PUBLICATION \u521b\u5efa\u65f6\u7684 SQL \u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SHOW CREATE PUBLICATION pubname;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#_3","title":"\u793a\u4f8b","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\nmysql> alter publication pub3 account add accx;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication |\n+-------------+-----------------------------------------------------------------------+\n| pub3 | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/","title":"SHOW CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u67d0\u4e2a\u8868\u7684\u8868\u7ed3\u6784\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW CREATE TABLE tbl_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show create table t1;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`col1` INT DEFAULT NULL COMMENT 'First column',\n`col2` FLOAT DEFAULT NULL COMMENT '\"%$^&*()_+@!',\n`col3` VARCHAR(65535) DEFAULT NULL COMMENT 'ZD5lTndyuEzw49gxR',\n`col4` BOOL DEFAULT NULL\n) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/","title":"SHOW CREATE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd9\u4e2a\u8bed\u53e5\u663e\u793a\u4e86\u521b\u5efa\u547d\u540d\u89c6\u56fe\u7684 CREATE VIEW
\u8bed\u53e5\u3002
> SHOW CREATE VIEW view_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#_3","title":"\u793a\u4f8b","text":"create table test_table(col1 int, col2 float, col3 bool, col4 Date, col5 varchar(255), col6 text);\ncreate view test_view as select * from test_table;\nmysql> show create view test_view;\n+-----------+---------------------------------------------------+\n| View | Create View |\n+-----------+---------------------------------------------------+\n| test_view | create view test_view as select * from test_table |\n+-----------+---------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/","title":"SHOW DATABASES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SHOW DATABASES
\u5217\u51fa MatrixOne \u4e0a\u7684\u6570\u636e\u5e93\u3002SHOW SCHEMAS
\u662f SHOW DATABASES
\u7684\u540c\u4e49\u8bcd\u3002
\u5982\u679c\u5b58\u5728 LIKE
\u5b50\u53e5\uff0c\u8868\u793a\u9700\u8981\u5339\u914d\u54ea\u4e9b\u6570\u636e\u5e93\u540d\u3002WHERE
\u5b50\u53e5\u53ef\u4ee5\u4f7f\u7528\u901a\u7528\u7684\u6761\u4ef6\u6765\u9009\u62e9\u884c\u3002
MatrixOne \u5c06\u6570\u636e\u5e93\u5c55\u793a\u5728\u6570\u636e\u76ee\u5f55\u4e2d\u3002
\u6570\u636e\u5e93\u4fe1\u606f\u4e5f\u53ef\u4ee5\u4ece INFORMATION_SCHEMA
SCHEMATA \u8868\u4e2d\u83b7\u5f97\u3002
> SHOW {DATABASES | SCHEMAS}\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#_3","title":"\u793a\u4f8b","text":"create database demo_1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| mo_task |\n| information_schema |\n| mysql |\n| system_metrics |\n| system |\n| demo_1 |\n| mo_catalog |\n+--------------------+\n7 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/","title":"SHOW FUNCTION STATUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW FUNCTION STATUS
\u662f\u7528\u6765\u663e\u793a\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u51fd\u6570\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u51fd\u6570\u540d\u3001\u6570\u636e\u5e93\u540d\u3001\u521b\u5efa\u65f6\u95f4\u7b49\u7b49\u3002
SHOW FUNCTION STATUS
\u547d\u4ee4\u53ea\u663e\u793a\u7528\u6237\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u4e0d\u5305\u62ec\u7cfb\u7edf\u51fd\u6570\u3002MatrixOne \u652f\u6301 SQL UDF \u548c Python UDF\u3002
> SHOW FUNCTION STATUS\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"LIKE 'pattern'
\u662f\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u7b5b\u9009\u8981\u663e\u793a\u7684\u51fd\u6570\u3002pattern
\u662f\u4e00\u4e2a\u6a21\u5f0f\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 %
\u548c _
\u901a\u914d\u7b26\u3002\u4f8b\u5982\uff0c\u8981\u663e\u793a\u6240\u6709\u4ee5 my_function
\u5f00\u5934\u7684\u51fd\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a
SHOW FUNCTION STATUS LIKE 'my_function%';\n
\u8f93\u51fa\u7ed3\u679c\u5c06\u5305\u62ec\u51fd\u6570\u540d\u3001\u6570\u636e\u5e93\u540d\u3001\u7c7b\u578b\u3001\u521b\u5efa\u65f6\u95f4\u548c\u4fee\u6539\u65f6\u95f4\u7b49\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#_4","title":"\u793a\u4f8b","text":"create or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\ncreate function twosum (x float, y float) returns float language sql as 'select $1 + $2' ;\ncreate function helloworld () returns int language sql as 'select id from tbl1 limit 1';\n\nmysql> show function status;\n+------+-------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+-------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| db1 | py_add | FUNCTION | root | 2024-01-16 08:00:21 | 2024-01-16 08:00:21 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n| db1 | twosum | FUNCTION | root | 2024-01-16 08:00:39 | 2024-01-16 08:00:39 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n| db1 | helloworld | FUNCTION | root | 2024-01-16 08:00:53 | 2024-01-16 08:00:53 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n+------+-------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n3 rows in set (0.01 sec)\n\nmysql> show function status like 'two%';\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| db1 | twosum | FUNCTION | root | 2024-01-16 08:00:39 | 2024-01-16 08:00:39 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n1 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/","title":"SHOW GRANTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4f7f\u7528 SHOW GRANTS
\u8bed\u53e5\u663e\u793a\u7528\u6237\u7684\u6240\u6709\u6388\u6743\u4fe1\u606f\u3002SHOW GRANTS
\u8bed\u53e5\u663e\u793a\u4f7f\u7528 GRANT
\u547d\u4ee4\u5206\u914d\u7ed9\u7528\u6237\u7684\u6743\u9650\u3002
\u4f7f\u7528 SHOW GRANTS
\u8bed\u53e5\u9700\u8981\u62e5\u6709\u67e5\u8be2 mo_catalog \u5e93\u4e0b\u6240\u6709\u8868\u7684 SELECT
\u6743\u9650\uff0c\u4f46\u663e\u793a\u5f53\u524d\u7528\u6237\u7684\u6743\u9650\u548c\u89d2\u8272\u9664\u5916\u3002
\u8981\u4e3a SHOW GRANTS
\u547d\u540d\u5e10\u6237\u6216\u89d2\u8272\uff0c\u5373\u4f7f\u7528\u4e0e GRANT
\u8bed\u53e5\u76f8\u540c\u7684\u683c\u5f0f\uff0c\u4f8b\u5982\uff1a
show grants for 'root'@'localhost';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW GRANTS FOR {username[@hostname] | rolename};\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#_3","title":"\u793a\u4f8b","text":"create role role1;\ngrant all on table *.* to role1;\ngrant create table, drop table on database *.* to role1;\ncreate user user1 identified by 'pass1';\ngrant role1 to user1;\n> show grants for 'user1'@'localhost';\n+--------------------------------------------------------+\n| Grants for user1@localhost |\n+--------------------------------------------------------+\n| GRANT connect ON account `user1`@`localhost` |\n| GRANT table all ON table *.* `user1`@`localhost` |\n| GRANT create table ON database *.* `user1`@`localhost` |\n| GRANT drop table ON database *.* `user1`@`localhost` |\n+--------------------------------------------------------+\n4 rows in set (0.00 sec)\n\nmysql> show grants for ROLE role1;\n+--------------------------------------------+\n| Grants for role1 |\n+--------------------------------------------+\n| GRANT table all ON table *.* `role1` |\n| GRANT create table ON database *.* `role1` |\n| GRANT drop table ON database *.* `role1` |\n+--------------------------------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/","title":"SHOW INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW INDEX
\u8fd4\u56de\u8868\u7684\u7d22\u5f15\u4fe1\u606f\u3002
SHOW INDEX
\u8fd4\u56de\u4ee5\u4e0b\u5b57\u6bb5\uff1a
> SHOW {INDEX | INDEXES}\n {FROM | IN} tbl_name\n [{FROM | IN} db_name]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"tbl_name FROM db_name
\u8bed\u6cd5\u7684\u66ff\u4ee3\u65b9\u6cd5\u662f db_name.tbl_name
\u3002
CREATE TABLE show_01(sname varchar(30),id int);\nmysql> show INDEX FROM show_01;\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Visible | Expression |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| show_01 | 0 | id | 1 | id | A | 0 | NULL | NULL | YES | | | YES | NULL |\n| show_01 | 0 | sname | 1 | sname | A | 0 | NULL | NULL | YES | | | YES | NULL |\n| show_01 | 0 | __mo_rowid | 1 | __mo_rowid | A | 0 | NULL | NULL | NO | | Physical address | NO | NULL |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n3 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/","title":"SHOW PROCESSLIST","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW PROCESSLIST
\u7528\u4e8e\u67e5\u770b\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u5217\u8868\uff08\u4e5f\u79f0\u4e3a\u8fdb\u7a0b\u5217\u8868\uff09\uff0c\u63d0\u4f9b\u4e86\u5173\u4e8e MatrixOne \u670d\u52a1\u5668\u4e0a\u6240\u6709\u6d3b\u52a8\u8fde\u63a5\u548c\u6267\u884c\u4e2d\u67e5\u8be2\u7684\u4fe1\u606f\u3002
SHOW PROCESSLIST
\u7528\u4e8e\u76d1\u63a7\u548c\u7ba1\u7406\u6570\u636e\u5e93\u4e2d\u7684\u6d3b\u52a8\uff0c\u53d1\u73b0\u6f5c\u5728\u95ee\u9898\uff0c\u5e2e\u52a9\u67e5\u8be2\u6027\u80fd\u95ee\u9898\uff0c\u5e76\u5e2e\u52a9\u51b3\u7b56\u4f18\u5316\u6570\u636e\u5e93\u7684\u8fd0\u884c\uff1a
\u76d1\u63a7\u6570\u636e\u5e93\u6d3b\u52a8\uff1a\u901a\u8fc7\u6267\u884c SHOW PROCESSLIST
\uff0c\u53ef\u4ee5\u5b9e\u65f6\u67e5\u770b\u6570\u636e\u5e93\u4e2d\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u548c\u64cd\u4f5c\u3002\u8fd9\u5bf9\u4e8e\u76d1\u63a7\u6570\u636e\u5e93\u6d3b\u52a8\u5e76\u53ca\u65f6\u53d1\u73b0\u53ef\u80fd\u7684\u6027\u80fd\u95ee\u9898\u975e\u5e38\u6709\u7528\u3002\u4f60\u53ef\u4ee5\u4e86\u89e3\u54ea\u4e9b\u67e5\u8be2\u6b63\u5728\u8fd0\u884c\uff0c\u5b83\u4eec\u7684\u72b6\u6001\u5982\u4f55\uff0c\u4ee5\u53ca\u662f\u5426\u6709\u957f\u65f6\u95f4\u8fd0\u884c\u6216\u963b\u585e\u7684\u67e5\u8be2\u3001\u6216\u8005\u9501\u5b9a\u3001\u6b7b\u9501\u6216\u8d44\u6e90\u4e89\u7528\u7b49\u3002
\u7ec8\u6b62\u67e5\u8be2\uff1a\u901a\u8fc7\u67e5\u770b\u8fdb\u7a0b\u5217\u8868\uff0c\u53ef\u4ee5\u786e\u5b9a\u8981\u7ec8\u6b62\u7684\u67e5\u8be2 ID\uff0c\u5e76\u4f7f\u7528 KILL
\u547d\u4ee4\u7ec8\u6b62\u5177\u4f53\u7684\u67e5\u8be2\u3002\u8fd9\u5bf9\u4e8e\u505c\u6b62\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u67e5\u8be2\u6216\u89e3\u51b3\u6b7b\u9501\u95ee\u9898\u975e\u5e38\u6709\u7528\u3002
> SHOW PROCESSLIST;\n
\u67e5\u8be2\u51fa\u7684\u8868\u7ed3\u6784\u5b57\u6bb5\u89e3\u91ca\u5982\u4e0b\uff1a
\u5217\u540d \u7c7b\u578b \u7ea6\u675f \u5907\u6ce8 node_id varchar not null \u8282\u70b9 ID\uff0c\u7528\u4e8e\u5728\u6570\u636e\u5e93\u96c6\u7fa4\u4e2d\u552f\u4e00\u6807\u8bc6\u4e0d\u540c\u7684\u8282\u70b9\u3002\u5728 MatrixOne \u4e2d\uff0c\u4e00\u4e2a\u8282\u70b9\u5373\u4e3a\u4e00\u4e2a CN\uff08Compute Node\uff09\u3002 Note: - \u5728\u5355\u673a\u7248\u672c\u7684 MatrixOne \u4e2d\uff0c\u901a\u5e38\u53ea\u6709\u4e00\u4e2a\u8282\u70b9\uff0c\u6240\u6709\u8fdb\u7a0b\u90fd\u8fd0\u884c\u5728\u8fd9\u4e2a\u8282\u70b9\u4e0a\uff0c\u56e0\u6b64\u6240\u6709\u8fdb\u7a0b\u7684 node_id \u90fd\u76f8\u540c\u3002 - \u5728\u5206\u5e03\u5f0f\u7248\u672c\u7684 MatrixOne \u4e2d\uff0c\u6bcf\u4e2a\u8282\u70b9\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684 node_id\u3002\u7cfb\u7edf\u79df\u6237\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u6240\u5728\u8282\u70b9\u5bf9\u5e94\u7684 node_id\uff0c\u800c\u975e\u7cfb\u7edf\u79df\u6237\u53ea\u80fd\u770b\u5230\u5c5e\u4e8e\u5176\u79df\u6237\u4e0b\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u7684\u8282\u70b9\u5bf9\u5e94\u7684 node_id\u3002 conn_id uint32 not null \u8fde\u63a5 ID\uff0c\u7528\u4e8e\u6807\u8bc6\u4e0d\u540c\u7684\u6570\u636e\u5e93\u8fde\u63a5\u3002\u5982\u679c\u9700\u8981\u7ec8\u6b62\u67d0\u4e2a\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u53ef\u4ee5\u4f7f\u7528KILL CONNECTION conn_id;
\u547d\u4ee4\u6765\u7ec8\u6b62\u8be5\u8fde\u63a5\u3002\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u6bcf\u4e2a\u8fde\u63a5\u90fd\u4f1a\u88ab\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684 conn_id\uff0c\u7528\u4e8e\u6807\u8bc6\u8be5\u8fde\u63a5\u3002 Note: \u7cfb\u7edf\u79df\u6237\u53ef\u4ee5\u67e5\u770b\u6240\u6709 conn_id\uff0c\u975e\u7cfb\u7edf\u79df\u6237\u53ea\u80fd\u770b\u5230\u79df\u6237\u4e0b\u7684 conn_id\u3002ID session_id varchar not null \u4f1a\u8bdd ID account varchar not null \u79df\u6237 Note: \u7cfb\u7edf\u79df\u6237\u4e0b\u53ef\u4ee5\u770b\u5230\u6240\u6709\u79df\u6237\u7684\u4f1a\u8bdd\u4e0e\u79df\u6237\u540d\u79f0\uff0c\u975e\u7cfb\u7edf\u79df\u6237\u53ea\u80fd\u770b\u5230\u81ea\u5df1\u79df\u6237\u7684\u4f1a\u8bdd\u4e0e\u79df\u6237\u540d\u79f0\u3002 user varchar not null \u7528\u6237 host varchar not null \u5ba2\u6237\u673a\u7aef\u7684\u4e3b\u673a\u540d db varchar \u6570\u636e\u5e93\u540d session_start varchar \u4f1a\u8bdd\u5f00\u59cb\u65f6\u95f4 command varchar not null \u547d\u4ee4\u7c7b\u578b\uff0c\u5982 COM_QUERY info varchar \u5f53\u524d\u6216\u4e0a\u4e00\u6761 SQL \u8bed\u53e5 txn_id varchar not null \u5f53\u524d\u6216\u4e0a\u4e00\u6761\u4e8b\u52a1 ID statement_id varchar \u5f53\u524d\u6216\u4e0a\u4e00\u6761\u8bed\u53e5 ID statement_type varchar \u5f53\u524d\u6216\u4e0a\u4e00\u6761\u8bed\u53e5\u7c7b\u578b query_type varchar \u67e5\u8be2\u7c7b\u578b\uff0c\u5982 DDL\uff0cDML \u7b49 sql_source_type varchar SQL \u6e90\u7c7b\u578b\uff0c\u5982 external_sql, internal_sql \u7b49 query_start varchar \u67e5\u8be2\u5f00\u59cb\u65f6\u95f4"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#_3","title":"\u793a\u4f8b","text":"mysql> SHOW PROCESSLIST;\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| node_id | conn_id | session_id | account | user | host | db | session_start | command | info | txn_id | statement_id | statement_type | query_type | sql_source_type | query_start |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 1 | 97f85f80-2a5c-11ee-ae41-5ad2460dea4f | sys | mo_logger | 127.0.0.1:6001 | | 2023-07-24 19:59:27.005755 | COM_QUERY | COMMIT | | | | | internal_sql | |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 8 | a056b7c6-2a5c-11ee-ae42-5ad2460dea4f | sys | root | 127.0.0.1:6001 | aab | 2023-07-24 19:59:41.045851 | COM_QUERY | SHOW PROCESSLIST | c207acc30a19432f8d3cbac387c6e520 | 421aadaa-2a68-11ee-ae5b-5ad2460dea4f | Show Processlist | Other | external_sql | 2023-07-24 21:22:56.907266 |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 24 | 0915f91a-2a63-11ee-ae4d-5ad2460dea4f | sys | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 20:45:33.762679 | COM_QUERY | select\ntask_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ntask_parent_id,\ntask_status,\ntask_runner,\ntask_epoch,\nlast_heartbeat,\nresult_code,\nerror_msg,\ncreate_at,\nend_at\nfrom mo_task.sys_async_task where task_id>17 AND task_runner='dd1dccb4-4d3c-41f8-b482-5251dc7a41bf' AND task_status=1 order by task_id limit 3 | | | | | internal_sql | |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 36 | d8aa4060-2a67-11ee-ae59-5ad2460dea4f | sys | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 21:20:00.009746 | COM_QUERY | select\ncron_task_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ncron_expr,\nnext_time,\ntrigger_times,\ncreate_at,\nupdate_at\nfrom mo_task.sys_cron_task | | | | | internal_sql | |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/","title":"SHOW PUBLICATIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u6240\u6709\u53d1\u5e03\u540d\u3001\u53d1\u5e03\u7684\u6570\u636e\u5e93\u540d\u3001\u53d1\u5e03\u521b\u5efa\u65f6\u95f4\u3001\u53d1\u5e03\u6700\u65b0\u4fee\u6539\u65f6\u95f4\u3001\u53d1\u5e03\u6307\u5b9a\u7684\u79df\u6237\u540d\u5217\u8868\uff08\u5982\u679c\u662f\u6240\u6709\u5219\u5c55\u793a \"*\"\uff09\u548c\u5907\u6ce8\u3002
\u5982\u9700\u67e5\u770b\u66f4\u591a\u4fe1\u606f\uff0c\u9700\u8981\u62e5\u6709\u79df\u6237\u7ba1\u7406\u5458\u6743\u9650\uff0c\u67e5\u770b\u7cfb\u7edf\u8868 mo_pubs \u67e5\u770b\u66f4\u591a\u53c2\u6570\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SHOW PUBLICATIONS;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#_3","title":"\u793a\u4f8b","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+-------------+----------+---------------------+-------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+-------------+-------------+----------+\n| pub3 | t | 2024-04-23 10:10:59 | NULL | acc0,acc1 | |\n+-------------+----------+---------------------+-------------+-------------+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/","title":"SHOW ROLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5217\u51fa\u4e3a\u4f60\u7684\u8d26\u6237\u4e0b\u521b\u5efa\u7684\u89d2\u8272\u7684\u5143\u4fe1\u606f\uff0c\u5305\u62ec\u89d2\u8272\u540d\u79f0\u3001\u521b\u5efa\u8005\u3001\u521b\u5efa\u65f6\u95f4\u4ee5\u53ca\u6ce8\u91ca\u5185\u5bb9\u3002
Note: \u5982\u679c\u9700\u8981\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u4f7f\u7528\u7684\u89d2\u8272\uff0c\u4f7f\u7528 select current_role()
\u8bed\u53e5\u3002
> SHOW ROLES [LIKE 'pattern'];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#_3","title":"\u793a\u4f8b","text":"-- \u5c55\u793a\u5f53\u524d\u4f60\u8d26\u6237\u4e0b\u7684\u89d2\u8272\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME | COMMENTS |\n+-----------+---------+---------------------+----------+\n| moadmin | 0 | 2023-04-19 06:37:58 | |\n| public | 0 | 2023-04-19 06:37:58 | |\n+-----------+---------+---------------------+----------+\n2 rows in set (0.01 sec)\n\n-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u89d2\u8272 rolex\nmysql> create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u518d\u6b21\u67e5\u770b\u5f53\u524d\u4f60\u8d26\u6237\u4e0b\u7684\u89d2\u8272\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME | COMMENTS |\n+-----------+---------+---------------------+----------+\n| rolex | 1 | 2023-04-19 06:43:29 | |\n| moadmin | 0 | 2023-04-19 06:37:58 | |\n| public | 0 | 2023-04-19 06:37:58 | |\n+-----------+---------+---------------------+----------+\n3 rows in set (0.01 sec)\n\n-- \u67e5\u8be2\u5f53\u524d\u4f60\u6240\u4f7f\u7528\u7684\u89d2\u8272\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/","title":"SHOW SEQUENCES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW SEQUENCES
\u7528\u4e8e\u67e5\u770b\u5f53\u524d\u5e8f\u5217\u5217\u8868\u7684\u540d\u79f0\u4e0e\u5217\u8868\u7c7b\u578b\u3002
> SHOW SQUENCES\n [WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#_3","title":"\u793a\u4f8b","text":"CREATE SEQUENCE s1 START 101;\nCREATE SEQUENCE s3 as smallint INCREMENT 10 MINVALUE -100 MAXVALUE 100 START 0 CYCLE;\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\nmysql> show sequences;\n+--------+-----------+\n| Names | Data Type |\n+--------+-----------+\n| s3 | SMALLINT |\n| s1 | BIGINT |\n| seq_id | BIGINT |\n+--------+-----------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-snapshots/","title":"SHOW SNAPSHOTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-snapshots/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW SNAPSHOTS
\u8fd4\u56de\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u7684\u5feb\u7167\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u5feb\u7167\u540d\u3001\u521b\u5efa\u65f6\u95f4\u6233\uff08UTC \u65f6\u95f4\uff09\u3001\u5feb\u7167\u7ea7\u522b\u3001\u79df\u6237\u540d\u79f0\u3001\u6570\u636e\u5e93\u540d\u3001\u8868\u540d\u3002
> SHOW SNAPSHOTS [WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-snapshots/#_3","title":"\u793a\u4f8b","text":"create account acc1 admin_name admin identified by '111';\ncreate snapshot sp1 for account acc1;\ncreate snapshot sp2 for account sys;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp2 | 2024-05-10 09:58:55.602263 | account | sys | | |\n| sp1 | 2024-05-10 09:58:55.212365 | account | acc1 | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n2 rows in set (0.01 sec)\n\nmysql> show snapshots where account_name=\"acc1\";\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| snapshot_name | timestamp | snapshot_level | account_name | database_name | table_name |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp1 | 2024-05-10 09:58:55.212365 | account | acc1 | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/","title":"SHOW STAGES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u6570\u636e\u9636\u6bb5\u3002
MatrixOne \u7528\u6237\u4f7f\u7528 SHOW STAGES
\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u6240\u6709\u7684\u6570\u636e\u9636\u6bb5\uff0c\u53ef\u4ee5\u9009\u62e9\u5c06\u6570\u636e\u5bfc\u51fa\u5230\u7684\u6709\u6548\u8def\u5f84\u3002
> SHOW STAGES [LIKE 'pattern']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\n-- \u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u6570\u636e\u9636\u6bb5\u3002\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL | STATUS | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1 | /tmp | ENABLED | |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/","title":"SHOW SUBSCRIPTIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u6240\u6709\u53d1\u5e03\u540d\u3001\u53d1\u5e03\u79df\u6237\u540d\u3001\u53d1\u5e03\u7684\u6570\u636e\u5e93\u540d\u3001\u53d1\u5e03\u7ed9\u8be5\u79df\u6237\u7684\u65f6\u95f4\u3001\u8ba2\u9605\u540d\u548c\u521b\u5efa\u8be5\u8ba2\u9605\u7684\u65f6\u95f4\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SHOW SUBSCRIPTIONS [ALL];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"mysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub3 | sys | t | 2024-04-23 11:11:06 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+----------+\n1 row in set (0.01 sec)\n\nmysql> show subscriptions;\nEmpty set (0.00 sec)\n\nmysql> create database sub3 from sys publication pub3;\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub3 | sys | t | 2024-04-23 11:11:06 | sub3 | 2024-04-23 11:12:11 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub3 | sys | t | 2024-04-23 11:11:06 | sub3 | 2024-04-23 11:12:11 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/","title":"SHOW TABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u6240\u6709\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW TABLES [LIKE 'pattern' | WHERE expr | FROM 'pattern' | IN 'pattern']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#_3","title":"\u793a\u4f8b","text":"> SHOW TABLES;\n+---------------+\n| name |\n+---------------+\n| clusters |\n| contributors |\n| databases |\n| functions |\n| numbers |\n| numbers_local |\n| numbers_mt |\n| one |\n| processes |\n| settings |\n| tables |\n| tracing |\n+---------------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/","title":"SHOW VARIABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u7cfb\u7edf\u53d8\u91cf\u7684\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW VARIABLES\n [LIKE 'pattern']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"LIKE
\u5b50\u53e5\u4ec5\u663e\u793a\u540d\u79f0\u4e0e\u6a21\u5f0f\u5339\u914d\u7684\u90a3\u4e9b\u53d8\u91cf\u7684\u884c\u3002\u8981\u83b7\u53d6\u540d\u79f0\u4e0e\u6a21\u5f0f\u5339\u914d\u7684\u53d8\u91cf\u5217\u8868\uff0c\u8bf7\u5728\u5b50\u53e5\u4e2d\u4f7f\u7528 % \u901a\u914d\u7b26\u3002mysql> SHOW VARIABLES;\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| Variable_name | Value |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| auto_increment_increment | 1 |\n| auto_increment_offset | 1 |\n| autocommit | 1 |\n| character_set_client | utf8mb4 |\n| character_set_connection | utf8mb4 |\n| character_set_database | utf8mb4 |\n| character_set_results | utf8mb4 |\n| character_set_server | utf8mb4 |\n| collation_connection | default |\n| collation_server | utf8mb4_bin |\n| completion_type | NO_CHAIN |\n| host | 0.0.0.0 |\n| init_connect | |\n| interactive_timeout | 28800 |\n| license | APACHE |\n| lower_case_table_names | 0 |\n| max_allowed_packet | 16777216 |\n| net_write_timeout | 60 |\n| performance_schema | 0 |\n| port | 6001 |\n| profiling | 0 |\n| query_result_maxsize | 100 |\n| query_result_timeout | 24 |\n| save_query_result | 0 |\n| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |\n| sql_safe_updates | 0 |\n| sql_select_limit | 18446744073709551615 |\n| system_time_zone | |\n| testbotchvar_nodyn | 0 |\n| testbothvar_dyn | 0 |\n| testglobalvar_dyn | 0 |\n| testglobalvar_nodyn | 0 |\n| testsessionvar_dyn | 0 |\n| testsessionvar_nodyn | 0 |\n| time_zone | SYSTEM |\n| transaction_isolation | REPEATABLE-READ |\n| transaction_read_only | 0 |\n| tx_isolation | REPEATABLE-READ |\n| tx_read_only | 0 |\n| version_comment | MatrixOne |\n| wait_timeout | 28800 |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n41 rows in set (0.01 sec)\n\nmysql> show variables like 'auto%';\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1 |\n| auto_increment_offset | 1 |\n| autocommit | 1 |\n+--------------------------+-------+\n3 rows in set (0.00 sec)\n\nmysql> show variables like 'auto_increment_increment';\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1 |\n+--------------------------+-------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/","title":"SET ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8bbe\u7f6e\u4f1a\u8bdd\u7684\u6d3b\u52a8/\u5f53\u524d\u4e3b\u8981\u89d2\u8272\u3002\u4e3a\u5f53\u524d\u6d3b\u52a8\u7684\u4e3b\u89d2\u8272\u8bbe\u7f6e\u4e0a\u4e0b\u6587\uff0c\u4ee5\u786e\u5b9a\u5f53\u524d\u7528\u6237\u662f\u5426\u62e5\u6709\u6267\u884c CREATE <object>
\u8bed\u53e5\u6216\u6267\u884c\u4efb\u4f55\u5176\u4ed6 SQL \u64cd\u4f5c\u6240\u9700\u7684\u6743\u9650\u3002
\u9664\u4e86\u521b\u5efa\u5bf9\u8c61\u4e4b\u5916\uff0c\u4efb\u4f55 SQL \u64cd\u4f5c\u7684\u6388\u6743\u90fd\u53ef\u4ee5\u7531\u6b21\u7ea7\u89d2\u8272\u6267\u884c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SET SECONDARY ROLE {\n NONE\n | ALL \n}\nSET ROLE role\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u89d2\u8272\u662f\u6743\u9650\u7684\u96c6\u5408\uff0c\u4e00\u4e2a\u7528\u6237\u53ef\u4ee5\u5bf9\u5e94\u591a\u4e2a\u89d2\u8272\u3002
\u4f8b\u5982\uff0cuser1 \u62e5\u6709\u4e3b\u8981\u89d2\u8272 role1\uff0c\u6b21\u8981\u89d2\u8272 role2 \u548c role3, role1 \u88ab\u6388\u4e88 pri1 \u548c pri2 \u6743\u9650\uff1brole2 \u88ab\u8d4b\u4e88\u6743\u9650 pri3\uff1brole3 \u88ab\u8d4b\u4e88\u6743\u9650 pri4\uff0c\u6388\u6743\u793a\u4f8b\u8868\u5982\u4e0b\uff1a
\u7528\u6237\u540d \u89d2\u8272\u540d \u6743\u9650\u540d user1 role1 pri1,pri2 role2 pri3 role3 pri4\u4e3a\u4e86\u66f4\u5bb9\u6613\u7406\u89e3\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u793a\u4f8b\uff1a
\u7528\u6237 \u89d2\u8272 \u6743\u9650\u540d Tom \u5e94\u7528\u5f00\u53d1\u8005\uff08Application Developer\uff09 \u8bfb\u6570\u636e\uff08Read Data\uff09\uff0c\u5199\u6570\u636e\uff08Write Data\uff09 \u8fd0\u7ef4\u4e13\u5bb6\uff08O&M expert\uff09 \u8bfb\u6570\u636e\uff08Read data\uff09 \u6570\u636e\u5e93\u7ba1\u7406\u5458\uff08Database Administrator\uff09 \u7ba1\u7406\u5458\u6743\u9650\uff08Administrator Privileges\uff09\u6b64\u65f6 Tom \u7684\u4e3b\u8981\u89d2\u8272\u662f\u5e94\u7528\u5f00\u53d1\u8005\uff0cTom \u9700\u8981\u8c03\u7528\u7ba1\u7406\u5458\u6743\u9650\uff0c\u90a3\u4e48 Tom \u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a
\u2014\u4f7f\u7528 SET role role
\u8bed\u53e5\u5c06\u5176\u89d2\u8272\u5207\u6362\u4e3a\u201c\u6570\u636e\u5e93\u7ba1\u7406\u5458\u201d\u3002
\u2014\u5982\u679c\u9700\u8981\u4f7f\u7528\u4e3b\u3001\u4ece\u89d2\u8272\u7684\u6240\u6709\u6743\u9650\uff0c\u53ef\u4ee5\u4f7f\u7528 SET secondary ROLE all
\u3002
\u8fd9\u4e24\u79cd\u8bed\u53e5\u89e3\u91ca\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-all","title":"SET SECONDARY ROLE ALL","text":"\u5c06\u8be5\u7528\u6237\u6240\u6709\u7684 ROLE \u53d6\u5e76\u96c6\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-none","title":"SET SECONDARY ROLE NONE","text":"\u5c06\u9664 PRIMARY ROLE \u4e4b\u5916\u7684\u6240\u6709\u89d2\u8272\u4ece\u5f53\u524d\u4f1a\u8bdd\u4e2d\u53bb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-role-role","title":"SET ROLE role","text":"\u5c06\u5f53\u524d\u89d2\u8272\u5207\u6362\u4e3a\u65b0\u89d2\u8272\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_4","title":"\u793a\u4f8b","text":"> drop role if exists use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> drop user if exists use_user_1,use_user_2;\n> drop database if exists use_db_1;\n> create role use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> create database use_db_1;\n> create user use_user_1 identified by '123456' default role use_role_1;\n-- \u628a\u6240\u6709\u8868\u7684 select\uff0cinsert \u548c update \u6743\u9650\u6388\u6743\u7ed9 use_role_1\n> grant select ,insert ,update on table *.* to use_role_1;\n-- \u628a\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\u6388\u6743\u7ed9 use_role_2\n> grant all on database * to use_role_2;\n-- \u628a\u89d2\u8272 use_role_2 \u5206\u914d\u7ed9\u7528\u6237 use_user_1\n> grant use_role_2 to use_user_1;\n-- \u521b\u5efa\u8868 use_table_1\n> create table use_db_1.use_table_1(a int,b varchar(20),c double );\n-- \u8bbe\u7f6e\u7528\u6237 use_user_1 \u4e3b\u8981\u89d2\u8272\u548c\u6b21\u8981\u89d2\u8272\u5168\u90e8\u53ef\u7528\n> set secondary role all;\n-- \u67e5\u770b\u7528\u6237 use_user_1 \u73b0\u5728\u62e5\u6709\u7684\u6743\u9650\n> show grants for 'use_user_1'@'localhost';\n+-----------------------------------------------------------+\n| Grants for use_user_1@localhost |\n+-----------------------------------------------------------+\n| GRANT select ON table *.* `use_user_1`@`localhost` |\n| GRANT insert ON table *.* `use_user_1`@`localhost` |\n| GRANT update ON table *.* `use_user_1`@`localhost` |\n| GRANT connect ON account `use_user_1`@`localhost` |\n| GRANT database all ON database * `use_user_1`@`localhost` |\n+-----------------------------------------------------------+\n5 rows in set (0.01 sec)\n-- \u53ef\u4ee5\u770b\u5230\uff0c\u7528\u6237 use_user_1 \u62e5\u6709\u9ed8\u8ba4\u7684\u8fde\u63a5 MatrixOne \u7684\u6743\u9650 connect\uff1b\u4e5f\u62e5\u6709\u5bf9\u6240\u6709\u8868\u7684 select\uff0cinsert \u548c update \u6743\u9650\uff0c\u540c\u65f6\u4e5f\u62e5\u6709\u5bf9\u6570\u636e\u5e93\u7684\u5168\u90e8\u6743\u9650\n
"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/","title":"\u5206\u5e03\u5f0f\u7248\u901a\u7528\u53c2\u6570\u914d\u7f6e","text":"\u5728 matrixone/etc/launch-with-proxy/ \u76ee\u5f55\u4e0b\uff0c\u6709\u56db\u4e2a\u914d\u7f6e\u6587\u4ef6\uff1acn.toml\u3001tn.toml\u3001proxy.toml \u548c log.toml\u3002\u8fd9\u4e9b\u914d\u7f6e\u6587\u4ef6\u4e2d\u5305\u542b\u7684\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_2","title":"\u9ed8\u8ba4\u53c2\u6570","text":"cn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [cn] cn \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 / port-base \"cn\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 18000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"127.0.0.1\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 port MatrixOne \u76d1\u542c\u53ca\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u7aef\u53e3 port = 6001 host \u76d1\u542c IP \u5730\u5740 host = \"0.0.0.0\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_3","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 cn.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 unix-socket \u76d1\u542c Unix \u57df\u63a5\u53e3 unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted \u63a7\u5236\u53f0\u8f93\u51fa\u67e5\u8be2\u957f\u5ea6 lengthOfQueryPrinted = 200000 enableTls \u662f\u5426\u542f\u7528 TLS enableTls = false tlsCaFile \u5ba2\u6237\u7aef SSL CA \u5217\u8868\u6587\u4ef6\u8def\u5f84 tlsCaFile = '' tlsCertFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsCertFile = '' tlsKeyFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsKeyFile = '' saveQueryResult \u662f\u5426\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c saveQueryResult = false queryResultTimeout \u67e5\u8be2\u7ed3\u679c\u8d85\u65f6\u65f6\u95f4 queryResultTimeout = 24 queryResultMaxsize \u67e5\u8be2\u7ed3\u679c\u6700\u5927\u89c4\u6a21 queryResultMaxsize = 100 lowerCaseTableNames \u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u654f\u611f\uff0c\u9ed8\u8ba4\u53c2\u6570\u503c\u4e3a 1\uff0c\u8868\u793a\u5927\u5c0f\u5199\u4e0d\u654f\u611f lowerCaseTableNames = 1 [cn.Txn] \u4e8b\u52a1\u914d\u7f6e\u8282 isolation \u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u3002\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u5b9a\u4e49\u4e86\u4e8b\u52a1\u5728\u5904\u7406\u5e76\u53d1\u64cd\u4f5c\u65f6\u7684\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u672a\u8bbe\u7f6e\u9694\u79bb\u7ea7\u522b\uff08Isolation\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\uff08Mode\uff09\u8bbe\u7f6e\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u5e8f\u5217\u5316\u9694\u79bb\uff08SI\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\u8bbe\u7f6e\u4e3a\u60b2\u89c2\uff08pessimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u53ef\u91cd\u590d\u8bfb\u9694\u79bb\uff08RC\uff09\u3002\u9ed8\u8ba4\uff1aRC isolation = \"RC\" mode \u4e8b\u52a1\u6a21\u5f0f\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u6a21\u5f0f\u3002\u4e8b\u52a1\u6a21\u5f0f\u5b9a\u4e49\u4e86\u5982\u4f55\u5904\u7406\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\u548c\u5e76\u53d1\u6027\u3002\u53ef\u9009\u7684\u503c\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u548c\u60b2\u89c2\uff08pessimistic\uff09\uff0c\u9ed8\u8ba4\u503c\u662f\u60b2\u89c2\uff08pessimistic\uff09\u3002 mode = \"pessimistic\" [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_4","title":"\u9ed8\u8ba4\u53c2\u6570","text":"tn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [dn] TN \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 uuid TN \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base \"TN\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 19000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"0.0.0.0\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_5","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 tn.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [dn.LogtailServer] Logtail \u670d\u52a1\u5668\u914d\u7f6e\u8282 rpc-enable-checksum \u662f\u5426\u5f00\u542f RPC \u6821\u9a8c\u548c rpc-enable-checksum = false [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_6","title":"\u9ed8\u8ba4\u53c2\u6570","text":"log.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [logservice] Logservice \u914d\u7f6e\u8282 uuid Logservice \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir \u9ed8\u8ba4\u6570\u636e\u76ee\u5f55 data-dir = \"./mo-data/logservice\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_7","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 log.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [logservice.BootstrapConfig] num-of-log-shards num-of-log-shards = 0 num-of-tn-shards num-of-tn-shards = 0 num-of-log-shard-replicas num-of-log-shard-replicas = 0 [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_8","title":"\u9ed8\u8ba4\u53c2\u6570","text":"proxy.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 listen-address \u76d1\u542c\u5730\u5740\uff0c\u9ed8\u8ba4\u4e3a0.0.0.0:6009
listen-address = \"0.0.0.0:6009\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_9","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 proxy.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 rebalance-interval \u91cd\u65b0\u5e73\u8861\u95f4\u9694\u3002\u8fd9\u662f\u4e24\u6b21\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u662f\u4e3a\u4e86\u5747\u8861\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8d1f\u8f7d\uff0c\u786e\u4fdd\u6bcf\u4e2a\u670d\u52a1\u5668\u90fd\u5177\u6709\u76f8\u4f3c\u7684\u5de5\u4f5c\u91cf\u3002 rebalance-interval = 30 rebalance-disabled \u91cd\u65b0\u5e73\u8861\u7981\u7528\u6807\u5fd7\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u88ab\u7981\u7528\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u81ea\u52a8\u6267\u884c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002 rebalance-disabled = false rebalance-tolerance \u91cd\u65b0\u5e73\u8861\u5bb9\u5fcd\u5ea6\u3002\u8fd9\u4e2a\u53c2\u6570\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u7684\u5bb9\u5fcd\u7a0b\u5ea6\u3002\u5f53\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u503c avg * (1 + tolerance) \u65f6\uff0c\u8fde\u63a5\u5c06\u88ab\u8fc1\u79fb\u5230\u5176\u4ed6 CN\uff08\u8ba1\u7b97\u8282\u70b9\uff09\u670d\u52a1\u5668\u4e0a\u3002\u5bb9\u5fcd\u5ea6\u7684\u503c\u5e94\u5c0f\u4e8e 1\uff0c\u5b83\u5b9a\u4e49\u4e86\u5728\u4f55\u79cd\u7a0b\u5ea6\u4e0a\u8fde\u63a5\u6570\u53ef\u4ee5\u8d85\u8fc7\u5e73\u5747\u503c\u800c\u4e0d\u89e6\u53d1\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5bb9\u5fcd\u5ea6\u8bbe\u7f6e\u4e3a 0.3\uff0c\u5f53\u67d0\u4e2a\u670d\u52a1\u5668\u7684\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u8fde\u63a5\u6570\u7684 30% \u65f6\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4f1a\u5f00\u59cb\u5c06\u8fde\u63a5\u8fc1\u79fb\u5230\u5176\u4ed6\u670d\u52a1\u5668\u4e0a\uff0c\u4ee5\u5e73\u8861\u8d1f\u8f7d\u3002 rebalance-tolerance = 0.3 [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/","title":"\u5355\u673a\u7248\u901a\u7528\u53c2\u6570\u914d\u7f6e","text":"\u5728 matrixone/etc/launch/ \u76ee\u5f55\u4e0b\u6709\u56db\u4e2a\u914d\u7f6e\u6587\u4ef6\uff1acn.toml\u3001tn.toml\u3001proxy.toml \u548c log.toml\uff0c\u7528\u4e8e\u914d\u7f6e\u901a\u7528\u53c2\u6570\u3002
"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_2","title":"\u9ed8\u8ba4\u53c2\u6570","text":"cn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [cn] cn \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 / port-base \"cn\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 18000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"127.0.0.1\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 port MatrixOne \u76d1\u542c\u53ca\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u7aef\u53e3 port = 6001 host \u76d1\u542c IP \u5730\u5740 host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_3","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 cn.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 unix-socket \u76d1\u542c Unix \u57df\u63a5\u53e3 unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted \u63a7\u5236\u53f0\u8f93\u51fa\u67e5\u8be2\u957f\u5ea6 lengthOfQueryPrinted = 200000 enableTls \u662f\u5426\u542f\u7528 TLS enableTls = false tlsCaFile \u5ba2\u6237\u7aef SSL CA \u5217\u8868\u6587\u4ef6\u8def\u5f84 tlsCaFile = '' tlsCertFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsCertFile = '' tlsKeyFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsKeyFile = '' saveQueryResult \u662f\u5426\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c saveQueryResult = false queryResultTimeout \u67e5\u8be2\u7ed3\u679c\u8d85\u65f6\u65f6\u95f4 queryResultTimeout = 24 queryResultMaxsize \u67e5\u8be2\u7ed3\u679c\u6700\u5927\u89c4\u6a21 queryResultMaxsize = 100 lowerCaseTableNames \u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u654f\u611f\uff0c\u9ed8\u8ba4\u53c2\u6570\u503c\u4e3a 1\uff0c\u8868\u793a\u5927\u5c0f\u5199\u4e0d\u654f\u611f lowerCaseTableNames = 1 [cn.Txn] \u4e8b\u52a1\u914d\u7f6e\u8282 isolation \u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u3002\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u5b9a\u4e49\u4e86\u4e8b\u52a1\u5728\u5904\u7406\u5e76\u53d1\u64cd\u4f5c\u65f6\u7684\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u672a\u8bbe\u7f6e\u9694\u79bb\u7ea7\u522b\uff08Isolation\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\uff08Mode\uff09\u8bbe\u7f6e\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u5e8f\u5217\u5316\u9694\u79bb\uff08SI\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\u8bbe\u7f6e\u4e3a\u60b2\u89c2\uff08pessimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u53ef\u91cd\u590d\u8bfb\u9694\u79bb\uff08RC\uff09\u3002\u9ed8\u8ba4\uff1aRC isolation = \"RC\" mode \u4e8b\u52a1\u6a21\u5f0f\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u6a21\u5f0f\u3002\u4e8b\u52a1\u6a21\u5f0f\u5b9a\u4e49\u4e86\u5982\u4f55\u5904\u7406\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\u548c\u5e76\u53d1\u6027\u3002\u53ef\u9009\u7684\u503c\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u548c\u60b2\u89c2\uff08pessimistic\uff09\uff0c\u9ed8\u8ba4\u503c\u662f\u4e50\u89c2\uff08optimistic\uff09\u3002 mode = \"optimistic\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_4","title":"\u9ed8\u8ba4\u53c2\u6570","text":"tn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [dn] TN \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 uuid TN \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base \"TN\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 19000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_5","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 tn.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"tn.log\" [dn.LogtailServer] Logtail \u670d\u52a1\u5668\u914d\u7f6e\u8282 rpc-enable-checksum \u662f\u5426\u5f00\u542f RPC \u6821\u9a8c\u548c rpc-enable-checksum = false [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_6","title":"\u9ed8\u8ba4\u53c2\u6570","text":"log.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [logservice] Logservice \u914d\u7f6e\u8282 uuid Logservice \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir \u9ed8\u8ba4\u6570\u636e\u76ee\u5f55 data-dir = \"./mo-data\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_7","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 log.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"log1.log\" [logservice] Logservice \u914d\u7f6e\u8282 logservice-address Logservice \u5730\u5740 logservice-address = \"0.0.0.0:32000\" raft-address Raft \u5730\u5740 raft-address = \"0.0.0.0:32001\" gossip-address Gossip \u5730\u5740 gossip-address = \"0.0.0.0:32002\" gossip-seed-addresses Gossip \u79cd\u5b50\u8282\u70b9\u5730\u5740 gossip-seed-addresses = \" \" [LogtailServer.BootstrapConfig] LogtailServer \u542f\u52a8\u914d\u7f6e\u8282 init-hakeeper-members \u521d\u59cb HAKeeper \u6210\u5458 init-hakeeper-members = \" \" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_8","title":"\u9ed8\u8ba4\u53c2\u6570","text":"proxy.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 listen-address \u76d1\u542c\u5730\u5740\uff0c\u9ed8\u8ba4\u4e3a0.0.0.0:6009
listen-address = \"0.0.0.0:6009\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_9","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 proxy.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"proxy.log\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 rebalance-interval \u91cd\u65b0\u5e73\u8861\u95f4\u9694\u3002\u8fd9\u662f\u4e24\u6b21\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u662f\u4e3a\u4e86\u5747\u8861\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8d1f\u8f7d\uff0c\u786e\u4fdd\u6bcf\u4e2a\u670d\u52a1\u5668\u90fd\u5177\u6709\u76f8\u4f3c\u7684\u5de5\u4f5c\u91cf\u3002 rebalance-interval = 30 rebalance-disabled \u91cd\u65b0\u5e73\u8861\u7981\u7528\u6807\u5fd7\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u88ab\u7981\u7528\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u81ea\u52a8\u6267\u884c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002 rebalance-disabled = false rebalance-tolerance \u91cd\u65b0\u5e73\u8861\u5bb9\u5fcd\u5ea6\u3002\u8fd9\u4e2a\u53c2\u6570\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u7684\u5bb9\u5fcd\u7a0b\u5ea6\u3002\u5f53\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u503c avg * (1 + tolerance) \u65f6\uff0c\u8fde\u63a5\u5c06\u88ab\u8fc1\u79fb\u5230\u5176\u4ed6 CN\uff08\u8ba1\u7b97\u8282\u70b9\uff09\u670d\u52a1\u5668\u4e0a\u3002\u5bb9\u5fcd\u5ea6\u7684\u503c\u5e94\u5c0f\u4e8e 1\uff0c\u5b83\u5b9a\u4e49\u4e86\u5728\u4f55\u79cd\u7a0b\u5ea6\u4e0a\u8fde\u63a5\u6570\u53ef\u4ee5\u8d85\u8fc7\u5e73\u5747\u503c\u800c\u4e0d\u89e6\u53d1\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5bb9\u5fcd\u5ea6\u8bbe\u7f6e\u4e3a 0.3\uff0c\u5f53\u67d0\u4e2a\u670d\u52a1\u5668\u7684\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u8fde\u63a5\u6570\u7684 30% \u65f6\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4f1a\u5f00\u59cb\u5c06\u8fde\u63a5\u8fc1\u79fb\u5230\u5176\u4ed6\u670d\u52a1\u5668\u4e0a\uff0c\u4ee5\u5e73\u8861\u8d1f\u8f7d\u3002 rebalance-tolerance = 0.3 [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/system-parameter/","title":"\u7cfb\u7edf\u53c2\u6570\u6982\u8ff0","text":"\u5728 MatrixOne \u4e2d\uff0c\u6d89\u53ca\u591a\u79cd\u6570\u636e\u5e93\u7cfb\u7edf\u53c2\u6570\uff0c\u5176\u4e2d\u4e00\u90e8\u5206\u4ee5\u914d\u7f6e\u6587\u4ef6\u7684\u65b9\u5f0f\u8fdb\u884c\u8bbe\u7f6e\uff0c\u4ec5\u5728\u542f\u52a8\u65f6\u751f\u6548\uff0c\u8fd9\u7c7b\u53c2\u6570\u88ab\u79f0\u4e3a\u9759\u6001\u53c2\u6570\u3002
\u53e6\u4e00\u79cd\u7c7b\u578b\u662f\u53ef\u4ee5\u5728\u5ba2\u6237\u7aef\u8fdb\u884c\u52a8\u6001\u914d\u7f6e\u4e14\u7acb\u5373\u751f\u6548\u7684\u53c2\u6570\uff0c\u88ab\u79f0\u4e3a\u52a8\u6001\u53c2\u6570\u3002\u8fd9\u4e24\u79cd\u53c2\u6570\u7c7b\u578b\u7528\u4e8e\u914d\u7f6e\u548c\u63a7\u5236 MatrixOne \u670d\u52a1\u5668\u7684\u884c\u4e3a\u3002
\u52a8\u6001\u53c2\u6570\u7684\u4fee\u6539\u65b9\u5f0f\u53ef\u4ee5\u5206\u4e3a\u4f1a\u8bdd\u7ea7\u522b\u548c\u5168\u5c40\u7ea7\u522b\u7684\u53c2\u6570\u914d\u7f6e\u3002
\u5168\u5c40\u7ea7\u522b\u53c2\u6570\u914d\u7f6e\uff1a\u9488\u5bf9 MatrixOne \u5f53\u524d\u79df\u6237\u7684\u53c2\u6570\u914d\u7f6e\u3002\u8fd9\u4e9b\u53c2\u6570\u5f71\u54cd\u6240\u6709\u65b0\u8fde\u63a5\u5230\u8be5\u79df\u6237\u7684\u4f1a\u8bdd\u3002\u5168\u5c40\u53c2\u6570\u5728 MatrixOne \u670d\u52a1\u5668\u542f\u52a8\u65f6\u4f1a\u6301\u4e45\u5316\u4fdd\u5b58\u5728\u5143\u6570\u636e\u8868 mo_catalog.mo_mysql_compatbility_mode \u4e2d\uff0c\u5bf9\u5168\u5c40\u53c2\u6570\u7684\u4fee\u6539\u4f1a\u5728\u4e0b\u6b21\u767b\u5f55\u65f6\u751f\u6548\u3002
\u4f1a\u8bdd\u7ea7\u522b\u53c2\u6570\u914d\u7f6e\uff1a\u9488\u5bf9\u5355\u4e2a MatrixOne \u8fde\u63a5\u7684\u53c2\u6570\u914d\u7f6e\u3002\u8fd9\u4e9b\u53c2\u6570\u4ec5\u5f71\u54cd\u8be5\u8fde\u63a5\u7684\u884c\u4e3a\u3002\u4f1a\u8bdd\u53c2\u6570\u4f1a\u5728\u8fde\u63a5\u5efa\u7acb\u65f6\u4ece mo_catalog.mo_mysql_compatbility_mode \u4e2d\u8bfb\u53d6\uff0c\u53ef\u4ee5\u901a\u8fc7\u5ba2\u6237\u7aef\u547d\u4ee4\u6765\u914d\u7f6e\u5f53\u524d\u8fde\u63a5\u3002\u5f53\u8fde\u63a5\u5173\u95ed\u65f6\uff0c\u4f1a\u8bdd\u53c2\u6570\u7684\u914d\u7f6e\u5c06\u4f1a\u88ab\u91cd\u7f6e\u4e3a\u9ed8\u8ba4\u503c\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cMatrixOne \u662f\u4e00\u4e2a\u591a\u79df\u6237\u6570\u636e\u5e93\uff0cset global
\u53ea\u4f1a\u5f71\u54cd\u5f53\u524d\u79df\u6237\u3002
\u9759\u6001\u53c2\u6570\u7684\u76f8\u5173\u6587\u6863\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\uff1a
\u52a8\u6001\u53c2\u6570\u7684\u76f8\u5173\u6587\u6863\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\uff1a
\u5728 MatrixOne \u4e2d\uff0c\u81ea\u5b9a\u4e49\u53d8\u91cf\u662f\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u548c\u64cd\u4f5c\u503c\u7684\u673a\u5236\u3002\u81ea\u5b9a\u4e49\u53d8\u91cf\u53ef\u4ee5\u901a\u8fc7 SET
\u8bed\u53e5\u8bbe\u7f6e\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u6574\u4e2a\u4f1a\u8bdd\u671f\u95f4\u4fdd\u6301\u503c\u4e0d\u53d8\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7 SET
\u547d\u4ee4\u8fdb\u884c\u53d8\u91cf\u7684\u81ea\u5b9a\u4e49\uff0c\u5e76\u4e14\u5728 SQL \u4e2d\u4f7f\u7528\u3002\u5177\u4f53\u8bed\u6cd5\u5982\u4e0b\uff1a
SET @variable_name = value;\n
@variable_name
\u662f\u81ea\u5b9a\u4e49\u53d8\u91cf\u7684\u540d\u79f0\uff0cvalue
\u662f\u8981\u5206\u914d\u7ed9\u8be5\u53d8\u91cf\u7684\u503c\u3002\u4e00\u65e6\u5b9a\u4e49\u4e86\u53d8\u91cf\uff0c\u53ef\u4ee5\u5728 SQL \u8bed\u53e5\u4e2d\u4f7f\u7528\u5b83\u6765\u4ee3\u66ff\u5b9e\u9645\u7684\u503c\u3002
\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8bed\u53e5\u5c06\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a @max_salary
\u7684\u53d8\u91cf\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a 100000\uff1a
SET @max_salary = 100000;\n-- \u67e5\u770b @max_salary \u53d8\u91cf\u8bbe\u7f6e\u7684\u503c\nmysql> select @max_salary;\n+-------------+\n| @max_salary |\n+-------------+\n| 100000 |\n+-------------+\n1 row in set (0.01 sec)\n
\u5728\u4f7f\u7528\u81ea\u5b9a\u4e49\u53d8\u91cf\u65f6\uff0c\u53ef\u4ee5\u5c06\u5176\u5305\u542b\u5728 SQL \u8bed\u53e5\u4e2d\uff0c\u4f7f\u7528 @variable_name
\u7684\u5f62\u5f0f\u5f15\u7528\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8bed\u53e5\u5c06\u8fd4\u56de\u6240\u6709\u85aa\u6c34\u5c0f\u4e8e @max_salary
\u7684\u5458\u5de5\u8bb0\u5f55\uff1a
SELECT * FROM employees WHERE salary < @max_salary;\n
\u53ef\u4ee5\u901a\u8fc7\u66f4\u6539\u81ea\u5b9a\u4e49\u53d8\u91cf\u7684\u503c\u6765\u5f71\u54cd SQL \u67e5\u8be2\u7684\u7ed3\u679c\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8bed\u53e5\u5c06\u66f4\u6539 @max_salary
\u7684\u503c\uff0c\u5e76\u8fd4\u56de\u65b0\u7684\u67e5\u8be2\u7ed3\u679c\uff1a
SET @max_salary = 80000;\nSELECT * FROM employees WHERE salary < @max_salary;\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u81ea\u5b9a\u4e49\u53d8\u91cf\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u4fdd\u6301\u6709\u6548\uff0c\u5f53\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u53d8\u91cf\u5c06\u88ab\u5220\u9664\u5e76\u91ca\u653e\u3002\u6b64\u5916\uff0c\u53d8\u91cf\u540d\u5fc5\u987b\u4ee5 @
\u7b26\u53f7\u5f00\u5934\uff0c\u5e76\u4e14\u5927\u5c0f\u5199\u654f\u611f\u3002
\u73b0\u5728\u4ee5\u5b9a\u4e49\u4e24\u4e2a\u53d8\u91cf a \u548c b \u4e3a\u4f8b\uff1a
> SET @a=2, @b=3;\nQuery OK, 0 rows affected (0.00 sec)\n\n> select @a;\n+------+\n| @a |\n+------+\n| 2 |\n+------+\n1 row in set (0.00 sec)\n\n> select @b;\n+------+\n| @b |\n+------+\n| 3 |\n+------+\n1 row in set (0.00 sec)\n
\u5728 SQL \u4e2d\u4f7f\u7528\u81ea\u5b9a\u4e49\u53d8\u91cf\uff1a
> create table t1(a int,b varchar(1));\nQuery OK, 0 rows affected (0.02 sec)\n\n> insert into t1 values(@a,@b);\nQuery OK, 1 row affected (0.02 sec)\n\n> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 3 |\n+------+------+\n1 row in set (0.01 sec)\n
Note
\u53d8\u91cf a \u548c b \u5728\u6b64\u5904\u90fd\u662f int \u6570\u636e\u7c7b\u578b\uff0c\u5982\u679c\u60f3\u8981\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684 2 \u6216 3\uff0c\u5efa\u8bae\u4f7f\u7528 SET @a='2', @b='3';
\u3002
MatrixOne \u652f\u6301\u4f1a\u8bdd\u7ea7\u522b\uff0c\u4e0e MySQL \u652f\u6301\u60c5\u51b5\u76f8\u540c\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/","title":"\u5916\u952e\u7ea6\u675f\u68c0\u67e5","text":"\u5728 MatrixOne \u4e2d\uff0cforeign_key_checks
\u662f\u4e00\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff0c\u7528\u4e8e\u63a7\u5236\u5916\u952e\u7ea6\u675f\u7684\u68c0\u67e5\u3002\u8fd9\u4e2a\u53d8\u91cf\u53ef\u4ee5\u662f\u5168\u5c40\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u4f1a\u8bdd\u7ea7\u522b\u7684\u3002\u5f53\u8bbe\u7f6e\u4e3a 1\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0cMatrixOne \u4f1a\u68c0\u67e5\u5916\u952e\u7ea6\u675f\u7684\u5b8c\u6574\u6027\uff0c\u786e\u4fdd\u6570\u636e\u7684\u53c2\u7167\u5b8c\u6574\u6027\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0\uff0c\u5219\u8df3\u8fc7\u8fd9\u4e9b\u68c0\u67e5\u3002
Note
\u4e0e MySQL \u884c\u4e3a\u4e0d\u4e00\u81f4\u7684\u662f\uff0c\u5f53\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u5220\u9664\u7236\u8868\uff0cMySQL \u4e0d\u4f1a\u5220\u9664\u5b50\u8868\u5f15\u7528\u7236\u8868\u7684\u5916\u952e\u5173\u7cfb\uff0c\u4f46 MatrixOne \u4f1a\u5220\u9664\u5b50\u8868\u5f15\u7528\u7236\u8868\u7684\u5916\u952e\u5173\u7cfb\uff0c\u91cd\u5efa\u7236\u8868\u540e\u4f1a\u91cd\u65b0\u5efa\u7acb\u5916\u952e\u5173\u7cfb\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/#foreign_key_checks","title":"\u67e5\u770b foreign_key_checks","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b foreign_key_checks\uff1a
--\u5168\u5c40\u6a21\u5f0f\nSELECT @@global.foreign_key_checks;\nSHOW global VARIABLES LIKE 'foreign_key_checks';\n\n--\u4f1a\u8bdd\u6a21\u5f0f\nSELECT @@session.foreign_key_checks;\nSHOW session VARIABLES LIKE 'foreign_key_checks';\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/#foreign_key_checks_1","title":"\u8bbe\u7f6e foreign_key_checks","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e foreign_key_checks\uff1a
--\u5168\u5c40\u6a21\u5f0f\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\nset global foreign_key_checks = 'xxx' --\u4f1a\u8bdd\u6a21\u5f0f\nset session foreign_key_checks = 'xxx'\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/#_2","title":"\u793a\u4f8b","text":"mysql> SELECT @@session.foreign_key_checks;\n+----------------------+\n| @@foreign_key_checks |\n+----------------------+\n| 1 |\n+----------------------+\n1 row in set (0.00 sec)\n\ncreate table t2(a int primary key,b int);\ncreate table t1( b int, constraint `c1` foreign key `fk1` (b) references t2(a));\n\ninsert into t2 values(1,2);\nmysql> insert into t1 values(3);--\u5f00\u542f\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u4e0d\u80fd\u63d2\u5165\u8fdd\u53cd\u7ea6\u675f\u7684\u503c\nERROR 20101 (HY000): internal error: Cannot add or update a child row: a foreign key constraint fails\n\nmysql> drop table t2;--\u5f00\u542f\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u4e0d\u80fd\u5220\u9664\u7236\u8868\nERROR 20101 (HY000): internal error: can not drop table 't2' referenced by some foreign key constraint\n\nset session foreign_key_checks =0;--\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\nmysql> SELECT @@session.foreign_key_checks;\n+----------------------+\n| @@foreign_key_checks |\n+----------------------+\n| 0 |\n+----------------------+\n1 row in set (0.00 sec)\n\nmysql> insert into t1 values(3);--\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u53ef\u4ee5\u63d2\u5165\u8fdd\u53cd\u7ea6\u675f\u7684\u503c\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> drop table t2;--\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u53ef\u4ee5\u5220\u9664\u7236\u8868\uff0c\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> show create table t1;--\u5220\u9664\u7236\u8868\uff0c\u5916\u952e\u7ea6\u675f\u4e5f\u88ab\u5220\u9664\n+-------+--------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`b` INT DEFAULT NULL\n) |\n+-------+--------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> create table t2(n1 int);--\u91cd\u5efa\u88ab\u5220\u9664\u7684\u7236\u8868 t2\uff0c\u9700\u5305\u542b\u5b50\u8868\u539f\u5916\u952e\u5f15\u7528\u5217\nERROR 20101 (HY000): internal error: column 'a' no exists in table ''\n\nmysql> create table t2(n1 int,a int primary key);--\u5305\u542b\u88ab\u5f15\u7528\u7684\u4e3b\u952e\u5217 a\uff0c\u91cd\u5efa\u6210\u529f\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show create table t1;--\u91cd\u5efa t2 \u540e\uff0c\u5916\u952e\u5173\u7cfb\u4f1a\u81ea\u52a8\u91cd\u65b0\u5efa\u7acb\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`b` INT DEFAULT NULL,\nCONSTRAINT `c1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/keep_user_target_list_in_result/","title":"keep_user_target_list_in_result \u4fdd\u6301\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u5927\u5c0f\u5199\u4e00\u81f4","text":"\u5728 MatrixOne \u67e5\u8be2\u4e2d\uff0c\u4fdd\u6301\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u4e00\u81f4\uff0c\u9664\u4e86\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u522b\u540d\uff08alias\uff09\u6765\u5b9e\u73b0\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u53c2\u6570\u6765\u5b9e\u73b0\u3002
keep_user_target_list_in_result
\u662f MatrixOne \u8bbe\u7f6e\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u5199\u662f\u5426\u4e00\u81f4\u7684\u4e00\u4e2a\u5168\u5c40\u53c2\u6570\u3002
\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b keep_user_target_list_in_result
\uff1a
--\u9ed8\u8ba4\u4e3a 1\nshow variables like \"keep_user_target_list_in_result\";\nselect @@keep_user_target_list_in_result;\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/keep_user_target_list_in_result/#keep_user_target_list_in_result_2","title":"\u8bbe\u7f6e keep_user_target_list_in_result","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e keep_user_target_list_in_result
\uff1a
--\u9ed8\u8ba4\u4e3a 1\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\nset global keep_user_target_list_in_result = 0;\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/keep_user_target_list_in_result/#_1","title":"\u793a\u4f8b","text":"create table t1(aa int, bb int, cc int, AbC varchar(25), A_BC_d double);\ninsert into t1 values (1,2,3,'A',10.9);\n\nmysql> select * from t1; +------+------+------+------+--------+\n| aa | bb | cc | abc | a_bc_d |\n+------+------+------+------+--------+\n| 1 | 2 | 3 | A | 10.9 |\n+------+------+------+------+--------+\n1 row in set (0.00 sec)\n\nmysql> select @@keep_user_target_list_in_result; --\u67e5\u8be2\u53c2\u6570\u503c\uff0c\u9ed8\u8ba4\u5f00\u542f\n+-----------------------------------+\n| @@keep_user_target_list_in_result |\n+-----------------------------------+\n| 1 |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select aA, bB, CC, abc, a_Bc_D from t1;--\u5728\u5f00\u542f\u60c5\u51b5\u4e0b\uff0c\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u5199\u4e00\u81f4\n+------+------+------+------+--------+\n| aA | bB | CC | abc | a_Bc_D |\n+------+------+------+------+--------+\n| 1 | 2 | 3 | A | 10.9 |\n+------+------+------+------+--------+\n1 row in set (0.00 sec)\n\nmysql> set global keep_user_target_list_in_result =0;--\u5173\u95ed\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u4e00\u81f4\u8bbe\u7f6e\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> exit;--\u9000\u51fa\u6570\u636e\u5e93\u91cd\u65b0\u8fde\u63a5\u540e\u53c2\u6570\u751f\u6548\n\nmysql> show variables like \"keep_user_target_list_in_result\";\n+---------------------------------+-------+\n| Variable_name | Value |\n+---------------------------------+-------+\n| keep_user_target_list_in_result | 0 |\n+---------------------------------+-------+\n1 row in set (0.00 sec)\n\nmysql> select aA, bB, CC, abc, a_Bc_D from t1;--\u5728\u8bbe\u7f6e\u5173\u95ed\u60c5\u51b5\u4e0b\uff0c\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u5199\u4e0d\u4e00\u81f4\n+------+------+------+------+--------+\n| aa | bb | cc | abc | a_bc_d |\n+------+------+------+------+--------+\n| 1 | 2 | 3 | A | 10.9 |\n+------+------+------+------+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/","title":"lower_case_table_names \u5927\u5c0f\u5199\u654f\u611f\u652f\u6301","text":"lower_case_table_names
\u662f MatrixOne \u8bbe\u7f6e\u5927\u5c0f\u5199\u662f\u5426\u654f\u611f\u7684\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u3002
Note
\u4e0e mysql \u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u6682\u65f6\u53ea\u652f\u6301 0 \u548c 1 \u4e24\u79cd\u6a21\u5f0f\uff0c\u4e14\u5728 linux \u548c mac \u7cfb\u7edf\u4e0b\u9ed8\u8ba4\u503c\u90fd\u4e3a 1\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#lower_case_table_names_1","title":"\u67e5\u770b lower_case_table_names","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b lower_case_table_names
\uff1a
show variables like \"lower_case_table_names\";--\u9ed8\u8ba4\u4e3a 1\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#lower_case_table_names_2","title":"\u8bbe\u7f6e lower_case_table_names","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e lower_case_table_names
\uff1a
set global lower_case_table_names = 0;--\u9ed8\u8ba4\u4e3a 1\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#_1","title":"\u53c2\u6570\u89e3\u91ca","text":""},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#0","title":"\u53c2\u6570\u8bbe\u7f6e\u4e3a 0","text":"\u5c06 lower_case_table_names
\u8bbe\u7f6e\u4e3a 0\u3002\u6807\u8bc6\u7b26\u5b58\u50a8\u4e3a\u539f\u59cb\u5b57\u7b26\u4e32\uff0c\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u654f\u611f\u3002
\u793a\u4f8b
mysql> show variables like \"lower_case_table_names\";--\u67e5\u770b\u9ed8\u8ba4\u53c2\u6570\uff0c\u9ed8\u8ba4\u503c\u4e3a 1\n+------------------------+-------+\n| Variable_name | Value |\n+------------------------+-------+\n| lower_case_table_names | 1 |\n+------------------------+-------+\n1 row in set (0.00 sec)\n\nset global lower_case_table_names = 0;--\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\n\nmysql> show variables like \"lower_case_table_names\";--\u91cd\u8fde\u6570\u636e\u5e93\u67e5\u770b\u53c2\u6570\uff0c\u4fee\u6539\u6210\u529f\n+------------------------+-------+\n| Variable_name | Value |\n+------------------------+-------+\n| lower_case_table_names | 0 |\n+------------------------+-------+\n1 row in set (0.00 sec)\n\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;--\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u654f\u611f\n+------+\n| Aa |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#1","title":"\u53c2\u6570\u8bbe\u7f6e\u4e3a 1","text":"\u5c06 lower_case_table_names
\u8bbe\u7f6e\u4e3a 1\u3002\u6807\u8bc6\u7b26\u5b58\u50a8\u4e3a\u5c0f\u5199\uff0c\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002
\u793a\u4f8b
set global lower_case_table_names = 1;--\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\n\nmysql> show variables like \"lower_case_table_names\";--\u91cd\u8fde\u6570\u636e\u5e93\u67e5\u770b\u53c2\u6570\uff0c\u4fee\u6539\u6210\u529f\n+------------------------+-------+\n| Variable_name | Value |\n+------------------------+-------+\n| lower_case_table_names | 1 |\n+------------------------+-------+\n1 row in set (0.00 sec)\n\ncreate table Tt (Aa int,Bb int);\ninsert into Tt values (1,2), (2,3), (3,4);\n\nmysql> select Aa from Tt;--\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u4e0d\u654f\u611f\n+------+\n| aa |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.03 sec)\n\n-- \u5217\u7684\u522b\u540d\u5728\u8fd4\u56de\u7ed3\u679c\u96c6\u65f6\u4f1a\u663e\u793a\u539f\u59cb\u5b57\u7b26\u4e32\uff0c\u4f46\u540d\u79f0\u6bd4\u8f83\u65f6\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a\nmysql> select Aa as AA,Bb from Tt;\n+------+------+\n| AA | bb |\n+------+------+\n| 1 | 2 |\n| 2 | 3 |\n| 3 | 4 |\n+------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/","title":"save_query_result \u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u652f\u6301","text":"\u5f00\u542f save_query_result
\u540e\uff0cMatrixOne \u4f1a\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u3002
\u5bf9\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u6709\u5f71\u54cd\u7684\u53c2\u6570\u6709\u4e09\u4e2a\uff1a
save_query_result
\uff1a\u5f00\u542f/\u5173\u95ed\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u3002
query_result_timeout
\uff1a\u8bbe\u7f6e\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u7684\u65f6\u95f4\u3002
query_result_maxsize
\uff1a\u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u6700\u5927\u503c\u3002
SELECT
, SHOW
, DESC
, EXECUTE
\u8bed\u53e5SELECT
\u8bed\u53e5\uff0c\u53ea\u4fdd\u5b58\u4ee5 /* cloud_user */
\u548c /* save_result */
\u56fa\u5b9a\u5f00\u5934\u7684 SELECT
\u8bed\u53e5\u7684\u7ed3\u679c\u3002-- \u9ed8\u8ba4\u4e3a off\nset save_query_result = on
-- \u9ed8\u8ba4\u4e3a off\nset global save_query_result = on
\u5168\u5c40\u5f00\u542f\u4e5f\u53ef\u5728\u542f\u52a8 MatrixOne \u4e4b\u524d\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 cn.toml
\uff0c\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1a
[cn.frontend]\nsaveQueryResult = \"on\" // \u9ed8\u8ba4\u4e3a off\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_3","title":"\u8bbe\u7f6e\u4fdd\u5b58\u65f6\u95f4","text":"\u8bbe\u7f6e\u4fdd\u5b58\u65f6\u95f4\u5355\u4f4d\u4e3a\u5c0f\u65f6\u3002
-- \u9ed8\u8ba4\u4e3a 24\nset query_result_timeout = 48\n
-- \u9ed8\u8ba4\u4e3a 24\nset global query_result_timeout = 48\n
\u5168\u5c40\u5f00\u542f\u4e5f\u53ef\u5728\u542f\u52a8 MatrixOne \u4e4b\u524d\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 cn.toml
\uff0c\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1a
[cn.frontend]\nqueryResultTimeout = 48 // \u9ed8\u8ba4\u4e3a 24\n
Note: \u4fdd\u5b58\u65f6\u95f4\u5982\u679c\u8bbe\u7f6e\u7684\u503c\u6bd4\u4e0a\u4e00\u6b21\u8bbe\u7f6e\u7684\u77ed\uff0c\u4e0d\u5f71\u54cd\u4e4b\u524d\u7684\u4fdd\u5b58\u7ed3\u679c\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_4","title":"\u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u7684\u6700\u5927\u503c","text":"\u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u7684\u6700\u5927\u503c\u5355\u4f4d\u4e3a MB\u3002
-- \u9ed8\u8ba4\u4e3a 100\nset query_result_maxsize = 200\n
-- \u9ed8\u8ba4\u4e3a 100\nset global query_result_maxsize = 200\n
\u5168\u5c40\u5f00\u542f\u4e5f\u53ef\u5728\u542f\u52a8 MatrixOne \u4e4b\u524d\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 cn.toml
\uff0c\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1a
[cn.frontend]\nqueryResultMaxsize = 200 // \u9ed8\u8ba4\u4e3a 100\n
Note: \u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u7684\u6700\u5927\u503c\u5982\u679c\u8bbe\u7f6e\u7684\u503c\u6bd4\u4e0a\u4e00\u6b21\u8bbe\u7f6e\u7684\u5c0f\uff0c\u4e0d\u5f71\u54cd\u4e4b\u524d\u7684\u4fdd\u5b58\u7ed3\u679c\u5927\u5c0f\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_5","title":"\u67e5\u8be2\u5143\u6570\u636e\u4fe1\u606f","text":"\u67e5\u8be2\u5143\u6570\u636e\u4fe1\u606f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684 SQL \u8bed\u53e5\uff1a
select * from meta_scan(query_id) as u;\n\u5f53\u524d account_id\nselect query_id from meta_scan(query_id) as u;\n
\u5143\u6570\u636e\u4fe1\u606f\u5982\u4e0b\uff1a
\u5217\u540d \u7c7b\u578b \u5907\u6ce8 query_id uuid \u67e5\u8be2\u7ed3\u679c ID statement text \u6267\u884c\u7684 SQL \u8bed\u53e5 account_id uint32 \u8d26\u6237 ID role_id uint32 \u89d2\u8272 ID result_path text \u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u7684\u8def\u5f84\uff0c\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\u4e3a matrixone \u6587\u4ef6\u5939 mo-data/s3\uff0c\u5982\u9700\u4fee\u6539\u9ed8\u8ba4\u4fdd\u5b58\u7684\u8def\u5f84\uff0c\u9700\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684data-dir = \"mo-data/s3\"
\u3002\u5982\u9700\u67e5\u9605\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e\uff0c\u53c2\u89c1\u901a\u7528\u53c2\u6570\u914d\u7f6e created_time timestamp \u521b\u5efa\u65f6\u95f4 result_size float \u7ed3\u679c\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3a MB\u3002 tables text SQL \u6240\u7528\u5230\u7684\u8868 user_id uint32 \u7528\u6237 ID expired_time timestamp \u67e5\u8be2\u7ed3\u679c\u7684\u8d85\u65f6\u65f6\u95f4 column_map text \u67e5\u8be2\u5982\u679c\u6709\u540c\u540d\u7684\u5217\u7ed3\u679c\u540d\uff0cresult scan \u4f1a\u5bf9\u5217\u540d\u505a\u91cd\u6620\u5c04"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_6","title":"\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c","text":"\u4f60\u53ef\u4ee5\u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5728\u4f60\u7684\u672c\u5730\u78c1\u76d8\u6216 S3 \u4e2d\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_7","title":"\u8bed\u6cd5\u7ed3\u6784","text":"MODUMP QUERY_RESULT query_id INTO s3_path\n[FIELDS TERMINATED BY 'char']\n[ENCLOSED BY 'char']\n[LINES TERMINATED BY 'string']\n[header 'bool']\n[MAX_FILE_SIZE unsigned_number]\n
query_id\uff1a\u662f UUID \u7684\u5b57\u7b26\u4e32\u3002
s3_path\uff1a\u662f\u67e5\u8be2\u7ed3\u679c\u6587\u4ef6\u4fdd\u5b58\u7684\u8def\u5f84\u3002\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\u4e3a matrixone \u6587\u4ef6\u5939 mo-data/s3\uff0c\u5982\u9700\u4fee\u6539\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\uff0c\u9700\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 data-dir = \"mo-data/s3\"
\u3002\u5982\u9700\u67e5\u9605\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e\uff0c\u53c2\u89c1\u901a\u7528\u53c2\u6570\u914d\u7f6e
root@rootMacBook-Pro 02matrixone % cd matrixone/mo-data\nroot@rootMacBook-Pro mo-data % ls\ntn-data etl local logservice-data s3\n
Note: \u5982\u679c\u4f60\u9700\u8981\u5bfc\u51fa csv
\u6587\u4ef6\u3002\u8def\u5f84\u9700\u8981\u4ee5 etl:
\u5f00\u5934\u3002
[FIELDS TERMINATED BY 'char']\uff1a\u53ef\u9009\u53c2\u6570\u3002\u5b57\u6bb5\u5206\u5272\u7b26\u53f7\uff0c\u9ed8\u8ba4\u4e3a\u5355\u5f15\u53f7 '
\u3002
[ENCLOSED BY 'char']\uff1a\u53ef\u9009\u53c2\u6570\u3002\u5b57\u6bb5\u5305\u62ec\u7b26\u53f7\uff0c\u9ed8\u8ba4\u4e3a\u5f15\u53cc\u53f7 \u201c
\u3002
[LINES TERMINATED BY 'string']\uff1a\u53ef\u9009\u53c2\u6570\u3002\u884c\u7ed3\u675f\u7b26\u53f7\uff0c\u9ed8\u8ba4\u4e3a\u6362\u884c\u7b26\u53f7 \\n
\u3002
[header 'bool']\uff1a\u53ef\u9009\u53c2\u6570\u3002bool \u7c7b\u578b\u53ef\u4ee5\u9009\u62e9 true
\u6216 false
\u3002csv
\u6587\u4ef6\u7b2c\u4e00\u884c\u4e3a\u5404\u4e2a\u5217\u540d\u7684\u6807\u9898\u884c\u3002
[MAX_FILE_SIZE unsigned_number]\uff1a\u53ef\u9009\u53c2\u6570\u3002\u6587\u4ef6\u6700\u5927\u6587\u4ef6\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3a KB\u3002\u9ed8\u8ba4\u4e3a 0\u3002
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> /* cloud_user */select a from t1;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.16 sec)\n-- \u67e5\u8be2\u5f53\u524d\u4f1a\u8bdd\u4e2d\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2 ID\nmysql> select last_query_id();\n+--------------------------------------+\n| last_query_id() |\n+--------------------------------------+\n| f005ebc6-a3dc-11ee-bb76-26dd28356ef3 |\n+--------------------------------------+\n1 row in set (0.12 sec)\n-- \u83b7\u53d6\u8fd9\u4e2a\u67e5\u8be2 ID \u7684\u67e5\u8be2\u7ed3\u679c\nmysql> select * from result_scan('f005ebc6-a3dc-11ee-bb76-26dd28356ef3') as t;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n-- \u67e5\u770b\u8fd9\u4e2a\u67e5\u8be2 ID \u7684\u5143\u6570\u636e\nmysql> select * from meta_scan('f005ebc6-a3dc-11ee-bb76-26dd28356ef3') as t;\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| f005ebc6-a3dc-11ee-bb76-26dd28356ef3 | select a from t1 | 0 | 0 | SHARED:/query_result/sys_f005ebc6-a3dc-11ee-bb76-26dd28356ef3_1.blk | 2023-12-26 18:53:01 | 0.000003814697265625 | t1 | 0 | 2023-12-27 18:53:01 | a -> a |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n1 row in set (0.01 sec)\n\n-- \u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5230\u672c\u5730\nMODUMP QUERY_RESULT 'f005ebc6-a3dc-11ee-bb76-26dd28356ef3' INTO 'etl:your_local_path';\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> /* save_result */select a from t1;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.02 sec)\n\nmysql> select last_query_id();\n+--------------------------------------+\n| last_query_id() |\n+--------------------------------------+\n| afc82394-a45e-11ee-bb9a-26dd28356ef3 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from result_scan('afc82394-a45e-11ee-bb9a-26dd28356ef3') as t;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n\nmysql> select * from meta_scan('afc82394-a45e-11ee-bb9a-26dd28356ef3') as t;\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| afc82394-a45e-11ee-bb9a-26dd28356ef3 | select a from t1 | 0 | 0 | SHARED:/query_result/sys_afc82394-a45e-11ee-bb9a-26dd28356ef3_1.blk | 2023-12-27 10:21:47 | 0.000003814697265625 | t1 | 0 | 2023-12-28 10:21:47 | a -> a |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n1 row in set (0.00 sec)\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> show create table t1;\n+-------+--------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`a` INT DEFAULT NULL\n) |\n+-------+--------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\n+--------------------------------------+----------------------+------------+---------+---------------------------------------------------------------------+---------------------+-----------------------+--------+---------+---------------------+----------------------------------------------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+----------------------+------------+---------+---------------------------------------------------------------------+---------------------+-----------------------+--------+---------+---------------------+----------------------------------------------+\n| 617647f4-a45c-11ee-bb97-26dd28356ef3 | show create table t1 | 0 | 0 | SHARED:/query_result/sys_617647f4-a45c-11ee-bb97-26dd28356ef3_1.blk | 2023-12-27 10:05:17 | 0.0000858306884765625 | | 0 | 2023-12-28 10:05:17 | Table -> Table, Create Table -> Create Table |\n+--------------------------------------+----------------------+------------+---------+---------------------------------------------------------------------+---------------------+-----------------------+--------+---------+---------------------+----------------------------------------------+\n1 row in set (0.00 sec)\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> desc t1;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n1 row in set (0.03 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\n+--------------------------------------+-----------+------------+---------+---------------------------------------------------------------------+---------------------+---------------------+------------+---------+---------------------+----------------------------------------------------------------------------------------------------------------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+-----------+------------+---------+---------------------------------------------------------------------+---------------------+---------------------+------------+---------+---------------------+----------------------------------------------------------------------------------------------------------------+\n| 143a54b6-a45d-11ee-bb97-26dd28356ef3 | desc t1 | 0 | 0 | SHARED:/query_result/sys_143a54b6-a45d-11ee-bb97-26dd28356ef3_1.blk | 2023-12-27 10:10:17 | 0.00016021728515625 | mo_columns | 0 | 2023-12-28 10:10:17 | Field -> Field, Type -> Type, Null -> Null, Key -> Key, Default -> Default, Extra -> Extra, Comment -> Comment |\n+--------------------------------------+-----------+------------+---------+---------------------------------------------------------------------+---------------------+---------------------+------------+---------+---------------------+----------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
mysql> CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\nQuery OK, 2 rows affected (0.01 sec)\n\nmysql> SET @si_min = -9223372036854775808;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk | ui | si |\n+------+------+----------------------+\n| 0 | 0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.02 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\n+--------------------------------------+---------------------------------------------------------------------------------------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+------------------------------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+---------------------------------------------------------------------------------------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+------------------------------+\n| e83b8df2-a45d-11ee-bb98-26dd28356ef3 | EXECUTE s2 USING @si_min // SELECT * FROM numbers WHERE si=? ; SET @si_min = -9223372036854775808 | 0 | 0 | SHARED:/query_result/sys_e83b8df2-a45d-11ee-bb98-26dd28356ef3_1.blk | 2023-12-27 10:16:13 | 0.000019073486328125 | | 0 | 2023-12-28 10:16:13 | pk -> pk, ui -> ui, si -> si |\n+--------------------------------------+---------------------------------------------------------------------------------------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+------------------------------+\n1 row in set (0.00 sec)\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\nERROR 20405 (HY000): file query_result_meta/sys_c16859e4-a462-11ee-bba0-26dd28356ef3.blk is not found\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/","title":"SQL \u6a21\u5f0f","text":"sql_mode \u662f MatrixOne \u4e2d\u7684\u4e00\u4e2a\u7cfb\u7edf\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a MatrixOne \u6267\u884c\u67e5\u8be2\u548c\u64cd\u4f5c\u7684\u6a21\u5f0f\u3002sql_mode \u53ef\u4ee5\u5f71\u54cd MatrixOne \u7684\u8bed\u6cd5\u548c\u8bed\u4e49\u89c4\u5219\uff0c\u4ece\u800c\u6539\u53d8 MatrixOne \u67e5\u8be2 SQL \u7684\u884c\u4e3a\u3002\u5728\u672c\u7bc7\u6587\u7ae0\u4e2d\uff0c\u5c06\u4e3a\u4f60\u4ecb\u7ecd sql_mode \u7684\u6a21\u5f0f\u3001\u4f5c\u7528\u4ee5\u53ca\u5982\u4f55\u8bbe\u7f6e SQL \u6a21\u5f0f\u3002
Note
MatrixOne \u76ee\u524d\u53ea\u652f\u6301 ONLY_FULL_GROUP_BY
\u8fd9\u4e00\u6a21\u5f0f\uff0c\u5176\u5b83\u6a21\u5f0f\u4ec5\u4f5c\u8bed\u6cd5\u652f\u6301\u3002ONLY_FULL_GROUP_BY
\u88ab\u7528\u4e8e\u63a7\u5236 GROUP BY \u8bed\u53e5\u7684\u884c\u4e3a\u3002\u5f53\u542f\u7528 ONLY_FULL_GROUP_BY
\u6a21\u5f0f\u65f6\uff0cMatrixOne \u8981\u6c42\u5728 SELECT \u8bed\u53e5\u4e2d\u7684 GROUP BY \u5b50\u53e5\u4e2d\u7684\u5217\u5fc5\u987b\u662f\u805a\u5408\u51fd\u6570 (\u5982 SUM\u3001COUNT \u7b49) \u6216\u5728 GROUP BY \u5b50\u53e5\u4e2d\u51fa\u73b0\u7684\u5217\u3002\u5982\u679c SELECT \u8bed\u53e5\u4e2d\u5b58\u5728\u4e0d\u7b26\u5408\u8fd9\u4e2a\u8981\u6c42\u7684\u5217\uff0c\u5c06\u4f1a\u629b\u51fa\u9519\u8bef\uff0c\u5982\u679c\u4f60\u7684\u8868\u7ed3\u6784\u590d\u6742\uff0c\u4e3a\u4e86\u4fbf\u4e8e\u67e5\u8be2\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u5c06 ONLY_FULL_GROUP_BY
\u6a21\u5f0f\u5173\u95ed\u3002
\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b sql_mode\uff1a
SELECT @@global.sql_mode;--\u5168\u5c40\u6a21\u5f0f\nSELECT @@session.sql_mode;--\u4f1a\u8bdd\u6a21\u5f0f\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#sql_mode_1","title":"\u8bbe\u7f6e sql_mode","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e sql_mode\uff1a
set global sql_mode = 'xxx' --\u5168\u5c40\u6a21\u5f0f\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\nset session sql_mode = 'xxx'--\u4f1a\u8bdd\u6a21\u5f0f\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#_1","title":"\u793a\u4f8b","text":"CREATE TABLE student(\nid int,\nname char(20),\nage int,\nnation char(20)\n);\n\nINSERT INTO student values(1,'tom',18,'\u4e0a\u6d77'),(2,'jan',19,'\u4e0a\u6d77'),(3,'jen',20,'\u5317\u4eac'),(4,'bob',20,'\u5317\u4eac'),(5,'tim',20,'\u5e7f\u5dde');\n\nmysql> select * from student group by nation;--\u5728`ONLY_FULL_GROUP_BY`\u6a21\u5f0f\u4e0b\u4e0d\u652f\u6301\u8fdb\u884c\u6b64\u64cd\u4f5c\nERROR 1149 (HY000): SQL syntax error: column \"student.id\" must appear in the GROUP BY clause or be used in an aggregate function\n\nmysql> SET session sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_TRANS_TAB\nLES';--\u5173\u95ed\u5f53\u524d\u4f1a\u8bdd\u7684 ONLY_FULL_GROUP_BY \u6a21\u5f0f\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> select * from student group by nation;--\u5728\u5f53\u524d\u4f1a\u8bdd\u5173\u95ed`ONLY_FULL_GROUP_BY`\u6a21\u5f0f\u7acb\u5373\u751f\u6548\n+------+------+------+--------+\n| id | name | age | nation |\n+------+------+------+--------+\n| 1 | tom | 18 | \u4e0a\u6d77 |\n| 3 | jen | 20 | \u5317\u4eac |\n| 5 | tim | 20 | \u5e7f\u5dde |\n+------+------+------+--------+\n3 rows in set (0.00 sec)\n\nmysql> SET global sql_mode='ONLY_FULL_GROUP_BY';--\u8bbe\u7f6e\u5168\u5c40\u5f00\u542f ONLY_FULL_GROUP_BY \u6a21\u5f0f\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> select * from student group by nation;--ONLY_FULL_GROUP_BY \u6a21\u5f0f\u672a\u751f\u6548\uff0c\u56e0\u4e3a\u5168\u5c40\u6a21\u5f0f\u5f00\u542f\u540e\u9700\u8981\u91cd\u8fde\u6570\u636e\u5e93\u65b9\u53ef\u751f\u6548\n+------+------+------+--------+\n| id | name | age | nation |\n+------+------+------+--------+\n| 1 | tom | 18 | \u4e0a\u6d77 |\n| 3 | jen | 20 | \u5317\u4eac |\n| 5 | tim | 20 | \u5e7f\u5dde |\n+------+------+------+--------+\n3 rows in set (0.00 sec)\n\nmysql> exit --\u9000\u51fa\u5f53\u524d\u4f1a\u8bdd\n\nmysql> select * from student group by nation;--\u91cd\u8fde\u6570\u636e\u5e93\u540e\u6267\u884c\u67e5\u8be2\u64cd\u4f5c\uff0cONLY_FULL_GROUP_BY \u6a21\u5f0f\u6210\u529f\u5f00\u542f\nERROR 1149 (HY000): SQL syntax error: column \"student.id\" must appear in the GROUP BY clause or be used in an aggregate function\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/","title":"\u670d\u52a1\u5668\u7cfb\u7edf\u53d8\u91cf","text":"MatrixOne \u670d\u52a1\u5668\u7cfb\u7edf\u53d8\u91cf\uff08System Variable\uff09\u662f\u6307\u5728 MatrixOne Server \u4e2d\uff0c\u7528\u4e8e\u63a7\u5236\u6216\u914d\u7f6e\u6570\u636e\u5e93\u5f15\u64ce\u6216\u5176\u4ed6\u7ec4\u4ef6\u884c\u4e3a\u7684\u4e00\u7ec4\u53d8\u91cf\u3002\u8fd9\u4e9b\u53d8\u91cf\u7684\u503c\u53ef\u4ee5\u901a\u8fc7 SET
\u8bed\u53e5\u8fdb\u884c\u8bbe\u7f6e\u548c\u66f4\u6539\u3002
\u7cfb\u7edf\u53d8\u91cf\u53ef\u5206\u4e3a\u4e24\u7c7b\uff1a\u5168\u5c40\u53d8\u91cf\u548c\u4f1a\u8bdd\u53d8\u91cf\u3002
\u5168\u5c40\u53d8\u91cf\uff1a\u662f\u6307\u5bf9\u6240\u6709\u8fde\u63a5\u7684 MatrixOne \u4f1a\u8bdd\u90fd\u9002\u7528\u7684\u53d8\u91cf\u3002\u5b83\u4eec\u7684\u503c\u5728 MatrixOne Server \u542f\u52a8\u65f6\u8bbe\u7f6e\uff0c\u5e76\u5728 MatrixOne Server \u5173\u95ed\u4e4b\u524d\u4fdd\u6301\u4e0d\u53d8\u3002\u5168\u5c40\u53d8\u91cf\u901a\u5e38\u7528\u4e8e\u63a7\u5236 MatrixOne Server \u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u6307\u5b9a\u9ed8\u8ba4\u5907\u4efd\u548c\u6062\u590d\u4f4d\u7f6e\uff0c\u6307\u5b9a\u9ed8\u8ba4\u8bed\u8a00\u73af\u5883\u7b49\u3002
\u4f1a\u8bdd\u53d8\u91cf\uff1a\u662f\u6307\u53ea\u5bf9\u5f53\u524d\u7528\u6237\u8fde\u63a5\u7684 MatrixOne \u4f1a\u8bdd\u9002\u7528\u7684\u53d8\u91cf\u3002\u5b83\u4eec\u7684\u503c\u53ef\u4ee5\u5728\u7528\u6237\u8fde\u63a5\u7684\u4efb\u4f55\u65f6\u95f4\u66f4\u6539\uff0c\u5e76\u5728\u7528\u6237\u65ad\u5f00\u8fde\u63a5\u65f6\u81ea\u52a8\u6e05\u9664\u3002\u4f1a\u8bdd\u53d8\u91cf\u901a\u5e38\u7528\u4e8e\u63a7\u5236\u4f1a\u8bdd\u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u63a7\u5236\u6253\u5370\u4fe1\u606f\u7684\u65b9\u5f0f\uff0c\u6307\u5b9a\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u7b49\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8be2\uff1a
SHOW VARIABLES;\n
\u8fd9\u4f1a\u5217\u51fa\u6240\u6709\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u67e5\u770b\u4e0e\u7279\u5b9a\u4e3b\u9898\u76f8\u5173\u7684\u7cfb\u7edf\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
SHOW VARIABLES LIKE '%theme%';\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002
Note: LIKE
\u8fd0\u7b97\u7b26\u662f\u7528\u6765\u6a21\u7cca\u5339\u914d\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\uff0c% \u8868\u793a\u96f6\u4e2a\u6216\u591a\u4e2a\u4efb\u610f\u5b57\u7b26\u3002\u6240\u4ee5\uff0c\u4e0a\u8ff0\u547d\u4ee4\u5c06\u5339\u914d\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4efb\u4f55\u7cfb\u7edf\u53d8\u91cf\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8be2\uff1a
SHOW GLOBAL VARIABLES;\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u5168\u5c40\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u67e5\u770b\u4e0e\u7279\u5b9a\u4e3b\u9898\u76f8\u5173\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
SHOW GLOBAL VARIABLES LIKE '%theme%';\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u5168\u5c40\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002
Note: LIKE
\u8fd0\u7b97\u7b26\u662f\u7528\u6765\u6a21\u7cca\u5339\u914d\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\uff0c% \u8868\u793a\u96f6\u4e2a\u6216\u591a\u4e2a\u4efb\u610f\u5b57\u7b26\u3002\u6240\u4ee5\uff0c\u4e0a\u8ff0\u547d\u4ee4\u5c06\u5339\u914d\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4efb\u4f55\u5168\u5c40\u7cfb\u7edf\u53d8\u91cf\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8be2\uff1a
SHOW SESSION VARIABLES;\n
\u8fd9\u5c06\u5217\u51fa\u5f53\u524d\u4f1a\u8bdd\u4e2d\u6240\u6709\u7684\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u67e5\u770b\u4e0e\u7279\u5b9a\u4e3b\u9898\u76f8\u5173\u7684\u4f1a\u8bdd\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
SHOW SESSION VARIABLES LIKE '%theme%';\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4f1a\u8bdd\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002
Note: LIKE
\u8fd0\u7b97\u7b26\u662f\u7528\u6765\u6a21\u7cca\u5339\u914d\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\uff0c% \u8868\u793a\u96f6\u4e2a\u6216\u591a\u4e2a\u4efb\u610f\u5b57\u7b26\u3002\u6240\u4ee5\uff0c\u4e0a\u8ff0\u547d\u4ee4\u5c06\u5339\u914d\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4efb\u4f55\u4f1a\u8bdd\u7cfb\u7edf\u53d8\u91cf\u3002
MatrixOne \u4e3a\u517c\u5bb9 MySQL\uff0cSQL \u6a21\u5f0f\u53ea\u652f\u6301 ONLY_FULL_GROUP_BY
\u6a21\u5f0f\uff1b\u5176\u4ed6 SQL \u6a21\u5f0f\u4ec5\u8bed\u6cd5\u652f\u6301\uff0c\u5b9e\u9645\u4e0d\u8d77\u4f5c\u7528\u3002
MatrixOne \u4f7f\u7528\u7684\u65f6\u533a\u53d6\u51b3\u4e8e\u4e09\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff1aglobal.time_zone
\uff0csession.time_zone
\u548c global.system_time_zone
\u3002
global.system_time_zone
\u8868\u793a\u670d\u52a1\u5668\u7cfb\u7edf\u65f6\u533a\u3002\u5f53\u670d\u52a1\u5668\u542f\u52a8\u65f6\uff0c\u5b83\u4f1a\u5c1d\u8bd5\u786e\u5b9a\u4e3b\u673a\u7684\u65f6\u533a\uff0c\u5e76\u4f7f\u7528\u5b83\u6765\u8bbe\u7f6e\u7cfb\u7edf\u65f6\u533a\uff08system_time_zone
\uff09\u3002
global.time_zone
\u8868\u793a\u670d\u52a1\u5668\u5f53\u524d\u65f6\u533a\u3002\u521d\u59cb time_zone
\u503c\u4e3a SYSTEM
\uff0c\u8868\u793a\u670d\u52a1\u5668\u65f6\u533a\u4e0e\u7cfb\u7edf\u65f6\u533a\u76f8\u540c\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5728\u8fd0\u884c\u65f6\u8bbe\u7f6e\u5168\u5c40\u670d\u52a1\u5668\u65f6\u533a\uff0c\u8bbe\u7f6e\u5b8c\u6210\u540e\u65e0\u6cd5\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u751f\u6548\uff0c\u4f60\u9700\u8981\u5148\u9000\u51fa\u5f53\u524d\u4f1a\u8bdd\uff0c\u518d\u6b21\u91cd\u65b0\u8fde\u63a5 MatrixOne \u65f6\u624d\u4f1a\u751f\u6548\u3002
> SET GLOBAL time_zone = timezone;\n
time_zone
\u53d8\u91cf\u51b3\u5b9a\u3002\u6700\u521d\uff0c\u4f1a\u8bdd\u65f6\u533a\u7684\u53d8\u91cf\u503c\u4ece\u5168\u5c40 time_zone
\u53d8\u91cf\u4e2d\u83b7\u5f97\uff0c\u4f46\u4f1a\u8bdd\u5ba2\u6237\u7aef\u53ef\u4ee5\u66f4\u6539\u81ea\u5df1\u7684\u65f6\u533a\u3002\u4f46\u662f\u8fd9\u4e2a\u8fd9\u4e2a\u8bbe\u7f6e\u53ea\u4f1a\u5728\u5f53\u524d\u4f1a\u8bdd\u671f\u95f4\u6709\u6548\u3002SET time_zone = timezone;\n
\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5f53\u524d\u5168\u5c40\u65f6\u533a\u3001\u5ba2\u6237\u7aef\u65f6\u533a\u548c\u7cfb\u7edf\u65f6\u533a\u7684\u503c\uff1a
> SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| timezone | +08:00 | CST |\n+-------------+-------------+--------------------+\n1 row in set (0.01 sec)\n
\u8bbe\u7f6e time_zone \u7684\u503c\u7684\u683c\u5f0f\uff1a
\u503c SYSTEM
\u8868\u793a\u65f6\u533a\u5e94\u4e0e\u670d\u52a1\u5668\u7cfb\u7edf\u65f6\u533a\u76f8\u540c\u3002
\u503c UTC
\u8868\u793a\u65f6\u533a\u8bbe\u7f6e\u4e3a UTC\uff08Coordinated Universal Time\uff0c\u534f\u8c03\u4e16\u754c\u65f6\uff09\u3002\u4ec5\u652f\u6301\u201cUTC\u201d\u7f29\u5199\u4f5c\u4e3a\u65f6\u533a\u4f7f\u7528\u3002
\u8be5\u503c\u53ef\u4ee5\u4f5c\u4e3a\u5b57\u7b26\u4e32\u7ed9\u51fa\uff0c\u8868\u793a UTC \u65f6\u95f4\u7684\u504f\u79fb\uff0c\u683c\u5f0f\u4e3a\u201cHH:MM\u201d\uff0c\u5e26\u6709 + \u6216 -\uff0c\u4f8b\u5982 +10:00
\u6216\u8005 -6:00
\u3002\u5141\u8bb8\u7684\u8303\u56f4\u662f\u201c-13:59\u201d\u5230\u201c+14:00\u201d\u3002
\u5f53\u524d\u4f1a\u8bdd\u65f6\u533a\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u65f6\u533a\u654f\u611f\u65f6\u95f4\u503c\u7684\u663e\u793a\u548c\u5b58\u50a8\u3002\u5373\u4f1a\u5f71\u54cd\u6267\u884c NOW()
\u7b49\u51fd\u6570\u67e5\u8be2\u5230\u7684\u503c\u4ee5\u53ca\u5b58\u50a8\u5728 TIMESTAMP
\u5217\u4e2d\u548c\u4ece TIMESTAMP
\u5217\u4e2d\u67e5\u8be2\u5230\u7684\u503c\u3002
\u4f1a\u8bdd\u65f6\u533a\u8bbe\u7f6e\u4e0d\u5f71\u54cd UTC_TIMESTAMP()
\u7b49\u51fd\u6570\u663e\u793a\u7684\u503c\u6216 DATE
\u3001TIME
\u6216 DATETIME
\u5217\u4e2d\u7684\u503c\u3002
Note
\u53ea\u6709 Timestamp \u6570\u636e\u7c7b\u578b\u7684\u503c\u662f\u53d7\u65f6\u533a\u5f71\u54cd\u7684\u3002\u53ef\u4ee5\u7406\u89e3\u4e3a\uff0cTimestamp \u6570\u636e\u7c7b\u578b\u7684\u5b9e\u9645\u8868\u793a\u4f7f\u7528\u7684\u662f\uff08\u5b57\u9762\u503c + \u65f6\u533a\u4fe1\u606f\uff09\u3002\u5176\u5b83\u65f6\u95f4\u548c\u65e5\u671f\u7c7b\u578b\uff0c\u6bd4\u5982 Datetime/Date/Time \u662f\u4e0d\u5305\u542b\u65f6\u533a\u4fe1\u606f\u7684\uff0c\u6240\u4ee5\u4e5f\u4e0d\u53d7\u5230\u65f6\u533a\u53d8\u5316\u7684\u5f71\u54cd\u3002
> SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| SYSTEM | SYSTEM | CST |\n+-------------+-------------+--------------------+\n1 row in set (0.00 sec)\n\n> create table t (ts timestamp, dt datetime);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> set @@time_zone = 'UTC';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> insert into t values ('2017-09-30 11:11:11', '2017-09-30 11:11:11');\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> set @@time_zone = '+08:00';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select * from t;\n+---------------------+---------------------+\n| ts | dt |\n+---------------------+---------------------+\n| 2017-09-30 19:11:11 | 2017-09-30 11:11:11 |\n+---------------------+---------------------+\n1 row in set (0.00 sec)\n
\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u65e0\u8bba\u600e\u4e48\u8c03\u6574\u65f6\u533a\u7684\u503c\uff0cDatetime \u7c7b\u578b\u5b57\u6bb5\u7684\u503c\u662f\u4e0d\u53d7\u5f71\u54cd\u7684\uff0c\u800c Timestamp \u5219\u968f\u7740\u65f6\u533a\u6539\u53d8\uff0c\u663e\u793a\u7684\u503c\u4f1a\u53d1\u751f\u53d8\u5316\u3002\u5176\u5b9e Timestamp \u6301\u4e45\u5316\u5230\u5b58\u50a8\u7684\u503c\u59cb\u7ec8\u6ca1\u6709\u53d8\u5316\u8fc7\uff0c\u53ea\u662f\u6839\u636e\u65f6\u533a\u7684\u4e0d\u540c\u663e\u793a\u503c\u4e0d\u540c\u3002
Note
Timestamp \u7c7b\u578b\u548c Datetime \u7b49\u7c7b\u578b\u7684\u503c\uff0c\u4e24\u8005\u76f8\u4e92\u8f6c\u6362\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u6d89\u53ca\u5230\u65f6\u533a\u3002\u8fd9\u79cd\u60c5\u51b5\u4e00\u5f8b\u57fa\u4e8e\u5f53\u524d time_zone \u65f6\u533a\u5904\u7406\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/#matrixone","title":"\u4fee\u6539 MatrixOne \u65f6\u533a","text":"> select now();\n+----------------------------+\n| now() |\n+----------------------------+\n| 2022-10-14 18:38:27.876181 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n> show variables like \"%time_zone%\";\n+------------------+--------+\n| Variable_name | Value |\n+------------------+--------+\n| system_time_zone | CST |\n| time_zone | SYSTEM |\n+------------------+--------+\n2 rows in set (0.00 sec)\n
time_zone
\uff1a\u4f7f\u7528 system \u7684\u65f6\u533a\u3002
system_time_zone
\u8bf4\u660e system \u4f7f\u7528\u670d\u52a1\u5668\u7cfb\u7edf\u65f6\u533a\u3002
\u4fee\u6539\u5f53\u524d\u65f6\u533a\uff1a
set global time_zone = '+08:00';\nset time_zone = '+08:00';\n
set global time_zone = '+08:00';
\uff1a\u4fee\u6539 MatrixOne \u5168\u5c40\u65f6\u533a\u4e3a\u5317\u4eac\u65f6\u95f4\uff0c\u5373\u6211\u4eec\u6240\u5728\u7684\u4e1c 8 \u533a\u3002set time_zone = '+08:00';
\uff1a\u4fee\u6539\u5f53\u524d\u4f1a\u8bdd\u65f6\u533a\u3002MatrixOne \u4ec5\u652f\u6301 (+/-)HH:MM
\u683c\u5f0f\u548c UTC
\u6765\u8bbe\u7f6e time_zone
\u7684\u503c\u3002
mo_ctl
\u662f\u4e00\u6b3e\u5e2e\u52a9\u4f60\u5bf9\u5355\u673a\u7248 MatrixOne \u8fdb\u884c\u90e8\u7f72\u5b89\u88c5\u3001\u542f\u505c\u63a7\u5236\u4ee5\u53ca\u6570\u636e\u5e93\u8fde\u63a5\u7b49\u64cd\u4f5c\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002
mo_ctl
\u76ee\u524d\u5df2\u9002\u914d\u8fc7\u7684\u64cd\u4f5c\u7cfb\u7edf\u5982\u4e0b\u8868\u6240\u793a\uff1a
mo_ctl
\u76ee\u524d\u7684\u529f\u80fd\u5217\u8868\u5982\u4e0b\u8868\u6240\u793a\u3002
mo_ctl help
\u67e5\u770bmo_ctl
\u5de5\u5177\u672c\u8eab\u7684\u8bed\u53e5\u548c\u529f\u80fd\u5217\u8868 mo_ctl precheck
\u68c0\u67e5 MatrixOne \u6e90\u7801\u5b89\u88c5\u6240\u9700\u8981\u7684\u4f9d\u8d56\u9879\uff0c\u5206\u522b\u4e3a golang, gcc, git,MySQL Client mo_ctl deploy
\u4e0b\u8f7d\u5e76\u5b89\u88c5\u53ca\u7f16\u8bd1 MatrixOne \u76f8\u5e94\u7248\u672c\uff0c\u9ed8\u8ba4\u4e3a\u5b89\u88c5\u6700\u65b0\u7a33\u5b9a\u7248\u672c mo_ctl start
\u542f\u52a8 MatrixOne \u670d\u52a1 mo_ctl status
\u68c0\u67e5 MatrixOne \u670d\u52a1\u662f\u5426\u6b63\u5728\u8fd0\u884c\u4e2d mo_ctl stop
\u505c\u6b62\u6240\u6709 MatrixOne \u670d\u52a1\u8fdb\u7a0b mo_ctl restart
\u91cd\u542f MatrixOne \u670d\u52a1 mo_ctl connect
\u8c03\u7528 MySQL Client \u8fde\u63a5 MatrixOne \u670d\u52a1 mo_ctl upgrade
\u5c06 MatrixOne \u4ece\u5f53\u524d\u7248\u672c\u5347\u7ea7/\u964d\u7ea7\u5230\u67d0\u4e2a\u53d1\u5e03\u7248\u672c\u6216\u8005 commit id \u7248\u672c mo_ctl set_conf
\u8bbe\u7f6e\u5404\u7c7b\u4f7f\u7528\u53c2\u6570 mo_ctl get_conf
\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u53c2\u6570 mo_ctl uninstall
\u4ece MO_PATH \u8def\u5f84\u4e0b\u5378\u8f7d MatrixOne mo_ctl watchdog
\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u4efb\u52a1\u4fdd\u8bc1 MatrixOne \u670d\u52a1\u53ef\u7528\u6027\uff0c\u6bcf\u5206\u949f\u68c0\u67e5 MatrixOne \u7684\u72b6\u6001\uff0c\u5982\u679c\u53d1\u73b0\u670d\u52a1\u4e2d\u6b62\u5219\u81ea\u52a8\u62c9\u8d77\u670d\u52a1 mo_ctl sql
\u76f4\u63a5\u901a\u8fc7\u547d\u4ee4\u6267\u884c SQL \u6216\u8005 SQL \u6784\u6210\u7684\u6587\u672c\u6587\u4ef6 mo_ctl ddl_convert
\u5c06 MySQL \u7684 DDL \u8bed\u53e5\u8f6c\u6362\u6210 MatrixOne \u8bed\u53e5\u7684\u5de5\u5177 mo_ctl get_cid
\u67e5\u770b\u5f53\u524d\u4f7f\u7528 MatrixOne \u4e0b\u8f7d\u4ed3\u5e93\u7684\u6e90\u7801\u7248\u672c mo_ctl get_branch
\u67e5\u770b\u5f53\u524d\u4f7f\u7528 MatrixOne \u4e0b\u8f7d\u4ed3\u5e93\u7684\u5206\u652f\u7248\u672c mo_ctl pprof
\u7528\u4e8e\u6536\u96c6 MatrixOne \u7684\u6027\u80fd\u5206\u6790\u6570\u636e"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#mo_ctl_1","title":"\u5b89\u88c5 mo_ctl","text":"\u6839\u636e\u60a8\u662f\u5426\u6709\u4e92\u8054\u7f51\u8bbf\u95ee\u6743\u9650\uff0c\u53ef\u4ee5\u9009\u62e9\u5728\u7ebf\u6216\u79bb\u7ebf\u5b89\u88c5 mo_ctl
\u5de5\u5177\uff0c\u4f60\u9700\u8981\u6ce8\u610f\u59cb\u7ec8\u4ee5 root \u6216\u5177\u6709 sudo \u6743\u9650\u6267\u884c\u547d\u4ee4\uff08\u5e76\u5728\u6bcf\u4e2a\u547d\u4ee4\u524d\u6dfb\u52a0 sudo\uff09\u3002\u540c\u65f6\uff0cinstall.sh
\u5c06\u4f7f\u7528 unzip
\u547d\u4ee4\u6765\u89e3\u538b mo_ctl
\u8f6f\u4ef6\u5305\uff0c\u8bf7\u786e\u4fdd\u5df2\u5b89\u88c5 unzip
\u547d\u4ee4\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo bash +x ./install.sh\n\n# \u5907\u7528\u5730\u5740\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh && sudo bash +x install.sh\n
\u5bf9\u4e8e\u5728 macOS \u73af\u5883\u4e2d\u8fd0\u884c\u6b64\u547d\u4ee4\u7684\u7528\u6237\uff0c\u5982\u679c\u60a8\u662f\u975e root \u7528\u6237\uff0c\u8bf7\u4ee5\u4ee5\u4e0b\u8bed\u53e5\u8fd0\u884c install.sh
:
sudo -u $(whoami) bash +x ./install.sh\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#_3","title":"\u79bb\u7ebf\u5b89\u88c5","text":"# 1. \u5148\u5c06\u5b89\u88c5\u811a\u672c\u4e0b\u8f7d\u5230\u672c\u5730\u8ba1\u7b97\u673a\uff0c\u518d\u4e0a\u4f20\u5230\u5b89\u88c5\u673a\u5668\u4e0a\nwget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh\nwget https://github.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# \u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u955c\u50cf\u5730\u5740\u4e0b\u8f7d\uff1a\nwget https://githubfast.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh\nwget https://githubfast.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# 2. \u4ece\u79bb\u7ebf\u5305\u5b89\u88c5\nbash +x ./install.sh mo_ctl.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#_4","title":"\u5feb\u901f\u4e0a\u624b","text":"\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5feb\u901f\u5b89\u88c5\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\uff0c\u8be6\u7ec6\u6307\u5357\u53ef\u4ee5\u67e5\u770b\u5355\u673a\u90e8\u7f72 MatrixOne.
\u4f7f\u7528\u547d\u4ee4 mo_ctl help
\u67e5\u770b\u5de5\u5177\u6307\u5357\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl precheck
\u67e5\u770b\u524d\u7f6e\u4f9d\u8d56\u6761\u4ef6\u662f\u5426\u6ee1\u8db3\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl get_conf
\u8bbe\u7f6e\u76f8\u5173\u53c2\u6570\uff0c\u53ef\u80fd\u7528\u5230\u7684\u53c2\u6570\u914d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a
mo_ctl set_conf MO_PATH=\"/data/mo/matrixone\" #\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u7684 MatrixOne \u4e0b\u8f7d\u8def\u5f84\nmo_ctl set_conf MO_GIT_URL=\"https://githubfast.com/matrixorigin/matrixone.git\" #\u9488\u5bf9 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\u95ee\u9898\uff0c\u8bbe\u7f6e\u955c\u50cf\u4e0b\u8f7d\u5730\u5740\n
\u4f7f\u7528\u547d\u4ee4 mo_ctl deploy
\u5b89\u88c5\u90e8\u7f72 MatrixOne \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl start
\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl connect
\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
mo_ctl help\nUsage : mo_ctl [option_1] [option_2]\n\n [option_1] : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | query | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n 1) connect : connect to mo via mysql client using connection info configured\n 2) ddl_convert : convert ddl file to mo format from other types of database\n 3) deploy : deploy mo onto the path configured\n 4) get_branch : upgrade or downgrade mo from current version to a target commit id or stable version\n 5) get_cid : print mo git commit id from the path configured\n 6) get_conf : get configurations\n 7) help : print help information\n 8) pprof : collect pprof information\n 9) precheck : check pre-requisites for mo_ctl\n 10) restart : a combination operation of stop and start\n 11) set_conf : set configurations\n 12) sql : execute sql from string, or a file or a path containg multiple files\n 13) start : start mo-service from the path configured\n 14) status : check if there's any mo process running on this machine\n 15) stop : stop all mo-service processes found on this machine\n 16) uninstall : uninstall mo from path MO_PATH=/data/mo/20230712_1228//matrixone\n 17) upgrade : upgrade or downgrade mo from current version to a target commit id or stable version\n 18) watchdog : setup a watchdog crontab task for mo-service to keep it alive\n e.g. : mo_ctl status\n\n [option_2] : Use \" mo_ctl [option_1] help \" to get more info\n e.g. : mo_ctl deploy help\n
\u4f7f\u7528 mo_ctl [option_1] help
\u6765\u83b7\u53d6\u4e0b\u4e00\u7ea7 mo_ctl [option_1]
\u529f\u80fd\u7684\u4f7f\u7528\u6307\u5357\u3002
\u6e90\u7801\u5b89\u88c5 MatrixOne \u524d\u4f7f\u7528 mo_ctl precheck
\u68c0\u67e5\u524d\u7f6e\u4f9d\u8d56\u6761\u4ef6\uff0c\u76ee\u524d\u524d\u7f6e\u4f9d\u8d56\u4e8e go
/gcc
/git
/mysql(client)
\u3002
mo_ctl precheck help\nUsage : mo_ctl precheck # check pre-requisites for mo_ctl\n Check list : go gcc git mysql\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#deploy-matrixone","title":"deploy - \u5b89\u88c5 MatrixOne","text":"\u4f7f\u7528 mo_ctl deploy [mo_version] [force]
\u5b89\u88c5\u90e8\u7f72\u7a33\u5b9a\u7248\u672c MatrixOne, \u6216\u67d0\u4e2a\u6307\u5b9a\u7248\u672c\uff0c\u901a\u8fc7 force
\u9009\u9879\u53ef\u4ee5\u5c06\u540c\u4e00\u76ee\u5f55\u4e0b\u5df2\u7ecf\u5b58\u5728\u7684 MatrixOne \u7248\u672c\u5220\u9664\uff0c\u5f3a\u5236\u91cd\u65b0\u5b89\u88c5\u65b0\u7248\u672c\u3002
mo_ctl deploy help\nUsage : mo_ctl deploy [mo_version] [force] # deploy mo onto the path configured\n [mo_version]: optional, specify an mo version to deploy\n [force] : optional, if specified will delete all content under MO_PATH and deploy from beginning\n e.g. : mo_ctl deploy # default, same as mo_ctl deploy 1.2.1\n : mo_ctl deploy main # deploy development latest version\n : mo_ctl deploy d29764a # deploy development version d29764a\n : mo_ctl deploy 1.2.1 # deploy stable verson 1.2.1\n : mo_ctl deploy force # delete all under MO_PATH and deploy verson 1.2.1\n : mo_ctl deploy 1.2.1 force # delete all under MO_PATH and deploy stable verson 1.2.1 from beginning\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#start-matrixone","title":"start - \u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl start
\u542f\u52a8 MatrixOne \u670d\u52a1\uff0c\u542f\u52a8\u6587\u4ef6\u8def\u5f84\u4f4d\u4e8e MO_PATH
\u4e0b\u3002
mo_ctl start help\nUsage : mo_ctl start # start mo-service from the path configured\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#stop-matrixone","title":"stop - \u505c\u6b62 MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl stop [force]
\u505c\u6b62\u672c\u673a\u5668\u4e0a\u6240\u6709 MatrixOne \u670d\u52a1\uff0c\u5982\u679c\u6709\u591a\u4e2a MatrixOne \u670d\u52a1\u5728\u8fd0\u884c\uff0c\u4e5f\u4f1a\u5168\u90e8\u505c\u6b62\u3002
mo_ctl stop help\nUsage : mo_ctl stop [force] # stop all mo-service processes found on this machine\n [force] : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n e.g. : mo_ctl stop # default, stop all mo-service processes found on this machine\n : mo_ctl stop force # stop all mo-services with kill -9 command\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#restart-matrixone","title":"restart - \u91cd\u542f MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl restart [force]
\u505c\u6b62\u6240\u6709\u672c\u673a\u5668\u4e0a MatrixOne \u670d\u52a1\uff0c\u5e76\u91cd\u542f\u4f4d\u4e8e MO_PATH
\u8def\u5f84\u4e0b\u7684 MatrixOne \u670d\u52a1\u3002
mo_ctl restart help\nUsage : mo_ctl restart [force] # a combination operation of stop and start\n [force] : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n e.g. : mo_ctl restart # default, stop all mo-service processes found on this machine and start mo-serivce under path of conf MO_PATH\n : mo_ctl restart force # stop all mo-services with kill -9 command and start mo-serivce under path of conf MO_PATH\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#connect-mysql-client-matrixone","title":"connect - \u901a\u8fc7 mysql-client \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl connect
\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\uff0c\u8fde\u63a5\u53c2\u6570\u5747\u7531 mo_ctl
\u5de5\u5177\u4e2d\u8bbe\u7f6e\u3002
mo_ctl connect help\nUsage : mo_ctl connect # connect to mo via mysql client using connection info configured\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#status-matrixone","title":"status - \u68c0\u67e5 MatrixOne \u7684\u72b6\u6001","text":"\u4f7f\u7528 mo_ctl status
\u6765\u68c0\u67e5 MatrixOne \u7684\u8fd0\u884c\u72b6\u6001\uff0c\u662f\u5426\u5728\u8fd0\u884c\u4e2d\u3002
mo_ctl status help\nUsage : mo_ctl status # check if there's any mo process running on this machine\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#get_cid-matrixone-id","title":"get_cid - \u6253\u5370 MatrixOne \u4ee3\u7801\u63d0\u4ea4 id","text":"\u4f7f\u7528 mo_ctl get_cid
\u6253\u5370\u5f53\u524d MO_PATH
\u8def\u5f84\u4e0b\u7684 MatrixOne \u4ee3\u7801\u5e93\u63d0\u4ea4 id\u3002
mo_ctl get_cid help\nUsage : mo_ctl get_cid # print mo commit id from the path configured\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#get_branch-matrixone-id","title":"get_branch - \u6253\u5370 MatrixOne \u4ee3\u7801\u63d0\u4ea4 id","text":"\u4f7f\u7528 mo_ctl get_branch
\u6253\u5370\u5f53\u524d MO_PATH
\u8def\u5f84\u4e0b\u7684 MatrixOne \u4ee3\u7801\u5e93\u5206\u652f\u3002
mo_ctl get_branch help\nUsage : mo_ctl get_branch # print which git branch mo is currently on\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#pprof-","title":"pprof - \u6536\u96c6\u6027\u80fd\u4fe1\u606f","text":"\u4f7f\u7528 mo_ctl pprof [item] [duration]
\u6536\u96c6 MatrixOne \u7684\u76f8\u5173\u6027\u80fd\u4fe1\u606f\uff0c\u4e3b\u8981\u4e3a\u5f00\u53d1\u4eba\u5458\u8fdb\u884c\u8c03\u8bd5\u4f7f\u7528\u3002
mo_ctl pprof help\nUsage : mo_ctl pprof [item] [duration] # collect pprof information\n [item] : optional, specify what pprof to collect, available: profile | heap | allocs\n 1) profile : default, collect profile pprof for 30 seconds\n 2) heap : collect heap pprof at current moment\n 3) allocs : collect allocs pprof at current moment\n [duration] : optional, only valid when [item]=profile, specifiy duration to collect profile\n e.g. : mo_ctl pprof\n : mo_ctl pprof profile # collect duration will use conf value PPROF_PROFILE_DURATION from conf file or 30 if it's not set\n : mo_ctl pprof profile 30\n : mo_ctl pprof heap\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#set_conf-","title":"set_conf - \u914d\u7f6e\u53c2\u6570","text":"\u4f7f\u7528 mo_ctl set_conf [conf_list]
\u914d\u7f6e 1 \u4e2a\u6216\u591a\u4e2a\u4f7f\u7528\u53c2\u6570\u3002
mo_ctl set_conf help\nUsage : mo_ctl setconf [conf_list] # set configurations\n [conf_list] : configuration list in key=value format, seperated by comma\n e.g. : mo_ctl setconf MO_PATH=/data/mo/matrixone,MO_PW=M@trix0riginR0cks,MO_PORT=6101 # set multiple configurations\n : mo_ctl setconf MO_PATH=/data/mo/matrixone # set single configuration\n
Note
\u5f53 set_conf \u7684\u8bbe\u7f6e\u7684\u8def\u5f84\u4e2d\u5305\u542b\u53d8\u91cf\u5982 ${MO_PATH}
\u65f6\uff0c\u9700\u8981\u5728 $
\u524d\u52a0\u4e0a \\
\uff0c\u4f8b\u5982\uff1a
mo_ctl set_conf MO_CONF_FILE=\"\\${MO_PATH}/matrixone/etc/launch/launch.toml\"\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#get_conf-","title":"get_conf - \u83b7\u53d6\u53c2\u6570\u5217\u8868","text":"\u4f7f\u7528 mo_ctl get_conf [conf_list]
\u83b7\u53d6\u4e00\u4e2a\u6216\u591a\u4e2a\u5f53\u524d\u914d\u7f6e\u9879\u3002
mo_ctl get_conf help\nUsage : mo_ctl getconf [conf_list] # get configurations\n [conf_list] : optional, configuration list in key, seperated by comma.\n : use 'all' or leave it as blank to print all configurations\n e.g. : mo_ctl getconf MO_PATH,MO_PW,MO_PORT # get multiple configurations\n : mo_ctl getconf MO_PATH # get single configuration\n : mo_ctl getconf all # get all configurations\n : mo_ctl getconf # get all configurations\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#mo_ctl-get_conf-","title":"mo_ctl get_conf - \u8be6\u7ec6\u53c2\u6570\u5217\u8868","text":"\u4f7f\u7528 mo_ctl get_conf
\u5c06\u6253\u5370\u5f53\u524d\u5de5\u5177\u4f7f\u7528\u7684\u6240\u6709\u53c2\u6570\u5217\u8868\uff0c\u5b83\u4eec\u7684\u91ca\u4e49\u4e0e\u53d6\u503c\u8303\u56f4\u5982\u4e0b\u8868\u6240\u793a\u3002
\u4f7f\u7528 mo_ctl ddl_convert [options] [src_file] [tgt_file]
\u5c06\u4e00\u4e2a DDL \u6587\u4ef6\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8bed\u6cd5\u683c\u5f0f\u8f6c\u6362\u6210 MatrixOne \u7684 DDL \u683c\u5f0f\uff0c\u76ee\u524d\u4ec5\u6709 mysql_to_mo
\u6a21\u5f0f\u652f\u6301\u3002
mo_ctl ddl_convert help\nUsage : mo_ctl ddl_convert [options] [src_file] [tgt_file] # convert a ddl file to mo format from other types of database\n [options] : available: mysql_to_mo\n [src_file] : source file to be converted, will use env DDL_SRC_FILE from conf file by default\n [tgt_file] : target file of converted output, will use env DDL_TGT_FILE from conf file by default\n e.g. : mo_ctl ddl_convert mysql_to_mo /tmp/mysql.sql /tmp/mo.sql\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#sql-sql","title":"sql - \u6267\u884c SQL","text":"\u4f7f\u7528 mo_ctl sql [sql]
\u6765\u6267\u884c SQL \u6587\u672c\u6216\u8005 SQL \u6587\u4ef6\u3002
mo_ctl sql help\nUsage : mo_ctl sql [sql] # execute sql from string, or a file or a path containg multiple files\n [sql] : a string quote by \"\", or a file, or a path\n e.g. : mo_ctl sql \"use test;select 1;\" # execute sql \"use test;select 1\"\n : mo_ctl sql /data/q1.sql # execute sql in file /data/q1.sql\n : mo_ctl sql /data/ # execute all sql files with .sql postfix in /data/\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#uninstall-matrixone","title":"uninstall - \u5378\u8f7d MatrixOne","text":"\u4f7f\u7528 mo_ctl uninstall
\u6765\u4ece MO_PATH \u4e0a\u5378\u8f7d MatrixOne\u3002
mo_ctl uninstall help\nUsage : mo_ctl uninstall # uninstall mo from path MO_PATH=/data/mo//matrixone\n # note: you will need to input 'Yes/No' to confirm before uninstalling\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#upgrade-matrixone","title":"upgrade - \u5347\u7ea7/\u964d\u7ea7 MatrixOne \u7248\u672c","text":"MatrixOne 0.8 \u53ca\u66f4\u9ad8\u7248\u672c\u53ef\u4f7f\u7528 mo_ctl upgrade version
\u6216\u8005 mo_ctl upgrade commitid
\u6765\u5c06 MatrixOne \u4ece\u5f53\u524d\u7248\u672c\u5347\u7ea7\u6216\u964d\u7ea7\u5230\u67d0\u4e2a\u7a33\u5b9a\u7248\u672c\u6216\u8005\u67d0\u4e2a commit id \u7248\u672c\u3002
mo_ctl upgrade help\nUsage : mo_ctl upgrade [version_commitid] # upgrade or downgrade mo from current version to a target commit id or stable version\n [commitid] : a commit id such as '38888f7', or a stable version such as '1.2.1'\n : use 'latest' to upgrade to latest commit on main branch if you don't know the id\n e.g. : mo_ctl upgrade 38888f7 # upgrade/downgrade to commit id 38888f7 on main branch\n : mo_ctl upgrade latest # upgrade/downgrade to latest commit on main branch\n : mo_ctl upgrade 1.2.1 # upgrade/downgrade to stable version 1.2.1\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#watchdog-matrixone","title":"watchdog - \u4fdd\u6d3b MatrixOne","text":"\u4f7f\u7528 mo_ctl watchdog [options]
\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u4efb\u52a1\u4fdd\u8bc1 MatrixOne \u670d\u52a1\u53ef\u7528\u6027\uff0c\u6bcf\u5206\u949f\u68c0\u67e5 MatrixOne \u7684\u72b6\u6001\uff0c\u5982\u679c\u53d1\u73b0\u670d\u52a1\u4e2d\u6b62\u5219\u81ea\u52a8\u62c9\u8d77\u670d\u52a1\u3002
mo_ctl watchdog help\nUsage : mo_ctl watchdog [options] # setup a watchdog crontab task for mo-service to keep it alive\n [options] : available: enable | disable | status\n e.g. : mo_ctl watchdog enable # enable watchdog service for mo, by default it will check if mo-servie is alive and pull it up if it's dead every one minute\n : mo_ctl watchdog disable # disable watchdog\n : mo_ctl watchdog status # check if watchdog is enabled or disabled\n : mo_ctl watchdog # same as mo_ctl watchdog status\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/","title":"mo_datax_writer \u5de5\u5177\u6307\u5357","text":"mo_datax_writer
\u662f\u4e00\u6b3e\u5e2e\u52a9\u4f60\u5b9e\u73b0\u5c06\u6570\u636e\u4ece mysql \u5230 matrixone \u8fc1\u79fb\u7684\u5de5\u5177\u3002
Note
mo_datax_writer
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_datax_writer/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip cd mo_datax_writer-1.0.1/ #\u5c06mo_datax_writer\u89e3\u538b\u5230datax/plugin/writer/\u76ee\u5f55\u4e0b\nunzip matrixonewriter.zip -d ../datax/plugin/writer/\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#matrixone","title":"\u521d\u59cb\u5316 MatrixOne \u6570\u636e\u8868","text":""},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_2","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"create database test;\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_3","title":"\u521b\u5efa\u8868","text":"use test;\n\nCREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n);\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#mysql","title":"\u521d\u59cb\u5316 MySQL \u6570\u636e\u8868","text":""},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_4","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"create database test;\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_5","title":"\u521b\u5efa\u8868","text":"use test;\n\nCREATE TABLE `user` (\n`name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n`age` int DEFAULT NULL,\n`city` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_6","title":"\u5bfc\u5165\u6570\u636e","text":"insert into user values('zhangsan',26,'Shanghai'),('lisi',24,'Chengdu'),('wangwu',28,'Xian'),('zhaoliu',22,'Beijing'),('tianqi',26,'Shenzhen');\n\nmysql> select * from user;\n+----------+------+----------+\n| name | age | city |\n+----------+------+----------+\n| zhangsan | 26 | Shanghai |\n| lisi | 24 | Chengdu |\n| wangwu | 28 | Xian |\n| zhaoliu | 22 | Beijing |\n| tianqi | 26 | Shenzhen |\n+----------+------+----------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#datax","title":"\u4f7f\u7528 DataX \u5bfc\u5165\u6570\u636e","text":""},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_7","title":"\u7f16\u5199\u914d\u7f6e\u6587\u4ef6","text":"\u5728 datax/job \u76ee\u5f55\u4e0b\u6dfb\u52a0 datax \u914d\u7f6e\u6587\u4ef6 mysql2mo.json\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a
{\n\"job\": {\n\"setting\": {\n\"speed\": {\n\"channel\": 1\n},\n\"errorLimit\": {\n\"record\": 0,\n\"percentage\": 0\n}\n},\n\"content\": [\n{\n\"reader\": {\n\"name\": \"mysqlreader\",\n\"parameter\": {\n// MySQL \u6570\u636e\u5e93\u7528\u6237\u540d\n\"username\": \"root\",\n// MySQL \u6570\u636e\u5e93\u5bc6\u7801\n\"password\": \"111\",\n// MySQL \u6570\u636e\u8868\u8bfb\u53d6\u7684\u5217\u540d\n\"column\": [\"name\",\"age\",\"city\"],\n\"splitPk\": \"\",\n\"connection\": [\n{\n// MySQL \u6570\u636e\u8868\n\"table\": [\"user\"],\n// MySQL \u8fde\u63a5\u4fe1\u606f\n\"jdbcUrl\": [\n\"jdbc:mysql://127.0.0.1:3306/test?useSSL=false\"\n]\n}\n]\n}\n},\n\"writer\": {\n\"name\": \"matrixonewriter\",\n\"parameter\": {\n// \u6570\u636e\u5e93\u7528\u6237\u540d\n\"username\": \"root\",\n// \u6570\u636e\u5e93\u5bc6\u7801\n\"password\": \"111\",\n// \u9700\u8981\u5bfc\u5165\u7684\u8868\u5217\u540d\n\"column\": [\"name\",\"age\",\"city\"],\n// \u5bfc\u5165\u4efb\u52a1\u5f00\u59cb\u524d\u9700\u8981\u6267\u884c\u7684 SQL \u8bed\u53e5\n\"preSql\": [],\n// \u5bfc\u5165\u4efb\u52a1\u5b8c\u6210\u4e4b\u540e\u8981\u6267\u884c\u7684 SQL \u8bed\u53e5\n\"postSql\": [],\n// \u6279\u91cf\u5199\u5165\u6761\u6570\uff0c\u5373\u8bfb\u53d6\u591a\u5c11\u6761\u6570\u636e\u540e\u6267\u884c load data inline \u5bfc\u5165\u4efb\u52a1\n\"maxBatchRows\": 60000,\n// \u6279\u91cf\u5199\u5165\u5927\u5c0f\uff0c\u5373\u8bfb\u53d6\u591a\u5927\u7684\u6570\u636e\u540e\u6267\u884c load data inline \u5bfc\u5165\u4efb\u52a1\n\"maxBatchSize\": 5242880,\n// \u5bfc\u5165\u4efb\u52a1\u6267\u884c\u65f6\u95f4\u95f4\u9694\uff0c\u5373\u7ecf\u8fc7\u591a\u957f\u65f6\u95f4\u540e\u6267\u884c load data inline \u5bfc\u5165\u4efb\u52a1\n\"flushInterval\": 300000,\n\"connection\": [\n{\n// \u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f\n\"jdbcUrl\": \"jdbc:mysql://127.0.0.1:6001/test?useUnicode=true&useSSL=false\",\n// \u6570\u636e\u5e93\u540d\n\"database\": \"test\",\n// \u6570\u636e\u5e93\u8868\n\"table\": [\"user\"]\n}\n]\n}\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#datax_1","title":"\u6267\u884c DataX \u4efb\u52a1","text":"\u8fdb\u5165 datax \u5b89\u88c5\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4
python bin/datax.py job/mysql2mo.json\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
2024-06-06 06:26:52.145 [job-0] INFO StandAloneJobContainerCommunicator - Total 5 records, 75 bytes | Speed 7B/s, 0 records/s | Error 0 records, 0 bytes | All Task WaitWriterTime 0.000s | All Task WaitReaderTime 0.012s | Percentage 100.00%\n2024-06-06 06:26:52.147 [job-0] INFO JobContainer - \n\u4efb\u52a1\u542f\u52a8\u65f6\u523b : 2024-06-06 14:26:41\n\u4efb\u52a1\u7ed3\u675f\u65f6\u523b : 2024-06-06 14:26:52\n\u4efb\u52a1\u603b\u8ba1\u8017\u65f6 : 10s\n\u4efb\u52a1\u5e73\u5747\u6d41\u91cf : 7B/s\n\u8bb0\u5f55\u5199\u5165\u901f\u5ea6 : 0rec/s\n\u8bfb\u51fa\u8bb0\u5f55\u603b\u6570 : 5\n\u8bfb\u5199\u5931\u8d25\u603b\u6570 : 0\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_8","title":"\u67e5\u770b\u7ed3\u679c","text":"\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\u67e5\u770b\u7ed3\u679c\uff0c\u53ef\u4ee5\u770b\u5230\u6570\u636e\u5df2\u7ecf\u4ece MySQL \u540c\u6b65\u5230 MatrixOne \u4e2d
mysql> select * from user;\n+----------+------+-----------+\n| name | age | city |\n+----------+------+-----------+\n| zhangsan | 26 | Shanghai |\n| lisi | 24 | Chengdu |\n| wangwu | 28 | Xian |\n| zhaoliu | 22 | Beijing |\n| tianqi | 26 | Shenzhen |\n+----------+------+-----------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/","title":"mo_ssb_open \u5de5\u5177\u6307\u5357","text":"mo_ssb_open
\u662f\u4e00\u6b3e\u9488\u5bf9 MatrixOne \u5b9e\u73b0 SSB \u6d4b\u8bd5\u7684\u5de5\u5177\u3002
Note
mo_ssb_open
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_ssb_open/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#_2","title":"\u751f\u6210\u6570\u636e\u96c6","text":"cd mo_ssb_open-1.0.1 \n./bin/gen-ssb-data.sh -s 1 -c 5\n
-s\uff1a\u8868\u793a\u4ea7\u751f\u5927\u7ea6 1GB \u7684\u6570\u636e\u96c6\uff0c\u4e0d\u6307\u5b9a\u53c2\u6570\uff0c\u9ed8\u8ba4\u751f\u6210 100G \u6570\u636e\uff0c
-c\uff1a\u8868\u793a\u751f\u6210 lineorder \u8868\u6570\u636e\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 10 \u7ebf\u7a0b\u3002
\u751f\u6210\u5b8c\u6574\u6570\u636e\u96c6\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u3002\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 mo_ssb_open-1.0.1/bin/ssb-data/ \u76ee\u5f55\u4e0b\u770b\u5230\u7ed3\u679c\u6587\u4ef6\u3002
root@host-10-222-4-8:~/soft/ssb/mo_ssb_open-1.0.1/bin/ssb-data# ls -l\ntotal 604976\n-rwS--S--T 1 root root 2837046 Jun 7 03:31 customer.tbl\n-rw-r--r-- 1 root root 229965 Jun 7 03:31 date.tbl\n-rw-r--r-- 1 root root 118904702 Jun 7 03:31 lineorder.tbl.1\n-rw-r--r-- 1 root root 119996341 Jun 7 03:31 lineorder.tbl.2\n-rw-r--r-- 1 root root 120146777 Jun 7 03:31 lineorder.tbl.3\n-rw-r--r-- 1 root root 120000311 Jun 7 03:31 lineorder.tbl.4\n-rw-r--r-- 1 root root 120057972 Jun 7 03:31 lineorder.tbl.5\n-rw-r--r-- 1 root root 17139259 Jun 7 03:31 part.tbl\n-rw-r--r-- 1 root root 166676 Jun 7 03:31 supplier.tbl\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#matrixone","title":"\u5728 MatrixOne \u4e2d\u5efa\u8868","text":"\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 conf/matrxione.conf\uff0c\u6307\u5b9a MatrixOne \u7684\u5730\u5740\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\uff0c\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b\u5982\u4e0b
# MatrixOne host\nexport HOST='127.0.0.1'\n# MatrixOne port\nexport PORT=6001\n# MatrixOne username\nexport USER='root'\n# MatrixOne password\nexport PASSWORD='111'\n# The database where SSB tables located\nexport DB='ssb'\n
\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u8fdb\u884c\u5efa\u8868\u64cd\u4f5c\u3002
./bin/create-ssb-tables.sh\n
\u8fde\u63a5 MatrixOne \u67e5\u770b\uff0c\u5efa\u8868\u6210\u529f\u3002
mysql> show tables;\n+----------------+\n| Tables_in_ssb |\n+----------------+\n| customer |\n| dates |\n| lineorder |\n| lineorder_flat |\n| part |\n| supplier |\n+----------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#_3","title":"\u5bfc\u5165\u6570\u636e","text":"\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u5bfc\u5165 ssb \u6d4b\u8bd5\u6240\u9700\u6570\u636e\uff1a
./bin/load-ssb-data.sh -c 10\n
\u53c2\u6570\u91ca\u4e49
-c: \u53ef\u4ee5\u6307\u5b9a\u6267\u884c\u5bfc\u5165\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 5 \u4e2a\u7ebf\u7a0b\u3002
\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u521b\u5efa\u7684\u8868\u67e5\u8be2 MatrixOne \u4e2d\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#_4","title":"\u8fd0\u884c\u67e5\u8be2\u547d\u4ee4","text":"\u67e5\u8be2\u7ed3\u679c\u7b2c\u4e00\u5217\u4e3a\u67e5\u8be2\u7f16\u7801\uff0c
root@host-10-222-4-8:~/soft/ssb/mo_ssb_open-1.0.1# ./bin/run-ssb-queries.sh\nmysqlslap Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nmysql Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nHOST: 127.0.0.1\nPORT: 6001\nUSER: root\nDB: ssb\nq1.1: 0.22 0.16 0.13 fast:0.13\nq1.2: 0.17 0.17 0.17 fast:0.17\nq1.3: 0.15 0.19 0.18 fast:0.15\nq2.1: 0.22 0.21 0.23 fast:0.21\nq2.2: 0.18 0.17 0.16 fast:0.16\nq2.3: 0.15 0.16 0.17 fast:0.15\nq3.1: 0.24 0.23 0.23 fast:0.23\nq3.2: 0.16 0.16 0.20 fast:0.16\nq3.3: 0.16 0.14 0.13 fast:0.13\nq3.4: 0.12 0.11 0.11 fast:0.11\nq4.1: 0.24 0.22 0.30 fast:0.22\nq4.2: 0.22 0.21 0.22 fast:0.21\nq4.3: 0.20 0.21 0.20 fast:0.20\ntotal time: 2.23 seconds\nFinish ssb queries.\n
root@host-10-222-4-8:~/soft/ssb/mo_ssb_open-1.0.1# ./bin/run-ssb-flat-queries.sh\nmysqlslap Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nmysql Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nHOST: 127.0.0.1\nPORT: 6001\nUSER: root\nDB: ssb\nq1.1: 0.21 0.13 0.14 fast:0.13\nq1.2: 0.15 0.13 0.15 fast:0.13\nq1.3: 0.16 0.21 0.22 fast:0.16\nq2.1: 0.36 0.34 0.38 fast:0.34\nq2.2: 0.36 0.34 0.32 fast:0.32\nq2.3: 0.25 0.26 0.22 fast:0.22\nq3.1: 0.39 0.39 0.30 fast:0.30\nq3.2: 0.32 0.33 0.29 fast:0.29\nq3.3: 0.22 0.23 0.29 fast:0.22\nq3.4: 0.32 0.28 0.31 fast:0.28\nq4.1: 0.42 0.38 0.38 fast:0.38\nq4.2: 0.42 0.48 0.45 fast:0.42\nq4.3: 0.35 0.34 0.29 fast:0.29\ntotal time: 3.48 seconds\nFinish ssb-flat queries.\n
\u67e5\u8be2\u7ed3\u679c\u5206\u522b\u5bf9\u5e94\uff1a\u67e5\u8be2\u8bed\u53e5\u3001\u7b2c\u4e00\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e8c\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e09\u6b21\u67e5\u8be2\u7ed3\u679c\u548c\u6700\u5feb\u7ed3\u679c\uff0c\u5355\u4f4d\u4e3a s\u3002
Note
\u60a8\u53ef\u4ee5\u5728 mo_ssb_open-1.0.1/ssb-queries \u76ee\u5f55\u4e0b\u67e5\u770b\u5177\u4f53\u7684\u67e5\u8be2\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/","title":"mo_tpch_open \u5de5\u5177\u6307\u5357","text":"mo_tpch_open
\u662f\u4e00\u6b3e\u9488\u5bf9 MatrixOne \u5b9e\u73b0 TPCH \u6d4b\u8bd5\u7684\u5de5\u5177\u3002
Note
mo_tpch_open
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_tpch_open/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#_2","title":"\u751f\u6210\u6570\u636e\u96c6","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u6570\u636e\u96c6\uff1a
cd mo_tpch_open-1.0.1\n./bin/gen-tpch-data.sh -s 1 -c 5\n
\u53c2\u6570\u91ca\u4e49
-s\uff1a\u8868\u793a\u4ea7\u751f\u5927\u7ea6 1GB \u7684\u6570\u636e\u96c6\uff0c\u4e0d\u6307\u5b9a\u53c2\u6570\uff0c\u9ed8\u8ba4\u751f\u6210 100G \u6570\u636e\uff0c
-c\uff1a\u8868\u793a\u751f\u6210\u8868\u6570\u636e\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 10 \u7ebf\u7a0b\u3002
\u751f\u6210\u5b8c\u6574\u6570\u636e\u96c6\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u3002\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 mo_tpch_open-1.0.1/bin/tpch-data \u76ee\u5f55\u4e0b\u770b\u5230\u7ed3\u679c\u6587\u4ef6\u3002
root@host-10-222-4-8:~/soft/tpch/tpch-tools/bin/tpch-data# ls -l\nroot@host-10-222-4-8:~/soft/tpch/mo_tpch_open-1.0.1/bin/tpch-data# ls -l\ntotal 1074936\n-rw-r--r-- 1 root root 24346144 Jun 7 03:16 customer.tbl\n-rw-r--r-- 1 root root 151051198 Jun 7 03:16 lineitem.tbl.1\n-rw-r--r-- 1 root root 152129724 Jun 7 03:16 lineitem.tbl.2\n-rw-r--r-- 1 root root 152344710 Jun 7 03:16 lineitem.tbl.3\n-rw-r--r-- 1 root root 152123661 Jun 7 03:16 lineitem.tbl.4\n-rw-r--r-- 1 root root 152213994 Jun 7 03:16 lineitem.tbl.5\n-rw-r--r-- 1 root root 2224 Jun 7 03:16 nation.tbl\n-rw-r--r-- 1 root root 34175478 Jun 7 03:16 orders.tbl.1\n-rw-r--r-- 1 root root 34463858 Jun 7 03:16 orders.tbl.2\n-rw-r--r-- 1 root root 34437453 Jun 7 03:16 orders.tbl.3\n-rw-r--r-- 1 root root 34445732 Jun 7 03:16 orders.tbl.4\n-rw-r--r-- 1 root root 34429640 Jun 7 03:16 orders.tbl.5\n-rw-r--r-- 1 root root 24135125 Jun 7 03:16 part.tbl\n-rw-r--r-- 1 root root 23677134 Jun 7 03:16 partsupp.tbl.1\n-rw-r--r-- 1 root root 23721079 Jun 7 03:16 partsupp.tbl.2\n-rw-r--r-- 1 root root 23808550 Jun 7 03:16 partsupp.tbl.3\n-rw-r--r-- 1 root root 23894802 Jun 7 03:16 partsupp.tbl.4\n-rw-r--r-- 1 root root 23883051 Jun 7 03:16 partsupp.tbl.5\n-rw-r--r-- 1 root root 389 Jun 7 03:16 region.tbl\n-rw-r--r-- 1 root root 1409184 Jun 7 03:16 supplier.tbl\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#matrixone","title":"\u5728 MatrixOne \u4e2d\u5efa\u8868","text":"\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 conf/matrxione.conf\uff0c\u6307\u5b9a MatrixOne \u7684\u5730\u5740\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\uff0c\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b\u5982\u4e0b
# MatrixOne host\nexport HOST='127.0.0.1'\n# MatrixOne port\nexport PORT=6001\n# MatrixOne username\nexport USER='root'\n# MatrixOne password\nexport PASSWORD='111'\n# The database where TPC-H tables located\nexport DB='tpch'\n
\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u8fdb\u884c\u5efa\u8868\u64cd\u4f5c\u3002
./bin/create-tpch-tables.sh\n
\u8fde\u63a5 MatrixOne \u67e5\u770b\uff0c\u5efa\u8868\u6210\u529f\u3002
mysql> show tables;\n+----------------+\n| Tables_in_tpch |\n+----------------+\n| customer |\n| lineitem |\n| nation |\n| orders |\n| part |\n| partsupp |\n| region |\n| revenue0 |\n| supplier |\n+----------------+\n9 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#_3","title":"\u5bfc\u5165\u6570\u636e","text":"\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u5bfc\u5165 TPC-H \u6d4b\u8bd5\u6240\u9700\u6570\u636e\uff1a
./bin/load-tpch-data.sh -c 10\n
\u53c2\u6570\u91ca\u4e49
-c: \u53ef\u4ee5\u6307\u5b9a\u6267\u884c\u5bfc\u5165\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 5 \u4e2a\u7ebf\u7a0b\u3002
\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u521b\u5efa\u7684\u8868\u67e5\u8be2 MatrixOne \u4e2d\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#_4","title":"\u8fd0\u884c\u67e5\u8be2\u547d\u4ee4","text":"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u67e5\u8be2\uff1a
root@host-10-222-4-8:~/soft/tpch/mo_tpch_open-1.0.1# ./bin/run-tpch-queries.sh\nmysql Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nHOST: 127.0.0.1\nPORT: 6001\nUSER: root\nDB: tpch\nTime Unit: ms\nq1 836 715 691 691\nq2 111 80 88 80\nq3 325 235 212 212\nq4 221 181 177 177\nq5 240 236 295 236\nq6 215 292 350 292\nq7 373 327 299 299\nq8 236 238 243 238\nq9 443 406 413 406\nq10 375 390 422 390\nq11 201 237 231 231\nq12 461 460 400 400\nq13 321 294 301 294\nq14 289 261 282 261\nq15 391 285 294 285\nq16 222 288 255 255\nq17 333 247 243 243\nq18 275 262 317 262\nq19 513 479 511 479\nq20 240 244 198 198\nq21 1503 1746 1786 1746\nq22 138 122 126 122\nTotal cold run time: 8262 ms\nTotal hot run time: 7797 ms\nFinish tpch queries.\n
\u67e5\u8be2\u7ed3\u679c\u5206\u522b\u5bf9\u5e94\uff1a\u67e5\u8be2\u8bed\u53e5\u3001\u7b2c\u4e00\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e8c\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e09\u6b21\u67e5\u8be2\u7ed3\u679c\u548c\u6700\u5feb\u7ed3\u679c\uff0c\u5355\u4f4d\u4e3a ms\u3002
Note
\u60a8\u53ef\u4ee5\u5728 mo_tpch_open-1.0.1/queries \u76ee\u5f55\u4e0b\u67e5\u770b\u5177\u4f53\u7684\u67e5\u8be2\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/","title":"mo_ts_perf_test \u5de5\u5177\u6307\u5357","text":"mo_ts_perf_test
\u662f\u4e00\u6b3e\u9488\u5bf9 MatrixOne \u8fdb\u884c\u65f6\u5e8f\u5199\u5165\u548c\u67e5\u8be2\u6d4b\u8bd5\u5de5\u5177\u3002
Note
mo_ts_perf_test
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_ts_perf_test/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/#_2","title":"\u914d\u7f6e","text":"\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u4fee\u6539 matrixone/conf \u76ee\u5f55\u4e0b\u7684 db.conf \u914d\u7f6e\u6587\u4ef6
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.0/matrixone/conf# cat db.conf [dbInfo]\nhost = 127.0.0.1\nport = 6001\nuser = root\npassword = 111\ntablePrefix = d\npoint_query_ts_condition = '2017-07-14 10:40:06.379'\nloadFilePath = /root/soft/perf/\n
\u914d\u7f6e\u8bf4\u660e\uff1a
mo-write \u4e3a MO \u5199\u5165\u6d4b\u8bd5\u5de5\u5177\uff0c\u547d\u4ee4\u4e3a\uff1a
mo-write -T -r -n -retry -mode -txc -tType -wType -wType\n
Note
\u6240\u6709\u5199\u5165\u90fd\u662f\u5411 test \u6570\u636e\u5e93\u4e0b\u7684\u8868\u5199\uff0c\u5355\u8868\u5199\u5165\u662f\u5411 d0 \u8868\u5199\uff0c\u591a\u8868\u5199\u5165\u662f\u5411 d0\u3001d1\u3001d2 \u7b49\u7b49\uff08\u6570\u91cf\u7531\u5ba2\u6237\u7aef\u6570\u636e\u51b3\u5b9a\uff09\u3002
\u53c2\u6570\u8bf4\u660e
\u4f7f\u7528\u9ed8\u8ba4\u914d\u7f6e\u5199\u6570\u636e\uff0c\u5373\uff1a7 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 load data inline \u7684\u65b9\u5f0f\uff0c\u5206\u522b\u5411\u65e0\u4e3b\u952e\u7684\u65f6\u5e8f\u8868\uff08d0\u3001d1\u2026\u2026 d6\uff09\u591a\u8868\u5199\u5165 500000 \u6761\u6570\u636e\uff08\u603b\u5171\u5199\u5165\u6570\u636e\u91cf\uff1a500000*7\uff09\uff0c\u6bcf\u6b21\u5199\u5165 10000 \u884c\u6570\u636e\uff0c\u6d4b\u8bd5\u4e00\u7ec4\u6570\u636e\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.0/matrixone/mo-write# ./mo-write r=10000, T=7, n=500000, mode=multi, retry=1, txc=0, tType=ts, wType=loadLine \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:7\ndb connection[1] created.\ndb connection[2] created.\ndb connection[3] created.\ndb connection[4] created.\ndb connection[5] created.\ndb connection[6] created.\ndb connection[7] created.\nmo-data of all clinet(7 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:7.255468 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=0 \n\nstart test 1 \u2026\u2026.\nspend time:7.405524 s\n1 test: 3500000/7.405524 = 472620.159086 records/second\n======== avg test: 472620.159086/1 = 472620.159086 records/second txc=0 ===========\n
2 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 insert into \u7684\u65b9\u5f0f\uff0c\u5206\u522b\u5411\u6709\u4e3b\u952e\u7684\u65f6\u5e8f\u8868\uff08d0\uff09\u5355\u8868\u5199 100000 \u6761\u6570\u636e\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-write# ./mo-write -T 2 -n 100000 -mode single -tType tsPK -wType insert\nr=10000, T=2, n=100000, mode=single, retry=1, txc=0, tType=tsPK, wType=insert \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:2\ndb connection[1] created.\ndb connection[2] created.\nmo-data of all clinet(2 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:0.819425 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=0 \n\nstart test 1 \u2026\u2026.\nspend time:11.388648 s\n1 test: 200000/11.388648 = 17561.347089 records/second\n======== avg test: 17561.347089/1 = 17561.347089 records/second txc=0 ===========\n
1 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 load data inline \u7684\u65b9\u5f0f\uff0c\u5411\u4e3b\u952e\u4e3a int \u7c7b\u578b\u7684\u666e\u901a\u8868\uff08d0\uff09\u5199 500000 \u6761\u6570\u636e\uff0c\u6d4b\u8bd5\u4e00\u7ec4\u6570\u636e\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-write# ./mo-write -T 1 -tType=intPK -retry 1\nr=10000, T=1, n=500000, mode=multi, retry=1, txc=0, tType=intPK, wType=loadLine \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:1\ndb connection[1] created.\nmo-data of all clinet(1 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:1.583363 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=0 \n\nstart test 1 \u2026\u2026.\nspend time:5.062582 s\n1 test: 500000/5.062582 = 98763.826906 records/second\n======== avg test: 98763.826906/1 = 98763.826906 records/second txc=0 ===========\n
8 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 load data inline \u7684\u65b9\u5f0f\uff0c\u901a\u8fc7\u4e8b\u52a1\u63d0\u4ea4\uff08\u6bcf\u6b21\u63d0\u4ea4 10 \u6b21\u5199\u5165\uff09\u5411\u65e0\u4e3b\u952e\u7684\u65f6\u5e8f\u8868\uff08d0\u2026\u2026d7\uff09\u591a\u8868\u5199 500000 \u6761\u6570\u636e\uff0c\u81ea\u52a8\u6d4b\u8bd5 3 \u7ec4\u6c42\u5e73\u5747\u503c\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-write# ./mo-write -T 8 -txc 10 -retry 3\nr=10000, T=8, n=500000, mode=multi, retry=3, txc=10, tType=ts, wType=loadLine \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:8\ndb connection[1] created.\ndb connection[2] created.\ndb connection[3] created.\ndb connection[4] created.\ndb connection[5] created.\ndb connection[6] created.\ndb connection[7] created.\ndb connection[8] created.\nmo-data of all clinet(8 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:7.854798 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=10 \n\nstart test 1 \u2026\u2026.\n\u5f00\u59cb\u4e8b\u52a1\u63d0\u4ea4\u5199\u5165, \u4e00\u6b21\u4e8b\u52a1\u63d0\u4ea4\u7684\u5199\u5165: 10\nspend time:9.482012 s\n1 test: 4000000/9.482012 = 421851.388088 records/second\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c2\u6b21\u6d4b\u8bd5, txc=10 \n\nstart test 2 \u2026\u2026.\ntables has truncated and start insert data \u2026\u2026\n\u5f00\u59cb\u4e8b\u52a1\u63d0\u4ea4\u5199\u5165, \u4e00\u6b21\u4e8b\u52a1\u63d0\u4ea4\u7684\u5199\u5165: 10\nspend time:10.227261 s\n2 test: 4000000/10.227261 = 391111.576833 records/second\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c3\u6b21\u6d4b\u8bd5, txc=10 \n\nstart test 3 \u2026\u2026.\ntables has truncated and start insert data \u2026\u2026\n\u5f00\u59cb\u4e8b\u52a1\u63d0\u4ea4\u5199\u5165, \u4e00\u6b21\u4e8b\u52a1\u63d0\u4ea4\u7684\u5199\u5165: 10\nspend time:8.994586 s\n3 test: 4000000/8.994586 = 444711.979564 records/second\n======== avg test: 1257674.944485/3 = 419224.981495 records/second txc=10 ===========\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/#mo-query","title":"\u4f7f\u7528 mo-query \u6267\u884c\u67e5\u8be2\u6d4b\u8bd5","text":"mo-query \u4e3a\u67e5\u8be2\u6d4b\u8bd5\u5de5\u5177\uff0c\u6d4b\u8bd5 select *\u3001\u70b9\u67e5\u8be2\u3001\u5e38\u7528\u805a\u5408\u67e5\u8be2\u3001\u65f6\u95f4\u7a97\u53e3\u7b49\u67e5\u8be2\u7684\u65f6\u95f4\uff0c\u6240\u6709\u67e5\u8be2\u90fd\u53ea\u67e5\u8be2 test \u5e93\u91cc d0 \u8fd9\u4e00\u5f20\u8868\u3002\u547d\u4ee4\u4e3a\uff1a
mo-query -T\n
\u53c2\u6570\u8bf4\u660e
-T: \u8868\u793a\u5e76\u53d1\u6267\u884c select * \u67e5\u8be2\u7684\u5ba2\u6237\u7aef\u6570\u91cf\uff0c\u9ed8\u8ba4\u4e3a 1\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/#_4","title":"\u793a\u4f8b","text":"root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-query# ./mo-query -T 5\nT=5 \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:5\ndb connection[1] created.\ndb connection[2] created.\ndb connection[3] created.\ndb connection[4] created.\ndb connection[5] created.\nmo all clinet(5 thread) has ready!\n\n count value is:200000\n'count(*)' query spend time:0.062345 s\n\n'select *' (5 client concurrent query) spend time:0.850350 s\nquery speed: 1000000/0.850350 = 1175985.806764 records/second\n\n point query sql: select * from test.d0 where ts='2017-07-14 10:40:06.379'\n'point query' spend time:0.001589 s\n\n avg value is: 0.07560730761790913\n'avg(current)' query spend time:0.026116 s\n\n sum value is: 15121.461523581824\n'sum(current)' query spend time:0.023109 s\n\n max value is: 3.9999022\n'max(current)' query spend time:0.054021 s\n\n min value is: -3.9999993\n'min(current)' query spend time:0.035809 s\n\nTimeWindow query sql:select _wstart, _wend, max(current), min(current) from d0 interval(ts, 60, minute) sliding(60, minute)\n2017-07-14 02:00:00 +0000 UTC 2017-07-14 03:00:00 +0000 UTC 3.9999022 -3.9999993\nTimeWindow query spend time:0.180333 s\n
"},{"location":"MatrixOne/Release-Notes/release-timeline/","title":"MatrixOne \u7248\u672c\u53d1\u5e03\u5386\u53f2\u8bb0\u5f55","text":"\u672c\u6587\u5217\u51fa\u4e86\u6240\u6709\u5df2\u53d1\u5e03\u7684 MatrixOne \u7248\u672c\uff0c\u6309\u53d1\u5e03\u65f6\u95f4\u5012\u5e8f\u6392\u5217\u5448\u73b0\u3002
\u7248\u672c \u53d1\u5e03\u65e5\u671f v1.2.1 2024/06/27 v1.2.0 2024/05/20 v1.1.3 2024/04/16 v1.1.2 2024/04/02 v1.1.1 2024/02/04 v1.1.0 2023/12/29 v1.0.2 2023/12/23 v1.0.1 2023/12/16 v1.0.0 2023/11/13 v1.0.0-rc2 2023/10/24 v1.0.0-rc1 2023/8/24 v0.8.0 2023/6/30 v0.7.0 2023/2/23 v0.6.0 2022/11/29 v0.5.1 2022/8/19 v0.5.0 2022/7/18 v0.4.0 2022/5/5 v0.3.0 2022/3/10 v0.2.0 2022/1/6 v0.1.0 2021/10/24"},{"location":"MatrixOne/Release-Notes/v0.1.0/","title":"MatrixOne v0.1.0 Release Notes","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.1.0 \u7248\u672c\u4e8e 2021 \u5e74 10 \u6708 24 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
"},{"location":"MatrixOne/Release-Notes/v0.1.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne 0.1.0 \u7248\u672c\u3002
"},{"location":"MatrixOne/Release-Notes/v0.1.0/#_1","title":"\u6838\u5fc3\u7279\u6027","text":""},{"location":"MatrixOne/Release-Notes/v0.1.0/#sql","title":"SQL","text":"\u672c\u6b21\u53d1\u5e03\u7684\u7248\u672c\u652f\u6301\u4e00\u4e0b SQL \u8bed\u53e5\uff1a
"},{"location":"MatrixOne/Release-Notes/v0.1.0/#ddl","title":"DDL","text":"\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 16 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 453 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002\u6b64\u5916\uff0c\u6211\u4eec\u683c\u5916\u611f\u8c22\u9996\u6b21\u4e3a MatrixOne \u4f5c\u51fa\u8d21\u732e\u7684\u5f00\u53d1\u8005\uff01
Yan Wenze (@nnsgmsone) Chen Mingsong (@m-schen) Jin Hai (@JinHai-CN) Jiang xinmeng (@jiangxinmeng1) Li Yang (@lignay) Lin Junhong (@iamlinjunhong) lni (@lni) Long Ran (@aunjgr) Peng Zhen (@daviszhen) Qin Shuqi (@sukki37) Shen JiangWei (@LeftHandCold) Wei Ziran (@w-zr) Xiong Jingjuan (@anitajjx) Xu Peng (@XuPeng-SH) Yan Wenze (@nnsgmsone) Zilong Zhou (@zzl200012) Zhang Yingfeng (@yingfeng)
"},{"location":"MatrixOne/Release-Notes/v0.2.0/","title":"MatrixOne v0.2.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.2.0 \u7248\u672c\u4e8e 2022 \u5e74 1 \u6708 6 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u4ee5\u4e0b\u6211\u4eec\u5c06\u5bf9\u7248\u672c\u6700\u65b0\u7684\u66f4\u65b0\u5185\u5bb9\u8fdb\u884c\u9648\u5217\u3002
"},{"location":"MatrixOne/Release-Notes/v0.2.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne0.2.0 \u7248\u672c\u3002
"},{"location":"MatrixOne/Release-Notes/v0.2.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"group by
\u6216\u805a\u5408\u8bed\u53e5\u4e2d\u4f7f\u7528 equi joinpre-allocate-group-num
\u53c2\u6570\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u66f4\u5927\u7684\u503c\u3002\u5426\u5219\uff0c\u8fc7\u7a0b\u4e2d\u4f1a\u62a5\u9519 \"no available raft group\"\u3002 \u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 21 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 243 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.3.0 \u7248\u672c\u4e8e 2022 \u5e74 3 \u6708 10 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u4ee5\u4e0b\u6211\u4eec\u5c06\u5bf9\u7248\u672c\u6700\u65b0\u7684\u66f4\u65b0\u5185\u5bb9\u8fdb\u884c\u9648\u5217\u3002
"},{"location":"MatrixOne/Release-Notes/v0.3.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne0.3.0 \u7248\u672c\u3002
"},{"location":"MatrixOne/Release-Notes/v0.3.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"IN
\u8fd0\u7b97\u7b26\uff0c\u5728 WHERE
\u5b50\u53e5\u4e2d\u6307\u5b9a\u591a\u4e2a\u503cGROUP BY
\u8bed\u53e5\u4e2d\u652f\u6301 NULLABLE
\u5217Chaos
\u6d4b\u8bd5\u6846\u67b6pre-allocate-group-num
\u53c2\u6570\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u66f4\u5927\u7684\u503c\u3002\u5426\u5219\uff0c\u8fc7\u7a0b\u4e2d\u4f1a\u62a5\u9519 \"no available raft group\"\u3002 \u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 21 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 157 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
\u6211\u4eec\u671f\u5f85\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.3.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.2.0...v0.3.0
"},{"location":"MatrixOne/Release-Notes/v0.4.0/","title":"MatrixOne v0.4.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.4.0 \u7248\u672c\u4e8e 2022 \u5e74 5 \u6708 5 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u4ee5\u4e0b\u6211\u4eec\u5bf9\u7248\u672c\u6700\u65b0\u7684\u66f4\u65b0\u5185\u5bb9\u8fdb\u884c\u7b80\u8981\u8bf4\u660e\u3002
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne0.4.0 \u7248\u672c\u3002
docker pull matrixorigin/matrixone:0.4.0\n
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"pre-allocate-group-num
\u53c2\u6570\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u66f4\u5927\u7684\u503c\u3002\u5426\u5219\uff0c\u5efa\u8868\u8fc7\u7a0b\u4e2d\u4f1a\u62a5\u9519 \"no available raft group\"\u3002 \u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 50 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 253 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.2.0...v0.3.0
"},{"location":"MatrixOne/Release-Notes/v0.5.0/","title":"MatrixOne v0.5.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.5.0 \u7248\u672c\u4e8e 2022 \u5e74 7 \u6708 18 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u62e5\u6709\u4e00\u4e2a\u72ec\u7acb\u7684\u5217\u5f0f\u5b58\u50a8\u5f15\u64ce\uff0c\u53ef\u4ee5\u652f\u6301 HTAP \u5de5\u4f5c\u8d1f\u8f7d\u3002\u5e72\u676f\uff01
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne 0.5.0 \u7248\u672c\u3002
docker pull matrixorigin/matrixone:0.5.0\n
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"UPDATE
\uff0cDELETE
\u548c INSERT INTO ... SELECT ...
\u8bed\u6cd5\u3002 \u2014 \u652f\u6301 BOOL
\u548c Timestamp
\u6570\u636e\u7c7b\u578b\u3002LEFT/RIGHT/OUTER/NATURAL JOIN
Having
\u8868\u8fbe\u3002CASE ... WHEN
\u8868\u8fbe\u5f0f\u3002Interva
\u8868\u8fbe\u5f0f\u3002Explain
\u8ba1\u5212\u6811\u3002Any_value
\u3002\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 73 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 811 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.0
"},{"location":"MatrixOne/Release-Notes/v0.5.1/","title":"MatrixOne v0.5.1 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.5.1 \u7248\u672c\u4e8e 2022 \u5e74 8 \u6708 19 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u89e3\u51b3\u4e86\u4e00\u4e9b\u65e5\u5fd7\u56de\u653e\u548c\u5b58\u50a8\u5783\u573e\u6536\u96c6\uff08GC\uff0cGarbage Collection\uff09\u95ee\u9898\u3002
"},{"location":"MatrixOne/Release-Notes/v0.5.1/#_1","title":"\u529f\u80fd\u4f18\u5316","text":"\u4fee\u590d\u8fd9\u4e9b\u9519\u8bef\u540e\uff0cMatrixOne \u5b9e\u4f8b\u7a33\u5b9a\u6027\u5f97\u4ee5\u63d0\u5347\u3002
"},{"location":"MatrixOne/Release-Notes/v0.5.1/#_2","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.1
"},{"location":"MatrixOne/Release-Notes/v0.6.0/","title":"MatrixOne v0.6.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.6.0 \u7248\u672c\u4e8e 2022 \u5e74 11 \u6708 29 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u5df2\u5347\u7ea7\u4e3a\u5b58\u7b97\u5206\u79bb\u3001\u8bfb\u5199\u5206\u79bb\u3001\u51b7\u70ed\u5206\u79bb\u3001\u4e8b\u52a1\u548c\u5206\u6790\u80fd\u529b\u5206\u79bb\u3001\u5e76\u62e5\u6709\u6781\u81f4\u6269\u5c55\u80fd\u529b\u548c\u5b8c\u6574\u529f\u80fd\u7684\u4e91\u539f\u751f HTAP \u6570\u636e\u5e93\u3002\u5e72\u676f\uff01
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#docker","title":"Docker","text":"docker pull matrixorigin/matrixone:0.6.0\n
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"TEXT
\u3001BLOB
\u3001TIME
\u3001JSON
\u6570\u636e\u7c7b\u578b\u3002CREATE/GRANT/SET ROLE/REVOKE
\u7b49\u64cd\u4f5c\u3002VIEW
\u3002CSV
\u548c JSON
\u6570\u636e\u3002mo-dump
\u3002system_metrics
\u6570\u636e\u5e93\u4ee5\u76d1\u63a7\u5b9e\u4f8b\u72b6\u6001\u3002system
\u6570\u636e\u5e93\uff0c\u7528\u4e8e\u8bb0\u5f55\u7528\u6237\u8bed\u53e5\u548c\u7cfb\u7edf\u65e5\u5fd7\u3002timezone
\u7684\u652f\u6301\u3002PREPARE
\u3001EXECUTE
\u3001DEALLOCATE
\u3002Explain Analyze
\u8be6\u7ec6\u67e5\u8be2\u8ba1\u5212\u5206\u6790\u3002UNION
\u3001UNION ALL
\u3001INTERSECT
\u3001MINUS
\u8fd0\u7b97\u7b26\u3002CREATE TEMPORARY TABLE
\u4e34\u65f6\u8868\u3002CREATE EXTERNAL TABLE
\u5916\u90e8\u8868\u3002Partition by
\u80fd\u529b\u3002JSON
\u4ee5\u53ca\u5927\u91cf Datetime
\u7c7b\u578b\u51fd\u6570\u3002UUID
\u51fd\u6570\u3002&, |, ^, ~, <<, >>
\u3002DDL
\u4e2d\u5e26 comment
\u529f\u80fd\u3002SET
\u81ea\u5b9a\u4e49\u53d8\u91cf\u529f\u80fd\u3002BLOB
\u4e2d\u4f1a\u51fa\u73b0\u5931\u8d25\u3002#6302\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 97 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 1520 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.5.1...v0.6.0
"},{"location":"MatrixOne/Release-Notes/v0.7.0/","title":"MatrixOne v0.7.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.7.0 \u7248\u672c\u4e8e 2023 \u5e74 2 \u6708 23 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u5728\u4e91\u539f\u751f\u67b6\u6784\u548c\u5b8c\u6574\u6570\u636e\u5e93\u529f\u80fd\u5f62\u6001\u4e0b\uff0c\u7248\u672c 0.7.0 \u8fdb\u884c\u4e86\u7a33\u5b9a\u6027\u548c\u6027\u80fd\u7684\u4e13\u9879\u4f18\u5316\uff1a
Cluster by
\u5b57\u6bb5\uff0c\u53ef\u4ee5\u9884\u5148\u5c06\u6570\u636e\u505a\u597d\u6392\u5e03\uff0c\u4ee5\u65b9\u4fbf\u66f4\u5feb\u7684\u83b7\u53d6\u3002\u53e6\u5916\u4e5f\u4f18\u5316\u4e86 IN
\u64cd\u4f5c\u7b26\u3001\u7c7b\u578b\u8f6c\u6362\u3001\u8c13\u8bcd\u8fc7\u6ee4\u7b49\u4f17\u591a\u6027\u80fd\u5361\u70b9\u3002\u5728\u5199\u7684\u65b9\u9762\uff0c\u8fd9\u4e2a\u8fed\u4ee3\u5b9e\u73b0\u4e86\u76f4\u63a5\u901a\u8fc7 CN
\u8282\u70b9\u5927\u6279\u91cf\u5e76\u884c\u5199\u5165\u5171\u4eab\u5b58\u50a8\uff0c\u4ece\u800c\u83b7\u5f97\u4e86\u52a0\u8f7d\u6027\u80fd\u7684\u5927\u5e45\u63d0\u5347\u3002docker pull matrixorigin/matrixone:0.7.0\n
"},{"location":"MatrixOne/Release-Notes/v0.7.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"Foreign Key
\u3002Cluster by
\u5b57\u6bb5\u3002MYSQL_COMPATBILITY_MODE
\u53c2\u6570\u7ba1\u7406\u90e8\u5206 MySQL \u4e13\u5c5e\u517c\u5bb9\u884c\u4e3a\u3002REPEATABLE_READ
\u5b9e\u73b0\u66f4\u4f18\u7684 MySQL \u517c\u5bb9\u3002Unique Index
\u5b9e\u73b0\u5b8c\u6574\u552f\u4e00\u7ea6\u675f\u3002Alter View
\u3002group_concat
\u3002format
, replace
, curdate
, field
, substring_index
\u7b49\u7cfb\u7edf\u51fd\u6570\u3002\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 43 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 656 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.7.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.7.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.6.0...v0.7.0
"},{"location":"MatrixOne/Release-Notes/v0.8.0/","title":"MatrixOne v0.8.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.8.0 \u7248\u672c\u4e8e 2023 \u5e74 6 \u6708 30 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
\u5728\u5386\u7ecf\u56db\u4e2a\u6708\u7684\u6df1\u5ea6\u7814\u53d1\u4e4b\u540e\uff0cMatrixOne \u5728\u6027\u80fd\u3001\u6269\u5c55\u6027\u548c\u53ef\u7528\u6027\u65b9\u9762\u5b9e\u73b0\u4e86\u663e\u8457\u63d0\u5347\u3002\u6b64\u6b21\u66f4\u65b0\u7684\u4eae\u70b9\u5728\u4e8e Proxy \u6a21\u5757\u7684\u5f15\u5165\uff0c\u5b83\u4f7f\u5f97 MatrixOne \u80fd\u591f\u51c6\u786e\u5730\u5c06\u5404\u7c7b SQL \u8bf7\u6c42\u548c\u8d1f\u8f7d\u7c7b\u578b\u4e0e\u76f8\u5e94\u7684 CN \u7ec4\u8fdb\u884c\u5173\u8054\uff0c\u4ece\u800c\u5728\u79df\u6237\u9694\u79bb\u3001\u8bfb\u5199\u5206\u79bb\u3001\u4e8b\u52a1\u5904\u7406\uff08TP\uff09/\u5206\u6790\u5904\u7406\uff08AP\uff09\u8d1f\u8f7d\u5206\u79bb\u7b49\u5173\u952e\u529f\u80fd\u4e0a\u53d6\u5f97\u4e86\u663e\u8457\u63d0\u5347\u3002\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u8fd9\u6b21\u53d1\u5e03\u7684 0.8.0 \u7248\u672c\u662f MatrixOne \u5728\u5168\u9762\u516c\u5f00\u53d1\u5e03\u524d\u7684\u6700\u540e\u4e00\u4e2a\u7248\u672c\uff0c\u540c\u65f6\u4e5f\u4f5c\u4e3a MatrixOne \u4ea7\u54c1\u7684\u516c\u6d4b Beta \u7248\uff0c\u6211\u4eec\u8bda\u631a\u9080\u8bf7\u5404\u4f4d\u7528\u6237\u548c\u5f00\u53d1\u8005\u4e0b\u8f7d\u8bd5\u7528\uff0c\u671f\u5f85\u4f60\u4eec\u7684\u53cd\u9988\u548c\u5efa\u8bae\u3002\u4e3a\u4e86\u8fd9\u4e00\u91cc\u7a0b\u7891\u5f0f\u7684\u8fdb\u6b65\uff0c\u8ba9\u6211\u4eec\u5171\u540c\u4e3e\u676f\u5e86\u795d\uff01
"},{"location":"MatrixOne/Release-Notes/v0.8.0/#docker","title":"Docker","text":"docker pull matrixorigin/matrixone:0.8.0\n
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:0.8.0\n
"},{"location":"MatrixOne/Release-Notes/v0.8.0/#_1","title":"\u91cd\u70b9\u5173\u6ce8","text":""},{"location":"MatrixOne/Release-Notes/v0.8.0/#_2","title":"\u6027\u80fd\u63d0\u5347","text":"mo_ctl
\uff0c\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u68c0\u67e5\u57fa\u7840\u786c\u4ef6\u73af\u5883\uff0c\u521d\u59cb\u5316\u914d\u7f6e\u53ca\u4e00\u952e\u5b89\u88c5\u90e8\u7f72\u3002\u4e0d\u8bba\u662f\u5355\u673a\u7248\u672c\u8fd8\u662f\u5206\u5e03\u5f0f\u7248\u672c\u7528\u6237\u90fd\u4e0d\u518d\u9700\u8981\u901a\u8fc7\u590d\u6742\u7684 Linux \u53ca K8s \u539f\u751f\u547d\u4ee4\u6765\u8fdb\u884c\u90e8\u7f72\u53ca\u8fd0\u7ef4\u3002information_schema
\u5e93\u7684\u8868\u7ed3\u6784\uff0c\u5927\u5927\u964d\u4f4e\u4e86\u4ece MySQL \u8fdb\u884c\u8fc1\u79fb\u7684\u9002\u914d\u5de5\u4f5c\u91cf\u3002Select for update
\u547d\u4ee4\u7684\u652f\u6301\u3002RANK()
\uff0cROW_NUMBER()
\u548c DENSE_RANK()
\u3002BINARY
\u7c7b\u578b\u548c\u76f8\u5173\u51fd\u6570\u3002PUBLISH
/SUBSCRIBE
\u51fd\u6570\u3002INSERT...ON DUPLICATE KEY UPDATE
\u8bed\u53e5\u3002Sequence
\u3002ALTER TABLE
\u3002RAND()
\u51fd\u6570\u3002Partition By
\u5206\u533a\u8868\u529f\u80fd\u3002\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.8.0/#_8","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.7.0...v0.8.0
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/","title":"MatrixOne v1.0.0-RC1 \u53d1\u5e03\u62a5\u544a","text":"\u6211\u4eec\u975e\u5e38\u9ad8\u5174\u5730\u5ba3\u5e03 MatrixOne \u5185\u6838 v1.0.0-RC1 \u7248\u672c\u4e8e 2023 \u5e74 8 \u6708 24 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
\u8fd9\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u91cc\u7a0b\u7891\uff0c\u6807\u5fd7\u7740 MatrixOne \u5df2\u7ecf\u57fa\u672c\u5b9e\u73b0\u4e00\u4e2a\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\u7684\u4e3b\u8981\u529f\u80fd\u3002MatrixOne \u5185\u6838 1.0 GA \u53ca MatrixOne Cloud \u6b63\u5f0f\u7248\u4e5f\u5c06\u5728\u8fd1\u671f\u53d1\u5e03\uff0c\u656c\u8bf7\u5173\u6ce8\uff01
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#matrixone-100-rc1","title":"MatrixOne 1.0.0-RC1 \u529f\u80fd\u6982\u89c8","text":"MatrixOne \u7684\u8bbe\u8ba1\u548c\u5f00\u53d1\u59cb\u7ec8\u805a\u7126\u5728\u8d44\u6e90\u5229\u7528\u6700\u5927\u5316\u548c\u8d85\u9ad8\u6027\u4ef7\u6bd4\u3001\u7b80\u5316\u6570\u636e\u5904\u7406\u67b6\u6784\u3001\u964d\u4f4e\u7528\u6237\u6570\u636e\u5904\u7406\u96be\u5ea6\u7b49\u51e0\u4e2a\u65b9\u9762\u3002MatrixOne 1.0.0-RC1 \u7684\u529f\u80fd\u4e0e\u6027\u80fd\u5df2\u7ecf\u57fa\u672c\u4e0a\u8fbe\u6210\u4e86\u67b6\u6784\u8bbe\u8ba1\u76ee\u6807\uff0c\u5b8c\u6574\u7684\u5b9e\u73b0\u4e86\u4e91\u539f\u751f\u53ca\u5b58\u7b97\u5206\u79bb\u3001\u51b7\u70ed\u5206\u79bb\u548c\u7ec6\u6570\u636e\u9897\u7c92\u5ea6\u7684\u8bfb\u5199\u5206\u79bb\u67b6\u6784\uff0c\u5177\u5907\u4e86\u4e00\u6b3e SQL \u6570\u636e\u5e93\u4ea7\u54c1\u7684\u4e3b\u8981\u529f\u80fd\uff0c\u4e14\u5728 OLTP\uff0cOLAP\uff0c\u65f6\u5e8f\u51e0\u4e2a\u4e0d\u540c\u8d1f\u8f7d\u4e0b\u7684\u6027\u80fd\u5747\u8868\u73b0\u826f\u597d\uff0c\u4e5f\u5df2\u7ecf\u63d0\u4f9b\u4e86\u6700\u57fa\u7840\u6d41\u8ba1\u7b97\u80fd\u529b\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#sql","title":"SQL \u80fd\u529b","text":"MatrixOne \u4ea7\u54c1\u9002\u7528\u4e8e\u4ee5\u4e0b\u51e0\u4e2a\u5e94\u7528\u573a\u666f\u3002\u6211\u4eec\u975e\u5e38\u6b22\u8fce\u6709\u4ee5\u4e0b\u4e1a\u52a1\u75db\u70b9\u53ca\u9700\u6c42\u7684\u7528\u6237\u4e0e\u6211\u4eec\u8054\u7cfb\u8fdb\u884c\u8bd5\u7528\u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#htap","title":"\u8f7b\u91cf\u7ea7 HTAP \u573a\u666f","text":"\u4f01\u4e1a\u5e38\u7528\u7684\u4e1a\u52a1\u7cfb\u7edf\uff0c\u5982 OA\uff0cERP\uff0cCRM \u7b49\u7cfb\u7edf\u968f\u7740\u4e1a\u52a1\u7684\u53d1\u5c55\u6570\u636e\u91cf\u589e\u5927\uff0c\u4f20\u7edf\u7684\u5355\u673a\u6570\u636e\u5e93\u65e0\u6cd5\u6ee1\u8db3\u5176\u6027\u80fd\u9700\u6c42\uff0c\u5c24\u5176\u5728\u7279\u6b8a\u65f6\u95f4\u70b9\u7684\u4e1a\u52a1\u5206\u6790\u9700\u6c42\uff0c\u5f88\u591a\u4f01\u4e1a\u4f1a\u4e13\u95e8\u914d\u5907\u4e00\u5957\u5206\u6790\u6570\u636e\u5e93\u7cfb\u7edf\u6765\u6ee1\u8db3\u6708\u672b\uff0c\u5b63\u672b\u7b49\u91cd\u8981\u8282\u70b9\u7684\u7edf\u8ba1\u62a5\u8868\u9700\u6c42\uff0c\u6216\u8005\u91c7\u7528\u5206\u5e93\u5206\u8868\u7b49\u5f62\u5f0f\u6765\u964d\u4f4e\u67e5\u8be2\u8d1f\u8f7d\u3002\u8fd9\u79cd\u573a\u666f\u91c7\u7528 MatrixOne \u6570\u636e\u5e93\u53ef\u4ee5\u7528\u4e00\u5957\u6570\u636e\u5e93\u540c\u65f6\u6ee1\u8db3\u4e1a\u52a1\u7cfb\u7edf\u548c\u5206\u6790\u7cfb\u7edf\u7684\u9700\u6c42\uff0c\u540c\u65f6\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u968f\u7740\u4e1a\u52a1\u589e\u957f\u53ef\u4ee5\u65e0\u7f1d\u6269\u5bb9\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_7","title":"\u5b9e\u65f6\u5206\u6790\u573a\u666f","text":"\u9488\u5bf9\u4f01\u4e1a\u5178\u578b\u7684 OLAP \u7c7b\u578b\u5e94\u7528\uff0c\u5982\u770b\u677f\u3001BI \u62a5\u8868\u7b49\u5206\u6790\u7cfb\u7edf\uff0c\u5f80\u5f80\u9700\u8981\u8fdb\u884c\u6d77\u91cf\u6570\u636e\u7684\u5206\u6790\uff0c\u6570\u636e\u91cf\u4e00\u65e6\u8f83\u4e3a\u5e9e\u5927\u5219\u4f1a\u9762\u4e34\u6027\u80fd\u74f6\u9888\uff0c\u5bfc\u81f4\u65f6\u6548\u6027\u8f83\u5dee\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u5206\u6790\u6027\u80fd\u548c\u53ef\u6269\u5c55\u80fd\u529b\uff0c\u53ef\u4ee5\u9488\u5bf9\u5404\u7c7b\u590d\u6742\u548c\u6570\u636e\u91cf\u5e9e\u5927\u7684 SQL \u67e5\u8be2\u8fdb\u884c\u52a0\u901f\uff0c\u83b7\u5f97\u79d2\u7ea7\u4f53\u9a8c\u7684\u6548\u679c\uff0c\u63d0\u9ad8\u4f01\u4e1a\u51b3\u7b56\u5206\u6790\u7684\u654f\u6377\u5ea6\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_8","title":"\u65f6\u5e8f\u6570\u636e\u573a\u666f","text":"\u968f\u7740\u4f20\u611f\u5668\u548c\u7f51\u7edc\u6280\u672f\u7684\u5927\u91cf\u5e94\u7528\uff0c\u6d77\u91cf\u7684\u5404\u7c7b IoT \u8bbe\u5907\u751f\u4ea7\u4e86\u5927\u91cf\u7684\u6570\u636e\uff0c\u6bd4\u5982\u5236\u9020\u4e1a\u5de5\u5382\u4ea7\u7ebf\uff0c\u65b0\u80fd\u6e90\u6c7d\u8f66\uff0c\u57ce\u5e02\u5b89\u9632\u76d1\u63a7\u6444\u50cf\u5934\u7b49\u7b49\uff0c\u5176\u89c4\u6a21\u53ef\u80fd\u8f7b\u6613\u80fd\u8fbe\u5230\u6570\u767e TB \u751a\u81f3 PB \u7ea7\u522b\uff0c\u800c\u5bf9\u6570\u5b57\u5316\u7684\u9700\u6c42\u4e5f\u8d8a\u6765\u8d8a\u591a\u7684\u8981\u6c42\u4f01\u4e1a\u5b58\u50a8\u548c\u5229\u7528\u8fd9\u4e9b\u6570\u636e\u3002\u4f46\u662f\u4f20\u7edf\u7684\u6570\u636e\u5e93\u65b9\u6848\u65e0\u6cd5\u6ee1\u8db3\u5982\u6b64\u6d77\u91cf\u4e14\u5927\u89c4\u6a21\u7684\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u4ee5\u53ca\u52a0\u5de5\u5e94\u7528\u7684\u573a\u666f\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u6d41\u5f0f\u6570\u636e\u5199\u5165\u548c\u52a0\u5de5\u7684\u80fd\u529b\uff0c\u540c\u65f6\u5f3a\u5927\u7684\u53ef\u6269\u5c55\u6027\u53ef\u4ee5\u9002\u5e94\u4efb\u610f\u89c4\u6a21\u7684\u8d1f\u8f7d\u548c\u6570\u636e\u91cf\uff0c\u53ef\u4ee5\u5b8c\u5168\u6ee1\u8db3\u8be5\u573a\u666f\u7684\u9700\u6c42\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_9","title":"\u8d1f\u8f7d\u6ce2\u52a8\u8f83\u591a\u7684\u521b\u65b0\u4e1a\u52a1\u573a\u666f","text":"\u5bf9\u4e8e\u6e38\u620f\uff0c\u7535\u5546\uff0c\u6587\u5a31\uff0c\u793e\u4ea4\uff0c\u65b0\u95fb\u7b49\u4e92\u8054\u7c7b\u5e94\u7528\u6765\u8bf4\uff0c\u7528\u6237\u6570\u91cf\u5e9e\u5927\u4e14\u4e1a\u52a1\u6ce2\u52a8\u5267\u70c8\u800c\u9891\u7e41\uff0c\u5728\u70ed\u95e8\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u5019\uff0c\u5f80\u5f80\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u6765\u652f\u6491\u4e1a\u52a1\u9700\u6c42\u3002MatrixOne \u5b8c\u5168\u4e91\u539f\u751f\u5316\u7684\u67b6\u6784\u5177\u5907\u8d85\u5f3a\u7684\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u8ddf\u968f\u4e1a\u52a1\u7684\u53d8\u5316\u81ea\u52a8\u7684\u5feb\u901f\u6269\u7f29\u5bb9\uff0c\u6781\u5927\u7684\u964d\u4f4e\u7528\u6237\u7684\u8fd0\u7ef4\u96be\u5ea6\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#saas","title":"\u4f01\u4e1a\u7ea7 SaaS \u573a\u666f","text":"\u4f01\u4e1a\u7ea7 SaaS \u5e94\u7528\u5728\u8fd1\u51e0\u5e74\u6210\u7206\u53d1\u5f0f\u7684\u589e\u957f\u8d8b\u52bf\uff0cSaaS \u7684\u5e94\u7528\u5f00\u53d1\u4e2d\u90fd\u9700\u8981\u8003\u8651\u81ea\u5df1\u7684\u591a\u79df\u6237\u6a21\u578b\uff0c\u4f20\u7edf\u7684\u65b9\u6848\u4e2d\u4f1a\u6709\u591a\u79df\u6237\u5171\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u548c\u5355\u79df\u6237\u72ec\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u4e24\u79cd\u6a21\u5f0f\uff0c\u4f46\u662f\u4f1a\u9762\u4e34\u7ba1\u7406\u6210\u672c\u548c\u9694\u79bb\u6027\u7684\u4e24\u96be\u9009\u62e9\u3002MatrixOne \u81ea\u5e26\u591a\u79df\u6237\u80fd\u529b\uff0c\u79df\u6237\u4e4b\u95f4\u5929\u7136\u8d1f\u8f7d\u9694\u79bb\u4e14\u53ef\u4ee5\u72ec\u7acb\u6269\u5c55\uff0c\u540c\u65f6\u53c8\u63d0\u4f9b\u4e86\u7edf\u4e00\u7ba1\u7406\u80fd\u529b\uff0c\u53ef\u4ee5\u517c\u987e\u4f01\u4e1a\u5bf9\u6210\u672c\uff0c\u7ba1\u7406\u7b80\u6613\u5ea6\u548c\u9694\u79bb\u6027\u7684\u9700\u6c42\uff0c\u662f SaaS \u5e94\u7528\u7684\u6700\u4f73\u9009\u62e9\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_10","title":"\u5feb\u901f\u8bd5\u7528","text":"\u793e\u533a\u7528\u6237\u53ca\u4f01\u4e1a\u5f00\u53d1\u8005\u90fd\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u4e00\u952e\u90e8\u7f72 MatrixOne \u8fdb\u884c\u8bd5\u7528\u3002
docker pull matrixorigin/matrixone:1.0.0-rc1\n
\u672c\u6587\u6863\u7f51\u7ad9\u4e5f\u63d0\u4f9b\u8be6\u7ec6\u7684\u67b6\u6784\u8bf4\u660e\u3001\u5b89\u88c5\u6307\u5357\u548c\u5f00\u53d1\u6559\u7a0b\uff0c\u5e2e\u52a9\u60a8\u63a2\u7d22 MatrixOne \u7684\u80fd\u529b\u3002
\u6b64\u5916\uff0c\u6211\u4eec\u7684 GitHub \u7f51\u7ad9\u548c\u793e\u533a\u5fae\u4fe1\u7fa4\u6b22\u8fce\u60a8\u63d0\u95ee\u3001\u8ba8\u8bba\u6216\u53cd\u9988\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#080-100","title":"0.8.0 \u5230 1.0.0 \u7684\u8fed\u4ee3\u66f4\u65b0","text":"\u5728\u8fd9\u4e24\u4e2a\u6708\u7684\u7248\u672c\u8fed\u4ee3\u4e2d\uff0c\u6211\u4eec\u4e5f\u7740\u91cd\u4f18\u5316\u4e86\u6211\u4eec\u9762\u5411\u751f\u4ea7\u73af\u5883\u7684\u4e00\u4e9b\u529f\u80fd\u53ca\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_11","title":"\u91cd\u70b9\u65b0\u529f\u80fd","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_12","title":"\u7269\u7406\u5907\u4efd\uff08\u4f01\u4e1a\u7248\uff09","text":"\u8fd9\u4e2a\u7248\u672c\u6211\u4eec\u5f15\u5165\u4e86\u7269\u7406\u5907\u4efd\u529f\u80fd\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u65b9\u4fbf\u5730\u5907\u4efd\u548c\u8fd8\u539f\u6570\u636e\u5e93\u3002\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u6570\u636e\u5e93\u7684\u5feb\u7167\uff0c\u5e76\u5728\u9700\u8981\u65f6\u6062\u590d\u5230\u5148\u524d\u7684\u72b6\u6001\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u53ef\u9760\u6027\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_13","title":"\u6d41\u8ba1\u7b97","text":"\u4f5c\u4e3a HSTAP \u67b6\u6784\u7684\u6700\u540e\u4e00\u5757\u62fc\u56fe\uff0c\u6211\u4eec\u5b8c\u6210\u4e86\u6d41\u8ba1\u7b97\u7684\u6846\u67b6\u8bbe\u8ba1\uff0c\u5e76\u5728\u8fd9\u4e2a\u8fed\u4ee3\u589e\u52a0\u4e86\u521b\u5efa\u6d41\u5f0f\u8868\u7684\u76f8\u5173\u80fd\u529b\uff0c\u540c\u65f6\u5b9e\u73b0\u4e86\u4e00\u4e2a Kafka \u7684\u8fde\u63a5\u5668\uff0c\u7528\u4e8e\u6ee1\u8db3\u5927\u91cf\u65f6\u5e8f\u573a\u666f\u7684\u6d41\u5f0f\u6570\u636e\u63a5\u5165\u9700\u6c42\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#cte","title":"\u9012\u5f52 CTE","text":"\u9012\u5f52 CTE \u662f\u4e00\u4e2a\u91cd\u590d\u6267\u884c\u521d\u59cb CTE \u4ee5\u8fd4\u56de\u6570\u636e\u5b50\u96c6\u76f4\u5230\u83b7\u53d6\u5b8c\u6574\u7ed3\u679c\u96c6\u7684\u516c\u7528\u8868\u8868\u8fbe\u5f0f\u3002\u672c\u8fed\u4ee3\u7684\u5b9e\u73b0\u5c06\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u5904\u7406\u5177\u6709\u5c42\u6b21\u7ed3\u6784\u7684\u6570\u636e\uff0c\u80fd\u591f\u4f7f\u7528\u9012\u5f52\u67e5\u8be2\u6784\u5efa\u66f4\u590d\u6742\u548c\u7075\u6d3b\u7684\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_14","title":"\u53ef\u7528\u6027\u63d0\u5347","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mysql","title":"MySQL \u5efa\u8868\u8bed\u53e5\u517c\u5bb9","text":"\u6211\u4eec\u8fdb\u4e00\u6b65\u6539\u8fdb\u4e86 MatrixOne \u5bf9 MySQL \u7684\u517c\u5bb9\u6027\uff0c\u4f7f\u5176\u80fd\u591f\u66f4\u597d\u5730\u652f\u6301 MySQL \u5efa\u8868\u8bed\u53e5\u3002\u73b0\u5728\u7528\u6237\u53ef\u4ee5\u65e0\u7f1d\u8fc1\u79fb\u73b0\u6709\u7684 MySQL \u5e94\u7528\u7a0b\u5e8f\u5230 MatrixOne \u4e2d\uff0c\u800c\u65e0\u9700\u4fee\u6539\u73b0\u6709\u7684\u5efa\u8868\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_15","title":"\u6269\u7f29\u5bb9\u4f1a\u8bdd\u8fc1\u79fb","text":"\u6211\u4eec\u589e\u52a0\u4e86\u6269\u7f29\u5bb9\u4f1a\u8bdd\u8fc1\u79fb\u7684\u80fd\u529b\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u5728\u5206\u5e03\u5f0f\u5b9e\u4f8b\u6269\u5bb9\u6216\u7f29\u5bb9\u65f6\u65e0\u7f1d\u8fc1\u79fb\u4f1a\u8bdd\u3002\u7528\u6237\u53ef\u4ee5\u5728\u4e0d\u5f71\u54cd\u73b0\u6709\u4f1a\u8bdd\u548c\u4e1a\u52a1\u7684\u60c5\u51b5\u4e0b\uff0c\u8f7b\u677e\u5730\u8c03\u6574 MatrixOne \u7684\u5bb9\u91cf\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_16","title":"\u7cfb\u7edf\u914d\u7f6e\u7b80\u5316","text":"\u6211\u4eec\u5927\u5e45\u7b80\u5316\u4e86\u5355\u673a\u4e0e\u5206\u5e03\u5f0f\u7248\u672c\u7684\u542f\u52a8\u914d\u7f6e\u9879\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u66f4\u5feb\u901f\u5730\u4e0a\u624b\u542f\u52a8\u6570\u636e\u5e93\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mo_ctl","title":"mo_ctl \u5de5\u5177\u4f18\u5316","text":"\u6211\u4eec\u9488\u5bf9\u5355\u673a\u4e0e\u5206\u5e03\u5f0f\u7684 mo_ctl \u8fd0\u7ef4\u5de5\u5177\u8fdb\u884c\u4e86\u529f\u80fd\u4f18\u5316\uff0c\u63d0\u4f9b\u4e86\u66f4\u5f3a\u5927\u548c\u6613\u7528\u7684\u8fd0\u7ef4\u529f\u80fd\u3002\u73b0\u5728\u60a8\u53ef\u4ee5\u901a\u8fc7\u5206\u5e03\u5f0f mo_ctl \u5de5\u5177\uff08\u4f01\u4e1a\u7248\uff09\u8f7b\u677e\u5b9e\u73b0\u90e8\u7f72\uff0c\u5347\u7ea7\uff0c\u6269\u7f29\u5bb9\u7b49\u8fd0\u7ef4\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_17","title":"\u5176\u4ed6\u65b0\u529f\u80fd","text":"Replace
\u8bed\u53e5Alter Table
\u5b8c\u5584\u4e86\u4fee\u6539\u5217\u5c5e\u6027\u76f8\u5173\u80fd\u529bCreate Stage
\u8bed\u53e5\uff0c\u7b80\u5316\u5bfc\u5165\u5bfc\u51fa\u7684\u6d41\u7a0bShow Processlist
\u8bed\u53e5\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u72b6\u6001enum
\u7c7b\u578bYear
\u7c7b\u578bTo_Days
/To_Seconds
\u7cfb\u7edf\u51fd\u6570Group by
\u884c\u4e3a\uff0c\u53ef\u4ee5\u652f\u6301\u522b\u540dhttps://github.com/matrixorigin/matrixone/compare/v0.8.0...v1.0.0-rc1
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc2/","title":"MatrixOne v1.0.0-RC2 \u53d1\u5e03\u62a5\u544a","text":"\u4e0e\u4e4b\u524d\u7684 v1.0.0-RC1 \u76f8\u6bd4\uff0cv1.0.0-RC2 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc2/#_1","title":"\u6027\u80fd\u63d0\u5347","text":"delete
\u64cd\u4f5c\u7684\u6027\u80fd\u548c\u7a33\u5b9a\u6027\uff1a#11541, #11542, #11882, #11969\u3002on duplicate key
\u7684\u529f\u80fd\uff1a#11632, #11760\u3002mo_ctl
\u7684\u80fd\u529b\uff1a#11680, #12247\u3002partition
\u76f8\u5173\u7684\u529f\u80fd\uff1a#11762\u3002runtime filter
#11868\u3002count/min/max
\u64cd\u4f5c\u8fdb\u884c\u4e86\u6027\u80fd\u4f18\u5316\uff1a#11959\u3002checkpoint
\u76f8\u5173\u7684\u9519\u8bef\uff1a#12014\uff0c#12124\uff0c#12172\u3002alter table/db
\u76f8\u5173\u7684\u9519\u8bef\uff1a#11429\uff0c#11484\uff0c#12162\u3002taskservice
\u76f8\u5173\u7684\u9519\u8bef\uff1a#11544\u3002show backend servers
\u663e\u793a\u9519\u8bef\u7ed3\u679c\u7684\u95ee\u9898 #11414\u3002insert
\u76f8\u5173\u7684 bug\uff1a#11495\u3002https://github.com/matrixorigin/matrixone/compare/v1.0.0-rc1...v1.0.0-rc2
"},{"location":"MatrixOne/Release-Notes/v1.0.0/","title":"MatrixOne v1.0.0 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2023 \u5e74 11 \u6708 13 \u65e5
MatrixOne \u7248\u672c\uff1av1.0.0
\u4e0e\u4e4b\u524d\u7684 v1.0.0-RC2 \u76f8\u6bd4\uff0cv1.0.0 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0/#_1","title":"\u6539\u8fdb","text":"https://github.com/matrixorigin/matrixone/compare/v1.0.0-rc2...v1.0.0
"},{"location":"MatrixOne/Release-Notes/v1.0.1/","title":"MatrixOne v1.0.1 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2023 \u5e74 12 \u6708 16 \u65e5
MatrixOne \u7248\u672c\uff1av1.0.1
\u4e0e\u4e4b\u524d\u7684 v1.0.0 \u76f8\u6bd4\uff0cv1.0.1 \u4ec5\u5f15\u5165\u4e86\u5c11\u91cf\u7cfb\u7edf\u51fd\u6570\u529f\u80fd\uff0c\u5176\u4ed6\u5747\u4e3a\u7cfb\u7edf\u4f18\u5316\u548c Bug \u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.1/#_1","title":"\u6539\u8fdb","text":"Show processlist
\u7684 bug: #12834https://github.com/matrixorigin/matrixone/compare/v1.0.0...v1.0.1
"},{"location":"MatrixOne/Release-Notes/v1.0.2/","title":"MatrixOne v1.0.2 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2023 \u5e74 12 \u6708 23 \u65e5
MatrixOne \u7248\u672c\uff1av1.0.2
\u4e0e\u4e4b\u524d\u7684 v1.0.1 \u76f8\u6bd4\uff0cv1.0.2 \u4ec5\u5f15\u5165\u4e86\u5c11\u91cf\u7684\u7cfb\u7edf\u51fd\u6570\u548c\u6539\u8fdb\uff0c\u800c\u66f4\u4e13\u6ce8\u4e8e\u5bf9\u9519\u8bef\u7684\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.2/#_1","title":"\u6539\u8fdb","text":"https://github.com/matrixorigin/matrixone/compare/v1.0.1...v1.0.2
"},{"location":"MatrixOne/Release-Notes/v1.1.0/","title":"MatrixOne v1.1.0 \u53d1\u5e03\u62a5\u544a","text":"\u6211\u4eec\u975e\u5e38\u9ad8\u5174\u5730\u5ba3\u5e03 MatrixOne \u5185\u6838 v1.1.0 \u7248\u672c\u4e8e 2023 \u5e74 12 \u6708 29 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#matrixone","title":"MatrixOne \u662f\u4ec0\u4e48\uff1f","text":"MatrixOne \u662f\u4e00\u6b3e\u5206\u5e03\u5f0f\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0cMatrixOne \u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u4e91\u539f\u751f\u3001\u9ad8\u6027\u80fd\u3001\u9ad8\u5f39\u6027\u3001\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684 HSTAP \u6570\u636e\u5e93\uff0c\u8ba9\u7528\u6237\u9762\u5bf9\u4e8b\u52a1\u3001\u5206\u6790\u3001\u65f6\u5e8f\u3001\u6d41\u8ba1\u7b97\u7b49\u6df7\u5408\u8d1f\u8f7d\u65f6\uff0c\u901a\u8fc7 MatrixOne \u4e00\u7ad9\u5f0f\u7684\u5b8c\u6210\u6574\u4e2a\u6570\u636e\u5904\u7406\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_1","title":"\u91cd\u70b9\u5173\u6ce8","text":"MatrixOne \u5728\u672c\u8fed\u4ee3\u589e\u52a0\u4e86\u591a\u4e2a\u91cd\u8981\u529f\u80fd\uff0c\u5728\u6574\u4f53 HTAP \u7684\u57fa\u7840\u4e0a\u589e\u5f3a\u4e86\u5411\u91cf\uff0c\u6d41\u548c\u65f6\u5e8f\u65b9\u9762\u7684\u80fd\u529b\uff0c\u8fdb\u4e00\u6b65\u4e30\u5bcc\u4e86\u80fd\u529b\u8c61\u9650\u548c\u9002\u7528\u8303\u56f4\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_2","title":"\u5411\u91cf\u6570\u636e\u7c7b\u578b","text":"\u4f5c\u4e3a 2023 \u5e74 AI \u4e0e\u5927\u6a21\u578b\u70ed\u6f6e\u7684\u6570\u636e\u57fa\u5ea7\u80fd\u529b\uff0c\u5411\u91cf\u7c7b\u578b\u5df2\u7ecf\u6210\u4e3a\u901a\u7528\u6570\u636e\u5e93\u7684\u6807\u914d\u3002\u672c\u8fed\u4ee3 MatrixOne \u652f\u6301\u4e86 vecf32 \u53ca vecf64 \u7684\u5411\u91cf\u7c7b\u578b\uff0c\u5206\u522b\u5bf9\u5e94 float32 \u548c float64 \u6570\u636e\u7c7b\u578b\uff0c\u540c\u65f6\u652f\u6301\u4e86\u57fa\u672c\u7684\u7b97\u5b50\u548c\u64cd\u4f5c\u7b26\uff0c\u4ee5\u53ca\u5411\u91cf\u5e38\u89c1\u7684\u6c42\u548c\uff0cL1 \u8303\u6570\uff0cL2 \u8303\u6570\uff0c\u5185\u79ef\uff0c\u4f59\u5f26\u76f8\u4f3c\u5ea6\u7b49\u8ba1\u7b97\u51fd\u6570\u3002\u7528\u6237\u4f7f\u7528\u7684\u65f6\u5019\u914d\u5408 AI \u7b97\u6cd5\u6a21\u578b\u53ef\u4ee5\u5feb\u901f\u642d\u5efa\u4e00\u4e2a AI \u5e94\u7528\u3002\u6bd4\u5982\u57fa\u4e8e\u5927\u8bed\u8a00\u6a21\u578b LLM \u7684 RAG \u5e94\u7528\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u7528\u6237\u4ec5\u9700\u5c06\u81ea\u5df1\u7684\u77e5\u8bc6\u5e93\u8c03\u7528 OpenAI \u7684 Embedding \u63a5\u53e3\u751f\u6210\u5411\u91cf\u6570\u636e\u5b58\u5165 MatrixOne \u4e2d\uff0c\u518d\u901a\u8fc7\u4f59\u5f26\u76f8\u4f3c\u5ea6\u51fd\u6570\u8ba1\u7b97\u641c\u7d22\u6700\u76f8\u4f3c\u7b54\u6848\uff0c\u518d\u5c06\u7b54\u6848\u901a\u8fc7 OpenAI \u7684 Prompt \u63a5\u53e3\u4ea4\u7ed9 LLM \u4f18\u5316\u56de\u7b54\u5373\u53ef\u3002
\u4e0e\u4e13\u7528\u7684\u5411\u91cf\u6570\u636e\u5e93\u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u662f\u4e00\u4e2a\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684\u901a\u7528\u6570\u636e\u5e93\uff0c\u7528\u6237\u51e0\u4e4e\u4e0d\u9700\u8981\u989d\u5916\u7684\u5b66\u4e60\u95e8\u69db\u5373\u53ef\u5feb\u901f\u4e0a\u624b\uff0c\u540c\u65f6\u5728\u6784\u5efa AI \u5e94\u7528\u7684\u65f6\u5019\u4e5f\u53ef\u4ee5\u5c06\u7ed3\u6784\u5316\u6570\u636e\u4e0e\u5411\u91cf\u6570\u636e\u7684\u5904\u7406\u5408\u4e8c\u4e3a\u4e00\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_3","title":"\u65f6\u5e8f\u80fd\u529b","text":"\u4e3a\u4e86\u66f4\u597d\u7684\u5904\u7406\u6570\u636e\u5feb\u901f\u6d41\u5165\u7684\u5404\u7c7b IoT \u573a\u666f\uff0c\u672c\u8fed\u4ee3 MatrixOne \u5728\u65f6\u5e8f\u65b9\u6848\u7684\u80fd\u529b\u4e5f\u5927\u5e45\u52a0\u5f3a\uff0c\u5177\u4f53\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u70b9\uff1a
\u672c\u8fed\u4ee3\u5728\u57fa\u7840\u6d41\u8ba1\u7b97\u7684\u6846\u67b6\u57fa\u7840\u4e0a\u5b9e\u73b0\u4e86 Kafka connector\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 CREATE DYNAMIC TABLE \u521b\u5efa\u6d41\u5f0f\u52a8\u6001\u8868\uff0c\u6b64\u7c7b\u578b\u7684\u8868\u662f Append Only \u7684\u8868\uff0c\u540c\u65f6\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 CREATE SOURCE \u7684\u65b9\u5f0f\u914d\u7f6e\u5916\u90e8\u6570\u636e\u6e90\uff0c\u672c\u8fed\u4ee3\u5df2\u9002\u914d Kafka \u4f5c\u4e3a\u6570\u636e\u6e90\uff0c\u53ef\u4ee5\u63a5\u5165 Kafka \u7684 Topic\uff08JSON \u7c7b\u578b\u6216\u8005 protobuf \u534f\u8bae\u7c7b\u578b\uff09\uff0c\u63a5\u5165\u540e MatrixOne \u4f1a\u81ea\u52a8\u5c06 Kafka \u7684 Message \u5199\u5165\u5230\u52a8\u6001\u8868\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u5bf9\u6d41\u5f0f\u8868\u8fdb\u884c\u7a97\u53e3\u67e5\u8be2\uff0c\u6216\u8005\u4e0e\u5176\u4ed6\u8868\u4e00\u8d77\u8fdb\u884c\u5173\u8054\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#udfbeta","title":"\u81ea\u5b9a\u4e49\u51fd\u6570 UDF\uff08beta\uff09","text":"\u672c\u8fed\u4ee3 MatrixOne \u5f00\u59cb\u652f\u6301\u7528\u6237\u7f16\u5199\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u76ee\u524d\u7b2c\u4e00\u4e2a\u7248\u672c\u4ec5\u652f\u6301 Python \u8bed\u8a00\u3002\u5728\u5f88\u591a\u573a\u666f\u4e2d\u6570\u636e\u5e93\u7cfb\u7edf\u63d0\u4f9b\u7684\u7cfb\u7edf\u51fd\u6570\u5e76\u65e0\u6cd5\u6ee1\u8db3\u7528\u6237\u7684\u4e1a\u52a1\u9700\u6c42\uff0c\u901a\u8fc7 UDF \u7684\u65b9\u5f0f\u7528\u6237\u53ef\u4ee5\u5c06\u4e1a\u52a1\u7684\u903b\u8f91\u5305\u88c5\u5728 Python \u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06\u5176\u5c01\u88c5\u6210 SQL \u7684\u51fd\u6570\uff0c\u5b9e\u73b0\u5728 SQL \u4e2d\u76f4\u63a5\u8c03\u7528\u3002\u57fa\u4e8e Python \u7684 UDF\uff0c\u7528\u6237\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u4f7f\u7528 numpy \u548c scikit-learn \u7b49 Python \u7684\u6d41\u884c\u5e93\uff0c\u5927\u5e45\u5ea6\u7684\u63d0\u9ad8 MatrixOne \u5728\u6570\u636e\u79d1\u5b66\uff0c\u673a\u5668\u5b66\u4e60\u53ca AI \u7b49\u9886\u57df\u7684\u9002\u7528\u6027\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_4","title":"\u5176\u4ed6\u65b0\u529f\u80fd","text":""},{"location":"MatrixOne/Release-Notes/v1.1.0/#ddl","title":"DDL \u8bed\u53e5","text":"https://github.com/matrixorigin/matrixone/compare/v1.0.0...v1.1.0
"},{"location":"MatrixOne/Release-Notes/v1.1.1/","title":"MatrixOne v1.1.1 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 02 \u6708 04 \u65e5
MatrixOne \u7248\u672c\uff1av1.1.1
\u4e0e\u4e4b\u524d\u7684 v1.1.0 \u76f8\u6bd4\uff0cv1.1.1 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.1/#_1","title":"\u6539\u8fdb","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.0...v1.1.1
"},{"location":"MatrixOne/Release-Notes/v1.1.2/","title":"MatrixOne v1.1.2 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 04 \u6708 02 \u65e5
MatrixOne \u7248\u672c\uff1av1.1.2
\u4e0e\u4e4b\u524d\u7684 v1.1.1 \u76f8\u6bd4\uff0cv1.1.2 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.2/#_1","title":"\u6539\u8fdb","text":"\u6709\u5173\u5176\u4ed6\u9519\u8bef\u4fee\u590d\uff0c\u8bf7\u70b9\u51fb MatrixOne-v1.1.2 \u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.2/#_3","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.1...v1.1.2
"},{"location":"MatrixOne/Release-Notes/v1.1.3/","title":"MatrixOne v1.1.3 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 04 \u6708 16 \u65e5
MatrixOne \u7248\u672c\uff1av1.1.3
\u4e0e\u4e4b\u524d\u7684 v1.1.2 \u76f8\u6bd4\uff0cv1.1.3 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.3/#_1","title":"\u9519\u8bef\u4fee\u590d","text":"\u6709\u5173\u5176\u4ed6\u9519\u8bef\u4fee\u590d\uff0c\u8bf7\u70b9\u51fb MatrixOne-v1.1.3 \u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.3/#_2","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.2...v1.1.3
"},{"location":"MatrixOne/Release-Notes/v1.2.0/","title":"MatrixOne v1.2.0 \u53d1\u5e03\u62a5\u544a","text":"\u6211\u4eec\u975e\u5e38\u9ad8\u5174\u5730\u5ba3\u5e03 MatrixOne \u5185\u6838 v1.2.0 \u7248\u672c\u4e8e 2024 \u5e74 05 \u6708 20 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#matrixone","title":"MatrixOne \u662f\u4ec0\u4e48\uff1f","text":"MatrixOne \u662f\u4e00\u6b3e\u5206\u5e03\u5f0f\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0cMatrixOne \u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u4e91\u539f\u751f\u3001\u9ad8\u6027\u80fd\u3001\u9ad8\u5f39\u6027\u3001\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684 HSTAP \u6570\u636e\u5e93\uff0c\u8ba9\u7528\u6237\u9762\u5bf9\u4e8b\u52a1\u3001\u5206\u6790\u3001\u65f6\u5e8f\u3001\u6d41\u8ba1\u7b97\u7b49\u6df7\u5408\u8d1f\u8f7d\u65f6\uff0c\u901a\u8fc7 MatrixOne \u4e00\u7ad9\u5f0f\u7684\u5b8c\u6210\u6574\u4e2a\u6570\u636e\u5904\u7406\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_1","title":"\u91cd\u70b9\u5173\u6ce8","text":"MatrixOne \u5728\u672c\u6b21\u7684\u8fed\u4ee3\u4e2d\u8fdb\u884c\u4e86\u663e\u8457\u7684\u529f\u80fd\u6269\u5c55\uff0c\u91cd\u70b9\u529f\u80fd\u6709\uff1a\u5feb\u7167\u5907\u4efd\u3001\u589e\u91cf\u7269\u7406\u5907\u4efd\u3001CTAS\u3001BITMAP \u548c\u5411\u91cf\u7d22\u5f15\u3002\u968f\u7740\u8fd9\u4e9b\u65b0\u529f\u80fd\u7684\u5f15\u5165\uff0cMatrixOne \u6b63\u9010\u6b65\u6210\u4e3a\u4f01\u4e1a\u7ea7\u6570\u636e\u7ba1\u7406\u548c\u5206\u6790\u7684\u7406\u60f3\u9009\u62e9\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#beta","title":"\u5feb\u7167\u5907\u4efd\u6062\u590d (Beta)","text":"\u6570\u636e\u5e93\u5feb\u7167\u5907\u4efd\u6280\u672f\u901a\u8fc7\u521b\u5efa\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u53ea\u8bfb\u526f\u672c\uff0c\u5728\u4e0d\u5f71\u54cd\u6570\u636e\u5e93\u8fd0\u884c\u7684\u60c5\u51b5\u4e0b\u4e3a\u6570\u636e\u63d0\u4f9b\u4e86\u4e00\u79cd\u9ad8\u6548\u7684\u4fdd\u62a4\u65b9\u5f0f\u3002\u5728\u672c\u6b21\u8fed\u4ee3\u4e2d\uff0cMatrixone \u5f00\u59cb\u652f\u6301\u79df\u6237\u7ea7\u522b\u7684\u5feb\u7167\u5907\u4efd\u6062\u590d\uff0c\u5728\u6570\u636e\u4e22\u5931\u6216\u635f\u574f\u7684\u60c5\u51b5\u4e0b\uff0c\u5feb\u7167\u5907\u4efd\u53ef\u4ee5\u5feb\u901f\u6062\u590d\u5230\u5907\u4efd\u65f6\u7684\u72b6\u6001\uff0c\u51cf\u5c11\u4e86\u6062\u590d\u65f6\u95f4\u76ee\u6807\uff08RTO\uff09\u3002\u5feb\u7167\u5907\u4efd\u4e0d\u9700\u8981\u505c\u6b62\u6570\u636e\u5e93\u670d\u52a1\uff0c\u56e0\u6b64\u53ef\u4ee5\u7b80\u5316\u5907\u4efd\u6d41\u7a0b\u5e76\u4fdd\u8bc1\u4e86\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002\u5728\u707e\u96be\u6062\u590d\u8ba1\u5212\u4e2d\uff0c\u5feb\u7167\u5907\u4efd\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\uff0c\u786e\u4fdd\u5728\u7d27\u6025\u60c5\u51b5\u4e0b\u80fd\u591f\u8fc5\u901f\u6062\u590d\u5173\u952e\u6570\u636e\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_2","title":"\u589e\u91cf\u7269\u7406\u5907\u4efd\uff08\u4f01\u4e1a\u7248\uff09","text":"\u5728 mo_backup \u5de5\u5177\u652f\u6301\u5168\u91cf\u7269\u7406\u5907\u4efd\u7684\u57fa\u7840\u4e0a\uff0c\u589e\u52a0\u4e86\u589e\u91cf\u7269\u7406\u5907\u4efd\u80fd\u529b\u3002\u5728\u6570\u636e\u91cf\u8f83\u5927\u7684\u73af\u5883\u4e0b\uff0c\u8fc7\u53bb\u6bcf\u6b21\u5907\u4efd\u90fd\u662f\u5168\u91cf\u5907\u4efd\uff0c\u5bfc\u81f4\u5907\u4efd\u65f6\u95f4\u8f83\u957f\uff0c\u4e14\u5360\u7528\u5927\u91cf\u5b58\u50a8\u7a7a\u95f4\u3002\u589e\u91cf\u5907\u4efd\u529f\u80fd\u4f1a\u81ea\u52a8\u8ba1\u7b97\u8fc7\u53bb\u5df2\u7ecf\u5907\u4efd\u8fc7\u7684\u65f6\u95f4\u70b9\u4ee5\u53ca\u5df2\u5907\u4efd\u8fc7\u7684 object \u5217\u8868\uff0c\u4ec5\u9700\u8981\u5bf9\u65b0\u7684 object \u5217\u8868\u8fdb\u884c\u5907\u4efd\u5373\u53ef\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#ctas","title":"CTAS","text":"\u5728\u672c\u8fed\u4ee3\u4e2d\uff0cMatrixOne \u652f\u6301\u4e86 CTAS\u3002CTAS \u662f\u4e00\u79cd SQL \u8bed\u53e5\uff0c\u7528\u4e8e\u57fa\u4e8e\u73b0\u6709\u6570\u636e\u5feb\u901f\u521b\u5efa\u4e00\u4e2a\u65b0\u8868\u3002\u5b83\u7ed3\u5408\u4e86\u521b\u5efa\u8868\u548c\u9009\u62e9\u67e5\u8be2\u7684\u529f\u80fd\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u9ad8\u6548\u7684\u65b9\u5f0f\u6765\u521b\u5efa\u8868\u7684\u5feb\u7167\u3001\u8fdb\u884c\u6570\u636e\u8f6c\u6362\u3001\u6216\u8005\u521b\u5efa\u7528\u4e8e\u62a5\u544a\u548c\u5206\u6790\u7684\u6570\u636e\u6a21\u578b\u3002\u7279\u70b9\u5982\u4e0b\uff1a
\u9ad8\u6548\u6027\uff1aCTAS \u901a\u5e38\u4f5c\u4e3a\u4e00\u4e2a\u539f\u5b50\u64cd\u4f5c\u6267\u884c\uff0c\u51cf\u5c11\u4e86\u521b\u5efa\u8868\u548c\u63d2\u5165\u6570\u636e\u7684\u6b65\u9aa4\uff0c\u63d0\u9ad8\u4e86\u6027\u80fd\u3002
\u7b80\u6d01\u6027\uff1a\u901a\u8fc7\u4e00\u6b21\u6027\u64cd\u4f5c\u521b\u5efa\u65b0\u8868\u548c\u586b\u5145\u6570\u636e\uff0c\u7b80\u5316\u4e86\u6570\u636e\u5efa\u6a21\u548c ETL \u8fc7\u7a0b\u3002
\u7075\u6d3b\u6027\uff1a\u53ef\u4ee5\u5229\u7528 SELECT \u8bed\u53e5\u4e2d\u7684\u5927\u90e8\u5206\u529f\u80fd\uff0c\u5982 WHERE\u3001JOIN\u3001GROUP BY \u7b49\uff0c\u8fdb\u884c\u590d\u6742\u7684\u6570\u636e\u8f6c\u6362\u3002
\u5728\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u652f\u6301\u7684\u8fc7\u7a0b\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9\u5927\u91cf\u6570\u636e\u8fdb\u884c\u53bb\u91cd\u8ba1\u6570\uff0c\u4ee5\u83b7\u5f97\u4e0d\u540c\u503c\u7684\u51c6\u786e\u6570\u91cf\u3002\u4f20\u7edf\u7684 count(distinct values) \u8bed\u53e5\u867d\u7136\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u76ee\u7684\uff0c\u4f46\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u96c6\u65f6\uff0c\u5176\u6027\u80fd\u5f80\u5f80\u4e0d\u5c3d\u4eba\u610f\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0cMatrixOne \u5728\u672c\u8fed\u4ee3\u4e2d\u5f15\u5165\u4e86 BITMAP\uff08\u4f4d\u56fe\uff09\u51fd\u6570\u3002\u8fd9\u4e9b\u5185\u7f6e\u51fd\u6570\u4f7f\u5f97 BITMAP \u5728\u8fdb\u884c\u6570\u636e\u53bb\u91cd\u3001\u8ba1\u6570\u3001\u67e5\u8be2\u7edf\u8ba1\u3001\u6392\u5e8f\u7b49\u64cd\u4f5c\u65f6\uff0c\u80fd\u591f\u63d0\u4f9b\u6bd4\u4f20\u7edf\u65b9\u6cd5\u66f4\u5feb\u7684\u5904\u7406\u901f\u5ea6\u548c\u66f4\u4f4e\u7684\u8d44\u6e90\u6d88\u8017\u3002\u5728\u5546\u4e1a\u667a\u80fd\u3001\u7528\u6237\u884c\u4e3a\u5206\u6790\u3001\u5b9e\u65f6\u63a8\u8350\u7cfb\u7edf\u7b49\u5e94\u7528\u573a\u666f\u4e2d\uff0cBITMAP \u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6570\u636e\u5904\u7406\u7684\u901f\u5ea6\u548c\u51c6\u786e\u6027\uff0c\u5e2e\u52a9\u4f01\u4e1a\u548c\u7ec4\u7ec7\u66f4\u597d\u5730\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u5236\u5b9a\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_3","title":"\u5411\u91cf\u7d22\u5f15","text":"\u5728\u4e0a\u4e2a\u8fed\u4ee3\u4e2d\uff0cMatrixone \u652f\u6301\u4e86\u5411\u91cf\u7c7b\u578b\u4ee5\u53ca\u5e38\u89c1\u7684\u5411\u91cf\u76f8\u4f3c\u5ea6\u51fd\u6570\uff0c\u5728\u672c\u6b21\u8fed\u4ee3\u4e2d\uff0cMatrixone \u8fdb\u4e00\u6b65\u5f15\u5165\u4e86\u5411\u91cf\u7d22\u5f15\u6280\u672f\uff0c\u8fd9\u4e00\u8fdb\u5c55\u663e\u8457\u63d0\u5347\u4e86\u7cfb\u7edf\u5728\u5904\u7406\u5411\u91cf\u6570\u636e\u65f6\u7684\u6027\u80fd\u3002\u5411\u91cf\u7d22\u5f15\u5141\u8bb8\u7cfb\u7edf\u5feb\u901f\u68c0\u7d22\u4e0e\u67e5\u8be2\u5411\u91cf\u6700\u76f8\u4f3c\u6216\u6700\u63a5\u8fd1\u7684\u6570\u636e\u70b9\u3002\u8fd9\u79cd\u9ad8\u6548\u7684\u68c0\u7d22\u80fd\u529b\uff0c\u5bf9\u4e8e\u9700\u8981\u5728\u6d77\u91cf\u6570\u636e\u4e2d\u8fdb\u884c\u5feb\u901f\u641c\u7d22\u548c\u5339\u914d\u7684\u5e94\u7528\u573a\u666f\u81f3\u5173\u91cd\u8981\u3002\u5728\u673a\u5668\u5b66\u4e60\u548c\u4eba\u5de5\u667a\u80fd\u9886\u57df\uff0c\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u548c\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08RAG\uff09\u7b49\u6280\u672f\u7684\u5e94\u7528\u65e5\u76ca\u589e\u591a\uff0c\u8fd9\u4e9b\u6280\u672f\u901a\u5e38\u9700\u8981\u5904\u7406\u5927\u91cf\u7684\u9ad8\u7ef4\u6570\u636e\uff0c\u5e76\u5bf9\u6570\u636e\u8fdb\u884c\u590d\u6742\u7684\u76f8\u4f3c\u6027\u6bd4\u8f83\u548c\u6a21\u5f0f\u5339\u914d\u3002\u5411\u91cf\u7d22\u5f15\u7684\u5f15\u5165\uff0c\u4e3a\u8fd9\u4e9b\u6280\u672f\u7684\u5e94\u7528\u63d0\u4f9b\u4e86\u575a\u5b9e\u7684\u57fa\u7840\u3002\u5b83\u4e0d\u4ec5\u80fd\u591f\u51cf\u5c11\u8ba1\u7b97\u8d44\u6e90\u7684\u6d88\u8017\uff0c\u8fd8\u80fd\u663e\u8457\u63d0\u9ad8\u67e5\u8be2\u54cd\u5e94\u65f6\u95f4\uff0c\u4ece\u800c\u4f18\u5316\u6574\u4f53\u7684\u7cfb\u7edf\u6027\u80fd\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_4","title":"\u5176\u4ed6\u65b0\u529f\u80fd","text":""},{"location":"MatrixOne/Release-Notes/v1.2.0/#sql","title":"SQL \u8bed\u53e5","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.0...v1.2.0
"},{"location":"MatrixOne/Release-Notes/v1.2.1/","title":"MatrixOne v1.2.1 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 06 \u6708 30 \u65e5
MatrixOne \u7248\u672c\uff1av1.2.1
\u4e0e\u4e4b\u524d\u7684 v1.2.0 \u76f8\u6bd4\uff0cv1.2.1 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u9519\u8bef\u4fee\u590d\u548c\u4f18\u5316\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.1/#_1","title":"\u6539\u8fdb","text":"show accounts
\u7684\u6027\u80fd\u3002 fileservice
\u7684\u53ef\u89c2\u5bdf\u6027\u5ea6\u91cf\u3002 TCP
\u6570\u636e\u5305\u7684\u4f30\u7b97\u3002 mologing
\u3002 zonemap
\u7684\u624b\u52a8\u5408\u5e76\u3002 \u4fee\u590d\u4e86\u4e0e\u5feb\u7167\u8bfb\u53d6\u3001MySQL \u517c\u5bb9\u6027\u3001\u9501\u670d\u52a1\u3001\u8fd0\u884c\u65f6\u7b5b\u9009\u5668\u548c\u7cfb\u7edf\u8868\u5347\u7ea7\u76f8\u5173\u7684\u9519\u8bef\u3002\u6709\u5173\u5176\u4ed6\u9519\u8bef\u4fee\u590d\uff0c\u8bf7\u70b9\u51fb MatrixOne-v1.2.1 \u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.1/#_3","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v1.2.0...v1.2.1
"},{"location":"MatrixOne/Security/Authentication/","title":"\u8eab\u4efd\u9274\u522b\u4e0e\u8ba4\u8bc1","text":"\u7528\u6237\u5728\u8bbf\u95ee MatrixOne \u6570\u636e\u5e93\u65f6\u9700\u8981\u8fdb\u884c\u8eab\u4efd\u9274\u522b\u4e0e\u8ba4\u8bc1\uff0c\u76ee\u524d MatrixOne \u4ec5\u652f\u6301\u7528\u6237\u540d\u5bc6\u7801\u9a8c\u8bc1\u65b9\u5f0f\u767b\u5f55\u3002\u6570\u636e\u5e93\u4f1a\u5bf9\u8bbf\u95ee\u6570\u636e\u7684\u7528\u6237\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\uff0c\u786e\u8ba4\u8be5\u7528\u6237\u662f\u5426\u80fd\u591f\u4e0e\u67d0\u4e00\u4e2a\u6570\u636e\u5e93\u7528\u6237\u8fdb\u884c\u5173\u8054\uff0c\u5e76\u68c0\u67e5\u5176\u63d0\u4f9b\u7684\u5bc6\u7801\u662f\u5426\u6709\u6548\u3002
"},{"location":"MatrixOne/Security/Authentication/#_2","title":"\u767b\u5f55\u8bed\u6cd5","text":"\u5728 MatrixOne \u4e2d\uff0c\u7528\u6237\u7684\u767b\u5f55\u8eab\u4efd\u9274\u522b\u7531 acccount_name
\uff0cuser_name
\uff0chost
\uff0cpassword
\u5171\u540c\u7ec4\u6210\u3002\u5b8c\u6574\u7684\u767b\u5f55\u8bed\u6cd5\u5982\u4e0b\uff1a
mysql -h host -p password -u accountname:username -P port\n
\u5176\u4e2d -h
\u3001-p
\u3001-P
\u53c2\u6570\u4e0e MySQL \u76f8\u540c\u3002\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\uff1a
-u
\u4ee3\u8868\u7528\u6237\uff0c\u5728 MatrixOne \u7684\u7528\u6237\u4f53\u7cfb\u4e2d\uff0c\u7528\u6237\u662f\u4f4d\u4e8e\u79df\u6237 account
\u4ee5\u4e0b\u4e00\u5c42\u7684\u6982\u5ff5\uff0c\u56e0\u6b64\u767b\u5f55\u65f6\u9700\u8981\u5148\u6307\u5b9a\u79df\u6237 account_name
\uff0c\u518d\u6307\u5b9a\u79df\u6237\u4e2d\u7684\u7528\u6237 username
\u624d\u80fd\u5b8c\u6210\u767b\u5f55\u3002\u5982\u679c\u4e0d\u6307\u5b9a account_name
\uff0c\u5219\u9ed8\u8ba4\u4e3a\u7cfb\u7edf\u79df\u6237 sys
\u3002\u793a\u4f8b\uff1a
> mysql -h 127.0.0.1 -P6001 -utenant1:u1 -p111\n
Note
\u5bf9\u4e8e\u5355\u673a\u7248 MatrixOne\uff0c\u53ef\u4ee5\u901a\u8fc7\u53c2\u6570\u914d\u7f6e\u5c06\u8fde\u63a5\u5b57\u7b26\u4e32\u7b80\u5316\u5230 mo_ctl \u5de5\u5177\u4e2d\uff0c\u4ee5\u7b80\u5316\u767b\u5f55\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Security/Authentication/#_3","title":"\u67e5\u8be2\u5f53\u524d\u7528\u6237","text":"\u767b\u5f55\u540e\u8981\u83b7\u53d6\u6709\u5173\u5f53\u524d\u7528\u6237\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528 user()
\u6216 current_user()
\u51fd\u6570\u3002
mysql> select user();\n+--------------------+\n| user() |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\nmysql> select current_user();\n+--------------------+\n| current_user() |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\n
Note
\u76ee\u524d MatrixOne \u4e0d\u652f\u6301 IP \u767d\u540d\u5355\uff0c\u56e0\u6b64\u65e0\u8bba\u4ece\u4efb\u4f55\u4f4d\u7f6e\u767b\u5f55\u67e5\u770b\u7684\u7528\u6237\u90fd\u4e3a 0.0.0.0\u3002
"},{"location":"MatrixOne/Security/Authentication/#_4","title":"\u67e5\u8be2\u6240\u6709\u7528\u6237","text":"\u6bcf\u4e2a\u7528\u6237\u8eab\u4efd\u5177\u6709\u552f\u4e00\u6027\uff0c\u6bcf\u4e2a\u5177\u6709 accountadmin
\u89d2\u8272\u7684\u7528\u6237\u53ef\u4ee5\u67e5\u770b\u8be5\u79df\u6237\u4e0b\u7684\u6240\u6709\u7528\u6237\u3002
mysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| 10001 | localhost | u1 | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-10 06:43:44 | NULL | PASSWORD | 0 | 0 | 1 |\n| 0 | localhost | root | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL | PASSWORD | 0 | 0 | 0 |\n| 1 | localhost | root | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL | PASSWORD | 0 | 0 | 0 |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n
Note
MatrixOne \u4e2d\u7528\u6237\u8868\u7684\u8bb0\u5f55\u4f4d\u7f6e\u548c\u8868\u7ed3\u6784\u4e0e MySQL \u4e0d\u540c\u3002MatrixOne \u4e2d\u7684\u7528\u6237\u5143\u6570\u636e\u4fe1\u606f\u4e0d\u5b58\u50a8\u5728 mysql.user
\u8868\u4e2d\uff0c\u800c\u662f\u5b58\u50a8\u5728 mo_catalog.mo_user
\u4e2d\u3002
sys
\u79df\u6237\u7684 root
\u7528\u6237\uff09\u521d\u59cb\u5bc6\u7801\u4e3a 111\u3002\u7528\u6237\u4fee\u6539\u5bc6\u7801\u540e\u9700\u8981\u81ea\u884c\u8bb0\u4f4f\u65b0\u5bc6\u7801\uff0c\u4e00\u65e6\u5fd8\u8bb0\u5bc6\u7801\uff0cMatrixOne \u76ee\u524d\u6ca1\u6709\u63d0\u4f9b\u627e\u56de\u6216\u7ed5\u8fc7\u5b89\u5168\u9a8c\u8bc1\u8fdb\u884c\u5bc6\u7801\u91cd\u7f6e\u7684\u65b9\u6cd5\uff0c\u5fc5\u987b\u91cd\u65b0\u5b89\u88c5 MatrixOne\u3002\u6570\u636e\u5e93\u5b89\u5168\u548c\u6743\u9650\u662f\u786e\u4fdd\u6570\u636e\u5e93\u7cfb\u7edf\u53ca\u5176\u4e2d\u5b58\u50a8\u7684\u6570\u636e\u53d7\u5230\u4fdd\u62a4\u548c\u7ba1\u7406\u7684\u5173\u952e\u65b9\u9762\u3002\u5b83\u6d89\u53ca\u4e00\u7cfb\u5217\u7b56\u7565\u3001\u63aa\u65bd\u548c\u6743\u9650\u63a7\u5236\uff0c\u4ee5\u786e\u4fdd\u53ea\u6709\u7ecf\u8fc7\u6388\u6743\u7684\u7528\u6237\u80fd\u591f\u8bbf\u95ee\u3001\u4fee\u6539\u548c\u64cd\u4f5c\u6570\u636e\u5e93\u3002\u672c\u7ae0\u8282\u5c06\u4e3a\u60a8\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u7684\u5b89\u5168\u4e0e\u6743\u9650\u7ba1\u7406\u4f53\u7cfb\u3002
"},{"location":"MatrixOne/Security/Security-Permission-Overview/#_2","title":"\u6570\u636e\u5e93\u5b89\u5168\u7ba1\u7406","text":"MatrixOne \u6570\u636e\u5e93\u5b89\u5168\u7684\u76ee\u6807\u662f\u4fdd\u62a4\u6570\u636e\u5e93\u514d\u53d7\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u3001\u6570\u636e\u6cc4\u9732\u3001\u6570\u636e\u7be1\u6539\u548c\u5176\u4ed6\u5b89\u5168\u5a01\u80c1\u3002MatrixOne \u63d0\u4f9b\u4ee5\u4e0b\u80fd\u529b\u6765\u786e\u4fdd\u6570\u636e\u5e93\u5b89\u5168\uff1a
MatrixOne \u6570\u636e\u5e93\u6743\u9650\u7ba1\u7406\u662f\u7ba1\u7406\u7528\u6237\u5bf9\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u548c\u64cd\u4f5c\u6743\u9650\u7684\u8fc7\u7a0b\u3002\u901a\u8fc7\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u63a7\u5236\uff0c\u53ef\u4ee5\u786e\u4fdd\u6bcf\u4e2a\u7528\u6237\u53ea\u80fd\u6267\u884c\u5176\u6240\u9700\u7684\u64cd\u4f5c\uff0c\u5e76\u9650\u5236\u5bf9\u654f\u611f\u6570\u636e\u7684\u8bbf\u95ee\u3002MatrixOne \u7684\u6570\u636e\u5e93\u6743\u9650\u7ba1\u7406\u5305\u62ec\u4ee5\u4e0b\u65b9\u9762\uff1a
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd MatrixOne \u5bf9\u6570\u636e\u4f20\u8f93\u52a0\u5bc6\u7684\u652f\u6301\u60c5\u51b5\u4ee5\u53ca\u5982\u4f55\u5f00\u59cb\u52a0\u5bc6\u4f20\u8f93\u3002
"},{"location":"MatrixOne/Security/TLS-introduction/#_2","title":"\u6982\u8ff0","text":"MatrixOne \u9ed8\u8ba4\u91c7\u7528\u975e\u52a0\u5bc6\u4f20\u8f93\uff0c\u4e5f\u652f\u6301\u542f\u7528\u57fa\u4e8e TLS \u534f\u8bae\u7684\u52a0\u5bc6\u4f20\u8f93\u3002\u4f7f\u7528\u52a0\u5bc6\u4f20\u8f93\u53ef\u4ee5\u51cf\u5c11\u6570\u636e\u5e93\u4e2d\u654f\u611f\u4fe1\u606f\u7684\u6cc4\u9732\u98ce\u9669\u3002\u52a0\u5bc6\u4f20\u8f93\u662f\u91c7\u7528\u5bc6\u94a5\u5bf9\u4fe1\u606f\u8fdb\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u4fdd\u62a4\u6570\u636e\u7684\u5b89\u5168\u3002
\u4f20\u8f93\u5c42\u5b89\u5168\u6027 (Transport Layer Security, TLS) \u662f\u4e00\u79cd\u5e7f\u6cdb\u91c7\u7528\u7684\u5b89\u5168\u6027\u534f\u8bae\uff0cMatrixOne \u652f\u6301\u7684\u534f\u8bae\u7248\u672c\u6709 TLS 1.0, TLS 1.1, TLS 1.2\u3002
TLS \u5b89\u5168\u8fde\u63a5\u914d\u7f6e\u4e3b\u8981\u6b65\u9aa4\u6982\u8ff0\uff1a
\u9996\u5148\u5728 MatrixOne \u4e2d\u5f00\u542f TLS\u3002
\u7136\u540e\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u5b89\u5168\u8fde\u63a5\u53c2\u6570\u3002
\u5b8c\u6210\u8fd9\u4e24\u4e2a\u4e3b\u8981\u6b65\u9aa4\u7684\u914d\u7f6e\u540e\uff0c\u5373\u53ef\u5efa\u7acb TLS \u5b89\u5168\u8fde\u63a5\u3002
"},{"location":"MatrixOne/Security/TLS-introduction/#matrixone-tls","title":"\u6b65\u9aa4\u4e00\uff1a\u5f00\u542f MatrixOne \u7684 TLS \u652f\u6301","text":"\u751f\u6210\u8bc1\u4e66\u53ca\u5bc6\u94a5\uff1aMatrixOne \u5c1a\u4e0d\u652f\u6301\u52a0\u8f7d\u6709\u5bc6\u7801\u4fdd\u62a4\u7684\u79c1\u94a5\uff0c\u56e0\u6b64\u5fc5\u987b\u63d0\u4f9b\u4e00\u4e2a\u6ca1\u6709\u5bc6\u7801\u7684\u79c1\u94a5\u6587\u4ef6\u3002\u8bc1\u4e66\u548c\u5bc6\u94a5\u53ef\u4ee5\u4f7f\u7528 OpenSSL \u7b7e\u53d1\u548c\u751f\u6210\uff0c\u63a8\u8350\u4f7f\u7528 MySQL \u81ea\u5e26\u7684\u5de5\u5177 mysql_ssl_rsa_setup
\u5feb\u6377\u751f\u6210\uff1a
#\u68c0\u67e5\u4f60\u672c\u5730 MySQL \u5ba2\u6237\u7aef\u7684\u5b89\u88c5\u76ee\u5f55\nps -ef|grep mysql\n#\u8fdb\u5165\u5230\u4f60\u672c\u5730 MySQL \u5ba2\u6237\u7aef\u7684\u5b89\u88c5\u76ee\u5f55\ncd /usr/local/mysql/bin\n#\u751f\u6210\u8bc1\u4e66\u548c\u5bc6\u94a5\n./mysql_ssl_rsa_setup --datadir=<yourpath>\n#\u68c0\u67e5\u4f60\u751f\u6210\u7684 pem \u6587\u4ef6\nls <yourpath>\n\u251c\u2500\u2500 ca-key.pem\n\u251c\u2500\u2500 ca.pem\n\u251c\u2500\u2500 client-cert.pem\n\u251c\u2500\u2500 client-key.pem\n\u251c\u2500\u2500 private_key.pem\n\u251c\u2500\u2500 public_key.pem\n\u251c\u2500\u2500 server-cert.pem\n\u2514\u2500\u2500 server-key.pem\n
Note: \u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684 <yourpath>
\u662f\u4f60\u9700\u8981\u5b58\u653e\u751f\u6210\u7684\u8bc1\u4e66\u53ca\u5bc6\u94a5\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u8def\u5f84\u3002
\u8fdb\u5165\u5230\u4f60\u672c\u5730\u7684 MatrixOne \u6587\u4ef6\u76ee\u5f55\u8def\u5f84 matrixone/etc/launch-tae-CN-tae-TN/ \u4e2d\u7684 cn.toml \u914d\u7f6e\u6587\u4ef6\uff1a
\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 vim \u547d\u4ee4\u76f4\u63a5\u5728\u7ec8\u7aef\u4e2d\u6253\u5f00 cn.toml \u6587\u4ef6
vim $matrixone/etc/launch-tae-CN-tae-TN/cn.toml\n
\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u6bb5\u590d\u5236\u7c98\u8d34\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\uff1a
[cn.frontend]\n#default is false. With true. Server will support tls\nenableTls = true\n\n#default is ''. Path of file that contains X509 certificate in PEM format for client\ntlsCertFile = \"<yourpath>/server-cert.pem\"\n\n#default is ''. Path of file that contains X509 key in PEM format for client\ntlsKeyFile = \"<yourpath>/server-key.pem\"\n\n#default is ''. Path of file that contains list of trusted SSL CAs for client\ntlsCaFile = \"<yourpath>/ca.pem\"\n
Note: \u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684 <yourpath>
\u662f\u4f60\u9700\u8981\u5b58\u653e\u751f\u6210\u7684\u8bc1\u4e66\u53ca\u5bc6\u94a5\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u8def\u5f84
\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u914d\u7f6e\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
\u53c2\u6570 \u63cf\u8ff0 enableTls \u5e03\u5c14\u7c7b\u578b\uff0c\u662f\u5426\u5728 MatrixOne \u670d\u52a1\u7aef\u6253\u5f00 TLS \u7684\u652f\u6301\u3002 tlsCertFile \u6307\u5b9a SSL \u8bc1\u4e66\u6587\u4ef6\u8def\u5f84 tlsKeyFile \u6307\u5b9a\u8bc1\u4e66\u6587\u4ef6\u5bf9\u5e94\u7684\u79c1\u94a5 tlsCaFile \u53ef\u9009\uff0c\u6307\u5b9a\u53d7\u4fe1\u4efb\u7684 CA \u8bc1\u4e66\u6587\u4ef6\u8def\u5f84Note: \u5982\u679c\u4f60\u662f\u4f7f\u7528 Docker \u5b89\u88c5\u90e8\u7f72\u7684 MatrixOne\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5148\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6\u518d\u8fdb\u884c\u4fee\u6539\uff0c\u64cd\u4f5c\u5177\u4f53\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
\u9a8c\u8bc1 MatrixOne \u7684 SSL \u662f\u5426\u542f\u7528\u3002
\u2460 \u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff0c\u6b64\u5904\u4ee5\u521d\u59cb\u8d26\u53f7\u548c\u5bc6\u7801\u4e3a\u4f8b\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n
\u2461 \u4f7f\u7528 Status
\u547d\u4ee4\u67e5\u770b SSL \u662f\u5426\u542f\u7528\u3002
\u6210\u529f\u542f\u7528\uff0c\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff0c\u53ef\u4ee5\u770b\u5230 SSL \u72b6\u6001\u4e3a Cipher in use is TLS_AES_128_GCM_SHA256
\uff1a
mysql> status\nmysql Ver 8.0.28 for macos11 on arm64 (MySQL Community Server - GPL)\n\nConnection id: 1001\nCurrent database:\nCurrent user: root@0.0.0.0\nSSL: Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager: stdout\nUsing outfile: ''\nUsing delimiter: ;\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\nProtocol version: 10\nConnection: 127.0.0.1 via TCP/IP\nServer characterset: utf8mb4\nDB characterset: utf8mb4\nClient characterset: utf8mb4\nConn. characterset: utf8mb4\nTCP port: 6001\nBinary data as: Hexadecimal\n--------------\n
\u672a\u542f\u7528\u6210\u529f\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u5982\u4e0b\uff0c\u53ef\u4ee5\u770b\u5230 SSL \u72b6\u6001\u4e3a Not in use
\uff0c\u4f60\u9700\u8981\u91cd\u65b0\u68c0\u67e5\u4e00\u4e0b\u4e0a\u8ff0\u6b65\u9aa4\u4e2d\u4f60\u6240\u914d\u7f6e\u8bc1\u4e66\u53ca\u5bc6\u94a5\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u8def\u5f84\uff08\u5373 \uff09\u662f\u5426\u6b63\u786e\uff1a
mysql> status;\n/usr/local/mysql/bin/mysql Ver 8.0.30 for macos12 on arm64 (MySQL Community Server - GPL)\n\nConnection id: 1009\nCurrent database: test\nCurrent user: root@0.0.0.0\nSSL: Not in use\nCurrent pager: stdout\nUsing outfile: ''\nUsing delimiter: ;\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne \nProtocol version: 10\nConnection: 127.0.0.1 via TCP/IP\nServer characterset: utf8mb4\nDb characterset: utf8mb4\nClient characterset: utf8mb4\nConn. characterset: utf8mb4\nTCP port: 6001\nBinary data as: Hexadecimal\n--------------\n
\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u5373\u5f00\u542f\u4e86 MatrixOne \u7684 TLS\u3002
"},{"location":"MatrixOne/Security/TLS-introduction/#mysql","title":"\u6b65\u9aa4\u4e8c\uff1a\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u53c2\u6570","text":"MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne Server \u65f6\uff0c\u9700\u8981\u901a\u8fc7 --ssl-mode
\u53c2\u6570\u6307\u5b9a\u52a0\u5bc6\u8fde\u63a5\u884c\u4e3a\uff0c\u5982\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111 --ssl-mode=PREFERRED\n
Info
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
ssl mode \u53d6\u503c\u7c7b\u578b\u5982\u4e0b\uff1a
ssl-mode \u53d6\u503c \u542b\u4e49 DISABLED \u4e0d\u4f7f\u7528 SSL/TLS \u5efa\u7acb\u52a0\u5bc6\u8fde\u63a5\uff0c\u4e0e skip-ssl \u540c\u4e49\u3002 PREFERRED \u9ed8\u8ba4\u884c\u4e3a\uff0c\u4f18\u5148\u5c1d\u8bd5\u4f7f\u7528 SSL/TLS \u5efa\u7acb\u52a0\u5bc6\u8fde\u63a5\uff0c\u5982\u679c\u65e0\u6cd5\u5efa\u5219\u5c1d\u8bd5\u5efa\u7acb\u975e SSL/TLS \u8fde\u63a5\u3002 REQUIRED \u53ea\u4f1a\u5c1d\u8bd5\u4f7f\u7528 SSL/TLS \u5efa\u7acb\u52a0\u5bc6\u8fde\u63a5\uff0c\u5982\u679c\u65e0\u6cd5\u5efa\u7acb\u8fde\u63a5\uff0c\u5219\u4f1a\u8fde\u63a5\u5931\u8d25\u3002 VERIFY_CA \u4e0e REQUIRED \u884c\u4e3a\u4e00\u6837\uff0c\u5e76\u4e14\u8fd8\u4f1a\u9a8c\u8bc1 Server \u7aef\u7684 CA \u8bc1\u4e66\u662f\u5426\u6709\u6548\u3002 VERIFY_IDENTITY \u4e0e VERIFY_CA \u884c\u4e3a\u4e00\u6837\uff0c\u5e76\u4e14\u8fd8\u9a8c\u8bc1 Server \u7aef CA \u8bc1\u4e66\u4e2d\u7684 host \u662f\u5426\u4e0e\u5b9e\u9645\u8fde\u63a5\u7684 hostname \u662f\u5426\u4e00\u81f4\u3002Note
\u5ba2\u6237\u7aef\u5728\u6307\u5b9a\u4e86 --ssl-mode=VERIFY_CA
\u65f6\uff0c\u9700\u8981\u4f7f\u7528 --ssl-ca
\u6765\u6307\u5b9a CA \u8bc1\u4e66\u3002 \u5ba2\u6237\u7aef\u5728\u6307\u5b9a\u4e86 --ssl-mode=VERIFY_IDENTITY
\u65f6\uff0c\u9700\u8981\u6307\u5b9a CA \u8bc1\u4e66\uff0c\u4e14\u9700\u8981\u4f7f\u7528 --ssl-key
\u6307\u5b9a\u5ba2\u6237\u7aef\u7684\u79c1\u94a5\u548c\u4f7f\u7528 --ssl-cert
\u6307\u5b9a\u5ba2\u6237\u7aef\u7684\u8bc1\u4e66\u3002
\u672c\u6587\u6863\u5bf9 MatrixOne \u5b89\u5168\u5ba1\u8ba1\u57fa\u672c\u529f\u80fd\u8fdb\u884c\u9610\u8ff0\uff0c\u5e76\u6307\u5f15\u5982\u4f55\u5f00\u542f\u548c\u4f7f\u7528\u3002
"},{"location":"MatrixOne/Security/audit/#_2","title":"\u6982\u8ff0","text":"\u5ba1\u8ba1\u662f\u7528\u6765\u8bb0\u5f55\u6570\u636e\u5e93\u7528\u6237\u884c\u4e3a\u4ee5\u53ca\u6570\u636e\u5e93\u5185\u90e8\u91cd\u8981\u4e8b\u4ef6\u7684\u529f\u80fd\uff0c\u5b83\u8bb0\u5f55\u4e86\u6240\u6709\u7528\u6237\u5728\u767b\u5f55\u6570\u636e\u5e93\u540e\u505a\u51fa\u7684\u6240\u6709\u6570\u636e\u5e93\u64cd\u4f5c\u4ee5\u53ca\u6570\u636e\u5185\u90e8\u7684\u91cd\u5927\u4e8b\u4ef6\u3002\u4e5f\u662f\u5f88\u591a\u4f01\u4e1a\u7ea7\u6570\u636e\u5e93\u5fc5\u5907\u7684\u529f\u80fd\u4e4b\u4e00\u3002
\u5728\u65e5\u5e38\u7684\u6570\u636e\u5e93\u8fd0\u7ef4\u4e2d\uff0c\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u5e93\u7528\u6237\u7684\u6240\u6709\u884c\u4e3a\u5408\u89c4\u5408\u6cd5\uff0c\u5ba1\u8ba1\u662f\u975e\u5e38\u6709\u6548\u7684\u624b\u6bb5\u3002\u5728\u6570\u636e\u5e93\u53d1\u751f\u91cd\u8981\u4e8b\u4ef6\u65f6\uff0c\u4f8b\u5982\u542f\u505c\u3001\u8282\u70b9\u5b95\u673a\u7b49\uff0c\u5ba1\u8ba1\u5185\u5bb9\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u8ffd\u8e2a\u5230\u524d\u540e\u65f6\u6bb5\u7684\u6570\u636e\u5e93\u884c\u4e3a\u3002
\u5bf9\u4e8e\u91cd\u8981\u7684\u4e1a\u52a1\u4fe1\u606f\u8868\u6216\u7cfb\u7edf\u914d\u7f6e\u8868\u9700\u8981\u8fdb\u884c\u6709\u6548\u5b8c\u6574\u7684\u884c\u4e3a\u76d1\u63a7\u65f6\uff0c\u6570\u636e\u5e93\u5ba1\u8ba1\u7684\u5f00\u542f\u5341\u5206\u6709\u5fc5\u8981\u3002\u4f8b\u5982\u76d1\u63a7\u5bf9\u7528\u6237 A \u5728\u6570\u636e\u5e93\u4e2d\u6240\u6709\u884c\u4e3a\uff0c\u4ee5\u4fbf\u4e8e\u53ca\u65f6\u53d1\u73b0\u8fdd\u89c4\u7684\u6570\u636e\u4fee\u6539\u6216\u5220\u9664\u6765\u6e90\u3002\u5bf9\u4e8e\u6570\u636e\u5e93\u5185\u90e8\u91cd\u5927\u4e8b\u4ef6\u7684\u76d1\u63a7\uff0c\u53ef\u4ee5\u7b2c\u4e00\u65f6\u95f4\u6392\u67e5\u6545\u969c\uff0c\u5e76\u4e14\u8ffd\u6eaf\u4e8b\u6545\u4ea7\u751f\u7684\u6839\u672c\u539f\u56e0\u3002
MatrixOne \u652f\u6301\u5bf9\u7528\u6237\u884c\u4e3a\uff0c\u64cd\u4f5c\u65e5\u5fd7\uff0cSQL \u8bed\u53e5\u7684\u5ba1\u8ba1\u3002MatrixOne \u7684\u5ba1\u8ba1\u6570\u636e\u4fdd\u5b58\u5728\u6570\u636e\u5e93\u8868\u4e2d\uff0c\u76f4\u63a5\u901a\u8fc7 SQL \u4ea4\u4e92\u53ef\u4ee5\u67e5\u8be2\u5ba1\u8ba1\u6570\u636e\u3002
"},{"location":"MatrixOne/Security/audit/#_3","title":"\u5f00\u542f\u5ba1\u8ba1","text":"\u6267\u884c\u5982\u4e0b\u5185\u5bb9\u811a\u672c\uff0c\u5f00\u542f\u5ba1\u8ba1\u529f\u80fd\uff1a
drop database if exists mo_audits;\ncreate database mo_audits;\nuse mo_audits;\ncreate view mo_user_action as select request_at,user,host,statement,status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like '______internal_%' order by request_at desc;\ncreate view mo_events as select timestamp,level,message from system.log_info where level in ('error','panic','fatal') order by timestamp desc;\n
"},{"location":"MatrixOne/Security/audit/#_4","title":"\u5ba1\u8ba1\u67e5\u8be2","text":"\u5bf9\u7528\u6237\u884c\u4e3a\u8fdb\u884c\u5ba1\u8ba1\u65f6\uff0c\u6267\u884c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u8fdb\u884c\u67e5\u770b\uff1a
mysql> select * from mo_audits.mo_user_action;\n
\u67e5\u8be2\u793a\u4f8b\u7ed3\u679c\u5982\u4e0b\uff1a
+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| request_at | user | host | statement | status |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| 2023-02-10 19:54:28.831970 | root | 0.0.0.0 | create view mo_user_action as select request_at, user, host, statement, status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like \"______internal_%\" order by request_at desc | Success |\n| 2023-02-10 19:54:14.079939 | root | 0.0.0.0 | show tables | Success |\n| 2023-02-10 19:54:14.076260 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:54:14.071728 | root | 0.0.0.0 | use mo_audits | Success |\n| 2023-02-10 19:54:14.071108 | root | 0.0.0.0 | select database() | Success |\n| 2023-02-10 19:54:01.007241 | root | 0.0.0.0 | create database mo_audits | Success |\n| 2023-02-10 19:53:48.924819 | root | 0.0.0.0 | drop database if exists mo_audits | Success |\n| 2023-02-10 19:30:59.668646 | root | 0.0.0.0 | show triggers | Success |\n| 2023-02-10 19:30:53.438212 | root | 0.0.0.0 | show locks | Success |\n| 2023-02-10 19:30:44.258894 | root | 0.0.0.0 | show index from t | Success |\n| 2023-02-10 19:30:43.662063 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a)) | Success |\n| 2023-02-10 19:30:23.104830 | root | 0.0.0.0 | show triggers | Success |\n| 2023-02-10 19:30:20.062010 | root | 0.0.0.0 | show tables | Success |\n| 2023-02-10 19:30:20.060324 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:30:20.055515 | root | 0.0.0.0 | use aab | Success |\n| 2023-02-10 19:30:20.055186 | root | 0.0.0.0 | select database() | Success |\n| 2023-02-10 19:30:17.152087 | root | 0.0.0.0 | create database aab | Success |\n| 2023-02-10 19:30:10.621294 | root | 0.0.0.0 | create aab | Failed |\n| 2023-02-10 19:29:59.983433 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:29:45.370956 | root | 0.0.0.0 | show index from t | Failed |\n| 2023-02-10 19:29:44.875580 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a)) | Failed |\n| 2023-02-10 19:29:44.859588 | root | 0.0.0.0 | drop table if exists t | Success |\n| 2023-02-10 19:29:19.974775 | root | 0.0.0.0 | show index | Failed |\n| 2023-02-10 19:29:11.188286 | root | 0.0.0.0 | show locks | Success |\n| 2023-02-10 19:29:06.618778 | root | 0.0.0.0 | show node list | Success |\n| 2023-02-10 19:19:11.319058 | root | 0.0.0.0 | show triggers | Failed |\n| 2023-02-10 19:19:06.809302 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:18:52.840282 | root | 0.0.0.0 | show triggers | Failed |\n| 2023-02-10 10:54:09.892254 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 10:54:04.468721 | root | 0.0.0.0 | select @@version_comment limit 1 | Success |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n30 rows in set (0.81 sec)\n
\u67e5\u8be2\u6570\u636e\u5e93\u5185\u90e8\u72b6\u6001\u53d8\u66f4\u67e5\u8be2\uff0c\u6267\u884c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u8fdb\u884c\u67e5\u770b\uff1a
mysql> select * from mo_events;\n
\u67e5\u8be2\u793a\u4f8b\u7ed3\u679c\u5982\u4e0b\uff1a
|\n| 2022-10-18 15:26:20.293735 | error | error: timeout, converted to code 20429 |\n| 2022-10-18 15:26:20.293725 | error | failed to propose initial cluster info |\n| 2022-10-18 15:26:20.288695 | error | failed to set initial cluster info |\n| 2022-10-18 15:26:20.288559 | error | failed to propose initial cluster info |\n| 2022-10-18 15:26:20.285384 | error | failed to set initial cluster info |\n| 2022-10-18 15:26:20.285235 | error | failed to propose initial cluster info |\n| 2022-10-18 15:26:18.473472 | error | failed to join the gossip group, 1 error occurred:\n * Failed to join 127.0.0.1:32022: dial tcp 127.0.0.1:32022: connect: connection refused |\n| 2022-10-18 15:26:18.469029 | error | failed to join the gossip group, 1 error occurred:\n * Failed to join 127.0.0.1:32012: dial tcp 127.0.0.1:32012: connect: connection refused \n
"},{"location":"MatrixOne/Security/audit/#_5","title":"\u5173\u95ed\u5ba1\u8ba1","text":"\u6267\u884c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\uff0c\u5173\u95ed\u5ba1\u8ba1\uff1a
> drop database if exists mo_audits;\n
"},{"location":"MatrixOne/Security/password-mgmt/","title":"\u5bc6\u7801\u7ba1\u7406","text":"\u4e3a\u4e86\u4fdd\u62a4\u7528\u6237\u5bc6\u7801\u7684\u5b89\u5168\uff0cMatrixOne \u652f\u6301\u5bc6\u7801\u7ba1\u7406\u80fd\u529b\uff1a
MatrixOne \u5efa\u8bae\u7528\u6237\u8bbe\u7f6e\u590d\u6742\u7684\u5bc6\u7801\uff0c\u4fdd\u8bc1\u8d26\u53f7\u5b89\u5168\u3002
\u6709\u5173\u6743\u9650\u7ea7\u522b\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53ef\u53c2\u8003 MatrixOne \u6743\u9650\u5206\u7c7b\u3002
"},{"location":"MatrixOne/Security/password-mgmt/#_4","title":"\u4fee\u6539\u5bc6\u7801\u6559\u7a0b","text":""},{"location":"MatrixOne/Security/password-mgmt/#root","title":"root \u7528\u6237\u4fee\u6539\u5bc6\u7801","text":""},{"location":"MatrixOne/Security/password-mgmt/#root_1","title":"root \u7528\u6237\u4fee\u6539\u81ea\u5df1\u7684\u5bc6\u7801","text":"\u542f\u52a8\u7684 MatrixOne \u5e76\u4f7f\u7528 root \u8d26\u53f7\u767b\u5f55\u6210\u529f\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u4fee\u6539\u5bc6\u7801\uff1a
mysql> alter user root identified by '${your password}'\n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u9000\u51fa\u5f53\u524d\u4f1a\u8bdd\uff0c\u518d\u6b21\u767b\u5f55 MatrixOne \u65b0\u5bc6\u7801\u751f\u6548\u3002
Note
\u7531\u4e8e root \u8d26\u53f7\u9ed8\u8ba4\u662f\u5177\u6709\u6700\u9ad8\u6743\u9650\u7684\u7528\u6237\uff0c\u8bf7\u4f7f\u7528\u521d\u59cb\u8d26\u53f7\u5bc6\u7801\u767b\u5f55\u540e\u53ca\u65f6\u4fee\u6539\u5bc6\u7801\u3002
"},{"location":"MatrixOne/Security/password-mgmt/#root_2","title":"root \u7528\u6237\u4fee\u6539\u79df\u6237\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER ACCOUNT
"},{"location":"MatrixOne/Security/password-mgmt/#_5","title":"\u5176\u4ed6\u7528\u6237\u4fee\u6539\u5bc6\u7801","text":""},{"location":"MatrixOne/Security/password-mgmt/#_6","title":"\u79df\u6237\u4fee\u6539\u81ea\u5df1\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER ACCOUNT
"},{"location":"MatrixOne/Security/password-mgmt/#_7","title":"\u79df\u6237\u4fee\u6539\u81ea\u5df1\u521b\u5efa\u7684\u5176\u4ed6\u7528\u6237\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER USER
"},{"location":"MatrixOne/Security/password-mgmt/#_8","title":"\u666e\u901a\u7528\u6237\u4fee\u6539\u81ea\u5df1\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER USER
"},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/","title":"\u521b\u5efa\u79df\u6237\uff0c\u9a8c\u8bc1\u8d44\u6e90\u9694\u79bb","text":"\u521d\u59cb\u5316\u63a5\u5165 MatrixOne \u96c6\u7fa4\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u9ed8\u8ba4\u8d26\u53f7\uff0c\u5373\u96c6\u7fa4\u7ba1\u7406\u5458\u3002\u96c6\u7fa4\u7ba1\u7406\u5458\u88ab\u81ea\u52a8\u9ed8\u8ba4\u8d4b\u4e88\u7ba1\u7406\u79df\u6237\u8d26\u53f7\u7684\u6743\u9650\uff0c\u4f46\u4e0d\u80fd\u7ba1\u7406\u79df\u6237\u4e0b\u7684\u8d44\u6e90\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u8d26\u53f7\u521b\u5efa\u4e24\u4e2a\u65b0\u7684\u79df\u6237\uff0c\u5e76\u8d4b\u4e88\u79df\u6237\u7ba1\u7406\u5458\u7684\u6743\u9650\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u5b9e\u73b0\u4e86\u79df\u6237\u4e4b\u95f4\u7684\u8d44\u6e90\u9694\u79bb\u3002
"},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/#_2","title":"\u524d\u63d0\u6761\u4ef6","text":"\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u7528\u6237\u540d\uff08\u9ed8\u8ba4 root\uff09\u548c\u5bc6\u7801\u767b\u5f55 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -u root -p\n
\u521b\u5efa\u65b0\u7684\u79df\u6237\uff1a
create account a1 ADMIN_NAME 'admin1' IDENTIFIED BY 'test123';\ncreate account a2 ADMIN_NAME 'admin2' IDENTIFIED BY 'test456';\n
\u4f7f\u7528 admin1 \u767b\u5f55\u79df\u6237 a1\uff0c\u5e76\u521b\u5efa\u6570\u636e\u8868 db1.t1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:admin1 -p\ncreate database db1;\ncreate table db1.t1(c1 int,c2 varchar);\ninsert into db1.t1 values (1,'shanghai'),(2,'beijing');\n
\u9a8c\u8bc1\u79df\u6237 a1 \u662f\u5426\u6210\u529f\u521b\u5efa\u8868\uff1a
mysql> select * from db1.t1;\n+------+----------+\n| c1 | c2 |\n+------+----------+\n| 1 | shanghai |\n| 2 | beijing |\n+------+----------+\n2 rows in set (0.01 sec)\n
\u4f7f\u7528 admin2 \u767b\u5f55\u79df\u6237 a2\uff1a
mysql -h 127.0.0.1 -P 6001 -u a2:admin2 -p\n
\u67e5\u770b\u79df\u6237 a1 \u4e2d\u7684 db1.t1 \u6570\u636e\uff1a
mysql> select * from db1.t1;\nERROR 1064 (HY000): SQL parser error: table \"t1\" does not exist\n
\u4e0a\u8ff0\u547d\u4ee4\u8fd0\u884c\u62a5\u9519\uff0c\u8bc1\u660e\u5728\u79df\u6237 a2 \u4e2d\uff0c\u5e76\u4e0d\u80fd\u770b\u5230\u79df\u6237 a1 \u4e2d\u7684\u6570\u636e\u5e93 db1\uff1a
\u5728\u79df\u6237 a2 \u4e2d\u4e5f\u53ef\u4ee5\u521b\u5efa\u5e93 db1 \u548c\u8868 db1.t1\uff1a
mysql> create database db1;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> create table db1.t1(c1 int,c2 varchar);\nQuery OK, 0 rows affected (0.05 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n
\u5728\u79df\u6237 a2 \u7684 db1.t1 \u8fd9\u5f20\u8868\u5185\u63d2\u5165\u4e0e\u79df\u6237 a1 \u4e2d\u8868 db1.t1 \u4e0d\u540c\u7684\u6570\u636e\u5e76\u67e5\u770b\uff1a
mysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n\nmysql> select * from db1.t1;\n+------+-----------+\n| c1 | c2 |\n+------+-----------+\n| 3 | guangzhou |\n+------+-----------+\n1 row in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u5373\u4f7f\u4e0e\u79df\u6237 a1 \u4e2d\u7684\u6570\u636e\u5e93\u4e0e\u8868\u91cd\u540d\uff0c\u4f46\u662f\u8fd9\u4e24\u4e2a\u6570\u636e\u5e93\u4e0e\u8868\u4e92\u4e0d\u5e72\u6270\uff0c\u5b8c\u5168\u9694\u79bb\u3002
\u521d\u59cb\u5316\u63a5\u5165 MatrixOne \u96c6\u7fa4\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u9ed8\u8ba4\u8d26\u53f7\uff0c\u5373\u96c6\u7fa4\u7ba1\u7406\u5458\u3002\u96c6\u7fa4\u7ba1\u7406\u5458\u9ed8\u8ba4\u7528\u6237\u540d\u4e3a root\uff0croot \u65e2\u662f\u96c6\u7fa4\u7ba1\u7406\u5458\uff0c\u540c\u65f6\u4e5f\u662f\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\uff0croot \u53ef\u4ee5\u521b\u5efa\u548c\u7ba1\u7406\u5176\u4ed6\u666e\u901a\u79df\u6237\uff08\u975e\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\uff09\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u79df\u6237\uff0c\u5e76\u5207\u6362\u81f3\u65b0\u79df\u6237\u767b\u5f55\uff0c\u7528\u65b0\u79df\u6237\u8d26\u53f7\u521b\u5efa\u7528\u6237\u3001\u521b\u5efa\u89d2\u8272\u3001\u521b\u5efa\u6743\u9650\uff0c\u5e76\u8d4b\u4e88\u7528\u6237\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#_2","title":"\u524d\u63d0\u6761\u4ef6","text":"\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u7528\u6237\u540d\uff08\u9ed8\u8ba4 root\uff09\u548c\u5bc6\u7801\u767b\u5f55 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -u root -p\n
\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u79df\u6237 a1\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u5206\u522b\u4e3a\uff1aadmin\uff0ctest123\uff1a
create account a1 ADMIN_NAME 'admin' IDENTIFIED BY 'test123';\n
\u67e5\u770b\u96c6\u7fa4\u4e2d\u7684\u6240\u6709\u79df\u6237\u4fe1\u606f\uff08\u4ec5 root \u53ef\u67e5\u770b\uff09\uff1a
mysql> select * from mo_catalog.mo_account;\n+------------+--------------+--------+---------------------+----------------+----------------+\n| account_id | account_name | status | created_time | comments | suspended_time |\n+------------+--------------+--------+---------------------+----------------+----------------+\n| 1 | a1 | open | 2022-12-19 14:47:19 | | NULL |\n| 0 | sys | open | 2022-12-07 11:00:58 | system account | NULL |\n+------------+--------------+--------+---------------------+----------------+----------------+\n
\u4f60\u53ef\u4ee5\u91cd\u65b0\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\uff0c\u4f7f\u7528 admin \u767b\u5f55\u79df\u6237 a1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:admin -p\n
\u73b0\u5728\u4f60\u53ef\u4ee5\u4f5c\u4e3a\u79df\u6237 a1 \u67e5\u770b\u79df\u6237\u4e0b\u7684\u9ed8\u8ba4\u7528\u6237\u548c\u89d2\u8272\uff1a
mysql> select * from mo_catalog.mo_role;\n+---------+--------------+---------+-------+---------------------+----------+\n| role_id | role_name | creator | owner | created_time | comments |\n+---------+--------------+---------+-------+---------------------+----------+\n| 2 | accountadmin | 0 | 0 | 2022-12-19 14:47:20 | |\n| 1 | public | 0 | 0 | 2022-12-19 14:47:20 | |\n+---------+--------------+---------+-------+---------------------+----------+\n2 rows in set (0.01 sec)\n\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| 2 | localhost | admin | test123 | unlock | 2022-12-19 14:47:20 | NULL | PASSWORD | 0 | 0 | 2 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n1 row in set (0.00 sec)\n
\u79df\u6237 a1 \u88ab\u521b\u5efa\u6210\u529f\u540e\u4fbf\u9ed8\u8ba4\u62e5\u6709\u4e86\u79df\u6237\u7ba1\u7406\u5458\u6743\u9650\uff0c\u6240\u4ee5\u53ef\u4ee5\u67e5\u770b\u79df\u6237 a1 \u4e0b\u7684\u7cfb\u7edf\u8868\u4fe1\u606f\u3002\u5728 mo_user \u8868\u4e2d\u53ef\u4ee5\u89c2\u5bdf\u5230\u5f53\u524d\u6709\u4e00\u4e2a\u7528\u6237\u540d\u4e3a admin \u7684\u7528\u6237\u8d26\u53f7\uff0c\u5373\u521b\u5efa\u79df\u6237\u65f6\u6307\u5b9a\u7684\uff1b\u6b64\u5916\uff0c\u8fd8\u6709 accountadmin \u548c public \u4e24\u4e2a\u9ed8\u8ba4\u89d2\u8272\uff1a
connect
\uff0c\u5373\u8fde\u63a5 MatrixOne\u3002\u6b64\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u5728\u7cfb\u7edf\u8868\u4e2d\u67e5\u770b\u5230\u8fd9\u4e9b\u9ed8\u8ba4\u89d2\u8272\u7684\u6743\u9650\u96c6\u5408\uff1a
mysql> select * from mo_catalog.mo_role_privs;\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n| role_id | role_name | obj_type | obj_id | privilege_id | privilege_name | privilege_level | operation_user_id | granted_time | with_grant_option |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n| 2 | accountadmin | account | 0 | 3 | create user | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 4 | drop user | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 5 | alter user | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 6 | create role | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 7 | drop role | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 9 | create database | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 10 | drop database | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 11 | show databases | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 12 | connect | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 13 | manage grants | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 14 | account all | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 18 | show tables | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 20 | create table | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 23 | drop table | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 26 | alter table | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 21 | create view | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 24 | drop view | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 27 | alter view | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 28 | database all | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 29 | database ownership | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 30 | select | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 31 | insert | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 32 | update | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 33 | truncate | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 34 | delete | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 35 | reference | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 36 | index | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 37 | table all | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 38 | table ownership | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 41 | values | t | 0 | 2022-12-19 14:47:20 | true |\n| 1 | public | account | 0 | 12 | connect | * | 0 | 2022-12-19 14:47:20 | true |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n
\u5728\u79df\u6237 a1 \u4e2d\uff0c\u521b\u5efa\u65b0\u7684\u7528\u6237\u548c\u89d2\u8272\uff1a
create user u1 identified by 'user123';\ncreate user u2 identified by 'user456';\ncreate role r1;\ncreate role r2;\n
\u521b\u5efa\u6570\u636e\u5e93 db1\uff0c\u5e76\u5728 db1 \u4e2d\u521b\u5efa\u8868 t1\uff1a
create database db1;\ncreate table db1.t1(c1 int,c2 varchar);\n
\u5c06 db1.t1 \u7684 select
\u6743\u9650\u6388\u4e88\u7ed9 r1\uff0cinsert
\u6743\u9650\u6388\u4e88\u7ed9 r2\uff1a
grant select on table db1.t1 to r1;\ngrant insert on table db1.t1 to r2;\n
\u5c06\u89d2\u8272 r1 \u6388\u4e88\u7ed9\u7528\u6237 u1\uff1b\u5c06\u89d2\u8272 r2 \u6388\u4e88\u7ed9\u7528\u6237 u2\uff1a
grant r1 to u1;\ngrant r2 to u2;\n
\u6b64\u65f6\uff0c\u65b0\u5efa\u7684\u7528\u6237\u3001\u89d2\u8272\u3001\u5bf9\u8c61\u6743\u9650\u5173\u7cfb\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u5206\u522b\u4f7f\u7528\u7528\u6237 u1 \u548c u2 \u767b\u5f55\u79df\u6237 a1\uff0c\u9a8c\u8bc1\u6743\u9650\u662f\u5426\u751f\u6548\u3002
\u7531\u4e8e u2 \u88ab\u6388\u4e88\u4e86 r2 \u89d2\u8272\uff0c\u4e14 r2 \u88ab\u6388\u4e88\u4e86 db1.t1 \u7684 insert
\u6743\u9650\uff0c\u6240\u4ee5 u2 \u5177\u5907 db1.t1 \u7684 insert
\u6743\u9650\uff0c\u5373\u53ef\u4ee5\u5411 db1.t1 \u63d2\u5165\u6570\u636e\uff0c
\u4f7f\u7528 u1 \u767b\u5f55 a1 \u8fdb\u884c\u9a8c\u8bc1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:u2:r2 -p\n\nmysql> insert into db1.t1 values (1,'shanghai'),(2,'beijing');\nQuery OK, 2 rows affected (0.04 sec)\n\nmysql> select * from db1.t1;\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n
u2 \u53ef\u4ee5\u6210\u529f\u5411\u8868 db1.t1 \u63d2\u5165\u6570\u636e\uff0c\u4f46\u65e0\u6cd5\u67e5\u770b db1.t1 \u8868\u91cc\u7684\u6570\u636e\u3002
\u540c\u6837\u7684\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 u1 \u767b\u5f55 a1 \u8fdb\u884c\u6743\u9650\u9a8c\u8bc1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:u1:r1 -p\n\nmysql> select * from db1.t1;\n+------+----------+\n| c1 | c2 |\n+------+----------+\n| 1 | shanghai |\n| 2 | beijing |\n+------+----------+\n2 rows in set (0.01 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n
\u5982\u4e0a\u8ff0\u4ee3\u7801\u6240\u793a\uff0cu1 \u53ef\u4ee5\u6210\u529f\u7684\u67e5\u8be2\u8868 db1.t1 \u7684\u6570\u636e\uff0c\u4f46\u4e0d\u80fd\u5411\u5176\u63d2\u5165\u6570\u636e\u3002
Note
\u4e0a\u8ff0\u64cd\u4f5c\u6b65\u9aa4\u4e2d\uff0c\u66f4\u591a\u6709\u5173\u67e5\u770b\u7684\u7cfb\u7edf\u8868\u4fe1\u606f\uff0c\u53c2\u89c1 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868
"},{"location":"MatrixOne/Security/how-tos/user-guide/","title":"\u6743\u9650\u7ba1\u7406\u64cd\u4f5c\u6982\u8ff0","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_2","title":"\u7ba1\u7406\u79df\u6237","text":"\u6709\u5173 root \u8d26\u53f7\u5bf9\u5e94\u7684\u89d2\u8272\u548c\u6743\u9650\u5982\u4e0b\u8868\u6240\u793a\uff1a
\u7528\u6237\u540d \u89e3\u91ca \u6240\u62e5\u6709\u7684\u89d2\u8272 \u6240\u62e5\u6709\u7684\u6743\u9650 \u63cf\u8ff0 root \u96c6\u7fa4\u7ba1\u7406\u5458 MOADMIN \u521b\u5efa\u3001\u7f16\u8f91\u3001\u5220\u9664\u79df\u6237 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 root \u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458 MOADMIN \u7ba1\u7406\u7cfb\u7edf\u79df\u6237\u4e0b\u7684\u6240\u6709\u8d44\u6e90\uff0c\u5305\u542b\u7528\u6237\u3001\u89d2\u8272\u3001\u6570\u636e\u5e93/\u8868/\u89c6\u56fe\uff0c\u6388\u6743\u7ba1\u7406 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88"},{"location":"MatrixOne/Security/how-tos/user-guide/#_3","title":"\u521b\u5efa\u79df\u6237","text":"SQL \u8bed\u6cd5
create account <account_name> admin_name='<user_name>' identified by '<password>';\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca account_name \u65b0\u5efa\u79df\u6237\u7684\u540d\u79f0 user_name \u65b0\u5efa\u79df\u6237\u7684\u7ba1\u7406\u5458\u7528\u6237\u540d\uff0c\u5176\u4f1a\u88ab\u81ea\u52a8\u6388\u4e88\u79df\u6237\u7684\u6700\u9ad8\u6743\u9650\u89d2\u8272\uff0c\u5373ACCOUNTADMIN
password \u65b0\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u5bc6\u7801 \u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE ACCOUNT\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_4","title":"\u67e5\u770b\u79df\u6237","text":"SQL \u8bed\u6cd5
select * from mo_catalog.mo_account;\n
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_5","title":"\u5220\u9664\u79df\u6237","text":"SQL \u8bed\u6cd5
drop account if exists account_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca account_name \u9700\u8981\u5220\u9664\u7684\u79df\u6237\u540d\u79f0Note
\u5220\u9664\u79df\u6237\u540e\u5219\u65e0\u6cd5\u6062\u590d\uff0c\u5305\u62ec\u79df\u6237\u8d26\u53f7\u4e0b\u7684\u6240\u6709\u6570\u636e\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 DROP ACCOUNT\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_6","title":"\u7ba1\u7406\u7528\u6237","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_7","title":"\u521b\u5efa\u7528\u6237","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 CREATE USER
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5728\u5f53\u524d\u79df\u6237\u4e2d\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002
SQL \u8bed\u6cd5
create user <user_name> identified by '<password>';\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca user_name \u65b0\u5efa\u7528\u6237\u7684\u540d\u79f0 password \u65b0\u5efa\u7684\u7528\u6237\u5bc6\u7801\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE USER\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_8","title":"\u67e5\u770b\u7528\u6237","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709\u67e5\u770b\u7528\u6237\u7684\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u67e5\u770b\u5f53\u524d\u79df\u6237\u4e0b\u6240\u6709\u7684\u7528\u6237\u3002
SQL \u8bed\u6cd5
select * from mo_catalog.mo_user;\n
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_9","title":"\u5220\u9664\u7528\u6237","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 DROP USER
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5220\u9664\u5f53\u524d\u79df\u6237\u4e0b\u7684\u6307\u5b9a\u7684\u7528\u6237\u3002
SQL \u8bed\u6cd5
drop user if exist <user_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca user_name \u65b0\u5efa\u7528\u6237\u7684\u540d\u79f0Note
\u5220\u9664\u7528\u6237\u65f6\uff0c\u9700\u8981\u5148\u505c\u6b62\u7528\u6237\u5f53\u524d\u5b58\u5728\u7684\u4f1a\u8bdd\uff0c\u5426\u5219\u5220\u9664\u5931\u8d25\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 DROP USER\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_10","title":"\u7ba1\u7406\u89d2\u8272","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_11","title":"\u521b\u5efa\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 CREATE ROLE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5728\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u89d2\u8272\u3002
SQL \u8bed\u6cd5
create role <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u65b0\u5efa\u89d2\u8272\u7684\u540d\u79f0\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_12","title":"\u67e5\u770b\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709\u67e5\u770b\u89d2\u8272\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u67e5\u770b\u5f53\u524d\u79df\u6237\u4e0b\u6240\u6709\u7684\u89d2\u8272\u3002
SQL \u8bed\u6cd5
select * from mo_catalog.mo_role;\n
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_13","title":"\u5207\u6362\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 SET ROLE
\u6743\u9650\u3002\u9ed8\u8ba4\u6240\u6709\u7528\u6237\u90fd\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5728\u79df\u6237\u4e2d\u5207\u6362\u7528\u6237\u7684\u89d2\u8272\uff0c\u83b7\u53d6\u5176\u4ed6\u89d2\u8272\u7684\u6743\u9650\uff0c\u4ee5\u4fbf\u6267\u884c\u76f8\u5e94\u7684 SQL\u3002
SQL \u8bed\u6cd5
set role <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u89d2\u8272\u7684\u540d\u79f0\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 SET ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_14","title":"\u5220\u9664\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 DROP ROLE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5220\u9664\u5f53\u524d\u79df\u6237\u4e0b\u7684\u7279\u5b9a\u89d2\u8272\u3002
SQL \u8bed\u6cd5
drop role if exists <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u9700\u8981\u5220\u9664\u7684\u89d2\u8272\u7684\u540d\u79f0Note
\u5220\u9664\u67d0\u4e2a\u6307\u5b9a\u89d2\u8272\u65f6\uff0c\u4f1a\u540c\u65f6\u56de\u6536\u5df2\u7ecf\u88ab\u6388\u6743\u7684\u7528\u6237\u7684\u89d2\u8272\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 DROP ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_15","title":"\u7ba1\u7406\u6743\u9650","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_16","title":"\u5411\u89d2\u8272\u6388\u4e88\u67d0\u4e2a\u5bf9\u8c61\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5411\u67d0\u4e2a\u89d2\u8272\u6388\u4e88\u67d0\u4e2a\u5bf9\u8c61\u7684\u67d0\u4e2a\u6743\u9650\u3002
SQL \u8bed\u6cd5
grant <privilege> on <object_type> <object_name> to <role_name>\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca privilege \u6743\u9650 object_type \u5bf9\u8c61\u7c7b\u578b object_name \u5bf9\u8c61\u540d\u79f0 role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT PRIVILEGES\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_17","title":"\u5411\u89d2\u8272\u6388\u4e88\u67d0\u7c7b\u5bf9\u8c61\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5411\u89d2\u8272\u6388\u4e88\u6240\u6709\u6570\u636e\u5e93/\u6570\u636e\u8868\u7684\u67d0\u4e2a\u6743\u9650\u3002
SQL \u8bed\u6cd5
grant <privilege> on database * to <role_name>;\ngrant <privilege> on table *.* to <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca privilege \u6743\u9650\u540d\u79f0 role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272\u540d\u79f0Note
\u8be5\u64cd\u4f5c\u867d\u7136\u5728\u6388\u6743\u591a\u4e2a\u76f8\u540c\u7c7b\u522b\u5bf9\u8c61\u65f6\u6bd4\u8f83\u7b80\u4fbf\uff0c\u4f46\u4e5f\u5f88\u5bb9\u6613\u53d1\u751f\u6743\u9650\u6cc4\u6f0f\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT PRIVILEGES\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_18","title":"\u5411\u7528\u6237\u6388\u4e88\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5411\u67d0\u4e2a\u7528\u6237\u6388\u4e88\u67d0\u4e2a\u89d2\u8272\u3002
SQL \u8bed\u6cd5
grant <role_name> to <user_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272 user_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u7528\u6237\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_19","title":"\u8ba9\u4e00\u4e2a\u89d2\u8272\u7ee7\u627f\u53e6\u4e00\u4e2a\u89d2\u8272\u7684\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u8ba9 role_b \u7ee7\u627f role_a \u7684\u6240\u6709\u6743\u9650\u3002
SQL \u8bed\u6cd5
grant <role_a> to <role_b>;\n
Note
\u8be5\u6743\u9650\u7ee7\u627f\u4e3a\u52a8\u6001\u7ee7\u627f\uff0c\u82e5 role_a \u7684\u6743\u9650\u53d1\u751f\u6539\u53d8\uff0c\u5219 role_b \u6240\u7ee7\u627f\u7684\u6743\u9650\u4e5f\u4f1a\u52a8\u6001\u66f4\u6539\u3002MatrixOne \u4e0d\u5141\u8bb8\u89d2\u8272\u73af\u7ee7\u627f\uff0c\u5373 role1 \u7ee7\u627f role2\uff0crole2 \u7ee7\u627f role3\uff0c\u4f46\u662f role3 \u7ee7\u627f\u4e0d\u80fd\u7ee7\u627f role1\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_20","title":"\u67e5\u770b\u67d0\u4e00\u7528\u6237\u6240\u62e5\u6709\u7684\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 SHOW GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u67e5\u770b\u6240\u6307\u5b9a\u7528\u6237\u5f53\u524d\u6240\u62e5\u6709\u7684\u5168\u90e8\u6743\u9650\u3002
SQL \u8bed\u6cd5
show grants for <user_name>@<localhost>\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca user_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u7528\u6237\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 SHOW GRANTS\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_21","title":"\u56de\u6536\u6388\u6743\u7528\u6237\u7684\u67d0\u4e2a\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 REVOKE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5c06\u67d0\u4e00\u7528\u6237\u7684\u67d0\u4e00\u89d2\u8272\u79fb\u9664\u3002
SQL \u8bed\u6cd5
revoke <role_name> from <user_name>\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272 user_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u7528\u6237\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 REVOKE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_22","title":"\u56de\u6536\u89d2\u8272\u4e2d\u7684\u67d0\u4e2a\u5bf9\u8c61\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 REVOKE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u56de\u6536\u89d2\u8272\u4e2d\u7684\u67d0\u4e2a\u5bf9\u8c61\u6743\u9650\u3002
SQL \u8bed\u6cd5
revoke <privilege> on <object_type> <object_name> to <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca privilege \u6743\u9650\u540d\u79f0 object_type \u5bf9\u8c61\u7c7b\u578b object_name \u5bf9\u8c61\u540d\u79f0 role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 REVOKE\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/","title":"\u6743\u9650\u7ba1\u7406\u6982\u8ff0","text":""},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#matrixone","title":"MatrixOne \u6743\u9650\u7ba1\u7406\u6982\u8ff0","text":"MatrixOne \u6743\u9650\u7ba1\u7406\u5e2e\u52a9\u4f60\u7ba1\u7406\u79df\u6237\u3001\u7528\u6237\u5e10\u53f7\u751f\u547d\u5468\u671f\uff0c\u5206\u914d\u7ed9\u7528\u6237\u76f8\u5e94\u7684\u89d2\u8272\uff0c\u63a7\u5236 MatrixOne \u4e2d\u8d44\u6e90\u7684\u8bbf\u95ee\u6743\u9650\u3002\u5f53\u6570\u636e\u5e93\u6216\u96c6\u7fa4\u5355\u4f4d\u4e2d\u5b58\u5728\u591a\u4e2a\u7528\u6237\u65f6\uff0c\u6743\u9650\u7ba1\u7406\u786e\u4fdd\u7528\u6237\u53ea\u8bbf\u95ee\u5df2\u88ab\u6388\u6743\u7684\u8d44\u6e90\uff0c\u8d4b\u4e88\u7528\u6237\u6700\u5c11\u6743\u9650\u539f\u5219\u53ef\u964d\u4f4e\u4f01\u4e1a\u4fe1\u606f\u5b89\u5168\u98ce\u9669\u3002 MatrixOne \u4e5f\u53ef\u4ee5\u901a\u8fc7\u6743\u9650\u7ba1\u7406\u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848\u3002\u5728 MatrixOne \u4e2d\uff0c\u6bcf\u4e2a\u79df\u6237\u5728\u96c6\u7fa4\u4e2d\u6240\u62e5\u6709\u7684\u6570\u636e\u6216\u8d44\u6e90\u88ab\u5b89\u5168\u7684\u9694\u79bb\uff0c\u8de8\u96c6\u7fa4\u5355\u4f4d\u7684\u7528\u6237\u4e0d\u53ef\u8bbf\u95ee\u5176\u4ed6\u96c6\u7fa4\u5355\u4f4d\u7684\u8d44\u6e90\uff0c\u5728\u8be5\u96c6\u7fa4\u4e2d\u88ab\u8d4b\u6743\u8bbf\u95ee\u8d44\u6e90\u7684\u7528\u6237\u624d\u6709\u6743\u8bbf\u95ee\u672c\u96c6\u7fa4\u5355\u4f4d\u5185\u7684\u8d44\u6e90\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#matrixone_1","title":"MatrixOne \u6743\u9650\u7ba1\u7406\u7279\u6027","text":"MatrixOne \u7684\u6743\u9650\u7ba1\u7406\u662f\u7ed3\u5408\u4e86\u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236 (RBAC\uff0cRole-based access control) \u548c\u81ea\u4e3b\u8bbf\u95ee\u63a7\u5236 (DAC\uff0cDiscretionary access control) \u4e24\u79cd\u5b89\u5168\u6a21\u578b\u8bbe\u8ba1\u548c\u5b9e\u73b0\u7684\uff0c\u8fd9\u4e24\u79cd\u5b89\u5168\u6a21\u578b\u662f\u4e2d\u7acb\u7684\u8bbf\u95ee\u63a7\u5236\u673a\u5236\uff0c\u4e3b\u8981\u56f4\u7ed5\u89d2\u8272\u548c\u6743\u9650\u6388\u6743\u7b56\u7565\u3002\u5b83\u65e2\u4fdd\u8bc1\u4e86\u6570\u636e\u8bbf\u95ee\u7684\u5b89\u5168\u6027\uff0c\u53c8\u7ed9\u6570\u636e\u5e93\u8fd0\u7ef4\u4eba\u5458\u63d0\u4f9b\u4e86\u7075\u6d3b\u4e14\u4fbf\u6377\u7684\u7ba1\u7406\u65b9\u6cd5\u3002
\u5728 MatrixOne \u4e2d\uff0c\u4e3a\u4e86\u65b9\u4fbf\u7ba1\u7406\u591a\u79cd\u64cd\u4f5c\u6743\u9650\uff0c\u4e8e\u662f\u4fbf\u628a\u6743\u9650\u5c01\u88c5\u5728\u4e00\u4e2a\u5b9e\u4f53\u5185\uff0c\u8fd9\u4e2a\u5b9e\u4f53\u5c31\u662f\u5bf9\u8c61\u3002
\u4f8b\u5982\uff0cSelect
\uff0cInsert
\uff0cUpdate
\u7b49\u64cd\u4f5c\u6743\u9650\uff0c\u4fbf\u5c01\u88c5\u5728\u4e86 Table \u5bf9\u8c61\u5185\u3002\u66f4\u591a\u5173\u4e8e\u5bf9\u8c61\u6743\u9650\u7684\u4fe1\u606f\u8bf7\u53c2\u8003 MatrixOne \u6743\u9650\u5206\u7c7b\u3002
\u5982\u4e0b\u56fe\u4e2d\u6240\u793a\uff0c\u4ece\u4e0a\u4e4b\u4e0b\uff0c\u9ad8\u5c42\u7ea7\u5bf9\u8c61\u53ef\u4ee5\u521b\u5efa\uff08\u6216\u5220\u9664\uff09\u4f4e\u5c42\u7ea7\u5bf9\u8c61\u3002
\u4e0a\u56fe\u4e2d\u7684\u5c42\u7ea7\u5173\u7cfb\u5747\u4e3a 1\uff1an \u7684\u5173\u7cfb\uff0c\u5373\uff0c\u4e00\u4e2a\u96c6\u7fa4\u4e2d\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u79df\u6237\uff08Account\uff09\uff0c\u4e00\u4e2a\u79df\u6237\u4e0b\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u7528\u6237\u548c\u89d2\u8272\uff0c\u4e00\u4e2a\u6570\u636e\u5e93\u4e2d\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u8868\u548c\u89c6\u56fe\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5c3d\u7ba1\u6bcf\u4e2a\u5bf9\u8c61\u4e2d\u7684\u64cd\u4f5c\u6743\u9650\u662f\u76f8\u4e92\u72ec\u7acb\u7684\uff08\u4f8b\u5982 Database \u5bf9\u8c61\u4e2d\u7684 SHOW TABLES
\u6743\u9650\u548c Table \u5bf9\u8c61\u4e2d\u7684 SELECT
\u6743\u9650\u5e76\u6ca1\u6709\u76f4\u63a5\u5173\u7cfb\uff09\uff0c\u4f46\u5bf9\u8c61\u4e4b\u95f4\u7684\u521b\u5efa\u4ecd\u5177\u6709\u4e00\u5b9a\u5173\u8054\uff0c\u4f8b\u5982 Database \u5bf9\u8c61\u4e2d\u7684 CREAT TABLE
\u6743\u9650\u53ef\u4ee5\u521b\u5efa Table \u5bf9\u8c61\uff0c\u8fd9\u4fbf\u5f62\u6210\u4e86\u5bf9\u8c61\u4e4b\u95f4\u7684\u5c42\u7ea7\u5173\u7cfb\uff0c
\u90a3\u4e48\uff0c\u7531\u4e8e\u9ad8\u5c42\u7ea7\u5bf9\u8c61\u53ef\u4ee5\u521b\u5efa\u4f4e\u5c42\u7ea7\u5bf9\u8c61\uff0c\u90a3\u4e48\u8f83\u9ad8\u5c42\u7ea7\u7684\u5bf9\u8c61\u5c31\u662f\u5bf9\u8c61\u7684\u521b\u5efa\u8005 (Owner)\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#owner","title":"\u5bf9\u8c61\u7684\u521b\u5efa\u8005\uff08Owner\uff09","text":"\u5f53\u4e00\u4e2a\u5bf9\u8c61\u88ab\u521b\u5efa\u540e\uff0c\u521b\u5efa\u8005\u4fbf\u662f\u8fd9\u4e2a\u5bf9\u8c61\u7684 Owner\uff0c\u5b83\u5177\u6709\u7ba1\u7406\u8fd9\u4e2a\u5bf9\u8c61\u7684\u6700\u9ad8\u6743\u9650\uff08\u5373 Ownership \u6743\u9650\uff0c\u5b83\u662f\u5bf9\u8c61\u5185\u6240\u5c01\u88c5\u7684\u6240\u6709\u6743\u9650\uff09\uff0c\u90a3\u4e48 Owner \u7684\u64cd\u4f5c\u6743\u9650\u96c6\u5408\u4e86\u8be5\u5bf9\u8c61\u7684\u6240\u6709\u64cd\u4f5c\u6743\u9650\u3002
\u4f8b\u5982 Table \u5bf9\u8c61\u6709 Select
\uff0cInsert
\uff0cUpdate
\uff0cDelete
\uff0cTruncate
\uff0cOwnership
\u6743\u9650\uff0c\u5982\u679c\u4e00\u4e2a\u89d2\u8272\u62e5\u6709\u4e86\u67d0\u4e2a Table \u7684 Ownership \u6743\u9650\uff0c\u90a3\u4e48\u8be5\u89d2\u8272\u7b49\u540c\u4e8e\u62e5\u6709\u4e86 Select
\uff0cInsert
\uff0cUpdate
\uff0cDelete
\uff0cTruncate
\u6743\u9650\u3002
\u7531\u4e8e\u6743\u9650\u3001\u89d2\u8272\u548c\u7528\u6237\u4e4b\u95f4\u7684\u4f20\u9012\u6027\uff0c\u4f60\u53ef\u4ee5\u628a\u5bf9\u8c61\u7684\u521b\u5efa\u8005\uff08\u4ee5\u4e0b\u79f0\u4e3a\u5bf9\u8c61 Owner\uff09\u7406\u89e3\u4e3a\u4e00\u4e2a\u89d2\u8272\u3002
\u5982\u4f55\u7406\u89e3\u5bf9\u8c61\u7684\u521b\u5efa\u8005\u662f\u4e00\u4e2a\u89d2\u8272\u5462\uff1f
\u4e00\u4e2a\u7528\u6237\u53ef\u4ee5\u540c\u65f6\u62e5\u6709\u591a\u4e2a\u89d2\u8272\uff0c\u6bd4\u5982 User A \u62e5\u6709 Role 1 \u548c Role 2\uff0c\u8fd8\u6709 Role 3 \u8fd9\u4e09\u4e2a\u89d2\u8272\uff0c\u6bcf\u4e2a\u89d2\u8272\u62e5\u6709\u7684\u6743\u9650\u4e0d\u540c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u7406\u89e3\u8fd9\u4e00\u884c\u4e3a\uff1a
\u5047\u5982 User A \u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u89d2\u8272\u4e3a Role 1\uff0cUser A \u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7528\u6237 New user B\uff0c\u53ef\u662f\u5f53\u524d Role 1 \u8fd9\u4e2a\u89d2\u8272\u6ca1\u6709\u521b\u5efa\u65b0\u7528\u6237\u7684\u6743\u9650\uff0cRole 2 \u62e5\u6709\u521b\u5efa\u65b0\u7528\u6237\u7684\u6743\u9650\uff0c\u90a3\u4e48 User A \u9700\u8981\u5207\u6362\u5230 Role 2 \u8fd9\u4e2a\u89d2\u8272\uff0c\u7136\u540e\u518d\u521b\u5efa\u65b0\u7684\u7528\u6237\u3002\u90a3\u4e48\uff0cNew user B \u7684 Owner \u662f Role 2\uff0c\u5176\u4ed6\u89d2\u8272 Role 1 \u548c Role 3 \u5e76\u4e0d\u80fd\u62e5\u6709 New user B \u7684\u6240\u6709\u6743\u3002
\u5bf9\u8c61\u7684 Owner \u8981\u70b9
\u5bf9\u8c61\u7684 Owner \u662f\u4e00\u4e2a\u89d2\u8272\uff0c\u5bf9\u8c61\u6700\u521d\u7684 Owner \u662f\u521b\u5efa\u5b83\u7684\u89d2\u8272\u3002
\u4e00\u4e2a\u5bf9\u8c61\u7684 Owner \u5728\u4efb\u610f\u65f6\u523b\u6709\u4e14\u53ea\u6709\u4e00\u4e2a\u3002
\u4e00\u4e2a\u89d2\u8272\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u5bf9\u8c61\uff0c\u56e0\u6b64\u4e00\u4e2a\u89d2\u8272\u53ef\u4ee5\u662f\u591a\u4e2a\u5bf9\u8c61\u7684 Owner\u3002
\u89d2\u8272\u672c\u8eab\u4e5f\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u56e0\u6b64\u89d2\u8272\u4e5f\u6709 Owner\u3002
\u5f53\u5bf9\u8c61\u7684 Owner \u88ab\u5220\u9664\u65f6\uff0c\u8be5\u5bf9\u8c61\u7684 Owner \u4f1a\u81ea\u52a8\u53d8\u66f4\u4e3a\u88ab\u5220\u9664\u89d2\u8272\u7684 Owner\u3002
Owner \u53ef\u4ee5\u8f6c\u79fb\u7ed9\u53e6\u4e00\u4e2a\u89d2\u8272\u3002
Note: ACCOUNTADMIN (\u79df\u6237\u7ba1\u7406\u5458\u89d2\u8272\uff0c\u79df\u6237\u88ab\u521b\u5efa\u540e\u5373\u81ea\u52a8\u751f\u6210) \u867d\u7136\u4e0d\u662f\u79df\u6237\u5185\u6240\u7528\u5bf9\u8c61\u7684 Owner\uff0c\u4f46\u5b83\u62e5\u6709\u6240\u6709\u5bf9\u8c61\u7684 Ownership \u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_5","title":"\u96c6\u7fa4","text":"\u96c6\u7fa4\u662f MatrixOne \u6743\u9650\u7ba1\u7406\u4e2d\u6700\u9ad8\u5c42\u7ea7\u7684\u5bf9\u8c61\uff0c\u5f53\u90e8\u7f72\u5b8c MatrixOne \u540e\u4fbf\u521b\u5efa\u4e86\u96c6\u7fa4\u8fd9\u4e2a\u5bf9\u8c61\u3002
Tip: \u5bf9\u96c6\u7fa4\u5bf9\u8c61\u7684\u64cd\u4f5c\u6743\u9650\u7684\u96c6\u5408\u88ab\u79f0\u4e3a\u7cfb\u7edf\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_6","title":"\u79df\u6237","text":"MatrixOne \u96c6\u7fa4\u5185\u53ef\u4ee5\u521b\u5efa\u548c\u7ba1\u7406\u591a\u4e2a\u6570\u636e\u548c\u7528\u6237\u6743\u9650\u4f53\u7cfb\u5b8c\u5168\u9694\u79bb\u7684\u79df\u6237\uff0c\u5e76\u5bf9\u8fd9\u4e9b\u8d44\u6e90\u9694\u79bb\u7684\u79df\u6237\u8fdb\u884c\u7ba1\u7406\uff0c\u8fd9\u79cd\u591a\u79df\u6237\u529f\u80fd\u65e2\u8282\u7701\u4e86\u90e8\u7f72\u548c\u8fd0\u7ef4\u591a\u5957\u6570\u636e\u4e1a\u52a1\u7cfb\u7edf\u7684\u6210\u672c\uff0c\u53c8\u80fd\u5229\u7528\u79df\u6237\u95f4\u7684\u786c\u4ef6\u8d44\u6e90\u5171\u4eab\u6700\u5927\u9650\u5ea6\u7684\u8282\u7ea6\u673a\u5668\u6210\u672c\u3002
\u5728 MatrixOne \u4e2d\u5c06\u79df\u6237\u79f0\u4e3a Account\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_7","title":"\u7cfb\u7edf\u79df\u6237","text":"\u4e3a\u4e86\u517c\u5bb9\u4f20\u7edf\u975e\u591a\u79df\u6237\u6570\u636e\u5e93\u7684\u4f7f\u7528\u4e60\u60ef\uff0cMatrixOne \u5728\u96c6\u7fa4\u521b\u5efa\u5b8c\u6210\u540e\u4f1a\u81ea\u52a8\u65b0\u5efa\u4e00\u4e2a\u7cfb\u7edf\u9ed8\u8ba4\u79df\u6237\uff0c\u4e5f\u5c31\u662f\u7cfb\u7edf\u79df\u6237\uff0c\u5373 Sys Account\uff0c\u5982\u679c\u4f60\u73b0\u5728\u53ea\u6709\u4e00\u5957\u6570\u636e\u4e1a\u52a1\u7cfb\u7edf\u9700\u8981 MatrixOne \u7ba1\u7406\uff0c\u4fbf\u4e0d\u9700\u8981\u521b\u5efa\u66f4\u591a\u7684\u79df\u6237\uff0c\u76f4\u63a5\u767b\u5f55\u5e76\u8bbf\u95ee\u7cfb\u7edf\u79df\u6237 (Sys Account) \u5373\u53ef\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_8","title":"\u89d2\u8272","text":"\u89d2\u8272\u4e5f\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5b83\u662f MatrixOne \u4e2d\u7528\u6765\u7ba1\u7406\u548c\u5206\u914d\u6743\u9650\u7684\u5bf9\u8c61\u3002
\u5728\u79df\u6237\u4e2d\uff0c\u7528\u6237\u5982\u679c\u6ca1\u6709\u88ab\u8d4b\u4e88\u89d2\u8272\uff0c\u90a3\u4e48\u7528\u6237\u5c31\u4e0d\u80fd\u505a\u4efb\u4f55\u64cd\u4f5c\u3002\u9996\u5148\uff0c\u9700\u8981\u5148\u6709\u4e00\u4e2a\u9ad8\u6743\u9650\u7684\u8d26\u53f7\u5148\u505a\u4e00\u4e9b\u521d\u671f\u7684\u8d44\u6e90\u5206\u914d\uff0c\u6bd4\u5982\u8bf4\uff0c\u7531\u7cfb\u7edf\u79df\u6237\u6216\u8005\u79df\u6237\u521b\u5efa\u4e00\u4e9b\u89d2\u8272\u548c\u7528\u6237\uff0c\u5c06\u5bf9\u8c61\u6743\u9650\u6388\u4e88\u7ed9\u89d2\u8272\uff0c\u518d\u5c06\u89d2\u8272\u8d4b\u4e88\u7ed9\u7528\u6237\uff0c\u8fd9\u4e2a\u65f6\u5019\uff0c\u7528\u6237\u5c31\u53ef\u4ee5\u5bf9\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c\u4e86\u3002
\u8bbe\u7acb\u89d2\u8272\uff0c\u662f\u4e3a\u4e86\u8282\u7701\u76f8\u540c\u6743\u9650\u6388\u4e88\u7684\u64cd\u4f5c\u6210\u672c\u3002p1\uff0cp2\uff0cp3 \u8fd9\u4e09\u4e2a\u6743\u9650\u90fd\u9700\u8981\u88ab\u6388\u4e88\u7ed9\u7528\u6237 u1\uff0cu2\uff0cu3\uff0c\u4f60\u53ea\u9700\u8981\u5148\u5c06 p1\uff0cp2\uff0cp3 \u6388\u4e88\u89d2\u8272 r1\uff0c\u518d\u5c06\u89d2\u8272 r1 \u4e00\u6b21\u6027\u6388\u4e88\u7528\u6237 u1\uff0cu2\uff0cu3\uff0c\u76f8\u6bd4\u628a\u6bcf\u4e2a\u6743\u9650\u90fd\u5206\u522b\u6388\u4e88\u6bcf\u4e2a\u7528\u6237\u6765\u8bf4\uff0c\u64cd\u4f5c\u4e0a\u66f4\u4e3a\u7b80\u5355\uff0c\u5e76\u4e14\u968f\u7740\u7528\u6237\u548c\u6743\u9650\u6570\u76ee\u7684\u589e\u52a0\uff0c\u8fd9\u4e00\u4f18\u52bf\u4f1a\u8d8a\u53d1\u660e\u663e\u3002\u540c\u65f6\uff0c\u89d2\u8272\u7684\u51fa\u73b0\u8fdb\u4e00\u6b65\u62bd\u8c61\u4e86\u6743\u9650\u96c6\u5408\u53ca\u5176\u5173\u7cfb\uff0c\u5bf9\u4e8e\u540e\u671f\u7684\u6743\u9650\u7ef4\u62a4\u4e5f\u5341\u5206\u65b9\u4fbf\u3002
MatrixOne \u5728\u96c6\u7fa4\u548c\u79df\u6237 (Account) \u521b\u5efa\u540e\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e9b\u9ed8\u8ba4\u89d2\u8272\u548c\u7528\u6237\uff08\u8be6\u89c1\u4e0b\u9762\u7684\u521d\u59cb\u5316\u8bbf\u95ee\u7ae0\u8282\uff09\uff0c\u8fd9\u4e9b\u89d2\u8272\u5177\u6709\u6700\u9ad8\u7ba1\u7406\u6743\u9650\uff0c\u7528\u4e8e\u5728\u6700\u5f00\u59cb\u7ba1\u7406\u96c6\u7fa4\u548c\u79df\u6237 (Account)\uff0c\u6211\u4eec\u4e0d\u5efa\u8bae\u60a8\u5c06\u8fd9\u4e9b\u89d2\u8272\u6388\u4e88\u65e5\u5e38\u6267\u884c SQL \u7684\u7528\u6237\uff0c\u6743\u9650\u8fc7\u9ad8\u4f1a\u5f15\u5165\u66f4\u591a\u7684\u5b89\u5168\u95ee\u9898\uff0c\u56e0\u6b64\uff0cMatrixOne \u652f\u6301\u521b\u5efa\u81ea\u5b9a\u4e49\u89d2\u8272\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u7528\u6237\u7684\u4e1a\u52a1\u9700\u8981\u81ea\u5b9a\u4e49\u89d2\u8272\uff0c\u518d\u5c06\u9002\u5408\u7684\u6743\u9650\u8d4b\u4e88\u8fd9\u4e9b\u89d2\u8272\u3002
\u89d2\u8272\u8981\u70b9
\u5728 MatrixOne \u4e2d\uff0c\u89d2\u8272\u7684\u884c\u4e3a\u7ec6\u8282\u5982\u4e0b\uff1a
\u4e00\u4e2a\u89d2\u8272\u53ef\u4ee5\u5c06\u5176\u6743\u9650\u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u89d2\u8272\u3002
\u5c06\u67d0\u4e00\u89d2\u8272\u7684\u5168\u90e8\u6743\u9650\u7ed9\u53e6\u4e00\u4e2a\u89d2\u8272\u4f7f\u7528\uff0c\u4f8b\u5982\u5c06 role1 \u7684\u6240\u6709\u6743\u9650\u4f20\u9012\u7ed9 role2 \u4f7f\u7528\uff0c\u90a3\u4e48 role2 \u7ee7\u627f\u4e86 role1 \u7684\u6743\u9650\u3002
\u89d2\u8272\u548c\u7528\u6237\u4ec5\u5728\u5404\u81ea\u7684\u79df\u6237 (Account) \u5185\u751f\u6548\uff0c\u5305\u62ec\u7cfb\u7edf\u79df\u6237 (Sys Account)\u3002
Note
\u4e00\u4e2a\u7528\u6237\u88ab\u6388\u4e88\u591a\u4e2a\u89d2\u8272\uff0c\u7528\u4e8e\u6267\u884c\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u4e1a\u52a1\u3002
\u4e3b\u8981\u89d2\u8272\uff1a\u7528\u6237\u5728\u67d0\u4e00\u65f6\u523b\u53ea\u80fd\u4f7f\u7528\u5176\u4e2d\u4e00\u4e2a\u89d2\u8272\uff0c\u6211\u4eec\u79f0\u5f53\u524d\u6240\u4f7f\u7528\u7684\u8fd9\u4e2a\u89d2\u8272\u4e3a\u4e3b\u8981\u89d2\u8272\u3002 \u6b21\u8981\u89d2\u8272\uff1a\u9664\u4e86\u4e3b\u8981\u89d2\u8272\u4e4b\u5916\u8be5\u7528\u6237\u6240\u62e5\u6709\u7684\u5176\u4ed6\u89d2\u8272\u96c6\u5408\u79f0\u4e3a\u6b21\u8981\u89d2\u8272\u3002
\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u7528\u6237\u60f3\u53bb\u6267\u884c\u53e6\u4e00\u4e2a\u89d2\u8272\u6743\u9650\u7684 SQL \u65f6\uff0c\u9700\u8981\u5148\u5207\u6362\u89d2\u8272\uff08\u5373 set role <role>
\uff09\u3002\u6b64\u5916\uff0c\u4e3a\u4e86\u517c\u5bb9\u7ecf\u5178\u6570\u636e\u5e93\u7684\u6743\u9650\u884c\u4e3a\uff0cMatrixOne \u8fd8\u652f\u6301\u5f00\u542f\u4f7f\u7528\u6b21\u8981\u89d2\u8272\u7684\u529f\u80fd\uff1a\u4f7f\u7528 set secondary role all
\uff0c\u6267\u884c\u8fd9\u6761 SQL \u540e\uff0c\u8be5\u7528\u6237\u4fbf\u53ef\u540c\u65f6\u62e5\u6709\u4ed6\u6240\u6709\u89d2\u8272\u7684\u6743\u9650\u4e86\uff0c\u6267\u884c set secondary role none
\u5373\u53ef\u5173\u95ed\u6b64\u529f\u80fd\u3002
A \u516c\u53f8\u8d2d\u4e70\u4e86 MatrixOne \u96c6\u7fa4\uff0c\u5e76\u4e14\u5b8c\u6210\u4e86\u90e8\u7f72\u3002\u7531\u4e8e A \u516c\u53f8\u89c4\u6a21\u6bd4\u8f83\u5927\uff0c\u4e1a\u52a1\u7ebf\u591a\u4e14\u590d\u6742\uff0c\u6570\u636e\u91cf\u4e5f\u975e\u5e38\u5e9e\u5927\uff0c\u60f3\u8981\u9488\u5bf9\u67d0\u4e2a\u4e1a\u52a1\u7ebf\u5f00\u53d1\u4e00\u6b3e\u5e94\u7528\u7a0b\u5e8f\uff0c\u5047\u8bbe\u547d\u540d\u4e3a BusinessApp\uff0c\u4f46\u662f\u9700\u8981\u8ddf\u5176\u4ed6\u4e1a\u52a1\u7ebf\u7684\u6570\u636e\u8fdb\u884c\u9694\u79bb\uff0c\u90a3\u4e48 MatrxiOne \u600e\u4e48\u9694\u79bb\u51fa\u8fd9\u4e9b\u6570\u636e\u8d44\u6e90\u3001\u6743\u9650\u8d44\u6e90\u5462\uff1f
\u5b8c\u6210\u90e8\u7f72 MatrixOne \u96c6\u7fa4\uff0c\u7814\u53d1\u90e8\u95e8\u7684 Tom \u83b7\u53d6\u5230\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u516c\u53f8\u6307\u6d3e\u4ed6\u6765\u5b8c\u6210\u8d44\u6e90\u9694\u79bb\u8fd9\u4e00\u4efb\u52a1\u3002Tom \u9700\u8981\u8fd9\u4e48\u505a\uff1a
Tom \u9700\u8981\u5148\u521b\u5efa\u4e24\u4e2a\u79df\u6237\uff0c\u79df\u6237\u8d26\u53f7\u4e00\u4e2a\u662f BusinessAccount\uff0c\u4e00\u4e2a\u662f ElseAccount\u3002
\u5173\u4e8e\u8d44\u6e90\u9694\u79bb\u7684\u5177\u4f53\u5b9e\u64cd\uff0c\u53ef\u4ee5\u53c2\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u9a8c\u8bc1\u8d44\u6e90\u9694\u79bb\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_12","title":"\u7528\u6237\u521b\u5efa\u548c\u6388\u6743\u573a\u666f\u4ecb\u7ecd","text":"\u8fd8\u662f\u6cbf\u7528\u4e0a\u9762\u7684\u573a\u666f\u793a\u4f8b\uff0cTom \u628a BusinessAccount \u8fd9\u4e2a\u79df\u6237\u8d26\u53f7\u7ed9\u4e86\u516c\u53f8\u7684\u6570\u636e\u7ba1\u7406\u5458 Robert\uff0c\u8ba9 Robert \u53bb\u5206\u914d\u65b0\u7684\u7528\u6237\u8d26\u53f7\u548c\u6743\u9650\u7ed9\u5176\u4ed6\u7814\u53d1\u540c\u4e8b\u3002
\u7814\u53d1\u540c\u4e8b Joe \u662f\u8fd9\u4e2a A \u516c\u53f8\u9879\u76ee BusinessApp \u7684\u5e94\u7528\u5f00\u53d1\u8005\uff0cJoe \u6709\u4e00\u4e2a\u5f00\u53d1\u4efb\u52a1\uff0cJoe \u9700\u8981\u4f7f\u7528\u6570\u636e\u5e93\u5185\u6240\u6709\u7684\u6570\u636e\u3002\u90a3\u4e48 Robert \u5c31\u8981\u5e2e Joe \u5f00\u901a\u8d26\u53f7\uff0c\u7ed9 Joe \u6388\u6743\uff1a
\u5173\u4e8e\u7528\u6237\u521b\u5efa\u548c\u6388\u6743\u7684\u5177\u4f53\u5b9e\u64cd\uff0c\u53ef\u4ee5\u53c2\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u521b\u5efa\u65b0\u79df\u6237\uff0c\u5e76\u7531\u65b0\u79df\u6237\u521b\u5efa\u7528\u6237\u3001\u521b\u5efa\u89d2\u8272\u548c\u6388\u6743\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_13","title":"\u521d\u59cb\u5316\u8bbf\u95ee","text":"\u521d\u59cb\u5316\u96c6\u7fa4\u6216\u8d26\u6237\u540e\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e9b\u9ed8\u8ba4\u7528\u6237\u548c\u9ed8\u8ba4\u89d2\u8272\uff1a
\u7528\u6237\u540d \u89e3\u91ca \u6240\u62e5\u6709\u7684\u89d2\u8272 \u6240\u62e5\u6709\u7684\u6743\u9650 \u63cf\u8ff0 root \u96c6\u7fa4\u7ba1\u7406\u5458 MOADMIN \u521b\u5efa\u3001\u7f16\u8f91\u3001\u5220\u9664\u79df\u6237 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 root \u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458 MOADMIN \u7ba1\u7406\u7cfb\u7edf\u79df\u6237\u4e0b\u7684\u6240\u6709\u8d44\u6e90\uff0c\u5305\u542b\u7528\u6237\u3001\u89d2\u8272\u3001\u6570\u636e\u5e93/\u8868/\u89c6\u56fe\uff0c\u6388\u6743\u7ba1\u7406 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 <\u81ea\u5b9a\u4e49> \u79df\u6237\u7ba1\u7406\u5458 ACCOUNTADMIN \u7ba1\u7406\u666e\u901a\u79df\u6237\u4e0b\u7684\u6240\u6709\u8d44\u6e90\uff0c\u5305\u542b\u7528\u6237\u3001\u89d2\u8272\u3001\u6570\u636e\u5e93/\u8868/\u89c6\u56fe\uff0c\u6388\u6743\u7ba1\u7406 \u79df\u6237\u88ab\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 \u6240\u6709\u7528\u6237 \u666e\u901a\u7528\u6237 PUBLIC \u8fde\u63a5 MatrixOne \u6240\u6709\u7528\u6237\u88ab\u521b\u5efa\u540e\uff0c\u81ea\u52a8\u88ab\u6388\u4e88 PUBLIC \u89d2\u8272"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_14","title":"\u9a6c\u4e0a\u5f00\u59cb","text":"\u5982\u679c\u4f60\u6240\u5728\u7684\u4f01\u4e1a\u90e8\u7f72\u4e86 MatrixOne \u96c6\u7fa4\uff0c\u90a3\u4e48\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u96c6\u7fa4\u521d\u59cb\u5316\u65f6\u5373\u81ea\u52a8\u5b58\u5728\u4e00\u4e2a\u96c6\u7fa4\u7ba1\u7406\u5458\u8d26\u6237\uff0c\u4f60\u53ef\u4ee5\u8054\u7cfb MatrxiOne \u7684\u9879\u76ee\u7ecf\u7406\u6216\u9500\u552e\u4ee3\u8868\u83b7\u53d6\u8d26\u53f7\u4fe1\u606f\u548c\u521d\u59cb\u5bc6\u7801\u3002\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u4f60\u53ef\u4ee5\u65b0\u5efa\u79df\u6237\uff0c\u7ba1\u7406\u79df\u6237\u751f\u547d\u5468\u671f\uff0c\u5e76\u5c06\u79df\u6237\u8d26\u53f7\u5bc6\u7801\u5206\u914d\u7ed9\u4f60\u6240\u5728\u4f01\u4e1a\u5bf9\u5e94\u7684\u8d1f\u8d23\u4eba\u3002\u7ba1\u7406\u79df\u6237\u7684\u64cd\u4f5c\u8bf4\u660e\uff0c\u8be6\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u521b\u5efa\u79df\u6237\uff0c\u9a8c\u8bc1\u8d44\u6e90\u9694\u79bb\u6216\u6743\u9650\u7ba1\u7406\u64cd\u4f5c\u6307\u5357\u3002
\u5982\u679c\u4f60\u6240\u5728\u7684\u4f01\u4e1a\u4ec5\u9700\u4f7f\u7528 MatrixOne \u96c6\u7fa4\u79df\u6237\u8d44\u6e90\uff0c\u5b8c\u6210\u90e8\u7f72\u540e\uff0cMatrixOne \u96c6\u7fa4\u7ba1\u7406\u5458\u4f1a\u5e2e\u4f60\u5f00\u901a\u79df\u6237\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u4f60\u53ef\u4ee5\u8054\u7cfb MatrxiOne \u7684\u9879\u76ee\u7ecf\u7406\u6216\u9500\u552e\u4ee3\u8868\u83b7\u53d6\u8d26\u53f7\u4fe1\u606f\u548c\u521d\u59cb\u5bc6\u7801\u3002\u4f7f\u7528\u79df\u6237\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u4f60\u53ef\u4ee5\u65b0\u5efa\u7528\u6237\uff0c\u7ba1\u7406\u7528\u6237\u751f\u547d\u5468\u671f\u3001\u79df\u6237\u5185\u7684\u8d44\u6e90\uff08\u7528\u6237\u3001\u89d2\u8272\u548c\u6743\u9650\uff09\uff0c\u5e76\u5c06\u7528\u6237\u8d26\u53f7\u5bc6\u7801\u5206\u914d\u7ed9\u4f60\u6240\u5728\u4f01\u4e1a\u5bf9\u5e94\u7684\u8d1f\u8d23\u4eba\u3002\u7ba1\u7406\u7528\u6237\u7684\u64cd\u4f5c\u8bf4\u660e\uff0c\u8be6\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u521b\u5efa\u7528\u6237\u3001\u521b\u5efa\u89d2\u8272\u548c\u6388\u6743\u6216\u6743\u9650\u7ba1\u7406\u64cd\u4f5c\u6307\u5357\u3002
\u5728\u5b9e\u9645\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u8bbe\u7acb\u4e00\u4e2a\u6570\u636e\u7ba1\u7406\u5458\u7684\u5c97\u4f4d\uff0c\u4ed6\u8d1f\u8d23\u7ba1\u7406\u6574\u4e2a\u6570\u636e\u5e93\u4e2d\u8d44\u6e90\u5206\u914d\u7684\u60c5\u51b5\uff0c\u6bd4\u5982\u8bf4\uff0c\u516c\u53f8\u5176\u4ed6\u6210\u5458\u9700\u8981\u88ab\u5206\u914d\u4e00\u4e2a\u7528\u6237\u8d26\u53f7\u548c\u5bc6\u7801\uff0c\u88ab\u5206\u914d\u89d2\u8272\uff0c\u5e76\u88ab\u6388\u4e88\u6700\u4f4e\u7684\u4f7f\u7528\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#_5","title":"\u524d\u63d0\u6761\u4ef6","text":"\u4f60\u9996\u5148\u9700\u8981\u62e5\u6709\u79df\u6237\u7ba1\u7406\u5458\u7684\u8d26\u53f7
\u5df2\u7ecf\u8fde\u63a5\u4e0a MatrixOne \u96c6\u7fa4
\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u7ba1\u7406\u5458\u7684\u89d2\u8272\uff0c\u6388\u4e88\u4ed6\u79df\u6237\u5185\u7684\u5168\u5c40\u7ba1\u7406\u7684\u6743\u9650\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u505a\u5230\u5982\u4e0b\u51e0\u70b9\uff1a
\u4f7f\u7528\u4f60\u6240\u62e5\u6709\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7\u767b\u5f55\u79df\u6237\uff1a
Note: \u6b64\u5904\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7 account1 \u4e3a\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u5728\u521b\u5efa\u79df\u6237\u7ba1\u7406\u5458\u65f6\u8fdb\u884c\u81ea\u5b9a\u4e49\u3002
mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u8d26\u53f7\uff0c\u547d\u540d\u4e3a dbauser\uff0c\u5bc6\u7801\u4e3a 123456\uff1a
create user dbauser identified by \"123456\";\n
\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u7ba1\u7406\u5458\u7684\u89d2\u8272\uff0c\u547d\u540d\u4e3a dba\uff1a
create role dba;\n
\u6388\u6743\u6743\u9650\u7ed9\u89d2\u8272\u5982\u4e0b\u6743\u9650\uff1a
grant all on account * to dba with grant option;\ngrant all on database * to dba with grant option;\ngrant all on table *.* to dba with grant option;\n
\u6388\u6743\u89d2\u8272 dba \u7ed9\u7528\u6237 dbauser\uff1a
grant dba to dbauser;\n
\u67e5\u770b\u6743\u9650\u6388\u4e88\u60c5\u51b5\uff1a
show grants for dbauser@localhost;\n
\u4f7f\u7528\u6570\u636e\u7ba1\u7406\u5458\u8d26\u53f7 dbauser \u767b\u5f55 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -u account1:dbauser:dba -p\n
\u67e5\u770b dbauser \u6240\u62e5\u6709\u7684\u6743\u9650\uff1a
show grants for dbauser@localhost;\n
\u67e5\u770b dbauser \u7684\u89d2\u8272\uff1a
SET SECONDARY ROLE ALL;\nuse mo_catalog;\nselect mu.user_name,mr.role_name from mo_role mr,mo_user mu,mo_user_grant mug where mu.user_id=mug.user_id and mr.role_id=mug.role_id and mu.user_name='dbauser';\n
\u5b9e\u9645\u64cd\u4f5c\u4e00\u4e2a\u6570\u636e\u5e93\u8fdb\u884c\u9a8c\u8bc1\uff1a
drop database if exists test;\ncreate database test;\nuse test;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\n
\u4e0a\u9762\u4ee3\u7801\u8868\u793a\u9a8c\u8bc1\u6210\u529f\u3002
\u5e94\u7528\u7cfb\u7edf\u4e0a\u7ebf\u65f6\uff0c\u4f1a\u6839\u636e\u5e94\u7528\u7cfb\u7edf\u7684\u4f7f\u7528\u9700\u6c42\uff0c\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u4e0e\u5bf9\u5e94\u6570\u636e\u5e93\u7528\u6237\uff0c\u5e76\u4e14\u6388\u4e88\u8fd9\u4e2a\u7528\u6237\u62e5\u6709\u76ee\u6807\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#_12","title":"\u524d\u63d0\u6761\u4ef6","text":"\u9700\u6c42 1\uff1a\u5e94\u7528\u7cfb\u7edf\u9700\u8981\u4e00\u5957\u65b0\u7684\u6570\u636e\u5e93\u4e13\u95e8\u5e94\u7528\u4e8e\u5e94\u7528\u7684\u5f00\u53d1\u3002
\u9700\u6c42 2\uff1a\u8be5\u5e94\u7528\u7cfb\u7edf\u9700\u8981\u4e13\u95e8\u7684\u89d2\u8272\u3002
\u9700\u6c42 3\uff1a\u8be5\u5e94\u7528\u7cfb\u7edf\u9700\u8981\u4e13\u95e8\u7684\u8d1f\u8d23\u4eba\u7ba1\u7406\u8fd9\u4e2a\u6570\u636e\u5e93\u3002
\u4f7f\u7528\u4f60\u6240\u62e5\u6709\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7\u767b\u5f55\u79df\u6237\uff1a
Note: \u6b64\u5904\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7 account1 \u4e3a\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u5728\u521b\u5efa\u79df\u6237\u7ba1\u7406\u5458\u65f6\u8fdb\u884c\u81ea\u5b9a\u4e49\u3002
mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
\u521b\u5efa\u5e94\u7528\u6240\u9700\u8981\u7684\u6570\u636e\u5e93\uff0c\u7ed9\u6570\u636e\u5e93\u547d\u540d\u4e3a appdb\uff1a
create database appdb;\n
\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a approle \u7684\u89d2\u8272\uff0c\u5e76\u6388\u6743\u7ed9\u8fd9\u4e2a\u89d2\u8272\u5bf9\u4e8e\u6570\u636e\u5e93 appdb \u7684\u5168\u90e8\u64cd\u4f5c\u6743\u9650\uff1a
create role approle;\ngrant all on database appdb to approle;\ngrant all on table appdb.* to approle;\n
\u521b\u5efa\u6570\u636e\u5e93\u7528\u6237 appuser\uff0c\u5bc6\u7801\u4e3a 123456\uff0c\u5e76\u5c06\u89d2\u8272 approle \u5206\u914d\u7ed9 appuser\uff1a
create user appuser identified by \"123456\" default role approle;\n
\u4f7f\u7528\u6570\u636e\u5e93\u7528\u6237\u8d26\u53f7 appuser \u767b\u5f55 MatrixOne\uff1a
mysql -h127.0.0.1 -utest:appuser -P6001 -p123456\n
\u9a8c\u8bc1\u6570\u636e\u7528\u6237\u8d26\u53f7 appuser \u7684\u6743\u9650\uff1a
set secondary role all;\nuse appdb;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\ndrop table t1;\n
\u4e0a\u9762\u4ee3\u7801\u8868\u793a\u9a8c\u8bc1\u6210\u529f\u3002
\u4ee5\u4e0b\u662f MatrixOne \u4e2d\u7684\u5178\u578b\u89d2\u8272\u4ee5\u53ca\u5efa\u8bae\u7684\u6700\u4f4e\u6743\u9650\uff0c\u4f9b\u4f60\u8fdb\u884c\u53c2\u8003\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/#_2","title":"\u8d1f\u8d23\u6570\u636e\u5e93\u8d44\u6e90\uff08\u7528\u6237\u3001\u89d2\u8272\u3001\u6743\u9650\uff09\u7ba1\u7406\u7684\u5de5\u7a0b\u5e08","text":"\u6570\u636e\u5e93\u7ba1\u7406\u5458
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u7ba1\u7406\u79df\u6237\u5185\u7684\u6240\u6709\u914d\u7f6e\u4fe1\u606f\u3001\u7528\u6237\u6743\u9650\u3001\u5907\u4efd\u6062\u590d\u3001\u6027\u80fd\u8c03\u4f18\u3001\u6545\u969c\u6392\u67e5
\u6570\u636e\u8fd0\u7ef4\u5de5\u7a0b\u5e08
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u7ba1\u7406\u79df\u6237\u5185\u7684\u6240\u6709\u6570\u636e\u4e0e\u5143\u6570\u636e\u4fe1\u606f\uff0c\u4ee5\u53ca\u6570\u636e\u7684\u6743\u9650\u6388\u6743
\u53c2\u8003\u6388\u4e88\u6743\u9650\uff1a\u79df\u6237\u7ea7\u522b\u7684\u6570\u636e\u7ba1\u7406\uff08ALL ON ACCOUNT\uff09
\u5e94\u7528\u5f00\u53d1\u8005
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u5bf9\u5f00\u53d1\u73af\u5883\u79df\u6237\u4e0b\u7279\u5b9a\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c\uff0c\u5e76\u62e5\u6709\u7cfb\u7edf\u79df\u6237\u7684\u53ea\u8bfb\u6743\u9650
\u53c2\u8003\u6388\u4e88\u6743\u9650\uff1a\u6570\u636e\u5e93\u7ea7\u522b\u7684\u6570\u636e\u7ba1\u7406\uff08ALL ON DATABASE\uff09\u3001\u7cfb\u7edf\u6570\u636e\u5e93\u53ea\u8bfb\uff08SELECT ON DATABASE\uff09
\u5e94\u7528\u7cfb\u7edf\u7ba1\u7406\u5de5\u7a0b\u5e08
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u5bf9\u751f\u4ea7\u73af\u5883\u79df\u6237\u4e0b\u7279\u5b9a\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c
\u53c2\u8003\u6388\u4e88\u6743\u9650\uff1a\u6570\u636e\u5e93\u7ea7\u522b\u7684\u6570\u636e\u7ba1\u7406\uff08ALL ON DATABASE\uff09
\u7cfb\u7edf\u76d1\u63a7\u5de5\u7a0b\u5e08
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u76d1\u63a7\u79df\u6237\u4e0b\u6240\u6709\u7684\u7cfb\u7edf\u7edf\u8ba1\u4fe1\u606f\u4e0e\u9519\u8bef\u4fe1\u606f
SSB \u661f\u578b\u6a21\u5f0f\u57fa\u51c6\u6d4b\u8bd5\u662f OLAP \u6570\u636e\u5e93\u6027\u80fd\u6d4b\u8bd5\u7684\u5e38\u7528\u573a\u666f\uff0c\u901a\u8fc7\u672c\u7bc7\u6559\u7a0b\uff0c\u60a8\u53ef\u4ee5\u4e86\u89e3\u5230\u5982\u4f55\u5728 MatrixOne \u4e2d\u5b9e\u73b0 SSB \u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_1","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#1-dbgen","title":"1. \u7f16\u8bd1 dbgen","text":"git clone https://github.com/vadimtk/ssb-dbgen.git\n\u6216\u8005\ngit clone https://githubfast.com/vadimtk/ssb-dbgen.git\ncd ssb-dbgen\nmake\n
Note
\u5982\u679c\u4f60\u7684\u786c\u4ef6\u914d\u7f6e\u4e3a M1 \u82af\u7247\uff0c\u7f16\u8bd1 dbgen \u4ecd\u9700\u8fdb\u884c\u5176\u4ed6\u914d\u7f6e\uff0c\u53c2\u89c1\u90e8\u7f72\u5e38\u89c1\u95ee\u9898\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#2","title":"2. \u751f\u6210\u6570\u636e","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_2","title":"\u9009\u9879\u4e00\uff1a\u751f\u6210\u5355\u8868\u6570\u636e\u96c6","text":"\u5f53\u4f7f\u7528 -s 1
\u65f6 dbgen
\u547d\u4ee4\u4f1a\u751f\u4ea7\u8fd1 600 \u4e07\u884c\u6570\u636e (670MB)\uff0c\u5f53\u4f7f\u7528 -s 10
\u65f6\u4f1a\u751f\u4ea7\u8fd1 6000 \u4e07\u884c\u6570\u636e\uff0c\u4f1a\u8017\u8d39\u5927\u91cf\u65f6\u95f4\u3002
./dbgen -s 1 -T c\n./dbgen -s 1 -T l\n./dbgen -s 1 -T p\n./dbgen -s 1 -T s\n./dbgen -s 1 -T d\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_3","title":"\u9009\u9879\u4e8c\uff1a\u4e0b\u8f7d\u5927\u5bbd\u8868\u6570\u636e\u96c6","text":"\u6211\u4eec\u51c6\u5907\u4e86 1GB \u7684\u5927\u5bbd\u8868\u6570\u636e\u96c6\u4f9b\u4f60\u4e0b\u8f7d\u3002
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
create database if not exists ssb;\nuse ssb;\ndrop table if exists lineorder;\ndrop table if exists part;\ndrop table if exists supplier;\ndrop table if exists customer;\ndrop table if exists date;\ndrop table if exists lineorder_flat;\n\ncreate table lineorder (\n lo_orderkey bigint,\n lo_linenumber int,\n lo_custkey int,\n lo_partkey int,\n lo_suppkey int,\n lo_orderdate date,\n lo_orderpriority char (15),\n lo_shippriority tinyint,\n lo_quantity double,\n lo_extendedprice double,\n lo_ordtotalprice double,\n lo_discount double,\n lo_revenue double,\n lo_supplycost double,\n lo_tax double,\n lo_commitdate date,\n lo_shipmode char (10)\n) ;\n\ncreate table part (\n p_partkey int,\n p_name varchar (22),\n p_mfgr char (6),\n p_category char (7),\n p_brand char (9),\n p_color varchar (11),\n p_type varchar (25),\n p_size int,\n p_container char (10)\n) ;\n\ncreate table supplier (\n s_suppkey int,\n s_name char (25),\n s_address varchar (25),\n s_city char (10),\n s_nation char (15),\n s_region char (12),\n s_phone char (15)\n) ;\n\ncreate table customer (\n c_custkey int,\n c_name varchar (25),\n c_address varchar (25),\n c_city char (10),\n c_nation char (15),\n c_region char (12),\n c_phone char (15),\n c_mktsegment char (10)\n) ;\n\ncreate table date (\n d_datekey date,\n d_date char (18),\n d_dayofweek char (9),\n d_month char (9),\n d_year int,\n d_yearmonthnum int,\n d_yearmonth char (7),\n d_daynuminweek varchar(12),\n d_daynuminmonth int,\n d_daynuminyear int,\n d_monthnuminyear int,\n d_weeknuminyear int,\n d_sellingseason varchar (12),\n d_lastdayinweekfl varchar (1),\n d_lastdayinmonthfl varchar (1),\n d_holidayfl varchar (1),\n d_weekdayfl varchar (1)\n) ;\n\nCREATE TABLE lineorder_flat(\n LO_ORDERKEY bigint key,\n LO_LINENUMBER int,\n LO_CUSTKEY int,\n LO_PARTKEY int,\n LO_SUPPKEY int,\n LO_ORDERDATE date,\n LO_ORDERPRIORITY char(15),\n LO_SHIPPRIORITY tinyint,\n LO_QUANTITY double,\n LO_EXTENDEDPRICE double,\n LO_ORDTOTALPRICE double,\n LO_DISCOUNT double,\n LO_REVENUE int unsigned,\n LO_SUPPLYCOST int unsigned,\n LO_TAX double,\n LO_COMMITDATE date,\n LO_SHIPMODE char(10),\n C_NAME varchar(25),\n C_ADDRESS varchar(25),\n C_CITY char(10),\n C_NATION char(15),\n C_REGION char(12),\n C_PHONE char(15),\n C_MKTSEGMENT char(10),\n S_NAME char(25),\n S_ADDRESS varchar(25),\n S_CITY char(10),\n S_NATION char(15),\n S_REGION char(12),\n S_PHONE char(15),\n P_NAME varchar(22),\n P_MFGR char(6),\n P_CATEGORY char(7),\n P_BRAND char(9),\n P_COLOR varchar(11),\n P_TYPE varchar(25),\n P_SIZE int,\n P_CONTAINER char(10)\n);\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#4","title":"4. \u5bfc\u5165\u6570\u636e","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_4","title":"\u9009\u9879\u4e00\uff1a\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5bfc\u5165\u5355\u8868\u6570\u636e\u96c6","text":"load data infile '/ssb-dbgen-path/supplier.tbl' into table supplier FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/customer.tbl' into table customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/date.tbl' into table date FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/part.tbl' into table part FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/lineorder.tbl' into table lineorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u63a5\u7740\u4f60\u53ef\u4ee5\u5728 MatrixOne \u4e2d\u8fdb\u884c\u67e5\u8be2\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_5","title":"\u9009\u9879\u4e8c\uff1a\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5bfc\u5165\u5927\u5bbd\u8868\u6570\u636e\u96c6","text":"\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6570\u636e\u5bfc\u5165 lineorder_flat
\uff1a
load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#5-ssb","title":"5. \u8fd0\u884c SSB \u6d4b\u8bd5\u547d\u4ee4","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_6","title":"\u5355\u8868\u67e5\u8be2","text":"--Q1.1\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25;\n\n--Q1.2\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n--Q1.3\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n--Q2.1\nSELECT sum(LO_REVENUE),year(LO_ORDERDATE) AS year,P_BRAND FROM lineorder_flat WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' GROUP BY year, P_BRAND ORDER BY year,P_BRAND;\n\n--Q2.2\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND BETWEEN 'MFGR#2221' AND 'MFGR#2228' AND S_REGION = 'ASIA' GROUP BY year, P_BRAND ORDER BY year, P_BRAND;\n\n--Q2.3\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' GROUP BY year, P_BRAND ORDER BY year, P_BRAND;\n\n--Q3.1\nSELECT C_NATION, S_NATION, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year(LO_ORDERDATE) between 1992 AND 1997 GROUP BY C_NATION, S_NATION, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q3.2\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_NATION = 'CHINA' AND S_NATION = 'CHINA' AND year(LO_ORDERDATE) between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q3.3\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'UNITED KI0' OR S_CITY = 'UNITED KI7') AND year(LO_ORDERDATE) between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q3.4\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'MOZAMBIQU1' OR S_CITY = 'KENYA 4') AND year(LO_ORDERDATE)= 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q4.1\nSELECT year(LO_ORDERDATE) AS year, C_NATION, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY year(LO_ORDERDATE), C_NATION ORDER BY year, C_NATION;\n\n--Q4.2\nSELECT year(LO_ORDERDATE) AS year, S_NATION, P_CATEGORY, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY year(LO_ORDERDATE), S_NATION, P_CATEGORY ORDER BY year, S_NATION, P_CATEGORY;\n\n--Q4.3\nSELECT year(LO_ORDERDATE) AS year, S_CITY, P_BRAND, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE S_NATION = 'UNITED STATES' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND P_CATEGORY = 'MFGR#14' GROUP BY year(LO_ORDERDATE), S_CITY, P_BRAND ORDER BY year, S_CITY, P_BRAND;\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_7","title":"\u591a\u8868\u67e5\u8be2","text":"--Q1.1\nselect sum(lo_revenue) as revenue\nfrom lineorder join date on lo_orderdate = d_datekey\nwhere year(d_datekey) = 1993 and lo_discount between 1 and 3 and lo_quantity < 25;\n\n--Q1.2\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_yearmonthnum = 199401\nand lo_discount between 4 and 6\nand lo_quantity between 26 and 35;\n\n--Q1.3\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_weeknuminyear = 6 and year(d_datekey) = 1994\nand lo_discount between 5 and 7\nand lo_quantity between 26 and 35;\n\n--Q2.1\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_category = 'MFGR#12' and s_region = 'AMERICA'\ngroup by year, p_brand\norder by year, p_brand;\n\n--Q2.2\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand between 'MFGR#2221' and 'MFGR#2228' and s_region = 'ASIA'\ngroup by year, p_brand\norder by year, p_brand;\n\n--Q2.3\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand = 'MFGR#2239' and s_region = 'EUROPE'\ngroup by year, p_brand\norder by year, p_brand;\n\n--Q3.1\nselect c_nation, s_nation, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_region = 'ASIA' and s_region = 'ASIA' and year(d_datekey) between 1992 and 1997\ngroup by c_nation, s_nation, year\norder by year asc, lo_revenue desc;\n\n--Q3.2\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_nation = 'UNITED STATES' and s_nation = 'UNITED STATES'\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year\norder by year asc, lo_revenue desc;\n\n--Q3.3\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5')\nand (s_city='UNITED KI1' or s_city='UNITED KI5')\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year\norder by year asc, lo_revenue desc;\n\n--Q3.4\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5') and (s_city='UNITED KI1' or s_city='UNITED KI5') and d_yearmonth = 'Dec1997'\ngroup by c_city, s_city, year\norder by year asc, lo_revenue desc;\n\n--Q4.1\nselect year(d_datekey) as year, c_nation, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA' and s_region = 'AMERICA' and (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year, c_nation\norder by year, c_nation;\n\n--Q4.2\nselect year(d_datekey) as year, s_nation, p_category, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA'and s_region = 'AMERICA'\nand (year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year, s_nation, p_category\norder by year, s_nation, p_category;\n\n--Q4.3\nselect year(d_datekey) as year, s_city, p_brand, sum(lo_revenue) - sum(lo_supplycost) as profit,c_region , s_nation, p_category\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere\n(year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand s_nation='ALGERIA'\ngroup by year, s_city, p_brand\norder by year, s_city, p_brand;\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#6","title":"6. \u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_8","title":"\u5355\u8868\u67e5\u8be2\u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":"-- Q1.1\n+--------------+\n| revenue |\n+--------------+\n| 702223464659 |\n+--------------+\n\n-- Q1.2\n+---------------+\n| revenue |\n+---------------+\n| 1842875090496 |\n+---------------+\n\n-- Q1.3\n+---------------+\n| revenue |\n+---------------+\n| 2208738861324 |\n+---------------+\n\n-- Q2.1\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand |\n+-----------------+------+-----------+\n| 283684289 | 1992 | MFGR#121 |\n| 1344702529 | 1992 | MFGR#1210 |\n| 757158682 | 1992 | MFGR#1211 |\n| 1156022815 | 1992 | MFGR#1212 |\n| 676164367 | 1992 | MFGR#1213 |\n| 522779256 | 1992 | MFGR#1214 |\n| 233507213 | 1992 | MFGR#1215 |\n| 726755819 | 1992 | MFGR#1216 |\n| 1865504710 | 1992 | MFGR#1217 |\n| 685600451 | 1992 | MFGR#1218 |\n| 814671470 | 1992 | MFGR#1219 |\n| 655405800 | 1992 | MFGR#122 |\n| 962120553 | 1992 | MFGR#1220 |\n| 961393626 | 1992 | MFGR#1221 |\n| 922110830 | 1992 | MFGR#1222 |\n| 814842712 | 1992 | MFGR#1223 |\n| 1402773165 | 1992 | MFGR#1224 |\n| 977517439 | 1992 | MFGR#1225 |\n| 1392114944 | 1992 | MFGR#1226 |\n| 658922951 | 1992 | MFGR#1227 |\n| 892495927 | 1992 | MFGR#1228 |\n| 806609100 | 1992 | MFGR#1229 |\n| 578875657 | 1992 | MFGR#123 |\n| 691236902 | 1992 | MFGR#1230 |\n| 482715249 | 1992 | MFGR#1231 |\n| 618556590 | 1992 | MFGR#1232 |\n| 981657009 | 1992 | MFGR#1233 |\n| 1050794669 | 1992 | MFGR#1234 |\n| 1335217991 | 1992 | MFGR#1235 |\n| 686009527 | 1992 | MFGR#1236 |\n| 605242584 | 1992 | MFGR#1237 |\n| 430455641 | 1992 | MFGR#1238 |\n| 359654993 | 1992 | MFGR#1239 |\n| 818818457 | 1992 | MFGR#124 |\n| 1388502581 | 1992 | MFGR#1240 |\n| 711566198 | 1992 | MFGR#125 |\n| 893045647 | 1992 | MFGR#126 |\n| 1240534333 | 1992 | MFGR#127 |\n| 871966127 | 1992 | MFGR#128 |\n| 719176622 | 1992 | MFGR#129 |\n| 245880758 | 1993 | MFGR#121 |\n| 1480662753 | 1993 | MFGR#1210 |\n| 982292725 | 1993 | MFGR#1211 |\n| 1001136766 | 1993 | MFGR#1212 |\n| 227144072 | 1993 | MFGR#1213 |\n| 291611370 | 1993 | MFGR#1214 |\n| 454576668 | 1993 | MFGR#1215 |\n| 772027256 | 1993 | MFGR#1216 |\n| 1155751851 | 1993 | MFGR#1217 |\n| 897883050 | 1993 | MFGR#1218 |\n| 1209508962 | 1993 | MFGR#1219 |\n| 530577973 | 1993 | MFGR#122 |\n| 901650471 | 1993 | MFGR#1220 |\n| 739540494 | 1993 | MFGR#1221 |\n| 698751459 | 1993 | MFGR#1222 |\n| 1327979157 | 1993 | MFGR#1223 |\n| 1476697469 | 1993 | MFGR#1224 |\n| 792103134 | 1993 | MFGR#1225 |\n| 1420277376 | 1993 | MFGR#1226 |\n| 1446032835 | 1993 | MFGR#1227 |\n| 884375309 | 1993 | MFGR#1228 |\n| 522705868 | 1993 | MFGR#1229 |\n| 601685233 | 1993 | MFGR#123 |\n| 806727248 | 1993 | MFGR#1230 |\n| 399477390 | 1993 | MFGR#1231 |\n| 894047578 | 1993 | MFGR#1232 |\n| 496067089 | 1993 | MFGR#1233 |\n| 1050223756 | 1993 | MFGR#1234 |\n| 891681399 | 1993 | MFGR#1235 |\n| 1402903631 | 1993 | MFGR#1236 |\n| 347380448 | 1993 | MFGR#1237 |\n| 514853194 | 1993 | MFGR#1238 |\n| 410543863 | 1993 | MFGR#1239 |\n| 673483594 | 1993 | MFGR#124 |\n| 713343630 | 1993 | MFGR#1240 |\n| 512610707 | 1993 | MFGR#125 |\n| 1228110634 | 1993 | MFGR#126 |\n| 936958961 | 1993 | MFGR#127 |\n| 579067515 | 1993 | MFGR#128 |\n| 636174833 | 1993 | MFGR#129 |\n| 370347074 | 1994 | MFGR#121 |\n| 483900410 | 1994 | MFGR#1210 |\n| 1240306281 | 1994 | MFGR#1211 |\n| 1003345253 | 1994 | MFGR#1212 |\n| 557310864 | 1994 | MFGR#1213 |\n| 314972328 | 1994 | MFGR#1214 |\n| 1130260810 | 1994 | MFGR#1215 |\n| 401618319 | 1994 | MFGR#1216 |\n| 652173601 | 1994 | MFGR#1217 |\n| 923612074 | 1994 | MFGR#1218 |\n| 469711377 | 1994 | MFGR#1219 |\n| 580152115 | 1994 | MFGR#122 |\n| 433134653 | 1994 | MFGR#1220 |\n| 730569849 | 1994 | MFGR#1221 |\n| 607609104 | 1994 | MFGR#1222 |\n| 949877669 | 1994 | MFGR#1223 |\n| 1644687916 | 1994 | MFGR#1224 |\n| 492974194 | 1994 | MFGR#1225 |\n| 921499688 | 1994 | MFGR#1226 |\n| 719059761 | 1994 | MFGR#1227 |\n| 1000497056 | 1994 | MFGR#1228 |\n| 486968927 | 1994 | MFGR#1229 |\n| 734124906 | 1994 | MFGR#123 |\n| 645016873 | 1994 | MFGR#1230 |\n| 526638240 | 1994 | MFGR#1231 |\n| 1358112405 | 1994 | MFGR#1232 |\n| 1167074905 | 1994 | MFGR#1233 |\n| 1102915239 | 1994 | MFGR#1234 |\n| 693058125 | 1994 | MFGR#1235 |\n| 1673392892 | 1994 | MFGR#1236 |\n| 849630029 | 1994 | MFGR#1237 |\n| 721392705 | 1994 | MFGR#1238 |\n| 1237195774 | 1994 | MFGR#1239 |\n| 1107832795 | 1994 | MFGR#124 |\n| 827906290 | 1994 | MFGR#1240 |\n| 682827304 | 1994 | MFGR#125 |\n| 1198768141 | 1994 | MFGR#126 |\n| 1274148181 | 1994 | MFGR#127 |\n| 738849138 | 1994 | MFGR#128 |\n| 751136619 | 1994 | MFGR#129 |\n| 318978803 | 1995 | MFGR#121 |\n| 383199448 | 1995 | MFGR#1210 |\n| 1300165814 | 1995 | MFGR#1211 |\n| 1550400731 | 1995 | MFGR#1212 |\n| 451958158 | 1995 | MFGR#1213 |\n| 431434279 | 1995 | MFGR#1214 |\n| 713735582 | 1995 | MFGR#1215 |\n| 919323722 | 1995 | MFGR#1216 |\n| 1542358864 | 1995 | MFGR#1217 |\n| 500930092 | 1995 | MFGR#1218 |\n| 1208162086 | 1995 | MFGR#1219 |\n| 785707989 | 1995 | MFGR#122 |\n| 993828211 | 1995 | MFGR#1220 |\n| 667253893 | 1995 | MFGR#1221 |\n| 1654114297 | 1995 | MFGR#1222 |\n| 986528377 | 1995 | MFGR#1223 |\n| 755014642 | 1995 | MFGR#1224 |\n| 1090300100 | 1995 | MFGR#1225 |\n| 1063626454 | 1995 | MFGR#1226 |\n| 1382528859 | 1995 | MFGR#1227 |\n| 919953351 | 1995 | MFGR#1228 |\n| 457795295 | 1995 | MFGR#1229 |\n| 953851827 | 1995 | MFGR#123 |\n| 807209283 | 1995 | MFGR#1230 |\n| 236304454 | 1995 | MFGR#1231 |\n| 668449537 | 1995 | MFGR#1232 |\n| 240657083 | 1995 | MFGR#1233 |\n| 920389826 | 1995 | MFGR#1234 |\n| 684096065 | 1995 | MFGR#1235 |\n| 1005844219 | 1995 | MFGR#1236 |\n| 626170996 | 1995 | MFGR#1237 |\n| 984581826 | 1995 | MFGR#1238 |\n| 602850634 | 1995 | MFGR#1239 |\n| 1172025628 | 1995 | MFGR#124 |\n| 489788581 | 1995 | MFGR#1240 |\n| 643100327 | 1995 | MFGR#125 |\n| 894596661 | 1995 | MFGR#126 |\n| 706917239 | 1995 | MFGR#127 |\n| 428671983 | 1995 | MFGR#128 |\n| 971611472 | 1995 | MFGR#129 |\n| 306497573 | 1996 | MFGR#121 |\n| 890719726 | 1996 | MFGR#1210 |\n| 1761977172 | 1996 | MFGR#1211 |\n| 633845765 | 1996 | MFGR#1212 |\n| 475801202 | 1996 | MFGR#1213 |\n| 271930385 | 1996 | MFGR#1214 |\n| 366399844 | 1996 | MFGR#1215 |\n| 877472476 | 1996 | MFGR#1216 |\n| 970366290 | 1996 | MFGR#1217 |\n| 537175690 | 1996 | MFGR#1218 |\n| 956970528 | 1996 | MFGR#1219 |\n| 711962074 | 1996 | MFGR#122 |\n| 1062161683 | 1996 | MFGR#1220 |\n| 406293744 | 1996 | MFGR#1221 |\n| 785404335 | 1996 | MFGR#1222 |\n| 579267044 | 1996 | MFGR#1223 |\n| 1220640256 | 1996 | MFGR#1224 |\n| 490130196 | 1996 | MFGR#1225 |\n| 1603805636 | 1996 | MFGR#1226 |\n| 1530646510 | 1996 | MFGR#1227 |\n| 1093328922 | 1996 | MFGR#1228 |\n| 596520140 | 1996 | MFGR#1229 |\n| 450815571 | 1996 | MFGR#123 |\n| 315053350 | 1996 | MFGR#1230 |\n| 198951017 | 1996 | MFGR#1231 |\n| 579778438 | 1996 | MFGR#1232 |\n| 480905486 | 1996 | MFGR#1233 |\n| 1433336215 | 1996 | MFGR#1234 |\n| 560925251 | 1996 | MFGR#1235 |\n| 1038766181 | 1996 | MFGR#1236 |\n| 783697960 | 1996 | MFGR#1237 |\n| 972656445 | 1996 | MFGR#1238 |\n| 614528801 | 1996 | MFGR#1239 |\n| 1418931894 | 1996 | MFGR#124 |\n| 995139591 | 1996 | MFGR#1240 |\n| 824028471 | 1996 | MFGR#125 |\n| 669475113 | 1996 | MFGR#126 |\n| 831704651 | 1996 | MFGR#127 |\n| 920514555 | 1996 | MFGR#128 |\n| 436162421 | 1996 | MFGR#129 |\n| 553684594 | 1997 | MFGR#121 |\n| 1317368046 | 1997 | MFGR#1210 |\n| 1617056983 | 1997 | MFGR#1211 |\n| 1196031005 | 1997 | MFGR#1212 |\n| 1056458336 | 1997 | MFGR#1213 |\n| 352179650 | 1997 | MFGR#1214 |\n| 511058114 | 1997 | MFGR#1215 |\n| 658259312 | 1997 | MFGR#1216 |\n| 1238450697 | 1997 | MFGR#1217 |\n| 376245955 | 1997 | MFGR#1218 |\n| 913437812 | 1997 | MFGR#1219 |\n| 1114996000 | 1997 | MFGR#122 |\n| 814059433 | 1997 | MFGR#1220 |\n| 817328516 | 1997 | MFGR#1221 |\n| 541428597 | 1997 | MFGR#1222 |\n| 1260539052 | 1997 | MFGR#1223 |\n| 1766426582 | 1997 | MFGR#1224 |\n| 1221271245 | 1997 | MFGR#1225 |\n| 1499152922 | 1997 | MFGR#1226 |\n| 491586909 | 1997 | MFGR#1227 |\n| 911517084 | 1997 | MFGR#1228 |\n| 728186585 | 1997 | MFGR#1229 |\n| 904363416 | 1997 | MFGR#123 |\n| 605369014 | 1997 | MFGR#1230 |\n| 290370455 | 1997 | MFGR#1231 |\n| 602414397 | 1997 | MFGR#1232 |\n| 765339065 | 1997 | MFGR#1233 |\n| 1170973957 | 1997 | MFGR#1234 |\n| 860319765 | 1997 | MFGR#1235 |\n| 1031080311 | 1997 | MFGR#1236 |\n| 736404810 | 1997 | MFGR#1237 |\n| 1012330790 | 1997 | MFGR#1238 |\n| 681055343 | 1997 | MFGR#1239 |\n| 601626600 | 1997 | MFGR#124 |\n| 920404157 | 1997 | MFGR#1240 |\n| 1007678757 | 1997 | MFGR#125 |\n| 622347203 | 1997 | MFGR#126 |\n| 1215295592 | 1997 | MFGR#127 |\n| 822274972 | 1997 | MFGR#128 |\n| 643903475 | 1997 | MFGR#129 |\n| 470008435 | 1998 | MFGR#121 |\n| 568508492 | 1998 | MFGR#1210 |\n| 323759101 | 1998 | MFGR#1211 |\n| 572013331 | 1998 | MFGR#1212 |\n| 448137748 | 1998 | MFGR#1213 |\n| 137422458 | 1998 | MFGR#1214 |\n| 346491756 | 1998 | MFGR#1215 |\n| 454542243 | 1998 | MFGR#1216 |\n| 759205210 | 1998 | MFGR#1217 |\n| 674544462 | 1998 | MFGR#1218 |\n| 735952270 | 1998 | MFGR#1219 |\n| 490186568 | 1998 | MFGR#122 |\n| 769456686 | 1998 | MFGR#1220 |\n| 654540341 | 1998 | MFGR#1221 |\n| 800329859 | 1998 | MFGR#1222 |\n| 263849231 | 1998 | MFGR#1223 |\n| 445461642 | 1998 | MFGR#1224 |\n| 387808862 | 1998 | MFGR#1225 |\n| 675424382 | 1998 | MFGR#1226 |\n| 265906673 | 1998 | MFGR#1227 |\n| 585938371 | 1998 | MFGR#1228 |\n| 683188537 | 1998 | MFGR#1229 |\n| 304403717 | 1998 | MFGR#123 |\n| 533781674 | 1998 | MFGR#1230 |\n| 304060011 | 1998 | MFGR#1231 |\n| 635275907 | 1998 | MFGR#1232 |\n| 658295080 | 1998 | MFGR#1233 |\n| 524133341 | 1998 | MFGR#1234 |\n| 363911877 | 1998 | MFGR#1235 |\n| 300885635 | 1998 | MFGR#1236 |\n| 532608453 | 1998 | MFGR#1237 |\n| 484291410 | 1998 | MFGR#1238 |\n| 445336624 | 1998 | MFGR#1239 |\n| 719027801 | 1998 | MFGR#124 |\n| 518860961 | 1998 | MFGR#1240 |\n| 491235383 | 1998 | MFGR#125 |\n| 520917638 | 1998 | MFGR#126 |\n| 1158787745 | 1998 | MFGR#127 |\n| 401190922 | 1998 | MFGR#128 |\n| 406656337 | 1998 | MFGR#129 |\n+-----------------+------+-----------+\n\n-- Q2.2\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand |\n+-----------------+------+-----------+\n| 1259802358 | 1992 | MFGR#2221 |\n| 1728549344 | 1992 | MFGR#2222 |\n| 1375260024 | 1992 | MFGR#2223 |\n| 1299982475 | 1992 | MFGR#2224 |\n| 1541960331 | 1992 | MFGR#2225 |\n| 1151853513 | 1992 | MFGR#2226 |\n| 1271175264 | 1992 | MFGR#2227 |\n| 1726441695 | 1992 | MFGR#2228 |\n| 1251460032 | 1993 | MFGR#2221 |\n| 1331062515 | 1993 | MFGR#2222 |\n| 902809293 | 1993 | MFGR#2223 |\n| 980512417 | 1993 | MFGR#2224 |\n| 1253088003 | 1993 | MFGR#2225 |\n| 959195148 | 1993 | MFGR#2226 |\n| 555593932 | 1993 | MFGR#2227 |\n| 2186479174 | 1993 | MFGR#2228 |\n| 1094092222 | 1994 | MFGR#2221 |\n| 1491699323 | 1994 | MFGR#2222 |\n| 1501160826 | 1994 | MFGR#2223 |\n| 1387107418 | 1994 | MFGR#2224 |\n| 1641588884 | 1994 | MFGR#2225 |\n| 1387296390 | 1994 | MFGR#2226 |\n| 1038341470 | 1994 | MFGR#2227 |\n| 1565763138 | 1994 | MFGR#2228 |\n| 1412945650 | 1995 | MFGR#2221 |\n| 1546178356 | 1995 | MFGR#2222 |\n| 1218352073 | 1995 | MFGR#2223 |\n| 1052197762 | 1995 | MFGR#2224 |\n| 1822921900 | 1995 | MFGR#2225 |\n| 728142181 | 1995 | MFGR#2226 |\n| 966131607 | 1995 | MFGR#2227 |\n| 1379320517 | 1995 | MFGR#2228 |\n| 1042767284 | 1996 | MFGR#2221 |\n| 994733835 | 1996 | MFGR#2222 |\n| 1615788545 | 1996 | MFGR#2223 |\n| 1113980216 | 1996 | MFGR#2224 |\n| 1622570253 | 1996 | MFGR#2225 |\n| 1540226758 | 1996 | MFGR#2226 |\n| 1115687883 | 1996 | MFGR#2227 |\n| 1716355343 | 1996 | MFGR#2228 |\n| 867705636 | 1997 | MFGR#2221 |\n| 1529877498 | 1997 | MFGR#2222 |\n| 1594444450 | 1997 | MFGR#2223 |\n| 587421043 | 1997 | MFGR#2224 |\n| 1112274470 | 1997 | MFGR#2225 |\n| 1327884722 | 1997 | MFGR#2226 |\n| 884180880 | 1997 | MFGR#2227 |\n| 1664207656 | 1997 | MFGR#2228 |\n| 827743515 | 1998 | MFGR#2221 |\n| 662242310 | 1998 | MFGR#2222 |\n| 861445539 | 1998 | MFGR#2223 |\n| 694538672 | 1998 | MFGR#2224 |\n| 675179021 | 1998 | MFGR#2225 |\n| 480728720 | 1998 | MFGR#2226 |\n| 643763072 | 1998 | MFGR#2227 |\n| 994499201 | 1998 | MFGR#2228 |\n+-----------------+------+-----------+\n\n-- Q2.3\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand |\n+-----------------+------+-----------+\n| 1428843284 | 1992 | MFGR#2239 |\n| 1865666054 | 1993 | MFGR#2239 |\n| 2242753254 | 1994 | MFGR#2239 |\n| 1446677305 | 1995 | MFGR#2239 |\n| 921681503 | 1996 | MFGR#2239 |\n| 1549990572 | 1997 | MFGR#2239 |\n| 926327433 | 1998 | MFGR#2239 |\n+-----------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation | s_nation | year | revenue |\n+-----------+-----------+------+-------------+\n| VIETNAM | CHINA | 1992 | 17194479086 |\n| JAPAN | CHINA | 1992 | 15572594510 |\n| JAPAN | JAPAN | 1992 | 13861682954 |\n| INDONESIA | CHINA | 1992 | 13499663933 |\n| VIETNAM | INDONESIA | 1992 | 13163103649 |\n| JAPAN | INDONESIA | 1992 | 13035158590 |\n| INDIA | CHINA | 1992 | 12987688902 |\n| INDONESIA | JAPAN | 1992 | 12939737918 |\n| VIETNAM | JAPAN | 1992 | 12174715858 |\n| JAPAN | VIETNAM | 1992 | 11669093753 |\n| INDIA | INDONESIA | 1992 | 11452602145 |\n| INDONESIA | INDONESIA | 1992 | 10394407561 |\n| INDIA | JAPAN | 1992 | 10313084900 |\n| JAPAN | INDIA | 1992 | 10035511089 |\n| CHINA | CHINA | 1992 | 9828744666 |\n| VIETNAM | VIETNAM | 1992 | 9701522505 |\n| INDONESIA | INDIA | 1992 | 9271105764 |\n| INDIA | INDIA | 1992 | 8879645522 |\n| CHINA | INDONESIA | 1992 | 8373693838 |\n| CHINA | JAPAN | 1992 | 8051248951 |\n| VIETNAM | INDIA | 1992 | 7804539029 |\n| INDONESIA | VIETNAM | 1992 | 7615465790 |\n| CHINA | INDIA | 1992 | 7344868842 |\n| INDIA | VIETNAM | 1992 | 6830508508 |\n| CHINA | VIETNAM | 1992 | 6529888238 |\n| JAPAN | CHINA | 1993 | 18839180326 |\n| VIETNAM | CHINA | 1993 | 14761890330 |\n| JAPAN | INDONESIA | 1993 | 13648082171 |\n| INDONESIA | CHINA | 1993 | 13518181805 |\n| INDIA | CHINA | 1993 | 13249555999 |\n| JAPAN | JAPAN | 1993 | 12667833152 |\n| JAPAN | VIETNAM | 1993 | 11529854580 |\n| CHINA | CHINA | 1993 | 11216468573 |\n| INDONESIA | INDONESIA | 1993 | 10953284722 |\n| VIETNAM | INDONESIA | 1993 | 10582912267 |\n| INDIA | JAPAN | 1993 | 10482950584 |\n| VIETNAM | JAPAN | 1993 | 10370811002 |\n| INDIA | INDONESIA | 1993 | 10145286112 |\n| INDONESIA | JAPAN | 1993 | 9850020303 |\n| VIETNAM | VIETNAM | 1993 | 9591468153 |\n| CHINA | INDONESIA | 1993 | 9015864524 |\n| CHINA | JAPAN | 1993 | 8972996729 |\n| INDONESIA | INDIA | 1993 | 8903638786 |\n| JAPAN | INDIA | 1993 | 8848048514 |\n| INDONESIA | VIETNAM | 1993 | 8024464882 |\n| VIETNAM | INDIA | 1993 | 7806575746 |\n| INDIA | VIETNAM | 1993 | 7537331106 |\n| INDIA | INDIA | 1993 | 7211053846 |\n| CHINA | VIETNAM | 1993 | 6700022269 |\n| CHINA | INDIA | 1993 | 6327331541 |\n| JAPAN | CHINA | 1994 | 15661051644 |\n| VIETNAM | CHINA | 1994 | 13958591931 |\n| JAPAN | JAPAN | 1994 | 13566252348 |\n| CHINA | CHINA | 1994 | 12870010072 |\n| VIETNAM | JAPAN | 1994 | 12728320716 |\n| INDONESIA | CHINA | 1994 | 12295790872 |\n| INDIA | CHINA | 1994 | 12166419121 |\n| JAPAN | INDONESIA | 1994 | 11358955025 |\n| INDIA | INDONESIA | 1994 | 11111248365 |\n| JAPAN | INDIA | 1994 | 10078806371 |\n| VIETNAM | INDONESIA | 1994 | 9923852578 |\n| INDIA | JAPAN | 1994 | 9839136767 |\n| CHINA | JAPAN | 1994 | 9836586308 |\n| INDONESIA | JAPAN | 1994 | 9786694572 |\n| INDIA | VIETNAM | 1994 | 9551081406 |\n| JAPAN | VIETNAM | 1994 | 9035431932 |\n| VIETNAM | INDIA | 1994 | 9032319402 |\n| INDONESIA | INDONESIA | 1994 | 8876012426 |\n| CHINA | INDONESIA | 1994 | 8375581981 |\n| VIETNAM | VIETNAM | 1994 | 8095638136 |\n| INDONESIA | INDIA | 1994 | 7943993512 |\n| INDONESIA | VIETNAM | 1994 | 7927236697 |\n| INDIA | INDIA | 1994 | 7534915457 |\n| CHINA | VIETNAM | 1994 | 6062387221 |\n| CHINA | INDIA | 1994 | 5816794324 |\n| VIETNAM | CHINA | 1995 | 15128423080 |\n| INDONESIA | CHINA | 1995 | 14794647970 |\n| INDIA | CHINA | 1995 | 14724240804 |\n| JAPAN | CHINA | 1995 | 14579848516 |\n| CHINA | CHINA | 1995 | 14296657586 |\n| INDIA | JAPAN | 1995 | 13511381754 |\n| JAPAN | JAPAN | 1995 | 12015968288 |\n| VIETNAM | INDONESIA | 1995 | 11290647784 |\n| JAPAN | INDONESIA | 1995 | 10968840402 |\n| INDIA | INDONESIA | 1995 | 10879296370 |\n| CHINA | INDONESIA | 1995 | 10611767914 |\n| VIETNAM | JAPAN | 1995 | 10493043807 |\n| INDONESIA | INDONESIA | 1995 | 10350165199 |\n| VIETNAM | INDIA | 1995 | 10147175135 |\n| CHINA | JAPAN | 1995 | 9967113498 |\n| JAPAN | VIETNAM | 1995 | 9871240910 |\n| INDONESIA | JAPAN | 1995 | 9554798320 |\n| JAPAN | INDIA | 1995 | 9224478715 |\n| INDIA | INDIA | 1995 | 8880501531 |\n| VIETNAM | VIETNAM | 1995 | 8530802028 |\n| INDIA | VIETNAM | 1995 | 8470249830 |\n| CHINA | INDIA | 1995 | 8460557790 |\n| INDONESIA | VIETNAM | 1995 | 8393411088 |\n| CHINA | VIETNAM | 1995 | 7838238263 |\n| INDONESIA | INDIA | 1995 | 7001659338 |\n| JAPAN | CHINA | 1996 | 14974943391 |\n| INDIA | CHINA | 1996 | 14236197987 |\n| VIETNAM | CHINA | 1996 | 13723231674 |\n| JAPAN | INDONESIA | 1996 | 13304501801 |\n| INDONESIA | CHINA | 1996 | 12444022202 |\n| CHINA | CHINA | 1996 | 12120893189 |\n| INDIA | JAPAN | 1996 | 11649117519 |\n| INDONESIA | JAPAN | 1996 | 11345350775 |\n| VIETNAM | JAPAN | 1996 | 11294284203 |\n| INDONESIA | INDONESIA | 1996 | 11111201530 |\n| JAPAN | INDIA | 1996 | 10871364136 |\n| JAPAN | JAPAN | 1996 | 10836947449 |\n| INDIA | INDONESIA | 1996 | 10568008435 |\n| JAPAN | VIETNAM | 1996 | 10503890555 |\n| VIETNAM | INDONESIA | 1996 | 10494783196 |\n| INDONESIA | VIETNAM | 1996 | 9940440124 |\n| INDONESIA | INDIA | 1996 | 9864980677 |\n| VIETNAM | VIETNAM | 1996 | 9560258720 |\n| INDIA | VIETNAM | 1996 | 9324764214 |\n| INDIA | INDIA | 1996 | 9023346020 |\n| VIETNAM | INDIA | 1996 | 8968179949 |\n| CHINA | INDONESIA | 1996 | 8877441837 |\n| CHINA | JAPAN | 1996 | 8749420872 |\n| CHINA | VIETNAM | 1996 | 6973983457 |\n| CHINA | INDIA | 1996 | 6515658476 |\n| JAPAN | CHINA | 1997 | 15365039212 |\n| INDONESIA | CHINA | 1997 | 14159930904 |\n| VIETNAM | CHINA | 1997 | 13678288757 |\n| INDIA | CHINA | 1997 | 13599028484 |\n| JAPAN | JAPAN | 1997 | 12921870544 |\n| CHINA | CHINA | 1997 | 12720975220 |\n| VIETNAM | JAPAN | 1997 | 11929000810 |\n| VIETNAM | INDONESIA | 1997 | 11325447090 |\n| JAPAN | INDONESIA | 1997 | 10764312416 |\n| INDONESIA | JAPAN | 1997 | 10555558162 |\n| INDONESIA | INDONESIA | 1997 | 10416928126 |\n| CHINA | INDONESIA | 1997 | 10317902565 |\n| INDIA | JAPAN | 1997 | 10272590051 |\n| JAPAN | VIETNAM | 1997 | 9940032294 |\n| CHINA | JAPAN | 1997 | 9519485461 |\n| JAPAN | INDIA | 1997 | 9465935835 |\n| INDIA | INDONESIA | 1997 | 9405085270 |\n| INDONESIA | INDIA | 1997 | 8930955270 |\n| INDIA | INDIA | 1997 | 8295504178 |\n| VIETNAM | VIETNAM | 1997 | 8293412532 |\n| INDONESIA | VIETNAM | 1997 | 8116443059 |\n| INDIA | VIETNAM | 1997 | 7960292262 |\n| VIETNAM | INDIA | 1997 | 7529455873 |\n| CHINA | VIETNAM | 1997 | 7038413355 |\n| CHINA | INDIA | 1997 | 6530770558 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n\n+------------+------------+------+-----------+\n| c_city | s_city | year | revenue |\n+------------+------------+------+-----------+\n| CHINA 3 | CHINA 0 | 1992 | 539864249 |\n| CHINA 0 | CHINA 6 | 1992 | 471363128 |\n| CHINA 8 | CHINA 1 | 1992 | 421384110 |\n| CHINA 6 | CHINA 1 | 1992 | 382204882 |\n| CHINA 6 | CHINA 7 | 1992 | 355755835 |\n| CHINA 8 | CHINA 9 | 1992 | 349006417 |\n| CHINA 7 | CHINA 7 | 1992 | 320232842 |\n| CHINA 8 | CHINA 3 | 1992 | 296105733 |\n| CHINA 5 | CHINA 3 | 1992 | 277283951 |\n| CHINA 6 | CHINA 6 | 1992 | 265527771 |\n| CHINA 4 | CHINA 1 | 1992 | 237402078 |\n| CHINA 8 | CHINA 6 | 1992 | 234720401 |\n| CHINA 4 | CHINA 6 | 1992 | 230169075 |\n| CHINA 9 | CHINA 1 | 1992 | 223815249 |\n| CHINA 1 | CHINA 1 | 1992 | 223467947 |\n| CHINA 2 | CHINA 1 | 1992 | 219559691 |\n| CHINA 9 | CHINA 6 | 1992 | 205915890 |\n| CHINA 7 | CHINA 9 | 1992 | 201288909 |\n| CHINA 1 | CHINA 6 | 1992 | 195622902 |\n| CHINA 9 | CHINA 7 | 1992 | 190345063 |\n| CHINA 8 | CHINA 4 | 1992 | 174478626 |\n| CHINA 1 | CHINA 7 | 1992 | 173803257 |\n| CHINA 9 | CHINA 9 | 1992 | 162458028 |\n| CHINA 6 | CHINA 0 | 1992 | 154260702 |\n| CHINA 8 | CHINA 0 | 1992 | 149794069 |\n| CHINA 5 | CHINA 9 | 1992 | 149369922 |\n| CHINA 8 | CHINA 8 | 1992 | 147607252 |\n| CHINA 6 | CHINA 4 | 1992 | 147137516 |\n| CHINA 7 | CHINA 8 | 1992 | 139974858 |\n| CHINA 5 | CHINA 6 | 1992 | 138467127 |\n| CHINA 3 | CHINA 6 | 1992 | 119521008 |\n| CHINA 8 | CHINA 7 | 1992 | 109887269 |\n| CHINA 6 | CHINA 3 | 1992 | 107201214 |\n| CHINA 9 | CHINA 4 | 1992 | 101504450 |\n| CHINA 1 | CHINA 3 | 1992 | 101388208 |\n| CHINA 7 | CHINA 0 | 1992 | 98475237 |\n| CHINA 5 | CHINA 8 | 1992 | 98370738 |\n| CHINA 2 | CHINA 6 | 1992 | 93254616 |\n| CHINA 2 | CHINA 4 | 1992 | 86394644 |\n| CHINA 3 | CHINA 7 | 1992 | 81027008 |\n| CHINA 5 | CHINA 4 | 1992 | 78587418 |\n| CHINA 3 | CHINA 9 | 1992 | 78114762 |\n| CHINA 2 | CHINA 0 | 1992 | 77786892 |\n| CHINA 2 | CHINA 8 | 1992 | 75605732 |\n| CHINA 4 | CHINA 3 | 1992 | 75101512 |\n| CHINA 7 | CHINA 4 | 1992 | 74119240 |\n| CHINA 2 | CHINA 9 | 1992 | 73413108 |\n| CHINA 5 | CHINA 7 | 1992 | 73199718 |\n| CHINA 4 | CHINA 4 | 1992 | 72839118 |\n| CHINA 1 | CHINA 9 | 1992 | 68538220 |\n| CHINA 0 | CHINA 8 | 1992 | 65856888 |\n| CHINA 0 | CHINA 9 | 1992 | 65590624 |\n| CHINA 3 | CHINA 8 | 1992 | 64556586 |\n| CHINA 2 | CHINA 7 | 1992 | 63336330 |\n| CHINA 4 | CHINA 9 | 1992 | 57645963 |\n| CHINA 0 | CHINA 7 | 1992 | 55251918 |\n| CHINA 0 | CHINA 1 | 1992 | 51774462 |\n| CHINA 6 | CHINA 8 | 1992 | 45676858 |\n| CHINA 3 | CHINA 3 | 1992 | 41147560 |\n| CHINA 3 | CHINA 4 | 1992 | 36838082 |\n| CHINA 5 | CHINA 0 | 1992 | 36554488 |\n| CHINA 3 | CHINA 1 | 1992 | 32036313 |\n| CHINA 4 | CHINA 8 | 1992 | 31517575 |\n| CHINA 0 | CHINA 3 | 1992 | 25524054 |\n| CHINA 1 | CHINA 4 | 1992 | 12681846 |\n| CHINA 7 | CHINA 3 | 1992 | 11395152 |\n| CHINA 6 | CHINA 9 | 1992 | 8642375 |\n| CHINA 8 | CHINA 6 | 1993 | 638396852 |\n| CHINA 7 | CHINA 6 | 1993 | 576731239 |\n| CHINA 2 | CHINA 6 | 1993 | 528008729 |\n| CHINA 8 | CHINA 9 | 1993 | 522412584 |\n| CHINA 8 | CHINA 7 | 1993 | 475478848 |\n| CHINA 8 | CHINA 1 | 1993 | 452064153 |\n| CHINA 0 | CHINA 1 | 1993 | 425902649 |\n| CHINA 9 | CHINA 1 | 1993 | 405252987 |\n| CHINA 6 | CHINA 9 | 1993 | 385005953 |\n| CHINA 8 | CHINA 8 | 1993 | 382884778 |\n| CHINA 0 | CHINA 6 | 1993 | 344911487 |\n| CHINA 6 | CHINA 7 | 1993 | 341436211 |\n| CHINA 3 | CHINA 6 | 1993 | 291652051 |\n| CHINA 7 | CHINA 1 | 1993 | 257769861 |\n| CHINA 8 | CHINA 0 | 1993 | 231981252 |\n| CHINA 4 | CHINA 6 | 1993 | 215180968 |\n| CHINA 3 | CHINA 0 | 1993 | 213320777 |\n| CHINA 9 | CHINA 6 | 1993 | 207281000 |\n| CHINA 5 | CHINA 9 | 1993 | 206555882 |\n| CHINA 6 | CHINA 1 | 1993 | 205665388 |\n| CHINA 5 | CHINA 1 | 1993 | 193491875 |\n| CHINA 2 | CHINA 9 | 1993 | 193324425 |\n| CHINA 5 | CHINA 8 | 1993 | 190521023 |\n| CHINA 7 | CHINA 0 | 1993 | 183487919 |\n| CHINA 0 | CHINA 9 | 1993 | 170223958 |\n| CHINA 6 | CHINA 8 | 1993 | 166821272 |\n| CHINA 3 | CHINA 8 | 1993 | 163053528 |\n| CHINA 2 | CHINA 0 | 1993 | 158276154 |\n| CHINA 3 | CHINA 1 | 1993 | 153652018 |\n| CHINA 5 | CHINA 6 | 1993 | 151359347 |\n| CHINA 6 | CHINA 0 | 1993 | 140494698 |\n| CHINA 8 | CHINA 4 | 1993 | 139857147 |\n| CHINA 2 | CHINA 7 | 1993 | 136009418 |\n| CHINA 5 | CHINA 7 | 1993 | 133892119 |\n| CHINA 9 | CHINA 9 | 1993 | 118965507 |\n| CHINA 1 | CHINA 1 | 1993 | 108898379 |\n| CHINA 6 | CHINA 6 | 1993 | 100311475 |\n| CHINA 0 | CHINA 4 | 1993 | 93483068 |\n| CHINA 1 | CHINA 4 | 1993 | 87714152 |\n| CHINA 4 | CHINA 1 | 1993 | 87690658 |\n| CHINA 4 | CHINA 7 | 1993 | 83701574 |\n| CHINA 1 | CHINA 0 | 1993 | 82670983 |\n| CHINA 7 | CHINA 4 | 1993 | 77396461 |\n| CHINA 5 | CHINA 4 | 1993 | 73556161 |\n| CHINA 4 | CHINA 8 | 1993 | 72203335 |\n| CHINA 0 | CHINA 7 | 1993 | 70395334 |\n| CHINA 3 | CHINA 4 | 1993 | 64771003 |\n| CHINA 7 | CHINA 8 | 1993 | 64514099 |\n| CHINA 3 | CHINA 7 | 1993 | 62868516 |\n| CHINA 8 | CHINA 3 | 1993 | 56504804 |\n| CHINA 2 | CHINA 4 | 1993 | 56031779 |\n| CHINA 1 | CHINA 7 | 1993 | 48951262 |\n| CHINA 7 | CHINA 3 | 1993 | 45962220 |\n| CHINA 4 | CHINA 9 | 1993 | 43158138 |\n| CHINA 7 | CHINA 9 | 1993 | 42611979 |\n| CHINA 2 | CHINA 8 | 1993 | 38092546 |\n| CHINA 1 | CHINA 9 | 1993 | 29665374 |\n| CHINA 1 | CHINA 3 | 1993 | 23991216 |\n| CHINA 6 | CHINA 6 | 1994 | 596294890 |\n| CHINA 8 | CHINA 6 | 1994 | 542104721 |\n| CHINA 6 | CHINA 1 | 1994 | 504359553 |\n| CHINA 3 | CHINA 7 | 1994 | 476727294 |\n| CHINA 3 | CHINA 6 | 1994 | 476349724 |\n| CHINA 8 | CHINA 9 | 1994 | 427241348 |\n| CHINA 6 | CHINA 9 | 1994 | 358191581 |\n| CHINA 9 | CHINA 6 | 1994 | 352344057 |\n| CHINA 3 | CHINA 0 | 1994 | 351708546 |\n| CHINA 8 | CHINA 0 | 1994 | 351131413 |\n| CHINA 3 | CHINA 3 | 1994 | 339279574 |\n| CHINA 0 | CHINA 1 | 1994 | 298307857 |\n| CHINA 0 | CHINA 7 | 1994 | 289536010 |\n| CHINA 0 | CHINA 6 | 1994 | 285639032 |\n| CHINA 7 | CHINA 6 | 1994 | 263170455 |\n| CHINA 2 | CHINA 8 | 1994 | 250332990 |\n| CHINA 6 | CHINA 4 | 1994 | 235897763 |\n| CHINA 5 | CHINA 1 | 1994 | 234681515 |\n| CHINA 8 | CHINA 7 | 1994 | 234390101 |\n| CHINA 1 | CHINA 6 | 1994 | 232792764 |\n| CHINA 8 | CHINA 1 | 1994 | 223808842 |\n| CHINA 4 | CHINA 6 | 1994 | 209522926 |\n| CHINA 8 | CHINA 4 | 1994 | 208632636 |\n| CHINA 7 | CHINA 3 | 1994 | 202424117 |\n| CHINA 4 | CHINA 7 | 1994 | 185487544 |\n| CHINA 2 | CHINA 7 | 1994 | 183551771 |\n| CHINA 7 | CHINA 1 | 1994 | 178421732 |\n| CHINA 4 | CHINA 1 | 1994 | 176262868 |\n| CHINA 5 | CHINA 6 | 1994 | 173651872 |\n| CHINA 0 | CHINA 4 | 1994 | 173584501 |\n| CHINA 8 | CHINA 8 | 1994 | 172179808 |\n| CHINA 9 | CHINA 1 | 1994 | 169617585 |\n| CHINA 0 | CHINA 9 | 1994 | 167569085 |\n| CHINA 5 | CHINA 8 | 1994 | 162066559 |\n| CHINA 7 | CHINA 9 | 1994 | 161041255 |\n| CHINA 5 | CHINA 4 | 1994 | 154820955 |\n| CHINA 7 | CHINA 0 | 1994 | 152844960 |\n| CHINA 2 | CHINA 6 | 1994 | 149839190 |\n| CHINA 7 | CHINA 8 | 1994 | 149536114 |\n| CHINA 1 | CHINA 4 | 1994 | 142403628 |\n| CHINA 9 | CHINA 9 | 1994 | 131064832 |\n| CHINA 2 | CHINA 1 | 1994 | 124489283 |\n| CHINA 2 | CHINA 0 | 1994 | 114263273 |\n| CHINA 5 | CHINA 7 | 1994 | 113311766 |\n| CHINA 8 | CHINA 3 | 1994 | 112573609 |\n| CHINA 3 | CHINA 4 | 1994 | 104903651 |\n| CHINA 4 | CHINA 0 | 1994 | 101914439 |\n| CHINA 3 | CHINA 1 | 1994 | 98253251 |\n| CHINA 1 | CHINA 7 | 1994 | 94582288 |\n| CHINA 4 | CHINA 4 | 1994 | 92818317 |\n| CHINA 1 | CHINA 9 | 1994 | 85220541 |\n| CHINA 6 | CHINA 3 | 1994 | 84604801 |\n| CHINA 0 | CHINA 3 | 1994 | 77574978 |\n| CHINA 1 | CHINA 3 | 1994 | 74435316 |\n| CHINA 4 | CHINA 9 | 1994 | 72622300 |\n| CHINA 3 | CHINA 8 | 1994 | 72559366 |\n| CHINA 9 | CHINA 0 | 1994 | 69298222 |\n| CHINA 3 | CHINA 9 | 1994 | 67472592 |\n| CHINA 6 | CHINA 8 | 1994 | 66271372 |\n| CHINA 7 | CHINA 4 | 1994 | 59634606 |\n| CHINA 2 | CHINA 9 | 1994 | 56882136 |\n| CHINA 1 | CHINA 1 | 1994 | 56592337 |\n| CHINA 5 | CHINA 9 | 1994 | 52879724 |\n| CHINA 9 | CHINA 4 | 1994 | 49324497 |\n| CHINA 2 | CHINA 3 | 1994 | 45042384 |\n| CHINA 7 | CHINA 7 | 1994 | 44458451 |\n| CHINA 5 | CHINA 0 | 1994 | 39091925 |\n| CHINA 9 | CHINA 3 | 1994 | 39082405 |\n| CHINA 0 | CHINA 8 | 1994 | 28203459 |\n| CHINA 6 | CHINA 7 | 1994 | 27243775 |\n| CHINA 0 | CHINA 0 | 1994 | 15591040 |\n| CHINA 2 | CHINA 6 | 1995 | 832176707 |\n| CHINA 8 | CHINA 6 | 1995 | 793322102 |\n| CHINA 3 | CHINA 7 | 1995 | 505446788 |\n| CHINA 7 | CHINA 9 | 1995 | 483519933 |\n| CHINA 4 | CHINA 6 | 1995 | 440320366 |\n| CHINA 8 | CHINA 1 | 1995 | 394522570 |\n| CHINA 7 | CHINA 1 | 1995 | 393861389 |\n| CHINA 5 | CHINA 1 | 1995 | 343166828 |\n| CHINA 1 | CHINA 7 | 1995 | 341736584 |\n| CHINA 8 | CHINA 7 | 1995 | 323623203 |\n| CHINA 6 | CHINA 6 | 1995 | 312876143 |\n| CHINA 3 | CHINA 6 | 1995 | 306516324 |\n| CHINA 7 | CHINA 6 | 1995 | 294840537 |\n| CHINA 3 | CHINA 3 | 1995 | 290066240 |\n| CHINA 8 | CHINA 3 | 1995 | 289182495 |\n| CHINA 3 | CHINA 1 | 1995 | 288853766 |\n| CHINA 0 | CHINA 1 | 1995 | 279082523 |\n| CHINA 0 | CHINA 8 | 1995 | 265291443 |\n| CHINA 1 | CHINA 6 | 1995 | 262283412 |\n| CHINA 4 | CHINA 1 | 1995 | 246559891 |\n| CHINA 2 | CHINA 8 | 1995 | 246465167 |\n| CHINA 6 | CHINA 7 | 1995 | 246385862 |\n| CHINA 9 | CHINA 6 | 1995 | 231314393 |\n| CHINA 2 | CHINA 7 | 1995 | 224354491 |\n| CHINA 4 | CHINA 7 | 1995 | 222368398 |\n| CHINA 0 | CHINA 7 | 1995 | 221334917 |\n| CHINA 6 | CHINA 3 | 1995 | 217756587 |\n| CHINA 6 | CHINA 9 | 1995 | 215736018 |\n| CHINA 4 | CHINA 9 | 1995 | 210496516 |\n| CHINA 0 | CHINA 6 | 1995 | 197891458 |\n| CHINA 8 | CHINA 9 | 1995 | 192018213 |\n| CHINA 7 | CHINA 0 | 1995 | 188804482 |\n| CHINA 5 | CHINA 6 | 1995 | 186378531 |\n| CHINA 6 | CHINA 1 | 1995 | 165831073 |\n| CHINA 1 | CHINA 3 | 1995 | 165118263 |\n| CHINA 6 | CHINA 8 | 1995 | 157640218 |\n| CHINA 1 | CHINA 1 | 1995 | 150838433 |\n| CHINA 1 | CHINA 4 | 1995 | 147632879 |\n| CHINA 6 | CHINA 0 | 1995 | 147314401 |\n| CHINA 5 | CHINA 4 | 1995 | 142820978 |\n| CHINA 5 | CHINA 9 | 1995 | 141416829 |\n| CHINA 2 | CHINA 0 | 1995 | 135608473 |\n| CHINA 5 | CHINA 7 | 1995 | 131596218 |\n| CHINA 0 | CHINA 4 | 1995 | 129159370 |\n| CHINA 3 | CHINA 9 | 1995 | 126837748 |\n| CHINA 8 | CHINA 0 | 1995 | 126564932 |\n| CHINA 0 | CHINA 3 | 1995 | 121337041 |\n| CHINA 7 | CHINA 7 | 1995 | 118697587 |\n| CHINA 5 | CHINA 8 | 1995 | 116538842 |\n| CHINA 8 | CHINA 8 | 1995 | 110161904 |\n| CHINA 9 | CHINA 0 | 1995 | 109582187 |\n| CHINA 9 | CHINA 1 | 1995 | 103455098 |\n| CHINA 2 | CHINA 1 | 1995 | 100264691 |\n| CHINA 7 | CHINA 3 | 1995 | 99011859 |\n| CHINA 3 | CHINA 0 | 1995 | 90383390 |\n| CHINA 4 | CHINA 3 | 1995 | 89908903 |\n| CHINA 7 | CHINA 8 | 1995 | 81425699 |\n| CHINA 3 | CHINA 4 | 1995 | 77577579 |\n| CHINA 4 | CHINA 8 | 1995 | 74805746 |\n| CHINA 9 | CHINA 7 | 1995 | 74597020 |\n| CHINA 9 | CHINA 9 | 1995 | 73514511 |\n| CHINA 5 | CHINA 0 | 1995 | 73274726 |\n| CHINA 8 | CHINA 4 | 1995 | 61708487 |\n| CHINA 1 | CHINA 0 | 1995 | 58753734 |\n| CHINA 3 | CHINA 8 | 1995 | 57133566 |\n| CHINA 9 | CHINA 4 | 1995 | 53259334 |\n| CHINA 1 | CHINA 9 | 1995 | 46177797 |\n| CHINA 2 | CHINA 4 | 1995 | 45147325 |\n| CHINA 0 | CHINA 0 | 1995 | 43963173 |\n| CHINA 0 | CHINA 9 | 1995 | 40184107 |\n| CHINA 1 | CHINA 8 | 1995 | 18859188 |\n| CHINA 8 | CHINA 7 | 1996 | 621957444 |\n| CHINA 3 | CHINA 9 | 1996 | 530082848 |\n| CHINA 8 | CHINA 6 | 1996 | 525755549 |\n| CHINA 8 | CHINA 1 | 1996 | 399229343 |\n| CHINA 6 | CHINA 7 | 1996 | 365540749 |\n| CHINA 8 | CHINA 8 | 1996 | 351864283 |\n| CHINA 1 | CHINA 6 | 1996 | 329186504 |\n| CHINA 9 | CHINA 6 | 1996 | 321113085 |\n| CHINA 3 | CHINA 6 | 1996 | 318264871 |\n| CHINA 2 | CHINA 6 | 1996 | 315233397 |\n| CHINA 2 | CHINA 9 | 1996 | 285852841 |\n| CHINA 9 | CHINA 9 | 1996 | 264510548 |\n| CHINA 5 | CHINA 6 | 1996 | 261385523 |\n| CHINA 8 | CHINA 9 | 1996 | 259497265 |\n| CHINA 6 | CHINA 6 | 1996 | 258200131 |\n| CHINA 4 | CHINA 9 | 1996 | 257345949 |\n| CHINA 6 | CHINA 9 | 1996 | 247667288 |\n| CHINA 2 | CHINA 7 | 1996 | 234569026 |\n| CHINA 2 | CHINA 1 | 1996 | 218568966 |\n| CHINA 4 | CHINA 1 | 1996 | 207383476 |\n| CHINA 0 | CHINA 1 | 1996 | 204596428 |\n| CHINA 3 | CHINA 0 | 1996 | 204375870 |\n| CHINA 4 | CHINA 0 | 1996 | 202299286 |\n| CHINA 4 | CHINA 4 | 1996 | 191983261 |\n| CHINA 4 | CHINA 8 | 1996 | 183961012 |\n| CHINA 4 | CHINA 6 | 1996 | 183872085 |\n| CHINA 6 | CHINA 8 | 1996 | 182132356 |\n| CHINA 7 | CHINA 9 | 1996 | 170941341 |\n| CHINA 0 | CHINA 6 | 1996 | 168082672 |\n| CHINA 1 | CHINA 7 | 1996 | 165942066 |\n| CHINA 1 | CHINA 9 | 1996 | 165878775 |\n| CHINA 9 | CHINA 8 | 1996 | 156009357 |\n| CHINA 7 | CHINA 7 | 1996 | 155842944 |\n| CHINA 2 | CHINA 0 | 1996 | 147709906 |\n| CHINA 5 | CHINA 7 | 1996 | 147257366 |\n| CHINA 1 | CHINA 8 | 1996 | 141840928 |\n| CHINA 2 | CHINA 4 | 1996 | 136244052 |\n| CHINA 9 | CHINA 0 | 1996 | 130997019 |\n| CHINA 1 | CHINA 0 | 1996 | 124362038 |\n| CHINA 0 | CHINA 9 | 1996 | 114011231 |\n| CHINA 7 | CHINA 3 | 1996 | 112398764 |\n| CHINA 4 | CHINA 7 | 1996 | 110567337 |\n| CHINA 3 | CHINA 4 | 1996 | 109269982 |\n| CHINA 5 | CHINA 1 | 1996 | 107482704 |\n| CHINA 6 | CHINA 4 | 1996 | 105485170 |\n| CHINA 1 | CHINA 4 | 1996 | 105320270 |\n| CHINA 0 | CHINA 7 | 1996 | 102545071 |\n| CHINA 2 | CHINA 3 | 1996 | 100407151 |\n| CHINA 0 | CHINA 4 | 1996 | 95913303 |\n| CHINA 7 | CHINA 0 | 1996 | 94706269 |\n| CHINA 6 | CHINA 1 | 1996 | 86949951 |\n| CHINA 8 | CHINA 3 | 1996 | 84157344 |\n| CHINA 2 | CHINA 8 | 1996 | 83176903 |\n| CHINA 5 | CHINA 9 | 1996 | 83104330 |\n| CHINA 7 | CHINA 8 | 1996 | 81490639 |\n| CHINA 9 | CHINA 3 | 1996 | 79655829 |\n| CHINA 5 | CHINA 0 | 1996 | 77489995 |\n| CHINA 8 | CHINA 0 | 1996 | 76989056 |\n| CHINA 9 | CHINA 1 | 1996 | 72011031 |\n| CHINA 7 | CHINA 4 | 1996 | 64764322 |\n| CHINA 5 | CHINA 4 | 1996 | 62827767 |\n| CHINA 5 | CHINA 8 | 1996 | 62673237 |\n| CHINA 7 | CHINA 6 | 1996 | 61880459 |\n| CHINA 3 | CHINA 7 | 1996 | 56642844 |\n| CHINA 3 | CHINA 1 | 1996 | 50799366 |\n| CHINA 3 | CHINA 3 | 1996 | 42601269 |\n| CHINA 4 | CHINA 3 | 1996 | 38290290 |\n| CHINA 3 | CHINA 8 | 1996 | 21263056 |\n| CHINA 7 | CHINA 1 | 1996 | 14836937 |\n| CHINA 5 | CHINA 3 | 1996 | 13611339 |\n| CHINA 1 | CHINA 3 | 1996 | 8430793 |\n| CHINA 1 | CHINA 1 | 1996 | 1601332 |\n| CHINA 1 | CHINA 7 | 1997 | 664436721 |\n| CHINA 8 | CHINA 9 | 1997 | 585552148 |\n| CHINA 8 | CHINA 6 | 1997 | 543571889 |\n| CHINA 8 | CHINA 7 | 1997 | 516131917 |\n| CHINA 6 | CHINA 7 | 1997 | 467477883 |\n| CHINA 3 | CHINA 9 | 1997 | 444914344 |\n| CHINA 5 | CHINA 6 | 1997 | 353316321 |\n| CHINA 6 | CHINA 4 | 1997 | 338136205 |\n| CHINA 0 | CHINA 7 | 1997 | 329137493 |\n| CHINA 5 | CHINA 1 | 1997 | 328142466 |\n| CHINA 8 | CHINA 4 | 1997 | 308276385 |\n| CHINA 6 | CHINA 9 | 1997 | 306814317 |\n| CHINA 5 | CHINA 9 | 1997 | 301145803 |\n| CHINA 7 | CHINA 1 | 1997 | 299575802 |\n| CHINA 8 | CHINA 8 | 1997 | 282083295 |\n| CHINA 4 | CHINA 9 | 1997 | 280242025 |\n| CHINA 9 | CHINA 1 | 1997 | 253155313 |\n| CHINA 4 | CHINA 6 | 1997 | 234247182 |\n| CHINA 5 | CHINA 0 | 1997 | 217246162 |\n| CHINA 9 | CHINA 4 | 1997 | 215424663 |\n| CHINA 0 | CHINA 6 | 1997 | 211152240 |\n| CHINA 3 | CHINA 6 | 1997 | 205982217 |\n| CHINA 7 | CHINA 6 | 1997 | 196440117 |\n| CHINA 1 | CHINA 6 | 1997 | 195757737 |\n| CHINA 2 | CHINA 3 | 1997 | 189836909 |\n| CHINA 7 | CHINA 8 | 1997 | 189291379 |\n| CHINA 9 | CHINA 6 | 1997 | 189236146 |\n| CHINA 3 | CHINA 1 | 1997 | 188537684 |\n| CHINA 9 | CHINA 7 | 1997 | 182516267 |\n| CHINA 0 | CHINA 0 | 1997 | 182459980 |\n| CHINA 5 | CHINA 8 | 1997 | 177077882 |\n| CHINA 2 | CHINA 6 | 1997 | 176030529 |\n| CHINA 2 | CHINA 1 | 1997 | 168770050 |\n| CHINA 8 | CHINA 0 | 1997 | 167294093 |\n| CHINA 4 | CHINA 3 | 1997 | 161980658 |\n| CHINA 3 | CHINA 4 | 1997 | 154433882 |\n| CHINA 6 | CHINA 6 | 1997 | 153336736 |\n| CHINA 6 | CHINA 3 | 1997 | 151596497 |\n| CHINA 8 | CHINA 1 | 1997 | 145432603 |\n| CHINA 1 | CHINA 4 | 1997 | 126773981 |\n| CHINA 1 | CHINA 0 | 1997 | 120594770 |\n| CHINA 7 | CHINA 3 | 1997 | 119618460 |\n| CHINA 6 | CHINA 1 | 1997 | 119529805 |\n| CHINA 2 | CHINA 9 | 1997 | 114591288 |\n| CHINA 7 | CHINA 7 | 1997 | 111335941 |\n| CHINA 5 | CHINA 3 | 1997 | 111044153 |\n| CHINA 6 | CHINA 0 | 1997 | 104404276 |\n| CHINA 1 | CHINA 1 | 1997 | 98869501 |\n| CHINA 7 | CHINA 0 | 1997 | 97198605 |\n| CHINA 7 | CHINA 9 | 1997 | 92872632 |\n| CHINA 0 | CHINA 9 | 1997 | 91097832 |\n| CHINA 9 | CHINA 9 | 1997 | 86479272 |\n| CHINA 2 | CHINA 7 | 1997 | 79380820 |\n| CHINA 9 | CHINA 0 | 1997 | 78499693 |\n| CHINA 1 | CHINA 9 | 1997 | 73589328 |\n| CHINA 2 | CHINA 8 | 1997 | 71633835 |\n| CHINA 8 | CHINA 3 | 1997 | 70505885 |\n| CHINA 3 | CHINA 0 | 1997 | 61039282 |\n| CHINA 0 | CHINA 3 | 1997 | 58325113 |\n| CHINA 5 | CHINA 7 | 1997 | 55476389 |\n| CHINA 4 | CHINA 7 | 1997 | 46480159 |\n| CHINA 0 | CHINA 1 | 1997 | 38223038 |\n| CHINA 4 | CHINA 1 | 1997 | 21636342 |\n| CHINA 9 | CHINA 3 | 1997 | 13092788 |\n| CHINA 6 | CHINA 8 | 1997 | 2490092 |\n+------------+------------+------+-----------+\n\n-- Q3.3\n+------------+------------+------+-----------+\n| c_city | s_city | year | revenue |\n+------------+------------+------+-----------+\n| UNITED KI0 | UNITED KI7 | 1992 | 251282102 |\n| UNITED KI0 | UNITED KI0 | 1992 | 170005406 |\n| UNITED KI7 | UNITED KI7 | 1992 | 36835396 |\n| UNITED KI0 | UNITED KI7 | 1993 | 560335810 |\n| UNITED KI0 | UNITED KI0 | 1993 | 294257692 |\n| UNITED KI7 | UNITED KI0 | 1993 | 159005896 |\n| UNITED KI7 | UNITED KI7 | 1993 | 139029264 |\n| UNITED KI0 | UNITED KI7 | 1994 | 739847089 |\n| UNITED KI0 | UNITED KI0 | 1994 | 302339390 |\n| UNITED KI7 | UNITED KI7 | 1994 | 275609814 |\n| UNITED KI7 | UNITED KI0 | 1994 | 117654093 |\n| UNITED KI0 | UNITED KI7 | 1995 | 540994655 |\n| UNITED KI0 | UNITED KI0 | 1995 | 230825439 |\n| UNITED KI7 | UNITED KI0 | 1995 | 197347696 |\n| UNITED KI7 | UNITED KI7 | 1995 | 136620517 |\n| UNITED KI0 | UNITED KI7 | 1996 | 448412094 |\n| UNITED KI0 | UNITED KI0 | 1996 | 203511607 |\n| UNITED KI7 | UNITED KI7 | 1996 | 94528075 |\n| UNITED KI7 | UNITED KI0 | 1996 | 35448536 |\n| UNITED KI7 | UNITED KI0 | 1997 | 289323850 |\n| UNITED KI7 | UNITED KI7 | 1997 | 214791175 |\n| UNITED KI0 | UNITED KI7 | 1997 | 196510174 |\n| UNITED KI0 | UNITED KI0 | 1997 | 125066127 |\n+------------+------------+------+-----------+\n\n-- Q3.4\n+------------+------------+------+-----------+\n| c_city | s_city | year | revenue |\n+------------+------------+------+-----------+\n| UNITED KI7 | KENYA 4 | 1997 | 170083300 |\n| UNITED KI0 | MOZAMBIQU1 | 1997 | 155234463 |\n| UNITED KI0 | KENYA 4 | 1997 | 87283610 |\n+------------+------------+------+-----------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation | profit |\n+------+---------------+-------------+\n| 1992 | ARGENTINA | 13746243380 |\n| 1992 | BRAZIL | 15762831144 |\n| 1992 | CANADA | 17477043721 |\n| 1992 | PERU | 14698567030 |\n| 1992 | UNITED STATES | 14043501956 |\n| 1993 | ARGENTINA | 13992888207 |\n| 1993 | BRAZIL | 15146262693 |\n| 1993 | CANADA | 12463985574 |\n| 1993 | PERU | 11385007831 |\n| 1993 | UNITED STATES | 10651361815 |\n| 1994 | ARGENTINA | 13128610315 |\n| 1994 | BRAZIL | 13764866493 |\n| 1994 | CANADA | 13723188154 |\n| 1994 | PERU | 12784683808 |\n| 1994 | UNITED STATES | 12554422837 |\n| 1995 | ARGENTINA | 14337205612 |\n| 1995 | BRAZIL | 15068918320 |\n| 1995 | CANADA | 14529005783 |\n| 1995 | PERU | 13086675480 |\n| 1995 | UNITED STATES | 11330297649 |\n| 1996 | ARGENTINA | 13659108915 |\n| 1996 | BRAZIL | 12660837584 |\n| 1996 | CANADA | 14558903190 |\n| 1996 | PERU | 14162285166 |\n| 1996 | UNITED STATES | 11117076866 |\n| 1997 | ARGENTINA | 12556399750 |\n| 1997 | BRAZIL | 13961587144 |\n| 1997 | CANADA | 15567856947 |\n| 1997 | PERU | 13595325340 |\n| 1997 | UNITED STATES | 10779073839 |\n| 1998 | ARGENTINA | 7843424759 |\n| 1998 | BRAZIL | 8853904827 |\n| 1998 | CANADA | 8286104334 |\n| 1998 | PERU | 5822590950 |\n| 1998 | UNITED STATES | 8526236814 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation | p_category | profit |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA | MFGR#11 | 1636950553 |\n| 1997 | ARGENTINA | MFGR#12 | 1265547847 |\n| 1997 | ARGENTINA | MFGR#13 | 1505131346 |\n| 1997 | ARGENTINA | MFGR#14 | 1405447137 |\n| 1997 | ARGENTINA | MFGR#15 | 1564085340 |\n| 1997 | ARGENTINA | MFGR#21 | 1335009490 |\n| 1997 | ARGENTINA | MFGR#22 | 1309054179 |\n| 1997 | ARGENTINA | MFGR#23 | 1305213794 |\n| 1997 | ARGENTINA | MFGR#24 | 1089725126 |\n| 1997 | ARGENTINA | MFGR#25 | 1291995512 |\n| 1997 | BRAZIL | MFGR#11 | 721240147 |\n| 1997 | BRAZIL | MFGR#12 | 928318830 |\n| 1997 | BRAZIL | MFGR#13 | 1164674879 |\n| 1997 | BRAZIL | MFGR#14 | 1215622587 |\n| 1997 | BRAZIL | MFGR#15 | 940971658 |\n| 1997 | BRAZIL | MFGR#21 | 1158909618 |\n| 1997 | BRAZIL | MFGR#22 | 1251221641 |\n| 1997 | BRAZIL | MFGR#23 | 1552552455 |\n| 1997 | BRAZIL | MFGR#24 | 929057361 |\n| 1997 | BRAZIL | MFGR#25 | 574645288 |\n| 1997 | CANADA | MFGR#11 | 1170341370 |\n| 1997 | CANADA | MFGR#12 | 1220238121 |\n| 1997 | CANADA | MFGR#13 | 1245774025 |\n| 1997 | CANADA | MFGR#14 | 1032046642 |\n| 1997 | CANADA | MFGR#15 | 738650612 |\n| 1997 | CANADA | MFGR#21 | 1476055209 |\n| 1997 | CANADA | MFGR#22 | 1239005798 |\n| 1997 | CANADA | MFGR#23 | 869393804 |\n| 1997 | CANADA | MFGR#24 | 1466964051 |\n| 1997 | CANADA | MFGR#25 | 1358922727 |\n| 1997 | PERU | MFGR#11 | 1031023174 |\n| 1997 | PERU | MFGR#12 | 731821491 |\n| 1997 | PERU | MFGR#13 | 1044642877 |\n| 1997 | PERU | MFGR#14 | 654877417 |\n| 1997 | PERU | MFGR#15 | 1201769474 |\n| 1997 | PERU | MFGR#21 | 1275496672 |\n| 1997 | PERU | MFGR#22 | 599324545 |\n| 1997 | PERU | MFGR#23 | 1200754744 |\n| 1997 | PERU | MFGR#24 | 942152801 |\n| 1997 | PERU | MFGR#25 | 1064322995 |\n| 1997 | UNITED STATES | MFGR#11 | 2365218925 |\n| 1997 | UNITED STATES | MFGR#12 | 1132346574 |\n| 1997 | UNITED STATES | MFGR#13 | 2460882362 |\n| 1997 | UNITED STATES | MFGR#14 | 2190816877 |\n| 1997 | UNITED STATES | MFGR#15 | 1687829921 |\n| 1997 | UNITED STATES | MFGR#21 | 2125880770 |\n| 1997 | UNITED STATES | MFGR#22 | 2013348097 |\n| 1997 | UNITED STATES | MFGR#23 | 2570581084 |\n| 1997 | UNITED STATES | MFGR#24 | 2724372315 |\n| 1997 | UNITED STATES | MFGR#25 | 1480012758 |\n| 1998 | ARGENTINA | MFGR#11 | 783662770 |\n| 1998 | ARGENTINA | MFGR#12 | 472818450 |\n| 1998 | ARGENTINA | MFGR#13 | 585091533 |\n| 1998 | ARGENTINA | MFGR#14 | 507297527 |\n| 1998 | ARGENTINA | MFGR#15 | 549185408 |\n| 1998 | ARGENTINA | MFGR#21 | 972928972 |\n| 1998 | ARGENTINA | MFGR#22 | 1508294213 |\n| 1998 | ARGENTINA | MFGR#23 | 517896738 |\n| 1998 | ARGENTINA | MFGR#24 | 240754731 |\n| 1998 | ARGENTINA | MFGR#25 | 757030162 |\n| 1998 | BRAZIL | MFGR#11 | 826283793 |\n| 1998 | BRAZIL | MFGR#12 | 482293349 |\n| 1998 | BRAZIL | MFGR#13 | 1037202334 |\n| 1998 | BRAZIL | MFGR#14 | 743598666 |\n| 1998 | BRAZIL | MFGR#15 | 584176304 |\n| 1998 | BRAZIL | MFGR#21 | 557259779 |\n| 1998 | BRAZIL | MFGR#22 | 535654445 |\n| 1998 | BRAZIL | MFGR#23 | 403656721 |\n| 1998 | BRAZIL | MFGR#24 | 1305217551 |\n| 1998 | BRAZIL | MFGR#25 | 1109801463 |\n| 1998 | CANADA | MFGR#11 | 936169617 |\n| 1998 | CANADA | MFGR#12 | 1017751308 |\n| 1998 | CANADA | MFGR#13 | 850046376 |\n| 1998 | CANADA | MFGR#14 | 808138010 |\n| 1998 | CANADA | MFGR#15 | 701990010 |\n| 1998 | CANADA | MFGR#21 | 402611051 |\n| 1998 | CANADA | MFGR#22 | 382705122 |\n| 1998 | CANADA | MFGR#23 | 509674722 |\n| 1998 | CANADA | MFGR#24 | 1003021250 |\n| 1998 | CANADA | MFGR#25 | 574602788 |\n| 1998 | PERU | MFGR#11 | 552608732 |\n| 1998 | PERU | MFGR#12 | 500581456 |\n| 1998 | PERU | MFGR#13 | 894607711 |\n| 1998 | PERU | MFGR#14 | 386487826 |\n| 1998 | PERU | MFGR#15 | 1044780577 |\n| 1998 | PERU | MFGR#21 | 184346232 |\n| 1998 | PERU | MFGR#22 | 674942976 |\n| 1998 | PERU | MFGR#23 | 665523956 |\n| 1998 | PERU | MFGR#24 | 631374203 |\n| 1998 | PERU | MFGR#25 | 602609608 |\n| 1998 | UNITED STATES | MFGR#11 | 1230069867 |\n| 1998 | UNITED STATES | MFGR#12 | 1557720319 |\n| 1998 | UNITED STATES | MFGR#13 | 999206739 |\n| 1998 | UNITED STATES | MFGR#14 | 605040268 |\n| 1998 | UNITED STATES | MFGR#15 | 850219215 |\n| 1998 | UNITED STATES | MFGR#21 | 1032550760 |\n| 1998 | UNITED STATES | MFGR#22 | 1370141401 |\n| 1998 | UNITED STATES | MFGR#23 | 1226632297 |\n| 1998 | UNITED STATES | MFGR#24 | 1528135100 |\n| 1998 | UNITED STATES | MFGR#25 | 1127867278 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+-----------+\n| year | s_city | p_brand | profit |\n+------+------------+-----------+-----------+\n| 1997 | UNITED ST0 | MFGR#1410 | 58481513 |\n| 1997 | UNITED ST0 | MFGR#1412 | 33582225 |\n| 1997 | UNITED ST0 | MFGR#1413 | 135625490 |\n| 1997 | UNITED ST0 | MFGR#1414 | 18581969 |\n| 1997 | UNITED ST0 | MFGR#142 | 164080005 |\n| 1997 | UNITED ST0 | MFGR#1420 | 30831591 |\n| 1997 | UNITED ST0 | MFGR#1424 | 4085253 |\n| 1997 | UNITED ST0 | MFGR#1425 | 163183170 |\n| 1997 | UNITED ST0 | MFGR#1427 | 87578288 |\n| 1997 | UNITED ST0 | MFGR#1428 | 109488143 |\n| 1997 | UNITED ST0 | MFGR#143 | 198055627 |\n| 1997 | UNITED ST0 | MFGR#1430 | 52544552 |\n| 1997 | UNITED ST0 | MFGR#1432 | 158742311 |\n| 1997 | UNITED ST0 | MFGR#144 | 43479982 |\n| 1997 | UNITED ST0 | MFGR#1440 | 40412893 |\n| 1997 | UNITED ST0 | MFGR#145 | 175568435 |\n| 1997 | UNITED ST1 | MFGR#141 | 11932912 |\n| 1997 | UNITED ST1 | MFGR#1411 | 40637463 |\n| 1997 | UNITED ST1 | MFGR#1415 | 27562355 |\n| 1997 | UNITED ST1 | MFGR#1421 | 100271780 |\n| 1997 | UNITED ST1 | MFGR#1422 | 103286764 |\n| 1997 | UNITED ST1 | MFGR#1423 | 106114459 |\n| 1997 | UNITED ST1 | MFGR#1427 | 157715681 |\n| 1997 | UNITED ST1 | MFGR#1428 | 91550168 |\n| 1997 | UNITED ST1 | MFGR#1430 | 56560173 |\n| 1997 | UNITED ST1 | MFGR#1431 | 248448914 |\n| 1997 | UNITED ST1 | MFGR#1435 | 994228 |\n| 1997 | UNITED ST1 | MFGR#144 | 55729825 |\n| 1997 | UNITED ST1 | MFGR#145 | 118034196 |\n| 1997 | UNITED ST1 | MFGR#146 | 99170724 |\n| 1997 | UNITED ST1 | MFGR#147 | 5123001 |\n| 1997 | UNITED ST2 | MFGR#141 | 111908637 |\n| 1997 | UNITED ST2 | MFGR#1414 | 96864725 |\n| 1997 | UNITED ST2 | MFGR#1415 | 123601050 |\n| 1997 | UNITED ST2 | MFGR#1421 | 21014618 |\n| 1997 | UNITED ST2 | MFGR#1427 | 46524767 |\n| 1997 | UNITED ST2 | MFGR#1429 | 18800062 |\n| 1997 | UNITED ST2 | MFGR#1431 | 79199532 |\n| 1997 | UNITED ST2 | MFGR#1432 | 53841788 |\n| 1997 | UNITED ST2 | MFGR#1433 | 133842836 |\n| 1997 | UNITED ST2 | MFGR#1434 | 96443006 |\n| 1997 | UNITED ST2 | MFGR#1435 | 50858424 |\n| 1997 | UNITED ST2 | MFGR#1438 | 64571457 |\n| 1997 | UNITED ST2 | MFGR#144 | 61319000 |\n| 1997 | UNITED ST2 | MFGR#146 | 69558050 |\n| 1997 | UNITED ST2 | MFGR#147 | 41160961 |\n| 1997 | UNITED ST2 | MFGR#149 | 31735872 |\n| 1997 | UNITED ST3 | MFGR#1410 | 306449140 |\n| 1997 | UNITED ST3 | MFGR#1411 | 114677189 |\n| 1997 | UNITED ST3 | MFGR#1412 | 49229127 |\n| 1997 | UNITED ST3 | MFGR#1413 | 174911640 |\n| 1997 | UNITED ST3 | MFGR#1415 | 134932298 |\n| 1997 | UNITED ST3 | MFGR#1416 | 97111854 |\n| 1997 | UNITED ST3 | MFGR#1417 | 176279103 |\n| 1997 | UNITED ST3 | MFGR#1418 | 70684147 |\n| 1997 | UNITED ST3 | MFGR#1420 | 27591782 |\n| 1997 | UNITED ST3 | MFGR#1422 | 39411253 |\n| 1997 | UNITED ST3 | MFGR#1424 | 226736650 |\n| 1997 | UNITED ST3 | MFGR#1426 | 63997112 |\n| 1997 | UNITED ST3 | MFGR#1429 | 556053 |\n| 1997 | UNITED ST3 | MFGR#143 | 73550925 |\n| 1997 | UNITED ST3 | MFGR#1430 | 218807697 |\n| 1997 | UNITED ST3 | MFGR#1431 | 39936281 |\n| 1997 | UNITED ST3 | MFGR#1432 | 44356689 |\n| 1997 | UNITED ST3 | MFGR#1435 | 49225455 |\n| 1997 | UNITED ST3 | MFGR#1436 | 90326644 |\n| 1997 | UNITED ST3 | MFGR#1439 | 84615817 |\n| 1997 | UNITED ST3 | MFGR#144 | 59081596 |\n| 1997 | UNITED ST3 | MFGR#1440 | 59601014 |\n| 1997 | UNITED ST3 | MFGR#145 | 100692258 |\n| 1997 | UNITED ST3 | MFGR#147 | 142417874 |\n| 1997 | UNITED ST3 | MFGR#148 | 38233221 |\n| 1997 | UNITED ST5 | MFGR#1416 | 62387773 |\n| 1997 | UNITED ST5 | MFGR#1417 | 54974702 |\n| 1997 | UNITED ST5 | MFGR#1418 | 87301086 |\n| 1997 | UNITED ST5 | MFGR#1421 | 9869673 |\n| 1997 | UNITED ST5 | MFGR#1422 | 58912225 |\n| 1997 | UNITED ST5 | MFGR#1424 | 80038584 |\n| 1997 | UNITED ST5 | MFGR#1428 | 44422717 |\n| 1997 | UNITED ST5 | MFGR#1430 | 67186074 |\n| 1997 | UNITED ST5 | MFGR#1433 | 105646942 |\n| 1997 | UNITED ST5 | MFGR#1434 | 13923867 |\n| 1997 | UNITED ST5 | MFGR#145 | 104286534 |\n| 1997 | UNITED ST5 | MFGR#146 | 20965182 |\n| 1997 | UNITED ST5 | MFGR#148 | 170596496 |\n| 1997 | UNITED ST5 | MFGR#149 | 42639213 |\n| 1997 | UNITED ST6 | MFGR#1411 | 48199726 |\n| 1997 | UNITED ST6 | MFGR#1413 | 28825982 |\n| 1997 | UNITED ST6 | MFGR#1414 | 107783723 |\n| 1997 | UNITED ST6 | MFGR#1415 | 92119787 |\n| 1997 | UNITED ST6 | MFGR#1416 | 35390328 |\n| 1997 | UNITED ST6 | MFGR#1417 | 92594053 |\n| 1997 | UNITED ST6 | MFGR#1418 | 67638716 |\n| 1997 | UNITED ST6 | MFGR#1421 | 98608466 |\n| 1997 | UNITED ST6 | MFGR#143 | 23938737 |\n| 1997 | UNITED ST6 | MFGR#1432 | 104846191 |\n| 1997 | UNITED ST6 | MFGR#1435 | 185809031 |\n| 1997 | UNITED ST6 | MFGR#1436 | 82920407 |\n| 1997 | UNITED ST6 | MFGR#1438 | 137524730 |\n| 1997 | UNITED ST6 | MFGR#146 | 28124052 |\n| 1997 | UNITED ST7 | MFGR#141 | 65266383 |\n| 1997 | UNITED ST7 | MFGR#1411 | 78295166 |\n| 1997 | UNITED ST7 | MFGR#1413 | 37554700 |\n| 1997 | UNITED ST7 | MFGR#1414 | 20428356 |\n| 1997 | UNITED ST7 | MFGR#1416 | 92381468 |\n| 1997 | UNITED ST7 | MFGR#1418 | 105276410 |\n| 1997 | UNITED ST7 | MFGR#1419 | 116086880 |\n| 1997 | UNITED ST7 | MFGR#1420 | 62010492 |\n| 1997 | UNITED ST7 | MFGR#1428 | 50904528 |\n| 1997 | UNITED ST7 | MFGR#1430 | 103558679 |\n| 1997 | UNITED ST7 | MFGR#1431 | 38342548 |\n| 1997 | UNITED ST7 | MFGR#1436 | 59859992 |\n| 1997 | UNITED ST7 | MFGR#1437 | 90701341 |\n| 1997 | UNITED ST7 | MFGR#147 | 133840269 |\n| 1997 | UNITED ST7 | MFGR#148 | 175852097 |\n| 1997 | UNITED ST9 | MFGR#1411 | 62786695 |\n| 1997 | UNITED ST9 | MFGR#1416 | 25354497 |\n| 1997 | UNITED ST9 | MFGR#1417 | 47367797 |\n| 1997 | UNITED ST9 | MFGR#1418 | 27220077 |\n| 1997 | UNITED ST9 | MFGR#142 | 41015203 |\n| 1997 | UNITED ST9 | MFGR#1423 | 41473506 |\n| 1997 | UNITED ST9 | MFGR#1424 | 10735092 |\n| 1997 | UNITED ST9 | MFGR#1425 | 27926087 |\n| 1997 | UNITED ST9 | MFGR#1426 | 136645966 |\n| 1997 | UNITED ST9 | MFGR#1430 | 41283531 |\n| 1997 | UNITED ST9 | MFGR#1433 | 497505 |\n| 1997 | UNITED ST9 | MFGR#1434 | 101147110 |\n| 1997 | UNITED ST9 | MFGR#1436 | 30923170 |\n| 1997 | UNITED ST9 | MFGR#145 | 18049495 |\n| 1997 | UNITED ST9 | MFGR#146 | 43726737 |\n| 1998 | UNITED ST0 | MFGR#1413 | 131487843 |\n| 1998 | UNITED ST0 | MFGR#1426 | 52942692 |\n| 1998 | UNITED ST0 | MFGR#146 | 13567224 |\n| 1998 | UNITED ST1 | MFGR#1410 | 65992198 |\n| 1998 | UNITED ST1 | MFGR#1416 | 115552383 |\n| 1998 | UNITED ST1 | MFGR#1418 | 15646035 |\n| 1998 | UNITED ST1 | MFGR#1419 | 129708776 |\n| 1998 | UNITED ST1 | MFGR#1428 | 18176281 |\n| 1998 | UNITED ST1 | MFGR#1431 | 17985830 |\n| 1998 | UNITED ST1 | MFGR#1436 | 16714417 |\n| 1998 | UNITED ST1 | MFGR#145 | 48297153 |\n| 1998 | UNITED ST2 | MFGR#1418 | 9240384 |\n| 1998 | UNITED ST2 | MFGR#1419 | 40909344 |\n| 1998 | UNITED ST2 | MFGR#1420 | 78625306 |\n| 1998 | UNITED ST2 | MFGR#1426 | 67161050 |\n| 1998 | UNITED ST2 | MFGR#1430 | 19028508 |\n| 1998 | UNITED ST2 | MFGR#1434 | 127804385 |\n| 1998 | UNITED ST2 | MFGR#1435 | 75092689 |\n| 1998 | UNITED ST2 | MFGR#1436 | 54579894 |\n| 1998 | UNITED ST2 | MFGR#1440 | 29067722 |\n| 1998 | UNITED ST2 | MFGR#148 | 78886426 |\n| 1998 | UNITED ST3 | MFGR#141 | 4311846 |\n| 1998 | UNITED ST3 | MFGR#1412 | 98979253 |\n| 1998 | UNITED ST3 | MFGR#1415 | 102275672 |\n| 1998 | UNITED ST3 | MFGR#1416 | 50781431 |\n| 1998 | UNITED ST3 | MFGR#1419 | 37451476 |\n| 1998 | UNITED ST3 | MFGR#1420 | 24660608 |\n| 1998 | UNITED ST3 | MFGR#1422 | 98548762 |\n| 1998 | UNITED ST3 | MFGR#1424 | 96601854 |\n| 1998 | UNITED ST3 | MFGR#1425 | 74508450 |\n| 1998 | UNITED ST3 | MFGR#1426 | 330583054 |\n| 1998 | UNITED ST3 | MFGR#1427 | 41352585 |\n| 1998 | UNITED ST3 | MFGR#1428 | 61979722 |\n| 1998 | UNITED ST3 | MFGR#1429 | 869295 |\n| 1998 | UNITED ST3 | MFGR#1432 | 66991135 |\n| 1998 | UNITED ST3 | MFGR#146 | 35929398 |\n| 1998 | UNITED ST3 | MFGR#147 | 8484972 |\n| 1998 | UNITED ST3 | MFGR#149 | 11793257 |\n| 1998 | UNITED ST5 | MFGR#1410 | 55951811 |\n| 1998 | UNITED ST5 | MFGR#1413 | 13403140 |\n| 1998 | UNITED ST5 | MFGR#142 | 24156762 |\n| 1998 | UNITED ST5 | MFGR#1422 | 105826683 |\n| 1998 | UNITED ST5 | MFGR#1430 | 67851607 |\n| 1998 | UNITED ST5 | MFGR#1431 | 84833774 |\n| 1998 | UNITED ST5 | MFGR#1434 | 45541810 |\n| 1998 | UNITED ST5 | MFGR#1437 | 33353745 |\n| 1998 | UNITED ST5 | MFGR#146 | 19891496 |\n| 1998 | UNITED ST6 | MFGR#1413 | 135522572 |\n| 1998 | UNITED ST6 | MFGR#1416 | 185707286 |\n| 1998 | UNITED ST6 | MFGR#1417 | 80511133 |\n| 1998 | UNITED ST6 | MFGR#1419 | 127132766 |\n| 1998 | UNITED ST6 | MFGR#142 | 72629474 |\n| 1998 | UNITED ST6 | MFGR#1435 | 158543190 |\n| 1998 | UNITED ST7 | MFGR#1412 | 56750777 |\n| 1998 | UNITED ST7 | MFGR#1424 | 89508621 |\n| 1998 | UNITED ST7 | MFGR#1425 | 160377031 |\n| 1998 | UNITED ST7 | MFGR#1434 | 20882477 |\n| 1998 | UNITED ST7 | MFGR#146 | 100783548 |\n| 1998 | UNITED ST7 | MFGR#147 | 61595522 |\n| 1998 | UNITED ST9 | MFGR#1412 | 5049765 |\n| 1998 | UNITED ST9 | MFGR#142 | 69919113 |\n| 1998 | UNITED ST9 | MFGR#1425 | 11003199 |\n| 1998 | UNITED ST9 | MFGR#1426 | 103616972 |\n| 1998 | UNITED ST9 | MFGR#1435 | 18879758 |\n| 1998 | UNITED ST9 | MFGR#1438 | 101903219 |\n+------+------------+-----------+-----------+\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_9","title":"\u591a\u8868\u67e5\u8be2\u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":"-- Q1.1\n+--------------+\n| revenue |\n+--------------+\n| 218453880421 |\n+--------------+\n\n-- Q1.2\n+---------+\n| revenue |\n+---------+\n| NULL |\n+---------+\n\n-- Q1.3\n+-------------+\n| revenue |\n+-------------+\n| 17527575453 |\n+-------------+\n\n-- Q2.1\n+------------+------+-----------+\n| lo_revenue | year | p_brand |\n+------------+------+-----------+\n| 1135676414 | 1992 | MFGR#121 |\n| 1221327580 | 1992 | MFGR#1210 |\n| 1101539324 | 1992 | MFGR#1211 |\n| 1298411712 | 1992 | MFGR#1212 |\n| 1248062482 | 1992 | MFGR#1213 |\n| 1340976936 | 1992 | MFGR#1214 |\n| 1266304940 | 1992 | MFGR#1215 |\n| 1349693562 | 1992 | MFGR#1216 |\n| 1350186870 | 1992 | MFGR#1217 |\n| 1200404140 | 1992 | MFGR#1218 |\n| 1076087188 | 1992 | MFGR#1219 |\n| 1310653344 | 1992 | MFGR#122 |\n| 1080525764 | 1992 | MFGR#1220 |\n| 1112241266 | 1992 | MFGR#1221 |\n| 1181525554 | 1992 | MFGR#1222 |\n| 1070897302 | 1992 | MFGR#1223 |\n| 1407505222 | 1992 | MFGR#1224 |\n| 1141665736 | 1992 | MFGR#1225 |\n| 1228123186 | 1992 | MFGR#1226 |\n| 1163518776 | 1992 | MFGR#1227 |\n| 1289285184 | 1992 | MFGR#1228 |\n| 1281716860 | 1992 | MFGR#1229 |\n| 1579511670 | 1992 | MFGR#123 |\n| 937070174 | 1992 | MFGR#1230 |\n| 1184873312 | 1992 | MFGR#1231 |\n| 1328550304 | 1992 | MFGR#1232 |\n| 1227770200 | 1992 | MFGR#1233 |\n| 1334798562 | 1992 | MFGR#1234 |\n| 1280580140 | 1992 | MFGR#1235 |\n| 1003785122 | 1992 | MFGR#1236 |\n| 1182963006 | 1992 | MFGR#1237 |\n| 954847540 | 1992 | MFGR#1238 |\n| 1276518748 | 1992 | MFGR#1239 |\n| 1144708392 | 1992 | MFGR#124 |\n| 1480958496 | 1992 | MFGR#1240 |\n| 957554190 | 1992 | MFGR#125 |\n| 1184349232 | 1992 | MFGR#126 |\n| 1412303264 | 1992 | MFGR#127 |\n| 1084613292 | 1992 | MFGR#128 |\n| 1163974704 | 1992 | MFGR#129 |\n| 1646175404 | 1993 | MFGR#121 |\n| 1296321412 | 1993 | MFGR#1210 |\n| 1269487796 | 1993 | MFGR#1211 |\n| 1571278566 | 1993 | MFGR#1212 |\n| 1276510058 | 1993 | MFGR#1213 |\n| 1233674474 | 1993 | MFGR#1214 |\n| 1269375950 | 1993 | MFGR#1215 |\n| 1276707800 | 1993 | MFGR#1216 |\n| 1326745902 | 1993 | MFGR#1217 |\n| 1367971710 | 1993 | MFGR#1218 |\n| 1293900066 | 1993 | MFGR#1219 |\n| 1245065968 | 1993 | MFGR#122 |\n| 1061660254 | 1993 | MFGR#1220 |\n| 1086692674 | 1993 | MFGR#1221 |\n| 1513842406 | 1993 | MFGR#1222 |\n| 1067088700 | 1993 | MFGR#1223 |\n| 1831832170 | 1993 | MFGR#1224 |\n| 946014762 | 1993 | MFGR#1225 |\n| 1478072248 | 1993 | MFGR#1226 |\n| 1184357774 | 1993 | MFGR#1227 |\n| 1167014116 | 1993 | MFGR#1228 |\n| 1234906982 | 1993 | MFGR#1229 |\n| 1275727736 | 1993 | MFGR#123 |\n| 1251068620 | 1993 | MFGR#1230 |\n| 1160655270 | 1993 | MFGR#1231 |\n| 1394746196 | 1993 | MFGR#1232 |\n| 1031142832 | 1993 | MFGR#1233 |\n| 1303871516 | 1993 | MFGR#1234 |\n| 1151558960 | 1993 | MFGR#1235 |\n| 1183757334 | 1993 | MFGR#1236 |\n| 1219237152 | 1993 | MFGR#1237 |\n| 889228020 | 1993 | MFGR#1238 |\n| 1190512654 | 1993 | MFGR#1239 |\n| 1321172474 | 1993 | MFGR#124 |\n| 1577460118 | 1993 | MFGR#1240 |\n| 1232449078 | 1993 | MFGR#125 |\n| 1234253508 | 1993 | MFGR#126 |\n| 1308876648 | 1993 | MFGR#127 |\n| 1463314002 | 1993 | MFGR#128 |\n| 1096096790 | 1993 | MFGR#129 |\n| 1128811296 | 1994 | MFGR#121 |\n| 1290809698 | 1994 | MFGR#1210 |\n| 1263241270 | 1994 | MFGR#1211 |\n| 1136664696 | 1994 | MFGR#1212 |\n| 1357571714 | 1994 | MFGR#1213 |\n| 1068004660 | 1994 | MFGR#1214 |\n| 1308800484 | 1994 | MFGR#1215 |\n| 1117292682 | 1994 | MFGR#1216 |\n| 1375691282 | 1994 | MFGR#1217 |\n| 1093348694 | 1994 | MFGR#1218 |\n| 1134545884 | 1994 | MFGR#1219 |\n| 1319768124 | 1994 | MFGR#122 |\n| 1125164344 | 1994 | MFGR#1220 |\n| 1197237994 | 1994 | MFGR#1221 |\n| 1202032882 | 1994 | MFGR#1222 |\n| 1110268808 | 1994 | MFGR#1223 |\n| 1474844604 | 1994 | MFGR#1224 |\n| 1141491910 | 1994 | MFGR#1225 |\n| 1492604490 | 1994 | MFGR#1226 |\n| 1303414962 | 1994 | MFGR#1227 |\n| 1147387094 | 1994 | MFGR#1228 |\n| 1295836746 | 1994 | MFGR#1229 |\n| 1160899184 | 1994 | MFGR#123 |\n| 986540824 | 1994 | MFGR#1230 |\n| 1207092296 | 1994 | MFGR#1231 |\n| 1439730662 | 1994 | MFGR#1232 |\n| 1277964476 | 1994 | MFGR#1233 |\n| 1486495354 | 1994 | MFGR#1234 |\n| 1197361918 | 1994 | MFGR#1235 |\n| 1231452194 | 1994 | MFGR#1236 |\n| 1085139630 | 1994 | MFGR#1237 |\n| 1147021562 | 1994 | MFGR#1238 |\n| 1159711706 | 1994 | MFGR#1239 |\n| 1369146644 | 1994 | MFGR#124 |\n| 1747471474 | 1994 | MFGR#1240 |\n| 1120976608 | 1994 | MFGR#125 |\n| 1314073028 | 1994 | MFGR#126 |\n| 1245142366 | 1994 | MFGR#127 |\n| 1173691328 | 1994 | MFGR#128 |\n| 1069083050 | 1994 | MFGR#129 |\n| 1412939022 | 1995 | MFGR#121 |\n| 1205785606 | 1995 | MFGR#1210 |\n| 1290332184 | 1995 | MFGR#1211 |\n| 1226578566 | 1995 | MFGR#1212 |\n| 1199172958 | 1995 | MFGR#1213 |\n| 1125141608 | 1995 | MFGR#1214 |\n| 1345057510 | 1995 | MFGR#1215 |\n| 1338001944 | 1995 | MFGR#1216 |\n| 1450724898 | 1995 | MFGR#1217 |\n| 1314053270 | 1995 | MFGR#1218 |\n| 1039318006 | 1995 | MFGR#1219 |\n| 1449455482 | 1995 | MFGR#122 |\n| 1035912262 | 1995 | MFGR#1220 |\n| 1271482702 | 1995 | MFGR#1221 |\n| 1128736820 | 1995 | MFGR#1222 |\n| 1201330298 | 1995 | MFGR#1223 |\n| 1525400702 | 1995 | MFGR#1224 |\n| 1343339172 | 1995 | MFGR#1225 |\n| 1145137496 | 1995 | MFGR#1226 |\n| 1060722600 | 1995 | MFGR#1227 |\n| 1266714170 | 1995 | MFGR#1228 |\n| 1095920488 | 1995 | MFGR#1229 |\n| 1321422154 | 1995 | MFGR#123 |\n| 1205471716 | 1995 | MFGR#1230 |\n| 999704292 | 1995 | MFGR#1231 |\n| 1430601506 | 1995 | MFGR#1232 |\n| 1114299142 | 1995 | MFGR#1233 |\n| 1420046118 | 1995 | MFGR#1234 |\n| 1244850478 | 1995 | MFGR#1235 |\n| 1269131002 | 1995 | MFGR#1236 |\n| 1145694540 | 1995 | MFGR#1237 |\n| 1098637824 | 1995 | MFGR#1238 |\n| 1187703424 | 1995 | MFGR#1239 |\n| 1170843630 | 1995 | MFGR#124 |\n| 1414415776 | 1995 | MFGR#1240 |\n| 1076493744 | 1995 | MFGR#125 |\n| 1211598042 | 1995 | MFGR#126 |\n| 1331956224 | 1995 | MFGR#127 |\n| 1293921912 | 1995 | MFGR#128 |\n| 1017498802 | 1995 | MFGR#129 |\n| 1047758290 | 1996 | MFGR#121 |\n| 1287290106 | 1996 | MFGR#1210 |\n| 1190130678 | 1996 | MFGR#1211 |\n| 1349252880 | 1996 | MFGR#1212 |\n| 992594174 | 1996 | MFGR#1213 |\n| 1166499010 | 1996 | MFGR#1214 |\n| 1404369714 | 1996 | MFGR#1215 |\n| 1203618668 | 1996 | MFGR#1216 |\n| 1409796774 | 1996 | MFGR#1217 |\n| 1057686172 | 1996 | MFGR#1218 |\n| 1172492660 | 1996 | MFGR#1219 |\n| 1424220984 | 1996 | MFGR#122 |\n| 1036888430 | 1996 | MFGR#1220 |\n| 998638828 | 1996 | MFGR#1221 |\n| 1358938712 | 1996 | MFGR#1222 |\n| 1257525508 | 1996 | MFGR#1223 |\n| 1449689712 | 1996 | MFGR#1224 |\n| 1321241174 | 1996 | MFGR#1225 |\n| 1335349458 | 1996 | MFGR#1226 |\n| 967676170 | 1996 | MFGR#1227 |\n| 1219710782 | 1996 | MFGR#1228 |\n| 1317919114 | 1996 | MFGR#1229 |\n| 1132435704 | 1996 | MFGR#123 |\n| 1057759996 | 1996 | MFGR#1230 |\n| 1178962388 | 1996 | MFGR#1231 |\n| 1405611792 | 1996 | MFGR#1232 |\n| 1327359894 | 1996 | MFGR#1233 |\n| 1142298900 | 1996 | MFGR#1234 |\n| 957296148 | 1996 | MFGR#1235 |\n| 1136498730 | 1996 | MFGR#1236 |\n| 1185232334 | 1996 | MFGR#1237 |\n| 933352296 | 1996 | MFGR#1238 |\n| 1341387438 | 1996 | MFGR#1239 |\n| 1121335438 | 1996 | MFGR#124 |\n| 1642335900 | 1996 | MFGR#1240 |\n| 953728666 | 1996 | MFGR#125 |\n| 1116061768 | 1996 | MFGR#126 |\n| 1271747782 | 1996 | MFGR#127 |\n| 1102021236 | 1996 | MFGR#128 |\n| 1121141260 | 1996 | MFGR#129 |\n| 1174026414 | 1997 | MFGR#121 |\n| 1232575784 | 1997 | MFGR#1210 |\n| 1097177522 | 1997 | MFGR#1211 |\n| 1179187784 | 1997 | MFGR#1212 |\n| 848613340 | 1997 | MFGR#1213 |\n| 1023943820 | 1997 | MFGR#1214 |\n| 1263544492 | 1997 | MFGR#1215 |\n| 1384270280 | 1997 | MFGR#1216 |\n| 1555989914 | 1997 | MFGR#1217 |\n| 1414107440 | 1997 | MFGR#1218 |\n| 1122339054 | 1997 | MFGR#1219 |\n| 1329832490 | 1997 | MFGR#122 |\n| 1188932314 | 1997 | MFGR#1220 |\n| 1177696342 | 1997 | MFGR#1221 |\n| 1057977920 | 1997 | MFGR#1222 |\n| 1074196422 | 1997 | MFGR#1223 |\n| 1349526332 | 1997 | MFGR#1224 |\n| 900804584 | 1997 | MFGR#1225 |\n| 1402721444 | 1997 | MFGR#1226 |\n| 1012023140 | 1997 | MFGR#1227 |\n| 1171157474 | 1997 | MFGR#1228 |\n| 1245488032 | 1997 | MFGR#1229 |\n| 1293006336 | 1997 | MFGR#123 |\n| 1143601882 | 1997 | MFGR#1230 |\n| 1005203580 | 1997 | MFGR#1231 |\n| 1355849312 | 1997 | MFGR#1232 |\n| 1068911952 | 1997 | MFGR#1233 |\n| 1429869430 | 1997 | MFGR#1234 |\n| 1534302840 | 1997 | MFGR#1235 |\n| 1237754358 | 1997 | MFGR#1236 |\n| 1279276114 | 1997 | MFGR#1237 |\n| 803906838 | 1997 | MFGR#1238 |\n| 1221513428 | 1997 | MFGR#1239 |\n| 1086496174 | 1997 | MFGR#124 |\n| 1350265384 | 1997 | MFGR#1240 |\n| 958198730 | 1997 | MFGR#125 |\n| 1141393136 | 1997 | MFGR#126 |\n| 1166149184 | 1997 | MFGR#127 |\n| 1390266208 | 1997 | MFGR#128 |\n| 1311277552 | 1997 | MFGR#129 |\n| 689151850 | 1998 | MFGR#121 |\n| 834304832 | 1998 | MFGR#1210 |\n| 634136336 | 1998 | MFGR#1211 |\n| 748683032 | 1998 | MFGR#1212 |\n| 665481806 | 1998 | MFGR#1213 |\n| 609746004 | 1998 | MFGR#1214 |\n| 732202264 | 1998 | MFGR#1215 |\n| 758267796 | 1998 | MFGR#1216 |\n| 719016994 | 1998 | MFGR#1217 |\n| 641246668 | 1998 | MFGR#1218 |\n| 692365724 | 1998 | MFGR#1219 |\n| 624880054 | 1998 | MFGR#122 |\n| 696247922 | 1998 | MFGR#1220 |\n| 679690796 | 1998 | MFGR#1221 |\n| 710832322 | 1998 | MFGR#1222 |\n| 689779644 | 1998 | MFGR#1223 |\n| 793813382 | 1998 | MFGR#1224 |\n| 580417756 | 1998 | MFGR#1225 |\n| 838831414 | 1998 | MFGR#1226 |\n| 716932680 | 1998 | MFGR#1227 |\n| 503099910 | 1998 | MFGR#1228 |\n| 766277720 | 1998 | MFGR#1229 |\n| 592661122 | 1998 | MFGR#123 |\n| 874362486 | 1998 | MFGR#1230 |\n| 797888984 | 1998 | MFGR#1231 |\n| 848124910 | 1998 | MFGR#1232 |\n| 813934376 | 1998 | MFGR#1233 |\n| 857734480 | 1998 | MFGR#1234 |\n| 704555562 | 1998 | MFGR#1235 |\n| 723654172 | 1998 | MFGR#1236 |\n| 683237138 | 1998 | MFGR#1237 |\n| 489478462 | 1998 | MFGR#1238 |\n| 828303606 | 1998 | MFGR#1239 |\n| 660164742 | 1998 | MFGR#124 |\n| 830624906 | 1998 | MFGR#1240 |\n| 720579248 | 1998 | MFGR#125 |\n| 683315160 | 1998 | MFGR#126 |\n| 755014122 | 1998 | MFGR#127 |\n| 722832994 | 1998 | MFGR#128 |\n| 637539146 | 1998 | MFGR#129 |\n+------------+------+-----------+\n\n-- Q2.2\n+------------+------+-----------+\n| lo_revenue | year | p_brand |\n+------------+------+-----------+\n| 1419049858 | 1992 | MFGR#2221 |\n| 1567692788 | 1992 | MFGR#2222 |\n| 1530104004 | 1992 | MFGR#2223 |\n| 1302977924 | 1992 | MFGR#2224 |\n| 1293057178 | 1992 | MFGR#2225 |\n| 1419301096 | 1992 | MFGR#2226 |\n| 1491112632 | 1992 | MFGR#2227 |\n| 1513803750 | 1992 | MFGR#2228 |\n| 1533042206 | 1993 | MFGR#2221 |\n| 1382951194 | 1993 | MFGR#2222 |\n| 1516441504 | 1993 | MFGR#2223 |\n| 1339325414 | 1993 | MFGR#2224 |\n| 1547708456 | 1993 | MFGR#2225 |\n| 1474175036 | 1993 | MFGR#2226 |\n| 1563935532 | 1993 | MFGR#2227 |\n| 1361760432 | 1993 | MFGR#2228 |\n| 1371555036 | 1994 | MFGR#2221 |\n| 1333049614 | 1994 | MFGR#2222 |\n| 1467987180 | 1994 | MFGR#2223 |\n| 1415738080 | 1994 | MFGR#2224 |\n| 1442503934 | 1994 | MFGR#2225 |\n| 1644991838 | 1994 | MFGR#2226 |\n| 1441674256 | 1994 | MFGR#2227 |\n| 1652450700 | 1994 | MFGR#2228 |\n| 1550874148 | 1995 | MFGR#2221 |\n| 1522709584 | 1995 | MFGR#2222 |\n| 1275665150 | 1995 | MFGR#2223 |\n| 1179531414 | 1995 | MFGR#2224 |\n| 1416580078 | 1995 | MFGR#2225 |\n| 1494712766 | 1995 | MFGR#2226 |\n| 1605005080 | 1995 | MFGR#2227 |\n| 1791873572 | 1995 | MFGR#2228 |\n| 1400020016 | 1996 | MFGR#2221 |\n| 1554620170 | 1996 | MFGR#2222 |\n| 1312190628 | 1996 | MFGR#2223 |\n| 1313719834 | 1996 | MFGR#2224 |\n| 1531641792 | 1996 | MFGR#2225 |\n| 1616355468 | 1996 | MFGR#2226 |\n| 1459126606 | 1996 | MFGR#2227 |\n| 1639331748 | 1996 | MFGR#2228 |\n| 1454684764 | 1997 | MFGR#2221 |\n| 1329067558 | 1997 | MFGR#2222 |\n| 1496576784 | 1997 | MFGR#2223 |\n| 1260844162 | 1997 | MFGR#2224 |\n| 1514782406 | 1997 | MFGR#2225 |\n| 1495778514 | 1997 | MFGR#2226 |\n| 1457715798 | 1997 | MFGR#2227 |\n| 1550625970 | 1997 | MFGR#2228 |\n| 670609008 | 1998 | MFGR#2221 |\n| 818694274 | 1998 | MFGR#2222 |\n| 918219154 | 1998 | MFGR#2223 |\n| 826636144 | 1998 | MFGR#2224 |\n| 820804190 | 1998 | MFGR#2225 |\n| 907030088 | 1998 | MFGR#2226 |\n| 781012810 | 1998 | MFGR#2227 |\n| 795878206 | 1998 | MFGR#2228 |\n+------------+------+-----------+\n\n-- Q2.3\n+------------+------+-----------+\n| lo_revenue | year | p_brand |\n+------------+------+-----------+\n| 1452854972 | 1992 | MFGR#2239 |\n| 1410477918 | 1993 | MFGR#2239 |\n| 1328290268 | 1994 | MFGR#2239 |\n| 1427678672 | 1995 | MFGR#2239 |\n| 1456985730 | 1996 | MFGR#2239 |\n| 1467793064 | 1997 | MFGR#2239 |\n| 760511462 | 1998 | MFGR#2239 |\n+------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation | s_nation | year | lo_revenue |\n+-----------+-----------+------+-------------+\n| INDONESIA | INDONESIA | 1992 | 13811397976 |\n| CHINA | INDONESIA | 1992 | 13232157738 |\n| CHINA | CHINA | 1992 | 12912862954 |\n| VIETNAM | INDONESIA | 1992 | 12680363414 |\n| VIETNAM | CHINA | 1992 | 12665688780 |\n| INDONESIA | CHINA | 1992 | 12621419066 |\n| INDIA | INDONESIA | 1992 | 12477614708 |\n| JAPAN | INDONESIA | 1992 | 12445131276 |\n| CHINA | INDIA | 1992 | 12379662702 |\n| CHINA | JAPAN | 1992 | 12315357786 |\n| JAPAN | CHINA | 1992 | 12134201310 |\n| INDIA | CHINA | 1992 | 12132923622 |\n| VIETNAM | JAPAN | 1992 | 11727572698 |\n| JAPAN | INDIA | 1992 | 11605499970 |\n| INDONESIA | INDIA | 1992 | 11540406436 |\n| VIETNAM | INDIA | 1992 | 11397022802 |\n| INDONESIA | JAPAN | 1992 | 11327531220 |\n| JAPAN | JAPAN | 1992 | 11296069422 |\n| INDIA | JAPAN | 1992 | 10843918562 |\n| CHINA | VIETNAM | 1992 | 10824644052 |\n| JAPAN | VIETNAM | 1992 | 10803385110 |\n| INDIA | INDIA | 1992 | 10722487510 |\n| INDONESIA | VIETNAM | 1992 | 10605276744 |\n| INDIA | VIETNAM | 1992 | 10490661242 |\n| VIETNAM | VIETNAM | 1992 | 10223463556 |\n| INDONESIA | INDONESIA | 1993 | 13862726524 |\n| INDONESIA | CHINA | 1993 | 13225782498 |\n| CHINA | INDONESIA | 1993 | 13163026732 |\n| VIETNAM | INDONESIA | 1993 | 13023278704 |\n| CHINA | CHINA | 1993 | 12889027574 |\n| CHINA | INDIA | 1993 | 12843388242 |\n| VIETNAM | CHINA | 1993 | 12827159998 |\n| INDIA | INDONESIA | 1993 | 12662117188 |\n| JAPAN | CHINA | 1993 | 12584587990 |\n| INDIA | CHINA | 1993 | 12418707584 |\n| CHINA | JAPAN | 1993 | 12390933768 |\n| VIETNAM | INDIA | 1993 | 12322348954 |\n| INDONESIA | INDIA | 1993 | 12303328612 |\n| INDONESIA | JAPAN | 1993 | 12295210498 |\n| JAPAN | INDONESIA | 1993 | 12107892626 |\n| INDIA | JAPAN | 1993 | 11990417970 |\n| CHINA | VIETNAM | 1993 | 11770046456 |\n| VIETNAM | JAPAN | 1993 | 11748533734 |\n| INDONESIA | VIETNAM | 1993 | 11680575444 |\n| JAPAN | INDIA | 1993 | 11646686314 |\n| INDIA | INDIA | 1993 | 11143151598 |\n| VIETNAM | VIETNAM | 1993 | 11108322366 |\n| JAPAN | JAPAN | 1993 | 10860637166 |\n| JAPAN | VIETNAM | 1993 | 10813139306 |\n| INDIA | VIETNAM | 1993 | 10467742974 |\n| VIETNAM | CHINA | 1994 | 13419766884 |\n| CHINA | CHINA | 1994 | 13297885930 |\n| INDONESIA | CHINA | 1994 | 12967201820 |\n| CHINA | JAPAN | 1994 | 12698074042 |\n| VIETNAM | INDONESIA | 1994 | 12694883862 |\n| JAPAN | CHINA | 1994 | 12640018436 |\n| INDONESIA | INDONESIA | 1994 | 12630662172 |\n| CHINA | INDIA | 1994 | 12595165622 |\n| CHINA | INDONESIA | 1994 | 12469575792 |\n| VIETNAM | JAPAN | 1994 | 12463946094 |\n| INDONESIA | INDIA | 1994 | 12396824490 |\n| INDIA | INDONESIA | 1994 | 12336379718 |\n| INDONESIA | JAPAN | 1994 | 12282391938 |\n| JAPAN | INDONESIA | 1994 | 12026069236 |\n| CHINA | VIETNAM | 1994 | 11770637466 |\n| INDIA | CHINA | 1994 | 11630045428 |\n| VIETNAM | INDIA | 1994 | 11578797382 |\n| JAPAN | JAPAN | 1994 | 11507642964 |\n| JAPAN | INDIA | 1994 | 11291637744 |\n| INDONESIA | VIETNAM | 1994 | 11248692736 |\n| INDIA | INDIA | 1994 | 11169873030 |\n| VIETNAM | VIETNAM | 1994 | 10836996318 |\n| INDIA | JAPAN | 1994 | 10788269948 |\n| JAPAN | VIETNAM | 1994 | 10551643274 |\n| INDIA | VIETNAM | 1994 | 10502079630 |\n| CHINA | INDONESIA | 1995 | 14149078888 |\n| INDONESIA | CHINA | 1995 | 13857241240 |\n| CHINA | CHINA | 1995 | 13249333224 |\n| JAPAN | CHINA | 1995 | 13039778770 |\n| VIETNAM | CHINA | 1995 | 12665462536 |\n| INDONESIA | INDONESIA | 1995 | 12537062642 |\n| VIETNAM | JAPAN | 1995 | 12527914040 |\n| CHINA | INDIA | 1995 | 12493312748 |\n| VIETNAM | INDIA | 1995 | 12396883914 |\n| INDONESIA | INDIA | 1995 | 12347610366 |\n| VIETNAM | INDONESIA | 1995 | 12115640296 |\n| CHINA | JAPAN | 1995 | 12043708260 |\n| INDONESIA | JAPAN | 1995 | 12038187742 |\n| INDIA | CHINA | 1995 | 12021065586 |\n| INDIA | INDONESIA | 1995 | 11951037194 |\n| JAPAN | JAPAN | 1995 | 11904558258 |\n| JAPAN | INDONESIA | 1995 | 11894001470 |\n| VIETNAM | VIETNAM | 1995 | 11509455214 |\n| JAPAN | INDIA | 1995 | 11461486252 |\n| INDONESIA | VIETNAM | 1995 | 11149948132 |\n| INDIA | INDIA | 1995 | 11131991100 |\n| JAPAN | VIETNAM | 1995 | 11002627550 |\n| CHINA | VIETNAM | 1995 | 10979872126 |\n| INDIA | JAPAN | 1995 | 10938406854 |\n| INDIA | VIETNAM | 1995 | 10414126568 |\n| INDONESIA | INDONESIA | 1996 | 13500112566 |\n| CHINA | INDONESIA | 1996 | 13314250150 |\n| INDONESIA | CHINA | 1996 | 13226878224 |\n| CHINA | CHINA | 1996 | 13183395830 |\n| VIETNAM | CHINA | 1996 | 12857307780 |\n| VIETNAM | INDONESIA | 1996 | 12591253464 |\n| JAPAN | INDONESIA | 1996 | 12454895712 |\n| INDIA | CHINA | 1996 | 12397135638 |\n| INDIA | INDONESIA | 1996 | 12378484116 |\n| CHINA | INDIA | 1996 | 12307574730 |\n| INDONESIA | INDIA | 1996 | 12277621726 |\n| CHINA | JAPAN | 1996 | 12211132648 |\n| JAPAN | CHINA | 1996 | 12177971128 |\n| INDONESIA | JAPAN | 1996 | 12111276444 |\n| VIETNAM | JAPAN | 1996 | 11839994300 |\n| VIETNAM | VIETNAM | 1996 | 11721684604 |\n| INDIA | JAPAN | 1996 | 11683329610 |\n| VIETNAM | INDIA | 1996 | 11614973966 |\n| JAPAN | INDIA | 1996 | 11289159232 |\n| JAPAN | JAPAN | 1996 | 11132409590 |\n| INDIA | INDIA | 1996 | 11064146206 |\n| INDONESIA | VIETNAM | 1996 | 10877028774 |\n| CHINA | VIETNAM | 1996 | 10869545636 |\n| JAPAN | VIETNAM | 1996 | 10668555098 |\n| INDIA | VIETNAM | 1996 | 10587783062 |\n| CHINA | INDONESIA | 1997 | 13306469392 |\n| INDONESIA | CHINA | 1997 | 13154792628 |\n| CHINA | CHINA | 1997 | 12927589590 |\n| JAPAN | INDONESIA | 1997 | 12858540252 |\n| INDONESIA | INDONESIA | 1997 | 12796855642 |\n| VIETNAM | INDONESIA | 1997 | 12727166240 |\n| CHINA | JAPAN | 1997 | 12569467036 |\n| VIETNAM | CHINA | 1997 | 12328437446 |\n| INDIA | CHINA | 1997 | 12306564428 |\n| CHINA | INDIA | 1997 | 12168567966 |\n| INDONESIA | JAPAN | 1997 | 12002855912 |\n| INDIA | INDONESIA | 1997 | 11966878600 |\n| JAPAN | CHINA | 1997 | 11947699374 |\n| CHINA | VIETNAM | 1997 | 11816508352 |\n| JAPAN | INDIA | 1997 | 11593843984 |\n| JAPAN | JAPAN | 1997 | 11580900078 |\n| INDONESIA | INDIA | 1997 | 11578734210 |\n| VIETNAM | INDIA | 1997 | 11460243216 |\n| INDIA | INDIA | 1997 | 11386057814 |\n| VIETNAM | JAPAN | 1997 | 11378690460 |\n| INDONESIA | VIETNAM | 1997 | 11331356264 |\n| VIETNAM | VIETNAM | 1997 | 11240502648 |\n| INDIA | JAPAN | 1997 | 11175655826 |\n| JAPAN | VIETNAM | 1997 | 10499749228 |\n| INDIA | VIETNAM | 1997 | 10007249674 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n+------------+------------+------+------------+\n| c_city | s_city | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED ST4 | UNITED ST1 | 1992 | 204054910 |\n| UNITED ST1 | UNITED ST0 | 1992 | 193978982 |\n| UNITED ST7 | UNITED ST0 | 1992 | 192156020 |\n| UNITED ST9 | UNITED ST0 | 1992 | 189626588 |\n| UNITED ST4 | UNITED ST0 | 1992 | 189288484 |\n| UNITED ST2 | UNITED ST4 | 1992 | 182361000 |\n| UNITED ST5 | UNITED ST0 | 1992 | 180864600 |\n| UNITED ST6 | UNITED ST7 | 1992 | 175316534 |\n| UNITED ST3 | UNITED ST9 | 1992 | 172284096 |\n| UNITED ST6 | UNITED ST5 | 1992 | 171765932 |\n| UNITED ST7 | UNITED ST3 | 1992 | 167531332 |\n| UNITED ST2 | UNITED ST9 | 1992 | 167411236 |\n| UNITED ST4 | UNITED ST6 | 1992 | 163772748 |\n| UNITED ST2 | UNITED ST1 | 1992 | 163678330 |\n| UNITED ST9 | UNITED ST1 | 1992 | 161590604 |\n| UNITED ST6 | UNITED ST3 | 1992 | 157556436 |\n| UNITED ST6 | UNITED ST0 | 1992 | 157393912 |\n| UNITED ST0 | UNITED ST1 | 1992 | 154534792 |\n| UNITED ST0 | UNITED ST0 | 1992 | 151244244 |\n| UNITED ST1 | UNITED ST9 | 1992 | 150734118 |\n| UNITED ST3 | UNITED ST1 | 1992 | 147274980 |\n| UNITED ST2 | UNITED ST0 | 1992 | 144420436 |\n| UNITED ST1 | UNITED ST7 | 1992 | 142945946 |\n| UNITED ST6 | UNITED ST4 | 1992 | 142173888 |\n| UNITED ST4 | UNITED ST4 | 1992 | 140222670 |\n| UNITED ST6 | UNITED ST1 | 1992 | 138817376 |\n| UNITED ST4 | UNITED ST3 | 1992 | 138003574 |\n| UNITED ST5 | UNITED ST7 | 1992 | 136667302 |\n| UNITED ST4 | UNITED ST9 | 1992 | 135675940 |\n| UNITED ST7 | UNITED ST6 | 1992 | 131026410 |\n| UNITED ST4 | UNITED ST5 | 1992 | 130115744 |\n| UNITED ST7 | UNITED ST4 | 1992 | 129801776 |\n| UNITED ST1 | UNITED ST1 | 1992 | 129338140 |\n| UNITED ST3 | UNITED ST5 | 1992 | 128478096 |\n| UNITED ST0 | UNITED ST9 | 1992 | 127959992 |\n| UNITED ST3 | UNITED ST4 | 1992 | 126289544 |\n| UNITED ST5 | UNITED ST6 | 1992 | 125256186 |\n| UNITED ST4 | UNITED ST7 | 1992 | 125058752 |\n| UNITED ST3 | UNITED ST0 | 1992 | 124883312 |\n| UNITED ST9 | UNITED ST4 | 1992 | 122979026 |\n| UNITED ST8 | UNITED ST6 | 1992 | 121080880 |\n| UNITED ST7 | UNITED ST9 | 1992 | 120652084 |\n| UNITED ST7 | UNITED ST7 | 1992 | 120242772 |\n| UNITED ST5 | UNITED ST1 | 1992 | 119890574 |\n| UNITED ST5 | UNITED ST4 | 1992 | 115251254 |\n| UNITED ST7 | UNITED ST5 | 1992 | 115133604 |\n| UNITED ST2 | UNITED ST5 | 1992 | 114042730 |\n| UNITED ST9 | UNITED ST7 | 1992 | 113766718 |\n| UNITED ST0 | UNITED ST3 | 1992 | 112718634 |\n| UNITED ST1 | UNITED ST3 | 1992 | 111454948 |\n| UNITED ST5 | UNITED ST3 | 1992 | 107927106 |\n| UNITED ST0 | UNITED ST7 | 1992 | 101166818 |\n| UNITED ST5 | UNITED ST9 | 1992 | 100382182 |\n| UNITED ST7 | UNITED ST1 | 1992 | 100334416 |\n| UNITED ST0 | UNITED ST8 | 1992 | 99465280 |\n| UNITED ST0 | UNITED ST4 | 1992 | 99353614 |\n| UNITED ST9 | UNITED ST3 | 1992 | 95362330 |\n| UNITED ST8 | UNITED ST4 | 1992 | 93514038 |\n| UNITED ST3 | UNITED ST3 | 1992 | 90174432 |\n| UNITED ST8 | UNITED ST0 | 1992 | 88737678 |\n| UNITED ST0 | UNITED ST6 | 1992 | 84943612 |\n| UNITED ST6 | UNITED ST8 | 1992 | 84927380 |\n| UNITED ST8 | UNITED ST7 | 1992 | 83795802 |\n| UNITED ST3 | UNITED ST8 | 1992 | 82551528 |\n| UNITED ST6 | UNITED ST9 | 1992 | 81183442 |\n| UNITED ST0 | UNITED ST5 | 1992 | 80241772 |\n| UNITED ST1 | UNITED ST4 | 1992 | 78652692 |\n| UNITED ST3 | UNITED ST7 | 1992 | 78057158 |\n| UNITED ST3 | UNITED ST6 | 1992 | 77597430 |\n| UNITED ST9 | UNITED ST9 | 1992 | 72096686 |\n| UNITED ST2 | UNITED ST8 | 1992 | 72092898 |\n| UNITED ST2 | UNITED ST3 | 1992 | 71963926 |\n| UNITED ST8 | UNITED ST1 | 1992 | 71361504 |\n| UNITED ST1 | UNITED ST6 | 1992 | 70809980 |\n| UNITED ST8 | UNITED ST5 | 1992 | 70375220 |\n| UNITED ST1 | UNITED ST5 | 1992 | 67942502 |\n| UNITED ST5 | UNITED ST8 | 1992 | 67756106 |\n| UNITED ST2 | UNITED ST7 | 1992 | 67405558 |\n| UNITED ST8 | UNITED ST3 | 1992 | 61898648 |\n| UNITED ST8 | UNITED ST8 | 1992 | 58618216 |\n| UNITED ST5 | UNITED ST5 | 1992 | 58559136 |\n| UNITED ST1 | UNITED ST8 | 1992 | 57131158 |\n| UNITED ST9 | UNITED ST5 | 1992 | 56150008 |\n| UNITED ST2 | UNITED ST6 | 1992 | 55627478 |\n| UNITED ST0 | UNITED ST2 | 1992 | 55437466 |\n| UNITED ST2 | UNITED ST2 | 1992 | 51487308 |\n| UNITED ST8 | UNITED ST9 | 1992 | 45368942 |\n| UNITED ST4 | UNITED ST8 | 1992 | 43856884 |\n| UNITED ST9 | UNITED ST8 | 1992 | 42772200 |\n| UNITED ST5 | UNITED ST2 | 1992 | 40991634 |\n| UNITED ST6 | UNITED ST6 | 1992 | 36274210 |\n| UNITED ST9 | UNITED ST6 | 1992 | 31759136 |\n| UNITED ST4 | UNITED ST2 | 1992 | 24123690 |\n| UNITED ST7 | UNITED ST8 | 1992 | 23791404 |\n| UNITED ST6 | UNITED ST2 | 1992 | 23641396 |\n| UNITED ST9 | UNITED ST2 | 1992 | 23246354 |\n| UNITED ST8 | UNITED ST2 | 1992 | 21943122 |\n| UNITED ST1 | UNITED ST2 | 1992 | 15413456 |\n| UNITED ST7 | UNITED ST2 | 1992 | 9886408 |\n| UNITED ST3 | UNITED ST2 | 1992 | 2194416 |\n| UNITED ST0 | UNITED ST9 | 1993 | 219668080 |\n| UNITED ST7 | UNITED ST0 | 1993 | 219576048 |\n| UNITED ST5 | UNITED ST0 | 1993 | 213645194 |\n| UNITED ST0 | UNITED ST0 | 1993 | 213485096 |\n| UNITED ST1 | UNITED ST0 | 1993 | 198611904 |\n| UNITED ST4 | UNITED ST4 | 1993 | 196300930 |\n| UNITED ST3 | UNITED ST4 | 1993 | 184987840 |\n| UNITED ST0 | UNITED ST1 | 1993 | 182393186 |\n| UNITED ST4 | UNITED ST1 | 1993 | 177042846 |\n| UNITED ST8 | UNITED ST0 | 1993 | 176712742 |\n| UNITED ST4 | UNITED ST7 | 1993 | 176344396 |\n| UNITED ST4 | UNITED ST0 | 1993 | 173836916 |\n| UNITED ST6 | UNITED ST3 | 1993 | 166834322 |\n| UNITED ST6 | UNITED ST1 | 1993 | 166691878 |\n| UNITED ST7 | UNITED ST9 | 1993 | 160621402 |\n| UNITED ST3 | UNITED ST1 | 1993 | 156460556 |\n| UNITED ST6 | UNITED ST7 | 1993 | 156394588 |\n| UNITED ST5 | UNITED ST9 | 1993 | 152573078 |\n| UNITED ST0 | UNITED ST3 | 1993 | 152342566 |\n| UNITED ST5 | UNITED ST8 | 1993 | 148718558 |\n| UNITED ST9 | UNITED ST1 | 1993 | 148118838 |\n| UNITED ST4 | UNITED ST9 | 1993 | 146593918 |\n| UNITED ST5 | UNITED ST1 | 1993 | 142909246 |\n| UNITED ST6 | UNITED ST4 | 1993 | 139293826 |\n| UNITED ST2 | UNITED ST1 | 1993 | 139263402 |\n| UNITED ST6 | UNITED ST0 | 1993 | 136495078 |\n| UNITED ST7 | UNITED ST7 | 1993 | 136219640 |\n| UNITED ST2 | UNITED ST3 | 1993 | 133944876 |\n| UNITED ST3 | UNITED ST0 | 1993 | 133253852 |\n| UNITED ST9 | UNITED ST7 | 1993 | 133250966 |\n| UNITED ST1 | UNITED ST8 | 1993 | 132292396 |\n| UNITED ST2 | UNITED ST7 | 1993 | 128370028 |\n| UNITED ST5 | UNITED ST4 | 1993 | 126831278 |\n| UNITED ST9 | UNITED ST9 | 1993 | 126521526 |\n| UNITED ST1 | UNITED ST4 | 1993 | 125768694 |\n| UNITED ST7 | UNITED ST4 | 1993 | 123313226 |\n| UNITED ST3 | UNITED ST6 | 1993 | 117169616 |\n| UNITED ST2 | UNITED ST4 | 1993 | 113300782 |\n| UNITED ST3 | UNITED ST5 | 1993 | 111814610 |\n| UNITED ST6 | UNITED ST9 | 1993 | 109801884 |\n| UNITED ST1 | UNITED ST7 | 1993 | 109702366 |\n| UNITED ST3 | UNITED ST9 | 1993 | 109525192 |\n| UNITED ST8 | UNITED ST6 | 1993 | 109266124 |\n| UNITED ST8 | UNITED ST3 | 1993 | 108099748 |\n| UNITED ST5 | UNITED ST7 | 1993 | 105491076 |\n| UNITED ST0 | UNITED ST5 | 1993 | 105402104 |\n| UNITED ST1 | UNITED ST9 | 1993 | 105029804 |\n| UNITED ST8 | UNITED ST5 | 1993 | 104475674 |\n| UNITED ST1 | UNITED ST3 | 1993 | 104195892 |\n| UNITED ST8 | UNITED ST4 | 1993 | 102838712 |\n| UNITED ST0 | UNITED ST6 | 1993 | 100864564 |\n| UNITED ST5 | UNITED ST5 | 1993 | 100714378 |\n| UNITED ST3 | UNITED ST7 | 1993 | 100270896 |\n| UNITED ST0 | UNITED ST4 | 1993 | 98520134 |\n| UNITED ST0 | UNITED ST7 | 1993 | 97592720 |\n| UNITED ST2 | UNITED ST9 | 1993 | 96377014 |\n| UNITED ST1 | UNITED ST1 | 1993 | 95077220 |\n| UNITED ST9 | UNITED ST3 | 1993 | 93887294 |\n| UNITED ST7 | UNITED ST5 | 1993 | 89527384 |\n| UNITED ST1 | UNITED ST6 | 1993 | 89457080 |\n| UNITED ST8 | UNITED ST1 | 1993 | 88830868 |\n| UNITED ST7 | UNITED ST8 | 1993 | 87805256 |\n| UNITED ST9 | UNITED ST6 | 1993 | 87734320 |\n| UNITED ST2 | UNITED ST0 | 1993 | 85690970 |\n| UNITED ST3 | UNITED ST8 | 1993 | 84503696 |\n| UNITED ST0 | UNITED ST8 | 1993 | 84005364 |\n| UNITED ST4 | UNITED ST8 | 1993 | 83315164 |\n| UNITED ST1 | UNITED ST5 | 1993 | 81387026 |\n| UNITED ST9 | UNITED ST5 | 1993 | 79370538 |\n| UNITED ST7 | UNITED ST3 | 1993 | 79047722 |\n| UNITED ST8 | UNITED ST8 | 1993 | 77580470 |\n| UNITED ST8 | UNITED ST9 | 1993 | 77032722 |\n| UNITED ST2 | UNITED ST5 | 1993 | 74813690 |\n| UNITED ST9 | UNITED ST8 | 1993 | 74369392 |\n| UNITED ST8 | UNITED ST7 | 1993 | 73804436 |\n| UNITED ST6 | UNITED ST8 | 1993 | 72913482 |\n| UNITED ST7 | UNITED ST1 | 1993 | 68782318 |\n| UNITED ST6 | UNITED ST5 | 1993 | 68458164 |\n| UNITED ST5 | UNITED ST3 | 1993 | 68063622 |\n| UNITED ST2 | UNITED ST8 | 1993 | 66890892 |\n| UNITED ST4 | UNITED ST3 | 1993 | 66258824 |\n| UNITED ST6 | UNITED ST6 | 1993 | 66101326 |\n| UNITED ST9 | UNITED ST0 | 1993 | 65306610 |\n| UNITED ST4 | UNITED ST6 | 1993 | 61398510 |\n| UNITED ST9 | UNITED ST4 | 1993 | 61289374 |\n| UNITED ST4 | UNITED ST5 | 1993 | 58239188 |\n| UNITED ST7 | UNITED ST6 | 1993 | 54201004 |\n| UNITED ST4 | UNITED ST2 | 1993 | 54025356 |\n| UNITED ST2 | UNITED ST6 | 1993 | 52964452 |\n| UNITED ST5 | UNITED ST6 | 1993 | 50715358 |\n| UNITED ST3 | UNITED ST3 | 1993 | 43554288 |\n| UNITED ST3 | UNITED ST2 | 1993 | 43118146 |\n| UNITED ST5 | UNITED ST2 | 1993 | 41220484 |\n| UNITED ST7 | UNITED ST2 | 1993 | 40438608 |\n| UNITED ST6 | UNITED ST2 | 1993 | 37628734 |\n| UNITED ST9 | UNITED ST2 | 1993 | 35436780 |\n| UNITED ST1 | UNITED ST2 | 1993 | 33689076 |\n| UNITED ST0 | UNITED ST2 | 1993 | 30084290 |\n| UNITED ST2 | UNITED ST2 | 1993 | 29043990 |\n| UNITED ST8 | UNITED ST2 | 1993 | 19968732 |\n| UNITED ST8 | UNITED ST0 | 1994 | 198441578 |\n| UNITED ST3 | UNITED ST9 | 1994 | 194952370 |\n| UNITED ST6 | UNITED ST1 | 1994 | 193874294 |\n| UNITED ST6 | UNITED ST9 | 1994 | 189366618 |\n| UNITED ST9 | UNITED ST1 | 1994 | 180881896 |\n| UNITED ST0 | UNITED ST9 | 1994 | 179730404 |\n| UNITED ST5 | UNITED ST7 | 1994 | 178179922 |\n| UNITED ST9 | UNITED ST0 | 1994 | 175341146 |\n| UNITED ST3 | UNITED ST1 | 1994 | 171047306 |\n| UNITED ST4 | UNITED ST9 | 1994 | 167644786 |\n| UNITED ST0 | UNITED ST0 | 1994 | 167053754 |\n| UNITED ST7 | UNITED ST0 | 1994 | 164531072 |\n| UNITED ST2 | UNITED ST1 | 1994 | 162600178 |\n| UNITED ST5 | UNITED ST0 | 1994 | 157296114 |\n| UNITED ST4 | UNITED ST7 | 1994 | 153908280 |\n| UNITED ST4 | UNITED ST4 | 1994 | 153674762 |\n| UNITED ST0 | UNITED ST1 | 1994 | 153226758 |\n| UNITED ST1 | UNITED ST3 | 1994 | 151984918 |\n| UNITED ST7 | UNITED ST1 | 1994 | 150641598 |\n| UNITED ST4 | UNITED ST0 | 1994 | 147438680 |\n| UNITED ST5 | UNITED ST1 | 1994 | 147016836 |\n| UNITED ST4 | UNITED ST1 | 1994 | 144439114 |\n| UNITED ST2 | UNITED ST9 | 1994 | 139342108 |\n| UNITED ST6 | UNITED ST5 | 1994 | 132923068 |\n| UNITED ST2 | UNITED ST3 | 1994 | 131241520 |\n| UNITED ST3 | UNITED ST0 | 1994 | 131045454 |\n| UNITED ST5 | UNITED ST3 | 1994 | 130669822 |\n| UNITED ST7 | UNITED ST4 | 1994 | 129557430 |\n| UNITED ST3 | UNITED ST4 | 1994 | 126824730 |\n| UNITED ST8 | UNITED ST4 | 1994 | 124283362 |\n| UNITED ST0 | UNITED ST4 | 1994 | 123039488 |\n| UNITED ST0 | UNITED ST7 | 1994 | 122961640 |\n| UNITED ST0 | UNITED ST6 | 1994 | 122577556 |\n| UNITED ST2 | UNITED ST0 | 1994 | 120364306 |\n| UNITED ST6 | UNITED ST4 | 1994 | 119659978 |\n| UNITED ST4 | UNITED ST5 | 1994 | 118794056 |\n| UNITED ST8 | UNITED ST9 | 1994 | 117333812 |\n| UNITED ST4 | UNITED ST6 | 1994 | 117266964 |\n| UNITED ST5 | UNITED ST5 | 1994 | 112470426 |\n| UNITED ST6 | UNITED ST3 | 1994 | 112246476 |\n| UNITED ST2 | UNITED ST4 | 1994 | 111358754 |\n| UNITED ST8 | UNITED ST3 | 1994 | 110407682 |\n| UNITED ST1 | UNITED ST1 | 1994 | 108766348 |\n| UNITED ST1 | UNITED ST7 | 1994 | 107706212 |\n| UNITED ST6 | UNITED ST0 | 1994 | 107457706 |\n| UNITED ST5 | UNITED ST9 | 1994 | 106734662 |\n| UNITED ST9 | UNITED ST9 | 1994 | 103961698 |\n| UNITED ST5 | UNITED ST4 | 1994 | 103599186 |\n| UNITED ST7 | UNITED ST9 | 1994 | 100288170 |\n| UNITED ST7 | UNITED ST7 | 1994 | 92892884 |\n| UNITED ST6 | UNITED ST6 | 1994 | 92399444 |\n| UNITED ST7 | UNITED ST5 | 1994 | 91790728 |\n| UNITED ST3 | UNITED ST3 | 1994 | 91254306 |\n| UNITED ST8 | UNITED ST5 | 1994 | 89106112 |\n| UNITED ST9 | UNITED ST4 | 1994 | 87821522 |\n| UNITED ST1 | UNITED ST0 | 1994 | 86450402 |\n| UNITED ST1 | UNITED ST9 | 1994 | 86000074 |\n| UNITED ST7 | UNITED ST8 | 1994 | 85552934 |\n| UNITED ST0 | UNITED ST5 | 1994 | 83616602 |\n| UNITED ST2 | UNITED ST6 | 1994 | 83052210 |\n| UNITED ST1 | UNITED ST4 | 1994 | 82763116 |\n| UNITED ST3 | UNITED ST7 | 1994 | 81870262 |\n| UNITED ST8 | UNITED ST1 | 1994 | 80304192 |\n| UNITED ST9 | UNITED ST8 | 1994 | 78557616 |\n| UNITED ST5 | UNITED ST6 | 1994 | 77316902 |\n| UNITED ST2 | UNITED ST5 | 1994 | 75280634 |\n| UNITED ST8 | UNITED ST7 | 1994 | 75201374 |\n| UNITED ST9 | UNITED ST5 | 1994 | 74293452 |\n| UNITED ST6 | UNITED ST7 | 1994 | 74115616 |\n| UNITED ST8 | UNITED ST6 | 1994 | 73553138 |\n| UNITED ST3 | UNITED ST6 | 1994 | 72580514 |\n| UNITED ST9 | UNITED ST3 | 1994 | 71693000 |\n| UNITED ST2 | UNITED ST8 | 1994 | 67535548 |\n| UNITED ST0 | UNITED ST8 | 1994 | 63690866 |\n| UNITED ST4 | UNITED ST3 | 1994 | 63198866 |\n| UNITED ST9 | UNITED ST7 | 1994 | 63172346 |\n| UNITED ST1 | UNITED ST6 | 1994 | 62574652 |\n| UNITED ST1 | UNITED ST8 | 1994 | 60490306 |\n| UNITED ST7 | UNITED ST3 | 1994 | 58849680 |\n| UNITED ST9 | UNITED ST6 | 1994 | 58425854 |\n| UNITED ST0 | UNITED ST3 | 1994 | 54655658 |\n| UNITED ST6 | UNITED ST8 | 1994 | 53185992 |\n| UNITED ST3 | UNITED ST5 | 1994 | 52395750 |\n| UNITED ST6 | UNITED ST2 | 1994 | 51618000 |\n| UNITED ST1 | UNITED ST5 | 1994 | 49878276 |\n| UNITED ST7 | UNITED ST6 | 1994 | 49263874 |\n| UNITED ST1 | UNITED ST2 | 1994 | 47113172 |\n| UNITED ST4 | UNITED ST2 | 1994 | 46071784 |\n| UNITED ST2 | UNITED ST7 | 1994 | 44365516 |\n| UNITED ST0 | UNITED ST2 | 1994 | 44035908 |\n| UNITED ST4 | UNITED ST8 | 1994 | 41370704 |\n| UNITED ST7 | UNITED ST2 | 1994 | 39310162 |\n| UNITED ST5 | UNITED ST8 | 1994 | 37863782 |\n| UNITED ST2 | UNITED ST2 | 1994 | 36137314 |\n| UNITED ST3 | UNITED ST8 | 1994 | 31872102 |\n| UNITED ST8 | UNITED ST8 | 1994 | 20046824 |\n| UNITED ST3 | UNITED ST2 | 1994 | 19990468 |\n| UNITED ST9 | UNITED ST2 | 1994 | 19401978 |\n| UNITED ST5 | UNITED ST2 | 1994 | 14325592 |\n| UNITED ST8 | UNITED ST2 | 1994 | 7579252 |\n| UNITED ST5 | UNITED ST1 | 1995 | 239587338 |\n| UNITED ST4 | UNITED ST9 | 1995 | 198980136 |\n| UNITED ST7 | UNITED ST0 | 1995 | 196062590 |\n| UNITED ST6 | UNITED ST0 | 1995 | 183436942 |\n| UNITED ST4 | UNITED ST1 | 1995 | 181757306 |\n| UNITED ST0 | UNITED ST1 | 1995 | 181527198 |\n| UNITED ST8 | UNITED ST9 | 1995 | 177710178 |\n| UNITED ST7 | UNITED ST7 | 1995 | 173143248 |\n| UNITED ST3 | UNITED ST0 | 1995 | 168925466 |\n| UNITED ST9 | UNITED ST1 | 1995 | 165877934 |\n| UNITED ST2 | UNITED ST4 | 1995 | 164864610 |\n| UNITED ST1 | UNITED ST0 | 1995 | 163353246 |\n| UNITED ST5 | UNITED ST4 | 1995 | 162033522 |\n| UNITED ST7 | UNITED ST1 | 1995 | 159928724 |\n| UNITED ST5 | UNITED ST3 | 1995 | 156198260 |\n| UNITED ST5 | UNITED ST0 | 1995 | 155231492 |\n| UNITED ST9 | UNITED ST9 | 1995 | 153031916 |\n| UNITED ST7 | UNITED ST9 | 1995 | 150635418 |\n| UNITED ST4 | UNITED ST4 | 1995 | 149174142 |\n| UNITED ST9 | UNITED ST4 | 1995 | 145051372 |\n| UNITED ST1 | UNITED ST9 | 1995 | 144941740 |\n| UNITED ST4 | UNITED ST7 | 1995 | 138528814 |\n| UNITED ST6 | UNITED ST3 | 1995 | 135026124 |\n| UNITED ST2 | UNITED ST3 | 1995 | 130436258 |\n| UNITED ST2 | UNITED ST9 | 1995 | 130110356 |\n| UNITED ST7 | UNITED ST6 | 1995 | 130041342 |\n| UNITED ST3 | UNITED ST1 | 1995 | 129525630 |\n| UNITED ST1 | UNITED ST1 | 1995 | 128398664 |\n| UNITED ST6 | UNITED ST9 | 1995 | 126914210 |\n| UNITED ST0 | UNITED ST9 | 1995 | 126506998 |\n| UNITED ST5 | UNITED ST9 | 1995 | 124729794 |\n| UNITED ST4 | UNITED ST5 | 1995 | 124163010 |\n| UNITED ST1 | UNITED ST7 | 1995 | 123031482 |\n| UNITED ST2 | UNITED ST7 | 1995 | 120000416 |\n| UNITED ST8 | UNITED ST6 | 1995 | 117980808 |\n| UNITED ST1 | UNITED ST4 | 1995 | 115071198 |\n| UNITED ST0 | UNITED ST3 | 1995 | 112721416 |\n| UNITED ST8 | UNITED ST0 | 1995 | 110463328 |\n| UNITED ST5 | UNITED ST7 | 1995 | 107481518 |\n| UNITED ST2 | UNITED ST0 | 1995 | 105121676 |\n| UNITED ST3 | UNITED ST7 | 1995 | 103159096 |\n| UNITED ST9 | UNITED ST0 | 1995 | 103097242 |\n| UNITED ST6 | UNITED ST6 | 1995 | 101909354 |\n| UNITED ST5 | UNITED ST5 | 1995 | 100788014 |\n| UNITED ST7 | UNITED ST4 | 1995 | 99799090 |\n| UNITED ST3 | UNITED ST3 | 1995 | 96316178 |\n| UNITED ST6 | UNITED ST4 | 1995 | 95394482 |\n| UNITED ST9 | UNITED ST7 | 1995 | 92929178 |\n| UNITED ST4 | UNITED ST0 | 1995 | 92285798 |\n| UNITED ST1 | UNITED ST3 | 1995 | 91646112 |\n| UNITED ST2 | UNITED ST1 | 1995 | 90874680 |\n| UNITED ST6 | UNITED ST5 | 1995 | 90856304 |\n| UNITED ST8 | UNITED ST5 | 1995 | 89989726 |\n| UNITED ST7 | UNITED ST3 | 1995 | 87399468 |\n| UNITED ST9 | UNITED ST6 | 1995 | 86964988 |\n| UNITED ST2 | UNITED ST5 | 1995 | 86764834 |\n| UNITED ST6 | UNITED ST8 | 1995 | 83947840 |\n| UNITED ST0 | UNITED ST6 | 1995 | 81437884 |\n| UNITED ST3 | UNITED ST5 | 1995 | 80115630 |\n| UNITED ST7 | UNITED ST5 | 1995 | 78030586 |\n| UNITED ST0 | UNITED ST0 | 1995 | 77969004 |\n| UNITED ST6 | UNITED ST1 | 1995 | 76656704 |\n| UNITED ST4 | UNITED ST6 | 1995 | 76219048 |\n| UNITED ST3 | UNITED ST9 | 1995 | 74729246 |\n| UNITED ST4 | UNITED ST3 | 1995 | 74712792 |\n| UNITED ST2 | UNITED ST6 | 1995 | 74292576 |\n| UNITED ST9 | UNITED ST5 | 1995 | 72019848 |\n| UNITED ST1 | UNITED ST8 | 1995 | 69837586 |\n| UNITED ST8 | UNITED ST1 | 1995 | 68435560 |\n| UNITED ST0 | UNITED ST7 | 1995 | 66790626 |\n| UNITED ST1 | UNITED ST5 | 1995 | 63714904 |\n| UNITED ST8 | UNITED ST7 | 1995 | 61836404 |\n| UNITED ST2 | UNITED ST8 | 1995 | 61008378 |\n| UNITED ST3 | UNITED ST4 | 1995 | 60844692 |\n| UNITED ST5 | UNITED ST6 | 1995 | 60409474 |\n| UNITED ST8 | UNITED ST3 | 1995 | 58699876 |\n| UNITED ST0 | UNITED ST4 | 1995 | 58340076 |\n| UNITED ST1 | UNITED ST6 | 1995 | 54278806 |\n| UNITED ST7 | UNITED ST8 | 1995 | 52888980 |\n| UNITED ST6 | UNITED ST7 | 1995 | 47667954 |\n| UNITED ST4 | UNITED ST8 | 1995 | 46106472 |\n| UNITED ST4 | UNITED ST2 | 1995 | 45574006 |\n| UNITED ST3 | UNITED ST8 | 1995 | 45010478 |\n| UNITED ST9 | UNITED ST8 | 1995 | 42585054 |\n| UNITED ST8 | UNITED ST4 | 1995 | 38574622 |\n| UNITED ST8 | UNITED ST2 | 1995 | 36565980 |\n| UNITED ST9 | UNITED ST3 | 1995 | 35078204 |\n| UNITED ST3 | UNITED ST6 | 1995 | 33477060 |\n| UNITED ST0 | UNITED ST8 | 1995 | 32786498 |\n| UNITED ST5 | UNITED ST2 | 1995 | 29902046 |\n| UNITED ST2 | UNITED ST2 | 1995 | 26910062 |\n| UNITED ST5 | UNITED ST8 | 1995 | 26693864 |\n| UNITED ST3 | UNITED ST2 | 1995 | 25773658 |\n| UNITED ST9 | UNITED ST2 | 1995 | 25306724 |\n| UNITED ST0 | UNITED ST5 | 1995 | 22907418 |\n| UNITED ST6 | UNITED ST2 | 1995 | 22727102 |\n| UNITED ST8 | UNITED ST8 | 1995 | 22571734 |\n| UNITED ST1 | UNITED ST2 | 1995 | 15983352 |\n| UNITED ST0 | UNITED ST2 | 1995 | 9552920 |\n| UNITED ST7 | UNITED ST2 | 1995 | 7947130 |\n| UNITED ST6 | UNITED ST0 | 1996 | 264573526 |\n| UNITED ST4 | UNITED ST0 | 1996 | 213795126 |\n| UNITED ST5 | UNITED ST0 | 1996 | 209003958 |\n| UNITED ST0 | UNITED ST4 | 1996 | 206457498 |\n| UNITED ST9 | UNITED ST1 | 1996 | 203967654 |\n| UNITED ST1 | UNITED ST0 | 1996 | 189723108 |\n| UNITED ST0 | UNITED ST1 | 1996 | 183897554 |\n| UNITED ST6 | UNITED ST1 | 1996 | 179411740 |\n| UNITED ST2 | UNITED ST1 | 1996 | 176512310 |\n| UNITED ST1 | UNITED ST1 | 1996 | 174531696 |\n| UNITED ST4 | UNITED ST7 | 1996 | 167355628 |\n| UNITED ST6 | UNITED ST3 | 1996 | 164336458 |\n| UNITED ST2 | UNITED ST7 | 1996 | 160936954 |\n| UNITED ST8 | UNITED ST1 | 1996 | 157943512 |\n| UNITED ST7 | UNITED ST4 | 1996 | 155882022 |\n| UNITED ST1 | UNITED ST3 | 1996 | 155221810 |\n| UNITED ST9 | UNITED ST9 | 1996 | 154603480 |\n| UNITED ST0 | UNITED ST9 | 1996 | 151870418 |\n| UNITED ST7 | UNITED ST0 | 1996 | 151204890 |\n| UNITED ST3 | UNITED ST1 | 1996 | 149493398 |\n| UNITED ST7 | UNITED ST7 | 1996 | 148081288 |\n| UNITED ST4 | UNITED ST1 | 1996 | 145639734 |\n| UNITED ST5 | UNITED ST9 | 1996 | 145228228 |\n| UNITED ST1 | UNITED ST9 | 1996 | 139647538 |\n| UNITED ST9 | UNITED ST4 | 1996 | 139233228 |\n| UNITED ST6 | UNITED ST4 | 1996 | 138592010 |\n| UNITED ST2 | UNITED ST0 | 1996 | 134190244 |\n| UNITED ST5 | UNITED ST1 | 1996 | 130692778 |\n| UNITED ST6 | UNITED ST9 | 1996 | 126512364 |\n| UNITED ST4 | UNITED ST6 | 1996 | 124378656 |\n| UNITED ST0 | UNITED ST0 | 1996 | 123057710 |\n| UNITED ST8 | UNITED ST9 | 1996 | 120933382 |\n| UNITED ST3 | UNITED ST0 | 1996 | 120453680 |\n| UNITED ST8 | UNITED ST6 | 1996 | 119493310 |\n| UNITED ST2 | UNITED ST3 | 1996 | 119297196 |\n| UNITED ST0 | UNITED ST5 | 1996 | 115525790 |\n| UNITED ST8 | UNITED ST7 | 1996 | 115047850 |\n| UNITED ST2 | UNITED ST4 | 1996 | 114974114 |\n| UNITED ST6 | UNITED ST7 | 1996 | 114181238 |\n| UNITED ST3 | UNITED ST4 | 1996 | 109676518 |\n| UNITED ST4 | UNITED ST9 | 1996 | 108269680 |\n| UNITED ST1 | UNITED ST6 | 1996 | 108112732 |\n| UNITED ST3 | UNITED ST7 | 1996 | 107974436 |\n| UNITED ST2 | UNITED ST9 | 1996 | 106982830 |\n| UNITED ST4 | UNITED ST8 | 1996 | 106071324 |\n| UNITED ST9 | UNITED ST5 | 1996 | 105651844 |\n| UNITED ST7 | UNITED ST3 | 1996 | 104713772 |\n| UNITED ST6 | UNITED ST8 | 1996 | 104273568 |\n| UNITED ST1 | UNITED ST5 | 1996 | 102379298 |\n| UNITED ST8 | UNITED ST4 | 1996 | 102066108 |\n| UNITED ST1 | UNITED ST4 | 1996 | 100271094 |\n| UNITED ST3 | UNITED ST9 | 1996 | 99224608 |\n| UNITED ST9 | UNITED ST0 | 1996 | 99181402 |\n| UNITED ST3 | UNITED ST3 | 1996 | 98527592 |\n| UNITED ST9 | UNITED ST7 | 1996 | 97597518 |\n| UNITED ST7 | UNITED ST1 | 1996 | 97568350 |\n| UNITED ST9 | UNITED ST6 | 1996 | 97370126 |\n| UNITED ST2 | UNITED ST5 | 1996 | 94057952 |\n| UNITED ST9 | UNITED ST3 | 1996 | 94042036 |\n| UNITED ST2 | UNITED ST8 | 1996 | 93730226 |\n| UNITED ST4 | UNITED ST3 | 1996 | 92921880 |\n| UNITED ST6 | UNITED ST5 | 1996 | 92060208 |\n| UNITED ST2 | UNITED ST6 | 1996 | 90833298 |\n| UNITED ST8 | UNITED ST5 | 1996 | 86960946 |\n| UNITED ST5 | UNITED ST5 | 1996 | 86041444 |\n| UNITED ST6 | UNITED ST6 | 1996 | 85846064 |\n| UNITED ST4 | UNITED ST5 | 1996 | 85616824 |\n| UNITED ST3 | UNITED ST6 | 1996 | 83763256 |\n| UNITED ST1 | UNITED ST7 | 1996 | 83443012 |\n| UNITED ST5 | UNITED ST7 | 1996 | 81892660 |\n| UNITED ST8 | UNITED ST0 | 1996 | 79690854 |\n| UNITED ST8 | UNITED ST3 | 1996 | 79071880 |\n| UNITED ST1 | UNITED ST8 | 1996 | 78861764 |\n| UNITED ST5 | UNITED ST6 | 1996 | 76664088 |\n| UNITED ST0 | UNITED ST6 | 1996 | 74464124 |\n| UNITED ST7 | UNITED ST6 | 1996 | 73071256 |\n| UNITED ST9 | UNITED ST8 | 1996 | 72224602 |\n| UNITED ST3 | UNITED ST8 | 1996 | 67849464 |\n| UNITED ST3 | UNITED ST5 | 1996 | 67434878 |\n| UNITED ST5 | UNITED ST4 | 1996 | 66849718 |\n| UNITED ST5 | UNITED ST3 | 1996 | 65839852 |\n| UNITED ST4 | UNITED ST4 | 1996 | 65575990 |\n| UNITED ST7 | UNITED ST5 | 1996 | 65568448 |\n| UNITED ST5 | UNITED ST8 | 1996 | 64831364 |\n| UNITED ST0 | UNITED ST7 | 1996 | 62782362 |\n| UNITED ST0 | UNITED ST3 | 1996 | 59591330 |\n| UNITED ST7 | UNITED ST9 | 1996 | 50056182 |\n| UNITED ST7 | UNITED ST8 | 1996 | 48697702 |\n| UNITED ST6 | UNITED ST2 | 1996 | 40895694 |\n| UNITED ST8 | UNITED ST8 | 1996 | 32681206 |\n| UNITED ST0 | UNITED ST8 | 1996 | 30336524 |\n| UNITED ST4 | UNITED ST2 | 1996 | 24903734 |\n| UNITED ST1 | UNITED ST2 | 1996 | 20165072 |\n| UNITED ST5 | UNITED ST2 | 1996 | 17088466 |\n| UNITED ST7 | UNITED ST2 | 1996 | 16780940 |\n| UNITED ST9 | UNITED ST2 | 1996 | 16216070 |\n| UNITED ST8 | UNITED ST2 | 1996 | 14056668 |\n| UNITED ST0 | UNITED ST2 | 1996 | 13814398 |\n| UNITED ST3 | UNITED ST2 | 1996 | 8623600 |\n| UNITED ST5 | UNITED ST0 | 1997 | 242915532 |\n| UNITED ST0 | UNITED ST9 | 1997 | 239712536 |\n| UNITED ST5 | UNITED ST1 | 1997 | 213800322 |\n| UNITED ST9 | UNITED ST9 | 1997 | 212445590 |\n| UNITED ST5 | UNITED ST4 | 1997 | 206865854 |\n| UNITED ST7 | UNITED ST1 | 1997 | 202653880 |\n| UNITED ST5 | UNITED ST9 | 1997 | 194785280 |\n| UNITED ST8 | UNITED ST0 | 1997 | 178869690 |\n| UNITED ST1 | UNITED ST3 | 1997 | 170351276 |\n| UNITED ST4 | UNITED ST1 | 1997 | 169222376 |\n| UNITED ST4 | UNITED ST7 | 1997 | 169213992 |\n| UNITED ST1 | UNITED ST4 | 1997 | 166185138 |\n| UNITED ST0 | UNITED ST1 | 1997 | 160334278 |\n| UNITED ST4 | UNITED ST9 | 1997 | 159395854 |\n| UNITED ST1 | UNITED ST0 | 1997 | 155335732 |\n| UNITED ST2 | UNITED ST0 | 1997 | 155182940 |\n| UNITED ST1 | UNITED ST7 | 1997 | 154091444 |\n| UNITED ST2 | UNITED ST7 | 1997 | 152967604 |\n| UNITED ST1 | UNITED ST1 | 1997 | 152680888 |\n| UNITED ST0 | UNITED ST7 | 1997 | 145154980 |\n| UNITED ST4 | UNITED ST0 | 1997 | 139751608 |\n| UNITED ST6 | UNITED ST3 | 1997 | 139451012 |\n| UNITED ST2 | UNITED ST9 | 1997 | 139087968 |\n| UNITED ST7 | UNITED ST0 | 1997 | 138708624 |\n| UNITED ST9 | UNITED ST7 | 1997 | 138105260 |\n| UNITED ST8 | UNITED ST3 | 1997 | 133836788 |\n| UNITED ST0 | UNITED ST0 | 1997 | 132617032 |\n| UNITED ST9 | UNITED ST0 | 1997 | 132133582 |\n| UNITED ST2 | UNITED ST3 | 1997 | 130858906 |\n| UNITED ST2 | UNITED ST1 | 1997 | 130792270 |\n| UNITED ST4 | UNITED ST4 | 1997 | 125064692 |\n| UNITED ST9 | UNITED ST1 | 1997 | 124836812 |\n| UNITED ST3 | UNITED ST7 | 1997 | 122190600 |\n| UNITED ST7 | UNITED ST4 | 1997 | 120246988 |\n| UNITED ST4 | UNITED ST3 | 1997 | 119268306 |\n| UNITED ST3 | UNITED ST4 | 1997 | 116712282 |\n| UNITED ST6 | UNITED ST9 | 1997 | 116462526 |\n| UNITED ST6 | UNITED ST4 | 1997 | 114430044 |\n| UNITED ST2 | UNITED ST4 | 1997 | 114025222 |\n| UNITED ST5 | UNITED ST3 | 1997 | 113579864 |\n| UNITED ST9 | UNITED ST5 | 1997 | 112183840 |\n| UNITED ST6 | UNITED ST0 | 1997 | 111649838 |\n| UNITED ST6 | UNITED ST1 | 1997 | 110235418 |\n| UNITED ST7 | UNITED ST9 | 1997 | 110079940 |\n| UNITED ST5 | UNITED ST7 | 1997 | 109068630 |\n| UNITED ST3 | UNITED ST1 | 1997 | 108301366 |\n| UNITED ST3 | UNITED ST0 | 1997 | 108100344 |\n| UNITED ST3 | UNITED ST9 | 1997 | 102740616 |\n| UNITED ST1 | UNITED ST5 | 1997 | 102104220 |\n| UNITED ST6 | UNITED ST7 | 1997 | 99591698 |\n| UNITED ST5 | UNITED ST6 | 1997 | 98060032 |\n| UNITED ST1 | UNITED ST9 | 1997 | 97888222 |\n| UNITED ST3 | UNITED ST3 | 1997 | 96770466 |\n| UNITED ST0 | UNITED ST5 | 1997 | 95976836 |\n| UNITED ST2 | UNITED ST8 | 1997 | 92783818 |\n| UNITED ST4 | UNITED ST6 | 1997 | 92473698 |\n| UNITED ST9 | UNITED ST3 | 1997 | 92243448 |\n| UNITED ST8 | UNITED ST9 | 1997 | 91705592 |\n| UNITED ST7 | UNITED ST8 | 1997 | 90952532 |\n| UNITED ST8 | UNITED ST1 | 1997 | 86568278 |\n| UNITED ST7 | UNITED ST7 | 1997 | 85133206 |\n| UNITED ST0 | UNITED ST4 | 1997 | 82387606 |\n| UNITED ST8 | UNITED ST7 | 1997 | 81756858 |\n| UNITED ST8 | UNITED ST8 | 1997 | 81498800 |\n| UNITED ST2 | UNITED ST5 | 1997 | 81325772 |\n| UNITED ST0 | UNITED ST3 | 1997 | 80157016 |\n| UNITED ST6 | UNITED ST8 | 1997 | 75976890 |\n| UNITED ST9 | UNITED ST6 | 1997 | 75193764 |\n| UNITED ST6 | UNITED ST5 | 1997 | 75143576 |\n| UNITED ST2 | UNITED ST2 | 1997 | 74068666 |\n| UNITED ST7 | UNITED ST5 | 1997 | 73779472 |\n| UNITED ST8 | UNITED ST4 | 1997 | 73201168 |\n| UNITED ST3 | UNITED ST6 | 1997 | 72151688 |\n| UNITED ST7 | UNITED ST3 | 1997 | 70337844 |\n| UNITED ST2 | UNITED ST6 | 1997 | 68548934 |\n| UNITED ST5 | UNITED ST8 | 1997 | 65821892 |\n| UNITED ST3 | UNITED ST5 | 1997 | 65623926 |\n| UNITED ST4 | UNITED ST8 | 1997 | 65199472 |\n| UNITED ST5 | UNITED ST5 | 1997 | 65137776 |\n| UNITED ST4 | UNITED ST5 | 1997 | 63991736 |\n| UNITED ST9 | UNITED ST4 | 1997 | 63530956 |\n| UNITED ST7 | UNITED ST2 | 1997 | 62819180 |\n| UNITED ST9 | UNITED ST8 | 1997 | 62544770 |\n| UNITED ST0 | UNITED ST8 | 1997 | 60482740 |\n| UNITED ST3 | UNITED ST8 | 1997 | 58204440 |\n| UNITED ST7 | UNITED ST6 | 1997 | 55079862 |\n| UNITED ST8 | UNITED ST5 | 1997 | 53347486 |\n| UNITED ST6 | UNITED ST6 | 1997 | 49966582 |\n| UNITED ST0 | UNITED ST2 | 1997 | 47168458 |\n| UNITED ST0 | UNITED ST6 | 1997 | 45848092 |\n| UNITED ST1 | UNITED ST2 | 1997 | 41198260 |\n| UNITED ST8 | UNITED ST6 | 1997 | 40146000 |\n| UNITED ST1 | UNITED ST6 | 1997 | 36410652 |\n| UNITED ST1 | UNITED ST8 | 1997 | 30750516 |\n| UNITED ST6 | UNITED ST2 | 1997 | 29493360 |\n| UNITED ST5 | UNITED ST2 | 1997 | 27726876 |\n| UNITED ST8 | UNITED ST2 | 1997 | 24107412 |\n| UNITED ST3 | UNITED ST2 | 1997 | 15783756 |\n| UNITED ST4 | UNITED ST2 | 1997 | 5696314 |\n| UNITED ST9 | UNITED ST2 | 1997 | 5323304 |\n+------------+------------+------+------------+\n\n-- Q3.3\n+------------+------------+------+------------+\n| c_city | s_city | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI1 | UNITED KI1 | 1992 | 93471990 |\n| UNITED KI5 | UNITED KI1 | 1992 | 72554110 |\n| UNITED KI5 | UNITED KI5 | 1992 | 50710534 |\n| UNITED KI1 | UNITED KI5 | 1992 | 43835692 |\n| UNITED KI5 | UNITED KI1 | 1993 | 122035214 |\n| UNITED KI1 | UNITED KI1 | 1993 | 91339070 |\n| UNITED KI5 | UNITED KI5 | 1993 | 68198784 |\n| UNITED KI1 | UNITED KI5 | 1993 | 42888412 |\n| UNITED KI5 | UNITED KI1 | 1994 | 72564326 |\n| UNITED KI1 | UNITED KI1 | 1994 | 69736882 |\n| UNITED KI5 | UNITED KI5 | 1994 | 69014568 |\n| UNITED KI1 | UNITED KI5 | 1994 | 42443560 |\n| UNITED KI5 | UNITED KI1 | 1995 | 165911792 |\n| UNITED KI1 | UNITED KI1 | 1995 | 71762372 |\n| UNITED KI5 | UNITED KI5 | 1995 | 41079610 |\n| UNITED KI1 | UNITED KI5 | 1995 | 34353020 |\n| UNITED KI5 | UNITED KI1 | 1996 | 131534098 |\n| UNITED KI1 | UNITED KI1 | 1996 | 119846074 |\n| UNITED KI5 | UNITED KI5 | 1996 | 92154684 |\n| UNITED KI1 | UNITED KI5 | 1996 | 27400508 |\n| UNITED KI1 | UNITED KI1 | 1997 | 140686266 |\n| UNITED KI5 | UNITED KI1 | 1997 | 129956718 |\n| UNITED KI5 | UNITED KI5 | 1997 | 54664054 |\n| UNITED KI1 | UNITED KI5 | 1997 | 32821336 |\n+------------+------------+------+------------+\n\n-- Q3.4\n+------------+------------+------+------------+\n| c_city | s_city | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI5 | UNITED KI1 | 1997 | 18235692 |\n| UNITED KI5 | UNITED KI5 | 1997 | 12407602 |\n| UNITED KI1 | UNITED KI5 | 1997 | 3740140 |\n+------------+------------+------+------------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation | profit |\n+------+---------------+-------------+\n| 1992 | ARGENTINA | 19317928938 |\n| 1992 | BRAZIL | 18453966110 |\n| 1992 | CANADA | 19286353574 |\n| 1992 | PERU | 18821353194 |\n| 1992 | UNITED STATES | 19698855306 |\n| 1993 | ARGENTINA | 19952665706 |\n| 1993 | BRAZIL | 18937598458 |\n| 1993 | CANADA | 19794604840 |\n| 1993 | PERU | 18618891672 |\n| 1993 | UNITED STATES | 20007970172 |\n| 1994 | ARGENTINA | 19880610430 |\n| 1994 | BRAZIL | 18697303354 |\n| 1994 | CANADA | 19165295192 |\n| 1994 | PERU | 18590530026 |\n| 1994 | UNITED STATES | 19039760850 |\n| 1995 | ARGENTINA | 20287682760 |\n| 1995 | BRAZIL | 18312154700 |\n| 1995 | CANADA | 19125224320 |\n| 1995 | PERU | 19556174422 |\n| 1995 | UNITED STATES | 18621130488 |\n| 1996 | ARGENTINA | 20003855790 |\n| 1996 | BRAZIL | 18336970302 |\n| 1996 | CANADA | 20123208406 |\n| 1996 | PERU | 18710271348 |\n| 1996 | UNITED STATES | 19539424348 |\n| 1997 | ARGENTINA | 19709120522 |\n| 1997 | BRAZIL | 18243142094 |\n| 1997 | CANADA | 20194743556 |\n| 1997 | PERU | 18631051834 |\n| 1997 | UNITED STATES | 21013447758 |\n| 1998 | ARGENTINA | 11668480814 |\n| 1998 | BRAZIL | 10712796190 |\n| 1998 | CANADA | 10846422392 |\n| 1998 | PERU | 11452371940 |\n| 1998 | UNITED STATES | 12018924038 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation | p_category | profit |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA | MFGR#11 | 1814143132 |\n| 1997 | ARGENTINA | MFGR#12 | 1848231124 |\n| 1997 | ARGENTINA | MFGR#13 | 1945723642 |\n| 1997 | ARGENTINA | MFGR#14 | 1950820690 |\n| 1997 | ARGENTINA | MFGR#15 | 1877734750 |\n| 1997 | ARGENTINA | MFGR#21 | 2029565148 |\n| 1997 | ARGENTINA | MFGR#22 | 1746033566 |\n| 1997 | ARGENTINA | MFGR#23 | 2060714604 |\n| 1997 | ARGENTINA | MFGR#24 | 1786921158 |\n| 1997 | ARGENTINA | MFGR#25 | 2012622806 |\n| 1997 | BRAZIL | MFGR#11 | 2146438656 |\n| 1997 | BRAZIL | MFGR#12 | 1979717666 |\n| 1997 | BRAZIL | MFGR#13 | 2256960758 |\n| 1997 | BRAZIL | MFGR#14 | 2388513444 |\n| 1997 | BRAZIL | MFGR#15 | 2188838248 |\n| 1997 | BRAZIL | MFGR#21 | 1820053664 |\n| 1997 | BRAZIL | MFGR#22 | 1986284096 |\n| 1997 | BRAZIL | MFGR#23 | 2215345748 |\n| 1997 | BRAZIL | MFGR#24 | 2116027298 |\n| 1997 | BRAZIL | MFGR#25 | 1989467528 |\n| 1997 | CANADA | MFGR#11 | 1709450040 |\n| 1997 | CANADA | MFGR#12 | 1877436328 |\n| 1997 | CANADA | MFGR#13 | 1918531780 |\n| 1997 | CANADA | MFGR#14 | 2005624900 |\n| 1997 | CANADA | MFGR#15 | 1696366026 |\n| 1997 | CANADA | MFGR#21 | 1999610544 |\n| 1997 | CANADA | MFGR#22 | 1556839526 |\n| 1997 | CANADA | MFGR#23 | 1856719290 |\n| 1997 | CANADA | MFGR#24 | 1699790256 |\n| 1997 | CANADA | MFGR#25 | 1809175930 |\n| 1997 | PERU | MFGR#11 | 2200485754 |\n| 1997 | PERU | MFGR#12 | 1988730700 |\n| 1997 | PERU | MFGR#13 | 1694972210 |\n| 1997 | PERU | MFGR#14 | 1895539366 |\n| 1997 | PERU | MFGR#15 | 1998791356 |\n| 1997 | PERU | MFGR#21 | 1735846788 |\n| 1997 | PERU | MFGR#22 | 1977494918 |\n| 1997 | PERU | MFGR#23 | 2133290172 |\n| 1997 | PERU | MFGR#24 | 1871331450 |\n| 1997 | PERU | MFGR#25 | 1962908258 |\n| 1997 | UNITED STATES | MFGR#11 | 2093412096 |\n| 1997 | UNITED STATES | MFGR#12 | 1818427418 |\n| 1997 | UNITED STATES | MFGR#13 | 2192557812 |\n| 1997 | UNITED STATES | MFGR#14 | 1868564222 |\n| 1997 | UNITED STATES | MFGR#15 | 1925521686 |\n| 1997 | UNITED STATES | MFGR#21 | 2001352948 |\n| 1997 | UNITED STATES | MFGR#22 | 2153895230 |\n| 1997 | UNITED STATES | MFGR#23 | 1874576204 |\n| 1997 | UNITED STATES | MFGR#24 | 2006772726 |\n| 1997 | UNITED STATES | MFGR#25 | 2107332104 |\n| 1998 | ARGENTINA | MFGR#11 | 1135224454 |\n| 1998 | ARGENTINA | MFGR#12 | 1054050084 |\n| 1998 | ARGENTINA | MFGR#13 | 1165583584 |\n| 1998 | ARGENTINA | MFGR#14 | 1047452736 |\n| 1998 | ARGENTINA | MFGR#15 | 1044156534 |\n| 1998 | ARGENTINA | MFGR#21 | 1009425370 |\n| 1998 | ARGENTINA | MFGR#22 | 1012123472 |\n| 1998 | ARGENTINA | MFGR#23 | 1120959602 |\n| 1998 | ARGENTINA | MFGR#24 | 1049158236 |\n| 1998 | ARGENTINA | MFGR#25 | 1095680422 |\n| 1998 | BRAZIL | MFGR#11 | 1277156976 |\n| 1998 | BRAZIL | MFGR#12 | 1292625362 |\n| 1998 | BRAZIL | MFGR#13 | 1310323544 |\n| 1998 | BRAZIL | MFGR#14 | 1105352340 |\n| 1998 | BRAZIL | MFGR#15 | 1327625418 |\n| 1998 | BRAZIL | MFGR#21 | 1337644896 |\n| 1998 | BRAZIL | MFGR#22 | 1183583836 |\n| 1998 | BRAZIL | MFGR#23 | 1381297754 |\n| 1998 | BRAZIL | MFGR#24 | 1124724440 |\n| 1998 | BRAZIL | MFGR#25 | 1408364752 |\n| 1998 | CANADA | MFGR#11 | 1018172250 |\n| 1998 | CANADA | MFGR#12 | 976179544 |\n| 1998 | CANADA | MFGR#13 | 973066594 |\n| 1998 | CANADA | MFGR#14 | 1055674454 |\n| 1998 | CANADA | MFGR#15 | 1071738598 |\n| 1998 | CANADA | MFGR#21 | 911737302 |\n| 1998 | CANADA | MFGR#22 | 1188554616 |\n| 1998 | CANADA | MFGR#23 | 1148250140 |\n| 1998 | CANADA | MFGR#24 | 1017060848 |\n| 1998 | CANADA | MFGR#25 | 1095515984 |\n| 1998 | PERU | MFGR#11 | 1135677094 |\n| 1998 | PERU | MFGR#12 | 1081089514 |\n| 1998 | PERU | MFGR#13 | 1182663766 |\n| 1998 | PERU | MFGR#14 | 962670128 |\n| 1998 | PERU | MFGR#15 | 1140492276 |\n| 1998 | PERU | MFGR#21 | 1067466660 |\n| 1998 | PERU | MFGR#22 | 1055581312 |\n| 1998 | PERU | MFGR#23 | 1272786442 |\n| 1998 | PERU | MFGR#24 | 1178150524 |\n| 1998 | PERU | MFGR#25 | 1086502230 |\n| 1998 | UNITED STATES | MFGR#11 | 1112552464 |\n| 1998 | UNITED STATES | MFGR#12 | 1224771964 |\n| 1998 | UNITED STATES | MFGR#13 | 1244827854 |\n| 1998 | UNITED STATES | MFGR#14 | 1110013774 |\n| 1998 | UNITED STATES | MFGR#15 | 1050239138 |\n| 1998 | UNITED STATES | MFGR#21 | 1126813672 |\n| 1998 | UNITED STATES | MFGR#22 | 1160957470 |\n| 1998 | UNITED STATES | MFGR#23 | 1312160930 |\n| 1998 | UNITED STATES | MFGR#24 | 1076890116 |\n| 1998 | UNITED STATES | MFGR#25 | 1178223904 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+---------------+\n| year | s_city | p_brand | profit |\n+------+------------+-----------+---------------+\n| 1997 | UNITED ST1 | MFGR#1414 | 10001830.0000 |\n| 1997 | UNITED ST1 | MFGR#147 | 13643806.0000 |\n| 1997 | UNITED ST9 | MFGR#144 | 4953914.0000 |\n| 1998 | UNITED ST0 | MFGR#1424 | 14202690.0000 |\n| 1998 | UNITED ST5 | MFGR#1430 | 7742358.0000 |\n+------+------------+-----------+---------------+\n5 rows in set (0.25 sec)\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/","title":"\u5b8c\u6210 TPC-C \u6d4b\u8bd5","text":"\u901a\u8fc7\u9605\u8bfb\u672c\u6559\u7a0b\uff0c\u4f60\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528 MatrixOne \u5b8c\u6210 TPC-C \u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#tpc-c_1","title":"TPC-C \u6982\u8ff0","text":"TPC-C \u662f\u4e00\u79cd\u8861\u91cf\u5728\u7ebf\u4e8b\u52a1\u5904\u7406\uff08OLTP\uff09\u7cfb\u7edf\u6027\u80fd\u548c\u53ef\u4f38\u7f29\u6027\u7684\u57fa\u51c6\u6d4b\u8bd5\u89c4\u8303\u3002TPC-C \u6a21\u62df\u4e86\u4e00\u4e2a\u6bd4\u8f83\u6709\u4ee3\u8868\u610f\u4e49\u7684 OLTP \u5e94\u7528\u73af\u5883\uff1a\u5728\u7ebf\u8ba2\u5355\u5904\u7406\u7cfb\u7edf\u3002TPC-C \u57fa\u51c6\u6d4b\u8bd5\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u5e93\u7531 Warehouse\u3001Customer\u3001Order\u3001Item \u7b49\u4e5d\u4e2a\u8868\u7ec4\u6210\uff08\u53c2\u89c1\u4e0b\u56fe\uff09\u3002\u9664 Item \u8868\u5916\uff0c\u6bcf\u6761\u8bb0\u5f55\u90fd\u4ee5\u6bcf\u4e2a Warehouse \u4e3a\u57fa\u7840\u8fdb\u884c\u586b\u5145\uff0c\u5e76\u4e14\u4ed3\u5e93\u7684\u6570\u91cf\u6309\u6bd4\u4f8b\u914d\u7f6e\u3002
TPC-C \u9700\u8981\u5904\u7406\u7684\u4ea4\u6613\u4e8b\u52a1\u6709\u4e94\u79cd\uff1aNewOrder\u3001Payment\u3001OrderStatus\u3001Delivery \u548c StockLevel\u3002TPC-C \u5b9a\u4e49\u4e86\u6bcf\u79cd\u4e8b\u52a1\u7684\u8bf7\u6c42\u7387\uff0c\u5176\u4e2d\u51e0\u4e4e 90% \u8bf7\u6c42\u7387\u7684\u4e8b\u52a1\u4e3a\u5199\u5bc6\u96c6\u578b\u7684 NewOrder \u548c Payment\u3002TPC-C \u4e8b\u52a1\u4e3b\u8981\u8bbf\u95ee\u5355\u4e2a\uff08\u672c\u5730\uff09\u4ed3\u5e93\uff0c\u4f46\u5927\u7ea6 10% \u7684\u4e8b\u52a1\u4e0e\u53e6\u4e00\u4e2a\uff08\u8fdc\u7a0b\uff09\u4ed3\u5e93\u4ea4\u4e92\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#matrixone","title":"\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne","text":"\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#mo-tpcc","title":"\u514b\u9686 mo-tpcc \u4ed3\u5e93\u5230\u672c\u5730","text":"git clone https://github.com/matrixorigin/mo-tpcc.git\n\u6216\u8005\ngit clone https://githubfast.com/matrixorigin/mo-tpcc.git\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#_2","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#_3","title":"\u6b65\u9aa4\u7b80\u4ecb","text":"\u672c\u8282\u5c06\u4ecb\u7ecd\u5982\u4f55\u751f\u6210 TPCC \u6570\u636e\u3001\u521b\u5efa TPCC \u8868\uff0c\u5e76\u5c06\u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4ee5\u53ca\u8fd0\u884c TPCC \u6d4b\u8bd5\u3002
\u73b0\u5728\u4f60\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u63cf\u8ff0\u9010\u6b65\u6267\u884c\u547d\u4ee4\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#1-propsmo","title":"1. \u914d\u7f6e props.mo \u6587\u4ef6","text":"\u514b\u9686 mo-tpch \u4ed3\u5e93\u5230\u672c\u5730\u540e\uff0c\u5728\u672c\u5730\u6253\u5f00 mo-tpch \u6587\u4ef6\u5939\uff0c\u6309\u7167\u4e0b\u9762\u7684\u914d\u7f6e\u9879\uff0c\u4fee\u6539\u6587\u4ef6\u5939\u4e2d\u7684 props.mo \u6587\u4ef6\u3002\u6570\u636e\u4ed3\u5e93\u7684\u6570\u91cf\u53ef\u4ee5\u901a\u8fc7\u8be5\u6587\u4ef6\u4e2d\u7684 warehouse=XX
\u884c\u8fdb\u884c\u914d\u7f6e\u3002
db=mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=111\n\n//the number of warehouse\nwarehouses=10\nloadWorkers=4\n\n//the num of terminals that will simultaneously run\n//must be less than warehouses*10\nterminals=1\n//To run specified transactions per terminal- runMins must equal zero\nrunTxnsPerTerminal=0\n//To run for specified minutes- runTxnsPerTerminal must equal zero\nrunMins=1\n//Number of total transactions per minute\nlimitTxnsPerMin=0\n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58 props.mo \u6587\u4ef6\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#2-tpcc","title":"2. \u521b\u5efa TPCC \u6570\u636e\u5e93\u548c\u8868","text":"\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff1a
cd mo-tpcc\n./runSQL.sh props.mo tableCreates\n
Note: \u5982\u679c\u5728\u8fd0\u884c ./runSQL.sh props.mo tableCreates
\u65f6\u4ea7\u751f java:command not found
\u62a5\u9519\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u5728\u4f60\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u6216\u91cd\u65b0\u5b89\u88c5 Java \u548c JDK\u3002
\u4e0a\u9762\u7684\u4ee3\u7801\u8868\u793a\uff0c\u8fdb\u5165\u5230 mo-tpch \u6587\u4ef6\u5939\u76ee\u5f55\uff0c\u6267\u884c\u4ee3\u7801\u521b\u5efa\u5b8c\u6210 TPCC \u6570\u636e\u5e93\u548c\u8868\u3002
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
# ------------------------------------------------------------\n# Loading SQL file ./sql/tableCreates.sql\n# ------------------------------------------------------------\ndrop database if exists tpcc;\ncreate database if not exists tpcc;\nuse tpcc;\ncreate table bmsql_config (\ncfg_name varchar(30) primary key,\ncfg_value varchar(50)\n);\ncreate table bmsql_warehouse (\nw_id integer not null,\nw_ytd decimal(12,2),\nw_tax decimal(4,4),\nw_name varchar(10),\nw_street_1 varchar(20),\nw_street_2 varchar(20),\nw_city varchar(20),\nw_state char(2),\nw_zip char(9),\nprimary key (w_id)\n) PARTITION BY KEY(w_id);\ncreate table bmsql_district (\nd_w_id integer not null,\nd_id integer not null,\nd_ytd decimal(12,2),\nd_tax decimal(4,4),\nd_next_o_id integer,\nd_name varchar(10),\nd_street_1 varchar(20),\nd_street_2 varchar(20),\nd_city varchar(20),\nd_state char(2),\nd_zip char(9),\nprimary key (d_w_id, d_id)\n) PARTITION BY KEY(d_w_id);\ncreate table bmsql_customer (\nc_w_id integer not null,\nc_d_id integer not null,\nc_id integer not null,\nc_discount decimal(4,4),\nc_credit char(2),\nc_last varchar(16),\nc_first varchar(16),\nc_credit_lim decimal(12,2),\nc_balance decimal(12,2),\nc_ytd_payment decimal(12,2),\nc_payment_cnt integer,\nc_delivery_cnt integer,\nc_street_1 varchar(20),\nc_street_2 varchar(20),\nc_city varchar(20),\nc_state char(2),\nc_zip char(9),\nc_phone char(16),\nc_since timestamp,\nc_middle char(2),\nc_data varchar(500),\nprimary key (c_w_id, c_d_id, c_id)\n) PARTITION BY KEY(c_w_id);\ncreate table bmsql_history (\nhist_id integer auto_increment,\nh_c_id integer,\nh_c_d_id integer,\nh_c_w_id integer,\nh_d_id integer,\nh_w_id integer,\nh_date timestamp,\nh_amount decimal(6,2),\nh_data varchar(24),\nprimary key (hist_id)\n);\ncreate table bmsql_new_order (\nno_w_id integer not null,\nno_d_id integer not null,\nno_o_id integer not null,\nprimary key (no_w_id, no_d_id, no_o_id)\n) PARTITION BY KEY(no_w_id);\ncreate table bmsql_oorder (\no_w_id integer not null,\no_d_id integer not null,\no_id integer not null,\no_c_id integer,\no_carrier_id integer,\no_ol_cnt integer,\no_all_local integer,\no_entry_d timestamp,\nprimary key (o_w_id, o_d_id, o_id)\n) PARTITION BY KEY(o_w_id);\ncreate table bmsql_order_line (\nol_w_id integer not null,\nol_d_id integer not null,\nol_o_id integer not null,\nol_number integer not null,\nol_i_id integer not null,\nol_delivery_d timestamp,\nol_amount decimal(6,2),\nol_supply_w_id integer,\nol_quantity integer,\nol_dist_info char(24),\nprimary key (ol_w_id, ol_d_id, ol_o_id, ol_number)\n) PARTITION BY KEY(ol_w_id);\ncreate table bmsql_item (\ni_id integer not null,\ni_name varchar(24),\ni_price decimal(5,2),\ni_data varchar(50),\ni_im_id integer,\nprimary key (i_id)\n) PARTITION BY KEY(i_id);\ncreate table bmsql_stock (\ns_w_id integer not null,\ns_i_id integer not null,\ns_quantity integer,\ns_ytd integer,\ns_order_cnt integer,\ns_remote_cnt integer,\ns_data varchar(50),\ns_dist_01 char(24),\ns_dist_02 char(24),\ns_dist_03 char(24),\ns_dist_04 char(24),\ns_dist_05 char(24),\ns_dist_06 char(24),\ns_dist_07 char(24),\ns_dist_08 char(24),\ns_dist_09 char(24),\ns_dist_10 char(24),\nprimary key (s_w_id, s_i_id)\n) PARTITION BY KEY(s_w_id);\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#3-tpcc","title":"3. \u751f\u6210 TPCC \u6570\u636e\u96c6","text":"\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u751f\u6210 TPCC \u6570\u636e\u96c6\uff1a
./runLoader.sh props.mo filelocation /yourpath/\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
Starting BenchmarkSQL LoadData\n\nprops.mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=***********\nwarehouses=10\nloadWorkers=4\nfileLocation (not defined)\ncsvNullValue (not defined - using default '')\n\nWorker 000: Loading ITEM\nWorker 001: Loading Warehouse 1\nWorker 002: Loading Warehouse 2\nWorker 003: Loading Warehouse 3\nWorker 000: Loading ITEM done\nWorker 000: Loading Warehouse 4\nWorker 003: Loading Warehouse 3 done\nWorker 003: Loading Warehouse 5\nWorker 001: Loading Warehouse 1 done\nWorker 001: Loading Warehouse 6\nWorker 002: Loading Warehouse 2 done\nWorker 002: Loading Warehouse 7\nWorker 000: Loading Warehouse 4 done\nWorker 000: Loading Warehouse 8\nWorker 003: Loading Warehouse 5 done\nWorker 003: Loading Warehouse 9\nWorker 000: Loading Warehouse 8 done\nWorker 000: Loading Warehouse 10\nWorker 002: Loading Warehouse 7 done\nWorker 001: Loading Warehouse 6 done\nWorker 000: Loading Warehouse 10 done\nWorker 003: Loading Warehouse 9 done\n
\u4f60\u4f1a\u5728\u4f60\u6240\u6307\u5b9a\u8def\u5f84\u4e2d\u627e\u5230 10 \u4e2a csv \u6587\u4ef6\uff0c\u6bcf\u4e2a csv \u6587\u4ef6\u90fd\u4f1a\u6620\u5c04\u5230\u7b2c 2 \u6b65\u4e2d\u521b\u5efa\u7684\u8868\u4e2d\u3002
config.csv\ncust-hist.csv\ncustomer.csv\ndistrict.csv\nitem.csv\nnew-order.csv\norder-line.csv\norder.csv\nstock.csv\nwarehouse.csv\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#4-tpcc-matrixone","title":"4. \u5c06 TPCC \u6570\u636e\u52a0\u8f7d\u5230 MatrixOne","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u5e76\u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\u5c06 csv \u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u4e2d\u3002
mysql> load data infile '/yourpath/config.csv' INTO TABLE bmsql_config FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/cust-hist.csv' INTO TABLE bmsql_history FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/customer.csv' INTO TABLE bmsql_customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/district.csv' INTO TABLE bmsql_district FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/warehouse.csv' INTO TABLE bmsql_warehouse FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/item.csv' INTO TABLE bmsql_item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/new-order.csv' INTO TABLE bmsql_new_order FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order-line.csv' INTO TABLE bmsql_order_line FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/stock.csv' INTO TABLE bmsql_stock FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order.csv' INTO TABLE bmsql_oorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#5-tpcc","title":"5. \u8fd0\u884c TPCC \u6d4b\u8bd5","text":"\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u8fd0\u884c TPCC \u6d4b\u8bd5\uff1a
./runBenchmark.sh props.mo\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
.:./lib/*\n2022-12-22 21:15:35 INFO jTPCC:78 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:79 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO jTPCC:80 - Term-00, BenchmarkSQL v5.0\n2022-12-22 21:15:35 INFO jTPCC:81 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO jTPCC:82 - Term-00, (c) 2003, Raul Barbosa\n2022-12-22 21:15:35 INFO jTPCC:83 - Term-00, (c) 2004-2016, Denis Lussier\n2022-12-22 21:15:35 INFO jTPCC:84 - Term-00, (c) 2016, Jan Wieck\n2022-12-22 21:15:35 INFO jTPCC:85 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO jTPCC:86 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, db=mo\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, driver=com.mysql.cj.jdbc.Driver\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, conn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, user=root\n2022-12-22 21:15:35 INFO jTPCC:93 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, warehouses=10\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, terminals=1\n2022-12-22 21:15:35 INFO jTPCC:100 - Term-00, runMins=1\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, limitTxnsPerMin=0\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, terminalWarehouseFixed=false\n2022-12-22 21:15:35 INFO jTPCC:108 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, newOrderWeight=45\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, paymentWeight=43\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, orderStatusWeight=4\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, deliveryWeight=4\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, stockLevelWeight=4\n2022-12-22 21:15:35 INFO jTPCC:115 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, osCollectorScript=null\n2022-12-22 21:15:35 INFO jTPCC:119 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:710 - Term-00, Loading database driver: 'com.mysql.cj.jdbc.Driver'...\n2022-12-22 21:15:35 INFO jTPCC:219 - Term-00, copied props.mo to my_result_2022-12-22_211535/run.properties\n2022-12-22 21:15:35 INFO jTPCC:239 - Term-00, created my_result_2022-12-22_211535/data/runInfo.csv for runID 1\n2022-12-22 21:15:35 INFO jTPCC:255 - Term-00, writing per transaction results to my_result_2022-12-22_211535/data/result.csv\n2022-12-22 21:15:35 INFO jTPCC:268 - Term-00,\n2022-12-22 21:15:36 INFO jTPCC:324 - Term-00, C value for C_LAST during load: 28\n2022-12-22 21:15:36 INFO jTPCC:325 - Term-00, C value for C_LAST this run: 132\n2022-12-22 21:15:36 INFO jTPCC:326 - Term-00,\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Session started! Memory Usage: 17MB / 245MB \n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Creating 1 terminal(s) with -1 transaction(s) per terminal...\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Terminal Warehouse is NOT fixed\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Transaction Weights: 45% New-Order, 43% Payment, 4% Order-Status, 4% Delivery, 4% Stock-Level\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Number of Terminals 1\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Creating database connection for Term-01...\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Term-01 7\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Transaction Weight\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % New-Order 45\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Payment 43\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Order-Status 4\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Delivery 4\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Stock-Level 4\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Transaction Number Terminal Type Execution Time (ms) Comment\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Created 1 terminal(s) successfully!\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Starting all terminals...\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, All terminals started executing 2022-12-22 21:15:36\nTerm-00, Running Average tpmTOTAL: 60000.00 Current tpmTOTAL: 12 Memory Usage: 19MB / 245MB 2022-12-22 21:15:36 INFO jTPCCTerminal:350 - Term-01, Executing for a limited time...\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, The time limit has been reached.: 21MB / 245MB \n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, Signalling all terminals to stop...\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Terminal received stop signal!\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Finishing current transaction before exit...\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, Waiting for all active transactions to end...\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, OTAL: 24 Memory Usage: 22MB / 245MB \n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Closing statement and connection...\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Terminal 'Term-01' finished after 0 transaction(s).\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, All terminals finished executing 2022-12-22 21:16:42\n\n2022-12-22 21:16:42 INFO jTPCC:694 - Term-00,\n2022-12-22 21:16:42 INFO jTPCC:695 - Term-00,\n2022-12-22 21:16:42 INFO jTPCC:696 - Term-00, Measured tpmC (NewOrders) = 2.74\n2022-12-22 21:16:42 INFO jTPCC:697 - Term-00, Measured tpmTOTAL = 3.66\n2022-12-22 21:16:42 INFO jTPCC:698 - Term-00, Measured tpmE (ErrorCount) = 0.0\n2022-12-22 21:16:42 INFO jTPCC:699 - Term-00, Session Start = 2022-12-22 21:15:36\n2022-12-22 21:16:42 INFO jTPCC:700 - Term-00, Session End = 2022-12-22 21:16:42\n2022-12-22 21:16:42 INFO jTPCC:701 - Term-00, Transaction Count = 3\n2022-12-22 21:16:42 INFO jTPCC:702 - Term-00, Transaction Error = 0\n2022-12-22 21:16:42 INFO jTPCC:703 - Term-00, Transaction NewOrders = 3\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, Session finished!\n
\u7531\u4e0a\u9762\u7684\u7ed3\u679c\u53ef\u4ee5\u5f97\u5230 tpmC\uff08\u6bcf\u5206\u949f\u4e8b\u52a1\u6570\uff09\u7684\u503c\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/","title":"\u5b8c\u6210 TPCH \u6d4b\u8bd5","text":"TPC Benchmark\u2122H\uff08TPC-H\uff09\u662f\u51b3\u7b56\u652f\u6301\u57fa\u51c6\u3002\u5b83\u7531\u4e00\u5957\u9762\u5411\u4e1a\u52a1\u7684\u5373\u65f6\u67e5\u8be2\uff08ad-hoc\uff09\u548c\u5e76\u53d1\u6570\u636e\u4fee\u6539\u7ec4\u6210\u3002\u9009\u62e9\u67e5\u8be2\u548c\u586b\u5145\u6570\u636e\u5e93\u7684\u6570\u636e\u5177\u6709\u5e7f\u6cdb\u7684\u884c\u4e1a\u76f8\u5173\u6027\u3002\u8be5\u57fa\u51c6\u6d4b\u8bd5\u89e3\u91ca\u8bf4\u660e\u4e86\u51b3\u7b56\u652f\u6301\u7cfb\u7edf\uff0c\u8be5\u7cfb\u7edf\u53ef\u68c0\u67e5\u5927\u91cf\u6570\u636e\uff0c\u6267\u884c\u9ad8\u5ea6\u590d\u6742\u7684\u67e5\u8be2\u5e76\u4e3a\u5173\u952e\u4e1a\u52a1\u95ee\u9898\u63d0\u4f9b\u7b54\u6848\u3002TPC-H \u662f OLAP \u6570\u636e\u5e93\u5e7f\u6cdb\u4f7f\u7528\u7684\u57fa\u51c6\u6d4b\u8bd5\u3002
\u901a\u8fc7\u9605\u8bfb\u672c\u6559\u7a0b\uff0c\u60a8\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528 MatrixOne \u5b8c\u6210 TPC-H \u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#1-dbgen","title":"1. \u7f16\u8bd1 dbgen","text":"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cTPCH dbgen \u5b9e\u7528\u7a0b\u5e8f\u662f\u7528\u6765\u751f\u6210\u6d4b\u8bd5\u6570\u636e\u96c6\u8868\u683c\u7684\u5de5\u5177\uff0c\u5b83\u6839\u636e\u6bd4\u4f8b\u56e0\u5b50 Scale Factor\uff08SF) \u7684\u5927\u5c0f\u786e\u5b9a\u6570\u636e\u96c6\u7684\u5927\u5c0f\uff0c\u5e76\u751f\u6210\u4e00\u7ec4\u5e73\u9762\u6587\u4ef6\uff08Flat File)\uff0c\u8fd9\u4e9b\u6587\u4ef6\u9002\u5408\u52a0\u8f7d\u5230 tpch \u6a21\u5f0f\u4e2d\u3002
\u5f53\u4f7f\u7528 -s 1
\u65f6 dbgen
\u547d\u4ee4\u4f1a\u4ea7\u751f 1GB \u7684\u5b8c\u6574\u6570\u636e\u96c6\uff0c\u5f53\u4f7f\u7528 -s 10
\u65f6\u4f1a\u4ea7\u751f\u5927\u7ea6 10GB \u7684\u6570\u636e\u96c6\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002
git clone https://github.com/electrum/tpch-dbgen.git\n\u6216\u8005\ngit clone https://githubfast.com/electrum/tpch-dbgen.git\ncd tpch-dbgen\nmake\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#2","title":"2. \u751f\u6210\u6570\u636e","text":"\u8fd0\u884c dbgen
\uff0c\u83b7\u5f97\u9002\u5f53\u7684\u6570\u636e\u5e93\u5927\u5c0f\u56e0\u5b50 (\u5728\u793a\u4f8b\u4e2d\u4e3a 1GB)\u3002
./dbgen -s 1\n
\u751f\u6210\u5b8c\u6574\u6570\u636e\u96c6\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u3002\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u7ed3\u679c\u6587\u4ef6\u3002
total 2150000\n-rw-r--r-- 1 deister staff 24346144 13 may 12:05 customer.tbl\n-rw-r--r-- 1 deister staff 759863287 13 may 12:05 lineitem.tbl\n-rw-r--r-- 1 deister staff 2224 13 may 12:05 nation.tbl\n-rw-r--r-- 1 deister staff 171952161 13 may 12:05 orders.tbl\n-rw-r--r-- 1 deister staff 24135125 13 may 12:05 part.tbl\n-rw-r--r-- 1 deister staff 118984616 13 may 12:05 partsupp.tbl\n-rw-r--r-- 1 deister staff 389 13 may 12:05 region.tbl\n-rw-r--r-- 1 deister staff 1409184 13 may 12:05 supplier.tbl\n
\u6211\u4eec\u540c\u65f6\u4e5f\u51c6\u5907\u4e86 1GB \u7684\u6570\u636e\u96c6\u4f9b\u60a8\u4e0b\u8f7d\u3002\u60a8\u53ef\u4ee5\u5728\u4ee5\u4e0b\u94fe\u63a5\u4e2d\u76f4\u63a5\u83b7\u53d6\u6570\u636e\u6587\u4ef6\uff1a
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#3-matrixone","title":"3. \u5728 MatrixOne \u4e2d\u5efa\u8868","text":"MatrixOne \u6682\u4e0d\u652f\u6301\u5206\u533a\u52a0\u901f\uff0cLINEITEM
\u8868\u7684\u521b\u5efa\u4ee3\u7801\u6709\u4ee5\u4e0b\u4fee\u6539\uff1a
LINEITEM
\u8868\u7684 PARTITION BY KEY()
\u3002drop database if exists TPCH;\ncreate database if not exists TPCH;\nuse tpch;\nCREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n\nCREATE TABLE REGION(\nR_REGIONKEY INTEGER NOT NULL,\nR_NAME CHAR(25) NOT NULL,\nR_COMMENT VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY)\n);\n\nCREATE TABLE PART(\nP_PARTKEY INTEGER NOT NULL,\nP_NAME VARCHAR(55) NOT NULL,\nP_MFGR CHAR(25) NOT NULL,\nP_BRAND CHAR(10) NOT NULL,\nP_TYPE VARCHAR(25) NOT NULL,\nP_SIZE INTEGER NOT NULL,\nP_CONTAINER CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY)\n);\n\nCREATE TABLE SUPPLIER(\nS_SUPPKEY INTEGER NOT NULL,\nS_NAME CHAR(25) NOT NULL,\nS_ADDRESS VARCHAR(40) NOT NULL,\nS_NATIONKEY INTEGER NOT NULL,\nS_PHONE CHAR(15) NOT NULL,\nS_ACCTBAL DECIMAL(15,2) NOT NULL,\nS_COMMENT VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY)\n);\n\nCREATE TABLE PARTSUPP (\nPS_PARTKEY INTEGER NOT NULL,\nPS_SUPPKEY INTEGER NOT NULL,\nPS_AVAILQTY INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY)\n);\n\nCREATE TABLE CUSTOMER(\nC_CUSTKEY INTEGER NOT NULL,\nC_NAME VARCHAR(25) NOT NULL,\nC_ADDRESS VARCHAR(40) NOT NULL,\nC_NATIONKEY INTEGER NOT NULL,\nC_PHONE CHAR(15) NOT NULL,\nC_ACCTBAL DECIMAL(15,2) NOT NULL,\nC_MKTSEGMENT CHAR(10) NOT NULL,\nC_COMMENT VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY)\n);\n\nCREATE TABLE ORDERS(\nO_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n\nCREATE TABLE LINEITEM (\nL_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER)\n);\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#4","title":"4. \u5bfc\u5165\u6570\u636e","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6570\u636e\u52a0\u8f7d\u5230\u76f8\u5173\u7684\u8868\u4e2d\u3002
load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u521b\u5efa\u7684\u8868\u67e5\u8be2 MatrixOne \u4e2d\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#5-tpch","title":"5. \u8fd0\u884c TPCH \u6d4b\u8bd5\u547d\u4ee4","text":"-- Q1\nselect\nl_returnflag,\nl_linestatus,\nsum(l_quantity) as sum_qty,\nsum(l_extendedprice) as sum_base_price,\nsum(l_extendedprice * (1 - l_discount)) as sum_disc_price,\nsum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,\navg(l_quantity) as avg_qty,\navg(l_extendedprice) as avg_price,\navg(l_discount) as avg_disc,\ncount(*) as count_order\nfrom\nlineitem\nwhere\nl_shipdate <= date '1998-12-01' - interval '112' day\ngroup by\nl_returnflag,\nl_linestatus\norder by\nl_returnflag,\nl_linestatus\n;\n\n-- Q2\nselect\ns_acctbal,\ns_name,\nn_name,\np_partkey,\np_mfgr,\ns_address,\ns_phone,\ns_comment\nfrom\npart,\nsupplier,\npartsupp,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand p_size = 48\nand p_type like '%TIN'\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\nand ps_supplycost = (\nselect\nmin(ps_supplycost)\nfrom\npartsupp,\nsupplier,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\n)\norder by\ns_acctbal desc,\nn_name,\ns_name,\np_partkey\nlimit 100\n;\n\n\n-- Q3\nselect\nl_orderkey,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\no_orderdate,\no_shippriority\nfrom\ncustomer,\norders,\nlineitem\nwhere\nc_mktsegment = 'HOUSEHOLD'\nand c_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate < date '1995-03-29'\nand l_shipdate > date '1995-03-29'\ngroup by\nl_orderkey,\no_orderdate,\no_shippriority\norder by\nrevenue desc,\no_orderdate\nlimit 10\n;\n\n-- Q4\nselect\no_orderpriority,\ncount(*) as order_count\nfrom\norders\nwhere\no_orderdate >= date '1997-07-01'\nand o_orderdate < date '1997-07-01' + interval '3' month\nand exists (\nselect\n*\nfrom\nlineitem\nwhere\nl_orderkey = o_orderkey\nand l_commitdate < l_receiptdate\n)\ngroup by\no_orderpriority\norder by\no_orderpriority\n;\n\n\n-- Q5\nselect\nn_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue\nfrom\ncustomer,\norders,\nlineitem,\nsupplier,\nnation,\nregion\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand l_suppkey = s_suppkey\nand c_nationkey = s_nationkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand o_orderdate >= date '1994-01-01'\nand o_orderdate < date '1994-01-01' + interval '1' year\ngroup by\nn_name\norder by\nrevenue desc\n;\n\n\n-- Q6\nselect\nsum(l_extendedprice * l_discount) as revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1994-01-01'\nand l_shipdate < date '1994-01-01' + interval '1' year\nand l_discount between 0.03 - 0.01 and 0.03 + 0.01\nand l_quantity < 24;\n\n-- Q7\nselect\nsupp_nation,\ncust_nation,\nl_year,\nsum(volume) as revenue\nfrom\n(\nselect\nn1.n_name as supp_nation,\nn2.n_name as cust_nation,\nextract(year from l_shipdate) as l_year,\nl_extendedprice * (1 - l_discount) as volume\nfrom\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2\nwhere\ns_suppkey = l_suppkey\nand o_orderkey = l_orderkey\nand c_custkey = o_custkey\nand s_nationkey = n1.n_nationkey\nand c_nationkey = n2.n_nationkey\nand (\n(n1.n_name = 'FRANCE' and n2.n_name = 'ARGENTINA')\nor (n1.n_name = 'ARGENTINA' and n2.n_name = 'FRANCE')\n)\nand l_shipdate between date '1995-01-01' and date '1996-12-31'\n) as shipping\ngroup by\nsupp_nation,\ncust_nation,\nl_year\norder by\nsupp_nation,\ncust_nation,\nl_year\n;\n\n-- Q8\nselect\no_year,\n(sum(case\nwhen nation = 'ARGENTINA' then volume\nelse 0\nend) / sum(volume)) as mkt_share\nfrom\n(\nselect\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) as volume,\nn2.n_name as nation\nfrom\npart,\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2,\nregion\nwhere\np_partkey = l_partkey\nand s_suppkey = l_suppkey\nand l_orderkey = o_orderkey\nand o_custkey = c_custkey\nand c_nationkey = n1.n_nationkey\nand n1.n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand s_nationkey = n2.n_nationkey\nand o_orderdate between date '1995-01-01' and date '1996-12-31'\nand p_type = 'ECONOMY BURNISHED TIN'\n) as all_nations\ngroup by\no_year\norder by\no_year\n;\n\n-- Q9\nselect\nnation,\no_year,\nsum(amount) as sum_profit\nfrom\n(\nselect\nn_name as nation,\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount\nfrom\npart,\nsupplier,\nlineitem,\npartsupp,\norders,\nnation\nwhere\ns_suppkey = l_suppkey\nand ps_suppkey = l_suppkey\nand ps_partkey = l_partkey\nand p_partkey = l_partkey\nand o_orderkey = l_orderkey\nand s_nationkey = n_nationkey\nand p_name like '%pink%'\n) as profit\ngroup by\nnation,\no_year\norder by\nnation,\no_year desc\n;\n\n\n-- Q10\nselect\nc_custkey,\nc_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\nc_acctbal,\nn_name,\nc_address,\nc_phone,\nc_comment\nfrom\ncustomer,\norders,\nlineitem,\nnation\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate >= date '1993-03-01'\nand o_orderdate < date '1993-03-01' + interval '3' month\nand l_returnflag = 'R'\nand c_nationkey = n_nationkey\ngroup by\nc_custkey,\nc_name,\nc_acctbal,\nc_phone,\nn_name,\nc_address,\nc_comment\norder by\nrevenue desc\nlimit 20\n;\n\n\n-- Q11\nselect\nps_partkey,\nsum(ps_supplycost * ps_availqty) as value\nfrom\npartsupp,\nsupplier,\nnation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\ngroup by\nps_partkey having\nsum(ps_supplycost * ps_availqty) > (\nselect\nsum(ps_supplycost * ps_availqty) * 0.0001000000\nfrom\npartsupp,\nsupplier,nation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\n)\norder by\nvalue desc\n;\n\n-- Q12\nselect\nl_shipmode,\nsum(case\nwhen o_orderpriority = '1-URGENT'\nor o_orderpriority = '2-HIGH'\nthen 1\nelse 0\nend) as high_line_count,\nsum(case\nwhen o_orderpriority <> '1-URGENT'\nand o_orderpriority <> '2-HIGH'\nthen 1\nelse 0\nend) as low_line_count\nfrom\norders,\nlineitem\nwhere\no_orderkey = l_orderkey\nand l_shipmode in ('FOB', 'TRUCK')\nand l_commitdate < l_receiptdate\nand l_shipdate < l_commitdate\nand l_receiptdate >= date '1996-01-01'\nand l_receiptdate < date '1996-01-01' + interval '1' year\ngroup by\nl_shipmode\norder by\nl_shipmode\n;\n\n-- Q13\nselect\nc_count,\ncount(*) as custdist\nfrom\n(\nselect\nc_custkey,\ncount(o_orderkey)\nfrom\ncustomer left outer join orders on\nc_custkey = o_custkey\nand o_comment not like '%pending%accounts%'\ngroup by\nc_custkey\n) as c_orders (c_custkey, c_count)\ngroup by\nc_count\norder by\ncustdist desc,\nc_count desc\n;\n\n-- Q14\nselect\n100.00 * sum(case\nwhen p_type like 'PROMO%'\nthen l_extendedprice * (1 - l_discount)\nelse 0\nend) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue\nfrom\nlineitem,\npart\nwhere\nl_partkey = p_partkey\nand l_shipdate >= date '1996-04-01'\nand l_shipdate < date '1996-04-01' + interval '1' month;\n\n-- Q15\nwith q15_revenue0 as (\nselect\nl_suppkey as supplier_no,\nsum(l_extendedprice * (1 - l_discount)) as total_revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1995-12-01'\nand l_shipdate < date '1995-12-01' + interval '3' month\ngroup by\nl_suppkey\n)\nselect\ns_suppkey,\ns_name,\ns_address,\ns_phone,\ntotal_revenue\nfrom\nsupplier,\nq15_revenue0\nwhere\ns_suppkey = supplier_no\nand total_revenue = (\nselect\nmax(total_revenue)\nfrom\nq15_revenue0\n)\norder by\ns_suppkey\n;\n\n-- Q16\nselect\np_brand,\np_type,\np_size,\ncount(distinct ps_suppkey) as supplier_cnt\nfrom\npartsupp,\npart\nwhere\np_partkey = ps_partkey\nand p_brand <> 'Brand#35'\nand p_type not like 'ECONOMY BURNISHED%'\nand p_size in (14, 7, 21, 24, 35, 33, 2, 20)\nand ps_suppkey not in (\nselect\ns_suppkey\nfrom\nsupplier\nwhere\ns_comment like '%Customer%Complaints%'\n)\ngroup by\np_brand,\np_type,\np_size\norder by\nsupplier_cnt desc,\np_brand,\np_type,\np_size\n;\n\n-- Q17\nselect\nsum(l_extendedprice) / 7.0 as avg_yearly\nfrom\nlineitem,\npart\nwhere\np_partkey = l_partkey\nand p_brand = 'Brand#54'\nand p_container = 'LG BAG'\nand l_quantity < (\nselect\n0.2 * avg(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = p_partkey\n);\n\n-- Q18\nselect\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice,\nsum(l_quantity)\nfrom\ncustomer,\norders,\nlineitem\nwhere\no_orderkey in (\nselect\nl_orderkey\nfrom\nlineitem\ngroup by\nl_orderkey having\nsum(l_quantity) > 314\n)\nand c_custkey = o_custkey\nand o_orderkey = l_orderkey\ngroup by\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice\norder by\no_totalprice desc,\no_orderdate\nlimit 100\n;\n\n-- Q19\nselect\nsum(l_extendedprice* (1 - l_discount)) as revenue\nfrom\nlineitem,\npart\nwhere\n(\np_partkey = l_partkey\nand p_brand = 'Brand#23'\nand p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')\nand l_quantity >= 5 and l_quantity <= 5 + 10\nand p_size between 1 and 5\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#15'\nand p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')\nand l_quantity >= 14 and l_quantity <= 14 + 10\nand p_size between 1 and 10\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#44'\nand p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')\nand l_quantity >= 28 and l_quantity <= 28 + 10\nand p_size between 1 and 15\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n);\n\n-- Q20\nselect\ns_name,\ns_address\nfrom\nsupplier,\nnation\nwhere\ns_suppkey in (\nselect\nps_suppkey\nfrom\npartsupp\nwhere\nps_partkey in (\nselect\np_partkey\nfrom\npart\nwhere\np_name like 'lime%'\n)\nand ps_availqty > (\nselect\n0.5 * sum(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = ps_partkey\nand l_suppkey = ps_suppkey\nand l_shipdate >= date '1993-01-01'\nand l_shipdate < date '1993-01-01' + interval '1' year\n)\n)\nand s_nationkey = n_nationkey\nand n_name = 'VIETNAM'\norder by s_name\n;\n\n-- Q21\nselect\ns_name,\ncount(*) as numwait\nfrom\nsupplier,\nlineitem l1,\norders,\nnation\nwhere\ns_suppkey = l1.l_suppkey\nand o_orderkey = l1.l_orderkey\nand o_orderstatus = 'F'\nand l1.l_receiptdate > l1.l_commitdate\nand exists (\nselect\n*\nfrom\nlineitem l2\nwhere\nl2.l_orderkey = l1.l_orderkey\nand l2.l_suppkey <> l1.l_suppkey\n)\nand not exists (\nselect\n*\nfrom\nlineitem l3\nwhere\nl3.l_orderkey = l1.l_orderkey\nand l3.l_suppkey <> l1.l_suppkey\nand l3.l_receiptdate > l3.l_commitdate\n)\nand s_nationkey = n_nationkey\nand n_name = 'BRAZIL'\ngroup by\ns_name\norder by\nnumwait desc,\ns_name\nlimit 100\n;\n\n-- Q22\nselect\ncntrycode,\ncount(*) as numcust,\nsum(c_acctbal) as totacctbal\nfrom\n(\nselect\nsubstring(c_phone from 1 for 2) as cntrycode,\nc_acctbal\nfrom\ncustomer\nwhere\nsubstring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\nand c_acctbal > (\nselect\navg(c_acctbal)\nfrom\ncustomer\nwhere\nc_acctbal > 0.00\nand substring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\n)\nand not exists (\nselect\n*\nfrom\norders\nwhere\no_custkey = c_custkey\n)\n) as custsale\ngroup by\ncntrycode\norder by\ncntrycode\n;\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#6","title":"6. \u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":"\u4ee5\u4e0b\u4e3a 22 \u4e2a TPCH \u67e5\u8be2\u7684\u9884\u671f\u7ed3\u679c\u3002
\u8bf4\u660e\uff1a\u7531\u4e8e Q16 \u7684\u7ed3\u679c\u6bb5\u843d\u8fc7\u957f\uff0c\u65e0\u6cd5\u5728\u4e0b\u6587\u5c55\u793a\uff0c\u8bf7\u53c2\u9605\u6b64\u8fde\u7ed3\u7684\u5b8c\u6574\u7ed3\u679c\uff1aQ16 \u8fd0\u884c\u9884\u671f\u7ed3\u679c
Q1\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+-------------+----------------+------------+-------------+\n| l_returnflag | l_linestatus | sum_qty | sum_base_price | sum_disc_price | sum_charge | avg_qty | avg_price | avg_disc | count_order |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+-------------+----------------+------------+-------------+\n| A | F | 37734107.00 | 56586554400.73 | 53758257134.8700 | 55909065222.827692 | 25.52200585 | 38273.12973462 | 0.04998530 | 1478493 |\n| N | F | 991417.00 | 1487504710.38 | 1413082168.0541 | 1469649223.194375 | 25.51647192 | 38284.46776085 | 0.05009343 | 38854 |\n| N | O | 73295769.00 | 109931611187.71 | 104436646745.0693 | 108617847377.142872 | 25.50176452 | 38248.45691074 | 0.04999662 | 2874145 |\n| R | F | 37719753.00 | 56568041380.90 | 53741292684.6040 | 55889619119.831932 | 25.50579361 | 38250.85462610 | 0.05000941 | 1478870 |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+-------------+----------------+------------+-------------+\n4 rows in set (0.56 sec)\n\nQ2\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n| s_acctbal | s_name | n_name | p_partkey | p_mfgr | s_address | s_phone | s_comment |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n| 9973.93 | Supplier#000004194 | JORDAN | 14193 | Manufacturer#1 | A8AoX9AK,qhf,CpEF | 23-944-413-2681 | t fluffily. regular requests about the regular, unusual somas play of the furiously busy |\n| 9956.34 | Supplier#000005108 | IRAN | 140079 | Manufacturer#5 | d3PLCdpPP3uE4GzbbAh4bWmU 7ecOifL9e1mNnzG | 20-842-882-7047 | ronic accounts. carefully bold accounts sleep beyond |\n| 9836.43 | Supplier#000000489 | IRAN | 190488 | Manufacturer#2 | y9NMoYGxDUPfrB1GwjYhLtCeV7pOt | 20-375-500-2226 | quickly carefully pending accounts. fina |\n| 9825.95 | Supplier#000007554 | IRAQ | 40041 | Manufacturer#5 | Huq0k qKET hByp3RcMcr | 21-787-637-9651 | ending, final requests thrash pending, |\n| 9806.52 | Supplier#000005276 | IRAQ | 132762 | Manufacturer#2 | inh0KOhRfLM7WRhdRNvJJDQx | 21-834-496-7360 | the slyly unusual theodolites; carefully even accounts use slyly. sl |\n| 9796.31 | Supplier#000005847 | IRAQ | 188292 | Manufacturer#1 | obol3bfh0zWi | 21-530-950-2847 | equests. blithely regular deposits should have to impress. final platelets integrate fluffily |\n| 9775.37 | Supplier#000007245 | IRAQ | 169696 | Manufacturer#5 | 5VOUnvxlJeOJ | 21-663-724-2985 | ic deposits about the slyly bold requests |\n| 9755.43 | Supplier#000002439 | EGYPT | 172438 | Manufacturer#5 | rXxojWV0VefSK7A0dhF | 14-410-168-5354 | p quickly packages. carefully pending pinto beans after the |\n| 9714.60 | Supplier#000007317 | EGYPT | 29810 | Manufacturer#4 | nJGsPl2ruoq4Ydtv0fwWG385eOFV6 VUokbCZ | 14-666-351-2592 | ons integrate furiously? slyly ironic requests sl |\n| 9557.33 | Supplier#000007367 | EGYPT | 197366 | Manufacturer#3 | bTP8DLvaRAB0n | 14-234-934-5255 | ep slyly regular accounts-- regular, regular excuses dazzle furiously about the reg |\n| 9538.15 | Supplier#000000979 | IRAN | 55968 | Manufacturer#1 | cdvHjrKZR7iDlmSWU2a | 20-151-688-1408 | ckages cajole quietly carefully regular in |\n| 9513.31 | Supplier#000004163 | SAUDI ARABIA | 109142 | Manufacturer#4 | 2VnQypC7pJPJRu6HzYRg7nAvhzckcYAQFbI | 30-544-852-3772 | he regular requests. blithely final |\n| 9450.15 | Supplier#000002067 | EGYPT | 9566 | Manufacturer#3 | 9dO68x0XLMCUDuFk1J6k9hpvLoKx 4qasok4lIb | 14-252-246-5791 | rding to the regular dolphins. quickly ir |\n| 9359.59 | Supplier#000005087 | JORDAN | 55086 | Manufacturer#4 | q0c6r9wYVQx31IeGBZKfe | 23-335-392-5204 | osits. quickly regular packages haggle among the quickly silent ins |\n| 9343.35 | Supplier#000006337 | IRAN | 173819 | Manufacturer#1 | ilQgNOdCAysclt3SgODb6LeJ7d4RzYD | 20-950-345-8173 | quickly ironic packages affix aft |\n| 9318.47 | Supplier#000003834 | SAUDI ARABIA | 11332 | Manufacturer#5 | cxGQnW3nShks59xA5bPoaC bIvcBWUt | 30-823-353-6520 | regular instructions. express packages run slyly pending |\n| 9318.47 | Supplier#000003834 | SAUDI ARABIA | 108813 | Manufacturer#2 | cxGQnW3nShks59xA5bPoaC bIvcBWUt | 30-823-353-6520 | regular instructions. express packages run slyly pending |\n| 9315.33 | Supplier#000003009 | IRAN | 40504 | Manufacturer#2 | oTbwfQ,Yfdcf3ysgc60NKtTpSIc | 20-306-556-2450 | the carefully special requests. express instructions wake |\n| 9296.31 | Supplier#000008213 | JORDAN | 163180 | Manufacturer#2 | YhdN9ESxYvhJp9ngr12Bbeo4t3zLPD, | 23-197-507-9431 | g to the blithely regular accounts! deposit |\n| 9284.57 | Supplier#000009781 | EGYPT | 4780 | Manufacturer#4 | 49NAd1iDiY4, | 14-410-636-4312 | its. ironic pinto beans are blithely. express depths use caref |\n| 9261.13 | Supplier#000000664 | EGYPT | 125639 | Manufacturer#5 | ln6wISAnC8Bpj q4V | 14-244-772-4913 | ly special foxes cajole slyly ironic reque |\n| 9260.78 | Supplier#000001949 | IRAN | 86932 | Manufacturer#2 | W79M2lpYiSY76Ujo6fSRUQiu | 20-531-767-2819 | thinly ironic excuses haggle slyly. f |\n| 9227.16 | Supplier#000009461 | EGYPT | 126948 | Manufacturer#2 | Eweba 0sfaF,l4sAxXGTgEjzsJsNWWIGjYhFkRWV | 14-983-137-4957 | lly bold packages. carefully express deposits integrate about the unusual accounts. regular, |\n| 9185.89 | Supplier#000007888 | EGYPT | 27887 | Manufacturer#1 | nq06Y48amPfS8YBuduy1RYu | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas |\n| 9185.89 | Supplier#000007888 | EGYPT | 190330 | Manufacturer#4 | nq06Y48amPfS8YBuduy1RYu | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas |\n| 9132.92 | Supplier#000007878 | IRAN | 92859 | Manufacturer#3 | aq6T3tUVq1, | 20-861-274-6282 | waters cajole ironic, ironic requests. furi |\n| 9058.94 | Supplier#000002789 | IRAN | 142788 | Manufacturer#4 | 7EkIldjP7M6psSWcJ11tf65GT7ZC7UaiCh | 20-842-716-4307 | s. platelets use carefully. busily regular accounts cajole fluffily above the slowly final pinto be |\n| 9026.80 | Supplier#000005436 | SAUDI ARABIA | 92926 | Manufacturer#3 | 3HiusYZGYmHItExgX5VfNCdJwkW8W7R | 30-453-280-6340 | . blithely unusual requests |\n| 9007.16 | Supplier#000001747 | EGYPT | 121746 | Manufacturer#3 | UyDlFjVxanP,ifej7L5jtNaubC | 14-141-360-9722 | maintain bravely across the busily express pinto beans. sometimes |\n| 8846.35 | Supplier#000005446 | EGYPT | 57930 | Manufacturer#2 | Nusoq0ckv9SwnJZV8Rw2dUqE,V0ylm Bon | 14-468-853-6477 | deposits. ironic, bold ideas wake. fluffily ironic deposits must have to sleep furiously pending |\n| 8837.21 | Supplier#000007210 | JORDAN | 144695 | Manufacturer#3 | G7MYkWkkJDVu,rr23aXjQCwNqZ2Vk6 | 23-560-295-1805 | en, express foxes use across the blithely bold |\n| 8800.91 | Supplier#000008182 | EGYPT | 143153 | Manufacturer#5 | KGMyipBiAF00tSB99DwH | 14-658-338-3635 | thely even excuses integrate blithel |\n| 8788.46 | Supplier#000003437 | IRAN | 118414 | Manufacturer#4 | JfgZDO9fsP4ljfzsi,s7431Ld3A7zXtHfrF74 | 20-547-871-1712 | ickly unusual dependencies. carefully regular dolphins ha |\n| 8750.12 | Supplier#000001064 | IRAQ | 31063 | Manufacturer#5 | QgmUIaEs5KpuW ,oREZV2b4wr3HEC1z4F | 21-440-809-7599 | sly even deposits? furiously regular pack |\n| 8594.80 | Supplier#000007553 | IRAN | 5052 | Manufacturer#4 | wAU2Lui w9 | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final |\n| 8594.80 | Supplier#000007553 | IRAN | 195033 | Manufacturer#1 | wAU2Lui w9 | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final |\n| 8588.63 | Supplier#000008094 | SAUDI ARABIA | 148093 | Manufacturer#1 | SNS6FCscBNZBFecA | 30-465-665-6735 | ake quickly blithely ironic theodolites. quickly ironic ideas boost. furiously iro |\n| 8522.70 | Supplier#000004208 | IRAQ | 166659 | Manufacturer#5 | x3jZYF7ZYN 8a4LY1c1kEsh | 21-468-998-1571 | furiously regular accounts! |\n| 8514.86 | Supplier#000006347 | JORDAN | 181310 | Manufacturer#5 | wwR5j4kdIAwLe33uBwo | 23-340-942-3641 | uests breach blithely ironic deposi |\n| 8473.01 | Supplier#000003912 | IRAQ | 33911 | Manufacturer#3 | Op7,1zt3MAxs34Qo4O W | 21-474-809-6508 | es. regular, brave instructions wa |\n| 8405.28 | Supplier#000007886 | IRAQ | 192847 | Manufacturer#4 | sFTj5nzc5EIVmzjXwenFTXD U | 21-735-778-5786 | ven dependencies boost blithely ironic de |\n| 8375.58 | Supplier#000001259 | IRAQ | 38755 | Manufacturer#2 | 32cJBGFFpGEkEjx1sF8JZAy0A72uXL5qU | 21-427-422-4993 | ironic accounts haggle slyly alongside of the carefully ironic deposit |\n| 8351.75 | Supplier#000007495 | IRAQ | 114983 | Manufacturer#4 | 3jQQGvfs,5Aryhn0Z | 21-953-463-7239 | requests. carefully final accounts after the qui |\n| 8230.12 | Supplier#000001058 | SAUDI ARABIA | 68551 | Manufacturer#2 | fJ8egP,xkLygXGv8bmtc9T1FJ | 30-496-504-3341 | requests haggle? regular, regular pinto beans integrate fluffily. dependenc |\n| 8195.44 | Supplier#000009805 | IRAQ | 4804 | Manufacturer#4 | dTTmLRYJNat,JbhlQlxwWp HjMR | 21-838-243-3925 | lets. quickly even theodolites dazzle slyly even a |\n| 8175.17 | Supplier#000003172 | IRAN | 55656 | Manufacturer#5 | 8ngbGS7BQoTDmJyMa5WV9XbaM31u5FAayd2vT3 | 20-834-374-7746 | ss deposits use furiously after the quickly final sentiments. fluffily ruthless ideas believe regu |\n| 8159.13 | Supplier#000007486 | EGYPT | 17485 | Manufacturer#1 | AjfdzbrrJE1 | 14-970-643-1521 | ld accounts. enticingly furious requests cajole. final packages s |\n| 8111.40 | Supplier#000007567 | IRAN | 197566 | Manufacturer#1 | 7W4k2qEVoBkRehprGliXRSYVOQEh | 20-377-181-7435 | gular foxes. silent attainments boost furiousl |\n| 8046.55 | Supplier#000001625 | IRAQ | 14121 | Manufacturer#2 | yKlKMbENR6bfmIu7aCFmbs | 21-769-404-7617 | deposits. ideas boost blithely. slyly even Tiresias according to the platelets are q |\n| 8040.16 | Supplier#000001925 | SAUDI ARABIA | 4424 | Manufacturer#4 | Cu5Ub AAdXT | 30-969-417-1108 | pending packages across the regular req |\n| 8031.68 | Supplier#000002370 | SAUDI ARABIA | 147341 | Manufacturer#5 | xGQB9xSPqRtCuMZaJavOrFuTY7km | 30-373-388-2352 | dependencies. carefully express deposits use slyly among the slyly unusual pearls. dogge |\n| 8031.42 | Supplier#000008216 | IRAN | 83199 | Manufacturer#2 | jsqlyr1ViAo | 20-224-305-7298 | to the carefully even excuses haggle blithely against the pending pinto be |\n| 8007.83 | Supplier#000006266 | JORDAN | 81249 | Manufacturer#1 | XWBf5Jd2V5SOurbn11Tt1 | 23-363-445-7184 | as cajole carefully against the quickly special ac |\n| 7995.78 | Supplier#000006957 | IRAN | 161924 | Manufacturer#1 | 8lvRhU5xtXv | 20-312-173-2216 | ly ironic accounts. stealthily regular foxes about the blithely ironic requests play blithely abo |\n| 7913.40 | Supplier#000003148 | JORDAN | 58137 | Manufacturer#1 | CpCJWI4PHeiwYuq0 | 23-767-770-9172 | ove the quickly final packages boost fluffily among the furiously final platelets. carefully s |\n| 7910.16 | Supplier#000002102 | IRAQ | 99592 | Manufacturer#2 | 1kuyUn5q6czLOGB60fAVgpv68M2suwchpmp2nK | 21-367-198-9930 | accounts after the blithely |\n| 7893.58 | Supplier#000000918 | SAUDI ARABIA | 13414 | Manufacturer#1 | e0sB7xAU3,cWF7pzXrpIbATUNydCUZup | 30-303-831-1662 | ependencies wake carefull |\n| 7885.17 | Supplier#000004001 | JORDAN | 38994 | Manufacturer#2 | 3M39sZY1XeQXPDRO | 23-109-632-6806 | efully express packages integrate across the regular pearls. blithely unusual packages mainta |\n| 7880.20 | Supplier#000005352 | JORDAN | 351 | Manufacturer#3 | PP9gHTn946hXqUF5E7idIPLkhnN | 23-557-756-7951 | egular frays. final instructions sleep a |\n| 7844.31 | Supplier#000006987 | IRAQ | 44482 | Manufacturer#5 | UH1zBxTNjTminnmHRe h YUT1eR | 21-963-444-7397 | nag quickly carefully regular requests. ironic theo |\n| 7812.27 | Supplier#000006967 | SAUDI ARABIA | 151936 | Manufacturer#4 | S4i1HfrSM4m3di3R9Cxxp59M1 | 30-193-457-6365 | ely. dependencies cajole quickly. final warhorses across the furiously ironic foxes integr |\n| 7767.63 | Supplier#000004306 | IRAN | 31802 | Manufacturer#2 | SkZkJZflW5mDg9wL fJ | 20-911-180-1895 | uickly regular ideas. blithely express accounts along the carefully sile |\n| 7741.42 | Supplier#000000899 | IRAQ | 53383 | Manufacturer#5 | oLlkiVghtro IwzcwFuzwMCG94rRpux | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi |\n| 7741.42 | Supplier#000000899 | IRAQ | 105878 | Manufacturer#3 | oLlkiVghtro IwzcwFuzwMCG94rRpux | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi |\n| 7741.10 | Supplier#000001059 | IRAN | 103528 | Manufacturer#4 | 4tBenOMokWbWVRB8i8HwENeO cQjM9 | 20-620-710-8984 | to the carefully special courts. |\n| 7599.20 | Supplier#000006596 | SAUDI ARABIA | 184077 | Manufacturer#2 | k8qeFxfXKIGYdQ82RXAfCwddSrc | 30-804-947-3851 | ously unusual deposits boost carefully after the enticing |\n| 7598.31 | Supplier#000008857 | IRAQ | 63844 | Manufacturer#4 | dP2th8vneyOLIUFwNBwqixkFD6 | 21-691-170-4769 | s. quickly ironic frays detect carefully |\n| 7591.79 | Supplier#000009723 | JORDAN | 104702 | Manufacturer#2 | Q1CkkpDdlLOpCJiV,zIf,Mv86otWhxj7slGc | 23-710-907-3873 | e fluffily even instructions. packages impress enticingly. |\n| 7575.12 | Supplier#000007557 | IRAQ | 77556 | Manufacturer#1 | udLvpjNvIx9qeRNdjL1ZAO0OZNOBo6h | 21-629-935-9941 | ally special accounts nod; f |\n| 7496.91 | Supplier#000005828 | IRAN | 103317 | Manufacturer#1 | Xt0EqDCNU6X00sNsIO7nd0ws3H | 20-435-850-8703 | furiously about the fluffily careful idea |\n| 7472.88 | Supplier#000004204 | EGYPT | 14203 | Manufacturer#1 | 0rGZJ6VZXdH | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care |\n| 7472.88 | Supplier#000004204 | EGYPT | 161687 | Manufacturer#3 | 0rGZJ6VZXdH | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care |\n| 7467.63 | Supplier#000003270 | IRAN | 45757 | Manufacturer#2 | 7j4n5FnNEHVJxFhiyz | 20-450-599-9591 | regular, even instructions boost deposits |\n| 7465.41 | Supplier#000008686 | EGYPT | 188685 | Manufacturer#4 | 4Onf4yxuNwHCRIC0y | 14-454-946-4151 | ly final ideas. bravely unusual deposits doze carefully. expr |\n| 7460.80 | Supplier#000008701 | IRAQ | 83684 | Manufacturer#3 | PLR2QehcW08 | 21-747-984-4244 | ideas use carefully pending, final deposits. ironic, pe |\n| 7447.86 | Supplier#000005877 | JORDAN | 120852 | Manufacturer#2 | EyqOHClZZMJkq grnOX9 4alZx6P7B2fq | 23-419-288-6451 | lar pinto beans breach carefully final pinto |\n| 7445.03 | Supplier#000009802 | IRAQ | 164769 | Manufacturer#5 | y6wLN KiZuTf5HT9Hbm0BELn1GUTD6yl | 21-116-708-2013 | nic requests. pinto beans across the carefully regular grouches snooze among the final pin |\n| 7401.46 | Supplier#000008677 | IRAN | 123652 | Manufacturer#5 | WNa780JZzivxuGBEsDszqoT1Pj | 20-899-256-5288 | onic instructions along the furiously ironic accounts haggle fluffily silently un |\n| 7393.50 | Supplier#000007056 | IRAQ | 54550 | Manufacturer#1 | M5cAJQvW9D5zwC7o2qkoe | 21-175-383-4727 | slyly even requests. forges haggle boldly express requests. furio |\n| 7376.11 | Supplier#000003982 | IRAQ | 118959 | Manufacturer#1 | jx9EloF33Ez | 21-890-236-4160 | s the furiously special warhorses affix after the car |\n| 7264.42 | Supplier#000001565 | IRAQ | 14061 | Manufacturer#4 | bOwKHdBteMkZoZcxdigk4Tnu07w1gDztmV7hvCw | 21-791-273-8592 | to beans. express accounts nag around the |\n| 7256.46 | Supplier#000009116 | IRAQ | 4115 | Manufacturer#3 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci |\n| 7256.46 | Supplier#000009116 | IRAQ | 99115 | Manufacturer#1 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci |\n| 7256.46 | Supplier#000009116 | IRAQ | 131576 | Manufacturer#4 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci |\n| 7254.81 | Supplier#000005664 | EGYPT | 35663 | Manufacturer#2 | b8VWuTXRt66wF9bfrgTmNGuxf1PU0x3O9e | 14-214-171-8987 | ts across the quickly pending pin |\n| 7186.63 | Supplier#000006958 | IRAN | 71943 | Manufacturer#4 | 0n9BD,gRzUc3B,PsFcxDBGp4BFf4P | 20-185-413-5590 | against the instructions. requests are. speci |\n| 7166.36 | Supplier#000003541 | EGYPT | 116007 | Manufacturer#1 | DbwyOxoaMEdhEtIB3y045QrKCi2fQpGRu, | 14-508-763-1850 | ages. carefully unusual requests across the pending instructions aff |\n| 7128.81 | Supplier#000000677 | JORDAN | 50676 | Manufacturer#4 | 8mhrffG7D2WJBSQbOGstQ | 23-290-639-3315 | nder blithely. slyly unusual theod |\n| 7051.73 | Supplier#000003349 | IRAQ | 125812 | Manufacturer#3 | wtTK9df9kY7mQ5QUM0Xe5bHLMRLgwE | 21-614-525-7451 | ar theodolites cajole fluffily across the pending requests. slyly final requests a |\n| 7023.47 | Supplier#000009543 | SAUDI ARABIA | 47038 | Manufacturer#1 | VYKinyOBNXRr Hdqn8kOxfTw | 30-785-782-6088 | sts. furiously pending packages sleep slyly even requests. final excuses print deposits. final pac |\n| 6985.93 | Supplier#000006409 | IRAQ | 131382 | Manufacturer#1 | eO8JDNM19HrlQMR | 21-627-356-3992 | sts. slyly final deposits around the regular accounts are along the furiously final pac |\n| 6964.75 | Supplier#000009931 | EGYPT | 57425 | Manufacturer#1 | peQYiRFk G0xZKfJ | 14-989-166-5782 | deposits according to the sometimes silent requests wake along the packages-- blithely f |\n| 6964.04 | Supplier#000007399 | IRAQ | 77398 | Manufacturer#2 | zdxjENOGR4QiCFP | 21-859-733-1999 | e blithely after the even requests. carefully ironic packages use slyly a |\n| 6913.81 | Supplier#000002625 | IRAQ | 22624 | Manufacturer#3 | a4V0rWemgbsT ZMj w7DB8rUbZ4F4lqqW5VKljQF | 21-136-564-3910 | . asymptotes among the express requests cajole furiously after the ca |\n| 6880.18 | Supplier#000006704 | IRAN | 26703 | Manufacturer#4 | 97rxJlAImbO1 sUlChUWoOJ0ZzvQ2NI3KI6VDOwk | 20-588-916-1286 | old accounts wake quickly. ca |\n| 6878.62 | Supplier#000001697 | IRAQ | 146668 | Manufacturer#5 | 37nm ODTeHy0xWTWegplgdWQqelh | 21-377-544-4864 | ironic theodolites. furiously regular d |\n| 6790.39 | Supplier#000008703 | IRAN | 123678 | Manufacturer#4 | wMslK1A8SEUTIIdApQ | 20-782-266-2552 | eep blithely regular, pending w |\n| 6763.46 | Supplier#000007882 | EGYPT | 137881 | Manufacturer#5 | JDv8BZiYG0UlZ | 14-111-252-9120 | the silent accounts wake foxes. furious |\n| 6751.81 | Supplier#000003156 | EGYPT | 165607 | Manufacturer#2 | alRWaW4FTFERMM4vf2rHKIKE | 14-843-946-7775 | are furiously. final theodolites affix slyly bold deposits. even packages haggle idly slyly specia |\n| 6702.07 | Supplier#000006276 | EGYPT | 31269 | Manufacturer#2 | ,dE1anEjKQGZfgquYfkx2fkGcXH | 14-896-626-7847 | ze about the carefully regular pint |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n100 rows in set (0.11 sec)\n\nQ3\n+------------+-------------+-------------+----------------+\n| l_orderkey | revenue | o_orderdate | o_shippriority |\n+------------+-------------+-------------+----------------+\n| 2152675 | 431309.8065 | 1995-03-28 | 0 |\n| 4994400 | 423834.7976 | 1995-03-09 | 0 |\n| 2160291 | 401149.7805 | 1995-03-18 | 0 |\n| 2845094 | 401094.1393 | 1995-03-06 | 0 |\n| 1902471 | 400497.3847 | 1995-03-01 | 0 |\n| 5624358 | 395710.6806 | 1995-03-20 | 0 |\n| 2346242 | 392580.0394 | 1995-03-17 | 0 |\n| 2529826 | 387365.1560 | 1995-02-17 | 0 |\n| 5168933 | 385433.6198 | 1995-03-20 | 0 |\n| 2839239 | 380503.7310 | 1995-03-22 | 0 |\n+------------+-------------+-------------+----------------+\n10 rows in set\n\nQ4\n+-----------------+-------------+\n| o_orderpriority | order_count |\n+-----------------+-------------+\n| 1-URGENT | 10623 |\n| 2-HIGH | 10465 |\n| 3-MEDIUM | 10309 |\n| 4-NOT SPECIFIED | 10618 |\n| 5-LOW | 10541 |\n+-----------------+-------------+\n5 rows in set\n\nQ5\n+---------------+---------------+\n| n_name | revenue |\n+---------------+---------------+\n| PERU | 56206762.5035 |\n| CANADA | 56052846.0161 |\n| ARGENTINA | 54595012.8076 |\n| BRAZIL | 53601776.5201 |\n| UNITED STATES | 50890580.8962 |\n+---------------+---------------+\n5 rows in set\n\nQ6\n+---------------+\n| revenue |\n+---------------+\n| 61660051.7967 |\n+---------------+\n\nQ7\n+-------------+-------------+--------+---------------+\n| supp_nation | cust_nation | l_year | revenue |\n+-------------+-------------+--------+---------------+\n| ARGENTINA | FRANCE | 1995 | 57928886.8015 |\n| ARGENTINA | FRANCE | 1996 | 55535134.8474 |\n| FRANCE | ARGENTINA | 1995 | 52916227.7375 |\n| FRANCE | ARGENTINA | 1996 | 51077995.8841 |\n+-------------+-------------+--------+---------------+\n4 rows in set\n\nQ8\n+--------+----------------------+\n| o_year | mkt_share |\n+--------+----------------------+\n| 1995 | 0.035094304475112484 |\n| 1996 | 0.03724375099464825 |\n+--------+----------------------+\n2 rows in set\n\nQ9\n+----------------+--------+---------------+\n| nation | o_year | sum_profit |\n+----------------+--------+---------------+\n| ALGERIA | 1998 | 29931671.4862 |\n| ALGERIA | 1997 | 49521023.1139 |\n| ALGERIA | 1996 | 51283603.7356 |\n| ALGERIA | 1995 | 50206939.3447 |\n| ALGERIA | 1994 | 48738988.5891 |\n| ALGERIA | 1993 | 48084070.1204 |\n| ALGERIA | 1992 | 49725592.1793 |\n| ARGENTINA | 1998 | 26407044.9262 |\n| ARGENTINA | 1997 | 46224601.0785 |\n| ARGENTINA | 1996 | 44579611.0571 |\n| ARGENTINA | 1995 | 45081953.2540 |\n| ARGENTINA | 1994 | 48291282.8512 |\n| ARGENTINA | 1993 | 48063838.9130 |\n| ARGENTINA | 1992 | 45277890.2991 |\n| BRAZIL | 1998 | 28577022.6384 |\n| BRAZIL | 1997 | 46808660.3688 |\n| BRAZIL | 1996 | 47119265.0765 |\n| BRAZIL | 1995 | 47706399.9100 |\n| BRAZIL | 1994 | 48377469.9386 |\n| BRAZIL | 1993 | 46933565.7471 |\n| BRAZIL | 1992 | 47272215.5408 |\n| CANADA | 1998 | 30500303.6521 |\n| CANADA | 1997 | 50046257.5687 |\n| CANADA | 1996 | 52638586.9029 |\n| CANADA | 1995 | 50433911.3289 |\n| CANADA | 1994 | 51605251.7124 |\n| CANADA | 1993 | 50117218.8464 |\n| CANADA | 1992 | 50347111.2789 |\n| CHINA | 1998 | 26956001.9487 |\n| CHINA | 1997 | 48311246.7866 |\n| CHINA | 1996 | 51133929.1033 |\n| CHINA | 1995 | 48024289.1049 |\n| CHINA | 1994 | 50027433.6557 |\n| CHINA | 1993 | 48240226.3801 |\n| CHINA | 1992 | 47769117.6007 |\n| EGYPT | 1998 | 26972573.1604 |\n| EGYPT | 1997 | 46708654.7666 |\n| EGYPT | 1996 | 46095050.4457 |\n| EGYPT | 1995 | 44901908.2949 |\n| EGYPT | 1994 | 48522762.8892 |\n| EGYPT | 1993 | 49055807.7642 |\n| EGYPT | 1992 | 46909796.1083 |\n| ETHIOPIA | 1998 | 26364411.6457 |\n| ETHIOPIA | 1997 | 44889623.0645 |\n| ETHIOPIA | 1996 | 47554295.2892 |\n| ETHIOPIA | 1995 | 44747639.5440 |\n| ETHIOPIA | 1994 | 46497570.0631 |\n| ETHIOPIA | 1993 | 43853718.5460 |\n| ETHIOPIA | 1992 | 44005773.0397 |\n| FRANCE | 1998 | 27033406.6353 |\n| FRANCE | 1997 | 45763555.5515 |\n| FRANCE | 1996 | 47178544.9301 |\n| FRANCE | 1995 | 48821282.1929 |\n| FRANCE | 1994 | 46444640.9397 |\n| FRANCE | 1993 | 46602311.0590 |\n| FRANCE | 1992 | 47769356.5113 |\n| GERMANY | 1998 | 26165681.8305 |\n| GERMANY | 1997 | 46600844.4431 |\n| GERMANY | 1996 | 44873520.1979 |\n| GERMANY | 1995 | 47761215.6058 |\n| GERMANY | 1994 | 42283120.0209 |\n| GERMANY | 1993 | 46954873.9820 |\n| GERMANY | 1992 | 46263626.6361 |\n| INDIA | 1998 | 27651103.0250 |\n| INDIA | 1997 | 46000888.8340 |\n| INDIA | 1996 | 43993476.7354 |\n| INDIA | 1995 | 44015709.1914 |\n| INDIA | 1994 | 44281439.6282 |\n| INDIA | 1993 | 45367255.7857 |\n| INDIA | 1992 | 45350810.5330 |\n| INDONESIA | 1998 | 27120545.3120 |\n| INDONESIA | 1997 | 45745362.3667 |\n| INDONESIA | 1996 | 45347554.8232 |\n| INDONESIA | 1995 | 45685709.4978 |\n| INDONESIA | 1994 | 44738603.1901 |\n| INDONESIA | 1993 | 45172063.2033 |\n| INDONESIA | 1992 | 44623924.3942 |\n| IRAN | 1998 | 27876287.0949 |\n| IRAN | 1997 | 47184621.5647 |\n| IRAN | 1996 | 47397859.7878 |\n| IRAN | 1995 | 49579120.6991 |\n| IRAN | 1994 | 48032316.8744 |\n| IRAN | 1993 | 48295593.2066 |\n| IRAN | 1992 | 50531453.3934 |\n| IRAQ | 1998 | 29997323.2927 |\n| IRAQ | 1997 | 52851471.1377 |\n| IRAQ | 1996 | 53671825.6297 |\n| IRAQ | 1995 | 53251012.1025 |\n| IRAQ | 1994 | 50934553.4361 |\n| IRAQ | 1993 | 51961214.1186 |\n| IRAQ | 1992 | 50840364.3833 |\n| JAPAN | 1998 | 26054615.4955 |\n| JAPAN | 1997 | 43557394.2595 |\n| JAPAN | 1996 | 46531743.0980 |\n| JAPAN | 1995 | 41688293.4741 |\n| JAPAN | 1994 | 45526719.0728 |\n| JAPAN | 1993 | 45619475.4478 |\n| JAPAN | 1992 | 44545639.3069 |\n| JORDAN | 1998 | 24793092.4101 |\n| JORDAN | 1997 | 42050730.7748 |\n| JORDAN | 1996 | 42562783.8663 |\n| JORDAN | 1995 | 42253019.5330 |\n| JORDAN | 1994 | 45027034.7721 |\n| JORDAN | 1993 | 44797510.9808 |\n| JORDAN | 1992 | 41313405.2890 |\n| KENYA | 1998 | 24550926.4693 |\n| KENYA | 1997 | 42767120.5848 |\n| KENYA | 1996 | 45000095.1105 |\n| KENYA | 1995 | 43250458.0109 |\n| KENYA | 1994 | 42891596.7158 |\n| KENYA | 1993 | 43599201.5126 |\n| KENYA | 1992 | 45286145.8141 |\n| MOROCCO | 1998 | 23482053.5970 |\n| MOROCCO | 1997 | 41503033.0020 |\n| MOROCCO | 1996 | 45645555.9409 |\n| MOROCCO | 1995 | 44462858.7689 |\n| MOROCCO | 1994 | 44768368.8310 |\n| MOROCCO | 1993 | 44611871.2477 |\n| MOROCCO | 1992 | 43057959.1352 |\n| MOZAMBIQUE | 1998 | 28824737.9244 |\n| MOZAMBIQUE | 1997 | 48682746.5995 |\n| MOZAMBIQUE | 1996 | 50816940.9909 |\n| MOZAMBIQUE | 1995 | 50010039.0178 |\n| MOZAMBIQUE | 1994 | 48794892.1253 |\n| MOZAMBIQUE | 1993 | 48451128.3332 |\n| MOZAMBIQUE | 1992 | 50113858.5449 |\n| PERU | 1998 | 30575758.1899 |\n| PERU | 1997 | 49323405.6808 |\n| PERU | 1996 | 50063490.6085 |\n| PERU | 1995 | 51272843.6555 |\n| PERU | 1994 | 50690589.2334 |\n| PERU | 1993 | 49086129.3668 |\n| PERU | 1992 | 50067216.3450 |\n| ROMANIA | 1998 | 27367992.9903 |\n| ROMANIA | 1997 | 45668932.7094 |\n| ROMANIA | 1996 | 46594220.7498 |\n| ROMANIA | 1995 | 44576835.1623 |\n| ROMANIA | 1994 | 45640971.0684 |\n| ROMANIA | 1993 | 46374545.0712 |\n| ROMANIA | 1992 | 47130533.3076 |\n| RUSSIA | 1998 | 27486839.8755 |\n| RUSSIA | 1997 | 44050712.6907 |\n| RUSSIA | 1996 | 45604597.4983 |\n| RUSSIA | 1995 | 48972490.6009 |\n| RUSSIA | 1994 | 45652045.5872 |\n| RUSSIA | 1993 | 47139548.1597 |\n| RUSSIA | 1992 | 47159990.1221 |\n| SAUDI ARABIA | 1998 | 29766229.7961 |\n| SAUDI ARABIA | 1997 | 51473031.6922 |\n| SAUDI ARABIA | 1996 | 52859666.6646 |\n| SAUDI ARABIA | 1995 | 50946175.0229 |\n| SAUDI ARABIA | 1994 | 53085288.9954 |\n| SAUDI ARABIA | 1993 | 50907571.2046 |\n| SAUDI ARABIA | 1992 | 50334063.0381 |\n| UNITED KINGDOM | 1998 | 27904712.8220 |\n| UNITED KINGDOM | 1997 | 48170994.4362 |\n| UNITED KINGDOM | 1996 | 46498116.9611 |\n| UNITED KINGDOM | 1995 | 43210619.0456 |\n| UNITED KINGDOM | 1994 | 47339709.9122 |\n| UNITED KINGDOM | 1993 | 44308436.3275 |\n| UNITED KINGDOM | 1992 | 45870809.6693 |\n| UNITED STATES | 1998 | 25856187.3719 |\n| UNITED STATES | 1997 | 44934753.2208 |\n| UNITED STATES | 1996 | 44826974.2915 |\n| UNITED STATES | 1995 | 44160425.4086 |\n| UNITED STATES | 1994 | 43193241.6843 |\n| UNITED STATES | 1993 | 45126307.2619 |\n| UNITED STATES | 1992 | 44205926.3317 |\n| VIETNAM | 1998 | 28289193.6726 |\n| VIETNAM | 1997 | 48284585.4019 |\n| VIETNAM | 1996 | 48360225.9084 |\n| VIETNAM | 1995 | 48742082.6165 |\n| VIETNAM | 1994 | 49035537.3894 |\n| VIETNAM | 1993 | 47222674.6352 |\n| VIETNAM | 1992 | 48628336.9011 |\n+----------------+--------+---------------+\n175 rows in set\n\nQ10\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n| c_custkey | c_name | revenue | c_acctbal | n_name | c_address | c_phone | c_comment |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n| 95962 | Customer#000095962 | 704336.0774 | -9.33 | MOZAMBIQUE | 83wOMt9iAb9OJ0HbkQ1PaX3odXVBNEIMXaE | 26-127-693-7436 | nusual theodolites maintain furiously fluffily iro |\n| 87064 | Customer#000087064 | 684037.4349 | 5244.68 | BRAZIL | 0xej6ldT8zi7MwLdDJ1II3YWwprkvwB1 I0kwsf | 12-930-206-2571 | de of the ironic, silent warthogs. bold, r |\n| 56416 | Customer#000056416 | 661218.0492 | 4303.82 | INDIA | CEuBN,xZVmP | 18-212-984-8331 | al waters cajole along the slyly unusual dugouts. carefully regular deposits use slyly? packages h |\n| 46450 | Customer#000046450 | 646205.6835 | 2400.59 | UNITED STATES | rzWQxB9iFpd8i4KUCAPdv | 34-765-320-4326 | ss, final deposits cajole sly |\n| 128713 | Customer#000128713 | 643240.1183 | 7200.30 | ARGENTINA | mm0kxtHFCchaZX4eYSCCyQHno7vq,SRmv4 | 11-174-994-6880 | ording to the express accounts cajole carefully across the bravely special packages. carefully regular account |\n| 102187 | Customer#000102187 | 637493.0787 | -896.03 | ETHIOPIA | EAi6vcGnWHUMb6rJwn,PtUgSH74tR Aixa | 15-877-462-6534 | gular packages. carefully regular deposits cajole carefully of the regular requests. carefully special accou |\n| 42541 | Customer#000042541 | 634546.9756 | 8082.14 | IRAN | IccOGHgp8g | 20-442-159-1337 | cross the final asymptotes. final packages wake furiously ironic dec |\n| 51595 | Customer#000051595 | 611926.8265 | 7236.80 | UNITED STATES | wQFWZk 7JCpeg50O0KCzSmUFnNNwX1aEQ7V3Q | 34-844-269-9070 | sts. always express accounts use carefully along the quickly speci |\n| 66391 | Customer#000066391 | 608385.5852 | 9404.57 | UNITED STATES | V0XvU1Nh9NU4zsyOkm,RBa | 34-149-224-8119 | ages cajole carefully carefully bold deposits: fluffily unusual deposits promise slyly carefully ironic co |\n| 48358 | Customer#000048358 | 603621.4823 | -611.15 | ETHIOPIA | ycg3uMG7iDdwQvJ1irr | 15-687-936-5181 | the slyly unusual foxes-- carefully regular |\n| 99175 | Customer#000099175 | 602125.3304 | 2218.76 | INDONESIA | 9wbW52xx9T84E0dZ Rvz1ozQ1 | 19-125-912-6494 | ide of the slyly ironic foxes boost silently ironic, even instructions. blithe |\n| 122509 | Customer#000122509 | 601580.1203 | 2613.83 | KENYA | ZN1sc0eJrkD8t6X5Q1d3 | 24-421-308-3881 | brave deposits haggle across the even deposits. instr |\n| 148055 | Customer#000148055 | 601003.6812 | 455.31 | PERU | Y,RCZ3Bislx64nTsPaRL,5gjx7xgC6y, yKYnCw | 27-473-476-4382 | uickly final accounts wake carefully sl |\n| 117451 | Customer#000117451 | 599792.7063 | 1090.48 | UNITED STATES | bSwr7mNPiaf1f lNK9 uTJxWCL2sn1Lak5NIB | 34-354-586-6011 | ding to the furiously express accounts boost carefully af |\n| 104110 | Customer#000104110 | 588194.3118 | 2762.52 | JORDAN | mm7 ZuDX5Z5nAQbKObB 80XBCy,1nyW | 23-639-800-5768 | urts sleep furiously alongside of the packages! slyly ironic packages sleep |\n| 13666 | Customer#000013666 | 579926.1679 | 7453.98 | EGYPT | DLRUWGcprmWqdROJvmZwpE | 14-316-135-4381 | ross the silent requests. special theodolit |\n| 96202 | Customer#000096202 | 571017.3398 | 4703.04 | CANADA | 4Vcxcx3w4zMjVYNQaqrweweQY6TJO AP9rdvQaLl | 13-194-779-9597 | en packages use. fluffily regular dependencies boost. never pending requ |\n| 70279 | Customer#000070279 | 561369.3650 | 9109.34 | CHINA | ltie8o3ihwffMrqMrkvN957KZVWmH5 | 28-842-825-1717 | theodolites sleep: blithely final requests are fur |\n| 16972 | Customer#000016972 | 560435.8065 | 6408.66 | ROMANIA | X6T8vRKy6kSO0f2wJJt | 29-483-958-3347 | sts. pending deposits are across the regular, express instructions. carefully daring foxes cajol |\n| 113443 | Customer#000113443 | 557272.6706 | -72.67 | UNITED KINGDOM | SUHbS85cYxgVkKbfh9sUpEa6ezVSlQuCKe3CV | 33-819-742-6112 | ic foxes cajole thinly furiously stealthy instructions. pinto beans are. quickly regular accounts integrate car |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n20 rows in set\n\nQ11\n+------------+-------------+\n| ps_partkey | value |\n+------------+-------------+\n| 131630 | 17882680.37 |\n| 104150 | 17613017.18 |\n| 128284 | 16502418.74 |\n| 8978 | 16470438.59 |\n| 147193 | 16462742.12 |\n| 78788 | 16010246.37 |\n| 76331 | 15776882.05 |\n| 137287 | 15770471.15 |\n| 51302 | 15730620.22 |\n| 141553 | 15333540.19 |\n| 137196 | 15035435.60 |\n| 186531 | 14818272.68 |\n| 103818 | 14690943.63 |\n| 80080 | 14626441.35 |\n| 1312 | 14330729.50 |\n| 6531 | 14267308.08 |\n| 96162 | 14154396.04 |\n| 69605 | 14018927.25 |\n| 30118 | 13854726.38 |\n| 17006 | 13731495.60 |\n| 95347 | 13716648.60 |\n| 18722 | 13707978.71 |\n| 122875 | 13640341.00 |\n| 105499 | 13532912.80 |\n| 165560 | 13509536.95 |\n| 1531 | 13337454.55 |\n| 34732 | 13304041.48 |\n| 173221 | 13038078.41 |\n| 180975 | 13038039.17 |\n| 24703 | 12957050.80 |\n| 72036 | 12939426.90 |\n| 124814 | 12849842.04 |\n| 174453 | 12814999.00 |\n| 14209 | 12814858.56 |\n| 185186 | 12657201.05 |\n| 187868 | 12647101.80 |\n| 125085 | 12639931.63 |\n| 80331 | 12625007.00 |\n| 118685 | 12515185.68 |\n| 163988 | 12484272.80 |\n| 124685 | 12432747.32 |\n| 92838 | 12410071.57 |\n| 140928 | 12396673.84 |\n| 1218 | 12362877.75 |\n| 39201 | 12328085.10 |\n| 33237 | 12180622.98 |\n| 183791 | 12150040.50 |\n| 3243 | 12136315.74 |\n| 62740 | 12131313.60 |\n| 154171 | 12105470.89 |\n| 49034 | 11982382.52 |\n| 88673 | 11925499.04 |\n| 52527 | 11923653.16 |\n| 83974 | 11871084.73 |\n| 88254 | 11870393.22 |\n| 411 | 11806670.95 |\n| 14320 | 11800136.02 |\n| 164979 | 11794760.03 |\n| 166149 | 11778499.72 |\n| 74105 | 11750224.34 |\n| 169104 | 11708532.18 |\n| 15542 | 11687293.42 |\n| 161538 | 11661769.80 |\n| 63337 | 11592505.40 |\n| 117197 | 11508165.60 |\n| 102989 | 11497056.75 |\n| 10836 | 11465875.43 |\n| 199561 | 11431793.36 |\n| 134683 | 11384564.54 |\n| 136318 | 11351893.30 |\n| 166270 | 11336004.81 |\n| 32200 | 11324838.00 |\n| 57033 | 11281026.52 |\n| 18098 | 11245398.24 |\n| 135174 | 11189782.12 |\n| 181616 | 11183947.65 |\n| 85064 | 11175761.43 |\n| 120719 | 11164342.08 |\n| 99670 | 11140257.47 |\n| 46096 | 11034143.76 |\n| 195124 | 11030197.30 |\n| 78838 | 11012446.40 |\n| 151656 | 11010376.90 |\n| 156956 | 10996384.80 |\n| 34028 | 10942671.24 |\n| 15778 | 10937778.75 |\n| 199707 | 10924333.33 |\n| 118776 | 10920609.31 |\n| 27640 | 10919693.42 |\n| 15237 | 10918145.54 |\n| 148243 | 10916765.29 |\n| 111498 | 10867707.51 |\n| 132024 | 10834280.47 |\n| 35124 | 10806898.50 |\n| 196818 | 10787371.25 |\n| 197669 | 10779504.60 |\n| 110042 | 10778828.37 |\n| 197422 | 10770092.44 |\n| 75160 | 10746976.60 |\n| 191567 | 10642430.39 |\n| 34225 | 10574664.41 |\n| 102588 | 10567012.05 |\n| 44148 | 10505249.34 |\n| 126607 | 10484944.29 |\n| 172625 | 10444857.62 |\n| 157054 | 10406203.24 |\n| 19322 | 10378704.98 |\n| 136541 | 10371536.77 |\n| 167526 | 10320346.58 |\n| 136011 | 10302146.84 |\n| 107431 | 10273992.76 |\n| 16485 | 10257703.67 |\n| 52580 | 10250264.05 |\n| 839 | 10238243.36 |\n| 31704 | 10196678.94 |\n| 122558 | 10137326.18 |\n| 180386 | 10123318.07 |\n| 97705 | 10089163.37 |\n| 96327 | 10087851.88 |\n| 136143 | 10082137.97 |\n| 15174 | 10057277.55 |\n| 193324 | 10039922.93 |\n| 33593 | 10019952.10 |\n| 126288 | 10014855.05 |\n| 64123 | 9985650.90 |\n| 183712 | 9973256.18 |\n| 138831 | 9963069.10 |\n| 123694 | 9959096.38 |\n| 51734 | 9952439.73 |\n| 11861 | 9949647.12 |\n| 119127 | 9942105.69 |\n| 173308 | 9932264.52 |\n| 40986 | 9921554.40 |\n| 176970 | 9919708.65 |\n| 54316 | 9913595.16 |\n| 62644 | 9903936.27 |\n| 185354 | 9895956.52 |\n| 81468 | 9885132.60 |\n| 104687 | 9883888.05 |\n| 198959 | 9875351.28 |\n| 179767 | 9872309.86 |\n| 102835 | 9870743.52 |\n| 163221 | 9856173.04 |\n| 32633 | 9852565.04 |\n| 19605 | 9850164.48 |\n| 47378 | 9826135.11 |\n| 44026 | 9822433.44 |\n| 126629 | 9816227.30 |\n| 199665 | 9812400.23 |\n| 30989 | 9812295.52 |\n| 102177 | 9810372.32 |\n| 25765 | 9806344.88 |\n| 110721 | 9804895.23 |\n| 159532 | 9803738.34 |\n| 101640 | 9801375.65 |\n| 151569 | 9792489.20 |\n| 180629 | 9782164.34 |\n| 165528 | 9769074.10 |\n| 23772 | 9766084.22 |\n| 149727 | 9765190.96 |\n| 189605 | 9761887.80 |\n| 74703 | 9758757.28 |\n| 83382 | 9758144.21 |\n| 93775 | 9726901.71 |\n| 56192 | 9725508.16 |\n| 50060 | 9712714.65 |\n| 15409 | 9706898.91 |\n| 139104 | 9701070.72 |\n| 177435 | 9686566.09 |\n| 31351 | 9675197.98 |\n| 20495 | 9672566.31 |\n| 24537 | 9654516.03 |\n| 160528 | 9650804.70 |\n| 34706 | 9647241.90 |\n| 149039 | 9643498.32 |\n| 147139 | 9642356.34 |\n| 118629 | 9624960.80 |\n| 35359 | 9621549.92 |\n| 33854 | 9616857.73 |\n| 33707 | 9609988.84 |\n| 149055 | 9599364.32 |\n| 127429 | 9580670.49 |\n| 67575 | 9579613.26 |\n| 80727 | 9576545.81 |\n| 181650 | 9574445.40 |\n| 50176 | 9573389.08 |\n| 171093 | 9571625.20 |\n| 151342 | 9569230.21 |\n| 123052 | 9561903.68 |\n| 132633 | 9545052.14 |\n| 130419 | 9524936.49 |\n| 89241 | 9512992.32 |\n| 138255 | 9503515.93 |\n| 31680 | 9502841.07 |\n| 151986 | 9500862.59 |\n| 146390 | 9490242.96 |\n| 62275 | 9475584.10 |\n| 33518 | 9475074.40 |\n| 5286 | 9473739.88 |\n| 39020 | 9467701.22 |\n| 113281 | 9466510.94 |\n| 138789 | 9464407.24 |\n| 165040 | 9462153.75 |\n| 150766 | 9461855.88 |\n| 54341 | 9459425.45 |\n| 33464 | 9459377.37 |\n| 15251 | 9455980.84 |\n| 145308 | 9454189.29 |\n| 192621 | 9449324.14 |\n| 175218 | 9448987.35 |\n| 58992 | 9446144.40 |\n| 24548 | 9442739.03 |\n| 177563 | 9440891.04 |\n| 184482 | 9431486.10 |\n| 78961 | 9430401.05 |\n| 174167 | 9428622.96 |\n| 88265 | 9423143.28 |\n| 6057 | 9405359.37 |\n| 85387 | 9402175.55 |\n| 47053 | 9399707.66 |\n| 128973 | 9399265.92 |\n| 65668 | 9395584.45 |\n| 50222 | 9394502.96 |\n| 116534 | 9388011.08 |\n| 140959 | 9386284.56 |\n| 46897 | 9385056.21 |\n| 141872 | 9383820.48 |\n| 177181 | 9383551.92 |\n| 168265 | 9376664.16 |\n| 48974 | 9374769.12 |\n| 46218 | 9364135.50 |\n| 104039 | 9363227.03 |\n| 61538 | 9360159.08 |\n| 94688 | 9359604.98 |\n| 122393 | 9357937.19 |\n| 7323 | 9356712.30 |\n| 197892 | 9356573.44 |\n| 194056 | 9352381.73 |\n| 61285 | 9348480.54 |\n| 180336 | 9347874.15 |\n| 121930 | 9347784.74 |\n| 80652 | 9347143.50 |\n| 18549 | 9346038.72 |\n| 23992 | 9339908.16 |\n| 136583 | 9337299.56 |\n| 156151 | 9337138.10 |\n| 160572 | 9336553.40 |\n| 113391 | 9335558.10 |\n| 48068 | 9334317.92 |\n| 20409 | 9331093.65 |\n| 39712 | 9324685.28 |\n| 59364 | 9322249.86 |\n| 1344 | 9308304.39 |\n| 60549 | 9308293.20 |\n| 83854 | 9307387.25 |\n| 92092 | 9307165.64 |\n| 193306 | 9306177.31 |\n| 118265 | 9300250.20 |\n| 107568 | 9296254.34 |\n| 109127 | 9293552.10 |\n| 184688 | 9291647.92 |\n| 8718 | 9287337.37 |\n| 80433 | 9286295.52 |\n| 26670 | 9284963.44 |\n| 139548 | 9283605.21 |\n| 14736 | 9280119.20 |\n| 97886 | 9273852.42 |\n| 181442 | 9273130.50 |\n| 172360 | 9272824.92 |\n| 192714 | 9268366.36 |\n| 106726 | 9264879.90 |\n| 72157 | 9263498.40 |\n| 70445 | 9257553.92 |\n| 75148 | 9257420.83 |\n| 26170 | 9256074.12 |\n| 116531 | 9249721.71 |\n| 133665 | 9245464.80 |\n| 129041 | 9244629.48 |\n| 136486 | 9240748.92 |\n| 198924 | 9239976.06 |\n| 115254 | 9233580.37 |\n| 168135 | 9232693.98 |\n| 22480 | 9232190.78 |\n| 192018 | 9230386.58 |\n| 111889 | 9228204.96 |\n| 151661 | 9227926.90 |\n| 96482 | 9226960.85 |\n| 49198 | 9226436.40 |\n| 41219 | 9222883.52 |\n| 113502 | 9222208.59 |\n| 84009 | 9218703.22 |\n| 192788 | 9213468.00 |\n| 160251 | 9206353.32 |\n| 188162 | 9200537.88 |\n| 167589 | 9195835.03 |\n| 132673 | 9194021.22 |\n| 191105 | 9192417.12 |\n| 128748 | 9189941.55 |\n| 130423 | 9184710.96 |\n| 22639 | 9182963.16 |\n| 199034 | 9180909.86 |\n| 187644 | 9180350.20 |\n| 970 | 9175757.70 |\n| 59070 | 9170000.64 |\n| 66568 | 9166070.04 |\n| 52715 | 9161221.80 |\n| 130276 | 9161201.57 |\n| 24189 | 9160740.15 |\n| 132402 | 9144498.48 |\n| 37799 | 9142271.24 |\n| 173337 | 9140566.68 |\n| 176552 | 9135054.51 |\n| 195714 | 9133679.77 |\n| 119363 | 9123261.90 |\n| 161160 | 9122259.60 |\n| 196968 | 9111592.20 |\n| 61943 | 9111527.33 |\n| 79766 | 9109534.89 |\n| 178082 | 9105694.92 |\n| 38800 | 9105468.72 |\n| 83608 | 9099493.68 |\n| 146346 | 9098628.00 |\n| 116690 | 9098099.93 |\n| 64690 | 9095441.10 |\n| 82061 | 9095381.18 |\n| 89015 | 9092660.48 |\n| 188457 | 9091400.40 |\n| 125177 | 9090455.55 |\n| 114776 | 9088177.68 |\n| 4486 | 9087487.20 |\n| 176940 | 9086842.84 |\n| 93157 | 9084361.81 |\n| 148624 | 9083370.78 |\n| 4441 | 9079520.58 |\n| 63590 | 9079125.44 |\n| 174189 | 9078023.39 |\n| 63054 | 9075441.98 |\n| 14950 | 9073156.19 |\n| 175646 | 9072322.47 |\n| 63712 | 9067710.48 |\n| 157197 | 9067452.77 |\n| 147196 | 9064699.80 |\n| 50551 | 9062434.72 |\n| 43035 | 9061782.03 |\n| 187679 | 9056529.40 |\n| 96673 | 9056525.94 |\n| 130148 | 9054217.06 |\n| 159007 | 9053155.29 |\n| 41544 | 9052820.94 |\n| 109476 | 9048012.09 |\n| 60092 | 9045562.44 |\n| 197490 | 9044579.88 |\n| 47311 | 9037223.52 |\n| 87230 | 9033227.61 |\n| 3860 | 9030622.02 |\n| 5466 | 9029841.66 |\n| 171537 | 9024699.30 |\n| 39707 | 9022833.12 |\n| 167048 | 9022709.18 |\n| 109006 | 9022258.40 |\n| 17910 | 9019688.45 |\n| 132826 | 9017286.74 |\n| 157502 | 9016444.08 |\n| 142309 | 9016270.60 |\n| 78891 | 9005693.25 |\n| 88301 | 9002414.82 |\n| 11496 | 9000803.97 |\n| 163633 | 8996162.06 |\n| 151809 | 8993104.95 |\n| 131555 | 8988340.68 |\n| 72812 | 8985370.68 |\n| 77047 | 8981489.79 |\n| 1553 | 8977226.10 |\n| 162531 | 8973689.92 |\n| 154026 | 8973320.24 |\n| 125499 | 8969667.84 |\n| 34547 | 8966116.43 |\n| 41301 | 8965350.42 |\n| 12853 | 8959403.59 |\n| 27736 | 8957933.23 |\n| 162817 | 8956868.20 |\n| 155389 | 8955349.85 |\n| 130360 | 8952928.25 |\n| 120878 | 8952393.10 |\n| 150671 | 8952112.72 |\n| 190365 | 8951671.57 |\n| 72364 | 8950587.82 |\n| 71615 | 8949277.07 |\n| 95277 | 8947796.58 |\n| 78180 | 8946814.80 |\n| 97062 | 8945057.46 |\n| 170013 | 8944660.40 |\n| 113426 | 8943016.29 |\n| 173751 | 8942914.28 |\n| 1478 | 8941906.24 |\n| 26061 | 8941022.48 |\n| 152527 | 8939654.10 |\n| 148360 | 8939589.40 |\n| 44057 | 8939101.36 |\n| 13595 | 8936720.10 |\n| 33337 | 8935366.48 |\n| 169698 | 8931507.20 |\n| 26155 | 8927283.11 |\n| 17185 | 8927218.40 |\n| 51996 | 8926661.08 |\n| 101869 | 8919281.70 |\n| 14561 | 8910653.92 |\n| 190047 | 8909427.90 |\n| 104143 | 8909328.40 |\n| 133330 | 8907195.90 |\n| 169144 | 8904989.34 |\n| 87067 | 8900079.44 |\n| 176075 | 8898845.64 |\n| 25076 | 8895274.12 |\n| 80838 | 8895205.30 |\n| 40387 | 8890891.55 |\n| 88004 | 8888748.80 |\n| 105527 | 8888672.72 |\n| 40741 | 8886674.24 |\n| 76690 | 8880622.61 |\n| 86485 | 8880488.57 |\n| 75736 | 8877666.06 |\n| 48704 | 8876626.52 |\n| 56450 | 8872277.59 |\n| 61683 | 8870173.93 |\n| 24067 | 8867814.12 |\n| 108012 | 8863632.38 |\n| 180971 | 8862007.20 |\n| 132986 | 8861335.20 |\n| 35839 | 8859344.64 |\n| 191553 | 8857411.14 |\n| 163492 | 8855825.91 |\n| 112101 | 8851904.10 |\n| 27050 | 8847924.19 |\n| 57481 | 8845309.59 |\n| 163252 | 8842276.65 |\n| 87958 | 8840221.67 |\n| 60162 | 8838927.08 |\n| 131928 | 8838900.48 |\n| 123514 | 8833601.14 |\n| 42891 | 8830401.37 |\n| 71547 | 8829540.72 |\n| 13975 | 8826582.48 |\n| 31577 | 8825371.40 |\n| 86165 | 8816308.38 |\n| 164646 | 8815470.18 |\n| 150176 | 8814992.11 |\n| 152464 | 8814533.82 |\n| 183434 | 8813941.24 |\n| 58839 | 8808010.20 |\n| 59952 | 8801497.32 |\n| 151038 | 8800215.80 |\n| 139523 | 8800032.57 |\n| 8828 | 8798704.66 |\n| 14080 | 8797032.12 |\n| 194080 | 8792825.27 |\n| 87199 | 8788933.64 |\n| 91747 | 8785811.64 |\n| 194429 | 8776185.03 |\n| 118998 | 8776071.00 |\n| 179467 | 8771474.74 |\n| 68715 | 8771302.80 |\n| 180572 | 8771095.68 |\n| 19821 | 8770770.82 |\n| 41702 | 8770565.71 |\n| 27916 | 8769001.47 |\n| 121302 | 8763598.50 |\n| 107013 | 8762893.37 |\n| 37287 | 8761196.43 |\n| 117050 | 8758230.00 |\n| 58547 | 8757757.40 |\n| 197088 | 8749026.12 |\n| 55839 | 8747234.02 |\n| 71829 | 8744546.91 |\n| 30961 | 8743416.92 |\n| 134548 | 8741635.28 |\n| 179833 | 8738680.00 |\n| 79721 | 8737857.70 |\n| 144577 | 8736427.08 |\n| 29051 | 8729063.28 |\n| 131481 | 8728799.64 |\n| 73271 | 8727985.25 |\n| 89553 | 8725727.19 |\n| 31306 | 8724451.12 |\n| 82181 | 8724017.16 |\n| 95549 | 8723460.30 |\n| 31507 | 8722094.40 |\n| 21302 | 8722054.95 |\n| 137953 | 8721611.83 |\n| 195768 | 8721020.99 |\n| 180105 | 8718021.20 |\n| 98241 | 8717935.36 |\n| 59431 | 8715482.28 |\n| 143694 | 8713267.63 |\n| 109020 | 8713043.36 |\n| 46732 | 8711642.04 |\n| 144172 | 8711013.10 |\n| 139056 | 8710786.50 |\n| 107543 | 8706135.75 |\n| 89127 | 8705410.56 |\n| 146544 | 8704812.86 |\n| 195524 | 8699333.14 |\n| 133563 | 8698060.14 |\n| 112707 | 8694322.84 |\n| 98951 | 8690376.70 |\n| 132635 | 8689305.24 |\n| 69056 | 8688980.25 |\n| 134143 | 8688695.26 |\n| 148150 | 8687553.16 |\n| 89122 | 8686767.31 |\n| 15085 | 8685772.26 |\n| 196686 | 8682783.57 |\n| 3076 | 8672940.78 |\n| 137428 | 8672547.80 |\n| 27263 | 8671719.36 |\n| 101561 | 8667962.72 |\n| 12597 | 8662223.52 |\n| 143329 | 8661688.72 |\n| 130813 | 8659409.04 |\n| 183679 | 8658698.30 |\n| 47449 | 8658493.58 |\n| 164677 | 8658220.00 |\n| 51437 | 8654713.02 |\n| 116162 | 8649713.36 |\n| 71889 | 8645159.67 |\n| 6486 | 8639891.76 |\n| 192102 | 8638102.72 |\n| 101660 | 8634451.80 |\n| 124703 | 8633146.86 |\n| 150469 | 8631948.60 |\n| 197467 | 8630739.78 |\n| 97621 | 8630453.32 |\n| 150354 | 8630288.15 |\n| 179544 | 8630121.63 |\n| 38972 | 8626072.00 |\n| 110732 | 8625761.16 |\n| 170791 | 8625203.06 |\n| 149414 | 8617070.17 |\n| 59527 | 8616079.20 |\n| 157580 | 8615676.04 |\n| 16268 | 8615087.46 |\n| 76464 | 8610219.38 |\n| 44474 | 8607934.92 |\n| 125527 | 8607708.08 |\n| 118076 | 8602251.65 |\n| 180362 | 8601367.05 |\n| 5808 | 8599851.04 |\n| 28703 | 8599486.36 |\n| 113373 | 8597996.36 |\n| 118918 | 8597063.80 |\n| 44868 | 8596304.52 |\n| 43419 | 8596265.35 |\n| 89763 | 8595248.64 |\n| 119232 | 8594224.56 |\n| 108649 | 8590683.68 |\n| 10396 | 8588398.05 |\n| 79536 | 8587117.83 |\n| 149800 | 8587058.86 |\n| 165839 | 8582991.20 |\n| 115397 | 8581524.77 |\n| 104394 | 8581384.42 |\n| 142569 | 8581127.40 |\n| 63676 | 8580930.08 |\n| 29029 | 8580613.53 |\n| 156604 | 8580477.00 |\n| 7310 | 8579949.50 |\n| 105381 | 8576164.24 |\n| 84306 | 8573960.40 |\n| 61217 | 8570393.04 |\n| 164438 | 8569616.36 |\n| 28073 | 8565639.60 |\n| 125743 | 8563258.90 |\n| 190032 | 8561620.55 |\n| 147122 | 8561245.68 |\n| 5384 | 8558830.08 |\n| 70172 | 8558319.64 |\n| 161966 | 8556193.38 |\n| 69530 | 8554377.60 |\n| 111243 | 8553627.55 |\n| 72590 | 8551077.51 |\n| 134423 | 8550604.77 |\n| 44509 | 8547134.31 |\n| 160707 | 8546000.68 |\n| 54123 | 8545976.26 |\n| 36547 | 8540333.04 |\n| 48715 | 8537983.35 |\n| 103078 | 8537142.60 |\n| 137613 | 8536278.96 |\n| 44995 | 8532416.72 |\n| 191159 | 8532173.37 |\n| 119345 | 8532070.56 |\n| 109941 | 8531904.79 |\n| 5449 | 8528034.35 |\n| 134116 | 8526854.95 |\n| 199268 | 8523599.58 |\n| 168520 | 8523360.67 |\n| 154189 | 8521620.13 |\n| 108771 | 8513853.87 |\n| 198651 | 8511238.80 |\n| 93681 | 8510935.14 |\n| 170680 | 8509087.68 |\n| 106409 | 8506859.19 |\n| 27110 | 8499811.75 |\n| 43224 | 8499539.52 |\n| 153225 | 8499434.28 |\n| 16681 | 8498021.66 |\n| 117983 | 8496934.32 |\n| 192158 | 8492372.03 |\n| 33900 | 8491139.64 |\n| 37006 | 8489126.28 |\n| 176554 | 8488633.92 |\n| 69234 | 8484937.26 |\n| 176652 | 8484496.02 |\n| 41660 | 8480585.65 |\n| 129104 | 8480411.17 |\n| 66960 | 8478978.86 |\n| 36296 | 8472438.75 |\n| 98665 | 8471241.57 |\n| 134173 | 8467888.57 |\n| 60496 | 8467019.22 |\n| 197520 | 8466553.20 |\n| 116746 | 8465792.60 |\n| 187394 | 8458248.24 |\n| 140377 | 8455546.68 |\n| 97326 | 8450501.67 |\n| 26770 | 8449625.64 |\n| 104884 | 8446152.26 |\n| 143109 | 8443547.19 |\n| 127361 | 8441094.08 |\n| 104754 | 8436883.50 |\n| 183676 | 8436165.76 |\n| 906 | 8434608.12 |\n| 55768 | 8433763.69 |\n| 118654 | 8433465.57 |\n| 39310 | 8433214.55 |\n| 173261 | 8432992.53 |\n| 93976 | 8432605.20 |\n| 63318 | 8432149.26 |\n| 128243 | 8424182.94 |\n| 156063 | 8422743.54 |\n| 195087 | 8421279.30 |\n| 67668 | 8417594.98 |\n| 49882 | 8417237.80 |\n| 105631 | 8412628.07 |\n| 40987 | 8406033.41 |\n| 185735 | 8404112.83 |\n| 173986 | 8403050.34 |\n| 87372 | 8402838.40 |\n| 24509 | 8398807.24 |\n| 180522 | 8394989.75 |\n| 76215 | 8394433.35 |\n| 193872 | 8390435.23 |\n| 141234 | 8390180.92 |\n| 91138 | 8386645.20 |\n| 28097 | 8385577.38 |\n| 4053 | 8384952.75 |\n| 17050 | 8380304.40 |\n| 64050 | 8377921.56 |\n| 80836 | 8375803.16 |\n| 86084 | 8373551.95 |\n| 168499 | 8373348.72 |\n| 178642 | 8372218.52 |\n| 8498 | 8370557.16 |\n| 156312 | 8366249.30 |\n| 136803 | 8361949.92 |\n| 92109 | 8359503.23 |\n| 138625 | 8358135.21 |\n| 137540 | 8358031.08 |\n| 176531 | 8355437.00 |\n| 53783 | 8352395.63 |\n| 106977 | 8352334.98 |\n| 21385 | 8351786.37 |\n| 114885 | 8351582.40 |\n| 113643 | 8350530.65 |\n| 89061 | 8349422.08 |\n| 77752 | 8348730.24 |\n| 28623 | 8348321.44 |\n| 74478 | 8348064.27 |\n| 41383 | 8347223.45 |\n| 147632 | 8346967.80 |\n| 40948 | 8346743.30 |\n| 154324 | 8346521.91 |\n| 89724 | 8346034.80 |\n| 119083 | 8338084.92 |\n| 124143 | 8335841.76 |\n| 80512 | 8335705.69 |\n| 105047 | 8332249.86 |\n| 38243 | 8329017.19 |\n| 42583 | 8328613.91 |\n| 44240 | 8327684.64 |\n| 57611 | 8321693.94 |\n| 9730 | 8319725.70 |\n| 91655 | 8318837.40 |\n| 13140 | 8316216.96 |\n| 112257 | 8315169.85 |\n| 27182 | 8314740.99 |\n| 166654 | 8314332.64 |\n| 40572 | 8312654.55 |\n| 26680 | 8311626.68 |\n| 138947 | 8311347.29 |\n| 184982 | 8310393.08 |\n| 35540 | 8308058.43 |\n| 181446 | 8304851.76 |\n| 65160 | 8299581.90 |\n| 9533 | 8299139.42 |\n| 67836 | 8294228.46 |\n| 159414 | 8293114.90 |\n| 115025 | 8291746.65 |\n| 30780 | 8291580.00 |\n| 164680 | 8290263.02 |\n| 4599 | 8288816.03 |\n| 73366 | 8286818.96 |\n| 135625 | 8284930.92 |\n| 46497 | 8284638.88 |\n| 63781 | 8284447.60 |\n| 84332 | 8283372.14 |\n| 196269 | 8276407.36 |\n| 166651 | 8275663.35 |\n| 142 | 8273960.31 |\n| 56904 | 8272891.44 |\n| 46821 | 8272603.71 |\n| 76051 | 8272300.75 |\n| 19666 | 8270192.64 |\n| 92723 | 8267074.20 |\n| 125843 | 8266816.38 |\n| 158722 | 8266634.88 |\n| 28941 | 8266245.12 |\n| 39968 | 8265605.53 |\n| 41429 | 8265317.84 |\n| 61601 | 8264074.31 |\n| 179159 | 8260137.47 |\n| 15969 | 8259835.96 |\n| 121125 | 8253912.49 |\n| 66486 | 8253743.66 |\n| 181031 | 8253570.14 |\n| 43712 | 8250825.78 |\n| 13842 | 8245765.00 |\n| 76203 | 8245412.16 |\n| 68992 | 8243081.46 |\n| 119704 | 8241363.06 |\n| 86109 | 8240377.92 |\n| 29534 | 8239914.00 |\n| 68596 | 8239825.29 |\n| 168291 | 8237626.32 |\n| 183308 | 8235947.21 |\n| 78657 | 8233481.64 |\n| 193545 | 8233037.49 |\n| 23658 | 8232306.18 |\n| 179945 | 8231365.25 |\n| 53391 | 8231252.10 |\n| 71380 | 8231125.68 |\n| 53666 | 8226715.00 |\n| 118592 | 8226181.00 |\n| 67203 | 8225355.99 |\n| 1178 | 8224625.05 |\n| 147876 | 8224189.62 |\n| 80042 | 8220826.70 |\n| 48950 | 8218611.22 |\n| 43331 | 8218448.04 |\n| 177706 | 8215723.50 |\n| 145442 | 8215706.16 |\n| 197042 | 8215536.00 |\n| 169952 | 8214698.43 |\n| 57907 | 8211740.04 |\n| 145741 | 8210316.57 |\n| 91144 | 8209855.02 |\n| 160266 | 8209468.80 |\n| 31602 | 8209366.90 |\n| 98672 | 8208412.85 |\n| 199012 | 8207897.50 |\n| 151148 | 8207645.16 |\n| 116545 | 8207573.24 |\n| 122176 | 8207508.04 |\n| 11021 | 8206766.10 |\n| 47752 | 8203436.82 |\n| 124 | 8203209.30 |\n| 148126 | 8202846.66 |\n| 15753 | 8202695.55 |\n| 50833 | 8200880.16 |\n| 11523 | 8196478.02 |\n| 71478 | 8195930.68 |\n| 129262 | 8190520.80 |\n| 43023 | 8186451.85 |\n| 119193 | 8184853.14 |\n| 85067 | 8182638.86 |\n| 164534 | 8181563.04 |\n| 82556 | 8180455.14 |\n| 31813 | 8179417.14 |\n| 81345 | 8173128.69 |\n| 38413 | 8172464.04 |\n| 106014 | 8171418.35 |\n| 191180 | 8170663.97 |\n| 43274 | 8169669.72 |\n| 5837 | 8166123.50 |\n| 63332 | 8161839.60 |\n| 47668 | 8161790.04 |\n| 112468 | 8160728.40 |\n| 132541 | 8160680.00 |\n| 59457 | 8160393.33 |\n| 71751 | 8159865.19 |\n| 118395 | 8156795.00 |\n| 132390 | 8154867.54 |\n| 44792 | 8153384.22 |\n| 128838 | 8153018.30 |\n| 87197 | 8152281.72 |\n| 187978 | 8150832.56 |\n| 147419 | 8150063.60 |\n| 149166 | 8149406.78 |\n| 196012 | 8147307.42 |\n| 190519 | 8145402.96 |\n| 151511 | 8144276.58 |\n| 88891 | 8140166.24 |\n| 168056 | 8139101.96 |\n| 189186 | 8136933.25 |\n| 117326 | 8136047.82 |\n| 60575 | 8133316.80 |\n| 75452 | 8130427.37 |\n| 194126 | 8129751.80 |\n| 130199 | 8129270.88 |\n| 41680 | 8128823.40 |\n| 107624 | 8125799.20 |\n| 135069 | 8123999.10 |\n| 119032 | 8123770.24 |\n| 27635 | 8123076.65 |\n| 14317 | 8121553.23 |\n| 148018 | 8119898.16 |\n| 51152 | 8118370.26 |\n| 112643 | 8117331.37 |\n| 119526 | 8116075.80 |\n| 192084 | 8114896.38 |\n| 151385 | 8114711.28 |\n| 160836 | 8112053.68 |\n| 91468 | 8111785.50 |\n| 58877 | 8108256.25 |\n| 41885 | 8107026.81 |\n| 155542 | 8106757.18 |\n| 149968 | 8104953.78 |\n| 168380 | 8103576.00 |\n| 134641 | 8101092.32 |\n| 92470 | 8100877.70 |\n| 113610 | 8098591.93 |\n| 198538 | 8097343.20 |\n| 122506 | 8096090.76 |\n| 29082 | 8093543.55 |\n| 161345 | 8093157.93 |\n| 105743 | 8093045.53 |\n| 103572 | 8091573.66 |\n| 59514 | 8089470.48 |\n| 8801 | 8088454.15 |\n| 129062 | 8088206.58 |\n| 155464 | 8086115.79 |\n| 86363 | 8082561.00 |\n| 180836 | 8082087.30 |\n| 92558 | 8081407.80 |\n| 85120 | 8073164.00 |\n| 149026 | 8072285.40 |\n| 51138 | 8072074.48 |\n| 36306 | 8071648.86 |\n| 102380 | 8070503.00 |\n| 147597 | 8069397.60 |\n| 41382 | 8059995.35 |\n| 121856 | 8059809.11 |\n| 86644 | 8058667.76 |\n| 108481 | 8058214.81 |\n| 41685 | 8057355.39 |\n| 175712 | 8054878.30 |\n| 72815 | 8052294.24 |\n| 58794 | 8047848.00 |\n| 118769 | 8047465.14 |\n| 157192 | 8046501.96 |\n| 195708 | 8045001.94 |\n| 163683 | 8044727.02 |\n| 189018 | 8043927.54 |\n| 62904 | 8043011.65 |\n| 80095 | 8042575.59 |\n| 90500 | 8042502.65 |\n| 73281 | 8040167.52 |\n| 150710 | 8035910.80 |\n| 139282 | 8034489.36 |\n| 172904 | 8033791.68 |\n| 38881 | 8032557.38 |\n| 53055 | 8030796.15 |\n| 105816 | 8025318.24 |\n| 88304 | 8024637.06 |\n| 115565 | 8023928.25 |\n| 55376 | 8021432.16 |\n| 56334 | 8019313.12 |\n| 58875 | 8016065.00 |\n| 4688 | 8012303.00 |\n| 49117 | 8009207.80 |\n| 57173 | 8008116.27 |\n| 48176 | 8006765.85 |\n| 112191 | 8003883.39 |\n| 33265 | 8002391.76 |\n| 181788 | 8002030.50 |\n| 172799 | 8001050.55 |\n| 2084 | 7999172.30 |\n| 174747 | 7997167.48 |\n| 171184 | 7996930.11 |\n| 113271 | 7992683.04 |\n| 68662 | 7991426.30 |\n| 179375 | 7991170.88 |\n| 188383 | 7990226.27 |\n| 50208 | 7989363.27 |\n| 23653 | 7988890.87 |\n| 159419 | 7988841.36 |\n| 74581 | 7987356.50 |\n| 133590 | 7986046.81 |\n| 195820 | 7985473.14 |\n| 87903 | 7983482.88 |\n| 69032 | 7981908.18 |\n| 113975 | 7980561.00 |\n| 178678 | 7975116.93 |\n| 52316 | 7973618.16 |\n| 135546 | 7972669.80 |\n| 89425 | 7970077.44 |\n| 115937 | 7966015.20 |\n| 151483 | 7964850.88 |\n| 73974 | 7964186.23 |\n| 39976 | 7964104.24 |\n| 130168 | 7961690.88 |\n| 58973 | 7957416.76 |\n| 16354 | 7956051.07 |\n| 23988 | 7955837.92 |\n| 138467 | 7955481.05 |\n| 26096 | 7955212.32 |\n| 192216 | 7953429.18 |\n| 112833 | 7952279.26 |\n| 60599 | 7951261.80 |\n| 129116 | 7948811.85 |\n| 79529 | 7947581.91 |\n| 71616 | 7944476.54 |\n| 136821 | 7942188.24 |\n| 116204 | 7941096.90 |\n| 165298 | 7939933.31 |\n| 44009 | 7939859.65 |\n| 194487 | 7938247.20 |\n| 11299 | 7938135.81 |\n| 76488 | 7935926.86 |\n| 58998 | 7934414.04 |\n| 25175 | 7931035.11 |\n| 136144 | 7929283.23 |\n| 132829 | 7926841.62 |\n| 84176 | 7925781.05 |\n| 68592 | 7922872.98 |\n| 139280 | 7922119.48 |\n| 160669 | 7921588.43 |\n| 42938 | 7917524.56 |\n| 183183 | 7915624.86 |\n| 95449 | 7914292.08 |\n| 115390 | 7912655.54 |\n| 173723 | 7911329.40 |\n| 48992 | 7911153.12 |\n| 173464 | 7910458.65 |\n| 26098 | 7910217.75 |\n| 141115 | 7909496.38 |\n| 195218 | 7906315.56 |\n| 116608 | 7906302.60 |\n| 163793 | 7905477.33 |\n| 10419 | 7904598.30 |\n| 106312 | 7901466.72 |\n| 48674 | 7901010.24 |\n| 35198 | 7899974.88 |\n| 88954 | 7899573.52 |\n| 41505 | 7897709.99 |\n| 115586 | 7897301.88 |\n| 167431 | 7895826.00 |\n| 158787 | 7894948.50 |\n| 161712 | 7893410.70 |\n| 46930 | 7892707.77 |\n| 58633 | 7892088.15 |\n| 10599 | 7892067.69 |\n| 99523 | 7891485.16 |\n| 70126 | 7890247.41 |\n| 32476 | 7890149.34 |\n| 152617 | 7890136.50 |\n| 162639 | 7889822.70 |\n| 82056 | 7889345.05 |\n| 186450 | 7887873.56 |\n| 39082 | 7886019.89 |\n| 183217 | 7885948.48 |\n| 192551 | 7884432.48 |\n| 164801 | 7882870.10 |\n| 112804 | 7882772.00 |\n| 5956 | 7878805.04 |\n| 73054 | 7878479.63 |\n| 62593 | 7878401.44 |\n| 137687 | 7873755.91 |\n| 80526 | 7871839.50 |\n| 195354 | 7869617.75 |\n| 4122 | 7867967.09 |\n| 4057 | 7865176.80 |\n| 63195 | 7864322.16 |\n| 143370 | 7863444.54 |\n| 41473 | 7862926.89 |\n| 155060 | 7860900.96 |\n| 76875 | 7858529.64 |\n| 135778 | 7857660.51 |\n| 30534 | 7855226.08 |\n| 99405 | 7853410.95 |\n| 161551 | 7852244.40 |\n| 185034 | 7850752.00 |\n| 17264 | 7850704.88 |\n| 23652 | 7848909.16 |\n| 123681 | 7848265.36 |\n| 186170 | 7845527.50 |\n| 81496 | 7840427.40 |\n| 25407 | 7840234.72 |\n| 96662 | 7839907.41 |\n| 156407 | 7839647.75 |\n| 165843 | 7839562.80 |\n| 153361 | 7838813.07 |\n| 149362 | 7838282.52 |\n| 46057 | 7835709.81 |\n| 114341 | 7835492.25 |\n| 154823 | 7834898.61 |\n| 139538 | 7834690.64 |\n| 42853 | 7833252.60 |\n| 177659 | 7831803.58 |\n| 29158 | 7829880.80 |\n| 85583 | 7825996.64 |\n| 165714 | 7825006.46 |\n| 58662 | 7821977.76 |\n| 185839 | 7821640.74 |\n| 93559 | 7821137.52 |\n| 58481 | 7818648.16 |\n| 162217 | 7817923.47 |\n| 130014 | 7815929.34 |\n| 125640 | 7815262.90 |\n| 83723 | 7815021.48 |\n| 54314 | 7813732.94 |\n| 146652 | 7809817.39 |\n| 189256 | 7808972.00 |\n| 87994 | 7808660.48 |\n| 157067 | 7806217.25 |\n| 56859 | 7805947.60 |\n| 118132 | 7804423.69 |\n| 189457 | 7802777.91 |\n| 1509 | 7802315.42 |\n| 129101 | 7801994.70 |\n| 162285 | 7801859.52 |\n| 182358 | 7801430.46 |\n| 6288 | 7800363.30 |\n| 68972 | 7799224.95 |\n| 51684 | 7795455.46 |\n| 148645 | 7794585.92 |\n| 94359 | 7794358.92 |\n| 40451 | 7791437.70 |\n| 44019 | 7790053.76 |\n| 81470 | 7788716.85 |\n| 12731 | 7786998.38 |\n| 114393 | 7784963.34 |\n| 69323 | 7783583.08 |\n| 169794 | 7780968.30 |\n| 25378 | 7778569.60 |\n| 104509 | 7777137.62 |\n| 81874 | 7775216.80 |\n| 70859 | 7771185.07 |\n| 135768 | 7769704.84 |\n| 181960 | 7768847.90 |\n| 28481 | 7768516.61 |\n| 191604 | 7765367.68 |\n| 754 | 7762507.02 |\n| 127702 | 7761776.05 |\n| 36488 | 7761744.00 |\n| 183906 | 7759864.80 |\n| 90365 | 7759602.50 |\n| 60725 | 7759495.78 |\n| 69436 | 7759033.52 |\n| 12963 | 7756623.52 |\n| 64571 | 7755731.04 |\n| 160111 | 7753787.70 |\n| 107970 | 7753735.88 |\n| 132036 | 7753401.36 |\n| 79965 | 7748656.15 |\n| 149862 | 7747239.10 |\n| 73218 | 7745499.42 |\n| 161036 | 7742807.45 |\n| 152467 | 7742471.40 |\n| 163358 | 7742034.00 |\n| 197951 | 7741768.84 |\n| 15820 | 7740003.00 |\n| 31444 | 7739519.60 |\n| 151208 | 7738273.85 |\n| 20410 | 7737192.99 |\n| 45462 | 7736792.55 |\n| 128966 | 7736467.65 |\n| 118945 | 7735275.00 |\n| 106458 | 7734069.72 |\n| 162706 | 7730189.88 |\n| 70528 | 7730088.25 |\n| 107998 | 7728273.45 |\n| 163110 | 7728042.40 |\n| 74591 | 7727297.76 |\n| 121454 | 7726200.56 |\n| 181252 | 7724464.38 |\n| 29154 | 7724129.66 |\n| 63854 | 7720353.88 |\n| 34157 | 7719803.30 |\n| 30684 | 7718307.84 |\n| 3985 | 7715042.96 |\n| 29387 | 7714858.80 |\n| 184703 | 7712545.12 |\n| 124679 | 7712528.72 |\n| 15606 | 7710658.46 |\n| 123814 | 7709872.95 |\n| 83760 | 7709633.92 |\n| 22084 | 7707219.79 |\n| 123210 | 7706030.42 |\n| 75066 | 7704727.51 |\n| 16337 | 7704517.80 |\n| 47109 | 7704111.51 |\n| 8232 | 7702887.50 |\n| 11222 | 7702535.62 |\n| 84961 | 7701923.72 |\n| 157118 | 7700132.88 |\n| 118362 | 7699210.20 |\n| 193755 | 7698545.20 |\n| 1520 | 7697759.37 |\n| 114599 | 7697377.50 |\n| 168842 | 7696152.00 |\n| 172245 | 7694286.06 |\n| 4584 | 7693352.79 |\n| 113651 | 7689659.67 |\n| 183207 | 7687955.66 |\n| 175802 | 7686604.70 |\n| 59066 | 7685120.43 |\n| 130726 | 7684159.25 |\n| 89672 | 7684049.50 |\n| 7224 | 7683446.40 |\n| 97533 | 7680694.62 |\n| 59941 | 7680100.80 |\n| 29298 | 7676823.42 |\n| 163962 | 7675924.96 |\n| 41086 | 7674518.14 |\n| 185483 | 7673376.60 |\n| 165010 | 7672469.70 |\n| 3708 | 7671744.18 |\n| 192994 | 7671712.00 |\n| 79968 | 7668060.48 |\n| 118494 | 7666659.00 |\n| 59236 | 7666625.98 |\n| 149509 | 7665930.67 |\n| 3793 | 7664981.28 |\n| 28979 | 7664632.93 |\n| 178389 | 7662544.96 |\n| 65315 | 7661085.88 |\n| 59710 | 7657442.00 |\n| 170276 | 7656813.89 |\n| 182707 | 7656387.06 |\n| 129170 | 7655820.48 |\n| 59765 | 7655009.92 |\n| 23337 | 7654271.94 |\n| 90396 | 7653568.35 |\n| 68842 | 7652742.72 |\n| 16315 | 7652630.70 |\n| 956 | 7652174.81 |\n| 10639 | 7651375.80 |\n| 112886 | 7649534.08 |\n| 9561 | 7648502.73 |\n| 65484 | 7647789.30 |\n| 68677 | 7646879.14 |\n| 196529 | 7645482.24 |\n| 6556 | 7642116.06 |\n| 9113 | 7640163.68 |\n| 128139 | 7638760.00 |\n| 143264 | 7635499.56 |\n| 21569 | 7634785.86 |\n| 193402 | 7633576.06 |\n| 35545 | 7632210.69 |\n| 65068 | 7632188.76 |\n| 25515 | 7630952.93 |\n| 180189 | 7630887.10 |\n| 131680 | 7629593.64 |\n| 80162 | 7629440.93 |\n| 139054 | 7629417.37 |\n| 8028 | 7629134.04 |\n| 76804 | 7626731.00 |\n| 74179 | 7624974.03 |\n| 122507 | 7623903.87 |\n| 141889 | 7623552.30 |\n| 184279 | 7623048.17 |\n| 8076 | 7620897.81 |\n| 192681 | 7619802.09 |\n| 21398 | 7617942.52 |\n| 14825 | 7617843.60 |\n| 17969 | 7617524.64 |\n| 170764 | 7616119.96 |\n| 115303 | 7615914.17 |\n| 67708 | 7615306.08 |\n| 33317 | 7613417.24 |\n| 190782 | 7613203.42 |\n| 113818 | 7612852.48 |\n| 178091 | 7611457.30 |\n| 87603 | 7611343.68 |\n| 108317 | 7610509.71 |\n| 106552 | 7609868.84 |\n| 28679 | 7609292.20 |\n| 192350 | 7609140.81 |\n| 154801 | 7607944.38 |\n| 5768 | 7607785.68 |\n| 127689 | 7606313.94 |\n| 62847 | 7605651.45 |\n| 111212 | 7605052.00 |\n| 156065 | 7603327.60 |\n| 115140 | 7601161.68 |\n| 19597 | 7601153.46 |\n| 55233 | 7600940.23 |\n| 89353 | 7600929.84 |\n| 75701 | 7600492.60 |\n| 64974 | 7599754.80 |\n| 116156 | 7597452.48 |\n| 59491 | 7596352.84 |\n| 6138 | 7594861.54 |\n| 62317 | 7594854.10 |\n| 106575 | 7594520.08 |\n| 161092 | 7594454.40 |\n| 9872 | 7593734.34 |\n| 77711 | 7593431.60 |\n| 61206 | 7593153.00 |\n| 123776 | 7592736.80 |\n| 185141 | 7592617.12 |\n| 5542 | 7592513.04 |\n| 185296 | 7591439.31 |\n| 72597 | 7591142.40 |\n+------------+-------------+\n1225 rows in set\n\nQ12\n+------------+-----------------+----------------+\n| l_shipmode | high_line_count | low_line_count |\n+------------+-----------------+----------------+\n| FOB | 6273 | 9429 |\n| TRUCK | 6336 | 9300 |\n+------------+-----------------+----------------+\n\nQ13\n+---------+----------+\n| c_count | custdist |\n+---------+----------+\n| 0 | 50005 |\n| 10 | 6574 |\n| 9 | 6554 |\n| 11 | 6072 |\n| 8 | 5934 |\n| 12 | 5598 |\n| 13 | 5032 |\n| 19 | 4685 |\n| 7 | 4663 |\n| 20 | 4607 |\n| 17 | 4550 |\n| 18 | 4515 |\n| 14 | 4480 |\n| 15 | 4476 |\n| 16 | 4341 |\n| 21 | 4176 |\n| 22 | 3710 |\n| 6 | 3303 |\n| 23 | 3172 |\n| 24 | 2670 |\n| 25 | 2111 |\n| 5 | 1954 |\n| 26 | 1605 |\n| 27 | 1195 |\n| 4 | 1030 |\n| 28 | 898 |\n| 29 | 620 |\n| 3 | 408 |\n| 30 | 353 |\n| 31 | 225 |\n| 32 | 135 |\n| 2 | 128 |\n| 33 | 82 |\n| 34 | 54 |\n| 35 | 33 |\n| 1 | 18 |\n| 36 | 17 |\n| 37 | 7 |\n| 41 | 3 |\n| 40 | 3 |\n| 38 | 3 |\n| 39 | 1 |\n+---------+----------+\n42 rows in set\n\n\nQ14\n+-------------------+\n| promo_revenue |\n+-------------------+\n| 16.65118731292792 |\n+-------------------+\n\nQ15\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n| s_suppkey | s_name | s_address | s_phone | total_revenue |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n| 7895 | Supplier#000007895 | NYl,i8UhxTykLxGJ2voIRn20Ugk1KTzz | 14-559-808-3306 | 1678635.2636 |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n\n\nQ16\n+----------+---------------------------+--------+--------------+\n| p_brand | p_type | p_size | supplier_cnt |\n+----------+---------------------------+--------+--------------+\n| Brand#55 | LARGE BURNISHED TIN | 21 | 36 |\n| Brand#25 | PROMO BRUSHED STEEL | 24 | 28 |\n| Brand#54 | STANDARD BRUSHED COPPER | 14 | 27 |\n| Brand#12 | MEDIUM PLATED BRASS | 21 | 24 |\n| Brand#14 | ECONOMY PLATED TIN | 33 | 24 |\n| Brand#24 | ECONOMY PLATED TIN | 33 | 24 |\n| Brand#25 | MEDIUM PLATED STEEL | 35 | 24 |\n| Brand#32 | MEDIUM POLISHED COPPER | 20 | 24 |\n| Brand#32 | SMALL ANODIZED BRASS | 7 | 24 |\n| Brand#33 | ECONOMY PLATED STEEL | 7 | 24 |\n| Brand#33 | MEDIUM PLATED COPPER | 20 | 24 |\n| Brand#33 | PROMO POLISHED STEEL | 14 | 24 |\n...\n| Brand#31 | PROMO ANODIZED COPPER | 20 | 3 |\n| Brand#41 | LARGE BURNISHED STEEL | 20 | 3 |\n| Brand#43 | SMALL BRUSHED COPPER | 7 | 3 |\n| Brand#52 | MEDIUM POLISHED BRASS | 21 | 3 |\n| Brand#52 | SMALL POLISHED TIN | 2 | 3 |\n+----------+---------------------------+--------+--------------+\n18341 rows in set\n\nQ17\n+-------------------+\n| avg_yearly |\n+-------------------+\n| 348406.0542857143 |\n+-------------------+\n\nQ18\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| c_name | c_custkey | o_orderkey | o_orderdate | o_totalprice | sum(l_quantity) |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| Customer#000128120 | 128120 | 4722021 | 1994-04-07 | 544089.09 | 323.00 |\n| Customer#000144617 | 144617 | 3043270 | 1997-02-12 | 530604.44 | 317.00 |\n| Customer#000066790 | 66790 | 2199712 | 1996-09-30 | 515531.82 | 327.00 |\n| Customer#000015619 | 15619 | 3767271 | 1996-08-07 | 480083.96 | 318.00 |\n| Customer#000147197 | 147197 | 1263015 | 1997-02-02 | 467149.67 | 320.00 |\n| Customer#000117919 | 117919 | 2869152 | 1996-06-20 | 456815.92 | 317.00 |\n| Customer#000126865 | 126865 | 4702759 | 1994-11-07 | 447606.65 | 320.00 |\n| Customer#000036619 | 36619 | 4806726 | 1995-01-17 | 446704.09 | 328.00 |\n| Customer#000119989 | 119989 | 1544643 | 1997-09-20 | 434568.25 | 320.00 |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n9 rows in set\n\nQ19\n+--------------+\n| revenue |\n+--------------+\n| 3083843.0578 |\n+--------------+\n\nQ20\n+--------------------+------------------------------------------+\n| s_name | s_address |\n+--------------------+------------------------------------------+\n| Supplier#000000035 | QymmGXxjVVQ5OuABCXVVsu,4eF gU0Qc6 |\n| Supplier#000000068 | Ue6N50wH2CwE4PPgTGLmat,ibGYYlDoOb3xQwtgb |\n| Supplier#000000080 | cJ2MHSEJ13rIL2Wj3D5i6hRo30,ZiNUXhqn |\n| Supplier#000000100 | rIlN li8zvW22l2slbcx ECP4fL |\n| Supplier#000000274 | usxbl9KSW41DTE6FAglxHU |\n| Supplier#000000406 | zMhU58CDF4aHTeodxg9IgRZgq |\n| Supplier#000000444 | mHr2VcUpRkvyQ9rjKMaPkeWbVZmEIhxhb8F |\n| Supplier#000000453 | bpt98PxU5HSQt61bVB695JPjBmJKUv hNzQeHvC |\n| Supplier#000000458 | IFNkUK1H53HwUHabiONkMFAUDb |\n| Supplier#000000622 | gCQimU1jYHoQiglDmW1FkQM9wzi YC1P15pMy1 |\n| Supplier#000000713 | DBMIf1HiYY8OyRFcbtHpKIz |\n| Supplier#000000767 | bHEuqKKdmCMEKOV |\n| Supplier#000000776 | nklfFoSkCwf,ooSuF |\n| Supplier#000000823 | gC0DrEG5U,v893fp3nj mmXa6rYhJ0tjpJ |\n| Supplier#000000828 | 0B2aPqJ6KTEr2fqxuC7z |\n| Supplier#000000941 | gqG2XEnVlzUhjjfQGYGlwk,jcaNsplI8Rleg |\n| Supplier#000000973 | 5 nhBZ 03rG6EcOEDkZXvt |\n| Supplier#000000984 | 6H6qqye iYbYzCmwWhj |\n| Supplier#000001149 | Nuno37wiZOjNGHF |\n| Supplier#000001201 | Seh4D7pi9UdK,XQkF46A0O2N |\n| Supplier#000001309 | 72RNUzKzbniUnnsSs24ZzGDvmcv2Pd |\n| Supplier#000001344 | 6iF,zVDNTykohVKcb7FKvn82s74ez |\n| Supplier#000001351 | zXdoBMmmRx1wOD7GKoHHBtemXGuYKLDb,U2KP |\n| Supplier#000001391 | hkWoAM561QlLjBNk,SdFdIgFx |\n| Supplier#000001481 | ARqVvJHMxBNKl2LrfPsR Wq9ZUXh,14 |\n| Supplier#000001584 | gJbTkijteJxSMLmdzBSzeMAH |\n| Supplier#000001651 | 6rJNoWL9YL |\n| Supplier#000001710 | J,sdOOJwUhwPv2mrEiNEA0UZlmu5IRmgz |\n| Supplier#000001755 | QstBVfnY,93NsbWXCqO |\n| Supplier#000001869 | nogoCdaFQii,ri9rs3P8f5rPt1wVOMw9I7TmypxK |\n| Supplier#000001895 | lywAGDbk37fYPDS |\n| Supplier#000001910 | vih,zrhclXX1O9x |\n| Supplier#000001930 | 2jCSw3KOLHol7y5omVO13 |\n| Supplier#000001979 | UNW7nA,IC 5igvVsgUHA7OaLL,jOzUcT |\n| Supplier#000002046 | BiTDgHknmvQGT6FpZXfRX,xlnR |\n| Supplier#000002071 | zLH3QAtZuuOq8AoVNM |\n| Supplier#000002270 | HIscbvhw8N94djn,3UbPaY4R |\n| Supplier#000002350 | TWsO2iJGOl7v3vSwiscXp6X |\n| Supplier#000002409 | oy39SaSQ,FIP pzLqblhxj |\n| Supplier#000002520 | 5y55UzYQKByZP3 |\n| Supplier#000002618 | 3UtbE1kKm29kKyx09hSEBMhRLM |\n| Supplier#000002643 | eDN6YjGtp2dcj0IF,BKEEYjElO,sUjjcNI |\n| Supplier#000002649 | agDQi9iCt1cUaS |\n| Supplier#000002655 | i6v8dkQBuK0NSCeqQCE8 |\n| Supplier#000002812 | Q9sO3wZkBU5QBe0VITRWShv |\n| Supplier#000002888 | 3AtRoxBFh6HIBa9kdBX,6,Ml2SZGUA |\n| Supplier#000002910 | nlH1gjApxHkQe5SU4iVZwi2xWk88wwhTWRkSvOBB |\n| Supplier#000002914 | fUC4IkGB8pt1S |\n| Supplier#000003000 | JtDvRf4iWHJkj54PYxl |\n| Supplier#000003011 | vfL mV0MTdyozfRIPZkJbM1Z7Lcm2NCPIj6qSgBz |\n| Supplier#000003038 | F5Tz7P juuCbABDuW8JGomRFxqVHBWyQrsLwg4i |\n| Supplier#000003150 | XwSjsmzEnANK,wAQUp4Xf5xJDqR |\n| Supplier#000003305 | GLZJimfuzKoQcqcv4 |\n| Supplier#000003394 | R6D7n3WrQjWNGSQTb7eN ,X0oCMkhyuTHBOSPw |\n| Supplier#000003452 | 7tMycIKhE,pe4OL3Du |\n| Supplier#000003666 | ENS fE9iSrSzw,iTwA,zGorkflw |\n| Supplier#000003698 | lnSEu64ca4B53BfznJPg |\n| Supplier#000003773 | UWjSotAjkAD |\n| Supplier#000003837 | SYXpXaKop3 |\n| Supplier#000003846 | wl076KfcEpYLRegb1LfIf93b3n5HBabFK2R,mEM |\n| Supplier#000003862 | 0XXFhF1IDBh |\n| Supplier#000003868 | 5aP4VBn0t666NbGYB |\n| Supplier#000003880 | DZo80mSznrhCpb8 |\n| Supplier#000003955 | piECPB8qbn7s3XP |\n| Supplier#000004007 | cvlSgCCKGOwpaB iFIPx4vU2qA5b6K hz9Z91 |\n| Supplier#000004066 | TNBnJFDScUmsjBy6pSWTS sfMg9jpfKx |\n| Supplier#000004127 | EduKm3NcCc75Cd |\n| Supplier#000004174 | Bk97olQYwXmjYdQjwyt N |\n| Supplier#000004328 | euddbWZRcVMD3W |\n| Supplier#000004341 | ea8KZYvO7amq8A |\n| Supplier#000004360 | w 7kM5J,fqjiqBu4SU0UPEDqspaUEm |\n| Supplier#000004375 | Cmr952zcJJuW0xAYc0W0MA7N6vMcCjy |\n| Supplier#000004391 | pcsiJBhSEHuFHNAxR3K c |\n| Supplier#000004398 | khZZ0CmLip49Zncec |\n| Supplier#000004402 | acagGfDWzwmS,,WVBsszubFs3LOA8rDRS0I |\n| Supplier#000004714 | IKRla2xArMmR4p3Mbn8JV8g0 |\n| Supplier#000004717 | H,Suh5pN230Ol,ggx0QEh3rrvzyQsq050Lat |\n| Supplier#000004740 | yM0TXkhfjpObafbQhuWU |\n| Supplier#000004763 | W 7kS9LLh4ZgLpk2 |\n| Supplier#000004837 | tYHMZS4XlJjzvj34mH2PCoj |\n| Supplier#000004882 | e,V Bo1KZEt |\n| Supplier#000004913 | em,yC41xEl Fst9LwEik |\n| Supplier#000005005 | K6 GI4WzmbsGEOh |\n| Supplier#000005238 | jmtI76 8RNG8Z2BZu |\n| Supplier#000005289 | 62XeOur9SnXgbdjGwb9E1aJIEBr5PA9 |\n| Supplier#000005317 | lPOPHufNjwZaUJGVNHCC2DE FYQcKZBzHltL5 |\n| Supplier#000005401 | eEOlCEAaIfVexStlrgTuzwQx7vjPF6ZT dm |\n| Supplier#000005449 | fhc8lUuZdqWUujcVaWogowEq1WVL9Y8m1efwCl3G |\n| Supplier#000005472 | LlyLSmvY9GFvMN4QhHzMokW0k5d |\n| Supplier#000005572 | o0VYozeSbEyqck |\n| Supplier#000005579 | ACVEMP4IwRf |\n| Supplier#000005661 | pq5wuxmkIW0DyWU |\n| Supplier#000005676 | HInJHZisl5svSU1oKsr |\n| Supplier#000005815 | S6cu6cspYxHlTz2 |\n| Supplier#000005835 | rYoXzV3EZ77Z |\n| Supplier#000006103 | l32l8iaPdbHgRXoq,kdjFAj3hZk2d |\n| Supplier#000006173 | hBdratcVfL4LpWxsEpCRP g0AksN0CDhBZ |\n| Supplier#000006226 | CKuDyeGAxPHeRHwC4a |\n| Supplier#000006254 | g7OY1vWNUb1vxIRgEl |\n| Supplier#000006348 | f2KDn2rLnadX8I DZR |\n| Supplier#000006359 | QyUuVHYBp8sTd7Y9WveNfsz |\n| Supplier#000006430 | F2RrkeaNcs6po8x2PyYvcPa1rtKd,fT2AMxP |\n| Supplier#000006516 | 89XwFOC,hLRxGq5rL0txv0EM9F |\n| Supplier#000006700 | BWjerJH5kbEPu 8h9 |\n| Supplier#000006785 | lyo6PpwulTeN9ZfIkvWag5NucL,XMC 89Kn7U |\n| Supplier#000006998 | r2i3HfkSQh9dvho, NpoabdMsPBG |\n| Supplier#000007019 | 2GQsALzRiTt2BQum6bocdeGawkOrsjNIZ |\n| Supplier#000007114 | s9s4YLeLWo7fLRO3rdQKFfUnZhrZUPjOC |\n| Supplier#000007170 | 9vABqu hZaciXSCQrbTj |\n| Supplier#000007171 | DXerxFIhNRpqF9dWNRw hDOlLX gEJFxh0 |\n| Supplier#000007213 | 2Nrby3JJHDJyWwVNiqPtm2U JGWlZpU |\n| Supplier#000007219 | p5Ui3IGPcmotYu |\n| Supplier#000007229 | iwNoWdaURFzLAsQHxK,BeOPpI5TOTo |\n| Supplier#000007263 | malQPdYc8xiup2MiFuKHa |\n| Supplier#000007270 | TksERECGdYZRPUjkUdDRZv5pW26cOTaA1 |\n| Supplier#000007276 | Vi9,aBg2ychZf |\n| Supplier#000007334 | NPXYWdJ8L9EDr20tw9CZQsEMqXlgXzI2JC Y |\n| Supplier#000007400 | 7r9zZj8J,,hN2GRfWtDxzuGa |\n| Supplier#000007442 | DzycM1,T6kh2EutfPeFpv0Ro |\n| Supplier#000007456 | ITYEeccPVJi0HvnAwVs2Z |\n| Supplier#000007559 | Wmzx1vskciC |\n| Supplier#000007677 | OoTYQdxQyd7NukSaSRv |\n| Supplier#000007712 | DyTQD 3ajuOtHQTpI4LsWSF kSd2SE6U4COgYHQ |\n| Supplier#000007715 | gZHd7Yzbtv7yb7DYCCAQPJH8FRHTqi6T4w |\n| Supplier#000007816 | 1ejcJ545bwLWLuY6Qq4qyEExZIsp0SG |\n| Supplier#000007845 | agwGVTzLyRKOsZxLVi,mPWZ08Qxb |\n| Supplier#000007875 | E0CkoBYngcIoH |\n| Supplier#000007908 | ghhHapj7GK |\n| Supplier#000007972 | WW0GuiWP2N3kUo4f |\n| Supplier#000008162 | XASpbn08mRV0kgHRmUSKx |\n| Supplier#000008235 | TjVWq6bTdGJB |\n| Supplier#000008249 | PwUjvlMk y72zaMRtZQ8trbCmu4j |\n| Supplier#000008309 | 6P,FQbW6sJouqunvttVO6vEeY |\n| Supplier#000008339 | uWw8 P6u,S |\n| Supplier#000008343 | BbHngAVqj0J8 |\n| Supplier#000008349 | 8Hkx1IDd0mZCTX |\n| Supplier#000008377 | ,Yk0mflw2LqQCTxMYR sU2juj5DorUAG4w6i |\n| Supplier#000008468 | 5R4jsweitleustYlE3w,u5otW |\n| Supplier#000008523 | C4ocdfNu5I2nnnVG2xSd3016J6KNLIg |\n| Supplier#000008580 | t5ri71bM6Sox3riP4JUZsMMNC |\n| Supplier#000008638 | yxj50B 8aMql |\n| Supplier#000008642 | qnN9N9du9Dg2arf6kjD xW0DjMT9cM |\n| Supplier#000008651 | pfw32RGA7BPXrUiavYqE |\n| Supplier#000008679 | JWFVoSsCwn9p8o |\n| Supplier#000008704 | a6DjHp0B6mifKBtqUk,C |\n| Supplier#000008737 | MsdGxF9Xoq9 8s |\n| Supplier#000008820 | uAsBvPBNsEsO |\n| Supplier#000008829 | lNcY7xNLDonCw TuRYL |\n| Supplier#000008947 | 1Ij3T0egGHnVbLich98HzY,UeCdVbxzYa ZpKDVc |\n| Supplier#000008964 | U2YJW,Y1xCbUWbjuovtzsLfsl |\n| Supplier#000008974 | 4JCXOJ3MyPfa51mIf,MQu |\n| Supplier#000008997 | KY MmMEcyQ6FEDCooFj xa uCwF2GbaeA8 |\n| Supplier#000009065 | ZELuiqWrWbJV9zAuco1OnXKTJClhR |\n| Supplier#000009114 | nkn6bcPvlP5w,lUpO0nZTBSj |\n| Supplier#000009125 | IQbCXbN1mmght |\n| Supplier#000009131 | gDBXgWtg4rTxu0WUJhhV |\n| Supplier#000009149 | yKX,bKryD6YtvF,cVLIKC0Z6rN |\n| Supplier#000009182 | z56kNgeqaWQ1kHFBp |\n| Supplier#000009220 | N4y,vP kdArpcmdypBh,fJVVB |\n| Supplier#000009226 | yzT10vNTFJ |\n| Supplier#000009288 | 251AA4ziZ3d7TTWXLGnXjb4BnXv |\n| Supplier#000009360 | 1NVjjX8zMjyBX2UapDTP0Sz |\n| Supplier#000009381 | rhCTm7QehIznqd8 Np7VT,H5J5zSGr |\n| Supplier#000009403 | 70841REghyWBrHyyg762Jh4sjCG7CKaIc |\n| Supplier#000009504 | Rqt07,ANI92kj1oU |\n| Supplier#000009598 | PnTAz7rNRLVDFO3zoo2QRTlh4o |\n| Supplier#000009609 | LV2rJUGfr0k3dPNRqufG1IoYHzV |\n| Supplier#000009619 | K0RwcJ9S75Xil jqKukFoDNkD |\n| Supplier#000009626 | Nm1FnIh4asUR3EnXv2Pvy3gXqI9es |\n| Supplier#000009738 | 15RRSVTuOzwdMP LmfCtIguMGXK |\n| Supplier#000009770 | Ag, SZfowit580QPDdbP8kmFHdpZ9ASI |\n| Supplier#000009865 | extcOh9ZrdDCMsHhhsFTkTUAh,HM2UQ2qa8sRo |\n| Supplier#000009866 | Auh6aZnOnQG1pPYKZ5o9ATramJBA |\n| Supplier#000009890 | izJXemCM Ikpgxk |\n| Supplier#000009937 | edZ9HQJ0KJAU6EWknTiDghKfRLHq6vtFqdey,0l |\n| Supplier#000009954 | VzElx9ihlXFJLIQw2Hn4bC2 |\n| Supplier#000009958 | ggiiSA4CSyvhwQUYjdJhWlKEY9PAfs |\n+--------------------+------------------------------------------+\n177 rows in set\n\n\nQ21\n+--------------------+---------+\n| s_name | numwait |\n+--------------------+---------+\n| Supplier#000009302 | 21 |\n| Supplier#000000342 | 20 |\n| Supplier#000000632 | 19 |\n| Supplier#000002196 | 19 |\n| Supplier#000003325 | 18 |\n| Supplier#000003915 | 18 |\n| Supplier#000005045 | 18 |\n| Supplier#000006442 | 18 |\n| Supplier#000003093 | 17 |\n| Supplier#000004498 | 17 |\n| Supplier#000000906 | 16 |\n| Supplier#000001183 | 16 |\n| Supplier#000001477 | 16 |\n| Supplier#000006043 | 16 |\n| Supplier#000000689 | 15 |\n| Supplier#000001955 | 15 |\n| Supplier#000002066 | 15 |\n| Supplier#000002146 | 15 |\n| Supplier#000003253 | 15 |\n| Supplier#000003527 | 15 |\n| Supplier#000003947 | 15 |\n| Supplier#000004915 | 15 |\n| Supplier#000005248 | 15 |\n| Supplier#000006718 | 15 |\n| Supplier#000007773 | 15 |\n| Supplier#000008121 | 15 |\n| Supplier#000008169 | 15 |\n| Supplier#000008645 | 15 |\n| Supplier#000008684 | 15 |\n| Supplier#000009079 | 15 |\n| Supplier#000009956 | 15 |\n| Supplier#000000737 | 14 |\n| Supplier#000000775 | 14 |\n| Supplier#000001474 | 14 |\n| Supplier#000001502 | 14 |\n| Supplier#000003196 | 14 |\n| Supplier#000004415 | 14 |\n| Supplier#000004940 | 14 |\n| Supplier#000005253 | 14 |\n| Supplier#000005703 | 14 |\n| Supplier#000006308 | 14 |\n| Supplier#000006789 | 14 |\n| Supplier#000007161 | 14 |\n| Supplier#000007952 | 14 |\n| Supplier#000008062 | 14 |\n| Supplier#000008414 | 14 |\n| Supplier#000008442 | 14 |\n| Supplier#000008508 | 14 |\n| Supplier#000000300 | 13 |\n| Supplier#000000727 | 13 |\n| Supplier#000000921 | 13 |\n| Supplier#000000992 | 13 |\n| Supplier#000001282 | 13 |\n| Supplier#000001582 | 13 |\n| Supplier#000001662 | 13 |\n| Supplier#000001683 | 13 |\n| Supplier#000002933 | 13 |\n| Supplier#000003177 | 13 |\n| Supplier#000003428 | 13 |\n| Supplier#000003640 | 13 |\n| Supplier#000004842 | 13 |\n| Supplier#000004951 | 13 |\n| Supplier#000005795 | 13 |\n| Supplier#000005981 | 13 |\n| Supplier#000006118 | 13 |\n| Supplier#000006433 | 13 |\n| Supplier#000006484 | 13 |\n| Supplier#000007268 | 13 |\n| Supplier#000008599 | 13 |\n| Supplier#000008675 | 13 |\n| Supplier#000009474 | 13 |\n| Supplier#000009521 | 13 |\n| Supplier#000009853 | 13 |\n| Supplier#000000021 | 12 |\n| Supplier#000000211 | 12 |\n| Supplier#000000743 | 12 |\n| Supplier#000000951 | 12 |\n| Supplier#000001654 | 12 |\n| Supplier#000001868 | 12 |\n| Supplier#000002089 | 12 |\n| Supplier#000002879 | 12 |\n| Supplier#000003060 | 12 |\n| Supplier#000003215 | 12 |\n| Supplier#000003365 | 12 |\n| Supplier#000003873 | 12 |\n| Supplier#000003985 | 12 |\n| Supplier#000004452 | 12 |\n| Supplier#000004639 | 12 |\n| Supplier#000005122 | 12 |\n| Supplier#000005633 | 12 |\n| Supplier#000005671 | 12 |\n| Supplier#000005782 | 12 |\n| Supplier#000006088 | 12 |\n| Supplier#000006477 | 12 |\n| Supplier#000006508 | 12 |\n| Supplier#000006750 | 12 |\n| Supplier#000006802 | 12 |\n| Supplier#000008236 | 12 |\n| Supplier#000009294 | 12 |\n| Supplier#000009329 | 12 |\n+--------------------+---------+\n100 rows in set\n\nQ22\n+-----------+---------+------------+\n| cntrycode | numcust | totacctbal |\n+-----------+---------+------------+\n| 10 | 882 | 6606081.31 |\n| 11 | 899 | 6702253.34 |\n| 19 | 963 | 7230776.82 |\n| 20 | 916 | 6824676.02 |\n| 22 | 894 | 6636740.03 |\n| 26 | 861 | 6404695.86 |\n| 27 | 877 | 6565078.99 |\n+-----------+---------+------------+\n7 rows in set\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/","title":"MO-Tester \u89c4\u8303\u8981\u6c42","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#-case","title":"\u7f16\u5199\u6d4b\u8bd5\u7528\u4f8b\u89c4\u8303 - case","text":"\u89c4\u8303 \u8be6\u60c5 \u6587\u4ef6\u547d\u540d 1. \u4ee5 .sql \u6216 .test \u4f5c\u4e3a\u540e\u7f00\u30022. \u6587\u4ef6\u540d\u79f0\u6709\u5b9e\u9645\u542b\u4e49\u3002\u4f8b\u5982\uff0c\u9700\u8981\u7f16\u5199\u6d4b\u8bd5\u7d22\u5f15\u7528\u4f8b\uff0c\u53ef\u4ee5\u5c06\u6d4b\u8bd5\u7d22\u5f15\u7528\u4f8b\u547d\u540d\u4e3a index.sql \u6216\u8005index_xxxx.sql\u3002 \u6d4b\u8bd5\u7528\u4f8b 1. \u6d4b\u8bd5\u7528\u4f8b\uff0c\u5373 case \u5185\u7684\u5177\u4f53\u793a\u4f8b\u5185\u5bb9\uff0c\u6240\u6709\u7684\u7a7a\u884c\u5728\u6d4b\u8bd5\u65f6\u90fd\u81ea\u52a8\u5ffd\u7565\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u7a7a\u884c\u6765\u4f7f\u6574\u4e2a\u6587\u4ef6\u5185\u5bb9\u66f4\u6613\u8bfb\u30022. \u6bcf\u6761 SQL \u8bed\u53e5\u53ea\u5199\u4e00\u884c\uff0c\u5982\u679c\u5fc5\u987b\u8981\u591a\u884c\u4e66\u5199\uff0c\u90a3\u4e48\u6bcf\u884c\u5fc5\u987b\u9876\u683c\u4e66\u5199\uff0c\u4e14 SQL \u7ed3\u5c3e\u4e0d\u80fd\u6709\u7a7a\u683c\uff0c\u5426\u5219\u5c06\u9020\u6210 case \u6587\u4ef6 \u548c result \u6587\u4ef6\u4e2d SQL \u4e0d\u80fd\u5b8c\u5168\u5339\u914d\u30023. \u6dfb\u52a0\u6ce8\u91ca\uff0c\u6ce8\u660e\u5f53\u524d\u6240\u5199\u6d4b\u8bd5\u7528\u4f8b\u7684\u76ee\u7684\u30024. \u4e3a\u9700\u8981\u589e\u52a0 Tag \u6807\u7b7e\u6d4b\u8bd5\u7528\u4f8b\u6dfb\u52a0 Tag\u3002"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#-tag","title":"\u6d4b\u8bd5\u7528\u4f8b\u6ce8\u89e3\u8bf4\u660e - Tag","text":"\u6ce8\u89e3 \u8d77\u59cb \u7ed3\u675f \u8bf4\u660e -- @bvt:issue -- @bvt:issue#{issueNO.}] -- @bvt:issue \u5e26\u6709\u6b64\u6ce8\u89e3\u6807\u8bb0\u7684 SQL \u5c06\u4e0d\u4f1a\u88ab\u6267\u884c -- @sessio -- @session:id=X{ -- @session} \u5e26\u6709\u6b64\u4e3b\u952e\u6807\u8bb0\u7684\u6240\u6709 SQL \u5c06\u5728 id=X \u7684\u65b0\u4f1a\u8bdd\u4e2d\u6267\u884c -- @separator / / \u6307\u5b9a SQL \u8bed\u53e5\u5728\u89e3\u6790\u5176 result \u4ee5\u53ca\u751f\u6210 result \u6587\u4ef6\u7684\u65f6\u5019\uff0c\u4f7f\u7528\u7684\u5217\u5206\u9694\u7b26\uff0c\u6709\u4e24\u4e2a\u53d6\u503c -- @separator:table / / \u8868\u793a\u7ed3\u679c\u4e2d\u5217\u5206\u9694\u7b26\u4e3a\u5236\u8868\u7b26 \\t -- @separator:space / / \u8868\u793a\u7ed3\u679c\u4e2d\u5217\u5206\u9694\u7b26\u4e3a 4 \u4e2a\u7a7a\u683c -- @sortkey -- @sortkey:1,2,3 / \u8868\u793a\u8be5 SQL \u8bed\u53e5\u7684\u7ed3\u679c\u662f\u6709\u5e8f\u7684\uff0c\u6392\u5e8f\u952e\u4e3a\u7b2c 1\uff0c2\uff0c3 \u5217\uff08\u4ece 0 \u5f00\u59cb\uff09\uff1b\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u88ab\u6d4b\u8bd5\u7cfb\u7edf\u8fd4\u56de\u7684\u7ed3\u679c\u987a\u5e8f\u662f\u4e0d\u56fa\u5b9a\u7684\uff0c\u6240\u4ee5\u5de5\u5177\u5728\u6bd4\u5bf9\u7684\u65f6\u5019\uff0c\u4f1a\u628a\u5b9e\u9645\u7ed3\u679c\u548c\u9884\u671f\u7ed3\u679c\u90fd\u8fdb\u884c\u6392\u5e8f\u540e\u6bd4\u5bf9\uff0c\u4f46\u662f\u5bf9\u4e8e\u67d0\u4e9b SQL\uff0c\u5176\u9884\u671f\u7684\u7ed3\u679c\u5c31\u5e94\u8be5\u662f\u6709\u5e8f\u7684\uff0c\u6bd4\u5982\u5b58\u5728 order by
\u7684 SQL \u8bed\u53e5\uff0c\u90a3\u4e48\u9700\u8981\u628a\u7c7b\u4f3c\u8fd9\u79cd SQL \u6dfb\u52a0\u4e0a\u8fd9\u6837\u7684 Tag\uff0c\u5de5\u5177\u5728\u6bd4\u5bf9\u7684\u65f6\u5019\uff0c\u4e0d\u4f1a\u5bf9 sortkey \u4e2d\u7684\u8fd9\u4e9b\u5217\u8fdb\u884c\u91cd\u65b0\u6392\u5e8f"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#-result","title":"\u7f16\u5199\u6d4b\u8bd5\u7ed3\u679c\u89c4\u8303 - result","text":"\u89c4\u8303 \u8be6\u60c5 \u666e\u901a\u6d4b\u8bd5\u7528\u4f8b\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c 1. \u5982\u679c\u65b0\u589e\u4e86\u6d4b\u8bd5 case \u6587\u4ef6\uff0c\u9996\u5148\u786e\u4fdd\u6240\u6709 SQL \u90fd\u8c03\u8bd5\u901a\u8fc7\uff0c\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u30022. \u5982\u679c\u662f\u5728\u5df2\u6709\u7684 case \u5185\u65b0\u589e\u4e00\u4e9b SQL\uff0c\u9996\u5148\u786e\u4fdd\u6240\u6709 SQL \u90fd\u8c03\u8bd5\u901a\u8fc7\uff0c\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u3002 \u542b\u6709 Tag \u7684\u6d4b\u8bd5\u7528\u4f8b\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c 1. \u5982\u679c\u65b0\u589e\u6d4b\u8bd5 case \u6587\u4ef6\uff0c\u4e14 case \u6587\u4ef6\u5185\u542b\u6709\u5e26 --bvt:issue
\u6807\u7b7e SQL\uff0c\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\uff0c\u5e26 --bvt:issue
\u6807\u7b7e SQL \u5728\u6240\u751f\u6210\u7684 result \u6587\u4ef6\u4e2d\u7ed3\u679c\u4e3a unknown result because it is related to issue#XXX\"
\u30022. \u5982\u679c\u662f\u5df2\u6709\u6d4b\u8bd5 case \u6587\u4ef6\uff0c\u5df2\u901a\u8fc7 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\uff0c\u518d\u6b21\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u65f6\uff0c\u5e26 --bvt:issue
\u6807\u7b7e SQL \u5728\u6240\u751f\u6210\u7684 result \u6587\u4ef6\u4e2d\u7ed3\u679c\u5c06\u4fdd\u7559\u539f\u6709\u503c\uff0c\u4e0d\u518d\u66f4\u65b0\u3002 \u624b\u52a8\u7f16\u5199\u6d4b\u8bd5\u7ed3\u679c 1. \u5982\u679c\u662f\u624b\u52a8\u7f16\u5199 result\uff0c\u4e0d\u53ef\u6709\u7a7a\u884c\uff0c\u5426\u5219\u7ed3\u679c\u5c06\u4ea7\u751f\u89e3\u6790\u9519\u8bef\u30022. \u5982\u679c\u9884\u671f\u67d0\u6761 SQL \u7684\u6267\u884c\u7ed3\u679c\u4e2d\uff0c\u5b58\u5728\u5236\u8868\u7b26\u6216\u8005\u8d85\u8fc7\u8fde\u7eed\u7684 4 \u4e2a\u7a7a\u683c\uff0c\u5219\u5728\u6d4b\u8bd5 case \u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684 SQL \u8bed\u53e5\uff0c\u5fc5\u987b\u589e\u52a0 Tag \u6807\u7b7e -- @separator:
\uff0c\u5426\u5219\u5c06\u89e3\u6790\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u82e5 case \u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684 SQL \u8bed\u53e5\u542b\u8fde\u7eed 4 \u4e2a\u7a7a\u683c\uff0c\u5219\u9700\u8981\u6307\u5b9a Tag \u6807\u7b7e -- @separator:space
\uff1b\u82e5\u542b\u542b\u6709\u5236\u8868\u7b26\uff0c\u5219\u6307\u5b9a Tag \u6807\u7b7e -- @separator:table
\u3002"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#_1","title":"\u5728\u6d4b\u8bd5\u7528\u4f8b\u811a\u672c\u4e2d\u8bbe\u7f6e\u6807\u8bb0","text":"\u6709\u65f6\uff0c\u4e3a\u4e86\u8fbe\u5230\u7279\u5b9a\u7684\u76ee\u7684\uff0c\u5982\u6682\u505c\u6216\u521b\u5efa\u65b0\u8fde\u63a5\uff0c\u60a8\u53ef\u4ee5\u5411\u811a\u672c\u6587\u4ef6\u6dfb\u52a0\u7279\u6b8a\u7684\u6807\u8bb0\u3002Mo tester \u63d0\u4f9b\u4ee5\u4e0b\u6807\u7b7e\u4f9b\u4f7f\u7528\uff1a
\u6807\u7b7e \u8bf4\u660e -- @skip:issue#{IssueNo.} \u8bbe\u7f6e\u540e\uff0c\u6574\u4e2a\u811a\u672c\u6587\u4ef6\u5c06\u88ab\u8df3\u8fc7\uff0c\u5e76\u4e14\u4e0d\u518d\u6267\u884c issue{IssueNo.} -- @bvt:issue#{IssueNo.}-- @bvt:issue \u4e0d\u6267\u884c issue{IssueNo.} \u8fd9\u4e24\u4e2a\u6807\u8bb0\u4e4b\u95f4\u7684 sql \u8bed\u53e5\u3002 -- @sleep:{time} mo-tester \u5c06\u7b49\u5f85\u65f6\u957f{time} -- @session:id=2&user=root&password=111 -- @session mo tester \u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\u6765\u6267\u884c\u8fd9\u4e24\u4e2a\u6807\u8bb0\u4e4b\u95f4\u7684 sql \u8bed\u53e5\u3002 id \u9ed8\u8ba4\u503c\u4e3a 1\uff0c\u6700\u5927\u503c\u4e3a 10\u3002\u5728 mo.yml \u4e2d\u914d\u7f6e\u4e86\u7528\u6237\u548c\u5bc6\u7801\u7684\u9ed8\u8ba4\u503c\u3002 -- @sortkey: \u8bbe\u7f6e\u6b64\u6807\u8bb0\uff0c\u8868\u793a\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f\u3002\u4f8b\u5982:\u2014\u2014@sortkey:0,1:\u8868\u793a\u6392\u5e8f\u952e\u662f\u7b2c\u4e00\u5217\u548c\u7b2c\u4e8c\u5217\u3002"},{"location":"MatrixOne/Test/testing-tool/mo-tester/","title":"MO-Tester \u7b80\u4ecb","text":"\u4ece 0.5.0 \u7248\u672c\u5f00\u59cb\uff0cMatrixOne \u5f15\u5165\u4e86\u4e00\u4e2a\u81ea\u52a8\u6d4b\u8bd5\u6846\u67b6 MO-Tester\u3002
MO-Tester \u6d4b\u8bd5\u6846\u67b6\uff0c\u4e5f\u53ef\u4ee5\u79f0\u4f5c\u4e3a\u6d4b\u8bd5\u5668\uff0c\u662f\u901a\u8fc7 SQL \u6d4b\u8bd5 MatrixOne \u6216\u5176\u4ed6\u6570\u636e\u5e93\u529f\u80fd\u7684\u3002
MO-Tester \u662f\u57fa\u4e8e Java \u8bed\u8a00\u8fdb\u884c\u5f00\u53d1\uff0c\u7528\u4e8e MatrixOne \u7684\u6d4b\u8bd5\u5957\u4ef6\u3002MO-Tester \u6784\u5efa\u4e86\u4e00\u6574\u5957\u5b8c\u6574\u7684\u5de5\u5177\u94fe\u6765\u8fdb\u884c SQL \u81ea\u52a8\u6d4b\u8bd5\u3002\u5b83\u5305\u542b\u6d4b\u8bd5\u7528\u4f8b\u548c\u8fd0\u884c\u7ed3\u679c\u3002MO-Tester \u542f\u52a8\u540e\uff0cMO-Tester \u5c06\u4f7f\u7528 MatrixOne \u8fd0\u884c\u6240\u6709 SQL \u6d4b\u8bd5\u7528\u4f8b\uff0c\u5e76\u5c06\u6240\u6709\u8f93\u51fa SQL \u6d4b\u8bd5\u7ed3\u679c\u4e0e\u9884\u671f\u7ed3\u679c\u8fdb\u884c\u6bd4\u8f83\u3002\u6240\u6709\u6848\u4f8b\u7684\u7ed3\u679c\u65e0\u8bba\u6210\u529f\u6216\u8005\u5931\u8d25\uff0c\u90fd\u5c06\u8bb0\u5f55\u5728\u62a5\u544a\u4e2d\u3002
MO-Tester \u76f8\u5173\u7528\u4f8b\u3001\u7ed3\u679c\u548c\u62a5\u544a\u7684\u653e\u5728 MatrixOne \u4ed3\u5e93\u5185\uff0c\u94fe\u63a5\u5982\u4e0b\uff1a
Cases: https://github.com/matrixorigin/matrixone/tree/main/test/distributed/cases
Result: \u751f\u6210\u5728 /cases \u7684\u5177\u4f53\u6d4b\u8bd5\u7528\u4f8b\u4e0b\uff0c\u4f8b\u5982 /cases/auto_increment \u76ee\u5f55\u7684\u5177\u4f53\u6d4b\u8bd5\u7528\u4f8b\u540c\u7ea7\u76ee\u5f55\u4e0b\u751f\u6210\u5bf9\u5e94\u7684. result \u6587\u4ef6\u3002
Report: \u8fd0\u884c\u7ed3\u675f\u540e\uff0c\u672c\u5730\u76ee\u5f55\u81ea\u52a8\u751f\u6210 mo-tester/report
\u3002
\u6d4b\u8bd5\u7528\u4f8b\u548c\u6d4b\u8bd5\u7ed3\u679c\u4e00\u4e00\u5bf9\u5e94\u3002\u5982\u9700\u6dfb\u52a0\u65b0\u7684\u6d4b\u8bd5\u7528\u4f8b\u548c\u6d4b\u8bd5\u7ed3\u679c\u8bf7\u8fdb\u5165\u53f3\u4fa7\u6240\u793a MatrixOne \u4ed3\u5e93\u8def\u5f84\u4e2d\u8fdb\u884c\u6dfb\u52a0\uff1ahttps://github.com/matrixorigin/matrixone/tree/main/test
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#mo-tester_1","title":"\u4f7f\u7528 MO-Tester","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#1","title":"1. \u51c6\u5907\u6d4b\u8bd5\u73af\u5883","text":"\u8bf7\u5148\u786e\u8ba4\u5df2\u5b89\u88c5 jdk8\u3002
\u542f\u52a8 MatrixOne \u6216\u5176\u4ed6\u6570\u636e\u5e93\u7528\u4f8b\u3002\u53c2\u89c1\u66f4\u591a\u4fe1\u606f >>\u5b89\u88c5\u5355\u673a\u7248 MatrixOne.
\u514b\u9686 mo-tester \u4ed3\u5e93\u3002
git clone https://github.com/matrixorigin/mo-tester.git\n\u6216\u8005 \ngit clone https://githubfast.com/matrixorigin/mo-tester.git\n
git clone https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit clone https://githubfast.com/matrixorigin/matrixone.git\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#2-mo-tester","title":"2. \u914d\u7f6e MO-Tester","text":"MO-tester \u57fa\u4e8e Java \u8bed\u8a00\u8fdb\u884c\u5f00\u53d1\uff0c\u56e0\u6b64 Mo-tester \u6240\u4f9d\u8d56\u7684 Java \u6570\u636e\u5e93\u8fde\u63a5\uff08JDBC\uff0cJava Database Connectivity\uff09\u9a71\u52a8\u7a0b\u5e8f\u9700\u8981\u914d\u7f6e mo.yml \u6587\u4ef6\u91cc\u7684\u53c2\u6570\u4fe1\u606f\uff1a\u8fdb\u5165\u5230 mo-tester \u672c\u5730\u4ed3\u5e93\uff0c\u6253\u5f00 mo.yml \u6587\u4ef6\uff0c\u914d\u7f6e\u670d\u52a1\u5668\u5730\u5740\u3001\u9ed8\u8ba4\u7684\u6570\u636e\u5e93\u540d\u79f0\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u7b49\u3002
\u4ee5\u4e0b\u662f\u672c\u5730\u72ec\u7acb\u7248\u672c MatrixOne \u7684\u9ed8\u8ba4\u793a\u4f8b\u3002
#jdbc\njdbc:\n driver: \"com.mysql.cj.jdbc.Driver\"\n server:\n - addr: \"127.0.0.1:6001\"\n database:\n default: \"test\"\n paremeter:\n characterSetResults: \"utf8\"\n continueBatchOnError: \"false\"\n useServerPrepStmts: \"true\"\n alwaysSendSetIsolation: \"false\"\n useLocalSessionState: \"true\"\n zeroDateTimeBehavior: \"CONVERT_TO_NULL\"\n failoverReadOnly: \"false\"\n serverTimezone: \"Asia/Shanghai\"\n socketTimeout: 30000\n#users\nuser:\n name: \"root\"\n passwrod: \"111\"\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#3-mo-tester","title":"3. \u8fd0\u884c MO-Tester","text":"\u8fd0\u884c\u4ee5\u4e0b\u6240\u793a\u547d\u4ee4\u884c\uff0cSQL \u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\u5c06\u81ea\u52a8\u8fd0\u884c\uff0c\u5e76\u5c06\u62a5\u544a\u548c\u9519\u8bef\u6d88\u606f\u751f\u6210\u81f3 report/report.txt \u548c report/error.txt \u6587\u4ef6\u4e2d\u3002
> ./run.sh -p {path_name}/matrixone/test/cases\n
\u5982\u679c\u4f60\u60f3\u8c03\u6574\u6d4b\u8bd5\u8303\u56f4\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539 run.yml
\u6587\u4ef6\u4e2d\u7684 path
\u53c2\u6570\u3002\u6216\u8005\uff0c\u5728\u6267\u884c ./run.sh
\u547d\u4ee4\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e9b\u53c2\u6570\uff0c\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
path
\u7684\u914d\u7f6e\u53c2\u6570 -m \u8bbe\u7f6e MO-tester \u6d4b\u8bd5\u7684\u65b9\u6cd5\uff0c\u5373\u76f4\u63a5\u8fd0\u884c\u6216\u8005\u751f\u6210\u65b0\u7684\u6d4b\u8bd5\u7ed3\u679c\u3002\u9ed8\u8ba4\u503c\u53ef\u4ee5\u53c2\u89c1 run.yaml \u6587\u4ef6\u4e2d method
\u7684\u914d\u7f6e\u53c2\u6570 -t \u8bbe\u7f6e MO-tester \u6267\u884c SQL \u547d\u4ee4\u7684\u683c\u5f0f\u7c7b\u578b\u3002\u9ed8\u8ba4\u503c\u53ef\u4ee5\u53c2\u89c1 run.yml \u6587\u4ef6\u4e2d type
\u7684\u914d\u7f6e\u53c2\u6570\u3002 -r \u8bbe\u7f6e\u6d4b\u8bd5\u7528\u4f8b\u5e94\u8be5\u8fbe\u5230\u7684\u6210\u529f\u7387\u3002\u9ed8\u8ba4\u503c\u53ef\u4ee5\u53c2\u89c1 run.yml \u6587\u4ef6\u4e2d rate
\u7684\u914d\u7f6e\u53c2\u6570\u3002 -i \u8bbe\u7f6e\u5305\u542b\u5217\u8868\uff0c\u53ea\u6709\u8def\u5f84\u4e2d\u540d\u79f0\u5305\u542b\u5176\u4e2d\u4e00\u4e2a\u5217\u8868\u7684\u811a\u672c\u6587\u4ef6\u5c06\u88ab\u6267\u884c\uff0c\u5982\u679c\u6709\u591a\u4e2a\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a\uff0c\u7528'\uff0c'\u5206\u9694\uff0c\u6307\u7684\u662f\u5305\u542b\u7684\u6240\u6709\u60c5\u51b5 set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by ,
, if not specified, refers to all cases included -e \u8bbe\u7f6e\u6392\u9664\u5217\u8868\uff0c\u5982\u679c\u8def\u5f84\u4e0b\u7684\u811a\u672c\u6587\u4ef6\u7684\u540d\u79f0\u5305\u542b\u4e00\u4e2a\u6392\u9664\u5217\u8868\uff0c\u5219\u4e0d\u4f1a\u88ab\u6267\u884c\uff0c\u5982\u679c\u6709\u591a\u4e2a\uff0c\u7528','\u5206\u9694\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a\uff0c\u8868\u793a\u4e0d\u6392\u9664\u4efb\u4f55\u60c5\u51b5 set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by ,
, if not specified, refers to none of the cases excluded -g \u8868\u793a\u5e26\u6709[-- @bvt:issue#{issueNO.}]\u6807\u5fd7\u7684 SQL \u547d\u4ee4\u5c06\u4e0d\u4f1a\u88ab\u6267\u884c\uff0c\u8be5\u6807\u5fd7\u4ee5 [-- @bvt:issue#{issueNO.}]\u5f00\u59cb\uff0c\u4ee5 [-- @bvt:issue]\u7ed3\u675f\u3002\u4f8b\u5982\uff0c-- @bvt:issue#3236select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-10000:1\" HOUR_MINUTE);select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-100 1\" YEAR_MONTH);-- @bvt:issue\u8fd9\u4e24\u4e2a SQL \u547d\u4ee4\u4e0e\u95ee\u9898 #3236 \u76f8\u5173\u8054\uff0c\u5b83\u4eec\u5c06\u4e0d\u4f1a\u5728 MO-tester \u6d4b\u8bd5\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u95ee\u9898 #3236 \u4fee\u590d\u540e\u6807\u7b7e\u79fb\u9664\u624d\u53ef\u4ee5\u5728\u6d4b\u8bd5\u4e2d\u6267\u884c\u3002 -n \u8868\u793a\u5728\u6bd4\u8f83\u7ed3\u679c\u65f6\u5c06\u5ffd\u7565\u7ed3\u679c\u96c6\u7684\u5143\u6570\u636e -c \u53ea\u9700\u8981\u68c0\u67e5 case \u6587\u4ef6\u4e0e result \u6587\u4ef6\u662f\u5426\u5339\u914d \u793a\u4f8b\uff1a
./run.sh -p {path_name}/matrixone/test/cases -m run -t script -r 100 -i select,subquery -e substring -g\n
\u5982\u679c\u4f60\u60f3\u6d4b\u8bd5\u65b0\u7684 SQL \u7528\u4f8b\u5e76\u81ea\u52a8\u751f\u6210 SQL \u7ed3\u679c\uff0c\u8fd0\u884c\u547d\u4ee4\u4e2d\u53ef\u4ee5\u5c06 -m run
\u66f4\u6539\u4e3a -m genrs
\uff0c\u6216\u8005\u5c06 run.yml \u6587\u4ef6\u91cc\u7684 method
\u53c2\u6570\u4fee\u6539\u4e3a genrs
\uff0c\u4e14. result \u6587\u4ef6\u5c06\u751f\u6210\u5728\u4e0e\u8fd9\u4e2a\u65b0\u7684 SQL \u7528\u4f8b\u540c\u7ea7\u76ee\u5f55\u5185\uff0c\u76f8\u5173\u793a\u4f8b\u53c2\u89c1
\u793a\u4f8b 4
Note
\u6bcf\u6b21\u8fd0\u884c ./run.sh
\u90fd\u4f1a\u8986\u76d6 mo-tester \u4ed3\u5e93\u5185 report/ \u8def\u5f84\u4e0b error.txt\u3001report.txt \u548c success.txt \u62a5\u544a\u6587\u4ef6\u3002
\u6d4b\u8bd5\u5b8c\u6210\u540e\uff0cmo-tester \u4ed3\u5e93\u5185\u5c06\u751f\u6210 error.txt\u3001report.txt \u548c success.txt \u62a5\u544a\u6587\u4ef6\u3002
[SUMMARY] COST : 98s, TOTAL :12702, SUCCESS : 11851, FAILED :13, IGNORED :838, ABNORAML :0, SUCCESS RATE : 99%\n[{path_name}/matrixone/test/cases/auto_increment/auto_increment_columns.sql] COST : 2.159s, TOTAL :185, SUCCESS :163, FAILED :0, IGNORED :22, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/01_DDL/01_create_table.sql] COST : 0.226s, TOTAL :11, SUCCESS :11, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/02_LOAD/02_insert_customer.sql] COST : 0.357s, TOTAL :16, SUCCESS :16, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
\u62a5\u544a\u5173\u952e\u8bcd \u89e3\u91ca TOTAL \u6267\u884c\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570 SUCCESS \u6267\u884c\u6210\u529f\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570 FAILED \u6267\u884c\u5931\u8d25\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570 IGNORED \u5ffd\u7565\u6267\u884c\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570\uff0c\u7279\u6307\u5177\u6709 --bvt:issue
\u6807\u7b7e\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09 ABNORAML \u6267\u884c\u5f02\u5e38\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570\uff0c\u6bd4\u5982\u6267\u884c\u8fc7\u7a0b\u4e2d\u88ab\u7cfb\u7edf\u5f02\u5e38\u5bfc\u81f4 MO \u65e0\u6cd5\u5224\u65ad\u5b9e\u9645\u7ed3\u679c\uff0c\u6216\u8005 .result \u6587\u4ef6\u89e3\u6790\u5931\u8d25\u7b49 SUCCESS RATE \u6210\u529f\u7387\uff0c\u5373 SUCCESS/(TOTAL - IGNORED) [ERROR]\n[SCRIPT FILE]: cases/transaction/atomicity.sql\n[ROW NUMBER]: 14\n[SQL STATEMENT]: select * from test_11 ;\n[EXPECT RESULT]:\nc d\n1 1\n2 2\n[ACTUAL RESULT]:\nc d\n1 1\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#5","title":"5. \u6d4b\u8bd5\u793a\u4f8b","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#1_1","title":"\u793a\u4f8b 1","text":"\u793a\u4f8b\u63cf\u8ff0\uff1a\u8fd0\u884c matrixone \u4ed3\u5e93\u5185\u7684 test/cases \u8def\u5f84\u4e0b\u7684\u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\u3002
\u6b65\u9aa4\uff1a
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases\n
\u793a\u4f8b\u63cf\u8ff0\uff1a\u8fd0\u884c matrixone \u4ed3\u5e93\u5185 /cases/transaction/ \u8def\u5f84\u4e0b\u7684\u6d4b\u8bd5\u7528\u4f8b\u3002
\u6b65\u9aa4\uff1a
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/\n
[SUMMARY] COST : 5s, TOTAL :1362, SUCCESS : 1354, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.575s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit.test] COST : 0.175s, TOTAL :50, SUCCESS :50, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_1.sql] COST : 1.141s, TOTAL :296, SUCCESS :288, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_atomicity.sql] COST : 0.52s, TOTAL :75, SUCCESS :75, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation.sql] COST : 1.607s, TOTAL :215, SUCCESS :215, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation_1.sql] COST : 1.438s, TOTAL :241, SUCCESS :241, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation.sql] COST : 1.632s, TOTAL :202, SUCCESS :202, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation_1.sql] COST : 1.512s, TOTAL :217, SUCCESS :217, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#3","title":"\u793a\u4f8b 3","text":"\u793a\u4f8b\u63cf\u8ff0\uff1a\u8fd0\u884c matrixone \u4ed3\u5e93\u5185 cases/transaction/atomicity.sql \u5355\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u3002
\u6b65\u9aa4\uff1a
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/atomicity.sql\n
[SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#4_1","title":"\u793a\u4f8b 4","text":"\u793a\u4f8b\u63cf\u8ff0\uff1a
\u6b65\u9aa4
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\uff1a
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql -m genrs -g\n
run
\u4fee\u6539\u4e3a genrs
\uff0c\u7136\u540e\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u3002cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql\n
\u5728 matrixone \u4ed3\u5e93\u5185 test/cases/local_test/ \u8def\u5f84\u4e0b\u67e5\u770b new_test.result \u7ed3\u679c\u3002
\u5728 mo-tester \u4ed3\u5e93\u5185 report/ \u8def\u5f84\u4e0b\u7684 error.txt\u3001report.txt \u548c success.txt \u62a5\u544a\u6587\u4ef6\u4e2d\u67e5\u770b\u8fd0\u884c\u7ed3\u679c\u3002\u4f8b\u5982\uff0creport.txt \u4e2d\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
[SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#_1","title":"\u53c2\u8003\u6587\u6863","text":"\u66f4\u591a\u5173\u4e8e MO-Tester \u6d4b\u8bd5\u5de5\u5177\u7684\u6ce8\u89e3\u4ee5\u53ca\u6d4b\u8bd5\u7528\u4f8b\u7f16\u5199\u89c4\u8303\uff0c\u53c2\u89c1 MO-Tester \u89c4\u8303\u8981\u6c42\u3002
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/","title":"\u5e38\u7528\u7edf\u8ba1\u6570\u636e\u67e5\u8be2","text":"\u7edf\u8ba1\u6570\u636e\u662f\u6570\u636e\u5e93\u5728\u8fd0\u7ef4\u4f7f\u7528\u7684\u8fc7\u7a0b\u4e2d\u5468\u671f\u6027\u8fdb\u884c\u7684\u5e38\u7528\u67e5\u8be2\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6570\u636e\u5e93\u7528\u6237\u8f83\u4e3a\u76f4\u89c2\u51c6\u786e\u5730\u638c\u63e1\u5f53\u524d\u6570\u636e\u5e93\u7684\u72b6\u6001\u4ee5\u53ca\u5065\u5eb7\u7a0b\u5ea6\u3002
\u5728 MatrixOne \u4e2d\uff0c\u7edf\u8ba1\u6570\u636e\u5305\u542b\u4e86\u5982\u4e0b\u51e0\u65b9\u9762\u7684\u5185\u5bb9\uff1a
> select md.datname as database_name,md.created_time as created_time,mu.user_name as creator, mr.role_name as owner_role, count(mt.reldatabase) as total_tables\nfrom mo_catalog.mo_database md,mo_catalog.mo_role mr, mo_catalog.mo_user mu, mo_catalog.mo_tables mt\nwhere md.creator=mu.user_id and md.owner=mr.role_id and mt.reldatabase_id=md.dat_id\ngroup by mt.reldatabase,md.datname,md.created_time,mu.user_name,mr.role_name\norder by md.created_time asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_3","title":"\u67e5\u770b\u6240\u6709\u7684\u81ea\u589e\u5217\u76f8\u5173\u4fe1\u606f","text":"> select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_is_auto_increment=1\norder by att_database, att_relname asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_4","title":"\u67e5\u770b\u6240\u6709\u89c6\u56fe","text":"> select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='v' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_5","title":"\u67e5\u770b\u6240\u6709\u5916\u90e8\u8868","text":"> select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='e' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_6","title":"\u67e5\u770b\u6240\u6709\u8868\u7684\u4e3b\u952e","text":"> select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p' and att_relname not like '%!%'\norder by att_database, att_relname asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_7","title":"\u67e5\u770b\u6240\u6709\u6ca1\u6709\u4e3b\u952e\u7684\u8868","text":"> select distinct att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nminus\nselect att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p'\norder by database_name,table_name asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#24-sql-sys","title":"\u67e5\u770b\u8fc7\u53bb 24 \u5c0f\u65f6\u5185\u7684 sql \u7edf\u8ba1\uff08\u975e sys \u79df\u6237\u6682\u4e0d\u652f\u6301\uff09","text":"> select user,host,status,count(status) as count, date_sub(now(), interval 24 hour) as start_time, now() as end_time\nfrom system.statement_info\nwhere status in ('Success','Failed') and user <> 'internal'\nand request_at between date_sub(now(), interval 24 hour) and now()\ngroup by status,user,host\norder by user,status asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_8","title":"\u67e5\u770b\u6240\u6709\u89d2\u8272\u6388\u4e88\u7528\u6237\u4fe1\u606f","text":"> select mu.user_name as user_name,mr.role_name as role_name,mug.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr, mo_catalog.mo_user_grant mug\nwhere mu.user_id=mug.user_id and mr.role_id=mug.role_id\norder by mu.user_name,mr.role_name asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_9","title":"\u67e5\u770b\u6240\u6709\u89d2\u8272\u6743\u9650\u4fe1\u606f","text":"> select mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,md.datname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_database md\nwhere mrp.obj_id=md.dat_id and mrp.obj_type='database'\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,'*',with_grant_option\nfrom mo_catalog.mo_role_privs mrp\nwhere obj_id=0\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,mt.relname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_tables mt\nwhere mrp.obj_id=mt.rel_id and mrp.obj_type='table'\norder by 1,2 asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_10","title":"\u67e5\u770b\u6240\u6709\u89d2\u8272\u7ee7\u627f\u4fe1\u606f","text":"> select mr1.role_name as inheritor_role,mr2.role_name as inheritee_role,mu.user_name as operator_user,mrg.granted_time,mrg.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr1, mo_catalog.mo_role mr2,mo_catalog.mo_role_grant mrg\nwhere mu.user_id=mrg.operation_user_id and mr1.role_id=mrg.grantee_id and mr2.role_id=mrg.granted_id\norder by mr1.role_name,mr2.role_name asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_11","title":"\u53c2\u8003\u6587\u6863","text":"\u672c\u7bc7\u6587\u7ae0\u4e2d\u6240\u67e5\u8be2\u7684 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u662f MatrixOne \u5b58\u50a8\u7cfb\u7edf\u4fe1\u606f\u7684\u5730\u65b9\u3002\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u3002
"},{"location":"MatrixOne/Troubleshooting/error-code/","title":"\u9519\u8bef\u7801","text":"\u5728 MatrixOne \u4e2d\uff0c\u9519\u8bef\u4fe1\u606f\u662f\u6839\u636e\u9519\u8bef\u7f16\u7801\u8fdb\u884c\u5206\u7c7b\uff0c\u67d0\u4e00\u7c7b\u7684\u9519\u8bef\u7f16\u7801\u4f1a\u7edf\u4e00\u81f3\u4e00\u4e2a\u786e\u5b9a\u7684\u9519\u8bef\u7f16\u7801\u4e2d\uff0c\u4ee5\u4fbf\u4e8e\u7528\u6237\u8fdb\u884c\u6392\u67e5\u3002MatrixOne \u6570\u636e\u5e93\u670d\u52a1\u6240\u53d1\u51fa\u7684\u6240\u6709\u6d88\u606f\u90fd\u5206\u914d\u6709\u4e94\u4e2a\u5b57\u7b26\u7684\u9519\u8bef\u4ee3\u7801\uff0c\u65e2\u5305\u542b\u4e86\u9519\u8bef\u7f16\u7801\u7684\u79cd\u7c7b\uff0c\u53c8\u5305\u542b\u4e86\u9519\u8bef\u7f16\u7801\u7684\u5177\u4f53\u7c7b\u522b\u3002
\u5b9e\u9645\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f18\u5148\u67e5\u770b\u9519\u8bef\u7f16\u7801\uff0c\u642d\u914d\u9519\u8bef\u7f16\u7801\u9644\u5e26\u7684\u6587\u672c\u9519\u8bef\u6d88\u606f\uff0c\u6765\u786e\u5b9a\u53d1\u751f\u4e86\u54ea\u79cd\u9519\u8bef\u60c5\u51b5\u3002\u9519\u8bef\u7f16\u7801\u4e0d\u4f1a\u53d1\u751f\u8de8\u7248\u672c\u66f4\u6539\uff0c\u5e76\u4e14\u4e5f\u4e0d\u4f1a\u56e0\u9519\u8bef\u6d88\u606f\u7684\u672c\u5730\u5316\u800c\u53d1\u751f\u66f4\u6539\u3002
Note
MatrixOne \u751f\u6210\u7684\u4e00\u90e8\u5206\u9519\u8bef\u7f16\u7801\u662f\u7531 SQL \u6807\u51c6\u5b9a\u4e49\u7684\uff1b\u4e00\u4e9b\u672a\u88ab\u6807\u51c6\u5b9a\u4e49\u7684\u6761\u4ef6\u7684\u989d\u5916\u9519\u8bef\u7f16\u7801\u662f\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u4e2d\u53d1\u660e\u6216\u501f\u7528\u7684\u3002
\u9519\u8bef\u7f16\u7801\u5f00\u5934 \u7c7b\u578b 201 \u5185\u90e8\u9519\u8bef 202 \u6570\u5b57\u4e0e\u51fd\u6570\u9519\u8bef 203 \u65e0\u6548\u64cd\u4f5c 204 \u672a\u77e5\u9519\u8bef\u6216 IO \u9519\u8bef 205 RPC \u8d85\u65f6 206 \u4e8b\u52a1\u9519\u8bef\u6216\u5b58\u50a8\u5f15\u64ce\u9519\u8bef\u8be6\u7ec6\u9519\u8bef\u7801\u5bf9\u5e94\u7684\u9519\u8bef\u4fe1\u606f\u53ca\u9519\u8bef\u8be6\u60c5\u8bf7\u53c2\u89c1\u4e0b\u8868\uff1a
\u9519\u8bef\u7801 \u9519\u8bef\u4fe1\u606f \u9519\u8bef\u8be6\u60c5 \u9519\u8bef\u5206\u7c7b 20100 ErrStart internal error code start \u5185\u90e8\u9519\u8bef 20101 ErrInternal Internal error \u5185\u90e8\u9519\u8bef 20103 ErrNYI not yet implemented \u5185\u90e8\u9519\u8bef 20104 ErrOOM out of memory \u5185\u90e8\u9519\u8bef 20105 ErrQueryInterrupted query interrupted \u5185\u90e8\u9519\u8bef 20106 ErrNotSupported not supported \u5185\u90e8\u9519\u8bef 20200 ErrDivByZero division by zero \u6570\u5b57\u4e0e\u51fd\u6570 20201 ErrOutOfRange data out of range \u6570\u5b57\u4e0e\u51fd\u6570 20202 ErrDataTruncated data truncated \u6570\u5b57\u4e0e\u51fd\u6570 20203 ErrInvalidArg invalid argument \u6570\u5b57\u4e0e\u51fd\u6570 20204 ErrTruncatedWrongValueForField truncated wrong value for column \u6570\u5b57\u4e0e\u51fd\u6570 20300 ErrBadConfig invalid configuration \u65e0\u6548\u64cd\u4f5c 20301 ErrInvalidInput invalid input \u65e0\u6548\u64cd\u4f5c 20302 ErrSyntaxError SQL syntax error \u65e0\u6548\u64cd\u4f5c 20303 ErrParseError SQL parser error \u65e0\u6548\u64cd\u4f5c 20304 ErrConstraintViolation constraint violation \u65e0\u6548\u64cd\u4f5c 20305 ErrDuplicate tae data duplicated \u65e0\u6548\u64cd\u4f5c 20306 ErrRoleGrantedToSelf cannot grant role \u65e0\u6548\u64cd\u4f5c 20307 ErrDuplicateEntry duplicate entry for key \u65e0\u6548\u64cd\u4f5c 20400 ErrInvalidState invalid state \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20401 ErrLogServiceNotReady log service not ready \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20402 ErrBadDB invalid database \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20403 ErrNoSuchTable no such table \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20404 ErrEmptyVector empty vector \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20405 ErrFileNotFound file is not found \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20406 ErrFileAlreadyExists file alread exists \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20407 ErrUnexpectedEOF unexpteded end of file \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20408 ErrEmptyRange empty range of file \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20409 ErrSizeNotMatch file size does not match \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20410 ErrNoProgress file has no io progress \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20411 ErrInvalidPath invalid file path \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20412 ErrShortWrite file io short write \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20413 ErrInvalidWrite file io invalid write \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20414 ErrShortBuffer file io short buffer \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20415 ErrNoDB not connect to a database \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20416 ErrNoWorkingStore no working store \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20417 ErrNoHAKeeper cannot locate ha keeper \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20418 ErrInvalidTruncateLsn invalid truncate lsn, shard already truncated \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20419 ErrNotLeaseHolder not lease holder, current lease holder ID xxx \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20420 ErrDBAlreadyExists database already exists \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20421 ErrTableAlreadyExists table already exists \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20422 ErrNoService service not found \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20423 ErrDupServiceName duplicate service name \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20424 ErrWrongService wrong service, expecting A, got B \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20425 ErrBadS3Config bad s3 config \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20426 ErrBadView invalid view \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20427 ErrInvalidTask invalid task \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20428 ErrInvalidServiceIndex invalid service idx \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20429 ErrDragonboatTimeout Dragonboat timeout \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20430 ErrDragonboatTimeoutTooSmall Dragonboat timeout too small \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20431 ErrDragonboatInvalidDeadline Dragonboat invalid deadline \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20432 ErrDragonboatRejected Dragonboat rejected \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20433 ErrDragonboatInvalidPayloadSize invalid payload size \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20434 ErrDragonboatShardNotReady shard not ready \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20435 ErrDragonboatSystemClosed Dragonboat system closed \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20436 ErrDragonboatInvalidRange Dragonboat invalid range \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20437 ErrDragonboatShardNotFound shard not found \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20438 ErrDragonboatOtherSystemError other system error \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20439 ErrDropNonExistsDB Can't drop database ; database doesn't exist \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20500 ErrRPCTimeout rpc timeout RPC \u8d85\u65f6 20501 ErrClientClosed client closed RPC \u8d85\u65f6 20502 ErrBackendClosed backend closed RPC \u8d85\u65f6 20503 ErrStreamClosed stream closed RPC \u8d85\u65f6 20504 ErrNoAvailableBackend no available backend RPC \u8d85\u65f6 20600 ErrTxnClosed the transaction has been committed or aborted \u4e8b\u52a1 20601 ErrTxnWriteConflict transaction write conflict \u4e8b\u52a1 20602 ErrMissingTxn missing transaction \u4e8b\u52a1 20603 ErrUnresolvedConflict unresolved conflict \u4e8b\u52a1 20604 ErrTxnError transaction error \u4e8b\u52a1 20605 ErrDNShardNotFound TN shard not found \u4e8b\u52a1 20606 ErrShardNotReported TN shard not reported \u4e8b\u52a1 20607 ErrTAEError tae error TAE \u9519\u8bef 20608 ErrTAERead tae read error TAE \u9519\u8bef 20609 ErrRpcError rpc error TAE \u9519\u8bef 20610 ErrWaitTxn transaction wait error TAE \u9519\u8bef 20611 ErrTxnNotFound transaction not found TAE \u9519\u8bef 20612 ErrTxnNotActive transaction not active TAE \u9519\u8bef 20613 ErrTAEWrite tae write error TAE \u9519\u8bef 20614 ErrTAECommit tae commit error TAE \u9519\u8bef 20615 ErrTAERollback tae rollback error TAE \u9519\u8bef 20616 ErrTAEPrepare tae prepare error TAE \u9519\u8bef 20617 ErrTAEPossibleDuplicate tae possible duplicate TAE \u9519\u8bef 20618 ErrTxnRWConflict r-w conflict TAE \u9519\u8bef 20619 ErrTxnWWConflict w-w conflict TAE \u9519\u8bef 20620 ErrNotFound transaction not found TAE \u9519\u8bef 20621 ErrTxnInternal transaction internal error TAE \u9519\u8bef 20622 ErrTxnReadConflict transaction read conflict TAE \u9519\u8bef 20623 ErrPrimaryKeyDuplicated duplicated primary key TAE \u9519\u8bef 20624 ErrAppendableSegmentNotFound appendable segment not found TAE \u9519\u8bef 20625 ErrAppendableBlockNotFound appendable block not found TAE \u9519\u8bef 20626 ErrTAEDebug TAE debug TAE \u9519\u8bef"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/","title":"MatrixOne \u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f","text":"MatrixOne \u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f\u662f\u6307\u6570\u636e\u5e93\u901a\u8fc7\u91c7\u6837\u3001\u7edf\u8ba1\u51fa\u6765\u7684\u8868\u3001\u5217\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u4f8b\u5982\uff0c\u8868\u7684\u4e2a\u6570\u3001\u8868\u7684\u5217\u6570\u3001\u8868\u6240\u5360\u7684\u5b58\u50a8\u7a7a\u95f4\u7b49\u3002MatrixOne \u6570\u636e\u5e93\u5728\u751f\u6210\u6267\u884c\u8ba1\u5212\u65f6\uff0c\u9700\u8981\u6839\u636e\u7edf\u8ba1\u4fe1\u606f\u8fdb\u884c\u4f30\u7b97\uff0c\u8ba1\u7b97\u51fa\u6700\u4f18\u7684\u6267\u884c\u8ba1\u5212\u3002
MatrixOne \u6570\u636e\u5e93\u7684\u7edf\u8ba1\u4fe1\u606f\u7ef4\u5ea6\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_1","title":"\u67e5\u770b\u6570\u636e\u5e93\u4e0b\u8868\u7684\u4e2a\u6570","text":"\u901a\u8fc7\u8be5\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u6307\u5b9a\u6570\u636e\u5e93\u4e0b\u8868\u7684\u603b\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
SHOW TABLE_NUMBER FROM {DATABASE_NAME}\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_2","title":"\u793a\u4f8b","text":"mysql> show table_number from mo_catalog;\n+--------------------------------+\n| Number of tables in mo_catalog |\n+--------------------------------+\n| 11 |\n+--------------------------------+\n\n-- \u9a8c\u8bc1\u4e00\u4e0b\u662f\u54ea\u4e9b\u8868\nmysql> use mo_catalog;\nmysql> show tables;\n+----------------------------+\n| Tables_in_mo_catalog |\n+----------------------------+\n| mo_user |\n| mo_account |\n| mo_role |\n| mo_user_grant |\n| mo_role_grant |\n| mo_role_privs |\n| mo_user_defined_function |\n| mo_columns |\n| mo_mysql_compatbility_mode |\n| mo_tables |\n| mo_database |\n+----------------------------+\n11 rows in set (0.01 sec)\n
create database demo_1;\nuse demo_1;\n-- \u521b\u5efa\u4e09\u4e2a\u65b0\u7684\u8868\nCREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nCREATE TABLE t2(a bigint, b int);\nCREATE TABLE t3(a int, b varchar(10), c varchar(10));\n\n-- \u67e5\u8be2\u51fa\u6570\u636e\u5e93 demo_1 \u4e2d\u6709\u4e09\u4e2a\u8868\nmysql> show table_number from demo_1;\n+----------------------------+\n| Number of tables in demo_1 |\n+----------------------------+\n| 3 |\n+----------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_3","title":"\u67e5\u770b\u8868\u62e5\u6709\u7684\u5217\u6570","text":"\u901a\u8fc7\u8be5\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u6307\u5b9a\u8868\u7684\u603b\u5217\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
SHOW COLUMN_NUMBER FROM {[DATABASE_NAME.]TABLE_NAME}\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_4","title":"\u793a\u4f8b","text":"use mo_catalog;\nuse mo_user;\nmysql> show column_number from mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n| 11 |\n+------------------------------+\n\n-- \u6216\u8005\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\nmysql> show column_number from mo_catalog.mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n| 11 |\n+------------------------------+\n\n-- \u67e5\u770b\u9a8c\u8bc1\u6709\u54ea\u4e9b\u5217\nmysql> desc mo_catalog.mo_user;\n+-----------------------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-----------------------+--------------+------+------+---------+-------+---------+\n| user_id | INT | YES | | NULL | | |\n| user_host | VARCHAR(100) | YES | | NULL | | |\n| user_name | VARCHAR(300) | YES | | NULL | | |\n| authentication_string | VARCHAR(100) | YES | | NULL | | |\n| status | VARCHAR(8) | YES | | NULL | | |\n| created_time | TIMESTAMP | YES | | NULL | | |\n| expired_time | TIMESTAMP | YES | | NULL | | |\n| login_type | VARCHAR(16) | YES | | NULL | | |\n| creator | INT | YES | | NULL | | |\n| owner | INT | YES | | NULL | | |\n| default_role | INT | YES | | NULL | | |\n+-----------------------+--------------+------+------+---------+-------+---------+\n11 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_5","title":"\u67e5\u770b\u8868\u4e2d\u6240\u6709\u5217\u5305\u542b\u7684\u6700\u5927\u4e0e\u6700\u5c0f\u503c","text":"\u901a\u8fc7\u8be5\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u6307\u5b9a\u8868\u4e2d\u7684\u6bcf\u4e00\u5217\u7684\u6700\u5927\u503c\u4e0e\u6700\u5c0f\u503c\u3002
Note: \u5982\u679c\u6307\u5b9a\u8868\u4e2d\u5404\u5217\u503c\u7684\u6570\u636e\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0c\u5219\u6392\u5e8f\u89c4\u5219\u4e3a\uff1a\u6309\u7167\u6570\u5b57\u7684\u5927\u5c0f\u6392\u5e8f\uff1b\u65e5\u671f\u6309\u7167\u65f6\u95f4\u5148\u540e\u6392\u5e8f\uff1b\u5b57\u7b26\u7c7b\u6309\u7167 ASCII \u7801\u6392\u5e8f\uff1b\u5f53\u51e0\u79cd\u6570\u636e\u7c7b\u578b\u6df7\u5408\u6392\u5e8f\u65f6\uff0c\u975e\u5b57\u7b26\u7c7b\u578b\u7684\u5219\u5148\u8f6c\u6362\u4e3a\u5b57\u7b26\u7c7b\u578b\uff0c\u7136\u540e\u6309 ASCII \u7801\u6392\u5e8f\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
SHOW TABLE_VALUES FROM {[DATABASE_NAME.]TABLE_NAME}\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_6","title":"\u793a\u4f8b","text":"create table t1(\ncol1 int,\ncol2 float,\ncol3 varchar\n);\ninsert into t1 values(1,1.11,'1.111'),(2,2.22,'1.222'),(3,0,'abc');\n\nmysql> show table_values from t1;\n+-----------+-----------+-----------+-----------+-----------+-----------+\n| max(col1) | min(col1) | max(col2) | min(col2) | max(col3) | min(col3) |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n| 3 | 1 | 2.22 | 0 | abc | 1.111 |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_7","title":"\u67e5\u770b\u8868\u4e2d\u7684\u6570\u636e\u603b\u884c\u6570","text":"\u901a\u8fc7\u8c03\u7528\u8be5\u51fd\u6570\uff0c\u5373\u53ef\u83b7\u5f97\u6570\u636e\u5e93\u4e2d\u67d0\u5f20\u8868\u7684\u6570\u636e\u603b\u884c\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
MO_TABLE_ROWS({DATABASE_NAME},{TABLE_NAME})\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_8","title":"\u793a\u4f8b","text":"-- \u67e5\u8be2\u6570\u636e\u5e93 mo_catalog \u4e0b\u8868 mo_tables \u7684\u603b\u884c\u6570\nmysql> select mo_table_rows('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_rows(mo_catalog, mo_tables) |\n+--------------------------------------+\n| 64 |\n+--------------------------------------+\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_9","title":"\u67e5\u770b\u8868\u5728\u5b58\u50a8\u4e2d\u5360\u7528\u7684\u7a7a\u95f4","text":"\u901a\u8fc7\u8c03\u7528\u8be5\u51fd\u6570\uff0c\u5373\u53ef\u83b7\u5f97\u6570\u636e\u5e93\u4e2d\u67d0\u5f20\u8868\u5360\u7528\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5355\u4f4d\u662f\u5b57\u8282\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
MO_TABLE_SIZE({DATABASE_NAME},{TABLE_NAME})\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_10","title":"\u793a\u4f8b","text":"-- \u67e5\u8be2\u6570\u636e\u5e93 mo_catalog \u4e0b\u8868 mo_tables \u5360\u7528\u7684\u5b58\u50a8\u7a7a\u95f4\nmysql> select mo_table_size('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_size(mo_catalog, mo_tables) |\n+--------------------------------------+\n| 16128 |\n+--------------------------------------+\n
"},{"location":"MatrixOne/Troubleshooting/slow-queries/","title":"\u6162\u67e5\u8be2","text":"\u6162\u67e5\u8be2\uff0c\u5373\u5728\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u8fd0\u884c\u6bd4\u8f83\u6162\u7684 SQL \u8bed\u53e5\u3002\u6162\u67e5\u8be2\u8bb0\u5f55\u5728\u6162\u67e5\u8be2\u65e5\u5fd7\u4e2d\uff0c\u901a\u8fc7\u6162\u67e5\u8be2\u65e5\u5fd7\uff0c\u53ef\u4ee5\u67e5\u627e\u51fa\u54ea\u4e9b\u67e5\u8be2\u8bed\u53e5\u7684\u6267\u884c\u6548\u7387\u4f4e\uff0c\u4ee5\u4fbf\u8fdb\u884c\u4f18\u5316\u3002
\u5f53\u524d MatrixOne \u7684\u6162\u67e5\u8be2\u662f\u8d85\u8fc7 1000 \u6beb\u79d2\u7684\u67e5\u8be2\uff0c\u6682\u4e0d\u652f\u6301\u5b9a\u5411\u8f93\u51fa\u5230\u5bf9\u5e94\u7684\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u901a\u8fc7\u521b\u5efa\u89c6\u56fe\u7684\u65b9\u5f0f\u8fdb\u884c\u8fc7\u6ee4\u83b7\u53d6\u3002
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#_2","title":"\u5f00\u542f\u6162\u67e5\u8be2","text":"\u6162\u67e5\u8be2\u65e5\u5fd7\u9ed8\u8ba4\u5173\u95ed\uff0c\u8981\u4f7f\u7528\u6162\u67e5\u8be2\u65e5\u5fd7\u529f\u80fd\uff0c\u9996\u5148\u8981\u5f00\u542f\u6162\u67e5\u8be2\u65e5\u5fd7\u529f\u80fd\u3002
MatrixOne \u7684\u6162\u67e5\u8be2\u529f\u80fd\u63d0\u4f9b\u4e86\u5982\u4e0b\u51e0\u4e2a\u57fa\u7840\u4fe1\u606f\uff1a
statement
\uff1a\u5373 SQL \u6587\u672c\uff0c\u7528\u4e8e\u63d0\u4f9b\u5b8c\u6574\u7684 SQL \u8bed\u53e5\u3002request_at
\uff1aSQL \u8bed\u53e5\u7684\u7684\u8d77\u59cb\u65f6\u95f4\u3002duration_second
\uff1aSQL \u8bed\u53e5\u7684\u5b9e\u9645\u6267\u884c\u65f6\u95f4\u3002exec_plan
\uff1aSQL \u8bed\u53e5\u7684\u8be6\u7ec6\u6267\u884c\u8ba1\u5212\u3002\u6267\u884c\u5982\u4e0b\u5185\u5bb9\u7684\u811a\u672c\uff0c\u5f00\u542f\u6162\u67e5\u8be2\uff1a
drop database if exists mo_ts;\ncreate database mo_ts;\nuse mo_ts;\ncreate view slow_query as select statement,request_at,duration/1000000000 as duration_second from system.statement_info where statement like 'select%' and duration/1000000000>1 order by request_at desc;\ncreate view slow_query_with_plan as select statement,request_at,duration/1000000000 as duration_second,exec_plan from system.statement_info where statement like 'select%' and duration/1000000000>1 order by request_at desc;\n
\u5bf9\u4e8e\u6240\u6709\u8d85\u8fc7 1 \u79d2\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u6267\u884c\u5982\u4e0b\u8bed\u53e5\uff1a
mysql> select * from mo_ts.slow_query;\nmysql> select * from mo_ts.slow_query_with_plan;\n
\u8bed\u53e5\u89e3\u91ca
select * from mo_ts.slow_query;
\uff1a\u4e0d\u5e26\u6267\u884c\u8ba1\u5212\u3002
select * from mo_ts.slow_query_with_plan;
\uff1a\u5e26\u6267\u884c\u8ba1\u5212\u3002
\u5728\u5f00\u542f\u4e86\u6162\u67e5\u8be2\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u5f00\u542f\u9519\u8bef\u65e5\u5fd7\uff0c\u68c0\u67e5\u65e5\u5fd7\uff0c\u5b9a\u4f4d\u9519\u8bef\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#_4","title":"\u5f00\u542f\u9519\u8bef\u65e5\u5fd7","text":"\u6267\u884c\u5982\u4e0b\u5185\u5bb9\u811a\u672c\uff1a
create database mo_ts if not exists mo_ts;\nuse mo_ts;\ncreate view error_message as select timestamp,message from system.log_info where level in ('error','panic','faltal');\ncreate view error_sql as select si.request_at time_stamp,si.statement,si.error as SQL from system.statement_info si where si.user<>'internal' and si.status='Failed' ;\n
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#_5","title":"\u67e5\u8be2\u6570\u636e\u5e93\u670d\u52a1\u9519\u8bef","text":"\u67e5\u8be2\u6570\u636e\u5e93\u670d\u52a1\u9519\u8bef\uff0c\u6267\u884c\u5982\u4e0b SQL\uff1a
mysql> select * from mo_ts.error_message;\n
\u67e5\u8be2\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
+----------------------------+-------------------------------------------------------------------------+\n| timestamp | message |\n+----------------------------+-------------------------------------------------------------------------+\n| 2022-11-28 14:47:31.324762 | error: SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 14:47:31.324837 | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 14:47:31.324872 | query trace status |\n| 2022-11-28 14:40:06.579795 | read loop stopped |\n| 2022-11-28 14:40:06.585220 | gc inactive backends task stopped |\n| 2022-11-28 14:40:06.591082 | error: cannot locate ha keeper |\n| 2022-11-28 14:40:08.442515 | failed to propose initial cluster info |\n| 2022-11-28 14:40:08.442667 | failed to set initial cluster info |\n| 2022-11-28 14:40:09.411286 | error: timeout, converted to code 20429 |\n| 2022-11-28 14:40:09.411508 | read loop stopped |\n| 2022-11-28 14:40:09.416557 | gc inactive backends task stopped |\n| 2022-11-28 14:40:10.052585 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:10.052630 | failed to create init tasks |\n| 2022-11-28 14:40:11.053926 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:11.054059 | failed to create init tasks |\n| 2022-11-28 14:40:12.054578 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:12.054630 | failed to create init tasks |\n| 2022-11-28 14:40:13.055828 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:13.055896 | failed to create init tasks |\n| 2022-11-28 14:40:14.057102 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:14.057208 | failed to create init tasks |\n| 2022-11-28 14:40:15.058425 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:15.058563 | failed to create init tasks |\n| 2022-11-28 14:40:16.059867 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:16.060031 | failed to create init tasks |\n| 2022-11-28 14:40:16.443234 | read loop stopped |\n| 2022-11-28 14:40:16.443162 | read from backend failed |\n| 2022-11-28 14:40:16.448858 | gc inactive backends task stopped |\n| 2022-11-28 14:40:16.457276 | error: file tnservice/dd4dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 14:40:17.061260 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:17.061323 | failed to create init tasks |\n| 2022-11-28 14:40:18.062165 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:18.062249 | failed to create init tasks |\n| 2022-11-28 14:40:18.642097 | error: TN shard uuid , id 2 not reported |\n| 2022-11-28 14:40:19.062775 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:19.062937 | failed to create init tasks |\n| 2022-11-28 14:40:20.063237 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:20.063252 | failed to create init tasks |\n| 2022-11-28 14:40:21.064529 | failed to create init tasks |\n| 2022-11-28 14:40:21.064457 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:21.463193 | read loop stopped |\n| 2022-11-28 14:40:21.468423 | gc inactive backends task stopped |\n| 2022-11-28 14:40:21.474688 | error: file cnservice/dd1dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 15:24:56.210577 | error: SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:24:56.210773 | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:24:56.210898 | query trace status |\n| 2022-11-28 14:40:22.065723 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:22.065838 | failed to create init tasks |\n| 2022-11-28 14:40:22.478229 | error: invalid state no cn in the cluster |\n| 2022-11-28 14:40:22.478846 | failed to refresh task storage |\n| 2022-11-28 14:40:23.090160 | error: invalid database mo_task |\n| 2022-11-28 14:40:23.090274 | invalid database mo_task |\n| 2022-11-28 14:40:23.090604 | query trace status |\n| 2022-11-28 15:32:30.354364 | error: SQL parser error: table \"slow_query\" does not exist |\n| 2022-11-28 15:32:30.354485 | SQL parser error: table \"slow_query\" does not exist |\n| 2022-11-28 15:32:30.354605 | query trace status |\n| 2022-11-28 15:26:59.639892 | error: SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:26:59.640039 | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:26:59.640208 | query trace status |\n| 2022-11-28 15:37:29.289457 | error: table slow_query already exists |\n| 2022-11-28 15:37:29.289486 | table slow_query already exists |\n| 2022-11-28 15:37:29.289518 | query trace status |\n| 2022-11-28 15:37:45.773829 | error: table slow_query_with_plan already exists |\n| 2022-11-28 15:37:45.773856 | table slow_query_with_plan already exists |\n| 2022-11-28 15:37:45.773888 | query trace status |\n| 2022-11-28 14:45:48.821324 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:45:48.823261 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:45:48.823426 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:45:48.823525 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:47:14.513831 | error: SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:14.513929 | SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:14.513962 | query trace status |\n+----------------------------+-------------------------------------------------------------------------+\n72 rows in set (0.13 sec)\n
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#sql","title":"\u67e5\u8be2 SQL \u9519\u8bef","text":"\u67e5\u8be2 SQL \u9519\u8bef\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a
mysql> select * from mo_ts.error_sql;\n
\u67e5\u8be2\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| time_stamp | statement | sql |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| 2022-11-28 14:40:23.073188 | use mo_task | invalid database mo_task |\n| 2022-11-28 15:26:59.637130 | select * from mo_ts.error_sql | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:37:29.283683 | create view slow_query as select statement, request_at, duration / 1000000000 as duration_second from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc | table slow_query already exists |\n| 2022-11-28 15:37:45.765394 | create view slow_query_with_plan as select statement, request_at, duration / 1000000000 as duration_second, exec_plan from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc | table slow_query_with_plan already exists |\n| 2022-11-28 15:32:30.351695 | select * from mo_ts.slow_query | SQL parser error: table \"slow_query\" does not exist |\n| 2022-11-28 14:47:14.510060 | create view error_sql as select si.request_at as time_stamp, si.statement as sql, el.err_code from statement_info as si cross join error_info as el where si.statement_id = el.statement_id and user != \"internal\" | SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:31.323884 | select * from mo_ts.error_sql | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:24:56.208171 | select * from mo_ts.error_sql | SQL parser error: table \"error_sql\" does not exist |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n8 rows in set (0.14 sec)\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/","title":"C# \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 C# \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne
\u5df2\u5b89\u88c5. NET Core SDK
\u5df2\u5b89\u88c5 MySQL Client
\u4f7f\u7528 dotnet \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a myapp \u7684\u65b0\u5e94\u7528\uff1a
dotnet new console -o myapp\n
\u968f\u540e\u5207\u6362\u5230 myapp \u76ee\u5f55\u4e0b
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#mysql-connectornet-nuget","title":"\u6b65\u9aa4\u4e8c\uff1a\u6dfb\u52a0 MySQL Connector/NET NuGet \u5305","text":"\u4f7f\u7528 NuGet \u5305\u7ba1\u7406\u5668\u5b89\u88c5 MySql.Data \u5305\uff1a
dotnet add package MySql.Data\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#matrixone","title":"\u6b65\u9aa4\u4e09\uff1a\u8fde\u63a5 Matrixone \u8fdb\u884c\u64cd\u4f5c","text":"\u7f16\u5199\u4ee3\u7801\u8fde\u63a5 Matrixone\uff0c\u5efa\u7acb\u4e00\u4e2a\u5b66\u751f\u8868\u5e76\u8fdb\u884c\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u5728 Program.cs \u6587\u4ef6\u4e2d\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a
using System;\nusing MySql.Data.MySqlClient;\n\nclass Program\n{\n\n static void ExecuteSQL(MySqlConnection connection, string query)\n {\n using (MySqlCommand command = new MySqlCommand(query, connection))\n {\n command.ExecuteNonQuery();\n }\n }\n static void Main(string[] args)\n {\n Program n =new Program();\n string connectionString = \"server=127.0.0.1;user=root;database=test;port=6001;password=111\";\n using (MySqlConnection connection = new MySqlConnection(connectionString))\n {\n try{\n connection.Open();\n Console.WriteLine(\"\u5df2\u7ecf\u5efa\u7acb\u8fde\u63a5\");\n // \u5efa\u8868\n ExecuteSQL(connection,\"CREATE TABLE IF NOT EXISTS Student (id INT auto_increment PRIMARY KEY, name VARCHAR(255),age int,remark VARCHAR(255) )\");\n Console.WriteLine(\"\u5efa\u8868\u6210\u529f\uff01\");\n //\u63d2\u5165\u6570\u636e\n ExecuteSQL(connection,\"INSERT INTO Student(name,age) VALUES ('\u5f20\u4e09',22),('\u674e\u56db',25),('\u8d75\u4e94',30)\");\n Console.WriteLine(\"\u6210\u529f\u63d2\u5165\u6570\u636e\uff01\");\n //\u66f4\u65b0\u6570\u636e\n ExecuteSQL(connection,\"UPDATE Student SET remark = 'Updated' WHERE id = 1\");\n Console.WriteLine(\"\u6210\u529f\u66f4\u65b0\u6570\u636e\uff01\");\n //\u5220\u9664\u6570\u636e\n ExecuteSQL(connection,\"DELETE FROM Student WHERE id = 2\");\n Console.WriteLine(\"\u6210\u529f\u5220\u9664\u6570\u636e\uff01\");\n //\u67e5\u8be2\u6570\u636e\n MySqlCommand command = new MySqlCommand(\"SELECT * FROM Student\", connection);\n using (MySqlDataReader reader = command.ExecuteReader())\n {\n while (reader.Read())\n {\n Console.WriteLine($\"\u59d3\u540d: {reader[\"name\"]}, \u5e74\u9f84: {reader[\"age\"]},\u5907\u6ce8: {reader[\"remark\"]}\");\n }\n }\n Console.WriteLine(\"\u6570\u636e\u67e5\u8be2\u6210\u529f\uff01\");\n }\n catch (MySqlException ex)\n {\n Console.WriteLine(ex.Message);\n\n }\n finally\n {\n Console.WriteLine(\"\u51c6\u5907\u65ad\u5f00\u8fde\u63a5\");\n connection.Close();\n Console.WriteLine(\"\u65ad\u5f00\u8fde\u63a5\u6210\u529f\uff01\");\n }\n\n //connection.Close();\n }\n }\n}\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#_3","title":"\u6b65\u9aa4\u56db\uff1a\u8fd0\u884c\u7a0b\u5e8f","text":"\u5728\u7ec8\u7aef\u6267\u884c\u547d\u4ee4 dotnet run
\uff1a
(base) admin@admindeMacBook-Pro myapp % dotnet run \n\u5df2\u7ecf\u5efa\u7acb\u8fde\u63a5\n\u5efa\u8868\u6210\u529f\uff01\n\u6210\u529f\u63d2\u5165\u6570\u636e\uff01\n\u6210\u529f\u66f4\u65b0\u6570\u636e\uff01\n\u6210\u529f\u5220\u9664\u6570\u636e\uff01\n\u59d3\u540d: \u8d75\u4e94, \u5e74\u9f84: 30,\u5907\u6ce8: \n\u59d3\u540d: \u5f20\u4e09, \u5e74\u9f84: 22,\u5907\u6ce8: Updated\n\u6570\u636e\u67e5\u8be2\u6210\u529f\uff01\n\u51c6\u5907\u65ad\u5f00\u8fde\u63a5\n\u65ad\u5f00\u8fde\u63a5\u6210\u529f\uff01\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#_4","title":"\u6b65\u9aa4\u4e94\uff1a\u68c0\u67e5\u6570\u636e","text":"\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5 Matrixone \u5bf9 Student \u8868\u8fdb\u884c\u67e5\u8be2\uff1a
mysql> select * from student;\n+------+--------+------+---------+\n| id | name | age | remark |\n+------+--------+------+---------+\n| 3 | \u8d75\u4e94 | 30 | NULL |\n| 1 | \u5f20\u4e09 | 22 | Updated |\n+------+--------+------+---------+\n2 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6570\u636e\u8fd4\u56de\u6b63\u786e\u3002
"},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/","title":"Golang \u57fa\u7840\u793a\u4f8b","text":""},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/#_1","title":"\u914d\u7f6e\u73af\u5883","text":"\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Golang 1.18 \u7248\u672c\u53ca\u4ee5\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u786e\u8ba4\u4f60\u7684 Golang \u7248\u672c\uff1a
#To check with Golang installation and its version\ngo version\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
Go-MySQL-Driver
\u5de5\u5177\u3002\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a test \u7684\u65b0\u6570\u636e\u5e93\u3002
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a golang_crud_matrixone.go
\u7684\u7eaf\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u62f7\u8d1d\u81f3\u6587\u4ef6\u5185\uff1a
package main\n\nimport (\n \"database/sql\"\n \"fmt\"\n \"log\"\n _ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n //Open a new connection to MatrixOne\n db, err := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\")\n checkErr(err)\n\n //Create a table\n _, err2 := db.Exec(\"CREATE TABLE `userinfo` (`uid` INT(10) NOT NULL AUTO_INCREMENT,`username` VARCHAR(64) NULL DEFAULT NULL,`department` VARCHAR(64) NULL DEFAULT NULL,`created` DATETIME NULL DEFAULT NULL, PRIMARY KEY (`uid`));\")\n if err2 != nil {\n log.Fatal(err2)\n }\n fmt.Print(\"Successfully Created\\n\")\n\n // Insert a record\n stmt, err := db.Prepare(\"INSERT userinfo SET username=?,department=?,created=?\")\n checkErr(err)\n\n res, err := stmt.Exec(\"Alex\", \"r&d\", \"2023-01-01 12:00:00\")\n checkErr(err)\n\n id, err := res.LastInsertId()\n checkErr(err)\n\n fmt.Println(id)\n //Update a record\n stmt, err = db.Prepare(\"update userinfo set username=? where uid=?\")\n checkErr(err)\n\n res, err = stmt.Exec(\"Mark\", id)\n checkErr(err)\n\n affect, err := res.RowsAffected()\n checkErr(err)\n\n fmt.Println(affect)\n\n // Query all records\n rows, err := db.Query(\"SELECT * FROM userinfo\")\n checkErr(err)\n\n for rows.Next() {\n var uid int\n var username string\n var department string\n var created string\n err = rows.Scan(&uid, &username, &department, &created)\n checkErr(err)\n fmt.Println(uid)\n fmt.Println(username)\n fmt.Println(department)\n fmt.Println(created)\n }\n\n // Delete a record\n stmt, err = db.Prepare(\"delete from userinfo where uid=?\")\n checkErr(err)\n\n res, err = stmt.Exec(id)\n checkErr(err)\n\n affect, err = res.RowsAffected()\n checkErr(err)\n\n fmt.Println(affect)\n\n db.Close()\n\n}\n\nfunc checkErr(err error) {\n if err != nil {\n panic(err)\n }\n}\n
\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff0c\u6267\u884c\u6b64 Golang \u6587\u4ef6\u3002
> go run golang_crud_matrixone.go\nSuccessfully Created\n1\n1\n1\nMark\nr&d\n2023-01-01\n1\n
Note
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u7684\u6f14\u793a\u7a0b\u5e8f\u7684\u6e90\u4ee3\u7801\u4e0b\u8f7d\u5730\u5740\u4e3a\uff1aJava CRUD \u793a\u4f8b\u3002
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#_1","title":"\u914d\u7f6e\u73af\u5883","text":"\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u4ee5\u4e0b\u8f6f\u4ef6\u3002
mysql> create database test;\n
Note
\u6211\u4eec\u4f7f\u7528 IDEA \u4f5c\u4e3a\u4e00\u4e2a IDE \u793a\u4f8b\u6765\u6f14\u793a\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u4f60\u53ef\u4ee5\u81ea\u7531\u5730\u9009\u62e9 Eclipse \u6216\u5176\u4ed6 IDE \u5de5\u5177\u5b9e\u8df5\u3002
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#java_1","title":"\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684 Java \u9879\u76ee","text":"\u542f\u52a8 IDEA\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Java \u9879\u76ee\uff0c\u5982\u4e0b\u6240\u793a\uff1a
\u8fdb\u5165\u83dc\u5355 Project Setting > Libraries\uff0c\u5bfc\u5165 mysql-connector-java-8.0.30.jar \u6587\u4ef6\u3002
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#java-matrixone","title":"\u7f16\u5199 Java \u4ee3\u7801\u8fde\u63a5 MatrixOne","text":"\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a JDBCUtils \u7684 Java \u7c7b\u4f5c\u4e3a\u8fde\u63a5\u5b9e\u7528\u7a0b\u5e8f\u3002\u8fd9\u4e2a\u7c7b\u5c06\u4f5c\u4e3a\u8fde\u63a5 MatrixOne \u548c\u6267\u884c SQL \u67e5\u8be2\u7684\u5de5\u5177\u3002
\u5728 src \u76ee\u5f55\u4e0b\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a JDBCUtils.java
\u7684\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u7f16\u8f91\u8be5\u6587\u4ef6\uff1a
import java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\npublic class JDBCUtils {\n private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n private static String jdbcUsername = \"root\";\n private static String jdbcPassword = \"111\";\n\n public static Connection getConnection() {\n Connection connection = null;\n try {\n connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n } catch (SQLException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n return connection;\n }\n\n public static void printSQLException(SQLException ex) {\n for (Throwable e : ex) {\n if (e instanceof SQLException) {\n e.printStackTrace(System.err);\n System.err.println(\"SQLState: \" + ((SQLException) e).getSQLState());\n System.err.println(\"Error Code: \" + ((SQLException) e).getErrorCode());\n System.err.println(\"Message: \" + e.getMessage());\n Throwable t = ex.getCause();\n while (t != null) {\n System.out.println(\"Cause: \" + t);\n t = t.getCause();\n }\n }\n }\n }\n}\n
\u5176\u6b21\uff0c\u6211\u4eec\u7528 MatrixOne \u7f16\u5199\u521b\u5efa\u3001\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u7684\u793a\u4f8b\u4ee3\u7801\u3002
\u6211\u4eec\u9700\u8981\u5728 src \u76ee\u5f55\u4e0b\u521b\u5efa\u76f8\u5e94\u7684 java \u6e90\u4ee3\u7801\u6587\u4ef6\uff1aCreate.java
\u3001Insert.java
\u3001Update.java
\u3001Select.java
\uff0c\u5e76\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u5bf9\u5e94\u653e\u5728\u8fd9\u4e9b\u6587\u4ef6\u4e2d\u3002
Create.java
)","text":"import java.sql.Connection;\nimport java.sql.SQLException;\nimport java.sql.Statement;\n\npublic class Create {\n private static final String createTableSQL = \"create table student (\\r\\n\" + \" id int primary key,\\r\\n\" +\n \" name varchar(20),\\r\\n\" + \" email varchar(20),\\r\\n\" + \" country varchar(20),\\r\\n\" +\n \" age int\\r\\n\" + \" );\";\n\n public static void main(String[] argv) throws SQLException {\n Create createTable = new Create();\n createTable.createTable();\n }\n\n public void createTable() throws SQLException {\n\n System.out.println(createTableSQL);\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n // Step 2:Create a statement using connection object\n Statement statement = connection.createStatement();) {\n\n // Step 3: Execute the query or update query\n statement.execute(createTableSQL);\n } catch (SQLException e) {\n\n // print SQL exception information\n JDBCUtils.printSQLException(e);\n }\n\n // Step 4: try-with-resource statement will auto close the connection.\n }\n}\n
\u6267\u884c\u4e0a\u8ff0\u4ee3\u7801\u4f1a\u5728 test
\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u8868\uff0c\u7136\u540e\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\u9a8c\u8bc1\u662f\u5426\u521b\u5efa\u4e86\u8868\u3002
mysql> show create table student;\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| student | CREATE TABLE `student` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(20) DEFAULT NULL,\n`email` VARCHAR(20) DEFAULT NULL,\n`country` VARCHAR(20) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#insertjava","title":"\u63d2\u5165\uff08Insert.java
\uff09","text":"import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Insert {\n private static final String INSERT_STUDENT_SQL = \"INSERT INTO student\" +\n \" (id, name, email, country, age) VALUES \" +\n \" (?, ?, ?, ?, ?);\";\n\n public static void main(String[] argv) throws SQLException {\n Insert insertTable = new Insert();\n insertTable.insertRecord();\n }\n\n public void insertRecord() throws SQLException {\n System.out.println(INSERT_STUDENT_SQL);\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n // Step 2:Create a statement using connection object\n PreparedStatement preparedStatement = connection.prepareStatement(INSERT_STUDENT_SQL)) {\n preparedStatement.setInt(1, 1);\n preparedStatement.setString(2, \"Tony\");\n preparedStatement.setString(3, \"tony@gmail.com\");\n preparedStatement.setString(4, \"US\");\n preparedStatement.setString(5, \"20\");\n\n System.out.println(preparedStatement);\n // Step 3: Execute the query or update query\n preparedStatement.executeUpdate();\n } catch (SQLException e) {\n\n // print SQL exception information\n JDBCUtils.printSQLException(e);\n }\n\n // Step 4: try-with-resource statement will auto close the connection.\n }\n\n}\n
\u6267\u884c\u7ed3\u679c\uff1a
mysql> select * from student;\n+------+------+----------------+---------+------+\n| id | name | email | country | age |\n+------+------+----------------+---------+------+\n| 1 | Tony | tony@gmail.com | US | 20 |\n+------+------+----------------+---------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#updatejava","title":"\u66f4\u65b0\uff08Update.java
\uff09","text":"import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Update {\n private static final String UPDATE_STUDENT_SQL = \"update student set name = ? where id = ?;\";\n\n public static void main(String[] argv) throws SQLException {\n Update updateTable = new Update();\n updateTable.updateRecord();\n }\n\n public void updateRecord() throws SQLException {\n System.out.println(UPDATE_STUDENT_SQL);\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n // Step 2:Create a statement using connection object\n PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_STUDENT_SQL)) {\n preparedStatement.setString(1, \"Ram\");\n preparedStatement.setInt(2, 1);\n\n // Step 3: Execute the query or update query\n preparedStatement.executeUpdate();\n } catch (SQLException e) {\n\n // print SQL exception information\n JDBCUtils.printSQLException(e);\n }\n\n // Step 4: try-with-resource statement will auto close the connection.\n }\n}\n
\u8fd0\u884c\u7ed3\u679c\uff1a
mysql> select * from student;\n+------+------+----------------+---------+------+\n| id | name | email | country | age |\n+------+------+----------------+---------+------+\n| 1 | Ram | tony@gmail.com | US | 20 |\n+------+------+----------------+---------+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#selectjava","title":"\u67e5\u8be2\uff08Select.java
\uff09","text":"import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\npublic class Select {\n private static final String QUERY = \"select id,name,email,country,age from student where id =?\";\n\n public static void main(String[] args) {\n\n // using try-with-resources to avoid closing resources (boiler plate code)\n\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n\n // Step 2:Create a statement using connection object\n PreparedStatement preparedStatement = connection.prepareStatement(QUERY);) {\n preparedStatement.setInt(1, 1);\n System.out.println(preparedStatement);\n // Step 3: Execute the query or update query\n ResultSet rs = preparedStatement.executeQuery();\n\n // Step 4: Process the ResultSet object.\n while (rs.next()) {\n int id = rs.getInt(\"id\");\n String name = rs.getString(\"name\");\n String email = rs.getString(\"email\");\n String country = rs.getString(\"country\");\n String password = rs.getString(\"age\");\n System.out.println(id + \",\" + name + \",\" + email + \",\" + country + \",\" + password);\n }\n } catch (SQLException e) {\n JDBCUtils.printSQLException(e);\n }\n // Step 4: try-with-resource statement will auto close the connection.\n }\n}\n
\u8fd0\u884c\u7ed3\u679c\uff1a
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/","title":"Python \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 Python \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_2","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus)\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
```\n#To check with Python installation and its version\npython3 -V\n```\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u548c cryptography
\u5de5\u5177\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u548c cryptography
\u5de5\u5177\uff1a
```\npip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n```\n
\u4f60\u53ef\u4ee5\u53c2\u8003 Python \u8fde\u63a5 MatrixOne \u670d\u52a1\u4e86\u89e3\u5982\u4f55\u901a\u8fc7 pymysql
\u8fde\u63a5\u5230 MatrixOne\uff0c\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664)\u3002
\u65b0\u5efa\u4e00\u4e2a create.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"CREATE TABLE cars (id INT NOT NULL AUTO_INCREMENT, car_model VARCHAR(45) NULL,car_brand VARCHAR(45) NULL,PRIMARY KEY (`id`))\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n print(\"Table created\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u3002\u8fd9\u5c06\u5728 MatrixOne \u4e2d\u7684\u6570 \u200b\u200b \u636e\u5e93 test \u5185\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a cars \u8868\u3002
> python3 create.py\nTable created\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u521b\u5efa\u6210\u529f\uff1a
mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| cars |\n+----------------+\n1 row in set (0.03 sec)\nmysql> show create table cars;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| cars | CREATE TABLE `cars` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`car_model` VARCHAR(45) DEFAULT NULL,\n`car_brand` VARCHAR(45) DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_4","title":"\u63d2\u5165\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a insert.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"INSERT INTO cars(car_model, car_brand) VALUES ('accord', 'honda')\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(\"Record Added\")\n else:\n print(sql_exec)\n print(\"Not Added\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\u4f1a\u5728 cars \u8868\u4e2d\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a
> python3 insert.py\n1\nRecord Added\n
\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u9a8c\u8bc1\u8fd9\u6761\u8bb0\u5f55\u662f\u5426\u63d2\u5165\u6210\u529f\uff1a
mysql> select * from cars;\n+------+-----------+-----------+\n| id | car_model | car_brand |\n+------+-----------+-----------+\n| 1 | accord | honda |\n+------+-----------+-----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_5","title":"\u67e5\u8be2\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a read.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"SELECT * FROM cars\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(cursor.fetchall())\n else:\n print(sql_exec)\n print(\"No Record\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\u67e5\u8be2\u5e76\u8fd4\u56de cars \u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff1a
> python3 read.py\n1\n[{'id': 1, 'car_model': 'accord', 'car_brand': 'honda'}]\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_6","title":"\u66f4\u65b0\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a update.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"UPDATE cars SET car_model = 'explorer', car_brand = 'ford' WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(\"Record Updated\")\n else:\n print(sql_exec)\n print(\"Not Updated\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u4ee3\u7801\u66f4\u65b0 id \u4e3a\u201c1\u201d\u7684\u8bb0\u5f55\uff1a
> python3 update.py\n1\nRecord Updated\n
\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u9a8c\u8bc1\u8fd9\u6761\u8bb0\u5f55\u662f\u5426\u66f4\u65b0\u6210\u529f\uff1a
mysql> select * from cars;\n+------+-----------+-----------+\n| id | car_model | car_brand |\n+------+-----------+-----------+\n| 1 | explorer | ford |\n+------+-----------+-----------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_7","title":"\u5220\u9664\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a delete.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"DELETE FROM cars WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(\"Record Deleted\")\n else:\n print(sql_exec)\n print(\"Not Deleted\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u4ee3\u7801\u5220\u9664 id \u4e3a\u201c1\u201d\u7684\u8bb0\u5f55\uff1a
> python3 delete.py\n1\nRecord Deleted\n
\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u9a8c\u8bc1\u8fd9\u6761\u8bb0\u5f55\u662f\u5426\u5220\u9664\u6210\u529f\uff1a
mysql> select * from cars;\nEmpty set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/","title":"Django \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 Django \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
Django \u662f\u4e00\u4e2a\u7531 Python \u7f16\u5199\u7684\u4e00\u4e2a\u5f00\u653e\u6e90\u4ee3\u7801\u7684 Web \u5e94\u7528\u6846\u67b6\u3002
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u76f8\u5173\u8f6f\u4ef6\u7684\u7b80\u5355\u4ecb\u7ecd\uff1a
\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -V\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Django\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Django \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -m django --version\n
pymysql
\u5de5\u5177\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\uff1apip3 install pymysql\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_3","title":"\u73af\u5883\u914d\u7f6e","text":"\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a test \u7684\u65b0\u6570\u636e\u5e93\u3002
mysql> create database test;\n
\u521b\u5efa\u9879\u76ee django_crud_matrixone
\u3002
django-admin startproject django_crud_matrixone\n
\u521b\u5efa\u5b8c\u6210\u540e\u6211\u4eec\u53ef\u4ee5\u67e5\u770b\u4e0b\u9879\u76ee\u7684\u76ee\u5f55\u7ed3\u6784\uff1a
cd django_crud_matrixone/\n\ndjango_crud_matrixone/\n\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 asgi.py\n\u2514\u2500\u2500 settings.py\n\u2514\u2500\u2500 urls.py\n\u2514\u2500\u2500 wsgi.py\nmanage.py\n
\u63a5\u4e0b\u6765\u6211\u4eec\u8fdb\u5165 django_crud_matrixone \u76ee\u5f55\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8\u670d\u52a1\u5668\uff1a
python3 manage.py runserver 0.0.0.0:8000\n
0.0.0.0 \u8ba9\u5176\u5b83\u7535\u8111\u53ef\u8fde\u63a5\u5230\u5f00\u53d1\u670d\u52a1\u5668\uff0c8000 \u4e3a\u7aef\u53e3\u53f7\u3002\u5982\u679c\u4e0d\u8bf4\u660e\uff0c\u90a3\u4e48\u7aef\u53e3\u53f7\u9ed8\u8ba4\u4e3a 8000\u3002
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
\u6211\u4eec\u5728\u9879\u76ee\u7684 settings.py \u6587\u4ef6\u4e2d\u627e\u5230 DATABASES \u914d\u7f6e\u9879\uff0c\u5c06\u5176\u4fe1\u606f\u4fee\u6539\u4e3a\uff1a
DATABASES = { \n 'default': \n { \n 'ENGINE': 'django.db.backends.mysql', # \u6570\u636e\u5e93\u5f15\u64ce\n 'NAME': 'test', # \u6570\u636e\u5e93\u540d\u79f0\n 'HOST': '127.0.0.1', # \u6570\u636e\u5e93\u5730\u5740\uff0c\u672c\u673a ip \u5730\u5740 127.0.0.1 \n 'PORT': 6001, # \u7aef\u53e3 \n 'USER': 'root', # \u6570\u636e\u5e93\u7528\u6237\u540d\n 'PASSWORD': '111', # \u6570\u636e\u5e93\u5bc6\u7801\n } \n}\n
\u63a5\u4e0b\u6765\uff0c\u544a\u8bc9 Django \u4f7f\u7528 pymysql \u6a21\u5757\u8fde\u63a5 mysql \u6570\u636e\u5e93\uff0c\u5728\u4e0e settings.py \u540c\u7ea7\u76ee\u5f55\u4e0b\u7684 init. py \u4e2d\u5f15\u5165\u6a21\u5757\u548c\u8fdb\u884c\u914d\u7f6e\uff1a
import pymysql\npymysql.install_as_MySQLdb()\n
\u521b\u5efa app\uff0cDjango \u89c4\u5b9a\uff0c\u5982\u679c\u8981\u4f7f\u7528\u6a21\u578b\uff0c\u5fc5\u987b\u8981\u521b\u5efa\u4e00\u4e2a app\u3002\u6211\u4eec\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a TestModel \u7684 app:
django-admin startapp TestModel\n
\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a
django_crud_matrixone/\n\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 asgi.py\n...\nTestModel\n\u2514\u2500\u2500 migrations\n\u2514\u2500\u2500 __init__.py\n\u2514\u2500\u2500 admin.py\n\u2514\u2500\u2500 apps.py\n\u2514\u2500\u2500 models.py\n\u2514\u2500\u2500 tests.py\n\u2514\u2500\u2500 views.py\n
\u63a5\u4e0b\u6765\u5728 settings.py \u4e2d\u627e\u5230 INSTALLED_APPS \u8fd9\u4e00\u9879\uff0c\u5982\u4e0b\uff1a
INSTALLED_APPS = [\n\"django.contrib.admin\",\n\"django.contrib.auth\",\n\"django.contrib.contenttypes\",\n\"django.contrib.sessions\",\n\"django.contrib.messages\",\n\"django.contrib.staticfiles\",\n\"TestModel\", #\u6dfb\u52a0\u6b64\u9879 \n]\n
from django.db import models\nclass Book(models.Model): \nid = models.AutoField(primary_key=True) # id \u4f1a\u81ea\u52a8\u521b\u5efa\uff0c\u53ef\u4ee5\u624b\u52a8\u5199\u5165\ntitle = models.CharField(max_length=32) # \u4e66\u7c4d\u540d\u79f0\nprice = models.DecimalField(max_digits=5, decimal_places=2) # \u4e66\u7c4d\u4ef7\u683c \npublish = models.CharField(max_length=32) # \u51fa\u7248\u793e\u540d\u79f0 \npub_date = models.DateField() # \u51fa\u7248\u65f6\u95f4\n
Django \u6a21\u578b\u4f7f\u7528\u81ea\u5e26\u7684 ORM\u3002\u4ee5\u4e0a\u7684\u7c7b\u540d\u4ee3\u8868\u4e86\u6570\u636e\u5e93\u8868\u540d\uff08testmodel_book)\uff0c\u4e14\u7ee7\u627f\u4e86 models.Model\uff0c\u7c7b\u91cc\u9762\u7684\u5b57\u6bb5\u4ee3\u8868\u6570\u636e\u8868\u4e2d\u7684\u5b57\u6bb5\uff0c\u6570\u636e\u7c7b\u578b\uff1aAutoField\uff08\u76f8\u5f53\u4e8e int\uff09\u3001CharField\uff08\u76f8\u5f53\u4e8e varchar\uff09\u3001DecimalField (\u76f8\u5f53\u4e8e decimal)\u3001DateField\uff08\u76f8\u5f53\u4e8e date\uff09\uff0cmax_length \u53c2\u6570\u9650\u5b9a\u957f\u5ea6\u3002
ORM \u5bf9\u5e94\u5173\u7cfb\u8868\uff1a
\u6709\u5173\u66f4\u591a\u6a21\u578b\u5b57\u6bb5\u7c7b\u578b\u8bf7\u53c2\u8003\uff1ahttps://docs.djangoproject.com/en/5.0/ref/models/fields/\u3002
python3 manage.py makemigrations TestModel # \u751f\u6210\u914d\u7f6e\u6587\u4ef6\u5e76\u653e\u5230app\u4e0b\u9762\u7684migrations\u76ee\u5f55\npython3 manage.py migrate TestModel # \u6839\u636e\u914d\u7f6e\u6587\u4ef6\u81ea\u52a8\u751f\u6210\u76f8\u5e94\u7684SQL\u8bed\u53e5\n
\u8fdb\u5165\u5230 test \u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230 testmodel_book \u8868\u5df2\u751f\u6210\u3002\u5176\u4e2d django_migrations \u8868\u4e2d\u751f\u6210\u6267\u884c\u8fc7\u7684\u64cd\u4f5c\u7684\u8bb0\u5f55\u3002
mysql> show tables;\n+-------------------+\n| Tables_in_test |\n+-------------------+\n| django_migrations |\n| testmodel_book |\n+-------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_5","title":"\u63d2\u5165\u6570\u636e","text":"from django.shortcuts import render,HttpResponse\nfrom TestModel import models \ndef add_book(request):\n books = models.Book.objects.create(title=\"\u767d\u591c\u884c\",price=39.50,publish=\"\u5357\u6d77\u51fa\u7248\u516c\u53f8\",pub_date=\"2010-10-10\") \n return HttpResponse(\"<p>\u6570\u636e\u6dfb\u52a0\u6210\u529f\uff01</p>\")\n
from django.contrib import admin\nfrom django.urls import path\nfrom . import views\n\nurlpatterns = [\n path('', views.add_book),\n ]\n
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from testmodel_book;\n+------+-----------+-------+--------------------+------------+\n| id | title | price | publish | pub_date |\n+------+-----------+-------+--------------------+------------+\n| 1 | \u767d\u591c\u884c | 39.50 | \u5357\u6d77\u51fa\u7248\u516c\u53f8 | 2010-10-10 |\n+------+-----------+-------+--------------------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_6","title":"\u67e5\u8be2\u6570\u636e","text":"def src_book(request):\n books = models.Book.objects.all()#\u4f7f\u7528 all() \u65b9\u6cd5\u6765\u67e5\u8be2\u6240\u6709\u5185\u5bb9\n for i in books:\n print(i.id,i.title,i.price,i.publish,i.pub_date)\n return HttpResponse(\"<p>\u67e5\u627e\u6210\u529f\uff01</p>\") \n
\u6709\u5173\u67e5\u8be2\u76f8\u5173\u7684\u66f4\u591a\u65b9\u6cd5\uff0c\u8bf7\u53c2\u8003\uff1ahttps://docs.djangoproject.com/en/5.0/ref/models/querysets/
\u4fee\u6539 urls.py \u6587\u4ef6\uff1a
urlpatterns = [\npath('', views.src_book),\n]\n
\u63a5\u4e0b\u6765\u6211\u4eec\u8fdb\u5165 django_crud_matrixone \u76ee\u5f55\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8\u670d\u52a1\u5668\uff1a
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
\u547d\u4ee4\u884c\u7ed3\u679c\u4e3a\uff1a
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_7","title":"\u66f4\u65b0\u6570\u636e","text":".update()
\uff0c\u4ee5\u4e0b\u4f8b\u5b50\u4e3a id \u503c\u4e3a 1 \u7684\u8bb0\u5f55\u7684 price \u503c\u66f4\u65b0\u4e3a 50\u3002\u4fee\u6539 django_crud_matrixone \u76ee\u5f55\u4e0b\u7684 views.py \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee3\u7801\uff1adef upd_book(request):\n books = models.Book.objects.filter(pk=1).update(price=50)\n return HttpResponse(\"<p>\u66f4\u65b0\u6210\u529f\uff01</p>\")\n
pk=1 \u7684\u610f\u601d\u662f\u4e3b\u952e primary key=1\uff0c\u76f8\u5f53\u4e8e id=1\u3002
urlpatterns = [\npath('', views.upd_book),\n]\n
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from testmodel_book;\n+------+-----------+-------+--------------------+------------+\n| id | title | price | publish | pub_date |\n+------+-----------+-------+--------------------+------------+\n| 1 | \u767d\u591c\u884c | 50.00 | \u5357\u6d77\u51fa\u7248\u516c\u53f8 | 2010-10-10 |\n+------+-----------+-------+--------------------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_8","title":"\u5220\u9664\u6570\u636e","text":".delete()
\uff0c\u4ee5\u4e0b\u4f8b\u5b50\u4e3a\u5220\u9664 price \u4e3a 50 \u7684\u8bb0\u5f55\u3002\u4fee\u6539 django_crud_matrixone \u76ee\u5f55\u4e0b\u7684 views.py \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee3\u7801\uff1adef del_book(request):\n books=models.Book.objects.filter(price=50).delete()\n return HttpResponse(\"<p>\u5220\u9664\u6210\u529f\uff01</p>\")\n
urlpatterns = [\npath('', views.del_book),\n]\n
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
sql mysql> select * from testmodel_book; Empty set (0.00 sec)
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 golang \u548c gorm \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
Gorm \u662f Golang \u8bed\u8a00\u4e2d\u6700\u6d41\u884c\u7684 ORM \u5de5\u5177\u4e4b\u4e00\u3002
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u76f8\u5173\u8f6f\u4ef6\u7684\u7b80\u5355\u4ecb\u7ecd\uff1a
gorm.io/gorm
\u548c gorm.io/driver/mysql
\u8fd9\u4e24\u4e2a\u5e93\u6765\u8ba9 Go \u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\u5e76\u5b8c\u6210 CRUD \u64cd\u4f5c\u3002\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
mysql> create database test;\n
#To check with Golang installation and its version\ngo version\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u786e\u8ba4\u4f60\u5df2\u7ecf\u5b89\u88c5 gorm.io/gorm
\u4ee5\u53ca gorm.io/driver/mysql
\uff0c\u4f7f\u7528 go get
\u547d\u4ee4\u5b89\u88c5\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a
go get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n
\u4f60\u53ef\u4ee5\u53c2\u8003 Golang \u8fde\u63a5 MatrixOne \u670d\u52a1\u4e86\u89e3\u5982\u4f55\u901a\u8fc7 Gorm
\u8fde\u63a5\u5230 MatrixOne\uff0c\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u3002
\u4f5c\u4e3a\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668\uff08ORM\uff09\u5de5\u5177\uff0cGorm
\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u521b\u5efa GO \u7c7b\u6765\u6620\u5c04\u5173\u7cfb\u6570\u636e\u5e93\u4e2d\u7684\u8868\u3002 \u5728\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\uff0c\u5c06\u521b\u5efa\u4e00\u4e2a USER
\u7c7b\uff0c\u8fd9\u91cc\u7684\u7c7b\u540d\u548c\u5c5e\u6027\u540d\u79f0\u5fc5\u987b\u4f7f\u7528\u5927\u5199\u82f1\u6587\u5f00\u5934\u4ee5\u4fdd\u8bc1 public
\u8bbf\u95ee\uff0c\u5426\u5219\u4e0d\u80fd\u521b\u5efa\u3002USER
\u7c7b\u5728 GORM
\u7684\u4f5c\u7528\u4e0b\u5c06\u8f6c\u5316\u4e3a\u4e00\u6761 SQL
\u8bed\u53e5\uff0c\u521b\u5efa\u8868\u540d\u4e3a users
\u7684\u8868\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_create.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{\n// Logger: logger.Default.LogMode(logger.Info), //print SQL\n})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n}\n
\u4f60\u53ef\u4ee5\u53d6\u6d88\u6ce8\u91ca Logger: logger.Default.LogMode(logger.Info)
\u4ee5\u628a\u8f6c\u5316\u540e\u7684 SQL
\u8f93\u51fa\u51fa\u6765\u3002 \u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_create.go\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u521b\u5efa\u6210\u529f\uff1a
mysql> show tables;\n+----------------+\n| Tables_in_test |\n+----------------+\n| users |\n+----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_4","title":"\u63d2\u5165\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5728\u521a\u521a\u521b\u5efa\u7684 users
\u8868\u4e2d\u63d2\u5165\u4e24\u6761\u6570\u636e\u8bb0\u5f55\uff0c\u8fd9\u91cc\u7684 ID
\u9ed8\u8ba4\u662f\u81ea\u589e\u7684\uff0c\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4e3a\u56fa\u5b9a\u7684\u503c\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_insert.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Insert users**\nusers := []USER{\n{\n// ID: 1, //autoincrement\nCNAME: \"lili\",\nCADDRESS: \"Shanghai\"},\n{\nID: 111,\nCNAME: \"zhang\",\nCADDRESS: \"Biejing\",\n},\n}\n\ndb.Create(users)\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_insert.go\n
\u540c\u6837\u7684\uff0c\u7ec8\u7aef\u4e5f\u4f1a\u8f93\u51fa SQL \u8bed\u53e5\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u6210\u529f\u63d2\u5165\u6570\u636e\uff1a
mysql> select * from users;\n+------+-------+----------+\n| id | cname | caddress |\n+------+-------+----------+\n| 1 | lili | Shanghai |\n| 111 | zhang | Biejing |\n+------+-------+----------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_5","title":"\u67e5\u8be2\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u7528\u6761\u4ef6\u67e5\u8be2\u90e8\u5206\u6570\u636e\uff0c\u67e5\u8be2 CNAME=zhang
\u7684\u6570\u636e\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_query.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Query\u2014\u2014 String condition** \nres := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&res)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nfmt.Println(res)\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_query.go\n
\u7ec8\u7aef\u7684\u8f93\u51fa\u7ed3\u679c\u4e2d\u5c06\u5305\u542b\u4ee5\u4e0b\u6570\u636e\uff1a
{111 zhang Biejing}\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_6","title":"\u66f4\u65b0\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u66f4\u65b0\u6570\u636e\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_update.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Update** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres:=db.Model(&aUser).Update(\"CADDRESS\", \"HongKong\")\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_update.go\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u66f4\u65b0\u6210\u529f\uff1a
mysql> select * from users;\n+------+-------+----------+\n| id | cname | caddress |\n+------+-------+----------+\n| 111 | zhang | HongKong |\n| 1 | lili | Shanghai |\n+------+-------+----------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_7","title":"\u5220\u9664\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u8fdb\u884c\u5355\u6761\u6570\u636e\u7684\u5220\u9664\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u5220\u9664\u5355\u6761\u8bb0\u5f55\u65f6\uff0c\u9700\u8981\u6307\u5b9a\u4e3b\u952e\uff0c\u5426\u5219\u53ef\u80fd\u4f1a\u89e6\u53d1\u6279\u91cf\u5220\u9664\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_delete.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Delete** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres := db.Delete(&aUser)\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_delete.go\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u5220\u9664\u6210\u529f\uff1a
mysql> select * from users;\n+------+-------+----------+\n| id | cname | caddress |\n+------+-------+----------+\n| 1 | lili | Shanghai |\n+------+-------+----------+\n1 row in set (0.00 sec)\n
\u4ee5\u4e0a\u4ec5\u662f GORM \u4e2d CRUD \u64cd\u4f5c\u7684\u90e8\u5206\u6f14\u793a\uff0c\u66f4\u591a\u7684\u7528\u6cd5\u548c\u6848\u4f8b\u53ef\u4ee5\u53c2\u8003 GORM \u5b98\u65b9\u6307\u5357
"},{"location":"MatrixOne/Tutorial/rag-demo/","title":"RAG \u5e94\u7528\u57fa\u7840\u793a\u4f8b","text":""},{"location":"MatrixOne/Tutorial/rag-demo/#rag_1","title":"\u4ec0\u4e48\u662f RAG?","text":"RAG\uff0c\u5168\u79f0\u4e3a Retrieval-Augmented Generation\uff08\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff09\uff0c\u662f\u4e00\u79cd\u7ed3\u5408\u4e86\u4fe1\u606f\u68c0\u7d22\u548c\u6587\u672c\u751f\u6210\u7684\u6280\u672f\uff0c\u7528\u4e8e\u63d0\u9ad8\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u751f\u6210\u6587\u672c\u7684\u51c6\u786e\u6027\u548c\u76f8\u5173\u6027\u3002LLM \u7531\u4e8e\u5176\u8bad\u7ec3\u6570\u636e\u7684\u5c40\u9650\u6027\uff0c\u53ef\u80fd\u65e0\u6cd5\u83b7\u53d6\u6700\u65b0\u7684\u4fe1\u606f\u3002
\u4f8b\u5982\u6211\u5411 GPT \u8be2\u95ee MatrixOne \u7684\u6700\u65b0\u7248\u672c\u65f6\uff0c\u5b83\u5e76\u4e0d\u80fd\u7ed9\u51fa\u7b54\u6848\u3002
\u6b64\u5916\uff0c\u8fd9\u4e9b\u6a21\u578b\u6709\u65f6\u4e5f\u53ef\u80fd\u4ea7\u751f\u8bef\u5bfc\u6027\u7684\u4fe1\u606f\uff0c\u751f\u6210\u4e0e\u4e8b\u5b9e\u4e0d\u7b26\u7684\u5185\u5bb9\u3002\u4f8b\u5982\u5f53\u6211\u8be2\u95ee\u9c81\u8fc5\u548c\u5468\u6811\u4eba\u7684\u5173\u7cfb\u65f6\uff0cGPT \u5f00\u59cb\u4e86\u4e00\u672c\u6b63\u7ecf\u5730\u80e1\u8bf4\u516b\u9053\u3002
\u8981\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u628a LLM \u6a21\u578b\u91cd\u65b0\u518d\u8bad\u7ec3\u4e00\u904d\uff0c\u4f46\u6210\u672c\u662f\u9ad8\u6602\u7684\u3002\u800c RAG \u7684\u4e3b\u8981\u4f18\u52bf\u5728\u4e8e\u53ef\u4ee5\u907f\u514d\u9488\u5bf9\u7279\u5b9a\u4efb\u52a1\u518d\u6b21\u8fdb\u884c\u8bad\u7ec3\uff0c\u5176\u9ad8\u53ef\u7528\u6027\u548c\u4f4e\u95e8\u69db\u4f7f\u4e4b\u6210\u4e3a LLM \u7cfb\u7edf\u4e2d\u6700\u53d7\u6b22\u8fce\u7684\u65b9\u6848\u4e4b\u4e00\uff0c\u8bb8\u591a LLM \u5e94\u7528\u90fd\u4f1a\u57fa\u4e8e RAG \u6784\u5efa\u3002RAG \u7684\u6838\u5fc3\u601d\u60f3\u662f\u8ba9\u6a21\u578b\u5728\u751f\u6210\u56de\u7b54\u65f6\uff0c\u4e0d\u4ec5\u4f9d\u8d56\u4e8e\u5176\u5728\u8bad\u7ec3\u9636\u6bb5\u5b66\u5230\u7684\u77e5\u8bc6\uff0c\u8fd8\u80fd\u5229\u7528\u5916\u90e8\u7684\u3001\u6700\u65b0\u7684\u3001\u4e13\u6709\u7684\u4fe1\u606f\u6e90\uff0c\u56e0\u6b64\u7528\u6237\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u989d\u5916\u9644\u52a0\u5916\u90e8\u77e5\u8bc6\u5e93\uff0c\u4e30\u5bcc\u8f93\u5165\uff0c\u4ece\u800c\u4f18\u5316\u6a21\u578b\u7684\u8f93\u51fa\u6548\u679c\u3002
RAG \u7684\u5de5\u4f5c\u6d41\u7a0b\u901a\u5e38\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a
\u4ee5\u4e0b\u4e3a Native RAG \u7684\u6d41\u7a0b\u56fe\uff1a
\u53ef\u4ee5\u770b\u5230\uff0c\u68c0\u7d22\u73af\u8282\u5728 RAG \u67b6\u6784\u4e2d\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\uff0cMatrixOne \u5177\u6709\u5411\u91cf\u68c0\u7d22\u7684\u80fd\u529b\uff0c\u8fd9\u4e3a\u6784\u5efa RAG \u5e94\u7528\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u68c0\u7d22\u652f\u6301\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#matrixone-rag","title":"Matrixone \u5728 RAG \u4e2d\u7684\u4f5c\u7528","text":"Matrxione \u4f5c\u4e3a\u8d85\u878d\u5408\u6570\u636e\u5e93\uff0c\u81ea\u5e26\u5411\u91cf\u80fd\u529b\uff0c\u8fd9\u5728 RAG \u5e94\u7528\u4e2d\u8d77\u7740\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
\u9ad8\u6548\u7684\u4fe1\u606f\u68c0\u7d22\uff1aMatrxione \u62e5\u6709\u5411\u91cf\u6570\u636e\u7c7b\u578b\uff0c\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u548c\u5b58\u50a8\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\uff0c\u5b83\u901a\u8fc7\u7279\u6b8a\u7684\u6570\u636e\u7ed3\u6784\u548c\u7d22\u5f15\u7b56\u7565\uff0c\u5982 KNN \u67e5\u8be2\uff0c\u6765\u5feb\u901f\u627e\u5230\u4e0e\u67e5\u8be2\u5411\u91cf\u6700\u76f8\u4f3c\u7684\u6570\u636e\u9879\u3002
\u652f\u6301\u5927\u89c4\u6a21\u6570\u636e\u5904\u7406\uff1aMatrxione \u80fd\u591f\u6709\u6548\u7ba1\u7406\u548c\u5904\u7406\u5927\u89c4\u6a21\u7684\u5411\u91cf\u6570\u636e\uff0c\u8fd9\u5bf9\u4e8e RAG \u7cfb\u7edf\u7684\u68c0\u7d22\u7ec4\u4ef6\u6765\u8bf4\u662f\u6838\u5fc3\u529f\u80fd\uff0c\u5b83\u4f7f\u5f97 RAG \u7cfb\u7edf\u80fd\u591f\u5feb\u901f\u4ece\u6d77\u91cf\u6570\u636e\u4e2d\u68c0\u7d22\u51fa\u4e0e\u7528\u6237\u67e5\u8be2\u6700\u76f8\u5173\u7684\u4fe1\u606f\u3002
\u63d0\u9ad8\u751f\u6210\u8d28\u91cf\uff1a\u901a\u8fc7 Matrxione \u5411\u91cf\u80fd\u529b\u7684\u68c0\u7d22\u529f\u80fd\uff0cRAG \u6280\u672f\u80fd\u591f\u5f15\u5165\u5916\u90e8\u77e5\u8bc6\u5e93\u4e2d\u7684\u4fe1\u606f\uff0c\u751f\u6210\u66f4\u52a0\u51c6\u786e\u3001\u4e30\u5bcc\u548c\u5177\u6709\u4e0a\u4e0b\u6587\u7684\u6587\u672c\uff0c\u4ece\u800c\u63d0\u5347\u751f\u6210\u6587\u672c\u7684\u8d28\u91cf\u3002
\u5b89\u5168\u6027\u548c\u9690\u79c1\u4fdd\u62a4\uff1aMatrxione \u8fd8\u53ef\u4ee5\u901a\u8fc7\u52a0\u5bc6\u5b58\u50a8\u548c\u8bbf\u95ee\u63a7\u5236\u7b49\u6570\u636e\u5b89\u5168\u63aa\u65bd\u6765\u4fdd\u62a4\u6570\u636e\uff0c\u8fd9\u5bf9\u4e8e\u5904\u7406\u654f\u611f\u6570\u636e\u7684 RAG \u5e94\u7528\u5c24\u5176\u91cd\u8981\u3002
\u7b80\u5316\u5f00\u53d1\u6d41\u7a0b\uff1a\u4f7f\u7528 Matrxione \u53ef\u4ee5\u7b80\u5316 RAG \u5e94\u7528\u7684\u5f00\u53d1\u6d41\u7a0b\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u5b58\u50a8\u548c\u68c0\u7d22\u5411\u91cf\u5316\u6570\u636e\u7684\u9ad8\u6548\u673a\u5236\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u5f00\u53d1\u8005\u5728\u6570\u636e\u7ba1\u7406\u65b9\u9762\u7684\u5de5\u4f5c\u8d1f\u62c5\u3002
\u672c\u6587\u57fa\u4e8e Ollama\uff0c\u7ed3\u5408 Llama2 \u548c Mxbai-embed-large\uff0c\u5229\u7528 Matrixone \u7684\u5411\u91cf\u80fd\u529b\u5feb\u901f\u6784\u5efa\u4e00\u4e2a Native RAG \u5e94\u7528\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Tutorial/rag-demo/#_2","title":"\u76f8\u5173\u77e5\u8bc6","text":"Ollama: Ollama \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5927\u578b\u8bed\u8a00\u6a21\u578b\u670d\u52a1\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u5728\u81ea\u5df1\u7684\u786c\u4ef6\u73af\u5883\u4e2d\u8f7b\u677e\u90e8\u7f72\u548c\u4f7f\u7528\u5927\u89c4\u6a21\u9884\u8bad\u7ec3\u6a21\u578b\u3002Ollama \u7684\u4e3b\u8981\u529f\u80fd\u662f\u5728 Docker \u5bb9\u5668\u5185\u90e8\u7f72\u548c\u7ba1\u7406\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u5feb\u901f\u5730\u5728\u672c\u5730\u8fd0\u884c\u8fd9\u4e9b\u6a21\u578b\u3002Ollama \u7b80\u5316\u4e86\u90e8\u7f72\u8fc7\u7a0b\uff0c\u901a\u8fc7\u7b80\u5355\u7684\u5b89\u88c5\u6307\u4ee4\uff0c\u7528\u6237\u53ef\u4ee5\u6267\u884c\u4e00\u6761\u547d\u4ee4\u5c31\u5728\u672c\u5730\u8fd0\u884c\u5f00\u6e90\u5927\u578b\u8bed\u8a00\u6a21\u578b\u3002
Llama2\uff1allama2 \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u8bed\u8a00\u5927\u6a21\u578b\uff0c\u53ef\u4ee5\u7406\u89e3\u548c\u751f\u6210\u957f\u6587\u672c\uff0c\u8be5\u6a21\u578b\u53ef\u7528\u4e8e\u7814\u7a76\u548c\u5546\u4e1a\u7528\u9014\u3002
Mxbai-embed-large\uff1amxbai-embed-large \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5d4c\u5165\u6a21\u578b\uff0c\u4e13\u4e3a\u6587\u672c\u5d4c\u5165\u548c\u68c0\u7d22\u4efb\u52a1\u8bbe\u8ba1\uff0c\u6a21\u578b\u751f\u6210\u7684\u5d4c\u5165\u5411\u91cf\u5927\u5c0f\u4e3a 1024\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#_3","title":"\u8f6f\u4ef6\u5b89\u88c5","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -V\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\uff1a
pip3 install pymysql\n
ollama -v \n
llama2
\u548c embedding \u6a21\u578b mxbai-embed-large
\uff1aollama pull llama2\nollama pull mxbai-embed-large\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#_4","title":"\u6784\u5efa\u5e94\u7528","text":""},{"location":"MatrixOne/Tutorial/rag-demo/#_5","title":"\u5efa\u8868","text":"\u8fde\u63a5 MatrixOne\uff0c\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3a rag_tab
\u7684\u8868\u6765\u5b58\u50a8\u6587\u672c\u4fe1\u606f\u548c\u5bf9\u5e94\u7684\u5411\u91cf\u4fe1\u606f\u3002
create table rag_tab(content text,embedding vecf32(1024));\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#matrixone","title":"\u6587\u672c\u5411\u91cf\u5316\u5b58\u50a8\u5230 MatrixOne","text":"\u521b\u5efa python \u6587\u4ef6 rag_example.py\uff0c\u5229\u7528 mxbai-embed-large \u5d4c\u5165\u6a21\u578b\u5c06\u6587\u672c\u4fe1\u606f\u5207\u5206\u548c\u5411\u91cf\u5316\uff0c\u7136\u540e\u5b58\u5230 MatrixOne \u7684 rag_tab
\u8868\u4e2d\u3002
import ollama\nimport pymysql.cursors\n\nconn = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='db1',\n autocommit=True\n )\ncursor = conn.cursor()\n\n#\u751f\u6210 embeddings\ndocuments = [\n\"MatrixOne is a hyper-converged cloud & edge native distributed database with a structure that separates storage, computation, and transactions to form a consolidated HSTAP data engine. This engine enables a single database system to accommodate diverse business loads such as OLTP, OLAP, and stream computing. It also supports deployment and utilization across public, private, and edge clouds, ensuring compatibility with diverse infrastructures.\",\n\"MatrixOne touts significant features, including real-time HTAP, multi-tenancy, stream computation, extreme scalability, cost-effectiveness, enterprise-grade availability, and extensive MySQL compatibility. MatrixOne unifies tasks traditionally performed by multiple databases into one system by offering a comprehensive ultra-hybrid data solution. This consolidation simplifies development and operations, minimizes data fragmentation, and boosts development agility.\",\n\"MatrixOne is optimally suited for scenarios requiring real-time data input, large data scales, frequent load fluctuations, and a mix of procedural and analytical business operations. It caters to use cases such as mobile internet apps, IoT data applications, real-time data warehouses, SaaS platforms, and more.\",\n\"Matrix is a collection of complex or real numbers arranged in a rectangular array.\",\n\"The lastest version of MatrixOne is 1.2.1, releases on 30th June, 2024.\",\n\"We are excited to announce MatrixOne 0.8.0 release on 2023/6/30.\"\n]\n\nfor i,d in enumerate(documents):\n response = ollama.embeddings(model=\"mxbai-embed-large\", prompt=d)\n embedding = response[\"embedding\"]\n insert_sql = \"insert into rag_tab(content,embedding) values (%s, %s)\"\n data_to_insert = (d, str(embedding))\n cursor.execute(insert_sql, data_to_insert)\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#rag_tab","title":"\u67e5\u770b rag_tab
\u8868\u4e2d\u6570\u91cf","text":"mysql> select count(*) from rag_tab;\n+----------+\n| count(*) |\n+----------+\n| 6 |\n+----------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6570\u636e\u6210\u529f\u5b58\u50a8\u5230\u6570\u636e\u5e93\u4e2d\u3002
\u5728\u5927\u89c4\u6a21\u9ad8\u7ef4\u6570\u636e\u68c0\u7d22\u65f6\uff0c\u5982\u679c\u91c7\u7528\u5168\u91cf\u641c\u7d22\uff0c\u9700\u8981\u5bf9\u6bcf\u4e2a\u67e5\u8be2\u90fd\u6267\u884c\u4e0e\u6574\u4e2a\u6570\u636e\u96c6\u4e2d\u6bcf\u4e2a\u5411\u91cf\u7684\u76f8\u4f3c\u5ea6\u8ba1\u7b97\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u5de8\u5927\u7684\u6027\u80fd\u5f00\u9500\u548c\u5ef6\u8fdf\u3002\u800c\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff0c\u901a\u8fc7\u5efa\u7acb\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u6765\u4f18\u5316\u641c\u7d22\u8fc7\u7a0b\uff0c\u63d0\u9ad8\u68c0\u7d22\u6027\u80fd\uff0c\u964d\u4f4e\u8ba1\u7b97\u548c\u5b58\u50a8\u6210\u672c\uff0c\u540c\u65f6\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u4e3a\u5411\u91cf\u5b57\u6bb5\u5efa\u7acb IVF-FLAT \u5411\u91cf\u7d22\u5f15
SET GLOBAL experimental_ivf_index = 1;--\u5f00\u542f\u5411\u91cf\u7d22\u5f15\ncreate index idx_rag using ivfflat on rag_tab(embedding) lists=1 op_type \"vector_l2_ops\";\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#_6","title":"\u5411\u91cf\u68c0\u7d22","text":"\u6570\u636e\u51c6\u5907\u597d\u4ee5\u540e\u5c31\u53ef\u4ee5\u6839\u636e\u6211\u4eec\u63d0\u51fa\u7684\u95ee\u9898\u5728\u6570\u636e\u5e93\u641c\u7d22\u6700\u76f8\u4f3c\u7684\u5185\u5bb9\uff0c\u8fd9\u4e00\u6b65\u4e3b\u8981\u4f9d\u8d56 MatrixOne \u7684\u5411\u91cf\u68c0\u7d22\u80fd\u529b\uff0cMatrixOne \u652f\u6301\u591a\u79cd\u76f8\u4f3c\u5ea6\u641c\u7d22\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528 l2_distance
\u6765\u68c0\u7d22\uff0c\u5e76\u8bbe\u7f6e\u8fd4\u56de\u7ed3\u679c\u6570\u91cf\u4e3a 3\u3002
prompt = \"What is the latest version of MatrixOne?\"\n\nresponse = ollama.embeddings(\n prompt=prompt,\n model=\"mxbai-embed-large\"\n)\nquery_embedding= response[\"embedding\"]\nquery_sql = \"select content from rag_tab order by l2_distance(embedding,%s) asc limit 3\"\ndata_to_query = str(query_embedding)\ncursor.execute(query_sql, data_to_query)\ndata = cursor.fetchall()\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#_7","title":"\u589e\u5f3a\u751f\u6210","text":"\u6211\u4eec\u5c06\u4e0a\u4e00\u6b65\u68c0\u7d22\u5230\u7684\u5185\u5bb9\u4e0e LLM \u7ed3\u5408\uff0c\u751f\u6210\u7b54\u6848\u3002
#\u589e\u5f3a\u751f\u6210\noutput = ollama.generate(\n model=\"llama2\",\n prompt=f\"Using this data: {data}. Respond to this prompt: {prompt}\"\n)\n\nprint(output['response'])\n
\u63a7\u5236\u53f0\u8f93\u51fa\u76f8\u5173\u56de\u7b54\uff1a
Based on the provided data, the latest version of MatrixOne is 1.2.1, which was released on June 30th, 2024.\n
\u5728\u589e\u5f3a\u540e\uff0c\u6a21\u578b\u751f\u6210\u4e86\u6b63\u786e\u7b54\u6848\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#_8","title":"\u53c2\u8003\u6587\u6863","text":"\u5f53\u4e0b\uff0c\u4ee5\u56fe\u641c\u56fe\u548c\u4ee5\u6587\u641c\u56fe\u7684\u76f8\u5173\u5e94\u7528\u6db5\u76d6\u4e86\u5e7f\u6cdb\u7684\u9886\u57df\uff0c\u5728\u7535\u5b50\u5546\u52a1\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4e0a\u4f20\u56fe\u7247\u6216\u6587\u672c\u63cf\u8ff0\u6765\u641c\u7d22\u5546\u54c1\uff1b\u5728\u793e\u4ea4\u5a92\u4f53\u5e73\u53f0\uff0c\u901a\u8fc7\u56fe\u50cf\u6216\u6587\u672c\u5feb\u901f\u627e\u5230\u76f8\u5173\u5185\u5bb9\uff0c\u589e\u5f3a\u7528\u6237\u7684\u4f53\u9a8c\uff1b\u800c\u5728\u7248\u6743\u68c0\u6d4b\u65b9\u9762\uff0c\u5219\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u548c\u4fdd\u62a4\u56fe\u50cf\u7248\u6743\uff1b\u6b64\u5916\uff0c\u4ee5\u6587\u641c\u56fe\u8fd8\u5e7f\u6cdb\u5e94\u7528\u4e8e\u641c\u7d22\u5f15\u64ce\uff0c\u5e2e\u52a9\u7528\u6237\u901a\u8fc7\u5173\u952e\u8bcd\u627e\u5230\u7279\u5b9a\u56fe\u50cf\uff0c\u800c\u4ee5\u56fe\u641c\u56fe\u5219\u5728\u673a\u5668\u5b66\u4e60\u548c\u4eba\u5de5\u667a\u80fd\u9886\u57df\u4e2d\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u548c\u5206\u7c7b\u4efb\u52a1\u3002
\u4ee5\u4e0b\u4e3a\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u7684\u6d41\u7a0b\u56fe\uff1a
\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\u4e2d\uff0c\u6d89\u53ca\u5230\u5bf9\u56fe\u7247\u7684\u5411\u91cf\u5316\u5b58\u50a8\u548c\u68c0\u7d22\uff0c\u800c MatrixOne \u5177\u5907\u5411\u91cf\u80fd\u529b\uff0c\u4e14\u63d0\u4f9b\u591a\u79cd\u68c0\u7d22\u65b9\u5f0f\uff0c\u8fd9\u4e3a\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\u63d0\u4f9b\u4e86\u5173\u952e\u7684\u6280\u672f\u652f\u6301\u3002
\u5728\u672c\u7ae0\u8282\uff0c\u6211\u4eec\u5c06\u57fa\u4e8e MatrixOne \u7684\u5411\u91cf\u80fd\u529b\u6765\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u7684\u5e94\u7528\u3002
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Tutorial/search-picture-demo/#_3","title":"\u76f8\u5173\u77e5\u8bc6","text":"Transformers\uff1aTransformers \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff0c\u63d0\u4f9b\u4e86\u5e7f\u6cdb\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u901a\u8fc7 Transformers \u5e93\uff0c\u7814\u7a76\u4eba\u5458\u548c\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528\u548c\u96c6\u6210 CLIP \u6a21\u578b\u5230\u4ed6\u4eec\u7684\u9879\u76ee\u4e2d\u3002
CLIP: CLIP \u6a21\u578b\u662f\u7531 OpenAI \u53d1\u5e03\u7684\u4e00\u79cd\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff0c\u6838\u5fc3\u662f\u901a\u8fc7\u5bf9\u6bd4\u5b66\u4e60\u7684\u65b9\u6cd5\u6765\u7edf\u4e00\u5904\u7406\u6587\u672c\u548c\u56fe\u50cf\uff0c\u4ece\u800c\u80fd\u591f\u901a\u8fc7\u6587\u672c - \u56fe\u50cf\u76f8\u4f3c\u5ea6\u6765\u5b8c\u6210\u56fe\u50cf\u5206\u7c7b\u7b49\u4efb\u52a1\uff0c\u800c\u65e0\u9700\u76f4\u63a5\u4f18\u5316\u4efb\u52a1\u3002\u5b83\u53ef\u4ee5\u7ed3\u5408\u5411\u91cf\u6570\u636e\u5e93\uff0c\u6765\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u7684\u5de5\u5177\u3002\u901a\u8fc7 CLIP \u6a21\u578b\u63d0\u53d6\u56fe\u50cf\u7684\u9ad8\u7ef4\u5411\u91cf\u8868\u793a\uff0c\u4ee5\u6355\u83b7\u5176\u8bed\u4e49\u548c\u611f\u77e5\u7279\u5f81\uff0c\u7136\u540e\u5c06\u8fd9\u4e9b\u56fe\u50cf\u7f16\u7801\u5230\u5d4c\u5165\u7a7a\u95f4\u4e2d\u3002\u5728\u67e5\u8be2\u65f6\uff0c\u6837\u672c\u56fe\u50cf\u901a\u8fc7\u76f8\u540c\u7684 CLIP \u7f16\u7801\u5668\u6765\u83b7\u53d6\u5176\u5d4c\u5165\uff0c\u6267\u884c\u5411\u91cf\u76f8\u4f3c\u6027\u641c\u7d22\u4ee5\u6709\u6548\u5730\u627e\u5230\u524d k \u4e2a\u6700\u63a5\u8fd1\u7684\u6570\u636e\u5e93\u56fe\u50cf\u5411\u91cf\u3002
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_4","title":"\u8f6f\u4ef6\u5b89\u88c5","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -V\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\uff1a
pip install pymysql\n
transformers
\u5e93\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 transformers
\u5e93\uff1apip install transformers\n
Pillow
\u5e93\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 Pillow
\u5e93\uff1apip install pillow \n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_5","title":"\u6784\u5efa\u5e94\u7528","text":""},{"location":"MatrixOne/Tutorial/search-picture-demo/#_6","title":"\u5efa\u8868","text":"\u8fde\u63a5 MatrixOne\uff0c\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3a pic_tab
\u7684\u8868\u6765\u5b58\u50a8\u56fe\u7247\u8def\u5f84\u4fe1\u606f\u548c\u5bf9\u5e94\u7684\u5411\u91cf\u4fe1\u606f\u3002
create table pic_tab(pic_path varchar(200), embedding vecf64(512));\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_7","title":"\u52a0\u8f7d\u6a21\u578b","text":"from transformers import CLIPProcessor, CLIPModel\n\n# \u4ece HuggingFace \u52a0\u8f7d\u6a21\u578b\nmodel = CLIPModel.from_pretrained(\"openai/clip-vit-base-patch32\")\nprocessor = CLIPProcessor.from_pretrained(\"openai/clip-vit-base-patch32\")\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_8","title":"\u904d\u5386\u56fe\u7247\u8def\u5f84","text":"\u5b9a\u4e49\u65b9\u6cd5 find_img_files
\u904d\u5386\u672c\u5730\u56fe\u7247\u6587\u4ef6\u5939\uff0c\u8fd9\u91cc\u6211\u9884\u5148\u5728\u672c\u5730\u5b58\u4e86\u82f9\u679c\u3001\u9999\u8549\u3001\u84dd\u8393\u3001\u6a31\u6843\u3001\u674f\u5b50\u4e94\u79cd\u7c7b\u522b\u7684\u6c34\u679c\u56fe\u7247\uff0c\u6bcf\u79cd\u7c7b\u522b\u82e5\u5e72\u5f20\uff0c\u683c\u5f0f\u90fd\u4e3a .jpg
\u3002
def find_img_files(directory):\n img_files = [] # \u7528\u4e8e\u5b58\u50a8\u627e\u5230\u7684.jpg \u6587\u4ef6\u8def\u5f84\n for root, dirs, files in os.walk(directory):\n for file in files:\n if file.lower().endswith('.jpg'):\n full_path = os.path.join(root, file)\n img_files.append(full_path) # \u6784\u5efa\u5b8c\u6574\u7684\u6587\u4ef6\u8def\u5f84\n return img_files\n
\u5b9a\u4e49\u65b9\u6cd5 storage_img
\u5c06\u56fe\u7247\u6620\u5c04\u6210\u5411\u91cf\uff0c\u8fdb\u884c\u5f52\u4e00\u5316\uff08\u975e\u5fc5\u9700\uff09\u5e76\u5b58\u50a8\u5230 MatrixOne \u91cc\u3002MatrixOne \u652f\u6301\u4f7f\u7528 NORMALIZE_L2()
\u51fd\u6570\u5bf9\u5411\u91cf\u6267\u884c L2 \u5f52\u4e00\u5316\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u7684\u7279\u5f81\u53ef\u80fd\u5206\u5e03\u5728\u4e0d\u540c\u7684\u5c3a\u5ea6\u4e0a\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u67d0\u4e9b\u7279\u5f81\u5bf9\u8ddd\u79bb\u8ba1\u7b97\u6709\u4e0d\u6210\u6bd4\u4f8b\u7684\u5f71\u54cd\u3002\u901a\u8fc7\u5f52\u4e00\u5316\uff0c\u53ef\u4ee5\u51cf\u5c11\u8fd9\u79cd\u5f71\u54cd\uff0c\u4f7f\u4e0d\u540c\u7279\u5f81\u5bf9\u6700\u7ec8\u7ed3\u679c\u7684\u8d21\u732e\u66f4\u52a0\u5747\u8861\u3002\u800c\u5728\u4f7f\u7528 L2 distance \u5ea6\u91cf\u65f6\uff0cL2 \u5f52\u4e00\u5316\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u957f\u5ea6\u7684\u5411\u91cf\u5f71\u54cd\u8ddd\u79bb\u8ba1\u7b97\u3002
import pymysql\nfrom PIL import Image\n\nconn = pymysql.connect(\n host = '127.0.0.1',\n port = 6001,\n user = 'root',\n password = \"111\",\n db = 'db1',\n autocommit = True\n )\n\ncursor = conn.cursor()\n\n# \u628a\u56fe\u50cf\u6620\u5c04\u6210\u5411\u91cf\uff0c\u5b58\u50a8\u5728 MatrixOne \u4e2d\ndef storage_img():\n for file_path in jpg_files:\n image = Image.open(file_path)\n if image.mode != 'RGBA':\n image = image.convert('RGBA')\n inputs = processor(images=image, return_tensors=\"pt\", padding=True)\n img_features = model.get_image_features(inputs[\"pixel_values\"]) # \u4f7f\u7528\u6a21\u578b\u83b7\u53d6\u56fe\u50cf\u7279\u5f81\n img_features = img_features .detach().tolist() # \u5206\u79bb\u5f20\u91cf\uff0c\u8f6c\u6362\u4e3a\u5217\u8868\n embeddings = img_features [0]\n insert_sql = \"insert into pic_tab(pic_path,embedding) values (%s, normalize_l2(%s))\"\n data_to_insert = (file_path, str(embeddings))\n cursor.execute(insert_sql, data_to_insert)\n image.close()\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#pic_tab","title":"\u67e5\u770b pic_tab
\u8868\u4e2d\u6570\u91cf","text":"mysql> select count(*) from pic_tab;\n+----------+\n| count(*) |\n+----------+\n| 4801 |\n+----------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6570\u636e\u6210\u529f\u5b58\u50a8\u5230\u6570\u636e\u5e93\u4e2d\u3002
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_9","title":"\u5efa\u7acb\u5411\u91cf\u7d22\u5f15","text":"MatrixOne \u652f\u6301\u5728 IVF-FLAT \u5411\u91cf\u7d22\u5f15\uff0c\u5728\u6ca1\u6709\u7d22\u5f15\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6b21\u641c\u7d22\u90fd\u9700\u8981\u91cd\u65b0\u8ba1\u7b97\u67e5\u8be2\u56fe\u50cf\u4e0e\u6570\u636e\u5e93\u4e2d\u6bcf\u5f20\u56fe\u50cf\u4e4b\u95f4\u7684\u76f8\u4f3c\u5ea6\u3002\u800c\u7d22\u5f15\u53ef\u4ee5\u51cf\u5c11\u5fc5\u8981\u7684\u8ba1\u7b97\u91cf\uff0c\u53ea\u5bf9\u7d22\u5f15\u4e2d\u6807\u8bb0\u4e3a\u201c\u76f8\u5173\u201d\u7684\u56fe\u50cf\u8fdb\u884c\u76f8\u4f3c\u5ea6\u8ba1\u7b97\u3002
def create_idx(n):\n cursor.execute('SET GLOBAL experimental_ivf_index = 1')\n create_sql = 'create index idx_pic using ivfflat on pic_tab(embedding) lists=%s op_type \"vector_l2_ops\"'\n cursor.execute(create_sql, n)\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_10","title":"\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe","text":"\u63a5\u7740\uff0c\u6211\u4eec\u5b9a\u4e49\u65b9\u6cd5 img_search_img
\u548c text_search_img
\u5b9e\u73b0\u4ee5\u56fe\u641c\u56fe\u548c\u4ee5\u6587\u641c\u56fe\uff0cMatrixOne \u5177\u6709\u5411\u91cf\u68c0\u7d22\u80fd\u529b\uff0c\u652f\u6301\u591a\u79cd\u76f8\u4f3c\u5ea6\u641c\u7d22\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528 l2_distance
\u6765\u68c0\u7d22\u3002
# \u4ee5\u56fe\u641c\u56fe\ndef img_search_img(img_path, k):\n image = Image.open(img_path)\n inputs = processor(images=image, return_tensors=\"pt\")\n img_features = model.get_image_features(**inputs)\n img_features = img_features.detach().tolist()\n img_features = img_features[0]\n query_sql = \"select pic_path from pic_tab order by l2_distance(embedding,normalize_l2(%s)) asc limit %s\"\n data_to_query = (str(img_features), k)\n cursor.execute(query_sql, data_to_query)\n global data\n data = cursor.fetchall()\n\n# \u4ee5\u6587\u641c\u56fe\ndef text_search_img(text,k):\n inputs = processor(text=text, return_tensors=\"pt\", padding=True)\n text_features = model.get_text_features(inputs[\"input_ids\"], inputs[\"attention_mask\"])\n embeddings = text_features.detach().tolist()\n embeddings = embeddings[0]\n query_sql = \"select pic_path from pic_tab order by l2_distance(embedding,normalize_l2(%s)) asc limit %s\"\n data_to_query = (str(embeddings),k)\n cursor.execute(query_sql, data_to_query)\n global data\n data = cursor.fetchall()\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_11","title":"\u641c\u7d22\u7ed3\u679c\u5c55\u793a","text":"\u5728\u6839\u636e\u56fe\u7247\u6216\u6587\u5b57\u68c0\u7d22\u5230\u76f8\u5173\u56fe\u7247\u65f6\uff0c\u6211\u4eec\u9700\u8981\u628a\u7ed3\u679c\u6253\u5370\u51fa\u6765\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528 Matplotlib \u6765\u5c55\u793a\u641c\u7d22\u7ed3\u679c\u3002
import matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\n\ndef show_img(img_path,rows,cols):\n if img_path:\n result_path = [img_path] + [path for path_tuple in data for path in path_tuple]\n else:\n result_path = [path for path_tuple in data for path in path_tuple]\n # \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u548c\u5750\u6807\u8f74\n fig, axes = plt.subplots(nrows=rows, ncols=cols, figsize=(10, 10))\n # \u5faa\u73af\u904d\u5386\u56fe\u7247\u8def\u5f84\u548c\u5750\u6807\u8f74\n for i, (result_path, ax) in enumerate(zip(result_path, axes.ravel())):\n image = mpimg.imread(result_path) # \u8bfb\u53d6\u56fe\u7247\n ax.imshow(image) # \u663e\u793a\u56fe\u7247\n ax.axis('off') # \u79fb\u9664\u5750\u6807\u8f74\n ax.set_title(f'image{i + 1}') # \u8bbe\u7f6e\u5b50\u56fe\u6807\u9898\n plt.tight_layout() # \u8c03\u6574\u5b50\u56fe\u95f4\u8ddd\n plt.show() # \u663e\u793a\u6574\u4e2a\u56fe\u5f62\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_12","title":"\u67e5\u770b\u7ed3\u679c","text":"\u5728\u4e3b\u7a0b\u5e8f\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff0c\u8fd0\u884c\u7a0b\u5e8f\uff1a
if __name__ == \"__main__\":\n directory_path = '/Users/admin/Downloads/fruit01' # \u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u76ee\u5f55\u8def\u5f84\n jpg_files = find_img_files(directory_path)\n storage_img()\n create_idx(4)\n img_path = '/Users/admin/Downloads/fruit01/blueberry/f_01_04_0450.jpg'\n img_search_img(img_path, 3) # \u4ee5\u56fe\u641c\u56fe\n show_img(img_path,1,4)\n text = [\"Banana\"]\n text_search_img(text,3) # \u4ee5\u6587\u641c\u56fe\n show_img(None,1,3)\n
\u4ee5\u56fe\u641c\u56fe\u7ed3\u679c\uff0c\u5de6\u8fb9\u7b2c\u4e00\u5f20\u56fe\u4e3a\u6bd4\u5bf9\u56fe\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u641c\u7d22\u51fa\u6765\u7684\u56fe\u7247\u4e0e\u88ab\u6bd4\u5bf9\u56fe\u975e\u5e38\u76f8\u4f3c\uff1a
\u4ee5\u6587\u641c\u56fe\u7ed3\u679c\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u641c\u51fa\u6765\u7684\u56fe\u7247\u4e0e\u8f93\u5165\u6587\u672c\u4e00\u81f4\uff1a
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_13","title":"\u53c2\u8003\u6587\u6863","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 SpringBoot\u3001Spring Data JPA \u548c Intellij IDEA \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#_1","title":"\u5f00\u59cb\u4e4b\u524d","text":"\u672c\u7bc7\u6559\u7a0b\u6d89\u53ca\u5230\u7684\u8f6f\u4ef6\u4ecb\u7ecd\u5982\u4e0b\uff1a
Spring Data JPA\uff1aJPA\uff08Java Persistence API\uff0cJava \u6301\u4e45\u5c42 API\uff09\u662f\u4e00\u79cd\u89c4\u8303\uff0c\u662f JDK 5.0 \u6ce8\u89e3\u6216 XML \u63cf\u8ff0\u5bf9\u8c61\u4e0e\u5173\u7cfb\u8868\u7684\u6620\u5c04\u5173\u7cfb\uff0c\u5e76\u5c06\u8fd0\u884c\u671f\u7684\u5b9e\u4f53\u5bf9\u8c61\u6301\u4e45\u5316\u5230\u6570\u636e\u5e93\u4e2d\u3002Spring Data JPA \u662f\u4e00\u4e2a Java \u5bf9\u8c61\u6620\u5c04\u5173\u7cfb\u7684\u89e3\u51b3\u65b9\u6848\u7684 ORM\uff08Object-Relational Mapping\uff09\u6846\u67b6\uff0c\u662f\u4e00\u4e2a\u5c06\u9762\u5411\u5bf9\u8c61\u7684\u57df\u6a21\u578b\u6620\u5c04\u5230\u5173\u7cfb\u6570\u636e\u5e93\u7684\u5f00\u6e90\u6846\u67b6\u3002
Intellij IDEA\uff1aIntelliJ IDEA \u662f\u4e00\u79cd\u5546\u4e1a\u5316\u9500\u552e\u7684 Java \u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08Integrated Development Environment\uff0cIDE\uff09\u5de5\u5177\u8f6f\u4ef6\u3002\u5b83\u6240\u62e5\u6709\u8bf8\u591a\u63d2\u4ef6\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6211\u4eec\u7684\u5de5\u4f5c\u6548\u7387\u3002
Maven\uff1aMaven \u662f Java \u4e2d\u529f\u80fd\u5f3a\u5927\u7684\u9879\u76ee\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u6839\u636e pom.xml \u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u81ea\u52a8\u4e0b\u8f7d\u548c\u5bfc\u5165 Jar \u6587\u4ef6\u3002\u8fd9\u4e2a\u7279\u6027\u51cf\u5c11\u4e86\u4e0d\u540c\u7248\u672c Jar \u6587\u4ef6\u4e4b\u95f4\u7684\u51b2\u7a81\u3002
Spring\uff1aSpring \u662f Java \u4e2d\u6700\u6d41\u884c\u7684\u6846\u67b6\u4e4b\u4e00\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u4f01\u4e1a\u4f7f\u7528 Spring \u6846\u67b6\u6765\u6784\u5efa\u4ed6\u4eec\u7684\u9879\u76ee\u3002Spring Boot \u6784\u5efa\u5728\u4f20\u7edf\u7684 Spring \u6846\u67b6\u4e4b\u4e0a\u3002\u56e0\u6b64\uff0c\u5b83\u63d0\u4f9b\u4e86 Spring \u7684\u6240\u6709\u7279\u6027\uff0c\u800c\u4e14\u6bd4 Spring \u66f4\u6613\u7528\u3002
Postman: Postman \u662f\u4e00\u4e2a\u7528\u4e8e API \u6d4b\u8bd5\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u662f\u4e00\u4e2a HTTP \u5ba2\u6237\u7aef\uff0c\u5229\u7528\u56fe\u5f62\u7528\u6237\u754c\u9762\u6d4b\u8bd5 HTTP \u8bf7\u6c42\uff0c\u4ee5\u83b7\u5f97\u9700\u8981\u8fdb\u884c\u9a8c\u8bc1\u7684\u4e0d\u540c\u7c7b\u578b\u7684\u54cd\u5e94\u3002
\u6309\u7167\u6b65\u9aa4\u4ecb\u7ecd\u5b8c\u6210\u5b89\u88c5\u5355\u673a\u7248 MatrixOne\uff0c\u5728 MySQL \u5ba2\u6237\u7aef\u65b0\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a test
\u6570\u636e\u5e93\u3002
mysql> create database test;\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-intellij-idea-spring-boot","title":"2. \u4f7f\u7528 IntelliJ IDEA \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Spring Boot \u9879\u76ee","text":"\u9009\u62e9 Spring Initializer\uff0c\u6309\u9700\u547d\u540d\u9879\u76ee\u540d\u79f0\u3002
\u9009\u62e9\u5982\u4e0b\u4f9d\u8d56\u9879\uff1a
\u70b9\u51fb Create \u521b\u5efa\u9879\u76ee\u3002\u4f9d\u8d56\u9879\u5217\u5728 pom.xml \u6587\u4ef6\u4e2d\u3002\u901a\u5e38\u4f60\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u4e1c\u897f\u3002
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n <groupId>com.example</groupId>\n <artifactId>jpademo</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <name>jpademo</name>\n <description>jpademo</description>\n\n <properties>\n <java.version>1.8</java.version>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n </properties>\n\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-data-jpa</artifactId>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-jdbc</artifactId>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-web</artifactId>\n </dependency>\n\n <dependency>\n <groupId>mysql</groupId>\n <artifactId>mysql-connector-java</artifactId>\n <scope>runtime</scope>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-test</artifactId>\n <scope>test</scope>\n <exclusions>\n <exclusion>\n <groupId>org.junit.vintage</groupId>\n <artifactId>junit-vintage-engine</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n </dependencies>\n\n <dependencyManagement>\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-dependencies</artifactId>\n <version>${spring-boot.version}</version>\n <type>pom</type>\n <scope>import</scope>\n </dependency>\n </dependencies>\n </dependencyManagement>\n\n <build>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-compiler-plugin</artifactId>\n <version>3.8.1</version>\n <configuration>\n <source>1.8</source>\n <target>1.8</target>\n <encoding>UTF-8</encoding>\n </configuration>\n </plugin>\n <plugin>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-maven-plugin</artifactId>\n <version>2.3.7.RELEASE</version>\n <configuration>\n <mainClass>com.example.jpademo.JpademoApplication</mainClass>\n </configuration>\n <executions>\n <execution>\n <id>repackage</id>\n <goals>\n <goal>repackage</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n\n</project>\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-applicationproperties","title":"3. \u4fee\u6539 application.properties \u6587\u4ef6","text":"\u8fdb\u5165\u5230 resources \u6587\u4ef6\u76ee\u5f55\u4e0b\uff0c\u914d\u7f6e application.properties \u6587\u4ef6\uff0c\u5b8c\u6210 MatrixOne \u8fde\u63a5\u3002
# Application Name\nspring.application.name=jpademo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with parameters\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n# Web application port\nserver.port=8080\n\n# Hibernate configurations\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.properties.hibernate.id.new_generator_mappings = false\nspring.jpa.properties.hibernate.format_sql = true\nspring.jpa.hibernate.ddl-auto = validate\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-matrixone","title":"4. \u5728 MatrixOne \u4e2d\u65b0\u5efa\u8868\u5e76\u63d2\u5165\u6570\u636e","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u5e76\u6267\u884c\u4ee5\u4e0b SQL \u8bed\u53e5\u3002\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e9b SQL \u8bed\u53e5\u4fdd\u5b58\u5728 /resource/database/ \u76ee\u5f55\u4e0b\u7684 book.sql \u4e2d\u3002
mysql> USE test;\nmysql> CREATE TABLE IF NOT EXISTS `book` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `author` varchar(255) DEFAULT NULL,\n `category` varchar(255) DEFAULT NULL,\n `name` varchar(255) DEFAULT NULL,\n `pages` int(11) DEFAULT NULL,\n `price` int(11) DEFAULT NULL,\n `publication` varchar(255) DEFAULT NULL,\n PRIMARY KEY (`id`)\n );\nmysql> INSERT INTO `book` (`id`, `author`, `category`, `name`, `pages`, `price`, `publication`) VALUES\n(1, 'Antoine de Saint-Exupery', 'Fantancy', 'The Little Prince', 100, 50, 'Amazon'),\n(2, 'J. K. Rowling', 'Fantancy', 'Harry Potter and the Sorcerer''s Stone', 1000, 200, 'Amazon'),\n(3, 'Lewis Carroll', 'Fantancy', 'Alice''s Adventures in Wonderland', 1500, 240, 'Amazon');\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#_3","title":"\u7f16\u5199\u4ee3\u7801","text":"\u5b8c\u6210\u73af\u5883\u914d\u7f6e\u540e\uff0c\u6211\u4eec\u7f16\u5199\u4ee3\u7801\u6765\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u5e94\u7528\u7a0b\u5e8f\u3002
\u5728\u5b8c\u6210\u7f16\u5199\u4ee3\u7801\u540e\uff0c\u4f60\u5c06\u62e5\u6709\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684\u9879\u76ee\u7ed3\u6784\u3002\u4f60\u53ef\u4ee5\u9884\u5148\u521b\u5efa\u8fd9\u4e9b\u5305\u548c java \u7c7b\u3002
\u6211\u4eec\u5c06\u4e3a\u8fd9\u4e2a\u6f14\u793a\u5e94\u7528\u7a0b\u5e8f\u7f16\u5199\u521b\u5efa\u3001\u66f4\u65b0\u3001\u63d2\u5165\u3001\u5220\u9664\u548c\u9009\u62e9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-bookstorecontrollerjava","title":"1. BookStoreController.java","text":"package com.example.jpademo.controller;\n\nimport com.example.jpademo.entity.Book;\nimport com.example.jpademo.services.IBookStoreService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\n\n@Controller\n@RequestMapping(\"bookservice\")\npublic class BookStoreController {\n\n @Autowired\n private IBookStoreService service;\n\n @GetMapping(\"books\")\n public ResponseEntity<List<Book>> getBooks(){\n\n List<Book> books = service.getBooks();\n return new ResponseEntity<List<Book>>(books, HttpStatus.OK);\n\n }\n\n @GetMapping(\"books/{id}\")\n public ResponseEntity<Book> getBook(@PathVariable(\"id\") Integer id){\n Book book = service.getBook(id);\n return new ResponseEntity<Book>(book, HttpStatus.OK);\n }\n\n @PostMapping(\"books\")\n public ResponseEntity<Book> createBook(@RequestBody Book book){\n Book b = service.createBook(book);\n return new ResponseEntity<Book>(b, HttpStatus.OK);\n\n }\n\n @PutMapping(\"books/{id}\")\n public ResponseEntity<Book> updateBook(@PathVariable(\"id\") int id, @RequestBody Book book){\n\n Book b = service.updateBook(id, book);\n return new ResponseEntity<Book>(b, HttpStatus.OK);\n }\n\n @DeleteMapping(\"books/{id}\")\n public ResponseEntity<String> deleteBook(@PathVariable(\"id\") int id){\n boolean isDeleted = service.deleteBook(id);\n if(isDeleted){\n String responseContent = \"Book has been deleted successfully\";\n return new ResponseEntity<String>(responseContent,HttpStatus.OK);\n }\n String error = \"Error while deleting book from database\";\n return new ResponseEntity<String>(error,HttpStatus.INTERNAL_SERVER_ERROR);\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-boostoredaojava","title":"2. BooStoreDAO.java","text":"package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\nimport org.springframework.stereotype.Repository;\nimport org.springframework.transaction.annotation.Transactional;\n\nimport javax.persistence.EntityManager;\nimport javax.persistence.PersistenceContext;\nimport javax.persistence.Query;\nimport java.util.List;\n\n@Transactional\n@Repository\npublic class BookStoreDAO implements IBookStoreDAO {\n\n @PersistenceContext\n private EntityManager entityManager;\n\n /**\n * This method is responsible to get all books available in database and return it as List<Book>\n */\n @SuppressWarnings(\"unchecked\")\n @Override\n public List<Book> getBooks() {\n\n String hql = \"FROM Book as atcl ORDER BY atcl.id\";\n return (List<Book>) entityManager.createQuery(hql).getResultList();\n }\n\n /**\n * This method is responsible to get a particular Book detail by given book id\n */\n @Override\n public Book getBook(int bookId) {\n\n return entityManager.find(Book.class, bookId);\n }\n\n /**\n * This method is responsible to create new book in database\n */\n @Override\n public Book createBook(Book book) {\n entityManager.persist(book);\n Book b = getLastInsertedBook();\n return b;\n }\n\n /**\n * This method is responsible to update book detail in database\n */\n @Override\n public Book updateBook(int bookId, Book book) {\n\n //First We are taking Book detail from database by given book id and\n // then updating detail with provided book object\n Book bookFromDB = getBook(bookId);\n bookFromDB.setName(book.getName());\n bookFromDB.setAuthor(book.getAuthor());\n bookFromDB.setCategory(book.getCategory());\n bookFromDB.setPublication(book.getPublication());\n bookFromDB.setPages(book.getPages());\n bookFromDB.setPrice(book.getPrice());\n\n entityManager.flush();\n\n //again i am taking updated result of book and returning the book object\n Book updatedBook = getBook(bookId);\n\n return updatedBook;\n }\n\n /**\n * This method is responsible for deleting a particular(which id will be passed that record)\n * record from the database\n */\n @Override\n public boolean deleteBook(int bookId) {\n Book book = getBook(bookId);\n entityManager.remove(book);\n\n //we are checking here that whether entityManager contains earlier deleted book or not\n // if contains then book is not deleted from DB that's why returning false;\n boolean status = entityManager.contains(book);\n if(status){\n return false;\n }\n return true;\n }\n\n /**\n * This method will get the latest inserted record from the database and return the object of Book class\n * @return book\n */\n private Book getLastInsertedBook(){\n String hql = \"from Book order by id DESC\";\n Query query = entityManager.createQuery(hql);\n query.setMaxResults(1);\n Book book = (Book)query.getSingleResult();\n return book;\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-ibookstoredaojava","title":"3. IBookStoreDAO.java","text":"package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreDAO {\n\n List<Book> getBooks();\n Book getBook(int bookId);\n Book createBook(Book book);\n Book updateBook(int bookId,Book book);\n boolean deleteBook(int bookId);\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-bookjava","title":"4. Book.java","text":"package com.example.jpademo.entity;\n\nimport javax.persistence.*;\nimport java.io.Serializable;\n\n@Entity\n@Table(name=\"book\")\npublic class Book implements Serializable {\n\n private static final long serialVersionUID = 1L;\n @Id\n @GeneratedValue(strategy= GenerationType.AUTO)\n @Column(name=\"id\")\n private int id;\n\n @Column(name=\"name\")\n private String name;\n\n @Column(name=\"author\")\n private String author;\n\n @Column(name=\"publication\")\n private String publication;\n\n @Column(name=\"category\")\n private String category;\n\n @Column(name=\"pages\")\n private int pages;\n\n @Column(name=\"price\")\n private int price;\n\n public int getId() {\n return id;\n }\n\n public void setId(int id) {\n this.id = id;\n }\n\n public String getName() {\n return name;\n }\n\n public void setName(String name) {\n this.name = name;\n }\n\n public String getAuthor() {\n return author;\n }\n\n public void setAuthor(String author) {\n this.author = author;\n }\n\n public String getPublication() {\n return publication;\n }\n\n public void setPublication(String publication) {\n this.publication = publication;\n }\n\n public String getCategory() {\n return category;\n }\n\n public void setCategory(String category) {\n this.category = category;\n }\n\n public int getPages() {\n return pages;\n }\n\n public void setPages(int pages) {\n this.pages = pages;\n }\n\n public int getPrice() {\n return price;\n }\n\n public void setPrice(int price) {\n this.price = price;\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-bookstoreservicejava","title":"5. BookStoreService.java","text":"package com.example.jpademo.services;\n\nimport com.example.jpademo.dao.IBookStoreDAO;\nimport com.example.jpademo.entity.Book;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\nimport java.util.List;\n\n@Service\npublic class BookStoreService implements IBookStoreService {\n\n @Autowired\n private IBookStoreDAO dao;\n\n @Override\n public List<Book> getBooks() {\n return dao.getBooks();\n }\n\n @Override\n public Book createBook(Book book) {\n return dao.createBook(book);\n }\n\n @Override\n public Book updateBook(int bookId, Book book) {\n return dao.updateBook(bookId, book);\n }\n\n @Override\n public Book getBook(int bookId) {\n return dao.getBook(bookId);\n }\n\n @Override\n public boolean deleteBook(int bookId) {\n return dao.deleteBook(bookId);\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#6-ibookstoreservicejava","title":"6. IBookStoreService.java","text":"package com.example.jpademo.services;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreService {\n\n List<Book> getBooks();\n Book createBook(Book book);\n Book updateBook(int bookId, Book book);\n Book getBook(int bookId);\n boolean deleteBook(int bookId);\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#7-jpademoapplication","title":"7. JpademoApplication","text":"package com.example.jpademo;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication\npublic class JpademoApplication {\n\n public static void main(String[] args) {\n SpringApplication.run(JpademoApplication.class, args);\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#_4","title":"\u6d4b\u8bd5","text":"\u6784\u5efa\u5e76\u542f\u52a8\u8fd9\u4e2a\u9879\u76ee\u3002
\u5f53\u51fa\u73b0\u4e0b\u9762\u7684\u6d88\u606f\u793a\u4f8b\u65f6\uff0c\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u6b63\u5e38\u542f\u52a8\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 Postman \u8c03\u7528 REST \u7aef\u53e3\u3002
2022-10-27 11:16:16.793 INFO 93488 --- [ main] com.example.jpademo.JpademoApplication : Starting JpademoApplication on username-macbookpro.local with PID 93488 (/Users/username/IdeaProjects/jpademo/target/classes started by username in /Users/username/IdeaProjects/jpademo)\n2022-10-27 11:16:16.796 INFO 93488 --- [ main] com.example.jpademo.JpademoApplication : No active profile set, falling back to default profiles: default\n2022-10-27 11:16:18.022 INFO 93488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.\n2022-10-27 11:16:18.093 INFO 93488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 50ms. Found 0 JPA repository interfaces.\n2022-10-27 11:16:18.806 INFO 93488 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)\n2022-10-27 11:16:18.814 INFO 93488 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]\n2022-10-27 11:16:18.814 INFO 93488 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-27 11:16:18.886 INFO 93488 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext\n2022-10-27 11:16:18.886 INFO 93488 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2005 ms\n2022-10-27 11:16:19.068 INFO 93488 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]\n2022-10-27 11:16:19.119 INFO 93488 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final\n2022-10-27 11:16:19.202 INFO 93488 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}\n2022-10-27 11:16:19.282 INFO 93488 --- [ main] com.zaxxer.hikari.HikariDataSource : defaultDataSource - Starting...\n2022-10-27 11:16:20.025 INFO 93488 --- [ main] com.zaxxer.hikari.HikariDataSource : defaultDataSource - Start completed.\n2022-10-27 11:16:20.035 INFO 93488 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect\n2022-10-27 11:16:21.929 INFO 93488 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]\n2022-10-27 11:16:21.937 INFO 93488 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'\n2022-10-27 11:16:22.073 WARN 93488 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning\n2022-10-27 11:16:22.221 INFO 93488 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-27 11:16:22.415 INFO 93488 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-27 11:16:22.430 INFO 93488 --- [ main] com.example.jpademo.JpademoApplication : Started JpademoApplication in 6.079 seconds (JVM running for 8.765)\n2022-10-27 11:16:40.180 INFO 93488 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'\n2022-10-27 11:16:40.183 INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'\n2022-10-27 11:16:40.249 INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 66 ms\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-book-get","title":"1. \u83b7\u53d6 Book \u5217\u8868\uff0c\u4f7f\u7528 GET \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":"http://localhost:8080/bookservice/books\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-book-post","title":"2. \u521b\u5efa\u4e00\u4e2a\u65b0 Book\uff0c\u4f7f\u7528 POST \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":"http://localhost:8080/bookservice/books\n
\u5c06 Header \u4e2d\u7684\u5185\u5bb9\u7c7b\u578b\u8bbe\u7f6e\u4e3a application/json
\uff0c\u5c06 Request Body \u8bbe\u7f6e\u4e3a\u539f\u59cb JSON \u6709\u6548\u8d1f\u8f7d\u3002
{\n \"name\": \"The Lion, the Witch and the Wardrobe\",\n \"author\": \"C. S. Lewis\",\n \"publication\": \"Amazon\",\n \"category\": \"Fantancy\",\n \"pages\": 123,\n \"price\": 10\n }\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-book-get","title":"3. \u5982\u9700\u83b7\u53d6\u7279\u5b9a Book\uff0c\u4f7f\u7528 GET \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":" http://localhost:8080/bookservice/books/<id>\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-book-put","title":"4. \u5728\u6570\u636e\u5e93\u4e2d\u5347\u7ea7 Book\uff0c\u4f7f\u7528 PUT \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":" http://localhost:8080/bookservice/books/<id>\n
\u5c06 Header \u4e2d\u7684\u5185\u5bb9\u7c7b\u578b\u8bbe\u7f6e\u4e3a application/json
\u3002
\u5c06 Request Body \u8bbe\u7f6e\u4e3a\u539f\u59cb JSON \u6709\u6548\u8d1f\u8f7d
{\n \"name\": \"Black Beauty\",\n \"author\": \"Anna Sewell\",\n \"publication\": \"Amazon\",\n \"category\": \"Fantancy\",\n \"pages\": 134,\n \"price\": 12\n }\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-book-delete","title":"5. \u5982\u9700\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664\u7279\u5b9a\u7684 Book\uff0c\u4f7f\u7528 DELETE \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":" http://localhost:8080/bookservice/books/<id>\n
mysql> select * from book;\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n| id | author | category | name | pages | price | publication |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n| 1 | Antoine de Saint-Exupery | Fantancy | The Little Prince | 100 | 50 | Amazon |\n| 2 | Anna Sewell | Fantancy | Black Beauty | 134 | 12 | Amazon |\n| 3 | Lewis Carroll | Fantancy | Alice's Adventures in Wonderland | 1500 | 240 | Amazon |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n3 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/","title":"SpringBoot \u548c MyBatis \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 SpringBoot\u3001Mybatis \u548c Intellij IDEA \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#_1","title":"\u5f00\u59cb\u4e4b\u524d","text":"\u672c\u7bc7\u6559\u7a0b\u6d89\u53ca\u5230\u7684\u8f6f\u4ef6\u4ecb\u7ecd\u5982\u4e0b\uff1a
MyBatis\uff1aMyBatis \u662f\u4e00\u6b3e\u4f18\u79c0\u7684\u6301\u4e45\u5c42\u6846\u67b6\uff0c\u5b83\u652f\u6301\u81ea\u5b9a\u4e49 SQL\u3001\u5b58\u50a8\u8fc7\u7a0b\u4ee5\u53ca\u9ad8\u7ea7\u6620\u5c04\u3002\u6211\u4eec\u53ea\u9700\u8981\u5173\u6ce8\u9879\u76ee\u4e2d\u7684 SQL \u672c\u8eab\u3002
Intellij IDEA\uff1aIntelliJ IDEA \u662f\u4e00\u79cd\u5546\u4e1a\u5316\u9500\u552e\u7684 Java \u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08Integrated Development Environment\uff0cIDE\uff09\u5de5\u5177\u8f6f\u4ef6\u3002\u5b83\u6240\u62e5\u6709\u7684\u8bf8\u591a\u63d2\u4ef6\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6211\u4eec\u7684\u5de5\u4f5c\u6548\u7387\u3002
Maven\uff1aMaven \u662f Java \u4e2d\u529f\u80fd\u5f3a\u5927\u7684\u9879\u76ee\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u6839\u636e pom.xml \u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u81ea\u52a8\u4e0b\u8f7d\u548c\u5bfc\u5165 Jar \u6587\u4ef6\u3002\u8fd9\u4e2a\u7279\u6027\u51cf\u5c11\u4e86\u4e0d\u540c\u7248\u672c Jar \u6587\u4ef6\u4e4b\u95f4\u7684\u51b2\u7a81\u3002
Spring\uff1aSpring \u662f Java \u4e2d\u6700\u6d41\u884c\u7684\u6846\u67b6\u4e4b\u4e00\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u4f01\u4e1a\u4f7f\u7528 Spring \u6846\u67b6\u6765\u6784\u5efa\u4ed6\u4eec\u7684\u9879\u76ee\u3002Spring Boot \u6784\u5efa\u5728\u4f20\u7edf\u7684 Spring \u6846\u67b6\u4e4b\u4e0a\u3002\u56e0\u6b64\uff0c\u5b83\u63d0\u4f9b\u4e86 Spring \u7684\u6240\u6709\u7279\u6027\uff0c\u800c\u4e14\u6bd4 Spring \u66f4\u6613\u7528\u3002
\u6309\u7167\u6b65\u9aa4\u4ecb\u7ecd\u5b8c\u6210\u5b89\u88c5\u5355\u673a\u7248 MatrixOne\uff0c\u5728 MySQL \u5ba2\u6237\u7aef\u65b0\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a test
\u6570\u636e\u5e93\u3002
mysql> create database test;\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-intellij-idea-spring-boot","title":"2. \u4f7f\u7528 IntelliJ IDEA \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Spring Boot \u9879\u76ee","text":"\u9009\u62e9 Spring Initializer\uff0c\u6309\u9700\u547d\u540d\u9879\u76ee\u540d\u79f0\u3002
\u9009\u62e9\u5982\u4e0b\u4f9d\u8d56\u9879\uff1a
\u70b9\u51fb Create \u521b\u5efa\u9879\u76ee\u3002\u4f9d\u8d56\u9879\u5217\u5728 pom.xml \u6587\u4ef6\u4e2d\u3002\u901a\u5e38\u4f60\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u4e1c\u897f\u3002
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n <groupId>com.example</groupId>\n <artifactId>mybatis-demo</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <name>mybatis-demo</name>\n <description>mybatis-demo</description>\n\n <properties>\n <java.version>1.8</java.version>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n </properties>\n\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-jdbc</artifactId>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-web</artifactId>\n </dependency>\n <dependency>\n <groupId>org.mybatis.spring.boot</groupId>\n <artifactId>mybatis-spring-boot-starter</artifactId>\n <version>2.1.4</version>\n </dependency>\n\n <dependency>\n <groupId>mysql</groupId>\n <artifactId>mysql-connector-java</artifactId>\n <scope>runtime</scope>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-test</artifactId>\n <scope>test</scope>\n <exclusions>\n <exclusion>\n <groupId>org.junit.vintage</groupId>\n <artifactId>junit-vintage-engine</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n </dependencies>\n\n <dependencyManagement>\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-dependencies</artifactId>\n <version>${spring-boot.version}</version>\n <type>pom</type>\n <scope>import</scope>\n </dependency>\n </dependencies>\n </dependencyManagement>\n\n <build>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-compiler-plugin</artifactId>\n <version>3.8.1</version>\n <configuration>\n <source>1.8</source>\n <target>1.8</target>\n <encoding>UTF-8</encoding>\n </configuration>\n </plugin>\n <plugin>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-maven-plugin</artifactId>\n <version>2.3.7.RELEASE</version>\n <configuration>\n <mainClass>com.example.mybatisdemo.MybatisDemoApplication</mainClass>\n </configuration>\n <executions>\n <execution>\n <id>repackage</id>\n <goals>\n <goal>repackage</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n\n</project>\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-applicationproperties","title":"3. \u4fee\u6539 application.properties \u6587\u4ef6","text":"\u8fdb\u5165\u5230 resources \u6587\u4ef6\u76ee\u5f55\u4e0b\uff0c\u914d\u7f6e application.properties \u6587\u4ef6\uff0c\u5b8c\u6210 MatrixOne \u8fde\u63a5\u3002
# Application Name\nspring.application.name=MyBatisDemo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with paratemers\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n\n# Mybatis mapper location\nmybatis.mapper-locations=classpath:mapping/*xml\n# Mybatis entity package\nmybatis.type-aliases-package=com.example.mybatisdemo.entity\n# Web application port\nserver.port=8080\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#_3","title":"\u7f16\u5199\u4ee3\u7801","text":"\u5b8c\u6210\u73af\u5883\u914d\u7f6e\u540e\uff0c\u6211\u4eec\u7f16\u5199\u4ee3\u7801\u6765\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u5e94\u7528\u7a0b\u5e8f\u3002
\u5728\u5b8c\u6210\u7f16\u5199\u4ee3\u7801\u540e\uff0c\u4f60\u5c06\u62e5\u6709\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684\u9879\u76ee\u7ed3\u6784\u3002\u4f60\u53ef\u4ee5\u9884\u5148\u521b\u5efa\u8fd9\u4e9b\u5305\u548c java \u7c7b\u3002
\u6211\u4eec\u5c06\u4e3a\u8fd9\u4e2a\u6f14\u793a\u5e94\u7528\u7a0b\u5e8f\u7f16\u5199\u521b\u5efa\u3001\u66f4\u65b0\u3001\u63d2\u5165\u3001\u5220\u9664\u548c\u9009\u62e9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-usercontrollerjava","title":"1. UserController.java","text":"package com.example.mybatisdemo.controller;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.service.UserService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.ResponseBody;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\n@RequestMapping(\"/test\")\npublic class UserController {\n\n String tableName = \"user\";\n @Autowired\n private UserService userService;\n\n @RequestMapping(value = \"/create\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n @ResponseBody\n public String createTable(){\n return userService.createTable(tableName);\n }\n\n @RequestMapping(value = \"/selectUserByid\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n @ResponseBody\n public String GetUser(User user){\n return userService.Sel(user).toString();\n }\n\n @RequestMapping(value = \"/add\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n public String Add(User user){\n return userService.Add(user);\n }\n\n @RequestMapping(value = \"/update\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n public String Update(User user){\n return userService.Update(user);\n }\n\n @RequestMapping(value = \"/delete\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n public String Delete(User user){\n return userService.Delete(user);\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-userjava","title":"2. User.java","text":"package com.example.mybatisdemo.entity;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\n\npublic class User {\n private Integer id;\n private String username;\n private String password;\n private String address;\n\n public User(Integer id, String username, String password, String address) {\n this.id = id;\n this.username = username;\n this.password = password;\n this.address = address;\n }\n\n public Integer getId() {\n return id;\n }\n\n public String getUsername() {\n return username;\n }\n\n public String getPassword() {\n return password;\n }\n\n public String getAddress() {\n return address;\n }\n\n public void setId(Integer id) {\n this.id = id;\n }\n\n public void setUsername(String username) {\n this.username = username;\n }\n\n public void setPassword(String password) {\n this.password = password;\n }\n\n public void setAddress(String address) {\n this.address = address;\n }\n\n @Override\n public String toString() {\n return \"User{\" +\n \"id=\" + id +\n \", username='\" + username + '\\'' +\n \", password='\" + password + '\\'' +\n \", address='\" + address + '\\'' +\n '}';\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-usermapperjava","title":"3. UserMapper.java","text":"package com.example.mybatisdemo.mapper;\n\nimport com.example.mybatisdemo.entity.User;\nimport org.apache.ibatis.annotations.Param;\nimport org.springframework.stereotype.Repository;\n\n@Repository\npublic interface UserMapper {\n\n int createTable(@Param(\"tableName\") String tableName);\n\n User Sel(@Param(\"user\")User user);\n\n int Add(@Param(\"user\")User user);\n\n int Update(@Param(\"user\")User user);\n\n int Delete(@Param(\"user\")User user);\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4-userservicejava","title":"4. UserService.java","text":"package com.example.mybatisdemo.service;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.mapper.UserMapper;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class UserService {\n @Autowired\n UserMapper userMapper;\n\n public String createTable(String table){\n int a = userMapper.createTable(table);\n if (a == 1) {\n return \"Create table failed\";\n } else {\n return \"Create table successfully\";\n }\n }\n\n public User Sel(User user) {\n return userMapper.Sel(user);\n }\n\n public String Add(User user) {\n int a = userMapper.Add(user);\n if (a == 1) {\n return \"Add user successfully\";\n } else {\n return \"Add user failed\";\n }\n }\n\n public String Update(User user) {\n int a = userMapper.Update(user);\n if (a == 1) {\n return \"Update user successfully\";\n } else {\n return \"Update user failed\";\n }\n }\n\n public String Delete(User user) {\n int a = userMapper.Delete(user);\n if (a == 1) {\n return \"Delete user successfully\";\n } else {\n return \"Delete user failed\";\n }\n }\n\n};\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5-mybatisdemoapplicationjava","title":"5. MyBatisDemoApplication.java","text":"package com.example.mybatisdemo;\n\nimport org.mybatis.spring.annotation.MapperScan;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@MapperScan(\"com.example.mybatisdemo.mapper\")\n@SpringBootApplication\npublic class MyBatisDemoApplication {\n public static void main(String[] args) {\n SpringApplication.run(MyBatisDemoApplication.class, args);\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#6-usermapperxml","title":"6. UserMapper.xml","text":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">\n\n<mapper namespace=\"com.example.mybatisdemo.mapper.UserMapper\">\n\n <resultMap id=\"BaseResultMap\" type=\"com.example.mybatisdemo.entity.User\">\n <result column=\"id\" jdbcType=\"INTEGER\" property=\"id\"/>\n <result column=\"userName\" jdbcType=\"VARCHAR\" property=\"username\"/>\n <result column=\"passWord\" jdbcType=\"VARCHAR\" property=\"password\"/>\n <result column=\"realName\" jdbcType=\"VARCHAR\" property=\"address\"/>\n </resultMap>\n\n <update id=\"createTable\" parameterType=\"string\">\n CREATE TABLE ${tableName} (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `username` varchar(255) DEFAULT NULL,\n `password` varchar(255) DEFAULT NULL,\n `address` varchar(255) DEFAULT NULL,\n PRIMARY KEY (`id`)\n );\n </update>\n\n <select id=\"Sel\" resultType=\"com.example.mybatisdemo.entity.User\">\n select * from user where 1=1\n <if test=\"user.id != null\">\n AND id = #{user.id}\n </if>\n </select>\n\n <insert id=\"Add\" parameterType=\"com.example.mybatisdemo.entity.User\">\n INSERT INTO user\n <trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">\n <if test=\"user.username != null\">\n username,\n </if>\n <if test=\"user.password != null\">\n password,\n </if>\n <if test=\"user.address != null\">\n address,\n </if>\n </trim>\n <trim prefix=\"VALUES (\" suffix=\")\" suffixOverrides=\",\">\n <if test=\"user.username != null\">\n #{user.username,jdbcType=VARCHAR},\n </if>\n <if test=\"user.password != null\">\n #{user.password,jdbcType=VARCHAR},\n </if>\n <if test=\"user.address != null\">\n #{user.address,jdbcType=VARCHAR},\n </if>\n </trim>\n </insert>\n\n <update id=\"Update\" parameterType=\"com.example.mybatisdemo.entity.User\">\n UPDATE user\n <set>\n <if test=\"user.username != null\">\n username = #{user.username},\n </if>\n <if test=\"user.password != null\">\n password = #{user.password},\n </if>\n <if test=\"user.address != null\">\n address = #{user.address},\n </if>\n </set>\n WHERE\n id=#{user.id}\n </update>\n\n <delete id=\"Delete\" parameterType=\"com.example.mybatisdemo.entity.User\">\n DELETE FROM user WHERE id = #{user.id}\n </delete>\n\n</mapper>\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#_4","title":"\u6d4b\u8bd5","text":"\u6784\u5efa\u5e76\u542f\u52a8\u8fd9\u4e2a\u9879\u76ee\u3002
\u5f53\u51fa\u73b0\u4e0b\u9762\u7684\u6d88\u606f\u793a\u4f8b\u65f6\uff0c\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u6b63\u5e38\u542f\u52a8\uff0c\u4f60\u53ef\u4ee5\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u53d1\u9001 HTTP \u8bf7\u6c42\u3002
2022-10-26 16:13:24.030 INFO 60253 --- [ main] c.e.mybatisdemo.MyBatisDemoApplication : Starting MyBatisDemoApplication on username-macbookpro.local with PID 60253 (/Users/username/IdeaProjects/MyBatisDemo/target/classes started by username in /Users/username/IdeaProjects/MyBatisDemo)\n2022-10-26 16:13:24.035 INFO 60253 --- [ main] c.e.mybatisdemo.MyBatisDemoApplication : No active profile set, falling back to default profiles: default\n2022-10-26 16:13:25.415 INFO 60253 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)\n2022-10-26 16:13:25.421 INFO 60253 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]\n2022-10-26 16:13:25.421 INFO 60253 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-26 16:13:25.476 INFO 60253 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext\n2022-10-26 16:13:25.477 INFO 60253 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1390 ms\n2022-10-26 16:13:26.020 INFO 60253 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-26 16:13:26.248 INFO 60253 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-26 16:13:26.272 INFO 60253 --- [ main] c.e.mybatisdemo.MyBatisDemoApplication : Started MyBatisDemoApplication in 2.669 seconds (JVM running for 3.544)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1","title":"1. \u6d4b\u8bd5\u65b0\u5efa\u8868","text":"\u6253\u5f00\u4f60\u7684\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/create
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u9a8c\u8bc1\u8868\u662f\u5426\u5df2\u6210\u529f\u521b\u5efa\u3002
mysql> use test;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| user |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> show create table user;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| user | CREATE TABLE `user` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`username` VARCHAR(255) DEFAULT null,\n`password` VARCHAR(255) DEFAULT null,\n`address` VARCHAR(255) DEFAULT null,\nPRIMARY KEY (`id`)\n) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2","title":"2. \u6d4b\u8bd5\u589e\u52a0\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/add?username=tom&password=123456&address=shanghai
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u6dfb\u52a0\u8bb0\u5f55\uff1a
mysql> select * from user;\n+------+----------+----------+----------+\n| id | username | password | address |\n+------+----------+----------+----------+\n| 1 | tom | 123456 | shanghai |\n+------+----------+----------+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3","title":"3. \u6d4b\u8bd5\u67e5\u8be2\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/selectUserByid?id=1
\u4f60\u53ef\u4ee5\u76f4\u63a5\u4ece\u6d4f\u89c8\u5668\u4e2d\u83b7\u53d6\u67e5\u8be2\u7ed3\u679c\u3002
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4","title":"4. \u6d4b\u8bd5\u66f4\u65b0\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/update?id=1&username=tom&password=654321&address=beijing
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u66f4\u65b0\u8bb0\u5f55\uff1a
mysql> select * from user;\n+------+----------+----------+---------+\n| id | username | password | address |\n+------+----------+----------+---------+\n| 1 | tom | 654321 | beijing |\n+------+----------+----------+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5","title":"5. \u6d4b\u8bd5\u5220\u9664\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/delete?id=1
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5220\u9664\u8bb0\u5f55\uff1a
mysql> select * from user;\nEmpty set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/","title":"SQLAlchemy \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 Python \u548c SQLAlchemy \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
SQLAlchemy \u662f Python \u8bed\u8a00\u4e2d\u6700\u6d41\u884c\u7684 ORM \u5de5\u5177\u4e4b\u4e00\u3002
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u76f8\u5173\u8f6f\u4ef6\u7684\u7b80\u5355\u4ecb\u7ecd\uff1a
SQLAlchemy\uff1aSQLAlchemy \u662f\u4e00\u4e2a Python \u5e93\uff0c\u53ef\u4ee5\u4fc3\u8fdb Python \u7a0b\u5e8f\u548c\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5927\u591a\u6570\u65f6\u5019\uff0c\u8fd9\u4e2a\u5e93\u7528\u4f5c\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668 (ORM) \u5de5\u5177\uff0c\u5c06 Python \u7c7b\u8f6c\u6362\u4e3a\u5173\u7cfb\u6570\u636e\u5e93\u4e0a\u7684\u8868\uff0c\u5e76\u81ea\u52a8\u5c06\u51fd\u6570\u8c03\u7528\u8f6c\u6362\u4e3a SQL \u8bed\u53e5\u3002
Faker\uff1aFaker \u662f\u4e00\u4e2a\u751f\u6210\u5047\u6570\u636e\u7684 Python \u5e93\u3002\u865a\u5047\u6570\u636e\u901a\u5e38\u7528\u4e8e\u6d4b\u8bd5\u6216\u7528\u4e00\u4e9b\u865a\u62df\u6570\u636e\u586b\u5145\u6570\u636e\u5e93\u3002
\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u5e76\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a test \u7684\u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
```\n#To check with Python installation and its version\npython3 -V\n```\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 sqlalchemy
\u3001pymysql
\u3001cryptography
\u548c faker
\u5de5\u5177\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 sqlalchemy
\u3001pymysql
\u3001cryptography
\u548c faker
\u5de5\u5177\uff1a
```\npip3 install sqlalchemy\npip3 install pymysql\npip3 install cryptography\npip3 install faker\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install faker -i https://pypi.tuna.tsinghua.edu.cn/simple\n```\n
\u4f60\u53ef\u4ee5\u53c2\u8003 Python \u8fde\u63a5 MatrixOne \u670d\u52a1\u4e86\u89e3\u5982\u4f55\u901a\u8fc7 SQLAlchemy
\u8fde\u63a5\u5230 MatrixOne\uff0c\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664)\u3002
\u4f5c\u4e3a\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668\uff08ORM\uff09\u5de5\u5177\uff0cSQLAlchemy \u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u521b\u5efa Python \u7c7b\u6765\u6620\u5c04\u5173\u7cfb\u6570\u636e\u5e93\u4e2d\u7684\u8868\u3002
\u5728\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\uff0c\u5c06\u521b\u5efa\u4e00\u4e2a Customer
\u7c7b\uff0c\u5b83\u5b9a\u4e49\u7684 Customer
\u7684\u4ee3\u7801\u76f8\u5f53\u4e8e\u4e00\u6761 SQL \u8bed\u53e5\uff0c\u5b83\u8868\u793a MatrixOne \u4e2d\u7684\u547d\u540d\u4e3a Customer
\u7684\u8868\uff1a
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_create.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from faker import Factory\nfrom sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nfaker = Factory.create()\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# Generate 10 Customer records\nCustomers = [Customer(name= faker.name(),address = faker.address()) for i in range(10)]\n\n# Create the table\nBase.metadata.create_all(engine)\n\n# Insert all customer records to Customer table\nsession.add_all(Customers)\n\nsession.commit()\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\uff1a
> python3 sqlalchemy_create.py\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u521b\u5efa\u6210\u529f\uff1a
mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| Customer |\n+----------------+\n1 row in set (0.04 sec)\nmysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id | cname | caddress |\n+------+------------------+-----------------------------------------------------+\n| 1 | Wendy Luna | 002 Brian Plaza\nAndrewhaven, SC 88456 |\n| 2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249 |\n| 3 | Angela Ramos | 029 Todd Curve Apt. 352\nMooreville, FM 15950 |\n| 4 | Lisa Bruce | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853 |\n| 5 | Julie Moore | Unit 1117 Box 1029\nDPO AP 87468 |\n| 6 | David Massey | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549 |\n| 7 | David Mccann | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n| 8 | Morgan Price | 57463 Lisa Drive\nThompsonshire, NM 88077 |\n| 9 | Samuel Griffin | 186 Patel Crossing\nNorth Stefaniechester, WV 08221 |\n| 10 | Tristan Pierce | 593 Blankenship Rapids\nNew Jameshaven, SD 89585 |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_4","title":"\u8bfb\u53d6\u6570\u636e","text":"\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5c06\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u4ece Customer
\u8868\u4e2d\u8bfb\u53d6\u6570\u636e\u3002
\u7b2c\u4e00\u79cd\u65b9\u5f0f\u662f\u5168\u8868\u626b\u63cf\uff1a
select * from `Customer`\n
\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u662f\u70b9\u67e5\u8be2\uff1a
select * from `Customer` where `cname` = 'David Mccann';\n
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_read.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n print(customer.__str__() +\"\\n--------------------------\\n\")\n\n# query with a filter condition\nMccann = session.query(Customer).filter_by(cname='David Mccann').first()\nprint(Mccann)\nprint(\"\\n------------------------\\n\")\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u5e76\u67e5\u770b\u7ed3\u679c\uff1a
> python3 sqlalchemy_read.py\ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n--------------------------\n\ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n\n------------------------\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_5","title":"\u66f4\u65b0\u6570\u636e","text":"\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u66f4\u65b0 Customer \u8868\u7684\u7b2c\u4e00\u4e2a cname \u5217\u4e3a\u53e6\u4e00\u4e2a\u503c\u3002
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_update.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\ncustomer = session.query(Customer).first()\nprint(customer)\nprint(\"\\n---------------------\\n\")\n\n# Rename customer\ncustomer.cname = \"Coby White\"\n\n\nsession.commit()\n\n# See the updated result\ncustomer = session.query(Customer).first()\nprint(customer)\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u5e76\u67e5\u770b\u7ed3\u679c\uff1a
> python3 sqlalchemy_update.py \ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n\n---------------------\n\ncname:Coby White caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u66f4\u65b0\u6210\u529f\uff1a
mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id | cname | caddress |\n+------+------------------+-----------------------------------------------------+\n| 1 | Coby White | 002 Brian Plaza\nAndrewhaven, SC 88456 |\n| 2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249 |\n| 3 | Angela Ramos | 029 Todd Curve Apt. 352\nMooreville, FM 15950 |\n| 4 | Lisa Bruce | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853 |\n| 5 | Julie Moore | Unit 1117 Box 1029\nDPO AP 87468 |\n| 6 | David Massey | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549 |\n| 7 | David Mccann | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n| 8 | Morgan Price | 57463 Lisa Drive\nThompsonshire, NM 88077 |\n| 9 | Samuel Griffin | 186 Patel Crossing\nNorth Stefaniechester, WV 08221 |\n| 10 | Tristan Pierce | 593 Blankenship Rapids\nNew Jameshaven, SD 89585 |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_6","title":"\u5220\u9664\u6570\u636e","text":"\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5220\u9664 Customer \u8868\u7684\u7b2c\u4e00\u6761\u6570\u636e\u3002
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_detele.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# delete the first record\ncustomer = session.query(Customer).first()\n\nsession.delete(customer)\nsession.commit()\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n print(customer.__str__() +\"\\n--------------------------\\n\")\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u5e76\u67e5\u770b\u7ed3\u679c\uff1a
> python3 sqlalchemy_delete.py \ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u4e2d\u7684\u8bb0\u5f55\u662f\u5426\u5220\u9664\u6210\u529f\uff1a
mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id | cname | caddress |\n+------+------------------+-----------------------------------------------------+\n| 2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249 |\n| 3 | Angela Ramos | 029 Todd Curve Apt. 352\nMooreville, FM 15950 |\n| 4 | Lisa Bruce | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853 |\n| 5 | Julie Moore | Unit 1117 Box 1029\nDPO AP 87468 |\n| 6 | David Massey | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549 |\n| 7 | David Mccann | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n| 8 | Morgan Price | 57463 Lisa Drive\nThompsonshire, NM 88077 |\n| 9 | Samuel Griffin | 186 Patel Crossing\nNorth Stefaniechester, WV 08221 |\n| 10 | Tristan Pierce | 593 Blankenship Rapids\nNew Jameshaven, SD 89585 |\n+------+------------------+-----------------------------------------------------+\n9 rows in set (0.04 sec)\n
"}]}
\ No newline at end of file
+{"config":{"lang":["en"],"separator":"[\\s\\-,:!=\\[\\]()\"/]+|[\uff0c\u3002\uff01\uff1f\u2026\uff1a\u201c\u201d\u2018\u2019\uff08\uff09\u2014\u3010\u3011\u300a\u300b]|(?!\\b)(?=[A-Z][a-z])|\\.(?!\\d)|&[lg]t;","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"MatrixOne \u6587\u6863","text":"\u6b22\u8fce\u6765\u5230 MatrixOne \u5b98\u65b9\u6587\u6863\u7f51\u7ad9\uff01
\u8fd9\u4e2a\u5b98\u65b9\u6587\u6863\u7f51\u7ad9\u63d0\u4f9b\u4e86\u76f8\u5173\u6982\u5ff5\u53ca\u6280\u672f\u67b6\u6784\u4ecb\u7ecd\u3001\u4ea7\u54c1\u7279\u6027\u3001\u4f7f\u7528\u6307\u5357\u548c\u53c2\u8003\u624b\u518c\uff0c\u4ee5\u5e2e\u52a9\u60a8\u4f7f\u7528 MatrixOne\u3002
"},{"location":"#_1","title":"\u63a8\u8350\u9605\u8bfb \ud83d\udc49","text":"\u4ece\u4e0b\u9762\u7684\u6587\u7ae0\u4e2d\u9009\u62e9\u4e00\u7bc7\uff0c\u5f00\u59cb\u60a8\u7684 MatrixOne \u4e4b\u65c5\u3002\u5982\u679c\u60a8\uff1a
\u5bf9 MatrixOne \u8fd8\u4e0d\u719f\u6089\uff0c\u8bf7\u4ece\u6982\u8ff0\u5f00\u59cb\uff0c\u4e86\u89e3 MatrixOne \u7684\u57fa\u672c\u6982\u5ff5\uff0c\u5173\u952e\u529f\u80fd\u548c\u6280\u672f\u67b6\u6784\u3002
\u5982\u679c\u60a8\u60f3\u8981\u5feb\u901f\u642d\u5efa MatrixOne \u5e76\u5f00\u59cb\u4f53\u9a8c\u57fa\u672c\u529f\u80fd\uff0c\u8bf7\u4ece\u5feb\u901f\u4e0a\u624b\u5f00\u59cb\u3002
\u5982\u679c\u60a8\u662f\u4e00\u4e2a\u5e94\u7528\u5f00\u53d1\u8005\uff0c\u60f3\u8981\u5c1d\u8bd5\u4f7f\u7528 MatrixOne \u4f5c\u4e3a\u5e95\u5c42\u6570\u636e\u5e93\uff0c\u8bf7\u9009\u62e9\u5f00\u53d1\u6307\u5357\u5f00\u59cb\u3002
\u5982\u679c\u60a8\u662f\u4e00\u4f4d\u7ecf\u9a8c\u4e30\u5bcc\u7684 MatrixOne \u5f00\u53d1\u8005\uff0c\u60f3\u5bfb\u627e\u8be6\u7ec6\u7684 SQL \u8bed\u53e5\uff0c\u6570\u636e\u7c7b\u578b\u6216\u8005\u51fd\u6570\u7684\u7ec6\u8282\u53c2\u6570\uff0c\u8bf7\u81f3\u53c2\u8003\u6587\u6863\u3002
\u65e0\u8bba\u60a8\u9700\u8981\u4e86\u89e3\u57fa\u672c\u6982\u5ff5\u3001\u64cd\u4f5c\u6307\u5357\u3001\u5f00\u53d1\u6307\u5357\u8fd8\u662f\u53c2\u8003\u8d44\u6599\uff0c\u6211\u4eec\u90fd\u5728\u4e3a\u60a8\u91cf\u8eab\u6253\u9020\u5185\u5bb9\u3002
\u6211\u4eec\u8bda\u631a\u5730\u6b22\u8fce\u5927\u5bb6\u4e3a MatrixOne \u6587\u6863\u4f5c\u51fa\u8d21\u732e\u3002\u6211\u4eec\u7684\u793e\u533a\u81f4\u529b\u4e8e\u7b80\u5316\u8d21\u732e\u6d41\u7a0b\uff0c\u4f7f\u5176\u7b80\u5355\u6613\u884c\u3002\u6b64\u5916\uff0c\u6211\u4eec\u8fd8\u5c06\u6301\u7eed\u63d0\u4f9b\u66f4\u65b0\u3002
\u60a8\u4f1a\u5728\u6bcf\u4e2a\u9875\u9762\u9876\u90e8\u53d1\u73b0\u4e00\u4e2a\u7f16\u8f91\u6309\u94ae\uff0c\u70b9\u51fb\u5b83\u4ee5\u8fdb\u5165\u5171\u540c\u7f16\u8f91\u6587\u6863\u3002\u8fd9\u4e9b\u8d44\u6e90\u662f\u4e3a\u60a8\u63d0\u4f9b\u7684\uff0c\u4f9b\u60a8\u5229\u7528\u3002\u60a8\u7684\u53c2\u4e0e\u4e0d\u4ec5\u4f7f\u6211\u4eec\u53d7\u5230\u9f13\u52b1\uff0c\u800c\u4e14\u60a8\u7684\u5efa\u8bae\u4e5f\u81f3\u5173\u91cd\u8981\uff01
\u5982\u679c\u60a8\u53d1\u73b0\u4efb\u4f55\u6587\u6863\u95ee\u9898\uff0c\u8bf7\u968f\u65f6\u521b\u5efa\u4e00\u4e2a Issue \u4ee5\u544a\u77e5\u6211\u4eec\uff0c\u6216\u76f4\u63a5\u63d0\u4ea4\u4e00\u4e2a Pull Request \u4ee5\u534f\u52a9\u4fee\u590d\u6216\u66f4\u65b0\u5185\u5bb9\u3002
Note
\u6709\u5173\u5982\u4f55\u4e3a\u6587\u6863\u505a\u51fa\u8d21\u732e\uff0c\u8bf7\u53c2\u9605 \u6587\u6863\u8d21\u732e\u6307\u5357.
"},{"location":"#_3","title":"\u52a0\u5165\u6211\u4eec\uff01","text":"GitHub \u4e0a\u7684 MatrixOne \u793e\u533a\u5145\u6ee1\u6d3b\u529b\u3001\u70ed\u60c5\u4e14\u77e5\u8bc6\u6e0a\u535a\u3002\u53c2\u4e0e\u8ba8\u8bba\uff0c\u8868\u8fbe\u60a8\u7684\u89c2\u70b9\uff0c\u63d0\u51fa\u529f\u80fd\u5efa\u8bae\uff0c\u5e76\u6df1\u5165\u7814\u7a76\u4ee3\u7801\u3002
\u4e00\u4e2a\u540c\u6837\u70ed\u60c5\u6d0b\u6ea2\u7684\u793e\u533a\u5728 MatrixOne Slack \u9891\u9053\u53ca MatrixOne \u5b98\u7f51\u7b49\u5f85\u7740\u60a8\u3002
"},{"location":"MatrixOne/MatrixCampEvent/","title":"MatrixCampEvent","text":"\u6b22\u8fce\u5927\u5bb6\u6765\u5230 MatrixOne\uff0c\u8fd9\u91cc\u5c31\u662f\u4f60\u8fdb\u5165\u77e9\u9635\u4e16\u754c\u7684\u7535\u8bdd\u4ead\u4e86\uff5e\u53ee\u94c3~~~
\u82f1\u6587\u7248\u672c\u6d3b\u52a8\u8bf4\u660e\u4f20\u9001\u95e8
"},{"location":"MatrixOne/MatrixCampEvent/#matrixcamp2022","title":"MatrixCamp2022 \u6d3b\u52a8","text":"MatrixCamp \u662f\u4e00\u4e2a\u7531 MatrixOne \u793e\u533a\u4e3e\u529e\u7684\u5f00\u53d1\u8005\u6d3b\u52a8\uff0c\u6b22\u8fce\u5bf9\u6570\u636e\u5e93\u6280\u672f\u611f\u5174\u8da3\u7684\u5f00\u53d1\u8005\u4eec\u6765\u53c2\u4e0e\u8fd9\u6b21\u4e3a\u671f 2 \u5468\u7684\u5f00\u53d1\u6311\u6218\u4efb\u52a1\u3002 MatrixOne \u793e\u533a\u4e00\u5171\u51c6\u5907\u4e86 4 \u4e2a\u7c7b\u522b\u7684 56 \u4e2a\u4efb\u52a1\uff0c\u6709\u4e0d\u540c\u7684\u96be\u5ea6\u7ea7\u522b\u548c\u529f\u80fd\u7c7b\u578b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6311\u9009\u81ea\u5df1\u611f\u5174\u8da3\u7684\u8fdb\u884c\u6311\u6218\u3002\u53c2\u4e0e\u6311\u6218\u4ec5\u9700\u8981\u4e00\u4e9b\u57fa\u7840\u7684 Golang \u8bed\u8a00\u7f16\u7a0b\u7ecf\u9a8c\u5c31\u591f\u4e86\uff0c\u53e6\u5916\u6211\u4eec\u4e5f\u6709\u8be6\u5c3d\u7684\u5f00\u53d1\u6307\u5357\u7684\u8010\u5fc3\u7684 mentor \u7ed9\u5927\u5bb6\u8fdb\u884c\u670d\u52a1\u3002
\u8fd9\u6b21\u7684\u4efb\u52a1\u5927\u5bb6\u5c06\u8981\u6311\u6218\u7684\u662f MatrixOne \u7684\u7cfb\u7edf\u51fd\u6570\u548c\u805a\u5408\u51fd\u6570\uff0c\u5bf9\u4e8e\u521a\u5165\u95e8\u6570\u636e\u5e93\u7684\u540c\u5b66\u6765\u8bb2\u662f\u76f8\u5bf9\u57fa\u7840\u4f46\u662f\u53c8\u4e0d\u4e4f\u6311\u6218\u7684\u4efb\u52a1\u3002
\u57fa\u7840\u4efb\u52a1 - \u7cfb\u7edf\u51fd\u6570\uff08Built-in function\uff09: \u6240\u8c13\u7684\u7cfb\u7edf\u51fd\u6570\u5c31\u662f\u6570\u636e\u5e93\u81ea\u5e26\u7684\u9488\u5bf9\u4e00\u4e9b\u57fa\u7840\u6570\u636e\u7c7b\u578b\u8fdb\u884c\u64cd\u4f5c\u7684\u51fd\u6570\uff0c\u6bd4\u5982\u5e38\u89c1\u7684 round(), time(), substring() \u7b49\u7b49\u3002\u7b2c\u4e00\u5468\u5c06\u6709 25 \u4e2a\u7cfb\u7edf\u51fd\u6570\u4f5c\u4e3a\u57fa\u7840\u4efb\u52a1\u53d1\u5e03\u7ed9\u5927\u5bb6\u8fdb\u884c\u6311\u6218\uff0c\u5305\u542b\u6570\u5b66\u7c7b\u51fd\u6570\uff0c\u65f6\u95f4\u65e5\u671f\u7c7b\u51fd\u6570\uff0c\u5b57\u7b26\u4e32\u7c7b\u51fd\u6570\uff0c\u6709 9 \u4e2a\u4efb\u52a1\u975e\u5e38\u5bb9\u6613\uff0c16 \u4e2a\u4efb\u52a1\u7a0d\u5fae\u6709\u4e00\u4e9b\u96be\u5ea6\uff0c\u53ea\u8981\u4f60\u6709\u4e00\u5b9a\u7684 go \u8bed\u8a00\u57fa\u7840\uff0c\u770b\u5f97\u61c2\u82f1\u6587\u6587\u6863\uff0c\u5c31\u80fd\u5feb\u901f\u4e0a\u624b\u89e3\u51b3\u54e6\u3002
\u6311\u6218\u4efb\u52a1 - \u805a\u5408\u51fd\u6570\uff08Aggregate function\uff09\uff1a\u6240\u8c13\u7684\u805a\u5408\u51fd\u6570\u5c31\u662f\u9700\u8981\u805a\u96c6\u4e00\u90e8\u5206\u6570\u636e\u8fdb\u884c\u8fd0\u7b97\u8fd4\u56de\u7ed3\u679c\u7684\u51fd\u6570\uff0c\u6bd4\u5982\u5e38\u89c1\u7684 sum(), count(), avg() \u7b49\u7b49\u3002\u5728 MatrixOne \u4e2d\uff0c\u5b9e\u73b0\u805a\u5408\u51fd\u6570\u662f\u8981\u7528\u5230\u6211\u4eec\u7684\u5927\u6740\u5668\u56e0\u5b50\u5316\u52a0\u901f\u80fd\u529b\u7684\uff0c\u9700\u8981\u5bf9\u56e0\u5b50\u5316\u4e2d\u7684\u201c\u73af\u201d\u6570\u636e\u7ed3\u6784\u7406\u8bba\u6709\u4e00\u5b9a\u7406\u89e3\uff0c\u5b9e\u73b0\u4f1a\u6709\u4e00\u5b9a\u590d\u6742\u5ea6\uff0c\u6240\u4ee5\u6211\u4eec\u5c06 5 \u4e2a\u805a\u5408\u51fd\u6570\u5217\u4e3a\u4e86\u6311\u6218\u4efb\u52a1\u3002
\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5148\u7ed9 MatrixOne \u9879\u76ee Star, Fork, Watch \u4e00\u4e0b\u5427\u3002
\u8bf7\u6ce8\u610f\uff1a1 \u4e2a\u5f00\u53d1\u8005\u53ef\u4ee5\u9009\u62e9\u591a\u4e2a\u6311\u6218\u4efb\u52a1\uff0c\u4f46\u662f 1 \u4e2a\u4efb\u52a1\u53ea\u80fd\u7531 1 \u4e2a\u5f00\u53d1\u8005\u5b8c\u6210
\u6765\u770b\u4e0b\u6211\u4eec\u7684\u4efb\u52a1\u5217\u8868\u5427\uff0c\u5176\u4e2d\u5df2\u7ecf\u88ab assign \u7684\u4efb\u52a1\u8bf7\u67e5\u770b\u82f1\u6587\u7248\u6d3b\u52a8\u8bf4\u660e\uff1a
"},{"location":"MatrixOne/MatrixCampEvent/#1-","title":"1. \u57fa\u7840\u4efb\u52a1 - \u6570\u5b66\u7c7b\u7cfb\u7edf\u51fd\u6570","text":"\u5b8c\u6210\u4ee3\u7801\u7f16\u5199\u4e4b\u540e\uff0c\u6309\u4ee5\u4e0b\u683c\u5f0f\u5411 MatrixOne \u63d0\u4ea4 PR:
PR \u683c\u5f0f\uff1a[MatrixCamp] + function name + PR title
PR \u5185\u5bb9\uff1a\u9075\u5faa [MatrixOne \u7684 PR \u6a21\u7248] (https://github.com/matrixorigin/matrixone/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
\u63d0\u4ea4 PR \u5b8c\u6210\u540e\uff0c\u5728\u4f60\u7684 PR \u4e0b\u9762\u6309\u4ee5\u4e0b\u683c\u5f0f\u8bc4\u8bba\uff1a \u8bc4\u8bba\u683c\u5f0f\uff1a\"I have finished Issue #\" + PR link id
Q: \u5fc5\u987b\u5148\u9886\u4efb\u52a1\u624d\u80fd\u5f00\u59cb\u4e48\uff0c\u53ef\u4ee5\u76f4\u63a5\u63d0 PR \u5417\uff1f A: \u662f\u7684\uff0c\u53c2\u4e0e\u5f00\u53d1\u8005\u90fd\u9700\u8981\u5728 issue \u4e0b\u9762\u8bc4\u8bba\u8ba4\u9886\u540e\u518d\u5f00\u59cb\u4efb\u52a1\uff0c\u4e0d\u5efa\u8bae\u76f4\u63a5\u63d0 PR\u3002\u8fd9\u6837\u662f\u4e3a\u4e86\u907f\u514d\u591a\u540d\u5f00\u53d1\u8005\u9488\u5bf9\u540c\u4e00\u95ee\u9898\u91cd\u590d\u52b3\u52a8\u3002
Q: \u4e3a\u4ec0\u4e48 select abs(-1);
\u548c select d, abs(-1) from t;
\u8fd9\u6837\u7684\u8bed\u53e5\u4f1a\u51fa\u95ee\u9898\uff1f A: \u76ee\u524d MatrixOne \u8fd8\u4e0d\u652f\u6301\u65e0\u8868\u53ca\u5e38\u6570\u53c2\u6570\u7684 SQL \u8bed\u53e5\uff0c\u56e0\u6b64 select abs(-1);
\u548c select abs(-1) from table1;
\u8fd9\u6837\u7684\u8bed\u53e5\u5747\u4f1a\u51fa\u9519\u3002\u6b63\u786e\u7684 SQL \u8bed\u53e5\u662f\u9700\u8981\u521b\u5efa\u4e00\u5f20\u8868\uff0c\u5bfc\u5165\u4e00\u4e9b\u6570\u636e\uff0c\u7136\u540e\u518d\u5c06\u5217\u540d\u4f5c\u4e3a\u53c2\u6570\u8fd0\u884c built-in \u51fd\u6570\u3002\u5982\u4ee5\u4e0b\u4f8b\u5b50\uff1a
select abs(a) from t;\n
Q: \u4e3a\u4ec0\u4e48\u6bcf\u6b21 PR \u5b8c\u6210\u4e4b\u540e\uff0c\u6211\u7684\u4ed3\u5e93\u603b\u662f\u4f1a\u6bd4 MatrixOne \u9886\u5148\uff1f A: MatrixOne \u5bf9\u6240\u6709 pr \u7684\u5408\u5e76\u90fd\u8981\u6c42\u662f squash and merge\uff0c\u56e0\u6b64 pr \u5408\u5e76\u540e\u8ddf\u4e3b\u5e72\u4f1a\u4e0d\u4e00\u81f4\u3002\u8fd9\u91cc\u63a8\u8350\u91c7\u7528\u7684 git \u6d41\u7a0b\uff0c\u53ef\u4ee5\u4fdd\u6301\u672c\u5730 git\uff0c\u8fdc\u7aef git \u4ed3\u5e93\u4e0e MatrixOne \u4ed3\u5e93\u4fdd\u6301\u4e00\u81f4\u7684\u65b9\u6cd5\uff1a
1. \u9996\u5148Fork MatrixOne\u7684\u4ed3\u5e93\u3002\n2. clone\u81ea\u5df1\u7684\u4ed3\u5e93\u5230\u672c\u5730: git clone https://github.com/YOUR_NAME/matrixone.git\n3. \u5c06MatrixOne\u4e3b\u4ed3\u5e93\u6dfb\u52a0\u4e3aremote\u4ed3\u5e93: git remote add upstream https://github.com/matrixorigin/matrixone.git\n4. \u5728\u672c\u5730\u4fee\u6539\u4ee3\u7801\uff0c\u5408\u5e76\u51b2\u7a81\uff0cetc.\n5. push\u5230\u4e00\u4e2a\u65b0\u7684\u5206\u652f: git push origin main:NEW_BRANCH\n6. \u5230\u81ea\u5df1\u4ed3\u5e93\u7684NEW_BRANCH\u5206\u652f\u63d0PR\uff0c\u7b49\u5f85\u5408\u5e76\n7. PR\u5408\u5e76\u4e4b\u540e\uff0c\u8986\u76d6\u672c\u5730\u63d0\u4ea4\u5386\u53f2: git pull --force upstream main:main\n8. \u518d\u6b21\u63d0\u4ea4\u5230\u81ea\u5df1\u7684\u8fdc\u7aef\u4ed3\u5e93\uff1agit push --force origin main:main\n
Q: \u6211\u63d0\u4ea4\u7684 PR \u5728\u81ea\u52a8\u6d4b\u8bd5\u9636\u6bb5\u5931\u8d25\u4e86\uff0c\u8fd9\u4e2a\u662f\u4ec0\u4e48\u539f\u56e0\uff1f A\uff1aMatrixOne \u4f1a\u5728 PR \u63d0\u4ea4\u4e4b\u540e\u81ea\u52a8\u8fdb\u884c\u4e00\u7cfb\u5217 CI \u53ca BVT \u6d4b\u8bd5\uff0c\u5f00\u53d1\u8005\u5728\u63d0\u4ea4\u4e4b\u540e\u53ef\u4ee5\u770b\u5230\u6d4b\u8bd5\u7684\u8fdb\u5c55\u53ca\u65e5\u5fd7\uff0c\u5982\u679c\u662f\u4e0e\u51fd\u6570\u529f\u80fd\u76f8\u5173\u7684\u6d4b\u8bd5\u6ca1\u6709\u901a\u8fc7\uff0c\u8bf7\u4fee\u6539 code \u540e\u91cd\u65b0\u63d0\u4ea4\u3002\u5982\u679c\u662f\u5176\u4ed6\u4e0e\u51fd\u6570\u65e0\u5173\u7684\u6d4b\u8bd5\u95ee\u9898\uff0c\u53ef\u4ee5\u5728 PR \u4e2d\u8fdb\u884c\u8bc4\u8bba\uff0c\u793e\u533a\u5c06\u4f1a\u67e5\u8be2\u95ee\u9898\u6240\u5728\uff0c\u4e0d\u4f1a\u5f71\u54cd\u672c\u6b21\u51fd\u6570\u4efb\u52a1\u7684\u5224\u5b9a\u7ed3\u679c\u3002\u76ee\u524d MatrixOne \u7684 CI \u6d4b\u8bd5\u6709\u4e00\u5b9a\u7684\u4e0d\u7a33\u5b9a\u7a0b\u5ea6\uff0c\u56e0\u6b64\u53ef\u80fd\u6709\u4e00\u4e9b\u4e0e\u51fd\u6570\u65e0\u5173\u7684 CI \u6d4b\u8bd5\u4f1a fail\u3002
Q: MatrixOne \u670d\u52a1\u542f\u52a8\u4e4b\u540e\u7684\u65e5\u5fd7\u4fe1\u606f\u6709\u70b9\u592a\u591a\u4e86\uff0c\u600e\u4e48\u80fd\u5173\u6389\uff1f A: \u76ee\u524d MatrixOne \u7684\u9ed8\u8ba4\u65e5\u5fd7\u7ea7\u522b\u662f DEBUG
\u7ea7\uff0c\u6240\u4ee5\u4fe1\u606f\u662f\u4f1a\u6bd4\u8f83\u591a\u7684\u3002\u63a7\u5236\u8fd9\u4e2a\u65e5\u5fd7\u7ea7\u522b\u7684\u662f\u7cfb\u7edf\u914d\u7f6e\u6587\u4ef6 system_vars_config.toml
\uff0c\u53ef\u4ee5\u5728\u8c03\u8bd5\u7684\u65f6\u5019\u5c06\u8be5\u6587\u4ef6\u7684 cubeLogLevel
\u4e0e level
\u4e24\u4e2a\u53c2\u6570\u8bbe\u7f6e\u6210 ERROR
\u7ea7\u522b\uff0c\u8fd9\u6837\u6253\u5370\u7684\u4fe1\u606f\u4f1a\u5c11\u5f88\u591a\u3002
cubeLogLevel = \"error\"\nlevel = \"error\"\n
Q: \u5982\u679c\u6211\u5bf9\u8ba4\u9886\u7684\u51fd\u6570\u5b9e\u73b0\u6709\u4e00\u4e9b\u7591\u95ee\uff0c\u6211\u5e94\u8be5\u5411\u8c01\u8be2\u95ee\uff1f A\uff1a\u5982\u679c\u662f\u9488\u5bf9 MatrixOne \u672c\u8eab\u7684\u6d4b\u8bd5\u548c\u884c\u4e3a\u53d1\u73b0 bug\uff0c\u6b22\u8fce\u5411 MatrixOne \u793e\u533a\u63d0\u51fa issue\uff0c\u6211\u4eec\u6709\u76f8\u5e94\u7684\u6a21\u7248\u5e2e\u52a9\u8bf4\u660e\u5982\u4f55\u5199 issue\uff0c\u793e\u533a\u4f1a\u5bf9 issue \u8fdb\u884c\u5904\u7406\u3002\u5982\u679c\u662f\u9488\u5bf9\u51fd\u6570\u672c\u8eab\u7684\u5b9e\u73b0\u6709\u95ee\u9898\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u8ba4\u9886\u7684 issue \u4e0b\u9762\u8bc4\u8bba\u4f60\u7684\u60f3\u6cd5\u548c\u7591\u95ee\uff0cMatrixOne \u793e\u533a\u7684 mentor \u4f1a\u53ca\u65f6\u56de\u590d\u3002
Q: \u6211\u542f\u52a8\u4e86 MatrixOne \u670d\u52a1\uff0c\u5e76\u4e14\u7528 MySQL \u8fdb\u884c\u8fde\u63a5\uff0c\u4f46\u662f\u597d\u50cf\u6ca1\u6709\u83b7\u5f97\u6b63\u786e\u7684\u7ed3\u679c\uff0c\u5982\u4f55\u624d\u77e5\u9053\u662f\u5426\u6210\u529f\u8fde\u63a5\uff1f A: \u5982\u679c\u4f60\u7684 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u540e\u6253\u5370\u5982\u4e0b\u4fe1\u606f\uff0c\u5c31\u8bf4\u660e\u5df2\u7ecf\u6210\u529f\u8fde\u63a5\uff1a
Welcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 1002\nServer version: 0.3.0 MatrixOne\n\nCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n
Q: \u6211\u7684 MatrixOne \u670d\u52a1\u542f\u52a8\u4e86\uff0c\u4f46\u662f\u6211\u7684 MySQL \u5ba2\u6237\u7aef\u59cb\u7ec8\u8fde\u63a5\u4e0d\u4e0a\uff0c\u8fd9\u4e2a\u5e94\u8be5\u600e\u4e48\u89e3\u51b3\uff1f A: \u8fd9\u4e2a\u53ef\u80fd\u7531\u5404\u79cd\u539f\u56e0\u5bfc\u81f4\uff0c\u9996\u5148\u8bf7\u5173\u6ce8\u9519\u8bef\u7684\u65e5\u5fd7\u4fe1\u606f\u6765\u5b9a\u4f4d\u95ee\u9898\uff0c\u76ee\u524d\u5728 MatrixOne \u4e2d\u6709\u4e24\u79cd\u5e38\u89c1\u9519\u8bef\uff1a
lsof -i:50000
\u547d\u4ee4\u6765\u67e5\u627e\u662f\u54ea\u4e2a\u8fdb\u7a0b\u5728\u5360\u7528\u8fd9\u4e2a\u7aef\u53e3\u3002\u4ece\u8fd9\u4e2a\u547d\u4ee4\u4e2d\u53ef\u4ee5\u83b7\u5f97\u8fd9\u4e2a\u8fdb\u7a0b\u7684 PID\uff0c\u518d\u901a\u8fc7 kill -9 PIDNAME
\u5173\u95ed\u8fd9\u4e2a\u8fdb\u7a0b\u3002Store
\u76ee\u5f55\u6e05\u7a7a\u5e76\u91cd\u542f MatrixOne \u670d\u52a1\u3002Q: Mentor \u8981\u6c42\u6211\u5bf9\u63d0\u4ea4\u7684\u4ee3\u7801\u683c\u5f0f\u8fdb\u884c\u7f29\u8fdb\uff0c\u8fd9\u4e2a\u5982\u4f55\u505a\uff1f A\uff1a\u53ef\u4ee5\u901a\u8fc7 Golang \u8bed\u8a00\u81ea\u5e26\u7684 gofmt \u5de5\u5177\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u884c\u64cd\u4f5c\uff0c\u6216\u8005\u5728\u4e00\u4e9b\u5e38\u89c1\u7684 IDE \u5982 VS Code \u548c GoLand \u4e2d\u4e5f\u5747\u6709\u76f8\u5e94\u7684\u8bbe\u7f6e\u3002
Q: \u5982\u4f55\u7406\u89e3 MatrixOne \u7684 Vector \u6570\u636e\u7ed3\u6784\uff1f A\uff1aVector \u662f MatrixOne \u4e2d\u8868\u793a\u4e00\u5217\u6570\u636e\u7684\u7ed3\u6784\uff0c\u662f MatrixOne \u6700\u91cd\u8981\u7684\u6570\u636e\u7ed3\u6784\u4f53\u4e4b\u4e00\u3002\u5b83\u5176\u4e2d\u7684\u4e0d\u540c\u53d8\u91cf\u542b\u4e49\uff1a
// Vector.Or: \u8868\u793a\u8fd9\u4e2aVector\u662f\u5426\u662f\u4ece\u78c1\u76d8\u8bfb\u53d6\u7684\u539f\u59cbVector\n// Link: \u8fd9\u4e2aVector\u62e5\u6709\u7684\u8f6f\u94fe\u63a5\u4e2a\u6570\n// Data: \u5185\u5b58\u4e2d\u4fdd\u5b58\u7684\u539f\u59cb\u6570\u636e\n// Typ: Vector\u7684\u7c7b\u578b\n// Col: \u5185\u5b58\u4e2d\u7ecf\u8fc7\u5e8f\u5217\u5316\u7f16\u7801\u7684\u6570\u636e\uff0c\u5b83\u4e0eVector.Data\u5171\u4eab\u5185\u5b58\u4f4d\u7f6e\uff0c\u4f46\u662f\u4f1a\u88ab\u8f6c\u6362\u5230\u67d0\u4e2a\u4e13\u95e8\u7684\u7c7b\u578b\uff0c\u6bd4\u5982int32\n// Nsp: \u5b58\u50a8\u4e00\u5217\u4e2d\u6240\u6709NULL\u7684\u4f4d\u56fe\n
"},{"location":"MatrixOne/add_syntax/","title":"Add syntax","text":"\u672c\u6587\u5c06\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u8bb2\u8bc9\u5982\u4f55\u5728 MatrixOne \u4e2d\u6dfb\u52a0\u8bed\u6cd5\u3002
"},{"location":"MatrixOne/add_syntax/#_1","title":"\u8bed\u6cd5\u89c4\u5219","text":"\u9996\u5148\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 MySQL 8.0 \u7684\u6587\u6863\uff08https://dev.mysql.com/doc/refman/8.0/en/clone.html\uff09\uff0cCLONE \u7684\u8bed\u6cd5\u89c4\u5219\u5982\u4e0b\uff1a
```sqs q CLONE clone_action
clone_action: { LOCAL DATA DIRECTORY [=] 'clone_dir' | INSTANCE FROM 'user'@'host':port IDENTIFIED BY 'password' [DATA DIRECTORY [=] 'clone_dir'] [REQUIRE [NO] SSL] }
\u53ef\u4ee5\u770b\u5230 clone_action \u53ef\u4ee5\u662f\uff1a\n
LOCAL DATA DIRECTORY [=] 'clone_dir'; \u6216\u8005\u662f\uff1a\n
INSTANCE FROM 'user'@'host':port IDENTIFIED BY 'password' [DATA DIRECTORY [=] 'clone_dir'] [REQUIRE [NO] SSL] \u672c\u6587\u4f1a\u4e3e\u4f8b\u6dfb\u52a0\u7b2c\u4e00\u4e2a clone_action \u7684\u89c4\u5219\uff0c\u5728\u7b2c\u4e00\u4e2a clone_action \u89c4\u5219\u4e2d\uff0cLOCAL\uff0cDATA\uff0cDIRECTORY \u662f MySQL \u4e2d\u7684\u5173\u952e\u5b57\uff08<https://dev.mysql.com/doc/refman/8.0/en/keywords.html>\uff09\u3002 [=] \u662f\u53ef\u9009\u9879\uff0c\u53ef\u4ee5\u6709\u7b49\u53f7\u6216\u8005\u6ca1\u6709\uff0c'clone_dir' \u662f\u5b57\u7b26\u4e32\u3002\u5bf9\u4e8e\u8fd9\u4e9b token\uff0c\u8bcd\u6cd5\u5206\u6790\u9636\u6bb5\u90fd\u4f1a\u505a\u533a\u5206\u3002\n\n\u6211\u4eec\u53ef\u4ee5\u5148\u5b9a\u4e49\u8bed\u6cd5\u6811\uff0c\u56e0\u4e3a CLONE \u662f\u65b0\u8bed\u53e5\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 tree \u76ee\u5f55\u521b\u5efa clone.go \u7136\u540e\u5b9a\u4e49\uff1a\n
type Clone struct { statementImpl CloneDir string } \u5728 mysql_sql.y \u4e2d\u6dfb\u52a0\u5982\u4e0b\u89c4\u5219\uff1a\n
... %union { // Clone \u5b9e\u73b0\u4e86 statement \u63a5\u53e3 statment tree.Statement } ...
// \u5b9a\u4e49\u7ec8\u7ed3\u7b26 CLONE %token CLONE
...
// \u5b9a\u4e49\u975e\u7ec8\u7ed3\u7b26 clone_stmt %type clone_stmt
...
%% ...
// clone_stmt \u662f stmt \u7684\u5177\u4f53\u5b9e\u73b0 stmt: ... | clone_stmt
// \u5b9a\u4e49 CLONE \u8bed\u6cd5\u89c4\u5219 clone_stmt: CLONE LOCAL DATA DIRECTORY equal_opt STRING { $$ = &tree.Clone{IsLocal: true, CloneDir: $6} }
...
non_reserved_keyword: ... | CLONE ...
...
%%
\u5176\u4e2d LOCAL\uff0cDATA\uff0cDIRECTORY \u5173\u952e\u5b57\u662f\u5df2\u7ecf\u5b9a\u4e49\u597d\u7684\u3002\n\n\u53ea\u9700\u8981\u5b9a\u4e49\u65b0\u7684\u5173\u952e\u5b57 CLONE\uff0c\u53ef\u4ee5\u53c2\u8003\u5176\u4e2d\u4e00\u4e2a\u662f\u600e\u4e48\u5b9a\u4e49\u7684\u3002\u6ce8\u610f\u8981\u5728 MySQL \u6587\u6863 <https://dev.mysql.com/doc/refman/8.0/en/keywords.html> \u4e2d\u67e5\u770b\uff0c\u662f\u4fdd\u7559\u5173\u952e\u5b57\uff0c\u8fd8\u662f\u975e\u4fdd\u7559\u5173\u952e\u5b57\u3002\u7136\u540e\u5728 keywords.go \u4e2d\u6dfb\u52a0\uff1a\n
keywords = map[string]int{ ... \"clone\": CLONE, ... } \u8ba9\u8bcd\u6cd5\u5206\u6790\u5668\u901a\u8fc7 map \u8bc6\u522b CLONE \u4e3a\u5173\u952e\u5b57\u3002\n\nSTRING \u8868\u793a\u5b57\u7b26\u4e32\uff0c\u4f1a\u5728\u8bcd\u6cd5\u5206\u6790\u4e2d\u533a\u5206\u3002equal_opt \u8868\u793a [=]\uff0c\u53ef\u4ee5\u6709\u7b49\u53f7\uff0c\u6216\u8005\u6ca1\u6709\uff1a\n
equal_opt: { $$ = \"\" } | '=' { $$ = string($1) } ## \u751f\u6210\u89e3\u6790\u5668\n\nMO parser \u5199\u4e86 Makefile\uff0c\u901a\u8fc7 goyacc \u751f\u6210\u8bed\u6cd5\u5206\u6790\u5668\u3002\u53ef\u4ee5\u76f4\u63a5\u8fdb\u5165\u5230 parsers \u76ee\u5f55\u4e0b\uff0c\u76f4\u63a5\n
make \u5c31\u4f1a\u751f\u6210\u65b0\u7684\u8bed\u6cd5\u5206\u6790\u5668 (mysql_sql.y)\u3002\u6ce8\u610f\uff1a\u5f53 make \u540e\u62a5 shift/reduce \u6216\u8005 reduce/reduce \u51b2\u7a81\uff0c\u8868\u793a\u7f16\u5199\u7684\u8bed\u6cd5\u89c4\u5219\u6709\u95ee\u9898\uff0c\u9700\u8981\u4fee\u6539\u3002\n\n## Format\n\nformat \u4f1a\u5c06 ast \u8f6c\u5316\u4e3a SQL \u5b57\u7b26\u4e32\uff0c\u4e3b\u8981\u4f5c\u7528\u662f\u65b9\u4fbf\u6d4b\u8bd5\uff0c\u5728 plan \u7684\u6784\u9020\u4e2d\u4e5f\u4f1a\u7528\u5230\u3002COLNE \u7684 format \u51fd\u6570\u5982\u4e0b\uff1a\n
func (node Clone) Format(ctx FmtCtx) { ctx.WriteString(\"clone\") if node.IsLocal { ctx.WriteString(\"local data directory = \") ctx.WriteString(node.CloneDir) } } ## \u6d4b\u8bd5\n\nMO parser \u7684\u6d4b\u8bd5\u4e3b\u8981\u662f\u5355\u4fa7\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 mysql_test.go \u4e2d\u6dfb\u52a0\n
validSQL = []struct { input string output string }{{ input: \"CLONE LOCAL DATA DIRECTORY = '/tmp'\", // \u56e0\u4e3a\u5728 Format \u51fd\u6570\u4e2d\uff0c\u5173\u952e\u5b57\u90fd\u88ab\u56fa\u5b9a\u4e3a\u5c0f\u5199\uff0c\u6240\u4ee5 Format \u540e\u4e5f\u4f1a\u53d8\u6210\u5c0f\u5199 output: \"clone local data directory = /tmp\", }, ... \u7136\u540e\u8dd1 TestValid \u6d4b\u8bd5\u3002\n\n\u5982\u679c\u53ea\u662f\u5355\u7eaf\u5730\u6dfb\u52a0\u8bed\u6cd5\uff0c\u9996\u5148\u5728\u6784\u9020\u6267\u884c\u8ba1\u5212\u65f6\uff0c\u9700\u8981\u629b\u51fa\u529f\u80fd\u4e0d\u652f\u6301\u9519\u8bef\u3002\u53ef\u4ee5\u8c03\u7528 moerr \u629b\u51fa\n
func NewNotSupported(msg string, args ...any) *Error ``` \u7136\u540e\u9700\u8981\u5728 test \u76ee\u5f55\u4e0b\u6dfb\u52a0 bvt \u6d4b\u8bd5\uff0c\u8fd9\u662f\u4e00\u4e2a\u7aef\u5230\u7aef\u7684\u6d4b\u8bd5\uff0c\u9884\u671f\u7ed3\u679c\u662f\u629b\u51fa\u76f8\u5e94\u7684\u9519\u8bef\uff0c\u6216\u6b63\u786e\u7684\u7ed3\u679c\u96c6\u3002\u6700\u540e\u53ef\u4ee5\u7528 mo-tester (\u4f7f\u7528\u53ef\u4ee5\u770b readme) \u4f5c\u4e3a\u68c0\u9a8c\u3002
\u5230\u6b64\uff0c\u4e3a MO parser \u6dfb\u52a0\u4e00\u4e2a\u7b80\u5355\u7684\u8bed\u6cd5\u6210\u529f\uff0c\u5728 MO \u6700\u65b0\u7684\u4ee3\u7801\u4e2d\uff0c\u8be5\u8bed\u6cd5\u8fd8\u672a\u88ab\u6dfb\u52a0\uff0c\u5927\u5bb6\u53ef\u4ee5\u5c1d\u8bd5\u9a8c\u8bc1\u8fd9\u4e2a\u8bed\u6cd5\u662f\u5426\u80fd\u89e3\u6790\u6210\u529f\uff0c\u6216\u8005\u6dfb\u52a0\u5176\u4ed6\u65b0\u7684\u8bed\u6cd5\u3002
"},{"location":"MatrixOne/glossary/","title":"\u672f\u8bed\u8868","text":""},{"location":"MatrixOne/glossary/#_2","title":"\u672f\u8bed","text":"\u9605\u8bfb\u4ee5\u4e0b\u5bf9\u76f8\u5173\u8bcd\u6c47\u7684\u6982\u5ff5\u89e3\u91ca\u6216\u8bb8\u6709\u52a9\u4e8e\u4f60\u7406\u89e3\u6211\u4eec\u7684\u6574\u4f53\u67b6\u6784\u3002
\u672f\u8bed \u5b9a\u4e49 A AST AST \u5373\u62bd\u8c61\u8bed\u6cd5\u6811\uff0c\u662f\u4ee3\u7801\u7684\u6811\u7ed3\u6784\u8868\u793a\u5f62\u5f0f\uff0c\u662f\u7ec4\u6210\u7f16\u8bd1\u5668\u5de5\u4f5c\u6a21\u5f0f\u7684\u57fa\u672c\u90e8\u5206 C Cluster MatrixOne \u7684\u5206\u5e03\u5f0f\u90e8\u7f72\u5f62\u5f0f\uff0c\u7531\u591a\u53f0\u4e3b\u673a\u7ec4\u6210\uff0c\u5728\u903b\u8f91\u4e0a\u6784\u6210\u4e00\u4e2a\u6574\u4f53\u3002 E Explicit Transactions \u663e\u5f0f\u4e8b\u52a1\uff0c\u5373\u662f\u4e00\u79cd\u6307\u5b9a\u7684\u4e8b\u52a1\uff0c\u8fd9\u79cd\u4e8b\u52a1\u9700\u8981\u7531\u4f60\u81ea\u5df1\u51b3\u5b9a\u54ea\u6279\u5de5\u4f5c\u5fc5\u987b\u6210\u529f\u5b8c\u6210\uff0c\u5426\u5219\u6240\u6709\u90e8\u5206\u90fd\u4e0d\u5b8c\u6210\u3002\u53ef\u4ee5\u4f7f\u7528BEGIN TRANSACTION
\u548c ROLLBACK TRANSACTION
\u6216 COMMIT TRANSACTION
\u5173\u952e\u5b57\u8fdb\u884c\u63a7\u5236\u3002 I Implicit transactions \u9690\u5f0f\u4e8b\u52a1\uff0c\u5373\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u3002 O Optimistic transaction \u4e50\u89c2\u4e8b\u52a1\uff0c\u4e50\u89c2\u4e8b\u52a1\u5373\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4e0d\u4f1a\u505a\u51b2\u7a81\u68c0\u6d4b\u6216\u9501\uff0c\u4f1a\u5c06\u5f53\u524d\u76f8\u5173\u6570\u636e\u7f13\u5b58\u81f3\u5bf9\u5e94\u5185\u5b58\u533a\u57df\uff0c\u5e76\u5bf9\u8be5\u6570\u636e\u8fdb\u884c\u589e\u5220\u6539\u3002 P Pessimistic transaction \u60b2\u89c2\u4e8b\u52a1\uff0cMatrixOne \u9ed8\u8ba4\u7684\u4e8b\u52a1\u6a21\u5f0f\uff0c\u5373\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u63d0\u524d\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5b8c\u6210\u4e0a\u9501\u52a8\u4f5c\u540e\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u63d0\u4ea4\u6216\u56de\u6eda\u540e\uff0c\u6570\u636e\u5b8c\u6210\u843d\u76d8\u5e76\u91ca\u653e\u9501\u3002 S Snapshot Isolation (SI) Snapshot Isolation \u662f\u4e00\u79cd\u5728\u5b9e\u8df5\u4e2d\u5e7f\u6cdb\u5e94\u7528\u7684\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\u6280\u672f\uff0cMatrixOne \u652f\u6301 Snapshot \u9694\u79bb\u7ea7\u522b\u7684\u5206\u5e03\u5f0f\u4e8b\u52a1\u3002"},{"location":"MatrixOne/glossary/#_3","title":"\u91cd\u8981\u6982\u5ff5","text":"\u6982\u5ff5 \u5b9a\u4e49 A Auto-Rebalance \u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u591a\u4e2a\u670d\u52a1\u5668\u7684\u5b58\u50a8\u91cf\u3001\u8bfb\u5199\u8d1f\u8f7d\u7684\u81ea\u52a8\u5e73\u8861\u8fc7\u7a0b\u79f0\u4e4b\u4e3a Auto-Rebalance\u3002 C Consistency MatrixOne \u652f\u6301\u5f3a\u4e00\u81f4\u6027\uff0c\u4fdd\u8bc1\u4e86\u5728\u6210\u529f\u5199\u5165\u6570\u636e\u540e\uff0c\u65e0\u8bba\u5728\u54ea\u4e2a Store(\u8282\u70b9) \u4e0a\u90fd\u80fd\u8bfb\u53d6\u5230\u6700\u65b0\u7684\u6570\u636e\u3002 E Execution Plan \u6570\u636e\u5e93\u4e2d\u7684\u6267\u884c\u8ba1\u5212\u662f\u67e5\u8be2\u4f18\u5316\u5668\u751f\u6210\u7684\u67e5\u8be2\u64cd\u4f5c\u7684\u56fe\u5f62\u8868\u793a\uff0c\u53ef\u4ee5\u5f97\u5230\u6267\u884c\u8be5\u64cd\u4f5c\u7684\u6700\u9ad8\u6548\u65b9\u6cd5 F Fault-Tolerance Fault-Tolerance\uff08\u5bb9\u9519\u6027\uff09\u610f\u5473\u7740\u7cfb\u7edf\u5728\u5176\u4e2d\u4e00\u4e2a\u6216\u591a\u4e2a\u7ec4\u4ef6\u53d1\u751f\u6545\u969c\u540e\u4ecd\u7136\u53ef\u4ee5\u7ee7\u7eed\u8fd0\u884c\u7684\u80fd\u529b\u3002 M Monolitic Engine Monolitic Engine \u5373\u8d85\u878d\u5408\u5f15\u64ce\uff0c\u53ef\u652f\u6301 TP\u3001AP\u3001\u65f6\u5e8f\u3001\u673a\u5668\u5b66\u4e60\u7b49\u6df7\u5408\u5de5\u4f5c\u8d1f\u8f7d\u3002 Materialized View Materialized View \u5373\u7269\u5316\u89c6\u56fe\uff0c\u662f\u9884\u5148\u88ab\u8ba1\u7b97\u597d\u7684\u6570\u636e\u96c6\uff0c\u5b58\u50a8\u4e0b\u6765\u4ee5\u4fbf\u540e\u7eed\u4f7f\u7528\uff0c\u901a\u5e38\u53ef\u4ee5\u63d0\u5347\u67e5\u8be2\u7684\u8fd0\u884c\u6548\u7387\u3002 Metadata Metadata \u5373\u5143\u6570\u636e\uff0c\u662f\u7528\u4e8e\u63cf\u8ff0\u6570\u636e\u5e93\u4e2d\u6570\u636e\u7684\u7ed3\u6784\u4fe1\u606f\u7684\u6570\u636e\u3002 P Paxos Paxos \u662f\u4e00\u79cd\u4e00\u81f4\u6027\u7b97\u6cd5\uff0c\u4fdd\u6301\u4e00\u7ec4\u5f02\u6b65\u7f51\u7edc\u901a\u4fe1\u7684\u5206\u5e03\u5f0f\u8ba1\u7b97\u673a\u4e4b\u95f4\u7684\u4e00\u81f4\u6027\u3002 R Raft Raft \u662f\u4e00\u79cd\u6613\u4e8e\u7406\u89e3\u7684\u4e00\u81f4\u6027\u534f\u8bae\u7b97\u6cd5\uff0c\u5728\u5bb9\u9519\u6027\u4e0e\u6027\u80fd\u4e0a\u4e0e Paxos \u76f8\u5f53\u3002 Raft Group and Leader Raft \u5728\u4e00\u7ec4\u4e2d\u5b9a\u4e49\u4e86\u4e00\u4e2a leader \u4ee5\u53ca\u8bb8\u591a followers\u3002\u4e00\u4e2a\u7ec4\u4ee3\u8868\u4e00\u4e2a\u590d\u5236\u72b6\u6001\u673a\uff0c\u53ea\u6709 leader \u624d\u53ef\u4ee5\u54cd\u5e94\u5ba2\u6237\u7aef\u8bf7\u6c42\uff0c\u7136\u540e\u5c06\u4f20\u8fbe\u7ed9 followers\u3002 S SIMD instruction SIMD \u662f Single Instruction/Multiple Data \u7684\u7b80\u5199\uff0c\u5373\u5355\u6307\u4ee4\u591a\u6570\u636e\u6d41\uff0cSIMD \u64cd\u4f5c\u4e00\u822c\u6307\u4e00\u79cd\u4f7f\u7528\u4e00\u6761\u6307\u4ee4\u5373\u53ef\u5904\u7406\u591a\u6761\u6570\u636e\u7684\u8ba1\u7b97\u65b9\u6cd5\u3002 T Transaction \u5728\u6570\u636e\u5e93\u4e2d\u6267\u884c\u7684\u4e00\u7cfb\u5217\u6ee1\u8db3 ACID \u57fa\u672c\u8981\u6c42\u7684\u64cd\u4f5c\u3002 TAE \u5168\u79f0 Transactional Analytic Engine\uff0c\u5b58\u50a8\u5f15\u64ce\u3002\u5b58\u50a8\u5f15\u64ce\u662f\u5b58\u50a8\u5c42\u7684\u4e3b\u8981\u516c\u5f00\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u540c\u65f6\u652f\u6301\u884c\u548c\u5217\u5b58\u50a8\u4ee5\u53ca\u4e8b\u52a1\u5904\u7406\u80fd\u529b\u3002 V Vectorized Execution \u901a\u8fc7\u6709\u6548\u5229\u7528 CPU \u7684\u7f13\u5b58\uff0c\u5411\u91cf\u5316\u6267\u884c\u63d0\u9ad8\u4e86\u5206\u6790\u67e5\u8be2\u5f15\u64ce\u7684\u901f\u5ea6\u3002Arrow \u7684\u5217\u5f0f\u683c\u5f0f\u53ef\u4ee5\u4f7f\u7528\u8f7b\u91cf\u7ea7\u7684\u67b6\u6784\uff0c\u5982 dictionary encoding\uff0cbit packing \u4ee5\u53ca run length encoding\uff0c\u8fd9\u90fd\u8fdb\u4e00\u6b65\u4e86\u63d0\u5347\u4e86\u67e5\u8be2\u6548\u7387\u3002"},{"location":"MatrixOne/parser_camp_event/","title":"Parser","text":""},{"location":"MatrixOne/parser_camp_event/#golang-and-mo-start","title":"Golang and MO start","text":""},{"location":"MatrixOne/parser_camp_event/#1-make-sure-your-golang-environment","title":"1. Make sure your golang environment","text":"To build MatrixOne locally, golang 1.22.3 is required. You can follow these steps to make sure your golang whether is ready.
$ go version\n
If the result is like 'go version go1.22.3 xxxxxx'
, you can skip step 2 and build your MatrixOne. If lower than go 1.22.3 or no golang, your can follow step 2 to configure your own golang 1.22.3 environment locally.
If your OS is Mac OS, download the installation package directly with this url: https://go.dev/dl After installation, use step 1 to make sure again.
If your OS is Linux, still download golang package and modify your profile. Here is a sampe as following. The path can be modified as your preferred.
$ wget https://go.dev/dl/go1.22.3.linux-amd64.tar.gz\n$ sudo tar -zxvf go1.22.3.linux-amd64.tar.gz -C\u00a0/usr/local\n$ cat >> /etc/profile << EOF\nexport GOROOT=/usr/local/go \nexport PATH=$GOROOT/bin:$PATH\nexport GOPATH=/home/go\nexport GOPROXY=https://goproxy.cn,direct \nEOF\n$ source /etc/profile\n$ rm -rf /usr/bin/go\n$ ln -s /usr/local/go/bin/go /usr/bin/go\n
After these, your can check your golang version with go version.
"},{"location":"MatrixOne/parser_camp_event/#3-build-and-run-your-own-matrixone","title":"3. Build and run your own MatrixOne","text":"You can get the code from https://github.com/matrixorigin/matrixone. After download with git clone command, then run the these commands to run MatrixOne instance in the diretory of matrixone.
$ make config\n$ make build\n$ ./mo-service -cfg etc/cn-standalone-test.toml\n
If in the make config
or make build
step, there is any timeout or downloading interrupted, please try to refresh your goproxy as following:
$ go env -w GOPROXY=<https://goproxy.cn,direct>\n
While notified \"Server Listening on : 0.0.0.0:6001\"
, it means your MatrixOne is started.
To access MatrixOne, you need a MySQL client with this url: https://dev.mysql.com/downloads/mysql After the MySQL client installation, you can use this command to access your MatrixOne locally in another CLI session.
$ mysql -P6001 -h127.0.0.1 -uroot -p111\n
When you are in mysql command line, you can start your MatrixOne experience. More details can be found in http://doc.matrixorigin.cn
"},{"location":"MatrixOne/parser_camp_event/#features-tasks","title":"Features Tasks","text":""},{"location":"MatrixOne/parser_camp_event/#1-insert-on-duplicate-key-update-statement","title":"1. INSERT ... ON DUPLICATE KEY UPDATE Statement","text":"If you specify an ON DUPLICATE KEY UPDATE
clause and a row to be inserted would cause a duplicate value in a UNIQUE
index or PRIMARY KEY
, an UPDATE
of the old row occurs.
INSERT\n [INTO] tbl_name\n [(col_name [, col_name] ...)]\n { {VALUES | VALUE} (value_list) [, (value_list)] ... }\n [AS row_alias[(col_alias [, col_alias] ...)]]\n [ON DUPLICATE KEY UPDATE assignment_list]\n\nassignment:\n col_name = \n value\n | [row_alias.]col_name\n | [tbl_name.]col_name\n | [row_alias.]col_alias\n\nassignment_list:\n assignment [, assignment] ...\n
For example, if column a is declared as UNIQUE and contains the value 1, the following two statements have similar effect:
INSERT INTO t1 (a,b,c) VALUES (1,2,3)\n ON DUPLICATE KEY UPDATE c=c+1;\n\nUPDATE t1 SET c=c+1 WHERE a=1;\n
If column b is also unique, the INSERT is equivalent to this UPDATE statement instead:
UPDATE t1 SET c=c+1 WHERE a=1 OR b=2 LIMIT 1;\n
In assignment value expressions in the ON DUPLICATE KEY UPDATE
clause, you can use the VALUES(col_name)
function to refer to column values from the INSERT portion of the INSERT ... ON DUPLICATE KEY UPDATE
statement. In other words, VALUES(col_name)
in the ON DUPLICATE KEY UPDATE
clause refers to the value of col_name that would be inserted, had no duplicate-key conflict occurred. This function is especially useful in multiple-row inserts. The VALUES()
function is meaningful only in the ON DUPLICATE KEY UPDATE
clause or INSERT
statements and returns NULL otherwise. Example:
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6)\n ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);\n
That statement is identical to the following two statements:
INSERT INTO t1 (a,b,c) VALUES (1,2,3)\n ON DUPLICATE KEY UPDATE c=3;\nINSERT INTO t1 (a,b,c) VALUES (4,5,6)\n ON DUPLICATE KEY UPDATE c=9;\n
If the result of INSERT ... ON DUPLICATE KEY UPDATE
is incorrect such as the following example, there should be notified error messages to users and this statement failed.
INSERT INTO t1 (a,b,c) VALUES (1,2,3)\n ON DUPLICATE KEY UPDATE c='a';\n
"},{"location":"MatrixOne/parser_camp_event/#2-replace-statement","title":"2. REPLACE Statement","text":"REPLACE
works exactly like INSERT
, except that if an old row in the table has the same value as a new row for a PRIMARY KEY
or a UNIQUE
index, the old row is deleted before the new row is inserted.
REPLACE \n INTO tbl_name\n [(col_name [, col_name] ...)]\n { {VALUES | VALUE} (value_list) [, (value_list)] ...\n |\n VALUES row_constructor_list\n }\n
Example:
CREATE TABLE test (\n id INT UNSIGNED NOT NULL AUTO_INCREMENT,\n data VARCHAR(64) DEFAULT NULL,\n ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (id)\n);\n
When we create this table and run the statements shown in the mysql client, the result is as follows:
mysql> REPLACE INTO test VALUES (1, 'Old', '2014-08-20 18:47:00');\nQuery OK, 1 row affected (0.04 sec)\n\nmysql> REPLACE INTO test VALUES (1, 'New', '2014-08-20 18:47:42');\nQuery OK, 2 rows affected (0.04 sec)\n\nmysql> SELECT * FROM test;\n+----+------+---------------------+\n| id | data | ts |\n+----+------+---------------------+\n| 1 | New | 2014-08-20 18:47:42 |\n+----+------+---------------------+\n1 row in set (0.00 sec)\n
Now we create a second table almost identical to the first, except that the primary key now covers 2 columns, as shown here (emphasized text):
CREATE TABLE test2 (\n id INT UNSIGNED NOT NULL AUTO_INCREMENT,\n data VARCHAR(64) DEFAULT NULL,\n ts TIMESTAMP NOT NULL,\n PRIMARY KEY (id, ts)\n);\n
When we run on test2 the same two REPLACE
statements as we did on the original test table, we obtain a different result:
mysql> REPLACE INTO test2 VALUES (1, 'Old', '2014-08-20 18:47:00');\nQuery OK, 1 row affected (0.05 sec)\n\nmysql> REPLACE INTO test2 VALUES (1, 'New', '2014-08-20 18:47:42');\nQuery OK, 1 row affected (0.06 sec)\n\nmysql> SELECT * FROM test2;\n+----+------+---------------------+\n| id | data | ts |\n+----+------+---------------------+\n| 1 | Old | 2014-08-20 18:47:00 |\n| 1 | New | 2014-08-20 18:47:42 |\n+----+------+---------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#3-values-statement","title":"3. VALUES STATEMENT","text":"VALUES
is a DML statement which returns a set of one or more rows as a table. In other words, it is a table value constructor which also functions as a standalone SQL statement.
VALUES row_constructor_list [ORDER BY column_designator] [LIMIT number]\n\nrow_constructor_list:\n ROW(value_list)[, ROW(value_list)][, ...]\n\nvalue_list:\n value[, value][, ...]\n\ncolumn_designator:\n column_index\n
The VALUES
statement consists of the VALUES
keyword followed by a list of one or more row constructors, separated by commas. A row constructor consists of the ROW()
row constructor clause with a value list of one or more scalar values enclosed in the parentheses. A value can be a literal of any MatrixOne data type or an expression that resolves to a scalar value. ROW()
cannot be empty (but each of the supplied scalar values can be NULL). Each ROW()
in the same VALUES
statement must have the same number of values in its value list. The DEFAULT
keyword is not supported by VALUES
and causes a syntax error, except when it is used to supply values in an INSERT statement. The output of VALUES
is a table:
mysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8);\n+----------+----------+----------+\n| column_0 | column_1 | column_2 |\n+----------+----------+----------+\n| 1 | -2 | 3 |\n| 5 | 7 | 9 |\n| 4 | 6 | 8 |\n+----------+----------+----------+\n3 rows in set (0.00 sec)\n
The columns of the table output from VALUES
have the implicitly named columns column_0, column_1, column_2, and so on, always beginning with 0. This fact can be used to order the rows by column using an optional ORDER BY
clause in the same way that this clause works with a SELECT
statement, as shown here:
mysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8) ORDER BY column_1;\n+----------+----------+----------+\n| column_0 | column_1 | column_2 |\n+----------+----------+----------+\n| 1 | -2 | 3 |\n| 4 | 6 | 8 |\n| 5 | 7 | 9 |\n+----------+----------+----------+\n3 rows in set (0.00 sec)\n\nmysql> VALUES ROW(1,-2,3), ROW(5,7,9), ROW(4,6,8) ORDER BY column_1 limit 1;\n+----------+----------+----------+\n| column_0 | column_1 | column_2 |\n+----------+----------+----------+\n| 1 | -2 | 3 |\n+----------+----------+----------+\n1 row in set (0.00 sec)\n
The VALUES
statement is permissive regarding data types of column values; you can mix types within the same column, as shown here:
mysql> VALUES ROW(\"q\", 42, '2019-12-18'),\n -> ROW(23, \"abc\", 98.6),\n -> ROW(27.0002, \"Mary Smith\", '{\"a\": 10, \"b\": 25}');\n+----------+------------+--------------------+\n| column_0 | column_1 | column_2 |\n+----------+------------+--------------------+\n| q | 42 | 2019-12-18 |\n| 23 | abc | 98.6 |\n| 27.0002 | Mary Smith | {\"a\": 10, \"b\": 25} |\n+----------+------------+--------------------+\n3 rows in set (0.00 sec)\n
With UNION
, as shown here:
mysql> VALUES ROW(1,2), ROW(3,4), ROW(5,6)\n > UNION VALUES ROW(10,15),ROW(20,25);\n+----------+----------+\n| column_0 | column_1 |\n+----------+----------+\n| 1 | 2 |\n| 3 | 4 |\n| 5 | 6 |\n| 10 | 15 |\n| 20 | 25 |\n+----------+----------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#4-do-statement-and-declare-statement","title":"4. DO Statement and DECLARE Statement","text":"DO
executes the expressions but does not return any results. In most respects, DO
is shorthand for SELECT expr, ...
, but has the advantage that it is slightly faster when you do not care about the result.
DO expr [, expr] ...\n
DO
is useful primarily with functions that have side effects, such as RELEASE_LOCK()
. Example: This SELECT
statement pauses, but also produces a result set:
mysql> SELECT SLEEP(5);\n+----------+\n| SLEEP(5) |\n+----------+\n| 0 |\n+----------+\n1 row in set (5.02 sec)\n
DO
, on the other hand, pauses without producing a result set.
mysql> DO SLEEP(5);\nQuery OK, 0 rows affected (4.99 sec)\n
DECLARE
statement declares local variables within stored programs. To provide a default value for a variable, include a DEFAULT
clause. The value can be specified as an expression; it need not be a constant. If the DEFAULT
clause is missing, the initial value is NULL.
DECLARE Statement\nDECLARE var_name [, var_name] ... type [DEFAULT value]\n
"},{"location":"MatrixOne/parser_camp_event/#5-handler-statement","title":"5. HANDLER Statement","text":"The HANDLER
statement provides direct access to table storage engine interfaces.
HANDLER tbl_name OPEN [ [AS] alias]\nHANDLER tbl_name READ { FIRST | NEXT }\n [ WHERE where_condition ] [LIMIT ... ]\nHANDLER tbl_name CLOSE\n
The HANDLER ... OPEN
statement opens a table, making it accessible using subsequent HANDLER ... READ
statements. This table object is not shared by other sessions and is not closed until the session calls HANDLER ... CLOSE
or the session terminates. The HANDLER ... READ
syntax fetches a row from the table in natural row order that matches the WHERE condition. Natural row order is the order in which rows are stored in a TAE table data file. Without a LIMIT
clause, all forms of HANDLER ... READ
fetch a single row if one is available. To return a specific number of rows, include a LIMIT
clause. It has the same syntax as for the SELECT statement. HANDLER ... CLOSE
closes a table that was opened with HANDLER ... OPEN
. Example:
mysql> create table t1(a int ,b int);\nQuery OK, 0 rows affected (0.01 sec)\nmysql> insert into t1 values(1,-1),(2,-2),(3,-3),(4,-4),(5,-5);\nQuery OK, 5 rows affected (0.04 sec)\nRecords: 5 Duplicates: 0 Warnings: 0\nmysql> handler t1 open as th;\nQuery OK, 0 rows affected (0.00 sec)\nmysql> handler th read first;\n+------+------+\n| a | b |\n+------+------+\n| 1 | -1 |\n+------+------+\n1 row in set (0.00 sec)\nmysql> handler th read first limit 3;\n+------+------+\n| a | b |\n+------+------+\n| 1 | -1 |\n| 2 | -2 |\n| 3 | -3 |\n+------+------+\n3 rows in set (0.00 sec)\nmysql> handler th read next;\n+------+------+\n| a | b |\n+------+------+\n| 5 | -5 |\n+------+------+\n2 rows in set (0.00 sec)\nmysql> handler th read next limit 3;\n+------+------+\n| a | b |\n+------+------+\n| 5 | -5 |\n+------+------+\n2 rows in set (0.00 sec)\nmysql> handler th close;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#6-create-table-like-statement-and-create-table-select-statement","title":"6. CREATE TABLE ... LIKE Statement and CREATE TABLE ... SELECT Statement","text":"Use CREATE TABLE ... LIKE
to create an empty table based on the definition of another table, including any column attributes and indexes defined in the original table:
CREATE TABLE new_tbl LIKE orig_tbl;\n
The copy is created using the same version of the table storage format as the original table.
create table test1(a int, b float);\ncreate table test2 like test1;\nshow columns from test2;\n+-------+-------+------+------+---------+---------+\n| Field | Type | Null | Key | Default | Comment |\n+-------+-------+------+------+---------+---------+\n| a | INT | YES | | NULL | |\n| b | FLOAT | YES | | NULL | |\n+-------+-------+------+------+---------+---------+\n2 rows in set (0.11 sec)\n
You can create one table from another by adding a SELECT
statement at the end of the CREATE TABLE
statement:
CREATE TABLE new_tbl [AS] SELECT * FROM orig_tbl;\n
Create new columns for all elements in the SELECT
. For example:
mysql> CREATE TABLE test (a INT NOT NULL AUTO_INCREMENT,\n -> PRIMARY KEY (a), KEY(b))\n -> SELECT b,c FROM test2;\n
This creates a table with three columns, a, b, and c. Notice that the columns from the SELECT
statement are appended to the right side of the table, not overlapped onto it. Take the following example:
mysql> SELECT * FROM foo;\n+---+\n| n |\n+---+\n| 1 |\n+---+\n1 row in set (0.00 sec)\n\nmysql> CREATE TABLE bar (m INT) SELECT n FROM foo;\nQuery OK, 1 row affected (0.02 sec)\nRecords: 1 Duplicates: 0 Warnings: 0\n\nmysql> SELECT * FROM bar;\n+------+---+\n| m | n |\n+------+---+\n| NULL | 1 |\n+------+---+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/parser_camp_event/#7-create-triggerdrop-trigger","title":"7. CREATE TRIGGER/DROP TRIGGER","text":"This statement creates a new trigger. A trigger is a named database object that is associated with a table, and that activates when a particular event occurs for the table. The trigger becomes associated with the table named tbl_name, which must refer to a permanent table.
CREATE\n [DEFINER = user]\n TRIGGER [IF NOT EXISTS] trigger_name\n trigger_time trigger_event\n ON tbl_name FOR EACH ROW\n [trigger_order]\n trigger_body\n\ntrigger_time: { BEFORE | AFTER }\n\ntrigger_event: { INSERT | UPDATE | DELETE }\n\ntrigger_order: { FOLLOWS | PRECEDES } other_trigger_name\n
IF NOT EXISTS
prevents an error from occurring if a trigger having the same name, on the same table, exists in the same schema.
trigger_time
is the trigger action time. It can be BEFORE or AFTER to indicate that the trigger activates before or after each row to be modified.
trigger_event
indicates the kind of operation that activates the trigger. These trigger_event
values are permitted: INSERT
: The trigger activates whenever a new row is inserted into the table (for example, through INSERT, LOAD DATA, and REPLACE statements). UPDATE
: The trigger activates whenever a row is modified (for example, through UPDATE
statements). DELETE
: The trigger activates whenever a row is deleted from the table (for example, through DELETE and REPLACE statements). DROP TABLE
and TRUNCATE TABLE
statements on the table do not activate this trigger, because they do not use DELETE
. Dropping a partition does not activate DELETE
triggers, either. The trigger_event
does not represent a literal type of SQL statement that activates the trigger so much as it represents a type of table operation. For example, an INSERT
trigger activates not only for INSERT
statements but also LOAD DATA
statements because both statements insert rows into a table. trigger_body
is the statement to execute when the trigger activates. To execute multiple statements, use the BEGIN ... END
compound statement construct.
DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name\n
This statement drops a trigger. The schema (database) name is optional. If the schema is omitted, the trigger is dropped from the default schema.
"},{"location":"MatrixOne/parser_camp_event/#8-truncate-table-and-kill-statement","title":"8. TRUNCATE TABLE and KILL Statement","text":"TRUNCATE TABLE Statement
TRUNCATE [TABLE] tbl_name\n
TRUNCATE TABLE
empties a table completely. Logically, TRUNCATE TABLE
is similar to a DELETE
statement that deletes all rows, or a sequence of DROP TABLE
and CREATE TABLE
statements.
KILL Statement
KILL [CONNECTION | QUERY] processlist_id\n
Each connection to mysqld runs in a separate thread. You can kill a thread with the KILL processlist_id
statement.
MatrixOne \u793e\u533a\u6b22\u8fce\u6240\u6709\u5f00\u53d1\u8005\u7684\u52a0\u5165\u548c\u8d21\u732e\uff01\u672c\u7ae0\u8282\u65e8\u5728\u5e2e\u52a9\u60a8\u5feb\u901f\u5b8c\u6210\u9996\u6b21\u8d21\u732e\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#_2","title":"\u5982\u4f55\u8d21\u732e\uff1f","text":"\u5728\u54ea\u4e9b\u65b9\u9762\u53ef\u4ee5\u5927\u5c55\u62f3\u811a\u5462\uff1f\u8be6\u60c5\u8bf7\u53c2\u89c1\u8d21\u732e\u79cd\u7c7b\u3002 \u5982\u679c\u60a8\u662f\u5b8c\u5168\u7684\u65b0\u624b\uff0c\u60a8\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u522b\u4e2d\u9009\u62e9\u4e00\u79cd\u8fdb\u884c\u5c1d\u8bd5\uff0c\u8fd9\u4e9b\u7c7b\u522b\u7684\u95ee\u9898\u5bf9\u60a8\u6280\u672f\u80cc\u666f\u7684\u8981\u6c42\u5f88\u5c11\uff0c\u6240\u4ee5\u4e0d\u5fc5\u62c5\u5fc3\uff01
\u5728\u5f00\u59cb\u5904\u7406\u95ee\u9898\u4e4b\u524d\uff0c\u5efa\u8bae\u60a8\u5148\u5c06\u627e\u5230\u7684\u95ee\u9898\u4f5c\u4e3a GitHub \u4e0a\u7684\u4e00\u9879 Issue \u63d0\u51fa\u3002\u6b64\u5916\uff0c\u6211\u4eec\u51c6\u5907\u4e86\u4e00\u7cfb\u5217\u5e26\u6709 good-first-issue
\u6807\u7b7e\u7684 Issue\uff0c\u5b83\u4eec\u5305\u542b\u4e86\u660e\u6670\u7684\u5b9e\u73b0\u6b65\u9aa4\u548c\u9884\u671f\u7ed3\u679c\uff0c\u60a8\u53ef\u4ee5\u6b64\u4f5c\u4e3a\u7a81\u7834\u53e3\uff01
\u5f53\u60a8\u63d0\u51fa Issue \u4e4b\u540e\u6216\u8005\u662f\u5728\u6d4f\u89c8 good-first-issue
\u540e\u51b3\u5b9a\u4e0a\u624b\u89e3\u51b3\uff0c\u60a8\u9700\u8981\u8ba4\u9886\u8fd9\u6b21 Issue\u3002\u5728\u76f8\u5e94 Issue \u7684\u8bc4\u8bba\u4e2d\u8f93\u5165\u5982\u201cI'd like to work on this issue\u201d\uff0c\u793e\u533a\u4eba\u5458\u4f1a\u5c06\u4efb\u52a1\u5206\u914d\u7ed9\u60a8\uff0c\u6b64\u65f6\uff0c\u60a8\u53ef\u4ee5\u5728\u53f3\u4fa7\u7684 Assignees \u677f\u5757\u770b\u89c1\u81ea\u5df1\uff0c\u63a5\u4e0b\u6765\u4fbf\u53ef\u4ee5\u6b63\u5f0f\u7740\u624b\u89e3\u51b3\u95ee\u9898\u3002
\u8bf7\u786e\u4fdd\u60a8\u81f3\u5c11\u5b89\u88c5\u4e86\u5355\u673a\u7248 MatrixOne \u5e76\u90e8\u7f72\u4e86\u76f8\u5173\u5f00\u53d1\u73af\u5883\u3002\u5177\u4f53\u8bf7\u53c2\u8003\u51c6\u5907\u5de5\u4f5c\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#_5","title":"\u5de5\u4f5c\u6d41\u7a0b","text":""},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#1fork","title":"\u6b65\u9aa4 1\uff1aFork \u9879\u76ee\u4ed3\u5e93","text":"\u9996\u5148\u524d\u5f80 Github \u4e0a\u7684 matrixorigin/matrixone \u4ed3\u5e93\u3002 \u5728\u9875\u9762\u53f3\u4e0a\u89d2\u5904\uff0c\u70b9\u51fb Fork
\u6309\u952e\uff0c\u521b\u5efa\u4e3b\u5e93\u7684\u5206\u53c9\uff0c\u5e76\u4f5c\u4e3a\u60a8\u4e4b\u540e\u4e3b\u8981\u5de5\u4f5c\u7684\u4ed3\u5e93\u3002
\u524d\u5f80\u521a\u624d\u60a8\u521b\u5efa\u7684 Fork \u4ed3\u5e93\uff0c\u70b9\u51fb Code
\uff0c\u7136\u540e\u518d\u70b9\u51fb\u590d\u5236\u56fe\u6807\uff0c\u5c06\u5e93\u7684\u7f51\u5740\u590d\u5236\u5230\u526a\u8d34\u677f\u3002
\u7136\u540e\uff0c\u5728\u60a8\u672c\u5730\u6311\u9009\u4e00\u4e2a\u5408\u9002\u7684\u5de5\u4f5c\u76ee\u5f55\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u8f93\u5165\u4ee5\u4e0b Git \u547d\u4ee4\u5c06\u6587\u4ef6\u514b\u9686\u81f3\u60a8\u672c\u5730\u7684\u76ee\u5f55\uff1a
git clone <content you just copied>\n
\u4f8b\u5982\uff1a
git clone git@github.com:<yourname>/matrixone.git\n
<yourname>
\u662f\u60a8\u7684 Github \u8d26\u53f7\u540d\uff0c\u6362\u8a00\u4e4b\uff0c\u60a8\u8981\u7528\u60a8\u81ea\u5df1\u7684\u8d26\u53f7\u540d\u66ff\u6362\u5b83\u3002
\u60a8\u53ef\u4ee5\u5c06 matrixorigin/matrixone \u6dfb\u52a0\u4e3a\u672c\u5730\u7684\u8fdc\u7a0b\u4ed3\u5e93\uff0c\u4ee5\u4fbf\u540e\u7eed\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a
git remote add upstream https://github.com/matrixorigin/matrixone.git \n
\u5176\u4e2d\uff0cupstream
\u662f\u8be5\u8fdc\u7a0b\u4ed3\u5e93\u7684\u540d\u5b57\uff0c\u60a8\u53ef\u4ee5\u81ea\u884c\u66ff\u6362\uff0c\u4f46\u6ce8\u610f\u540e\u7eed\u5bf9\u8be5\u8bcd\u4e5f\u5e94\u8be5\u4e00\u5e76\u66ff\u6362\u3002
\u514b\u9686\u4ee3\u7801\u5e93\u4e4b\u540e\u60a8\u5c31\u53ef\u4ee5\u5f00\u59cb\u60a8\u7684\u5f00\u53d1\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u5728\u60a8\u6240\u9700\u8981\u7684\u5730\u65b9\u8fdb\u884c\u4efb\u4f55\u4fee\u6539\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#_7","title":"\u8bd5\u8fd0\u884c","text":"\u5982\u679c\u60a8\u5728\u4fee\u6539\u5b8c\u6210\u540e\u60f3\u77e5\u9053\u6539\u52a8\u662f\u5426\u6709\u6548\uff0c\u80fd\u5426\u89e3\u51b3\u6700\u521d\u7684\u95ee\u9898\uff0c\u6216\u8005\u662f\u5426\u5f71\u54cd\u7a0b\u5e8f\u8fd0\u884c\uff0c\u60a8\u53ef\u4ee5\u8fd0\u884c MatrixOne \u8fdb\u884c\u7b80\u5355\u7684\u9884\u89c8\u548c\u6d4b\u8bd5\u3002 \u5f53\u7136\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u6309\u7167\u6559\u7a0b\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#5","title":"\u6b65\u9aa4 5\uff1a\u63d0\u4ea4\u4fee\u6539","text":"\u5f53\u5b8c\u6210\u4ee5\u4e0a\u4fee\u6539\u548c\u6d4b\u8bd5\u540e\uff0c\u60a8\u5c31\u53ef\u4ee5\u5f00\u59cb\u63d0\u4ea4\u4fee\u6539\u3002\u9996\u5148\u4f7f\u7528\u5c06\u60a8\u6240\u66f4\u6539\u7684\u6587\u4ef6\u6dfb\u52a0\u81f3 git \u6240\u7ba1\u7406\u7684\u76ee\u5f55\u4e2d\uff1a
git add <filename>\n
<filename>
\u662f\u60a8\u6240\u4fee\u6539\u7684\u6587\u4ef6\u7684\u540d\u79f0\u3002 \u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff0c\u76f4\u63a5\u5c06\u5f53\u524d\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u90fd\u6dfb\u52a0\u81f3\u7ba1\u7406\u76ee\u5f55\uff1a
git add .\n
\u4e4b\u540e\uff0c\u60a8\u53ef\u4ee5\u63d0\u4ea4\u60a8\u7684\u4fee\u6539
git commit -m \"<commit message>\" -s\n
<commit message>
\u662f\u60a8\u5bf9\u672c\u6b21\u4fee\u6539\u7684\u7b80\u5355\u603b\u7ed3\u548c\u63cf\u8ff0\uff0c\u8bd5\u7740\u505a\u5230\u7b80\u660e\u627c\u8981\u3002
\u63d0\u4ea4\u4fee\u6539\u540e\uff0c\u60a8\u9700\u8981\u5c06\u672c\u5730\u7684\u63d0\u4ea4\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u2014\u2014\u2014\u6211\u4eec\u5f3a\u70c8\u63a8\u8350\u60a8\u63a8\u9001\u81f3\u76ee\u6807\u4ed3\u5e93\u7684\u4e00\u4e2a\u65b0\u5206\u652f\uff1a
git push origin main:NEW_BRANCH\n
NEW_BRANCH
\u60a8\u521b\u5efa\u5e76\u63a8\u9001\u81f3\u7684\u65b0\u5206\u652f\u540d\uff0c\u60a8\u4e5f\u53ef\u4ee5\u968f\u610f\u66ff\u6362\u5b83\uff0c\u4f46\u4e5f\u8bb0\u5f97\u540e\u7eed\u4e00\u5e76\u4fee\u6539\u3002
\u63a8\u9001\u540e\uff0c\u53ef\u4ee5\u5728\u60a8\u6240 Fork \u7684\u4ed3\u5e93\u4e2d\u770b\u5230\u76f8\u5173\u63d0\u793a\u4fe1\u606f\uff0c\u70b9\u51fb Compare & Pull Request \u6309\u952e\u6765\u521b\u5efa\u4e00\u4e2a PR\uff08\u8be5 PR \u5e94\u8be5\u662f\u4ece\u4e2a\u4eba\u4ed3\u5e93\u7684 NEW_BRANCH
\u5206\u652f\u5230\u4e3b\u5e93\u7684 main
\u5206\u652f\uff09\u3002
Note
\u5efa\u8bae\u6309\u7167 PR \u4e2d\u6240\u7ed9\u51fa\u7684\u6a21\u677f\u8981\u6c42\uff0c\u64b0\u5199\u76f8\u5173\u4fe1\u606f\uff0c\u5982\u6b64\u53ef\u4ee5\u51c6\u786e\u8868\u8fbe\u60a8\u7684\u95ee\u9898\u4ee5\u53ca\u6240\u505a\u7684\u4fee\u6539\uff0c\u4ece\u800c\u63d0\u9ad8\u5ba1\u67e5\u6548\u7387\u3002
\u60a8\u7684 PR \u4e00\u65e6\u521b\u5efa\uff0c\u5c31\u6709\u793e\u533a\u8d44\u6df1\u7684\u5f00\u53d1\u4eba\u5458\u5ba1\u6838\u60a8\u7684\u4ee3\u7801\uff0c\u4ed6\u5c06\u4f1a\u68c0\u67e5\u60a8\u505a\u7684\u4fee\u6539\u5e76\u4e14\u8fdb\u884c\u56de\u590d\uff0c\u8bf7\u53ca\u65f6\u4e0e\u60a8\u6c9f\u901a\uff0c\u7136\u540e\u6309\u7167\u8981\u6c42\u8fdb\u884c\u4fee\u6539\u3002
"},{"location":"MatrixOne/Contribution-Guide/make-your-first-contribution/#8","title":"\u6b65\u9aa4 8\uff1a\u540c\u6b65\u4ee3\u7801\u5e93","text":"\u5f53\u8fdb\u884c\u5230\u8fd9\u4e00\u6b65\u65f6\uff0c\u606d\u559c\u60a8\u7684\u4fee\u6539\u5df2\u7ecf\u88ab\u63a5\u53d7\u5e76\u4e14 Merge \u8fdb\u5165\u9879\u76ee\u4e2d\uff0c\u611f\u8c22\u60a8\u505a\u51fa\u7684\u8d21\u732e\uff01 \u4f46\u5de5\u4f5c\u8fd8\u6ca1\u6709\u7ed3\u675f\uff0c\u8fd8\u6709\u4e00\u4e9b\u5de5\u4f5c\u8981\u505a\uff08\u8fd9\u4e9b\u5de5\u4f5c\u6709\u52a9\u4e8e\u4fdd\u8bc1\u63d0\u4ea4\u8bb0\u5f55\u7684\u5e72\u51c0\uff0c\u6709\u5229\u4e8e\u9879\u76ee\u8fdb\u4e00\u6b65\u53d1\u5c55\uff09\u3002 \u53ef\u4ee5\u5c06\u8fdc\u7aef\u4ed3\u5e93\u7684\u4ee3\u7801\u62c9\u53d6\u4e0b\u6765\u8986\u76d6\u672c\u5730\uff0c\u4ee5\u4fdd\u6301\u540c\u6b65\uff1a
git pull --force upstream main:main\n
\u6700\u540e\uff0c\u518d\u5c06\u4ee3\u7801\u63a8\u9001\u5230\u60a8\u7684\u4ed3\u5e93\u4e2d\u7684 main
\u5206\u652f\uff0c\u8fd9\u6837\u5c31\u80fd\u4fdd\u8bc1\u4e09\u4e2a\u4ed3\u5e93\u4ee3\u7801\u5747\u4e00\u81f4\u3002
git push --force origin main:main\n
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/","title":"\u4ee3\u7801\u6ce8\u91ca\u89c4\u8303","text":"\u672c\u6587\u63cf\u8ff0\u4e86 MatrixOne \u6240\u4f7f\u7528\u7684\u4ee3\u7801\u6ce8\u91ca\u7684\u89c4\u8303\u548c\u6837\u5f0f\u3002\u5f53\u4f60\u63d0\u4ea4\u4ee3\u7801\u65f6\uff0c\u8bf7\u52a1\u5fc5\u9075\u5faa\u5df2\u6709\u7684\u4ee3\u7801\u6ce8\u91ca\u89c4\u8303\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-comment-style/#_2","title":"\u4e3a\u4ec0\u4e48\u6ce8\u91ca\u5f88\u91cd\u8981\uff1f","text":"\u4ee5\u4e0b\u7c7b\u578b\u7684\u4ee3\u7801\u65f6\u5f88\u6709\u5fc5\u8981\u505a\u51fa\u6ce8\u91ca\uff1a
\u4ee5\u4e0b\u90e8\u5206\u4e5f\u9700\u8981\u8fdb\u884c\u6ce8\u91ca\uff1a
Go
//
\u6765\u8fdb\u884c\u5355\u884c\u6ce8\u91ca/* ... */
\u5bf9\u4ee3\u7801\u5757\u8fdb\u884c\u6ce8\u91ca\u628a\u5355\u884c\u6ce8\u91ca\u3001\u4ee3\u7801\u5757\u6ce8\u91ca\u653e\u5728\u4ee3\u7801\u4e0a\u65b9
\u6ce8\u91ca\u4e2d\u7684\u6bcf\u884c\u6587\u672c\u4e0d\u8d85\u8fc7 100 \u4e2a\u8bcd
\u5305\u542b URL \u7684\u6ce8\u91ca\uff1a
\u5355\u8bcd
\u8bf7\u7edf\u4e00\u4f7f\u7528\u7f8e\u5f0f\u82f1\u8bed
\u6ce8\u610f\u62fc\u5199\u6b63\u786e
\u4f7f\u7528\u6807\u51c6\u6216\u5b98\u65b9\u7684\u5927\u5199
\u4f7f\u7528\u4e00\u81f4\u6027\u7684\u77ed\u8bed\u548c\u8bcd\u6c47
\u4e0d\u8981\u4f7f\u7528\u5197\u957f\u7684\u590d\u5408\u8bcd
\u5c3d\u91cf\u4e0d\u4f7f\u7528\u7f29\u5199
\u7528 We \u7528\u6765\u4ee3\u6307\u4f5c\u8005\u548c\u8bfb\u8005
\u53e5\u5b50
\u53e5\u5b50\u9996\u5b57\u6bcd\u5927\u5199\uff0c\u5e76\u4ee5\u53e5\u53f7\u7ed3\u5c3e
\u5982\u679c\u4e00\u4e2a\u5c0f\u5199\u7684\u6807\u8bc6\u7b26\u4f4d\u4e8e\u53e5\u5b50\u5f00\u5934\uff0c\u53ef\u4ee5\u4e0d\u7528\u5927\u5199
// enterGame causes Players to enter the\n// video game, which is about a romantic\n// story in ancient China.\nfunc enterGame() os.Error {\n ...\n}\n
\u5f53\u6ce8\u91ca\u7528\u6765\u63cf\u8ff0\u4ee3\u7801\u65f6\uff0c\u5e94\u8be5\u4fdd\u8bc1\u4f7f\u7528\u63cf\u8ff0\u6027\u8bed\u53e5\u800c\u975e\u7948\u4f7f\u53e5
\u4f7f\u7528 \"this\" \u800c\u975e \"the\" \u6765\u6307\u4ee3\u5f53\u524d\u4e8b\u7269
\u5141\u8bb8\u4f7f\u7528 Markdown \u8bed\u6cd5\u683c\u5f0f
log
file \u611f\u8c22\u60a8\u7684\u8d21\u732e\uff01
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/","title":"MatrixOne \u884c\u4e3a\u5b88\u5219","text":""},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_1","title":"\u5171\u540c\u7684\u627f\u8bfa","text":"\u6211\u4eec\u4f5c\u4e3a\u9879\u76ee\u4e0e\u793e\u533a\u7684\u8d21\u732e\u8005\u548c\u7ef4\u62a4\u8005\uff0c\u627f\u8bfa\u5728\u53c2\u4e0e\u9879\u76ee\u4ee5\u53ca\u793e\u533a\u7684\u8fc7\u7a0b\u4e2d\uff0c\u81f4\u529b\u4e8e\u5f7c\u6b64\u5e2e\u52a9\u3001\u5171\u540c\u6210\u957f\uff0c\u7ef4\u62a4\u5f00\u6e90\u5f00\u653e\u3001\u548c\u8c10\u53cb\u5584\u7684\u6c1b\u56f4\uff0c\u65e0\u8bba\u5e74\u9f84\u3001\u4f53\u578b\u3001\u79cd\u65cf\u3001\u6027\u522b\u3001\u6027\u53d6\u5411\u3001\u8868\u8fbe\u3001\u7ecf\u9a8c\u3001\u6559\u80b2\u3001\u793e\u4f1a\u7ecf\u6d4e\u5730\u4f4d\u3001\u56fd\u7c4d\u3001\u4e2a\u4eba\u5916\u8c8c\u3001\u56fd\u5bb6\u3001\u5b97\u6559\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_2","title":"\u884c\u4e3a\u51c6\u5219","text":"\u6211\u4eec\u63d0\u5021\u90a3\u4e9b\u6709\u52a9\u4e8e\u8425\u9020\u7f8e\u597d\u793e\u533a\u73af\u5883\u7684\u884c\u4e3a\uff1a
\u6211\u4eec\u4e0d\u63d0\u5021\u66f4\u4e0d\u63a5\u53d7\u4ee5\u4e0b\u884c\u4e3a\uff1a
\u9879\u76ee\u7ef4\u62a4\u4eba\u5458\u6709\u8d23\u4efb\u660e\u786e\u503c\u5f97\u63d0\u5021\u7684\u884c\u4e3a\u89c4\u8303\uff0c\u5e76\u5bf9\u4efb\u4f55\u4e0d\u5f53\u884c\u4e3a\u91c7\u53d6\u9002\u5f53\u4e14\u516c\u5e73\u7684\u5904\u7406\u63aa\u65bd\u3002
\u9879\u76ee\u7ef4\u62a4\u4eba\u5458\u6709\u6743\u5229\u4e5f\u6709\u8d23\u4efb\u5220\u9664\u3001\u7f16\u8f91\u6216\u62d2\u7edd\u4e0d\u7b26\u5408\u4e0a\u8ff0\u884c\u4e3a\u51c6\u5219\u7684\u8bc4\u8bba\u3001\u63d0\u4ea4\u3001\u4ee3\u7801\u3001wiki \u7f16\u8f91\u548c issue\uff0c\u5e76\u6682\u65f6\u6216\u6c38\u4e45\u5c01\u7981\u53d1\u8868\u4e0d\u5f53\u8a00\u8bba\u6216\u505a\u51fa\u4e0d\u5f53\u884c\u4e3a\u7684\u8d21\u732e\u8005\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_4","title":"\u9002\u7528\u8303\u56f4","text":"\u672c\u884c\u4e3a\u5b88\u5219\u9002\u7528\u4e8e\u6240\u6709\u9879\u76ee\u7a7a\u95f4\uff0c\u4ee5\u53ca\u4efb\u4f55\u4ee3\u8868\u9879\u76ee\u3001\u793e\u533a\u7684\u516c\u5f00\u53d1\u8a00\u3002\u6bd4\u5982\uff1a\u4f7f\u7528\u5b98\u65b9\u7684\u9879\u76ee\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff0c\u901a\u8fc7\u5b98\u65b9\u793e\u4ea4\u5a92\u4f53\u8d26\u6237\u53d1\u5e03\u4fe1\u606f\uff0c\u6216\u4f5c\u4e3a\u6307\u5b9a\u4ee3\u8868\u53c2\u52a0\u7ebf\u4e0a\u7ebf\u4e0b\u6d3b\u52a8\u3002\u5177\u4f53\u6761\u4ef6\u7531\u9879\u76ee\u7ba1\u7406\u8005\u8fdb\u4e00\u6b65\u660e\u786e\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/code-of-conduct/#_5","title":"\u5177\u4f53\u5b9e\u65bd","text":"\u82e5\u60a8\u53d1\u73b0\u4efb\u4f55\u4fae\u8fb1\u3001\u9a9a\u6270\u6216\u5176\u4ed6\u4e0d\u5408\u89c4\u5b9a\u7684\u884c\u4e3a\u90fd\u53ef\u4ee5\u62a5\u544a\u7ed9\u9879\u76ee\u56e2\u961f\uff1ahai.jin@matrixorigin.io
\u3002\u6211\u4eec\u5c06\u6df1\u5165\u5ba1\u6838\u3001\u8c03\u67e5\u6240\u6709\u7684\u6295\u8bc9\u5e76\u4e14\u505a\u51fa\u53ca\u65f6\u3001\u5408\u7406\u7684\u53cd\u9988\u3002\u6b64\u5916\uff0c\u9879\u76ee\u56e2\u961f\u6709\u4e49\u52a1\u4fdd\u62a4\u4e3e\u62a5\u4eba\u7684\u9690\u79c1\u5b89\u5168\u3002 \u66f4\u52a0\u5177\u4f53\u7684\u6267\u884c\u653f\u7b56\u5c06\u53e6\u884c\u516c\u5e03\u3002
\u672c\u7bc7\u884c\u4e3a\u5b88\u5219\u6539\u7f16\u81ea\u8d21\u732e\u8005\u516c\u7ea6\uff0cversion 1.4\uff0c\u4e5f\u53ef\u53c2\u89c1 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\u3002
\u76f8\u5173\u95ee\u9898\u7684\u56de\u7b54\u53ef\u53c2\u89c1\uff1ahttps://www.contributor-covenant.org/faq
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/","title":"\u63d0\u4ea4\u4fe1\u606f&PR \u89c4\u8303","text":"\u672c\u6587\u6863\u63cf\u8ff0\u4e86\u5e94\u7528\u4e8e MatrixOrigin \u7684\u6240\u6709\u5b58\u50a8\u5e93\u7684\u63d0\u4ea4\u6d88\u606f (commit mesage) \u548c PR(pull request) \u7684\u6837\u5f0f\u89c4\u8303\u3002\u5f53\u4f60\u63d0\u4ea4\u4ee3\u7801\u65f6\uff0c\u52a1\u5fc5\u9075\u5faa\u8fd9\u79cd\u89c4\u8303\uff0c\u4fdd\u8bc1\u63d0\u4ea4\u7684\u8d28\u91cf\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#commit-message","title":"\u4e00\u6761\u597d\u7684 commit message \u6709\u591a\u91cd\u8981\uff1f","text":"\u6211\u4eec\u8ba4\u4e3a\u6709\u4ee5\u4e0b\u8981\u7d20\uff1a
What is your change? (\u5fc5\u8981)
\u5b83\u53ef\u80fd\u4fee\u590d\u4e86\u4e00\u4e2a\u7279\u5b9a\u7684 bug\uff0c\u6dfb\u52a0\u4e86\u4e00\u4e2a feature\uff0c\u63d0\u9ad8\u4e86\u6027\u80fd\u3001\u53ef\u9760\u6027\u6216\u7a33\u5b9a\u6027\uff0c\u6216\u8005\u53ea\u662f\u4fdd\u969c\u5b89\u5168\u6027\u800c\u8fdb\u884c\u7684\u66f4\u6539\u3002
Why this change was made? (\u5fc5\u8981)
\u5bf9\u4e8e\u7b80\u8981\u7684\u8865\u4e01\uff0c\u8fd9\u90e8\u5206\u53ef\u4ee5\u7701\u7565\u3002
What effect does the commit have? (\u53ef\u9009)
\u9664\u4e86\u5fc5\u7136\u4f1a\u4ea7\u751f\u7684\u5f71\u54cd\u4e4b\u5916\uff0c\u53ef\u80fd\u8fd8\u5305\u62ec\u57fa\u51c6\u6d4b\u8bd5\u6027\u80fd\u53d8\u5316\u3001\u5bf9\u5b89\u5168\u6027\u7684\u5f71\u54cd\u7b49\u3002\u5bf9\u4e8e\u7b80\u8981\u7684\u6539\u52a8\uff0c\u8fd9\u90e8\u5206\u53ef\u4ee5\u7701\u7565\u3002
\u8981\u5199\u51fa\u4e00\u6761\u4f18\u8d28\u7684 commit message\uff0c\u6211\u4eec\u5efa\u8bae\u60a8\u9075\u5faa\u89c4\u5b9a\u7684\u683c\u5f0f\uff0c\u57f9\u517b\u826f\u597d\u7684\u4e60\u60ef\u5e76\u4f7f\u7528\u89c4\u8303\u7684\u8bed\u8a00\u3002
"},{"location":"MatrixOne/Contribution-Guide/Code-Style/commit-pr-style/#_1","title":"\u89c4\u5b9a\u7684\u683c\u5f0f","text":"\u8bf7\u5728\u63d0\u4ea4\u65f6\u9075\u5faa\u4ee5\u4e0b\u683c\u5f0f\uff1a
<subsystem>: <what changed>\n<BLANK LINE>\n<why this change was made>\n<BLANK LINE>\n<footer>(optional)\n
\u7b2c\u4e00\u884c
util/codec, util/types:
\u3002*
\uff0c\u5982 *:
\u3002\u7b2c\u4e8c\u884c\u8bf7\u7559\u767d
misc fixes
\u7b49\u8868\u8fbe\u5173\u4e8e Pull Request \u4e2d\u7684\u63cf\u8ff0\uff0c\u8bf7\u53c2\u8003\u4e0b\u9762\u7684 Pull Request \u6a21\u677f\uff0c\u6db5\u76d6\u5fc5\u8981\u4fe1\u606f\uff1a
**What type of PR is this?**\n\n- [ ] API-change\n- [ ] BUG\n- [ ] Improvement\n- [ ] Documentation\n- [ ] Feature\n- [ ] Test and CI\n- [ ] Code Refactoring\n\n**Which issue(s) this PR fixes:**\n\nissue #\n\n**What this PR does / why we need it:**\n\n\n**Special notes for your reviewer:**\n\n\n**Additional documentation (e.g. design docs, usage docs, and so on.):**\n
\u5982\u679c\u9700\u8981\uff0c\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6e05\u5355\u6765\u5217\u4e3e\u5185\u5bb9\uff0cMarkdown \u8bed\u6cd5\u5982\u4e0b\uff1a
- [x] A checked line, something already done or fulfilled\n- [ ] An unchecked line, something not finished yet\n
\u5bf9\u4e8e\u975e\u5e38\u7b80\u8981\u7684 Pull Requests\uff0c\u4f60\u53ef\u4ee5\u7701\u7565\u4e0a\u9762\u7684\u4e00\u4e9b\u4fe1\u606f\u3002 \u975e\u5e38\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff01
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/","title":"\u4ee3\u7801\u8d21\u732e","text":"MatrixOne \u662f\u4e00\u4e2a\u7531\u9879\u76ee\u7ba1\u7406\u8005\u3001\u793e\u533a\u5f00\u53d1\u8005\u5171\u540c\u7ef4\u62a4\u3001\u6539\u8fdb\u548c\u6269\u5c55\u7684\u5f00\u6e90\u9879\u76ee\u3002 \u672c\u6587\u6863\u4e3b\u8981\u63cf\u8ff0\u4e86\u5f00\u53d1\u7684\u51c6\u5219\u4e0e\u4e00\u822c\u6d41\u7a0b\uff0c\u5e76\u63d0\u4f9b\u4e86\u5728\u7f16\u5199\u4ee3\u7801\u3001\u63d0\u4ea4 PR \u8fc7\u7a0b\u4e2d\u9700\u8981\u4f7f\u7528\u7684\u6837\u5f0f\u548c\u6a21\u677f\u3002\u5982\u679c\u60a8\u5728\u53c2\u4e0e MatrixOne \u7684\u8d21\u732e\u8fc7\u7a0b\u4e2d\u9047\u5230\u4efb\u4f55\u95ee\u9898\u6216\u53d1\u73b0\u4e00\u4e9b\u9519\u8bef\uff0c\u8bf7\u5728 Github \u4e0a\u63d0\u51fa issue \u6216\u901a\u5176\u4ed6\u5e73\u53f0\u8054\u7cfb\u6211\u4eec\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_2","title":"\u524d\u7f6e\u51c6\u5907","text":"\u5728\u6b63\u5f0f\u5f00\u53d1\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\u9605\u8bfb\u4e86\u51c6\u5907\u5de5\u4f5c\uff0c\u5df2\u7ecf\u5bf9 MatrixOne \u7684\u6838\u5fc3\u7406\u5ff5\u3001\u57fa\u7840\u67b6\u6784\u6709\u4e00\u5b9a\u4e86\u89e3\uff0c\u5e76\u51c6\u5907\u597d\u4e86\u5f00\u53d1\u6240\u9700\u8981\u7684\u76f8\u5e94\u73af\u5883\u3001\u8bed\u8a00\u3001\u5de5\u5177\u7b49\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_3","title":"\u98ce\u683c\u89c4\u8303\u6307\u5357","text":"\u5728\u5bf9 MatrixOne \u8fdb\u884c\u5f00\u53d1\u548c\u5b8c\u5584\u65f6\uff0c\u5e94\u8be5\u4f7f\u4ee3\u7801\u3001\u4ee3\u7801\u6ce8\u91ca\u3001\u63d0\u4ea4\u4fe1\u606f (Committing Message) \u548c\u62c9\u53d6\u8bf7\u6c42 (Pull Request\uff0c\u7b80\u79f0 PR) \u4fdd\u6301\u4e00\u81f4\u7684\u98ce\u683c\u3002\u5f53\u60a8\u63d0\u4ea4 PR \u65f6\uff0c\u6211\u4eec\u5f3a\u70c8\u5efa\u8bae\u60a8\u786e\u4fdd\u6240\u4f5c\u51fa\u7684\u4fee\u6539\u7b26\u5408\u6211\u4eec\u7684\u4e00\u8d2f\u98ce\u683c\uff0c\u8fd9\u4e0d\u4ec5\u4f1a\u63d0\u9ad8 PR \u7684\u901a\u8fc7\u7387\uff0c\u5e76\u4e14\u4e5f\u80fd\u4f7f MatrixOne \u6613\u4e8e\u5ba1\u67e5\u3001\u7ef4\u62a4\u548c\u8fdb\u4e00\u6b65\u5f00\u53d1\u3002
MatrixOne \u91c7\u7528\u4e86 Golang \u793e\u533a\u5efa\u8bae\u7684\u7f16\u7801\u89c4\u8303\uff0c\u8be6\u60c5\u8bf7\u89c1 Effective Go\u3002
\u5173\u4e8e\u4ee3\u7801\u6ce8\u91ca\uff0c\u8bf7\u53c2\u8003\u4ee3\u7801\u6ce8\u91ca\u89c4\u8303\u3002
\u53ef\u53c2\u8003 Commit & PR \u89c4\u8303\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_4","title":"\u4e00\u822c\u5de5\u4f5c\u6d41\u7a0b","text":"\u60a8\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u5de5\u4f5c\u6d41\u7a0b\u6765\u8fdb\u884c\u5f00\u53d1\u5e76\u5728 Github \u4e0a\u63d0\u4ea4\u4fee\u6539\uff0c\u5982\u679c\u60a8\u8fd8\u9700\u8981\u66f4\u52a0\u8be6\u7ec6\u7684\u89e3\u91ca\uff0c\u53ef\u4ee5\u67e5\u770b Make Your First Contribution
1. \u5728 Github \u4e0a Fork matrixorigin/matrixone \u4ed3\u5e93\u3002
2. \u5c06 Fork \u7684\u4ed3\u5e93\u514b\u9686\u81f3\u672c\u5730\uff1a
git clone git@github.com:<yourname>/matrixone.git\n
\u5e76\u4e14\u628a matrixone \u4ed3\u5e93\u6dfb\u52a0\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\uff1a
git remote add upstream https://github.com/matrixorigin/matrixone.git\n
3. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5206\u652f\uff0c\u5206\u652f\u540d\u81ea\u5b9a\u4e49\uff1a
git checkout -b topic-branch\n
4. \u5728\u672c\u5730\u8fdb\u884c\u5f00\u53d1\uff0c\u5b8c\u6210\u76f8\u5173\u4fee\u6539\uff0c\u5e76\u5b8c\u6210\u5fc5\u8981\u7684\u5355\u5143\u6d4b\u8bd5\uff0c\u6700\u540e\u8fdb\u884c\u63d0\u4ea4\u3002
5. \u5c06\u4fee\u6539\u63a8\u9001\u81f3\u4ed3\u5e93\u7684\u4e00\u4e2a\u65b0\u5206\u652f\uff1a
git push origin main:NEW_BRANCH\n
6. \u5728\u4ed3\u5e93\u4e2d\u7684\u65b0\u5206\u652f NEW_BRANCH
\u4e2d\u521b\u5efa Pull Request\uff0c\u5e76\u6dfb\u52a0\u76f8\u5e94\u6807\u7b7e\u3001\u5efa\u7acb\u4e0e\u76f8\u5173 issue \u7684\u5173\u8054\u3002
7. PR \u901a\u8fc7\u540e\uff0c\u8986\u76d6\u672c\u5730\u63d0\u4ea4\u5386\u53f2\uff1a
git pull --force upstream main:main\n
8. \u66f4\u65b0\u60a8\u7684\u4ed3\u5e93\u7684 main
\u5206\u652f\uff1a
git push --force origin main:main\n
\u5982\u679c\u60a8\u4ecd\u7136\u6709\u4e00\u4e9b\u56f0\u60d1\uff0c\u53ef\u4ee5\u53c2\u8003 GitHub \u5b98\u65b9\u6587\u6863\u5bfb\u6c42\u5e2e\u52a9\uff1b\u82e5\u60a8\u53d1\u73b0\u6211\u4eec\u63d0\u4f9b\u7684\u5de5\u4f5c\u6d41\u7a0b\u6709\u9519\u8bef\u6216\u60f3\u8981\u63d0\u51fa\u6539\u5584\u7684\u65b9\u6cd5\uff0c\u6b22\u8fce\u60a8\u63d0\u51fa\u5efa\u8bae\uff01
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-code/#_5","title":"\u4ee3\u7801\u5ba1\u9605","text":"\u5f53\u60a8\u521b\u5efa PR \u8bf7\u6c42\u65f6\uff0c\u60a8\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e9b\u5ba1\u9605\u8005\uff0c\u6216\u8005\u7559\u7a7a\u3002\u5e76\u4e14\u60a8\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e9b\u76f8\u5173\u7684\u6807\u7b7e\uff0c\u8fd9\u6837\u66f4\u5bb9\u6613\u8bc6\u522b PR \u7684\u7c7b\u578b\u3001\u4f18\u5148\u7ea7\u7b49\u3002\u5728\u4ee3\u7801\u5ba1\u9605\u671f\u95f4\uff0c\u5ba1\u9605\u8005\u4f1a\u5bf9\u60a8\u7684\u4ee3\u7801\u7247\u6bb5\u7ed9\u51fa\u610f\u89c1\uff0c\u60a8\u53ef\u4ee5\u76f8\u5e94\u5730\u5728\u672c\u5730\u4fee\u6539\u60a8\u7684\u5206\u652f\u4e0a\u7684\u4ee3\u7801\uff0c\u63d0\u4ea4\u66f4\u6539\uff0c\u7136\u540e\u63a8\u9001\u5230 GitHub\uff0c\u65b0\u7684\u63d0\u4ea4\u4f1a\u81ea\u52a8\u9644\u52a0\u5230 PR \u4e0a\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/","title":"\u6587\u6863\u8d21\u732e\u6307\u5357","text":"\u6b22\u8fce\u5bf9 MatrixOne \u6587\u6863\u7684\u63d0\u51fa\u8d21\u732e\u3002MatrixOne \u793e\u533a\u4e00\u76f4\u5728\u52aa\u529b\u7b80\u5316\u6574\u4e2a\u8d21\u732e\u6d41\u7a0b\uff0c\u4e3a\u6b64\uff0c\u6211\u4eec\u521b\u5efa\u672c\u8282\u6765\u4e00\u6b65\u6b65\u5730\u6307\u5bfc\u60a8\u5b8c\u6210\u6587\u6863\u8d21\u732e\u7684\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#_2","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u5f00\u59cb\u4e4b\u524d\u8bf7\u5c3d\u91cf\u719f\u6089\u57fa\u672c\u7684 Markdown \u8bed\u6cd5\u5e76\u9605\u8bfb\u884c\u4e3a\u5b88\u5219\u548c\u8c37\u6b4c\u5f00\u53d1\u8005\u6587\u6863\u98ce\u683c\u6307\u5357\uff0c\u4ee5\u4fbf\u60a8\u5199\u51fa\u66f4\u9ad8\u8d28\u91cf\u7684\u6587\u6863\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#_3","title":"\u6587\u6863\u7ba1\u7406\u903b\u8f91","text":"MatrixOne \u6587\u6863\u901a\u8fc7\u4e09\u4e2a\u4ed3\u5e93\u6765\u534f\u8c03\u7ba1\u7406\uff1a
matrixorigin.io \u4ed3\u5e93\u5305\u542b\u82f1\u6587\u6587\u6863\u7684\u5177\u4f53\u5185\u5bb9\u3002\uff08. md \u6587\u4ef6\uff09
matrixorigin.io.cn \u4ed3\u5e93\u5305\u542b\u4e2d\u6587\u6587\u6863\u7684\u5177\u4f53\u5185\u5bb9\u3002\uff08. md \u6587\u4ef6\uff09
artwork \u4ed3\u5e93\u5305\u542b\u4e86\u6587\u6863\u6240\u7528\u5230\u7684\u56fe\u50cf\u7b49\u975e\u7ed3\u6784\u6027\u6587\u4ef6\u3002\u56fe\u50cf\u7b49\u975e\u7ed3\u6784\u5316\u6587\u4ef6\u5219\u76f4\u63a5\u5f15\u7528 artwork
\u4ed3\u5e93\u7684\u7f51\u7ad9\u94fe\u63a5\uff0c\u5982\uff1a
https://github.com/matrixorigin/artwork/blob/main/docs/overview/overall-architecture.png?raw=true\n
matrixorigin.io
\u548c matrixorigin.io.cn
\u5747\u90e8\u7f72\u4e86\u4e00\u4e2a CI \u7a0b\u5e8f\uff0c\u5f53\u6709\u65b0\u7684\u4ee3\u7801\u88ab\u5408\u5e76\u65f6\u5c06\u81ea\u52a8\u89e6\u53d1\uff0c\u5c06\u6587\u6863\u53d1\u5e03\u5230\u6211\u4eec\u7684\u5b98\u65b9\u6587\u6863\u7f51\u7ad9\u3002 \u6211\u4eec\u7684\u6587\u6863\u662f\u57fa\u4e8e mkdocs-material \u7ec4\u4ef6\u8fdb\u884c\u5f00\u53d1\u7684\uff0c\u60a8\u53ef\u4ee5\u5728\u6b64\u94fe\u63a5\u4e2d\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002
MatrixOne \u6587\u6863\u5185\u5bb9\u53ef\u4ee5\u5206\u4e3a\u5982\u4e0b\u51e0\u4e2a\u6a21\u5757\uff1a
Overview: MatrixOne \u7684\u7b80\u4ecb\uff0c\u5305\u542b\u4e86\u4ea7\u54c1\u7279\u70b9\u3001\u67b6\u6784\u3001\u8bbe\u8ba1\u601d\u8def\u548c\u6280\u672f\u7ec6\u8282\u3002
Getting Started: \u4ecb\u7ecd\u5982\u4f55\u5728\u5355\u673a\u73af\u5883\u4e2d\u5feb\u901f\u90e8\u7f72\u548c\u8fd0\u884c MatrixOne\u3002
Developing Guide: \u4ecb\u7ecd\u5982\u4f55\u5728\u5355\u673a\u6216\u5206\u5e03\u5f0f\u73af\u5883\u4e2d\u6df1\u5ea6\u4f7f\u7528 MatrixOne\u3002
Deploying: \u4ecb\u7ecd\u5982\u4f55\u5728\u90e8\u7f72\u548c\u8fd0\u884c MatrixOne \u96c6\u7fa4\u3002
Maintenance: \u4ecb\u7ecd\u5982\u4f55\u8fd0\u7ef4 MatrixOne\uff0c\u5305\u62ec\u5907\u4efd\u4e0e\u6062\u590d\u6570\u636e\u7b49\u3002
Migrating: \u4ecb\u7ecd\u5982\u4f55\u5c06\u6570\u636e\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8fc1\u79fb\u81f3 MatrixOne\u3002
Testing: \u4ecb\u7ecd\u5982\u4f55\u5728\u4f7f\u7528\u6d4b\u8bd5\u5de5\u5177\u5b8c\u6210\u81ea\u6d4b\uff0c\u6216\u8005\u5bf9 MatrixOne \u8fdb\u884c\u6027\u80fd\u6d4b\u8bd5\u3002
Troubleshooting: \u4ecb\u7ecd\u5982\u4f55\u5bf9 MatrixOne \u8fdb\u884c\u6545\u969c\u8bca\u65ad\u3002
Tuning Performance: \u4ecb\u7ecd\u5982\u4f55\u5728\u5355\u673a\u6216\u5206\u5e03\u5f0f\u73af\u5883\u4e2d\u5bf9 MatrixOne \u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u3002
Privilege: \u4ecb\u7ecd MatrixOne \u96c6\u7fa4\u4e0b\u591a\u79df\u6237\u7ba1\u7406\u3001\u8d26\u53f7\u751f\u547d\u5468\u671f\u7ba1\u7406\u3001\u6388\u6743\u7b49\u3002
Reference: \u5305\u62ec SQL \u53c2\u8003\u6307\u5357\u3001\u914d\u7f6e\u53c2\u6570\u8bbe\u7f6e\u3001\u4f7f\u7528\u9650\u5236\u7b49\u3002
FAQs: \u5173\u4e8e\u4ea7\u54c1\u3001\u6280\u672f\u8bbe\u8ba1\u3001SQL\u3001\u90e8\u7f72\u7684\u5e38\u89c1\u7591\u96be\u95ee\u9898\u3002
Release Notes: \u6240\u6709\u7248\u672c\u7684\u53d1\u5e03\u8bf4\u660e\u3002
Contribution Guide: \u4ecb\u7ecd\u5982\u4f55\u4e3a MatrixOne \u9879\u76ee\u505a\u51fa\u8d21\u732e\u3002
Glossary: \u540d\u8bcd\u91ca\u4e49\u8868\u3002
\u5982\u679c\u60a8\u53d1\u73b0\u4e86\u9519\u522b\u5b57\u6216\u8bed\u6cd5\u9519\u8bef\uff0c\u53ef\u4ee5\u70b9\u51fb\u672c\u9875\u9762\u7684 Edit this Page
\u6309\u952e\u76f4\u63a5\u8fdb\u884c\u4fee\u6539\u3002
\u5f53\u60a8\u9700\u8981\u66f4\u6539\u6587\u6863\u7684\u5177\u4f53\u5185\u5bb9\u4f46\u4e0d\u6d89\u53ca\u7ae0\u8282\u987a\u5e8f\u3001\u67b6\u6784\u7ec4\u7ec7\u7684\u8c03\u6574\u65f6\uff0c\u9700\u8981\u5bf9 matrixorigin.io/tree/main/docs/MatrixOne
\u6216 matrixorigin.io.cn/tree/main/docs/MatrixOne
\u8fdb\u884c\u64cd\u4f5c\u3002
\u5982\u679c\u9700\u8981\u5bf9\u7ae0\u8282\u987a\u5e8f\u3001\u67b6\u6784\u7ec4\u7ec7\u8fdb\u884c\u8c03\u6574\u65f6\uff0c\u9700\u8981\u5bf9 matrixorigin.io/blob/main/mkdocs.yml
\u6216 matrixorigin.io.cn/blob/main/mkdocs.yml
\u8fdb\u884c\u64cd\u4f5c\u3002
\u4ee5\u4e0b\u6d41\u7a0b\u6f14\u793a\u7684\u662f\u5bf9\u4e8c\u8005\u5747\u505a\u4fee\u6539\u7684\u60c5\u51b5\uff0c\u5b9e\u9645\u60c5\u51b5\u53ef\u4ee5\u6839\u636e\u60a8\u7684\u9700\u6c42\u8fdb\u884c\u7b80\u5316\u3002
1. \u5728 GitHub \u4e0a\u5bf9\u82f1\u6587\u6587\u6863\u63d0\u51fa Issue \u6216\u5bf9\u4e2d\u6587\u6587\u6863\u63d0\u51fa Issue\uff0c\u7b80\u5355\u4ecb\u7ecd\u60a8\u53d1\u73b0\u7684\u95ee\u9898\u3002\u5e76\u4e14\u5728 Issue \u4e0b\u9762\u8bc4\u8bba\u8ba4\u9886\u8be5\u95ee\u9898\u3002
2. Fork matrixorigin.io \u548c matrixorigin.io.cn \u4ed3\u5e93\u3002
3. \u514b\u9686 matrixorigin.io \u548c matrixorigin.io.cn \u4ed3\u5e93\u3002
git clone git@github.com:yourusername/matrixorigin.io.git\n
git clone git@github.com:yourusername/matrixorigin.io.cn.git\n
4. \u5728\u60a8\u7684\u672c\u5730 matrixorigin.io \u548c matrixorigin.io.cn \u6587\u4ef6\u5939\u4e2d\u5c06\u5bf9\u5e94\u4ed3\u5e93\u6dfb\u52a0\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\u3002
matrixorigin.io
\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\uff1agit remote add upstream https://github.com/matrixorigin/matrixorigin.io.git\n
matrixorigin.io.cn
\u4e3a\u8fdc\u7a0b\u4ed3\u5e93\uff1agit remote add upstream https://github.com/matrixorigin/matrixorigin.io.cn.git\n
5. \u672c\u5730\u7684 matrixorigin.io \u6216 matrixorigin.io.cn \u6587\u4ef6\u5939\u4e2d\u5c06\u5305\u542b\u6587\u6863\u6240\u9700\u8981\u7684\u5168\u90e8\u6587\u4ef6\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u8fd0\u884c mkdocs serve
\u547d\u4ee4\uff0c\u7136\u540e\u5728 http://localhost:8000
\u7f51\u5740\u4e2d\u9884\u89c8\u6587\u6863\uff0c\u68c0\u67e5\u6574\u4e2a\u9879\u76ee\u6587\u4ef6\u662f\u5426\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\uff0c\u5e76\u4e14\u540e\u7eed\u4e5f\u53ef\u4ee5\u68c0\u67e5\u60a8\u6240\u505a\u7684\u4fee\u6539\u662f\u5426\u6b63\u786e\u3002
mkdocs serve\n
6. \u8fdb\u884c\u6587\u6863\u7684\u4fee\u6539\u548c\u5b8c\u5584\uff0c\u5982\u679c\u60a8\u60f3\u5bf9\u9879\u76ee\u7684\u8bbe\u7f6e\u8fdb\u884c\u6539\u52a8\uff0c\u6216\u8005\u6dfb\u52a0\u65b0\u7684 page \u6765\u66f4\u65b0 sitemap\uff0c\u6216\u66f4\u65b0 CI&CD \u5de5\u4f5c\u6d41\u4ee3\u7801\uff0c\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7 http://localhost:8000
\u6765\u67e5\u770b\u60a8\u7684\u4fee\u6539\u662f\u5426\u6709\u6548\u3002
7. \u786e\u8ba4\u4fee\u6539\u65e0\u8bef\u540e\uff0c\u4f7f\u7528 git add .
\u548c git commit
\u547d\u4ee4\u5728\u672c\u5730\u63d0\u4ea4\u4fee\u6539\uff0c\u5e76\u63a8\u9001\u81f3\u60a8 Fork \u7684\u8fdc\u7a0b\u4ed3\u5e93 matrixorigin.io
\u4e0e matrixorigin.io.cn
\u3002 \u6211\u4eec\u5efa\u8bae\u60a8\u63a8\u9001\u81f3\u8fdc\u7a0b\u4ed3\u5e93\u7684\u65b0\u5206\u652f\uff1a
git push origin main:NEW_BRANCH\n
8. \u5728 Github \u4e0a\u76f8\u5e94\u4ed3\u5e93\u7684 NEW_BRANCH
\u5206\u652f\u63d0\u4ea4 Pull Request\u3002
9. \u4e00\u65e6\u60a8\u7684\u4fee\u6539\u901a\u8fc7\uff0cCI \u5de5\u4f5c\u6d41\u5c06\u5f00\u59cb\u8fd0\u884c\u5e76\u66f4\u65b0\u6587\u6863\u7f51\u7ad9\uff0c\u8fd9\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4\u3002
10. \u6700\u540e\uff0c\u8fd8\u6709\u4e00\u4e9b\u64cd\u4f5c\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u6301\u60a8\u7684\u8fdc\u7aef\u4ed3\u5e93\u548c\u672c\u5730\u4ed3\u5e93\u5747\u4fdd\u6301\u4e00\u81f4\u3002
\u8986\u76d6\u672c\u5730\u63d0\u4ea4\u5386\u53f2\uff1a
git pull --force upstream main:main\n
\u66f4\u65b0 Github \u4e0a\u7684 main
\u5206\u652f\uff1a
git push --force origin main:main\n
Info
\u82e5\u60a8\u5728\u4e2d\u82f1\u6587\u4e24\u4e2a\u4ed3\u5e93\u90fd\u505a\u4e86\u4fee\u6539\uff0c\u90a3\u4e48\u4ee5\u4e0a\u5927\u90e8\u5206\u64cd\u4f5c\u90fd\u9700\u8981\u5206\u522b\u9488\u5bf9\u4e2d\u82f1\u6587\u4e24\u4e2a\u4ed3\u5e93\u90fd\u6267\u884c\u4e00\u904d\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/contribute-documentation/#_7","title":"\u5199\u4e00\u7bc7\u535a\u6587","text":"\u5982\u679c\u60a8\u6709\u610f\u5199\u4e00\u7bc7\u5173\u4e8e MatrixOne \u7684\u535a\u6587\uff0c\u8bf7\u5728 GitHub \u4e0a\u63d0\u51fa Issue\uff0c\u6216\u8005\u5c06\u60a8\u7684\u60f3\u6cd5\u53d1\u9001\u5230 dengnan@matrixorigin.io\uff0c\u65e0\u8bba\u662f\u7b80\u5355\u7684 Idea \u8fd8\u662f\u5b8c\u6574\u7684\u8349\u6848\uff0c\u6211\u4eec\u7edf\u7edf\u63a5\u53d7\u3002\u6211\u4eec\u4f1a\u5c3d\u5feb\u5ba1\u67e5\u6240\u6709\u5185\u5bb9\uff0c\u5982\u679c\u60a8\u7684\u6587\u7ae0\u6216\u60f3\u6cd5\u5f88\u5951\u5408\u6211\u4eec\u7684\u535a\u5ba2\uff0c\u6211\u4eec\u4f1a\u76f4\u63a5\u8054\u7cfb\u60a8\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/","title":"\u63d0\u4ea4\u8bbe\u8ba1\u65b9\u6848","text":"\u524d\u9762\u7ae0\u8282\u63d0\u5230\u4e86\u5f88\u591a\u79cd\u7c7b\u7684\u4fee\u6539\uff0c\u6bd4\u5982 Bug \u4fee\u590d\u3001\u6587\u6863\u5b8c\u5584\uff0c\u8fd9\u4e9b\u90fd\u53ef\u4ee5\u901a\u8fc7 GitHub \u7684 PR \u5de5\u4f5c\u6d41\u7a0b\u6765\u5b9e\u73b0\uff1b\u4f46\u4e0e\u6b64\u4e0d\u540c\u7684\u662f\uff0c\u5982\u679c\u60a8\u60f3\u8981\u5728 MatrixOne \u4e2d\u5b9e\u73b0\u65b0\u7684\u529f\u80fd\u6216\u589e\u6dfb\u65b0\u7684\u7ec4\u4ef6\uff0c\u90fd\u4e0d\u4ec5\u4ec5\u662f\u4e00\u4e2a Idea \u8fd9\u4e48\u7b80\u5355\uff0c\u6211\u4eec\u9f13\u52b1\u60a8\u63d0\u51fa\u60f3\u6cd5\u7684\u540c\u65f6\u8fd8\u5236\u5b9a\u76f8\u5e94\u7684\u8bbe\u8ba1\u65b9\u6848\uff0c\u5c06\u5176\u8868\u8fbe\u4e3a\u6280\u672f\u8bbe\u8ba1\u6587\u6863\u3002 \u56e0\u6b64\uff0c\u672c\u8282\u7684\u76ee\u7684\u6b63\u662f\u5f15\u5bfc\u60a8\u64b0\u5199\u4e00\u4efd\u6280\u672f\u8bbe\u8ba1\u6587\u6863\uff0c\u4ee5\u671f\u53ef\u4ee5\u4e3a\u8fd9\u4e2a\u65b0\u529f\u80fd\u63d0\u4f9b\u4e00\u4e2a\u66f4\u52a0\u6743\u5a01\u7684\u3001\u5927\u4f17\u5316\u7684\u89e3\u91ca\uff0c\u5404\u65b9\u4eba\u5458\u53ef\u4ee5\u66f4\u6df1\u5165\u5730\u4e86\u89e3\u8fd9\u4e2a\u6a21\u5757\u7684\u6838\u5fc3\u7406\u5ff5\u4e0e\u53d1\u5c55\u65b9\u5411\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/make-a-design/#_2","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u4e0e\u5176\u4ed6\u5de5\u4f5c\u4e00\u6837\uff0c\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5c3d\u91cf\u505a\u8db3\u51c6\u5907\uff0c\u8fd9\u6837\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u60a8\u7684\u5de5\u4f5c\u6548\u7387\uff0c\u8fd8\u53ef\u4ee5\u589e\u52a0\u65b9\u6848\u901a\u8fc7\u7684\u53ef\u80fd\u6027\uff1b\u76f8\u53cd\uff0c\u4e00\u4efd\u7c97\u7cd9\u800c\u968f\u610f\u7684\u8bbe\u8ba1\u6587\u4ef6\u53ef\u80fd\u4f1a\u56e0\u4e3a\u8d28\u91cf\u592a\u5dee\u800c\u5403\u5230\u95ed\u95e8\u7fb9\u3002 \u6211\u4eec\u9f13\u52b1\u60a8\u5411\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u4eba\u5458\u5bfb\u6c42\u5e2e\u52a9\uff0c\u901a\u8fc7\u4ed6\u4eec\u7684\u5efa\u8bae\u60a8\u53ef\u4ee5\u4fee\u6b63\u8bbe\u8ba1\u67b6\u6784\u5e76\u5b8c\u5584\u6280\u672f\u7ec6\u8282\u3002 \u60a8\u53ef\u4ee5\u5728\u524d\u5f80 Github\uff0c\u63d0\u4ea4\u4e00\u4e2a Feature Request
\u6216 Refactoring Request
\u6765\u5411\u5927\u5bb6\u5c55\u793a\u60a8\u7684\u60f3\u6cd5\u3002
\u901a\u5e38\uff0c\u4ece\u5934\u5230\u5c3e\u5730\u5b8c\u6210\u4e00\u9879\u6280\u672f\u8bbe\u8ba1\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u8bf7\u53ca\u65f6\u67e5\u770b\u5b50\u4efb\u52a1\u7684 Tracking issue \u6765\u8ddf\u8e2a\u4efb\u52a1\u5f00\u53d1\u8fdb\u7a0b\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u975e\u5e38\u6b22\u8fce\u60a8\u53c2\u4e0e\u5230 MatrixOne\uff08\u4ee5\u4e0b\u7b80\u79f0 MO\uff09\u9879\u76ee\u7684\u5efa\u8bbe\u4e2d\u6765\uff01\u65e0\u8bba\u4f60\u662f\u521d\u8bc6 MatrixOne\uff0c\u8fd8\u662f\u5df2\u7ecf\u8feb\u5207\u5730\u60f3\u53c2\u4e0e\u5230\u5f00\u53d1\u5de5\u4f5c\u4e2d\u6765\uff0c\u4ea6\u6216\u662f\u5728\u9605\u8bfb\u6587\u6863\u3001\u4f7f\u7528\u4ea7\u54c1\u7684\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u90fd\u6b22\u8fce\u4f60\u63d0\u51fa\u610f\u89c1\u548c\u5efa\u8bae\uff0c\u4e0e\u6211\u4eec\u5171\u540c\u6253\u9020\u66f4\u52a0\u5f3a\u5927\u3001\u7a33\u5b9a\u7684 MatrixOne\uff01 \u5f53\u7136\uff0c\u5728\u60a8\u5411 MatrixOne \u9879\u76ee\u63d0\u51fa\u6539\u8fdb\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u63d0\u524d\u8bf4\u660e\u4e00\u4e9b\u57fa\u672c\u89c4\u8303\u4e0e\u6d41\u7a0b\uff0c\u4ee5\u63d0\u9ad8\u6574\u4e2a\u8d21\u732e\u8fc7\u7a0b\u7684\u8d28\u91cf\u4e0e\u6d41\u7545\u6027\uff0c\u540c\u65f6\u4e5f\u80fd\u4fdd\u969c MO \u7684\u7a33\u5b9a\u6027\u4e0e\u5b89\u5168\u6027\u3002 \u6b64\u5916\uff0c\u5728\u672c\u7ae0\u4e2d\uff0c\u6211\u4eec\u4e3a\u5c1a\u672a\u719f\u77e5 MO \u7684\u8d21\u732e\u8005\u4eec\u63d0\u4f9b\u4e00\u4e9b\u4e86\u89e3\u6211\u4eec\u7684\u6e20\u9053\uff0c\u5e0c\u671b\u80fd\u4e3a\u4f60\u4eec\u5e26\u6765\u4e00\u4e9b\u4fbf\u5229\uff01
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#matrixone","title":"\u4e86\u89e3 MatrixOne","text":""},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_2","title":"\u7279\u70b9\u4e0e\u6846\u67b6","text":"\u5728 MatrixOne \u7b80\u4ecb\u4e2d\u60a8\u53ef\u4ee5\u4e86\u89e3\u5230 MO \u7684\u8d85\u878d\u5408\u3001\u4e91\u8fb9\u534f\u540c\u7279\u6027\u4ee5\u53ca\u5176\u6240\u521b\u9020\u7684\u4f18\u5f02\u8868\u73b0\u4e0e\u72ec\u7279\u4ef7\u503c\u3002 \u6b64\u5916\uff0c\u5728 MatrixOne \u6846\u67b6\u4e2d\u60a8\u53ef\u4ee5\u8be6\u7ec6\u5730\u4e86\u89e3 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\uff0c\u4ee5\u53ca\u5b58\u50a8\u5c42\u3001\u65e5\u5fd7\u5c42\u7b49\u5177\u4f53\u7ec4\u6210\u60c5\u51b5\u3002 \u540c\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u67e5\u9605 MatrixOne \u672f\u8bed\u8868\u6765\u4e86\u89e3\u4e00\u4e9b\u590d\u6742\u7684\u8bcd\u6c47\u3002 \u5728\u6280\u672f\u5c42\u9762\uff0cSQL \u53c2\u8003\u6307\u5357\u4e3a\u60a8\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684 SQL \u8bed\u8a00\u7684\u53c2\u8003\uff0c\u5176\u4e2d\u5bf9\u8bed\u6cd5\u548c\u793a\u4f8b\u90fd\u6709\u8be6\u7ec6\u89e3\u91ca\uff1b\u540c\u6837\uff0c\u81ea\u5b9a\u4e49\u51fd\u6570\u63d0\u4f9b\u4e86 MO \u4e2d\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u76f8\u5173\u89e3\u91ca\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_3","title":"\u5efa\u8bbe\u60c5\u51b5","text":"\u76ee\u524d\uff0cMatrixOne v1.2.1 \u5df2\u7ecf\u53d1\u5e03\u4e86\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u7248\u672c\u53d1\u5e03\u6307\u5357\u6765\u4e86\u89e3\u6700\u65b0\u7684\u53d1\u5e03\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u6700\u65b0\u7684\u4fee\u6539\u4e0e\u4f18\u5316\u3002
\u5173\u4e8e\u957f\u671f\u7684\u9879\u76ee\u89c4\u5212\uff0c\u8bf7\u53c2\u9605 MatrixOne Roadmap\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_4","title":"\u4f60\u53ef\u4ee5\u505a\u4e9b\u4ec0\u4e48\uff1f","text":"\u5bf9 MatrixOne \u7684\u8d21\u732e\u53ef\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a
\u6211\u4eec\u5c06\u4e3a Github \u4e0a matrixorigin/matrixone \u7684\u9879\u76ee\u76ee\u5f55\u53ca\u5176\u4e2d\u5173\u952e\u6587\u4ef6\u8fdb\u884c\u7b80\u5355\u4ecb\u7ecd\uff0c\u4ee5\u671f\u4e3a\u60a8\u7684\u6df1\u5165\u4e86\u89e3\u548c\u5f00\u53d1\u63d0\u4f9b\u6307\u5bfc\u6027\u5e2e\u52a9\u3002 matrixone \u662f MatrixOne \u4ee3\u7801\u6240\u5728\u7684\u4e3b\u5e93\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5176\u4e2d\u7684\u9879\u76ee\u76ee\u5f55\u4ee5\u53ca\u5173\u952e\u6587\u4ef6\uff0c\u4ee5\u671f\u4e3a\u60a8\u7684\u6df1\u5165\u4e86\u89e3\u548c\u5f00\u53d1\u63d0\u4f9b\u6307\u5bfc\u6027\u5e2e\u52a9\u3002
\u76ee\u5f55 \u5185\u5bb9 /LICENSES \u76f8\u5173\u4f9d\u8d56\u5e93\u7684\u8bb8\u53ef /cmd Go \u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684 binary entry optools \u6d4b\u8bd5\u4e0e\u90e8\u7f72\u5de5\u5177 pkg MatrixOne \u9879\u76ee\u7684\u4e3b\u8981\u4ee3\u7801\u5e93\u5bf9\u4e8e\u4e0d\u540c\u7684\u6280\u672f\u6a21\u5757\uff0c/pkg
\u559c\u7231\u7684\u4ee3\u7801\u7ed3\u6784\u5982\u4e0b\u8868\u6240\u793a\u3002
\u5728\u6587\u6863\u65b9\u9762\uff0cmatrixorigin.io\u3001matrixorigin.io.cn \u4e0e artwork \u90fd\u662f\u5728\u8d21\u732e\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f7f\u7528\u7684\u5e93\uff0c\u8be6\u60c5\u53c2\u89c1\u6587\u6863\u8d21\u732e\u3002
\u76ee\u5f55 \u5185\u5bb9 matrixone/docs/rfcs MatrixOne \u9879\u76ee\u7684\u8bbe\u8ba1\u6587\u6863 matrixorigin.io/docs/MatrixOne \u82f1\u6587\u6587\u6863\u7f51\u7ad9\u7684\u5177\u4f53\u5185\u5bb9\u6587\u4ef6\uff08.md \u6587\u4ef6\uff09 matrixorigin.io.cn/docs/MatrixOne \u4e2d\u6587\u6587\u6863\u7f51\u7ad9\u7684\u5177\u4f53\u5185\u5bb9\u6587\u4ef6\uff08.md \u6587\u4ef6\uff09 matrixorigin.io/mkdocs.yml \u82f1\u6587\u6587\u6863\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6 matrixorigin.io.cn/mkdocs.yml \u4e2d\u6587\u6587\u6863\u7f51\u7ad9\u7684\u914d\u7f6e\u6587\u4ef6 artwork/docs \u6587\u6863\u5b98\u7f51\u51fa\u73b0\u7684\u56fe\u7247\u548c\u56fe\u8868"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#_6","title":"\u5f00\u53d1\u73af\u5883","text":"MO \u4e3b\u8981\u7531 Go \u8bed\u8a00\u7f16\u5199\uff0c\u56e0\u6b64\u9700\u8981\u63d0\u524d\u5b89\u88c5\u90e8\u7f72\u597d\u76f8\u5173\u7684\u5f00\u53d1\u73af\u5883\uff0c\u7b80\u8981\u7684\u793a\u4f8b\u6d41\u7a0b\u5982\u4e0b\uff1a
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin\n
Note
MatrixOne \u4f7f\u7528 Go Modules
\u6765\u7ba1\u7406\u76f8\u5173\u4f9d\u8d56\u3002
\u82e5\u60a8\u9700\u8981\u8865\u5145 Go \u8bed\u8a00\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u53ef\u4ee5\u901a\u8fc7 How to Write Go Code \u8fdb\u884c\u4e86\u89e3\u3002
\u6b64\u5916\uff0c\u786e\u4fdd\u60a8\u81f3\u5c11\u5df2\u7ecf\u5b89\u88c5\u4e86\u5355\u673a\u7248\u672c\u7684 MatrixOne\uff0c\u5177\u4f53\u8fc7\u7a0b\u53ef\u53c2\u7167 Install Standalone MatrixOne\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/preparation/#github-git","title":"Github & Git","text":"\u4e3a\u66f4\u597d\u5730\u5f00\u53d1\u5efa\u8bbe MatrixOne\uff0c\u6211\u4eec\u91c7\u53d6\u4e86\u5f00\u6e90\u8fd0\u8425\u7684\u65b9\u5f0f\uff0c\u901a\u8fc7 Github \u4e3a\u9879\u76ee\u7ef4\u62a4\u4eba\u5458\u548c\u5176\u4ed6\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u4e2a\u534f\u4f5c\u5e73\u53f0\u3002\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u60f3\u53c2\u4e0e\u5230 MO \u7684\u5f00\u53d1\u4e2d\u6765\uff0c\u6211\u4eec\u5f3a\u70c8\u5efa\u8bae\u60a8\u91c7\u53d6 Github \u7684\u6e20\u9053\u3002 \u82e5\u60a8\u8fd8\u672a\u4f7f\u7528\u8fc7 Github \u6216\u7f3a\u5c11\u76f8\u5173\u5f00\u53d1\u7ecf\u9a8c\uff0c\u60a8\u9996\u5148\u9700\u8981\u719f\u6089 GitHub \u4e0a\u7684\u76f8\u5173\u64cd\u4f5c\uff0c\u5e76\u5b66\u4e60\u57fa\u672c\u7684 git \u547d\u4ee4\u3002 \u5982\u679c\u60a8\u6ca1\u6709 Github \u5e10\u6237\uff0c\u8bf7\u5728 https://github.com \u4e0a\u5b8c\u6210\u6ce8\u518c\u3002 \u5982\u679c\u4f60\u6ca1\u6709 SSH \u5bc6\u94a5\uff0c\u4f60\u53ef\u4ee5\u6309\u7167 GitHub \u4e0a\u5173\u4e8e SSH \u7684\u6559\u7a0b\u6765\u751f\u6210\u3001\u6dfb\u52a0\u5bc6\u94a5\u3002 \u66f4\u591a\u8be6\u60c5\u8bf7\u53c2\u89c1 Github Docs\u3002
\u6b64\u5916\uff0c\u6211\u4eec\u5efa\u8bae\u60a8\u5b66\u4e60\u5e76\u4f7f\u7528 git \u547d\u4ee4\u6765\u5b8c\u6210 Github \u4e0a\u7684\u5404\u79cd\u6d41\u7a0b\uff0c\u56e0\u4e3a\u6211\u4eec\u63d0\u4f9b\u7684\u76f8\u5173\u5de5\u4f5c\u6d41\u7a0b\u5927\u591a\u901a\u8fc7 git \u547d\u4ee4\u5b8c\u6210\uff0c\u8fd9\u6709\u52a9\u4e8e\u60a8\u63d0\u9ad8\u6548\u7387\u3002 \u60a8\u53ef\u901a\u8fc7 Install git \u5b89\u88c5 Git \u73af\u5883\u3002 \u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6559\u7a0b\u6765\u5b66\u4e60\u5982\u4f55\u4f7f\u7528\uff1a
\u60a8\u5728\u4f7f\u7528\u6216\u5f00\u53d1 MatrixOne \u8fc7\u7a0b\u4e2d\u9047\u89c1\u7684\u4efb\u4f55\u95ee\u9898\u90fd\u80fd\u4ee5 Issues \u7684\u5f62\u5f0f\u63d0\u51fa\u6765\uff0c\u6211\u4eec\u4e5f\u9f13\u52b1\u60a8\u6309\u7167\u6211\u4eec\u8bbe\u5b9a\u7684\u6a21\u677f\u548c\u6807\u7b7e\u5bf9 Issues \u8fdb\u884c\u8be6\u7ec6\u63cf\u8ff0\u548c\u5206\u7c7b\uff0c\u4ee5\u4fbf\u66f4\u9ad8\u6548\u5730\u89e3\u51b3\u95ee\u9898\u3002 \u672c\u8282\u65e8\u5728\u4ecb\u7ecd\u63d0\u51fa\u95ee\u9898\u65f6\u9700\u8981\u9075\u5faa\u7684\u6a21\u677f\u3001\u6807\u7b7e\u548c\u6ce8\u610f\u4e8b\u9879\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#_2","title":"\u907f\u514d\u91cd\u590d\u95ee\u9898","text":"\u5728\u63d0\u51fa Issue \u4e4b\u524d\uff0c\u5c3d\u91cf\u5148\u786e\u8ba4\u5176\u4ed6\u4eba\u662f\u5426\u5df2\u7ecf\u63d0\u51fa\u8fc7\u76f8\u540c\u6216\u7c7b\u4f3c\u7684\u95ee\u9898\uff0c\u907f\u514d\u91cd\u590d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 search bar \u5de5\u5177\u5e2e\u52a9\u60a8\u7b5b\u9009\u67e5\u627e\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/report-an-issue/#_3","title":"\u6a21\u677f","text":"\u9488\u5bf9\u4e0d\u540c\u79cd\u7c7b\u7684\u95ee\u9898\uff0cMatrixOne \u4f7f\u7528\u4e86\u4e0d\u540c\u7684\u6a21\u677f\u5bf9\u5176\u5185\u5bb9\u8fdb\u884c\u523b\u753b\uff0c\u5176\u4e2d\u5927\u591a\u63cf\u8ff0\u4e86\u95ee\u9898\u7684\u5173\u952e\u4fe1\u606f\uff0c\u6709\u52a9\u4e8e\u5ba1\u67e5\u8005\u4e0e\u5176\u4ed6\u5f00\u53d1\u8005\u7406\u89e3\u5e76\u53c2\u4e0e\u5176\u4e2d\u3002
\u4f8b\u5982\uff0cBug report
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Enhancement
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Feature Request
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Performance Question
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Documentation Issue
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
Refactoring Request
\u95ee\u9898\u6a21\u677f\u5305\u542b\u4ee5\u4e0b\u4fe1\u606f\uff1a
\u9664\u4e86\u63cf\u8ff0\u95ee\u9898\u7684\u8be6\u7ec6\u4fe1\u606f\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u6839\u636e\u95ee\u9898\u6240\u5c5e\u7684\u7ec4\u4ef6\u4ee5\u53ca\u95ee\u9898\u6240\u5c5e\u7248\u672c\u4e3a\u5176\u6dfb\u52a0\u9002\u5f53\u7684\u6807\u7b7e\u3002\u5f53\u60a8\u7684 Issue \u63d0\u4ea4\u4e4b\u540e\uff0c\u4f1a\u81ea\u52a8\u6253\u4e0a needs-triage
\u7684\u6807\u7b7e\uff0c\u4e4b\u540e\u9879\u76ee\u7ef4\u62a4\u8005\u4f1a\u8be6\u7ec6\u9605\u8bfb\u60a8\u7684 Issue\uff0c\u7136\u540e\u4e3a\u4e4b\u6253\u4e0a\u5408\u9002\u7684\u6807\u7b7e\u5e76\u5206\u914d\u7ed9\u5408\u9002\u7684\u5f00\u53d1\u8005\u3002 \u5982\u679c\u60a8\u60f3\u81ea\u5df1\u4eb2\u624b\u5904\u7406\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u5728\u8bc4\u8bba\u4e2d\u63d0\u51fa\uff0c\u793e\u533a\u7ba1\u7406\u5458\u4f1a\u7ed9\u60a8\u5206\u914d\u8fd9\u4e2a issue\u3002\u82e5\u5728 Assignees \u90e8\u5206\u53ef\u4ee5\u770b\u89c1\u60a8\u81ea\u5df1\uff0c\u8bf4\u660e\u64cd\u4f5c\u6210\u529f\u3002
\u5f53\u60a8\u9996\u6b21\u53c2\u4e0e\u8d21\u732e\u65f6\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9 good-first-issue
\u6807\u7b7e\u4e0b\u7684\u95ee\u9898\u7740\u624b\u89e3\u51b3\uff0c\u5176\u4e0b\u7684\u6bcf\u4e2a\u95ee\u9898\u90fd\u662f\u76f8\u5bf9\u6765\u8bf4\u5bb9\u6613\u89e3\u51b3\u7684\u3002 \u8be6\u60c5\u8bf7\u9605\u8bfb\u5feb\u901f\u4e0a\u624b\u7ae0\u8282\u3002
\u5bf9 MatrixOne \u6765\u8bf4\uff0c\u5bf9 PR \u7684\u5ba1\u9605\u548c\u8bc4\u8bba\u662f\u81f3\u5173\u91cd\u8981\u7684\uff1a\u60a8\u53ef\u4ee5\u5bf9\u4ed6\u4eba\u7684 PR \u8fdb\u884c\u5206\u7c7b\uff0c\u4ee5\u4fbf\u6709\u4e13\u5bb6\u66f4\u5feb\u7684\u6765\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff1b\u60a8\u4e5f\u53ef\u4ee5\u5bf9\u4ee3\u7801\u7684\u5185\u5bb9\u8fdb\u884c\u5ba1\u9605\uff0c\u5bf9\u4ee3\u7801\u7f16\u5199\u7684\u98ce\u683c\u3001\u89c4\u8303\u7b49\u63d0\u51fa\u5efa\u8bae\uff1b\u54ea\u6015\u662f\u5728\u8bc4\u8bba\u533a\u7559\u4e0b\u4e00\u4e2a\u5c0f\u5c0f\u7684 Idea\uff0c\u8fd9\u4e5f\u5f25\u8db3\u73cd\u8d35\u3002 \u6240\u6709\u522b\u518d\u72b9\u8c6b\uff0c\u522b\u518d\u62c5\u5fc3\u60a8\u7684\u60f3\u6cd5\u4e0d\u591f\u5b8c\u5584\uff0c\u65e0\u8bba\u591a\u4e48\u5fae\u5c0f\u7684\u5efa\u8bae\u90fd\u53ef\u80fd\u4f1a\u5bf9 MatrixOne \u4ea7\u751f\u6df1\u8fdc\u5f71\u54cd\u3002
\u5f53\u7136\uff0c\u5728\u6b64\u4e4b\u524d\uff0c\u6211\u4eec\u5e0c\u671b\u60a8\u80fd\u8ba4\u771f\u9605\u8bfb\u672c\u8282\uff0c\u4e86\u89e3\u57fa\u672c\u8981\u6c42\u548c\u76f8\u5173\u65b9\u6cd5\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#_2","title":"\u57fa\u672c\u539f\u5219","text":"\u5f53\u5bf9\u4e00\u4e2a PR \u8fdb\u884c\u8bc4\u8bba\u6216\u8005\u5ba1\u9605\u65f6\uff0c\u65e0\u8bba\u5185\u5bb9\u5982\u4f55\uff0c\u6211\u4eec\u547c\u5401\u6240\u6709\u53c2\u4e0e\u8005\u90fd\u4fdd\u6301\u53cb\u597d\u548c\u5584\u7684\u6001\u5ea6\uff0c\u8425\u9020\u4e00\u4e2a\u548c\u8c10\u7684\u793e\u533a\u6c1b\u56f4\u3002
\u5c0a\u91cd\u4ed6\u4eba \u5c0a\u91cd\u6bcf\u4e00\u4e2a PR \u8bf7\u6c42\u7684\u53d1\u8d77\u4eba\u548c\u5176\u4ed6\u5ba1\u9605\u8005\u3002\u4ee3\u7801\u5ba1\u9605\u662f\u793e\u533a\u6d3b\u52a8\u7684\u91cd\u8981\u90e8\u5206\uff0c\u56e0\u6b64\u8bf7\u9075\u5faa\u793e\u533a\u8981\u6c42\u3002
\u6ce8\u610f\u8bed\u6c14 \u5728\u4e0e\u4ed6\u4eba\u6c9f\u901a\u4ea4\u6d41\u65f6\uff0c\u6211\u4eec\u9f13\u52b1\u60a8\u591a\u4f7f\u7528\u201c\u5efa\u8bae\u201d\u6216\u8005\u201c\u63d0\u95ee\u201d\u7684\u8bed\u6c14\uff0c\u800c\u4e0d\u8981\u603b\u662f\u547d\u4ee4\u4ed6\u4eba\u3002\u6362\u4f4d\u601d\u8003\uff0c\u6240\u6709\u4eba\u90fd\u5e0c\u671b\u88ab\u6e29\u67d4\u4ee5\u5f85\uff01
\u8d5e\u7f8e \u4e0d\u8981\u541d\u556c\u5bf9\u4ed6\u4eba\u7684\u8d5e\u7f8e\uff01\u4e00\u4e2a\u597d\u7684\u60f3\u6cd5\u6216\u8005\u597d\u7684\u6210\u679c\u503c\u5f97\u6211\u4eec\u5938\u8d5e\u3002\u5728\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u9f13\u52b1\u3001\u8d5e\u7f8e\u4ed6\u4eba\u5f80\u5f80\u6bd4\u4e0d\u7559\u60c5\u9762\u7684\u6279\u8bc4\u66f4\u6709\u4ef7\u503c\uff01
\u6b64\u5916\uff0c\u5728\u5177\u4f53\u5185\u5bb9\u4e0a\u6211\u4eec\u6709\u5982\u4e0b\u5efa\u8bae\uff1a
\u8be6\u7ec6\u800c\u5177\u4f53 \u6211\u4eec\u5e0c\u671b\u60a8\u80fd\u5728\u8bc4\u8bba\u4e2d\u63d0\u4f9b\u66f4\u4e3a\u8be6\u7ec6\u800c\u5177\u4f53\u7684\u4fe1\u606f\uff0c\u56e0\u4e3a\u4fe1\u606f\u8d8a\u8be6\u7ec6\uff0c\u4ed6\u4eba\u5c31\u66f4\u5bb9\u6613\u7406\u89e3\uff0c\u4e5f\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u89e3\u51b3\u95ee\u9898\u3002\u5982\u679c\u60a8\u8fdb\u884c\u4e86\u6d4b\u8bd5\uff0c\u5b8c\u5168\u53ef\u4ee5\u653e\u4e0a\u6d4b\u8bd5\u73af\u5883\u548c\u7ed3\u679c\uff1b\u5982\u679c\u60a8\u63d0\u51fa\u4e86\u4e00\u4e9b\u5efa\u8bae\uff0c\u90a3\u4e0d\u59a8\u8bf4\u8bf4\u5e94\u8be5\u5982\u4f55\u843d\u5b9e\u3002
\u5ba2\u89c2\u800c\u516c\u6b63 \u8bf7\u907f\u514d\u4e2a\u4eba\u504f\u89c1\u548c\u4e3b\u89c2\u60c5\u7eea\u3002\u8bda\u7136\uff0c\u6bcf\u4e2a\u4eba\u7684\u8bc4\u8bba\u6216\u591a\u6216\u5c11\u90fd\u4f1a\u5e26\u6709\u4e3b\u89c2\u8272\u5f69\uff0c\u4f46\u662f\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u6210\u719f\u7684\u5ba1\u9605\u8005\uff0c\u60a8\u5e94\u8be5\u6ce8\u91cd\u6280\u672f\u548c\u6570\u636e\uff0c\u800c\u4e0d\u662f\u4e2a\u4eba\u7684\u559c\u597d\u3002
\u7075\u6d3b\u800c\u5ba1\u614e \u5f53\u9047\u89c1\u4e00\u4e9b\u590d\u6742\u95ee\u9898\u65f6\uff0c\u5373\u4f7f\u662f\u5728\u7efc\u5408\u8003\u91cf\u591a\u65b9\u56e0\u7d20\u4e4b\u540e\u4e5f\u5f88\u96be\u6289\u62e9\uff0c\u201c\u63a5\u53d7\u201d\u8fd8\u662f\u201c\u62d2\u7edd\u201d\uff0c\u662f\u4e2a\u4e24\u96be\u7684\u95ee\u9898\u2014\u2014\u2014\u6211\u4eec\u4e5f\u65e0\u6cd5\u7ed9\u51fa\u4e00\u4e2a\u660e\u786e\u3001\u5177\u4f53\u7684\u6807\u51c6\uff0c\u53ea\u80fd\u8bf4\u201c\u5177\u4f53\u60c5\u51b5\uff0c\u5177\u4f53\u5206\u6790\u201d\u3002\u4f46\u662f\u6211\u4eec\u5efa\u8bae\u60a8\u5728\u96be\u4ee5\u6289\u62e9\u65f6\uff0c\u5bfb\u6c42\u4ed6\u4eba\u7684\u5e2e\u52a9\u3002
\u6709\u4e9b PR \u521b\u5efa\u8005\u53ef\u80fd\u5e76\u4e0d\u719f\u6089 MatrixOne \u6216\u76f8\u5173\u5f00\u53d1\u5de5\u4f5c\u6d41\u7a0b\uff0c\u56e0\u6b64\u4e0d\u786e\u5b9a\u5e94\u8be5\u6dfb\u52a0\u4f55\u79cd\u6807\u7b7e\uff0c\u4e5f\u4e0d\u4e86\u89e3\u5e94\u8be5\u628a\u95ee\u9898\u5206\u914d\u7ed9\u8c01\u3002\u5982\u679c\u60a8\u77e5\u9053\u8be5\u5982\u4f55\u505a\uff0c\u6211\u4eec\u5e0c\u671b\u60a8\u53ef\u4ee5\u5411\u4ed6\u4eec\u65bd\u4ee5\u63f4\u624b\uff0c\u4e3a\u95ee\u9898\u8865\u5145\u4e0a\u6807\u7b7e\u7b49\u4fe1\u606f\uff0c\u8fd9\u6709\u52a9\u4e8e\u63a8\u52a8\u95ee\u9898\u7684\u89e3\u51b3\u8fdb\u7a0b\u3002
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/review-a-pull-request/#_3","title":"\u68c0\u67e5\u6b63\u8bef","text":"\u5f53\u60a8\u68c0\u67e5\u4ee3\u7801\u6216\u5176\u4ed6\u4fee\u6539\u7684\u6b63\u8bef\u65f6\uff0c\u52a1\u5fc5\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a
README.md
\u3002\u7c7b\u4f3c\u5730\uff0c\u5982\u679c\u4e00\u4e2a PR \u5220\u9664\u6216\u5f03\u7528\u4e86\u4e00\u6bb5\u4ee3\u7801\uff0c\u60a8\u5fc5\u987b\u68c0\u67e5\u76f8\u5e94\u7684\u6587\u6863\u662f\u5426\u4e5f\u5e94\u8be5\u88ab\u5220\u9664\u3002\u5bf9 MatrixOne \u7684\u8d21\u732e\u7edd\u4e0d\u4ec5\u9650\u4e8e\u4ee3\u7801\u3002\u4ee5\u4e0b\u4e3a\u60a8\u5c55\u793a\u4e86\u53c2\u4e0e MatrixOne \u9879\u76ee\u5e76\u53c2\u4e0e\u6211\u4eec\u7684\u5f00\u6e90\u793e\u533a\u7684\u5404\u79cd\u65b9\u5f0f\uff1a
"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#_2","title":"\u4ee3\u7801\u8d21\u732e","text":"\u7c7b\u578b \u8bf4\u660e \u62a5\u544a Bug \u60a8\u53ef\u4ee5\u5728 GitHub \u4e0a\u63d0\u51fa Issue \u6765\u62a5\u544a\u60a8\u5728\u8fd0\u884c\u6216\u5f00\u53d1 MatrixOne \u65f6\u6240\u9047\u89c1\u7684 Bug\u3002 \u63d0\u4ea4\u4ee3\u7801 \u540c\u6837\uff0c\u60a8\u4e5f\u53ef\u4ee5\u4fee\u590d\u5df2\u6709\u7684 Bug \u6216\u8005\u89e3\u51b3 GitHub \u4e0a\u63d0\u51fa\u7684\u5173\u952e\u6027\u95ee\u9898\uff0c\u4e5f\u53ef\u4ee5\u63d0\u51fa\u65b0\u7684\u529f\u80fd\u9700\u6c42\u4ee5\u53ca\u8bbe\u8ba1\u6784\u601d\u3002\u8bf7\u53c2\u89c1\u4ee3\u7801\u8d21\u732e\u6765\u4e86\u89e3\u5177\u4f53\u7684\u89c4\u8303\u4e0e\u6b65\u9aa4\u3002 \u5ba1\u67e5 \u60a8\u4e5f\u53ef\u4ee5\u4ee5\u5ba1\u67e5\u8005\u7684\u8eab\u4efd\u5bf9 MatrixOne \u4e2d\u7684 PR \u8fdb\u884c\u8bc4\u8bba\u3001\u5ba1\u67e5\uff0c\u4e3a\u4ed6\u4eba\u63d0\u4f9b\u5efa\u8bae\u548c\u5e2e\u52a9\u3002"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#matrixone","title":"\u5b8c\u5584 MatrixOne \u6587\u6863","text":"\u7c7b\u578b \u8bf4\u660e \u62a5\u544a\u6216\u4fee\u590d\u6280\u672f\u6587\u6863\u7684\u95ee\u9898 \u60a8\u53ef\u4ee5\u70b9\u51fb\u6587\u6863\u7f51\u7ad9\u4e0a\u7684 Edit the page \u6309\u952e\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u5f53\u524d\u9875\u9762\u8fdb\u884c\u4fee\u6539\u5e76\u63d0\u4ea4\u82f1\u6587\u6587\u6863 PR \u6216\u63d0\u4ea4\u4e2d\u6587\u6587\u6863 PR\u3002\u5f53\u7136\u60a8\u53ef\u4ee5\u53ef\u4ee5\u5728 GitHub \u7684[Issue]\u4e2d\u63d0\u51fa\u95ee\u9898\uff0c\u5e76\u63cf\u8ff0\u76f8\u5173\u4fe1\u606f\uff1a\u82f1\u6587\u6587\u6863 Issue\u4e2d\u6587\u6587\u6863 Issue \u63d0\u4ea4\u4e00\u4efd\u65b0\u7684\u6587\u6863 \u5728\u64b0\u5199\u4e00\u4efd\u5b8c\u6574\u7684\u6587\u6863\u4e4b\u524d\uff0c\u8bf7\u9605\u8bfb\u6587\u6863\u8d21\u732e\u6307\u5357\u3002"},{"location":"MatrixOne/Contribution-Guide/How-to-Contribute/types-of-contributions/#_3","title":"\u5176\u4ed6","text":"\u7c7b\u578b \u8bf4\u660e \u5206\u4eab\u7528\u4f8b\u548c\u89e3\u51b3\u65b9\u6848 \u5411\u7528\u6237\u5c55\u793a\u5982\u4f55\u5728\u7279\u5b9a\u573a\u666f\u4e0b\u4f7f\u7528 MatrixOne\uff0c\u53ef\u4ee5\u5c06\u60a8\u7684\u7528\u4f8b\u53d1\u9001\u5230 dengnan@matrixorigin.io\uff0c\u6211\u4eec\u5c06\u5728\u793e\u533a\u4e2d\u53d1\u5e03\u3002 \u64b0\u5199\u535a\u6587\u3001\u6545\u4e8b\u5899\u3001\u767d\u76ae\u4e66 \u64b0\u5199\u9ad8\u8d28\u91cf\u7684\u6587\u7ae0\uff0c\u6e05\u6670\u51c6\u786e\u5730\u89e3\u91ca\u6709\u5173 MatrixOne \u7684\u6280\u672f\u7ec6\u8282\u3002 \u505a\u4e00\u573a\u6280\u672f\u6f14\u8bb2\u6216\u73b0\u573a\u76f4\u64ad \u53d1\u8868\u6f14\u8bb2\u6216\u73b0\u573a\u76f4\u64ad\u53ef\u4ee5\u5e2e\u52a9\u63d0\u9ad8\u5404\u754c\u670b\u53cb\u5bf9 MatrixOne \u7684\u8ba4\u8bc6\u3002 \u4e92\u76f8\u652f\u6301 \u5e2e\u52a9 GitHub \u4e0a\u7684\u7528\u6237\u89e3\u51b3\u4f7f\u7528 MatrixOne \u65f6\u9047\u5230\u7684\u95ee\u9898\u3002 Issue \u5206\u7c7b \u5728 GitHub Issues \u4e2d\u4e3a\u5404\u4e2a Issue \u6dfb\u52a0\u5408\u9002\u7684\u6807\u7b7e\uff0c\u53ef\u4ee5\u5f88\u5feb\u5730\u628a\u95ee\u9898\u5206\u914d\u7ed9\u5bf9\u5e94\u8d1f\u8d23\u4eba\uff0c\u63d0\u9ad8\u95ee\u9898\u7684\u89e3\u51b3\u6548\u7387\u3002\u8fd9\u662f\u5bf9 MatrixOne \u5de5\u4f5c\u5f00\u53d1\u6d41\u7a0b\u7684\u5de8\u5927\u8d21\u732e\u3002 \u5176\u4ed6\u4efb\u4f55\u8d21\u732e \u6211\u4eec\u6b22\u8fce\u4efb\u4f55\u5bf9 MatrixOne \u53ca\u5176\u5f00\u6e90\u793e\u533a\u7684\u53d1\u5c55\u8d77\u5230\u79ef\u6781\u4f5c\u7528\u7684\u8d21\u732e\u3002"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/","title":"Operator \u7ba1\u7406","text":""},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#matrixone-operator","title":"MatrixOne Operator \u6982\u8ff0","text":"MatrixOne Operator \u7528\u6765\u5b9a\u4e49\u548c\u7ba1\u7406 MatrixOne \u96c6\u7fa4\u5728 Kubernetes \u7684\u8d44\u6e90\u9700\u6c42\uff0c\u7531\u4e00\u7ec4 Kubernetes \u81ea\u5b9a\u4e49\u8d44\u6e90\uff08CustomResourceDefinitions, CRD\uff09\uff0c\u4e00\u7ec4 Kubernetes \u63a7\u5236\u5668\u548c\u4e00\u7ec4 WebHook \u670d\u52a1\u7ec4\u6210\uff1a
CRD\uff1a\u5728 Kubernetes \u4e2d\uff0cCRD \u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u7528\u4e8e\u6ce8\u518c\u65b0\u7684\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b\u5230 Kubernetes APIServer \u4e2d\u3002MatrixOne Operator \u4e2d\u5305\u542b\u7684 CRDs \u6ce8\u518c\u4e86\u591a\u79cd\u81ea\u5b9a\u4e49\u8d44\u6e90\uff0c\u5305\u62ec\u7528\u4e8e\u63cf\u8ff0 MatrixOne \u96c6\u7fa4\u7684 MatrixOneCluster \u8d44\u6e90\u3001\u4ee5\u53ca\u63cf\u8ff0\u96c6\u7fa4\u5185\u7ec4\u4ef6\u7684 CNSet\u3001TNSet\u3001LogSet \u7b49\u8d44\u6e90\u3002\u6ce8\u518c\u5b8c\u6210\u540e\uff0c\u5ba2\u6237\u7aef\u5c31\u80fd\u591f\u5728 Kubernetes APIServer \u4e0a\u8bfb\u5199\u8fd9\u4e9b\u8d44\u6e90\u3002
\u63a7\u5236\u5668\uff1a\u63a7\u5236\u5668\u662f\u4e00\u4e2a\u957f\u671f\u8fd0\u884c\u7684\u81ea\u52a8\u5316\u7a0b\u5e8f\uff0c\u8d1f\u8d23\u76d1\u63a7 Kubernetes \u4e2d\u8d44\u6e90\u7684\u671f\u671b\u72b6\u6001\u548c\u6536\u96c6\u8fd9\u4e9b\u8d44\u6e90\u7684\u5b9e\u9645\u72b6\u6001\uff0c\u5e76\u81ea\u52a8\u8fd0\u7ef4\uff0c\u9a71\u52a8\u5b9e\u9645\u72b6\u6001\u5411\u671f\u671b\u72b6\u6001\u8f6c\u79fb\u3002matrixone-operator \u4e2d\u7684\u63a7\u5236\u5668\u4f1a\u76d1\u89c6 MatrixOneCluster\u3001CNSet\u3001TNSet\u3001LogSet \u7b49\u8d44\u6e90\uff0c\u5e76\u8d1f\u8d23\u5b9e\u73b0\u7528\u6237\u901a\u8fc7\u8fd9\u4e9b\u8d44\u6e90\u58f0\u660e\u7684\u671f\u671b\u72b6\u6001\u3002
Webhook \u670d\u52a1\uff1aWebhook \u670d\u52a1\u662f\u4e00\u4e2a\u957f\u671f\u8fd0\u884c\u7684 HTTP \u670d\u52a1\u3002\u5f53 Kubernetes APIServer \u6536\u5230\u7528\u6237\u8bfb\u5199 MatrixOneCluster\u3001CNSet\u3001TNSet\u3001LogSet \u7b49\u8d44\u6e90\u7684\u8bf7\u6c42\u65f6\uff0c\u4f1a\u5c06\u8bf7\u6c42\u8f6c\u53d1\u7ed9 Webhook \u670d\u52a1\uff0c\u7531 Webhook \u670d\u52a1\u6267\u884c\u8bf7\u6c42\u6821\u9a8c\u3001\u9ed8\u8ba4\u503c\u586b\u5145\u7b49\u903b\u8f91\u3002
\u5728\u4f7f\u7528 Helm chart \u5b89\u88c5 Matrixone-Operator \u65f6\uff0c\u4f1a\u81ea\u52a8\u63d0\u4ea4\u6240\u9700\u7684 CRDs \u5230 Kubernetes APIServer\uff0c\u5b8c\u6210\u81ea\u5b9a\u4e49\u8d44\u6e90\u7684\u6ce8\u518c\uff0c\u5e76\u90e8\u7f72\u4e00\u4e2a\u957f\u671f\u8fd0\u884c\u7684 Matrixone-Operator \u5e94\u7528\u3002\u8be5\u5e94\u7528\u4e2d\u6253\u5305\u4e86\u4e0a\u8ff0\u7684\u63a7\u5236\u5668\u548c Webhook \u670d\u52a1\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_1","title":"\u96c6\u7fa4\u7ba1\u7406","text":"MatrixOne Operator \u901a\u8fc7 MatrixOneCluster \u8d44\u6e90\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u58f0\u660e\u5f0f\u7684\u96c6\u7fa4\u7ba1\u7406\u80fd\u529b\u3002\u5177\u4f53\u800c\u8a00\uff0c\u5728 Kubernetes \u4e0a\u90e8\u7f72 MatrixOne \u96c6\u7fa4\u65f6\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528 YAML \u683c\u5f0f\u58f0\u660e\u4e00\u4e2a MatrixOneCluster \u5bf9\u8c61\u6765\u63cf\u8ff0\u96c6\u7fa4\uff0c\u8be5 operator \u7684\u63a7\u5236\u5668\u4f1a\u6839\u636e\u8be5\u63cf\u8ff0\u5b9e\u73b0\u96c6\u7fa4\u7684\u7f16\u6392\uff0c\u5e76\u5c06\u96c6\u7fa4\u72b6\u6001\u66f4\u65b0\u5230 MatrixOneCluster \u5bf9\u8c61\u7684 .status
\u5b57\u6bb5\u4e2d\u3002
MatrixOneCluster \u96c6\u7fa4\u7531\u591a\u4e2a\u7ec4\u4ef6\uff08\u5982 Compute Node\uff08CN\uff09\u3001Transaction Node\uff08TN\uff09\u548c Log Service\uff09\u6784\u6210\uff0c\u8fd9\u4e9b\u7ec4\u4ef6\u5bf9\u5e94\u4e8e CNSet\u3001TNSet \u548c LogSet \u7b49\u5b50\u8d44\u6e90\u3002\u56e0\u6b64\uff0cMatrixOneCluster \u8d44\u6e90\u7684\u63a7\u5236\u5668\u4f1a\u7f16\u6392\u8fd9\u4e9b\u5b50\u8d44\u6e90\uff0c\u5e76\u4f9d\u8d56\u8fd9\u4e9b\u5b50\u8d44\u6e90\u7684\u63a7\u5236\u5668\u6765\u5b8c\u6210\u5b83\u4eec\u7684\u7f16\u6392\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_2","title":"\u90e8\u7f72\u4e0e\u8fd0\u7ef4","text":"\u672c\u7ae0\u8282\u6240\u4ecb\u7ecd\u5230\u7684\u90e8\u7f72\u4e0e\u8fd0\u7ef4\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
\u4ee5\u4e0b\u64cd\u4f5c\u5747\u5728 master0 \u8282\u70b9\u8fdb\u884c\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_3","title":"\u90e8\u7f72","text":"\u53ef\u4ee5\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684 MatrixOne-Operator \u90e8\u7f72\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_4","title":"\u68c0\u67e5\u72b6\u6001","text":"\u6211\u4eec\u91c7\u7528\u4e86 Helm \u5de5\u5177\u5bf9 MatrixOne Operator \u8fdb\u884c\u90e8\u7f72\u3002Helm \u662f Kubernetes \u5e94\u7528\u5305\u7ba1\u7406\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u7ba1\u7406 chart\uff0c\u9884\u5148\u914d\u7f6e\u597d\u7684\u5b89\u88c5\u5305\u8d44\u6e90\uff0c\u7c7b\u4f3c\u4e8e Ubuntu \u7684 APT \u548c CentOS \u4e2d\u7684 YUM\u3002\u4f7f\u7528 helm list
\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b Operator \u7684\u90e8\u7f72\u72b6\u6001\u3002
[root@master0 ~]# NS=\"matrixone-operator\"\n[root@master0 ~]# helm list -n${NS}\nNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION\nmatrixone-operator matrixone-operator 1 2023-05-09 15:19:38.363683192 +0800 CST deployed matrixone-operator-0.8.0-alpha.2 0.1.0\n
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_5","title":"\u5347\u7ea7","text":"MatrixOne-Operator \u9879\u76ee\u662f\u957f\u671f\u7ef4\u62a4\u66f4\u65b0\u7684\u9879\u76ee\uff0c\u8bf7\u66f4\u65b0\u81f3\u6700\u65b0\u7248\u672c\u3002\u4f60\u53ef\u4ee5\u5728 Github \u4e0a\u4e0b\u8f7d\u65b0\u7248\u672c\u7684 Operator\uff0c\u4f8b\u5982\uff1amatrixone-operator-0.8.0-alpha.2
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u89e3\u538b\u6587\u4ef6\uff1a
tar xvf ./matrixone-operator-0.8.0-alpha.2.tgz\ncd matrixone-operator\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 helm upgrade
\u547d\u4ee4\u6765\u5347\u7ea7 Matrixone-Operator\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u83b7\u53d6\u955c\u50cf\u7248\u672c\uff1a
cd matrixone-operator\nNS=\"matrixone-operator\"\nhelm upgrade -n \"${NS}\" matrixone-operator ./ --dependency-update\n
\u5347\u7ea7\u6210\u529f\u540e\uff0c\u4ee3\u7801\u5c55\u793a\u5982\u4e0b\u6240\u793a\uff1a
Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May 9 17:59:06 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 2\nTEST SUITE: None\n
\u5347\u7ea7\u5b8c\u6210\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u7248\u672c\uff1a
#\u83b7\u53d6\u955c\u50cf\u7248\u672c\nNS=\"matrixone-operator\"\nkubectl get pod -n${NS} `kubectl get pod -n${NS} | grep operator | head -1 | awk '{print $1}'` -ojsonpath='{.spec.containers[0].image}'\nmatrixorigin/matrixone-operator:0.8.0-alpha.2\n
\u5728\u5347\u7ea7 Matrixone-Operator \u4e4b\u540e\uff0c\u4f1a\u5728 matrixone-operator
\u547d\u540d\u7a7a\u95f4\u4e0b\u5148\u91cd\u65b0\u751f\u6210\u4e00\u4e2a\u65b0\u7684 matrixone-operator-xxxx-xxx
\u7684 Pod\uff0c\u4e4b\u540e\u4f1a\u628a\u65e7\u7684 Pod \u5220\u9664\u3002
Note
\u5347\u7ea7\u5b8c\u6210\u540e\uff0c\u5047\u5982 Matrixone-Operator \u5347\u7ea7\u6240\u5e26\u6765\u7684\u53d8\u66f4\u4e5f\u4f1a\u66f4\u65b0\u9ed8\u8ba4 .spec
\uff0c\u90a3\u4e48\u6709\u53ef\u80fd\u4f1a\u6eda\u52a8\u66f4\u65b0 MatrixOne \u96c6\u7fa4\u76f8\u5173\u670d\u52a1\u6216\u914d\u7f6e\uff0c\u56e0\u6b64 MatrixOne \u670d\u52a1\u53ef\u80fd\u4f1a\u88ab\u91cd\u542f\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u76d1\u63a7\u5347\u7ea7\u8fc7\u7a0b\uff1awatch -e \"kubectl get pod -nmo-hn -owide\"
\u3002
NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6 1/1 Running 0 164m 10.234.168.43 node1 <none> <none>\n
"},{"location":"MatrixOne/Deploy/MatrixOne-Operator-mgmt/#_6","title":"\u6269\u7f29\u5bb9","text":"\u7531\u4e8e Operator \u7ecf\u5e38\u4f7f\u7528\u6709\u9650\u7684\u8d44\u6e90\uff0c\u56e0\u6b64\u5782\u76f4\u6269\u7f29\u5bb9\u7684\u573a\u666f\u76f8\u5bf9\u8f83\u5c11\u3002\u4e00\u822c\u800c\u8a00\uff0c\u6211\u4eec\u53ea\u9700\u8981\u8003\u8651\u6c34\u5e73\u6269\u7f29\u5bb9\uff0c\u4e5f\u5c31\u662f\u589e\u52a0\u6216\u51cf\u5c11\u526f\u672c\u7684\u6570\u91cf\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cOperator \u662f\u5355\u526f\u672c\u7684\uff0c\u5982\u679c\u6211\u4eec\u9700\u8981\u589e\u5f3a Operator \u7684\u9ad8\u53ef\u7528\u6027\uff0c\u53ef\u4ee5\u8003\u8651\u5c06\u5176\u6269\u5bb9\uff0c\u4f8b\u5982\u6269\u5bb9\u4e3a\u4e24\u4e2a\u526f\u672c\u3002\u8fd9\u6837\uff0c\u5373\u4f7f\u7b2c\u4e00\u4e2a\u526f\u672c\u51fa\u73b0\u5f02\u5e38\uff08\u4f8b\u5982\uff0c\u5728\u6240\u5728\u8282\u70b9\u4e0a\u62c9\u53d6\u6620\u50cf\u5931\u8d25\uff09\uff0c\u53e6\u4e00\u4e2a\u526f\u672c\u4ecd\u7136\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002\u8fd9\u5bf9\u4e8e MO \u96c6\u7fa4\u7684\u90e8\u7f72\u548c\u8fd0\u7ef4\u7ba1\u7406\u64cd\u4f5c\u975e\u5e38\u91cd\u8981\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u5f53\u524d Operator \u7248\u672c\u7684\u90e8\u7f72\u76ee\u5f55\u4e0b\uff0c\u4f7f\u7528 Helm Upgrade \u547d\u4ee4\u5e76\u6307\u5b9a replicaCount \u7684\u6570\u91cf\u6765\u5b8c\u6210 Operator \u526f\u672c\u6570\u7684\u6269\u7f29\u5bb9\u3002
\u5728\u8fdb\u884c\u6269\u5bb9\u4e4b\u524d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b Operator \u7684\u6570\u91cf\uff1a
NS=\"matrixone-operator\"\nwatch -e \"kubectl get pod -n${NS} -owide\"\n
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmatrixone-operator-f8496ff5c-s2lr6 1/1 Running 0 164m 10.234.168.43 node1 <none> <none>\n
# \u526f\u672c\u6570\ncd matrixone-operator\nNUM=2\nNS=\"matrixone-operator\"\nhelm upgrade -n${NS} matrixone-operator ./ --dependency-update --set replicaCount=${NUM}\n
\u6269\u5bb9\u6210\u529f\uff0c\u6253\u5370\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
Release \"matrixone-operator\" has been upgraded. Happy Helming!\nNAME: matrixone-operator\nLAST DEPLOYED: Tue May 9 18:07:03 2023\nNAMESPACE: matrixone-operator\nSTATUS: deployed\nREVISION: 3\nTEST SUITE: None\n
\u4f60\u53ef\u4ee5\u7ee7\u7eed\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u89c2\u5bdf operator \u4e2a\u6570\uff1a
watch -e \"kubectl get pod -nmo-hn -owide\"\nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmatrixone-operator-f8496ff5c-nt8qs 1/1 Running 0 9s 10.234.60.126 node0 <none> <none>\nmatrixone-operator-f8496ff5c-s2lr6 1/1 Running 0 167m 10.234.168.43 node1 <none> <none>\n
\u5982\u679c\u9700\u8981\u6c34\u5e73\u7f29\u5bb9\uff0c\u53ef\u4ee5\u901a\u8fc7 helm upgrade
\u964d\u4f4e replicaCount
\u6570\u91cf\u6765\u5b8c\u6210 operator \u526f\u672c\u6570\u7684\u7f29\u5bb9\u3002
Warning
\u5728\u5378\u8f7d Matrixone-Operator \u4e4b\u524d\uff0c\u52a1\u5fc5\u786e\u8ba4\u6e05\u695a\uff0c\u56e0\u4e3a\u5378\u8f7d\u64cd\u4f5c\u4f1a\u76f4\u63a5\u5378\u8f7d Matrixone \u96c6\u7fa4\u76f8\u5173\u7684\u8d44\u6e90\uff0c\u5305\u62ec SVC\u3001Pod \u7b49\uff08\u4f46\u4e0d\u5305\u62ec log service \u4f7f\u7528\u7684 pvc \u8d44\u6e90\uff09\u3002
\u4f7f\u7528\u5982\u4e0b\u6307\u4ee4\u5378\u8f7d Matrixone-Operator\uff1a
helm uninstall matrixone-operator -n mo-hn\n
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/","title":"\u96c6\u7fa4\u6269\u7f29\u5bb9","text":"\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd MatrixOne \u96c6\u7fa4\u5982\u4f55\u8fdb\u884c\u6269\u7f29\u5bb9\uff0c\u5e76\u5305\u62ec Kubernetes \u96c6\u7fa4\u672c\u8eab\u7684\u6269\u7f29\u5bb9\u4e0e MatrixOne \u7684\u5404\u4e2a\u670d\u52a1\u7684\u6269\u7f29\u5bb9\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#_2","title":"\u4f55\u65f6\u9700\u8981\u8fdb\u884c\u6269\u5bb9/\u7f29\u5bb9","text":"\u4e3a\u4e86\u786e\u5b9a\u662f\u5426\u9700\u8981\u5bf9 MatrixOne \u670d\u52a1\u8fdb\u884c\u6269\u7f29\u5bb9\uff0c\u7528\u6237\u9700\u8981\u76d1\u63a7 MatrixOne \u96c6\u7fa4\u6240\u5728\u7684\u8282\u70b9\u548c\u76f8\u5173\u7ec4\u4ef6\u5bf9\u5e94\u7684 Pod \u6240\u4f7f\u7528\u7684\u8d44\u6e90\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 kubectl top
\u547d\u4ee4\u6765\u5b8c\u6210\u6b64\u64cd\u4f5c\u3002\u66f4\u8be6\u7ec6\u7684\u64cd\u4f5c\u6b65\u9aa4\u53ef\u4ee5\u53c2\u8003\u5065\u5eb7\u68c0\u67e5\u4e0e\u8d44\u6e90\u76d1\u63a7\u3002
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u53d1\u73b0\u8282\u70b9\u6216\u8005 Pod \u7684\u8d44\u6e90\u4f7f\u7528\u7387\u8d85\u8fc7\u4e86 60% \u5e76\u4e14\u6301\u7eed\u4e00\u6bb5\u65f6\u95f4\uff0c\u53ef\u80fd\u9700\u8981\u8003\u8651\u8fdb\u884c\u6269\u5bb9\u4ee5\u5e94\u5bf9\u8d1f\u8f7d\u9ad8\u5cf0\u3002\u6b64\u5916\uff0c\u5982\u679c\u6839\u636e\u4e1a\u52a1\u6307\u6807\u89c2\u5bdf\u5230\u9ad8\u7684 TPS \u8bf7\u6c42\u91cf\uff0c\u4e5f\u9700\u8981\u8003\u8651\u8fdb\u884c\u6269\u5bb9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#kubernetes","title":"Kubernetes \u6269\u7f29\u5bb9","text":"\u7531\u4e8e MatrixOne \u5206\u5e03\u5f0f\u7248\u672c\u7684\u57fa\u7840\u786c\u4ef6\u8d44\u6e90\u90fd\u662f\u901a\u8fc7 Kubernetes \u6765\u8fdb\u884c\u7ba1\u7406\u548c\u5206\u914d\u7684\uff0c\u56e0\u6b64\u6574\u4e2a\u96c6\u7fa4\u7684\u786c\u4ef6\u8282\u70b9\u6269\u7f29\u5bb9\u5747\u662f\u7531 Kubernetes \u5b8c\u6210\u7684\u3002
Kubernetes \u53ef\u4ee5\u901a\u8fc7 kuboard spray \u56fe\u5f62\u5316\u7ba1\u7406\u9875\u9762\u6765\u5b8c\u6210\u8282\u70b9\u7684\u6269\u7f29\u5bb9\uff0c\u8be6\u7ec6\u6559\u7a0b\u53ef\u53c2\u89c1 kuboard spray \u7684\u5b98\u65b9\u6587\u6863\u3002
\u4f60\u9700\u8981\u5728\u8be5\u96c6\u7fa4\u4e2d\u589e\u52a0\u4e86\u4e00\u4e2a\u5de5\u4f5c\u8282\u70b9\uff0c\u6574\u4f53\u7684\u786c\u4ef6\u914d\u7f6e\u8d44\u6e90\u5982\u4e0b\u8868\u6240\u793a\uff1a
Host \u5185\u7f51 IP \u5916\u7f51 IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker node1 10.206.134.16 129.211.211.29 8G 2C 50G worker "},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#matrixone","title":"MatrixOne \u5404\u670d\u52a1\u7684\u6269\u7f29\u5bb9","text":"\u670d\u52a1\u7684\u6269\u7f29\u5bb9\uff0c\u6307\u7684\u662f MatrixOne \u96c6\u7fa4\u4e2d\u6838\u5fc3\u7684\u7ec4\u4ef6\u670d\u52a1\uff0c\u4f8b\u5982\uff0c\u5bf9 Log Service\u3001TN\u3001CN \u7b49\u8fdb\u884c\u6269\u7f29\u5bb9\u3002
\u6839\u636e MatrixOne \u7684\u67b6\u6784\u7279\u70b9\uff0c\u8fd9\u4e9b\u670d\u52a1\u8282\u70b9\u60c5\u51b5\u5982\u4e0b\uff1a
\u56e0\u6b64\uff0cLog Service\u3001TN \u7684\u8282\u70b9\u53ea\u80fd\u5782\u76f4\u6269\u7f29\u5bb9\uff0cCN \u8282\u70b9\u53ef\u540c\u65f6\u6c34\u5e73\u6269\u7f29\u5bb9\u548c\u5782\u76f4\u6269\u7f29\u5bb9\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-cluster-Scale/#_3","title":"\u6c34\u5e73\u6269\u7f29\u5bb9","text":"\u6c34\u5e73\u6269\u7f29\u5bb9\uff0c\u6307\u7684\u662f\u670d\u52a1\u7684\u526f\u672c\u6570\u589e\u52a0\u6216\u51cf\u5c11\u3002\u53ef\u901a\u8fc7\u4fee\u6539 MatrixOne Operator \u542f\u52a8 yaml \u6587\u4ef6\u4e2d\u7684 .spec.[component].replicas
\u5b57\u6bb5\u7684\u503c\uff0c\u5b8c\u6210\u670d\u52a1\u526f\u672c\u6570\u7684\u66f4\u6539\u3002
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4fee\u6539 yaml \u6587\u4ef6\u4e2d\u7684 .spec.[component].replicas
\u5b57\u6bb5\u7684\u503c\uff1a
kubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff1a
tp:\n replicas: 2 #\u4f8b\u5982\uff0c\u6269\u5bb9\u662f\u7531\u539f\u6765\u7684 1 \u4e2a CN \u66f4\u6539\u4e3a 2 \u4e2a CN\n#\u5176\u4ed6\u5185\u5bb9\u5ffd\u7565 \n
Note
\u7f29\u5bb9\u4e5f\u53ef\u53c2\u8003\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u66f4\u6539 replicas
\u7684\u5b57\u6bb5\u503c\u3002
\u7f16\u8f91\u5b8c\u6210 replicas
\u4e2a\u6570\u4fdd\u5b58\u9000\u51fa\u540e\uff0cMatrixOne Operator \u5c06\u4f1a\u81ea\u52a8\u542f\u52a8\u4e00\u4e2a\u65b0\u7684 CN\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u89c2\u5bdf\u65b0\u7684 CN \u72b6\u6001\uff1a
[root@master0 ~]# kubectl get pods -n mo-hn \nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-6c9c49fbd7-lw2h2 1/1 Running 2 (8h ago) 9h\nmo-tn-0 1/1 Running 0 11m\nmo-log-0 1/1 Running 0 12m\nmo-log-1 1/1 Running 0 12m\nmo-log-2 1/1 Running 0 12m\nmo-tp-cn-0 1/1 Running 0 11m\nmo-tp-cn-1 1/1 Running 0 63s\n
\u53e6\u5916\uff0cKubernetes \u7684 SVC \u4f1a\u81ea\u52a8\u4fdd\u8bc1 CN \u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u7528\u6237\u8fde\u63a5\u7684 connection \u4f1a\u88ab\u5747\u5300\u7684\u5206\u914d\u5230\u4e0d\u540c\u7684 CN \u4e0a\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7 MatrixOne \u5185\u7f6e\u7684 system_metrics.server_connections
\u8868\u67e5\u770b\u6bcf\u4e2a CN \u4e0a\u7684 connection \u4e2a\u6570\u3002
\u5782\u76f4\u6269\u7f29\u5bb9\uff0c\u6307\u7684\u662f\u5bf9\u5355\u4e2a\u7ec4\u4ef6\u670d\u52a1\u526f\u672c\u672c\u8eab\u6240\u9700\u8981\u7684\u8d44\u6e90\uff0c\u4f8b\u5982\uff0c\u5bf9 CPU \u6216\u5185\u5b58\u8fdb\u884c\u8c03\u6574\u3002
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4fee\u6539\u5bf9\u5e94\u7ec4\u4ef6\u7684 .spec.[component].resources
\u4e2d\u7684 requests
\u548c limits
\u914d\u7f6e\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
kubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff1a
metadata:\n name: mo\n # \u4e2d\u95f4\u5185\u5bb9\u7701\u7565\nspec:\n tp:\n resources:\n requests:\n cpu: 1\n memory: 2Gi\n limits:\n cpu: 1\n memory: 2Gi\n...\n# \u5176\u4ed6\u5185\u5bb9\u7701\u7565\n
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cMatrixone-operator \u4e0d\u4f1a\u4e3a\u6bcf\u4e2a\u7ec4\u4ef6\u7684 Pod \u914d\u7f6e\u62d3\u6251\u89c4\u5219\uff0c\u800c\u662f\u4f7f\u7528 Kubernetes \u9ed8\u8ba4\u7684\u8c03\u5ea6\u5668\u6839\u636e\u6bcf\u4e2a Pod \u7684\u8d44\u6e90\u8bf7\u6c42\u8fdb\u884c\u8c03\u5ea6\u3002\u5982\u679c\u9700\u8981\u8bbe\u7f6e\u7279\u5b9a\u7684\u8c03\u5ea6\u89c4\u5219\uff0c\u4f8b\u5982\u5c06 cn \u7ec4\u4ef6\u8c03\u5ea6\u5230\u7279\u5b9a\u7684\u4e24\u4e2a\u8282\u70b9 node0 \u548c node1 \u4e0a\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a
\u4e3a node0
\u548c node1
\u8bbe\u7f6e\u6807\u7b7e\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\u8bbe\u7f6e nodeSelector
\uff0c\u4f7f\u670d\u52a1\u80fd\u591f\u8c03\u5ea6\u5230\u5bf9\u5e94\u7684\u8282\u70b9\u4e0a\u3002
\uff08\u53ef\u9009\uff09\u5728 MatrixOne \u96c6\u7fa4\u4e2d\u8bbe\u7f6e TopologySpread
\u5b57\u6bb5\uff0c\u4ee5\u5b9e\u73b0\u670d\u52a1\u5728\u8282\u70b9\u4e4b\u95f4\u7684\u5747\u5300\u5206\u5e03\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\u8bbe\u7f6e\u526f\u672c\u6570 replicas
\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u9700\u8981\u67e5\u770b\u96c6\u7fa4\u8282\u70b9\u7684\u60c5\u51b5\uff1a
[root@master0 ~]# kubectl get node\nNAME STATUS ROLES AGE VERSION\nmaster0 Ready control-plane,master 47h v1.23.17\nnode0 Ready <none> 47h v1.23.17\nnode1 Ready <none> 65s v1.23.17\n
\u6839\u636e\u4e0a\u8ff0\u8fd4\u56de\u7684\u7ed3\u679c\u548c\u5b9e\u9645\u9700\u6c42\uff0c\u4f60\u53ef\u4ee5\u4e3a\u8282\u70b9\u6253\u4e0a\u6807\u7b7e\uff0c\u53c2\u89c1\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\uff1a
NODE=\"[\u5f85\u6253\u4e0a\u6807\u7b7e\u7684\u8282\u70b9]\" # \u6839\u636e\u4e0a\u8ff0\u7ed3\u679c\uff0c\u6709\u53ef\u80fd\u662f ip\u3001\u4e5f\u53ef\u80fd\u662f\u4e3b\u673a\u540d\u3001\u6216\u8005\u522b\u540d\uff0c\u4f8b\u5982 10.0.0.1\u3001host-10-0-0-1\u3001node01\uff0c\u90a3\u4e48\u8bbe\u7f6e NODE=\"node0\"\nLABEL_K=\"mo-role\" # \u6807\u7b7e\u7684 key\uff0c\u53ef\u6309\u9700\u5b9a\u4e49\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u7528\u793a\u4f8b\nLABEL_V=\"mo-cn\" # \u6807\u7b7e\u7684 value\uff0c\u53ef\u6309\u9700\u5b9a\u4e49\uff0c\u4e5f\u53ef\u4ee5\u76f4\u63a5\u7528\u793a\u4f8b\n\nkubectl label node ${NODE} ${LABEL_K}=${LABEL_V}\n
\u5728\u672c\u7bc7\u6848\u4f8b\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5199\u6210\u4ee5\u4e0b\u4e24\u6761\u8bed\u53e5\uff1a
kubectl label node node0 \"mo-role\"=\"mo-cn\"\nkubectl label node node1 \"mo-role\"=\"mo-cn\"\n
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u786e\u8ba4\u8282\u70b9\u6807\u7b7e\u662f\u5426\u5df2\u6253\u4e0a\uff1a
[root@master0 ~]# kubectl get node node0 --show-labels | grep mo_role \nnode0 Ready <none> 47h v1.23.17 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node0,kubernetes.io/os=linux,mo_role=mo_cn\n[root@master0 ~]# kubectl get node node1 --show-labels | grep mo_role\nnode1 Ready <none> 7m25s v1.23.17 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=node1,kubernetes.io/os=linux,mo_role=mo_cn\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u6309\u9700\u5220\u9664\u6807\u7b7e\uff1a
kubectl label node ${NODE} ${LABEL_K}-\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u76ee\u524d\u7684 Pod \u5728\u591a\u4e2a\u8282\u70b9\u4e0a\u7684\u5206\u914d\u60c5\u51b5\uff1a
[root@master0 mo]# kubectl get pod -nmo-hn -owide\nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmo-tn-0 1/1 Running 0 34m 10.234.60.120 node0 <none> 2/2\nmo-log-0 1/1 Running 0 34m 10.234.168.72 node1 <none> 2/2\nmo-log-1 1/1 Running 0 34m 10.234.60.118 node0 <none> 2/2\nmo-log-2 1/1 Running 0 34m 10.234.168.73 node1 <none> 2/2\nmo-tp-cn-0 1/1 Running 0 33m 10.234.168.75 node1 <none> 2/2\n
\u6839\u636e\u4e0a\u8ff0\u8f93\u51fa\u548c\u5b9e\u9645\u9700\u6c42\u53ef\u4ee5\u770b\u51fa\u76ee\u524d\u53ea\u6709 1 \u4e2a CN\uff0c\u6211\u4eec\u9700\u8981\u4e3a CN \u7ec4\u4ef6\u8fdb\u884c\u8c03\u5ea6\u89c4\u5219\u7684\u8bbe\u7f6e\u3002\u6211\u4eec\u5c06\u5728 MatrixOne \u96c6\u7fa4\u5bf9\u8c61\u7684\u5c5e\u6027\u4e2d\u8fdb\u884c\u4fee\u6539\u3002\u5728\u8c03\u5ea6\u8303\u56f4\u5185\u5747\u5300\u5206\u5e03\u7684\u89c4\u5219\u4e0b\u65b0\u7684 CN \u4f1a\u88ab\u8c03\u5ea6\u5230 node0 \u4e0a\u3002\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff1a
mo_ns=\"mo-hn\"\nmo_cluster_name=\"mo\" # \u4e00\u822c\u540d\u79f0\u4e3a mo\uff0c\u6839\u636e\u90e8\u7f72\u65f6 matrixonecluster \u5bf9\u8c61\u7684 yaml \u6587\u4ef6\u4e2d\u7684 name \u6307\u5b9a\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7 kubectl get matrixonecluster -n${mo_ns} \u6765\u786e\u8ba4\nkubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u5728\u7f16\u8f91\u6a21\u5f0f\u4e0b\uff0c\u6839\u636e\u4e0a\u8ff0\u573a\u666f\uff0c\u6211\u4eec\u5c06\u8bbe\u7f6e CN \u7684\u526f\u672c\u6570\u4e3a 2\uff0c\u5e76\u4e14\u5728\u6807\u7b7e\u4e3a mo-role:mo-cn
\u7684\u8282\u70b9\u4e0a\u8fdb\u884c\u8c03\u5ea6\uff0c\u5b9e\u73b0\u5728\u8c03\u5ea6\u8303\u56f4\u5185\u7684\u5747\u5300\u5206\u5e03\u3002\u6211\u4eec\u5c06\u4f7f\u7528 spec.[component].nodeSelector
\u6765\u6307\u5b9a\u5177\u4f53\u7ec4\u4ef6\u7684\u6807\u7b7e\u9009\u62e9\u5668\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b\u7684\u7f16\u8f91\u5185\u5bb9\uff1a
metadata:\n name: mo\n# \u4e2d\u95f4\u5185\u5bb9\u7701\u7565\nspec:\n# \u4e2d\u95f4\u5185\u5bb9\u7701\u7565\n tp:\n # \u8bbe\u7f6e\u526f\u672c\u6570\n replicas: 2\n # \u8bbe\u7f6e\u8c03\u5ea6\u89c4\u5219\n nodeSelector:\n mo-role: mo-cn\n # \u8bbe\u7f6e\u5728\u8c03\u5ea6\u8303\u56f4\u5185\u5747\u5300\u5206\u5e03\n topologySpread:\n - topology.kubernetes.io/zone\n - kubernetes.io/hostname\n# \u5176\u4ed6\u5185\u5bb9\u7701\u7565\n
\u66f4\u6539\u751f\u6548\u540e\uff0c\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u4e24\u4e2a CN \u5df2\u7ecf\u5206\u522b\u5728\u4e24\u4e2a\u8282\u70b9\u4e0a\uff1a
[root@master0 ~]# kubectl get pod -nmo-hn -owide \nNAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES\nmo-tn-0 1/1 Running 1 (2m53s ago) 3m6s 10.234.168.80 node1 <none> 2/2\nmo-log-0 1/1 Running 0 3m40s 10.234.168.78 node1 <none> 2/2\nmo-log-1 1/1 Running 0 3m40s 10.234.60.122 node0 <none> 2/2\nmo-log-2 1/1 Running 0 3m40s 10.234.168.77 node1 <none> 2/2\nmo-tp-cn-0 1/1 Running 0 84s 10.234.60.125 node0 <none> 2/2\nmo-tp-cn-1 1/1 Running 0 86s 10.234.168.82 node1 <none> 2/2\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u7684\u914d\u7f6e\u4f1a\u4f7f\u5f97\u96c6\u7fa4\u4e2d\u7684 Pod \u5728 topology.kubernetes.io/zone
\u548c kubernetes.io/hostname
\u8fd9\u4e24\u4e2a\u7ef4\u5ea6\u4e0a\u5b9e\u73b0\u5747\u5300\u5206\u5e03\u3002\u5728 topologySpread
\u4e2d\u6307\u5b9a\u7684\u6807\u7b7e\u952e\u662f\u6709\u987a\u5e8f\u7684\u3002\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0cPod \u9996\u5148\u5728\u53ef\u7528\u533a\u7ef4\u5ea6\u4e0a\u5747\u5300\u5206\u5e03\uff0c\u7136\u540e\u5728\u6bcf\u4e2a\u53ef\u7528\u533a\u5185\u7684 Pod \u518d\u5747\u5300\u5730\u5206\u5e03\u5230\u8be5\u533a\u57df\u5185\u7684\u8282\u70b9\u4e0a\u3002
\u4f7f\u7528 topologySpread
\u529f\u80fd\u53ef\u4ee5\u63d0\u9ad8\u96c6\u7fa4\u7684\u53ef\u7528\u6027\uff0c\u964d\u4f4e\u7531\u4e8e\u5355\u70b9\u6216\u533a\u57df\u6027\u6545\u969c\u800c\u7834\u574f\u96c6\u7fa4\u4e2d\u7684\u5927\u591a\u6570\u526f\u672c\u7684\u53ef\u80fd\u6027\u3002\u4f46\u8fd9\u4e5f\u589e\u52a0\u4e86\u8c03\u5ea6\u7684\u8981\u6c42\uff0c\u9700\u8981\u786e\u4fdd\u96c6\u7fa4\u5728\u6bcf\u4e2a\u533a\u57df\u5185\u90fd\u6709\u8db3\u591f\u7684\u8d44\u6e90\u53ef\u7528\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u5982\u4f55\u542f\u505c\u5206\u5e03\u5f0f MatrixOne \u96c6\u7fa4\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u5347\u7ea7\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#_2","title":"\u96c6\u7fa4\u505c\u6b62\u4e0b\u7ebf","text":"\u8981\u505c\u6b62 MatrixOne \u96c6\u7fa4\uff0c\u53ea\u9700\u505c\u6b62\u4e1a\u52a1\u7684\u8bfb\u5199\u64cd\u4f5c\uff0c\u7136\u540e\u76f4\u63a5\u5173\u95ed\u670d\u52a1\u5668\u5373\u53ef\u3002\u5173\u95ed\u7684\u987a\u5e8f\u4e3a\uff1a\u9996\u5148\u5173\u95ed node0 \u8282\u70b9\uff0c\u63a5\u7740\u5173\u95ed master0 \u8282\u70b9\uff0c\u6700\u540e\u5173\u95ed Kuboard-Spray \u8282\u70b9\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#_3","title":"\u96c6\u7fa4\u91cd\u542f\u4e0a\u7ebf","text":"\u8981\u91cd\u65b0\u542f\u52a8 MatrixOne \u96c6\u7fa4\uff0c\u5efa\u8bae\u6309\u7167\u4ee5\u4e0b\u786c\u4ef6\u542f\u52a8\u987a\u5e8f\uff1a\u9996\u5148\u542f\u52a8 Kuboard-Spray \u8282\u70b9\uff0c\u63a5\u7740\u542f\u52a8 master0 \u8282\u70b9\uff0c\u6700\u540e\u542f\u52a8 node0 \u8282\u70b9\u3002
\u5728\u786c\u4ef6\u542f\u52a8\u5b8c\u6210\u540e\uff0ck8s \u4f1a\u81ea\u52a8\u8fdb\u884c\u6062\u590d\u3002\u540c\u65f6\uff0cMatrixOne \u548c minio \u76f8\u5173\u670d\u52a1\u4e5f\u4f1a\u81ea\u52a8\u6062\u590d\uff0c\u65e0\u9700\u4eba\u5de5\u5e72\u9884\u3002\u4f46\u662f\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cKuboard-Spray \u8282\u70b9\u7684 Docker \u4e0d\u4f1a\u81ea\u52a8\u6062\u590d\uff0c\u9700\u8981\u624b\u52a8\u542f\u52a8 Kuboard-Spray \u670d\u52a1\u3002
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#k8s","title":"\u68c0\u67e5 K8s \u72b6\u6001","text":"\u5728\u64cd\u4f5c k8s \u7684 master0 \u8282\u70b9\u4e0a\uff0c\u53ef\u4ee5\u68c0\u67e5 k8s \u96c6\u7fa4\u8282\u70b9\u7684\u72b6\u6001\u3002
\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u6240\u6709\u8282\u70b9\u7684\u72b6\u6001\u5e94\u8be5\u4e3a Ready\u3002\u5982\u679c\u67d0\u4e9b\u8282\u70b9\u72b6\u6001\u5f02\u5e38\uff0c\u5c31\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u539f\u56e0\u3002
kubectl get node\n# \u5982\u975eready\u72b6\u6001\uff0c\u5219\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u8282\u70b9\u7684\u60c5\u51b5\n# kubectl describe node ${NODE_NAME}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#minio","title":"\u68c0\u67e5 MinIO \u72b6\u6001","text":"\u5728\u64cd\u4f5c k8s \u7684 master0 \u8282\u70b9\u4e0a\uff0c\u53ef\u4ee5\u68c0\u67e5 MinIO \u7684\u72b6\u6001\u3002
\u786c\u4ef6\u542f\u52a8\u540e\uff0cMinIO \u4e5f\u4f1a\u81ea\u52a8\u6062\u590d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5 MinIO \u72b6\u6001\uff1a
NS=\"mostorage\"\nkubectl get pod -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#matrixone","title":"\u68c0\u67e5 MatrixOne \u96c6\u7fa4\u53ca\u7ec4\u4ef6\u72b6\u6001","text":""},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#matrixonecluster","title":"\u68c0\u67e5 MatrixOneCluster \u72b6\u6001","text":"\u9996\u5148\uff0c\u8981\u68c0\u67e5 MatrixOne \u96c6\u7fa4\u662f\u5426\u6b63\u5e38\u3002MatrixOne \u96c6\u7fa4\u5bf9\u5e94\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b MatrixOneCluster\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5 MatrixOneCluster \u7684\u72b6\u6001\uff1a
MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n${NS} ${MO_NAME}\n
\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u72b6\u6001\u5e94\u8be5\u4e3a Ready\u3002\u5982\u679c\u72b6\u6001\u4e3a NotReady\uff0c\u5219\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u72b6\u6001\u56fe\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#matrixone_1","title":"\u67e5\u770b MatrixOne \u96c6\u7fa4\u72b6\u6001\u8be6\u7ec6\u4fe1\u606f","text":"\u5982\u679c MatrixOne \u96c6\u7fa4\u72b6\u6001\u4e0d\u6b63\u5e38\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\uff1a
kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#tnsetcnsetlogset","title":"\u68c0\u67e5 TNSet/CNSet/LogSet \u72b6\u6001","text":"\u5f53\u524d MatrixOne \u96c6\u7fa4\u7684\u7ec4\u4ef6\u4e3b\u8981\u6709\uff1aTN\u3001CN\u3001Log Service\uff0c\u5206\u522b\u5bf9\u5e94\u7684\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b TNSet\u3001CNSet\u3001LogSet\u3002\u8fd9\u4e9b\u5bf9\u8c61\u5747\u7531 MatrixOneCluster \u63a7\u5236\u5668\u751f\u6210\u3002
\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\u5404\u7ec4\u4ef6\u7684\u72b6\u6001\uff0c\u4ee5 TN \u4e3a\u4f8b\uff1a
SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/MatrixOne-start-stop/#pod","title":"\u68c0\u67e5 Pod \u72b6\u6001","text":"\u53ef\u4ee5\u76f4\u63a5\u68c0\u67e5 MO \u96c6\u7fa4\u4e2d\u751f\u6210\u7684\u539f\u751f k8s \u5bf9\u8c61\uff0c\u6765\u786e\u8ba4\u96c6\u7fa4\u7684\u5065\u5eb7\u7a0b\u5ea6\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7\u5bf9 Pod \u7684\u72b6\u6001\u786e\u8ba4\u5373\u53ef\uff1a
NS=\"mo-hn\"\nkubectl get pod -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
\u4e00\u822c\u6765\u8bf4\uff0cRunning \u72b6\u6001\u5373\u4e3a\u6b63\u5e38\u72b6\u6001\u3002\u4f46\u4e5f\u6709\u5c11\u6570\u4f8b\u5916\u7684\u60c5\u51b5\uff0c\u4f8b\u5982\u72b6\u6001\u4e3a Running\uff0c\u4f46 MO \u96c6\u7fa4\u5b9e\u9645\u4e0a\u4e0d\u6b63\u5e38\uff0c\u4f8b\u5982\u65e0\u6cd5\u901a\u8fc7 MySQL Client \u8fde\u63a5 MO \u96c6\u7fa4\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6392\u67e5 Pod \u7684\u65e5\u5fd7\u662f\u5426\u6709\u5f02\u5e38\u4fe1\u606f\u8f93\u51fa\uff1a
NS=\"mo-hn\"\nPOD_NAME=\"[\u4e0a\u8ff0\u8fd4\u56depod\u7684\u540d\u79f0]\" # \u4f8b\u5982mo-tp-cn-3\nkubectl logs ${POD_NAME} -n${NS}\n
\u5982\u679c\u72b6\u6001\u4e3a\u975e Running\uff0c\u4f8b\u5982 Pending\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b Pod \u72b6\u6001\u4e2d\u7684\u4e8b\u4ef6\uff08event\uff09\u6765\u786e\u8ba4\u5f02\u5e38\u539f\u56e0\u3002\u4f8b\u5982\uff0c\u7531\u4e8e\u96c6\u7fa4\u8d44\u6e90\u65e0\u6cd5\u6ee1\u8db3 mo-tp-cn-3 \u7684\u7533\u8bf7\uff0c\u8fd9\u4e2a Pod \u65e0\u6cd5\u88ab\u8c03\u5ea6\uff0c\u5904\u4e8e Pending \u72b6\u6001\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u6269\u5bb9\u8282\u70b9\u8d44\u6e90\u6765\u89e3\u51b3\u3002
kubectl describe pod ${POD_NAME} -n${NS}\n
\u4ee5\u4e0b\u662f\u72b6\u6001\u4ee3\u7801\u56fe\u793a\u793a\u4f8b\uff1a
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/","title":"\u5065\u5eb7\u68c0\u67e5\u4e0e\u8d44\u6e90\u76d1\u63a7","text":"\u5728 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u4e2d\uff0c\u5305\u542b\u4e86\u591a\u4e2a\u7ec4\u4ef6\u548c\u5bf9\u8c61\uff0c\u4e3a\u4e86\u786e\u4fdd\u5176\u6b63\u5e38\u8fd0\u884c\u5e76\u6392\u9664\u6545\u969c\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u4e00\u7cfb\u5217\u7684\u5065\u5eb7\u68c0\u67e5\u548c\u8d44\u6e90\u76d1\u63a7\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u5065\u5eb7\u68c0\u67e5\u4e0e\u8d44\u6e90\u76d1\u63a7\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#_2","title":"\u68c0\u67e5\u5bf9\u8c61","text":"\u7269\u7406\u8d44\u6e90\u5c42\uff1a\u5305\u62ec\u4e09\u53f0\u865a\u62df\u673a\u7684 CPU\u3001\u5185\u5b58\u548c\u78c1\u76d8\u8d44\u6e90\u3002\u6709\u5173\u76d1\u63a7\u8fd9\u4e9b\u8d44\u6e90\u7684\u6210\u719f\u65b9\u6848\uff0c\u53ef\u4ee5\u53c2\u8003\u76d1\u63a7\u65b9\u6848\u3002\u5728\u6b64\u4e0d\u505a\u8fc7\u591a\u4ecb\u7ecd\u3002
\u903b\u8f91\u8d44\u6e90\u5c42\uff1a\u5305\u62ec MinIO \u7684\u5bb9\u91cf\u4f7f\u7528\u60c5\u51b5\uff0cKubernetes \u7684\u5404\u4e2a\u8282\u70b9\u548c Pod \u7684 CPU \u548c\u5185\u5b58\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\uff0c\u4ee5\u53ca MatrixOne \u7684\u6574\u4f53\u72b6\u6001\u548c\u5404\u4e2a\u7ec4\u4ef6\uff08\u5982 LogService\u3001CN\u3001TN\uff09\u7684\u72b6\u6001\u3002
MinIO \u81ea\u5e26\u4e86\u4e00\u4e2a\u7ba1\u7406\u754c\u9762\uff0c\u901a\u8fc7\u8be5\u754c\u9762\u6211\u4eec\u53ef\u4ee5\u4ee5\u53ef\u89c6\u5316\u7684\u65b9\u5f0f\u76d1\u63a7\u5176\u5bb9\u91cf\u4f7f\u7528\u60c5\u51b5\uff0c\u5305\u62ec\u5269\u4f59\u7a7a\u95f4\u7684\u6570\u91cf\u7b49\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\u3002
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#nodepod","title":"Node/Pod \u8d44\u6e90\u76d1\u63a7","text":"\u4e3a\u4e86\u786e\u5b9a MatrixOne \u670d\u52a1\u662f\u5426\u9700\u8981\u6269\u7f29\u5bb9\uff0c\u7528\u6237\u5f80\u5f80\u9700\u8981\u9488\u5bf9 MatrixOne \u96c6\u7fa4\u6240\u5728 Node \u548c\u7ec4\u4ef6\u5bf9\u5e94 Pod \u6240\u4f7f\u7528\u7684\u8d44\u6e90\u8fdb\u884c\u76d1\u63a7\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 kubectl top
\u547d\u4ee4\u5b8c\u6210\uff0c\u8be6\u7ec6\u7684\u547d\u4ee4\u53ef\u4ee5\u53c2\u8003\u5bf9\u5e94\u7248\u672c\u7684 Kubernetes \u5b98\u7f51\u6587\u6863\u3002
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u67e5\u770b MatrixOne \u96c6\u7fa4\u8282\u70b9\u8be6\u60c5\uff1a
kubectl get node\n
[root@master0 ~]# kubectl get node\nNAME STATUS ROLES AGE VERSION\nmaster0 Ready control-plane,master 22h v1.23.17\nnode0 Ready <none> 22h v1.23.17\n
\u6839\u636e\u4e0a\u8ff0\u8fd4\u56de\u7ed3\u679c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u7279\u5b9a\u8282\u70b9\u7684\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\u3002\u6839\u636e\u4e4b\u524d\u7684\u90e8\u7f72\u65b9\u6848\uff0c\u53ef\u4ee5\u67e5\u770b\u5230 MatrixOne \u96c6\u7fa4\u4f4d\u4e8e\u540d\u4e3a node0 \u7684\u8282\u70b9\u4e0a\uff1a
NODE=\"[\u5f85\u76d1\u63a7\u8282\u70b9]\" # \u6839\u636e\u4e0a\u8ff0\u7ed3\u679c\uff0c\u6709\u53ef\u80fd\u662f ip\u3001\u4e5f\u53ef\u80fd\u662f\u4e3b\u673a\u540d\u3001\u6216\u8005\u522b\u540d\uff0c\u4f8b\u5982 10.0.0.1\u3001host-10-0-0-1\u3001node01\nkubectl top node ${NODE}\n
[root@master0 ~]# kubectl top node\nNAME CPU(cores) CPU% MEMORY(bytes) MEMORY% \nmaster0 179m 9% 4632Mi 66% \nnode0 292m 15% 4115Mi 56% \n[root@master0 ~]# kubectl top node node0\nNAME CPU(cores) CPU% MEMORY(bytes) MEMORY% \nnode0 299m 15% 4079Mi 56% \n
\u4f60\u8fd8\u53ef\u4ee5\u67e5\u770b\u8282\u70b9\u7684\u8d44\u6e90\u5206\u914d\u548c\u8d44\u6e90\u4e0a\u9650\u3002\u8bf7\u6ce8\u610f\uff0c\u5df2\u5206\u914d\u7684\u8d44\u6e90\u5e76\u4e0d\u7b49\u4e8e\u5df2\u4f7f\u7528\u7684\u8d44\u6e90\u3002
[root@master0 ~]# kubectl describe node node0\nName: master0\nRoles: control-plane,master\nLabels: beta.kubernetes.io/arch=amd64\n beta.kubernetes.io/os=linux\n kubernetes.io/arch=amd64\n kubernetes.io/hostname=master0\n kubernetes.io/os=linux\n node-role.kubernetes.io/control-plane=\n node-role.kubernetes.io/master=\n node.kubernetes.io/exclude-from-external-load-balancers=\nAnnotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n node.alpha.kubernetes.io/ttl: 0\n projectcalico.org/IPv4Address: 10.206.134.8/24\n projectcalico.org/IPv4VXLANTunnelAddr: 10.234.166.0\n volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp: Sun, 07 May 2023 12:28:57 +0800\nTaints: node-role.kubernetes.io/master:NoSchedule\nUnschedulable: false\nLease:\n HolderIdentity: master0\n AcquireTime: <unset>\n RenewTime: Mon, 08 May 2023 10:56:08 +0800\nConditions:\n Type Status LastHeartbeatTime LastTransitionTime Reason Message\n ---- ------ ----------------- ------------------ ------ -------\n NetworkUnavailable False Sun, 07 May 2023 12:30:08 +0800 Sun, 07 May 2023 12:30:08 +0800 CalicoIsUp Calico is running on this node\n MemoryPressure False Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 12:28:55 +0800 KubeletHasSufficientMemory kubelet has sufficient memory available\n DiskPressure False Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 12:28:55 +0800 KubeletHasNoDiskPressure kubelet has no disk pressure\n PIDPressure False Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 12:28:55 +0800 KubeletHasSufficientPID kubelet has sufficient PID available\n Ready True Mon, 08 May 2023 10:56:07 +0800 Sun, 07 May 2023 20:47:39 +0800 KubeletReady kubelet is posting ready status\nAddresses:\n InternalIP: 10.206.134.8\n Hostname: master0\nCapacity:\n cpu: 2\n ephemeral-storage: 51473868Ki\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7782436Ki\n pods: 110\nAllocatable:\n cpu: 1800m\n ephemeral-storage: 47438316671\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7155748Ki\n pods: 110\nSystem Info:\n Machine ID: fb436be013b5415799d27abf653585d3\n System UUID: FB436BE0-13B5-4157-99D2-7ABF653585D3\n Boot ID: 552bd576-56c8-4d22-9549-d950069a5a77\n Kernel Version: 3.10.0-1160.88.1.el7.x86_64\n OS Image: CentOS Linux 7 (Core)\n Operating System: linux\n Architecture: amd64\n Container Runtime Version: docker://20.10.23\n Kubelet Version: v1.23.17\n Kube-Proxy Version: v1.23.17\nPodCIDR: 10.234.0.0/23\nPodCIDRs: 10.234.0.0/23\nNon-terminated Pods: (12 in total)\n Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits Age\n --------- ---- ------------ ---------- --------------- ------------- ---\n default netchecker-agent-7xnwb 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n default netchecker-agent-hostnet-bw85f 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n kruise-system kruise-daemon-xvl8t 0 (0%) 50m (2%) 0 (0%) 128Mi (1%) 20h\n kube-system calico-node-sbzfc 150m (8%) 300m (16%) 64M (0%) 500M (6%) 22h\n kube-system dns-autoscaler-7874cf6bcf-l55q4 20m (1%) 0 (0%) 10Mi (0%) 0 (0%) 22h\n kube-system kube-apiserver-master0 250m (13%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system kube-controller-manager-master0 200m (11%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system kube-proxy-lfkhk 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system kube-scheduler-master0 100m (5%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system metrics-server-7bd47f88c4-knh9b 100m (5%) 100m (5%) 200Mi (2%) 200Mi (2%) 22h\n kube-system nodelocaldns-dcffl 100m (5%) 0 (0%) 70Mi (1%) 170Mi (2%) 14h\n kuboard kuboard-v3-master0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22h\nAllocated resources:\n (Total limits may be over 100 percent, i.e., overcommitted.)\n Resource Requests Limits\n -------- -------- ------\n cpu 950m (52%) 510m (28%)\n memory 485601280 (6%) 1222190848 (16%)\n ephemeral-storage 0 (0%) 0 (0%)\n hugepages-1Gi 0 (0%) 0 (0%)\n hugepages-2Mi 0 (0%) 0 (0%)\nEvents: <none>\n\n\nName: node0\nRoles: <none>\nLabels: beta.kubernetes.io/arch=amd64\n beta.kubernetes.io/os=linux\n kubernetes.io/arch=amd64\n kubernetes.io/hostname=node0\n kubernetes.io/os=linux\nAnnotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock\n node.alpha.kubernetes.io/ttl: 0\n projectcalico.org/IPv4Address: 10.206.134.14/24\n projectcalico.org/IPv4VXLANTunnelAddr: 10.234.60.0\n volumes.kubernetes.io/controller-managed-attach-detach: true\nCreationTimestamp: Sun, 07 May 2023 12:29:46 +0800\nTaints: <none>\nUnschedulable: false\nLease:\n HolderIdentity: node0\n AcquireTime: <unset>\n RenewTime: Mon, 08 May 2023 10:56:06 +0800\nConditions:\n Type Status LastHeartbeatTime LastTransitionTime Reason Message\n ---- ------ ----------------- ------------------ ------ -------\n NetworkUnavailable False Sun, 07 May 2023 12:30:08 +0800 Sun, 07 May 2023 12:30:08 +0800 CalicoIsUp Calico is running on this node\n MemoryPressure False Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 12:29:46 +0800 KubeletHasSufficientMemory kubelet has sufficient memory available\n DiskPressure False Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 12:29:46 +0800 KubeletHasNoDiskPressure kubelet has no disk pressure\n PIDPressure False Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 12:29:46 +0800 KubeletHasSufficientPID kubelet has sufficient PID available\n Ready True Mon, 08 May 2023 10:56:12 +0800 Sun, 07 May 2023 20:48:36 +0800 KubeletReady kubelet is posting ready status\nAddresses:\n InternalIP: 10.206.134.14\n Hostname: node0\nCapacity:\n cpu: 2\n ephemeral-storage: 51473868Ki\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7782444Ki\n pods: 110\nAllocatable:\n cpu: 1900m\n ephemeral-storage: 47438316671\n hugepages-1Gi: 0\n hugepages-2Mi: 0\n memory: 7417900Ki\n pods: 110\nSystem Info:\n Machine ID: a6600151884b44fb9f0bc9af490e44b7\n System UUID: A6600151-884B-44FB-9F0B-C9AF490E44B7\n Boot ID: b7f3357f-44e6-425e-8c90-6ada14e92703\n Kernel Version: 3.10.0-1160.88.1.el7.x86_64\n OS Image: CentOS Linux 7 (Core)\n Operating System: linux\n Architecture: amd64\n Container Runtime Version: docker://20.10.23\n Kubelet Version: v1.23.17\n Kube-Proxy Version: v1.23.17\nPodCIDR: 10.234.2.0/23\nPodCIDRs: 10.234.2.0/23\nNon-terminated Pods: (20 in total)\n Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits Age\n --------- ---- ------------ ---------- --------------- ------------- ---\n default netchecker-agent-6v8rl 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n default netchecker-agent-hostnet-fb2jn 15m (0%) 30m (1%) 64M (0%) 100M (1%) 22h\n default netchecker-server-645d759b79-v4bqm 150m (7%) 300m (15%) 192M (2%) 512M (6%) 22h\n kruise-system kruise-controller-manager-74847d59cf-295rk 100m (5%) 200m (10%) 256Mi (3%) 512Mi (7%) 20h\n kruise-system kruise-controller-manager-74847d59cf-854sq 100m (5%) 200m (10%) 256Mi (3%) 512Mi (7%) 20h\n kruise-system kruise-daemon-rz9pj 0 (0%) 50m (2%) 0 (0%) 128Mi (1%) 20h\n kube-system calico-kube-controllers-74df5cd99c-n9qsn 30m (1%) 1 (52%) 64M (0%) 256M (3%) 22h\n kube-system calico-node-brqrk 150m (7%) 300m (15%) 64M (0%) 500M (6%) 22h\n kube-system coredns-76b4fb4578-9cqc7 100m (5%) 0 (0%) 70Mi (0%) 170Mi (2%) 14h\n kube-system kube-proxy-rpxb5 0 (0%) 0 (0%) 0 (0%) 0 (0%) 22h\n kube-system nginx-proxy-node0 25m (1%) 0 (0%) 32M (0%) 0 (0%) 22h\n kube-system nodelocaldns-qkxhv 100m (5%) 0 (0%) 70Mi (0%) 170Mi (2%) 14h\n local-path-storage local-path-storage-local-path-provisioner-d5bb7f8c9-qfp8h 0 (0%) 0 (0%) 0 (0%) 0 (0%) 21h\n mo-hn matrixone-operator-f8496ff5c-fp6zm 0 (0%) 0 (0%) 0 (0%) 0 (0%) 20h\n mo-hn mo-tn-0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-log-0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-log-1 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-log-2 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mo-hn mo-tp-cn-0 0 (0%) 0 (0%) 0 (0%) 0 (0%) 13h\n mostorage minio-674ccf54f7-tdglh 0 (0%) 0 (0%) 512Mi (7%) 0 (0%) 20h\nAllocated resources:\n (Total limits may be over 100 percent, i.e., overcommitted.)\n Resource Requests Limits\n -------- -------- ------\n cpu 785m (41%) 2110m (111%)\n memory 1700542464 (22%) 3032475392 (39%)\n ephemeral-storage 0 (0%) 0 (0%)\n hugepages-1Gi 0 (0%) 0 (0%)\n hugepages-2Mi 0 (0%) 0 (0%)\nEvents: <none>\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#pod","title":"Pod \u76d1\u63a7","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u67e5\u770b MatrixOne \u96c6\u7fa4\u7684 Pod\uff1a
NS=\"mo-hn\"\nkubectl get pod -n${NS}\n
\u6839\u636e\u4e0a\u8ff0\u8fd4\u56de\u7ed3\u679c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u7279\u5b9a Pod \u7684\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\uff1a
POD=\"[\u5f85\u76d1\u63a7 pod \u540d\u79f0]\" # \u6839\u636e\u4e0a\u8ff0\u7ed3\u679c\uff0c\u4f8b\u5982\uff1atn \u4e3a mo-tn-0\uff0ccn \u4e3a mo-tp-cn-0\u3001mo-tp-cn-1\u3001...\uff0clogservice \u4e3a mo-log-0\u3001mo-log-1\u3001...\nkubectl top pod ${POD} -n${NS}\n
\u8be5\u547d\u4ee4\u5c06\u663e\u793a\u6307\u5b9a Pod \u7684 CPU \u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u8f93\u51fa\uff1a
[root@master0 ~]# kubectl top pod mo-tp-cn-0 -nmo-hn\nNAME CPU(cores) MEMORY(bytes) \nmo-tp-cn-0 20m 214Mi\n[root@master0 ~]# kubectl top pod mo-tn-0 -nmo-hn \nNAME CPU(cores) MEMORY(bytes) \nmo-tn-0 36m 161Mi \n
\u6b64\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u67e5\u770b\u7279\u5b9a Pod \u7684\u8d44\u6e90\u58f0\u660e\u60c5\u51b5\uff0c\u4ee5\u4fbf\u4e0e\u5b9e\u9645\u4f7f\u7528\u7684\u8d44\u6e90\u8fdb\u884c\u5bf9\u6bd4\u3002
kubectl describe pod ${POD_NAME} -n${NS}\nkubectl get pod ${POD_NAME} -n${NS} -oyaml\n
[root@master0 ~]# kubectl describe pod mo-tp-cn-0 -nmo-hn\nName: mo-tp-cn-0\nNamespace: mo-hn\nPriority: 0\nNode: node0/10.206.134.14\nStart Time: Sun, 07 May 2023 21:01:50 +0800\nLabels: controller-revision-hash=mo-tp-cn-8666cdfb56\n lifecycle.apps.kruise.io/state=Normal\n matrixorigin.io/cluster=mo\n matrixorigin.io/component=CNSet\n matrixorigin.io/instance=mo-tp\n matrixorigin.io/namespace=mo-hn\n statefulset.kubernetes.io/pod-name=mo-tp-cn-0\nAnnotations: apps.kruise.io/runtime-containers-meta:\n {\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"...\n cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n cni.projectcalico.org/podIP: 10.234.60.53/32\n cni.projectcalico.org/podIPs: 10.234.60.53/32\n kruise.io/related-pub: mo\n lifecycle.apps.kruise.io/timestamp: 2023-05-07T13:01:50Z\n matrixone.cloud/cn-label: null\n matrixone.cloud/dns-based-identity: False\nStatus: Running\nIP: 10.234.60.53\nIPs:\n IP: 10.234.60.53\nControlled By: StatefulSet/mo-tp-cn\nContainers:\n main:\n Container ID: docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n Image: matrixorigin/matrixone:nightly-144f3be4\n Image ID: docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n Port: <none>\n Host Port: <none>\n Command:\n /bin/sh\n /etc/matrixone/config/start.sh\n Args:\n -debug-http=:6060\n State: Running\n Started: Sun, 07 May 2023 21:01:54 +0800\n Ready: True\n Restart Count: 0\n Environment:\n POD_NAME: mo-tp-cn-0 (v1:metadata.name)\n NAMESPACE: mo-hn (v1:metadata.namespace)\n HEADLESS_SERVICE_NAME: mo-tp-cn-headless\n AWS_ACCESS_KEY_ID: <set to the key 'AWS_ACCESS_KEY_ID' in secret 'minio'> Optional: false\n AWS_SECRET_ACCESS_KEY: <set to the key 'AWS_SECRET_ACCESS_KEY' in secret 'minio'> Optional: false\n AWS_REGION: us-west-2\n Mounts:\n /etc/matrixone/config from config (ro)\n /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-ngpcs (ro)\nReadiness Gates:\n Type Status\n InPlaceUpdateReady True\n KruisePodReady True\nConditions:\n Type Status\n KruisePodReady True\n InPlaceUpdateReady True\n Initialized True\n Ready True\n ContainersReady True\n PodScheduled True\nVolumes:\n config:\n Type: ConfigMap (a volume populated by a ConfigMap)\n Name: mo-tp-cn-config-5abf454\n Optional: false\n kube-api-access-ngpcs:\n Type: Projected (a volume that contains injected data from multiple sources)\n TokenExpirationSeconds: 3607\n ConfigMapName: kube-root-ca.crt\n ConfigMapOptional: <nil>\n DownwardAPI: true\nQoS Class: BestEffort\nNode-Selectors: <none>\nTolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s\n node.kubernetes.io/unreachable:NoExecute op=Exists for 300s\nEvents: <none>\n[root@master0 ~]# kubectl get pod mo-tp-cn-0 -nmo-hn -oyaml\napiVersion: v1\nkind: Pod\nmetadata:\n annotations:\n apps.kruise.io/runtime-containers-meta: '{\"containers\":[{\"name\":\"main\",\"containerID\":\"docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\",\"restartCount\":0,\"hashes\":{\"plainHash\":1670287891}}]}'\n cni.projectcalico.org/containerID: 80b286789a2d6fa9e615c3edee79b57edb452eaeafddb9b7b82ec5fb2e339409\n cni.projectcalico.org/podIP: 10.234.60.53/32\n cni.projectcalico.org/podIPs: 10.234.60.53/32\n kruise.io/related-pub: mo\n lifecycle.apps.kruise.io/timestamp: \"2023-05-07T13:01:50Z\"\n matrixone.cloud/cn-label: \"null\"\n matrixone.cloud/dns-based-identity: \"False\"\n creationTimestamp: \"2023-05-07T13:01:50Z\"\n generateName: mo-tp-cn-\n labels:\n controller-revision-hash: mo-tp-cn-8666cdfb56\n lifecycle.apps.kruise.io/state: Normal\n matrixorigin.io/cluster: mo\n matrixorigin.io/component: CNSet\n matrixorigin.io/instance: mo-tp\n matrixorigin.io/namespace: mo-hn\n statefulset.kubernetes.io/pod-name: mo-tp-cn-0\n name: mo-tp-cn-0\n namespace: mo-hn\n ownerReferences:\n - apiVersion: apps.kruise.io/v1beta1\n blockOwnerDeletion: true\n controller: true\n kind: StatefulSet\n name: mo-tp-cn\n uid: 891e0453-89a5-45d5-ad12-16ef048c804f\n resourceVersion: \"72625\"\n uid: 1e3e2df3-f1c2-4444-8694-8d23e7125d35\nspec:\n containers:\n - args:\n - -debug-http=:6060\n command:\n - /bin/sh\n - /etc/matrixone/config/start.sh\n env:\n - name: POD_NAME\n valueFrom:\n fieldRef:\n apiVersion: v1\n fieldPath: metadata.name\n - name: NAMESPACE\n valueFrom:\n fieldRef:\n apiVersion: v1\n fieldPath: metadata.namespace\n - name: HEADLESS_SERVICE_NAME\n value: mo-tp-cn-headless\n - name: AWS_ACCESS_KEY_ID\n valueFrom:\n secretKeyRef:\n key: AWS_ACCESS_KEY_ID\n name: minio\n - name: AWS_SECRET_ACCESS_KEY\n valueFrom:\n secretKeyRef:\n key: AWS_SECRET_ACCESS_KEY\n name: minio\n - name: AWS_REGION\n value: us-west-2\n image: matrixorigin/matrixone:nightly-144f3be4\n imagePullPolicy: Always\n name: main\n resources: {}\n terminationMessagePath: /dev/termination-log\n terminationMessagePolicy: File\n volumeMounts:\n - mountPath: /etc/matrixone/config\n name: config\n readOnly: true\n - mountPath: /var/run/secrets/kubernetes.io/serviceaccount\n name: kube-api-access-ngpcs\n readOnly: true\n dnsPolicy: ClusterFirst\n enableServiceLinks: true\n hostname: mo-tp-cn-0\n nodeName: node0\n preemptionPolicy: PreemptLowerPriority\n priority: 0\n readinessGates:\n - conditionType: InPlaceUpdateReady\n - conditionType: KruisePodReady\n restartPolicy: Always\n schedulerName: default-scheduler\n securityContext: {}\n serviceAccount: default\n serviceAccountName: default\n subdomain: mo-tp-cn-headless\n terminationGracePeriodSeconds: 30\n tolerations:\n - effect: NoExecute\n key: node.kubernetes.io/not-ready\n operator: Exists\n tolerationSeconds: 300\n - effect: NoExecute\n key: node.kubernetes.io/unreachable\n operator: Exists\n tolerationSeconds: 300\n volumes:\n - configMap:\n defaultMode: 420\n name: mo-tp-cn-config-5abf454\n name: config\n - name: kube-api-access-ngpcs\n projected:\n defaultMode: 420\n sources:\n - serviceAccountToken:\n expirationSeconds: 3607\n path: token\n - configMap:\n items:\n - key: ca.crt\n path: ca.crt\n name: kube-root-ca.crt\n - downwardAPI:\n items:\n - fieldRef:\n apiVersion: v1\n fieldPath: metadata.namespace\n path: namespace\nstatus:\n conditions:\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: KruisePodReady\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: InPlaceUpdateReady\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: Initialized\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:54Z\"\n status: \"True\"\n type: Ready\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:54Z\"\n status: \"True\"\n type: ContainersReady\n - lastProbeTime: null\n lastTransitionTime: \"2023-05-07T13:01:50Z\"\n status: \"True\"\n type: PodScheduled\n containerStatuses:\n - containerID: docker://679d672a330d7318f97a90835dacefcdd03e8a08062b8844d438f8cdd6bcdc8f\n image: matrixorigin/matrixone:nightly-144f3be4\n imageID: docker-pullable://matrixorigin/matrixone@sha256:288fe3d626c6aa564684099e4686a9d4b28e16fdd16512bd968a67bb41d5aaa3\n lastState: {}\n name: main\n ready: true\n restartCount: 0\n started: true\n state:\n running:\n startedAt: \"2023-05-07T13:01:54Z\"\n hostIP: 10.206.134.14\n phase: Running\n podIP: 10.234.60.53\n podIPs:\n - ip: 10.234.60.53\n qosClass: BestEffort\n startTime: \"2023-05-07T13:01:50Z\"\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#matrixone","title":"MatrixOne \u76d1\u63a7","text":""},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#_4","title":"\u67e5\u770b\u96c6\u7fa4\u72b6\u6001","text":"\u5728 Operator \u90e8\u7f72\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86 matrixOnecluster
\u4f5c\u4e3a\u6574\u4e2a\u96c6\u7fa4\u7684\u81ea\u5b9a\u4e49\u8d44\u6e90\u540d\u79f0\u3002\u901a\u8fc7\u68c0\u67e5 MatrixOneCluster\uff0c\u6211\u4eec\u53ef\u4ee5\u5224\u65ad\u96c6\u7fa4\u662f\u5426\u6b63\u5e38\u8fd0\u884c\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u68c0\u67e5\uff1a
MO_NAME=\"mo\"\nNS=\"mo-hn\"\nkubectl get matrixonecluster -n${NS} ${MO_NAME}\n
\u5982\u679c\u72b6\u6001\u4e3a \"Ready\"\uff0c\u5219\u8868\u793a\u96c6\u7fa4\u6b63\u5e38\u3002\u5982\u679c\u72b6\u6001\u4e3a \"NotReady\"\uff0c\u5219\u9700\u8981\u8fdb\u4e00\u6b65\u6392\u67e5\u95ee\u9898\u3002
[root@master0 ~]# MO_NAME=\"mo\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get matrixonecluster -n${NS} ${MO_NAME}\nNAME LOG TN TP AP VERSION PHASE AGE\nmo 3 1 1 nightly-144f3be4 Ready 13h\n
\u8981\u67e5\u770b MatrixOne \u96c6\u7fa4\u72b6\u6001\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
kubectl describe matrixonecluster -n${NS} ${MO_NAME}\n
[root@master0 ~]# kubectl describe matrixonecluster -n${NS} ${MO_NAME}\nName: mo\nNamespace: mo-hn\nLabels: <none>\nAnnotations: <none>\nAPI Version: core.matrixorigin.io/v1alpha1\nKind: MatrixOneCluster\nMetadata:\n Creation Timestamp: 2023-05-07T12:54:17Z\n Finalizers:\n matrixorigin.io/matrixonecluster\n Generation: 2\n Managed Fields:\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:metadata:\n f:annotations:\n .:\n f:kubectl.kubernetes.io/last-applied-configuration:\n f:spec:\n .:\n f:Tn:\n .:\n f:config:\n f:replicas:\n f:imagePullPolicy:\n f:imageRepository:\n f:logService:\n .:\n f:config:\n f:pvcRetentionPolicy:\n f:replicas:\n f:sharedStorage:\n .:\n f:s3:\n .:\n f:endpoint:\n f:secretRef:\n f:type:\n f:volume:\n .:\n f:size:\n f:tp:\n .:\n f:config:\n f:nodePort:\n f:replicas:\n f:serviceType:\n f:version:\n Manager: kubectl-client-side-apply\n Operation: Update\n Time: 2023-05-07T12:54:17Z\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:metadata:\n f:finalizers:\n .:\n v:\"matrixorigin.io/matrixonecluster\":\n Manager: manager\n Operation: Update\n Time: 2023-05-07T12:54:17Z\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:spec:\n f:logService:\n f:sharedStorage:\n f:s3:\n f:path:\n Manager: kubectl-edit\n Operation: Update\n Time: 2023-05-07T13:00:53Z\n API Version: core.matrixorigin.io/v1alpha1\n Fields Type: FieldsV1\n fieldsV1:\n f:status:\n .:\n f:cnGroups:\n .:\n f:desiredGroups:\n f:readyGroups:\n f:syncedGroups:\n f:conditions:\n f:credentialRef:\n f:Tn:\n .:\n f:availableStores:\n f:conditions:\n f:logService:\n .:\n f:availableStores:\n f:conditions:\n f:discovery:\n .:\n f:address:\n f:port:\n f:phase:\n Manager: manager\n Operation: Update\n Subresource: status\n Time: 2023-05-07T13:02:12Z\n Resource Version: 72671\n UID: be2355c0-0c69-4f0f-95bb-9310224200b6\nSpec:\n Tn:\n Config: \n[dn]\n\n[dn.Ckp]\nflush-interval = \"60s\"\nglobal-interval = \"100000s\"\nincremental-interval = \"60s\"\nmin-count = 100\nscan-interval = \"5s\"\n\n[dn.Txn]\n\n[dn.Txn.Storage]\nbackend = \"TAE\"\nlog-backend = \"logservice\"\n\n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n Replicas: 1\n Resources:\n Service Args:\n -debug-http=:6060\n Shared Storage Cache:\n Memory Cache Size: 0\n Image Pull Policy: Always\n Image Repository: matrixorigin/matrixone\n Log Service:\n Config: \n[log]\nformat = \"json\"\nlevel = \"error\"\nmax-size = 512\n\n Initial Config:\n TN Shards: 1\n Log Shard Replicas: 3\n Log Shards: 1\n Pvc Retention Policy: Retain\n Replicas: 3\n Resources:\n Service Args:\n -debug-http=:6060\n Shared Storage:\n s3:\n Endpoint: http://minio.mostorage:9000\n Path: minio-mo\n s3RetentionPolicy: Retain\n Secret Ref:\n Name: minio\n Type: minio\n Store Failure Timeout: 10m0s\n Volume:\n Size: 1Gi\n Tp:\n Config: \n[cn]\n\n[cn.Engine]\ntype = \"distributed-tae\"\n\n[log]\nformat = \"json\"\nlevel = \"debug\"\nmax-size = 512\n\n Node Port: 31474\n Replicas: 1\n Resources:\n Service Args:\n -debug-http=:6060\n Service Type: NodePort\n Shared Storage Cache:\n Memory Cache Size: 0\n Version: nightly-144f3be4\nStatus:\n Cn Groups:\n Desired Groups: 1\n Ready Groups: 1\n Synced Groups: 1\n Conditions:\n Last Transition Time: 2023-05-07T13:02:14Z\n Message: the object is synced\n Reason: empty\n Status: True\n Type: Synced\n Last Transition Time: 2023-05-07T13:02:14Z\n Message: \n Reason: AllSetsReady\n Status: True\n Type: Ready\n Credential Ref:\n Name: mo-credential\n Tn:\n Available Stores:\n Last Transition: 2023-05-07T13:01:48Z\n Phase: Up\n Pod Name: mo-tn-0\n Conditions:\n Last Transition Time: 2023-05-07T13:01:48Z\n Message: the object is synced\n Reason: empty\n Status: True\n Type: Synced\n Last Transition Time: 2023-05-07T13:01:48Z\n Message: \n Reason: empty\n Status: True\n Type: Ready\n Log Service:\n Available Stores:\n Last Transition: 2023-05-07T13:01:25Z\n Phase: Up\n Pod Name: mo-log-0\n Last Transition: 2023-05-07T13:01:25Z\n Phase: Up\n Pod Name: mo-log-1\n Last Transition: 2023-05-07T13:01:25Z\n Phase: Up\n Pod Name: mo-log-2\n Conditions:\n Last Transition Time: 2023-05-07T13:01:25Z\n Message: the object is synced\n Reason: empty\n Status: True\n Type: Synced\n Last Transition Time: 2023-05-07T13:01:25Z\n Message: \n Reason: empty\n Status: True\n Type: Ready\n Discovery:\n Address: mo-log-discovery.mo-hn.svc\n Port: 32001\n Phase: Ready\nEvents:\n Type Reason Age From Message\n ---- ------ ---- ---- -------\n Normal ReconcileSuccess 29m (x2 over 13h) matrixonecluster object is synced\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#_5","title":"\u67e5\u770b\u7ec4\u4ef6\u72b6\u6001","text":"\u5f53\u524d MatrixOne \u96c6\u7fa4\u5305\u542b\u4ee5\u4e0b\u7ec4\u4ef6\uff1aTN\u3001CN\u3001Log Service\uff0c\u5b83\u4eec\u5206\u522b\u5bf9\u5e94\u7740\u81ea\u5b9a\u4e49\u8d44\u6e90\u7c7b\u578b TNSet\u3001CNSet\u3001LogSet\uff0c\u8fd9\u4e9b\u5bf9\u8c61\u7531 MatrixOneCluster \u63a7\u5236\u5668\u751f\u6210\u3002
\u8981\u68c0\u67e5\u5404\u7ec4\u4ef6\u662f\u5426\u6b63\u5e38\uff0c\u4ee5 TN \u4e3a\u4f8b\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
SET_TYPE=\"tnset\"\nNS=\"mo-hn\"\nkubectl get ${SET_TYPE} -n${NS}\n
\u8fd9\u5c06\u663e\u793a TN \u7ec4\u4ef6\u7684\u72b6\u6001\u4fe1\u606f\uff0c\u4fe1\u606f\u5982\u4e0b\uff1a
[root@master0 ~]# SET_TYPE=\"tnset\"\n[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME IMAGE REPLICAS AGE\nmo matrixorigin/matrixone:nightly-144f3be4 1 13h\n[root@master0 ~]# SET_TYPE=\"cnset\"\n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME IMAGE REPLICAS AGE\nmo-tp matrixorigin/matrixone:nightly-144f3be4 1 13h\n[root@master0 ~]# SET_TYPE=\"logset\" \n[root@master0 ~]# kubectl get ${SET_TYPE} -n${NS}\nNAME IMAGE REPLICAS AGE\nmo matrixorigin/matrixone:nightly-144f3be4 3 13h\n
"},{"location":"MatrixOne/Deploy/health-check-resource-monitoring/#pod_1","title":"\u67e5\u770b Pod \u72b6\u6001","text":"\u4f60\u53ef\u4ee5\u76f4\u63a5\u68c0\u67e5 MO \u96c6\u7fa4\u4e2d\u751f\u6210\u7684\u539f\u751f Kubernetes \u5bf9\u8c61\uff0c\u4ee5\u786e\u8ba4\u96c6\u7fa4\u7684\u5065\u5eb7\u72b6\u6001\u3002\u901a\u5e38\uff0c\u901a\u8fc7\u67e5\u8be2 Pod \u5373\u53ef\u5b8c\u6210\u3002
NS=\"mo-hn\"\nkubectl get pod -n${NS}\n
\u8fd9\u5c06\u663e\u793a Pod \u7684\u72b6\u6001\u4fe1\u606f\u3002
[root@master0 ~]# NS=\"mo-hn\"\n[root@master0 ~]# kubectl get pod -n${NS}\nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-f8496ff5c-fp6zm 1/1 Running 0 19h\nmo-tn-0 1/1 Running 0 13h\nmo-log-0 1/1 Running 0 13h\nmo-log-1 1/1 Running 0 13h\nmo-log-2 1/1 Running 0 13h\nmo-tp-cn-0 1/1 Running 0 13h\n
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cRunning \u72b6\u6001\u8868\u793a Pod \u6b63\u5e38\u8fd0\u884c\u3002\u4f46\u4e5f\u6709\u4e00\u4e9b\u7279\u6b8a\u60c5\u51b5\uff0c\u53ef\u80fd Pod \u72b6\u6001\u4e3a Running\uff0c\u4f46 MatrixOne \u96c6\u7fa4\u5b9e\u9645\u4e0a\u4e0d\u6b63\u5e38\u3002\u4f8b\u5982\uff0c\u65e0\u6cd5\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u96c6\u7fa4\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u8fdb\u4e00\u6b65\u67e5\u770b Pod \u7684\u65e5\u5fd7\uff0c\u4ee5\u68c0\u67e5\u662f\u5426\u6709\u5f02\u5e38\u4fe1\u606f\u8f93\u51fa\u3002
NS=\"mo-hn\"\nPOD_NAME=\"[\u4e0a\u8ff0\u8fd4\u56depod\u7684\u540d\u79f0]\" # \u4f8b\u5982mo-tp-cn-0\nkubectl logs ${POD_NAME} -n${NS}\n
\u5982\u679c Pod \u72b6\u6001\u4e3a\u975e Running \u72b6\u6001\uff0c\u4f8b\u5982 Pending\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b Pod \u7684\u4e8b\u4ef6\uff08Events\uff09\u6765\u786e\u8ba4\u5f02\u5e38\u539f\u56e0\u3002\u4ee5\u524d\u9762\u7684\u4f8b\u5b50\u4e3a\u4f8b\uff0c\u7531\u4e8e\u96c6\u7fa4\u8d44\u6e90\u65e0\u6cd5\u6ee1\u8db3 mo-tp-cn-3
\u7684\u8bf7\u6c42\uff0c\u8be5 Pod \u65e0\u6cd5\u8c03\u5ea6\uff0c\u5e76\u5904\u4e8e Pending \u72b6\u6001\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6269\u5bb9\u8282\u70b9\u8d44\u6e90\u6765\u89e3\u51b3\u3002
kubectl describe pod ${POD_NAME} -n${NS}\n
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/","title":"\u672c\u5730\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165\u5bfc\u5165\u6570\u636e","text":"\u5728 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u4e2d\uff0c\u9664\u4e86\u672c\u5730\u5bfc\u5165\u6570\u636e\u548c\u4ece\u516c\u6709\u4e91\u5bf9\u8c61\u5b58\u50a8 S3 \u5bfc\u5165\u6570\u636e\u5230 MatrixOne\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u672c\u5730 Minio \u7ec4\u4ef6\u5bfc\u5165\u6570\u636e\u3002
\u901a\u8fc7\u672c\u5730 Minio \u7ec4\u4ef6\u5bfc\u5165\u6570\u636e\u5230 MatrixOne \u9002\u7528\u4e8e\uff1a\u9047\u5230\u6ca1\u6709\u516c\u7f51\u8bbf\u95ee\u6216\u5bfc\u5165\u6587\u4ef6\u8fc7\u5927\u8d85\u51fa\u672c\u5730\u78c1\u76d8\u7a7a\u95f4\u7b49\u60c5\u51b5\u3002
\u672c\u7bc7\u6587\u7ae0\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u4f7f\u7528\u672c\u5730 Minio \u5bfc\u5165 CSV \u6587\u4ef6\u3002\u5e76\u4e14\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\uff0c\u8bf7\u786e\u4fdd\u6574\u4e2a MatrixOne \u5df2\u7ecf\u5b89\u88c5\u5b8c\u6bd5\u3002
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#_2","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#_3","title":"\u5bfc\u5165\u6570\u636e","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee http://192.168.56.10:32001 \u6765\u767b\u5f55 Minio \u7684\u56fe\u5f62\u5316\u754c\u9762\u3002\u8d26\u6237\u548c\u5bc6\u7801\u53ef\u4ee5\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7ae0\u8282\u4e2d\u5b89\u88c5\u548c\u90e8\u7f72 Minio \u8fc7\u7a0b\u4e2d\u521b\u5efa\u7684 rootUser \u548c rootPassword\u3002\u767b\u5f55\u540e\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u4e13\u5c5e\u7684\u5b58\u50a8\u6876 load-from-minio
\uff0c\u5e76\u5c06\u76f8\u5e94\u7684 CSV \u6587\u4ef6\u4e0a\u4f20\u5230\u8be5\u5b58\u50a8\u6876\u4e2d\u3002
\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528\u7684\u6848\u4f8b\u4e3a\u4e00\u4e2a\u4ec5\u5305\u542b 6 \u884c\u6570\u636e\u7684\u7b80\u5355 addresses.csv
\u6848\u4f8b\u3002
\u4ece\u672c\u5730 Minio \u91cc\u52a0\u8f7d\u6570\u636e\u5230 MatrixOne \u96c6\u7fa4\u7684\u539f\u7406\u4e0e\u4ece\u516c\u6709\u4e91\u7684\u5bf9\u8c61\u5b58\u50a8 S3 \u4e2d\u52a0\u8f7d\u6570\u636e\u65b9\u5f0f\u5b8c\u5168\u76f8\u540c\uff0c\u4ed6\u4eec\u7684\u8bed\u6cd5\u7ed3\u6784\u4e00\u6837\u3002\u4f46\u662f\u516c\u6709\u4e91\u65b9\u5f0f\u5176\u4e2d\u7684\u53c2\u6570\u4f1a\u6709\u516c\u6709\u4e91\u5382\u5546\u7ed9\u51fa\uff0c\u800c\u672c\u5730 Minio \u4e2d\u7684\u53c2\u6570\u9700\u8981\u81ea\u884c\u8bbe\u7f6e\u3002
LOAD DATA\n | URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>', \"provider\"='<string>'}\n INTO TABLE tbl_name\n [{FIELDS | COLUMNS}\n [TERMINATED BY 'string']\n [[OPTIONALLY] ENCLOSED BY 'char']\n [ESCAPED BY 'char']\n ]\n [IGNORE number {LINES | ROWS}]\n [PARALLEL {'TRUE' | 'FALSE'}]\n
\u8981\u4ece\u672c\u5730 Minio \u52a0\u8f7d\u6570\u636e\uff0c\u9996\u5148\u9700\u8981\u627e\u5230 Minio \u7684 endpoint\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0b\u6574\u4e2a\u8c03\u7528\u94fe\u8def\u7684\u67b6\u6784\u3002
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#minio","title":"Minio \u8bbf\u95ee\u67b6\u6784","text":"\u903b\u8f91\u4e0a\u6765\u8bf4\uff0cMatrixOne \u901a\u8fc7 Minio \u7684\u8bbf\u95ee\u7aef\u53e3 endpoint \u4e0e Minio \u901a\u4fe1\uff0c\u5e76\u4ece\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u5b9e\u9645\u4e0a\uff0cMinio \u5728 Kubernetes\uff08K8s\uff09\u4e2d\u88ab\u7eb3\u7ba1\uff0c\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u5fc5\u987b\u901a\u8fc7 K8s \u7684 Service\uff08SVC\uff09\u8bbf\u95ee\u3002\u4efb\u52a1\u7684\u5b9e\u9645\u6267\u884c\u662f\u5728 K8s Pod \u4e2d\u5b8c\u6210\u7684\u3002SVC \u53ef\u4ee5\u4fdd\u8bc1\u4e0d\u7ba1 Pod \u5982\u4f55\u53d8\u5316\uff0c\u5bf9\u5916\u90e8\u5e94\u7528\u6765\u8bf4\u59cb\u7ec8\u4fdd\u6301\u7edf\u4e00\u7aef\u53e3\u3002SVC \u4e0e Pod \u7684\u5173\u8054\u9700\u8981\u901a\u8fc7 K8s \u4e2d\u7684 Endpoint\uff08EP\uff09\u6765\u5efa\u7acb\u89c4\u5219\u3002\u56e0\u6b64\uff0cMatrixOne \u5b9e\u9645\u4e0a\u662f\u901a\u8fc7 SVC \u4e0e Minio \u670d\u52a1\u8fde\u63a5\u7684\uff0c\u5177\u4f53\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a
"},{"location":"MatrixOne/Deploy/import-data-from-minio-to-mo/#_4","title":"\u5b9e\u9645\u547d\u4ee4","text":"\u6211\u4eec\u5728\u5b89\u88c5 Minio \u7684\u65f6\u5019\u521b\u5efa\u4e86\u540d\u4e3a mostorage \u7684\u547d\u540d\u7a7a\u95f4\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u6761 K8s \u547d\u4ee4\u6765\u627e\u51fa\u8fd9\u4e2a endpoint\u3002
kubectl get svc -n${ns}
\uff1a\u5217\u51fa\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709\u7684 SVC\u3002kubectl get pod -n${ns}
\uff1a\u5217\u51fa\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709\u7684 Pod\u3002kubectl get ep -n${ns}
\uff1a\u5217\u51fa\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709\u7684\u8f6c\u53d1\u89c4\u5219\u5173\u7cfb\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
root@VM-32-16-debian:~# ns=\"mostorage\"\nroot@VM-32-16-debian:~# kubectl get svc -n${ns}\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\nminio ClusterIP 10.96.1.65 <none> 80/TCP 127d\nminio1-console NodePort 10.96.3.53 <none> 9090:30869/TCP 127d\nminio1-hl ClusterIP None <none> 9000/TCP 127d\nroot@VM-32-16-debian:~# kubectl get pod -n${ns}\nkubectl get ep -n${ns}NAME READY STATUS RESTARTS AGE\nminio1-ss-0-0 1/1 Running 0 106d\nminio1-ss-0-1 1/1 Running 0 106d\nminio1-ss-0-2 1/1 Running 0 106d\nminio1-ss-0-3 1/1 Running 0 106d\nroot@VM-32-16-debian:~# kubectl get ep -n${ns}\nNAME ENDPOINTS AGE\nminio 100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more... 127d\nminio1-console 100.92.250.195:9090,100.92.250.200:9090,100.92.250.201:9090 + 1 more... 127d\nminio1-hl 100.92.250.195:9000,100.92.250.200:9000,100.92.250.201:9000 + 1 more... 127d\n
SVC \u7684\u8bbf\u95ee\u5730\u5740\u662f\u5728 Load
\u8bed\u53e5\u4e2d\u9700\u8981\u6dfb\u52a0\u7684\u7ec8\u7aef\u5730\u5740\u3002\u8981\u6784\u5efa SVC \u5730\u5740\uff0c\u53ef\u4ee5\u4f7f\u7528 ${service_name}.{namespace}.svc.cluster.local
\u7684\u65b9\u5f0f\uff08\u540e\u4e09\u4f4d\u53ef\u7701\u7565\uff09\u3002\u4ee5\u4e0a\u547d\u4ee4\u7684\u7ed3\u679c\u8868\u660e\uff0cminio1-hl \u7684 SVC \u4f7f\u7528 9000 \u4f5c\u4e3a\u5bf9\u5916\u8f6c\u53d1\u7aef\u53e3\uff0cminio \u7684 SVC \u4f7f\u7528 80 \u4f5c\u4e3a\u5bf9\u5916\u8f6c\u53d1\u7aef\u53e3\u3002\u56e0\u6b64\uff0c\u8fde\u63a5 Mostorage \u7684 Minio \u7684\u6700\u7ec8 endpoint \u4e3a\uff1ahttp://minio1-hl.mostorage:9000 \u6216\u8005 http://minio.mostorage:80\u3002
\u6309\u7167 addresses.csv
\u7684\u6570\u636e\u7ed3\u6784\u6784\u5efa\u597d\u76f8\u5e94\u7684\u8868\uff1a
create table address (firstname varchar(50), lastname varchar(50), address varchar(500), city varchar(20), state varchar(10), postcode varchar(20));\n
\u53c2\u7167 Load S3 \u7684\u8bed\u6cd5\u7ed3\u6784\uff0c\u5c06\u53c2\u6570\u4fe1\u606f\u586b\u5165 Load
\u8bed\u53e5\u4e2d\u5176\u4e2d\uff1a
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4ece\u672c\u5730 Minio \u5e26\u5165\u9700\u8981\u5728\u53c2\u6570\u4e32\u4e2d\u589e\u52a0\u4e00\u6761 \"provider\"=\"minio\"
\u6765\u6307\u660e\u5e95\u5c42\u5b58\u50a8\u6765\u6e90\u662f\u672c\u5730 Minio\uff0c\u6700\u7ec8\u5f62\u6210\u5982\u4ee5\u4e0b\u7684 SQL \u8bed\u53e5\u3002
MySQL [stock]> load data url s3option{\"endpoint\"='http://minio.mostorage:80',\"access_key_id\"='rootuser', \"secret_access_key\"='rootpass123',\"bucket\"='load-from-minio', \"filepath\"='/addresses.csv', \"compression\"='none', \"provider\"=\"minio\"} INTO TABLE address FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' PARALLEL 'TRUE';\nQuery OK, 6 rows affected (2.302 sec)\n
Note
\"provider\"=\"minio\" \u4ec5\u5728\u672c\u5730 Minio \u73af\u5883\u4e2d\u751f\u6548\uff0c\u5982\u679c\u4ece\u516c\u6709\u4e91\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u5bfc\u5165\u6570\u636e\u65e0\u9700\u52a0\u8be5\u53c2\u6570\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/","title":"\u8d1f\u8f7d\u4e0e\u79df\u6237\u9694\u79bb","text":"Proxy \u662f MatrixOne \u5728 0.8 \u7248\u672c\u4e2d\u5f15\u8fdb\u7684\u65b0\u7cfb\u7edf\u7ec4\u4ef6\uff0c\u5b83\u53ef\u4ee5\u901a\u8fc7\u6d41\u91cf\u4ee3\u7406\u548c\u8f6c\u53d1\u7684\u65b9\u5f0f\u5b9e\u73b0\u79df\u6237\u3001\u8d1f\u8f7d\u9694\u79bb\u7b49\u529f\u80fd\u3002\u5173\u4e8e Proxy \u7684\u6280\u672f\u8bbe\u8ba1\uff0c\u53ef\u4ee5\u53c2\u8003 Proxy \u67b6\u6784\u8be6\u89e3\u3002
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Proxy \u6765\u5efa\u7acb\u4e0d\u540c\u7684 CN \u7ec4\uff0c\u4ee5\u5b9e\u73b0\u79df\u6237\u548c\u8d1f\u8f7d\u7684\u72ec\u7acb\u8d44\u6e90\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_2","title":"\u7cfb\u7edf\u67b6\u6784","text":"\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u7528\u6237\u9996\u5148\u8fde\u63a5\u5230 Proxy \u6a21\u5757\u3002Proxy \u7ec4\u4ef6\u6839\u636e\u7528\u6237\u8fde\u63a5\u4e32\u4e2d\u7684\u8eab\u4efd\u548c\u6807\u7b7e\u4fe1\u606f\uff0c\u5c06\u7528\u6237\u7684\u6570\u636e\u5e93\u8fde\u63a5\uff08connection\uff09\u5206\u53d1\u5230\u76f8\u5e94\u7684 CN \u7ec4\u3002\u5176\u4ed6 CN \u7ec4\u4e0d\u4f1a\u63a5\u6536\u5230\u6b64\u7528\u6237\u8fde\u63a5\uff0c\u4e5f\u4e0d\u4f1a\u53c2\u4e0e\u8be5\u8fde\u63a5\u7684\u8ba1\u7b97\u8fc7\u7a0b\u3002
CN \u7ec4\u662f\u7531\u4e00\u7ec4\u5177\u6709\u76f8\u540c\u5c5e\u6027\u548c\u5927\u5c0f\u7684 CN \u8282\u70b9\u7ec4\u6210\u7684\u903b\u8f91 CN \u7ec4\uff0c\u5b83\u662f MatrixOne \u96c6\u7fa4\u4e2d\u7528\u4e8e\u9694\u79bb\u4e0d\u540c\u8d44\u6e90\u7ec4\u7684\u5355\u4f4d\u3002\u6bcf\u4e2a CN \u7ec4\u53ef\u5305\u542b 1 \u4e2a\u5230\u65e0\u9650\u4e2a CN \u8282\u70b9\uff0c\u5e76\u53ef\u4f7f\u7528\u4e00\u7cfb\u5217\u6807\u7b7e\u5b9a\u4e49\u5176\u5c5e\u6027\uff0c\u4f8b\u5982\u5b9a\u4e49\u67d0\u79df\u6237\u5bf9\u5e94\u7684 Account \u6807\u7b7e\uff0c\u5c06\u8fde\u63a5\u8f6c\u53d1\u81f3\u5e26\u6709\u76f8\u5e94\u6807\u7b7e\u7684 CN \u7ec4\uff0c\u4fbf\u53ef\u5b9e\u73b0\u79df\u6237\u8d44\u6e90\u9694\u79bb\u548c\u4e1a\u52a1\u8d1f\u8f7d\u9694\u79bb\u529f\u80fd\u3002\u7ed3\u5408 CN \u7ec4\u4e2d CN \u8282\u70b9\u53ef\u65e0\u9650\u6c34\u5e73\u6269\u5c55\u7684\u7279\u6027\uff0c\u53ef\u5b9e\u73b0\u9488\u5bf9\u79df\u6237\u6216\u6307\u5b9a\u8d1f\u8f7d\u7684\u72ec\u7acb\u6269\u5c55\u3002
\u4e3a\u786e\u4fdd Proxy \u7684\u9ad8\u53ef\u7528\u6027\uff0c\u9700\u8981\u5728\u96c6\u7fa4\u4e2d\u8bbe\u7f6e\u81f3\u5c11 2 \u4e2a\u526f\u672c\u3002
\u5f53\u5bf9 CN \u8fdb\u884c\u7f29\u5bb9\u65f6\uff0cProxy \u5728 YAML \u6587\u4ef6\u7684\u884c\u4e3a\u5982\u4e0b\uff1a
\u540c\u4e00\u4e2a Label \u4f1a\u8bdd\u642c\u8fc1\uff1a\u5f53 CN \u7684\u526f\u672c\u6570\u91cf\u51cf\u5c11\u65f6\uff0c\u5177\u6709\u76f8\u540c Label \u7684\u4f1a\u8bdd\u5c06\u88ab\u8fc1\u79fb\u5230\u5176\u4ed6\u7f29\u5bb9\u540e\u7684 CN \u8282\u70b9\u4e0a\u3002\u8fd9\u6837\u53ef\u4ee5\u4fdd\u6301\u4e0e\u7279\u5b9a Label \u76f8\u5173\u7684\u4f1a\u8bdd\u7684\u8fde\u7eed\u6027\u548c\u53ef\u7528\u6027\u3002
\u4e0d\u540c Label \u4f1a\u8bdd\u642c\u8fc1\uff1a\u5982\u679c\u67d0\u4e2a Label \u7684 CN \u526f\u672c\u88ab\u7f6e\u4e3a 0 \u6216\u53d6\u6d88\uff0c\u6839\u636e Label \u7684\u5339\u914d\u89c4\u5219\uff0c\u5c06\u4f1a\u5728\u5c06\u6765\u7684\u4f1a\u8bdd\u4e2d\u5c06\u8fd9\u4e2a Label \u76f8\u5173\u7684\u4f1a\u8bdd\u8fc1\u79fb\u5230\u7a7a\u95f2\u7684 Label \u4e0a\u3002
Label \u53d6\u6d88\u5e76\u4e14\u6ca1\u6709\u5339\u914d Label\uff1a\u5982\u679c\u67d0\u4e2a Label \u88ab\u53d6\u6d88\uff0c\u800c\u4e14\u6ca1\u6709\u4e0e\u4e4b\u5339\u914d\u7684 Label\uff0c\u76f8\u5173\u4f1a\u8bdd\u5c06\u88ab\u5173\u95ed\uff0c\u56e0\u4e3a\u6ca1\u6709\u76ee\u6807 CN \u53ef\u4ee5\u63a5\u6536\u8fd9\u4e9b\u4f1a\u8bdd\u3002
Proxy \u5728 CN \u7f29\u5bb9\u65f6\u901a\u8fc7\u4ee5\u4e0a\u884c\u4e3a\u5904\u7406\u4f1a\u8bdd\u7684\u8fc1\u79fb\u548c\u5173\u95ed\uff0c\u4ee5\u786e\u4fdd\u8d1f\u8f7d\u548c\u79df\u6237\u4e4b\u95f4\u7684\u9694\u79bb\u4ee5\u53ca\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_3","title":"\u64cd\u4f5c\u6b65\u9aa4","text":"\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u4f7f\u7528 Proxy \u7ba1\u7406 CN \u7ec4\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
\u4e3a\u4e86\u65b9\u4fbf\u4f60\u4e86\u89e3\u8d44\u6e90\u9694\u79bb\u4e0e\u5206\u914d\u60c5\u51b5\uff0c\u53ef\u4ee5\u5728\u4e0b\u9762\u8868\u683c\u4e2d\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u73af\u5883\u4e2d\u5404\u4e2a\u786c\u4ef6\u8282\u70b9\u60c5\u51b5\u5206\u5e03\uff0c\u5177\u4f53\u5982\u4e0b\u6240\u793a\uff1a
Host \u5185\u7f51 IP \u5916\u7f51 IP \u5185\u5b58 CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#proxy","title":"\u7b2c\u4e00\u6b65\uff1a\u542f\u7528 Proxy","text":"\u5728 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u4e2d\u542f\u7528 Proxy \u7ec4\u4ef6\uff0c\u4f60\u9700\u8981\u5728\u521b\u5efa\u96c6\u7fa4\u65f6\u6307\u5b9a\u6240\u9700\u7684 Proxy \u62d3\u6251\uff0c\u6216\u8005\u5728\u73b0\u6709\u96c6\u7fa4\u4e2d\u6dfb\u52a0 Proxy \u62d3\u6251\u540e\uff0c\u6267\u884c kubectl apply
\u4ee5\u542f\u7528 Proxy \u7ec4\u4ef6\u3002\u8be6\u7ec6\u6b65\u9aa4\u5982\u4e0b\uff1a
\u4fee\u6539 MatrixOne \u96c6\u7fa4\u7684 mo.yaml
\u6587\u4ef6\uff1a
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ proxy:\n+ replicas: 2 #\u4e3a\u4e86\u9ad8\u53ef\u7528\uff0cproxy \u7684 replicas \u9700\u8981\u81f3\u5c11 2 \u4e2a\n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u8fd0\u884c mo.yaml
\u6587\u4ef6\uff1a
kubectl apply -f mo.yaml\n
\u8fd0\u884c kubectl get pod -nmo-hn
\u68c0\u67e5 Proxy \u72b6\u6001\u662f\u5426\u6b63\u5e38\u542f\u52a8\uff1a
root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME READY STATUS RESTARTS AGE\nmo-tn-0 1/1 Running 0 2m51s\nmo-log-0 1/1 Running 0 3m25s\nmo-log-1 1/1 Running 0 3m25s\nmo-log-2 1/1 Running 0 3m25s\nmo-proxy-69zjf 1/1 Running 0 2m51s\nmo-proxy-fpn2g 1/1 Running 0 2m51s\nmo-tp-cn-0 1/1 Running 0 2m25s\n
\u6b63\u5e38\u542f\u52a8\u540e\u7684\u4ee3\u7801\u793a\u4f8b\u5982\u4e0a\u8ff0\u6240\u793a\u3002\u8fd9\u6837\u6700\u5c0f\u5316\u7684 Proxy \u7ec4\u4ef6\u5c31\u542f\u52a8\u5b8c\u6210\u4e86\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 kubectl get svc -nmo-hn
\u901a\u8fc7 Proxy \u7684 SVC \u5730\u5740\u5373\u53ef\u4ee5\u8fde\u63a5\u5230\u8be5\u96c6\u7fa4\uff1a
root@HOST-10-206-134-16:~# kubectl get svc -nmo-hn\nNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE\nmo-tn-headless ClusterIP None <none> <none> 70m\nmo-log-discovery ClusterIP 10.96.3.186 <none> 32001/TCP 71m\nmo-log-headless ClusterIP None <none> <none> 71m\nmo-proxy NodePort 10.96.1.153 <none> 6001:31429/TCP 70m\nmo-tp-cn ClusterIP 10.96.1.43 <none> 6001/TCP 70m\nmo-tp-cn-headless ClusterIP None <none> <none> 70m\nroot@HOST-10-206-134-16:~# mysql -h 10.96.1.153 -P6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 2064\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective owners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
\u82e5\u6574\u4e2a\u96c6\u7fa4\u4e2d\u6709\u591a\u4e2a CN \u7684\u8bdd\uff0cProxy \u4f1a\u81ea\u52a8\u5b9e\u73b0\u8fde\u63a5\u7ea7\u522b\u7684\u8d1f\u8f7d\u5747\u8861\uff0c\u5c06\u7528\u6237\u7684\u8fde\u63a5\u5747\u5300\u5206\u914d\u5230\u4e0d\u540c\u7684 CN \u4e0a\u3002\u4f60\u53ef\u4ee5\u67e5\u8be2\u7cfb\u7edf\u8868 system_metrics.server_connections
\u6765\u67e5\u770b\u6bcf\u4e2a CN \u4e0a\u7684\u7528\u6237\u8fde\u63a5\u4e2a\u6570\u3002
\u5728 MatrixOne \u96c6\u7fa4\u7684 mo.yaml
\u6587\u4ef6\u4e2d\uff0c\u4f60\u9700\u8981\u901a\u8fc7\u8bbe\u7f6e cnGroups
\u5b57\u6bb5\u6765\u914d\u7f6e CN \u7ec4\uff0c\u5e76\u5728\u6bcf\u4e2a cnGroups
\u4e2d\u914d\u7f6e cnLabels
\u5b57\u6bb5\uff0c\u4ee5\u8bbe\u5b9a\u8be5 CN \u7ec4\u4e2d\u6240\u6709 CN \u7684\u6807\u7b7e\u3002Proxy \u4f1a\u6839\u636e\u8fde\u63a5\u6807\u7b7e\u8fdb\u884c\u8def\u7531\u8f6c\u53d1\u3002\u4f8b\u5982\uff0c\u5728\u4ee5\u4e0b\u793a\u4f8b\u4e2d\uff0c\u4f60\u8bbe\u7f6e\u4e86\u540d\u4e3a cn-set1
\u548c cn-set2
\u7684\u4e24\u4e2a CN \u7ec4\u3002\u6bcf\u4e2a CN \u7ec4\u53ef\u4ee5\u5177\u6709\u81ea\u5df1\u7684\u72ec\u7acb\u526f\u672c\u6570\u3001\u4e0d\u540c\u7684\u65e5\u5fd7\u7ea7\u522b\u3001CN \u53c2\u6570\u914d\u7f6e\u4ee5\u53ca CN \u6807\u7b7e\u3002
CN \u7ec4\u7684\u6807\u7b7e\u91c7\u7528\u4e00\u5230\u591a\u7ec4 Key/value \u683c\u5f0f\uff0c\u5176\u4e2d\u6bcf\u7ec4 Key \u4e0e value \u4e4b\u95f4\u5b58\u5728\u4e00\u5bf9\u591a\u7684\u5173\u7cfb\uff0c\u5373\u6bcf\u4e2a Key \u53ef\u62e5\u6709\u591a\u4e2a value\u3002
\u8be6\u7ec6\u6b65\u9aa4\u5982\u4e0b\uff1a
\u53c2\u7167\u4e0b\u9762\u7684\u914d\u7f6e\u53c2\u6570\u793a\u4f8b\uff0c\u914d\u7f6e CN \u7ec4\u7684\u6807\u7b7e\uff1a
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+ replicas: 1\n+ cnLabels:\n+ - key: \"cn-set1\"\n+ values: [\"1\", \"high\"]\n+ - key: \"account\"\n+ values: [\"acc1\"]\n+\n+ - name: cn-set2\n+ replicas: 1\n+ cnLabels:\n+ - key: \"cn-set2\"\n+ values: [\"2\", \"medium\"]\n+ - key: \"account\"\n+ values: [\"acc2\"] \n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u8fd0\u884c mo.yaml
\u6587\u4ef6\uff1a
kubectl apply -f mo.yaml\n
\u8fd0\u884c kubectl get pod -nmo-hn
\u68c0\u67e5 Proxy \u72b6\u6001\u662f\u5426\u6b63\u5e38\u542f\u52a8\uff1a
root@HOST-10-206-134-16:~# kubectl get pod -nmo-hn\nNAME READY STATUS RESTARTS AGE\nmo-cn-set1-cn-0 1/1 Running 0 6s\nmo-cn-set2-cn-0 1/1 Running 0 6s\nmo-tn-0 1/1 Running 0 97m\nmo-log-0 1/1 Running 0 97m\nmo-log-1 1/1 Running 0 97m\nmo-log-2 1/1 Running 0 97m\nmo-proxy-69zjf 1/1 Running 0 97m\nmo-proxy-fpn2g 1/1 Running 0 97m\n
\u6b63\u5e38\u542f\u52a8\u540e\u7684\u4ee3\u7801\u793a\u4f8b\u5982\u4e0a\u8ff0\u6240\u793a\u3002
CN \u7ec4\u7684\u6807\u7b7e\u8bbe\u7f6e\u975e\u5e38\u7075\u6d3b\uff0c\u4f46\u662f\u4e00\u822c\u6700\u5e38\u89c1\u7684\u8fd8\u662f\u7528\u5728\u79df\u6237\u548c\u8d1f\u8f7d\u7684\u9694\u79bb\u4e0a\u3002
\u5173\u4e8e\u5982\u4f55\u5b9e\u73b0\u79df\u6237\u9694\u79bb\u548c\u8d1f\u8f7d\u9694\u79bb\uff0c\u8bf7\u7ee7\u7eed\u53c2\u52a0\u4e0b\u9762\u7684\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_4","title":"\u5b9e\u73b0\u79df\u6237\u9694\u79bb","text":"MatrixOne 0.7 \u7248\u672c\u5df2\u5b9e\u73b0\u5bf9\u591a\u79df\u6237\u6570\u636e\u9694\u79bb\u7684\u652f\u6301\u3002\u82e5\u8981\u5b9e\u73b0\u79df\u6237\u8d1f\u8f7d\u9694\u79bb\uff0c\u5219\u9700\u901a\u8fc7\u914d\u7f6e Proxy \u548c CN \u7ec4\u6765\u5b8c\u6210\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_5","title":"\u666e\u901a\u79df\u6237","text":"\u5728 CN \u7ec4\u7684\u6807\u7b7e\u8bbe\u7f6e\u4e2d\uff0caccount
\u6807\u7b7e\u662f\u4fdd\u7559\u5b57\u6bb5\uff0c\u7528\u4f5c\u5339\u914d\u79df\u6237\u3002
\u5728\u672c\u7ae0\u4e2d\uff0c\u5047\u8bbe\u9700\u8981\u4e3a acc1
\u548c acc2
\u8fd9\u4e24\u4e2a\u79df\u6237\u5b9e\u73b0\u79df\u6237\u8d1f\u8f7d\u9694\u79bb\uff0c\u4f60\u53ef\u4ee5\u53c2\u89c1\u4e0b\u9762\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a
Note
\u4ec5\u652f\u6301\u62e5\u6709\u7cfb\u7edf\u79df\u6237\u6743\u9650\u7684\u7528\u6237\u624d\u80fd\u4e3a\u666e\u901a\u79df\u6237\u914d\u7f6e\u8d1f\u8f7d\u9694\u79bb\u3002
\u4f7f\u7528\u7cfb\u7edf\u79df\u6237\u767b\u5f55\u5230 MatrixOne \u96c6\u7fa4\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u8bf7\u54a8\u8be2\u4f60\u6240\u5728\u516c\u53f8\u7684\u6570\u636e\u5e93\u7ba1\u7406\u5458\u3002\u767b\u5f55\u5230 MatrixOne \u96c6\u7fa4\u540e\uff0c\u5206\u522b\u521b\u5efa\u4e24\u4e2a\u65b0\u79df\u6237 acc1
\u548c acc2
\uff1a
-- \u521b\u5efa\u65b0\u79df\u6237 acc1\uff0c\u5bc6\u7801\u4e3a 123456\uff08\u5728\u8fd9\u91cc\u8bbe\u7f6e\u7b80\u5355\u5bc6\u7801\uff0c\u4ec5\u505a\u4e3a\u793a\u4f8b\u8bb2\u89e3\u4f7f\u7528\uff09\nmysql> create account acc1 admin_name 'admin' identified by '123456';\n-- \u521b\u5efa\u65b0\u79df\u6237 acc2\uff0c\u5bc6\u7801\u4e3a 123456\uff08\u5728\u8fd9\u91cc\u8bbe\u7f6e\u7b80\u5355\u5bc6\u7801\uff0c\u4ec5\u505a\u4e3a\u793a\u4f8b\u8bb2\u89e3\u4f7f\u7528\uff09\nmysql> create account acc2 admin_name 'admin' identified by '123456';\n
\u4fee\u6539 MatrixOne \u96c6\u7fa4\u7684 mo.yaml
\u6587\u4ef6\uff0c\u5c06\u4e24\u4e2a CN \u7ec4\u5206\u522b\u6253\u4e0a\u4e86 account:acc1
\u53ca account:acc2
\u7684\u6807\u7b7e\uff0c\u5206\u522b\u5bf9\u5e94\u540d\u4e3a acc1
\u548c acc2
\u7684\u79df\u6237\uff1a
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+ replicas: 1\n+ cnLabels:\n+ - key: \"account\"\n+ values: [\"acc1\"]\n+\n+ - name: cn-set2\n+ replicas: 1\n+ cnLabels:\n+ - key: \"account\"\n+ values: [\"acc2\"] \n
\u5206\u522b\u4f7f\u7528 acc1
\u548c acc2
\u767b\u5f55\uff0c\u767b\u5f55\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 show backend servers
\u68c0\u67e5\u5b9e\u9645\u767b\u5f55\u4f7f\u7528\u4e86\u54ea\u4e9b CN \u7ec4\u3002\u4ee5\u4e0b\u65e5\u5fd7\u663e\u793a\u4e0d\u540c\u7684\u5e10\u6237\u5df2\u767b\u5f55\u5e76\u4f7f\u7528\u4e86\u76f8\u5e94\u7684 CN \u7ec4
-- acc1 \u79df\u6237\u767b\u5f55 MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc1:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 32309\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc1 \u67e5\u770b\u5b9e\u9645\u767b\u5f55\u4f7f\u7528\u7684 CN \u7ec4\u662f\u54ea\u4e9b\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| UUID | Address | Work State | Labels |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n| 32333337-3966-3137-3032-613035306561 | mo-cn-set1-cn-0.mo-cn-set1-cn-headless.mo-hn.svc:6001 | Working | account:acc1;cn-set1:1,high; |\n+--------------------------------------+-------------------------------------------------------+------------+------------------------------+\n1 row in set (0.00 sec)\n
-- acc2 \u79df\u6237\u767b\u5f55 MatrixOne\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc2:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 32640\nServer version: 8.0.30-MatrixOne-v0.5.0 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n-- acc2 \u67e5\u770b\u5b9e\u9645\u767b\u5f55\u4f7f\u7528\u7684 CN \u7ec4\u662f\u54ea\u4e9b\nmysql> show backend servers;\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| UUID | Address | Work State | Labels |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n| 33663265-3234-3365-3737-333030613535 | mo-cn-set2-cn-0.mo-cn-set2-cn-headless.mo-hn.svc:6001 | Working | account:acc2;cn-set2:2,medium; |\n+--------------------------------------+-------------------------------------------------------+------------+--------------------------------+\n1 row in set (0.00 sec)\n
\u5982\u679c\u4e00\u4e2a\u666e\u901a\u79df\u6237\u6ca1\u6709\u5bf9\u5e94\u7684 CN \u7ec4\uff0c\u90a3\u4e48\u79df\u6237\u65e0\u6cd5\u767b\u5f55\u6210\u529f\u3002\u4f8b\u5982\uff0c\u4f60\u5982\u679c\u521b\u5efa\u4e00\u4e2a\u6ca1\u6709 CN \u7ec4\u6807\u7b7e\u5bf9\u5e94\u7684\u79df\u6237 acc3
\uff0c\u5e76\u5c1d\u8bd5\u767b\u5f55\uff0c\u4f1a\u51fa\u73b0 no available CN server
\u9519\u8bef\u3002
mysql> create account acc3 admin_name 'admin' identified by '123456';\nroot@HOST-10-206-134-7:~# mysql -h 10.96.1.153 -uacc3:admin -P6001 -p123456\nmysql: [Warning] Using a password on the command line interface can be insecure.\nERROR 1045 (28000): internal error: no available CN server\n
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_6","title":"\u7cfb\u7edf\u79df\u6237","text":"\u5bf9\u4e8e\u7cfb\u7edf\u79df\u6237\uff0cMatrixOne \u5c06\u6309\u7167\u4ee5\u4e0b\u987a\u5e8f\u81ea\u52a8\u9009\u62e9\u5408\u9002\u7684 CN \u7ec4\u8fdb\u884c\u8fde\u63a5\uff1a
account
\u6807\u7b7e\u4e3a sys
\u7684 CN \u7ec4\u3002account
\u6807\u7b7e\u7684 CN \u7ec4\u3002\u6839\u636e\u8fd9\u4e00\u539f\u5219\uff0c\u7cfb\u7edf\u79df\u6237\u4f1a\u4f18\u5148\u9009\u62e9\u4e13\u4e3a\u81ea\u5df1\u4fdd\u7559\u6216\u672a\u88ab\u5176\u4ed6\u79df\u6237\u9884\u7559\u7684 CN \u7ec4\u3002\u7136\u800c\uff0c\u5982\u679c\u4ee5\u4e0a\u6761\u4ef6\u5747\u4e0d\u6ee1\u8db3\uff0c\u7cfb\u7edf\u79df\u6237\u53ef\u80fd\u4f1a\u4e0e\u5176\u4ed6\u79df\u6237\u5171\u4eab CN \u7ec4\uff0c\u4ece\u800c\u65e0\u6cd5\u786e\u4fdd\u7cfb\u7edf\u79df\u6237\u4e0e\u666e\u901a\u79df\u6237\u4e4b\u95f4\u7684\u8d1f\u8f7d\u9694\u79bb\u3002
"},{"location":"MatrixOne/Deploy/mgmt-cn-group-using-proxy/#_7","title":"\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb","text":"Proxy \u4ee3\u7406\u4f7f\u7528\u573a\u666f\u662f\u8d1f\u8f7d\u9694\u79bb\u3002\u5728\u8bb8\u591a\u6807\u51c6\u4e1a\u52a1\u73af\u5883\u4e2d\uff0c\u5982\u9ad8\u5e76\u53d1\u5199\u5165\u3001\u62a5\u8868\u751f\u6210\u3001\u5907\u4efd\u548c\u5927\u6570\u636e\u5bfc\u51fa\u7b49\uff0c\u4f20\u7edf\u6570\u636e\u5e93\u65b9\u6848\u901a\u5e38\u9700\u6c42\u90e8\u7f72\u7279\u5b9a\u7684\u5b9e\u4f8b\u4ee5\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb\u3002\u8fd9\u79cd\u65b9\u5f0f\u540c\u65f6\u8fd8\u4f1a\u5bfc\u81f4\u989d\u5916\u7684\u6570\u636e\u540c\u6b65\u8d1f\u62c5\u3002
MatrixOne \u5229\u7528 Proxy \u6765\u5b9e\u73b0\u8d44\u6e90\u7ec4\u7684\u5212\u5206\uff0c\u5b83\u80fd\u591f\u7075\u6d3b\u5730\u5c06 CN \u7ec4\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u8d1f\u8f7d\u6807\u7b7e\u7ed3\u5408\u3002\u5728\u8d1f\u8f7d\u53d8\u52a8\u7684\u60c5\u51b5\u4e0b\uff0cMatrixOne \u80fd\u591f\u901a\u8fc7\u8f6f\u4ef6\u914d\u7f6e\u8c03\u6574\u8d44\u6e90\u7ec4\u7684\u89c4\u6a21\uff0c\u4ece\u800c\u66f4\u597d\u5730\u9002\u5e94\u53d8\u5316\u3002
\u4ee5\u4e0a\u8ff0\u4e3a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u5c06\u4e24\u4e2a CN \u7684\u8d1f\u8f7d\u6807\u7b7e\u5206\u522b\u8bbe\u7f6e\u4e3a olap
\u548c oltp
\u3002\u7136\u540e\uff0c\u4f7f\u7528 SSB \u6a21\u62df OLTP \u8d1f\u8f7d\uff0c\u5e76\u4f7f\u7528 TPCH \u6a21\u62df OLAP \u8d1f\u8f7d\u3002
Note
\u5728\u8fdb\u884c\u6027\u80fd\u6d4b\u8bd5\u65f6\uff0c\u4f60\u9996\u5148\u9700\u8981\u5bf9\u6574\u4e2a\u96c6\u7fa4\u8fdb\u884c\u6269\u5c55\u3002
metadata:\n name: mo\n namespace: mo-hn\nspec:\n+ cnGroups:\n+ - name: cn-set1\n+ replicas: 1\n+ cnLabels:\n+ - key: \"workload\"\n+ # \u8d1f\u8f7d\u6807\u7b7e\u8bbe\u7f6e\u4e3a olap\n+ values: [\"olap\"]\n+\n+ - name: cn-set2\n+ replicas: 1\n+ cnLabels:\n+ - key: \"workload\"\n+ # \u8d1f\u8f7d\u6807\u7b7e\u8bbe\u7f6e\u4e3a oltp\n+ values: [\"oltp\"]\n
\u914d\u7f6e\u5b8c\u96c6\u7fa4\u7684\u8d1f\u8f7d\u4e4b\u540e\uff0c\u53ef\u4ee5\u8fde\u63a5\u5230\u96c6\u7fa4\u8fdb\u884c\u8d1f\u8f7d\u6d4b\u8bd5\uff1a
\u901a\u8fc7 JDBC \u8fde\u63a5\uff1a
\u5728 JDBC \u7684\u8fde\u63a5\u4e32\u4e2d\u6307\u5b9a connectionAttributes\uff0c\u5e76\u8bbe\u7f6e\u76f8\u5e94\u7684 key \u548c value\uff0ckey \u548c value \u4e4b\u95f4\u7528\u5192\u53f7 :
\u95f4\u9694\uff0c\u591a\u4e2a key-value \u4e4b\u95f4\u7528\u9017\u53f7 ,
\u95f4\u9694\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
jdbc:mysql://localhost:6001/test_db1?serverTimezone=UTC&connectionAttributes=workload:olap,another_key:test_value\n
\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u5b9e\u73b0\u8fde\u63a5\uff1a
\u901a\u8fc7\u6269\u5c55\u7528\u6237\u540d\uff08username\uff09\u5b57\u6bb5\uff0c\u5b9e\u73b0\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fdb\u884c\u8fde\u63a5\u3002\u5728\u7528\u6237\u540d\uff08username\uff09\u540e\u6dfb\u52a0 ?
\uff0c\u968f\u540e\u7684\u7f16\u5199\u65b9\u5f0f\u9075\u5faa JDBC \u4e2d\u7684 connectionAttributes \u683c\u5f0f\uff0c\u4e0e JDBC \u4e2d\u7684 connectionAttributes \u683c\u5f0f\u4e0d\u540c\u7684\u662f\uff0ckey \u548c value \u4e4b\u95f4\u7528 =
\u95f4\u9694\uff0c\u591a\u4e2a key-value \u4e4b\u95f4\u7528\u9017\u53f7 ,
\u95f4\u9694\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
mysql -h127.0.0.1 -uuser1?workload=olap,another_key=test_value -P6001 -pxxx\n
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u5982\u4f55\u6eda\u52a8\u5347\u7ea7\u6216\u8005\u91cd\u88c5\u5347\u7ea7 MatrixOne \u96c6\u7fa4\u3002
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u5230\u7684\u5347\u7ea7\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#_2","title":"\u6eda\u52a8\u5347\u7ea7","text":"\u6eda\u52a8\u5347\u7ea7\uff0c\u662f\u4e00\u79cd\u5728\u7ebf\u5347\u7ea7\u65b9\u5f0f\uff0c\u5373 MatrixOne \u96c6\u7fa4\u5728\u4fdd\u8bc1\u90e8\u5206\u6216\u5168\u90e8\u670d\u52a1\u53ef\u7528\u7684\u60c5\u51b5\u4e0b\u5b8c\u6210\u8f6f\u4ef6\u7684\u5347\u7ea7\u3002
MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u4e2d\u4ecb\u7ecd\uff0c\u5b89\u88c5 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u57fa\u4e8e Kubernetes \u548c MatrixOne Operator\uff0c\u56e0\u6b64\u6eda\u52a8\u5347\u7ea7 MatrixOne \u5c31\u662f\u901a\u8fc7\u52a8\u6001\u4fee\u6539 MatrixOne Operator \u4e2d\u7684 MatrixOne \u955c\u50cf\u7248\u672c\u53f7\u6765\u5b9e\u73b0\u81ea\u52a8\u7684\u7248\u672c\u66f4\u65b0\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#_3","title":"\u64cd\u4f5c\u6b65\u9aa4","text":"\u5728 master0 \u8282\u70b9\u7684\u7ec8\u7aef\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fdb\u5165\u52a8\u6001\u4fee\u6539 operator \u4f7f\u7528\u7684 yaml
\u914d\u7f6e\u6587\u4ef6\u7684\u754c\u9762\u3002
mo_ns=\"mo-hn\" #matrixone \u96c6\u7fa4\u7684 namespace\nmo_cluster_name=\"mo\" # matrixone \u7684\u96c6\u7fa4\u540d\u79f0\uff0c\u4e00\u822c\u4e3a mo\uff0c\u6839\u636e\u90e8\u7f72\u65f6 matrixonecluster \u5bf9\u8c61\u7684 yaml \u6587\u4ef6\u4e2d\u7684 name \u6307\u5b9a\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7 kubectl get matrixonecluster -n${mo_ns}\u6765\u786e\u8ba4\n#mo-hn \u53ca mo \u5df2\u5728\u5b89\u88c5\u90e8\u7f72\u7684 mo.yaml \u6587\u4ef6\u4e2d\u8bbe\u7f6e\nkubectl edit matrixonecluster ${mo_cluster_name} -n${mo_ns}\n
\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\u540e\uff0c\u4fee\u6539 spec.version
\u7684\u503c\uff0c\u5176\u4e2d\uff1a
${TAG}\uff1a\u4e3a\u5bf9\u5e94 dockerhub \u4e0a Matrixone \u7684\u955c\u50cf tag\uff0c\u4f8b\u5982\uff1anightly-f0d52530
${REPO_URL}\uff1a\u662f Matrixone \u516c\u5f00\u955c\u50cf\u4ed3\u5e93\uff0c\u9ed8\u8ba4\u4e3a matrixorigin/matrixone\u3002\u5047\u5982\u76ee\u6807\u7248\u672c\u5728 MatrixOne \u7684\u516c\u5f00\u955c\u50cf\u4ed3\u5e93\u4e0d\u5b58\u5728\uff0c\u5219\u9700\u8981\u540c\u65f6\u4fee\u6539\u955c\u50cf\u4ed3\u5e93\u7684 URL \u4e3a\u5b9e\u9645\u7684\u4ed3\u5e93\uff1a
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u6309 :wq
\u4fdd\u5b58\u5373\u53ef\uff0cMatrixOne Operator \u4f1a\u81ea\u52a8\u62c9\u53d6\u65b0\u7248\u672c\u7684\u955c\u50cf\uff0c\u5e76\u91cd\u542f\u7ec4\u4ef6\u670d\u52a1\uff0c\u5305\u62ec Log Service\uff0cTN \u548c CN\uff0c\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u89c2\u5bdf\u5176\u8fd0\u884c\u72b6\u6001\u3002
watch -e \"kubectl get pod -n${mo_ns}\"\n
NAME READY STATUS RESTARTS AGE\nmatrixone-operator-f8496ff5c-fp6zm 1/1 Running 0 24h\nmo-tn-0 1/1 Running 1 (51s ago) 18h\nmo-log-0 1/1 Running 0 18h\nmo-log-1 1/1 Running 1 (5s ago) 18h\nmo-log-2 1/1 Running 1 (53s ago) 18h\nmo-tp-cn-0 1/1 Running 1 (53s ago) 18h\n
\u5982\u679c\u53d1\u751f error\u3001crashbackoff \u7b49\u60c5\u51b5\uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u7ec4\u4ef6\u7684\u65e5\u5fd7\u6765\u8fdb\u4e00\u6b65\u6392\u67e5\u95ee\u9898\u3002
# pod_name \u662f pod \u7684\u540d\u79f0\uff0c\u5982 mo-tn-0,mo-tp-cn-0\npod_name=mo-tn-0\nkubectl logs ${pod_name} -nmo-hn > /tmp/tn.log\nvim /tmp/tn.log\n
\u5f53 MatrixOne \u96c6\u7fa4\u4e2d\u7684\u7ec4\u4ef6\u5747 Restart
\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u7528 MySQL Client \u8fde\u63a5\u96c6\u7fa4\uff0c\u5982\u679c\u8fde\u63a5\u6210\u529f\u4e14\u7528\u6237\u6570\u636e\u5747\u5b8c\u6574\uff0c\u5219\u8bf4\u660e\u5347\u7ea7\u6210\u529f\u3002
# \u4f7f\u7528 'mysql' \u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230 MySQL \u670d\u52a1\n# \u4f7f\u7528 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' \u83b7\u53d6 Kubernetes \u96c6\u7fa4\u4e2d\u670d\u52a1\u7684\u96c6\u7fa4 IP \u5730\u5740\n# '-h' \u53c2\u6570\u6307\u5b9a\u4e86 MySQL \u670d\u52a1\u7684\u4e3b\u673a\u540d\u6216 IP \u5730\u5740\n# '-P' \u53c2\u6570\u6307\u5b9a\u4e86 MySQL \u670d\u52a1\u7684\u7aef\u53e3\u53f7\uff0c\u8fd9\u91cc\u662f 6001\n# '-uroot' \u8868\u793a\u7528 root \u7528\u6237\u767b\u5f55\n# '-p111' \u8868\u793a\u521d\u59cb\u5bc6\u7801\u662f 111\nroot@master0 ~]# mysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nWelcome to the MariaDB monitor. Commands end with ; or \\g.\nYour MySQL connection id is 1005\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\nMySQL [(none)]> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| mo_task |\n| information_schema |\n| mysql |\n| system_metrics |\n| system |\n| test |\n| mo_catalog |\n+--------------------+\n7 rows in set (0.01 sec)\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u6eda\u52a8\u66f4\u65b0\u53ef\u80fd\u56e0\u4e3a\u9519\u8bef\u7684\u914d\u7f6e\u800c\u6682\u505c\uff08\u6bd4\u5982\u5728\u5347\u7ea7\u65f6\u6307\u5b9a\u4e86\u4e0d\u5b58\u5728\u7684\u7248\u672c\uff09\u3002\u6b64\u65f6\uff0c\u9700\u91cd\u65b0\u4fee\u6539 operator \u52a8\u6001\u914d\u7f6e\uff0c\u91cd\u7f6e version \u53f7\uff0c\u56de\u6eda\u53d8\u66f4\uff0c\u5df2\u7ecf\u5931\u8d25\u7684 Pod \u5c06\u88ab\u91cd\u65b0\u66f4\u65b0\u3002
\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u5f53\u524d MatrixOne \u90e8\u7f72\u7684\u7248\u672c\u53f7\uff1a
[root@master0 matrixone-operator]# kubectl get matrixoneclusters -n mo-hn -o yaml | grep version\n {\"apiVersion\":\"core.matrixorigin.io/v1alpha1\",\"kind\":\"MatrixOneCluster\",\"metadata\":{\"annotations\":{},\"name\":\"mo\",\"namespace\":\"mo-hn\"},\"spec\":{\"tn\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[dn.Txn.Storage]\\nbackend = \\\"TAE\\\"\\nlog-backend = \\\"logservice\\\"\\n[dn.Ckp]\\nflush-interval = \\\"60s\\\"\\nmin-count = 100\\nscan-interval = \\\"5s\\\"\\nincremental-interval = \\\"60s\\\"\\nglobal-interval = \\\"100000s\\\"\\n[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}}},\"imagePullPolicy\":\"IfNotPresent\",\"imageRepository\":\"matrixorigin/matrixone\",\"logService\":{\"config\":\"[log]\\nlevel = \\\"error\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"pvcRetentionPolicy\":\"Retain\",\"replicas\":3,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"1Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"sharedStorage\":{\"s3\":{\"endpoint\":\"http://minio.mostorage:9000\",\"path\":\"minio-mo\",\"secretRef\":{\"name\":\"minio\"},\"type\":\"minio\"}},\"volume\":{\"size\":\"1Gi\"}},\"tp\":{\"cacheVolume\":{\"size\":\"5Gi\",\"storageClassName\":\"local-path\"},\"config\":\"[cn.Engine]\\ntype = \\\"distributed-tae\\\"\\n[log]\\nlevel = \\\"debug\\\"\\nformat = \\\"json\\\"\\nmax-size = 512\\n\",\"nodePort\":31429,\"replicas\":1,\"resources\":{\"limits\":{\"cpu\":\"200m\",\"memory\":\"2Gi\"},\"requests\":{\"cpu\":\"100m\",\"memory\":\"500Mi\"}},\"serviceType\":\"NodePort\"},\"version\":\"nightly-54b5e8c\"}}\n version: nightly-54b5e8c\n
\u91cd\u88c5\u5347\u7ea7\uff0c\u610f\u5473\u7740 MatrixOne \u96c6\u7fa4\u88ab\u5168\u90e8\u5220\u9664\uff0c\u6570\u636e\u4f1a\u88ab\u820d\u5f03\uff0c\u5373\u91cd\u65b0\u8fdb\u884c\u5b89\u88c5\u3002
\u9002\u7528\u573a\u666f\uff1a
Note
\u64cd\u4f5c\u524d\uff0c\u8bf7\u52a1\u5fc5\u786e\u4fdd\u6570\u636e\u5df2\u5907\u4efd\uff08\u53c2\u89c1 mo-dump \u5907\u4efd\u5de5\u5177\uff09\uff0c\u4e14\u4e1a\u52a1\u5df2\u77e5\u6653\u6570\u636e\u5e93\u5df2\u505c\u6b62\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#_5","title":"\u64cd\u4f5c\u6b65\u9aa4","text":""},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#1","title":"1. \u5220\u9664\u65e7\u7248\u672c\u96c6\u7fa4","text":"\u5728 master0 \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4efb\u610f\u4e00\u79cd\u65b9\u5f0f\u5220\u9664\u65e7\u7248\u672c\u96c6\u7fa4\uff1a
# \u65b9\u5f0f1\uff1a\u901a\u8fc7\u90e8\u7f72\u65f6mo\u96c6\u7fa4\u7684yaml\u6587\u4ef6\u5220\u9664\uff0c\u4f8b\u5982\uff1a\nkubectl delete -f /root/deploy/mo.yaml\n# \u65b9\u5f0f2\uff1a\u901a\u8fc7\u5220\u9664matrixonecluster\u5bf9\u8c61\uff0c\u5176\u4e2dmo\u662f\u540d\u5b57\nkubectl delete matrixonecluster.core.matrixorigin.io mo -nmo-hn\n
\u901a\u8fc7\u67e5\u770b pod \u72b6\u6001\u786e\u8ba4 mo \u76f8\u5173\u8d44\u6e90\u662f\u5426\u5df2\u5220\u9664\uff1a
kubectl get pod -nmo-hn\n
\u53e6\u5916\uff0c\u5982\u679c\u8fd8\u6709 mo \u4f7f\u7528\u7684 pvc \u6ca1\u6709\u5220\u9664\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u624b\u52a8\u5220\u9664\uff1a
kubectl get pvc -nmo-hn\n# \u4f8b\u5982\uff0c\u8fd8\u6709log service\u4f7f\u7528\u7684pvc\u672a\u5220\u9664\uff0c\u624b\u52a8\u5220\u9664\nkubectl delete pvc mo-data-mo-log-0 -nmo-hn\nkubectl delete pvc mo-data-mo-log-1 -nmo-hn\nkubectl delete pvc mo-data-mo-log-2 -nmo-hn\n
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#2","title":"2. \u6e05\u7a7a\u6876\u6570\u636e","text":"\u5728 MinIO \u7ba1\u63a7\u9875\u9762\uff0c\u5220\u9664 MO \u4f7f\u7528\u7684 MinIO \u4f7f\u7528\u7684\u6876\u91cc\u9762\u7684\u6570\u636e\uff0c\u5305\u62ec mo-data\u3001etl \u7b49\u5b50\u76ee\u5f55\u3002
\u6216\u8005\u901a\u8fc7 MinIO \u5ba2\u6237\u7aef mc \u6765\u64cd\u4f5c\uff1a
mc rb --force minio/minio-mo/data/\nmc rb --force minio/minio-mo/etl\n
\u53e6\u5916\uff0c\u5982\u679c\u4e0d\u60f3\u5220\u9664\u65e7\u6570\u636e\uff0c\u4e5f\u53ef\u4ee5\u65b0\u5efa\u4e00\u4e2a MinIO \u7684\u6876\uff0c\u7136\u540e\u5728\u90e8\u7f72 MatrixOne \u96c6\u7fa4\u7684 yaml \u6587\u4ef6\u6307\u5b9a\u65b0\u7684\u6876\u540d\u5373\u53ef\u3002
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#3","title":"3. \u90e8\u7f72\u65b0\u7248\u672c\u96c6\u7fa4","text":"\u7f16\u8f91\u5b9a\u4e49 MO \u96c6\u7fa4\u7684 yaml \u6587\u4ef6\uff0c\u53c2\u8003\u6eda\u52a8\u5347\u7ea7\u7ae0\u8282\uff0c\u4fee\u6539 .spec.version
\u5b57\u6bb5\u4e3a\u6700\u65b0\u7248\u672c\uff0c\u91cd\u65b0\u90e8\u7f72 MatrixOne \u96c6\u7fa4\uff1a
vi mo.yaml\n# \u5185\u5bb9\u7701\u7565\nkubectl apply -f mo.yaml\n
"},{"location":"MatrixOne/Deploy/update-MatrixOne-cluster/#4","title":"4. \u68c0\u67e5\u5347\u7ea7\u662f\u5426\u6210\u529f","text":"\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5 MatrixOne \u662f\u5426\u6210\u529f\u542f\u52a8\u3002
\u5982\u4e0b\u9762\u4ee3\u7801\u793a\u4f8b\u6240\u793a\uff0c\u5f53 Log Service, TN, CN \u90fd\u6b63\u5e38\u8fd0\u884c\uff0c\u5219 MatrixOne \u96c6\u7fa4\u6210\u529f\u542f\u52a8\u3002\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7 MySQL Client \u8fde\u63a5\u68c0\u67e5\u6570\u636e\u5e93\u529f\u80fd\u662f\u5426\u6b63\u5e38\u3002
[root@master0 ~]# kubectl get pods -n mo-hn \nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-6c9c49fbd7-lw2h2 1/1 Running 2 (8h ago) 9h\nmo-tn-0 1/1 Running 0 2m13s\nmo-log-0 1/1 Running 0 2m47s\nmo-log-1 1/1 Running 0 2m47s\nmo-log-2 1/1 Running 0 2m47s\nmo-tp-cn-0 1/1 Running 0 111s\n
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/","title":"\u96c6\u7fa4\u90e8\u7f72\u6307\u5357","text":"\u672c\u7bc7\u6587\u6863\u5c06\u4e3b\u8981\u8bb2\u8ff0\u5982\u4f55\u5728\u5df2\u5b58\u5728 Kubernetes \u548c S3 \u73af\u5883\u7684\u57fa\u7840\u4e0a\u90e8\u7f72\u4e00\u4e2a MatrixOne \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_2","title":"\u8d44\u6e90\u9700\u6c42","text":""},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_3","title":"\u4f53\u9a8c\u73af\u5883","text":"MatrixOne \u96c6\u7fa4\u4f53\u9a8c\u73af\u5883\u53ef\u7528\u4e8e\u7b80\u5355\u4f53\u9a8c\u6d4b\u8bd5\u3001\u5b66\u4e60\u6216\u5f00\u53d1\uff0c\u4f46\u4e0d\u9002\u5408\u8fdb\u884c\u4e1a\u52a1\u751f\u4ea7\u3002\u4ee5\u4e0b\u4e3a\u4f53\u9a8c\u73af\u5883\u7684\u8d44\u6e90\u89c4\u5212\uff1a
\u5bb9\u5668\u8d44\u6e90\uff1a
\u7ec4\u4ef6 \u4f5c\u7528 \u670d\u52a1\u526f\u672c \u526f\u672c\u5206\u5e03\u7b56\u7565\u5efa\u8bae cpu(C) \u5185\u5b58 (G) \u5b58\u50a8\u8d44\u6e90\u7c7b\u578b \u5b58\u50a8\u5377\u683c\u5f0f \u5b58\u50a8\u5927\u5c0f (G) \u8bbf\u95ee\u6a21\u5f0f logservice \u9884\u5199\u65e5\u5fd7 WAL \u7ba1\u7406 3 3 \u4e2a\u8282\u70b9\uff0c\u6bcf\u8282\u70b9 1 \u526f\u672c 2 4 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce tn \u4e8b\u52a1\u7ba1\u7406 1 \u5355\u8282\u70b9\u5355\u526f\u672c 4 8 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce cn \u6570\u636e\u8ba1\u7b97 1 \u5355\u8282\u70b9\u5355\u526f\u672c 2 4 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce\u5bf9\u8c61\u5b58\u50a8\u8d44\u6e90 (S3)\uff1a
\u7ec4\u4ef6 \u63a5\u53e3\u534f\u8bae \u5b58\u50a8\u5927\u5c0f (G) \u4e1a\u52a1\u3001\u76d1\u63a7\u3001\u65e5\u5fd7\u7b49\u6570\u636e s3v4 >=50"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_4","title":"\u63a8\u8350\u73af\u5883","text":"MatrixOne \u96c6\u7fa4\u63a8\u8350\u73af\u5883\u5177\u5907\u9ad8\u53ef\u7528\u6027\u3001\u53ef\u9760\u6027\u548c\u5f3a\u5927\u7684\u6027\u80fd\uff0c\u53ef\u7528\u4e8e\u5b9e\u9645\u4e1a\u52a1\u751f\u4ea7\u3002\u4ee5\u4e0b\u4e3a\u63a8\u8350\u73af\u5883\u7684\u8d44\u6e90\u89c4\u5212\uff1a
\u5bb9\u5668\u8d44\u6e90\uff1a
\u7ec4\u4ef6 \u4f5c\u7528 \u670d\u52a1\u526f\u672c \u526f\u672c\u5206\u5e03\u7b56\u7565\u5efa\u8bae cpu(C) \u5185\u5b58 (G) \u5b58\u50a8\u8d44\u6e90\u7c7b\u578b \u5b58\u50a8\u5377\u683c\u5f0f \u5b58\u50a8\u5927\u5c0f (G) \u8bbf\u95ee\u6a21\u5f0f logservice \u9884\u5199\u65e5\u5fd7 WAL \u7ba1\u7406 3 3 \u4e2a\u8282\u70b9\uff0c\u6bcf\u8282\u70b9 1 \u526f\u672c 4 8 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce tn \u4e8b\u52a1\u7ba1\u7406 1 \u5355\u8282\u70b9\u5355\u526f\u672c 16 64 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce cn \u6570\u636e\u8ba1\u7b97 N N \u6839\u636e\u4e1a\u52a1\u9700\u6c42\u5b9a\uff0c\u9ad8\u53ef\u7528\u5efa\u8bae 2+ 16 32 PVC \u6587\u4ef6\u7cfb\u7edf 100 ReadWriteOnce\u5bf9\u8c61\u5b58\u50a8\u8d44\u6e90 (S3)\uff1a
\u7ec4\u4ef6 \u63a5\u53e3\u534f\u8bae \u5b58\u50a8\u5927\u5c0f (G) IOPS \u5e26\u5bbd \u4e1a\u52a1\u3001\u76d1\u63a7\u3001\u65e5\u5fd7\u7b49\u6570\u636e s3v4 \u6839\u636e\u4e1a\u52a1\u5b9a\uff0c\u5efa\u8bae>=500 \u987a\u5e8f\u8bfb\u5199\uff1a>=2000\uff0c\u975e\u987a\u5e8f\u8bfb\u5199\uff1a>=10000 >=10GB\u5982\u9700\u4e86\u89e3\u8d44\u6e90\u9700\u6c42\u7684\u66f4\u591a\u4fe1\u606f\u8bf7\u53c2\u8003\u96c6\u7fa4\u62d3\u6251\u89c4\u5212\u7ae0\u8282\u4e2d\u7684\u4f53\u9a8c\u73af\u5883\u548c\u63a8\u8350\u751f\u4ea7\u73af\u5883\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_5","title":"\u524d\u7f6e\u6761\u4ef6","text":"\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u7ecf\u51c6\u5907\u597d\u4ee5\u4e0b\u73af\u5883\uff1a
\u7b26\u5408\u8d44\u6e90\u9700\u6c42\u7684 Kubernetes \u96c6\u7fa4\u73af\u5883\u548c s3 \u73af\u5883
\u4e00\u53f0\u80fd\u8fde\u63a5 Kubernetes \u96c6\u7fa4\u7684\u5ba2\u6237\u7aef\u673a\u5668\u3002
\u5ba2\u6237\u7aef\u673a\u5668\u9700\u5b89\u88c5\u597d helm\u3001kubectl \u5ba2\u6237\u7aef\uff0c\u5e76\u914d\u7f6e\u8bbf\u95ee\u96c6\u7fa4\u7684 kubeconfig \u6587\u4ef6\uff0c\u6743\u9650\u662f\u80fd\u591f\u90e8\u7f72 helm chart \u5305\u548c\u5b89\u88c5 CRD \u8d44\u6e90\u5bf9\u8c61\u3002
\u5177\u5907\u5916\u7f51\u8bbf\u95ee\u6761\u4ef6\uff0c\u5982 github.io\u3001hub.docker.com \u7b49\uff1b\u5982\u679c\u65e0\u6cd5\u8bbf\u95ee\u5916\u7f51\uff0c\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a\u79c1\u6709\u955c\u50cf\u4ed3\u5e93\u7528\u4e8e\u4e0a\u4f20\u76f8\u5173\u955c\u50cf\uff0c\u5e76\u5728 mo \u96c6\u7fa4 yaml \u5b9a\u4e49\u4e2d\uff0c\u4fee\u6539\u955c\u50cf\u4ed3\u5e93\u5730\u5740\u4e3a\u79c1\u6709\u4ed3\u5e93\u5730\u5740\u3002
\u96c6\u7fa4\u8282\u70b9\u80fd\u8bbf\u95ee\u5230\u5bf9\u8c61\u5b58\u50a8\uff0c\u6bd4\u5982\u80fd\u89e3\u6790\u5bf9\u8c61\u5b58\u50a8\u6240\u5728\u57df\u540d\u3002
Note: \u4ee5\u4e0b\u64cd\u4f5c\u5982\u65e0\u8bf4\u660e\uff0c\u5747\u5728\u5ba2\u6237\u7aef\u673a\u5668\u6267\u884c\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#matrixone-operator","title":"\u90e8\u7f72 MatrixOne Operator","text":"MatrixOne Operator \u662f\u4e00\u4e2a\u5728 Kubernetes \u4e0a\u90e8\u7f72\u548c\u7ba1\u7406 MatrixOne \u96c6\u7fa4\u7684\u72ec\u7acb\u8f6f\u4ef6\u5de5\u5177\uff0c\u5b89\u88c5\u6b65\u9aa4\u5982\u4e0b\uff1a
\u4e3a Operator \u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684\u547d\u540d\u7a7a\u95f4 mo-op
NS=\"mo-op\"\nkubectl create ns \"${NS}\"\nkubectl get ns # \u8fd4\u56de\u6709 mo-op\n
\u4e0b\u8f7d\u5e76\u89e3\u538b matrixone-operator \u5b89\u88c5\u5305
wget https://github.com/matrixorigin/matrixone-operator/releases/download/chart-1.1.0-alpha2/matrixone-operator-1.1.0-alpha2.tgz\ntar xvf matrixone-operator-1.1.0-alpha2.tgz\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone-operator/releases/download/chart-1.1.0-alpha2/matrixone-operator-1.1.0-alpha2.tgz\n
\u89e3\u538b\u540e\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u751f\u4ea7\u6587\u4ef6\u5939 matrixone-operator
\u3002
\u90e8\u7f72 matrixone-operator
NS=\"mo-op\"\ncd matrixone-operator/\nhelm install -n ${NS} mo-op ./ --dependency-update # \u6210\u529f\u5e94\u8fd4\u56de deployed \u7684\u72b6\u6001\n
\u4e0a\u8ff0\u4f9d\u8d56\u7684 docker \u955c\u50cf\u6e05\u5355\u4e3a\uff1a
\u8be6\u60c5\u53ef\u67e5\u770b matrixone-operator/values.yaml\u3002
\u68c0\u67e5 operator \u90e8\u7f72\u72b6\u6001
NS=\"mo-op\"\nhelm list -n \"${NS}\" # \u8fd4\u56de\u6709\u5bf9\u5e94\u7684 helm chart \u5305\uff0c\u90e8\u7f72\u72b6\u6001\u4e3a deployed\nkubectl get pod -n \"${NS}\" -owide # \u8fd4\u56de\u6709\u4e00\u4e2a pod \u526f\u672c\uff0c\u72b6\u6001\u4e3a Running\n
\u5982\u9700\u4e86\u89e3\u6709\u5173 Matrixone Operator \u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u67e5\u770b Operator \u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#matrixone","title":"\u90e8\u7f72 MatrixOne","text":"\u672c\u8282\u4ecb\u7ecd\u4e86 YAML \u548c Chart \u4e24\u79cd\u90e8\u7f72 MatrixOne \u7684\u65b9\u5f0f\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#_6","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u521b\u5efa MatrixOne \u7684\u547d\u540d\u7a7a\u95f4 mo
\uff1a
NS=\"mo\"\nkubectl create ns \"${NS}\"\nkubectl get ns # \u8fd4\u56de\u6709 mo\n
Note
\u5efa\u8bae\u8fd9\u4e2a\u547d\u540d\u7a7a\u95f4\u4e0e MatrixOne Operator \u7684\u547d\u540d\u7a7a\u95f4\u5206\u5f00\uff0c\u4e0d\u8981\u4f7f\u7528\u540c\u4e00\u4e2a\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5728\u547d\u540d\u7a7a\u95f4 mo \u4e2d\u521b\u5efa\u7528\u4e8e\u8bbf\u95ee s3 \u7684 Secret \u670d\u52a1\uff1a
S3 \u5982\u679c\u901a\u8fc7 HTTP \u534f\u8bae\u8bbf\u95ee\uff0c\u4e0d\u9700\u8981\u63d0\u4f9b CA \u8bc1\u4e66
NS=\"mo\"\nname=\"s3mo\"\n\nkubectl -n \"${NS}\" create secret generic \"${name}\" --from-literal=AWS_ACCESS_KEY_ID=51e1bHqcbfKla0fuakAtoJ2LMEvKThg4NiMjxxxx --from-literal=AWS_SECRET_ACCESS_KEY=aDMWw1hO2rqxltyIcBN6sy8qE_leIgzo6Satxxxx\n#\u6839\u636e\u5b9e\u9645\u4fee\u6539\nkubectl get secret -n \"${NS}\" \"${name}\" -oyaml # \u6b63\u5e38\u8f93\u51fa\u5bc6\u94a5\u4fe1\u606f\n
S3 \u901a\u8fc7 HTTPS \u534f\u8bae\u8bbf\u95ee\u5219\u9700\u8981\u63d0\u4f9b CA \u8bc1\u4e66\uff0c\u5e76\u4e14\u5728\u5f00\u59cb\u524d\u8981\u5148\u6267\u884c\u76f8\u5173\u64cd\u4f5c\u548c\u914d\u7f6e\u76f8\u5173\u7684\u6587\u4ef6\uff0c\u6b65\u9aa4\u5982\u4e0b\uff1a
NS=mo\nca_file_path=\"/data/deploy/csp_cert/ca.crt\" # \u8bc1\u4e66\u5728\u5bc6\u94a5\u4e2d\u5b9a\u4e49\u7684\u6587\u4ef6\u8def\u5f84\nca_file_name=\"csp.cert\" # \u8bc1\u4e66\u5728\u5bc6\u94a5\u4e2d\u5b9a\u4e49\u7684\u6587\u4ef6\u540d\u79f0\nca_secret_name=\"csp.cert\" # \u8bc1\u4e66\u5bc6\u94a5\u672c\u8eab\u7684\u540d\u79f0\n# \u521b\u5efa\u5bc6\u94a5\nkubectl -n ${ns} create secret generic ${ca_secret_name} --from-file=${ca_file_name}=${ca_file_path}\n
sharedStorage:\n s3:\n endpoint: xx.yy.com\n path: mypath\n # secretRef is required when there is no environment based auth available.\n secretRef:\n # secretRef.name \u5bf9\u5e94 ca_secret_name\n name: csp\n certificateRef:\n # certificateRef.name \u5bf9\u5e94${ca_file_name}\n name: csp.cert\n files:\n # certificateRef.files \u6570\u7ec4\u4e0b\u9762\u7684\u503c\u5bf9\u5e94${ca_file_path}\n - csp.cert\n
\u7ed9\u673a\u5668\u6dfb\u52a0\u6807\u7b7e
\u4ee5\u4e0b\u6807\u7b7e\u662f\u90e8\u7f72\u524d\u9700\u8981\u6253\u5230\u8282\u70b9\u4e0a\u7684\uff0c\u5426\u5219\u4f1a\u8c03\u5ea6\u5931\u8d25\u3002\u4e0b\u8ff0\u6807\u7b7e\u539f\u5219\u4e0a\u5efa\u8bae\u662f\u627e\u4e0d\u540c\u7684\u8282\u70b9\u6253\uff0c\u4e14\u6839\u636e\u526f\u672c\u9700\u8981\u6253\u591a\u4e2a\u8282\u70b9\uff0c\u5982\u65e0\u6cd5\u6ee1\u8db3\u4e5f\u81f3\u5c11\u9700\u8981\u628a\u4e0b\u8ff0\u6807\u7b7e\u6253\u5230 1 \u4e2a\u8282\u70b9\u4e0a\u3002\uff08\u5efa\u8bae 7 \u4e2a\u4e0d\u540c\u8282\u70b9\uff09
matrixone/cn: true\nmatrixone/tn: true\nmatrixone/lg: true\n
\u7b2c\u4e00\u7ec4\uff1a\u627e\u4e09\u53f0\u4e0d\u540c\u7684\u673a\u5668\uff0c\u5206\u522b\u6253\u4e0a cn \u7684\u6807\u7b7e\u3002
NODE_1=\"10.0.0.1\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_2=\"10.0.0.2\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_3=\"10.0.0.3\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\n\nkubectl label node ${NODE_1} matrixone/cn: true\nkubectl label node ${NODE_2} matrixone/cn: true\nkubectl label node ${NODE_3} matrixone/cn: true\n
\u7b2c\u4e8c\u7ec4\uff1a\u627e\u7b2c 4 \u53f0\u4e0d\u540c\u7684\u673a\u5668\uff0c\u5206\u522b\u6253\u4e0a tn \u7684\u6807\u7b7e\u3002
NODE_4=\"10.0.0.4\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\n\nkubectl label node ${NODE_4} matrixone/tn: true\n
\u7b2c\u4e09\u7ec4\uff1a\u627e\u4e09\u53f0\u4e0d\u540c\u7684\u673a\u5668\uff0c\u5206\u522b\u6253\u4e0a log \u7684\u6807\u7b7e\u3002
NODE_5=\"10.0.0.5\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_6=\"10.0.0.6\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\nNODE_7=\"10.0.0.7\" # \u66f4\u6362\u4e3a\u5b9e\u9645\u7684 IP\n\nkubectl label node ${NODE_5} matrixone/lg: true\nkubectl label node ${NODE_6} matrixone/lg: true\nkubectl label node ${NODE_7} matrixone/lg: true\n
\u81ea\u5b9a\u4e49 MatrixOne \u96c6\u7fa4\u7684 yaml \u6587\u4ef6\uff0c\u7f16\u5199\u5982\u4e0b mo.yaml \u7684\u6587\u4ef6\uff08\u6309\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u8d44\u6e90\u8bf7\u6c42\uff09\uff1a
apiVersion: core.matrixorigin.io/v1alpha1\nkind: MatrixOneCluster\nmetadata:\n name: mo\n namespace: mo\n\nspec:\n # 1. \u914d\u7f6e cn\n cnGroups:\n - cacheVolume:\n size: 800Gi\n config: |2\n [log]\n level = \"info\"\n name: cng1\n nodeSelector:# \u6dfb\u52a0\u6807\u7b7e\uff0c\u6839\u636e\u5b9e\u9645\u6dfb\u52a0\n matrixone/cn: \"true\"\n serviceType: NodePort\n nodePort: 31429\n replicas: 3\n resources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\n overlay:\n env:\n - name: GOMEMLIMIT\n value: \"57600MiB\" \n # 2. \u914d\u7f6e tn\n tn:\n cacheVolume:\n size: 100Gi\n config: |2\n\n [log]\n level = \"info\"\n nodeSelector:\n matrixone/tn: \"true\"\n replicas: 1\n resources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\n # 3. \u914d\u7f6e logservice\n logService:\n config: |2\n [log]\n level = \"info\"\n nodeSelector: \n matrixone/lg: \"true\"\n pvcRetentionPolicy: Retain\n replicas: 3\n # \u914d\u7f6e logservice \u5bf9\u63a5\u7684 s3 \u5b58\u50a8\n sharedStorage:\n s3:\n endpoint: s3-qos.iot.qiniuec-test.com \n path: mo-test\n s3RetentionPolicy: Retain\n secretRef: #\u914d\u7f6e\u8bbf\u95ee s3 \u7684\u5bc6\u94a5\u5373 secret\uff0c\u540d\u79f0\u4e3a s3mo\n name: s3mo\n volume:\n size: 100Gi \n resources:\n requests:\n cpu: 4000m\n memory: 16000Mi\n limits:\n cpu: 4000m\n memory: 16000Mi\n topologySpread:\n - kubernetes.io/hostname\n imagePullPolicy: IfNotPresent\n imageRepository: registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone\n version: 1.1.1 #\u6b64\u5904\u4e3a MO \u955c\u50cf\u7684\u7248\u672c\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u521b\u5efa MatrixOne \u96c6\u7fa4
kubectl apply -f ./mo.yaml\n
\u5411 helm \u6dfb\u52a0\u4e00\u4e2a matrixone-operator \u4ed3\u5e93
helm repo add matrixone-operator https://matrixorigin.github.io/matrixone-operator\n
\u66f4\u65b0\u4ed3\u5e93
helm repo update\n
\u67e5\u770b MatrixOne Chart \u7248\u672c
helm search repo matrixone-operator/matrixone --devel\n
\u793a\u4f8b\u8fd4\u56de
> helm search repo matrixone-operator/matrixone --devel\nNAME CHART VERSION APP VERSION DESCRIPTION\nmatrixone-operator/matrixone 0.1.0 1.16.0 A Helm chart to deploy MatrixOne on K8S\nmatrixone-operator/matrixone-operator 1.1.0-alpha2 0.1.0 Matrixone Kubernetes Operator\nhelm search repo matrixone-operator/matrixone --devel\n
\u90e8\u7f72 MatrixOne
\u4fee\u6539 values.yaml \u6587\u4ef6\uff0c\u6e05\u7a7a\u539f\u6587\u4ef6\uff0c\u66ff\u6362\u4e3a\u4ee5\u4e0b\u5185\u5bb9\uff08\u6309\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u8d44\u6e90\u8bf7\u6c42\uff09\uff1a
# 1. \u914d\u7f6e cn\ncnGroups:\n- cacheVolume:\n size: 800Gi\nconfig: |2\n [log]\n level = \"info\"\nname: cng1\nnodeSelector:\n matrixone/cn: \"true\"\nserviceType: NodePort\nnodePort: 31429\nreplicas: 3 # cn \u7684\u526f\u672c\u6570\nresources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\noverlay:\n env:\n - name: GOMEMLIMIT\n value: \"57600MiB\" \n# 2. \u914d\u7f6e tn\ntn:\ncacheVolume:\n size: 100Gi\nconfig: |2\n\n [log]\n level = \"info\"\nnodeSelector:\n matrixone/tn: \"true\"\nreplicas: 1 # tn \u7684\u526f\u672c\u6570\uff0c\u4e0d\u53ef\u4fee\u6539\u3002\u5f53\u524d\u7248\u672c\u4ec5\u652f\u6301\u8bbe\u7f6e\u4e3a 1\u3002\nresources:\n requests:\n cpu: 16000m\n memory: 64000Mi\n limits:\n cpu: 16000m\n memory: 64000Mi\n# 3. \u914d\u7f6e logService\nlogService:\nconfig: |2\n [log]\n level = \"info\"\nnodeSelector: \n matrixone/lg: \"true\"\npvcRetentionPolicy: Retain\nreplicas: 3 # logService \u7684\u526f\u672c\u6570\n#\u914d\u7f6e logService \u5bf9\u63a5\u7684 s3 \u5b58\u50a8\nsharedStorage:\n s3:\n endpoint: s3-qos.iot.qiniuec-test.com \n path: mo-test\n s3RetentionPolicy: Retain\n secretRef: #\u914d\u7f6e\u8bbf\u95ee s3 \u7684\u5bc6\u94a5\u5373 secret\uff0c\u540d\u79f0\u4e3a s3mo\n name: s3mo\nvolume:\n size: 100Gi\nresources:\n requests:\n cpu: 4000m\n memory: 16000Mi\n limits:\n cpu: 4000m\n memory: 16000Mi\ntopologySpread:\n- kubernetes.io/hostname\nimagePullPolicy: IfNotPresent\nimageRepository: registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone\nversion: 1.1.1 #\u6b64\u5904\u4e3a MO \u955c\u50cf\u7684\u7248\u672c\n
\u5b89\u88c5 MatrixOne Chart\uff08\u8fd9\u4f1a\u90e8\u7f72\u4e00\u4e2a MatrixOneCluster \u5bf9\u8c61\uff09
NS=\"mo\"\nRELEASE_NAME=\"mo_chart\"\nVERSION=v1\nhelm install -n ${NS} ${RELEASE_NAME} matrixone-operator/matrixone --version ${VERSION} -f values.yaml\n
\u89c2\u5bdf\u96c6\u7fa4\u72b6\u6001\uff0c\u76f4\u81f3 Ready
NS=\"mo\"\nkubectl get mo -n \"${NS}\" # \u7b49\u5f85\u72b6\u6001\u4e3a Ready\n
\u89c2\u5bdf pod \u72b6\u6001\uff0c\u76f4\u81f3\u6240\u6709\u4e3a Running
NS=\"mo\"\nkubectl get pod -n \"${NS}\" -owide # \u7b49\u5f85\u72b6\u6001\u4e3a Running\n
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-with-k8/#matrixone_1","title":"\u8fde\u63a5 MatrixOne \u96c6\u7fa4","text":"\u4e3a\u4e86\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u60a8\u9700\u8981\u5c06\u5bf9\u5e94\u670d\u52a1\u7684\u7aef\u53e3\u6620\u5c04\u5230 MatrixOne \u8282\u70b9\u4e0a\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 kubectl port-forward
\u8fde\u63a5 MatrixOne \u96c6\u7fa4\u7684\u6307\u5bfc\uff1a
nohup kubectl port-forward -nmo svc/svc_name 6001:6001 &\n
nohup kubectl port-forward -nmo --address 0.0.0.0 svc/svc_name 6001:6001 &\n
\u5728\u6307\u5b9a\u5141\u8bb8\u672c\u5730\u8bbf\u95ee\u6216\u6307\u5b9a\u67d0\u53f0\u673a\u5668\u6216\u8005\u6240\u6709\u673a\u5668\u8bbf\u95ee\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff1a
# \u4f7f\u7528 'mysql' \u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230MySQL\u670d\u52a1\n# \u4f7f\u7528 'kubectl get svc/svc_name -n mo -o jsonpath='{.spec.clusterIP}' ' \u83b7\u53d6Kubernetes\u96c6\u7fa4\u4e2d\u670d\u52a1\u7684\u96c6\u7fa4IP\u5730\u5740\n# '-h' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u4e3b\u673a\u540d\u6216IP\u5730\u5740\n# '-P' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u7aef\u53e3\u53f7\uff0c\u8fd9\u91cc\u662f6001\n# '-uroot' \u8868\u793a\u7528root\u7528\u6237\u767b\u5f55\n# '-p111' \u8868\u793a\u521d\u59cb\u5bc6\u7801\u662f111\nmysql -h $(kubectl get svc/svc_name -n mo -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 163\nServer version: 8.0.30-MatrixOne-v1.1.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
\u663e\u5f0f mysql>
\u540e\uff0c\u5206\u5e03\u5f0f\u7684 MatrixOne \u96c6\u7fa4\u642d\u5efa\u8fde\u63a5\u5b8c\u6210\u3002
Info
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/","title":"\u96c6\u7fa4\u90e8\u7f72\u6307\u5357","text":"\u672c\u7bc7\u6587\u6863\u5c06\u4e3b\u8981\u8bb2\u8ff0\u5982\u4f55\u4ece 0 \u5f00\u59cb\u90e8\u7f72\u4e00\u4e2a\u57fa\u4e8e\u79c1\u6709\u5316 Kubernetes \u96c6\u7fa4\u7684\u4e91\u539f\u751f\u5b58\u7b97\u5206\u79bb\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93 MatrixOne\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_2","title":"\u4e3b\u8981\u6b65\u9aa4","text":"\u7531\u4e8e\u8be5\u6587\u6863\u4f1a\u6d89\u53ca\u5230\u4f17\u591a Kubernetes \u76f8\u5173\u7684\u540d\u8bcd\uff0c\u4e3a\u4e86\u8ba9\u5927\u5bb6\u80fd\u591f\u7406\u89e3\u642d\u5efa\u6d41\u7a0b\uff0c\u8fd9\u91cc\u5bf9\u6d89\u53ca\u5230\u7684\u91cd\u8981\u540d\u8bcd\u8fdb\u884c\u7b80\u5355\u89e3\u91ca\uff0c\u5982\u679c\u9700\u8981\u8be6\u7ec6\u4e86\u89e3 Kubernetes \u76f8\u5173\u7684\u5185\u5bb9\uff0c\u53ef\u4ee5\u76f4\u63a5\u53c2\u8003 Kubernetes \u4e2d\u6587\u793e\u533a | \u4e2d\u6587\u6587\u6863
Pod \u662f Kubernetes \u4e2d\u6700\u5c0f\u7684\u8d44\u6e90\u7ba1\u7406\u7ec4\u4ef6\uff0cPod \u4e5f\u662f\u6700\u5c0f\u5316\u8fd0\u884c\u5bb9\u5668\u5316\u5e94\u7528\u7684\u8d44\u6e90\u5bf9\u8c61\u3002\u4e00\u4e2a Pod \u4ee3\u8868\u7740\u96c6\u7fa4\u4e2d\u8fd0\u884c\u7684\u4e00\u4e2a\u8fdb\u7a0b\u3002\u7b80\u5355\u7406\u89e3\uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u4e00\u7ec4\u63d0\u4f9b\u7279\u5b9a\u529f\u80fd\u7684\u5e94\u7528\u79f0\u4e3a\u4e00\u4e2a pod\uff0c\u5b83\u4f1a\u5305\u542b\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5bb9\u5668\u5bf9\u8c61\uff0c\u5171\u540c\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002
Storage Class\uff0c\u7b80\u79f0 SC\uff0c\u7528\u4e8e\u6807\u8bb0\u5b58\u50a8\u8d44\u6e90\u7684\u7279\u6027\u548c\u6027\u80fd\uff0c\u7ba1\u7406\u5458\u53ef\u4ee5\u5c06\u5b58\u50a8\u8d44\u6e90\u5b9a\u4e49\u4e3a\u67d0\u79cd\u7c7b\u522b\uff0c\u6b63\u5982\u5b58\u50a8\u8bbe\u5907\u5bf9\u4e8e\u81ea\u8eab\u7684\u914d\u7f6e\u63cf\u8ff0\uff08Profile\uff09\u3002\u6839\u636e SC \u7684\u63cf\u8ff0\u53ef\u4ee5\u76f4\u89c2\u7684\u5f97\u77e5\u5404\u79cd\u5b58\u50a8\u8d44\u6e90\u7684\u7279\u6027\uff0c\u5c31\u53ef\u4ee5\u6839\u636e\u5e94\u7528\u5bf9\u5b58\u50a8\u8d44\u6e90\u7684\u9700\u6c42\u53bb\u7533\u8bf7\u5b58\u50a8\u8d44\u6e90\u4e86\u3002
Kubernetes \u63d0\u4f9b\u4e86 CSI \u63a5\u53e3\uff08Container Storage Interface\uff0c\u5bb9\u5668\u5b58\u50a8\u63a5\u53e3\uff09\uff0c\u57fa\u4e8e CSI \u8fd9\u5957\u63a5\u53e3\uff0c\u53ef\u4ee5\u5f00\u53d1\u5b9a\u5236\u51fa CSI \u63d2\u4ef6\uff0c\u4ece\u800c\u652f\u6301\u7279\u5b9a\u7684\u5b58\u50a8\uff0c\u8fbe\u5230\u89e3\u8026\u7684\u76ee\u7684\u3002
PersistentVolume\uff0c\u7b80\u79f0 PV\uff0cPV \u4f5c\u4e3a\u5b58\u50a8\u8d44\u6e90\uff0c\u4e3b\u8981\u5305\u62ec\u5b58\u50a8\u80fd\u529b\u3001\u8bbf\u95ee\u6a21\u5f0f\u3001\u5b58\u50a8\u7c7b\u578b\u3001\u56de\u6536\u7b56\u7565\u3001\u540e\u7aef\u5b58\u50a8\u7c7b\u578b\u7b49\u5173\u952e\u4fe1\u606f\u7684\u8bbe\u7f6e\u3002
PersistentVolumeClaim\uff0c\u7b80\u79f0 PVC\uff0c\u4f5c\u4e3a\u7528\u6237\u5bf9\u5b58\u50a8\u8d44\u6e90\u7684\u9700\u6c42\u7533\u8bf7\uff0c\u4e3b\u8981\u5305\u62ec\u5b58\u50a8\u7a7a\u95f4\u8bf7\u6c42\u3001\u8bbf\u95ee\u6a21\u5f0f\u3001PV \u9009\u62e9\u6761\u4ef6\u548c\u5b58\u50a8\u7c7b\u522b\u7b49\u4fe1\u606f\u7684\u8bbe\u7f6e\u3002
\u4e5f\u53eb\u505a SVC\uff0c\u901a\u8fc7\u6807\u7b7e\u9009\u62e9\u7684\u65b9\u5f0f\u5339\u914d\u4e00\u7ec4 Pod \u5bf9\u5916\u8bbf\u95ee\u670d\u52a1\u7684\u4e00\u79cd\u673a\u5236\uff0c\u6bcf\u4e00\u4e2a svc \u53ef\u4ee5\u7406\u89e3\u4e3a\u4e00\u4e2a\u5fae\u670d\u52a1\u3002
Kubernetes Operator \u662f\u4e00\u79cd\u5c01\u88c5\u3001\u90e8\u7f72\u548c\u7ba1\u7406 Kubernetes \u5e94\u7528\u7684\u65b9\u6cd5\u3002\u6211\u4eec\u4f7f\u7528 Kubernetes API\uff08\u5e94\u7528\u7f16\u7a0b\u63a5\u53e3\uff09\u548c kubectl \u5de5\u5177\u5728 Kubernetes \u4e0a\u90e8\u7f72\u5e76\u7ba1\u7406 Kubernetes \u5e94\u7528\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_4","title":"\u90e8\u7f72\u67b6\u6784","text":""},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_5","title":"\u4f9d\u8d56\u7ec4\u4ef6","text":"MatrixOne \u5206\u5e03\u5f0f\u7cfb\u7edf\u4f9d\u8d56\u4e8e\u4ee5\u4e0b\u7ec4\u4ef6\uff1a
Kubernetes\uff1a\u4f5c\u4e3a\u6574\u4e2a MatrixOne \u96c6\u7fa4\u7684\u8d44\u6e90\u7ba1\u7406\u5e73\u53f0\uff0c\u5305\u62ec Logservice\u3001CN\u3001TN \u7b49\u7ec4\u4ef6\uff0c\u90fd\u5728\u7531 Kubernetes \u7ba1\u7406\u7684 Pod \u4e2d\u8fd0\u884c\u3002\u5982\u679c\u53d1\u751f\u6545\u969c\uff0cKubernetes \u5c06\u8d1f\u8d23\u5254\u9664\u6545\u969c\u7684 Pod \u5e76\u542f\u52a8\u65b0\u7684 Pod \u8fdb\u884c\u66ff\u6362\u3002
Minio\uff1a\u4e3a\u6574\u4e2a MatrixOne \u96c6\u7fa4\u63d0\u4f9b\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff0cMatrixOne \u7684\u6240\u6709\u6570\u636e\u5b58\u50a8\u5728\u7531 Minio \u63d0\u4f9b\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002
\u6b64\u5916\uff0c\u4e3a\u4e86\u5728 Kubernetes \u4e0a\u8fdb\u884c\u5bb9\u5668\u7ba1\u7406\u548c\u7f16\u6392\uff0c\u6211\u4eec\u9700\u8981\u4ee5\u4e0b\u63d2\u4ef6\uff1a
Helm\uff1aHelm \u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406 Kubernetes \u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u7c7b\u4f3c\u4e8e Ubuntu \u7684 APT \u548c CentOS \u7684 YUM\u3002\u5b83\u7528\u4e8e\u7ba1\u7406\u9884\u5148\u914d\u7f6e\u7684\u5b89\u88c5\u5305\u8d44\u6e90\uff0c\u79f0\u4e3a Chart\u3002
local-path-provisioner\uff1a\u4f5c\u4e3a Kubernetes \u4e2d\u5b9e\u73b0\u4e86 CSI\uff08Container Storage Interface\uff09\u63a5\u53e3\u7684\u63d2\u4ef6\uff0clocal-path-provisioner \u8d1f\u8d23\u4e3a MatrixOne \u5404\u7ec4\u4ef6\u7684 Pod \u548c Minio \u521b\u5efa\u6301\u4e45\u5316\u5377\uff08PV\uff09\uff0c\u4ee5\u4fbf\u5b9e\u73b0\u6570\u636e\u7684\u6301\u4e45\u5316\u5b58\u50a8\u3002
\u6574\u4f53\u7684\u90e8\u7f72\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6574\u4f53\u67b6\u6784\u7531\u4ee5\u4e0b\u7ec4\u4ef6\u7ec4\u6210\uff1a
\u5e95\u5c42\u662f\u4e09\u4e2a\u670d\u52a1\u5668\u8282\u70b9\uff1a\u7b2c\u4e00\u53f0\u4f5c\u4e3a\u5b89\u88c5 Kubernetes \u8df3\u677f\u673a\u7684 host1\uff0c\u7b2c\u4e8c\u53f0\u662f Kubernetes \u7684\u4e3b\u8282\u70b9\uff08master\uff09\uff0c\u7b2c\u4e09\u53f0\u662f Kubernetes \u7684\u5de5\u4f5c\u8282\u70b9\uff08node\uff09\u3002
\u4e0a\u5c42\u662f\u5df2\u5b89\u88c5\u7684 Kubernetes \u548c Docker \u73af\u5883\uff0c\u6784\u6210\u4e91\u539f\u751f\u5e73\u53f0\u5c42\u3002
\u57fa\u4e8e Helm \u8fdb\u884c\u7ba1\u7406\u7684 Kubernetes \u63d2\u4ef6\u5c42\uff0c\u5305\u62ec\u5b9e\u73b0 CSI \u63a5\u53e3\u7684 local-path-storage \u63d2\u4ef6\u3001Minio \u548c MatrixOne Operator\u3002
\u6700\u9876\u5c42\u662f\u7531\u8fd9\u4e9b\u7ec4\u4ef6\u914d\u7f6e\u751f\u6210\u7684\u591a\u4e2a Pod \u548c Service\u3002
MatrixOne \u6839\u636e Operator \u7684\u89c4\u5219\u521b\u5efa\u4e00\u7cfb\u5217\u7684 Kubernetes \u5bf9\u8c61\uff0c\u8fd9\u4e9b\u5bf9\u8c61\u6839\u636e\u7ec4\u4ef6\u5206\u7c7b\u5e76\u5f52\u7c7b\u5230\u8d44\u6e90\u7ec4\u4e2d\uff0c\u5206\u522b\u4e3a CNSet\u3001TNSet \u548c LogSet\u3002
Service\uff1a\u6bcf\u4e2a\u8d44\u6e90\u7ec4\u4e2d\u7684\u670d\u52a1\u9700\u8981\u901a\u8fc7 Service \u8fdb\u884c\u5bf9\u5916\u63d0\u4f9b\u3002Service \u627f\u8f7d\u4e86\u5bf9\u5916\u8fde\u63a5\u7684\u529f\u80fd\uff0c\u786e\u4fdd\u5728 Pod \u5d29\u6e83\u6216\u88ab\u66ff\u6362\u65f6\u4ecd\u80fd\u63d0\u4f9b\u670d\u52a1\u3002\u5916\u90e8\u5e94\u7528\u7a0b\u5e8f\u901a\u8fc7 Service \u7684\u516c\u5f00\u7aef\u53e3\u8fde\u63a5\uff0c\u800c Service \u5219\u901a\u8fc7\u5185\u90e8\u8f6c\u53d1\u89c4\u5219\u5c06\u8fde\u63a5\u8f6c\u53d1\u5230\u76f8\u5e94\u7684 Pod\u3002
Pod\uff1aMatrixOne \u7ec4\u4ef6\u7684\u5bb9\u5668\u5316\u5b9e\u4f8b\uff0c\u5176\u4e2d\u8fd0\u884c\u7740 MatrixOne \u7684\u6838\u5fc3\u5185\u6838\u4ee3\u7801\u3002
PVC\uff1a\u6bcf\u4e2a Pod \u90fd\u901a\u8fc7 PVC\uff08Persistent Volume Claim\uff09\u58f0\u660e\u81ea\u5df1\u6240\u9700\u7684\u5b58\u50a8\u8d44\u6e90\u3002\u5728\u6211\u4eec\u7684\u67b6\u6784\u4e2d\uff0cCN \u548c TN \u9700\u8981\u7533\u8bf7\u4e00\u5757\u5b58\u50a8\u8d44\u6e90\u4f5c\u4e3a\u7f13\u5b58\uff0c\u800c LogService \u5219\u9700\u8981\u76f8\u5e94\u7684 S3 \u8d44\u6e90\u3002\u8fd9\u4e9b\u9700\u6c42\u901a\u8fc7 PVC \u8fdb\u884c\u58f0\u660e\u3002
PV\uff1aPV\uff08Persistent Volume\uff09\u662f\u5b58\u50a8\u4ecb\u8d28\u7684\u62bd\u8c61\u8868\u793a\uff0c\u53ef\u4ee5\u770b\u4f5c\u662f\u5b58\u50a8\u5355\u5143\u3002\u5728 PVC \u7684\u7533\u8bf7\u540e\uff0c\u901a\u8fc7\u5b9e\u73b0 CSI \u63a5\u53e3\u7684\u8f6f\u4ef6\u521b\u5efa PV\uff0c\u5e76\u5c06\u5176\u4e0e\u7533\u8bf7\u8d44\u6e90\u7684 PVC \u8fdb\u884c\u7ed1\u5b9a\u3002
\u7531\u4e8e MatrixOne \u7684\u5206\u5e03\u5f0f\u90e8\u7f72\u4f9d\u8d56\u4e8e Kubernetes \u96c6\u7fa4\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u4e00\u4e2a Kubernetes \u96c6\u7fa4\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u4f7f\u7528 Kuboard-Spray \u7684\u65b9\u5f0f\u642d\u5efa\u4e00\u4e2a Kubernetes \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_7","title":"\u51c6\u5907\u96c6\u7fa4\u73af\u5883","text":"\u5bf9\u4e8e\u96c6\u7fa4\u73af\u5883\uff0c\u9700\u8981\u505a\u5982\u4e0b\u51c6\u5907\uff1a
\u5404\u4e2a\u673a\u5668\u60c5\u51b5\u5206\u5e03\u5177\u4f53\u5982\u4e0b\u6240\u793a\uff1a
Host \u5185\u7f51 IP \u5916\u7f51 IP mem CPU Disk Role kuboardspray 10.206.0.6 1.13.2.100 2G 2C 50G \u8df3\u677f\u673a master0 10.206.134.8 118.195.255.252 8G 2C 50G master etcd node0 10.206.134.14 1.13.13.199 8G 2C 50G worker"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kuboard-spray","title":"\u8df3\u677f\u673a\u90e8\u7f72 Kuboard Spray","text":"Kuboard-Spray \u662f\u7528\u6765\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u7684\u4e00\u4e2a\u5de5\u5177\u3002\u5b83\u4f1a\u4f7f\u7528 Docker \u5feb\u901f\u62c9\u8d77\u4e00\u4e2a\u80fd\u591f\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u7684 Web \u5e94\u7528\u3002Kubernetes \u96c6\u7fa4\u73af\u5883\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5c06\u8be5 Docker \u5e94\u7528\u505c\u6389\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_8","title":"\u8df3\u677f\u673a\u73af\u5883\u51c6\u5907","text":"\u5b89\u88c5 Docker\uff1a\u7531\u4e8e\u4f1a\u4f7f\u7528\u5230 Docker\uff0c\u56e0\u6b64\u9700\u8981\u5177\u5907 Docker \u7684\u73af\u5883\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728\u8df3\u677f\u673a\u5b89\u88c5\u5e76\u542f\u52a8 Docker\uff1a
curl -sSL https://get.docker.io/ | sh\n#\u5982\u679c\u5728\u56fd\u5185\u7684\u7f51\u7edc\u53d7\u9650\u73af\u5883\u4e0b\uff0c\u53ef\u4ee5\u6362\u4ee5\u4e0b\u56fd\u5185\u955c\u50cf\u5730\u5740\ncurl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun\n
\u542f\u52a8 Docker\uff1a
[root@VM-0-6-centos ~]# systemctl start docker\n[root@VM-0-6-centos ~]# systemctl status docker\n\u25cf docker.service - Docker Application Container Engine\n Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n Active: active (running) since Sun 2023-05-07 11:48:06 CST; 15s ago\n Docs: https://docs.docker.com\n Main PID: 5845 (dockerd)\n Tasks: 8\n Memory: 27.8M\n CGroup: /system.slice/docker.service\n \u2514\u25005845 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock\n\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Starting Docker Application Container Engine...\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.391166236+08:00\" level=info msg=\"Starting up\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.421736631+08:00\" level=info msg=\"Loading containers: start.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.531022702+08:00\" level=info msg=\"Loading containers: done.\"\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544715135+08:00\" level=info msg=\"Docker daemon\" commit=94d3ad6 graphdriver=overlay2 version=23.0.5\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.544798391+08:00\" level=info msg=\"Daemon has completed initialization\"\nMay 07 11:48:06 VM-0-6-centos systemd[1]: Started Docker Application Container Engine.\nMay 07 11:48:06 VM-0-6-centos dockerd[5845]: time=\"2023-05-07T11:48:06.569274215+08:00\" level=info msg=\"API listen on /run/docker.sock\"\n
\u73af\u5883\u51c6\u5907\u5b8c\u6210\u540e\uff0c\u5373\u53ef\u90e8\u7f72 Kuboard-Spray\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kuboard-spray_1","title":"\u90e8\u7f72 Kuboard-Spray","text":"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Kuboard-Spray\uff1a
docker run -d \\\n --privileged \\\n --restart=unless-stopped \\\n --name=kuboard-spray \\\n -p 80:80/tcp \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n -v ~/kuboard-spray-data:/data \\\n eipwork/kuboard-spray:latest-amd64\n
\u5982\u679c\u7531\u4e8e\u7f51\u7edc\u95ee\u9898\u5bfc\u81f4\u955c\u50cf\u62c9\u53d6\u5931\u8d25\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u5907\u7528\u5730\u5740\uff1a
docker run -d \\\n --privileged \\\n --restart=unless-stopped \\\n --name=kuboard-spray \\\n -p 80:80/tcp \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n -v ~/kuboard-spray-data:/data \\\n swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard-spray:latest-amd64\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u5373\u53ef\u5728\u6d4f\u89c8\u5668\u8f93\u5165 http://1.13.2.100
\uff08\u8df3\u677f\u673a IP \u5730\u5740\uff09\u6253\u5f00 Kuboard-Spray \u7684 Web \u754c\u9762\uff0c\u8f93\u5165\u7528\u6237\u540d admin
\uff0c\u9ed8\u8ba4\u5bc6\u7801 Kuboard123
\uff0c\u5373\u53ef\u767b\u5f55 Kuboard-Spray \u754c\u9762\uff0c\u5982\u4e0b\u6240\u793a\uff1a
\u767b\u5f55\u4e4b\u540e\uff0c\u5373\u53ef\u5f00\u59cb\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kubernetes","title":"\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4","text":"\u767b\u5f55 Kuboard-Spray \u754c\u9762\u4e4b\u540e\uff0c\u5373\u53ef\u5f00\u59cb\u53ef\u89c6\u5316\u90e8\u7f72 Kubernetes \u96c6\u7fa4\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#kubernetes_1","title":"\u5bfc\u5165 Kubernetes \u76f8\u5173\u8d44\u6e90\u5305","text":"\u5b89\u88c5\u754c\u9762\u4f1a\u901a\u8fc7\u5728\u7ebf\u4e0b\u8f7d\u7684\u65b9\u5f0f\uff0c\u4e0b\u8f7d Kubernetes \u96c6\u7fa4\u6240\u5bf9\u5e94\u7684\u8d44\u6e90\u5305\uff0c\u4ee5\u5b9e\u73b0\u79bb\u7ebf\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u3002
\u70b9\u51fb\u8d44\u6e90\u5305\u7ba1\u7406\uff0c\u9009\u62e9\u5bf9\u5e94\u7248\u672c\u7684 Kubernetes \u8d44\u6e90\u5305\u4e0b\u8f7d\uff1a
\u4e0b\u8f7d spray-v2.18.0b-2_k8s-v1.23.17_v1.24-amd64
\u7248\u672c
\u70b9\u51fb\u5bfc\u5165\u540e\uff0c\u9009\u62e9\u52a0\u8f7d\u8d44\u6e90\u5305\uff0c\u9009\u62e9\u5408\u9002\u7684\u4e0b\u8f7d\u6e90\uff0c\u7b49\u5f85\u8d44\u6e90\u5305\u4e0b\u8f7d\u5b8c\u6210\u3002
Note
\u63a8\u8350\u60a8\u9009\u62e9 Docker \u4f5c\u4e3a\u7528\u4e8e K8s \u96c6\u7fa4\u7684\u5bb9\u5668\u5f15\u64ce\u3002\u9009\u62e9 Docker \u4f5c\u4e3a K8s \u7684\u5bb9\u5668\u5f15\u64ce\u540e\uff0cKuboard-Spray \u4f1a\u81ea\u52a8\u4f7f\u7528 Docker \u6765\u8fd0\u884c K8s \u96c6\u7fa4\u7684\u5404\u4e2a\u7ec4\u4ef6\uff0c\u5305\u62ec Master \u8282\u70b9\u548c Worker \u8282\u70b9\u4e0a\u7684\u5bb9\u5668\u3002
\u6b64\u65f6\u4f1a pull
\u76f8\u5173\u7684\u955c\u50cf\u4f9d\u8d56\uff1a
\u955c\u50cf\u8d44\u6e90\u5305\u62c9\u53d6\u6210\u529f\u540e\uff0c\u8fd4\u56de Kuboard-Spray \u7684 Web \u754c\u9762\uff0c\u53ef\u4ee5\u770b\u5230\u5bf9\u5e94\u7248\u672c\u7684\u8d44\u6e90\u5305\u5df2\u7ecf\u5bfc\u5165\u5b8c\u6210\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u8fdb\u884c Kubernetes \u96c6\u7fa4\u7684\u5b89\u88c5\u3002
\u9009\u62e9\u96c6\u7fa4\u7ba1\u7406\uff0c\u9009\u62e9\u6dfb\u52a0\u96c6\u7fa4\u5b89\u88c5\u8ba1\u5212\uff1a
\u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\uff0c\u5b9a\u4e49\u96c6\u7fa4\u7684\u540d\u79f0\uff0c\u9009\u62e9\u521a\u521a\u5bfc\u5165\u7684\u8d44\u6e90\u5305\u7684\u7248\u672c\uff0c\u518d\u70b9\u51fb\u786e\u5b9a\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6309\u7167\u4e8b\u5148\u5b9a\u4e49\u597d\u7684\u89d2\u8272\u5206\u7c7b\uff0cKubernetes \u96c6\u7fa4\u91c7\u7528 1 master + 1 worker +1 etcd
\u7684\u6a21\u5f0f\u8fdb\u884c\u90e8\u7f72\u3002
\u5728\u4e0a\u4e00\u6b65\u5b9a\u4e49\u5b8c\u6210\u96c6\u7fa4\u540d\u79f0\uff0c\u5e76\u9009\u62e9\u5b8c\u6210\u8d44\u6e90\u5305\u7248\u672c\uff0c\u70b9\u51fb\u786e\u5b9a\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u53ef\u4ee5\u76f4\u63a5\u8fdb\u5165\u5230\u96c6\u7fa4\u89c4\u5212\u9636\u6bb5\u3002
\u9009\u62e9\u5bf9\u5e94\u8282\u70b9\u7684\u89d2\u8272\u548c\u540d\u79f0\uff1a
\u5728\u6bcf\u4e00\u4e2a\u8282\u70b9\u586b\u5199\u5b8c\u89d2\u8272\u548c\u8282\u70b9\u540d\u79f0\u540e\uff0c\u8bf7\u5728\u53f3\u4fa7\u586b\u5199\u5bf9\u5e94\u8282\u70b9\u7684\u8fde\u63a5\u4fe1\u606f\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u586b\u5199\u5b8c\u6240\u6709\u7684\u89d2\u8272\u4e4b\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u3002\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u51c6\u5907\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u4e86\u3002
\u5728\u4e0a\u4e00\u6b65\u586b\u5199\u5b8c\u6210\u6240\u6709\u89d2\u8272\uff0c\u5e76\u4fdd\u5b58\u540e\uff0c\u70b9\u51fb\u6267\u884c\uff0c\u5373\u53ef\u5f00\u59cb Kubernetes \u96c6\u7fa4\u7684\u5b89\u88c5\u3002
\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u70b9\u51fb\u786e\u5b9a\uff0c\u5f00\u59cb\u5b89\u88c5 Kubernetes \u96c6\u7fa4\uff1a
\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u65f6\uff0c\u4f1a\u5728\u5bf9\u5e94\u8282\u70b9\u4e0a\u6267\u884c ansible
\u811a\u672c\uff0c\u5b89\u88c5 Kubernetes \u96c6\u7fa4\u3002\u6574\u4f53\u4e8b\u4ef6\u4f1a\u6839\u636e\u673a\u5668\u914d\u7f6e\u548c\u7f51\u7edc\u4e0d\u540c\uff0c\u9700\u8981\u7b49\u5f85\u7684\u65f6\u95f4\u4e0d\u540c\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u9700\u8981 5 ~ 10 \u5206\u949f\u3002
Note: \u5982\u679c\u51fa\u73b0\u9519\u8bef\uff0c\u4f60\u53ef\u4ee5\u770b\u65e5\u5fd7\u7684\u5185\u5bb9\uff0c\u786e\u8ba4\u662f\u5426\u662f Kuboard-Spray \u7684\u7248\u672c\u4e0d\u5339\u914d\uff0c\u5982\u679c\u7248\u672c\u4e0d\u5339\u914d\uff0c\u8bf7\u66f4\u6362\u5408\u9002\u7684\u7248\u672c\u3002
\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5230 Kubernetes \u96c6\u7fa4\u7684 master \u8282\u70b9\u4e0a\u6267\u884c kubectl get node
\uff1a
[root@master0 ~]# kubectl get node\nNAME STATUS ROLES AGE VERSION\nmaster0 Ready control-plane,master 52m v1.23.17\nnode0 Ready <none> 52m v1.23.17\n
\u547d\u4ee4\u7ed3\u679c\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u5373\u8868\u793a Kubernetes \u96c6\u7fa4\u5b89\u88c5\u5b8c\u6210\u3002
\u5728 Kubernetes \u7684\u6bcf\u4e2a\u8282\u70b9\u4e0a\u8c03\u6574 DNS \u8def\u7531\u8868\u3002\u8bf7\u5728\u6bcf\u53f0\u673a\u5668\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u627e\u5305\u542b 169.254.25.10
\u7684 nameserver\uff0c\u5e76\u5220\u9664\u8be5\u8bb0\u5f55\u3002\uff08\u8be5\u8bb0\u5f55\u53ef\u80fd\u5f71\u54cd\u5404\u4e2a Pod \u4e4b\u95f4\u7684\u901a\u4fe1\u6548\u7387\uff0c\u5982\u679c\u4e0d\u5b58\u5728\u8fd9\u6761\u8bb0\u5f55\u5219\u65e0\u9700\u66f4\u6539\uff09
vim /etc/resolve.conf\n
Helm \u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406 Kubernetes \u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u7ba1\u7406\u5de5\u5177\u3002\u5b83\u901a\u8fc7\u4f7f\u7528 chart\uff08\u9884\u5148\u914d\u7f6e\u7684\u5b89\u88c5\u5305\u8d44\u6e90\uff09\u6765\u7b80\u5316\u5e94\u7528\u7a0b\u5e8f\u7684\u90e8\u7f72\u548c\u7ba1\u7406\u8fc7\u7a0b\u3002\u7c7b\u4f3c\u4e8e Ubuntu \u7684 APT \u548c CentOS \u7684 YUM\uff0cHelm \u63d0\u4f9b\u4e86\u4e00\u79cd\u4fbf\u6377\u7684\u65b9\u5f0f\u6765\u5b89\u88c5\u3001\u5347\u7ea7\u548c\u7ba1\u7406 Kubernetes \u5e94\u7528\u7a0b\u5e8f\u3002
\u5728\u5b89\u88c5 Minio \u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u5b89\u88c5 Helm\uff0c\u56e0\u4e3a Minio \u7684\u5b89\u88c5\u8fc7\u7a0b\u4f9d\u8d56\u4e8e Helm\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5 Helm \u7684\u6b65\u9aa4\uff1a
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
\u4e0b\u8f7d helm \u5b89\u88c5\u5305\uff1a
wget https://get.helm.sh/helm-v3.10.2-linux-amd64.tar.gz\n#\u5982\u679c\u5728\u56fd\u5185\u7684\u7f51\u7edc\u53d7\u9650\u73af\u5883\u4e0b\uff0c\u53ef\u4ee5\u6362\u4ee5\u4e0b\u56fd\u5185\u955c\u50cf\u5730\u5740\nwget https://mirrors.huaweicloud.com/helm/v3.10.2/helm-v3.10.2-linux-amd64.tar.gz\n
\u89e3\u538b\u5e76\u5b89\u88c5\uff1a
tar -zxf helm-v3.10.2-linux-amd64.tar.gz\nmv linux-amd64/helm /usr/local/bin/helm\n
\u9a8c\u8bc1\u7248\u672c\uff0c\u67e5\u770b\u662f\u5426\u5b89\u88c5\u5b8c\u6210\uff1a
[root@k8s01 home]# helm version\nversion.BuildInfo{Version:\"v3.10.2\", GitCommit:\"50f003e5ee8704ec937a756c646870227d7c8b58\", GitTreeState:\"clean\", GoVersion:\"go1.18.8\"}\n
\u51fa\u73b0\u4e0a\u9762\u6240\u793a\u7248\u672c\u4fe1\u606f\u5373\u8868\u793a\u5b89\u88c5\u5b8c\u6210\u3002
CSI \u4e3a Kubernetes \u7684\u5b58\u50a8\u63d2\u4ef6\uff0c\u4e3a MinIO \u548c MarixOne \u63d0\u4f9b\u5b58\u50a8\u670d\u52a1\u3002\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 local-path-provisioner
\u63d2\u4ef6\u3002
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\uff0c\u5b89\u88c5 CSI\uff1a
wget https://github.com/rancher/local-path-provisioner/archive/refs/tags/v0.0.23.zip\nunzip v0.0.23.zip\ncd local-path-provisioner-0.0.23/deploy/chart/local-path-provisioner\nhelm install --set nodePathMap[0].paths[0]=\"/opt/local-path-provisioner\",nodePathMap[0].node=DEFAULT_PATH_FOR_NON_LISTED_NODES --create-namespace --namespace local-path-storage local-path-storage ./\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/rancher/local-path-provisioner/archive/refs/tags/v0.0.23.zip\n
\u5b89\u88c5\u6210\u529f\u540e\uff0c\u547d\u4ee4\u884c\u663e\u793a\u5982\u4e0b\u6240\u793a\uff1a
root@master0:~# kubectl get pod -n local-path-storage\nNAME READY STATUS RESTARTS AGE\nlocal-path-storage-local-path-provisioner-57bf67f7c-lcb88 1/1 Running 0 89s\n
Note: \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8be5 storageClass \u4f1a\u5728 worker \u8282\u70b9\u7684 \"/opt/local-path-provisioner\" \u76ee\u5f55\u63d0\u4f9b\u5b58\u50a8\u670d\u52a1\u3002\u4f60\u53ef\u4ee5\u4fee\u6539\u4e3a\u5176\u5b83\u8def\u5f84\u3002
\u8bbe\u7f6e\u7f3a\u7701 storageClass
\uff1a
kubectl patch storageclass local-path -p '{\"metadata\": {\"annotations\":{\"storageclass.kubernetes.io/is-default-class\":\"true\"}}}'\n
\u8bbe\u7f6e\u7f3a\u7701\u6210\u529f\u540e\uff0c\u547d\u4ee4\u884c\u663e\u793a\u5982\u4e0b\uff1a
root@master0:~# kubectl get storageclass\nNAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE\nlocal-path (default) cluster.local/local-path-storage-local-path-provisioner Delete WaitForFirstConsumer true 115s\n
MinIO \u7684\u4f5c\u7528\u662f\u4e3a MatrixOne \u63d0\u4f9b\u5bf9\u8c61\u5b58\u50a8\u3002\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u90e8\u7f72\u4e00\u4e2a\u5355\u8282\u70b9\u7684 MinIO\u3002
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#_10","title":"\u5b89\u88c5\u542f\u52a8","text":"\u5b89\u88c5\u5e76\u542f\u52a8 MinIO \u7684\u547d\u4ee4\u884c\u5982\u4e0b\uff1a
helm repo add minio https://charts.min.io/\nmkdir minio_ins && cd minio_ins\nhelm fetch minio/minio\nls -lth\ntar -zxvf minio-5.0.9.tgz # \u8fd9\u4e2a\u7248\u672c\u53ef\u80fd\u4f1a\u53d8\uff0c\u4ee5\u5b9e\u9645\u4e0b\u8f7d\u5230\u7684\u4e3a\u51c6\ncd ./minio/\n\nkubectl create ns mostorage\n\nhelm install minio \\\n--namespace mostorage \\\n--set resources.requests.memory=512Mi \\\n--set replicas=1 \\\n--set persistence.size=10G \\\n--set mode=standalone \\\n--set rootUser=rootuser,rootPassword=rootpass123 \\\n--set consoleService.type=NodePort \\\n--set image.repository=minio/minio \\\n--set image.tag=latest \\\n--set mcImage.repository=minio/mc \\\n--set mcImage.tag=latest \\\n-f values.yaml minio/minio\n
Note
--set resources.requests.memory=512Mi
\u8bbe\u7f6e\u4e86 MinIO \u7684\u5185\u5b58\u6700\u4f4e\u6d88\u8017--set persistence.size=1G
\u8bbe\u7f6e\u4e86 MinIO \u7684\u5b58\u50a8\u5927\u5c0f\u4e3a 1G--set rootUser=rootuser,rootPassword=rootpass123
\u8fd9\u91cc\u7684 rootUser \u548c rootPassword \u8bbe\u7f6e\u7684\u53c2\u6570\uff0c\u5728\u540e\u7eed\u521b\u5efa Kubernetes \u96c6\u7fa4\u7684 scrects \u6587\u4ef6\u65f6\uff0c\u9700\u8981\u7528\u5230\uff0c\u56e0\u6b64\u4f7f\u7528\u4e00\u4e2a\u80fd\u8bb0\u4f4f\u7684\u4fe1\u606f\u3002\u5982\u679c\u7531\u4e8e\u7f51\u7edc\u6216\u5176\u4ed6\u539f\u56e0\u591a\u6b21\u53cd\u590d\u6267\u884c\uff0c\u9700\u8981\u5148\u5378\u8f7d\uff1a
helm uninstall minio --namespace mostorage\n
\u5b89\u88c5\u5e76\u542f\u52a8 MinIO \u6210\u529f\u540e\uff0c\u547d\u4ee4\u884c\u663e\u793a\u5982\u4e0b\u6240\u793a\uff1a
NAME: minio\nLAST DEPLOYED: Sun May 7 14:17:18 2023\nNAMESPACE: mostorage\nSTATUS: deployed\nREVISION: 1\nTEST SUITE: None\nNOTES:\nMinIO can be accessed via port 9000 on the following DNS name from within your cluster:\nminio.mostorage.svc.cluster.local\n\nTo access MinIO from localhost, run the below commands:\n\n 1. export POD_NAME=$(kubectl get pods --namespace mostorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\n\n 2. kubectl port-forward $POD_NAME 9000 --namespace mostorage\n\nRead more about port forwarding here: http://kubernetes.io/docs/user-guide/kubectl/kubectl_port-forward/\n\nYou can now access MinIO server on http://localhost:9000. Follow the below steps to connect to MinIO server with mc client:\n\n 1. Download the MinIO mc client - https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart\n\n 2. export MC_HOST_minio-local=http://$(kubectl get secret --namespace mostorage minio -o jsonpath=\"{.data.rootUser}\" | base64 --decode):$(kubectl get secret --namespace mostorage minio -o jsonpath=\"{.data.rootPassword}\" | base64 --decode)@localhost:9000\n\n 3. mc ls minio-local\n
\u76ee\u524d\u4e3a\u6b62\uff0cMinio \u5df2\u7ecf\u6210\u529f\u5b89\u88c5\u5b8c\u6bd5\u3002\u5728\u540e\u7eed\u7684 MatrixOne \u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0cMatrixOne \u5c06\u76f4\u63a5\u901a\u8fc7 Kubernetes \u7684 Service\uff08SVC\uff09\u4e0e Minio \u8fdb\u884c\u901a\u4fe1\uff0c\u65e0\u9700\u8fdb\u884c\u989d\u5916\u7684\u914d\u7f6e\u3002
\u7136\u800c\uff0c\u5982\u679c\u60a8\u5e0c\u671b\u4ece localhost
\u8fde\u63a5\u5230 Minio\uff0c\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u884c\u6765\u8bbe\u7f6e POD_NAME
\u53d8\u91cf\uff0c\u5e76\u5c06 mostorage
\u8fde\u63a5\u5230 9000 \u7aef\u53e3\uff1a
export POD_NAME=$(kubectl get pods --namespace mostorage -l \"release=minio\" -o jsonpath=\"{.items[0].metadata.name}\")\nnohup kubectl port-forward --address 0.0.0.0 $POD_NAME -n mostorage 9000:9000 &\n
\u542f\u52a8\u540e\uff0c\u4f7f\u7528 http://118.195.255.252:32001/ \u5373\u53ef\u767b\u5f55 MinIO \u7684\u9875\u9762\uff0c\u521b\u5efa\u5bf9\u8c61\u5b58\u50a8\u7684\u4fe1\u606f\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u8d26\u6237\u5bc6\u7801\u5373\u4e0a\u8ff0\u6b65\u9aa4\u4e2d --set rootUser=rootuser,rootPassword=rootpass123
\u8bbe\u7f6e\u7684 rootUser \u548c rootPassword\uff1a
\u767b\u5f55\u5b8c\u6210\u540e\uff0c\u4f60\u9700\u8981\u521b\u5efa\u5bf9\u8c61\u5b58\u50a8\u76f8\u5173\u7684\u4fe1\u606f\uff1a
\u70b9\u51fb Bucket > Create Bucket\uff0c\u5728 Bucket Name \u4e2d\u586b\u5199 Bucket \u7684\u540d\u79f0 minio-mo\u3002\u586b\u5199\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u53f3\u4e0b\u65b9\u6309\u94ae Create Bucket\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u90e8\u7f72 MatrixOne \u96c6\u7fa4\u3002
Note: \u672c\u7ae0\u8282\u5747\u662f\u5728 master0 \u8282\u70b9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#matrixone-operator","title":"\u5b89\u88c5 MatrixOne-Operator","text":"MatrixOne Operator \u662f\u4e00\u4e2a\u5728 Kubernetes \u4e0a\u90e8\u7f72\u548c\u7ba1\u7406 MatrixOne \u96c6\u7fa4\u7684\u72ec\u7acb\u8f6f\u4ef6\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u4ece\u9879\u76ee\u7684 Release \u5217\u8868\u4e2d\u9009\u62e9\u6700\u65b0\u7684 Operator Release \u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u5728 master0 \u4e0a\u5b89\u88c5 MatrixOne Operator\u3002\u6211\u4eec\u5c06\u4e3a Operator \u521b\u5efa\u4e00\u4e2a\u72ec\u7acb\u7684\u547d\u540d\u7a7a\u95f4 matrixone-operator
\u3002
\u6dfb\u52a0 matrixone-operator \u5730\u5740\u5230 helm \u4ed3\u5e93\uff1a
helm repo add matrixone-operator https://matrixorigin.github.io/matrixone-operator\n
\u66f4\u65b0\u4ed3\u5e93\uff1a
helm repo update\n
\u67e5\u770b MatrixOne Operator \u7248\u672c\uff1a
helm search repo matrixone-operator/matrixone-operator --versions --devel\n
\u6307\u5b9a\u53d1\u5e03\u7248\u672c\u5b89\u88c5 MatrixOne Operator\uff1a
helm install matrixone-operator matrixone-operator/matrixone-operator --version <VERSION> --create-namespace --namespace matrixone-operator\n
Note
\u53c2\u6570 VERSION \u4e3a\u8981\u90e8\u7f72\u7684 MatrixOne Operator \u7684\u7248\u672c\u53f7\uff0c\u5982 1.0.0-alpha.2\u3002
\u5b89\u88c5\u6210\u529f\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u786e\u8ba4\u5b89\u88c5\u72b6\u6001\uff1a
kubectl get pod -n matrixone-operator\n
\u786e\u4fdd\u4e0a\u8ff0\u547d\u4ee4\u8f93\u51fa\u4e2d\u7684\u6240\u6709 Pod \u72b6\u6001\u90fd\u4e3a Running\u3002
[root@master0 matrixone-operator]# kubectl get pod -n matrixone-operator\nNAME READY STATUS RESTARTS AGE\nmatrixone-operator-f8496ff5c-fp6zm 1/1 Running 0 3m26s\n
\u5982\u4e0a\u4ee3\u7801\u884c\u6240\u793a\uff0c\u5bf9\u5e94 Pod \u72b6\u6001\u5747\u6b63\u5e38\u3002
"},{"location":"MatrixOne/Deploy/deploy-Matrixone-cluster/deploy-MatrixOne-cluster-without-k8/#matrixone","title":"\u521b\u5efa MatrixOne \u96c6\u7fa4","text":"\u9996\u5148\u521b\u5efa MatrixOne \u7684\u547d\u540d\u7a7a\u95f4\uff1a
NS=\"mo-hn\"\nkubectl create ns ${NS}\n
\u81ea\u5b9a\u4e49 MatrixOne \u96c6\u7fa4\u7684 yaml
\u6587\u4ef6\uff0c\u7f16\u5199\u5982\u4e0b mo.yaml
\u7684\u6587\u4ef6\uff1a
apiVersion: core.matrixorigin.io/v1alpha1\nkind: MatrixOneCluster\nmetadata:\n name: mo\n namespace: mo-hn\nspec:\n # 1. \u914d\u7f6e tn\n tn:\n cacheVolume: # tn \u7684\u78c1\u76d8\u7f13\u5b58\n size: 5Gi # \u6839\u636e\u5b9e\u9645\u78c1\u76d8\u5927\u5c0f\u548c\u9700\u6c42\u4fee\u6539\n storageClassName: local-path # \u5982\u679c\u4e0d\u5199\uff0c\u4f1a\u7528\u7cfb\u7edf\u9ed8\u8ba4\u7684 storage class\n resources:\n requests:\n cpu: 100m #1000m=1c\n memory: 500Mi # 1024Mi\n limits: # \u6ce8\u610f limits \u4e0d\u80fd\u4f4e\u4e8e requests\uff0c\u4e5f\u4e0d\u80fd\u8d85\u8fc7\u5355\u8282\u70b9\u7684\u80fd\u529b\uff0c\u4e00\u822c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u5206\u914d\uff0c\u4e00\u822c\u8bbe\u7f6e limits \u548c requests \u4e00\u81f4\u5373\u53ef\n cpu: 200m\n memory: 1Gi\n config: | # tn \u7684\u914d\u7f6e\n [dn.Txn.Storage]\n backend = \"TAE\"\n log-backend = \"logservice\"\n [dn.Ckp]\n flush-interval = \"60s\"\n min-count = 100\n scan-interval = \"5s\"\n incremental-interval = \"60s\"\n global-interval = \"100000s\"\n [log]\n level = \"error\"\n format = \"json\"\n max-size = 512\n replicas: 1 # tn \u7684\u526f\u672c\u6570\uff0c\u4e0d\u53ef\u4fee\u6539\u3002\u5f53\u524d\u7248\u672c\u4ec5\u652f\u6301\u8bbe\u7f6e\u4e3a 1\u3002\n # 2. \u914d\u7f6e logservice\n logService:\n replicas: 3 # logservice \u7684\u526f\u672c\u6570\n resources:\n requests:\n cpu: 100m #1000m=1c\n memory: 500Mi # 1024Mi\n limits: # \u6ce8\u610f limits \u4e0d\u80fd\u4f4e\u4e8e requests\uff0c\u4e5f\u4e0d\u80fd\u8d85\u8fc7\u5355\u8282\u70b9\u7684\u80fd\u529b\uff0c\u4e00\u822c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u5206\u914d\uff0c\u4e00\u822c\u8bbe\u7f6e limits \u548c requests \u4e00\u81f4\u5373\u53ef\n cpu: 200m\n memory: 1Gi\n sharedStorage: # \u914d\u7f6e logservice \u5bf9\u63a5\u7684 s3 \u5b58\u50a8\n s3:\n type: minio # \u6240\u5bf9\u63a5\u7684 s3 \u5b58\u50a8\u7c7b\u578b\u4e3a minio\n path: minio-mo # \u7ed9 mo \u7528\u7684 minio \u6876\u7684\u8def\u5f84\uff0c\u6b64\u524d\u901a\u8fc7\u63a7\u5236\u53f0\u6216 mc \u547d\u4ee4\u521b\u5efa\n endpoint: http://minio.mostorage:9000 # \u6b64\u5904\u4e3a minio \u670d\u52a1\u7684 svc \u5730\u5740\u548c\u7aef\u53e3\n secretRef: # \u914d\u7f6e\u8bbf\u95ee minio \u7684\u5bc6\u94a5\u5373 secret\uff0c\u540d\u79f0\u4e3a minio\n name: minio\n pvcRetentionPolicy: Retain # \u914d\u7f6e\u96c6\u7fa4\u9500\u6bc1\u540e\uff0cpvc \u7684\u5468\u671f\u7b56\u7565\uff0cRetain \u4e3a\u4fdd\u7559\uff0cDelete \u4e3a\u5220\u9664\n volume:\n size: 1Gi # \u914d\u7f6e S3 \u5bf9\u8c61\u5b58\u50a8\u7684\u5927\u5c0f\uff0c\u6839\u636e\u5b9e\u9645\u78c1\u76d8\u5927\u5c0f\u548c\u9700\u6c42\u4fee\u6539\n config: | # logservice \u7684\u914d\u7f6e\n [log]\n level = \"error\"\n format = \"json\"\n max-size = 512\n # 3. \u914d\u7f6e cn\n tp:\n cacheVolume: # cn \u7684\u78c1\u76d8\u7f13\u5b58\n size: 5Gi # \u6839\u636e\u5b9e\u9645\u78c1\u76d8\u5927\u5c0f\u548c\u9700\u6c42\u4fee\u6539\n storageClassName: local-path # \u5982\u679c\u4e0d\u5199\uff0c\u4f1a\u7528\u7cfb\u7edf\u9ed8\u8ba4\u7684 storage class\n resources:\n requests:\n cpu: 100m #1000m=1c\n memory: 500Mi # 1024Mi\n limits: # \u6ce8\u610f limits \u4e0d\u80fd\u4f4e\u4e8e requests\uff0c\u4e5f\u4e0d\u80fd\u8d85\u8fc7\u5355\u8282\u70b9\u7684\u80fd\u529b\uff0c\u4e00\u822c\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u6765\u5206\u914d\uff0c\u4e00\u822c\u8bbe\u7f6e limits \u548c requests \u4e00\u81f4\u5373\u53ef\n cpu: 200m\n memory: 2Gi\n serviceType: NodePort # cn \u9700\u8981\u5bf9\u5916\u63d0\u4f9b\u8bbf\u95ee\u5165\u53e3\uff0c\u5176 svc \u8bbe\u7f6e\u4e3a NodePort\n nodePort: 31429 # nodePort \u7aef\u53e3\u8bbe\u7f6e\n config: | # cn \u7684\u914d\u7f6e\n [cn.Engine]\n type = \"distributed-tae\"\n [log]\n level = \"debug\"\n format = \"json\"\n max-size = 512\n replicas: 1\n version: nightly-54b5e8c # \u6b64\u5904\u4e3a MO \u955c\u50cf\u7684\u7248\u672c\uff0c\u53ef\u901a\u8fc7 dockerhub \u67e5\u9605\uff0c\u4e00\u822c cn\u3001tn\u3001logservice \u4e3a\u540c\u4e00\u4e2a\u955c\u50cf\u6253\u5305\uff0c\u6240\u4ee5\u7528\u540c\u4e00\u4e2a\u5b57\u6bb5\u6307\u5b9a\u5373\u53ef\uff0c\u4e5f\u652f\u6301\u5355\u72ec\u5728\u5404\u81ea\u90e8\u5206\u4e2d\u6307\u5b9a\uff0c\u4f46\u65e0\u7279\u6b8a\u60c5\u51b5\u8bf7\u7528\u7edf\u4e00\u7684\u955c\u50cf\u7248\u672c\n # https://hub.docker.com/r/matrixorigin/matrixone/tags\n imageRepository: matrixorigin/matrixone # \u955c\u50cf\u4ed3\u5e93\u5730\u5740\uff0c\u5982\u679c\u672c\u5730\u62c9\u53d6\u540e\uff0c\u6709\u4fee\u6539\u8fc7 tag\uff0c\u90a3\u4e48\u53ef\u4ee5\u8c03\u6574\u8fd9\u4e2a\u914d\u7f6e\u9879\n imagePullPolicy: IfNotPresent # \u955c\u50cf\u62c9\u53d6\u7b56\u7565\uff0c\u4e0e k8s \u5b98\u65b9\u53ef\u914d\u7f6e\u503c\u4e00\u81f4\n
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5728\u547d\u540d\u7a7a\u95f4 mo-hn
\u4e2d\u521b\u5efa\u7528\u4e8e\u8bbf\u95ee MinIO \u7684 Secret \u670d\u52a1\uff1a
kubectl -n mo-hn create secret generic minio --from-literal=AWS_ACCESS_KEY_ID=rootuser --from-literal=AWS_SECRET_ACCESS_KEY=rootpass123\n
\u5176\u4e2d\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u4f7f\u7528\u5728\u521b\u5efa MinIO \u96c6\u7fa4\u65f6\u8bbe\u7f6e\u7684 rootUser
\u548c rootPassword
\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u90e8\u7f72 MatrixOne \u96c6\u7fa4\uff1a
kubectl apply -f mo.yaml\n
\u8bf7\u8010\u5fc3\u7b49\u5f85\u5927\u7ea6 10 \u5206\u949f\uff0c\u5982\u679c\u51fa\u73b0 Pod \u91cd\u542f\uff0c\u8bf7\u7ee7\u7eed\u7b49\u5f85\u3002\u76f4\u5230\u4f60\u770b\u5230\u4ee5\u4e0b\u4fe1\u606f\u8868\u793a\u90e8\u7f72\u6210\u529f\uff1a
[root@master0 mo]# kubectl get pods -n mo-hn \nNAME READY STATUS RESTARTS AGE\nmo-tn-0 1/1 Running 0 74s\nmo-log-0 1/1 Running 1 (25s ago) 2m2s\nmo-log-1 1/1 Running 1 (24s ago) 2m2s\nmo-log-2 1/1 Running 1 (22s ago) 2m2s\nmo-tp-cn-0 1/1 Running 0 50s\n
\u4e3a\u4e86\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u60a8\u9700\u8981\u5c06\u5bf9\u5e94\u670d\u52a1\u7684\u7aef\u53e3\u6620\u5c04\u5230 MatrixOne \u8282\u70b9\u4e0a\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 kubectl port-forward
\u8fde\u63a5 MatrixOne \u96c6\u7fa4\u7684\u6307\u5bfc\uff1a
nohup kubectl port-forward -nmo-hn svc/mo-tp-cn 6001:6001 &\n
nohup kubectl port-forward -nmo-hn --address 0.0.0.0 svc/mo-tp-cn 6001:6001 &\n
\u5728\u6307\u5b9a\u5141\u8bb8\u672c\u5730\u8bbf\u95ee\u6216\u6307\u5b9a\u67d0\u53f0\u673a\u5668\u6216\u8005\u6240\u6709\u673a\u5668\u8bbf\u95ee\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff1a
# \u4f7f\u7528 'mysql' \u547d\u4ee4\u884c\u5de5\u5177\u8fde\u63a5\u5230MySQL\u670d\u52a1\n# \u4f7f\u7528 'kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}' ' \u83b7\u53d6Kubernetes\u96c6\u7fa4\u4e2d\u670d\u52a1\u7684\u96c6\u7fa4IP\u5730\u5740\n# '-h' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u4e3b\u673a\u540d\u6216IP\u5730\u5740\n# '-P' \u53c2\u6570\u6307\u5b9a\u4e86MySQL\u670d\u52a1\u7684\u7aef\u53e3\u53f7\uff0c\u8fd9\u91cc\u662f6001\n# '-uroot' \u8868\u793a\u7528root\u7528\u6237\u767b\u5f55\n# '-p111' \u8868\u793a\u521d\u59cb\u5bc6\u7801\u662f111\nmysql -h $(kubectl get svc/mo-tp-cn -n mo-hn -o jsonpath='{.spec.clusterIP}') -P 6001 -uroot -p111\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 163\nServer version: 8.0.30-MatrixOne-v1.1.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
\u663e\u793a mysql>
\u540e\uff0c\u5206\u5e03\u5f0f\u7684 MatrixOne \u96c6\u7fa4\u642d\u5efa\u8fde\u63a5\u5b8c\u6210\u3002
Info
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/","title":"\u4f53\u9a8c\u73af\u5883","text":"\u672c\u7bc7\u6587\u6863\u4ecb\u7ecd\u7684 MatrixOne \u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u89c4\u5212\u53ef\u4ee5\u7528\u4e8e\u4f53\u9a8c MatrixOne \u7684\u5206\u5e03\u5f0f\u57fa\u7840\u80fd\u529b\uff0c\u4f60\u53ef\u4ee5\u7b80\u5355\u4f53\u9a8c\u6570\u636e\u5e93\u7684\u57fa\u7840\u5f00\u53d1\u3001\u8fd0\u7ef4\u7b49\u529f\u80fd\uff0c\u4f46\u662f\u4e0d\u9002\u7528\u4e8e\u90e8\u7f72\u751f\u4ea7\u73af\u5883\uff0c\u8fdb\u884c\u6027\u80fd\u538b\u6d4b\uff0c\u6216\u8fdb\u884c\u9ad8\u53ef\u7528\u6d4b\u8bd5\u7b49\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_2","title":"\u786c\u4ef6\u914d\u7f6e","text":"\u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u5982\u4e0b\uff1a
\u786c\u4ef6\u73af\u5883\u8981\u6c42 \u7269\u7406\u673a/\u865a\u62df\u673a \u8bbe\u5907\u53f0\u6570 3 \u53f0 CPU \u914d\u7f6e 2 \u6838\u4ee5\u4e0a \u5185\u5b58\u914d\u7f6e 8GB \u4ee5\u4e0a \u78c1\u76d8\u914d\u7f6e 200GB \u4ee5\u4e0a \u7f51\u5361\u914d\u7f6e \u4e0d\u9650"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_3","title":"\u8f6f\u4ef6\u914d\u7f6e","text":"\u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u8f6f\u4ef6\u914d\u7f6e\u8981\u6c42\u5305\u62ec\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u7684\u8981\u6c42\u548c\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42\uff1a
"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_4","title":"\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u8981\u6c42","text":"\u64cd\u4f5c\u7cfb\u7edf \u652f\u6301\u7684 CPU \u67b6\u6784 CentOS 7.3 \u53ca\u4ee5\u4e0a\u7684 7.x \u7248\u672c X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/experience-deployment-topology/#_5","title":"\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42","text":"\u8f6f\u4ef6\u6a21\u5757 \u90e8\u7f72\u53f0\u6570 \u529f\u80fd\u8bf4\u660e Kubernetes 3 \u63d0\u4f9b\u6574\u4e2a\u96c6\u7fa4\u7684\u5bb9\u5668\u5316\u7ba1\u7406 Minio 1 \u63d0\u4f9b MatrixOne \u96c6\u7fa4\u7684\u5b58\u50a8\u670d\u52a1 MatrixOne 1 \u6570\u636e\u5e93\u6838\u5fc3MatrixOne \u5206\u5e03\u5f0f\u73af\u5883\u7684\u4f53\u9a8c\u73af\u5883\u90e8\u7f72\u6307\u5f15\u53ef\u4ee5\u53c2\u8003 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/","title":"\u6700\u5c0f\u751f\u4ea7\u73af\u5883","text":"\u672c\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u7684 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7684\u6700\u5c0f\u751f\u4ea7\u914d\u7f6e\u53ef\u4ee5\u7528\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u53ef\u4ee5\u652f\u6491\u5343\u4e07\u7ea7\u6570\u636e\u6570\u767e\u5e76\u53d1\u7684 OLTP \u4e1a\u52a1\uff0c\u6216\u8005\u6570\u5341 GB \u6570\u636e\u91cf\u7684 OLAP \u4e1a\u52a1\uff0c\u540c\u65f6\u6709\u4e00\u5b9a\u7684\u9ad8\u53ef\u7528\u4fdd\u969c\uff0c3 \u8282\u70b9\u5982\u679c\u6709 1 \u4e2a\u8282\u70b9\u4e0b\u7ebf\u7684\u60c5\u51b5\u4e0b\u4ecd\u7136\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_2","title":"\u786c\u4ef6\u914d\u7f6e","text":"\u6700\u5c0f\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u5982\u4e0b\uff1a
\u786c\u4ef6\u73af\u5883\u8981\u6c42 \u7269\u7406\u673a\u3001\u865a\u62df\u673a\u5747\u53ef \u8bbe\u5907\u53f0\u6570 3 \u53f0 CPU \u914d\u7f6e 8 \u6838\u4ee5\u4e0a \u5185\u5b58\u914d\u7f6e 32GB \u4ee5\u4e0a \u78c1\u76d8\u914d\u7f6e \u6bcf\u8282\u70b9 1 \u5757\u7cfb\u7edf\u76d8 100G, 4-7 \u5757\u6570\u636e\u76d8 100G, \u5747\u9700\u8981 PCIe NVME SSD 3.0 \u7f51\u5361\u914d\u7f6e \u53cc\u4e07\u5146\u7f51\u53e3\uff0c\u4e07\u5146\u7f51\u5361\u53ca\u4ea4\u6362\u673a"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_3","title":"\u8f6f\u4ef6\u914d\u7f6e","text":"\u6700\u5c0f\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u89c4\u5212\u7684\u8f6f\u4ef6\u914d\u7f6e\u8981\u6c42\u5305\u62ec\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u7684\u8981\u6c42\u548c\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42\uff1a
"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_4","title":"\u64cd\u4f5c\u7cfb\u7edf\u53ca\u5e73\u53f0\u8981\u6c42","text":"\u64cd\u4f5c\u7cfb\u7edf \u652f\u6301\u7684 CPU \u67b6\u6784 Debian 11 \u4ee5\u4e0a\u7248\u672c\uff08Kernel \u5185\u6838\u8981\u6c42 5.0 \u4ee5\u4e0a\uff09 X86_64"},{"location":"MatrixOne/Deploy/deployment-topology/minimal-deployment-topology/#_5","title":"\u90e8\u7f72\u8f6f\u4ef6\u6a21\u5757\u8981\u6c42","text":"\u8282\u70b9\u540d\u79f0 \u8d44\u6e90 \u8282\u70b9\u89d2\u8272 \u90e8\u7f72\u6a21\u5757 \u78c1\u76d8\u90e8\u7f72 node0 8c32g \u7ba1\u63a7/\u5b58\u50a8/\u8ba1\u7b97 \u90e8\u7f72\u53ca\u8fd0\u7ef4\u5de5\u5177 mo-ctl, Kubernetes master/node\uff0cMinio\uff0cMatrixOne Proxy\uff0cLogservice\uff0cTN\uff0c\u8d1f\u8f7d\u5747\u8861 Kubernetes \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cMinio \u9700\u8981 1 \u81f3 4 \u5757\u6570\u636e\u76d8\uff08\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u4e5f\u53ef\u903b\u8f91\u5206\u76d8\uff09, Logservice \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cTN \u9700\u8981 1 \u5757\u6570\u636e\u76d8 node1 8c32g \u7ba1\u63a7/\u5b58\u50a8/\u8ba1\u7b97 \u90e8\u7f72\u53ca\u8fd0\u7ef4\u5de5\u5177 mo-ctl, Kubernetes master/node\uff0cMinio\uff0cMatrixOne Proxy\uff0cLogservice\uff0cCN\uff0c\u8d1f\u8f7d\u5747\u8861 Kubernetes \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cMinio \u9700\u8981 1-4 \u5757\u6570\u636e\u76d8\uff08\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u4e5f\u53ef\u903b\u8f91\u5206\u76d8\uff09, Logservice \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cCN \u9700\u8981 1 \u5757\u6570\u636e\u76d8 node2 8c32g \u7ba1\u63a7/\u5b58\u50a8/\u8ba1\u7b97 \u90e8\u7f72\u53ca\u8fd0\u7ef4\u5de5\u5177 mo-ctl, Kubernetes master/node\uff0cMinio\uff0cMatrixOne Proxy\uff0cLogservice\uff0cCN\uff0c\u8d1f\u8f7d\u5747\u8861 Kubernetes \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cMinio \u9700\u8981 1-4 \u5757\u6570\u636e\u76d8\uff08\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u4e5f\u53ef\u903b\u8f91\u5206\u76d8\uff09, Logservice \u9700\u8981 1 \u5757\u6570\u636e\u76d8\uff0cCN \u9700\u8981 1 \u5757\u6570\u636e\u76d8"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/","title":"\u63a8\u8350\u751f\u4ea7\u73af\u5883","text":"\u672c\u7bc7\u6587\u6863\u4ecb\u7ecd\u7684 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7684\u63a8\u8350\u914d\u7f6e\u9002\u7528\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u5e76\u5177\u5907\u5f3a\u5927\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002\u8fd9\u79cd\u914d\u7f6e\u53ef\u4ee5\u652f\u6301\u4ebf\u7ea7\u6570\u636e\u7684\u6570\u5343\u5e76\u53d1 OLTP \u4e1a\u52a1\uff0c\u6216\u8005\u5904\u7406\u6570\u5341 TB \u6570\u636e\u91cf\u7684 OLAP \u4e1a\u52a1\u3002
\u6b64\u914d\u7f6e\u5177\u6709\u9ad8\u5ea6\u7684\u53ef\u7528\u6027\u4fdd\u8bc1\u3002\u65e0\u8bba\u662f Kubernetes\u3001Minio \u8fd8\u662f MatrixOne\uff0c\u7cfb\u7edf\u90fd\u53ef\u4ee5\u5728\u4e00\u4e2a\u8282\u70b9\u4e0b\u7ebf\u7684\u60c5\u51b5\u4e0b\u7ee7\u7eed\u6b63\u5e38\u8fd0\u884c\u3002\u8fd9\u610f\u5473\u7740\u7cfb\u7edf\u5177\u5907\u5f3a\u5927\u7684\u5bb9\u9519\u80fd\u529b\uff0c\u53ef\u4ee5\u5728\u8282\u70b9\u6545\u969c\u7684\u60c5\u51b5\u4e0b\u4fdd\u6301\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002
\u4ee5\u4e0b\u5185\u5bb9\u4e3a\u63a8\u8350\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u89c4\u5212\uff1a
"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#_2","title":"\u8f6f\u4ef6\u53ca\u786c\u4ef6\u914d\u7f6e\u8981\u6c42","text":"\u6a21\u5757 Kubernetes master Minio LogService TN\uff08\u6df7\u90e8 Proxy \u53ca\u8d1f\u8f7d\u5747\u8861\uff09 CN\uff08\u6df7\u90e8 Proxy \u53ca\u8d1f\u8f7d\u5747\u8861\uff09 \u53f0\u6570\uff08\u7269\u7406\u673a\u3001\u865a\u62df\u673a\u5747\u53ef\uff09 3 \u53f0 4 \u53f0 3 \u53f0 1 \u53f0 y \u53f0 \u8282\u70b9\u89d2\u8272 Kubernetes \u7ba1\u63a7 \u5b58\u50a8\u670d\u52a1 MatrixOne \u5de5\u4f5c\u8282\u70b9 MatrixOne \u5de5\u4f5c\u8282\u70b9 MatrixOne \u5de5\u4f5c\u8282\u70b9 CPU \u914d\u7f6e 4 \u6838\u4ee5\u4e0a 4 \u6838\u4ee5\u4e0a 4 \u6838\u4ee5\u4e0a 16 \u6838\u4ee5\u4e0a 16 \u6838\u4ee5\u4e0a \u5185\u5b58\u914d\u7f6e 8GB \u4ee5\u4e0a 8GB \u4ee5\u4e0a 8GB \u4ee5\u4e0a 64GB \u4ee5\u4e0a 32GB \u4ee5\u4e0a \u7f51\u5361 \u53cc\u4e07\u5146\u7f51\u53e3\uff0c\u4e07\u5146\u7f51\u5361 \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u7cfb\u7edf\u76d8\u914d\u7f6e \u6bcf\u8282\u70b9 PCIe NVME SSD 3.0 \u00d7 1 \u5757 100GB\uff0c\u5efa\u8bae\u505a Raid 1 \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a Kubernetes \u76d8\u914d\u7f6e \u6bcf\u8282\u70b9 PCIe NVME SSD 3.0 \u00d7 1 \u5757 100GB\uff0c\u5efa\u8bae\u505a Raid 1 \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u540c\u4e0a \u6570\u636e\u76d8\u914d\u7f6e N/A \u6bcf\u8282\u70b9 PCIe NVME SSD 3.0 \u00d7 4 \u5757 \u00d7 a G/\u5757\uff0craid \u65e0\u8981\u6c42\uff0c\u5efa\u8bae\u7269\u7406\u5206\u76d8\uff0c\u53ef\u903b\u8f91\u5206\u76d8\u3002 \u6bcf\u8282\u70b9 NVME SSD 3.0/4.0 (1G/s \u4ee5\u4e0a\u8bfb\u53d6\u901f\u7387) \u00d7 1 \u5757 \u00d7 b G/\u5757\u3002 NVME SSD 3.0/4.0 \u00d7 2 \u5757 \u00d7 c G/\u5757 \u6bcf\u8282\u70b9 NVME SSD 3.0/4.0 \u00d7 2 \u5757 \u00d7 d G/\u5757\u3002 \u5907\u6ce8 a \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0ca = \u4e1a\u52a1\u6570\u636e\u91cf\u00d72/16\u3002 b \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0c\u8d8a\u63a5\u8fd1\u8d8a\u597d\u3002 c \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0c\u8d8a\u63a5\u8fd1\u8d8a\u597d\u3002\u5176\u4e2d\u4e00\u5757\u7ed9 TN/CN \u6545\u969c\u6062\u590d\u65f6\u5907\u7528\u3002 d \u4e0e\u4e1a\u52a1\u6570\u636e\u91cf\u76f8\u5173\uff0c\u8d8a\u63a5\u8fd1\u8d8a\u597d\u3002\u5176\u4e2d\u4e00\u5757\u7ed9 TN/CN \u6545\u969c\u6062\u590d\u65f6\u5907\u7528\u3002y \u4e0e\u4e1a\u52a1\u8d1f\u8f7d\u76f8\u5173\u3002"},{"location":"MatrixOne/Deploy/deployment-topology/recommended-prd-deployment-topology/#_3","title":"\u5176\u4ed6\u914d\u7f6e","text":"\u64cd\u4f5c\u7cfb\u7edf \u652f\u6301\u7684 CPU \u67b6\u6784 Debian 11 \u4ee5\u4e0a\u7248\u672c\uff08Kernel \u5185\u6838\u8981\u6c42 5.0 \u4ee5\u4e0a\uff09 X86_64\u7531\u4e8e\u6bcf\u4e2a\u79c1\u6709\u5316\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u573a\u666f\u5747\u5b58\u5728\u5dee\u5f02\uff0c\u6709\u5173\u5177\u4f53\u90e8\u7f72\u65b9\u6848\u53ca\u90e8\u7f72\u7ec6\u8282\uff0c\u8bf7\u8054\u7cfb MatrixOne \u7684\u5ba2\u6237\u652f\u6301\u56e2\u961f\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/","title":"MatrixOne \u96c6\u7fa4\u62d3\u6251\u6982\u8ff0","text":"MatrixOne \u6570\u636e\u5e93\u96c6\u7fa4\u662f\u4e00\u79cd\u5728\u591a\u4e2a\u7269\u7406\u6216\u865a\u62df\u670d\u52a1\u5668\u4e0a\u5206\u5e03\u5f0f\u90e8\u7f72\u6570\u636e\u5e93\u7cfb\u7edf\u7684\u67b6\u6784\uff0c\u65e8\u5728\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u3001\u9ad8\u53ef\u4f38\u7f29\u6027\u3002\u901a\u8fc7\u5c06\u6570\u636e\u5e93\u5206\u6563\u5230\u591a\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u96c6\u7fa4\u53ef\u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u5197\u4f59\u5907\u4efd\u3001\u8d1f\u8f7d\u5747\u8861\u548c\u6545\u969c\u6062\u590d\uff0c\u4ece\u800c\u63d0\u4f9b\u66f4\u9ad8\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002
\u6570\u636e\u5e93\u96c6\u7fa4\u62d3\u6251\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u548c\u6027\u80fd\u8981\u6c42\u7684\u4e0d\u540c\uff0c\u53ef\u4ee5\u9009\u62e9\u9002\u5408\u7684\u67b6\u6784\u3002\u4e86\u89e3\u4e0d\u540c\u62d3\u6251\u7684\u4f18\u7f3a\u70b9\u4ee5\u53ca\u9002\u7528\u573a\u666f\uff0c\u6709\u52a9\u4e8e\u8bbe\u8ba1\u51fa\u7a33\u5b9a\u3001\u9ad8\u6548\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u67b6\u6784\u3002
"},{"location":"MatrixOne/Deploy/deployment-topology/topology-overview/#_1","title":"\u62d3\u6251\u90e8\u7f72\u6587\u6863","text":"\u6211\u4eec\u63a8\u8350\u4e09\u79cd\u73af\u5883\u7684\u90e8\u7f72\u6587\u6863\uff0c\u53c2\u8003\uff1a
\u672c\u7bc7\u6587\u7ae0\u53ca\u5176\u540e\u7eed\u7ae0\u8282\u4e3b\u8981\u65e8\u5728\u4ecb\u7ecd\u5982\u4f55\u5229\u7528 MatrixOne \u8fdb\u884c\u5e94\u7528\u5f00\u53d1\u3002\u6211\u4eec\u5c06\u5c55\u793a\u5982\u4f55\u8fde\u63a5\u5230 MatrixOne\uff0c\u5982\u4f55\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\uff0c\u4ee5\u53ca\u5982\u4f55\u6784\u5efa\u57fa\u4e8e\u5e38\u89c1\u7f16\u7a0b\u8bed\u8a00\uff08\u5982 Java\uff0cPython\uff0cGolang\uff09\u7684\u5e94\u7528\u7a0b\u5e8f\u3002
"},{"location":"MatrixOne/Develop/develop-overview/#matrixone","title":"MatrixOne \u4e0e\u5e94\u7528\u7684\u4ea4\u4e92","text":"\u603b\u4f53\u6765\u8bf4\uff0cMatrixOne \u4e0e MySQL 8.0 \u5177\u6709\u9ad8\u5ea6\u7684\u517c\u5bb9\u6027\uff0c\u65e0\u8bba\u5728\u901a\u4fe1\u534f\u8bae\uff0cSQL \u8bed\u6cd5\uff0c\u8fde\u63a5\u5de5\u5177\uff0c\u8fd8\u662f\u5f00\u53d1\u6a21\u5f0f\u4e0a\uff0c\u90fd\u4e0e MySQL \u57fa\u672c\u4e00\u81f4\u3002\u5982\u679c\u672c\u6587\u6863\u4e2d\u6ca1\u6709\u660e\u786e\u8bf4\u660e\u67d0\u4e9b\u7528\u6cd5\uff0c\u4f60\u53ef\u4ee5\u53c2\u7167 MySQL 8.0 \u7684\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u64cd\u4f5c\u3002\u5927\u90e8\u5206\u7684\u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\u6216\u7f16\u7a0b\u8bed\u8a00\u90fd\u53ef\u4ee5\u4f7f\u7528 MySQL \u7684\u5ba2\u6237\u7aef\u5e93\u3002
\u5bf9\u4e8e MatrixOne \u548c MySQL \u6709\u663e\u8457\u5dee\u5f02\u7684\u5730\u65b9\uff0c\u8bf7\u53c2\u9605 MySQL \u517c\u5bb9\u6027\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Develop/develop-overview/#matrixone_1","title":"MatrixOne \u4e8b\u52a1\u673a\u5236","text":"MatrixOne \u652f\u6301\u4e50\u89c2\u4e8b\u52a1\u548c\u60b2\u89c2\u4e8b\u52a1\u4e24\u79cd\u6a21\u5f0f\u3002\u5728 MatrixOne \u7684\u5f53\u524d\u7248\u672c\u4e2d\uff0c\u9ed8\u8ba4\u91c7\u7528\u7684\u662f\u60b2\u89c2\u4e8b\u52a1\u6a21\u5f0f\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u6765\u5f00\u542f\u4e50\u89c2\u4e8b\u52a1\u6a21\u5f0f\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 BEGIN
\u6765\u5f00\u542f\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4f7f\u7528 COMMIT
\u6765\u63d0\u4ea4\u4e8b\u52a1\uff0c\u6216\u8005\u4f7f\u7528 ROLLBACK
\u6765\u56de\u6eda\u4e8b\u52a1\u3002MatrixOne \u4f1a\u786e\u4fdd\u4ece BEGIN
\u5f00\u59cb\u5230 COMMIT
\u6216 ROLLBACK
\u7ed3\u675f\u4e4b\u95f4\u7684\u6240\u6709\u8bed\u53e5\u5177\u6709\u539f\u5b50\u6027\uff0c\u5373\u5728\u8fd9\u6bb5\u65f6\u95f4\u5185\u7684\u6240\u6709\u8bed\u53e5\u8981\u4e48\u5168\u90e8\u6210\u529f\uff0c\u8981\u4e48\u5168\u90e8\u5931\u8d25\uff0c\u4ee5\u6b64\u6765\u4fdd\u8bc1\u4f60\u5728\u5e94\u7528\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u9700\u8981\u7684\u6570\u636e\u4e00\u81f4\u6027\u3002
\u5982\u679c\u4f60\u9009\u62e9\u4f7f\u7528\u4e50\u89c2\u4e8b\u52a1\uff0c\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8bf7\u589e\u52a0\u9519\u8bef\u5904\u7406\u548c\u91cd\u8bd5\u673a\u5236\uff0c\u56e0\u4e3a MatrixOne \u5e76\u4e0d\u4fdd\u8bc1\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u80fd\u6267\u884c\u6210\u529f\u3002\u5982\u679c\u4f60\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\uff0c\u90a3\u4e48\u5c31\u65e0\u9700\u8003\u8651\u8fd9\u4e00\u70b9\u3002\u4e50\u89c2\u4e8b\u52a1\u5728\u5e76\u53d1\u6027\u80fd\u4e0a\u4f1a\u4f18\u4e8e\u60b2\u89c2\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/develop-overview/#_2","title":"\u53c2\u8003\u6587\u6863","text":"FineBI \u662f\u65b0\u4e00\u4ee3\u5927\u6570\u636e\u5206\u6790\u5de5\u5177\uff0c\u5b83\u6709\u52a9\u4e8e\u4f01\u4e1a\u7684\u4e1a\u52a1\u4eba\u5458\u6df1\u5165\u4e86\u89e3\u548c\u5145\u5206\u5229\u7528\u4ed6\u4eec\u7684\u6570\u636e\u3002\u5728 FineBI \u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u5236\u4f5c\u591a\u6837\u5316\u7684\u6570\u636e\u53ef\u89c6\u5316\u4fe1\u606f\uff0c\u81ea\u7531\u5206\u6790\u548c\u63a2\u7d22\u6570\u636e\u3002FineBI \u5177\u6709\u591a\u79cd\u6570\u636e\u8fde\u63a5\u529f\u80fd\uff0c\u53ef\u7528\u4e8e\u521b\u5efa\u5404\u79cd\u590d\u6742\u7684\u62a5\u8868\uff0c\u6784\u5efa\u6570\u636e\u51b3\u7b56\u5206\u6790\u7cfb\u7edf\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u516c\u53f8\u7ecf\u8425\u7ba1\u7406\u3001\u751f\u4ea7\u7ba1\u7406\u3001\u8d22\u52a1\u667a\u80fd\u6838\u7b97\u3001\u9500\u552e\u8fd0\u8425\u7b49\u9886\u57df\u3002
MatrixOne \u652f\u6301\u8fde\u63a5\u5230\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177 FineBI\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7 FineBI \u8fde\u63a5\u5230\u5355\u673a\u7248 MatrixOne\uff0c\u5e76\u521b\u5efa\u5404\u79cd\u53ef\u89c6\u5316\u6570\u636e\u62a5\u8868\uff0c\u5c06\u5b83\u4eec\u7ec4\u88c5\u6210\u4eea\u8868\u677f\uff0c\u4ee5\u4fbf\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u63a2\u7d22\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#_2","title":"\u524d\u671f\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5b89\u88c5 FineBI \u548c FineBI \u521d\u59cb\u5316\u8bbe\u7f6e\u3002
Note
\u672c\u7bc7\u6587\u6863\u6240\u5c55\u793a\u7684\u64cd\u4f5c\u793a\u4f8b\u4e2d\u4f7f\u7528\u7684 FineBI \u7248\u672c\u4e3a Linux 6.0 \u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u5b89\u88c5\u5305 Linux_unix_FineBI6_0-CN.sh\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/FineBI-connection/#finebi-matrixone_1","title":"\u901a\u8fc7 FineBI \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u521b\u5efa Demo \u6570\u636e\uff1a
\u9996\u5148\uff0c\u767b\u5f55\u5230 MatrixOne \u6570\u636e\u5e93\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b SQL \u8bed\u53e5\u6765\u521b\u5efa\u6f14\u793a\u6240\u9700\u7684\u6570\u636e\u8868\u548c\u89c6\u56fe\uff1a
create database orders;\nuse orders;\nCREATE TABLE `category` (`product_category_name` VARCHAR(255) DEFAULT NULL,\n`product_category_name_english` VARCHAR(255) DEFAULT NULL );\nCREATE TABLE `item` (`order_id` VARCHAR(255) NOT NULL, `order_item_id` INT DEFAULT null,\n`product_id` VARCHAR(255) DEFAULT null,\n`seller_id` VARCHAR(255) DEFAULT null, `shipping_limit_date` DATETIME DEFAULT null,\n`price` DECIMAL(10,2) DEFAULT null,\n`freight_value` DECIMAL(10,2) DEFAULT null\n);\nCREATE TABLE `review` (\n`review_id` VARCHAR(255) NOT NULL,\n`order_id` VARCHAR(255) DEFAULT null,\n`review_score` TINYINT DEFAULT null,\n`review_comment_title` VARCHAR(255) DEFAULT null,\n`review_comment_message` TEXT DEFAULT null,\n`review_creation_date` DATETIME DEFAULT null,\n`review_answer_timestamp` DATETIME DEFAULT null,\nPRIMARY KEY (`review_id`)\n);\nCREATE TABLE `order_time` (\n`order_id` VARCHAR(255) NOT NULL,\n`customer_id` VARCHAR(255) DEFAULT null,\n`y` INT DEFAULT null,\n`q` INT DEFAULT null,\n`m` INT DEFAULT null,\n`d` DATE DEFAULT null,\n`h` INT DEFAULT null,\n`order_purchase_timestamp` DATETIME DEFAULT null\n);\nCREATE TABLE `orders` (\n`order_id` VARCHAR(255) NOT NULL,\n`customer_id` VARCHAR(255) DEFAULT null,\n`order_status` VARCHAR(255) DEFAULT null,\n`order_purchase_timestamp` DATETIME DEFAULT null,\n`order_approved_at` DATETIME DEFAULT null,\n`order_delivered_carrier_date` DATETIME DEFAULT null,\n`order_delivered_customer_date` DATETIME DEFAULT null,\n`order_estimated_delivery_date` DATETIME DEFAULT null,\nPRIMARY KEY (`order_id`)\n);\nCREATE TABLE `product` (\n`product_id` VARCHAR(255) NOT NULL,\n`product_category_name` VARCHAR(255) DEFAULT null,\n`product_name_lenght` INT DEFAULT null,\n`product_description_lenght` INT DEFAULT null,\n`product_photos_qty` INT DEFAULT null,\n`product_weight_g` INT DEFAULT null,\n`product_length_cm` INT DEFAULT null,\n`product_height_cm` INT DEFAULT null,\n`product_width_cm` INT DEFAULT null,\nPRIMARY KEY (`product_id`)\n);\nCREATE TABLE `rfm` (\n`customer_id` VARCHAR(255) DEFAULT null,\n`user_type` VARCHAR(255) DEFAULT null,\n`shijian` DATE DEFAULT null\n);\n\nCREATE view total_order_value as select t.order_id,product_id,seller_id,(price*total)+(freight_value*total) as order_value from (select order_id,count(*) as total from item group by order_id) t join item on t.order_id=item.order_id;\n\nCREATE view order_detail as select a.order_id,product_id,seller_id, customer_id,round(order_value,2) as order_value, y,q,m,d,h,order_purchase_timestamp from total_order_value a inner join order_time b on a.order_id=b.order_id;\n
\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u4ee5\u4e0b SQL \u5bfc\u5165\u8bed\u53e5\uff0c\u5c06\u9884\u5148\u51c6\u5907\u7684 Demo \u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u7684\u76f8\u5e94\u8868\u4e2d\u3002
Note
\u8bf7\u6ce8\u610f\uff0c\u8def\u5f84 /root/data/table_name.csv
\u662f\u5404\u8868\u6570\u636e\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u60a8\u53ef\u4ee5\u53c2\u8003\u6b64\u8fc7\u7a0b\u81ea\u884c\u751f\u6210\u6570\u636e\u3002
use orders;\nload data local infile '/root/data/category.csv' into table category FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/review.csv' into table review FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/product.csv' into table product FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/item.csv' into table item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/order_time.csv' into table order_time FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/orders.csv' into table orders FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data local infile '/root/data/rfm.csv' into table rfm FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
\u6dfb\u52a0\u6570\u636e\u96c6\uff1a
\u5728 FineBI \u4e2d\uff0c\u70b9\u51fb\u516c\u5171\u6570\u636e\uff0c\u7136\u540e\u70b9\u51fb\u65b0\u5efa\u6587\u4ef6\u5939\uff0c\u521b\u5efa\u5e76\u9009\u62e9\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u7136\u540e\u70b9\u51fb\u65b0\u5efa\u6570\u636e\u96c6\uff0c\u9009\u62e9 SQL \u6570\u636e\u96c6\uff0c\u5c06 SQL \u67e5\u8be2\u6dfb\u52a0\u5230\u9009\u5b9a\u7684\u6587\u4ef6\u5939\u4e2d\u3002\u8f93\u5165\u6570\u636e\u96c6\u540d\u79f0\u5e76\u586b\u5199 SQL \u67e5\u8be2\uff0c\u5982\u4e0b\u6240\u793a\uff1a
select d,\ncount(order_id) as order_num,\ncount(DISTINCT customer_id)\nfrom orders.order_detail\ngroup by d\norder by d\n
\u60a8\u53ef\u4ee5\u70b9\u51fb\u9884\u89c8\u6309\u94ae\u67e5\u770b SQL \u67e5\u8be2\u7684\u7ed3\u679c\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\u8fdb\u884c\u4fdd\u5b58\uff1a
\u4e0b\u9762\u662f\u672c\u793a\u4f8b\u4e2d\u4f7f\u7528\u7684\u6240\u6709\u67e5\u8be2 SQL \u7684\u793a\u4f8b\uff1a
-- \u65e5\u6d3b\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\nselect d,\ncount(order_id) as order_num,\ncount(DISTINCT customer_id)\nfrom orders.order_detail\ngroup by d\norder by d\n\n-- \u6708\u6d3b\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\nselect count(DISTINCT customer_id),\ncount(order_id),\nconcat(y, '-', m)\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- \u5404\u65f6\u6bb5\u6d3b\u8dc3\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\nselect h,\ncount(DISTINCT customer_id),\ncount(order_id) order_num\nfrom orders.order_detail\ngroup by h\norder by h\n\n-- \u5404\u7c7b\u578b\u7528\u6237\u6570\u91cf\nSELECT count(*),\nuser_type\nfrom orders.rfm\nGROUP BY user_type\n\n-- \u6708 GMV\nselect y,m,\nsum(order_value),\nconcat(y, \"-\", m) month\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- \u5b63\u5ea6 GMV\nselect y,q,\nsum(order_value) gmv,\nconcat(y, \"\u5b63\u5ea6\", q) as quator\nfrom orders.order_detail\ngroup by y,q\norder by concat(y, \"\u5b63\u5ea6\", q) asc\n\n-- \u5b63\u5ea6 ARPU\nselect y,q,\nround((sum(order_value)/count(DISTINCT customer_id)),2) arpu,\nconcat(y, \"\u5b63\u5ea6\", q) as quator\nfrom orders.order_detail\ngroup by y,q\norder by y,q\n\n-- \u6708\u5ea6 ARPU\nselect y,m,\nround((sum(order_value)/count(DISTINCT customer_id)),2) arpu,\nconcat(y, \"-\", m) as month\nfrom orders.order_detail\ngroup by y,m\norder by y,m\n\n-- \u91cd\u8981\u633d\u7559\u7528\u6237\u70ed\u95e8\u6307\u6570\nSELECT e.product_category_name_english good_type,\nSUM(a.order_value) ordder_total_value,\nROUND(AVG(c.review_score), 2) good_review_score,\n(0.7*SUM(a.order_value)+\n\n0.3*10000*ROUND(AVG(c.review_score), 7))\ntop_rank_rate\nFROM orders.order_detail a\nINNER JOIN\n(SELECT customer_id\nfrom orders.rfm\nWHERE user_type='\u91cd\u8981\u633d\u7559\u7528\u6237' ) as b ON a.customer_id=b.customer_id\nLEFT JOIN orders.review c ON a.order_id=c.order_id\nLEFT JOIN orders.product d ON a.product_id=d.product_id\nLEFT JOIN orders.category e ON d.product_category_name=e.product_category_name\nwhere e.product_category_name_english is not NULL\nGROUP BY e.product_category_name_english limit 50\n\n-- \u4e00\u822c\u633d\u7559\u7528\u6237\u70ed\u95e8\u6307\u6570\nSELECT e.product_category_name_english good_type,\nSUM(a.order_value) ordder_total_value,\nROUND(AVG(c.review_score), 2) good_review_score,\n(0.7*SUM(a.order_value)+0.3*10000*ROUND(AVG(c.review_score), 7))\ntop_rank_rate\nFROM orders.order_detail a\nINNER JOIN\n(SELECT customer_id from orders.rfm\nWHERE user_type='\u4e00\u822c\u633d\u7559\u7528\u6237' ) as b ON a.customer_id=b.customer_id\nLEFT JOIN orders.review c ON a.order_id=c.order_id\nLEFT JOIN orders.product d ON a.product_id=d.product_id\nLEFT JOIN orders.category e ON d.product_category_name=e.product_category_name\nwhere e.product_category_name_english is not NULL\nGROUP BY e.product_category_name_english limit 50\n
\u66f4\u65b0\u6570\u636e\uff1a
\u4fdd\u5b58\u6570\u636e\u96c6\u540e\uff0c\u60a8\u9700\u8981\u70b9\u51fb\u66f4\u65b0\u6570\u636e\u6309\u94ae\uff0c\u7b49\u5f85\u6570\u636e\u66f4\u65b0\u5b8c\u6210\u540e\u624d\u80fd\u8fdb\u884c\u5206\u6790\uff1a
\u521b\u5efa\u5206\u6790\u4e3b\u9898\uff1a
\u672c\u793a\u4f8b\u7684\u5206\u6790\u4e3b\u9898\u7528\u4e8e\u53ef\u89c6\u5316\u5c55\u793a\u7535\u5546\u5e73\u53f0\u7684\u4e00\u822c\u633d\u7559\u7528\u6237\u3001\u91cd\u8981\u633d\u7559\u7528\u6237\u3001\u6708 ARPU\u3001\u5b63\u5ea6 ARPU\u3001\u4e0d\u540c\u65f6\u6bb5\u6d3b\u8dc3\u7528\u6237\u3001\u65e5\u6d3b\u8dc3\u7528\u6237\u3001\u6708\u6d3b\u8dc3\u7528\u6237\u6570\u53ca\u8ba2\u5355\u6570\u7b49\u6570\u636e\uff0c\u4ee5\u8f85\u52a9\u51b3\u7b56\u548c\u63d0\u5347\u4e1a\u52a1\u3002\u521b\u5efa\u5206\u6790\u4e3b\u9898\u7684\u5177\u4f53\u6b65\u9aa4\u5982\u4e0b\uff1a
Note: \u60a8\u53ef\u4ee5\u4f7f\u7528\u6279\u91cf\u9009\u62e9\u529f\u80fd\u6765\u9009\u62e9\u591a\u4e2a\u6570\u636e\u96c6\u8fdb\u884c\u4e3b\u9898\u5206\u6790\u3002
\u70b9\u51fb\u6dfb\u52a0\u7ec4\u4ef6\u6309\u94ae\uff0c\u9009\u62e9\u56fe\u8868\u7c7b\u578b\uff0c\u5c06\u5de6\u4fa7\u7684\u5b57\u6bb5\u6309\u9700\u8981\u62d6\u52a8\u5230\u53f3\u4fa7\uff0c\u53cc\u51fb\u4fee\u6539\u5b57\u6bb5\u53ef\u89c6\u5316\u540d\u79f0\uff0c\u5728\u4e0b\u65b9\u4fee\u6539\u7ec4\u4ef6\u540d\u79f0\uff0c\u7ec4\u4ef6\u540d\u79f0\u5373\u8be5\u7ec4\u4ef6\u6240\u5206\u6790\u7684\u62a5\u8868\u5185\u5bb9\uff1a
\u7ec4\u88c5\u4eea\u8868\u677f\uff1a
\u70b9\u51fb\u6dfb\u52a0\u4eea\u8868\u677f\uff0c\u5c06\u521a\u521a\u521b\u5efa\u7684\u7ec4\u4ef6\u6dfb\u52a0\u5230\u4eea\u8868\u677f\u4e2d\u3002\u60a8\u53ef\u4ee5\u81ea\u7531\u62d6\u52a8\u548c\u7f29\u653e\u7ec4\u4ef6\u7684\u5927\u5c0f\u548c\u4f4d\u7f6e\uff0c\u5e76\u5728\u4e0b\u65b9\u4fee\u6539\u7ec4\u4ef6\u540d\u79f0\uff0c\u4ee5\u63cf\u8ff0\u8be5\u7ec4\u4ef6\u6240\u5206\u6790\u7684\u62a5\u8868\u5185\u5bb9\u3002
\u53d1\u5e03\u4eea\u8868\u677f\uff1a
\u7ec4\u88c5\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u7533\u8bf7\u53d1\u5e03\uff0c\u8bbe\u7f6e\u53d1\u5e03\u540d\u79f0\u3001\u53d1\u5e03\u8282\u70b9\u548c\u5c55\u793a\u5e73\u53f0\u3002\u7136\u540e\u70b9\u51fb\u786e\u8ba4\uff0c\u60a8\u7684\u4eea\u8868\u677f\u5c06\u6210\u529f\u53d1\u5e03\u3002
\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u5728\u9996\u9875\u5bfc\u822a\u4e0b\u627e\u5230\u521a\u521a\u53d1\u5e03\u7684\u4eea\u8868\u677f\uff0c\u5e76\u67e5\u770b\u5176\u5c55\u793a\u6548\u679c\u3002
Superset \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u3001\u73b0\u4ee3\u7684\u3001\u8f7b\u91cf\u7ea7 BI \u5206\u6790\u5de5\u5177\uff0c\u80fd\u591f\u8fde\u63a5\u591a\u79cd\u6570\u636e\u6e90\u3001\u63d0\u4f9b\u4e30\u5bcc\u7684\u53ef\u89c6\u5316\u56fe\u8868\uff0c\u652f\u6301\u81ea\u5b9a\u4e49\u4eea\u8868\u76d8\uff0c\u5e2e\u52a9\u7528\u6237\u8f7b\u677e\u63a2\u7d22\u548c\u5448\u73b0\u6570\u636e\u3002
MatrixOne 1.0 \u7248\u672c\u73b0\u5728\u652f\u6301\u4e0e\u6570\u636e\u53ef\u89c6\u5316\u5de5\u5177 Superset \u96c6\u6210\u3002\u672c\u6307\u5357\u5c06\u5f15\u5bfc\u60a8\u5feb\u901f\u90e8\u7f72 MatrixOne \u548c Superset \u73af\u5883\uff0c\u901a\u8fc7\u5c06 MatrixOne \u4e0e Superset \u7684\u53ef\u89c6\u5316\u529f\u80fd\u76f8\u7ed3\u5408\uff0c\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u76d1\u63a7\u9762\u677f\uff0c\u7528\u4e8e\u76d1\u6d4b MatrixOne \u6570\u636e\u5e93\uff0c\u4f7f\u7528\u5176\u4e2d\u7684 'system_metric' \u6570\u636e\u3002
\u5982\u679c\u60a8\u5e0c\u671b\u8fdb\u4e00\u6b65\u6269\u5c55\u529f\u80fd\uff0c\u60a8\u8fd8\u53ef\u4ee5\u63a2\u7d22\u5176\u4ed6\u914d\u7f6e\u9009\u9879\uff0c\u4ee5\u76d1\u63a7\u6574\u4e2a MatrixOne \u6570\u636e\u5e93\u7684\u5404\u4e2a\u65b9\u9762\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#_2","title":"\u524d\u671f\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#_3","title":"\u786c\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u5bf9\u4e8e\u673a\u5668\u7684\u786c\u4ef6\u8981\u6c42\u4e0d\u9ad8\uff0c2C 4G \u7684\u5c0f\u578b\u865a\u62df\u673a\u5373\u53ef\u5b8c\u6210\u8fd9\u4e2a\u6d41\u7a0b\u7684\u529f\u80fd\u4f53\u9a8c\u3002
\u672c\u6b21\u5b9e\u8df5\u9700\u8981\u5b89\u88c5\u90e8\u7f72\u4ee5\u4e0b\u8f6f\u4ef6\u73af\u5883\uff1a
\u4f60\u53ef\u4ee5\u53c2\u7167\u4e0b\u9762\u7684\u7ae0\u8282\u8fdb\u884c\u5b89\u88c5\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#docker","title":"\u5b89\u88c5 Docker","text":"\u672c\u6b21\u5b9e\u8df5\u6240\u6709\u8f6f\u4ef6\u73af\u5883\u7684\u5b89\u88c5\u90fd\u662f\u57fa\u4e8e Docker \u8fdb\u884c\uff0c\u4f60\u53ef\u4ee5\u53c2\u7167 Docker \u5b98\u65b9\u6587\u6863\u8fdb\u884c\u5b89\u88c5\u5e76\u542f\u52a8 Docker\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#matrixone","title":"\u5b89\u88c5 MatrixOne","text":"\u4f60\u53ef\u4ee5\u53c2\u7167 macOS \u73af\u5883\u4e0b\u4f7f\u7528 Docker \u90e8\u7f72 MatrixOne \u6216 Linux \u73af\u5883\u4e0b\u4f7f\u7528 Docker \u90e8\u7f72 MatrixOne \u8fdb\u884c\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne.
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/Superset-connection/#superset","title":"\u5b89\u88c5 Superset","text":"\u4f7f\u7528 Docker \u90e8\u7f72\u5355\u8282\u70b9\u7684 Superset \u6b65\u9aa4\u5982\u4e0b\uff1a
\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 Docker \u4ee5\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ece Docker Hub \u4e2d\u62c9\u53d6 Superset \u7684\u955c\u50cf\uff1a
docker pull amancevice/superset\n
\u542f\u52a8 Superset \u955c\u50cf\uff1a
docker run -e \"SUPERSET_SECRET_KEY=your_secret_key_here\" --name superset -u 0 -d -p 8088:8088 amancevice/superset\n
Note
\u5b89\u5168\u5bc6\u94a5\u53ef\u901a\u8fc7 openssl rand -base64 $num
\u6765\u751f\u6210\uff0c\u4f8b\u5982\u751f\u6210\u5bc6\u94a5 openssl rand -base64 49
\u3002 \u53c2\u6570\u53ef\u53c2\u8003\u5b98\u7f51\u8bf4\u660e\uff1aYour App secret key will be used for securely signing the session cookie and encrypting sensitive information on the database. Make sure you are changing this key for your deployment with a strong key. You can generate a strong key using openssl rand -base64 42
. Alternatively you can set it with SUPERSET_SECRET_KEY
environment variable.
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521d\u59cb\u5316 Superset \u6570\u636e\u5e93\uff1a
docker exec -it superset superset db upgrade\n
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa Superset \u7ba1\u7406\u5458\u7528\u6237\uff0c\u6839\u636e\u63d0\u793a\u8f93\u5165\u76f8\u5173\u6ce8\u518c\u4fe1\u606f\uff1a
docker exec -it superset superset fab create-admin\n
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u9ed8\u8ba4\u8d26\u6237\uff1a
docker exec -it superset superset init\n
\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u670d\u52a1\uff0c\u540c\u65f6\u5f00\u542f\u7ebf\u7a0b\u3001\u81ea\u52a8\u91cd\u65b0\u52a0\u8f7d\u548c\u8c03\u8bd5\u6a21\u5f0f\uff1a
docker exec -it superset superset run --with-threads --reload --debugger\n
\u8bbf\u95ee Superset \u7684\u767b\u5f55\u9875\u9762\uff0c\u901a\u5e38\u662f http://ip:8080
\uff0c\u7136\u540e\u8f93\u5165\u60a8\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u767b\u5f55 Superset\u3002
Note: Superset \u7684\u7aef\u53e3\u53ef\u80fd\u662f 8080 \u6216 8088\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u60a8\u7684\u914d\u7f6e\uff1b\u7528\u6237\u540d\u548c\u5bc6\u7801\u662f\u60a8\u5728\u90e8\u7f72 Superset \u65f6\u8bbe\u7f6e\u7684\u3002
\u767b\u5f55\u540e\uff0c\u60a8\u5c06\u770b\u5230 Superset \u7684\u4e3b\u754c\u9762\u3002
\u521b\u5efa\u6570\u636e\u5e93\u8fde\u63a5\uff1a
\u5728 Superset \u4e2d\uff0c\u9996\u5148\u9700\u8981\u521b\u5efa\u4e0e MatrixOne \u7684\u6570\u636e\u5e93\u8fde\u63a5\u3002\u5728\u53f3\u4e0a\u89d2\u70b9\u51fb Settings\uff0c\u7136\u540e\u9009\u62e9 Database Connections\u3002
\u5728 Database Connections \u9875\u9762\uff0c\u70b9\u51fb + DATABASE \u6309\u94ae\uff0c\u5e76\u9009\u62e9 MySQL \u4f5c\u4e3a\u6570\u636e\u5e93\u7c7b\u578b\u3002
\u586b\u5199 MatrixOne \u6570\u636e\u5e93\u7684\u8fde\u63a5\u4fe1\u606f\uff0c\u5305\u62ec\u4e3b\u673a\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002
\u586b\u5199\u5b8c\u6bd5\u540e\uff0c\u70b9\u51fb CONNECT \u6309\u94ae\uff0c\u7136\u540e\u518d\u70b9\u51fb FINISH\u3002
\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 MatrixOne \u6570\u636e\u5e93\u521b\u5efa\u4e00\u4e2a\u76d1\u63a7\u4eea\u8868\u677f\u3002
\u70b9\u51fb\u9875\u9762\u4e0a\u7684 SQL > SQL Lab\uff0c\u9009\u62e9\u521a\u521a\u521b\u5efa\u7684 MatrixOne \u6570\u636e\u5e93\u8fde\u63a5\uff0c\u5e76\u7f16\u5199 SQL \u67e5\u8be2\u4ee5\u9009\u62e9\u8981\u76d1\u63a7\u7684\u6570\u636e\u8868\u3002
\u60a8\u53ef\u4ee5\u7f16\u5199\u591a\u4e2a\u67e5\u8be2\u6765\u76d1\u63a7\u4e0d\u540c\u7684\u6307\u6807\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b\u67e5\u8be2\u7684 SQL \u8bed\u53e5\uff1a
SELECT metric_name, collecttime, value\nFROM metric\nWHERE metric_name = 'sys_cpu_combined_percent' or metric_name = 'sys_cpu_seconds_total'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'server_storage_usage'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'server_connections'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_disk_read_bytes' OR metric_name = 'sys_disk_write_bytes'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_net_sent_bytes' OR metric_name = 'sys_net_recv_bytes'\nORDER BY collecttime DESC;\n
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sys_memory_available' OR metric_name = 'sys_memory_used'\nORDER BY collecttime DESC;\n
\u4e8b\u52a1\u9519\u8bef\u603b\u6570\uff1a
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sql_transaction_errors' OR metric_name = 'sql_transaction_total'\nORDER BY collecttime DESC;\n
SQL \u9519\u8bef\u603b\u6570\uff1a
SELECT metric_name, value, collecttime\nFROM metric\nWHERE metric_name = 'sql_statement_errors' OR metric_name = 'sql_statement_total'\nORDER BY collecttime DESC;\n
\u70b9\u51fb SAVE > Save dataset > SAVE & EXPLORE \u4fdd\u5b58\u4e0a\u9762\u7684\u6bcf\u4e2a\u67e5\u8be2\u5e76\u5c06\u5176\u7528\u4f5c\u540e\u7eed\u56fe\u8868\u7684\u6570\u636e\u6e90\u3002
\u7f16\u8f91\u56fe\u8868\uff1a
\u8fd9\u91cc\u6211\u4eec\u7528\u5176\u4e2d\u4e00\u4e2a\u67e5\u8be2\u4e3a\u4f8b\uff0c\u6765\u6f14\u793a\u5982\u4f55\u7f16\u8f91\u4e00\u4e2a\u53ef\u89c6\u5316\u7684\u56fe\u8868\u3002\u9996\u5148\uff0c\u6211\u4eec\u9009\u62e9 disk_read_write
\u7684\u67e5\u8be2\u4f5c\u4e3a\u56fe\u8868\u7684\u5236\u4f5c\u6570\u636e\u6e90\uff0c\u5728 SQL Lab \u4e2d\u5bf9\u5e94\u67e5\u8be2\u7684\u4e0b\u9762\u70b9\u51fb CREATE CHART \u6216\u8005\u5728\u4e0a\u4e00\u6b65\u4fdd\u5b58\u5b8c Query \u4e4b\u540e\uff0c\u9875\u9762\u5c06\u8df3\u8f6c\u81f3\u7f16\u8f91 Chart \u9875\u9762\uff1a
\u8fdb\u5165\u5230\u56fe\u8868\u7f16\u8f91\u7684\u9875\u9762\uff0c\u4f9d\u6b21\u9009\u62e9\u56fe\u8868\u7c7b\u578b\u3001\u65f6\u95f4\u5b57\u6bb5\u3001\u67e5\u8be2\u7684\u6307\u6807\u5217\u3001\u67e5\u8be2\u7684\u5206\u7ec4\u5217\u7b49\u9009\u9879\uff0c\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u9009\u62e9\u8fd0\u884c\uff1a
\u70b9\u51fb UPDATE CHART > SAVE\uff0c\u5c06\u7f16\u8f91\u597d\u7684 Chart \u4fdd\u5b58\u3002
\u521b\u5efa\u4e86\u591a\u4e2a\u56fe\u8868\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 Superset \u4e2d\u7ec4\u88c5\u5b83\u4eec\u4ee5\u521b\u5efa\u4e00\u4e2a\u76d1\u63a7\u4eea\u8868\u677f\uff1a
\u70b9\u51fb Dashboards\uff0c\u7136\u540e\u70b9\u51fb + DASHBOARD \u6765\u521b\u5efa\u65b0\u7684\u4eea\u8868\u677f\uff0c\u6216\u8005\u7f16\u8f91\u73b0\u6709\u7684\u4eea\u8868\u677f\u3002
\u5728\u4eea\u8868\u677f\u7f16\u8f91\u9875\u9762\uff0c\u4f60\u53ef\u4ee5\u4ece\u53f3\u4fa7\u7684 CHARTS \u5217\u8868\u4e2d\u62d6\u62fd\u5df2\u521b\u5efa\u7684\u56fe\u8868\u5230\u4eea\u8868\u677f\u4e0a\u8fdb\u884c\u7ec4\u88c5\u3002\u4f60\u4e5f\u53ef\u4ee5\u81ea\u7531\u8c03\u6574\u56fe\u8868\u7684\u4f4d\u7f6e\uff0c\u6dfb\u52a0\u6807\u9898\u7b49\u3002
\u60a8\u5df2\u7ecf\u6210\u529f\u5730\u8fde\u63a5\u4e86 MatrixOne \u6570\u636e\u5e93\u4e0e Superset\uff0c\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u76d1\u63a7\u4eea\u8868\u677f\uff0c\u4ee5\u53ef\u89c6\u5316\u5c55\u793a MatrixOne \u6570\u636e\u5e93\u7684\u91cd\u8981\u6307\u6807\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/","title":"\u901a\u8fc7\u6c38\u6d2a BI \u5b9e\u73b0 MatrixOne \u7684\u53ef\u89c6\u5316\u62a5\u8868","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_1","title":"\u6982\u8ff0","text":"\u6c38\u6d2a BI \u662f\u4e00\u6b3e\u5168\u9762\u7684\u5927\u6570\u636e\u5e73\u53f0\uff0c\u5b83\u6574\u5408\u4e86\u81ea\u670d\u52a1\u6570\u636e\u51c6\u5907\u3001\u63a2\u7d22\u6027\u81ea\u52a9\u5206\u6790\u3001\u6df1\u5ea6\u5206\u6790\u3001\u4f01\u4e1a\u7ea7\u7ba1\u7406\u548c\u9ad8\u6027\u80fd\u8ba1\u7b97\u529f\u80fd\uff0c\u63d0\u4f9b\u4e86\u4e00\u7ad9\u5f0f\u7684\u5927\u6570\u636e\u89e3\u51b3\u65b9\u6848\u3002\u6c38\u6d2a BI \u7684\u76ee\u6807\u662f\u4e3a\u5404\u79cd\u89c4\u6a21\u7684\u4f01\u4e1a\u63d0\u4f9b\u7075\u6d3b\u6613\u7528\u7684\u5168\u4e1a\u52a1\u94fe\u5927\u6570\u636e\u5206\u6790\u5de5\u5177\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u8f7b\u677e\u53d1\u6398\u5927\u6570\u636e\u7684\u4ef7\u503c\u5e76\u83b7\u5f97\u6df1\u523b\u7684\u6d1e\u5bdf\u529b\u3002
MatrixOne \u652f\u6301\u8fde\u63a5\u5230\u667a\u80fd\u6570\u636e\u5206\u6790\u5de5\u5177\u6c38\u6d2a BI\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7\u6c38\u6d2a BI \u8fde\u63a5\u5230\u5355\u673a\u7248 MatrixOne\uff0c\u5e76\u521b\u5efa\u5404\u79cd\u53ef\u89c6\u5316\u6570\u636e\u62a5\u8868\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u6253\u5f00\u6c38\u6d2a BI\uff0c\u9009\u62e9\u5de6\u4fa7\u7684\u6dfb\u52a0\u6570\u636e\u6e90 > +\uff08\u65b0\u5efa\u6570\u636e\u6e90\uff09\uff0c\u5728\u5f39\u51fa\u7684\u6570\u636e\u5e93\u9009\u9879\u4e2d\u9009\u62e9 MySQL\u3002
\u586b\u5199\u5b8c\u6210 MatrixOne \u6570\u636e\u5e93\u76f8\u5173\u7684\u8fde\u63a5\u4fe1\u606f\u540e\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u53f3\u4e0a\u89d2\u7684\u6d4b\u8bd5\u8fde\u63a5\u6309\u94ae\uff0c\u4ee5\u786e\u4fdd\u8fde\u63a5\u6210\u529f\u3002
\u8fde\u63a5\u6210\u529f\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u4ee5\u4fdd\u5b58\u6211\u4eec\u521a\u521a\u586b\u5199\u7684\u6570\u636e\u6e90\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_4","title":"\u521b\u5efa\u6570\u636e\u96c6","text":"\u5728\u6c38\u6d2a BI \u4e2d\uff0c\u9009\u62e9\u5de6\u4fa7\u7684\u521b\u5efa\u6570\u636e\u96c6\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u521a\u521a\u6dfb\u52a0\u7684\u6570\u636e\u6e90\u3002\u60a8\u5c06\u770b\u5230 MatrixOne \u6570\u636e\u5e93\u4e2d\u7684\u8868\u683c\u548c\u89c6\u56fe\u4fe1\u606f\u3002\u6839\u636e\u60a8\u7684\u4e1a\u52a1\u9700\u6c42\uff0c\u6dfb\u52a0\u81ea\u5b9a\u4e49 SQL\uff0c\u7136\u540e\u70b9\u51fb\u5237\u65b0\u6570\u636e\u3002\u67e5\u8be2\u7ed3\u679c\u5c06\u663e\u793a\u5728\u53f3\u4fa7\uff0c\u786e\u8ba4\u67e5\u8be2\u7ed3\u679c\u662f\u5426\u7b26\u5408\u9884\u671f\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u4ee5\u4fdd\u5b58\u6570\u636e\u96c6\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_5","title":"\u5236\u4f5c\u62a5\u544a","text":"\u9996\u5148\uff0c\u5728\u6c38\u6d2a BI \u4e2d\u9009\u62e9\u5de6\u4fa7\u7684\u5236\u4f5c\u62a5\u544a\u83dc\u5355\uff0c\u7136\u540e\u4ece\u53f3\u4fa7\u9009\u62e9\u5408\u9002\u7684\u56fe\u8868\u7ec4\u4ef6\u5e76\u62d6\u52a8\u5230\u5de6\u4fa7\u3002
\u9009\u62e9\u521a\u521a\u521b\u5efa\u7684\u6570\u636e\u96c6\uff0c\u5c06\u65f6\u95f4\u7ef4\u5ea6\u8bbe\u7f6e\u4e3a X \u8f74\uff0c\u5c06\u65e5\u8ba2\u5355\u6570\u548c\u6d3b\u8dc3\u7528\u6237\u6570\u8bbe\u7f6e\u4e3a Y \u8f74\u3002\u60a8\u53ef\u4ee5\u5c06\u5ea6\u91cf\u548c\u7ef4\u5ea6\u5b57\u6bb5\u6839\u636e\u9700\u8981\u62d6\u52a8\u5230\u76f8\u5e94\u7684\u4f4d\u7f6e\u3002\u7f16\u8f91\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u4fdd\u5b58\u4ee5\u4fdd\u5b58\u521a\u521a\u5236\u4f5c\u7684\u62a5\u544a\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/BI-Connection/yonghong-connection/#_6","title":"\u67e5\u770b\u62a5\u544a","text":"\u6700\u540e\uff0c\u5728\u6c38\u6d2a BI \u4e2d\u9009\u62e9\u67e5\u770b\u62a5\u544a\uff0c\u7136\u540e\u70b9\u51fb\u5de6\u4fa7\u7684\u6811\u72b6\u83dc\u5355\u4e2d\u6211\u4eec\u521a\u521a\u521b\u5efa\u7684\u62a5\u544a\u540d\u79f0\uff0c\u60a8\u5c06\u80fd\u591f\u67e5\u770b\u6211\u4eec\u4e0a\u9762\u5236\u4f5c\u7684\u62a5\u544a\u6548\u679c\u3002
\u60a8\u5df2\u7ecf\u6210\u529f\u5730\u4f7f\u7528\u6c38\u6d2a BI \u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\uff0c\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u62a5\u544a\uff0c\u7528\u4e8e\u53ef\u89c6\u5316\u5c55\u793a MatrixOne \u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/","title":"\u4f7f\u7528 DataX \u5c06\u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_1","title":"\u6982\u8ff0","text":"\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 DataX \u5de5\u5177\u5c06\u6570\u636e\u79bb\u7ebf\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u3002
DataX \u662f\u4e00\u6b3e\u7531\u963f\u91cc\u5f00\u6e90\u7684\u5f02\u6784\u6570\u636e\u6e90\u79bb\u7ebf\u540c\u6b65\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u7a33\u5b9a\u548c\u9ad8\u6548\u7684\u6570\u636e\u540c\u6b65\u529f\u80fd\uff0c\u65e8\u5728\u5b9e\u73b0\u5404\u79cd\u5f02\u6784\u6570\u636e\u6e90\u4e4b\u95f4\u7684\u9ad8\u6548\u6570\u636e\u540c\u6b65\u3002
DataX \u5c06\u4e0d\u540c\u6570\u636e\u6e90\u7684\u540c\u6b65\u5206\u4e3a\u4e24\u4e2a\u4e3b\u8981\u7ec4\u4ef6\uff1aReader\uff08\u8bfb\u53d6\u6570\u636e\u6e90\uff09 \u548c Writer\uff08\u5199\u5165\u76ee\u6807\u6570\u636e\u6e90\uff09\u3002DataX \u6846\u67b6\u7406\u8bba\u4e0a\u652f\u6301\u4efb\u4f55\u6570\u636e\u6e90\u7c7b\u578b\u7684\u6570\u636e\u540c\u6b65\u5de5\u4f5c\u3002
MatrixOne \u4e0e MySQL 8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u4f46\u7531\u4e8e DataX \u81ea\u5e26\u7684 MySQL Writer \u63d2\u4ef6\u9002\u914d\u7684\u662f MySQL 5.1 \u7684 JDBC \u9a71\u52a8\uff0c\u4e3a\u4e86\u63d0\u5347\u517c\u5bb9\u6027\uff0c\u793e\u533a\u5355\u72ec\u6539\u9020\u4e86\u57fa\u4e8e MySQL 8.0 \u9a71\u52a8\u7684 MatrixOneWriter \u63d2\u4ef6\u3002MatrixOneWriter \u63d2\u4ef6\u5b9e\u73b0\u4e86\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u76ee\u6807\u8868\u7684\u529f\u80fd\u3002\u5728\u5e95\u5c42\u5b9e\u73b0\u4e2d\uff0cMatrixOneWriter \u901a\u8fc7 JDBC \u8fde\u63a5\u5230\u8fdc\u7a0b MatrixOne \u6570\u636e\u5e93\uff0c\u5e76\u6267\u884c\u76f8\u5e94\u7684 insert into ...
SQL \u8bed\u53e5\u5c06\u6570\u636e\u5199\u5165 MatrixOne\uff0c\u540c\u65f6\u652f\u6301\u6279\u91cf\u63d0\u4ea4\u3002
MatrixOneWriter \u5229\u7528 DataX \u6846\u67b6\u4ece Reader \u83b7\u53d6\u751f\u6210\u7684\u534f\u8bae\u6570\u636e\uff0c\u5e76\u6839\u636e\u60a8\u914d\u7f6e\u7684 writeMode
\u751f\u6210\u76f8\u5e94\u7684 insert into...
\u8bed\u53e5\u3002\u5728\u9047\u5230\u4e3b\u952e\u6216\u552f\u4e00\u6027\u7d22\u5f15\u51b2\u7a81\u65f6\uff0c\u4f1a\u6392\u9664\u51b2\u7a81\u7684\u884c\u5e76\u7ee7\u7eed\u5199\u5165\u3002\u51fa\u4e8e\u6027\u80fd\u4f18\u5316\u7684\u8003\u8651\uff0c\u6211\u4eec\u91c7\u7528\u4e86 PreparedStatement + Batch
\u7684\u65b9\u5f0f\uff0c\u5e76\u8bbe\u7f6e\u4e86 rewriteBatchedStatements=true
\u9009\u9879\uff0c\u4ee5\u5c06\u6570\u636e\u7f13\u51b2\u5230\u7ebf\u7a0b\u4e0a\u4e0b\u6587\u7684\u7f13\u51b2\u533a\u4e2d\u3002\u53ea\u6709\u5f53\u7f13\u51b2\u533a\u7684\u6570\u636e\u91cf\u8fbe\u5230\u9884\u5b9a\u7684\u9608\u503c\u65f6\uff0c\u624d\u4f1a\u89e6\u53d1\u5199\u5165\u8bf7\u6c42\u3002
Note
\u6267\u884c\u6574\u4e2a\u4efb\u52a1\u81f3\u5c11\u9700\u8981\u62e5\u6709 insert into ...
\u7684\u6743\u9650\uff0c\u662f\u5426\u9700\u8981\u5176\u4ed6\u6743\u9650\u53d6\u51b3\u4e8e\u4f60\u5728\u4efb\u52a1\u914d\u7f6e\u4e2d\u7684 preSql
\u548c postSql
\u3002
MatrixOneWriter \u4e3b\u8981\u9762\u5411 ETL \u5f00\u53d1\u5de5\u7a0b\u5e08\uff0c\u4ed6\u4eec\u4f7f\u7528 MatrixOneWriter \u5c06\u6570\u636e\u4ece\u6570\u636e\u4ed3\u5e93\u5bfc\u5165\u5230 MatrixOne\u3002\u540c\u65f6\uff0cMatrixOneWriter \u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u6570\u636e\u8fc1\u79fb\u5de5\u5177\u4e3a DBA \u7b49\u7528\u6237\u63d0\u4f9b\u670d\u52a1\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u5f00\u59cb\u4f7f\u7528 DataX \u5c06\u6570\u636e\u5199\u5165 MatrixOne \u4e4b\u524d\uff0c\u9700\u8981\u5b8c\u6210\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\uff1a
plugin/writer/
\u76ee\u5f55\u4e0b\u3002\u4f7f\u7528 Mysql Client \u8fde\u63a5 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u8868\uff1a
CREATE DATABASE mo_demo;\nUSE mo_demo;\nCREATE TABLE m_user(\nM_ID INT NOT NULL,\nM_NAME CHAR(25) NOT NULL\n);\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_4","title":"\u914d\u7f6e\u6570\u636e\u6e90","text":"\u672c\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u5185\u5b58\u4e2d\u751f\u6210\u7684\u6570\u636e\u4f5c\u4e3a\u6570\u636e\u6e90\uff1a
\"reader\": {\n\"name\": \"streamreader\", \"parameter\": {\n\"column\" : [ #\u53ef\u4ee5\u5199\u591a\u4e2a\u5217\n{\n\"value\": 20210106, #\u8868\u793a\u8be5\u5217\u7684\u503c\n\"type\": \"long\" #\u8868\u793a\u8be5\u5217\u7684\u7c7b\u578b\n},\n{\n\"value\": \"matrixone\",\n\"type\": \"string\"\n}\n],\n\"sliceRecordCount\": 1000 #\u8868\u793a\u8981\u6253\u5370\u591a\u5c11\u6b21\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_5","title":"\u7f16\u5199\u4f5c\u4e1a\u914d\u7f6e\u6587\u4ef6","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u914d\u7f6e\u6a21\u677f\uff1a
python datax.py -r {YOUR_READER} -w matrixonewriter\n
\u7f16\u5199\u4f5c\u4e1a\u7684\u914d\u7f6e\u6587\u4ef6 stream2matrixone.json
\uff1a
{\n\"job\": {\n\"setting\": {\n\"speed\": {\n\"channel\": 1\n}\n},\n\"content\": [\n{\n\"reader\": {\n\"name\": \"streamreader\",\n\"parameter\": {\n\"column\" : [\n{\n\"value\": 20210106,\n\"type\": \"long\"\n},\n{\n\"value\": \"matrixone\",\n\"type\": \"string\"\n}\n],\n\"sliceRecordCount\": 1000\n}\n},\n\"writer\": {\n\"name\": \"matrixonewriter\",\n\"parameter\": {\n\"writeMode\": \"insert\",\n\"username\": \"root\",\n\"password\": \"111\",\n\"column\": [\n\"M_ID\",\n\"M_NAME\"\n],\n\"preSql\": [\n\"delete from m_user\"\n],\n\"connection\": [\n{\n\"jdbcUrl\": \"jdbc:mysql://127.0.0.1:6001/mo_demo\",\n\"table\": [\n\"m_user\"\n]\n}\n]\n}\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#datax","title":"\u542f\u52a8 DataX","text":"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 DataX\uff1a
$ cd {YOUR_DATAX_DIR_BIN}\n$ python datax.py stream2matrixone.json\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_6","title":"\u67e5\u770b\u8fd0\u884c\u7ed3\u679c","text":"\u4f7f\u7528 Mysql Client \u8fde\u63a5 MatrixOne\uff0c\u4f7f\u7528 select
\u67e5\u8be2\u63d2\u5165\u7684\u7ed3\u679c\u3002\u5185\u5b58\u4e2d\u7684 1000 \u6761\u6570\u636e\u5df2\u6210\u529f\u5199\u5165 MatrixOne\u3002
mysql> select * from m_user limit 5;\n+----------+-----------+\n| m_id | m_name |\n+----------+-----------+\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n| 20210106 | matrixone |\n+----------+-----------+\n5 rows in set (0.01 sec)\n\nmysql> select count(*) from m_user limit 5;\n+----------+\n| count(*) |\n+----------+\n| 1000 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_7","title":"\u53c2\u6570\u8bf4\u660e","text":"\u4ee5\u4e0b\u662f MatrixOneWriter \u7684\u4e00\u4e9b\u5e38\u7528\u53c2\u6570\u8bf4\u660e\uff1a
\u53c2\u6570\u540d\u79f0 \u53c2\u6570\u63cf\u8ff0 \u662f\u5426\u5fc5\u9009 \u9ed8\u8ba4\u503c jdbcUrl \u76ee\u6807\u6570\u636e\u5e93\u7684 JDBC \u8fde\u63a5\u4fe1\u606f\u3002DataX \u5728\u8fd0\u884c\u65f6\u4f1a\u5728\u63d0\u4f9b\u7684jdbcUrl
\u540e\u9762\u8ffd\u52a0\u4e00\u4e9b\u5c5e\u6027\uff0c\u4f8b\u5982\uff1ayearIsDateType=false&zeroDateTimeBehavior=CONVERT_TO_NULL&rewriteBatchedStatements=true&tinyInt1isBit=false&serverTimezone=Asia/Shanghai
\u3002 \u662f \u65e0 username \u76ee\u6807\u6570\u636e\u5e93\u7684\u7528\u6237\u540d\u3002 \u662f \u65e0 password \u76ee\u6807\u6570\u636e\u5e93\u7684\u5bc6\u7801\u3002 \u662f \u65e0 table \u76ee\u6807\u8868\u7684\u540d\u79f0\u3002\u652f\u6301\u5199\u5165\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\uff0c\u5982\u679c\u914d\u7f6e\u591a\u5f20\u8868\uff0c\u5fc5\u987b\u786e\u4fdd\u5b83\u4eec\u7684\u7ed3\u6784\u4fdd\u6301\u4e00\u81f4\u3002 \u662f \u65e0 column \u76ee\u6807\u8868\u4e2d\u9700\u8981\u5199\u5165\u6570\u636e\u7684\u5b57\u6bb5\uff0c\u5b57\u6bb5\u4e4b\u95f4\u7528\u82f1\u6587\u9017\u53f7\u5206\u9694\u3002\u4f8b\u5982\uff1a\"column\": [\"id\",\"name\",\"age\"]
\u3002\u5982\u679c\u8981\u5199\u5165\u6240\u6709\u5217\uff0c\u53ef\u4ee5\u4f7f\u7528 *
\u8868\u793a\uff0c\u4f8b\u5982\uff1a\"column\": [\"*\"]
\u3002 \u662f \u65e0 preSql \u5199\u5165\u6570\u636e\u5230\u76ee\u6807\u8868\u4e4b\u524d\uff0c\u4f1a\u6267\u884c\u8fd9\u91cc\u914d\u7f6e\u7684\u6807\u51c6 SQL \u8bed\u53e5\u3002 \u5426 \u65e0 postSql \u5199\u5165\u6570\u636e\u5230\u76ee\u6807\u8868\u4e4b\u540e\uff0c\u4f1a\u6267\u884c\u8fd9\u91cc\u914d\u7f6e\u7684\u6807\u51c6 SQL \u8bed\u53e5\u3002 \u5426 \u65e0 writeMode \u63a7\u5236\u5199\u5165\u6570\u636e\u5230\u76ee\u6807\u8868\u65f6\u4f7f\u7528\u7684 SQL \u8bed\u53e5\uff0c\u53ef\u4ee5\u9009\u62e9 insert
\u6216 update
\u3002 insert
\u6216 update
insert
batchSize \u4e00\u6b21\u6027\u6279\u91cf\u63d0\u4ea4\u7684\u8bb0\u5f55\u6570\u5927\u5c0f\uff0c\u53ef\u4ee5\u663e\u8457\u51cf\u5c11 DataX \u4e0e MatrixOne \u7684\u7f51\u7edc\u4ea4\u4e92\u6b21\u6570\uff0c\u63d0\u9ad8\u6574\u4f53\u541e\u5410\u91cf\u3002\u4f46\u662f\u8bbe\u7f6e\u8fc7\u5927\u53ef\u80fd\u5bfc\u81f4 DataX \u8fd0\u884c\u8fdb\u7a0b\u5185\u5b58\u6ea2\u51fa \u5426 1024"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_8","title":"\u7c7b\u578b\u8f6c\u6362","text":"MatrixOneWriter \u652f\u6301\u5927\u591a\u6570 MatrixOne \u6570\u636e\u7c7b\u578b\uff0c\u4f46\u4e5f\u6709\u5c11\u6570\u7c7b\u578b\u5c1a\u672a\u652f\u6301\uff0c\u9700\u8981\u7279\u522b\u6ce8\u610f\u4f60\u7684\u6570\u636e\u7c7b\u578b\u3002
\u4ee5\u4e0b\u662f MatrixOneWriter \u9488\u5bf9 MatrixOne \u6570\u636e\u7c7b\u578b\u7684\u8f6c\u6362\u5217\u8868\uff1a
DataX \u5185\u90e8\u7c7b\u578b MatrixOne \u6570\u636e\u7c7b\u578b Long int, tinyint, smallint, bigint Double float, double, decimal String varchar, char, text Date date, datetime, timestamp, time Boolean bool Bytes blob"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_9","title":"\u53c2\u8003\u5176\u4ed6\u8bf4\u660e","text":"MatrixOne \u517c\u5bb9 MySQL \u534f\u8bae\uff0cMatrixOneWriter \u5b9e\u9645\u4e0a\u662f\u5bf9 MySQL Writer \u8fdb\u884c\u4e86\u4e00\u4e9b JDBC \u9a71\u52a8\u7248\u672c\u4e0a\u7684\u8c03\u6574\u540e\u7684\u6539\u9020\u7248\u672c\uff0c\u4f60\u4ecd\u7136\u53ef\u4ee5\u4f7f\u7528 MySQL Writer \u6765\u5199\u5165 MatrixOne\u3002
\u5728 DataX \u4e2d\u6dfb\u52a0 MatrixOne Writer\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u4e0b\u8f7d matrixonewriter.zip\uff0c\u7136\u540e\u5c06\u5176\u89e3\u538b\u7f29\u5230 DataX \u9879\u76ee\u6839\u76ee\u5f55\u7684 plugin/writer/
\u76ee\u5f55\u4e0b\uff0c\u5373\u53ef\u5f00\u59cb\u4f7f\u7528\u3002
MatrixOne \u64c5\u957f HTAP \u573a\u666f\u7684\u4e8b\u52a1\u5904\u7406\u548c\u4f4e\u5ef6\u8fdf\u5206\u6790\u8ba1\u7b97\uff0cElasticSearch \u64c5\u957f\u5168\u6587\u68c0\u7d22\uff0c\u4e24\u8005\u505a\u4e3a\u6d41\u884c\u7684\u641c\u7d22\u548c\u5206\u6790\u5f15\u64ce\uff0c\u7ed3\u5408\u8d77\u6765\u53ef\u5f62\u6210\u66f4\u5b8c\u5584\u7684\u5168\u573a\u666f\u5206\u6790\u89e3\u51b3\u65b9\u6848\u3002\u4e3a\u4e86\u5728\u4e0d\u540c\u573a\u666f\u95f4\u8fdb\u884c\u6570\u636e\u7684\u9ad8\u6548\u6d41\u8f6c\uff0c\u6211\u4eec\u53ef\u901a\u8fc7 DataX \u8fdb\u884c MatrixOne \u4e0e ElasticSearch \u95f4\u7684\u6570\u636e\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_10","title":"\u73af\u5883\u51c6\u5907","text":"MatrixOne \u7248\u672c\uff1a1.1.3
Elasticsearch \u7248\u672c\uff1a7.10.2
DataX \u7248\u672c\uff1aDataX_v202309
\u521b\u5efa\u6570\u636e\u5e93 mo
\uff0c\u5e76\u5728\u8be5\u5e93\u521b\u5efa\u6570\u636e\u8868 person\uff1a
create database mo;\nCREATE TABLE mo.`person` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`birthday` DATE DEFAULT NULL\n);\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#elasticsearch","title":"\u5728 ElasticSearch \u4e2d\u521b\u5efa\u7d22\u5f15","text":"\u521b\u5efa\u540d\u79f0\u4e3a person \u7684\u7d22\u5f15\uff08\u4e0b\u6587 -u
\u53c2\u6570\u540e\u4e3a ElasticSearch \u4e2d\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u672c\u5730\u6d4b\u8bd5\u65f6\u53ef\u6309\u9700\u8fdb\u884c\u4fee\u6539\u6216\u5220\u9664\uff09\uff1a
curl -X PUT \"http://127.0.0.1:9200/person\" -u elastic:elastic\n
\u8f93\u51fa\u5982\u4e0b\u4fe1\u606f\u8868\u793a\u521b\u5efa\u6210\u529f\uff1a
{\"acknowledged\":true,\"shards_acknowledged\":true,\"index\":\"person\"}\n
\u7ed9\u7d22\u5f15 person \u6dfb\u52a0\u5b57\u6bb5\uff1a
curl -X PUT \"127.0.0.1:9200/person/_mapping\" -H 'Content-Type: application/json' -u elastic:elastic -d'\n{\n \"properties\": {\n \"id\": { \"type\": \"integer\" },\n \"name\": { \"type\": \"text\" },\n \"birthday\": {\"type\": \"date\"}\n }\n}\n'\n
\u8f93\u51fa\u5982\u4e0b\u4fe1\u606f\u8868\u793a\u8bbe\u7f6e\u6210\u529f\uff1a
{\"acknowledged\":true}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#elasticsearch_1","title":"\u4e3a ElasticSearch \u7d22\u5f15\u6dfb\u52a0\u6570\u636e","text":"\u901a\u8fc7 curl \u547d\u4ee4\u6dfb\u52a0\u4e09\u6761\u6570\u636e\uff1a
curl -X POST '127.0.0.1:9200/person/_bulk' -H 'Content-Type: application/json' -u elastic:elastic -d '\n{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":1}}\n{\"id\": 1,\"name\": \"MatrixOne\",\"birthday\": \"1992-08-08\"}\n{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":2}}\n{\"id\": 2,\"name\": \"MO\",\"birthday\": \"1993-08-08\"}\n{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":3}}\n{\"id\": 3,\"name\": \"\u58a8\u58a8\",\"birthday\": \"1994-08-08\"}\n'
\u8f93\u51fa\u5982\u4e0b\u4fe1\u606f\u8868\u793a\u6267\u884c\u6210\u529f\uff1a
{\"took\":5,\"errors\":false,\"items\":[{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":\"1\",\"_version\":1,\"result\":\"created\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"_seq_no\":0,\"_primary_term\":1,\"status\":201}},{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":\"2\",\"_version\":1,\"result\":\"created\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"_seq_no\":1,\"_primary_term\":1,\"status\":201}},{\"index\":{\"_index\":\"person\",\"_type\":\"_doc\",\"_id\":\"3\",\"_version\":1,\"result\":\"created\",\"_shards\":{\"total\":2,\"successful\":1,\"failed\":0},\"_seq_no\":2,\"_primary_term\":1,\"status\":201}}]}\n
\u67e5\u770b\u7d22\u5f15\u4e2d\u6240\u6709\u5185\u5bb9\uff1a
curl -u elastic:elastic -X GET http://127.0.0.1:9200/person/_search?pretty -H 'Content-Type: application/json' -d'\n{\n \"query\" : {\n \"match_all\": {}\n }\n}'\n
\u53ef\u6b63\u5e38\u770b\u5230\u7d22\u5f15\u4e2d\u65b0\u589e\u7684\u6570\u636e\u5373\u8868\u793a\u6267\u884c\u6210\u529f\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#datax_1","title":"\u4f7f\u7528 DataX \u5bfc\u5165\u6570\u636e","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#1-datax","title":"1. \u4e0b\u8f7d\u5e76\u89e3\u538b DataX","text":"DataX \u89e3\u538b\u540e\u76ee\u5f55\u5982\u4e0b\uff1a
[root@node01 datax]# ll\ntotal 4\ndrwxr-xr-x. 2 root root 59 Nov 28 13:48 bin\ndrwxr-xr-x. 2 root root 68 Oct 11 09:55 conf\ndrwxr-xr-x. 2 root root 22 Oct 11 09:55 job\ndrwxr-xr-x. 2 root root 4096 Oct 11 09:55 lib\ndrwxr-xr-x. 4 root root 42 Oct 12 18:42 log\ndrwxr-xr-x. 4 root root 42 Oct 12 18:42 log_perf\ndrwxr-xr-x. 4 root root 34 Oct 11 09:55 plugin\ndrwxr-xr-x. 2 root root 23 Oct 11 09:55 script\ndrwxr-xr-x. 2 root root 24 Oct 11 09:55 tmp\n
\u4e3a\u4fdd\u8bc1\u8fc1\u79fb\u7684\u6613\u7528\u6027\u548c\u9ad8\u6548\u6027\uff0cMatrixOne \u793e\u533a\u5f00\u53d1\u4e86 elasticsearchreader
\u4ee5\u53ca matrixonewriter
\u4e24\u4e2a\u63d2\u4ef6\uff0c\u5c06 elasticsearchreader.zip \u4e0b\u8f7d\u540e\u4f7f\u7528 unzip
\u547d\u4ee4\u89e3\u538b\u81f3 datax/plugin/reader
\u76ee\u5f55\u4e0b\uff08\u6ce8\u610f\u4e0d\u8981\u5728\u8be5\u76ee\u5f55\u4e2d\u4fdd\u7559\u63d2\u4ef6 zip \u5305\uff0c\u5173\u4e8e elasticsearchreader \u7684\u8be6\u7ec6\u4ecb\u7ecd\u53ef\u53c2\u8003\u63d2\u4ef6\u5305\u5185\u7684 elasticsearchreader.md \u6587\u6863\uff09\uff0c\u540c\u6837\uff0c\u5c06 matrixonewriter.zip \u4e0b\u8f7d\u540e\u89e3\u538b\u81f3 datax/plugin/writer
\u76ee\u5f55\u4e0b\uff0cmatrixonewriter \u662f\u793e\u533a\u57fa\u4e8e mysqlwriter \u7684\u6539\u9020\u7248\uff0c\u4f7f\u7528 mysql-connector-j-8.0.33.jar \u9a71\u52a8\u6765\u4fdd\u8bc1\u66f4\u597d\u7684\u6027\u80fd\u548c\u517c\u5bb9\u6027\uff0cwriter \u90e8\u5206\u7684\u5176\u8bed\u6cd5\u53ef\u53c2\u8003\u4e0a\u6587\u201c\u53c2\u6570\u8bf4\u660e\u201d\u7ae0\u8282\u3002
\u5728\u8fdb\u884c\u540e\u7eed\u7684\u64cd\u4f5c\u524d\uff0c\u8bf7\u5148\u68c0\u67e5\u63d2\u4ef6\u662f\u5426\u5df2\u6b63\u786e\u5206\u53d1\u5728\u5bf9\u5e94\u7684\u4f4d\u7f6e\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#2-elasticsearch-matrixone","title":"2. \u7f16\u5199 ElasticSearch \u81f3 MatrixOne \u7684\u8fc1\u79fb\u4f5c\u4e1a\u6587\u4ef6","text":"DataX \u4f7f\u7528 json \u6587\u4ef6\u6765\u914d\u7f6e\u4f5c\u4e1a\u4fe1\u606f\uff0c\u7f16\u5199\u4f5c\u4e1a\u6587\u4ef6\u4f8b\u5982 es2mo.json\uff0c\u4e60\u60ef\u6027\u7684\u53ef\u4ee5\u5c06\u5176\u5b58\u653e\u5728 datax/job
\u76ee\u5f55\u4e2d\uff1a
{\n\"job\":{\n\"setting\":{\n\"speed\":{\n\"channel\":1\n},\n\"errorLimit\":{\n\"record\":0,\n\"percentage\":0.02\n}\n},\n\"content\":[\n{\n\"reader\":{\n\"name\":\"elasticsearchreader\",\n\"parameter\":{\n\"endpoint\":\"http://127.0.0.1:9200\",\n\"accessId\":\"elastic\",\n\"accessKey\":\"elastic\",\n\"index\":\"person\",\n\"type\":\"_doc\",\n\"headers\":{\n\n},\n\"scroll\":\"3m\",\n\"search\":[\n{\n\"query\":{\n\"match_all\":{\n\n}\n}\n}\n],\n\"table\":{\n\"filter\":\"\",\n\"nameCase\":\"UPPERCASE\",\n\"column\":[\n{\n\"name\":\"id\",\n\"type\":\"integer\"\n},\n{\n\"name\":\"name\",\n\"type\":\"text\"\n},\n{\n\"name\":\"birthday\",\n\"type\":\"date\"\n}\n]\n}\n}\n},\n\"writer\":{\n\"name\":\"matrixonewriter\",\n\"parameter\":{\n\"username\":\"root\",\n\"password\":\"111\",\n\"column\":[\n\"id\",\n\"name\",\n\"birthday\"\n],\n\"connection\":[\n{\n\"table\":[\n\"person\"\n],\n\"jdbcUrl\":\"jdbc:mysql://127.0.0.1:6001/mo\"\n}\n]\n}\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#3","title":"3. \u6267\u884c\u8fc1\u79fb\u4efb\u52a1","text":"\u8fdb\u5165 datax \u5b89\u88c5\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u8fc1\u79fb\u4f5c\u4e1a\uff1a
cd datax\npython bin/datax.py job/es2mo.json\n
\u4f5c\u4e1a\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
2023-11-28 15:55:45.642 [job-0] INFO StandAloneJobContainerCommunicator - Total 3 records, 67 bytes | Speed 6B/s, 0 records/s | Error 0 records, 0 bytes | All Task WaitWriterTime 0.000s | All Task WaitReaderTime 0.456s | Percentage 100.00%\n2023-11-28 15:55:45.644 [job-0] INFO JobContainer - \n\u4efb\u52a1\u542f\u52a8\u65f6\u523b : 2023-11-28 15:55:31\n\u4efb\u52a1\u7ed3\u675f\u65f6\u523b : 2023-11-28 15:55:45\n\u4efb\u52a1\u603b\u8ba1\u8017\u65f6 : 14s\n\u4efb\u52a1\u5e73\u5747\u6d41\u91cf : 6B/s\n\u8bb0\u5f55\u5199\u5165\u901f\u5ea6 : 0rec/s\n\u8bfb\u51fa\u8bb0\u5f55\u603b\u6570 : 3\n\u8bfb\u5199\u5931\u8d25\u603b\u6570 : 0\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#4-matrixone","title":"4. \u5728 MatrixOne \u4e2d\u67e5\u770b\u8fc1\u79fb\u540e\u6570\u636e","text":"\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\u67e5\u770b\u76ee\u6807\u8868\u4e2d\u7684\u7ed3\u679c\uff0c\u786e\u8ba4\u8fc1\u79fb\u5df2\u5b8c\u6210\uff1a
mysql> select * from mo.person;\n+------+-----------+------------+\n| id | name | birthday |\n+------+-----------+------------+\n| 1 | MatrixOne | 1992-08-08 |\n| 2 | MO | 1993-08-08 |\n| 3 | \u58a8\u58a8 | 1994-08-08 |\n+------+-----------+------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#5-matrixone-elasticsearch","title":"5. \u7f16\u5199 MatrixOne \u81f3 ElasticSearch \u7684\u4f5c\u4e1a\u6587\u4ef6","text":"\u7f16\u5199 datax \u4f5c\u4e1a\u6587\u4ef6 mo2es.json\uff0c\u540c\u6837\u653e\u5728 datax/job
\u76ee\u5f55\uff0cMatrixOne \u9ad8\u5ea6\u517c\u5bb9 MySQL \u534f\u8bae\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 mysqlreader \u6765\u901a\u8fc7 jdbc \u65b9\u5f0f\u8bfb\u53d6 MatrixOne \u4e2d\u7684\u6570\u636e\uff1a
{\n\"job\": {\n\"setting\": {\n\"speed\": {\n\"channel\": 1\n},\n\"errorLimit\": {\n\"record\": 0,\n\"percentage\": 0.02\n}\n},\n\"content\": [{\n\"reader\": {\n\"name\": \"mysqlreader\",\n\"parameter\": {\n\"username\": \"root\",\n\"password\": \"111\",\n\"column\": [\n\"id\",\n\"name\",\n\"birthday\"\n],\n\"splitPk\": \"id\",\n\"connection\": [{\n\"table\": [\n\"person\"\n],\n\"jdbcUrl\": [\n\"jdbc:mysql://127.0.0.1:6001/mo\"\n]\n}]\n}\n},\n\"writer\": {\n\"name\": \"elasticsearchwriter\",\n\"parameter\": {\n\"endpoint\": \"http://127.0.0.1:9200\",\n\"accessId\": \"elastic\",\n\"accessKey\": \"elastic\",\n\"index\": \"person\",\n\"type\": \"_doc\",\n\"cleanup\": true,\n\"settings\": {\n\"index\": {\n\"number_of_shards\": 1,\n\"number_of_replicas\": 1\n}\n},\n\"discovery\": false,\n\"batchSize\": 1000,\n\"splitter\": \",\",\n\"column\": [{\n\"name\": \"id\",\n\"type\": \"integer\"\n},\n{\n\"name\": \"name\",\n\"type\": \"text\"\n},\n{\n\"name\": \"birthday\",\n\"type\": \"date\"\n}\n]\n\n}\n\n}\n}]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#6matrixone","title":"6.MatrixOne \u6570\u636e\u51c6\u5907","text":"truncate table mo.person;\nINSERT into mo.person (id, name, birthday)\nVALUES(1, 'mo101', '2023-07-09'),(2, 'mo102', '2023-07-08'),(3, 'mo103', '2023-07-12');\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#7-matrixone-elasticsearch","title":"7. \u6267\u884c MatrixOne \u5411 ElasticSearch \u7684\u8fc1\u79fb\u4efb\u52a1","text":"\u8fdb\u5165 datax \u5b89\u88c5\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4
cd datax\npython bin/datax.py job/mo2es.json\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
2023-11-28 17:38:04.795 [job-0] INFO StandAloneJobContainerCommunicator - Total 3 records, 42 bytes | Speed 4B/s, 0 records/s | Error 0 records, 0 bytes | All Task WaitWriterTime 0.000s | All Task WaitReaderTime 0.000s | Percentage 100.00%\n2023-11-28 17:38:04.799 [job-0] INFO JobContainer - \n\u4efb\u52a1\u542f\u52a8\u65f6\u523b : 2023-11-28 17:37:49\n\u4efb\u52a1\u7ed3\u675f\u65f6\u523b : 2023-11-28 17:38:04\n\u4efb\u52a1\u603b\u8ba1\u8017\u65f6 : 15s\n\u4efb\u52a1\u5e73\u5747\u6d41\u91cf : 4B/s\n\u8bb0\u5f55\u5199\u5165\u901f\u5ea6 : 0rec/s\n\u8bfb\u51fa\u8bb0\u5f55\u603b\u6570 : 3\n\u8bfb\u5199\u5931\u8d25\u603b\u6570 : 0\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#8","title":"8. \u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 Elasticsearch \u4e2d\u67e5\u770b\u7ed3\u679c
curl -u elastic:elastic -X GET http://127.0.0.1:9200/person/_search?pretty -H 'Content-Type: application/json' -d'\n{\n \"query\" : {\n \"match_all\": {}\n }\n}'\n
\u7ed3\u679c\u663e\u793a\u5982\u4e0b\uff0c\u8868\u793a\u8fc1\u79fb\u4f5c\u4e1a\u5df2\u6b63\u5e38\u5b8c\u6210\uff1a
{\n\"took\" : 7,\n\"timed_out\" : false,\n\"_shards\" : {\n\"total\" : 1,\n\"successful\" : 1,\n\"skipped\" : 0,\n\"failed\" : 0\n},\n\"hits\" : {\n\"total\" : {\n\"value\" : 3,\n\"relation\" : \"eq\"\n},\n\"max_score\" : 1.0,\n\"hits\" : [\n{\n\"_index\" : \"person\",\n\"_type\" : \"_doc\",\n\"_id\" : \"dv9QFYwBPwIzfbNQfgG1\",\n\"_score\" : 1.0,\n\"_source\" : {\n\"birthday\" : \"2023-07-09T00:00:00.000+08:00\",\n\"name\" : \"mo101\",\n\"id\" : 1\n}\n},\n{\n\"_index\" : \"person\",\n\"_type\" : \"_doc\",\n\"_id\" : \"d_9QFYwBPwIzfbNQfgG1\",\n\"_score\" : 1.0,\n\"_source\" : {\n\"birthday\" : \"2023-07-08T00:00:00.000+08:00\",\n\"name\" : \"mo102\",\n\"id\" : 2\n}\n},\n{\n\"_index\" : \"person\",\n\"_type\" : \"_doc\",\n\"_id\" : \"eP9QFYwBPwIzfbNQfgG1\",\n\"_score\" : 1.0,\n\"_source\" : {\n\"birthday\" : \"2023-07-12T00:00:00.000+08:00\",\n\"name\" : \"mo103\",\n\"id\" : 3\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/DataX-write/#_11","title":"\u5e38\u89c1\u95ee\u9898","text":"Q: \u5728\u8fd0\u884c\u65f6\uff0c\u6211\u9047\u5230\u4e86\u201c\u914d\u7f6e\u4fe1\u606f\u9519\u8bef\uff0c\u60a8\u63d0\u4f9b\u7684\u914d\u7f6e\u6587\u4ef6/{YOUR_MATRIXONE_WRITER_PATH}/plugin.json \u4e0d\u5b58\u5728\u201d\u7684\u95ee\u9898\u8be5\u600e\u4e48\u5904\u7406\uff1f
A: DataX \u5728\u542f\u52a8\u65f6\u4f1a\u5c1d\u8bd5\u67e5\u627e\u76f8\u4f3c\u7684\u6587\u4ef6\u5939\u4ee5\u5bfb\u627e plugin.json \u6587\u4ef6\u3002\u5982\u679c matrixonewriter.zip \u6587\u4ef6\u4e5f\u5b58\u5728\u4e8e\u76f8\u540c\u7684\u76ee\u5f55\u4e0b\uff0cDataX \u5c06\u5c1d\u8bd5\u4ece .../datax/plugin/writer/matrixonewriter.zip/plugin.json
\u4e2d\u67e5\u627e\u3002\u5728 MacOS \u73af\u5883\u4e0b\uff0cDataX \u8fd8\u4f1a\u5c1d\u8bd5\u4ece .../datax/plugin/writer/.DS_Store/plugin.json
\u4e2d\u67e5\u627e\u3002\u6b64\u65f6\uff0c\u60a8\u9700\u8981\u5220\u9664\u8fd9\u4e9b\u591a\u4f59\u7684\u6587\u4ef6\u6216\u6587\u4ef6\u5939\u3002
Apache Flink \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6846\u67b6\u548c\u5206\u5e03\u5f0f\u5904\u7406\u5f15\u64ce\uff0c\u4e13\u6ce8\u4e8e\u8fdb\u884c\u6709\u72b6\u6001\u8ba1\u7b97\uff0c\u9002\u7528\u4e8e\u5904\u7406\u65e0\u8fb9\u754c\u548c\u6709\u8fb9\u754c\u7684\u6570\u636e\u6d41\u3002Flink \u80fd\u591f\u5728\u5404\u79cd\u5e38\u89c1\u96c6\u7fa4\u73af\u5883\u4e2d\u9ad8\u6548\u8fd0\u884c\uff0c\u5e76\u4ee5\u5185\u5b58\u901f\u5ea6\u6267\u884c\u8ba1\u7b97\uff0c\u652f\u6301\u5904\u7406\u4efb\u610f\u89c4\u6a21\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u4e8b\u4ef6\u9a71\u52a8\u578b\u5e94\u7528
\u4e8b\u4ef6\u9a71\u52a8\u578b\u5e94\u7528\u901a\u5e38\u5177\u5907\u72b6\u6001\uff0c\u5e76\u4e14\u5b83\u4eec\u4ece\u4e00\u4e2a\u6216\u591a\u4e2a\u4e8b\u4ef6\u6d41\u4e2d\u63d0\u53d6\u6570\u636e\uff0c\u6839\u636e\u5230\u8fbe\u7684\u4e8b\u4ef6\u89e6\u53d1\u8ba1\u7b97\u3001\u72b6\u6001\u66f4\u65b0\u6216\u6267\u884c\u5176\u4ed6\u5916\u90e8\u52a8\u4f5c\u3002\u5178\u578b\u7684\u4e8b\u4ef6\u9a71\u52a8\u578b\u5e94\u7528\u5305\u62ec\u53cd\u6b3a\u8bc8\u7cfb\u7edf\u3001\u5f02\u5e38\u68c0\u6d4b\u3001\u57fa\u4e8e\u89c4\u5219\u7684\u62a5\u8b66\u7cfb\u7edf\u548c\u4e1a\u52a1\u6d41\u7a0b\u76d1\u63a7\u3002
\u6570\u636e\u5206\u6790\u5e94\u7528
\u6570\u636e\u5206\u6790\u4efb\u52a1\u7684\u4e3b\u8981\u76ee\u6807\u662f\u4ece\u539f\u59cb\u6570\u636e\u4e2d\u63d0\u53d6\u6709\u4ef7\u503c\u7684\u4fe1\u606f\u548c\u6307\u6807\u3002Flink \u652f\u6301\u6d41\u5f0f\u548c\u6279\u91cf\u5206\u6790\u5e94\u7528\uff0c\u9002\u7528\u4e8e\u5404\u79cd\u573a\u666f\uff0c\u4f8b\u5982\u7535\u4fe1\u7f51\u7edc\u8d28\u91cf\u76d1\u63a7\u3001\u79fb\u52a8\u5e94\u7528\u4e2d\u7684\u4ea7\u54c1\u66f4\u65b0\u548c\u5b9e\u9a8c\u8bc4\u4f30\u5206\u6790\u3001\u6d88\u8d39\u8005\u6280\u672f\u9886\u57df\u7684\u5b9e\u65f6\u6570\u636e\u5373\u5e2d\u5206\u6790\u4ee5\u53ca\u5927\u89c4\u6a21\u56fe\u5206\u6790\u3002
\u6570\u636e\u7ba1\u9053\u5e94\u7528
\u63d0\u53d6 - \u8f6c\u6362 - \u52a0\u8f7d\uff08ETL\uff09\u662f\u5728\u4e0d\u540c\u5b58\u50a8\u7cfb\u7edf\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u8f6c\u6362\u548c\u8fc1\u79fb\u7684\u5e38\u89c1\u65b9\u6cd5\u3002\u6570\u636e\u7ba1\u9053\u548c ETL \u4f5c\u4e1a\u6709\u76f8\u4f3c\u4e4b\u5904\uff0c\u90fd\u53ef\u4ee5\u8fdb\u884c\u6570\u636e\u8f6c\u6362\u548c\u4e30\u5bcc\uff0c\u7136\u540e\u5c06\u6570\u636e\u4ece\u4e00\u4e2a\u5b58\u50a8\u7cfb\u7edf\u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u5b58\u50a8\u7cfb\u7edf\u3002\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u6570\u636e\u7ba1\u9053\u4ee5\u6301\u7eed\u6d41\u6a21\u5f0f\u8fd0\u884c\uff0c\u800c\u4e0d\u662f\u5468\u671f\u6027\u89e6\u53d1\u3002\u5178\u578b\u7684\u6570\u636e\u7ba1\u9053\u5e94\u7528\u5305\u62ec\u7535\u5b50\u5546\u52a1\u4e2d\u7684\u5b9e\u65f6\u67e5\u8be2\u7d22\u5f15\u6784\u5efa\u548c\u6301\u7eed ETL\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u4e24\u79cd\u793a\u4f8b\uff0c\u4e00\u79cd\u662f\u4f7f\u7528\u8ba1\u7b97\u5f15\u64ce Flink \u5b9e\u73b0\u5c06\u5b9e\u65f6\u6570\u636e\u5199\u5165\u5230 MatrixOne\uff0c\u53e6\u4e00\u79cd\u662f\u4f7f\u7528\u8ba1\u7b97\u5f15\u64ce Flink \u5c06\u6d41\u5f0f\u6570\u636e\u5199\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_3","title":"\u524d\u671f\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_4","title":"\u786c\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u5bf9\u4e8e\u673a\u5668\u7684\u786c\u4ef6\u8981\u6c42\u5982\u4e0b\uff1a
\u670d\u52a1\u5668\u540d\u79f0 \u670d\u52a1\u5668 IP \u5b89\u88c5\u8f6f\u4ef6 \u64cd\u4f5c\u7cfb\u7edf node1 192.168.146.10 MatrixOne Debian11.1 x86 node2 192.168.146.12 kafka Centos7.9 node3 192.168.146.11 IDEA\u3001MYSQL win10"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_5","title":"\u8f6f\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u9700\u8981\u5b89\u88c5\u90e8\u7f72\u4ee5\u4e0b\u8f6f\u4ef6\u73af\u5883\uff1a
\u6253\u5f00 IDEA\uff0c\u70b9\u51fb File > New > Project\uff0c\u9009\u62e9 Spring Initializer\uff0c\u5e76\u586b\u5199\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u914d\u7f6e\u793a\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6dfb\u52a0\u9879\u76ee\u4f9d\u8d56\uff0c\u7f16\u8f91\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 pom.xml
\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u5185\u5bb9\u6dfb\u52a0\u5230\u6587\u4ef6\u4e2d\uff1a
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n<modelVersion>4.0.0</modelVersion>\n\n<groupId>com.matrixone.flink</groupId>\n<artifactId>matrixone-flink-demo</artifactId>\n<version>1.0-SNAPSHOT</version>\n\n<properties>\n<scala.binary.version>2.12</scala.binary.version>\n<java.version>1.8</java.version>\n<flink.version>1.17.0</flink.version>\n<scope.mode>compile</scope.mode>\n</properties>\n\n<dependencies>\n\n<!-- Flink Dependency -->\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-connector-hive_2.12</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-java</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-streaming-java</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-clients</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-table-api-java-bridge</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-table-planner_2.12</artifactId>\n<version>${flink.version}</version>\n</dependency>\n\n<!-- JDBC\u76f8\u5173\u4f9d\u8d56\u5305 -->\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-connector-jdbc</artifactId>\n<version>1.15.4</version>\n</dependency>\n<dependency>\n<groupId>mysql</groupId>\n<artifactId>mysql-connector-java</artifactId>\n<version>8.0.33</version>\n</dependency>\n\n<!-- Kafka\u76f8\u5173\u4f9d\u8d56 -->\n<dependency>\n<groupId>org.apache.kafka</groupId>\n<artifactId>kafka_2.13</artifactId>\n<version>3.5.0</version>\n</dependency>\n<dependency>\n<groupId>org.apache.flink</groupId>\n<artifactId>flink-connector-kafka</artifactId>\n<version>3.0.0-1.17</version>\n</dependency>\n\n<!-- JSON -->\n<dependency>\n<groupId>com.alibaba.fastjson2</groupId>\n<artifactId>fastjson2</artifactId>\n<version>2.0.34</version>\n</dependency>\n\n</dependencies>\n\n\n\n\n<build>\n<plugins>\n<plugin>\n<groupId>org.apache.maven.plugins</groupId>\n<artifactId>maven-compiler-plugin</artifactId>\n<version>3.8.0</version>\n<configuration>\n<source>${java.version}</source>\n<target>${java.version}</target>\n<encoding>UTF-8</encoding>\n</configuration>\n</plugin>\n<plugin>\n<artifactId>maven-assembly-plugin</artifactId>\n<version>2.6</version>\n<configuration>\n<descriptorRefs>\n<descriptor>jar-with-dependencies</descriptor>\n</descriptorRefs>\n</configuration>\n<executions>\n<execution>\n<id>make-assembly</id>\n<phase>package</phase>\n<goals>\n<goal>single</goal>\n</goals>\n</execution>\n</executions>\n</plugin>\n\n</plugins>\n</build>\n\n</project>\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#matrixone","title":"\u6b65\u9aa4\u4e8c\uff1a\u8bfb\u53d6 MatrixOne \u6570\u636e","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u540e\uff0c\u521b\u5efa\u6f14\u793a\u6240\u9700\u7684\u6570\u636e\u5e93\u4ee5\u53ca\u6570\u636e\u8868\u3002
\u5728 MatrixOne \u4e2d\u521b\u5efa\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\uff0c\u5e76\u5bfc\u5165\u6570\u636e\uff1a
CREATE DATABASE test;\nUSE test;\nCREATE TABLE `person` (`id` INT DEFAULT NULL, `name` VARCHAR(255) DEFAULT NULL, `birthday` DATE DEFAULT NULL);\nINSERT INTO test.person (id, name, birthday) VALUES(1, 'zhangsan', '2023-07-09'),(2, 'lisi', '2023-07-08'),(3, 'wangwu', '2023-07-12');\n
\u5728 IDEA \u4e2d\u521b\u5efa MoRead.java
\u7c7b\uff0c\u4ee5\u4f7f\u7528 Flink \u8bfb\u53d6 MatrixOne \u6570\u636e\uff1a
package com.matrixone.flink.demo;\n\nimport org.apache.flink.api.common.functions.MapFunction;\nimport org.apache.flink.api.common.typeinfo.BasicTypeInfo;\nimport org.apache.flink.api.java.ExecutionEnvironment;\nimport org.apache.flink.api.java.operators.DataSource;\nimport org.apache.flink.api.java.operators.MapOperator;\nimport org.apache.flink.api.java.typeutils.RowTypeInfo;\nimport org.apache.flink.connector.jdbc.JdbcInputFormat;\nimport org.apache.flink.types.Row;\n\nimport java.text.SimpleDateFormat;\n\n/**\n * @author MatrixOne\n * @description\n */\npublic class MoRead {\n\nprivate static String srcHost = \"192.168.146.10\";\nprivate static Integer srcPort = 6001;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"111\";\nprivate static String srcDataBase = \"test\";\n\npublic static void main(String[] args) throws Exception {\n\nExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();\n// \u8bbe\u7f6e\u5e76\u884c\u5ea6\nenvironment.setParallelism(1);\nSimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd\");\n\n// \u8bbe\u7f6e\u67e5\u8be2\u7684\u5b57\u6bb5\u7c7b\u578b\nRowTypeInfo rowTypeInfo = new RowTypeInfo(\nnew BasicTypeInfo[]{\nBasicTypeInfo.INT_TYPE_INFO,\nBasicTypeInfo.STRING_TYPE_INFO,\nBasicTypeInfo.DATE_TYPE_INFO\n},\nnew String[]{\n\"id\",\n\"name\",\n\"birthday\"\n}\n);\n\nDataSource<Row> dataSource = environment.createInput(JdbcInputFormat.buildJdbcInputFormat()\n.setDrivername(\"com.mysql.cj.jdbc.Driver\")\n.setDBUrl(\"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase)\n.setUsername(srcUserName)\n.setPassword(srcPassword)\n.setQuery(\"select * from person\")\n.setRowTypeInfo(rowTypeInfo)\n.finish());\n\n// \u5c06 Wed Jul 12 00:00:00 CST 2023 \u65e5\u671f\u683c\u5f0f\u8f6c\u6362\u4e3a 2023-07-12\nMapOperator<Row, Row> mapOperator = dataSource.map((MapFunction<Row, Row>) row -> {\nrow.setField(\"birthday\", sdf.format(row.getField(\"birthday\")));\nreturn row;\n});\n\nmapOperator.print();\n}\n}\n
\u5728 IDEA \u4e2d\u8fd0\u884c MoRead.Main()
\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528 Flink \u5c06 MySQL \u6570\u636e\u8fc1\u79fb\u5230 MatrixOne\u3002
\u51c6\u5907 MySQL \u6570\u636e\uff1a\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730 Mysql\uff0c\u521b\u5efa\u6240\u9700\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\u3001\u5e76\u63d2\u5165\u6570\u636e\uff1a
mysql -h127.0.0.1 -P3306 -uroot -proot\nmysql> CREATE DATABASE motest;\nmysql> USE motest;\nmysql> CREATE TABLE `person` (`id` int DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `birthday` date DEFAULT NULL);\nmysql> INSERT INTO motest.person (id, name, birthday) VALUES(2, 'lisi', '2023-07-09'),(3, 'wangwu', '2023-07-13'),(4, 'zhaoliu', '2023-08-08');\n
\u6e05\u7a7a MatrixOne \u8868\u6570\u636e\uff1a
\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 node1 \u7684 MatrixOne\u3002\u7531\u4e8e\u672c\u793a\u4f8b\u7ee7\u7eed\u4f7f\u7528\u524d\u9762\u8bfb\u53d6 MatrixOne \u6570\u636e\u7684\u793a\u4f8b\u4e2d\u7684 test
\u6570\u636e\u5e93\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u9996\u5148\u6e05\u7a7a person
\u8868\u7684\u6570\u636e\u3002
-- \u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5 node1 \u7684 MatrixOne\nmysql -h192.168.146.10 -P6001 -uroot -p111\nmysql> TRUNCATE TABLE test.person;\n
\u5728 IDEA \u4e2d\u7f16\u5199\u4ee3\u7801\uff1a
\u521b\u5efa Person.java
\u548c Mysql2Mo.java
\u7c7b\uff0c\u4f7f\u7528 Flink \u8bfb\u53d6 MySQL \u6570\u636e\uff0c\u6267\u884c\u7b80\u5355\u7684 ETL \u64cd\u4f5c\uff08\u5c06 Row \u8f6c\u6362\u4e3a Person \u5bf9\u8c61\uff09\uff0c\u6700\u7ec8\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u4e2d\u3002
package com.matrixone.flink.demo.entity;\n\n\nimport java.util.Date;\n\npublic class Person {\n\nprivate int id;\nprivate String name;\nprivate Date birthday;\n\npublic int getId() {\nreturn id;\n}\n\npublic void setId(int id) {\nthis.id = id;\n}\n\npublic String getName() {\nreturn name;\n}\n\npublic void setName(String name) {\nthis.name = name;\n}\n\npublic Date getBirthday() {\nreturn birthday;\n}\n\npublic void setBirthday(Date birthday) {\nthis.birthday = birthday;\n}\n}\n
package com.matrixone.flink.demo;\n\nimport com.matrixone.flink.demo.entity.Person;\nimport org.apache.flink.api.common.functions.MapFunction;\nimport org.apache.flink.api.common.typeinfo.BasicTypeInfo;\nimport org.apache.flink.api.java.typeutils.RowTypeInfo;\nimport org.apache.flink.connector.jdbc.*;\nimport org.apache.flink.streaming.api.datastream.DataStreamSink;\nimport org.apache.flink.streaming.api.datastream.DataStreamSource;\nimport org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;\nimport org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;\nimport org.apache.flink.types.Row;\n\nimport java.sql.Date;\n\n/**\n * @author MatrixOne\n * @description\n */\npublic class Mysql2Mo {\n\nprivate static String srcHost = \"127.0.0.1\";\nprivate static Integer srcPort = 3306;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"root\";\nprivate static String srcDataBase = \"motest\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"person\";\n\n\npublic static void main(String[] args) throws Exception {\n\nStreamExecutionEnvironment environment = StreamExecutionEnvironment.getExecutionEnvironment();\n//\u8bbe\u7f6e\u5e76\u884c\u5ea6\nenvironment.setParallelism(1);\n//\u8bbe\u7f6e\u67e5\u8be2\u7684\u5b57\u6bb5\u7c7b\u578b\nRowTypeInfo rowTypeInfo = new RowTypeInfo(\nnew BasicTypeInfo[]{\nBasicTypeInfo.INT_TYPE_INFO,\nBasicTypeInfo.STRING_TYPE_INFO,\nBasicTypeInfo.DATE_TYPE_INFO\n},\nnew String[]{\n\"id\",\n\"name\",\n\"birthday\"\n}\n);\n\n//\u6dfb\u52a0 srouce\nDataStreamSource<Row> dataSource = environment.createInput(JdbcInputFormat.buildJdbcInputFormat()\n.setDrivername(\"com.mysql.cj.jdbc.Driver\")\n.setDBUrl(\"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase)\n.setUsername(srcUserName)\n.setPassword(srcPassword)\n.setQuery(\"select * from person\")\n.setRowTypeInfo(rowTypeInfo)\n.finish());\n\n//\u8fdb\u884c ETL\nSingleOutputStreamOperator<Person> mapOperator = dataSource.map((MapFunction<Row, Person>) row -> {\nPerson person = new Person();\nperson.setId((Integer) row.getField(\"id\"));\nperson.setName((String) row.getField(\"name\"));\nperson.setBirthday((java.util.Date)row.getField(\"birthday\"));\nreturn person;\n});\n\n//\u8bbe\u7f6e matrixone sink \u4fe1\u606f\nmapOperator.addSink(\nJdbcSink.sink(\n\"insert into \" + destTable + \" values(?,?,?)\",\n(ps, t) -> {\nps.setInt(1, t.getId());\nps.setString(2, t.getName());\nps.setDate(3, new Date(t.getBirthday().getTime()));\n},\nnew JdbcConnectionOptions.JdbcConnectionOptionsBuilder()\n.withDriverName(\"com.mysql.cj.jdbc.Driver\")\n.withUrl(\"jdbc:mysql://\" + destHost + \":\" + destPort + \"/\" + destDataBase)\n.withUsername(destUserName)\n.withPassword(destPassword)\n.build()\n)\n);\n\nenvironment.execute();\n}\n\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_7","title":"\u6b65\u9aa4\u56db\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u8be2\u7ed3\u679c\uff1a
mysql> select * from test.person;\n+------+---------+------------+\n| id | name | birthday |\n+------+---------+------------+\n| 2 | lisi | 2023-07-09 |\n| 3 | wangwu | 2023-07-13 |\n| 4 | zhaoliu | 2023-08-08 |\n+------+---------+------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#2-kafka-matrixone","title":"\u793a\u4f8b 2\uff1a\u5c06 Kafka \u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#kafka","title":"\u6b65\u9aa4\u4e00\uff1a\u542f\u52a8 Kafka \u670d\u52a1","text":"Kafka \u96c6\u7fa4\u534f\u8c03\u548c\u5143\u6570\u636e\u7ba1\u7406\u53ef\u4ee5\u901a\u8fc7 KRaft \u6216 ZooKeeper \u6765\u5b9e\u73b0\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 Kafka 3.5.0 \u7248\u672c\uff0c\u65e0\u9700\u4f9d\u8d56\u72ec\u7acb\u7684 ZooKeeper \u8f6f\u4ef6\uff0c\u800c\u662f\u4f7f\u7528 Kafka \u81ea\u5e26\u7684 KRaft \u6765\u8fdb\u884c\u5143\u6570\u636e\u7ba1\u7406\u3002\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u914d\u7f6e\u914d\u7f6e\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u4f4d\u4e8e Kafka \u8f6f\u4ef6\u6839\u76ee\u5f55\u4e0b\u7684 config/kraft/server.properties
\u3002
\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a
# Licensed to the Apache Software Foundation (ASF) under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding copyright ownership.\n# The ASF licenses this file to You under the Apache License, Version 2.0\n# (the \"License\"); you may not use this file except in compliance with\n# the License. You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n#\n# This configuration file is intended for use in KRaft mode, where\n# Apache ZooKeeper is not present. See config/kraft/README.md for details.\n#\n\n############################# Server Basics #############################\n\n# The role of this server. Setting this puts us in KRaft mode\nprocess.roles=broker,controller\n\n# The node id associated with this instance's roles\nnode.id=1\n\n# The connect string for the controller quorum\ncontroller.quorum.voters=1@192.168.146.12:9093\n\n############################# Socket Server Settings #############################\n\n# The address the socket server listens on.\n# Combined nodes (i.e. those with `process.roles=broker,controller`) must list the controller listener here at a minimum.\n# If the broker listener is not defined, the default listener will use a host name that is equal to the value of java.net.InetAddress.getCanonicalHostName(),\n# with PLAINTEXT listener name, and port 9092.\n# FORMAT:\n# listeners = listener_name://host_name:port\n# EXAMPLE:\n# listeners = PLAINTEXT://your.host.name:9092\n#listeners=PLAINTEXT://:9092,CONTROLLER://:9093\nlisteners=PLAINTEXT://192.168.146.12:9092,CONTROLLER://192.168.146.12:9093\n\n# Name of listener used for communication between brokers.\ninter.broker.listener.name=PLAINTEXT\n\n# Listener name, hostname and port the broker will advertise to clients.\n# If not set, it uses the value for \"listeners\".\n#advertised.listeners=PLAINTEXT://localhost:9092\n\n# A comma-separated list of the names of the listeners used by the controller.\n# If no explicit mapping set in `listener.security.protocol.map`, default will be using PLAINTEXT protocol\n# This is required if running in KRaft mode.\ncontroller.listener.names=CONTROLLER\n\n# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details\nlistener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL\n\n# The number of threads that the server uses for receiving requests from the network and sending responses to the network\nnum.network.threads=3\n\n# The number of threads that the server uses for processing requests, which may include disk I/O\nnum.io.threads=8\n\n# The send buffer (SO_SNDBUF) used by the socket server\nsocket.send.buffer.bytes=102400\n\n# The receive buffer (SO_RCVBUF) used by the socket server\nsocket.receive.buffer.bytes=102400\n\n# The maximum size of a request that the socket server will accept (protection against OOM)\nsocket.request.max.bytes=104857600\n\n\n############################# Log Basics #############################\n\n# A comma separated list of directories under which to store log files\nlog.dirs=/home/software/kafka_2.13-3.5.0/kraft-combined-logs\n\n# The default number of log partitions per topic. More partitions allow greater\n# parallelism for consumption, but this will also result in more files across\n# the brokers.\nnum.partitions=1\n\n# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.\n# This value is recommended to be increased for installations with data dirs located in RAID array.\nnum.recovery.threads.per.data.dir=1\n\n############################# Internal Topic Settings #############################\n# The replication factor for the group metadata internal topics \"__consumer_offsets\" and \"__transaction_state\"\n# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.\noffsets.topic.replication.factor=1\ntransaction.state.log.replication.factor=1\ntransaction.state.log.min.isr=1\n\n############################# Log Flush Policy #############################\n\n# Messages are immediately written to the filesystem but by default we only fsync() to sync\n# the OS cache lazily. The following configurations control the flush of data to disk.\n# There are a few important trade-offs here:\n# 1. Durability: Unflushed data may be lost if you are not using replication.\n# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.\n# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.\n# The settings below allow one to configure the flush policy to flush data after a period of time or\n# every N messages (or both). This can be done globally and overridden on a per-topic basis.\n\n# The number of messages to accept before forcing a flush of data to disk\n#log.flush.interval.messages=10000\n\n# The maximum amount of time a message can sit in a log before we force a flush\n#log.flush.interval.ms=1000\n\n############################# Log Retention Policy #############################\n\n# The following configurations control the disposal of log segments. The policy can\n# be set to delete segments after a period of time, or after a given size has accumulated.\n# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens\n# from the end of the log.\n\n# The minimum age of a log file to be eligible for deletion due to age\nlog.retention.hours=72\n\n# A size-based retention policy for logs. Segments are pruned from the log unless the remaining\n# segments drop below log.retention.bytes. Functions independently of log.retention.hours.\n#log.retention.bytes=1073741824\n\n# The maximum size of a log segment file. When this size is reached a new log segment will be created.\nlog.segment.bytes=1073741824\n\n# The interval at which log segments are checked to see if they can be deleted according\n# to the retention policies\nlog.retention.check.interval.ms=300000\n
\u6587\u4ef6\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8 Kafka \u670d\u52a1\uff1a
#\u751f\u6210\u96c6\u7fa4ID\n$ KAFKA_CLUSTER_ID=\"$(bin/kafka-storage.sh random-uuid)\"\n#\u8bbe\u7f6e\u65e5\u5fd7\u76ee\u5f55\u683c\u5f0f\n$ bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.properties\n#\u542f\u52a8Kafka\u670d\u52a1\n$ bin/kafka-server-start.sh config/kraft/server.properties\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#kafka_1","title":"\u6b65\u9aa4\u4e8c\uff1a\u521b\u5efa Kafka \u4e3b\u9898","text":"\u4e3a\u4e86\u4f7f Flink \u80fd\u591f\u4ece\u4e2d\u8bfb\u53d6\u6570\u636e\u5e76\u5199\u5165\u5230 MatrixOne\uff0c\u6211\u4eec\u9700\u8981\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"matrixone\" \u7684 Kafka \u4e3b\u9898\u3002\u5728\u4e0b\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u4f7f\u7528 --bootstrap-server
\u53c2\u6570\u6307\u5b9a Kafka \u670d\u52a1\u7684\u76d1\u542c\u5730\u5740\u4e3a 192.168.146.12:9092
\uff1a
$ bin/kafka-topics.sh --create --topic matrixone --bootstrap-server 192.168.146.12:9092\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#matrixone_1","title":"\u6b65\u9aa4\u4e09\uff1a\u8bfb\u53d6 MatrixOne \u6570\u636e","text":"\u5728\u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\u4e4b\u540e\uff0c\u9700\u8981\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\u4ee5\u521b\u5efa\u6240\u9700\u7684\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff1a
\u5728 MatrixOne \u4e2d\u521b\u5efa\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff0c\u5e76\u5bfc\u5165\u6570\u636e\uff1a
CREATE TABLE `users` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL\n)\n
\u5728 IDEA \u96c6\u6210\u5f00\u53d1\u73af\u5883\u4e2d\u7f16\u5199\u4ee3\u7801\uff1a
\u5728 IDEA \u4e2d\uff0c\u521b\u5efa\u4e24\u4e2a\u7c7b\uff1aUser.java
\u548c Kafka2Mo.java
\u3002\u8fd9\u4e9b\u7c7b\u7528\u4e8e\u4f7f\u7528 Flink \u4ece Kafka \u8bfb\u53d6\u6570\u636e\uff0c\u5e76\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u4e2d\u3002
package com.matrixone.flink.demo.entity;\n\npublic class User {\n\nprivate int id;\nprivate String name;\nprivate int age;\n\npublic int getId() {\nreturn id;\n}\n\npublic void setId(int id) {\nthis.id = id;\n}\n\npublic String getName() {\nreturn name;\n}\n\npublic void setName(String name) {\nthis.name = name;\n}\n\npublic int getAge() {\nreturn age;\n}\n\npublic void setAge(int age) {\nthis.age = age;\n}\n}\n
package com.matrixone.flink.demo;\n\nimport com.alibaba.fastjson2.JSON;\nimport com.matrixone.flink.demo.entity.User;\nimport org.apache.flink.api.common.eventtime.WatermarkStrategy;\nimport org.apache.flink.api.common.serialization.AbstractDeserializationSchema;\nimport org.apache.flink.connector.jdbc.JdbcExecutionOptions;\nimport org.apache.flink.connector.jdbc.JdbcSink;\nimport org.apache.flink.connector.jdbc.JdbcStatementBuilder;\nimport org.apache.flink.connector.jdbc.internal.options.JdbcConnectorOptions;\nimport org.apache.flink.connector.kafka.source.KafkaSource;\nimport org.apache.flink.connector.kafka.source.enumerator.initializer.OffsetsInitializer;\nimport org.apache.flink.streaming.api.datastream.DataStreamSource;\nimport org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;\nimport org.apache.kafka.clients.consumer.OffsetResetStrategy;\n\nimport java.nio.charset.StandardCharsets;\n\n/**\n * @author MatrixOne\n * @desc\n */\npublic class Kafka2Mo {\n\nprivate static String srcServer = \"192.168.146.12:9092\";\nprivate static String srcTopic = \"matrixone\";\nprivate static String consumerGroup = \"matrixone_group\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"person\";\n\npublic static void main(String[] args) throws Exception {\n\n//\u521d\u59cb\u5316\u73af\u5883\nStreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();\n//\u8bbe\u7f6e\u5e76\u884c\u5ea6\nenv.setParallelism(1);\n\n//\u8bbe\u7f6e kafka source \u4fe1\u606f\nKafkaSource<User> source = KafkaSource.<User>builder()\n//Kafka \u670d\u52a1\n.setBootstrapServers(srcServer)\n//\u6d88\u606f\u4e3b\u9898\n.setTopics(srcTopic)\n//\u6d88\u8d39\u7ec4\n.setGroupId(consumerGroup)\n//\u504f\u79fb\u91cf \u5f53\u6ca1\u6709\u63d0\u4ea4\u504f\u79fb\u91cf\u5219\u4ece\u6700\u5f00\u59cb\u5f00\u59cb\u6d88\u8d39\n.setStartingOffsets(OffsetsInitializer.committedOffsets(OffsetResetStrategy.LATEST))\n//\u81ea\u5b9a\u4e49\u89e3\u6790\u6d88\u606f\u5185\u5bb9\n.setValueOnlyDeserializer(new AbstractDeserializationSchema<User>() {\n@Override\npublic User deserialize(byte[] message) {\nreturn JSON.parseObject(new String(message, StandardCharsets.UTF_8), User.class);\n}\n})\n.build();\nDataStreamSource<User> kafkaSource = env.fromSource(source, WatermarkStrategy.noWatermarks(), \"kafka_maxtixone\");\n//kafkaSource.print();\n\n//\u8bbe\u7f6e matrixone sink \u4fe1\u606f\nkafkaSource.addSink(JdbcSink.sink(\n\"insert into users (id,name,age) values(?,?,?)\",\n(JdbcStatementBuilder<User>) (preparedStatement, user) -> {\npreparedStatement.setInt(1, user.getId());\npreparedStatement.setString(2, user.getName());\npreparedStatement.setInt(3, user.getAge());\n},\nJdbcExecutionOptions.builder()\n//\u9ed8\u8ba4\u503c 5000\n.withBatchSize(1000)\n//\u9ed8\u8ba4\u503c\u4e3a 0\n.withBatchIntervalMs(200)\n//\u6700\u5927\u5c1d\u8bd5\u6b21\u6570\n.withMaxRetries(5)\n.build(),\nJdbcConnectorOptions.builder()\n.setDBUrl(\"jdbc:mysql://\"+destHost+\":\"+destPort+\"/\"+destDataBase)\n.setUsername(destUserName)\n.setPassword(destPassword)\n.setDriverName(\"com.mysql.cj.jdbc.Driver\")\n.setTableName(destTable)\n.build()\n));\nenv.execute();\n}\n}\n
\u4ee3\u7801\u7f16\u5199\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c Flink \u4efb\u52a1\uff0c\u5373\u5728 IDEA \u4e2d\u9009\u62e9 Kafka2Mo.java
\u6587\u4ef6\uff0c\u7136\u540e\u6267\u884c Kafka2Mo.Main()
\u3002
\u4f7f\u7528 Kafka \u63d0\u4f9b\u7684\u547d\u4ee4\u884c\u751f\u4ea7\u8005\u5de5\u5177\uff0c\u60a8\u53ef\u4ee5\u5411 Kafka \u7684 \"matrixone\" \u4e3b\u9898\u4e2d\u6dfb\u52a0\u6570\u636e\u3002\u5728\u4e0b\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u4f7f\u7528 --topic
\u53c2\u6570\u6307\u5b9a\u8981\u6dfb\u52a0\u5230\u7684\u4e3b\u9898\uff0c\u800c --bootstrap-server
\u53c2\u6570\u6307\u5b9a\u4e86 Kafka \u670d\u52a1\u7684\u76d1\u542c\u5730\u5740\u3002
bin/kafka-console-producer.sh --topic matrixone --bootstrap-server 192.168.146.12:9092\n
\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u60a8\u5c06\u5728\u63a7\u5236\u53f0\u4e0a\u7b49\u5f85\u8f93\u5165\u6d88\u606f\u5185\u5bb9\u3002\u53ea\u9700\u76f4\u63a5\u8f93\u5165\u6d88\u606f\u503c (value)\uff0c\u6bcf\u884c\u8868\u793a\u4e00\u6761\u6d88\u606f\uff08\u4ee5\u6362\u884c\u7b26\u5206\u9694\uff09\uff0c\u5982\u4e0b\u6240\u793a\uff1a
{\"id\": 10, \"name\": \"xiaowang\", \"age\": 22}\n{\"id\": 20, \"name\": \"xiaozhang\", \"age\": 24}\n{\"id\": 30, \"name\": \"xiaogao\", \"age\": 18}\n{\"id\": 40, \"name\": \"xiaowu\", \"age\": 20}\n{\"id\": 50, \"name\": \"xiaoli\", \"age\": 42}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Flink/#_9","title":"\u6b65\u9aa4\u4e94\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u8be2\u7ed3\u679c\uff1a
mysql> select * from test.users;\n+------+-----------+------+\n| id | name | age |\n+------+-----------+------+\n| 10 | xiaowang | 22 |\n| 20 | xiaozhang | 24 |\n| 30 | xiaogao | 18 |\n| 40 | xiaowu | 20 |\n| 50 | xiaoli | 42 |\n+------+-----------+------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/","title":"\u4f7f\u7528 Spark \u5c06\u6279\u91cf\u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_1","title":"\u6982\u8ff0","text":"Apache Spark \u662f\u4e00\u4e2a\u4e3a\u9ad8\u6548\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u800c\u8bbe\u8ba1\u7684\u5206\u5e03\u5f0f\u8ba1\u7b97\u5f15\u64ce\u3002\u5b83\u91c7\u7528\u5206\u5e03\u5f0f\u5e76\u884c\u8ba1\u7b97\u7684\u65b9\u5f0f\uff0c\u5c06\u6570\u636e\u62c6\u5206\u3001\u8ba1\u7b97\u3001\u5408\u5e76\u7684\u4efb\u52a1\u5206\u6563\u5230\u591a\u53f0\u8ba1\u7b97\u673a\u4e0a\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u9ad8\u6548\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u5927\u89c4\u6a21\u6570\u636e\u5904\u7406\u4e0e\u5206\u6790
Spark \u80fd\u591f\u5904\u7406\u6d77\u91cf\u6570\u636e\uff0c\u901a\u8fc7\u5e76\u884c\u8ba1\u7b97\u4efb\u52a1\u63d0\u9ad8\u4e86\u5904\u7406\u6548\u7387\u3002\u5b83\u5e7f\u6cdb\u5e94\u7528\u4e8e\u91d1\u878d\u3001\u7535\u4fe1\u3001\u533b\u7597\u7b49\u9886\u57df\u7684\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u3002
\u6d41\u5f0f\u6570\u636e\u5904\u7406
Spark Streaming \u5141\u8bb8\u5b9e\u65f6\u5904\u7406\u6570\u636e\u6d41\uff0c\u5c06\u5176\u8f6c\u5316\u4e3a\u53ef\u4f9b\u5206\u6790\u548c\u5b58\u50a8\u7684\u6279\u5904\u7406\u6570\u636e\u3002\u8fd9\u5728\u5728\u7ebf\u5e7f\u544a\u3001\u7f51\u7edc\u5b89\u5168\u7b49\u5b9e\u65f6\u6570\u636e\u5206\u6790\u573a\u666f\u4e2d\u975e\u5e38\u6709\u7528\u3002
\u673a\u5668\u5b66\u4e60
Spark \u63d0\u4f9b\u4e86\u673a\u5668\u5b66\u4e60\u5e93\uff08MLlib\uff09\uff0c\u652f\u6301\u591a\u79cd\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u548c\u6a21\u578b\u8bad\u7ec3\uff0c\u7528\u4e8e\u63a8\u8350\u7cfb\u7edf\u3001\u56fe\u50cf\u8bc6\u522b\u7b49\u673a\u5668\u5b66\u4e60\u5e94\u7528\u3002
\u56fe\u8ba1\u7b97
Spark \u7684\u56fe\u8ba1\u7b97\u5e93\uff08GraphX\uff09\u652f\u6301\u591a\u79cd\u56fe\u8ba1\u7b97\u7b97\u6cd5\uff0c\u9002\u7528\u4e8e\u793e\u4ea4\u7f51\u7edc\u5206\u6790\u3001\u63a8\u8350\u7cfb\u7edf\u7b49\u56fe\u5206\u6790\u573a\u666f\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd\u4e24\u79cd\u4f7f\u7528 Spark \u8ba1\u7b97\u5f15\u64ce\u5b9e\u73b0\u6279\u91cf\u6570\u636e\u5199\u5165 MatrixOne \u7684\u793a\u4f8b\u3002\u4e00\u79cd\u793a\u4f8b\u662f\u4ece MySQL \u8fc1\u79fb\u6570\u636e\u81f3 MatrixOne\uff0c\u53e6\u4e00\u79cd\u662f\u5c06 Hive \u6570\u636e\u5199\u5165 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_3","title":"\u524d\u671f\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_4","title":"\u786c\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u5bf9\u4e8e\u673a\u5668\u7684\u786c\u4ef6\u8981\u6c42\u5982\u4e0b\uff1a
\u670d\u52a1\u5668\u540d\u79f0 \u670d\u52a1\u5668 IP \u5b89\u88c5\u8f6f\u4ef6 \u64cd\u4f5c\u7cfb\u7edf node1 192.168.146.10 MatrixOne Debian11.1 x86 node3 192.168.146.11 IDEA\u3001MYSQL\u3001Hadoop\u3001Hive Windows 10"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_5","title":"\u8f6f\u4ef6\u73af\u5883","text":"\u672c\u6b21\u5b9e\u8df5\u9700\u8981\u5b89\u88c5\u90e8\u7f72\u4ee5\u4e0b\u8f6f\u4ef6\u73af\u5883\uff1a
\u542f\u52a8 IDEA\uff0c\u70b9\u51fb File > New > Project\uff0c\u9009\u62e9 Spring Initializer\uff0c\u5e76\u586b\u5199\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u6dfb\u52a0\u9879\u76ee\u4f9d\u8d56\uff0c\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 pom.xml
\u5185\u5bb9\u7f16\u8f91\u5982\u4e0b\uff1a
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n<modelVersion>4.0.0</modelVersion>\n\n<groupId>com.example.mo</groupId>\n<artifactId>mo-spark-demo</artifactId>\n<version>1.0-SNAPSHOT</version>\n\n<properties>\n<maven.compiler.source>8</maven.compiler.source>\n<maven.compiler.target>8</maven.compiler.target>\n<spark.version>3.2.1</spark.version>\n</properties>\n\n<dependencies>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-sql_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-hive_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-catalyst_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-core_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-core-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-mapper-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n\n\n<dependency>\n<groupId>mysql</groupId>\n<artifactId>mysql-connector-java</artifactId>\n<version>8.0.16</version>\n</dependency>\n\n</dependencies>\n\n</project>\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#matrixone","title":"\u6b65\u9aa4\u4e8c\uff1a\u8bfb\u53d6 MatrixOne \u6570\u636e","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u540e\uff0c\u521b\u5efa\u6f14\u793a\u6240\u9700\u7684\u6570\u636e\u5e93\u4ee5\u53ca\u6570\u636e\u8868\u3002
\u5728 MatrixOne \u4e2d\u521b\u5efa\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\uff0c\u5e76\u5bfc\u5165\u6570\u636e\uff1a
CREATE DATABASE test;\nUSE test;\nCREATE TABLE `person` (`id` INT DEFAULT NULL, `name` VARCHAR(255) DEFAULT NULL, `birthday` DATE DEFAULT NULL);\nINSERT INTO test.person (id, name, birthday) VALUES(1, 'zhangsan', '2023-07-09'),(2, 'lisi', '2023-07-08'),(3, 'wangwu', '2023-07-12');\n
\u5728 IDEA \u4e2d\u521b\u5efa MoRead.java
\u7c7b\uff0c\u4ee5\u4f7f\u7528 Spark \u8bfb\u53d6 MatrixOne \u6570\u636e\uff1a
package com.matrixone.spark;\n\nimport org.apache.spark.sql.Dataset;\nimport org.apache.spark.sql.Row;\nimport org.apache.spark.sql.SQLContext;\nimport org.apache.spark.sql.SparkSession;\n\nimport java.util.Properties;\n\n/**\n * @auther MatrixOne\n * @desc \u8bfb\u53d6 MatrixOne \u6570\u636e\n */\npublic class MoRead {\n\n// parameters\nprivate static String master = \"local[2]\";\nprivate static String appName = \"mo_spark_demo\";\n\nprivate static String srcHost = \"192.168.146.10\";\nprivate static Integer srcPort = 6001;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"111\";\nprivate static String srcDataBase = \"test\";\nprivate static String srcTable = \"person\";\n\npublic static void main(String[] args) {\nSparkSession sparkSession = SparkSession.builder().appName(appName).master(master).getOrCreate();\nSQLContext sqlContext = new SQLContext(sparkSession);\nProperties properties = new Properties();\nproperties.put(\"user\", srcUserName);\nproperties.put(\"password\", srcPassword);\nDataset<Row> dataset = sqlContext.read()\n.jdbc(\"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase,srcTable, properties);\ndataset.show();\n}\n\n}\n
\u5728 IDEA \u4e2d\u8fd0\u884c MoRead.Main()
\uff0c\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
\u73b0\u5728\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528 Spark \u5c06 MySQL \u6570\u636e\u8fc1\u79fb\u5230 MatrixOne\u3002
\u51c6\u5907 MySQL \u6570\u636e\uff1a\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730 Mysql\uff0c\u521b\u5efa\u6240\u9700\u6570\u636e\u5e93\u3001\u6570\u636e\u8868\u3001\u5e76\u63d2\u5165\u6570\u636e\uff1a
mysql -h127.0.0.1 -P3306 -uroot -proot\nmysql> CREATE DATABASE motest;\nmysql> USE motest;\nmysql> CREATE TABLE `person` (`id` int DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `birthday` date DEFAULT NULL);\nmysql> INSERT INTO motest.person (id, name, birthday) VALUES(2, 'lisi', '2023-07-09'),(3, 'wangwu', '2023-07-13'),(4, 'zhaoliu', '2023-08-08');\n
\u6e05\u7a7a MatrixOne \u8868\u6570\u636e\uff1a
\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u672c\u5730 MatrixOne\u3002\u7531\u4e8e\u672c\u793a\u4f8b\u7ee7\u7eed\u4f7f\u7528\u524d\u9762\u8bfb\u53d6 MatrixOne \u6570\u636e\u7684\u793a\u4f8b\u4e2d\u7684 test
\u6570\u636e\u5e93\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u9996\u5148\u6e05\u7a7a person
\u8868\u7684\u6570\u636e\u3002
-- \u5728 node3 \u4e0a\uff0c\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5 node1 \u7684 MatrixOne\nmysql -h192.168.146.10 -P6001 -uroot -p111\nmysql> TRUNCATE TABLE test.person;\n
\u5728 IDEA \u4e2d\u7f16\u5199\u4ee3\u7801\uff1a
\u521b\u5efa Person.java
\u548c Mysql2Mo.java
\u7c7b\uff0c\u4f7f\u7528 Spark \u8bfb\u53d6 MySQL \u6570\u636e\u3002Mysql2Mo.java
\u7c7b\u4ee3\u7801\u53ef\u53c2\u8003\u5982\u4e0b\u793a\u4f8b\uff1a
package com.matrixone.spark;\n\nimport org.apache.spark.api.java.function.MapFunction;\nimport org.apache.spark.sql.*;\n\nimport java.sql.SQLException;\nimport java.util.Properties;\n\n/**\n * @auther MatrixOne\n * @desc\n */\npublic class Mysql2Mo {\n\n// parameters\nprivate static String master = \"local[2]\";\nprivate static String appName = \"app_spark_demo\";\n\nprivate static String srcHost = \"127.0.0.1\";\nprivate static Integer srcPort = 3306;\nprivate static String srcUserName = \"root\";\nprivate static String srcPassword = \"root\";\nprivate static String srcDataBase = \"motest\";\nprivate static String srcTable = \"person\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"person\";\n\n\npublic static void main(String[] args) throws SQLException {\nSparkSession sparkSession = SparkSession.builder().appName(appName).master(master).getOrCreate();\nSQLContext sqlContext = new SQLContext(sparkSession);\nProperties connectionProperties = new Properties();\nconnectionProperties.put(\"user\", srcUserName);\nconnectionProperties.put(\"password\", srcPassword);\nconnectionProperties.put(\"driver\",\"com.mysql.cj.jdbc.Driver\");\n\n//jdbc.url=jdbc:mysql://127.0.0.1:3306/database\nString url = \"jdbc:mysql://\" + srcHost + \":\" + srcPort + \"/\" + srcDataBase + \"?characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai\";\n\n//SparkJdbc \u8bfb\u53d6\u8868\u5185\u5bb9\nSystem.out.println(\"\u8bfb\u53d6\u6570\u636e\u5e93\u4e2d person \u7684\u8868\u5185\u5bb9\");\n// \u8bfb\u53d6\u8868\u4e2d\u6240\u6709\u6570\u636e\nDataset<Row> rowDataset = sqlContext.read().jdbc(url,srcTable,connectionProperties).select(\"*\");\n//\u663e\u793a\u6570\u636e\n//rowDataset.show();\n//\u7b5b\u9009 id > 2 \u7684\u6570\u636e\uff0c\u5e76\u5c06 name \u5b57\u6bb5\u6dfb\u52a0 spark_ \u524d\u7f00\nDataset<Row> dataset = rowDataset.filter(\"id > 2\")\n.map((MapFunction<Row, Row>) row -> RowFactory.create(row.getInt(0), \"spark_\" + row.getString(1), row.getDate(2)), RowEncoder.apply(rowDataset.schema()));\n//\u663e\u793a\u6570\u636e\n//dataset.show();\nProperties properties = new Properties();\nproperties.put(\"user\", destUserName);\nproperties.put(\"password\", destPassword);;\ndataset.write()\n.mode(SaveMode.Append)\n.jdbc(\"jdbc:mysql://\" + destHost + \":\" + destPort + \"/\" + destDataBase,destTable, properties);\n}\n\n}\n
\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6267\u884c\u4e86\u7b80\u5355\u7684 ETL \u64cd\u4f5c\uff08\u7b5b\u9009 id > 2 \u7684\u6570\u636e\uff0c\u5e76\u5728 name \u5b57\u6bb5\u524d\u6dfb\u52a0\u524d\u7f00 \"spark_\"\uff09\uff0c\u5e76\u5c06\u5904\u7406\u540e\u7684\u6570\u636e\u5199\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_7","title":"\u6b65\u9aa4\u56db\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u770b\u6267\u884c\u7ed3\u679c\uff1a
select * from test.person;\n+------+---------------+------------+\n| id | name | birthday |\n+------+---------------+------------+\n| 3 | spark_wangwu | 2023-07-12 |\n| 4 | spark_zhaoliu | 2023-08-07 |\n+------+---------------+------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#2-hive-matrixone","title":"\u793a\u4f8b 2\uff1a\u5c06 Hive \u6570\u636e\u5bfc\u5165\u5230 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_8","title":"\u6b65\u9aa4\u4e00\uff1a\u521d\u59cb\u5316\u9879\u76ee","text":"\u542f\u52a8 IDEA\uff0c\u70b9\u51fb File > New > Project\uff0c\u9009\u62e9 Spring Initializer\uff0c\u5e76\u586b\u5199\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u6dfb\u52a0\u9879\u76ee\u4f9d\u8d56\uff0c\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u7684 pom.xml
\u5185\u5bb9\u7f16\u8f91\u5982\u4e0b\uff1a
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n<modelVersion>4.0.0</modelVersion>\n\n<groupId>com.example.mo</groupId>\n<artifactId>mo-spark-demo</artifactId>\n<version>1.0-SNAPSHOT</version>\n\n<properties>\n<maven.compiler.source>8</maven.compiler.source>\n<maven.compiler.target>8</maven.compiler.target>\n<spark.version>3.2.1</spark.version>\n</properties>\n\n<dependencies>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-sql_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-hive_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-catalyst_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.apache.spark</groupId>\n<artifactId>spark-core_2.12</artifactId>\n<version>${spark.version}</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-core-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n<dependency>\n<groupId>org.codehaus.jackson</groupId>\n<artifactId>jackson-mapper-asl</artifactId>\n<version>1.9.13</version>\n</dependency>\n\n\n<dependency>\n<groupId>mysql</groupId>\n<artifactId>mysql-connector-java</artifactId>\n<version>8.0.16</version>\n</dependency>\n\n</dependencies>\n\n</project>\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#hive","title":"\u6b65\u9aa4\u4e8c\uff1a\u51c6\u5907 Hive \u6570\u636e","text":"\u5728\u7ec8\u7aef\u7a97\u53e3\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u521b\u5efa Hive \u6570\u636e\u5e93\u3001\u6570\u636e\u8868\uff0c\u5e76\u63d2\u5165\u6570\u636e\uff1a
hive\nhive> create database motest;\nhive> CREATE TABLE `users`(\n`id` int,\n`name` varchar(255),\n`age` int);\nhive> INSERT INTO motest.users (id, name, age) VALUES(1, 'zhangsan', 12),(2, 'lisi', 17),(3, 'wangwu', 19);\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#matrixone_1","title":"\u6b65\u9aa4\u4e09\uff1a\u521b\u5efa MatrixOne \u6570\u636e\u8868","text":"\u5728 node3 \u4e0a\uff0c\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 node1 \u7684 MatrixOne\u3002\u7136\u540e\u7ee7\u7eed\u4f7f\u7528\u4e4b\u524d\u521b\u5efa\u7684 \"test\" \u6570\u636e\u5e93\uff0c\u5e76\u521b\u5efa\u65b0\u7684\u6570\u636e\u8868 \"users\"\u3002
CREATE TABLE `users` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL\n)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_9","title":"\u6b65\u9aa4\u56db\uff1a\u62f7\u8d1d\u914d\u7f6e\u6587\u4ef6","text":"\u5c06 Hadoop \u6839\u76ee\u5f55\u4e0b\u7684 \"etc/hadoop/core-site.xml\" \u548c \"hdfs-site.xml\" \u4ee5\u53ca Hive \u6839\u76ee\u5f55\u4e0b\u7684 \"conf/hive-site.xml\" \u8fd9\u4e09\u4e2a\u914d\u7f6e\u6587\u4ef6\u590d\u5236\u5230\u9879\u76ee\u7684 \"resource\" \u76ee\u5f55\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_10","title":"\u6b65\u9aa4\u4e94\uff1a\u7f16\u5199\u4ee3\u7801","text":"\u5728 IntelliJ IDEA \u4e2d\u521b\u5efa\u540d\u4e3a \"Hive2Mo.java\" \u7684\u7c7b\uff0c\u7528\u4e8e\u4f7f\u7528 Spark \u4ece Hive \u4e2d\u8bfb\u53d6\u6570\u636e\u5e76\u5c06\u6570\u636e\u5199\u5165 MatrixOne\u3002
package com.matrixone.spark;\n\nimport org.apache.spark.sql.*;\n\nimport java.sql.SQLException;\nimport java.util.Properties;\n\n/**\n * @auther MatrixOne\n * @date 2022/2/9 10:02\n * @desc\n *\n * 1.\u5728 hive \u548c matrixone \u4e2d\u5206\u522b\u521b\u5efa\u76f8\u5e94\u7684\u8868\n * 2.\u5c06 core-site.xml hdfs-site.xml \u548c hive-site.xml \u62f7\u8d1d\u5230 resources \u76ee\u5f55\u4e0b\n * 3.\u9700\u8981\u8bbe\u7f6e\u57df\u540d\u6620\u5c04\n */\npublic class Hive2Mo {\n\n// parameters\nprivate static String master = \"local[2]\";\nprivate static String appName = \"app_spark_demo\";\n\nprivate static String destHost = \"192.168.146.10\";\nprivate static Integer destPort = 6001;\nprivate static String destUserName = \"root\";\nprivate static String destPassword = \"111\";\nprivate static String destDataBase = \"test\";\nprivate static String destTable = \"users\";\n\n\npublic static void main(String[] args) throws SQLException {\nSparkSession sparkSession = SparkSession.builder()\n.appName(appName)\n.master(master)\n.enableHiveSupport()\n.getOrCreate();\n\n//SparkJdbc \u8bfb\u53d6\u8868\u5185\u5bb9\nSystem.out.println(\"\u8bfb\u53d6 hive \u4e2d person \u7684\u8868\u5185\u5bb9\");\n// \u8bfb\u53d6\u8868\u4e2d\u6240\u6709\u6570\u636e\nDataset<Row> rowDataset = sparkSession.sql(\"select * from motest.users\");\n//\u663e\u793a\u6570\u636e\n//rowDataset.show();\nProperties properties = new Properties();\nproperties.put(\"user\", destUserName);\nproperties.put(\"password\", destPassword);;\nrowDataset.write()\n.mode(SaveMode.Append)\n.jdbc(\"jdbc:mysql://\" + destHost + \":\" + destPort + \"/\" + destDataBase,destTable, properties);\n}\n\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/Spark/#_11","title":"\u6b65\u9aa4\u516d\uff1a\u67e5\u770b\u6267\u884c\u7ed3\u679c","text":"\u5728 MatrixOne \u4e2d\u6267\u884c\u5982\u4e0b SQL \u67e5\u770b\u6267\u884c\u7ed3\u679c\uff1a
mysql> select * from test.users;\n+------+----------+------+\n| id | name | age |\n+------+----------+------+\n| 1 | zhangsan | 12 |\n| 2 | lisi | 17 |\n| 3 | wangwu | 19 |\n+------+----------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/","title":"\u4f7f\u7528 SeaTunnel \u5c06\u6570\u636e\u5199\u5165 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_1","title":"\u6982\u8ff0","text":"SeaTunnel \u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u3001\u9ad8\u6027\u80fd\u3001\u6613\u6269\u5c55\u7684\u6570\u636e\u96c6\u6210\u5e73\u53f0\uff0c\u4e13\u6ce8\u4e8e\u6d77\u91cf\u6570\u636e\uff08\u5305\u62ec\u79bb\u7ebf\u548c\u5b9e\u65f6\u6570\u636e\uff09\u540c\u6b65\u548c\u8f6c\u5316\u3002MatrixOne \u652f\u6301\u4f7f\u7528 SeaTunnel \u4ece\u5176\u4ed6\u6570\u636e\u5e93\u540c\u6b65\u6570\u636e\uff0c\u53ef\u4ee5\u7a33\u5b9a\u9ad8\u6548\u5730\u5904\u7406\u6570\u767e\u4ebf\u6761\u6570\u636e\u3002
\u672c\u6587\u6863\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SeaTunnel \u5411 MatrixOne \u4e2d\u5199\u5165\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u4f7f\u7528 SeaTunnel \u5411 MatrixOne \u5199\u5165\u6570\u636e\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5b8c\u6210\u4ee5\u4e0b\u51c6\u5907\u5de5\u4f5c\uff1a
\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5b89\u88c5 SeaTunnel Version 2.3.3\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7 shell \u547d\u4ee4\u884c\u5b9a\u4e49 SeaTunnel \u7684\u5b89\u88c5\u8def\u5f84\uff1a
export SEATNUNNEL_HOME=\"/root/seatunnel\"\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_3","title":"\u64cd\u4f5c\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_4","title":"\u521b\u5efa\u6d4b\u8bd5\u6570\u636e","text":"\u521b\u5efa\u540d\u4e3a test1
\u7684 MySQL \u6570\u636e\u5e93\uff0c\u5e76\u5728\u5176\u4e2d\u521b\u5efa\u540d\u4e3a test_table
\u7684\u8868\uff0c\u5b58\u50a8\u5728 root \u4e0b\u7684 mysql.sql
\u4e2d\u3002\u4ee5\u4e0b\u662f MySQL \u7684 DDL \u8bed\u53e5\uff1a
create database test1;\nuse test1;\nCREATE TABLE `test_table` (\n`name` varchar(255) DEFAULT NULL,\n`age` int(11) DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n
\u4f7f\u7528 mo_ctl \u5de5\u5177\u5c06 MySQL \u7684 DDL \u8bed\u53e5\u76f4\u63a5\u5bfc\u5165\u81f3 MatrixOne\u3002\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
mo_ctl sql /root/mysql.sql\n
\u672c\u7bc7\u6587\u6863\u4e2d\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SeaTunnel \u7684 connector-jdbc
\u8fde\u63a5\u63d2\u4ef6\u8fde\u63a5 MatrixOne\u3002
\u5728 SeaTunnel \u7684 ${SEATNUNNEL_HOME}/config/plugin_config
\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a
--connectors-v2--\nconnector-jdbc\n--end--\n
\u7248\u672c 2.3.3 \u7684 SeaTunnel \u4e8c\u8fdb\u5236\u5305\u9ed8\u8ba4\u4e0d\u63d0\u4f9b\u8fde\u63a5\u5668\u4f9d\u8d56\u9879\uff0c\u4f60\u9700\u8981\u5728\u9996\u6b21\u4f7f\u7528 SeaTunnel \u65f6\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5\u8fde\u63a5\u5668\uff1a
sh bin/install-plugin.sh 2.3.3\n
Note: \u672c\u7bc7\u6587\u6863\u4e2d\u4f7f\u7528 SeaTunnel \u5f15\u64ce\u5c06\u6570\u636e\u5199\u5165 MatrixOne\uff0c\u65e0\u9700\u4f9d\u8d56 Flink \u6216 Spark\u3002
\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 MySQL \u6570\u636e\u5e93\u7684 test_table
\u8868\u4f5c\u4e3a\u6570\u636e\u6e90\uff0c\u4e0d\u8fdb\u884c\u6570\u636e\u5904\u7406\uff0c\u76f4\u63a5\u5c06\u6570\u636e\u5199\u5165 MatrixOne \u6570\u636e\u5e93\u7684 test_table
\u8868\u4e2d\u3002
\u90a3\u4e48\uff0c\u7531\u4e8e\u6570\u636e\u517c\u5bb9\u6027\u7684\u95ee\u9898\uff0c\u9700\u8981\u914d\u7f6e\u4efb\u52a1\u914d\u7f6e\u6587\u4ef6 ${SEATNUNNEL_HOME}/config/v2.batch.config.template
\uff0c\u5b83\u5b9a\u4e49\u4e86 SeaTunnel \u542f\u52a8\u540e\u7684\u6570\u636e\u8f93\u5165\u3001\u5904\u7406\u548c\u8f93\u51fa\u65b9\u5f0f\u548c\u903b\u8f91\u3002
\u6309\u7167\u4ee5\u4e0b\u5185\u5bb9\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a
env {\nexecution.parallelism = 2\njob.mode = \"BATCH\"\n}\n\nsource {\nJdbc {\nurl = \"jdbc:mysql://192.168.110.40:3306/test\"\ndriver = \"com.mysql.cj.jdbc.Driver\"\nconnection_check_timeout_sec = 100\nuser = \"root\"\npassword = \"123456\"\nquery = \"select * from test_table\"\n}\n}\n\ntransform {\n\n}\n\nsink {\njdbc {\nurl = \"jdbc:mysql://192.168.110.248:6001/test\"\ndriver = \"com.mysql.cj.jdbc.Driver\"\nuser = \"root\"\npassword = \"111\"\nquery = \"insert into test_table(name,age) values(?,?)\"\n}\n}\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_6","title":"\u5b89\u88c5\u6570\u636e\u5e93\u4f9d\u8d56\u9879","text":"\u4e0b\u8f7d mysql-connector-java-8.0.33.jar\uff0c\u5e76\u5c06\u6587\u4ef6\u590d\u5236\u5230 ${SEATNUNNEL_HOME}/plugins/jdbc/lib/
\u76ee\u5f55\u4e0b\u3002
\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8 SeaTunnel \u5e94\u7528\uff1a
./bin/seatunnel.sh --config ./config/v2.batch.config.template -e local\n
"},{"location":"MatrixOne/Develop/Ecological-Tools/Computing-Engine/seatunnel-write/#_7","title":"\u67e5\u770b\u8fd0\u884c\u7ed3\u679c","text":"SeaTunnel \u8fd0\u884c\u7ed3\u675f\u540e\uff0c\u5c06\u663e\u793a\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u7edf\u8ba1\u7ed3\u679c\uff0c\u6c47\u603b\u4e86\u672c\u6b21\u5199\u5165\u7684\u7528\u65f6\u3001\u603b\u8bfb\u53d6\u6570\u636e\u6570\u91cf\u3001\u603b\u5199\u5165\u6570\u91cf\u4ee5\u53ca\u603b\u5199\u5165\u5931\u8d25\u6570\u91cf\uff1a
***********************************************\n Job Statistic Information\n***********************************************\nStart Time : 2023-08-07 16:45:02\nEnd Time : 2023-08-07 16:45:05\nTotal Time(s) : 3\nTotal Read Count : 5000000\nTotal Write Count : 5000000\nTotal Failed Count : 0\n***********************************************\n
\u4f60\u5df2\u7ecf\u6210\u529f\u5c06\u6570\u636e\u4ece MySQL \u6570\u636e\u5e93\u540c\u6b65\u5199\u5165\u5230 MatrixOne \u6570\u636e\u5e93\u4e2d\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Message-Queue/Kafka/","title":"\u4f7f\u7528 Kafka \u8fde\u63a5 MatrixOne","text":""},{"location":"MatrixOne/Develop/Ecological-Tools/Message-Queue/Kafka/#_1","title":"\u6982\u8ff0","text":"Apache Kafka \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u4e8b\u4ef6\u6d41\u5e73\u53f0\uff0c\u88ab\u6570\u5343\u5bb6\u516c\u53f8\u7528\u4e8e\u9ad8\u6027\u80fd\u6570\u636e\u7ba1\u9053\u3001\u6d41\u5206\u6790\u3001\u6570\u636e\u96c6\u6210\u548c\u5173\u952e\u4efb\u52a1\u5e94\u7528\u3002
MatrixOne \u652f\u6301\u4e0e Apache Kafka \u8fdb\u884c\u8fde\u63a5\uff0c\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7 Apache Kafka \u8fde\u63a5\u5230 MatrixOne \u5e76\u5b9e\u73b0\u9ad8\u6548\u6570\u636e\u6d41\u96c6\u6210\u4e0e\u6301\u4e45\u5316\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Message-Queue/Kafka/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u4e0b\u8f7d Apache Kafka \u4e8c\u8fdb\u5236\u5305\u3002
\u89e3\u538b\u4e8c\u8fdb\u5236\u5305 (\u6ce8\u610f\u5bf9\u5e94\u7248\u672c)
tar -xzf kafka_2.13-3.6.1.tgz\ncd kafka_2.13-3.6.1\n
\u542f\u52a8 ZooKeeper
bin/zookeeper-server-start.sh config/zookeeper.properties\n
\u5f00\u542f\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u542f\u52a8 Kafka
bin/kafka-server-start.sh config/server.properties\n
\u5f00\u542f\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u521b\u5efa\u4e00\u4e2a topic
bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test\n
\u5f00\u542f\u4e00\u4e2a\u751f\u4ea7\u8005\u5f80 topic \u4e2d\u5199\u5165 json \u6570\u636e
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test\n{\"c1\": -2147483648,\"c2\":20,\"c3\": -3,\"c4\":8,\"c5\":425,\"c6\":55}\n{\"c1\": 21474,\"c2\":-20,\"c3\": 3,\"c4\":9090,\"c5\":42,\"c6\":53}\n
\u5f00\u542f\u4e00\u4e2a\u6d88\u8d39\u8005\u67e5\u770b\u662f\u5426\u6210\u529f\u5199\u5165 topic\uff1a
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test\n{\"c1\": -2147483648,\"c2\":20,\"c3\": -3,\"c4\":8,\"c5\":425,\"c6\":55}\n{\"c1\": 21474,\"c2\":-20,\"c3\": 3,\"c4\":9090,\"c5\":42,\"c6\":53}\n
\u521b\u5efa Source \u8868
create source stream_test(c1 int,c2 tinyint,c3 smallint,c4 bigint,c5 int unsigned ,c6 tinyint unsigned)\nwith(\n\"type\"='kafka',\n\"topic\"= 'test',\n\"partition\" = '0',\n\"value\"= 'json',\n\"bootstrap.servers\"='127.0.0.1:9092' )
\u67e5\u770b\u662f\u5426\u63a5\u53d7\u4e86\u6570\u636e\uff1a
select * from stream_test;\n+-------------+------+------+------+------+------+\n| c1 | c2 | c3 | c4 | c5 | c6 |\n+-------------+------+------+------+------+------+\n| -2147483648 | 20 | -3 | 8 | 425 | 55 |\n| 21474 | -20 | 3 | 9090 | 42 | 53 |\n+-------------+------+------+------+------+------+\n2 rows in set (0.37 sec)
\u5f80 topic \u4e2d\u6301\u7eed\u5199\u5165 json \u6570\u636e\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u7ee7\u7eed\u63a5\u53d7\u4e86\u6570\u636e\uff1a
{\"c1\": -3421474,\"c2\":92,\"c3\": 333,\"c4\":9,\"c5\":42233,\"c6\":87}\n
\u67e5\u770b\u662f\u5426\u63a5\u53d7\u4e86\u6570\u636e\uff1a
select * from stream_test;\n+-------------+------+------+------+-------+------+\n| c1 | c2 | c3 | c4 | c5 | c6 |\n+-------------+------+------+------+-------+------+\n| -2147483648 | 20 | -3 | 8 | 425 | 55 |\n| 21474 | -20 | 3 | 9090 | 42 | 53 |\n| -3421474 | 92 | 333 | 9 | 42233 | 87 |\n+-------------+------+------+------+-------+------+\n3 rows in set (0.44 sec)\n
\u521b\u5efa\u52a8\u6001\u8868\u4ee5\u6d88\u8d39 Source \u8868\uff1a
create dynamic table dt_test as select c1, c2+c3, c3*c4,c5/c3,c6/10 from stream_test;\n
\u67e5\u770b\u52a8\u6001\u8868\uff1a
select * from dt_test;\n+-------------+---------+---------+---------------------+---------+\n| c1 | c2 + c3 | c3 * c4 | c5 / c3 | c6 / 10 |\n+-------------+---------+---------+---------------------+---------+\n| -2147483648 | 17 | -24 | -141.66666666666666 | 5.5 |\n| 21474 | -17 | 27270 | 14 | 5.3 |\n| -3421474 | 425 | 2997 | 126.82582582582583 | 8.7 |\n+-------------+---------+---------+---------------------+---------+\n3 rows in set (0.00 sec)\n
\u5f80 topic \u4e2d\u6301\u7eed\u5199\u5165 json \u6570\u636e\uff0c\u5e76\u68c0\u67e5\u52a8\u6001\u8868\u662f\u5426\u66f4\u65b0\uff1a
{\"c1\": 1474,\"c2\":2,\"c3\": 453,\"c4\":1,\"c5\":56233,\"c6\":7}\n
\u67e5\u770b\u52a8\u6001\u8868\u53d1\u73b0\u6210\u529f\u66f4\u65b0\uff1a
select * from dt_test;\n+-------------+---------+---------+---------------------+---------+\n| c1 | c2 + c3 | c3 * c4 | c5 / c3 | c6 / 10 |\n+-------------+---------+---------+---------------------+---------+\n| -2147483648 | 17 | -24 | -141.66666666666666 | 5.5 |\n| 21474 | -17 | 27270 | 14 | 5.3 |\n| -3421474 | 425 | 2997 | 126.82582582582583 | 8.7 |\n| 1474 | 455 | 453 | 124.13465783664459 | 0.7 |\n+-------------+---------+---------+---------------------+---------+\n4 rows in set (0.00 sec)\n
Apache DolphinScheduler \u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u3001\u6613\u6269\u5c55\u7684\u53ef\u89c6\u5316 DAG \u5de5\u4f5c\u6d41\u4efb\u52a1\u8c03\u5ea6\u5f00\u6e90\u7cfb\u7edf\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\uff0c\u53ef\u4ee5\u901a\u8fc7\u53ef\u89c6\u5316\u64cd\u4f5c\u4efb\u52a1\u3001\u5de5\u4f5c\u6d41\u548c\u5168\u751f\u547d\u5468\u671f\u7684\u6570\u636e\u5904\u7406\u8fc7\u7a0b\u3002
Apache DolphinScheduler \u7684\u4e3b\u8981\u76ee\u6807\u662f\u89e3\u51b3\u590d\u6742\u7684\u5927\u6570\u636e\u4efb\u52a1\u4f9d\u8d56\u5173\u7cfb\u3002\u5b83\u4f7f\u7528 DAG\uff08Directed Acyclic Graph\uff0c\u6709\u5411\u65e0\u73af\u56fe\uff09\u7684\u6d41\u5f0f\u65b9\u5f0f\u6765\u7ec4\u88c5\u4efb\u52a1\uff0c\u5141\u8bb8\u60a8\u5b9e\u65f6\u76d1\u63a7\u4efb\u52a1\u7684\u6267\u884c\u72b6\u6001\uff0c\u652f\u6301\u4efb\u52a1\u91cd\u8bd5\u3001\u6307\u5b9a\u8282\u70b9\u6062\u590d\u5931\u8d25\u3001\u6682\u505c\u3001\u6062\u590d\u3001\u7ec8\u6b62\u7b49\u64cd\u4f5c\u3002
MatrixOne \u652f\u6301\u4e0e\u53ef\u89c6\u5316 DAG \u5de5\u4f5c\u6d41\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf DolphinScheduler \u8fdb\u884c\u8fde\u63a5\u3002\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u901a\u8fc7 DolphinScheduler \u8fde\u63a5\u5230 MatrixOne \u5e76\u521b\u5efa\u4efb\u52a1\u5de5\u4f5c\u6d41\u3002
"},{"location":"MatrixOne/Develop/Ecological-Tools/Scheduling-Tools/dolphinScheduler/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u548c\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5b89\u88c5 DolphinScheduler\u3002
\u4e0b\u8f7d MySQL \u9a71\u52a8\u5e76\u5c06\u5176\u590d\u5236\u5230 libs \u76ee\u5f55\uff1a
\u5728\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u9700\u8981\u624b\u52a8\u4e0b\u8f7d mysql-connector-java \u9a71\u52a8\uff08\u7248\u672c 8.0.16\uff09\uff0c\u7136\u540e\u5c06\u5b83\u5206\u522b\u590d\u5236\u5230 DolphinScheduler \u5b89\u88c5\u76ee\u5f55\u4e0b\u7684\u56db\u4e2a\u76ee\u5f55\u4e2d\uff1aapi-server/libs
\u3001alert-server/libs
\u3001master-server/libs
\u548c worker-server/libs
\u3002
\u6ce8\u610f
\u63a8\u8350\u4f7f\u7528 `mysql-connector-java-8.0.16.jar` \u4f5c\u4e3a MySQL \u9a71\u52a8\u5305\u3002\n
\u91cd\u542f DolphinScheduler\uff1a
\u590d\u5236\u9a71\u52a8\u5305\u5b8c\u6210\u540e\uff0c\u9700\u8981\u91cd\u542f DolphinScheduler \u670d\u52a1\u3002\u9996\u5148\u8fdb\u5165 DolphinScheduler \u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u91cd\u542f DolphinScheduler \u670d\u52a1\uff1a
# \u505c\u6b62 Standalone Server \u670d\u52a1\nbash ./bin/dolphinscheduler-daemon.sh stop standalone-server\n# \u542f\u52a8 Standalone Server \u670d\u52a1\nbash ./bin/dolphinscheduler-daemon.sh start standalone-server\n
\u767b\u5f55 DolphinScheduler\uff1a
\u4f7f\u7528\u9ed8\u8ba4\u7528\u6237\u540d admin
\u548c\u5bc6\u7801 dolphinscheduler123
\uff0c\u901a\u8fc7\u8bbf\u95ee http://ip:12345/dolphinscheduler/ui \u767b\u5f55 DolphinScheduler \u7684 Web \u7528\u6237\u754c\u9762\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u521b\u5efa\u6570\u636e\u6e90\uff1a
\u70b9\u51fb\u6570\u636e\u6e90\u4e2d\u5fc3 > \u521b\u5efa\u6570\u636e\u6e90\uff0c\u586b\u5199 MatrixOne \u6570\u636e\u8fde\u63a5\u4fe1\u606f\u3002\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u6d4b\u8bd5\u8fde\u63a5\uff0c\u5982\u679c\u8fde\u63a5\u6210\u529f\uff0c\u70b9\u51fb\u786e\u5b9a\u4fdd\u5b58\uff1a
\u521b\u5efa\u79df\u6237\uff1a
\u5728\u5b89\u5168\u4e2d\u5fc3\u4e2d\uff0c\u70b9\u51fb\u521b\u5efa\u79df\u6237\uff0c\u586b\u5199\u79df\u6237\u540d\u79f0\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6ce8\u610f
\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u4e0d\u5efa\u8bae\u4f7f\u7528 root \u4f5c\u4e3a\u79df\u6237\u3002\n
\u521b\u5efa\u9879\u76ee\uff1a
\u5728\u9879\u76ee\u7ba1\u7406\u4e2d\uff0c\u70b9\u51fb\u521b\u5efa\u9879\u76ee\uff0c\u586b\u5199\u9879\u76ee\u540d\u79f0\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u521b\u5efa\u5de5\u4f5c\u6d41\u5e76\u6dfb\u52a0\u8282\u70b9\uff1a
\u70b9\u51fb\u4e0a\u4e00\u6b65\u521b\u5efa\u7684\u9879\u76ee\u540d\u79f0\uff0c\u7136\u540e\u70b9\u51fb\u521b\u5efa\u5de5\u4f5c\u6d41\u3002\u4ece\u5de6\u4fa7\u62d6\u52a8 SQL \u8282\u70b9\u5230\u53f3\u4fa7\u7684\u753b\u5e03\u4e0a\uff0c\u586b\u5199\u8282\u70b9\u540d\u79f0\u3001\u6570\u636e\u6e90\u4fe1\u606f\u3001SQL \u7c7b\u578b\u3001SQL \u8bed\u53e5\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u6b64\u6b65\u9aa4\u521b\u5efa\u7684\u662f\u4e00\u4e2a\u5efa\u8868\u8282\u70b9\uff0cSQL \u8bed\u53e5\u7528\u4e8e\u521b\u5efa\u8868\u683c\u3002
\u63a5\u4e0b\u6765\uff0c\u7c7b\u4f3c\u5730\u521b\u5efa\u63d2\u5165\u6570\u636e\u548c\u67e5\u8be2\u6570\u636e\u8282\u70b9\u3002\u8fd9\u4e09\u4e2a\u8282\u70b9\u7684\u4f9d\u8d56\u5173\u7cfb\u5982\u4e0b\u56fe\uff0c\u60a8\u53ef\u4ee5\u624b\u52a8\u8fde\u63a5\u5b83\u4eec\uff1a
\u4e09\u4e2a\u8282\u70b9\u7684 SQL \u8bed\u53e5\u5982\u4e0b\uff1a
#create_table\n\nCREATE TABLE IF NOT EXISTS test_table (id INT AUTO_INCREMENT PRIMARY KEY, name\n\nVARCHAR(255) NOT NULL)\n\n#insert_data\n\nINSERT INTO test_table (name) VALUES ('John Doe')\n\n#select_data\n\nSELECT * FROM test_table\n
\u6839\u636e\u4f9d\u8d56\u5173\u7cfb\u8fde\u63a5\u8fd9\u4e09\u4e2a\u8282\u70b9\uff0c\u7136\u540e\u70b9\u51fb\u4fdd\u5b58\u3002\u586b\u5199\u5de5\u4f5c\u6d41\u540d\u79f0\uff0c\u9009\u62e9\u4e4b\u524d\u521b\u5efa\u7684\u79df\u6237\uff0c\u9009\u62e9\u6267\u884c\u7b56\u7565\u4e3a\u5e76\u884c\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\u3002
\u521b\u5efa\u597d\u5de5\u4f5c\u6d41\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u5de5\u4f5c\u6d41\u5173\u7cfb\u9875\u9762\u770b\u5230\u521b\u5efa\u7684\u5de5\u4f5c\u6d41\uff0c\u5176\u72b6\u6001\u4e3a\u5de5\u4f5c\u6d41\u4e0b\u7ebf\uff1a
\u540c\u6837\uff0c\u60a8\u4e5f\u53ef\u4ee5\u5728\u5de5\u4f5c\u6d41\u5b9a\u4e49\u9875\u9762\u770b\u5230\u5b9a\u4e49\u7684\u5de5\u4f5c\u6d41\uff0c\u5176\u72b6\u6001\u4e3a\u4e0b\u7ebf\uff1a
\u4e0a\u7ebf\u5e76\u8fd0\u884c\u5de5\u4f5c\u6d41\uff1a
\u5de5\u4f5c\u6d41\u5fc5\u987b\u5148\u4e0a\u7ebf\u624d\u80fd\u8fd0\u884c\u3002\u70b9\u51fb\u4e0a\u7ebf\u6309\u94ae\uff0c\u5c06\u4e4b\u524d\u521b\u5efa\u7684\u5de5\u4f5c\u6d41\u4e0a\u7ebf\uff1a
\u4e0a\u7ebf\u540e\uff0c\u5de5\u4f5c\u6d41\u7684\u72b6\u6001\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u63a5\u4e0b\u6765\uff0c\u70b9\u51fb\u8fd0\u884c\u6309\u94ae\uff0c\u8bbe\u7f6e\u542f\u52a8\u524d\u7684\u914d\u7f6e\u53c2\u6570\uff0c\u7136\u540e\u70b9\u51fb\u786e\u5b9a\uff1a
\u6700\u540e\uff0c\u8fd4\u56de\u9879\u76ee\u6982\u51b5\uff0c\u67e5\u770b\u5de5\u4f5c\u6d41\u4ee5\u53ca\u4e0b\u9762\u7684\u4e09\u4e2a\u4efb\u52a1\u662f\u5426\u6210\u529f\u8fd0\u884c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u4e0e MySQL \u4e0d\u540c\uff0cMatrixOne \u662f\u4e00\u4e2a\u5177\u5907\u591a\u79df\u6237\u80fd\u529b\u7684\u6570\u636e\u5e93\u3002\u5728\u4e00\u4e2a MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 CREATE ACCOUNT
\u547d\u4ee4\u521b\u5efa\u79df\u6237\u3002\u8fd9\u4e9b\u79df\u6237\u5728\u903b\u8f91\u4e0a\u662f\u5b8c\u5168\u72ec\u7acb\u7684\u6570\u636e\u7a7a\u95f4\uff0c\u6240\u6709\u7684\u6570\u636e\u548c\u64cd\u4f5c\u90fd\u4e0e\u5176\u4ed6\u79df\u6237\u5b8c\u5168\u9694\u79bb\u3002\u5f53\u7528\u6237\u901a\u8fc7\u79df\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u767b\u5f55\u65f6\uff0c\u76f8\u5f53\u4e8e\u8fdb\u5165\u4e86\u4e00\u4e2a\u72ec\u7acb\u7684 MySQL \u5b9e\u4f8b\uff0c\u53ef\u4ee5\u8fdb\u884c\u5404\u79cd\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\u7684\u521b\u5efa\u64cd\u4f5c\uff0c\u800c\u4e0d\u4f1a\u5bf9\u5176\u4ed6\u79df\u6237\u7684\u6570\u636e\u4ea7\u751f\u4efb\u4f55\u5f71\u54cd\u3002
\u5728 MatrixOne \u4e2d\uff0c\u79df\u6237\uff08Account\uff09
\u662f\u6743\u9650\u7ba1\u7406\u4f53\u7cfb\u7684\u4e00\u90e8\u5206\u3002\u53ef\u4ee5\u53c2\u8003\u6743\u9650\u7ba1\u7406\u6982\u8ff0\u7ae0\u8282\u4ee5\u4e86\u89e3\u66f4\u8be6\u7ec6\u7684\u6743\u9650\u7ba1\u7406\u4f53\u7cfb\u4fe1\u606f\u3002
\u591a\u79df\u6237\u7684\u4f7f\u7528\u573a\u666f\u591a\u79cd\u591a\u6837\uff0c\u5305\u62ec\u5728 SaaS \u5e94\u7528\u4e2d\u7684\u591a\u79df\u6237\u8bbe\u8ba1\u3001\u96c6\u56e2\u516c\u53f8\u4e2d\u4e0d\u540c\u5b50\u516c\u53f8\u8d26\u53f7\u7684\u9694\u79bb\u3001\u5fae\u670d\u52a1\u67b6\u6784\u4e0b\u5404\u670d\u52a1\u6570\u636e\u5e93\u7684\u4f7f\u7528\u7b49\u3002\u6709\u5173\u8be6\u7ec6\u7684\u5e94\u7528\u573a\u666f\uff0c\u8bf7\u53c2\u8003 MatrixOne \u529f\u80fd\u6982\u8ff0\u4e2d\u7684\u591a\u79df\u6237\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/multi-account-overview/#_3","title":"\u521b\u5efa\u548c\u4f7f\u7528\u79df\u6237","text":"\u9664\u4e86\u786e\u4fdd\u79df\u6237\u4e4b\u95f4\u7684\u6570\u636e\u548c\u8d1f\u8f7d\u9694\u79bb\u5916\uff0cMatrixOne \u8fd8\u63d0\u4f9b\u4e86\u4e00\u79cd\u5141\u8bb8\u79df\u6237\u95f4\u6570\u636e\u4e92\u901a\u7684\u673a\u5236\uff0c\u5373\u53d1\u5e03\u548c\u8ba2\u9605\u80fd\u529b\u3002\u8fd9\u4e00\u673a\u5236\u53ef\u7528\u4e8e\u89e3\u51b3\u6570\u636e\u540c\u6b65\u548c\u5927\u91cf\u6570\u636e\u5206\u53d1\u7b49\u573a\u666f\u4e2d\u7684\u4e92\u901a\u95ee\u9898\u3002\u8be6\u7ec6\u4fe1\u606f\u8bf7\u53c2\u8003\u53d1\u5e03\u8ba2\u9605\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/","title":"\u53d1\u5e03\u8ba2\u9605","text":"\u6570\u636e\u5e93\u7684\u53d1\u5e03\u8ba2\u9605\uff08Publish-Subscribe\uff0c\u7b80\u79f0 Pub/Sub\uff09\u662f\u4e00\u79cd\u6d88\u606f\u4f20\u9012\u6a21\u5f0f\uff0c\u5176\u4e2d\u53d1\u5e03\u8005\u5c06\u6d88\u606f\u53d1\u9001\u7ed9\u4e00\u4e2a\u6216\u591a\u4e2a\u8ba2\u9605\u8005\uff0c\u800c\u8ba2\u9605\u8005\u5219\u63a5\u6536\u5e76\u5904\u7406\u8be5\u6d88\u606f\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u53d1\u5e03\u8005\u548c\u8ba2\u9605\u8005\u4e4b\u95f4\u662f\u677e\u8026\u5408\u7684\uff0c\u5b83\u4eec\u4e4b\u95f4\u4e0d\u9700\u8981\u76f4\u63a5\u901a\u4fe1\uff0c\u56e0\u6b64\u53ef\u4ee5\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u7684\u53ef\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\u3002
\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u901a\u5e38\u88ab\u7528\u4e8e\u5b9e\u65f6\u6570\u636e\u66f4\u65b0\u3001\u7f13\u5b58\u540c\u6b65\u3001\u4e1a\u52a1\u4e8b\u4ef6\u901a\u77e5\u7b49\u573a\u666f\u3002\u4f8b\u5982\uff0c\u5f53\u6570\u636e\u5e93\u4e2d\u67d0\u4e2a\u8868\u7684\u6570\u636e\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u5b9e\u65f6\u901a\u77e5\u8ba2\u9605\u8005\uff0c\u4ece\u800c\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u540c\u6b65\u548c\u5904\u7406\u3002\u53e6\u5916\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u6765\u5b9e\u73b0\u4e1a\u52a1\u4e8b\u4ef6\u7684\u901a\u77e5\uff0c\u4f8b\u5982\u67d0\u4e2a\u8ba2\u5355\u88ab\u53d6\u6d88\u3001\u67d0\u4e2a\u5e93\u5b58\u6570\u91cf\u4e0d\u8db3\u7b49\u7b49\u3002
\u901a\u5e38\uff0c\u6570\u636e\u5e93\u7684\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff1a\u53d1\u5e03\u8005\u548c\u8ba2\u9605\u8005\u3002\u53d1\u5e03\u8005\u8d1f\u8d23\u53d1\u5e03\u6d88\u606f\uff0c\u800c\u8ba2\u9605\u8005\u5219\u8ba2\u9605\u76f8\u5e94\u6d88\u606f\u4ee5\u8fbe\u5230\u6570\u636e\u540c\u6b65\u7684\u76ee\u7684\u3002\u53d1\u5e03\u8005\u548c\u8ba2\u9605\u8005\u4e4b\u95f4\u53ef\u4ee5\u5b58\u5728\u591a\u5bf9\u591a\u7684\u5173\u7cfb\uff0c\u5373\u4e00\u4e2a\u53d1\u5e03\u8005\u53ef\u4ee5\u5411\u591a\u4e2a\u8ba2\u9605\u8005\u53d1\u5e03\u6d88\u606f\uff0c\u800c\u4e00\u4e2a\u8ba2\u9605\u8005\u4e5f\u53ef\u4ee5\u8ba2\u9605\u591a\u4e2a\u6d88\u606f/\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u5177\u6709\u591a\u79cd\u5178\u578b\u7684\u5e94\u7528\u573a\u666f\uff1a
\u6570\u636e\u540c\u6b65\uff1a\u5f53\u4e00\u4e2a\u6570\u636e\u5e93\u9700\u8981\u4e0e\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u4fdd\u6301\u540c\u6b65\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u66f4\u6539\u53d1\u9001\u5230\u8ba2\u9605\u8005\u6570\u636e\u5e93\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u7f51\u7ad9\u9700\u8981\u5c06\u6570\u636e\u4ece\u4e00\u4e2a\u5730\u7406\u4f4d\u7f6e\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u5730\u7406\u4f4d\u7f6e\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u786e\u4fdd\u4e24\u4e2a\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u6570\u636e\u540c\u6b65\u3002
\u4e1a\u52a1\u6570\u636e\u5206\u53d1\uff1a\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u4e1a\u52a1\u6570\u636e\u5206\u53d1\u5230\u4e0d\u540c\u7684\u7cfb\u7edf\u6216\u4e1a\u52a1\u6d41\u7a0b\u4e2d\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u94f6\u884c\u9700\u8981\u5c06\u5ba2\u6237\u8d26\u6237\u4fe1\u606f\u5206\u53d1\u5230\u591a\u4e2a\u4e1a\u52a1\u7cfb\u7edf\u4e2d\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u5206\u53d1\u5230\u76f8\u5e94\u7684\u7cfb\u7edf\u4e2d\uff0c\u786e\u4fdd\u5404\u4e2a\u4e1a\u52a1\u6d41\u7a0b\u4e4b\u95f4\u7684\u6570\u636e\u4e00\u81f4\u6027\u3002
\u6570\u636e\u5907\u4efd\uff1a\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5907\u4efd\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u6570\u636e\u5e93\u9700\u8981\u5907\u4efd\u5230\u53e6\u4e00\u4e2a\u6570\u636e\u5e93\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u5907\u4efd\u5230\u8ba2\u9605\u8005\u6570\u636e\u5e93\u4e2d\uff0c\u4ee5\u4fbf\u5728\u4e3b\u6570\u636e\u5e93\u51fa\u73b0\u6545\u969c\u65f6\u6062\u590d\u6570\u636e\u3002
\u5b9e\u65f6\u6570\u636e\u5904\u7406\uff1a\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u5904\u7406\u3002\u4f8b\u5982\uff0c\u5f53\u4e00\u4e2a\u7f51\u7ad9\u9700\u8981\u5bf9\u6765\u81ea\u4e0d\u540c\u7528\u6237\u7684\u6570\u636e\u8fdb\u884c\u5904\u7406\u65f6\uff0c\u53d1\u5e03\u8ba2\u9605\u529f\u80fd\u53ef\u4ee5\u7528\u6765\u5c06\u6570\u636e\u4f20\u8f93\u5230\u5904\u7406\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u5904\u7406\uff0c\u4ee5\u4fbf\u5b9e\u73b0\u5b9e\u65f6\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u3002
\u53d1\u5e03\uff1a\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u53d1\u5e03\u901a\u5e38\u6307\u7684\u662f\u5c06\u4e00\u4e2a\u6570\u636e\u5e93\u5bf9\u8c61\u8bbe\u7f6e\u4e3a\u53ef\u4f9b\u5176\u4ed6\u79df\u6237\u8bbf\u95ee\u7684\u72b6\u6001\u3002\u8fd9\u662f\u6570\u636e\u5171\u4eab\u548c\u590d\u5236\u7684\u4e00\u4e2a\u91cd\u8981\u6b65\u9aa4\uff0c\u53d1\u5e03\u7684\u5bf9\u8c61\u53ef\u4ee5\u88ab\u5176\u4ed6\u79df\u6237\u8ba2\u9605\u5e76\u83b7\u53d6\u6570\u636e\u3002
\u8ba2\u9605\uff1a\u8ba2\u9605\u662f\u6307\u4e00\u4e2a\u6570\u636e\u5e93\u9009\u62e9\u63a5\u6536\u548c\u590d\u5236\u53d1\u5e03\u7684\u6570\u636e\u5e93\u5bf9\u8c61\u7684\u6570\u636e\u3002
\u53d1\u5e03\u7aef\uff08Pub\uff09\uff1a\u53d1\u5e03\u7aef\u662f\u6267\u884c\u53d1\u5e03\u64cd\u4f5c\u7684\u6570\u636e\u5e93\u3002\u53d1\u5e03\u7aef\u8d1f\u8d23\u521b\u5efa\u548c\u7ba1\u7406\u53d1\u5e03\u7684\u5bf9\u8c61\uff0c\u4ee5\u53ca\u7ba1\u7406\u8ba2\u9605\u8be5\u53d1\u5e03\u5bf9\u8c61\u7684\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u3002
\u8ba2\u9605\u7aef\uff08Sub\uff09\uff1a\u8ba2\u9605\u7aef\u662f\u8ba2\u9605\u53d1\u5e03\u5bf9\u8c61\u7684\u79df\u6237\u3002
\u53d1\u5e03\u5bf9\u8c61\uff1a\u53d1\u5e03\u5bf9\u8c61\u662f\u5728\u53d1\u5e03\u7aef\u521b\u5efa\u5e76\u8bbe\u7f6e\u4e3a\u53ef\u53d1\u5e03\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5373\u6570\u636e\u5e93\u3002\u8fd9\u4e9b\u5bf9\u8c61\u7684\u6570\u636e\u53ef\u4ee5\u88ab\u8ba2\u9605\u7aef\u8bbf\u95ee\u548c\u590d\u5236\u3002
\u8ba2\u9605\u5bf9\u8c61\uff1a\u8ba2\u9605\u5bf9\u8c61\u662f\u5728\u8ba2\u9605\u7aef\u590d\u5236\u548c\u5b58\u50a8\u7684\u53d1\u5e03\u5bf9\u8c61\u3002\u8ba2\u9605\u5bf9\u8c61\u7684\u6570\u636e\u4f1a\u6839\u636e\u53d1\u5e03\u7aef\u7684\u6570\u636e\u8fdb\u884c\u66f4\u65b0\u3002
\u53d1\u5e03\u7aef\uff08Pub\uff09\u548c\u8ba2\u9605\u7aef\uff08Sub\uff09\u5747\u4e3a MatrixOne \u7684\u79df\u6237\u3002
"},{"location":"MatrixOne/Develop/Publish-Subscribe/pub-sub-overview/#_6","title":"\u53ef\u53d1\u5e03/\u53ef\u8ba2\u9605\u6743\u9650\u8303\u56f4","text":"\u672c\u7ae0\u8282\u5c06\u7ed9\u51fa\u4e00\u4e2a\u793a\u4f8b\uff0c\u4ecb\u7ecd\u5f53\u524d\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u5b58\u5728 3 \u4e2a\u79df\u6237\uff0csys\u3001acc1 \u4e0e acc2\uff0c\u6309\u7167\u64cd\u4f5c\u987a\u5e8f\u5bf9\u4e09\u4e2a\u79df\u6237\u8fdb\u884c\u64cd\u4f5c\uff1a
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u521b\u5efa\u6570\u636e\u5e93 sub1 \u4e0e\u8868 t1\uff0c\u5e76\u53d1\u5e03 pub1\uff1a
create database sub1;\ncreate table sub1.t1(a int,b int);\ncreate publication pub1 database sub1;\nmysql> show publications;\n+-------------+----------+---------------------+-------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+-------------+-------------+----------+\n| pub1 | sub1 | 2024-04-23 10:28:15 | NULL | * | |\n+-------------+----------+---------------------+-------------+-------------+----------+\n1 row in set (0.01 sec)\n
\u8ba2\u9605\u8005\uff1aacc1 \u548c acc2 \u90fd\u521b\u5efa\u8ba2\u9605\u5e93 syssub1\uff0c\u4e8e\u662f\u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1\uff1a
-- all \u9009\u9879\u53ef\u4ee5\u770b\u5230\u6240\u6709\u6709\u6743\u9650\u7684\u8ba2\u9605\uff0c\u672a\u8ba2\u9605\u7684 sub_time, sub_name \u4e3a null\uff0c\u4e0d\u52a0 all \u53ea\u80fd\u770b\u5230\u5df2\u8ba2\u9605\u7684\u53d1\u5e03\u4fe1\u606f\u3002\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+----------+\n1 row in set (0.01 sec)\n\n-- acc1 \u548c acc2 \u521b\u5efa\u8ba2\u9605\u5e93\u7684 sql \u8bed\u53e5\u4e00\u81f4\uff0c\u6b64\u5904\u4e0d\u505a\u8d58\u8ff0\ncreate database syssub1 from sys publication pub1;\nuse syssub1;\n\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub1 |\n+--------------------+\n| t1 |\n+--------------------+\n2 rows in set (0.02 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u521b\u5efa\u6570\u636e\u8868 t2\uff1a
create table sub1.t2(a text);\n
\u8ba2\u9605\u8005\uff1aacc1 \u548c acc2 \u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1 \u548c t2\uff1a
use syssub1;\nmysql> show tables;\n+-------------------+\n| Tables_in_syssub1 |\n+-------------------+\n| t1 |\n| t2 |\n+-------------------+\n2 rows in set (0.01 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u521b\u5efa\u6570\u636e\u5e93 sub2 \u4e0e\u8868 t1\uff0c\u5e76\u53d1\u5e03 pub2 \u7ed9\u79df\u6237 acc1
create database sub2;\ncreate table sub2.t1(a float);\ncreate publication pub2 database sub2 account acc1;\n
\u8ba2\u9605\u8005\uff1aacc1 \u548c acc2 \u90fd\u521b\u5efa\u8ba2\u9605\u5e93 syssub2\uff0cacc1 \u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1\uff1bacc2 \u521b\u5efa\u8ba2\u9605\u5e93 syssub2 \u5931\u8d25\uff1a
mysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:30:43 |\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.01 sec)\n\ncreate database syssub2 from sys publication pub2;\nuse syssub2;\n\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:30:43 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2 |\n+--------------------+\n| t1 |\n+--------------------+\n2 rows in set (0.02 sec)\n
-- acc2 \u770b\u4e0d\u5230 pub2\uff0c\u56e0\u4e3a\u6ca1\u6709\u8ba2\u9605\u6743\u9650\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.01 sec)\n\nmysql> create database syssub2 from sys publication pub2;\nERROR 20101 (HY000): internal error: the account acc2 is not allowed to subscribe the publication pub2\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u4fee\u6539\u53d1\u5e03 pub2 \u7ed9\u5168\u90e8\u79df\u6237\uff1a
alter publication pub2 account all;\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| pub2 | sub2 | 2024-04-23 10:40:54 | 2024-04-23 10:47:53 | * | |\n| pub1 | sub1 | 2024-04-23 10:28:15 | NULL | * | |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n2 rows in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc2 \u521b\u5efa\u8ba2\u9605\u5e93 syssub2 \u6210\u529f\uff0c\u5f97\u5230\u5171\u4eab\u7684\u6570\u636e\u8868 t1\uff1a
-- acc2 \u73b0\u5728\u80fd\u770b\u5230 pub2 \u4e86\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.00 sec)\n\ncreate database syssub2 from sys publication pub2;\nuse syssub2;\n\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:50:43 |\n| pub1 | sys | sub1 | 2024-04-23 10:28:15 | syssub1 | 2024-04-23 10:35:13 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.00 sec)\n\nmysql> show tables;\n+--------------------+\n| Tables_in_syssub2 |\n+--------------------+\n| t1 |\n+--------------------+\n2 rows in set (0.02 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u5220\u9664\u53d1\u5e03 pub1\uff1a
drop publication pub1;\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| pub2 | sub2 | 2024-04-23 10:40:54 | 2024-04-23 10:47:53 | * | |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n1 row in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc1\u3001acc2 \u8fde\u63a5 syspub1 \u5931\u8d25\uff1a
mysql> use syssub1;\nERROR 20101 (HY000): internal error: there is no publication pub1\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u65b0\u5efa\u6570\u636e\u5e93 sub1_new\uff0c\u5e76\u91cd\u65b0\u4ee5 pub1 \u53d1\u5e03
create database sub1_new;\nuse sub1_new;\ncreate table t3(n1 int);\ninsert into t3 values (1);\ncreate publication pub1 database sub1_new;\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n| pub2 | sub2 | 2024-04-23 10:40:54 | 2024-04-23 10:47:53 | * | |\n| pub1 | sub1_new | 2024-04-23 10:59:11 | NULL | * | |\n+-------------+----------+---------------------+---------------------+-------------+----------+\n2 rows in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc1\u3001acc2 \u8fde\u63a5 syspub1\uff0c\u53ef\u4ee5\u770b\u5230 pub1 \u65b0\u7684\u5185\u5bb9\uff0c\u5c31\u662f\u8bf4\u5982\u679c\u53d1\u5e03\u65b9\u66f4\u6539\u4e86\u53d1\u5e03\u7684\u5185\u5bb9\uff0c\u8ba2\u9605\u65b9\u4e0d\u7528\u505a\u4efb\u4f55\u64cd\u4f5c\u5373\u53ef\u770b\u5230\u66f4\u65b0\u3002
use syssub1;\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n| pub1 | sys | sub1_new | 2024-04-23 10:59:11 | syssub1 | 2024-04-23 10:30:43 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> show tables;\n+-------------------+\n| Tables_in_syssub1 |\n+-------------------+\n| t3 |\n+-------------------+\n1 row in set (0.01 sec)\n\nmysql> select * from t3;\n+------+\n| n1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n
\u8ba2\u9605\u8005\uff1aacc1 \u5220\u9664\u8ba2\u9605\uff1a
-- \u901a\u8fc7 drop database \u5220\u9664\u8ba2\u9605\ndrop database syssub1;\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u5220\u9664\u5df2\u53d1\u5e03\u7684\u6570\u636e\u5e93\u4e4b\u524d\uff0c\u8981\u5148\u5220\u9664\u5176\u5bf9\u5e94\u7684\u53d1\u5e03\uff1a
mysql> drop database sub1_new;\nERROR 20101 (HY000): internal error: can not drop database 'sub1_new' which is publishing\nmysql> drop publication pub1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> drop database sub1_new;\nQuery OK, 1 row affected (0.03 sec)\n
\u53d1\u5e03\u8005\uff1asys \u79df\u6237\u4fee\u6539\u53d1\u5e03\u5185\u5bb9\uff1a
alter publication pub2 comment \"this is pub2\";--\u4fee\u6539comments\nmysql> show publications;\ncreate database new_sub2;\ncreate table new_sub2.new_t (xxx int);\ninsert into new_sub2.new_t values (123);\nalter publication pub2 database new_sub2;--\u4fee\u6539database\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+-------------+--------------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+-------------+--------------+\n| pub2 | new_sub2 | 2024-04-23 10:40:54 | 2024-04-23 11:04:20 | * | this is pub2 |\n+-------------+----------+---------------------+---------------------+-------------+--------------+\n1 row in set (0.00 sec)\n
\u8ba2\u9605\u8005\uff1aacc1\u3001acc2 \u67e5\u770b\u8ba2\u9605\uff0c\u80fd\u770b\u5230\u53d1\u5e03\u6570\u636e\u5e93\u4fee\u6539\u540e\u7684\u5185\u5bb9\uff1a
mysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub2 | sys | new_sub2 | 2024-04-23 10:40:54 | syssub2 | 2024-04-23 10:42:31 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n\nuse syssub2;\nmysql> show tables;\n+-------------------+\n| Tables_in_syssub2 |\n+-------------------+\n| new_t |\n+-------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from new_t;\n+------+\n| xxx |\n+------+\n| 123 |\n+------+\n1 row in set (0.00 sec)\n
\u5728\u8bb8\u591a\u5927\u578b\u3001\u5173\u952e\u7684\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u8ba1\u7b97\u673a\u6bcf\u79d2\u949f\u90fd\u5728\u6267\u884c\u5927\u91cf\u7684\u4efb\u52a1\u3002\u66f4\u4e3a\u7ecf\u5e38\u7684\u4e0d\u662f\u8fd9\u4e9b\u4efb\u52a1\u672c\u8eab\uff0c\u800c\u662f\u5c06\u8fd9\u4e9b\u4efb\u52a1\u7ed3\u5408\u5728\u4e00\u8d77\u5b8c\u6210\u4e00\u4e2a\u4e1a\u52a1\u8981\u6c42\uff0c\u79f0\u4e3a\u4e8b\u52a1\u3002\u5982\u679c\u80fd\u6210\u529f\u5730\u6267\u884c\u4e00\u4e2a\u4efb\u52a1\uff0c\u800c\u5728\u7b2c\u4e8c\u4e2a\u6216\u7b2c\u4e09\u4e2a\u76f8\u5173\u7684\u4efb\u52a1\u4e2d\u51fa\u73b0\u9519\u8bef\uff0c\u5c06\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f\u8fd9\u4e2a\u9519\u8bef\u5f88\u53ef\u80fd\u4f7f\u7cfb\u7edf\u6570\u636e\u5904\u4e8e\u4e0d\u4e00\u81f4\u72b6\u6001\u3002\u8fd9\u65f6\u4e8b\u52a1\u53d8\u5f97\u975e\u5e38\u91cd\u8981\uff0c\u5b83\u80fd\u4f7f\u7cfb\u7edf\u6570\u636e\u6446\u8131\u8fd9\u79cd\u4e0d\u4e00\u81f4\u7684\u72b6\u6001\u3002 \u5982\u4f55\u7406\u89e3\u4e8b\u52a1\u5462\uff1f\u4f8b\u5982\u5728\u67d0\u5bb6\u94f6\u884c\u7684\u94f6\u884c\u7cfb\u7edf\u4e2d\uff0c\u5982\u679c\u6ca1\u6709\u4e8b\u52a1\u5bf9\u6570\u636e\u8fdb\u884c\u63a7\u5236\u548c\u7ba1\u7406\uff0c\u5f88\u53ef\u80fd\u51fa\u73b0 A \u4ece\u4f01\u4e1a\u8d26\u6237\u4e2d\u53d6\u51fa\u4e00\u7b14\u94b1\uff0c\u540c\u65f6 B \u548c C \u4e5f\u4ece\u540c\u4e00\u4f01\u4e1a\u8d26\u6237\u4e2d\u53d6\u94b1\u3002\u6bcf\u4e00\u7b14\u8f6c\u8d26\u6d89\u53ca\u5230\u6700\u5c11\u4e24\u4e2a\u8d26\u6237\u4fe1\u606f\u7684\u53d8\u5316\uff08\u4f8b\u5982\uff0cA \u7684\u94b1\u5230\u8d26\uff0c\u4f01\u4e1a\u8d26\u6237\u51fa\u8d26\uff1bB \u7684\u94b1\u5230\u8d26\uff0c\u4f01\u4e1a\u8d26\u6237\u51fa\u8d26\uff1bC \u7684\u94b1\u5230\u8d26\uff0c\u4f01\u4e1a\u8d26\u6237\u51fa\u8d26\uff09\uff0c\u5982\u679c\u6ca1\u6709\u4e8b\u52a1\uff0c\u90a3\u4e48\u8d26\u9762\u91d1\u989d\u7684\u5177\u4f53\u6570\u503c\u5c06\u65e0\u6cd5\u786e\u5b9a\u3002\u5728\u5f15\u5165\u4e8b\u52a1\u8fd9\u4e00\u4e1a\u52a1\u8981\u6c42\u4e4b\u540e\uff0c\u4e8b\u52a1\u7684\u57fa\u672c\u7279\u6027\uff08ACID\uff09\u786e\u4fdd\u4e86\u94f6\u884c\u8d26\u9762\u7684\u8d44\u91d1\u64cd\u4f5c\u662f\u539f\u5b50\u6027\uff08\u4e0d\u53ef\u518d\u5206\u5272\uff09\u7684\uff0c\u5176\u4ed6\u4eba\u770b\u5230\u7684\u91d1\u989d\u662f\u5177\u5907\u9694\u79bb\u6027\u7684\uff0c\u6bcf\u4e00\u6b21\u64cd\u4f5c\u90fd\u662f\u5177\u6709\u4e00\u81f4\u6027\u7684\uff0c\u6240\u6709\u64cd\u4f5c\u662f\u6301\u4e45\u6027\u7684\uff0c\u8fd9\u6837\u4fdd\u8bc1\u4e86\u94f6\u884c\u7cfb\u7edf\u6570\u636e\u51fa\u5165\u8d26\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_3","title":"\u4ec0\u4e48\u662f\u4e8b\u52a1\uff1f","text":"\u6570\u636e\u5e93\u4e8b\u52a1\uff08\u5373\uff0cTransaction\uff0c\u4e8b\u52a1\uff09\u662f\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u4e00\u4e2a\u903b\u8f91\u5355\u4f4d\uff0c\u7531\u4e00\u4e2a\u6709\u9650\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u5e8f\u5217\u6784\u6210\u3002 \u4e8b\u52a1\u5c31\u662f\u4f5c\u4e3a\u4e00\u4e2a\u903b\u8f91\u5355\u4f4d\u63d0\u4ea4\u6216\u8005\u56de\u6eda\u4e00\u7cfb\u5217\u7684 SQL \u8bed\u53e5\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_4","title":"\u4e8b\u52a1\u7684\u7279\u5f81","text":"\u901a\u5e38\u4e8b\u52a1\u9700\u8981\u5177\u5907 ACID \u56db\u4e2a\u7279\u5f81\uff1a
\u4f8b\u5982\uff0c\u6211\u4eec\u73b0\u5728\u6709\u5982\u4e0b\u4e8b\u52a1\uff1a
start transaction;\ninsert into t1 values(1,2,3),(4,5,6);\nupdate t2 set c1='b' where c1='B';\ncommit;\n
\u5982\u679c\u5bf9 t1 \u63d2\u5165\u6570\u636e\u6216\u4fee\u6539 t2 \u6570\u636e\u4e2d\u7684\u4efb\u610f\u4e00\u6761\u53d1\u751f\u9519\u8bef\uff0c\u6574\u4e2a\u4e8b\u52a1\u90fd\u4f1a\u56de\u6eda\uff0c\u800c\u53ea\u6709\u4e24\u6761\u8bed\u53e5\u540c\u65f6\u6210\u529f\u65f6\uff0c\u624d\u4f1a\u63d0\u4ea4\u6210\u529f\uff0c\u4e0d\u4f1a\u51fa\u73b0\u4e00\u4e2a\u64cd\u4f5c\u6210\u529f\u800c\u53e6\u4e00\u4e2a\u64cd\u4f5c\u5931\u8d25\u3002
\u4f8b\u5982\uff0c\u6211\u4eec\u5728\u6570\u636e\u5e93\u4e2d\u5efa\u7acb\u4e00\u4e2a\u65b0\u8868
create table t1(a int primary key,b varchar(5) not null);\n
\u6b64\u5904\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u6027\uff0c\u6211\u4eec\u5728\u63d2\u5165\u6570\u636e\u65f6\uff0c\u4f60\u8981\u4fdd\u8bc1 a \u548c b \u5217\u7684\u6570\u636e\u7c7b\u578b\u4e0e\u8303\u56f4\uff0c\u540c\u65f6\u8fd8\u8981\u6ee1\u8db3 a \u5217\u7684\u4e3b\u952e\u7ea6\u675f\u4e0e b \u5217\u7684\u975e\u7a7a\u7ea6\u675f\uff1a
insert into t1 values(1,'abcde'),(2,'bcdef');\n
\u4f8b\u5982\uff0c\u5982\u4e0b\u4e8b\u52a1\u793a\u4f8b\uff0c\u4f1a\u8bdd\u9694\u79bb\u7ea7\u522b\u662f\u8bfb\u5df2\u63d0\u4ea4\uff0c\u5728\u4f1a\u8bdd 1 \u80fd\u770b\u5230\u7684\u6570\u636e\u5982\u4e0b\uff1a
select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n+------+------+\n
\u6b64\u65f6\u5728\u4f1a\u8bdd 2 \u4e2d\uff0c\u505a\u5982\u4e0b\u64cd\u4f5c\uff1a
begin;\ndelete from t1 where a=3;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u7684\u6570\u636e\u4ecd\u7136\u4e0d\u4f1a\u6709\u53d8\u5316\uff1a
select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n+------+------+\n
\u76f4\u5230\u5728\u4f1a\u8bdd 2 \u4e2d\u63d0\u4ea4\u5f53\u524d\u4e8b\u52a1\uff1a
commit;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\u624d\u4f1a\u770b\u5230\u5df2\u63d0\u4ea4\u4e8b\u52a1\u7684\u7ed3\u679c\uff1a
select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | a |\n| 2 | b |\n+------+------+\n
\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u4e8b\u52a1\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a
\u8fd9\u4e24\u5927\u7c7b\u4e8b\u52a1\u7684\u5206\u7c7b\u5f7c\u6b64\u4e0d\u53d7\u5bf9\u65b9\u9650\u5236\uff0c\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\u53ef\u4ee5\u662f\u4e50\u89c2\u4e8b\u52a1\u6216\u60b2\u89c2\u4e8b\u52a1\uff0c\u540c\u65f6\u4e00\u4e2a\u60b2\u89c2\u4e8b\u52a1\u53ef\u80fd\u662f\u663e\u5f0f\u4e8b\u52a1\u4e5f\u53ef\u80fd\u662f\u9690\u5f0f\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_6","title":"\u663e\u5f0f\u4e8b\u52a1\u548c\u9690\u5f0f\u4e8b\u52a1","text":"\u663e\u5f0f\u4e8b\u52a1\uff1a\u4e00\u822c\u6765\u8bf4\uff0c\u53ef\u4ee5\u901a\u8fc7\u6267\u884c BEGIN \u8bed\u53e5\u663e\u5f0f\u542f\u52a8\u4e8b\u52a1\u3002\u53ef\u4ee5\u901a\u8fc7\u6267\u884c COMMIT \u6216 ROLLBACK \u663e\u5f0f\u7ed3\u675f\u4e8b\u52a1\u3002MatrixOne \u7684\u663e\u793a\u4e8b\u52a1\u542f\u52a8\u548c\u6267\u884c\u65b9\u5f0f\u7565\u6709\u4e0d\u540c\uff0c\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u663e\u5f0f\u4e8b\u52a1\u3002
\u9690\u5f0f\u4e8b\u52a1\uff1a\u5373\u4e8b\u52a1\u53ef\u4ee5\u9690\u5f0f\u5f00\u59cb\u548c\u7ed3\u675f\uff0c\u65e0\u9700\u4f7f\u7528 BEGIN TRANSACTION\u3001COMMIT \u6216\u8005 ROLLBACK \u8bed\u53e5\u5c31\u53ef\u4ee5\u5f00\u59cb\u548c\u7ed3\u675f\u3002\u9690\u5f0f\u4e8b\u52a1\u7684\u884c\u4e3a\u65b9\u5f0f\u4e0e\u663e\u5f0f\u4e8b\u52a1\u76f8\u540c\u3002\u4f46\u662f\uff0c\u786e\u5b9a\u9690\u5f0f\u4e8b\u52a1\u4f55\u65f6\u5f00\u59cb\u7684\u89c4\u5219\u4e0d\u540c\u4e8e\u786e\u5b9a\u663e\u5f0f\u4e8b\u52a1\u4f55\u65f6\u5f00\u59cb\u7684\u89c4\u5219\u3002MatrixOne \u7684\u9690\u5f0f\u4e8b\u52a1\u542f\u52a8\u548c\u6267\u884c\u65b9\u5f0f\u7565\u6709\u4e0d\u540c\uff0c\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u9690\u5f0f\u4e8b\u52a1\u3002
\u65e0\u8bba\u662f\u4e50\u89c2\u4e8b\u52a1\uff0c\u8fd8\u662f\u60b2\u89c2\u4e8b\u52a1\uff0c\u5176\u4e8b\u52a1\u7684\u6267\u884c\u7ed3\u679c\u90fd\u662f\u4e00\u6837\u7684\uff0c\u5373\u4e00\u4e2a\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\uff0c\u5bf9 ACID \u7ea7\u522b\u7684\u8981\u6c42\uff0c\u5b8c\u5168\u4e00\u6837\uff0c\u65e0\u8bba\u662f\u539f\u5b50\u6027\u3001\u4e00\u81f4\u6027\u3001\u9694\u79bb\u6027\u6216\u8005\u6301\u4e45\u6027\uff0c\u90fd\u662f\u5b8c\u5168\u4e00\u81f4\uff0c\u4e0d\u5b58\u5728\u4e50\u89c2\u4e8b\u52a1\u5c31\u5bbd\u677e\u4e00\u4e9b\uff0c\u60b2\u89c2\u4e8b\u52a1\u5c31\u4e25\u683c\u4e00\u4e9b\u7684\u60c5\u51b5\u3002
\u4e50\u89c2\u4e8b\u52a1\u4e0e\u60b2\u89c2\u4e8b\u52a1\u7684\u533a\u522b\uff0c\u5b83\u53ea\u662f\u4e24\u9636\u6bb5\u63d0\u4ea4\u57fa\u4e8e\u5f85\u5904\u7406\u4e1a\u52a1\u72b6\u6001\u7684\u4e0d\u540c\u6267\u884c\u7b56\u7565\uff0c\u5176\u9009\u62e9\u57fa\u4e8e\u6267\u884c\u8005\u7684\u5224\u65ad\uff0c\u5176\u6548\u7387\u9ad8\u4f4e\u57fa\u4e8e\u88ab\u5904\u7406\u4e1a\u52a1\u7684\u5b9e\u9645\u72b6\u6001\uff08\u5e76\u53d1\u4e8b\u52a1\u7684\u5199\u51b2\u7a81\u9891\u7e41\u5ea6\uff09\u3002\u5373\u5728\u4e8e\u5bf9\u4e8e\u4e8b\u52a1\u76f8\u5173\u8d44\u6e90\u7684\u72b6\u6001\u505a\u51fa\u4e0d\u540c\u7684\u5047\u8bbe\uff0c\u4ece\u800c\u5c06\u5199\u9501\u653e\u5728\u4e0d\u540c\u7684\u9636\u6bb5\u4e2d\u3002
\u5728\u4e50\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4e0d\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u8fd9\u4e00\u9636\u6bb5\u4e0d\u4f1a\u5bf9\u6570\u636e\u52a0\u9501\uff0c\u800c\u5728\u6570\u636e\u63d0\u4ea4\u65f6\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5728\u5b8c\u6210\u63d0\u4ea4\u540e\u89e3\u9501\u3002
\u800c\u5728\u60b2\u89c2\u4e8b\u52a1\u4e2d\uff0c\u4e00\u4e2a\u4e8b\u52a1\u5728\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u4e00\u5b9a\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\uff0c\u9884\u5148\u5bf9\u76f8\u5173\u8868\u6216\u884c\u52a0\u9501\u3002\u7136\u540e\u624d\u5728\u5185\u5b58\u4e2d\uff0c\u5bf9\u76f8\u5173\u6570\u636e\u8fdb\u884c\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u5e76\u63d0\u4ea4\u3002\u53ea\u6709\u5728\u63d0\u4ea4\u6216\u56de\u6eda\u5b8c\u6210\u540e\u624d\u5bf9\u6570\u636e\u8fdb\u884c\u89e3\u9501\u3002
\u4e50\u89c2\u4e8b\u52a1\u4e0e\u60b2\u89c2\u4e8b\u52a1\u5728\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6709\u7740\u5982\u4e0b\u7684\u4f18\u7f3a\u70b9\uff1a
MatrixOne \u7684\u4e50\u89c2\u4e8b\u52a1\u8be6\u60c5\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u4e50\u89c2\u4e8b\u52a1\u3002
MatrixOne \u7684\u60b2\u89c2\u4e8b\u52a1\u8be6\u60c5\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u60b2\u89c2\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/common-transaction-overview/#_8","title":"\u4e8b\u52a1\u9694\u79bb","text":"\u5173\u4e8e\u4e8b\u52a1\u7279\u5f81\u4e2d\u6709\u4e00\u6761\u662f\u9694\u79bb\u6027\uff0c\u6211\u4eec\u901a\u5e38\u79f0\u4e4b\u4e3a\u4e8b\u52a1\u9694\u79bb\u3002
\u5728\u6570\u636e\u5e93\u4e8b\u52a1\u7684 ACID \u56db\u4e2a\u5c5e\u6027\u4e2d\uff0c\u9694\u79bb\u6027\u662f\u4e00\u4e2a\u9650\u5236\u6700\u5bbd\u677e\u7684\u3002\u4e3a\u4e86\u83b7\u53d6\u66f4\u9ad8\u7684\u9694\u79bb\u7b49\u7ea7\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u901a\u5e38\u4f7f\u7528\u9501\u673a\u5236\u6216\u8005\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\u673a\u5236\u3002\u5e94\u7528\u8f6f\u4ef6\u4e5f\u9700\u8981\u989d\u5916\u7684\u903b\u8f91\u6765\u4f7f\u5176\u6b63\u5e38\u5de5\u4f5c\u3002
\u5f88\u591a\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff08DBMS\uff09\u5b9a\u4e49\u4e86\u4e0d\u540c\u7684\u201c\u4e8b\u52a1\u9694\u79bb\u7b49\u7ea7\u201d\u6765\u63a7\u5236\u9501\u7684\u7a0b\u5ea6\u3002\u5728\u5f88\u591a\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0c\u591a\u6570\u7684\u4e8b\u52a1\u90fd\u907f\u514d\u9ad8\u7b49\u7ea7\u7684\u9694\u79bb\u7b49\u7ea7\uff08\u5982\u53ef\u4e32\u884c\u5316\uff09\u4ece\u800c\u51cf\u5c11\u9501\u7684\u5f00\u9500\u3002\u7a0b\u5e8f\u5458\u9700\u8981\u5c0f\u5fc3\u7684\u5206\u6790\u6570\u636e\u5e93\u8bbf\u95ee\u90e8\u5206\u7684\u4ee3\u7801\u6765\u4fdd\u8bc1\u9694\u79bb\u7ea7\u522b\u7684\u964d\u4f4e\u4e0d\u4f1a\u9020\u6210\u96be\u4ee5\u53d1\u73b0\u7684\u4ee3\u7801\u9519\u8bef\u3002\u76f8\u53cd\u7684\uff0c\u66f4\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u4f1a\u589e\u52a0\u6b7b\u9501\u53d1\u751f\u7684\u51e0\u7387\uff0c\u540c\u6837\u9700\u8981\u5728\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u53bb\u907f\u514d\u3002
\u7531\u4e8e\u66f4\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u4e2d\u4e0d\u5b58\u5728\u88ab\u4e00\u4e2a\u66f4\u4f4e\u7684\u9694\u79bb\u7ea7\u522b\u7981\u6b62\u7684\u64cd\u4f5c\uff0cDBMS \u88ab\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u6bd4\u8bf7\u6c42\u7684\u9694\u79bb\u7ea7\u522b\u66f4\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u3002
ANSI/ISO SQL \u5b9a\u4e49\u7684\u6807\u51c6\u9694\u79bb\u7ea7\u522b\u5171\u6709\u56db\u4e2a\uff1a
\u9694\u79bb\u7ea7\u522b \u810f\u5199 (Dirty Write) \u810f\u8bfb (Dirty Read) \u4e0d\u53ef\u91cd\u590d\u8bfb (Fuzzy Read) \u5e7b\u8bfb (Phantom) READ UNCOMMITTED Not Possible Possible Possible Possible READ COMMITTED Not Possible Not Possible Possible Possible REPEATABLE READ Not Possible Not Possible Not Possible Possible SERIALIZABLE Not Possible Not Possible Not Possible Not Possible\u8bfb\u672a\u63d0\u4ea4\uff1a\u8bfb\u672a\u63d0\u4ea4\uff08READ UNCOMMITTED\uff09\u662f\u6700\u4f4e\u7684\u9694\u79bb\u7ea7\u522b\u3002\u5141\u8bb8\u201c\u810f\u8bfb\u201d\uff08dirty reads\uff09\uff0c\u4e8b\u52a1\u53ef\u4ee5\u770b\u5230\u5176\u4ed6\u4e8b\u52a1\u201c\u5c1a\u672a\u63d0\u4ea4\u201d\u7684\u4fee\u6539\u3002
\u8bfb\u5df2\u63d0\u4ea4\uff1a\u8bfb\u5df2\u63d0\u4ea4\uff08READ COMMITTED\uff09\u7ea7\u522b\u4e2d\uff0c\u57fa\u4e8e\u9501\u673a\u5236\u5e76\u53d1\u63a7\u5236\u7684 DBMS \u9700\u8981\u5bf9\u9009\u5b9a\u5bf9\u8c61\u7684\u5199\u9501\u4e00\u76f4\u4fdd\u6301\u5230\u4e8b\u52a1\u7ed3\u675f\uff0c\u4f46\u662f\u8bfb\u9501\u5728 SELECT \u64cd\u4f5c\u5b8c\u6210\u540e\u9a6c\u4e0a\u91ca\u653e\u3002\u548c\u524d\u4e00\u79cd\u9694\u79bb\u7ea7\u522b\u4e00\u6837\uff0c\u4e5f\u4e0d\u8981\u6c42\u201c\u8303\u56f4\u9501\u201d\u3002
\u53ef\u91cd\u590d\u8bfb\uff1a\u5728\u53ef\u91cd\u590d\u8bfb\uff08REPEATABLE READS\uff09\u9694\u79bb\u7ea7\u522b\u4e2d\uff0c\u57fa\u4e8e\u9501\u673a\u5236\u5e76\u53d1\u63a7\u5236\u7684 DBMS \u9700\u8981\u5bf9\u9009\u5b9a\u5bf9\u8c61\u7684\u8bfb\u9501\uff08read locks\uff09\u548c\u5199\u9501\uff08write locks\uff09\u4e00\u76f4\u4fdd\u6301\u5230\u4e8b\u52a1\u7ed3\u675f\uff0c\u4f46\u4e0d\u8981\u6c42\u201c\u8303\u56f4\u9501\u201d\uff0c\u56e0\u6b64\u53ef\u80fd\u4f1a\u53d1\u751f\u201c\u5e7b\u8bfb\u201d\u3002MatrixOne \u5b9e\u73b0\u4e86\u5feb\u7167\u9694\u79bb\uff08\u5373 Snapshot Isolation\uff09\uff0c\u4e3a\u4e86\u4e0e MySQL \u9694\u79bb\u7ea7\u522b\u4fdd\u6301\u4e00\u81f4\uff0cMatrixOne \u5feb\u7167\u9694\u79bb\u53c8\u53eb\u505a\u53ef\u91cd\u590d\u8bfb\uff08REPEATABLE READS\uff09\u3002
\u53ef\u4e32\u884c\u5316\uff1a\u53ef\u4e32\u884c\u5316\uff08SERIALIZABLE\uff09\u662f\u6700\u9ad8\u7684\u9694\u79bb\u7ea7\u522b\u3002\u5728\u57fa\u4e8e\u9501\u673a\u5236\u5e76\u53d1\u63a7\u5236\u7684 DBMS \u4e0a\uff0c\u53ef\u4e32\u884c\u5316\u8981\u6c42\u5728\u9009\u5b9a\u5bf9\u8c61\u4e0a\u7684\u8bfb\u9501\u548c\u5199\u9501\u76f4\u5230\u4e8b\u52a1\u7ed3\u675f\u540e\u624d\u80fd\u91ca\u653e\u3002\u5728 SELECT \u7684\u67e5\u8be2\u4e2d\u4f7f\u7528\u4e00\u4e2a\u201cWHERE\u201d\u5b50\u53e5\u6765\u63cf\u8ff0\u4e00\u4e2a\u8303\u56f4\u65f6\u5e94\u8be5\u83b7\u5f97\u4e00\u4e2a\u201c\u8303\u56f4\u9501\u201d\uff08range-locks\uff09\u3002
\u901a\u8fc7\u6bd4\u4f4e\u4e00\u7ea7\u7684\u9694\u79bb\u7ea7\u522b\u8981\u6c42\u66f4\u591a\u7684\u9650\u5236\uff0c\u9ad8\u4e00\u7ea7\u7684\u7ea7\u522b\u63d0\u4f9b\u66f4\u5f3a\u7684\u9694\u79bb\u6027\u3002\u6807\u51c6\u5141\u8bb8\u4e8b\u52a1\u8fd0\u884c\u5728\u66f4\u5f3a\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u4e0a\u3002
Note
MatrixOne \u7684\u4e8b\u52a1\u9694\u79bb\u4e0e\u901a\u7528\u7684\u9694\u79bb\u5b9a\u4e49\u7684\u9694\u79bb\u7ea7\u522b\u7684\u5212\u5206\u7565\u6709\u4e0d\u540c\uff0c\u53ef\u4ee5\u53c2\u89c1 MatrixOne \u7684\u9694\u79bb\u7ea7\u522b\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/","title":"\u663e\u5f0f\u4e8b\u52a1","text":"\u5728 MatrixOne \u7684\u4e8b\u52a1\u7c7b\u522b\u4e2d\uff0c\u663e\u5f0f\u4e8b\u52a1\u8fd8\u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#_2","title":"\u663e\u5f0f\u4e8b\u52a1\u89c4\u5219","text":"BEGIN...END
\u6216 START TRANSACTION...COMMIT
\u6216 ROLLBACK
\u4f5c\u4e3a\u8d77\u59cb\u7ed3\u675f\u3002START TRANSACTIONS
\u4e4b\u540e\u518d\u9047\u5230 START TRANSACTIONS
\uff0c\u4e24\u4e2a START TRANSACTIONS
\u4e4b\u95f4\u7684\u6240\u6709\u8bed\u53e5\u90fd\u4f1a\u5f3a\u5236\u63d0\u4ea4\uff0c\u65e0\u8bba AUTOCOMMIT
\u7684\u503c\u662f 1 \u6216 0\u3002SET
\u547d\u4ee4\u4e0e\u7ba1\u7406\u7c7b\u547d\u4ee4\uff08CREATE USER/ROLE
\u6216 GRANT
\uff09\uff0c\u53ea\u80fd\u5305\u542b DML \u4e0e DDL\u3002AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4e0d\u4f1a\u5bf9\u4e8b\u52a1\u8fdb\u884c\u4efb\u4f55\u66f4\u6539\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u4f1a\u5728\u4e00\u4e2a\u65b0\u7684\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u4e2d\u6267\u884c\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u4f1a\u5728\u663e\u5f0f\u5f00\u542f\u7684\u4e8b\u52a1\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 \u663e\u5f0f\u4e8b\u52a1\u4e0e\u975e\u81ea\u52a8\u63d0\u4ea4 \u5f53 AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4f1a\u5728\u6bcf\u4e2a\u8bed\u53e5\u6267\u884c\u540e\u81ea\u52a8\u63d0\u4ea4\u672a\u63d0\u4ea4\u7684\u4e8b\u52a1\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u4f1a\u5728\u663e\u5f0f\u5f00\u542f\u7684\u4e8b\u52a1\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 MySQL \u4e0e MatrixOne \u663e\u5f0f\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b
mysql> CREATE TABLE Accounts (account_number INT PRIMARY KEY, balance DECIMAL(10, 2));\nQuery OK, 0 rows affected (0.07 sec)\n\nmysql> INSERT INTO Accounts (account_number, balance) VALUES (1, 1000.00), (2, 500.00);\nQuery OK, 2 rows affected (0.00 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance + 100.00 WHERE account_number = 2;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> COMMIT;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> BEGIN;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> UPDATE Accounts SET balance = balance - 100.00 WHERE account_number = 1;\nQuery OK, 1 row affected (0.00 sec)\n\nmysql> UPDATE Accounts SET invalid_column = 0 WHERE account_number = 2;\nERROR 20101 (HY000): internal error: column 'invalid_column' not found in table\nPrevious DML conflicts with existing constraints or data format. This transaction has to be aborted\nmysql> ROLLBACK;\nQuery OK, 0 rows affected (0.00 sec)\nmysql> SELECT * FROM Accounts;\n+----------------+---------+\n| account_number | balance |\n+----------------+---------+\n| 1 | 900.00 |\n| 2 | 600.00 |\n+----------------+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/explicit-transaction/#_3","title":"\u8de8\u5e93\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b","text":"MatrixOne \u652f\u6301\u8de8\u5e93\u4e8b\u52a1\u884c\u4e3a\uff0c\u8fd9\u91cc\u5c06\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u8fdb\u884c\u8bf4\u660e\u3002
\u9996\u5148\uff0c\u8ba9\u6211\u4eec\u521b\u5efa\u4e24\u4e2a\u6570\u636e\u5e93\uff08db1 \u548c db2\uff09\u4ee5\u53ca\u5b83\u4eec\u5404\u81ea\u7684\u8868\uff08table1 \u548c table2\uff09\uff1a
-- \u521b\u5efa db1 \u6570\u636e\u5e93\nCREATE DATABASE db1;\nUSE db1;\n\n-- \u521b\u5efa db1 \u4e2d\u7684\u8868 table1\nCREATE TABLE table1 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield1 INT\n);\n\n-- \u521b\u5efa db2 \u6570\u636e\u5e93\nCREATE DATABASE db2;\nUSE db2;\n\n-- \u521b\u5efa db2 \u4e2d\u7684\u8868 table2\nCREATE TABLE table2 (\nid INT AUTO_INCREMENT PRIMARY KEY,\nfield2 INT\n);\n
\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u521b\u5efa\u4e86\u4e24\u4e2a\u6570\u636e\u5e93\u548c\u5b83\u4eec\u7684\u8868\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u63d2\u5165\u4e00\u4e9b\u6570\u636e\uff1a
-- \u5728 db1 \u7684 table1 \u4e2d\u63d2\u5165\u6570\u636e\nINSERT INTO db1.table1 (field1) VALUES (100), (200), (300);\n\n-- \u5728 db2 \u7684 table2 \u4e2d\u63d2\u5165\u6570\u636e\nINSERT INTO db2.table2 (field2) VALUES (500), (600), (700);\n
\u73b0\u5728\uff0c\u6211\u4eec\u5df2\u7ecf\u6709\u4e86\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u6267\u884c\u4e00\u4e2a\u8de8\u5e93\u4e8b\u52a1\uff0c\u540c\u65f6\u4fee\u6539\u8fd9\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\uff1a
-- \u5f00\u59cb\u8de8\u5e93\u4e8b\u52a1\nSTART TRANSACTION;\n\n-- \u5728 db1 \u4e2d\u66f4\u65b0 table1 \u7684\u6570\u636e\nUPDATE db1.table1 SET field1 = field1 + 10;\n\n-- \u5728 db2 \u4e2d\u66f4\u65b0 table2 \u7684\u6570\u636e\nUPDATE db2.table2 SET field2 = field2 - 50;\n\n-- \u63d0\u4ea4\u8de8\u5e93\u4e8b\u52a1\nCOMMIT;\n
\u5728\u4e0a\u9762\u7684\u8de8\u5e93\u4e8b\u52a1\u4e2d\uff0c\u9996\u5148\u4f7f\u7528 START TRANSACTION;
\u5f00\u59cb\u4e8b\u52a1\uff0c\u7136\u540e\u5206\u522b\u5728 db1 \u548c db2 \u4e2d\u66f4\u65b0\u4e86\u5404\u81ea\u7684\u8868\u6570\u636e\uff0c\u6700\u540e\u4f7f\u7528 COMMIT;
\u63d0\u4ea4\u4e8b\u52a1\u3002\u5982\u679c\u5728\u4e8b\u52a1\u671f\u95f4\u4efb\u4f55\u4e00\u6b65\u5931\u8d25\uff0c\u6574\u4e2a\u4e8b\u52a1\u5c06\u56de\u6eda\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
\u8fd9\u4e2a\u793a\u4f8b\u5c55\u793a\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u8de8\u5e93\u4e8b\u52a1\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u8de8\u5e93\u4e8b\u52a1\u53ef\u80fd\u66f4\u52a0\u590d\u6742\uff0c\u8fd9\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u57fa\u672c\u7684\u6982\u5ff5\u548c\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/","title":"\u4e8b\u52a1\u4f7f\u7528\u6307\u5357","text":"\u672c\u7ae0\u8282\u5411\u4f60\u4ecb\u7ecd\u5982\u4f55\u7b80\u5355\u7684\u5f00\u542f\u3001\u63d0\u4ea4\u3001\u56de\u6eda\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4ee5\u53ca\u5982\u4f55\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_2","title":"\u5f00\u542f\u4e8b\u52a1","text":"\u5f00\u542f\u4e8b\u52a1\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 START TRANSACTION
\u5f00\u59cb\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4e5f\u53ef\u4ee5\u7528\u65b9\u8a00\u547d\u4ee4 BEGIN
\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a
START TRANSACTION;\ninsert into t1 values(123,'123');\n
\u6216\uff1a
BEGIN;\ninsert into t1 values(123,'123');\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_3","title":"\u63d0\u4ea4\u4e8b\u52a1","text":"\u63d0\u4ea4\u4e8b\u52a1\u65f6\uff0cMatrixOne \u63a5\u53d7 COMMIT
\u547d\u4ee4\u4f5c\u4e3a\u63d0\u4ea4\u547d\u4ee4\u3002\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
START TRANSACTION;\ninsert into t1 values(123,'123');\ncommit;\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_4","title":"\u56de\u6eda\u4e8b\u52a1","text":"\u56de\u6eda\u4e8b\u52a1\u65f6\uff0cMatrixOne \u63a5\u53d7 ROLLBACK
\u547d\u4ee4\u4f5c\u4e3a\u63d0\u4ea4\u547d\u4ee4\u3002\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
START TRANSACTION;\ninsert into t1 values(123,'123');\nrollback;\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_5","title":"\u81ea\u52a8\u63d0\u4ea4","text":"\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e00\u4e2a\u53c2\u6570 AUTOCOMMIT
\uff0c\u51b3\u5b9a\u4e86\u6ca1\u6709 START TRANSACTION
\u6216 BEGIN
\u7684\u60c5\u51b5\u4e0b\uff0c\u5355\u6761 SQL \u8bed\u53e5\u7684\u662f\u5426\u88ab\u5f53\u505a\u72ec\u7acb\u4e8b\u52a1\u81ea\u52a8\u63d0\u4ea4\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a
-- \u8bbe\u7f6e\u8be5\u53c2\u6570\u7684\u503c\nSET AUTOCOMMIT={on|off|0|1} SHOW VARIABLES LIKE 'AUTOCOMMIT';\n
\u5728\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a ON \u6216 1 \u7684\u65f6\u5019\uff0c\u610f\u5473\u7740\u81ea\u52a8\u63d0\u4ea4\uff0c\u6240\u6709\u4e0d\u5728 START TRANSACTION
\u6216 BEGIN
\u4e2d\u7684\u5355\u6761 SQL \u8bed\u53e5\uff0c\u90fd\u4f1a\u5728\u6267\u884c\u65f6\u81ea\u52a8\u63d0\u4ea4\u3002
-- \u6b64\u65f6\u81ea\u52a8\u63d0\u4ea4\ninsert into t1 values(1,2,3);
\u5728\u8be5\u53c2\u6570\u8bbe\u7f6e\u4e3a OFF \u6216 0 \u7684\u65f6\u5019\uff0c\u610f\u5473\u7740\u975e\u81ea\u52a8\u63d0\u4ea4\uff0c\u6240\u6709\u4e0d\u5728 START TRANSACTION
\u6216 BEGIN
\u4e2d\u7684 SQL \u8bed\u53e5\uff0c\u9700\u8981\u7528 COMMIT
\u6216 ROLLBACK
\u6765\u6267\u884c\u63d0\u4ea4\u6216\u56de\u6eda\u3002
insert into t1 values(1,2,3);\n-- \u6b64\u5904\u9700\u8981\u624b\u52a8\u63d0\u4ea4\nCOMMIT\uff1b
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/how-to-use/#_6","title":"\u5207\u6362\u4e8b\u52a1\u6a21\u5f0f","text":"MatrixOne \u9ed8\u8ba4\u91c7\u7528\u60b2\u89c2\u4e8b\u52a1\u4e0e RC \u9694\u79bb\u7ea7\u522b\u3002\u4f46\u82e5\u4f60\u9700\u8981\u5207\u6362\u81f3\u4e50\u89c2\u4e8b\u52a1\u6a21\u5f0f\uff0c\u76f8\u5e94\u7684\u9694\u79bb\u7ea7\u522b\u5c06\u81ea\u52a8\u66f4\u6539\u4e3a\u5feb\u7167\u9694\u79bb\u3002
\u5728 matrixone/etc/launch-with-proxy/ \u76ee\u5f55\u4e0b\u7684\u914d\u7f6e\u6587\u4ef6 cn.toml \u4e2d\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\u53c2\u6570\u4ee5\u5207\u6362\u4e8b\u52a1\u6a21\u5f0f\uff1a
[cn.Txn]\nmode = \"optimistic\"\nisolation = \"SI\"\n
Note: \u5982\u679c\u4f60\u53ea\u6dfb\u52a0\u4e8b\u52a1\u6a21\u5f0f\u53c2\u6570 mode = \"optimistic\"
\uff0c\u4f46\u672a\u6dfb\u52a0 isolation = \"SI\"
\uff0c\u7cfb\u7edf\u4e5f\u5c06\u9ed8\u8ba4\u5728\u4e50\u89c2\u4e8b\u52a1\u6a21\u5f0f\u4e0b\u7684\u9694\u79bb\u7ea7\u522b\u4e3a SI \u9694\u79bb\u3002
\u91cd\u542f MatrixOne\uff0c\u4fbf\u80fd\u4f7f\u5207\u6362\u540e\u7684\u4e8b\u52a1\u6a21\u5f0f\u751f\u6548\u3002
\u66f4\u591a\u5173\u4e8e\u914d\u7f6e\u53c2\u6570\u4fe1\u606f\uff0c\u53c2\u89c1\u5206\u5e03\u5f0f\u7248\u901a\u7528\u53c2\u6570\u914d\u7f6e\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/","title":"\u9690\u5f0f\u4e8b\u52a1","text":"\u5728 MatrixOne \u7684\u4e8b\u52a1\u7c7b\u522b\u4e2d\uff0c\u9690\u5f0f\u4e8b\u52a1\u8fd8\u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#_2","title":"\u9690\u5f0f\u4e8b\u52a1\u89c4\u5219","text":"MatrixOne \u5728 AUTOCOMMIT
\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u5bf9\u4e8e\u9690\u5f0f\u4e8b\u52a1\u672a\u63d0\u4ea4\u7684\u60c5\u51b5\u4f1a\u8fdb\u884c\u9519\u8bef\u5904\u7406\uff0c\u5e76\u5411\u7528\u6237\u63d0\u793a\u9700\u8981\u5148\u63d0\u4ea4\u53d8\u5316\u3002
\u5728 AUTOCOMMIT=0
\u4e14\u5f53\u524d\u5b58\u5728\u6d3b\u8dc3\u4e8b\u52a1\u7684\u60c5\u51b5\u4e0b\uff0c\u7981\u6b62\u4fee\u6539\u81ea\u52a8\u63d0\u4ea4\u4e0e\u9694\u79bb\u7ea7\u522b\uff0c\u4ee5\u53ca\u7ba1\u7406\u7c7b\u4e0e\u53c2\u6570\u8bbe\u7f6e\u547d\u4ee4\uff0c\u4f8b\u5982 SET
\u3001CREATE USER/ROLE
\u6216\u6388\u6743\u64cd\u4f5c\u4e5f\u5c06\u88ab\u9650\u5236\u3002
\u5f53 AUTOCOMMIT=1
\u65f6\uff0c\u6bcf\u6761 DML \u8bed\u53e5\u90fd\u88ab\u89c6\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684\u4e8b\u52a1\uff0c\u5728\u6267\u884c\u540e\u7acb\u5373\u8fdb\u884c\u63d0\u4ea4\u3002
\u800c\u5728 AUTOCOMMIT=0
\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6761 DML \u8bed\u53e5\u5728\u6267\u884c\u540e\u5e76\u4e0d\u4f1a\u7acb\u5373\u63d0\u4ea4\uff0c\u9700\u8981\u624b\u52a8\u6267\u884c COMMIT
\u6216 ROLLBACK
\u64cd\u4f5c\u3002\u82e5\u5728\u5c1a\u672a\u63d0\u4ea4\u6216\u56de\u6eda\u7684\u72b6\u6001\u4e0b\u9000\u51fa\u5ba2\u6237\u7aef\uff0c\u5219\u9ed8\u8ba4\u8fdb\u884c\u56de\u6eda\u64cd\u4f5c\u3002
\u5728 AUTOCOMMIT=0
\u7684\u60c5\u51b5\u4e0b\uff0cDML \u4e0e DDL \u53ef\u4ee5\u540c\u65f6\u5b58\u5728\u4e8e\u4e00\u4e2a\u9690\u5f0f\u4e8b\u52a1\u4e2d\uff0c\u4f46 DDL \u7684\u5bf9\u8c61\u7c7b\u578b\u4e0d\u80fd\u4e3a\u6570\u636e\u5e93\u4e0e\u5e8f\u5217\u3002
\u82e5\u5728 AUTOCOMMIT=0
\u7684\u72b6\u6001\u4e0b\u51fa\u73b0 CREATE/DROP DATABASE
\u6216 CREATE/DROP SEQUENCE
\u64cd\u4f5c\uff0c\u5219\u4f1a\u5f3a\u5236\u63d0\u4ea4\u4e4b\u524d\u672a\u63d0\u4ea4\u7684\u6240\u6709\u5185\u5bb9\u3002\u540c\u65f6\uff0cCREATE/DROP DATABASE
\u64cd\u4f5c\u5c06\u4f1a\u7acb\u5373\u4f5c\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684\u4e8b\u52a1\u8fdb\u884c\u63d0\u4ea4\u3002
\u5f53\u5b58\u5728\u672a\u63d0\u4ea4\u5185\u5bb9\u7684\u9690\u5f0f\u4e8b\u52a1\u65f6\uff0c\u82e5\u542f\u52a8\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\uff0c\u5219\u4f1a\u5f3a\u5236\u63d0\u4ea4\u4e4b\u524d\u672a\u63d0\u4ea4\u7684\u5185\u5bb9\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5982\u679c\u5f00\u542f\u4e86\u9690\u5f0f\u4e8b\u52a1\uff08SET AUTOCOMMIT=0
\uff09\uff0c\u5219\u6240\u6709\u64cd\u4f5c\u90fd\u9700\u8981\u624b\u52a8\u6267\u884c COMMIT
\u6216 ROLLBACK
\u6765\u7ed3\u675f\u4e8b\u52a1\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0cMySQL \u5728\u9047\u5230 DDL \u6216\u7c7b\u4f3c SET
\u8bed\u53e5\u65f6\u4f1a\u81ea\u52a8\u63d0\u4ea4\u3002
AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4e0d\u4f1a\u5bf9\u4e8b\u52a1\u8fdb\u884c\u4efb\u4f55\u66f4\u6539\uff0c\u6bcf\u4e2a\u8bed\u53e5\u90fd\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0cMySQL \u4e5f\u4e0d\u4f1a\u5bf9\u4e8b\u52a1\u8fdb\u884c\u4efb\u4f55\u66f4\u6539\uff0c\u4f46\u968f\u540e\u7684\u8bed\u53e5\u5c06\u7ee7\u7eed\u5728\u5f53\u524d\u4e8b\u52a1\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 \u9690\u5f0f\u4e8b\u52a1\u4e0e\u975e\u81ea\u52a8\u63d0\u4ea4 \u5f53 AUTOCOMMIT=1
\u65f6\uff0cMySQL \u4f1a\u5728\u6bcf\u4e2a\u8bed\u53e5\u6267\u884c\u540e\u81ea\u52a8\u63d0\u4ea4\u672a\u63d0\u4ea4\u7684\u4e8b\u52a1\u3002 \u5f53 AUTOCOMMIT=0
\u65f6\uff0cMySQL \u4f1a\u7ee7\u7eed\u5728\u5f53\u524d\u4e8b\u52a1\u4e2d\u6267\u884c\u968f\u540e\u7684\u8bed\u53e5\uff0c\u76f4\u5230\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u4e8b\u52a1\u3002 MySQL \u9690\u5f0f\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b
mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = default;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.00 sec)\n
MatrixOne \u9690\u5f0f\u4e8b\u52a1\u884c\u4e3a\u793a\u4f8b
mysql> select @@SQL_SELECT_LIMIT;\n+----------------------+\n| @@SQL_SELECT_LIMIT |\n+----------------------+\n| 18446744073709551615 |\n+----------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> set SQL_SELECT_LIMIT = 1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> rollback;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select @@SQL_SELECT_LIMIT;\n+--------------------+\n| @@SQL_SELECT_LIMIT |\n+--------------------+\n| 1 |\n+--------------------+\n1 row in set (0.01 sec)\n\nmysql> set autocommit=0;\nERROR 20101 (HY000): internal error: Uncommitted transaction exists. Please commit or rollback first.\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/implicit-transaction/#_3","title":"\u9690\u5f0f\u4e8b\u52a1\u793a\u4f8b","text":"\u4f8b\u5982\uff0c\u5bf9 t1 \u63d2\u5165\u6570\u636e (4,5,6)\uff0c\u5373\u6210\u4e3a\u4e00\u4e2a\u9690\u5f0f\u4e8b\u52a1\u3002\u800c\u8be5\u9690\u5f0f\u4e8b\u52a1\u662f\u5426\u7acb\u5373\u63d0\u4ea4\uff0c\u53d6\u51b3\u4e8e AUTOCOMMIT
\u53c2\u6570\u7684\u503c\uff1a
CREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nSTART TRANSACTION;\nINSERT INTO t1 values(1,2,3);\nCOMMIT;\n\n-- \u67e5\u770b AUTOCOMMIT \u5f00\u5173\u53c2\u6570\nmysql> SHOW VARIABLES LIKE 'AUTOCOMMIT';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit | 1 |\n+---------------+-------+\n1 row in set (0.00 sec)\n-- \u6b64\u5904\u5f00\u59cb\u4e00\u4e2a\u9690\u5f0f\u4e8b\u52a1\uff0c\u5728 AUTOCOMMIT=1 \u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u4e00\u6761 DML \u5728\u6267\u884c\u540e\u7acb\u5373\u63d0\u4ea4\ninsert into t1 values(4,5,6);\n\n-- \u9690\u5f0f\u4e8b\u52a1\u81ea\u52a8\u63d0\u4ea4\uff0c\u8868\u6570\u636e\u5982\u4e0b\u6240\u793a\nmysql> select * from t1;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 2 | 3 |\n| 4 | 5 | 6 |\n+------+------+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/","title":"\u9694\u79bb\u7ea7\u522b","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#_2","title":"\u8bfb\u5df2\u63d0\u4ea4","text":"MatrixOne \u9ed8\u8ba4\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u9694\u79bb\u7ea7\u522b\uff0c\u5b83\u7684\u7279\u70b9\u5982\u4e0b\uff1a
\u4f60\u53ef\u4ee5\u53c2\u7167\u4e0b\u9762\u7684\u793a\u4f8b\uff0c\u6765\u7406\u89e3\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\u3002
\u9996\u5148\u5728 MatrixOne \u4e2d\uff0c\u6211\u4eec\u5efa\u7acb\u4e00\u4e2a\u547d\u540d\u4e3a test
\u7684\u6570\u636e\u5e93\u4e0e\u8868 t1
\uff0c\u5e76\u63d2\u5165\u6570\u636e\uff1a
create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u5f00\u542f\u4e00\u4e2a\u4e8b\u52a1\uff1a
use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7684\u7ed3\u679c\u662f\u5982\u4e0b\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 2 | version3 |\n| 1 | version1 |\n+------+----------+\n
\u6b64\u65f6\u5f00\u542f\u4f1a\u8bdd 2\uff0c\u5f00\u542f\u4e00\u4e2a\u65b0\u4e8b\u52a1\u53bb\u67e5\u8be2 t1 \u7684\u5185\u5bb9\uff1a
use test;\nbegin;\nSELECT * FROM t1;\n
\u770b\u5230\u7684\u7ed3\u679c\u4ecd\u7136\u662f\u539f\u59cb\u6570\u636e\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version2 |\n+------+----------+\n
\u5728\u4f1a\u8bdd 2 \u4e2d\uff0c\u4fee\u6539 tid=1
\u7684\u884c\uff1a
UPDATE t1 SET tname='version0' WHERE tid=1;\n
\u6b64\u65f6\uff0c\u5728\u4f1a\u8bdd 1 \u4e2d\u67e5\u8be2 t1
\u7684\u5185\u5bb9\u4ecd\u7136\u8fd8\u662f\u4fee\u6539\u540e\u7684\u6570\u636e\uff1a
SELECT * FROM t1;\n+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version3 |\n+------+----------+\n
\u5728\u4f1a\u8bdd 2 \u63d0\u4ea4\u81ea\u5df1\u7684\u6570\u636e\u540e\uff0c\u518d\u67e5\u8be2\u4f1a\u8bdd 1\uff0c\u4f1a\u53d1\u73b0\uff0c\u6b64\u65f6\u4f1a\u8bdd 1 \u7684\u5185\u5bb9\u5df2\u7ecf\u53d8\u6210\u4e86\u4f1a\u8bdd 2 \u63d0\u4ea4\u4e4b\u540e\u7684\u6570\u636e\uff1a
-- \u5728\u4f1a\u8bdd 2 \u4e2d\u63d0\u4ea4\u6570\u636e\uff1a\nCOMMIT;\n
-- \u67e5\u8be2\u4f1a\u8bdd 1 \u7684\u5185\u5bb9\u662f\u5426\u5df2\u7ecf\u53d8\u6210\u4e86\u4f1a\u8bdd 2 \u63d0\u4ea4\u4e4b\u540e\u7684\u6570\u636e\uff1a\nSELECT * FROM t1;\n+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version0 |\n| 2 | version3 |\n+------+----------+\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#_5","title":"\u5feb\u7167\u9694\u79bb","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e5f\u652f\u6301\u5feb\u7167\u9694\u79bb\uff08Snapshot Isolation\uff09\uff0c\u4e3a\u4e86\u4e0e MySQL \u9694\u79bb\u7ea7\u522b\u4fdd\u6301\u4e00\u81f4\uff0cMatrixOne \u5feb\u7167\u9694\u79bb\u53c8\u53eb\u505a\u53ef\u91cd\u590d\u8bfb\uff08REPEATABLE READS\uff09\u3002\u8be5\u7ea7\u522b\u7684\u9694\u79bb\u5b9e\u73b0\u539f\u7406\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/isolation-level/#_6","title":"\u5feb\u7167\u9694\u79bb\u539f\u7406","text":"\u4f60\u53ef\u4ee5\u53c2\u7167\u4e0b\u9762\u7684\u793a\u4f8b\uff0c\u6765\u5e2e\u52a9\u7406\u89e3\u5feb\u7167\u9694\u79bb\u3002
\u9996\u5148\u5728 MatrixOne \u4e2d\uff0c\u6211\u4eec\u5efa\u7acb\u4e00\u4e2a\u6570\u636e\u5e93 test \u4e0e\u8868 t1\uff1a
create database test;\nuse test;\nCREATE TABLE t1\n(\ntid INT NOT NULL primary key,\ntname VARCHAR(50) NOT NULL\n);\nINSERT INTO t1 VALUES(1,'version1');\nINSERT INTO t1 VALUES(2,'version2');\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u5f00\u542f\u4e00\u4e2a\u4e8b\u52a1\uff1a
use test;\nbegin;\nUPDATE t1 SET tname='version3' WHERE tid=2;\nSELECT * FROM t1;\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7684\u7ed3\u679c\u662f\u5982\u4e0b\uff0c\u6839\u636e\u5feb\u7167\u7684\u6570\u636e\u6240\u8fdb\u884c\u7684\u4fee\u6539\u7ed3\u679c\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 2 | version3 |\n| 1 | version1 |\n+------+----------+\n
\u6b64\u65f6\u5f00\u542f\u4f1a\u8bdd 2\uff0c\u53bb\u67e5\u8be2 t1 \u7684\u5185\u5bb9\uff1a
use test;\nSELECT * FROM t1;\n
\u770b\u5230\u7684\u7ed3\u679c\u4ecd\u7136\u662f\u539f\u59cb\u6570\u636e\uff1a
+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version2 |\n+------+----------+\n
\u5728\u4f1a\u8bdd 1 \u4e2d\uff0c\u6211\u4eec\u5c06\u4e8b\u52a1\u63d0\u4ea4\uff1a
COMMIT;\n
\u6b64\u65f6\uff0c\u5728\u4f1a\u8bdd 2 \u4e2d\u67e5\u8be2 t1 \u7684\u5185\u5bb9\u5c31\u53d8\u6210\u4e86\u63d0\u4ea4\u540e\u7684\u6570\u636e\uff1a
SELECT * FROM t1;\n+------+----------+\n| tid | tname |\n+------+----------+\n| 1 | version1 |\n| 2 | version3 |\n+------+----------+\n
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/mvcc/","title":"MVCC","text":"MVCC\uff08Multiversion Concurrency Control\uff0c\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09\u5e94\u7528\u4e8e MatrixOne\uff0c\u4ee5\u4fdd\u8bc1\u4e8b\u52a1\u5feb\u7167\u9694\u79bb\uff0c\u5b9e\u73b0\u4e8b\u52a1\u7684\u9694\u79bb\u6027\u3002
\u57fa\u4e8e\u6570\u636e\u5143\u7ec4\uff08Tuple\uff0c\u5373\u8868\u4e2d\u7684\u6bcf\u884c\uff09\u7684\u6307\u9488\u5b57\u6bb5\u6765\u521b\u5efa\u4e00\u4e2a Latch Free \u7684\u94fe\u8868\uff0c\u79f0\u4e3a\u7248\u672c\u94fe\u3002\u8fd9\u4e2a\u7248\u672c\u94fe\u5141\u8bb8\u6570\u636e\u5e93\u5b9a\u4f4d\u4e00\u4e2a Tuple \u7684\u6240\u9700\u7248\u672c\u3002\u56e0\u6b64\u8fd9\u4e9b\u7248\u672c\u6570\u636e\u7684\u5b58\u653e\u673a\u5236\u662f\u6570\u636e\u5e93\u5b58\u50a8\u5f15\u64ce\u8bbe\u8ba1\u7684\u4e00\u4e2a\u91cd\u8981\u8003\u91cf\u3002
\u4e00\u4e2a\u65b9\u6848\u662f\u91c7\u7528 Append Only \u673a\u5236\uff0c\u4e00\u4e2a\u8868\u7684\u6240\u6709 Tuple \u7248\u672c\u90fd\u5b58\u50a8\u5728\u540c\u4e00\u4e2a\u5b58\u50a8\u7a7a\u95f4\u3002\u8fd9\u79cd\u65b9\u6cd5\u88ab\u7528\u4e8e Postgre SQL\uff0c\u4e3a\u4e86\u66f4\u65b0\u4e00\u4e2a\u73b0\u6709\u7684 Tuple\uff0c\u6570\u636e\u5e93\u9996\u5148\u4e3a\u65b0\u7684\u7248\u672c\u4ece\u8868\u4e2d\u83b7\u53d6\u4e00\u4e2a\u7a7a\u7684\u69fd\uff08Slot\uff09\uff0c\u7136\u540e\uff0c\u5b83\u5c06\u5f53\u524d\u7248\u672c\u7684\u5185\u5bb9\u590d\u5236\u5230\u65b0\u7248\u672c\u3002\u6700\u540e\uff0c\u5b83\u5728\u65b0\u5206\u914d\u7684 Slot \u4e2d\u5e94\u7528\u5bf9 Tuple \u7684\u4fee\u6539\u3002Append Only \u673a\u5236\u7684\u5173\u952e\u662f\u51b3\u5b9a\u5982\u4f55\u4e3a Tuple \u7684\u7248\u672c\u94fe\u6392\u5e8f\uff0c\u7531\u4e8e\u4e0d\u53ef\u80fd\u7ef4\u6301\u4e00\u4e2a\u65e0\u9501\uff08Lock free\uff09\u7684\u53cc\u5411\u94fe\u8868\uff0c\u56e0\u6b64\u7248\u672c\u94fe\u53ea\u6307\u5411\u4e00\u4e2a\u65b9\u5411\uff0c\u6216\u8005\u4ece Old \u5230 New\uff08O2N\uff09\uff0c\u6216\u8005\u4ece New \u5230 Old\uff08N2O\uff09\u3002
\u53e6\u5916\u4e00\u4e2a\u7c7b\u4f3c\u7684\u65b9\u6848\u79f0\u4e3a\u65f6\u95f4\u65c5\u884c\uff08Time Travel\uff09\uff0c\u5b83\u4f1a\u628a\u7248\u672c\u94fe\u7684\u4fe1\u606f\u5355\u72ec\u5b58\u653e\uff0c\u800c\u4e3b\u8868\u7ef4\u62a4\u4e3b\u7248\u672c\u6570\u636e\u3002
\u7b2c\u4e09\u79cd\u65b9\u6848\uff0c\u662f\u5728\u4e3b\u8868\u4e2d\u7ef4\u62a4 Tuple \u7684\u4e3b\u7248\u672c\uff0c\u5728\u4e00\u4e2a\u5355\u72ec\u7684\u6570\u636e\u5e93\u5bf9\u6bd4\u5de5\u5177\uff08Delta\uff09\u5b58\u50a8\u4e2d\u7ef4\u62a4\u4e00\u7cfb\u5217 Delta \u7248\u672c\u3002\u8fd9\u79cd\u5b58\u50a8\u5728 MySQL \u548c Oracle \u4e2d\u88ab\u79f0\u4e3a\u56de\u6eda\u6bb5\u3002\u4e3a\u4e86\u66f4\u65b0\u4e00\u4e2a\u73b0\u6709\u7684 Tuple\uff0c\u6570\u636e\u5e93\u4ece Delta \u5b58\u50a8\u4e2d\u83b7\u53d6\u4e00\u4e2a\u8fde\u7eed\u7684\u7a7a\u95f4\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Delta \u7248\u672c\u3002\u8fd9\u4e2a Delta \u7248\u672c\u5305\u542b\u4fee\u6539\u8fc7\u7684\u5c5e\u6027\u7684\u539f\u59cb\u503c\uff0c\u800c\u4e0d\u662f\u6574\u4e2a Tuple\u3002\u7136\u540e\u6570\u636e\u5e93\u76f4\u63a5\u5bf9\u4e3b\u8868\u4e2d\u7684\u4e3b\u7248\u672c\u8fdb\u884c\u539f\u5730\u66f4\u65b0\uff08In Place Update\uff09\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/","title":"\u4e50\u89c2\u4e8b\u52a1","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#_2","title":"\u4e50\u89c2\u4e8b\u52a1\u539f\u7406","text":"\u4e50\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4e0d\u4f1a\u505a\u51b2\u7a81\u68c0\u6d4b\u6216\u9501\u64cd\u4f5c\uff0c\u4f1a\u5c06\u5f53\u524d\u76f8\u5173\u6570\u636e\u7f13\u5b58\u81f3\u5bf9\u5e94\u5185\u5b58\u533a\u57df\uff0c\u5e76\u5bf9\u8be5\u6570\u636e\u8fdb\u884c\u589e\u5220\u6539\u3002
\u5728\u5b8c\u6210\u4fee\u6539\u540e\uff0c\u8fdb\u5165\u63d0\u4ea4\u9636\u6bb5\u65f6\uff0c\u5c06\u5206\u4e3a\u4e24\u4e2a\u6b65\u9aa4\u8fdb\u884c\u63d0\u4ea4\uff1a
\u6b65\u9aa4\u4e00\uff1a\u5c06\u5f85\u5199\u6570\u636e\u4e2d\u7684\u67d0\u4e00\u5217\u5f53\u505a\u4e3b\u952e\u5217\uff0c\u5e76\u5bf9\u8be5\u5217\u4e0a\u9501\u5e76\u521b\u5efa\u65f6\u95f4\u6233\u3002\u57fa\u4e8e\u6b64\u65f6\u95f4\u6233\u4e4b\u540e\u5bf9\u76f8\u5173\u884c\u8fdb\u884c\u7684\u5199\u5165\u5747\u5224\u5b9a\u4e3a\u5199\u51b2\u7a81\u3002
\u6b65\u9aa4\u4e8c\uff1a\u5199\u5165\u6570\u636e\uff0c\u5e76\u4e14\u8bb0\u5f55\u6b64\u65f6\u7684\u65f6\u95f4\u6233\uff0c\u89e3\u5f00\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#_3","title":"\u4e50\u89c2\u4e8b\u52a1\u6a21\u578b","text":"MatrixOne \u652f\u6301\u4e50\u89c2\u4e8b\u52a1\u6a21\u578b\u3002\u4f60\u5728\u4f7f\u7528\u4e50\u89c2\u5e76\u53d1\u8bfb\u53d6\u4e00\u884c\u65f6\u4e0d\u4f1a\u9501\u5b9a\u8be5\u884c\u3002\u5f53\u4f60\u60f3\u8981\u66f4\u65b0\u4e00\u884c\u65f6\uff0c\u5e94\u7528\u7a0b\u5e8f\u5fc5\u987b\u786e\u5b9a\u5176\u4ed6\u7528\u6237\u662f\u5426\u5728\u8bfb\u53d6\u8be5\u884c\u540e\u5bf9\u8be5\u884c\u4e0a\u9501\u4e86\u3002\u4e50\u89c2\u5e76\u53d1\u4e8b\u52a1\u901a\u5e38\u7528\u4e8e\u6570\u636e\u4e89\u7528\u8f83\u4f4e\u7684\u73af\u5883\u4e2d\u3002
\u5728\u4e50\u89c2\u5e76\u53d1\u6a21\u578b\u4e2d\uff0c\u5982\u679c\u4f60\u4ece\u6570\u636e\u5e93\u63a5\u6536\u5230\u4e00\u4e2a\u503c\u540e\uff0c\u53e6\u4e00\u4e2a\u7528\u6237\u5728\u4f60\u8bd5\u56fe\u4fee\u6539\u8be5\u503c\u4e4b\u524d\u4fee\u6539\u4e86\u8be5\u503c\uff0c\u5219\u4ea7\u751f\u62a5\u9519\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/optimistic-transaction/#_4","title":"\u6a21\u578b\u793a\u4f8b","text":"\u4e0b\u9762\u4e3a\u4e50\u89c2\u5e76\u53d1\u7684\u793a\u4f8b\uff0c\u5c06\u4e3a\u4f60\u5c55\u793a MatrixOne \u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u51b2\u7a81\u3002
\u5728\u4e0b\u5348 1:00\uff0c\u7528\u6237 1 \u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u4e00\u884c\uff0c\u5176\u503c\u5982\u4e0b\uff1a
CustID LastName FirstName\n101 Smith Bob\n
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob \u5728\u4e0b\u5348 1:01\uff0c\u7528\u6237 2 \u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u540c\u4e00\u884c\u3002
\u5728\u4e0b\u5348 1:03\uff0c\u7528\u6237 2 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cRobert\u201d\uff0c\u5e76\u66f4\u65b0\u5230\u6570\u636e\u5e93\u91cc\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob\u5982\u4e0a\u8868\u6240\u793a\uff0c\u66f4\u65b0\u65f6\u6570\u636e\u5e93\u4e2d\u7684\u503c\u4e0e\u7528\u6237 2 \u7684\u539f\u59cb\u503c\u5339\u914d\uff0c\u8868\u793a\u66f4\u65b0\u6210\u529f\u3002
\u5728\u4e0b\u5348 1:05\uff0c\u7528\u6237 1 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cJames\u201d\uff0c\u5e76\u5c1d\u8bd5\u8fdb\u884c\u66f4\u65b0\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Robert\u6b64\u65f6\uff0c\u7528\u6237 1 \u9047\u5230\u4e86\u4e50\u89c2\u5e76\u53d1\u51b2\u7a81\uff0c\u56e0\u4e3a\u6570\u636e\u5e93\u4e2d\u7684\u503c\u201cRobert\u201d\u4e0d\u518d\u4e0e\u7528\u6237 1 \u671f\u671b\u7684\u539f\u59cb\u503c\u201cBob\u201d\u5339\u914d\uff0c\u5e76\u53d1\u51b2\u7a81\u63d0\u793a\u66f4\u65b0\u5931\u8d25\u3002\u4e0b\u4e00\u6b65\u9700\u8981\u51b3\u5b9a\uff0c\u662f\u91c7\u7528\u7528\u6237 1 \u7684\u66f4\u6539\u8986\u76d6\u7528\u6237 2 \u7684\u66f4\u6539\uff0c\u8fd8\u662f\u53d6\u6d88\u7528\u6237 1 \u7684\u66f4\u6539\u3002
MatrixOne \u4e8b\u52a1\u9075\u5faa\u6570\u636e\u5e93\u4e8b\u52a1\u7684\u6807\u51c6\u5b9a\u4e49\u4e0e\u57fa\u672c\u7279\u5f81 (ACID)\u3002\u5b83\u65e8\u5728\u5e2e\u52a9\u7528\u6237\u5728\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u73af\u5883\u4e0b\uff0c\u786e\u4fdd\u6bcf\u4e00\u6b21\u6570\u636e\u5e93\u6570\u636e\u64cd\u4f5c\u884c\u4e3a\uff0c\u90fd\u80fd\u591f\u4ee4\u7ed3\u679c\u4fdd\u8bc1\u6570\u636e\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\uff0c\u5728\u5e76\u53d1\u8bf7\u6c42\u4e0b\u4e92\u76f8\u9694\u79bb\u4e0d\u53d7\u5e72\u6270\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone_2","title":"MatrixOne \u7684\u4e8b\u52a1\u7c7b\u578b","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e8b\u52a1\u4e0e\u901a\u7528\u4e8b\u52a1\u4e00\u6837\uff0c\u4e5f\u5206\u4e3a\u4ee5\u4e0b\u4e24\u5927\u7c7b\uff1a
\u8fd9\u4e24\u5927\u7c7b\u4e8b\u52a1\u7684\u5206\u7c7b\u5f7c\u6b64\u4e0d\u53d7\u5bf9\u65b9\u9650\u5236\uff0c\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\u53ef\u4ee5\u662f\u4e50\u89c2\u4e8b\u52a1\u6216\u60b2\u89c2\u4e8b\u52a1\uff0c\u540c\u65f6\u4e00\u4e2a\u60b2\u89c2\u4e8b\u52a1\u53ef\u80fd\u662f\u663e\u5f0f\u4e8b\u52a1\u4e5f\u53ef\u80fd\u662f\u9690\u5f0f\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#_1","title":"\u663e\u5f0f\u4e8b\u52a1","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e00\u4e2a\u4e8b\u52a1\u4ee5 START TRANSACTION
\u663e\u5f0f\u58f0\u660e\uff0c\u5373\u6210\u4e3a\u4e00\u4e2a\u663e\u5f0f\u4e8b\u52a1\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5982\u679c\u4e00\u4e2a\u4e8b\u52a1\u5e76\u6ca1\u6709\u901a\u8fc7 START TRANSACTION
\u6216 BEGIN
\u6765\u663e\u5f0f\u58f0\u660e\uff0c\u90a3\u4e48\u4e3a\u9690\u5f0f\u4e8b\u52a1\u3002
\u5728\u4e50\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4e0d\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u8fd9\u4e00\u9636\u6bb5\u4e0d\u4f1a\u5bf9\u6570\u636e\u52a0\u9501\uff0c\u800c\u5728\u6570\u636e\u63d0\u4ea4\u65f6\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5728\u5b8c\u6210\u63d0\u4ea4\u540e\u89e3\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#_4","title":"\u60b2\u89c2\u4e8b\u52a1","text":"MatrixOne \u9ed8\u8ba4\u60b2\u89c2\u4e8b\u52a1\u3002\u5728\u60b2\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5047\u5b9a\u4e8b\u52a1\u76f8\u5173\u7684\u8868\u5904\u4e8e\u4e00\u4e2a\u4f1a\u53d1\u751f\u5199\u51b2\u7a81\u7684\u72b6\u6001\uff0c\u63d0\u524d\u5bf9\u76f8\u5e94\u7684\u6570\u636e\u8868\u6216\u6570\u636e\u884c\u4e0a\u9501\uff0c\u5b8c\u6210\u4e0a\u9501\u52a8\u4f5c\u540e\uff0c\u628a\u5bf9\u6570\u636e\u7684\u63d2\u5165\u3001\u4fee\u6539\u6216\u5220\u9664\u7f13\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u5728\u63d0\u4ea4\u6216\u56de\u6eda\u540e\uff0c\u6570\u636e\u5b8c\u6210\u843d\u76d8\u5e76\u91ca\u653e\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone_3","title":"MatrixOne \u652f\u6301\u8de8\u6570\u636e\u5e93\u4e8b\u52a1","text":"MatrixOne \u63d0\u4f9b\u4e86\u652f\u6301\u8de8\u6570\u636e\u5e93\u7684\u4e8b\u52a1\u529f\u80fd\uff0c\u5141\u8bb8\u4e00\u4e2a\u4e8b\u52a1\u540c\u65f6\u8bbf\u95ee\u548c\u4fee\u6539\u591a\u4e2a\u4e0d\u540c\u7684\u6570\u636e\u5e93\u3002
\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u67d0\u4e9b\u4e1a\u52a1\u9700\u6c42\u53ef\u80fd\u9700\u8981\u6d89\u53ca\u591a\u4e2a\u6570\u636e\u5e93\u7684\u64cd\u4f5c\uff0c\u800c\u8de8\u6570\u636e\u5e93\u4e8b\u52a1\u7684\u51fa\u73b0\u6b63\u662f\u4e3a\u4e86\u6ee1\u8db3\u8fd9\u79cd\u9700\u6c42\u3002\u8fd9\u79cd\u529f\u80fd\u786e\u4fdd\u4e86\u4e0d\u540c\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u64cd\u4f5c\u80fd\u591f\u4fdd\u6301\u4e00\u81f4\u6027\u548c\u9694\u79bb\u6027\uff0c\u5c31\u50cf\u5728\u5355\u4e2a\u6570\u636e\u5e93\u5185\u6267\u884c\u64cd\u4f5c\u4e00\u6837\u3002\u8fd9\u610f\u5473\u7740\u5f53\u60a8\u9700\u8981\u5728\u591a\u4e2a\u6570\u636e\u5e93\u4e4b\u95f4\u6267\u884c\u4e00\u7cfb\u5217\u64cd\u4f5c\u65f6\uff0c\u53ef\u4ee5\u5c06\u5b83\u4eec\u5305\u88c5\u5728\u4e00\u4e2a\u4e8b\u52a1\u4e2d\uff0c\u4ee5\u4fbf\u5728\u4fdd\u6301\u6570\u636e\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u7684\u540c\u65f6\u5b8c\u6210\u8fd9\u4e9b\u64cd\u4f5c\u3002
\u8de8\u6570\u636e\u5e93\u4e8b\u52a1\u901a\u5e38\u5728\u590d\u6742\u7684\u4f01\u4e1a\u5e94\u7528\u573a\u666f\u4e2d\u53d1\u6325\u5173\u952e\u4f5c\u7528\u3002\u5728\u8fd9\u4e9b\u573a\u666f\u4e2d\uff0c\u4e0d\u540c\u7684\u4e1a\u52a1\u529f\u80fd\u6216\u90e8\u95e8\u53ef\u80fd\u4f7f\u7528\u4e0d\u540c\u7684\u6570\u636e\u5e93\uff0c\u4f46\u5b83\u4eec\u9700\u8981\u534f\u540c\u5de5\u4f5c\u4ee5\u6ee1\u8db3\u590d\u6742\u7684\u4e1a\u52a1\u9700\u6c42\u3002MatrixOne \u7684\u652f\u6301\u8de8\u6570\u636e\u5e93\u4e8b\u52a1\u529f\u80fd\u63d0\u9ad8\u4e86\u7cfb\u7edf\u7684\u7075\u6d3b\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0c\u4f46\u540c\u65f6\u4e5f\u9700\u8981\u8c28\u614e\u7684\u8bbe\u8ba1\u548c\u7ba1\u7406\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u5f97\u4ee5\u4fdd\u6301\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#matrixone_4","title":"MatrixOne \u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b","text":"MatrixOne \u652f\u6301\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u548c\u5feb\u7167\u9694\u79bb\u4e24\u79cd\u9694\u79bb\u7ea7\u522b\uff0c\u9ed8\u8ba4\u9694\u79bb\u7ea7\u522b\u662f\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/overview/#_5","title":"\u8bfb\u5df2\u63d0\u4ea4","text":"\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u662f MatrixOne \u5728 0.8 \u7248\u672c\u4e4b\u540e\u7684\u9ed8\u8ba4\u9694\u79bb\u7ea7\u522b\uff0c\u4e5f\u662f SQL \u6807\u51c6\u4e2d\u7684\u56db\u4e2a\u9694\u79bb\u7ea7\u522b\u4e4b\u4e00\u3002\u5b83\u6700\u663e\u8457\u7684\u7279\u70b9\u662f\uff1a
\u4e0e SQL \u6807\u51c6\u6240\u5b9a\u4e49\u7684\u56db\u4e2a\u9694\u79bb\u7ea7\u522b\u4e0d\u540c\uff0c\u5728 MatrixOne \u4e2d\uff0c\u652f\u6301\u7684\u9694\u79bb\u7ea7\u522b\u662f\u5feb\u7167\u9694\u79bb\uff08Snapshot Isolation\uff09\uff0c\u8be5\u7ea7\u522b\u7684\u9694\u79bb\u5728 SQL-92 \u6807\u51c6\u7684 REPEATABLE READ \u548c SERIALIZABLE \u4e4b\u95f4\u3002\u4e0e\u5176\u4ed6\u9694\u79bb\u7ea7\u522b\u6709\u6240\u533a\u522b\u7684\u662f\uff0c\u5feb\u7167\u9694\u79bb\u5177\u5907\u5982\u4e0b\u7279\u6027\uff1a
\u5feb\u7167\u9694\u79bb\u5bf9\u4e8e\u6307\u5b9a\u4e8b\u52a1\u5185\u8bfb\u53d6\u7684\u6570\u636e\u4e0d\u4f1a\u53cd\u6620\u5176\u4ed6\u540c\u6b65\u7684\u4e8b\u52a1\u5bf9\u6570\u636e\u6240\u505a\u7684\u66f4\u6539\u3002\u6307\u5b9a\u4e8b\u52a1\u4f7f\u7528\u672c\u6b21\u4e8b\u52a1\u5f00\u59cb\u65f6\u8bfb\u53d6\u7684\u6570\u636e\u884c\u3002
\u8bfb\u53d6\u6570\u636e\u65f6\u4e0d\u4f1a\u5bf9\u6570\u636e\u8fdb\u884c\u9501\u5b9a\uff0c\u56e0\u6b64\u5feb\u7167\u4e8b\u52a1\u4e0d\u4f1a\u963b\u6b62\u5176\u4ed6\u4e8b\u52a1\u5199\u5165\u6570\u636e\u3002
\u5199\u5165\u6570\u636e\u7684\u4e8b\u52a1\u4e5f\u4e0d\u4f1a\u963b\u6b62\u5feb\u7167\u4e8b\u52a1\u8bfb\u53d6\u6570\u636e\u3002
\u4e0e\u5176\u4ed6\u9694\u79bb\u7ea7\u522b\u76f8\u6bd4\uff0c\u5feb\u7167\u9694\u79bb\u5bf9\u4e8e\u810f\u8bfb (\u8bfb\u53d6\u672a\u63d0\u4ea4\u6570\u636e)\u3001\u810f\u5199\uff08\u5199\u4e86\u4fee\u6539\u540e\u672a\u63d0\u4ea4\u7684\u8bb0\u5f55\uff09\u3001\u5e7b\u8bfb (\u524d\u540e\u591a\u6b21\u8bfb\u53d6\uff0c\u6570\u636e\u603b\u91cf\u4e0d\u4e00\u81f4) \u7b49\u573a\u666f\u4e5f\u5b9e\u73b0\u4e86\u6709\u6548\u56de\u907f\uff1a
Isolation Level P0 Dirty Write P1 Dirty Read P4C Cursor Lost Update P4 Lost Update P2 Fuzzy Read P3 Phantom A5A Read Skew A5B Write Skew MatrixOne's Snapshot Isolation Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Not Possible Possible"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/","title":"\u60b2\u89c2\u4e8b\u52a1","text":""},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_2","title":"\u60b2\u89c2\u4e8b\u52a1\u539f\u7406","text":"\u60b2\u89c2\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0c\u4e00\u5b9a\u4f1a\u505a\u51b2\u7a81\u68c0\u6d4b\u6216\u9501\u64cd\u4f5c\uff0c\u5728\u672a\u68c0\u6d4b\u5230\u51b2\u7a81\u6216\u9501\u7684\u65f6\u5019\uff0c\u4f1a\u5c06\u5f85\u5199\u6570\u636e\u4e2d\u7684\u67d0\u4e00\u5217\u5f53\u505a\u4e3b\u952e\u5217\uff0c\u5e76\u5bf9\u8be5\u5217\u4e0a\u9501\u5e76\u521b\u5efa\u65f6\u95f4\u6233\u3002\u5bf9\u4e8e\u6b64\u65f6\u95f4\u6233\u4e4b\u540e\u5bf9\u76f8\u5173\u884c\u8fdb\u884c\u7684\u5199\u5165\u5747\u5224\u5b9a\u4e3a\u5199\u51b2\u7a81\u3002
\u5c06\u5f53\u524d\u76f8\u5173\u6570\u636e\u7f13\u5b58\u81f3\u5bf9\u5e94\u5185\u5b58\u533a\u57df\uff0c\u5e76\u5bf9\u8be5\u6570\u636e\u8fdb\u884c\u589e\u5220\u6539\u3002\u5982\u679c\u5f53\u524d\u8868\u5b58\u5728\u9501\uff0c\u5219\u8fdb\u5165\u7b49\u5f85\u72b6\u6001\uff0c\u5f53\u7b49\u5f85\u8d85\u65f6\u540e\uff0c\u7b49\u5f85\u4e8b\u52a1\u5c06\u4f1a\u88ab\u53d6\u6d88\u3002
\u5728\u5b8c\u6210\u4fee\u6539\u540e\uff0c\u8fdb\u5165\u63d0\u4ea4\u9636\u6bb5\uff0c\u5199\u5165\u6570\u636e\uff0c\u5e76\u4e14\u8bb0\u5f55\u6b64\u65f6\u7684\u65f6\u95f4\u6233\uff0c\u89e3\u5f00\u9501\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_3","title":"\u60b2\u89c2\u4e8b\u52a1\u6a21\u578b","text":"MatrixOne \u9ed8\u8ba4\u60b2\u89c2\u4e8b\u52a1\u3002
\u4f60\u5728\u4f7f\u7528\u60b2\u89c2\u5e76\u53d1\u8bfb\u53d6\u4e00\u884c\u65f6\uff0c\u4e0d\u4f1a\u9501\u5b9a\u8be5\u884c\u3002\u5f53\u4f60\u60f3\u8981\u66f4\u65b0\u4e00\u884c\u65f6\uff0c\u5e94\u7528\u7a0b\u5e8f\u5fc5\u987b\u786e\u5b9a\u5176\u4ed6\u7528\u6237\u662f\u5426\u5df2\u7ecf\u5bf9\u8be5\u884c\u4e0a\u9501\u3002\u60b2\u89c2\u5e76\u53d1\u4e8b\u52a1\u901a\u5e38\u7528\u4e8e\u6570\u636e\u4e89\u7528\u8f83\u9ad8\u7684\u73af\u5883\u4e2d\u3002
\u5728\u60b2\u89c2\u5e76\u53d1\u6a21\u578b\u4e2d\uff0c\u5982\u679c\u4f60\u4ece\u6570\u636e\u5e93\u63a5\u6536\u5230\u4e00\u4e2a\u503c\u540e\uff0c\u53e6\u4e00\u4e2a\u7528\u6237\u5728\u4f60\u8bd5\u56fe\u4fee\u6539\u8be5\u503c\u4e4b\u524d\uff0c\u5c06\u4f1a\u9047\u5230\u9501\u800c\u8fdb\u5165\u7b49\u5f85\u72b6\u6001\uff0c\u8d85\u8fc7 MatrixOne \u8bbe\u7f6e\u7684\u4e8b\u52a1\u7b49\u5f85\u65f6\u95f4\uff085 \u5206\u949f\uff09\u540e\uff0c\u7b49\u5f85\u4e8b\u52a1\u5c06\u4f1a\u88ab\u5f3a\u5236\u53d6\u6d88\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_4","title":"\u6b7b\u9501","text":"\u5728\u60b2\u89c2\u4e8b\u52a1\u4e2d\uff0c\u6709\u53ef\u80fd\u51fa\u73b0\u4e00\u79cd\u60c5\u51b5\uff0c\u5373\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u4e8b\u52a1\u4e92\u76f8\u9501\u4f4f\u4e86\u5bf9\u65b9\u6240\u9700\u8981\u7684\u8d44\u6e90\u65f6\uff0c\u4ee4\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u65e0\u6cd5\u8fdb\u884c\u4e0b\u53bb\u7684\u72b6\u6001\uff0c\u8fd9\u79cd\u60c5\u51b5\u88ab\u79f0\u4e4b\u4e3a\u6b7b\u9501\uff08Deadlock\uff09\u3002\u53ea\u6709\u901a\u8fc7\u4eba\u4e3a\u5e72\u9884\u5176\u4e2d\u67d0\u4e2a\u4e8b\u52a1\uff0c\u4f8b\u5982\uff0c\u901a\u8fc7\u624b\u52a8 Kill
\u4f1a\u8bdd\u7684\u65b9\u5f0f\uff0c\u624d\u80fd\u7acb\u5373\u7ed3\u675f\u6b7b\u9501\uff0c\u5426\u5219\u53ea\u80fd\u7b49\u4e8b\u52a1\u8d85\u51fa\u6700\u957f\u7b49\u5f85\u65f6\u95f4\u3002
\u6b7b\u9501\u793a\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\uff1a
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/pessimistic-transaction/#_5","title":"\u6a21\u578b\u793a\u4f8b","text":"\u4e0b\u9762\u4e3a\u60b2\u89c2\u5e76\u53d1\u7684\u793a\u4f8b\uff0c\u5c06\u4e3a\u4f60\u5c55\u793a MatrixOne \u5982\u4f55\u89e3\u51b3\u5e76\u53d1\u51b2\u7a81\u3002
CustID LastName FirstName\n101 Smith Bob\n
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Bob Bob \u5728\u4e0b\u5348 1:01\uff0c\u7528\u6237 2 \u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u540c\u4e00\u884c\u3002
\u5728\u4e0b\u5348 1:03\uff0c\u7528\u6237 2 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cRobert\u201d\uff0c\u6b64\u65f6\u5904\u4e8e\u672a\u63d0\u4ea4\u72b6\u6001\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob Robert Bob\u5728\u4e0b\u5348 1:05\uff0c\u7528\u6237 1 \u5c06 FirstName \u5217\u7684\u201cBob\u201d\u6539\u4e3a\u201cJames\u201d\uff0c\u5e76\u5c1d\u8bd5\u8fdb\u884c\u66f4\u65b0\u3002
Column name Original value Current value Value in database CustID 101 101 101 LastName Smith Smith Smith FirstName Bob James Bob\u6b64\u65f6\uff0c\u7528\u6237 1 \u9047\u5230\u4e86\u60b2\u89c2\u5e76\u53d1\u51b2\u7a81\uff0c\u56e0\u4e3a\u6570\u636e\u5e93\u4e2d\u7684\u503c\u201cRobert\u201d\u6240\u5728\u884c\u5df2\u7ecf\u88ab\u9501\u5b9a\uff0c\u9700\u8981\u7b49\u5f85\u7528\u6237 2 \u7684\u4e0b\u4e00\u6b65\u64cd\u4f5c\u3002
\u5728\u4e0b\u5348 1:06\uff0c\u7528\u6237 1 \u5bf9\u4e8b\u52a1\u63d0\u4ea4\u3002\u6b64\u65f6\u7528\u6237 2 \u89e3\u9664\u7b49\u5f85\u72b6\u6001\u5f00\u59cb\u4e8b\u52a1\uff0c\u4f46\u662f\u56e0\u4e3a\u5df2\u7ecf\u65e0\u6cd5\u5339\u914d\u5230\u5bf9\u5e94\u7684 FirstName\uff0c\u56e0\u6b64\u7528\u6237 2 \u7684\u4e8b\u52a1\u4f1a\u66f4\u65b0\u5931\u8d25\u3002
\u5728\u4e00\u4e2a\u8d22\u52a1\u7cfb\u7edf\u4e2d\uff0c\u4e0d\u540c\u7528\u6237\u4e4b\u95f4\u7684\u8f6c\u8d26\u662f\u975e\u5e38\u5e38\u89c1\u7684\u573a\u666f\uff0c\u800c\u8f6c\u8d26\u5728\u6570\u636e\u5e93\u4e2d\u7684\u5b9e\u9645\u64cd\u4f5c\uff0c\u901a\u5e38\u662f\u4e24\u4e2a\u6b65\u9aa4\uff0c\u9996\u5148\u662f\u5bf9\u4e00\u4e2a\u7528\u6237\u7684\u8d26\u9762\u91d1\u989d\u62b5\u6263\u4e4b\u540e\uff0c\u7136\u540e\u662f\u5bf9\u53e6\u4e00\u4e2a\u7528\u6237\u7684\u8d26\u9762\u91d1\u989d\u8fdb\u884c\u589e\u52a0\u3002\u53ea\u6709\u5229\u7528\u4e8b\u52a1\u7684\u539f\u5b50\u6027\uff0c\u624d\u80fd\u786e\u4fdd\u603b\u8d26\u9762\u8d44\u91d1\u6ca1\u6709\u53d8\u5316\uff0c\u540c\u65f6\u4e24\u4e2a\u7528\u6237\u4e4b\u95f4\u7684\u8d26\u6237\u90fd\u5b8c\u6210\u4e86\u5404\u81ea\u7684\u62b5\u6263\u4e0e\u589e\u52a0\uff0c\u4f8b\u5982 A \u7528\u6237\u6b64\u65f6\u5bf9 B \u7528\u6237\u8f6c\u8d26 50\uff1a
start transaction;\nupdate accounts set balance=balance-50 where name='A';\nupdate accounts set balance=balance+50 where name='B';\ncommit;\n
\u5f53\u4e24\u6b21 update
\u90fd\u6210\u529f\u5e76\u4e14\u6700\u7ec8\u63d0\u4ea4\uff0c\u6574\u4e2a\u8f6c\u8d26\u624d\u7b97\u771f\u6b63\u5b8c\u6210\uff0c\u4efb\u4f55\u4e00\u6b65\u7684\u5931\u8d25\uff0c\u5fc5\u987b\u8ba9\u6574\u4e2a\u4e8b\u52a1\u56de\u6eda\uff0c\u624d\u80fd\u786e\u4fdd\u539f\u5b50\u6027\u3002
\u6b64\u5916\uff0c\u4e24\u4e2a\u8d26\u6237\u8f6c\u8d26\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5728\u6ca1\u6709\u63d0\u4ea4\u4e4b\u524d\uff0c\u65e0\u8bba\u662f A \u6216\u8005 B\uff0c\u770b\u5230\u7684\u90fd\u662f\u5c1a\u672a\u8f6c\u8d26\u5b8c\u6210\u7684\u8d26\u9762\u4f59\u989d\uff0c\u8fd9\u662f\u4e8b\u52a1\u7684\u9694\u79bb\u6027\u3002
\u5728\u8f6c\u8d26\u8fc7\u7a0b\u4e2d\uff0c\u6570\u636e\u5e93\u4f1a\u68c0\u67e5 A \u7684\u8d26\u9762\u8d44\u91d1\u662f\u5426\u5927\u4e8e 50\uff0cA \u548c B \u5728\u7cfb\u7edf\u4e2d\u662f\u5426\u786e\u6709\u5176\u4eba\uff0c\u53ea\u6709\u90fd\u6ee1\u8db3\u8fd9\u4e9b\u7ea6\u675f\uff0c\u624d\u80fd\u4fdd\u8bc1\u4e8b\u52a1\u7684\u4e00\u81f4\u6027\u3002
\u5b8c\u6210\u8f6c\u8d26\u540e\uff0c\u65e0\u8bba\u7cfb\u7edf\u662f\u5426\u91cd\u542f\uff0c\u6570\u636e\u5df2\u7ecf\u5b8c\u6210\u4e86\u6301\u4e45\u5316\uff0c\u4f53\u73b0\u4e86\u4e8b\u52a1\u7684\u6301\u4e45\u6027\u3002
"},{"location":"MatrixOne/Develop/Transactions/matrixone-transaction-overview/scenario/#matrixone","title":"MatrixOne \u7684\u60b2\u89c2\u4e8b\u52a1\u4e0e\u8bfb\u5df2\u63d0\u4ea4","text":"MatrixOne \u9ed8\u8ba4\u60b2\u89c2\u4e8b\u52a1\u4e0e\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\uff0c\u8fd9\u79cd\u7ec4\u5408\u65b9\u5f0f\u4f7f\u6027\u80fd\u8fbe\u5230\u6700\u4f18\u3002
\u60b2\u89c2\u4e8b\u52a1\uff08Pessimistic Transaction\uff09\u662f\u6307\u5728\u4e8b\u52a1\u671f\u95f4\uff0c\u6301\u6709\u8d44\u6e90\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5c06\u8d44\u6e90\u9501\u5b9a\uff0c\u4ee5\u907f\u514d\u5176\u4ed6\u5e76\u53d1\u4e8b\u52a1\u5bf9\u8be5\u8d44\u6e90\u7684\u4fee\u6539\u6216\u8bfb\u53d6\u3002\u60b2\u89c2\u4e8b\u52a1\u5047\u5b9a\u5e76\u53d1\u4e8b\u52a1\u53ef\u80fd\u4f1a\u5bf9\u8d44\u6e90\u8fdb\u884c\u64cd\u4f5c\uff0c\u5e76\u9632\u6b62\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\u3002
\u5728 MatrixOne \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 UPDATE ... WHERE...
\u8bed\u53e5\u6765\u5b9e\u73b0\u60b2\u89c2\u9501\u5b9a\uff0c\u8be5\u8bed\u53e5\u4f1a\u9501\u5b9a\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u76f4\u5230\u4e8b\u52a1\u63d0\u4ea4\u6216\u56de\u6eda\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u9501\u5b9a\u4e86 user
\u8868\u4e2d id=1
\u7684\u8bb0\u5f55\uff1a
START TRANSACTION;\nUPDATE t1 WHERE id=1;\n-- \u5728\u4e8b\u52a1\u671f\u95f4\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff0c\u4f8b\u5982\u4fee\u6539\u8be5\u8bb0\u5f55\nCOMMIT;\n
\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u662f\u4e00\u79cd\u9694\u79bb\u7ea7\u522b\uff0c\u5b83\u786e\u4fdd\u5728\u4e8b\u52a1\u63d0\u4ea4\u4e4b\u524d\uff0c\u5176\u4ed6\u4e8b\u52a1\u6240\u505a\u7684\u4fee\u6539\u4e0d\u4f1a\u5bf9\u5f53\u524d\u4e8b\u52a1\u53ef\u89c1\u3002\u5728\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u4e8b\u52a1\u53ea\u80fd\u770b\u5230\u5df2\u7ecf\u63d0\u4ea4\u7684\u6570\u636e\uff0c\u65e0\u6cd5\u770b\u5230\u672a\u63d0\u4ea4\u7684\u6570\u636e\u3002\u56e0\u6b64\uff0c\u5728\u8be5\u9694\u79bb\u7ea7\u522b\u4e0b\uff0c\u53ef\u4ee5\u907f\u514d\u810f\u8bfb\uff08Dirty Read\uff09\u3002
\u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
\u8bed\u53e5\u8bbe\u7f6e\u9694\u79bb\u7ea7\u522b\u4e3a\u8bfb\u5df2\u63d0\u4ea4\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u67e5\u8be2\u4e86 user \u8868\u4e2d id=1 \u7684\u8bb0\u5f55\uff0c\u4f46\u5982\u679c\u5176\u4ed6\u4e8b\u52a1\u6b63\u5728\u4fee\u6539\u8be5\u8bb0\u5f55\uff0c\u5219\u5f53\u524d\u4e8b\u52a1\u65e0\u6cd5\u770b\u5230\u672a\u63d0\u4ea4\u7684\u4fee\u6539\uff1a
BEGIN TRANSACTION;\nSET TRANSACTION ISOLATION LEVEL READ COMMITTED;\n-- \u5982\u679c\u5176\u4ed6\u4e8b\u52a1\u6b63\u5728\u4fee\u6539 user \u8868\u4e2d id=1 \u7684\u8bb0\u5f55\uff0c\u4e0b\u9762\u7684\u8bed\u53e5\u5c06\u4f1a\u7b49\u5f85\uff0c\u76f4\u5230\u9501\u5b9a\u88ab\u91ca\u653e\nSELECT * FROM user WHERE id = 1;\nCOMMIT;\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u548c\u8bfb\u5df2\u63d0\u4ea4\u9694\u79bb\u7ea7\u522b\u53ef\u4ee5\u907f\u514d\u4e00\u4e9b\u5e76\u53d1\u95ee\u9898\uff0c\u4f46\u4e5f\u53ef\u80fd\u4f1a\u5e26\u6765\u4e00\u4e9b\u989d\u5916\u7684\u5f00\u9500\uff0c\u56e0\u6b64\u9700\u8981\u6743\u8861\u5229\u5f0a\u5e76\u6839\u636e\u5b9e\u9645\u9700\u6c42\u6765\u9009\u62e9\u4f7f\u7528\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/","title":"\u805a\u7c7b\u4e2d\u5fc3","text":""},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_2","title":"\u4ec0\u4e48\u662f\u805a\u7c7b\u4e2d\u5fc3","text":"\u5728\u4f7f\u7528\u805a\u7c7b\u7b97\u6cd5\uff0c\u7279\u522b\u662f K-means \u7b97\u6cd5\u65f6\uff0c\u805a\u7c7b\u6570\u91cf K \u4ee3\u8868\u4e86\u4f60\u60f3\u8981\u5c06\u6570\u636e\u96c6\u5206\u6210\u7684\u7c07\uff08cluster\uff09\u7684\u6570\u91cf\u3002\u6bcf\u4e2a\u7c07\u7531\u5176\u805a\u7c7b\u4e2d\u5fc3\uff08centroid\uff09\u4ee3\u8868\uff0c\u805a\u7c7b\u4e2d\u5fc3\u662f\u7c07\u5185\u6240\u6709\u6570\u636e\u70b9\u7684\u4e2d\u5fc3\u70b9\u6216\u5e73\u5747\u4f4d\u7f6e\u3002
\u5728 K-means \u7b97\u6cd5\u4e2d\uff0cK \u7684\u9009\u62e9\u5bf9\u805a\u7c7b\u7ed3\u679c\u6709\u5f88\u5927\u5f71\u54cd\u3002\u9009\u62e9\u5408\u9002\u7684 K \u503c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u6570\u636e\u7684\u7ed3\u6784\u548c\u6a21\u5f0f\u3002\u5982\u679c K \u503c\u9009\u62e9\u4e0d\u5f53\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4ee5\u4e0b\u95ee\u9898\uff1a
Matrixone \u63d0\u4f9b\u805a\u7c7b\u4e2d\u5fc3\u67e5\u8be2\u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u5217\u7684 K \u4e2a\u805a\u7c7b\u4e2d\u5fc3\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_3","title":"\u805a\u7c7b\u4e2d\u5fc3\u7684\u5e94\u7528\u573a\u666f","text":"\u805a\u7c7b\u5728\u6570\u636e\u5206\u6790\u548c\u673a\u5668\u5b66\u4e60\u9886\u57df\u626e\u6f14\u7740\u91cd\u8981\u89d2\u8272\u3002\u4ee5\u4e0b\u662f\u805a\u7c7b\u4e2d\u5fc3\u7684\u4e00\u4e9b\u4e3b\u8981\u5e94\u7528\u573a\u666f\uff1a
\u5e02\u573a\u7ec6\u5206\uff1a\u5728\u5e02\u573a\u5206\u6790\u4e2d\uff0c\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u4e0d\u540c\u7684\u5ba2\u6237\u7fa4\u4f53\u7279\u5f81\uff0c\u4ece\u800c\u4e3a\u6bcf\u4e2a\u7fa4\u4f53\u5b9a\u5236\u8425\u9500\u7b56\u7565\u3002
\u56fe\u50cf\u5206\u5272\uff1a\u5728\u56fe\u50cf\u5904\u7406\u4e2d\uff0c\u805a\u7c7b\u4e2d\u5fc3\u7528\u4e8e\u533a\u5206\u56fe\u50cf\u4e2d\u4e0d\u540c\u7684\u533a\u57df\u6216\u5bf9\u8c61\uff0c\u5e38\u7528\u4e8e\u56fe\u50cf\u538b\u7f29\u548c\u5206\u5272\u3002
\u793e\u4ea4\u7f51\u7edc\u5206\u6790\uff1a\u901a\u8fc7\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u8bc6\u522b\u793e\u4ea4\u7f51\u7edc\u4e2d\u5177\u6709\u76f8\u4f3c\u884c\u4e3a\u6216\u5174\u8da3\u7684\u7528\u6237\u7fa4\u4f53\u3002
\u5f02\u5e38\u68c0\u6d4b\uff1a\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u6570\u636e\u4e2d\u7684\u5f02\u5e38\u70b9\uff0c\u56e0\u4e3a\u5f02\u5e38\u70b9\u901a\u5e38\u8fdc\u79bb\u6240\u6709\u805a\u7c7b\u4e2d\u5fc3\u3002
\u5929\u6587\u6570\u636e\u5206\u6790\uff1a\u5728\u5929\u6587\u5b66\u4e2d\uff0c\u805a\u7c7b\u4e2d\u5fc3\u53ef\u4ee5\u7528\u4e8e\u8bc6\u522b\u661f\u7cfb\u56e2\u6216\u6052\u661f\u7fa4\u7684\u7279\u5f81\u3002
\u5728 Matrixone \u4e2d\u786e\u5b9a\u5411\u91cf\u6570\u636e\u96c6\u7684\u805a\u7c7b\u4e2d\u5fc3\uff0c\u6d89\u53ca\u5230\u4ee5\u4e0b\u7b97\u6cd5\uff1a
Random (\u968f\u673a\u521d\u59cb\u5316)\uff1a\u5728\u968f\u673a\u521d\u59cb\u5316\u4e2d\uff0c\u7b97\u6cd5\u4ece\u6570\u636e\u96c6\u4e2d\u968f\u673a\u9009\u62e9 n_clusters \u4e2a\u89c2\u6d4b\u503c\u4f5c\u4e3a\u521d\u59cb\u8d28\u5fc3\u70b9\u3002\u8fd9\u79cd\u65b9\u6cd5\u7b80\u5355\u5feb\u901f\uff0c\u4f46\u53ef\u80fd\u5bfc\u81f4\u805a\u7c7b\u7ed3\u679c\u7684\u8d28\u91cf\u4f9d\u8d56\u4e8e\u521d\u59cb\u8d28\u5fc3\u7684\u9009\u53d6\uff0c\u56e0\u4e3a\u968f\u673a\u9009\u62e9\u53ef\u80fd\u4e0d\u4f1a\u843d\u5728\u6570\u636e\u7684\u7a20\u5bc6\u533a\u57df\u3002
K-means++(k-means++ \u521d\u59cb\u5316)\uff1ak-means++ \u662f\u4e00\u79cd\u66f4\u9ad8\u7ea7\u7684\u521d\u59cb\u5316\u65b9\u6cd5\uff0c\u65e8\u5728\u6539\u5584\u968f\u673a\u521d\u59cb\u5316\u7684\u4e0d\u8db3\uff0c\u5b83\u901a\u8fc7\u591a\u6b65\u9aa4\u8fc7\u7a0b\u6765\u9009\u62e9\u521d\u59cb\u8d28\u5fc3\uff0c\u4ee5\u589e\u52a0\u9009\u62e9\u7684\u8d28\u5fc3\u70b9\u80fd\u591f\u4ee3\u8868\u6570\u636e\u6574\u4f53\u5206\u5e03\u7684\u6982\u7387\u3002
Regular Kmeans\uff08\u5e38\u89c4 K-means \u7b97\u6cd5\uff09\uff1a\u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u805a\u7c7b\u65b9\u6cd5\uff0c\u65e8\u5728\u5c06\u6570\u636e\u70b9\u5212\u5206\u4e3a K \u4e2a\u7c07\uff0c\u4f7f\u5f97\u7c07\u5185\u7684\u6570\u636e\u70b9\u5c3d\u53ef\u80fd\u76f8\u4f3c\uff0c\u800c\u7c07\u95f4\u7684\u6570\u636e\u70b9\u5c3d\u53ef\u80fd\u4e0d\u540c\u3002\u8fd9\u79cd\u65b9\u6cd5\u57fa\u4e8e\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb\u6765\u8861\u91cf\u6570\u636e\u70b9\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\uff0c\u56e0\u6b64\u5b83\u66f4\u9002\u5408\u4e8e\u5728\u5e73\u9762\u7a7a\u95f4\u4e2d\u5904\u7406\u6570\u636e\u3002
Spherical Kmeans\uff08\u7403\u5f62 K-means\uff09\uff1a\u662f\u4e00\u79cd\u5bf9\u6570\u636e\u70b9\u8fdb\u884c\u805a\u7c7b\u7684\u7b97\u6cd5\uff0cSpherical K-means \u7b97\u6cd5\u8ba1\u7b97\u805a\u7c7b\u4e2d\u5fc3\u7684\u8fc7\u7a0b\u6d89\u53ca\u5230\u5bf9\u6570\u636e\u70b9\u8fdb\u884c\u5f52\u4e00\u5316\u5904\u7406\u3002\u7279\u522b\u9002\u7528\u4e8e\u9ad8\u7ef4\u4e14\u7a00\u758f\u9ad8\u7ef4\u4e14\u7a00\u758f\u7684\uff0c\u6216\u8005\u6570\u636e\u70b9\u7684\u65b9\u5411\u6027\u6bd4\u8ddd\u79bb\u66f4\u4e3a\u91cd\u8981\u7684\u6570\u636e\uff0c\u5982\u6587\u672c\u6570\u636e\u3001\u5730\u7406\u4f4d\u7f6e\u6216\u7528\u6237\u5174\u8da3\u6a21\u578b\u3002
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u7ec4\u5ba2\u6237\u7684\u5e74\u5ea6\u8d2d\u7269\u6570\u636e\uff0c\u5305\u62ec\u4ed6\u4eec\u7684\u5e74\u6536\u5165\u548c\u5e74\u5ea6\u6d88\u8d39\u603b\u989d\u3002\u6211\u4eec\u60f3\u8981\u901a\u8fc7\u8fd9\u4e9b\u6570\u636e\u4e86\u89e3\u5ba2\u6237\u7684\u6d88\u8d39\u884c\u4e3a\uff0c\u5e76\u5c06\u5176\u5206\u6210\u4e0d\u540c\u7684\u6d88\u8d39\u884c\u4e3a\u7fa4\u4f53\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_6","title":"\u6b65\u9aa4","text":"\u5efa\u7acb\u5ba2\u6237\u8868\u5e76\u63d2\u5165\u6570\u636e
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a customer_table
\u7684\u8868\uff0c\u63d2\u5165 10 \u6761\u987e\u5ba2\u6570\u636e\u3002\u4e8c\u7ef4\u5411\u91cf\u4ee3\u8868\u5ba2\u6237\u7684\u5e74\u6536\u5165\u548c\u5e74\u5ea6\u6d88\u8d39\u603b\u989d\u3002
CREATE TABLE customer_table(id int auto_increment PRIMARY KEY,in_ex vecf64(2));\nINSERT INTO customer_table(in_ex) VALUES(\"[120,50]\"),(\"[80,25]\"),(\"[200,100]\"),(\"[100,40]\"),(\"[300,120]\"),(\"[150,75]\"),(\"[90,30]\"),(\"[250,90]\"),(\"[75,20]\"),(\"[150,60]\");\n\nmysql> select * from customer_table;\n+------+------------+\n| id | in_ex |\n+------+------------+\n| 1 | [120, 50] |\n| 2 | [80, 25] |\n| 3 | [200, 100] |\n| 4 | [100, 40] |\n| 5 | [300, 120] |\n| 6 | [150, 75] |\n| 7 | [90, 30] |\n| 8 | [250, 90] |\n| 9 | [75, 20] |\n| 10 | [150, 60] |\n+------+------------+\n10 rows in set (0.01 sec)\n
\u786e\u5b9a\u805a\u7c7b\u4e2d\u5fc3
mysql> SELECT cluster_centers(in_ex kmeans '2,vector_l2_ops,random,false') AS centers FROM customer_table;\n+------------------------------------------------------------------------+\n| centers |\n+------------------------------------------------------------------------+\n| [ [109.28571428571428, 42.857142857142854],[250, 103.33333333333333] ] |\n+------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
\u68c0\u67e5\u805a\u7c7b\u4e2d\u5fc3
\u4e00\u4e2a\u597d\u7684\u805a\u7c7b\u901a\u5e38\u4f1a\u5728\u53ef\u89c6\u5316\u4e2d\u663e\u793a\u4e3a\u660e\u663e\u7684\u5206\u79bb\u7fa4\u7ec4\u3002\u7531\u4e0b\u56fe\u89c2\u5bdf\u53ef\u5f97\uff0c\u805a\u7c7b\u4e2d\u5fc3\u9009\u62e9\u8f83\u4e3a\u9002\u5f53\u3002
\u901a\u8fc7\u805a\u7c7b\u4e2d\u5fc3\u7684\u786e\u5b9a\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5ba2\u6237\u5206\u4e3a\u4e24\u4e2a\u7fa4\u4f53\uff1a\u4e00\u4e2a\u7fa4\u4f53\u662f\u4e2d\u7b49\u6536\u5165\u548c\u4e2d\u7b49\u6d88\u8d39\u6c34\u5e73\u7684\u5ba2\u6237\uff08\u805a\u7c7b\u4e2d\u5fc3 A\uff09\uff0c\u53e6\u4e00\u4e2a\u7fa4\u4f53\u662f\u8f83\u9ad8\u6536\u5165\u548c\u8f83\u9ad8\u6d88\u8d39\u6c34\u5e73\u7684\u5ba2\u6237\uff08\u805a\u7c7b\u4e2d\u5fc3 B\uff09\u3002\u5546\u5bb6\u53ef\u4ee5\u6839\u636e\u6bcf\u4e2a\u7fa4\u4f53\u7684\u6d88\u8d39\u7279\u5f81\u8c03\u6574\u4ea7\u54c1\u5b9a\u4f4d\uff0c\u6bd4\u5982\u4e3a\u805a\u7c7b\u4e2d\u5fc3 A \u63d0\u4f9b\u6027\u4ef7\u6bd4\u8f83\u9ad8\u7684\u4ea7\u54c1\uff0c\u800c\u4e3a\u805a\u7c7b\u4e2d\u5fc3 B \u63d0\u4f9b\u9ad8\u7aef\u6216\u5962\u4f88\u54c1\u724c\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#2","title":"\u793a\u4f8b 2","text":"\u4e00\u5bb6\u97f3\u4e50\u6d41\u5a92\u4f53\u670d\u52a1\u60f3\u8981\u6839\u636e\u7528\u6237\u5bf9\u4e0d\u540c\u97f3\u4e50\u7c7b\u578b\u7684\u504f\u597d\u5c06\u4ed6\u4eec\u5206\u4e3a\u51e0\u4e2a\u7fa4\u4f53\uff0c\u4ee5\u4fbf\u63d0\u4f9b\u4e2a\u6027\u5316\u7684\u64ad\u653e\u5217\u8868\u3002\u4ed6\u4eec\u6536\u96c6\u4e86\u7528\u6237\u5bf9\u4ee5\u4e0b 5 \u79cd\u97f3\u4e50\u7c7b\u578b\u7684\u504f\u597d\u8bc4\u5206\uff081 \u5206\u8868\u793a\u4e0d\u611f\u5174\u8da3\uff0c5 \u5206\u8868\u793a\u975e\u5e38\u559c\u6b22\uff09\uff1a\u6447\u6eda\u3001\u6d41\u884c\u3001\u7235\u58eb\u3001\u53e4\u5178\u548c\u563b\u54c8\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_7","title":"\u6b65\u9aa4","text":"\u5efa\u7acb\u97f3\u4e50\u7c7b\u578b\u8868\u5e76\u63d2\u5165\u6570\u636e
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a music_table
\u7684\u8868\uff0c\u63d2\u5165 5 \u6761\u7528\u6237\u6570\u636e\u3002\u4e94\u7ef4\u5411\u91cf\u5bf9\u5e94\u7528\u6237\u5bf9\u6447\u6eda\u3001\u6d41\u884c\u3001\u7235\u58eb\u3001\u53e4\u5178\u548c\u563b\u54c8\u4e94\u79cd\u7c7b\u578b\u97f3\u4e50\u7684\u504f\u597d\u8bc4\u5206\u3002
CREATE TABLE music_table(id int,grade vecf64(5));\nINSERT INTO music_table VALUES(1,\"[5,2,3,1,4]\"),(2,\"[3,5,2,1,4]\"),(3,\"[4,3,5,1,2]\"),(4,\"[2,5,4,3,1]\"),(5,\"[5,4,3,2,5]\");\n\nmysql> select * from music_table;\n+------+-----------------+\n| id | grade |\n+------+-----------------+\n| 1 | [5, 2, 3, 1, 4] |\n| 2 | [3, 5, 2, 1, 4] |\n| 3 | [4, 3, 5, 1, 2] |\n| 4 | [2, 5, 4, 3, 1] |\n| 5 | [5, 4, 3, 2, 5] |\n+------+-----------------+\n5 rows in set (0.01 sec)\n
\u67e5\u770b\u5411\u91cf\u5f52\u4e00\u5316\u7ed3\u679c
mysql> select normalize_l2(grade) from music_table;\n+---------------------------------------------------------------------------------------------------------+\n| normalize_l2(grade) |\n+---------------------------------------------------------------------------------------------------------+\n| [0.6741998624632421, 0.26967994498529685, 0.40451991747794525, 0.13483997249264842, 0.5393598899705937] |\n| [0.40451991747794525, 0.6741998624632421, 0.26967994498529685, 0.13483997249264842, 0.5393598899705937] |\n| [0.5393598899705937, 0.40451991747794525, 0.6741998624632421, 0.13483997249264842, 0.26967994498529685] |\n| [0.26967994498529685, 0.6741998624632421, 0.5393598899705937, 0.40451991747794525, 0.13483997249264842] |\n| [0.562543950463012, 0.4500351603704096, 0.3375263702778072, 0.2250175801852048, 0.562543950463012] |\n+---------------------------------------------------------------------------------------------------------+\n5 rows in set (0.01 sec)\n
\u786e\u5b9a\u805a\u7c7b\u4e2d\u5fc3
mysql> SELECT cluster_centers(grade kmeans '2,vector_l2_ops,kmeansplusplus,true') AS centers FROM music_table;\n+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| centers |\n+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| [ [0.3370999312316211, 0.6741998624632421, 0.40451991747794525, 0.26967994498529685, 0.3370999312316211],[0.5920345676322826, 0.3747450076112172, 0.4720820500729982, 0.16489917505683388, 0.4571945951396342] ] |\n+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
\u68c0\u67e5\u805a\u7c7b\u4e2d\u5fc3
\u4f7f\u7528 t-SNE \u5c06\u9ad8\u7ef4\u6570\u636e\u964d\u5230 2D\uff0c\u5e76\u53ef\u89c6\u5316\u805a\u7c7b\u7ed3\u679c\u3002\u4ece\u4e0b\u56fe\u53ef\u770b\u5230\u6570\u636e\u70b9\u5728\u964d\u7ef4\u540e\u7684\u7a7a\u95f4\u4e2d\u6309\u805a\u7c7b\u4e2d\u5fc3\u660e\u663e\u5206\u5f00\uff0c\u8fd9\u589e\u52a0\u4e86\u805a\u7c7b\u4e2d\u5fc3\u6b63\u786e\u6027\u7684\u4fe1\u5fc3\u3002
\u901a\u8fc7\u805a\u7c7b\u4e2d\u5fc3\u7684\u786e\u5b9a\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u7528\u6237\u5206\u4e3a\u4e24\u4e2a\u7fa4\u4f53\uff1a\u7c07 1 \u4e3b\u8981\u7531\u559c\u6b22\u6447\u6eda\u548c\u563b\u54c8\u97f3\u4e50\u7684\u7528\u6237\u7ec4\u6210\uff0c\u8fd9\u53ef\u80fd\u4ee3\u8868\u4e86\u4e00\u4e2a\u5bfb\u6c42\u73b0\u4ee3\u548c\u8282\u594f\u611f\u5f3a\u70c8\u97f3\u4e50\u7684\u7528\u6237\u7fa4\u4f53\u3002\u7c07 2 \u5219\u7531\u559c\u6b22\u6d41\u884c\u548c\u7235\u58eb\u97f3\u4e50\u7684\u7528\u6237\u7ec4\u6210\uff0c\u8fd9\u53ef\u80fd\u4ee3\u8868\u4e86\u4e00\u4e2a\u504f\u597d\u65cb\u5f8b\u548c\u8f7b\u677e\u6c1b\u56f4\u97f3\u4e50\u7684\u7528\u6237\u7fa4\u4f53\u3002\u5a92\u4f53\u516c\u53f8\u53ef\u4ee5\u6839\u636e\u7528\u6237\u559c\u597d\u6765\u4e3a\u4ed6\u4eec\u63a8\u9001\u76f8\u5e94\u98ce\u683c\u7684\u97f3\u4e50\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Develop/Vector/cluster_centers/#_8","title":"\u53c2\u8003\u6587\u6863","text":"\u5411\u91cf\u6570\u636e\u7c7b\u578b
CLUSTER_CENTERS()
L2_DISTANCE()
NORMALIZE_L2()
"},{"location":"MatrixOne/Develop/Vector/vector_search/","title":"\u5411\u91cf\u68c0\u7d22","text":""},{"location":"MatrixOne/Develop/Vector/vector_search/#_2","title":"\u4ec0\u4e48\u662f\u5411\u91cf\u68c0\u7d22","text":"\u5411\u91cf\u68c0\u7d22\u5c31\u662f\u5728\u4e00\u4e2a\u7ed9\u5b9a\u5411\u91cf\u6570\u636e\u96c6\u4e2d\uff0c\u6309\u7167\u67d0\u79cd\u5ea6\u91cf\u65b9\u5f0f\uff0c\u68c0\u7d22\u51fa\u4e0e\u67e5\u8be2\u5411\u91cf\u76f8\u8fd1\u7684 K \u4e2a\u5411\u91cf\uff08K-Nearest Neighbor\uff0cKNN\uff09\u3002\u8fd9\u662f\u4e00\u79cd\u5728\u5927\u89c4\u6a21\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\u4e2d\u5bfb\u627e\u4e0e\u7ed9\u5b9a\u67e5\u8be2\u5411\u91cf\u76f8\u4f3c\u7684\u5411\u91cf\u7684\u6280\u672f\u3002\u5411\u91cf\u68c0\u7d22\u5728\u8bb8\u591a AI \u9886\u57df\u5177\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u5982\u56fe\u50cf\u68c0\u7d22\u3001\u6587\u672c\u68c0\u7d22\u3001\u8bed\u97f3\u8bc6\u522b\u3001\u63a8\u8350\u7cfb\u7edf\u7b49\u3002\u5411\u91cf\u68c0\u7d22\u4e0e\u4f20\u7edf\u6570\u636e\u5e93\u68c0\u7d22\u6709\u5f88\u5927\u5dee\u522b\uff0c\u4f20\u7edf\u6570\u636e\u5e93\u4e0a\u7684\u6807\u91cf\u641c\u7d22\u4e3b\u8981\u9488\u5bf9\u7ed3\u6784\u5316\u6570\u636e\u8fdb\u884c\u7cbe\u786e\u7684\u6570\u636e\u67e5\u8be2\uff0c\u800c\u5411\u91cf\u641c\u7d22\u4e3b\u8981\u9488\u5bf9\u975e\u7ed3\u6784\u5316\u6570\u636e\u5411\u91cf\u5316\u4e4b\u540e\u7684\u5411\u91cf\u6570\u636e\u8fdb\u884c\u76f8\u4f3c\u68c0\u7d22\uff0c\u53ea\u80fd\u8fd1\u4f3c\u83b7\u5f97\u6700\u5339\u914d\u7684\u7ed3\u679c\u3002
Matrixone \u76ee\u524d\u652f\u6301\u4f7f\u7528\u4ee5\u4e0b\u8ddd\u79bb\u5ea6\u91cf\u51fd\u6570\u8fdb\u884c\u5411\u91cf\u68c0\u7d22\uff1a
cosine_similarity
cosine_distance
l2_distance
Note
Matrixone \u76ee\u524d\u53ea\u652f\u6301\u5728 l2_distance \u5ea6\u91cf\u4e0a\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\u8fdb\u884c\u5feb\u901f KNN \u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/Vector/vector_search/#_3","title":"\u5411\u91cf\u68c0\u7d22\u7684\u5e94\u7528\u573a\u666f","text":"\u6570\u636e\u5e93\u62e5\u6709\u5411\u91cf\u80fd\u529b\u610f\u5473\u7740\u6570\u636e\u5e93\u7cfb\u7edf\u5177\u5907\u5b58\u50a8\u3001\u67e5\u8be2\u548c\u5206\u6790\u5411\u91cf\u6570\u636e\u7684\u80fd\u529b\u3002\u8fd9\u4e9b\u5411\u91cf\u901a\u5e38\u4e0e\u590d\u6742\u7684\u6570\u636e\u5206\u6790\u3001\u673a\u5668\u5b66\u4e60\u548c\u6570\u636e\u6316\u6398\u4efb\u52a1\u76f8\u5173\u3002\u4ee5\u4e0b\u662f\u6570\u636e\u5e93\u62e5\u6709\u5411\u91cf\u5904\u7406\u80fd\u529b\u540e\u7684\u90e8\u5206\u5e94\u7528\u573a\u666f\uff1a
\u9e22\u5c3e\u82b1\u6570\u636e\u96c6\u662f\u4e00\u4e2a\u8457\u540d\u7684\u591a\u7c7b\u5206\u7c7b\u6570\u636e\u96c6\uff0c\u53ef\u81ea\u884c\u5728\u7f51\u4e0a\u641c\u7d22\u5e76\u4e0b\u8f7d\u3002\u6b64\u6570\u636e\u96c6\u5305\u542b 150 \u4e2a\u6837\u672c\uff0c\u5206\u4e3a 3 \u4e2a\u7c7b\u522b\uff1aIris Setosa\uff08\u5c71\u9e22\u5c3e\uff09\u3001Iris Versicolour\uff08\u53d8\u8272\u9e22\u5c3e\uff09\u548c Iris Virginica\uff08\u7ef4\u5409\u5c3c\u4e9a\u9e22\u5c3e\uff09\u3002\u6bcf\u4e2a\u6837\u672c\u6709 4 \u4e2a\u7279\u5f81\uff1a\u82b1\u843c\u957f\u5ea6\u3001\u82b1\u843c\u5bbd\u5ea6\u3001\u82b1\u74e3\u957f\u5ea6\u548c\u82b1\u74e3\u5bbd\u5ea6\u3002\u4e0b\u9762\u6211\u4eec\u5728\u9e22\u5c3e\u82b1\u6570\u636e\u96c6\u4e0a\u6267\u884c KNN \u67e5\u8be2\uff08\u57fa\u4e8e l2_distance)\uff0c\u6839\u636e\u9e22\u5c3e\u82b1\u7684\u7279\u5f81\u627e\u51fa\u4e0e\u67d0\u4e2a\u7279\u5b9a\u6837\u672c\u6700\u76f8\u4f3c\u7684 K \u4e2a\u6837\u672c\uff0c\u4ece\u800c\u786e\u5b9a\u8be5\u6837\u672c\u7684\u79cd\u7c7b\u3002
\u5efa\u7acb\u9e22\u5c3e\u82b1\u8868\u5e76\u5bfc\u5165\u6570\u636e
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a iris_table
\u7684\u8868\u4ee5\u53ca\u5bf9\u5e94\u7684\u9e22\u5c3e\u82b1\u6570\u636e\u96c6\u6570\u636e\uff0c\u6570\u636e\u96c6\u5171\u6709 150 \u884c\u6570\u636e\uff0c\u6bcf\u884c\u7531\u4e00\u4e2a\u56db\u7ef4\u7684\u7279\u5f81\u5411\u91cf\u548c\u79cd\u7c7b\u7ec4\u6210\u3002
CREATE TABLE iris_table(\nspecies varchar(100),--\u7c7b\u522b\nattributes vecf64(4)--\u7279\u5f81\n);\nLOAD DATA INFILE '/your_path/iris.csv' INTO TABLE iris_table;\n
\u4f7f\u7528 KNN \u6765\u9884\u6d4b\u8fd9\u4e2a\u8f93\u5165\u7279\u5f81\u7684\u7c7b\u522b
mysql> select * from iris_table order by l2_distance(attributes,\"[4,3.3,3,0.9]\") asc limit 1;\n+------------------+--------------------+\n| species | attributes |\n+------------------+--------------------+\n| Iris-versicolour | [4.9, 2.4, 3.3, 1] |\n+------------------+--------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from iris_table order by l2_distance(attributes,\"[4,3.3,3,0.9]\") asc limit 5;\n+------------------+----------------------+\n| species | attributes |\n+------------------+----------------------+\n| Iris-versicolour | [4.9, 2.4, 3.3, 1] |\n| Iris-versicolour | [5.1, 2.5, 3, 1.1] |\n| Iris-versicolour | [5, 2.3, 3.3, 1] |\n| Iris-setosa | [4.8, 3.4, 1.9, 0.2] |\n| Iris-versicolour | [5.2, 2.7, 3.9, 1.4] |\n+------------------+----------------------+\n5 rows in set (0.00 sec)\n
\u7ecf\u8fc7\u68c0\u7d22\uff0c\u6211\u4eec\u53ef\u4ee5\u5927\u81f4\u786e\u5b9a\u8be5\u6837\u672c\u7c7b\u578b\u4e3a\u53d8\u8272\u9e22\u5c3e\u3002
\u5982\u9700\u4e86\u89e3\u5411\u91cf\u68c0\u7d22\u5728\u6784\u5efa RAG \u5e94\u7528\u4e0a\u7684\u4f5c\u7528\uff0c\u8bf7\u53c2\u8003\u67e5\u770b\u5e94\u7528\u5f00\u53d1\u793a\u4f8b\u4e2d\u7684 RAG \u5e94\u7528\u57fa\u7840\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/Vector/vector_search/#_5","title":"\u53c2\u8003\u6587\u6863","text":"\u5411\u91cf\u6570\u636e\u7c7b\u578b
L2_DISTANCE()
"},{"location":"MatrixOne/Develop/Vector/vector_type/","title":"\u5411\u91cf\u7c7b\u578b","text":""},{"location":"MatrixOne/Develop/Vector/vector_type/#_2","title":"\u4ec0\u4e48\u662f\u5411\u91cf\uff1f","text":"\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u5411\u91cf\u901a\u5e38\u662f\u4e00\u7ec4\u6570\u5b57\uff0c\u5b83\u4eec\u4ee5\u7279\u5b9a\u7684\u65b9\u5f0f\u6392\u5217\uff0c\u4ee5\u8868\u793a\u67d0\u79cd\u6570\u636e\u6216\u7279\u5f81\u3002\u8fd9\u4e9b\u5411\u91cf\u53ef\u4ee5\u662f\u4e00\u7ef4\u6570\u7ec4\u3001\u591a\u7ef4\u6570\u7ec4\u6216\u5177\u6709\u66f4\u9ad8\u7ef4\u5ea6\u7684\u6570\u636e\u7ed3\u6784\u3002\u5728\u673a\u5668\u5b66\u4e60\u548c\u6570\u636e\u5206\u6790\u9886\u57df\u4e2d\uff0c\u5411\u91cf\u7528\u4e8e\u8868\u793a\u6570\u636e\u70b9\u3001\u7279\u5f81\u6216\u6a21\u578b\u53c2\u6570\u3002\u5b83\u4eec\u901a\u5e38\u662f\u7528\u6765\u5904\u7406\u975e\u7ed3\u6784\u5316\u6570\u636e\uff0c\u5982\u56fe\u7247\uff0c\u8bed\u97f3\uff0c\u6587\u672c\u7b49\uff0c\u4ee5\u901a\u8fc7\u673a\u5668\u5b66\u4e60\u6a21\u578b\uff0c\u5c06\u975e\u7ed3\u6784\u5316\u6570\u636e\u8f6c\u5316\u4e3a embedding \u5411\u91cf\uff0c\u968f\u540e\u5904\u7406\u5206\u6790\u8fd9\u4e9b\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/Vector/vector_type/#matrixone","title":"Matrixone \u652f\u6301\u5411\u91cf\u7c7b\u578b","text":"\u4f20\u7edf\u7684\u5411\u91cf\u6570\u636e\u5e93\u4e13\u95e8\u8bbe\u8ba1\u7528\u4e8e\u5904\u7406\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\uff0c\u57fa\u672c\u662f\u975e\u7ed3\u6784\u5316\u7684\uff0c\u5b58\u5728\u4e00\u5b9a\u7684\u5c40\u9650\u6027\u3002\u5b83\u4eec\u53ef\u80fd\u4e0d\u50cf\u4f20\u7edf\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u90a3\u6837\u63d0\u4f9b\u4e30\u5bcc\u7684\u5bf9\u975e\u5411\u91cf\u5b57\u6bb5\uff08\u4f8b\u5982\uff0c\u5143\u6570\u636e\u6216\u6587\u672c\u63cf\u8ff0\uff09\u7684\u652f\u6301\uff0c\u4e5f\u7f3a\u4e4f\u5bf9\u590d\u6742\u6570\u636e\u5173\u7cfb\u548c\u4e8b\u52a1\u5904\u7406\u7684\u80fd\u529b\uff0c\u4ee5\u53ca\u5728\u6570\u636e\u5b8c\u6574\u6027\u7ea6\u675f\u548c\u5143\u6570\u636e\u7ba1\u7406\u65b9\u9762\u7684\u529f\u80fd\u4e0d\u8db3\u3002\u56e0\u6b64\uff0c\u5411\u91cf\u6570\u636e\u5e93\u53ef\u80fd\u4e0d\u9002\u7528\u4e8e\u9700\u8981\u590d\u6742\u67e5\u8be2\u3001\u591a\u6837\u5316\u6570\u636e\u7c7b\u578b\u652f\u6301\u6216\u5f3a\u6570\u636e\u4e00\u81f4\u6027\u4fdd\u8bc1\u7684\u573a\u666f\u3002
\u800c MatrixOne \u4f5c\u4e3a\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0c\u540c\u65f6\u5177\u5907\u5411\u91cf\u80fd\u529b\uff0c\u80fd\u591f\u63d0\u4f9b\u5f3a\u5927\u7684\u6570\u636e\u7ba1\u7406\u529f\u80fd\u3002MatrixOne \u7ed3\u5408\u4e86\u4f20\u7edf\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7684\u4e8b\u52a1\u4e00\u81f4\u6027\u3001\u6570\u636e\u5b8c\u6574\u6027\u3001\u6613\u4e8e\u96c6\u6210\u548c\u4e30\u5bcc\u7684\u5de5\u5177\u751f\u6001\u7cfb\u7edf\u7b49\u4f18\u70b9\uff0c\u540c\u65f6\u589e\u52a0\u4e86\u5bf9\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\u7684\u5b58\u50a8\u548c\u9ad8\u6548\u76f8\u4f3c\u6027\u641c\u7d22\u7684\u80fd\u529b\u3002\u8fd9\u79cd\u7ed3\u5408\u4f7f\u5f97\u6570\u636e\u5e93\u80fd\u591f\u7edf\u4e00\u7ba1\u7406\u548c\u67e5\u8be2\u7ed3\u6784\u5316\u4e0e\u975e\u7ed3\u6784\u5316\u6570\u636e\uff0c\u652f\u6301\u590d\u6742\u7684 AI \u548c\u673a\u5668\u5b66\u4e60\u5e94\u7528\uff0c\u540c\u65f6\u4fdd\u6301\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u6cbb\u7406\uff0c\u964d\u4f4e\u4e86\u7ef4\u62a4\u6210\u672c\u548c\u7cfb\u7edf\u590d\u6742\u6027\uff0c\u4e3a\u73b0\u4ee3\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u7075\u6d3b\u800c\u5168\u9762\u7684\u6570\u636e\u89e3\u51b3\u65b9\u6848\u3002
Matrixone \u76ee\u524d\u652f\u6301 float32
\u53ca float64
\u7c7b\u578b\u7684\u5411\u91cf\uff0c\u5206\u522b\u79f0\u4e4b\u4e3a vecf32
\u4e0e vecf64
\u800c\u4e0d\u652f\u6301\u5b57\u7b26\u4e32\u7c7b\u578b\u548c\u6574\u578b\u7c7b\u578b\u7684\u6570\u5b57\u3002
\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\uff1a\u5728\u5c06\u5411\u91cf\u4ece\u4e00\u79cd\u7c7b\u578b\u8f6c\u6362\u4e3a\u53e6\u4e00\u79cd\u7c7b\u578b\u65f6\uff0c\u5efa\u8bae\u540c\u65f6\u6307\u5b9a\u7ef4\u5ea6\u3002\u4f8b\u5982\uff1a
SELECT b + CAST(\"[1,2,3]\" AS vecf32(3)) FROM t1;\n
\u8fd9\u79cd\u505a\u6cd5\u786e\u4fdd\u4e86\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\u7684\u51c6\u786e\u6027\u548c\u4e00\u81f4\u6027\u3002
\u4f7f\u7528\u4e8c\u8fdb\u5236\u683c\u5f0f\uff1a\u4e3a\u4e86\u63d0\u9ad8\u6574\u4f53\u63d2\u5165\u6027\u80fd\uff0c\u8003\u8651\u4f7f\u7528\u4e8c\u8fdb\u5236\u683c\u5f0f\u800c\u4e0d\u662f\u6587\u672c\u683c\u5f0f\u3002\u5728\u8f6c\u6362\u4e3a\u5341\u516d\u8fdb\u5236\u7f16\u7801\u4e4b\u524d\uff0c\u786e\u4fdd\u6570\u7ec4\u91c7\u7528\u5c0f\u7aef\u5e8f\u683c\u5f0f\u3002\u4ee5\u4e0b\u662f\u793a\u4f8b Python \u4ee3\u7801\uff1a
import binascii\n\n# 'value' \u662f\u4e00\u4e2a NumPy \u5bf9\u8c61\ndef to_binary(value):\n if value is None:\n return value\n\n # \u5c0f\u7aef\u5e8f\u6d6e\u70b9\u6570\u7ec4\n value = np.asarray(value, dtype='<f')\n\n if value.ndim != 1:\n raise ValueError('\u671f\u671b ndim \u4e3a 1')\n\n return binascii.b2a_hex(value)\n
\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6570\u636e\u63d2\u5165\u7684\u6548\u7387\u3002
\u6784\u5efa RAG \u5e94\u7528\uff1a\u8be6\u60c5\u8bf7\u67e5\u770b\u5e94\u7528\u5f00\u53d1\u793a\u4f8b\u4e2d\u7684 RAG \u5e94\u7528\u57fa\u7840\u793a\u4f8b\u3002
\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\uff1a\u8be6\u60c5\u8bf7\u67e5\u770b\u5e94\u7528\u5f00\u53d1\u793a\u4f8b\u4e2d\u7684\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\u57fa\u7840\u793a\u4f8b\u3002
\u5411\u91cf\u6570\u636e\u7c7b\u578b
"},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/","title":"\u914d\u7f6e MatrixOne SSL","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#_1","title":"\u6982\u8ff0","text":"\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u914d\u7f6e SSL \u5b89\u5168\u8fde\u63a5 MatrixOne \u670d\u52a1\u5668\u3002\u5728\u4f20\u9001\u4fe1\u606f\u65f6\uff0c\u91c7\u7528 SSL \u8fde\u63a5\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u907f\u514d\u6076\u610f\u7528\u6237\u62e6\u622a\u4f60\u7684\u6d41\u91cf\u3002
"},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#matrixone-ssl_1","title":"\u914d\u7f6e MatrixOne SSL \u8fde\u63a5","text":""},{"location":"MatrixOne/Develop/connect-mo/configure-mo-ssl-connection/#ssl","title":"\u65b0\u5efa\u76ee\u5f55\u5b58\u50a8 SSL \u5bc6\u94a5","text":"\u521b\u5efa\u5305\u542b SSL \u5bc6\u94a5\u7684\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u901a\u8fc7 SSH \u767b\u5f55 MatrixOne \u670d\u52a1\uff0c\u5148\u786e\u8ba4\u4f60\u5df2\u5b89\u88c5 mysql_ssl_rsa_setup
\u5de5\u5177\u3002\u4e00\u822c\u5982\u679c MySQL \u5b89\u88c5\u5b8c\u6210\u7684\u8bdd\uff0cmysql_ssl_rsa_setup
\u4e5f\u4f1a\u88ab\u4e00\u8d77\u5b89\u88c5\u3002
\u68c0\u67e5\u4f60\u662f\u5426\u5b89\u88c5 mysql_ssl_rsa_setup
\uff1a\u5982\u679c\u4f60\u5df2\u5b89\u88c5 mysql_ssl_rsa_setup
\uff0c\u5728\u547d\u4ee4\u884c\u5de5\u5177\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4e0b\u5217\u7ed3\u679c\uff0c\u5219\u9700\u8981\u91cd\u65b0\u5b89\u88c5 MySQL, \u53ef\u4ee5\u53c2\u89c1 install MySQL\uff0cmysql_ssl_rsa_setup
\u4e5f\u5c06\u4e00\u5e76\u5b89\u88c5\u3002\u53e6\u5916\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7 whereis mysql_ssl_rsa_setup
\u547d\u4ee4\u67e5\u770b mysql_ssl_rsa_setup
\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002
[pcusername@VM-0-12-centos matrixone]$ mysql_ssl_rsa_setup\n2022-10-19 10:57:30 [ERROR] Failed to access directory pointed by --datadir. Please make sure that directory exists and is accessible by mysql_ssl_rsa_setup. Supplied value : /var/lib/mysql\n[pcusername@VM-0-12-centos matrixone]$ whereis mysql_ssl_rsa_setup\nmysql_ssl_rsa_setup: /usr/bin/mysql_ssl_rsa_setup /usr/share/man/man1/mysql_ssl_rsa_setup.1.gz\n
\u521b\u5efa\u4e00\u4e2a MatrixOne \u53ef\u4ee5\u8bbf\u95ee\u7684 SSL \u5bc6\u94a5\u5b58\u50a8\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u6267\u884c\u547d\u4ee4 mkdir /home/user/mo_keys
\u521b\u5efa\u76ee\u5f55 mo_keys\u3002
\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\u521b\u5efa SSL \u5bc6\u94a5\uff1a
\u8fd0\u884c\u547d\u4ee4\u521b\u5efa CA (Certificate Authority) \u5bc6\u94a5\uff1a
mysql_ssl_rsa_setup --datadir=/home/user/mo_keys\n
\u6587\u4ef6\u5939\u5c06\u521b\u5efa\u4ea7\u751f\u591a\u4e2a. pem \u6587\u4ef6\u3002
/mo_keys \u251c\u2500\u2500 ca-key.pem \u251c\u2500\u2500 ca.pem \u251c\u2500\u2500 client-cert.pem \u251c\u2500\u2500 client-key.pem \u251c\u2500\u2500 private_key.pem \u251c\u2500\u2500 public_key.pem \u251c\u2500\u2500 server-cert.pem \u2514\u2500\u2500 server-key.pem
\u5728 MatrixOne \u76ee\u5f55\u4e0b\u7684 etc/launch-with-proxy/cn.toml \u6587\u4ef6\u5185\u7684 [cn.frontend]
\u90e8\u5206\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u6bb5\uff1a
[cn.frontend]\nenableTls = true\ntlsCertFile = \"/home/user/mo_keys/server-cert.pem\"\ntlsKeyFile = \"/home/user/mo_keys/server-key.pem\"\ntlsCaFile = \"/home/user/mo_keys/ca.pem\"\n
\u5982\u679c [cn.frontend]
\u90e8\u5206\u5728 MatrixOne \u7cfb\u7edf\u8bbe\u7f6e\u6587\u4ef6\u4e2d\u4e0d\u5b58\u5728\uff0c\u4f60\u53ef\u4ee5\u7528\u4e0a\u8ff0\u8bbe\u7f6e\u521b\u5efa\u4e00\u4e2a\u3002
\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff0c\u6d4b\u8bd5\u6d4b\u8bd5 SSL \u914d\u7f6e\u662f\u5426\u6210\u529f\uff1a
\u5355\u673a\u90e8\u7f72 MatrixOne \u670d\u52a1\uff0c\u5177\u4f53\u6b65\u9aa4\uff0c\u53c2\u89c1\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4 1 \u4e2d\u5355\u673a\u90e8\u7f72 MatriOne \u670d\u52a1\u5e76\u8fde\u63a5\u6210\u529f\u540e\uff0c\u8fd0\u884c status
\u547d\u4ee4\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
mysql> status\n--------------\nmysql Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)\n\nConnection id: 1001\nCurrent database:\nCurrent user: root@0.0.0.0\nSSL: Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager: stdout\nUsing outfile: ''\nUsing delimiter: ;\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\nProtocol version: 10\nConnection: 127.0.0.1 via TCP/IP\nClient characterset: utf8mb4\nServer characterset: utf8mb4\nTCP port: 6002\nBinary data as: Hexadecimal\n--------------\n
MatrixOne \u652f\u6301 C# \u8fde\u63a5\uff0c\u5e76\u4e14\u652f\u6301 MySQL Connector/NET \u9a71\u52a8\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 C# \u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne
\u5df2\u5b89\u88c5. NET Core SDK
\u5df2\u5b89\u88c5 MySQL Client
\u4f7f\u7528 dotnet \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u63a7\u5236\u53f0\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a myapp \u7684\u65b0\u5e94\u7528\uff1a
dotnet new console -o myapp\n
\u968f\u540e\u5207\u6362\u5230 myapp \u76ee\u5f55\u4e0b
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#mysql-connectornet-nuget","title":"\u6b65\u9aa4\u4e8c\uff1a\u6dfb\u52a0 MySQL Connector/NET NuGet \u5305","text":"\u4f7f\u7528 NuGet \u5305\u7ba1\u7406\u5668\u5b89\u88c5 MySql.Data \u5305\uff1a
dotnet add package MySql.Data\n
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#matrixone","title":"\u6b65\u9aa4\u4e09\uff1a\u8fde\u63a5 Matrixone","text":"\u5728 Program.cs \u6587\u4ef6\u4e2d\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a
using System;\nusing MySql.Data.MySqlClient;\n\nclass Program\n{\n static void Main(string[] args)\n {\n Program n =new Program();\n string connectionString = \"server=127.0.0.1;user=root;database=test;port=6001;password=111\";\n using (MySqlConnection connection = new MySqlConnection(connectionString))\n {\n try{\n connection.Open();\n Console.WriteLine(\"\u6210\u529f\u5efa\u7acb\u8fde\u63a5\");\n }\n catch (MySqlException ex)\n {\n Console.WriteLine(ex.Message);\n }\n finally\n {\n connection.Close();\n }\n }\n }\n}\n
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#_2","title":"\u6b65\u9aa4\u56db\uff1a\u8fd0\u884c\u7a0b\u5e8f","text":"\u5728\u7ec8\u7aef\u6267\u884c\u547d\u4ee4 dotnet run
\uff1a
(base) admin@admindeMacBook-Pro myapp % dotnet run \n\u6210\u529f\u5efa\u7acb\u8fde\u63a5\n
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-c%23/#_3","title":"\u53c2\u8003\u6587\u6863","text":"\u5173\u4e8e\u4f7f\u7528 C# \u901a\u8fc7 MatrixOne \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u7684\u793a\u4f8b\uff0c\u53c2\u89c1 C# \u57fa\u7840\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/","title":"Golang \u8fde\u63a5","text":"MatrixOne \u652f\u6301 Golang \u8fde\u63a5\uff0c\u5e76\u4e14\u652f\u6301 Go-MySQL-Driver
\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 Golang \u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/connect-to-matrixone-with-go/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b89\u88c5 Golang 1.18 \u7248\u672c\u53ca\u4ee5\u4e0a\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u70b9\u51fb Golang 1.18 \u7248\u672c\u53ca\u4ee5\u4e0a\u81f3\u5b98\u65b9\u7f51\u7ad9\u8fdb\u884c\u4e0b\u8f7d\u5b89\u88c5\uff1b\u5982\u679c\u4f60\u5df2\u5b89\u88c5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u68c0\u67e5\u7248\u672c\uff1a
#\u68c0\u67e5 Golang \u7248\u672c\u53f7\uff0c\u786e\u8ba4\u662f\u5426\u5b89\u88c5\ngo version\n
\u5df2\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u70b9\u51fb MySQL \u5ba2\u6237\u7aef\u81f3\u5b98\u65b9\u7f51\u7ad9\u8fdb\u884c\u4e0b\u8f7d\u5b89\u88c5\u3002
\u5df2\u5b89\u88c5 Git \u5de5\u5177\uff0c\u5982\u679c\u4f60\u6ca1\u6709\u5b89\u88c5\uff0c\u53ef\u4ee5\u70b9\u51fb Git \u81f3\u5b98\u65b9\u7f51\u7ad9\u8fdb\u884c\u4e0b\u8f7d\u5b89\u88c5\u3002
Go-MySQL-Driver
\u662f\u4e00\u4e2a\u7528\u4e8e Go \u8bed\u8a00\u7684 MySQL \u9a71\u52a8\u7a0b\u5e8f\uff0c\u5b83\u5b9e\u73b0\u4e86 Go \u6807\u51c6\u5e93\u4e2d database/sql \u63a5\u53e3\u7684\u65b9\u6cd5\uff0c\u4f7f\u5f97 Go \u8bed\u8a00\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u9a71\u52a8\u7a0b\u5e8f\u8fde\u63a5\u548c\u64cd\u4f5c MySQL \u6570\u636e\u5e93\u3002
\u5b89\u88c5 Go-MySQL-Driver
\u5de5\u5177\uff1a
\u4f7f\u7528 Go Tool \u5c06 Go-MySQL-Driver
\u5305\u5b89\u88c5\u5230\u4f60\u7684 $GOPATH\u3002
\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u5b89\u88c5 Go-MySQL-Driver
\u5de5\u5177\uff1a
> go get -u github.com/go-sql-driver/mysql\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 golang_connect_matrixone.go \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
package main\n\nimport (\n\"database/sql\"\n\"fmt\"\n_ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n//\"username:password@[protocol](address:port)/database\"\ndb, _ := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\") // Set database connection\ndefer db.Close() //Close DB\nerr := db.Ping() //Connect to DB\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\nreturn\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\n}\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
> go run golang_connect_matrixone.go\nDatabase Connection Succeed\n
gorm
\u662f\u4e00\u4e2a\u57fa\u4e8e golang \u7684\u4e00\u4e2a\u795e\u5947\u7684\u5168\u529f\u80fd ORM \u5e93\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 gorm.io/gorm
\u548c gorm.io/driver/mysql
\u8fd9\u4e24\u4e2a\u5e93\u6765\u8ba9 Go \u8fde\u63a5\u5230 MYSQL \u6570\u636e\u5e93\u3002
gorm.io/gorm
\u548c gorm.io/driver/mysql
\u5e93\uff0c\u4f7f\u7528 go get
\u547d\u4ee4\u5b89\u88c5\uff1ago get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u6587\u672c\u6587\u4ef6 golang_gorm_connect_matrixone.go \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
package main\nimport (\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"fmt\"\n)\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO \ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{ })\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\nfunc main() {\ngetDBConn()\n}\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
> go run golang_gorm_connect_matrixone.go\nDatabase Connection Succeed\n
\u5173\u4e8e\u4f7f\u7528 Golang \u901a\u8fc7 MatrixOne \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u7684\u793a\u4f8b\uff0c\u53c2\u89c1 Golang \u57fa\u7840\u793a\u4f8b\u3002
\u5173\u4e8e\u4f7f\u7528 Gorm \u901a\u8fc7 MatrixOne \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u7684\u793a\u4f8b\uff0c\u53c2\u89c1 Gorm \u57fa\u7840\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/","title":"\u5ba2\u6237\u7aef\u5de5\u5177\u8fde\u63a5","text":"MatrixOne \u73b0\u5728\u652f\u6301\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u6570\u636e\u5e93\u5ba2\u6237\u7aef\u5de5\u5177\u7684\u65b9\u5f0f\u8fde\u63a5 MatrixOne \u670d\u52a1\uff1a
\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#mysql-client-matrixone","title":"\u901a\u8fc7 MySQL Client \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4e0b\u8f7d\u5b89\u88c5 MySQL Client\u3002
\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u6765\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
mysql -h IP -P PORT -uUsername -p\n
\u8fde\u63a5\u7b26\u7684\u683c\u5f0f\u4e0e MySQL \u683c\u5f0f\u76f8\u540c\uff0c\u4f60\u9700\u8981\u63d0\u4f9b\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002
\u6b64\u5904\u4ee5\u5185\u7f6e\u5e10\u53f7\u4f5c\u4e3a\u793a\u4f8b\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password:\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u8fde\u63a5\u6210\u529f\u63d0\u793a\u5982\u4e0b\uff1a
Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 1031\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\nCopyright (c) 2000, 2022, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n
\u66f4\u591a\u5173\u4e8e\u5b89\u88c5\u90e8\u7f72\u7684\u95ee\u9898\uff0c\u53c2\u89c1\u90e8\u7f72\u5e38\u89c1\u95ee\u9898\u3002
Note
MatrixOne \u4e0e\u5ba2\u6237\u7aef\u9ed8\u8ba4\u662f\u975e\u52a0\u5bc6\u4f20\u8f93\uff0c\u5982\u679c\u9700\u8981\u5f00\u542f\u52a0\u5bc6\u4f20\u8f93\u8bf7\u53c2\u89c1\u6570\u636e\u4f20\u8f93\u52a0\u5bc6\u3002
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#navicat-matrixone","title":"\u901a\u8fc7 Navicat \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4e0b\u8f7d\u5b89\u88c5 Navicat\u3002
\u5b89\u88c5 Navicat \u5b8c\u6210\u540e\uff0c\u6253\u5f00 Navicat\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2 Connection > MySQL\uff0c\u5728\u5f39\u7a97\u4e2d\u586b\u5165\u5982\u4e0b\u53c2\u6570\uff1a
\u70b9\u51fb Save \u4fdd\u5b58\u8bbe\u7f6e\u3002
\u53cc\u51fb\u5de6\u4fa7\u6570\u636e\u5e93\u76ee\u5f55\u4e2d\u7684 MatrixOne\uff0c\u56fe\u6807\u70b9\u4eae\uff0c\u8fde\u63a5\u6210\u529f\u3002
\u8fde\u63a5\u5230 MatrixOne \u540e\uff0c\u5728\u5de6\u4fa7\u6570\u636e\u5e93\u76ee\u5f55\u680f\uff0c\u4f60\u5c06\u770b\u5230 6 \u4e2a\u9ed8\u8ba4\u7cfb\u7edf\u6570\u636e\u5e93\uff1a
\u53f3\u4fa7\u7a97\u53e3\u53ef\u67e5\u770b\u6709\u5173\u6b64\u8fde\u63a5\u7684\u57fa\u672c\u4fe1\u606f\uff1a
<div align=\"center\">\n<img src=https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/artwork/docs/develop/navicat-connection.png width=50% heigth=50%/>\n</div>\n
"},{"location":"MatrixOne/Develop/connect-mo/database-client-tools/#dbeaver-matrixone","title":"\u901a\u8fc7 DBeaver \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4e0b\u8f7d\u5b89\u88c5 DBeaver\u3002
\u5b89\u88c5 DBeaver \u5b8c\u6210\u540e\uff0c\u6253\u5f00 DBeaver\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2\u8fde\u63a5\u56fe\u6807\uff0c\u5728\u5f39\u7a97\u4e2d\u9009\u62e9 MySQL\uff0c\u70b9\u51fb Next\u3002
\u5728 Connect to a database \u7a97\u53e3\u7684 Main \u533a\u4e2d\u586b\u5199\u5982\u4e0b\u53c2\u6570\uff1a
\u53cc\u51fb\u5de6\u4fa7\u76ee\u5f55\u4e2d\u7684 MatrixOne\uff0c\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002\u4f60\u53ef\u4ee5\u5728\u5de6\u4fa7\u76ee\u5f55\u6811\u4e2d\u770b\u5230\u9ed8\u8ba4\u7684\u56db\u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\uff1a
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cDBeaver \u4e2d\u4e0d\u5c55\u793a\u89c6\u56fe\u3002\u5982\u9700\u663e\u793a\u5b8c\u6574\u7684\u7cfb\u7edf\u6570\u636e\u5e93\uff0c\u4f60\u53ef\u4ee5\u53f3\u952e\u5355\u51fb MatrixOne\uff0c\u9009\u62e9 Connection view \u5e76\u6253\u5f00 Show system objects\uff1a
\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u4f60\u5c06\u770b\u5230 6 \u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\u3002
MatrixOne \u652f\u6301 Python \u8fde\u63a5\uff0c\u652f\u6301 pymysql
\u548c sqlalchemy
\u4e24\u79cd\u9a71\u52a8\u7a0b\u5e8f\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4e86\u89e3\u5982\u4f55\u901a\u8fc7\u8fd9\u4e24\u4e2a python \u9a71\u52a8\u7a0b\u5e8f\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/python-connect-to-matrixone/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne\u3002
\u5df2\u5b89\u88c5 Python 3.8(or plus) version\u3002
#\u68c0\u67e5 Python \u7248\u672c\u53f7\uff0c\u786e\u8ba4\u662f\u5426\u5b89\u88c5\npython3 -V\n
PyMySQL \u662f\u4e00\u4e2a\u7eaf Python MySQL \u5ba2\u6237\u7aef\u5e93\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql \u548c cryptography \u5de5\u5177\uff1a
pip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 pymysql_connect_matrixone.py \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
#!/usr/bin/python3\n\nimport pymysql\n\n# Open database connection\ndb = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n )\n# prepare a cursor object using cursor() method\ncursor = db.cursor()\n\n# execute SQL query using execute() method.\ncursor.execute(\"SELECT VERSION()\")\n\n# Fetch a single row using fetchone() method.\ndata = cursor.fetchone()\nprint (\"Database version : %s \" % data)\n\n# disconnect from server\ndb.close()\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
> python3 pymysql_connect_matrixone.py\nDatabase version : 8.0.30-MatrixOne-v1.2.1\n
SQLAlchemy \u662f Python SQL \u5de5\u5177\u5305\u548c\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668 (ORM)\uff0c\u5b83\u4e3a\u5e94\u7528\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u4e86 SQL \u7684\u5168\u90e8\u529f\u80fd\u3002
\u4e0b\u8f7d\u5e76\u5b89\u88c5 sqlalchemy \u5de5\u5177\uff0c\u4e0b\u8f7d\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
pip3 install sqlalchemy\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\n
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\uff0c\u5e76\u4e14\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a student \u8868\uff0c\u7136\u540e\u63d2\u5165\u4e24\u6761\u6570\u636e\uff1a
mysql> create database test;\nmysql> use test;\nmysql> create table student (name varchar(20), age int);\nmysql> insert into student values (\"tom\", 11), (\"alice\", \"10\");\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 sqlalchemy_connect_matrixone.py \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff1a
#!/usr/bin/python3\nfrom sqlalchemy import create_engine, text\n\n# Open database connection\nmy_conn = create_engine(\"mysql+mysqldb://root:111@127.0.0.1:6001/test\")\n\n# execute SQL query using execute() method.\nquery=text(\"SELECT * FROM student LIMIT 0,10\")\nmy_data=my_conn.execute(query)\n\n# print SQL result\nfor row in my_data:\n print(\"name:\", row[\"name\"])\n print(\"age:\", row[\"age\"])\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
python3 sqlalchemy_connect_matrixone.py\nname: tom\nage: 11\nname: alice\nage: 10\n
\u5728 Java \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 Java \u4ee3\u7801\u4f7f\u7528 JDBC \u8fde\u63a5\u5668\uff08Java Database Connectivity\uff09\u8fde\u63a5\u5230 MatrixOne\u3002JDBC \u662f\u7528\u4e8e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u6807\u51c6 API \u4e4b\u4e00\uff0c\u4f7f\u7528\u5b83\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u8fd0\u884c SQL \u8bed\u53e5\u5e76\u4e14\u4ece\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-jdbc/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f7f\u7528 JDBC \u8fde\u63a5 MatrixOne \u524d\uff0c\u9700\u8981\u5b8c\u6210\u4ee5\u4e0b\u4e0b\u8f7d\u5b89\u88c5\u4efb\u52a1\uff1a
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\u3002\u5728 MatrixOne \u65b0\u5efa\u4e00\u4e2a\u540d\u4e3a test \u6570\u636e\u5e93\u548c\u4e00\u4e2a\u65b0\u7684\u8868 t1\uff1a
create database test;\nuse test;\ncreate table t1\n(\ncode int primary key,\ntitle char(35)\n);\n
\u5728 IDEA \u4e2d\u65b0\u5efa Java \u540d\u79f0\u4e3a testJDBC \u7684\u9879\u76ee\u5e76\u9009\u62e9\u5728 Build System \u4e2d\u9009\u62e9 Maven \u4f5c\u4e3a\u6784\u5efa\u7cfb\u7edf\uff0c\u70b9\u51fb Create\u3002
\u70b9\u51fb File > Project Structure\uff0c\u8fdb\u5165\u5230 Project Setting\uff0c\u70b9\u9009 Library\uff0c\u5e76\u70b9\u51fb + \u6309\u94ae\uff0c\u6dfb\u52a0 From Maven\u3002
\u8f93\u5165\u6846\u4e2d\u8f93\u5165 mysql-connector-java \u641c\u7d22\u6574\u4e2a\u5e93\uff0c\u9009\u62e9 mysql:mysql-connector-java:8.0.30\uff0c\u5e94\u7528\u5230\u672c\u9879\u76ee\u4e2d\u3002
\u4fee\u6539 src/main/java/org/example/Main.java \u4e2d\u7684\u9ed8\u8ba4 Java \u6e90\u4ee3\u7801\u3002\u5982\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\u6240\u793a\uff0c\u8fd9\u6bb5\u4ee3\u7801\u4f7f\u7528\u8fde\u63a5\u5730\u5740\u548c\u51ed\u636e\u521b\u5efa\u8fde\u63a5\u3002\u8fde\u63a5\u5230 MatrixOne \u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 Java \u8bed\u8a00\u5bf9 MatrixOne \u6570\u636e\u5e93\u548c\u8868\u8fdb\u884c\u64cd\u4f5c\u3002
\u6709\u5173\u5982\u4f55\u4f7f\u7528 JDBC \u5728 MatrixOne \u4e2d\u5f00\u53d1 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u5e94\u7528\u7a0b\u5e8f\u7684\u5b8c\u6574\u793a\u4f8b\uff0c\u53c2\u8003 Java CRUD \u793a\u4f8b\u3002
package org.example;\n\nimport java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\n\n\npublic class Main {\n\n\n private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n private static String jdbcUsername = \"root\";\n private static String jdbcPassword = \"111\";\n\n public static void main(String[] args) {\n\n\n try {\n Connection connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n // Do something with the Connection\n\n } catch (SQLException ex) {\n // handle any errors\n System.out.println(\"SQLException: \" + ex.getMessage());\n System.out.println(\"SQLState: \" + ex.getSQLState());\n System.out.println(\"VendorError: \" + ex.getErrorCode());\n }\n }\n}\n
\u6709\u5173 MatrixOne \u5bf9 JDBC \u7279\u6027\u652f\u6301\u7684\u5b8c\u6574\u5217\u8868\uff0c\u53c2\u89c1 MatrixOne \u7684 JDBC \u529f\u80fd\u652f\u6301\u5217\u8868\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/","title":"\u4f7f\u7528 Java ORMs \u8fde\u63a5","text":"\u9664\u4e86\u4f7f\u7528 JDBC \u8fde\u63a5 MatrixOne \u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04 (ORM) \u6846\u67b6\u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\u3002\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u4ecb\u7ecd\u4e86\u5982\u4f55\u4f7f\u7528 Spring Data JPA \u548c MyBatis \u8fde\u63a5\u5230 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#mybatis","title":"MyBatis","text":"MyBatis \u662f SQL \u6620\u5c04\u6846\u67b6\uff0c\u5b83\u7684\u4f18\u70b9\u662f\u7b80\u5355\u6613\u7528\u3002\u4f60\u53ef\u4ee5\u53c2\u8003 SpringBoot \u548c MyBatis CRUD \u793a\u4f8b\u5b8c\u6574\u6559\u7a0b\u5b66\u4e60\u5982\u4f55\u6784\u5efa\u4e00\u4e2a CRUD \u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u5c06\u91cd\u70b9\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 MatrixOne \u914d\u7f6e MyBatis\u3002
\u4e0b\u9762\u7684\u793a\u4f8b\u662f Maven \u6784\u5efa\u7cfb\u7edf\u7684\u5178\u578b\u8bbe\u7f6e\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-pomxml-mybatis-spring-boot-starter","title":"1. \u5728 Pom.xml \u4e2d\u6dfb\u52a0 MyBatis-Spring-Boot-Starter","text":"\u5728 Spring Boot \u4e0a\u6784\u5efa MyBatis \u5e94\u7528\u7a0b\u5e8f\uff0c\u4f60\u9700\u8981\u5c06 MyBatis-Spring-Boot-Starter \u6a21\u5757\u6dfb\u52a0\u5230 pom.xml \u4e2d\uff0cMyBatis-Spring-Boot-Starter \u6a21\u5757\u5219\u662f\u5728\u9009\u62e9 Maven \u9879\u76ee\u65f6\u8fdb\u884c\u521b\u5efa\u7684\u3002
<dependency>\n <groupId>org.mybatis.spring.boot</groupId>\n <artifactId>mybatis-spring-boot-starter</artifactId>\n <version>2.1.4</version>\n</dependency>\n
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2","title":"2. \u6dfb\u52a0\u914d\u7f6e","text":"\u5728 application.properties
\u4e2d\u9700\u8981\u4fee\u6539\u7684\u53c2\u6570\u5982\u4e0b\uff0c\u5176\u4f59\u53c2\u6570\u53ef\u4ee5\u4fdd\u5b58\u9ed8\u8ba4\u503c\uff1a
spring.datasource.driver-class-name
\uff1aMySQL \u8fde\u63a5\u5668\u7684\u9a71\u52a8\u7a0b\u5e8f\u540d\u79f0\u3002spring.datasource.url
\uff1aJDBC \u8fde\u63a5 URL \u53c2\u6570\u3002spring.datasource.username
\uff1a\u6570\u636e\u5e93\u7528\u6237\u540d\u3002spring.datasource.password
\uff1a\u6570\u636e\u5e93\u5bc6\u7801\u3002mybatis.mapper-locations
\uff1aMapper XML \u914d\u7f6e\u6587\u4ef6\u7684\u4f4d\u7f6e\u3002MatrixOne \u4e2d\u63a8\u8350\u914d\u7f6e\u5982\u4e0b\uff1a
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nmybatis.mapper-locations=classpath:mapping/*xml\n
Note
\u9700\u8981\u4f7f\u7528\u63a8\u8350\u914d\u7f6e\u7684 JDBC \u8fde\u63a5 URL\uff0c\u5426\u5219\u5c06\u5bfc\u81f4\u8fde\u63a5\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#spring-data-jpa","title":"Spring Data JPA","text":"Spring Data JPA \u662f Spring \u57fa\u4e8e ORM \u6846\u67b6\u3001JPA \u89c4\u8303\u7684\u57fa\u7840\u4e0a\u5c01\u88c5\u7684\u4e00\u5957 JPA \u5e94\u7528\u6846\u67b6\uff0c\u53ef\u4f7f\u5f00\u53d1\u8005\u7528\u6781\u7b80\u7684\u4ee3\u7801\u5373\u53ef\u5b9e\u73b0\u5bf9\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u548c\u64cd\u4f5c\uff0c\u5b83\u6709\u52a9\u4e8e\u51cf\u5c11\u6837\u677f\u4ee3\u7801\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u79cd\u901a\u8fc7\u51e0\u4e2a\u9884\u5b9a\u4e49\u7684\u5b58\u50a8\u5e93\u63a5\u53e3\u4e4b\u4e00\u5b9e\u73b0\u57fa\u672c CRUD \u64cd\u4f5c\u7684\u673a\u5236\uff0c\u5e76\u4e14\u5b83\u4e5f\u63d0\u4f9b\u4e86\u5305\u62ec\u589e\u5220\u6539\u67e5\u7b49\u5728\u5185\u7684\u5e38\u7528\u529f\u80fd\uff0c\u4e14\u6613\u4e8e\u6269\u5c55\u3002
Spring Data JPA \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5e94\u7528\u6846\u67b6\uff0c\u5b83\u6709\u52a9\u4e8e\u51cf\u5c11\u6837\u677f\u4ee3\u7801\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u79cd\u901a\u8fc7\u51e0\u4e2a\u9884\u5b9a\u4e49\u7684\u5b58\u50a8\u5e93\u63a5\u53e3\u4e4b\u4e00\u5b9e\u73b0\u57fa\u672c CRUD \u64cd\u4f5c\u7684\u673a\u5236\u3002\u4f60\u53ef\u4ee5\u53c2\u8003 SpringBoot \u548c Hibernate CRUD \u793a\u4f8b\u5b8c\u6574\u6559\u7a0b\u5b66\u4e60\u5982\u4f55\u6784\u5efa CRUD \u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u672c\u7bc7\u6587\u6863\u4e2d\uff0c\u5c06\u91cd\u70b9\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 MatrixOne \u8fde\u63a5\u914d\u7f6e Spring JPA\u3002
\u4e0b\u9762\u7684\u793a\u4f8b\u662f Maven \u6784\u5efa\u7cfb\u7edf\u7684\u5178\u578b\u8bbe\u7f6e\u3002
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#1-pomxml-spring-boot-starter-data-jpa","title":"1. \u5728 Pom.xml \u4e2d\u6dfb\u52a0 spring-boot-starter-data-jpa","text":"\u5728 Spring Boot \u4e0a\u6784\u5efa Spring Data JPA \u5e94\u7528\u7a0b\u5e8f\uff0c\u4f60\u9700\u8981\u5c06 spring-boot-starter-data-jpa \u6a21\u5757\u6dfb\u52a0\u5230 pom.xml \u4e2d\uff0cspring-boot-starter-data-jpa \u6a21\u5757\u5219\u662f\u5728\u9009\u62e9 Maven \u9879\u76ee\u65f6\u8fdb\u884c\u521b\u5efa\u7684\u3002
<dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-data-jpa</artifactId>\n</dependency>\n
"},{"location":"MatrixOne/Develop/connect-mo/java-connect-to-matrixone/connect-mo-with-orm/#2_1","title":"2. \u6dfb\u52a0\u914d\u7f6e","text":"\u5728 application.properties
\u4e2d\u9700\u8981\u4fee\u6539\u7684\u53c2\u6570\u5982\u4e0b\uff0c\u5176\u4f59\u53c2\u6570\u53ef\u4ee5\u4fdd\u5b58\u9ed8\u8ba4\u503c\uff1a
spring.datasource.driver-class-name
\uff1aMySQL \u8fde\u63a5\u5668\u7684\u9a71\u52a8\u7a0b\u5e8f\u540d\u79f0\u3002spring.datasource.url
\uff1aJDBC \u8fde\u63a5 URL \u53c2\u6570\u3002spring.datasource.username
\uff1a\u6570\u636e\u5e93\u7528\u6237\u540d\u3002spring.datasource.password
\uff1a\u6570\u636e\u5e93\u5bc6\u7801\u3002spring.jpa.properties.hibernate.dialect
\uff1aSQL dialect\uff08\u5373 SQL \u65b9\u8a00\uff09\u4f7f Hibernate \u4e3a\u6240\u9009\u6570\u636e\u5e93\u751f\u6210\u66f4\u597d\u7684 SQL\u3002MatrixOne \u5f53\u524d\u4ec5\u652f\u6301 org.hibernate.dialect.MySQLDialect
\u3002
spring.jpa.hibernate.ddl-auto
\uff1aspring.jpa.hibernate.ddl-auto
\u5c5e\u6027\u91c7\u7528\u4e00\u4e2a\u679a\u4e3e\uff0c\u8be5\u679a\u4e3e\u4ee5\u66f4\u53ef\u63a7\u7684\u65b9\u5f0f\u63a7\u5236\u6a21\u5f0f\u751f\u6210\u3002\u53ef\u80fd\u7684\u9009\u9879\u548c\u6548\u679c\u5982\u4e0b\u8868\u6240\u793a\u3002MatrixOne \u5f53\u524d\u4ec5\u652f\u6301 none \u548c validate\u3002
MatrixOne \u4e2d\u63a8\u8350\u914d\u7f6e\u5982\u4e0b\uff1a
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\nspring.datasource.username=root\nspring.datasource.password=111\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.hibernate.ddl-auto = validate\n
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/","title":"\u4f7f\u7528 BITMAP \u5bf9\u6570\u636e\u53bb\u91cd","text":"Matrixone \u652f\u6301\u4f7f\u7528 BITMAP
\u5904\u7406\u4e0d\u540c\u503c\uff08distinct values\uff09\u7684\u8ba1\u6570\u3002
\u672c\u7bc7\u6587\u7ae0\u5c06\u4ecb\u7ecd BITMAP
\u7684\u4e00\u4e9b\u5e94\u7528\u573a\u666f\u548c\u6848\u4f8b\u3002
\u5728 MatrixOne \u4e2d\uff0cBITMAP
\u7528\u4e8e\u4f18\u5316\u7279\u5b9a\u7c7b\u578b\u7684\u67e5\u8be2\u64cd\u4f5c\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5177\u6709\u4f4e\u57fa\u6570\uff08low cardinality\uff09\u7684\u5217\u65f6\uff0c\u5e2e\u52a9\u7528\u6237\u5728\u5927\u6570\u636e\u73af\u5883\u4e2d\u5b9e\u73b0\u4e86\u5feb\u901f\u7684\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u652f\u6301\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b BITMAP
\u7684\u4f7f\u7528\u573a\u666f\uff1a
\u7528\u6237\u884c\u4e3a\u5206\u6790\uff1a\u5047\u8bbe\u4e00\u4e2a\u7535\u5546\u5e73\u53f0\u60f3\u8981\u5206\u6790\u4e0d\u540c\u7528\u6237\u7684\u884c\u4e3a\u6a21\u5f0f\u3002\u4ed6\u4eec\u6709\u4e00\u4e2a\u4e8b\u4ef6\u8868\uff0c\u8bb0\u5f55\u4e86\u7528\u6237\u7684\u6bcf\u4e00\u6b21\u70b9\u51fb\u4e8b\u4ef6\uff0c\u5305\u62ec\u7528\u6237 ID\u3001\u65f6\u95f4\u6233\u3001\u4e8b\u4ef6\u7c7b\u578b\u7b49\u3002\u901a\u8fc7\u4f7f\u7528 BITMAP
\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5bf9\u7528\u6237\u7684\u884c\u4e3a\u8fdb\u884c\u5206\u7c7b\u548c\u7edf\u8ba1\uff0c\u4f8b\u5982\uff0c\u627e\u51fa\u6240\u6709\u8fdb\u884c\u8fc7\u201c\u8d2d\u4e70\u201d\u884c\u4e3a\u7684\u7528\u6237\u6570\u91cf\u3002
\u591a\u7ef4\u5ea6\u5206\u6790\uff1a\u5728\u6570\u636e\u4ed3\u5e93\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9\u591a\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u5206\u6790\uff0c\u4f8b\u5982\uff0c\u5206\u6790\u7279\u5b9a\u65f6\u95f4\u6bb5\u5185\u4e0d\u540c\u5730\u533a\u7684\u9500\u552e\u60c5\u51b5\u3002\u901a\u8fc7 BITMAP
\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5bf9\u65e5\u671f\u548c\u5730\u533a\u8fd9\u4e24\u4e2a\u7ef4\u5ea6\u8fdb\u884c\u7b5b\u9009\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002
\u7edf\u8ba1\u4e0d\u540c\u503c\u7684\u6570\u91cf\uff1a\u5728\u5904\u7406\u5177\u6709\u5927\u91cf\u552f\u4e00\u503c\u7684\u5217\u65f6\uff0c\u5982\u4ea7\u54c1\u7c7b\u522b\u6216\u7528\u6237\u72b6\u6001\uff0c\u4f7f\u7528 BITMAP
\u53ef\u4ee5\u9ad8\u6548\u5730\u8ba1\u7b97\u8fd9\u4e9b\u5217\u4e2d\u4e0d\u540c\u503c\u7684\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u793e\u4ea4\u5a92\u4f53\u5e73\u53f0\u53ef\u80fd\u9700\u8981\u7edf\u8ba1\u5176\u7528\u6237\u6d3b\u8dc3\u72b6\u6001\uff08\u5728\u7ebf\u3001\u79bb\u7ebf\uff09\u7684\u4e0d\u540c\u6570\u91cf\u3002
\u5c42\u6b21\u5316\u805a\u5408\u52a0\u901f\uff1a\u5728\u9700\u8981\u8fdb\u884c\u5c42\u6b21\u5316\u805a\u5408\u67e5\u8be2\u65f6\uff0c\u5982\u5bf9\u9500\u552e\u6570\u636e\u8fdb\u884c\u5b63\u5ea6\u548c\u5e74\u5ea6\u6c47\u603b\uff0cBITMAP
\u53ef\u4ee5\u52a0\u901f\u8ba1\u7b97\u8fc7\u7a0b\u3002\u901a\u8fc7\u4f7f\u7528 BITMAP
\uff0c\u53ef\u4ee5\u5feb\u901f\u5730\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\u548c\u805a\u5408\uff0c\u4ece\u800c\u5f97\u5230\u6240\u9700\u7684\u7edf\u8ba1\u4fe1\u606f\u3002
\u4f18\u5316\u590d\u6742\u67e5\u8be2\uff1a\u5bf9\u4e8e\u5305\u542b\u591a\u4e2a\u6761\u4ef6\u7684\u590d\u6742\u67e5\u8be2\uff0cBITMAP
\u53ef\u4ee5\u5feb\u901f\u7b5b\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u91d1\u878d\u516c\u53f8\u53ef\u80fd\u9700\u8981\u627e\u51fa\u540c\u65f6\u6ee1\u8db3\u201c\u9ad8\u51c0\u503c\u5ba2\u6237\u201d\u548c\u201c\u6295\u8d44\u4e8e\u7279\u5b9a\u57fa\u91d1\u201d\u7684\u7528\u6237\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#_3","title":"\u6848\u4f8b","text":"\u6839\u636e\u4e0a\u8ff0\u573a\u666f\u4e00\u8bbe\u8ba1\u6848\u4f8b\uff0c\u5206\u6790\u7535\u5546\u5e73\u53f0\u4e0d\u540c\u7528\u6237\u7684\u884c\u4e3a\u6a21\u5f0f\u3002
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#_4","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/distinct-data/bitmap/#1","title":"1. \u5efa\u7acb\u7528\u6237\u8868\u5e76\u5bfc\u5165\u6570\u636e","text":"\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a user_behavior_table
\u7684\u8868\u4ee5\u53ca\u5bf9\u5e94\u7684 csv \u6570\u636e\uff0c\u8fd9\u4e2a csv \u6570\u636e\u8868\u5171\u6709 39270760 \u884c\u6570\u636e\u3002
CREATE TABLE user_behavior_table(\nuser_id int,--\u7528\u6237 id\nbehavior varchar(100),--\u884c\u4e3a\uff0c\u5305\u62ec browser,purchase,returns\noccur_year varchar(100)--\u884c\u4e3a\u53d1\u751f\u5e74\u4efd\n);\n\nLOAD DATA INFILE '/your_path/user_behavior_table.csv' INTO TABLE user_behavior_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#2","title":"2. \u5b9a\u4e49\u9884\u8ba1\u7b97\u8868","text":"\u628a\u7c97\u7c92\u5ea6\u7684\u8ba1\u7b97\u7ed3\u679c\u4fdd\u5b58\u5728\u9884\u8ba1\u7b97\u8868\u4e2d\uff0c\u540e\u7eed\u5404\u79cd\u4e0d\u540c\u7ef4\u5ea6\u805a\u5408\u53ef\u4ee5\u4f7f\u7528\u9884\u8ba1\u7b97\u8868\u4e2d\u7684\u7ed3\u679c\uff0c\u7ecf\u8fc7\u7b80\u5355\u7684\u8ba1\u7b97\u5c31\u53ef\u4ee5\u5f97\u5230\u7ed3\u679c\uff0c\u52a0\u901f\u67e5\u8be2\u3002
CREATE TABLE precompute AS\nSELECT\nbehavior,\noccur_year,\nBITMAP_BUCKET_NUMBER(user_id) as bucket,\nBITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(user_id)) as bitmap FROM user_behavior_table\nGROUP BY behavior,occur_year,bucket;\n
"},{"location":"MatrixOne/Develop/distinct-data/bitmap/#3","title":"3. \u6309\u4e0d\u540c\u7ef4\u5ea6\u805a\u5408\u7b5b\u9009\u6570\u636e","text":"\u8ba1\u7b97\u5728\u7528\u6237\u884c\u4e3a\u548c\u5e74\u4efd\u805a\u5408\u60c5\u51b5\u4e0b user_id \u7684\u53bb\u91cd\u6570\u91cf\uff0c\u53cd\u5e94\u7684\u662f\u5728\u4e0d\u540c\u5e74\u4efd\u8fdb\u884c\u5546\u54c1\u6d4f\u89c8\u3001\u8d2d\u4e70\u548c\u9000\u8d27\u7684\u7528\u6237\u6570\u91cf\u3002
mysql> SELECT\n-> behavior,\n-> occur_year,\n-> SUM(BITMAP_COUNT(bitmap))\n-> FROM precompute\n-> GROUP BY behavior,occur_year;\n+----------+------------+---------------------------+\n| behavior | occur_year | sum(bitmap_count(bitmap)) |\n+----------+------------+---------------------------+\n| browser | 2022 | 939995 |\n| browser | 2023 | 1003173 |\n| purchase | 2022 | 669474 |\n| purchase | 2023 | 660605 |\n| returns | 2023 | 4910 |\n| returns | 2022 | 4350 |\n+----------+------------+---------------------------+\n6 rows in set (0.01 sec)\n\nmysql> select behavior,occur_year,count(distinct user_id) from user_behavior_table group by behavior,occur_year;\n+----------+------------+---------------------------+\n| behavior | occur_year | sum(bitmap_count(bitmap)) |\n+----------+------------+---------------------------+\n| browser | 2022 | 939995 |\n| browser | 2023 | 1003173 |\n| purchase | 2022 | 669474 |\n| purchase | 2023 | 660605 |\n| returns | 2023 | 4910 |\n| returns | 2022 | 4350 |\n+----------+------------+---------------------------+\n6 rows in set (3.26 sec)\n
\u8ba1\u7b97 2022-2023 \u5e74\u8fdb\u884c\u5546\u54c1\u6d4f\u89c8\u3001\u8d2d\u4e70\u548c\u9000\u8d27\u7684\u7528\u6237\u6570\u91cf\u3002
mysql> SELECT behavior, SUM(cnt) FROM (\n-> SELECT\n-> behavior,\n-> BITMAP_COUNT(BITMAP_OR_AGG(bitmap)) cnt\n-> FROM precompute\n-> GROUP BY behavior,bucket\n-> )\n-> GROUP BY behavior;\n+----------+----------+\n| behavior | sum(cnt) |\n+----------+----------+\n| browser | 1003459 |\n| purchase | 780308 |\n| returns | 9260 |\n+----------+----------+\n3 rows in set (0.01 sec)\n\nmysql> select behavior,count(distinct user_id) from user_behavior_table group by behavior;\n+----------+-------------------------+\n| behavior | count(distinct user_id) |\n+----------+-------------------------+\n| browser | 1003459 |\n| purchase | 780308 |\n| returns | 9260 |\n+----------+-------------------------+\n3 rows in set (1.44 sec)\n
\u5bf9\u6bd4\u4e24\u79cd\u67e5\u8be2\u7684\u8fd4\u56de\u65f6\u95f4\uff0c\u663e\u7136\u4f7f\u7528 BITMAP
\u66f4\u9ad8\u6548\u3002\u901a\u8fc7\u4f7f\u7528 BITMAP
\uff0c\u5546\u5bb6\u80fd\u591f\u8fc5\u901f\u5730\u7b5b\u9009\u51fa\u7279\u5b9a\u7c7b\u578b\u7684\u4e8b\u4ef6\uff0c\u4ece\u800c\u7edf\u8ba1\u51fa\u5177\u6709\u67d0\u79cd\u884c\u4e3a\u7684\u7528\u6237\u603b\u6570\u3002
COUNT(DISTINCT)
\u63d0\u4f9b\u4e86\u7cbe\u786e\u7684\u53bb\u91cd\u8ba1\u6570\u7ed3\u679c\uff0c\u4f46\u53ef\u80fd\u5728\u5927\u6570\u636e\u96c6\u4e0a\u6548\u7387\u8f83\u4f4e\u3002\u5982\u9700\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u8bf7\u4f7f\u7528 BITMAP\u3002
\u672c\u7bc7\u6587\u7ae0\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 COUNT(DISTINCT)
\u5bf9\u5c11\u91cf\u6570\u636e\u53bb\u91cd\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/distinct-data/count-distinct/#_2","title":"\u793a\u4f8b","text":"--\u5efa\u7acb orders \u8868\uff0c\u6709 customer_id \u548c product_id \u4e24\u4e2a\u5b57\u6bb5\uff0c\u5206\u522b\u8868\u793a\u5ba2\u6237\u548c\u4ea7\u54c1\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002\nCREATE TABLE orders (\norder_id INT AUTO_INCREMENT PRIMARY KEY,\ncustomer_id INT,\nproduct_id INT,\norder_date DATE,\nquantity INT\n);\n\n--\u63d2\u5165\u4e00\u4e9b\u793a\u4f8b\u6570\u636e\uff1a\nINSERT INTO orders (customer_id, product_id, order_date, quantity)\nVALUES\n(1, 101, '2023-04-01', 2),\n(1, 102, '2023-04-02', 1),\n(2, 101, '2023-04-03', 5),\n(3, 103, '2023-04-04', 3),\n(2, 104, '2023-04-05', 1),\n(4, 101, '2023-04-06', 2),\n(4, 102, '2023-04-07', 1),\n(5, 105, '2023-04-08', 4),\n(1, 101, '2023-04-09', 2);\n\n--\u8ba1\u7b97\u4e0d\u540c\u5ba2\u6237\u7684\u6570\u91cf\uff1a\nmysql> SELECT COUNT(DISTINCT customer_id) AS unique_customer_count FROM orders;\n+-----------------------+\n| unique_customer_count |\n+-----------------------+\n| 5 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n--\u8ba1\u7b97\u4e0d\u540c\u4ea7\u54c1\u7684\u6570\u91cf\uff1a\nmysql> SELECT COUNT(DISTINCT product_id) AS unique_product_count FROM orders;\n+----------------------+\n| unique_product_count |\n+----------------------+\n| 5 |\n+----------------------+\n1 row in set (0.01 sec)\n
\u8fd9\u4e24\u4e2a\u67e5\u8be2\u5c06\u5206\u522b\u8fd4\u56de orders \u8868\u4e2d\u552f\u4e00\u5ba2\u6237\u7684\u6570\u91cf\u548c\u552f\u4e00\u4ea7\u54c1\u7684\u6570\u91cf\u3002\u8fd9\u4e9b\u4fe1\u606f\u5bf9\u4e8e\u5206\u6790\u5ba2\u6237\u591a\u6837\u6027\u548c\u4ea7\u54c1\u9500\u552e\u8303\u56f4\u975e\u5e38\u6709\u7528\u3002
"},{"location":"MatrixOne/Develop/distinct-data/count-distinct/#_3","title":"\u53c2\u8003\u6587\u6863","text":"MatrixOne \u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u5bfc\u51fa\u6570\u636e\uff1a
SELECT INTO...OUTFILE
mo-dump
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 mo-dump
\u5bfc\u51fa\u6570\u636e\u3002
mo-dump
\u662f MatrixOne \u7684\u4e00\u4e2a\u5ba2\u6237\u7aef\u5b9e\u7528\u5de5\u5177\uff0c\u4e0e mysqldump
\u4e00\u6837\uff0c\u5b83\u53ef\u4ee5\u88ab\u7528\u4e8e\u901a\u8fc7\u5bfc\u51fa .sql
\u7c7b\u578b\u7684\u6587\u4ef6\u6765\u5bf9 MatrixOne \u6570\u636e\u5e93\u8fdb\u884c\u5907\u4efd\uff0c\u8be5\u6587\u4ef6\u7c7b\u578b\u5305\u542b\u53ef\u6267\u884c\u4ee5\u91cd\u65b0\u521b\u5efa\u539f\u59cb\u6570\u636e\u5e93\u7684 SQL \u8bed\u53e5\u3002
\u4f7f\u7528 mo-dump
\u5de5\u5177\uff0c\u4f60\u5fc5\u987b\u80fd\u591f\u8bbf\u95ee\u8fd0\u884c MatrixOne \u5b9e\u4f8b\u7684\u670d\u52a1\u5668\u3002\u4f60\u8fd8\u5fc5\u987b\u62e5\u6709\u5bfc\u51fa\u7684\u6570\u636e\u5e93\u7684\u7528\u6237\u6743\u9650\u3002
./mo-dump -u ${user} -p ${password} \\\n-h ${host} -P ${port} -db ${database}\\\n[--local-infile=true] [-csv]\\\n[-no-data] [-tbl ${table}...]\\\n-net-buffer-length ${net-buffer-length} > {importStatement.sql}\n
\u53c2\u6570\u91ca\u4e49
-u [user]\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1\u5668\u7684\u7528\u6237\u540d\u3002\u53ea\u6709\u5177\u6709\u6570\u636e\u5e93\u548c\u8868\u8bfb\u53d6\u6743\u9650\u7684\u7528\u6237\u624d\u80fd\u4f7f\u7528 mo-dump
\u5b9e\u7528\u7a0b\u5e8f\uff0c\u9ed8\u8ba4\u503c dump
\u3002
-p [password]\uff1aMatrixOne \u7528\u6237\u7684\u6709\u6548\u5bc6\u7801\u3002\u9ed8\u8ba4\u503c\uff1a111
\u3002
-h [host]\uff1aMatrixOne \u670d\u52a1\u5668\u7684\u4e3b\u673a IP \u5730\u5740\u3002\u9ed8\u8ba4\u503c\uff1a127.0.0.1
\u3002
-P [port]\uff1aMatrixOne \u670d\u52a1\u5668\u7684\u7aef\u53e3\u3002\u9ed8\u8ba4\u503c\uff1a6001
\u3002
-db [databaseName]\uff1a\u5fc5\u9700\u53c2\u6570\u3002\u8981\u5907\u4efd\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002\u53ef\u4ee5\u6307\u5b9a\u591a\u4e2a\u6570\u636e\u5e93\uff0c\u6570\u636e\u5e93\u540d\u79f0\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002
-net-buffer-length [\u6570\u636e\u5305\u5927\u5c0f]\uff1a\u6570\u636e\u5305\u5927\u5c0f\uff0c\u5373 SQL \u8bed\u53e5\u5b57\u7b26\u7684\u603b\u5927\u5c0f\u3002\u6570\u636e\u5305\u662f SQL \u5bfc\u51fa\u6570\u636e\u7684\u57fa\u672c\u5355\u4f4d\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\u53c2\u6570\uff0c\u5219\u9ed8\u8ba4 1048576 Byte\uff081M\uff09\uff0c\u6700\u5927\u53ef\u8bbe\u7f6e 16777216 Byte\uff0816M\uff09\u3002\u5047\u5982\u8fd9\u91cc\u7684\u53c2\u6570\u8bbe\u7f6e\u4e3a 16777216 Byte\uff0816M\uff09\uff0c\u90a3\u4e48\uff0c\u5f53\u8981\u5bfc\u51fa\u5927\u4e8e 16M \u7684\u6570\u636e\u65f6\uff0c\u4f1a\u628a\u6570\u636e\u62c6\u5206\u6210\u591a\u4e2a 16M \u7684\u6570\u636e\u5305\uff0c\u9664\u6700\u540e\u4e00\u4e2a\u6570\u636e\u5305\u4e4b\u5916\uff0c\u5176\u5b83\u6570\u636e\u5305\u5927\u5c0f\u90fd\u4e3a 16M\u3002
-csv\uff1a\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5f53\u8bbe\u7f6e\u4e3a true \u65f6\u8868\u793a\u5bfc\u51fa\u7684\u6570\u636e\u4e3a csv \u683c\u5f0f\uff0c\u751f\u6210\u6570\u636e\u5e93\u548c\u8868\u7ed3\u6784\u4ee5\u53ca\u5bfc\u5165\u7684 SQL \u8bed\u53e5\u5c06\u4f1a\u4fdd\u5b58\u5728\u751f\u6210\u7684 sql \u6587\u4ef6\u4e2d\uff0c\u800c\u6570\u636e\u5219\u5bfc\u51fa\u5230\u5f53\u524d\u76ee\u5f55\u4e0b\u751f\u6210\u7684 ${databaseName}_${tableName}.csv
\u6587\u4ef6\u4e2d\u3002
--local-infile\uff1a\u9ed8\u8ba4\u503c\u4e3a true\uff0c\u4ec5\u5728\u53c2\u6570 -csv \u8bbe\u7f6e\u4e3a true \u65f6\u751f\u6548\u3002\u5f53\u53c2\u6570\u4e3a true \u65f6\uff0cmo-dump \u8f93\u51fa\u7684 sql \u6587\u4ef6\u811a\u672c\u4e2d\u4e3a LOAD DATA LOCAL INFILE\u3002\u5f53\u53c2\u6570\u4e3a false \u65f6\uff0cmo-dump \u8f93\u51fa\u7684 sql \u6587\u4ef6\u811a\u672c\u4e2d\u4e3a LOAD DATA INFILE\u3002
-tbl [tableName]\uff1a\u53ef\u9009\u53c2\u6570\u3002\u5982\u679c\u53c2\u6570\u4e3a\u7a7a\uff0c\u5219\u5bfc\u51fa\u6574\u4e2a\u6570\u636e\u5e93\u3002\u5982\u679c\u8981\u5907\u4efd\u6307\u5b9a\u8868\uff0c\u5219\u53ef\u4ee5\u5728\u547d\u4ee4\u4e2d\u6dfb\u52a0\u53c2\u6570 -tbl
\u548c tableName
\u3002\u5982\u679c\u6307\u5b9a\u591a\u4e2a\u8868\uff0c\u8868\u540d\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002
-no-data\uff1a\u9ed8\u8ba4\u503c\u4e3a false\u3002\u5f53\u8bbe\u7f6e\u4e3a true \u65f6\u8868\u793a\u4e0d\u5bfc\u51fa\u6570\u636e\uff0c\u4ec5\u5bfc\u51fa\u8868\u7ed3\u6784\u3002
> {importStatement.sql}\uff1a\u5c06\u8f93\u51fa\u7684 SQL \u8bed\u53e5\u5b58\u50a8\u5230\u6587\u4ef6 importStatement.sql \u4e2d\uff0c\u5426\u5219\u5728\u5c4f\u5e55\u4e0a\u8f93\u51fa\u3002
\u4e0b\u8f7d\u65b9\u5f0f\u4e00\u548c\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\u9700\u8981\u5148\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177 wget \u6216 curl\uff0c\u5982\u679c\u4f60\u672a\u5b89\u88c5\uff0c\u8bf7\u5148\u81ea\u884c\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177\u3002
wget
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305 x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-x86_64.zip\nunzip mo-dump-1.0.0-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-arm64.zip\nunzip mo-dump-1.0.0-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-x86_64.zip\nunzip mo-dump-1.0.0-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-arm64.zip\nunzip mo-dump-1.0.0-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-darwin-xxx.zip\n
wget
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305 x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-x86_64.zip\nunzip mo-dump-1.0.0-linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-arm64.zip\nunzip mo-dump-1.0.0-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-x86_64.zip\nunzip mo-dump-1.0.0-linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-arm64.zip\nunzip mo-dump-1.0.0-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/mo_dump/releases/download/1.0.0/mo-dump-1.0.0-linux-xxx.zip\n
Note
\u7531\u4e8e linux \u5185\u6838\u7684\u9650\u5236\uff0cmo-dump \u5728\u4f4e\u7248\u672c\u5185\u6838\uff08\u4f4e\u4e8e 5.0\uff09\u7684 OS \u4e0a\u53ef\u80fd\u4f1a\u51fa\u73b0\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u7684\u60c5\u51b5\uff0c\u6b64\u65f6\u9700\u8981\u5347\u7ea7\u60a8\u7684\u5185\u6838\u7248\u672c\u3002
"},{"location":"MatrixOne/Develop/export-data/modump/#mo-dump-matrixone","title":"\u5982\u4f55\u4f7f\u7528mo-dump
\u5bfc\u51fa MatrixOne \u6570\u636e\u5e93","text":"mo-dump
\u5728\u547d\u4ee4\u884c\u4e2d\u975e\u5e38\u6613\u7528\u3002\u5728\u4f60\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u6253\u5f00\u7ec8\u7aef\u7a97\u53e3\uff0c\u8fdb\u5165\u5230\u89e3\u538b\u540e\u7684 mo_dump \u6587\u4ef6\u5939\u76ee\u5f55\uff0c\u627e\u5230 mo-dump
\u53ef\u6267\u884c\u6587\u4ef6\uff1amo-dump\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u8fde\u63a5\u5230 MatrixOne\uff0c\u5e76\u4e14\u5bfc\u51fa\u6570\u636e\u5e93\uff1a
./mo-dump -u username -p password -h host_ip_address -P port -db database > importStatement.sql\n
"},{"location":"MatrixOne/Develop/export-data/modump/#_1","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
\u5982\u679c\u4f60\u5728\u4e0e MatrixOne \u5b9e\u4f8b\u76f8\u540c\u7684\u670d\u52a1\u5668\u4e2d\u542f\u52a8\u7ec8\u7aef\uff0c\u5e76\u4e14\u4f60\u60f3\u8981\u751f\u6210\u5355\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5e93\u4ee5\u53ca\u5176\u4e2d\u6240\u6709\u8868\u7684\u5907\u4efd\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u5728 importMydb.sql \u6587\u4ef6\u4e2d\u751f\u6210 mydb1 \u548c mydb2 \u6570\u636e\u5e93\u4ee5\u53ca\u8868\u7684\u7ed3\u6784\u548c\u6570\u636e\u7684\u5907\u4efd\u3002importMydb.sql \u6587\u4ef6\u4f1a\u4fdd\u5b58\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff1a
./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db mydb1,mydb2 > importMydb.sql\n
\u793a\u4f8b 2
\u5982\u679c\u4f60\u60f3\u5c06\u6570\u636e\u5e93 mydb \u5185\u7684\u8868\u7684\u6570\u636e\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff0c\u6570\u636e\u5e93 mydb \u4e2d\u7684\u6240\u6709\u8868\u7684\u6570\u636e\u5c06\u4f1a\u4ee5 ${databaseName}_${tableName}.csv
\u7684\u683c\u5f0f\u5bfc\u51fa\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\uff0c\u751f\u6210\u6570\u636e\u5e93\u548c\u8868\u7ed3\u6784\u4ee5\u53ca\u5bfc\u5165\u7684 SQL \u8bed\u53e5\u5c06\u4f1a\u4fdd\u5b58\u5728 mydb.sql \u6587\u4ef6\u4e2d\uff1a
./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db mydb -csv > mydb.sql\n
\u793a\u4f8b 3
\u5982\u679c\u8981\u5728\u6570\u636e\u5e93\u4e2d\u6307\u5b9a\u751f\u6210\u67d0\u4e00\u4e2a\u8868\u6216\u8005\u67d0\u51e0\u4e2a\u8868\u7684\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u6570\u636e\u5e93 db1 \u4e2d t1 \u8868\u548c t2 \u8868\u7684\u7ed3\u6784\u548c\u6570\u636e\u5907\u4efd\uff0c\u4fdd\u5b58\u5728 tab2.sql \u6587\u4ef6\u4e2d\u3002
./mo-dump -u root -p 111 -db db1 -tbl t1,t2 > tab2.sql \n
\u793a\u4f8b 4
\u5982\u679c\u8981\u5728\u6570\u636e\u5e93\u4e2d\u67d0\u4e00\u4e2a\u8868\u6216\u8005\u67d0\u51e0\u4e2a\u8868\u7684\u7ed3\u6784\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u6570\u636e\u5e93 db1 \u4e2d t1 \u8868\u548c t2 \u8868\u7684\u7ed3\u6784\uff0c\u4fdd\u5b58\u5728 tab_nodata.sql \u6587\u4ef6\u4e2d\u3002
./mo-dump -u root -p 111 -db db1 -no-data -tbl t1,t2 > tab_nodata.sql\n
"},{"location":"MatrixOne/Develop/export-data/modump/#_2","title":"\u9650\u5236","text":"mo-dump
\u6682\u4e0d\u652f\u6301\u53ea\u5bfc\u51fa\u6570\u636e\u3002\u5982\u679c\u4f60\u60f3\u5728\u6ca1\u6709\u6570\u636e\u5e93\u548c\u8868\u7ed3\u6784\u7684\u60c5\u51b5\u4e0b\u751f\u6210\u6570\u636e\u7684\u5907\u4efd\uff0c\u90a3\u4e48\uff0c\u4f60\u9700\u8981\u624b\u52a8\u62c6\u5206 .sql
\u6587\u4ef6\u3002MatrixOne \u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u5bfc\u51fa\u6570\u636e\uff1a
SELECT INTO...OUTFILE
mo-dump
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SELECT INTO...OUTFILE
\u5bfc\u51fa\u6570\u636e\u3002
\u4f7f\u7528 SELECT...INTO OUTFILE
\u8bed\u6cd5\u53ef\u4ee5\u5c06\u8868\u6570\u636e\u5bfc\u51fa\u5230\u4e3b\u673a\u4e0a\u7684\u6587\u672c\u6587\u4ef6\u4e2d\u3002
SELECT...INTO OUTFILE
\u8bed\u6cd5\u662f SELECT
\u8bed\u6cd5\u548c INTO OUTFILE filename
\u7684\u7ed3\u5408\u3002\u9ed8\u8ba4\u8f93\u51fa\u683c\u5f0f\u4e0e LOAD DATA
\u547d\u4ee4\u76f8\u540c\u3002\u56e0\u6b64\uff0c\u4ee5\u4e0b\u8bed\u53e5\u662f\u5c06\u540d\u79f0\u4e3a test \u7684\u8868\u5bfc\u51fa\u5230\u76ee\u5f55\u8def\u5f84\u4e3a /root/test \u7684. csv \u6587\u4ef6\u4e2d\u3002
mysql> SELECT * FROM TEST\n -> INTO OUTFILE '/root/test.csv';\n
\u4f60\u53ef\u4ee5\u91c7\u7528\u591a\u79cd\u5f62\u5f0f\u548c\u9009\u9879\u66f4\u6539\u8f93\u51fa\u683c\u5f0f\uff0c\u7528\u4e8e\u8868\u793a\u5982\u4f55\u5f15\u7528\u3001\u5206\u9694\u5217\u548c\u8bb0\u5f55\u3002
\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u4ee5. csv \u683c\u5f0f\u5bfc\u51fa TEST \u8868\uff0c\u4e0b\u9762\u7684\u4ee3\u7801\u884c\u662f\u7528\u56de\u8f66\u6362\u884c\u8fdb\u884c\u5c55\u793a\u7684\uff1a
mysql> SELECT * FROM TEST INTO OUTFILE '/root/test.csv'\n -> FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n -> LINES TERMINATED BY '\\r\\n';\n
SELECT ... INTO OUTFILE
\u7279\u6027\u5982\u4e0b\uff1a
\u5bfc\u51fa\u7684\u6587\u4ef6\u662f\u7531 MatrixOne \u670d\u52a1\u76f4\u63a5\u521b\u5efa\u7684\uff0c\u56e0\u6b64\u547d\u4ee4\u884c\u4e2d\u7684 filename
\u5e94\u8be5\u6307\u5411\u4f60\u9700\u8981\u6587\u4ef6\u5b58\u5165\u7684\u670d\u52a1\u5668\u4e3b\u673a\u7684\u4f4d\u7f6e\u3002MatrixOne \u6682\u4e0d\u652f\u6301\u5c06\u6587\u4ef6\u5bfc\u51fa\u5230\u5ba2\u6237\u7aef\u6587\u4ef6\u7cfb\u7edf\u3002
SELECT ... INTO OUTFILE
\u662f\u7528\u4e8e\u5c06\u68c0\u7d22\u51fa\u6765\u7684\u6570\u636e\u6309\u683c\u5f0f\u5bfc\u51fa\u5230\u6587\u4ef6\u4e2d\uff0c\u5373\u9700\u8981\u5bfc\u51fa\u7684\u6587\u4ef6\u662f\u7531 MatrixOne \u670d\u52a1\u76f4\u63a5\u521b\u5efa\uff0c\u5bfc\u51fa\u7684\u6587\u4ef6\u53ea\u80fd\u4f4d\u4e8e MatrixOne \u6240\u5728\u7684\u670d\u52a1\u5668\u4e3b\u673a\u4e0a\uff0c\u6240\u4ee5\u4f60\u5fc5\u987b\u5f97\u6709\u767b\u5f55 MatrixOne \u6240\u5728\u7684\u670d\u52a1\u5668\u4e3b\u673a\u7684\u7528\u6237\u540d\u5bc6\u7801\uff0c\u5e76\u4e14\u4f60\u6709\u6743\u9650\u53ef\u4ee5\u4ece MatrixOne \u68c0\u7d22\u6587\u4ef6\u3002
\u4f60\u5fc5\u987b\u6709\u6267\u884c SELECT
\u7684\u6743\u9650\u3002
\u68c0\u67e5\u6587\u4ef6\u9700\u8981\u5bfc\u51fa\u5230\u7684\u76ee\u5f55\u91cc\u4e0d\u8981\u6709\u91cd\u540d\u7684\u6587\u4ef6\uff0c\u5426\u5219\u4f1a\u88ab\u65b0\u5bfc\u51fa\u7684\u6587\u4ef6\u8986\u76d6\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
Note
\u5982\u679c\u4f60\u662f\u901a\u8fc7 docker
\u5b89\u88c5\u7684 MatrixOne\uff0c\u90a3\u4e48\u5bfc\u51fa\u76ee\u5f55\u9ed8\u8ba4\u4f4d\u4e8e docker \u955c\u50cf\u4e2d\u3002\u5982\u679c\u4f60\u8981\u9700\u8981\u6302\u8f7d\u672c\u5730\u76ee\u5f55\uff0c\u53c2\u89c1\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\uff1a\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84 ${local_data_path}/mo-data \u6302\u8f7d\u5230 MatrixOne Docker \u955c\u50cf\u4e2d\uff0c\u5e76\u6620\u5c04\u5230 /mo-data \u8def\u5f84\u4e0b\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 Docker Mount Volume tutorial\u3002
sudo docker run --name <name> --privileged -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:0.8.0\n
"},{"location":"MatrixOne/Develop/export-data/select-into-outfile/#_4","title":"\u6b65\u9aa4","text":"\u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u6570\u636e\u8868\uff1a
create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\ninsert into user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\nselect * from user;\n+------+-----------+------+\n| id | user_name | sex |\n+------+-----------+------+\n| 1 | weder | man |\n| 2 | tom | man |\n| 3 | wederTom | man |\n+------+-----------+------+\n
\u5bf9\u4e8e\u4f7f\u7528\u6e90\u4ee3\u7801\u6216\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684\u65b9\u5f0f\u5b89\u88c5\u6784\u5efa MatrixOne\uff0c\u5c06\u8868\u5bfc\u51fa\u5230\u672c\u5730\u76ee\u5f55\uff0c\u4f8b\u5982 ~/tmp/export_demo/export_datatable.txt\uff0c\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
select * from user into outfile '~/tmp/export_demo/export_datatable.txt'\n
\u4f7f\u7528 Docker \u5b89\u88c5\u542f\u52a8 MatrixOne\uff0c\u5bfc\u51fa\u5230\u4f60\u6302\u8f7d\u7684\u5bb9\u5668\u76ee\u5f55\u8def\u5f84\uff0c\u5982\u4e0b\u4f8b\u6240\u793a\u3002\u5176\u4e2d\u76ee\u5f55 mo-data \u6307\u7684\u662f\u672c\u5730\u8def\u5f84 ~/tmp/docker_export_demo/mo-data\u3002
select * from user into outfile 'mo-data/export_datatable.txt';\n
\u5230\u4f60\u672c\u5730 export_datatable.txt \u6587\u4ef6\u4e0b\u67e5\u770b\u5bfc\u51fa\u60c5\u51b5\uff1a
id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\n3,\"wederTom\",\"man\"\n
\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u5220\u9664\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/delete-data/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/delete-data/#sql","title":"\u5220\u9664\u6570\u636e SQL \u8bed\u53e5","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e09\u79cd\u65b9\u5f0f\u5220\u9664\u6570\u636e\uff1aDROP TABLE
\u3001TRUNCATE TABLE
\u548c DELETE TABLE
\u3002
\u4e09\u8005\u7684\u533a\u522b\u662f\uff1a
DELETE TABLE
\uff1a\u5f53\u4f60\u8981\u5220\u9664\u90e8\u5206\u8bb0\u5f55\u65f6\uff0c\u7528 DELETE TABLE
\u3002TRUNCATE TABLE
\uff1a\u5f53\u4f60\u4ecd\u8981\u4fdd\u7559\u8be5\u8868\uff0c\u8868\u7684\u7ed3\u6784\u3001\u7d22\u5f15\u548c\u7ea6\u675f\u7b49\u90fd\u9700\u8981\u4fdd\u6301\u4e0d\u53d8\uff0c\u4f46\u8981\u5220\u9664\u6240\u6709\u8bb0\u5f55\u65f6\uff0c\u7528 TRUNCATE TABLE
\u3002DROP TABLE
\uff1a\u5f53\u4f60\u4e0d\u518d\u9700\u8981\u8be5\u8868\u65f6\uff0c\u7528 DROP TABLE
\u3002DELETE
","text":"DELETE FROM tbl_name [[AS] tbl_alias]\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
DELETE FROM tbl_name
\uff1a\u6307\u5b9a\u8981\u4ece\u8868\u4e2d\u5220\u9664\u6570\u636e\u7684\u76ee\u6807\u8868\u3002tbl_name \u662f\u8868\u7684\u540d\u79f0\u3002
[AS] tbl_alias
\uff08\u53ef\u9009\uff09\uff1a\u53ef\u4ee5\u4f7f\u7528 AS \u5173\u952e\u5b57\u4e3a\u76ee\u6807\u8868\u6307\u5b9a\u4e00\u4e2a\u8868\u522b\u540d\uff08tbl_alias\uff09\u3002\u522b\u540d\u662f\u53ef\u9009\u7684\uff0c\u7528\u4e8e\u7b80\u5316\u67e5\u8be2\u5e76\u5728\u8bed\u53e5\u4e2d\u5f15\u7528\u8868\u3002
[WHERE where_condition]
\uff08\u53ef\u9009\uff09\uff1aWHERE \u5b50\u53e5\u7528\u4e8e\u6307\u5b9a\u5220\u9664\u6570\u636e\u7684\u6761\u4ef6\u3002\u53ea\u6709\u6ee1\u8db3\u6307\u5b9a\u6761\u4ef6\u7684\u884c\u624d\u4f1a\u88ab\u5220\u9664\u3002where_condition \u662f\u4e00\u4e2a\u903b\u8f91\u8868\u8fbe\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u5b9a\u4e49\u6761\u4ef6\u3002
[ORDER BY ...]
\uff08\u53ef\u9009\uff09\uff1aORDER BY \u5b50\u53e5\u7528\u4e8e\u6309\u6307\u5b9a\u7684\u5217\u5bf9\u8981\u5220\u9664\u7684\u884c\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\uff0c\u5e76\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002\u6392\u5e8f\u5c06\u5f71\u54cd\u5220\u9664\u7684\u884c\u7684\u987a\u5e8f\u3002
[LIMIT row_count]
\uff08\u53ef\u9009\uff09\uff1aLIMIT \u5b50\u53e5\u7528\u4e8e\u9650\u5236\u4ece\u8868\u4e2d\u5220\u9664\u7684\u884c\u6570\u3002\u5b83\u6307\u5b9a\u8981\u5220\u9664\u7684\u6700\u5927\u884c\u6570\uff08row_count\uff09\u3002\u5982\u679c\u672a\u6307\u5b9a LIMIT \u5b50\u53e5\uff0c\u5219\u5c06\u5220\u9664\u6ee1\u8db3 WHERE \u6761\u4ef6\u7684\u6240\u6709\u884c\u3002
TRUNCATE
","text":"> TRUNCATE [TABLE] table_name;\n
TRUNCATE
\u8bed\u53e5\u7528\u4e8e\u5220\u9664\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\uff0c\u4fdd\u7559\u8868\u7684\u7ed3\u6784\u3002\u5b83\u5c06\u5feb\u901f\u6e05\u7a7a\u8868\uff0c\u800c\u4e0d\u662f\u9010\u884c\u5220\u9664\u6570\u636e\u3002
[TABLE]
\uff08\u53ef\u9009\uff09\u5173\u952e\u5b57\u7528\u4e8e\u63d0\u4f9b\u66f4\u6e05\u6670\u7684\u8bed\u6cd5\uff0c\u4f46\u5728\u5927\u591a\u6570\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\u53ef\u4ee5\u7701\u7565\u3002table_name
\u662f\u8981\u8fdb\u884c\u64cd\u4f5c\u7684\u76ee\u6807\u8868\u7684\u540d\u79f0\u3002DROP
","text":"> DROP TABLE [IF EXISTS] [db.]name\n
DROP TABLE
\u8bed\u53e5\u7528\u4e8e\u5b8c\u5168\u5220\u9664\u6570\u636e\u5e93\u4e2d\u7684\u8868\uff0c\u5305\u62ec\u8868\u7684\u7ed3\u6784\u548c\u6570\u636e\u3002
[IF EXISTS]
\uff08\u53ef\u9009\uff09\u5173\u952e\u5b57\u8868\u793a\u5982\u679c\u8868\u5b58\u5728\uff0c\u5219\u6267\u884c\u5220\u9664\u64cd\u4f5c\u3002\u5982\u679c\u7701\u7565\u6b64\u5173\u952e\u5b57\uff0c\u5e76\u4e14\u8981\u5220\u9664\u7684\u8868\u4e0d\u5b58\u5728\uff0c\u5c06\u5f15\u53d1\u9519\u8bef\u3002[db.]
\uff08\u53ef\u9009\uff09\u6307\u5b9a\u8868\u6240\u5728\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6570\u636e\u5e93\u540d\u79f0\uff0c\u5219\u9ed8\u8ba4\u4e3a\u5f53\u524d\u6570\u636e\u5e93\u3002name
\u662f\u8981\u5220\u9664\u7684\u8868\u7684\u540d\u79f0\u3002\u5728\u9ed8\u8ba4\u914d\u7f6e\u4e0b\uff0cMatrixOne \u5728\u6267\u884c DELETE
\u3001DROP
\u6216 TRUNCATE
\u8bed\u53e5\u540e\uff0c\u5e76\u4e0d\u4f1a\u7acb\u5373\u4ece\u78c1\u76d8\u4e2d\u5220\u9664\u6570\u636e\uff0c\u800c\u662f\u5c06\u8fd9\u4e9b\u6570\u636e\u6807\u8bb0\u4e3a\u53ef\u5220\u9664\u72b6\u6001\u3002\u968f\u540e\uff0cGC\uff08\u5783\u573e\u56de\u6536\uff09\u673a\u5236\u4f1a\u5b9a\u671f\u8fdb\u884c\u626b\u63cf\uff0c\u5e76\u6e05\u7406\u4e0d\u518d\u9700\u8981\u7684\u65e7\u6570\u636e\u3002
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5783\u573e\u56de\u6536\u673a\u5236\u6bcf\u9694 30 \u5206\u949f\u8fdb\u884c\u4e00\u6b21\u626b\u63cf\u3002\u6bcf\u6b21\u626b\u63cf\u4f1a\u67e5\u627e\u8d85\u8fc7 1 \u5c0f\u65f6\u901a\u8fc7 SQL \u8bed\u53e5\u88ab\u5220\u9664\u7684\u6570\u636e\uff0c\u5e76\u5f00\u59cb\u6e05\u7406\u64cd\u4f5c\uff0c\u4ee5\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002\u5b8c\u6210\u6240\u6709\u6e05\u7406\u7684\u6700\u957f\u5468\u671f\u4e3a 90 \u5206\u949f\u3002\u56e0\u6b64\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6267\u884c DELETE
\u3001DROP
\u6216 TRUNCATE
\u8bed\u53e5\u5e76\u4e0d\u4f1a\u7acb\u5373\u51cf\u5c11\u78c1\u76d8\u4f7f\u7528\u91cf\u3002\u53ea\u6709\u5728\u5783\u573e\u56de\u6536\u8fc7\u7a0b\u4e2d\uff0c\u88ab\u6807\u8bb0\u4e3a\u53ef\u5220\u9664\u7684\u6570\u636e\u624d\u4f1a\u88ab\u6e05\u7406\u5e76\u91ca\u653e\u7a7a\u95f4\u3002
-- \u521b\u5efa\u8868\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO employees (id, name, department)\nVALUES (1, 'John Doe', 'HR'),\n(2, 'Jane Smith', 'Marketing'),\n(3, 'Mike Johnson', 'IT'),\n(4, 'Emily Brown', 'Finance');\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id | name | department |\n+------+--------------+------------+\n| 1 | John Doe | HR |\n| 2 | Jane Smith | Marketing |\n| 3 | Mike Johnson | IT |\n| 4 | Emily Brown | Finance |\n+------+--------------+------------+\n4 rows in set (0.01 sec)\n\n-- \u5220\u9664\u90e8\u5206\u6570\u636e\nmysql> DELETE FROM employees WHERE department = 'IT';\nQuery OK, 1 row affected (0.01 sec)\n\n-- \u67e5\u770b\u5220\u9664\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+-------------+------------+\n| id | name | department |\n+------+-------------+------------+\n| 1 | John Doe | HR |\n| 2 | Jane Smith | Marketing |\n| 4 | Emily Brown | Finance |\n+------+-------------+------------+\n3 rows in set (0.00 sec)\n
-- \u521b\u5efa\u8868\nCREATE TABLE orders (\norder_id INT PRIMARY KEY,\ncustomer_name VARCHAR(50),\norder_date DATE\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO orders (order_id, customer_name, order_date)\nVALUES (1, 'John Doe', '2022-01-01'),\n(2, 'Jane Smith', '2022-02-01'),\n(3, 'Mike Johnson', '2022-03-01'),\n(4, 'Emily Brown', '2022-04-01'),\n(5, 'David Wilson', '2022-05-01');\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n| 1 | John Doe | 2022-01-01 |\n| 2 | Jane Smith | 2022-02-01 |\n| 3 | Mike Johnson | 2022-03-01 |\n| 4 | Emily Brown | 2022-04-01 |\n| 5 | David Wilson | 2022-05-01 |\n+----------+---------------+------------+\n5 rows in set (0.01 sec)\n\n-- \u5220\u9664\u6700\u65e9\u7684\u4e24\u4e2a\u8ba2\u5355\nmysql> DELETE FROM orders\nWHERE order_id IN (\nSELECT order_id\nFROM orders\nORDER BY order_date\nLIMIT 2);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- \u67e5\u770b\u5220\u9664\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM orders;\n+----------+---------------+------------+\n| order_id | customer_name | order_date |\n+----------+---------------+------------+\n| 3 | Mike Johnson | 2022-03-01 |\n| 4 | Emily Brown | 2022-04-01 |\n| 5 | David Wilson | 2022-05-01 |\n+----------+---------------+------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/import-data/insert-data/","title":"INSERT \u63d2\u5165","text":"\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u63d2\u5165\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/insert-data/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into","title":"INSERT INTO \u8bed\u53e5","text":"INSERT INTO
\u8bed\u53e5\u6709\u4ee5\u4e0b\u5199\u6cd5\uff1a
\u6307\u5b9a\u8981\u63d2\u5165\u7684\u5217\u540d\u548c\u503c\uff1a
INSERT INTO tbl_name (a,b,c) VALUES (1,2,3);\n
\u5982\u679c\u8981\u4e3a\u8868\u7684\u6240\u6709\u5217\u6dfb\u52a0\u503c\uff0c\u5219\u4e0d\u9700\u8981\u5728 SQL \u67e5\u8be2\u4e2d\u6307\u5b9a\u5217\u540d\u3002\u5fc5\u987b\u786e\u4fdd\u503c\u7684\u987a\u5e8f\u4e0e\u8868\u4e2d\u5217\u7684\u987a\u5e8f\u76f8\u540c\u3002INSERT INTO
\u8bed\u6cd5\u5982\u4e0b\uff1a
INSERT INTO tbl_name VALUES (1,2,3);\n
\u4f7f\u7528 INSERT...VALUES...
\u8bed\u53e5\u53ef\u4ee5\u63d2\u5165\u591a\u884c\u3002\u8bed\u53e5\u4e2d\u5fc5\u987b\u5305\u542b\u591a\u4e2a\u7528\u9017\u53f7\u5206\u9694\u7684\u503c\u5217\u8868\uff0c\u503c\u5217\u8868\u7528\u5706\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u7528\u9017\u53f7\u5206\u9694\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3), (4,5,6), (7,8,9);\n
\u4ee5\u4e0b\u662f\u4ece Northwind \u793a\u4f8b\u6570\u636e\u5e93\u4e2d\u7684 Customers \u8868\u4e2d\u9009\u62e9\u7684\u8868\u793a\u4f8b\uff1a
CREATE TABLE Customers (\n CustomerID INT AUTO_INCREMENT NOT NULL,\n CustomerName VARCHAR(40) NOT NULL,\n ContactName VARCHAR(30) NULL,\n Address VARCHAR(60) NULL,\n City VARCHAR(15) NULL,\n PostalCode VARCHAR(10) NULL,\n Country VARCHAR(15) NULL,\n PRIMARY KEY (CustomerID)\n );\n
CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-into_1","title":"INSERT INTO \u793a\u4f8b","text":"\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5728 Customers \u8868\u4e2d\u63d2\u5165\u4e86\u4e00\u6761\u65b0\u8bb0\u5f55\uff1a
"},{"location":"MatrixOne/Develop/import-data/insert-data/#example","title":"Example","text":"INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)\nVALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal Tom B. Erichsen Skagen 21 Stavanger 4006 Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#_3","title":"\u4ec5\u5728\u6307\u5b9a\u5217\u4e2d\u63d2\u5165\u6570\u636e","text":"MatrixOne \u4e5f\u652f\u6301\u4f7f\u7528 SQL \u8bed\u53e5\u4ec5\u5728\u7279\u5b9a\u5217\u4e2d\u63d2\u5165\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/insert-data/#_4","title":"\u793a\u4f8b","text":"\u4f7f\u7528\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5c06\u63d2\u5165\u4e00\u6761\u65b0\u8bb0\u5f55\uff0c\u4f46\u53ea\u63d2\u5165 CustomerName\u3001City \u548c Country \u5217\u4e2d\u7684\u6570\u636e\uff0c\u540c\u65f6 CustomerID \u5c06\u81ea\u52a8\u66f4\u65b0\uff1a
INSERT INTO Customers (CustomerName, City, Country)\nVALUES ('Cardinal', 'Stavanger', 'Norway');\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 89 White Clover Markets Karl Jablonski 305 - 14th Ave. S. Suite 3B Seattle 98128 USA 90 Wilman Kala Matti Karttunen Keskuskatu 45 Helsinki 21240 Finland 91 Wolski Zbyszek ul. Filtrowa 68 Walla 01-012 Poland 92 Cardinal null null Stavanger null Norway"},{"location":"MatrixOne/Develop/import-data/insert-data/#insert-intoselect","title":"INSERT INTO...SELECT","text":"\u4f7f\u7528 INSERT INTO SELECT
\uff0c\u4f60\u53ef\u4ee5\u4ece SELECT
\u8bed\u53e5\u7684\u7ed3\u679c\u4e2d\u5feb\u901f\u63d2\u5165\u591a\u884c\u5230\u8868\u4e2d\uff0cSELECT
\u8bed\u53e5\u53ef\u4ee5\u4ece\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u4e2d\u8fdb\u884c\u9009\u62e9\u3002INSERT INTO SELECT
\u8bed\u53e5\u8981\u6c42\u6e90\u8868\u548c\u76ee\u6807\u8868\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u5339\u914d\u3002
\u4ece\u4e00\u4e2a\u8868\u590d\u5236\u6240\u6709\u5217\u5230\u53e6\u4e00\u4e2a\u8868\uff1a
INSERT INTO *table2*\nSELECT * FROM *table1\n*WHERE *condition*;\n
\u53ea\u4ece\u4e00\u4e2a\u8868\u590d\u5236\u4e00\u4e9b\u5217\u5230\u53e6\u4e00\u4e2a\u8868\uff1a
INSERT INTO *table2* (*column1*, *column2*, *column3*, ...)\nSELECT *column1*, *column2*, *column3*, ...\nFROM *table1*\nWHERE *condition*;\n
"},{"location":"MatrixOne/Develop/import-data/insert-data/#northwind","title":"Northwind \u6570\u636e\u5e93\u793a\u4f8b","text":"\u4ee5\u4e0b\u662f\u4ece Northwind \u793a\u4f8b\u6570\u636e\u5e93\u4e2d\u7684\u8868\u4e2d\u9009\u62e9\u7684\u8868\u793a\u4f8b\uff1a
CREATE TABLE Customers (\n CustomerID INT AUTO_INCREMENT NOT NULL,\n CustomerName VARCHAR(40) NOT NULL,\n ContactName VARCHAR(30) NULL,\n Address VARCHAR(60) NULL,\n City VARCHAR(15) NULL,\n PostalCode VARCHAR(10) NULL,\n Country VARCHAR(15) NULL,\n PRIMARY KEY (CustomerID)\n );\nCREATE TABLE Suppliers (\n SupplierID INT AUTO_INCREMENT NOT NULL,\n SupplierName VARCHAR(40) NOT NULL,\n ContactName VARCHAR(30) NULL,\n Address VARCHAR(60) NULL,\n City VARCHAR(15) NULL,\n PostalCode VARCHAR(10) NULL,\n Country VARCHAR(15) NULL,\n PRIMARY KEY (SupplierID)\n );\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 MexicoSuppliers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
SupplierID SupplierName ContactName Address City PostalCode Country 1 Exotic Liquid Charlotte Cooper 49 Gilbert St. Londona EC1 4SD UK 2 New Orleans Cajun Delights Shelley Burke P.O. Box 78934 New Orleans 70117 USA 3 Grandma Kelly's Homestead Regina Murphy 707 Oxford Rd. Ann Arbor 48104 USA"},{"location":"MatrixOne/Develop/import-data/insert-data/#_5","title":"\u793a\u4f8b","text":"\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5c06 Suppliers \u590d\u5236\u5230 Customers \u4e2d\uff0c\u540c\u65f6\u672a\u586b\u5145\u6570\u636e\u7684\u5217\u5c06\u586b\u5145\u4e3a NULL
\uff1a
INSERT INTO Customers (CustomerName, City, Country)\nSELECT SupplierName, City, Country FROM Suppliers;\n
Customers \u8868\u5c55\u793a\u51fa\u6765\u5982\u4e0b\u6240\u793a\uff1a
CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constituci\u00f3n 2222 M\u00e9xico D.F. 05021 Mexico 3 Antonio Moreno Taquer\u00eda Antonio Moreno Mataderos 2312 M\u00e9xico D.F. 05023 Mexico 4 Exotic Liquid null null Londona null UK 5 New Orleans Cajun Delights null null New Orleans null USA 6 Grandma Kelly's Homestead null null Ann Arbor null USA"},{"location":"MatrixOne/Develop/import-data/prepared/","title":"\u9884\u5904\u7406","text":"MatrixOne \u63d0\u4f9b\u5bf9\u670d\u52a1\u5668\u7aef\u9884\u5904\u7406\u8bed\u53e5\u7684\u652f\u6301\u3002\u5229\u7528\u5ba2\u6237\u7aef\u6216\u670d\u52a1\u5668\u4e8c\u8fdb\u5236\u534f\u8bae\u7684\u9ad8\u6548\u6027\uff0c\u5bf9\u53c2\u6570\u503c\u4f7f\u7528\u5e26\u6709\u5360\u4f4d\u7b26\u7684\u8bed\u53e5\u8fdb\u884c\u9884\u5904\u7406\uff0c\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u4f18\u70b9\u5982\u4e0b\uff1a
\u6bcf\u6b21\u6267\u884c\u8bed\u53e5\u65f6\u89e3\u6790\u8bed\u53e5\u7684\u6548\u7387\u63d0\u9ad8\u3002\u901a\u5e38\uff0c\u6570\u636e\u5e93\u5e94\u7528\u7a0b\u5e8f\u5904\u7406\u5927\u91cf\u51e0\u4e4e\u76f8\u540c\u7684\u8bed\u53e5\uff0c\u53ea\u66f4\u6539\u5b50\u53e5\u4e2d\u7684\u6587\u5b57\u6216\u53d8\u91cf\u503c\uff0c\u4f8b\u5982\u7528\u4e8e\u67e5\u8be2\u548c\u5220\u9664\u7684 WHERE
\u3001\u7528\u4e8e\u66f4\u65b0\u7684 SET
\u548c\u7528\u4e8e\u63d2\u5165\u7684 VALUES
\u3002
\u9632\u6b62 SQL \u6ce8\u5165\u3002\u53c2\u6570\u503c\u53ef\u4ee5\u5305\u542b\u672a\u8f6c\u4e49\u7684 SQL \u5f15\u53f7\u548c\u5206\u9694\u7b26\uff0c\u4e00\u6b21\u7f16\u8bd1\uff0c\u591a\u6b21\u8fd0\u884c\uff0c\u7701\u53bb\u4e86\u89e3\u6790\u4f18\u5316\u7b49\u8fc7\u7a0b\u3002
PREPARE
\u3001EXECUTE
\u3001\u548c DEALLOCATE PREPARE
\u8bed\u53e5","text":"PREPARE \u8bed\u53e5\u7684 SQL \u57fa\u672c\u8bed\u6cd5\u4e3b\u8981\u4e3a\u4ee5\u4e0b\u4e09\u79cd SQL \u8bed\u53e5\uff1a
PREPARE\uff1a\u6267\u884c\u9884\u7f16\u8bd1\u8bed\u53e5\u3002
EXECUTE\uff1a\u6267\u884c\u5df2\u9884\u7f16\u8bd1\u7684\u53e5\u3002
DEALLOCATE PREPARE\uff1a\u91ca\u653e\u4e00\u6761\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u3002
PREPARE stmt_name FROM preparable_stmt\n
\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0 preparable_stmt \u5305\u542b SQL \u8bed\u53e5\u6587\u672c\u7684\u5b57\u7b26\u4e32\u6587\u5b57\u6216\u7528\u6237\u53d8\u91cf\u3002\u6587\u672c\u5fc5\u987b\u4ee3\u8868\u5355\u4e2a\u8bed\u53e5\uff0c\u800c\u4e0d\u662f\u591a\u4e2a\u8bed\u53e5\u3002"},{"location":"MatrixOne/Develop/import-data/prepared/#_3","title":"\u6267\u884c\u9884\u5904\u7406\u8bed\u53e5","text":"EXECUTE stmt_name [USING @var_name [, @var_name] ...]\n
\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Develop/import-data/prepared/#_4","title":"\u5220\u9664\u9884\u5904\u7406\u8bed\u53e5","text":"{DEALLOCATE | DROP} PREPARE stmt_name\n
\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Develop/import-data/prepared/#_5","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u8868\nCREATE TABLE customers (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nemail VARCHAR(50)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO customers (id, name, email)\nVALUES (1, 'John Doe', 'john@example.com'),\n(2, 'Jane Smith', 'jane@example.com'),\n(3, 'Mike Johnson', 'mike@example.com');\n\n-- \u8fdb\u884c\u9884\u5904\u7406\nmysql> PREPARE stmt FROM 'SELECT * FROM customers WHERE id = ?';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u6267\u884c\u9884\u5904\u7406\nmysql> SET @id = 2;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> EXECUTE stmt USING @id;\n+------+------------+------------------+\n| id | name | email |\n+------+------------+------------------+\n| 2 | Jane Smith | jane@example.com |\n+------+------------+------------------+\n1 row in set (0.01 sec)\n\n-- \u5220\u9664\u9884\u5904\u7406\nmysql> DEALLOCATE PREPARE stmt;\nQuery OK, 0 rows affected (0.00 sec)\n
\u4e0a\u8ff0\u793a\u4f8b\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a customers
\u7684\u8868\uff0c\u8be5\u8868\u5305\u542b id
\u3001name
\u548c email
\u4e09\u4e2a\u5217\u3002\u63a5\u4e0b\u6765\uff0c\u63d2\u5165\u4e86\u4e09\u6761\u6570\u636e\u5230\u8be5\u8868\u4e2d\u3002
\u7136\u540e\uff0c\u4f7f\u7528 PREPARE
\u8bed\u53e5\u8fdb\u884c\u9884\u5904\u7406\uff0c\u5c06 SELECT * FROM customers WHERE id = ?
\u4f5c\u4e3a\u9884\u5904\u7406\u8bed\u53e5\u4fdd\u5b58\u5728 stmt
\u4e2d\u3002
\u6267\u884c\u9884\u5904\u7406\u65f6\uff0c\u5c06 @id
\u53d8\u91cf\u8bbe\u7f6e\u4e3a 2\uff0c\u5e76\u4f7f\u7528 EXECUTE
\u8bed\u53e5\u6267\u884c\u9884\u5904\u7406\uff0c\u5c06 @id
\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u9884\u5904\u7406\u8bed\u53e5\u3002
\u6700\u540e\uff0c\u4f7f\u7528 DEALLOCATE PREPARE
\u8bed\u53e5\u5220\u9664\u9884\u5904\u7406\uff0c\u91ca\u653e\u76f8\u5173\u8d44\u6e90\u3002
\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u8fdb\u884c\u6d41\u5f0f\u5bfc\u5165\u6570\u636e\u3002\u5177\u4f53\u6765\u8bf4\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA INLINE
\u8bed\u6cd5\u5bf9\u4ee5 csv \u683c\u5f0f\u7ec4\u7ec7\u7684\u5b57\u7b26\u4e32\u8fdb\u884c\u5bfc\u5165\uff0c\u5bfc\u5165\u901f\u5ea6\u8f83 INSERT
\u64cd\u4f5c\u66f4\u5feb\u3002
mysql> LOAD DATA INLINE FORMAT='csv' ,\nDATA=$XXX$\ncsv_string $XXX$\nINTO TABLE tbl_name;\n
\u53c2\u6570\u89e3\u91ca
FORMAT='csv'
\u8868\u793a\u540e\u9762 DATA
\u4e2d\u7684\u5b57\u7b26\u4e32\u6570\u636e\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u7684\u3002
DATA=$XXX$ csv_string $XXX$
\u4e2d\u7684 $XXX$
\u662f\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\u3002csv_string
\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u5b57\u7b26\u4e32\u6570\u636e\uff0c\u4ee5 \\n
\u6216\u8005 \\r\\n
\u4f5c\u4e3a\u6362\u884c\u7b26\u3002
Note
$XXX$
\u4e3a\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\uff0c\u6ce8\u610f\u6570\u636e\u7ed3\u675f\u5904\u7684 $XXX$
\u9700\u8981\u548c\u6700\u540e\u4e00\u884c\u6570\u636e\u653e\u5728\u540c\u4e00\u884c\uff0c\u6362\u884c\u53ef\u80fd\u5bfc\u81f4 ERROR 20101
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/stream-load/#mysql-client-load-data-inline","title":"MySQL Client \u4e2d\u4f7f\u7528LOAD DATA INLINE
\u547d\u4ee4\u5bfc\u5165\u6570\u636e","text":"\u4f60\u53ef\u4ee5\u4f7f\u7528 LOAD DATA INLINE
\u5c06\u6d41\u5f0f\u6570\u636e\u5bfc\u5165 MatrixOne\uff0c\u672c\u7ae0\u5c06\u4ecb\u7ecd\u5982\u4f55\u8fdb\u884c\u6d41\u5f0f\u5bfc\u5165\uff0c\u5e76\u4e14\u7ed9\u51fa\u5bfc\u5165 csv \u6570\u636e\u7684\u793a\u4f8b\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MatrixOne \u4e2d\u6267\u884c LOAD DATA INLINE
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868 user
:
CREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n)\n
\u5728 MySQL \u5ba2\u6237\u7aef\u6267\u884c LOAD DATA INLINE
\u8fdb\u884c\u6570\u636e\u5bfc\u5165\uff0c\u4ee5 csv \u683c\u5f0f\u5bfc\u5165\u6570\u636e\uff1a
mysql> LOAD DATA INLINE FORMAT='csv',\nDATA=$XXX$\nLihua,23,Shanghai\nBob,25,Beijing $XXX$ INTO TABLE user;\n
LOAD DATA INLINE
\u547d\u4ee4\u5bfc\u5165\u6570\u636e","text":"PyMySQL \u662f\u4e00\u4e2a\u7eaf Python MySQL \u5ba2\u6237\u7aef\u5e93\uff0c\u4e0b\u9762\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 PyMySQL \u8fdb\u884c LOAD DATA INLINE
\u64cd\u4f5c\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql\uff1a
pip3 install pymysql #If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff0c\u65b0\u5efa\u4e00\u4e2a\u540d\u79f0\u4e3a test \u6570\u636e\u5e93\u548c user \u7684\u6570\u636e\u8868\uff1a
mysql> create database test;\nuse test;\nCREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n);\n
\u521b\u5efa\u4e00\u4e2a\u7eaf\u6587\u672c\u6587\u4ef6 pymysql_load_data_inline.py \u5e76\u5c06\u4ee3\u7801\u5199\u5165\u6587\u4ef6\uff0c\u6b64\u5904\u4f5c\u4e3a\u793a\u8303 csv_string \u53ea\u5199\u4e86\u4e24\u884c\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u6d41\u5f0f\u6570\u636e\u51b3\u5b9a csv_string \u7684\u5927\u5c0f\uff1a
#!/usr/bin/python3\nimport pymysql\n\n# Open database connection\ndb = pymysql.connect(\n host='127.0.01',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n )\n# prepare a cursor object using cursor() method\ncursor = db.cursor()\ncsv_string=\"Lihua,23,Shanghai \\n Bob,25,Beijing\"\nsql=\"load data inline format='csv',data=$XXX$\" + csv_string + \" $XXX$ into table user;\"\n# execute SQL query using execute() method.\ncursor.execute(sql)\ndata=db.commit()\n# Fetch a single row using fetchone() method.\n# disconnect from server\ndb.close()\n
\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\uff0c\u5728\u7ec8\u7aef\u5185\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a
python3 pymysql_load_data_inline.py\n
\u6253\u5f00 mysql \u5ba2\u6237\u7aef\uff0c\u67e5\u8be2\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff0c\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from user;\n+-------+------+-----------+\n| name | age | city |\n+-------+------+-----------+\n| Lihua | 23 | Shanghai |\n| Bob | 25 | Beijing |\n+-------+------+-----------+\n2 rows in set (0.02 sec)\n
\u672c\u6587\u6863\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u8bed\u53e5\u5728 MatrixOne \u4e2d\u66f4\u65b0\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/update-data/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/update-data/#sql","title":"\u66f4\u65b0\u6570\u636e SQL \u8bed\u53e5","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u66f4\u65b0\u6570\u636e\uff1aUPDATE
\u548c INSERT ON DUPLICATE KEY UPDATE
\u3002
\u4e8c\u8005\u7684\u533a\u522b\u662f\uff1a
-UPDATE
\uff1a
INSERT ON DUPLICATE KEY UPDATE
\uff1a
\u5173\u952e\u533a\u522b\uff1a
UPDATE
","text":"UPDATE table_reference\n SET assignment_list\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
UPDATE table_reference
\uff1a\u6307\u5b9a\u8981\u66f4\u65b0\u6570\u636e\u7684\u76ee\u6807\u8868\u3002table_reference \u53ef\u4ee5\u662f\u5355\u4e2a\u8868\u6216\u591a\u4e2a\u8868\u7684\u8054\u63a5\u3002
SET assignment_list
\uff1a\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u503c\u3002assignment_list \u662f\u4e00\u4e2a\u7531\u5217\u540d\u548c\u76f8\u5e94\u7684\u503c\u7ec4\u6210\u7684\u5217\u8868\uff0c\u7528\u9017\u53f7\u5206\u9694\u3002\u6bcf\u4e2a\u5217\u540d\u540e\u9762\u4f7f\u7528\u7b49\u53f7\uff08=\uff09\u5c06\u5176\u4e0e\u8981\u66f4\u65b0\u7684\u65b0\u503c\u76f8\u5173\u8054\u3002
[WHERE where_condition]
\uff08\u53ef\u9009\uff09\uff1aWHERE \u5b50\u53e5\u7528\u4e8e\u6307\u5b9a\u66f4\u65b0\u6570\u636e\u7684\u6761\u4ef6\u3002\u53ea\u6709\u6ee1\u8db3\u6307\u5b9a\u6761\u4ef6\u7684\u884c\u624d\u4f1a\u88ab\u66f4\u65b0\u3002where_condition \u662f\u4e00\u4e2a\u903b\u8f91\u8868\u8fbe\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u903b\u8f91\u8fd0\u7b97\u7b26\u6765\u5b9a\u4e49\u6761\u4ef6\u3002
[ORDER BY ...]
\uff08\u53ef\u9009\uff09\uff1aORDER BY \u5b50\u53e5\u7528\u4e8e\u6309\u6307\u5b9a\u7684\u5217\u5bf9\u8981\u66f4\u65b0\u7684\u884c\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\uff0c\u5e76\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002\u6392\u5e8f\u5c06\u5f71\u54cd\u66f4\u65b0\u7684\u884c\u7684\u987a\u5e8f\u3002
[LIMIT row_count]
\uff08\u53ef\u9009\uff09\uff1aLIMIT \u5b50\u53e5\u7528\u4e8e\u9650\u5236\u8981\u66f4\u65b0\u7684\u884c\u6570\u3002\u5b83\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u6700\u5927\u884c\u6570\uff08row_count\uff09\u3002\u5982\u679c\u672a\u6307\u5b9a LIMIT \u5b50\u53e5\uff0c\u5219\u5c06\u66f4\u65b0\u6ee1\u8db3 WHERE \u6761\u4ef6\u7684\u6240\u6709\u884c\u3002
\u66f4\u65b0\u6570\u636e\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u8868\u3001\u8981\u66f4\u65b0\u7684\u5217\u548c\u503c\u3001\u66f4\u65b0\u7684\u6761\u4ef6\u4ee5\u53ca\u6392\u5e8f\u548c\u9650\u5236\uff0c\u4ee5\u4fbf\u6839\u636e\u9700\u6c42\u8fdb\u884c\u7075\u6d3b\u7684\u6570\u636e\u66f4\u65b0\u3002
"},{"location":"MatrixOne/Develop/import-data/update-data/#insert-on-duplicate-key-update","title":"INSERT ON DUPLICATE KEY UPDATE
","text":"> INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...
INSERT INTO
\u8bed\u53e5\u7528\u4e8e\u5411\u8868\u4e2d\u63d2\u5165\u65b0\u7684\u884c\u3002[db.]
\uff08\u53ef\u9009\uff09\u6307\u5b9a\u8868\u6240\u5728\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6570\u636e\u5e93\u540d\u79f0\uff0c\u5219\u9ed8\u8ba4\u4e3a\u5f53\u524d\u6570\u636e\u5e93\u3002table
\u662f\u8981\u63d2\u5165\u6570\u636e\u7684\u76ee\u6807\u8868\u7684\u540d\u79f0\u3002[(c1, c2, c3)]
\uff08\u53ef\u9009\uff09\u6307\u5b9a\u8981\u63d2\u5165\u7684\u5217\uff0c\u7528\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u4f7f\u7528\u9017\u53f7\u5206\u9694\u5217\u540d\u3002\u5982\u679c\u672a\u6307\u5b9a\u5217\u540d\uff0c\u5219\u5047\u5b9a\u5c06\u63d2\u5165\u8868\u4e2d\u6240\u6709\u53ef\u7528\u7684\u5217\u3002VALUES
\u5b50\u53e5\u6307\u5b9a\u8981\u63d2\u5165\u7684\u503c\u3002\u6bcf\u4e2a\u503c\u4e0e\u5bf9\u5e94\u7684\u5217\u4e00\u4e00\u5bf9\u5e94\uff0c\u7528\u9017\u53f7\u5206\u9694\uff0c\u653e\u5728\u62ec\u53f7\u4e2d\u3002\u53ef\u4ee5\u63d2\u5165\u591a\u884c\u6570\u636e\uff0c\u6bcf\u4e00\u884c\u7528\u9017\u53f7\u5206\u9694\u3002
[ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...]
ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u7528\u4e8e\u5728\u63d2\u5165\u6570\u636e\u65f6\u5904\u7406\u91cd\u590d\u952e\uff08Duplicate Key\uff09\u7684\u60c5\u51b5\u3002column1, column2, column3
\u7b49\u8868\u793a\u8981\u66f4\u65b0\u7684\u5217\u540d\uff0cvalue1, value2, value3
\u7b49\u8868\u793a\u8981\u66f4\u65b0\u7684\u5bf9\u5e94\u503c\u3002\u8fd9\u4e2a\u8bed\u6cd5\u7ed3\u6784\u5141\u8bb8\u5c06\u4e00\u884c\u6216\u591a\u884c\u6570\u636e\u63d2\u5165\u5230\u6307\u5b9a\u7684\u8868\u4e2d\u3002\u5982\u679c\u51fa\u73b0\u91cd\u590d\u952e\u7684\u60c5\u51b5\uff0c\u5373\u5df2\u5b58\u5728\u76f8\u540c\u952e\u503c\u7684\u884c\uff0c\u53ef\u4ee5\u9009\u62e9\u6267\u884c UPDATE
\u64cd\u4f5c\u6765\u66f4\u65b0\u8be5\u884c\u7684\u6570\u636e\u3002
\u8bf7\u6ce8\u610f\uff0c\u5728\u4f7f\u7528 INSERT INTO \u8bed\u53e5\u65f6\uff0c\u6839\u636e\u8868\u7684\u7ed3\u6784\u548c\u9700\u6c42\uff0c\u63d0\u4f9b\u76f8\u5e94\u7684\u5217\u540d\u548c\u5bf9\u5e94\u7684\u503c\u3002\u5982\u679c\u5b58\u5728\u91cd\u590d\u952e\u7684\u60c5\u51b5\uff0c\u5e76\u4e14\u4f7f\u7528\u4e86 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\uff0c\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u5bf9\u5e94\u7684\u503c\u3002
UPDATE
-- \u521b\u5efa\u8868\nCREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nsalary DECIMAL(10, 2)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO employees (id, name, department, salary)\nVALUES (1, 'John Doe', 'HR', 5000),\n(2, 'Jane Smith', 'Marketing', 6000),\n(3, 'Mike Johnson', 'IT', 7000),\n(4, 'Emily Brown', 'Finance', 8000),\n(5, 'David Wilson', 'HR', 5500);\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id | name | department | salary |\n+------+--------------+------------+---------+\n| 1 | John Doe | HR | 5000.00 |\n| 2 | Jane Smith | Marketing | 6000.00 |\n| 3 | Mike Johnson | IT | 7000.00 |\n| 4 | Emily Brown | Finance | 8000.00 |\n| 5 | David Wilson | HR | 5500.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.01 sec)\n\n-- \u66f4\u65b0\u6570\u636e\uff0c\u4f7f\u7528 UPDATE \u8bed\u53e5\u66f4\u65b0\u4e86\u90e8\u95e8\u4e3a'HR'\u7684\u524d\u4e24\u4e2a\u5458\u5de5\u7684\u85aa\u8d44\uff0c\u85aa\u8d44\u589e\u52a0\u4e86 10%\u3002WHERE \u5b50\u53e5\u6307\u5b9a\u4e86\u66f4\u65b0\u6570\u636e\u7684\u6761\u4ef6\uff0c\u53ea\u6709\u6ee1\u8db3\u90e8\u95e8\u4e3a'HR'\u7684\u884c\u624d\u4f1a\u88ab\u66f4\u65b0\u3002ORDER BY \u5b50\u53e5\u6309\u7167 id \u5217\u8fdb\u884c\u5347\u5e8f\u6392\u5e8f\uff0cLIMIT \u5b50\u53e5\u9650\u5236\u53ea\u66f4\u65b0\u4e24\u884c\u6570\u636e\u3002\nmysql> UPDATE employees\nSET salary = salary * 1.1\nWHERE department = 'HR'\nORDER BY id\nLIMIT 2;\nQuery OK, 2 rows affected (0.02 sec)\n\n-- \u67e5\u770b\u66f4\u65b0\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM employees;\n+------+--------------+------------+---------+\n| id | name | department | salary |\n+------+--------------+------------+---------+\n| 2 | Jane Smith | Marketing | 6000.00 |\n| 3 | Mike Johnson | IT | 7000.00 |\n| 4 | Emily Brown | Finance | 8000.00 |\n| 1 | John Doe | HR | 5500.00 |\n| 5 | David Wilson | HR | 6050.00 |\n+------+--------------+------------+---------+\n5 rows in set (0.00 sec)\n
INSERT ... ON DUPLICATE KEY UPDATE
-- \u521b\u5efa\u8868\nCREATE TABLE students (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\ngrade VARCHAR(10)\n);\n\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO students (id, name, age, grade)\nVALUES (1, 'John Doe', 18, 'A'),\n(2, 'Jane Smith', 17, 'B'),\n(3, 'Mike Johnson', 19, 'A'),\n(4, 'Emily Brown', 18, 'A');\n\n-- \u67e5\u770b\u521d\u59cb\u6570\u636e\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id | name | age | grade |\n+------+--------------+------+-------+\n| 1 | John Doe | 18 | A |\n| 2 | Jane Smith | 17 | B |\n| 3 | Mike Johnson | 19 | A |\n| 4 | Emily Brown | 18 | A |\n+------+--------------+------+-------+\n4 rows in set (0.01 sec)\n\n-- \u66f4\u65b0\u6570\u636e\nmysql> INSERT INTO students (id, name, age, grade)\nVALUES (2, 'Jane Smith', 18, 'A')\nON DUPLICATE KEY UPDATE age = VALUES(age), grade = VALUES(grade);\nQuery OK, 1 row affected (0.01 sec)\n\n-- \u67e5\u770b\u66f4\u65b0\u540e\u7684\u6570\u636e\nmysql> SELECT * FROM students;\n+------+--------------+------+-------+\n| id | name | age | grade |\n+------+--------------+------+-------+\n| 1 | John Doe | 18 | A |\n| 3 | Mike Johnson | 19 | A |\n| 4 | Emily Brown | 18 | A |\n| 2 | Jane Smith | 18 | A |\n+------+--------------+------+-------+\n4 rows in set (0.00 sec)\n
\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a students
\u7684\u8868\uff0c\u5305\u542b id
\u3001name
\u3001age
\u548c grade
\u56db\u4e2a\u5217\u3002\u7136\u540e\uff0c\u4f7f\u7528 INSERT INTO
\u8bed\u53e5\u63d2\u5165\u4e86\u56db\u884c\u5b66\u751f\u6570\u636e\u3002
\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528 SELECT \u8bed\u53e5\u67e5\u770b\u521d\u59cb\u6570\u636e\u3002\u7136\u540e\uff0c\u4f7f\u7528 INSERT INTO \u8bed\u53e5\u63d2\u5165\u4e86\u4e00\u884c\u5b66\u751f\u6570\u636e\uff0c\u5176\u4e2d id
\u4e3a 2 \u7684\u5b66\u751f\u5df2\u7ecf\u5b58\u5728\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u91cd\u590d\u952e\u7684\u60c5\u51b5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u6765\u66f4\u65b0\u8be5\u884c\u7684\u6570\u636e\u3002\u901a\u8fc7 VALUES \u51fd\u6570\uff0c\u6211\u4eec\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u5bf9\u5e94\u7684\u503c\u3002
\u6700\u540e\uff0c\u4f7f\u7528 SELECT
\u8bed\u53e5\u518d\u6b21\u67e5\u770b\u66f4\u65b0\u540e\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u770b\u5230 id
\u4e3a 2 \u7684\u5b66\u751f\u7684\u5e74\u9f84\u548c\u6210\u7ee9\u5df2\u7ecf\u88ab\u66f4\u65b0\u3002
S3\uff08Simple Storage Service\uff09\u5bf9\u8c61\u5b58\u50a8\u662f\u6307\u4e9a\u9a6c\u900a\u7684\u7b80\u5355\u5b58\u50a8\u670d\u52a1\u3002\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4e0e S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u6765\u5b58\u50a8\u51e0\u4e4e\u4efb\u4f55\u7c7b\u578b\u548c\u5927\u5c0f\u7684\u6570\u636e\uff0c\u5305\u62ec\u6570\u636e\u6e56\u3001\u4e91\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u548c\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089 S3 \u5bf9\u8c61\u670d\u52a1\uff0c\u4f60\u53ef\u4ee5\u5728 AWS \u4e2d\u67e5\u627e\u4e00\u4e9b\u57fa\u672c\u4ecb\u7ecd\u3002
AWS S3 \u5341\u591a\u5e74\u6765\u4e00\u76f4\u975e\u5e38\u6210\u529f\uff0c\u56e0\u6b64\u5b83\u6210\u4e3a\u4e86\u5bf9\u8c61\u5b58\u50a8\u7684\u6807\u51c6\u3002\u56e0\u6b64\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u516c\u6709\u4e91\u5382\u5546\u90fd\u63d0\u4f9b\u4e86\u517c\u5bb9 S3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
MatrixOne \u652f\u6301\u5c06\u6587\u4ef6\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u52a0\u8f7d\u5230\u6570\u636e\u5e93\u4e2d\u3002MatrixOne \u652f\u6301 AWS \u548c\u56fd\u5185\u4e3b\u6d41\u4e91\u5382\u5546\uff08\u963f\u91cc\u4e91\u3001\u817e\u8baf\u4e91\uff09\u3002
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u5bfc\u5165\u6570\u636e\uff1a
Load data
\u5c06\u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u4e2d\u3002\u6b64\u65b9\u6cd5\u4f1a\u5c06\u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4e2d\uff0c\u6240\u6709\u63a5\u4e0b\u6765\u7684\u67e5\u8be2\u90fd\u5c06\u5728 MatrixOne \u4e2d\u8fdb\u884c\u3002\u540c\u65f6\uff0c\u5982\u679c\u8981\u5bfc\u5165\u6765\u81ea\u516c\u6709\u4e91\uff08\u4f8b\u5982 AWS S3 \u6216\u963f\u91cc\u4e91 OSS\uff09\u7684\u6570\u636e\uff0c\u9700\u8981\u5177\u5907\u76f8\u5e94\u7684\u8bbf\u95ee\u6743\u9650\u3002\u901a\u5e38\u6709\u4e24\u79cd\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1a\u89d2\u8272\u8bbf\u95ee\u548c\u5bc6\u94a5\u8bbf\u95ee\u3002
\u89d2\u8272\u8bbf\u95ee\uff1a\u5728\u5b58\u50a8\u6570\u636e\u7684\u516c\u6709\u4e91\u8d26\u6237\u4e2d\u521b\u5efa\u4e00\u4e2a\u7279\u5b9a\u89d2\u8272\uff0c\u8be5\u89d2\u8272\u88ab\u6388\u6743\u8ba9 MatrixOne \u5e94\u7528\u4f7f\u7528\u4ee5\u83b7\u53d6\u6570\u636e\u7684\u6743\u9650\u3002\u8fd9\u79cd\u65b9\u5f0f\u66f4\u4e3a\u5b89\u5168\uff0c\u540c\u65f6\u4e5f\u66f4\u52a0\u4fbf\u4e8e\u7ba1\u7406\u548c\u8c03\u6574\u6570\u636e\u8bbf\u95ee\u6743\u9650\u3002
\u5bc6\u94a5\u8bbf\u95ee\uff1a\u901a\u8fc7\u4f7f\u7528\u62e5\u6709\u6570\u636e\u8bbf\u95ee\u6743\u9650\u7684\u7528\u6237\u7684 Access Key ID
\u548c Secret Access Key
\u6765\u83b7\u53d6\u6570\u636e\u3002\u8fd9\u79cd\u65b9\u5f0f\u76f8\u5bf9\u7b80\u5355\uff0c\u4f46\u4e0d\u591f\u5b89\u5168\uff0c\u56e0\u4e3a\u4e00\u65e6 Access Key ID
\u548c Secret Access Key
\u6cc4\u9732\uff0c\u53ef\u80fd\u4f1a\u9020\u6210\u4e25\u91cd\u540e\u679c\u3002
LOAD DATA
","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA\n| URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com Note:LOAD DATA
\u4ec5\u652f\u6301\u83b7\u53d6 AWS \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u548c\u963f\u91cc\u4e91\u5916\u7f51\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002 access_key_id Access key ID\u3002\u7528\u4e8e\u8eab\u4efd\u9a8c\u8bc1\u7684\u8bbf\u95ee\u5bc6\u94a5 ID\u3002 secret_access_key Secret access key\u3002\u4e0e\u8bbf\u95ee\u5bc6\u94a5 ID \u76f8\u5173\u8054\u7684\u5bc6\u94a5\u3002 bucket \u6307\u5b9a S3 \u5b58\u50a8\u4e2d\u7684\u6876\uff08Bucket\uff09 role_arn AWS \u89d2\u8272\u7684 Amazon \u8d44\u6e90\u540d\u79f0\uff08ARN\uff09\uff0c\u901a\u5e38\u7528\u4e8e\u8de8\u8d26\u6237\u8bbf\u95ee\u3002Note: \u63a8\u8350\u4f7f\u7528\u89d2\u8272\u8bbf\u95ee\u7684\u65b9\u5f0f\u3002\u5982\u679c\u4f60\u9009\u62e9\u89d2\u8272\u8bbf\u95ee\u7684\u65b9\u5f0f\uff0c\u5219\u65e0\u9700\u586b\u5199 access_key_id
\u548c secret_access_key
\uff0c\u4ec5\u586b\u5199\u53c2\u6570 role_arn
\u3002 external_id \u7528\u4e8e\u4e0e\u89d2\u8272 ARN \u4e00\u8d77\u4f7f\u7528\u7684\u5916\u90e8 ID\u3002 filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002 \u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
# LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"bucket\"='test-load-mo', \"role_arn\"='xxxx', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"bucket\"='test-load-data', \"role_arn\"='xxxx', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
# LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-mo', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-data', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression\nLOAD DATA URL s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
Note
MatrixOne \u63d0\u4f9b\u4e86 S3 \u9a8c\u8bc1\u4fe1\u606f\u7684\u5b89\u5168\u4fdd\u8bc1\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u654f\u611f\u4fe1\u606f\u5728\u7cfb\u7edf\u8868\uff08statement_info\uff09\u8bb0\u5f55\u91cc\u5c06\u88ab\u9690\u85cf\uff0c\u4fdd\u8bc1\u4f60\u7684\u8d26\u6237\u5b89\u5168\u3002
\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4ece AWS S3 \u52a0\u8f7d csv \u6587\u4ef6\u7684\u8fc7\u7a0b\u3002
\u5982\u679c\u4f60\u5df2\u7ecf\u62e5\u6709\u4e00\u4e2a AWS \u8d26\u6237\u5e76\u4e14\u5df2\u7ecf\u5728\u4f60\u7684 S3 \u670d\u52a1\u4e2d\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u90a3\u4e48\u8bf7\u7ee7\u7eed\u9605\u8bfb\u672c\u6559\u7a0b\u7ae0\u8282\u3002
\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u8bf7\u5148\u6ce8\u518c\u5e76\u4e0a\u4f20\u4f60\u7684\u6570\u636e\u6587\u4ef6\uff1b\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b AWS S3 \u5b98\u65b9\u6559\u7a0b\u3002\u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u60f3\u8981\u4e0a\u4f20\u5230\u963f\u91cc\u4e91 OSS \u6216\u8005\u817e\u8baf\u4e91 COS \u4e0a\uff0c\u90a3\u4e48\u64cd\u4f5c\u6d41\u7a0b\u4e0e AWS S3 \u7c7b\u4f3c\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u8fdb\u5165 AWS S3 > buckets > \u521b\u5efa\u5b58\u50a8\u6876\uff0c\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u516c\u5171\u8bbf\u95ee\u6743\u9650\u7684\u5b58\u50a8\u6876 test-loading \u5e76\u4e0a\u4f20\u6587\u4ef6 char_varchar_1.csv\u3002
\u83b7\u53d6\u6216\u521b\u5efa\u4f60\u7684 AWS Access key\u3002\u8f93\u5165 Your Account Name > Security Credentials\u3002
\u8fdb\u5165\u5230 Security Credentials > Create access key\uff0c\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 Access key
\u548c Secret access key
\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u8868\uff0cSQL \u793a\u4f8b\u5982\u4e0b\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u6587\u4ef6\u5bfc\u5165 MatrixOne\uff1a
LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"bucket\"='test-loading', \"role_arn\"='xxxx\", \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
\u5bfc\u5165\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c SQL \u8bed\u53e5\u68c0\u67e5\u6587\u4ef6\u5bfc\u5165\u662f\u5426\u6210\u529f\uff1a
mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (0.03 sec)\n
create external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} [{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}];\n
Note
MatrixOne \u5f53\u524d\u4ec5\u652f\u6301\u5bf9\u5916\u90e8\u8868\u8fdb\u884c select
\uff0c\u6682\u4e0d\u652f\u6301 Delete
\uff0cinsert
\uff0cupdate
\u3002
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002\u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
\u6709\u5173\u5916\u90e8\u8868\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u521b\u5efa\u5916\u90e8\u8868\u3002
\u8bed\u6cd5\u793a\u4f8b\uff1a
## Create a external table for a .csv file from AWS S3\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n\n## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' ignore 1 lines;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/1.1-load-s3/#s3","title":"\u6559\u7a0b\uff1a\u4f7f\u7528 S3 \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868","text":"\u672c\u6559\u7a0b\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4f7f\u7528\u6765\u81ea AWS S3 \u7684. csv \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868\u7684\u6574\u4e2a\u8fc7\u7a0b\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u4e0b\u8f7d\u6570\u636e\u6587\u4ef6\u3002\u8fdb\u5165 AWS S3 > buckets\uff0c\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u516c\u5171\u8bbf\u95ee\u6743\u9650\u7684\u5b58\u50a8\u6876 test-loading \u5e76\u4e0a\u4f20\u6587\u4ef6 char_varchar_1.csv\u3002
\u83b7\u53d6\u6216\u521b\u5efa\u4f60\u7684 AWS Access key\u3002\u8f93\u5165 Your Account Name > Security Credentials\uff0c\u83b7\u53d6\u4f60\u73b0\u6709\u7684\u8bbf\u95ee\u5bc6\u94a5\u6216\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8bbf\u95ee\u5bc6\u94a5\u3002
\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 Access key
\u548c Secret access key
\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u6307\u5b9a S3 \u6587\u4ef6\u5230\u5916\u90e8\u8868\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u6570\u636e\u7684\u7ed3\u679c\u3002\u4f60\u5c06\u53ef\u4ee5\u770b\u5230\u67e5\u8be2\u901f\u5ea6\u660e\u663e\u6162\u4e8e\u4ece\u672c\u5730\u8868\u67e5\u8be2\u3002
select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (1.32 sec)\n
\uff08\u9009\u505a\uff09\u5982\u679c\u9700\u8981\u5c06\u5916\u90e8\u8868\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u6570\u636e\u8868\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\uff1a \u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u8868 t2\uff1a
create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u5916\u90e8\u8868 t1 \u5bfc\u5165\u5230 t2\uff1a
insert into t2 select * from t1;\n
MatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u5c06\u5927\u91cf\u884c\u63d2\u5165\u81f3 MatrixOne \u6570\u636e\u8868\uff0c\u4e5f\u652f\u6301\u4f7f\u7528 SOURCE
\u547d\u4ee4\u5c06\u8868\u7ed3\u6784\u548c\u6570\u636e\u5bfc\u5165\u6574\u4e2a\u6570\u636e\u5e93\u3002
LOAD DATA
","text":"MatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u4ece\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u6216 S3 \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u6279\u91cf\u5bfc\u5165 csv \u6587\u4ef6\u3001jsonline \u6587\u4ef6\u3002
\u6839\u636e\u6570\u636e\u6587\u4ef6\u7c7b\u578b\u4e0d\u540c\u7684\u60c5\u51b5\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u5bfc\u5165 csv \u548c jl \u683c\u5f0f\u3002
\u6839\u636e\u6570\u636e\u5b58\u50a8\u4f4d\u7f6e\u4e0d\u540c\u7684\u60c5\u51b5\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u4ece\u672c\u5730\u8fdb\u884c\u5bfc\u5165\u548c\u4ece\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff08Simple Storage Service, S3) \u5bfc\u5165\u3002
SOURCE
","text":"MatrixOne \u652f\u6301\u4f7f\u7528 SOURCE
\u547d\u4ee4\u4ece\u5916\u90e8 SQL \u811a\u672c\u6587\u4ef6\u6267\u884c SQL \u8bed\u53e5\u5bfc\u5165\u6574\u4e2a\u6570\u636e\u5e93\u7ed3\u6784\uff08\u5305\u62ec\u8868\u7ed3\u6784\u548c\u6570\u636e\uff09\u3002SOURCE
\u547d\u4ee4\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u53ef\u80fd\u6ca1\u6709 LOAD DATA
\u547d\u4ee4\u6027\u80fd\u9ad8\uff0c\u56e0\u4e3a\u5b83\u9700\u8981\u89e3\u6790\u548c\u6267\u884c\u6bcf\u4e2a SQL \u8bed\u53e5\u3002
LOAD DATA
\u5bfc\u5165\u6570\u636e\u7684\u53c2\u6570\u8bf4\u660e\u3002\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5728 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u65f6\u5982\u4f55\u5b8c\u6210 csv \u683c\u5f0f\u6570\u636e\u5bfc\u5165\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#_1","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
LOAD DATA LOCAL\nINFILE 'file_name'\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n]\n[LINES\n[STARTING BY 'string']\n[TERMINATED BY 'string']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#mysql-client-load-data","title":"MySQL Client \u4e2d\u4f7f\u7528Load data
\u547d\u4ee4\u5bfc\u5165\u6570\u636e","text":"\u4f60\u53ef\u4ee5\u4f7f\u7528 Load Data
\u4ece\u5927\u6570\u636e\u6587\u4ef6\u4e2d\u5bfc\u5165\u6570\u636e\uff0c\u672c\u7ae0\u5c06\u4ecb\u7ecd\u5982\u4f55\u5bfc\u5165 csv \u683c\u5f0f\u6587\u4ef6\u3002
Note: csv\uff08\u9017\u53f7\u5206\u9694\u503c\uff09\u6587\u4ef6\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u6587\u4ef6\u7c7b\u578b\uff0c\u53ef\u5728 Excel \u4e2d\u521b\u5efa\u6216\u7f16\u8f91\uff0ccsv \u6587\u4ef6\u4e0d\u662f\u91c7\u7528\u591a\u5217\u7684\u5f62\u5f0f\u5b58\u50a8\u4fe1\u606f\uff0c\u800c\u662f\u4f7f\u7528\u9017\u53f7\u5206\u9694\u7684\u5f62\u5f0f\u5b58\u50a8\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#_3","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-csv/#matrixone","title":"\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a","text":"\u5728 MatrixOne \u4e2d\u6267\u884c Load Data
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MySQL \u5ba2\u6237\u7aef\u5bf9\u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\u6267\u884c LOAD DATA
\uff1a
mysql> LOAD DATA INFILE '/tmp/xxx.csv'\nINTO TABLE table_name\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
\u5728 MatrixOne \u4e2d\u6267\u884c LOAD DATA LOCAL
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868\u3002
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h <mo-host-ip> -P 6001 -uroot -p111 --local-infile\n
\u5728 MySQL \u5ba2\u6237\u7aef\u5bf9\u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\u6267\u884c LOAD DATA LOCAL
\uff1a
mysql> LOAD DATA LOCAL INFILE '/tmp/xxx.csv'\nINTO TABLE table_name\nFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
Load data
","text":"\u5982\u679c\u4f60\u901a\u8fc7 Docker \u5b89\u88c5 MatrixOne\uff0c\u90a3\u4e48\u6587\u4ef6\u9ed8\u8ba4\u5b58\u50a8\u5728 Docker \u955c\u50cf\u4e2d\u3002\u5982\u679c\u4f60\u9700\u8981\u5c06\u6587\u4ef6\u5b58\u50a8\u5728\u672c\u5730\u76ee\u5f55\uff0c\u4f60\u9700\u8981\u5148\u5c06\u672c\u5730\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u3002
\u5728\u4ee5\u4e0b\u793a\u4f8b\u4e2d\uff0c\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u8def\u5f84 ~/tmp/docker_loaddata_demo/
\u6302\u8f7d\u5230 MatrixOne Docker \u955c\u50cf\uff0c\u5e76\u6620\u5c04\u5230 Docker \u5bb9\u5668\u5185\u7684 /ssb-dbgen-path
\u76ee\u5f55\u3002\u672c\u7bc7\u793a\u4f8b\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 Docker \u52a0\u8f7d\u6570\u636e\u3002
\u4e0b\u8f7d\u6570\u636e\u96c6\uff0c\u5e76\u4e14\u5c06\u6570\u636e\u96c6\u5b58\u50a8\u5230\u672c\u5730 ~/tmp/docker_loaddata_demo/ \u8def\u5f84\u4e0b\uff1a
cd ~/tmp/docker_loaddata_demo/\nwget https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
\u89e3\u538b\u6570\u636e\u96c6\uff1a
tar -jxvf lineorder_flat.tar.bz2\n
\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne\uff0c\u542f\u52a8\u65f6\u5c06\u5b58\u653e\u4e86\u6570\u636e\u6587\u4ef6\u7684\u76ee\u5f55 ~/tmp/docker_loaddata_demo/ \u6302\u8f7d\u5230\u5bb9\u5668\u7684\u67d0\u4e2a\u76ee\u5f55\u4e0b\uff0c\u8fd9\u91cc\u5bb9\u5668\u76ee\u5f55\u4ee5 /ssb-dbgen-path \u4e3a\u4f8b\uff1a
sudo docker run --name matrixone --privileged -d -p 6001:6001 -v ~/tmp/docker_loaddata_demo/:/ssb-dbgen-path:rw matrixorigin/matrixone:1.2.1\n
\u8fde\u63a5 MatrixOne \u670d\u52a1\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note: \u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\uff0c\u5373\u6570\u636e\u6587\u4ef6\u5728\u4f60\u6240\u4f7f\u7528\u7684\u5ba2\u6237\u7aef\u673a\u5668\u4e0a\u65f6\uff0c\u90a3\u4e48\u4f60\u8fde\u63a5 MatrixOne \u670d\u52a1\u4e3b\u673a\u9700\u8981\u4f7f\u7528\u547d\u4ee4\u884c\uff1amysql -h <mo-host-ip> -P 6001 -uroot -p111 --local-infile
\uff1b\u5e76\u4e14\u5bfc\u5165\u7684\u547d\u4ee4\u884c\u9700\u8981\u4f7f\u7528 LOAD DATA LOCAL INFILE
\u8bed\u6cd5\u3002
\u5728 MatrixOne \u4e2d\u65b0\u5efa\u8868 lineorder_flat\uff0c\u5e76\u4e14\u5c06\u6570\u636e\u96c6\u5bfc\u5165\u81f3 MatriOne\uff1a
mysql> create database if not exists ssb;\nmysql> use ssb;\nmysql> drop table if exists lineorder_flat;\nmysql> CREATE TABLE lineorder_flat(\n LO_ORDERKEY bigint key,\n LO_LINENUMBER int,\n LO_CUSTKEY int,\n LO_PARTKEY int,\n LO_SUPPKEY int,\n LO_ORDERDATE date,\n LO_ORDERPRIORITY char(15),\n LO_SHIPPRIORITY tinyint,\n LO_QUANTITY double,\n LO_EXTENDEDPRICE double,\n LO_ORDTOTALPRICE double,\n LO_DISCOUNT double,\n LO_REVENUE int unsigned,\n LO_SUPPLYCOST int unsigned,\n LO_TAX double,\n LO_COMMITDATE date,\n LO_SHIPMODE char(10),\n C_NAME varchar(25),\n C_ADDRESS varchar(25),\n C_CITY char(10),\n C_NATION char(15),\n C_REGION char(12),\n C_PHONE char(15),\n C_MKTSEGMENT char(10),\n S_NAME char(25),\n S_ADDRESS varchar(25),\n S_CITY char(10),\n S_NATION char(15),\n S_REGION char(12),\n S_PHONE char(15),\n P_NAME varchar(22),\n P_MFGR char(6),\n P_CATEGORY char(7),\n P_BRAND char(9),\n P_COLOR varchar(11),\n P_TYPE varchar(25),\n P_SIZE int,\n P_CONTAINER char(10)\n);\nmysql> load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u6570\u636e\u7684\u884c\u6570\uff1a
select count(*) from lineorder_flat;\n/*\n expected results:\n */\n+----------+\n| count(*) |\n+----------+\n| 10272594 |\n+----------+\n
\u52a0\u8f7d csv
\u683c\u5f0f\u652f\u6301 JSON \u7c7b\u578b\uff0c\u4f46\u662f\u9700\u8981\u786e\u4fdd JSON \u5185\u4e0d\u542b\u6709\u5b57\u6bb5\u7ec8\u6b62\u7b26\u53f7\uff0c\u5982\u679c JSON \u5185\u542b\u6709\u5b57\u6bb5\u7ec8\u6b62\u7b26\u53f7\uff0c\u90a3\u4e48 JSON \u9700\u8981\u7528\u53cc\u5f15\u53f7\u5305\u88f9\u8d77\u6765\u3002\u4f8b\u5982\uff1a
\"{\"a\":1, \"b\":2}\", 2
{\"a\":1, \"b\":2}, 2
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06 JSONLines \u683c\u5f0f\u6570\u636e\uff08\u5373 jl \u6216 jsonl \u6587\u4ef6\uff09\u5bfc\u5165 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#jsonlines_1","title":"\u6709\u5173 JSONLines \u683c\u5f0f","text":"JSON\uff08JavaScript Object Notation\uff09\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u3002\u4f60\u53ef\u4ee5\u53c2\u89c1\u5b98\u65b9\u6587\u6863\u83b7\u53d6\u66f4\u591a\u6709\u5173 JSON \u7684\u4fe1\u606f\u3002
JSONLines \u6587\u672c\u683c\u5f0f\uff0c\u4e5f\u79f0\u4e3a\u6362\u884c\u7b26\u5206\u9694\u7684 JSON\uff0c\u5b83\u662f\u4e00\u79cd\u66f4\u4e3a\u65b9\u4fbf\u5b58\u50a8\u7ed3\u6784\u5316\u7684\u6570\u636e\u683c\u5f0f\uff0c\u53ef\u4ee5\u4e00\u6b21\u5904\u7406\u4e00\u6761\u8bb0\u5f55\u3002\u5b83\u6bcf\u4e00\u884c\u90fd\u662f\u5b8c\u6574\u3001\u5408\u6cd5\u7684 JSON \u503c\uff1b\u5b83\u91c7\u7528 \\n
\u4f5c\u4e3a\u884c\u5206\u9694\u7b26\u3002JSONLines \u7684\u6bcf\u4e00\u884c\u90fd\u662f\u72ec\u7acb\u7684\uff0c\u56e0\u6b64\u884c\u7684\u5f00\u5934\u6216\u7ed3\u5c3e\u4e0d\u9700\u8981\u9017\u53f7\u3002JSONLines \u7684\u5168\u90e8\u5185\u5bb9\u4e5f\u4e0d\u9700\u8981\u7528 []
\u6216 {}
\u62ec\u8d77\u6765\u3002
JSONLines \u5bf9\u4e8e\u6570\u636e\u6d41\u6765\u8bf4\u66f4\u4e3a\u53cb\u597d\u3002\u56e0\u4e3a\u6bcf\u4e00\u4e2a\u65b0\u7684\u884c\u610f\u5473\u7740\u4e00\u4e2a\u5355\u72ec\u7684\u6761\u76ee\uff0c\u56e0\u6b64 JSON \u884c\u683c\u5f0f\u7684\u6587\u4ef6\u53ef\u4ee5\u6d41\u5f0f\u4f20\u8f93\u3002\u5b83\u4e0d\u9700\u8981\u81ea\u5b9a\u4e49\u89e3\u6790\u5668\u3002\u53ea\u9700\u8bfb\u53d6\u4e00\u884c\uff0c\u89e3\u6790\u4e3a JSON\uff0c\u518d\u8bfb\u53d6\u4e00\u884c\uff0c\u89e3\u6790\u4e3a JSON\uff0c\u4e00\u76f4\u5230\u5b8c\u6210\u3002
JSONLines \u683c\u5f0f\u6709\u4ee5\u4e0b\u4e09\u4e2a\u8981\u6c42\uff1a
UTF-8 \u7f16\u7801\uff1aJSON \u5141\u8bb8\u4ec5\u4f7f\u7528 ASCII \u8f6c\u4e49\u5e8f\u5217\u5bf9 Unicode \u5b57\u7b26\u4e32\u8fdb\u884c\u7f16\u7801\uff0c\u4f46\u662f\u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\uff0c\u8fd9\u4e9b\u8f6c\u4e49\u96be\u4ee5\u9605\u8bfb\u3002JSON Lines \u6587\u4ef6\u7684\u4f5c\u8005\u53ef\u4ee5\u9009\u62e9\u8f6c\u4e49\u5b57\u7b26\u6765\u5904\u7406\u7eaf ASCII \u6587\u4ef6\u3002
\u6bcf\u884c\u90fd\u662f\u4e00\u4e2a\u5408\u6cd5\u7684 JSON \u503c\uff1a\u6700\u5e38\u89c1\u7684\u503c\u662f\u5bf9\u8c61\u6216\u6570\u7ec4\uff0c\u4efb\u4f55 JSON \u503c\u90fd\u662f\u5408\u6cd5\u7684\u3002
\u884c\u5206\u9694\u7b26\u4e3a \\n
\uff1a\u7531\u4e8e\u5728\u89e3\u6790 JSON \u503c\u65f6\u4f1a\u9690\u5f0f\u5ffd\u7565\u5468\u56f4\u7684\u7a7a\u683c\u5728\u652f\u6301\u884c\u5206\u9694\u7b26 \\n
\u7684\u540c\u65f6\u4e5f\u652f\u6301\u201c\\r\\n\u201d\u3002
JSONLines \u683c\u5f0f\u53ea\u9700\u8981\u6bcf\u4e00\u884c\u90fd\u6709\u4e00\u4e2a\u6709\u6548\u7684 JSON \u503c\u3002\u4f46 MatrixOne \u9700\u8981\u66f4\u7ed3\u6784\u5316\u7684 JSONLines \u683c\u5f0f\uff0c\u5728 MatrixOne \u4e2d\u53ea\u5141\u8bb8\u5177\u6709\u76f8\u540c\u7c7b\u578b\u503c\u548c\u666e\u901a\u7ed3\u6784\u7684 JSON \u5bf9\u8c61\u6216 JSON \u6570\u7ec4\u3002\u5982\u679c\u60a8\u7684 JSONLines \u6587\u4ef6\u6709\u5d4c\u5957\u7ed3\u6784\uff0cMatrixOne \u6682\u65f6\u4e0d\u652f\u6301\u52a0\u8f7d\u5b83\u3002
\u4e00\u4e2a\u6709\u6548\u5bf9\u8c61 JSONLines \u793a\u4f8b\uff1a
{\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\"}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\"}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\"}\n
\u65e0\u6548\u5bf9\u8c61 JSONLines \u793a\u4f8b\uff08\u5177\u6709\u5d4c\u5957\u7ed3\u6784\uff09\uff1a
{\"id\":1,\"father\":\"Mark\",\"mother\":\"Charlotte\",\"children\":[\"Tom\"]}\n{\"id\":2,\"father\":\"John\",\"mother\":\"Ann\",\"children\":[\"Jessika\",\"Antony\",\"Jack\"]}\n{\"id\":3,\"father\":\"Bob\",\"mother\":\"Monika\",\"children\":[\"Jerry\",\"Karol\"]}\n
\u4e00\u4e2a\u6709\u6548\u6570\u7ec4 JSONLines \u793a\u4f8b\uff0c\u5b83\u66f4\u50cf\u662f csv \u683c\u5f0f\u3002
[\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n
\u65e0\u6548\u6570\u7ec4 JSONLines \u793a\u4f8b\uff08\u65e0\u6548\u539f\u56e0\u662f\u56e0\u4e3a\u6570\u636e\u7c7b\u578b\u548c\u5217\u53f7\u4e0d\u5339\u914d\uff09\uff1a
[\"Gilbert\", \"2013\", 24, true, 100]\n[\"Alexa\", \"2013\", \"twenty nine\", true]\n[\"May\", \"2012B\", 14, \"no\"]\n[\"Deloise\", \"2012A\", 19, true, 40]\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#_1","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA INFILE\n {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS]\n [PARALLEL {'TRUE' | 'FALSE'}];\n
LOAD DATA LOCAL INFILE\n {'filepath'='FILEPATH', 'compression'='COMPRESSION_FORMAT', 'format'='FILE_FORMAT', 'jsondata'='object'/'array'} INTO TABLE table_name [IGNORE x LINES/ROWS]\n [PARALLEL {'TRUE' | 'FALSE'}];\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u503c \u5fc5\u987b/\u53ef\u9009 \u63cf\u8ff0 filepath String \u5fc5\u987b \u6587\u4ef6\u8def\u5f84 compression auto/none/bz2/gzip/lz4 \u53ef\u9009 \u538b\u7f29\u683c\u5f0f format csv/jsonline \u53ef\u9009 \u52a0\u8f7d\u6587\u4ef6\u683c\u5f0f\uff0c\u9ed8\u8ba4 .csv jsondata object/array \u53ef\u9009 JSON \u6570\u636e\u683c\u5f0f\u3002\u5982\u679cformat
\u4e3a jsonline\uff0c\u5219\u5fc5\u987b\u6307\u5b9a jsondata table_name String \u5fc5\u987b \u9700\u52a0\u8f7d\u6570\u636e\u5230\u8868\u7684\u8868\u540d\u79f0 x Number \u53ef\u9009 \u52a0\u8f7d\u65f6\u8981\u5ffd\u7565\u7684\u884c JSONLines \u683c\u5f0f\u6570\u636e\u7684 DDL \u6307\u5357
\u5728\u5c06 JSONLines \u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u8868\u3002
\u7531\u4e8e JSON \u6570\u636e\u7c7b\u578b\u4e0e MatrixOne \u7684\u6570\u636e\u7c7b\u578b\u4e0d\u540c\uff0c\u53c2\u89c1\u4e0b\u8868\uff0c\u53ef\u4ee5\u67e5\u770b JSON \u6570\u636e\u7c7b\u578b\u5bf9\u5e94\u5230 MatrixOne \u4e2d\u65f6\u7684\u6570\u636e\u7c7b\u578b\uff1a
JSON \u7c7b\u578b MatrixOne \u4e2d\u7684\u6570\u636e\u7c7b\u578b String VARCHAR (\u5b9a\u957f\u5b57\u7b26\u4e32) String TEXT (\u957f\u6587\u672c\u6570\u636e) String DATETIME or TIMESTAMP (\u683c\u5f0f\u4e3a \"YYYY-MM-DD HH:MM:SS.XXXXXX\") String DATE (\u683c\u5f0f\u4e3a \"YYYY-MM-DD\") String TIME (\u683c\u5f0f\u4e3a \"HH-MM-SS.XXXXXX\") Number INT (\u6574\u6570) Number FLOAT \u6216 DOUBLE (\u6d6e\u70b9\u6570) Boolean BOOL(true/false) Object Json \u7c7b\u578b Array Json \u7c7b\u578b Null \u652f\u6301\u6240\u6709\u7c7b\u578b\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u5148\u4f7f\u7528 SQL \u8bed\u53e5\u4e3a JSONLines \u683c\u5f0f\u6587\u4ef6\u5148\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u8868\uff0c\u5982\u4e0b\u6240\u793a\uff1a
mysql> create table t1 (name varchar(100), session varchar(100), score int, completed bool);\n
[\"Name\", \"Session\", \"Score\", \"Completed\"]\n[\"Gilbert\", \"2013\", 24, true]\n[\"Alexa\", \"2013\", 29, true]\n[\"May\", \"2012B\", 14, false]\n[\"Deloise\", \"2012A\", 19, true]\n
\u793a\u4f8b
\u4ee5\u4e0b\u4ee3\u7801\u6bb5\u662f\u5c06 JSONLines \u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u7684\u5b8c\u6574 SQL \u793a\u4f8b\u3002
#Load a BZIP2 compressed jsonline object file\nload data infile {'filepath'='data.bzip2', 'compression'='bz2','format'='jsonline','jsondata'='object'} into table db.a\n\n#Load a plain jsonline array file\nload data infile {'filepath'='data.jl', 'format'='jsonline','jsondata'='array'} into table db.a\n\n#Load a gzip compressed jsonline array file and ignore the first line\nload data infile {'filepath'='data.jl.gz', 'compression'='gzip','format'='jsonline','jsondata'='array'} into table db.a ignore 1 lines;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-jsonline/#_2","title":"\u6559\u7a0b\u793a\u4f8b","text":"\u5728\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u52a0\u8f7d\u4e24\u4e2a\u5177\u6709\u5bf9\u8c61\u548c\u6570\u7ec4 json \u683c\u5f0f\u7684 jsonline \u6587\u4ef6\u3002
Note: \u672c\u6559\u7a0b\u4e2d\uff0c\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u3002\u5982\u679c\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 Load Data
\u8fdb\u884c\u6570\u636e\u5bfc\u5165\u3002
\u51c6\u5907\u6570\u636e\u3002\u4f60\u4e5f\u53ef\u4ee5\u4e0b\u8f7d\u4f7f\u7528\u6211\u4eec\u51c6\u5907\u597d\u7684 jl \u6587\u4ef6\u3002
\u6253\u5f00\u7ec8\u7aef\uff0c\u8fdb\u5165\u5230 jl \u6587\u4ef6\u6240\u5728\u76ee\u5f55\uff0c\u8f93\u5165\u4e0b\u9762\u7684\u547d\u4ee4\u884c\uff0c\u663e\u793a\u6587\u4ef6\u5185\u7684\u5177\u4f53\u5185\u5bb9\uff1a
> cd /$filepath\n> head jsonline_object.jl\n{\"col1\":true,\"col2\":1,\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":121.11}\n{\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\"}\n{\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col8\":\"121.11\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col1\":\"true\",\"col2\":\"1\",\"col3\":\"var\"}\n{\"col2\":1,\"col3\":\"var\",\"col1\":true,\"col6\":\"2020-09-07 00:00:00\",\"col7\":\"18\",\"col4\":\"2020-09-07\",\"col5\":\"2020-09-07 00:00:00\",\"col8\":121.11}\n> head jsonline_array.jl\n[true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\"]\n
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5\u5230 MatrixOne\u3002
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note: \u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u670d\u52a1\u5668\u5728\u4e0d\u540c\u7684\u673a\u5668\u4e0a\uff0c\u5373\u6570\u636e\u6587\u4ef6\u5728\u4f60\u6240\u4f7f\u7528\u7684\u5ba2\u6237\u7aef\u673a\u5668\u4e0a\u65f6\uff0c\u90a3\u4e48\u4f60\u8fde\u63a5 MatrixOne \u670d\u52a1\u4e3b\u673a\u9700\u8981\u4f7f\u7528\u547d\u4ee4\u884c\uff1amysql -h <mo-host-ip> -P <mo-host-ip> -uroot -p111 --local-infile
\uff1b\u5e76\u4e14\u5bfc\u5165\u7684\u547d\u4ee4\u884c\u9700\u8981\u4f7f\u7528 LOAD DATA LOCAL INFILE
\u8bed\u6cd5\u3002
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MatrixOne \u5efa\u8868\uff1a
create database db1;\nuse db1;\ndrop table if exists t1;\ncreate table t1(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\ndrop table if exists t2;\ncreate table t2(col1 bool,col2 int,col3 varchar, col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float);\n
\u5728 MySQL \u5ba2\u6237\u7aef\u5bf9\u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\u6267\u884c LOAD DATA
\uff0c\u5bfc\u5165 jsonline_object.jl \u548c jsonline_array.jl \u6587\u4ef6\uff1a
load data infile {'filepath'='$filepath/jsonline_object.jl','format'='jsonline','jsondata'='object'} into table t1;\nload data infile {'filepath'='$filepath/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t2;\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u7ed3\u679c\uff1a
select * from t1;\ncol1 col2 col3 col4 col5 col6 col7 col8\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\ntrue 1 var 2020-09-07 2020-09-07 00:00:00 2020-09-07 00:00:00 18 121.11\n
Note
\u5982\u679c\u60a8\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne\uff0c\u5f53\u4f60\u9700\u8981\u5bfc\u5165 JSONline \u6587\u4ef6\u65f6\uff0c\u8bf7\u786e\u4fdd\u4f60\u5df2\u5c06\u6570\u636e\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u3002\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b\u5bfc\u5165 csv \u683c\u5f0f\u6570\u636e\uff0c\u4e86\u89e3\u5982\u4f55\u4f7f\u7528 Docker \u6302\u8f7d\u6570\u636e\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/","title":"\u4ece\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165\u6587\u4ef6","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#_2","title":"\u6982\u8ff0","text":"S3\uff08Simple Storage Service\uff09\u5bf9\u8c61\u5b58\u50a8\u662f\u6307\u4e9a\u9a6c\u900a\u7684\u7b80\u5355\u5b58\u50a8\u670d\u52a1\u3002\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4e0e S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u6765\u5b58\u50a8\u51e0\u4e4e\u4efb\u4f55\u7c7b\u578b\u548c\u5927\u5c0f\u7684\u6570\u636e\uff0c\u5305\u62ec\u6570\u636e\u6e56\u3001\u4e91\u539f\u751f\u5e94\u7528\u7a0b\u5e8f\u548c\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089 S3 \u5bf9\u8c61\u670d\u52a1\uff0c\u4f60\u53ef\u4ee5\u5728 AWS \u4e2d\u67e5\u627e\u4e00\u4e9b\u57fa\u672c\u4ecb\u7ecd\u3002
AWS S3 \u5341\u591a\u5e74\u6765\u4e00\u76f4\u975e\u5e38\u6210\u529f\uff0c\u56e0\u6b64\u5b83\u6210\u4e3a\u4e86\u5bf9\u8c61\u5b58\u50a8\u7684\u6807\u51c6\u3002\u56e0\u6b64\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u516c\u6709\u4e91\u5382\u5546\u90fd\u63d0\u4f9b\u4e86\u517c\u5bb9 S3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
MatrixOne \u652f\u6301\u5c06\u6587\u4ef6\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u52a0\u8f7d\u5230\u6570\u636e\u5e93\u4e2d\u3002MatrixOne \u652f\u6301 AWS \u548c\u56fd\u5185\u4e3b\u6d41\u4e91\u5382\u5546\uff08\u963f\u91cc\u4e91\u3001\u817e\u8baf\u4e91\uff09\u3002
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u4ece S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u4e2d\u5bfc\u5165\u6570\u636e\uff1a
Load data
\u5c06\u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u4e2d\u3002\u6b64\u65b9\u6cd5\u4f1a\u5c06\u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4e2d\uff0c\u6240\u6709\u63a5\u4e0b\u6765\u7684\u67e5\u8be2\u90fd\u5c06\u5728 MatrixOne \u4e2d\u8fdb\u884c\u3002LOAD DATA
","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"LOAD DATA\n| URL s3options {\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"role_arn\"='xxxx', \"external_id\"='yyy', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'}\nINTO TABLE tbl_name\n[{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}]\n[PARALLEL {'TRUE' | 'FALSE'}]\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 role_arn external_id filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002\u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
\u8bed\u6cd5\u793a\u4f8b\uff1a
# LOAD a csv file from AWS S3 us-east-1 region, test-load-mo bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-mo', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD all csv files from Alibaba Cloud OSS Shanghai region, test-load-data bucket, without compression\nLOAD DATA URL s3option{\"endpoint\"='oss-cn-shanghai.aliyuncs.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-load-data', \"filepath\"='/test/*.csv', \"region\"='oss-cn-shanghai', \"compression\"='none'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n# LOAD a csv file from Tencent Cloud COS Shanghai region, test-1252279971 bucket, without bz2 compression\nLOAD DATA URL s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
Note
MatrixOne \u63d0\u4f9b\u4e86 S3 \u9a8c\u8bc1\u4fe1\u606f\u7684\u5b89\u5168\u4fdd\u8bc1\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u654f\u611f\u4fe1\u606f\u5728\u7cfb\u7edf\u8868\uff08statement_info\uff09\u8bb0\u5f55\u91cc\u5c06\u88ab\u9690\u85cf\uff0c\u4fdd\u8bc1\u4f60\u7684\u8d26\u6237\u5b89\u5168\u3002
\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4ece AWS S3 \u52a0\u8f7d. csv \u6587\u4ef6\u7684\u8fc7\u7a0b\u3002
\u5982\u679c\u4f60\u5df2\u7ecf\u62e5\u6709\u4e00\u4e2a AWS \u8d26\u6237\u5e76\u4e14\u5df2\u7ecf\u5728\u4f60\u7684 S3 \u670d\u52a1\u4e2d\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u90a3\u4e48\u8bf7\u7ee7\u7eed\u9605\u8bfb\u672c\u6559\u7a0b\u7ae0\u8282\u3002
\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u51c6\u5907\u597d\u6570\u636e\u6587\u4ef6\uff0c\u8bf7\u5148\u6ce8\u518c\u5e76\u4e0a\u4f20\u4f60\u7684\u6570\u636e\u6587\u4ef6\uff1b\u4f60\u4e5f\u53ef\u4ee5\u67e5\u770b AWS S3 \u5b98\u65b9\u6559\u7a0b\u3002\u5982\u679c\u4f60\u7684\u6570\u636e\u6587\u4ef6\u60f3\u8981\u4e0a\u4f20\u5230\u963f\u91cc\u4e91 OSS \u6216\u8005\u817e\u8baf\u4e91 COS \u4e0a\uff0c\u90a3\u4e48\u64cd\u4f5c\u6d41\u7a0b\u4e0e AWS S3 \u7c7b\u4f3c\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 `Access key` \u548c `Secret access key`\u3002\n
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u8868\uff0cSQL \u793a\u4f8b\u5982\u4e0b\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u6587\u4ef6\u5bfc\u5165 MatrixOne\uff1a
LOAD DATA URL s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} INTO TABLE t1;\n
\u5bfc\u5165\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c SQL \u8bed\u53e5\u68c0\u67e5\u6587\u4ef6\u5bfc\u5165\u662f\u5426\u6210\u529f\uff1a
mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (0.03 sec)\n
create external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} [{FIELDS | COLUMNS}\n[TERMINATED BY 'string']\n[[OPTIONALLY] ENCLOSED BY 'char']\n[ESCAPED BY 'char']\n]\n[IGNORE number {LINES | ROWS}];\n
Note
MatrixOne \u5f53\u524d\u4ec5\u652f\u6301\u5bf9\u5916\u90e8\u8868\u8fdb\u884c select
\uff0c\u6682\u4e0d\u652f\u6301 Delete
\uff0cinsert
\uff0cupdate
\u3002
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u63cf\u8ff0 endpoint \u53ef\u4ee5\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id Access key ID secret_access_key Secret access key bucket S3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u76f8\u5bf9\u6587\u4ef6\u8def\u5f84\u3002 /files/*.csv \u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u3002 region \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002\u5982\u679c\u4e3a\u7a7a\u6216 \"none\"\uff0c\uff0c\u5219\u8868\u793a\u672a\u538b\u7f29\u7684\u6587\u4ef6\u3002\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\u201cauto\u201d\u3001\u201cnone\u201d\u3001\u201cgzip\u201d\u3001\u201cbz2\u201d\u548c\u201clz4\u201d\u3002\u5176\u4ed6\u53c2\u6570\u4e0e\u901a\u7528 LOAD DATA
\u53c2\u6570\u76f8\u540c\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 LOAD DATA\u3002
\u6709\u5173\u5916\u90e8\u8868\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u521b\u5efa\u5916\u90e8\u8868\u3002
\u8bed\u6cd5\u793a\u4f8b\uff1a
## Create a external table for a .csv file from AWS S3\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='test.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n\n## Create a external table for a .csv file compressed with BZIP2 from Tencent Cloud\ncreate external table t1(col1 char(225)) url s3option{\"endpoint\"='cos.ap-shanghai.myqcloud.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-1252279971', \"filepath\"='test.csv.bz2', \"region\"='ap-shanghai', \"compression\"='bz2'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n' ignore 1 lines;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/load-s3/#s3","title":"\u6559\u7a0b\uff1a\u4f7f\u7528 S3 \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868","text":"\u672c\u6559\u7a0b\u5c06\u6307\u5bfc\u4f60\u5b8c\u6210\u4f7f\u7528\u6765\u81ea AWS S3 \u7684. csv \u6587\u4ef6\u521b\u5efa\u5916\u90e8\u8868\u7684\u6574\u4e2a\u8fc7\u7a0b\u3002
Note
\u7531\u4e8e\u5e10\u6237\u9690\u79c1\uff0c\u6b64\u4ee3\u7801\u793a\u4f8b\u4e0d\u4f1a\u663e\u793a\u5e10\u6237\u4fe1\u606f\uff0c\u4f8b\u5982 access_key_id
\u548c secret_access_key
\u3002 \u4f60\u53ef\u4ee5\u9605\u8bfb\u672c\u6587\u6863\u4ee5\u4e86\u89e3\u4e3b\u8981\u6b65\u9aa4\uff1b\u5177\u4f53\u6570\u636e\u548c\u8d26\u6237\u4fe1\u606f\u5c06\u4e0d\u4f1a\u663e\u793a\u3002
\u4f60\u53ef\u4ee5\u4ece\u4e0b\u8f7d\u7684\u51ed\u636e\u6216\u6b64\u7f51\u9875\u4e2d\u83b7\u53d6 `Access key` \u548c `Secret access key`\u3002\n
\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u6307\u5b9a S3 \u6587\u4ef6\u5230\u5916\u90e8\u8868\uff1a
create database db;\nuse db;\ndrop table if exists t1;\ncreate external table t1(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225)) url s3option{\"endpoint\"='s3.us-east-1.amazonaws.com', \"access_key_id\"='XXXXXX', \"secret_access_key\"='XXXXXX', \"bucket\"='test-loading', \"filepath\"='char_varchar_1.csv', \"region\"='us-east-1', \"compression\"='none'} fields terminated by ',' enclosed by '\\\"' lines terminated by '\\n';\n
\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f60\u53ef\u4ee5\u8fd0\u884c\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u6570\u636e\u7684\u7ed3\u679c\u3002\u4f60\u5c06\u53ef\u4ee5\u770b\u5230\u67e5\u8be2\u901f\u5ea6\u660e\u663e\u6162\u4e8e\u4ece\u672c\u5730\u8868\u67e5\u8be2\u3002
select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa,aa | bb,bb | cc,cc | dd,dd |\n| aa, | bb, | cc, | dd, |\n| aa,,,aa | bb,,,bb | cc,,,cc | dd,,,dd |\n| aa',',,aa | bb',',,bb | cc',',,cc | dd',',,dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\",aa | bb\",bb | cc\",cc | dd\",dd |\n| aa\"\",aa | bb\"\",bb | cc\"\",cc | dd\"\",dd |\n| | | | |\n| | | | |\n| NULL | NULL | NULL | NULL |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n21 rows in set (1.32 sec)\n
\uff08\u9009\u505a\uff09\u5982\u679c\u9700\u8981\u5c06\u5916\u90e8\u8868\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u6570\u636e\u8868\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\uff1a
\u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u8868 t2\uff1a
create table t2(col1 char(225), col2 varchar(225), col3 text, col4 varchar(225));\n
\u5c06\u5916\u90e8\u8868 t1 \u5bfc\u5165\u5230 t2\uff1a
insert into t2 select * from t1;\n
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 source
\u547d\u4ee4\u6279\u91cf\u5bfc\u5165\u6570\u636e\u81f3 MatrixOne\u3002
SOURCE /path/to/your/sql_script.sql;\n
/path/to/your/sql_script.sql
\u662f SQL \u811a\u672c\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84\u3002\u5f53\u6267\u884c\u6b64\u547d\u4ee4\u65f6\uff0c\u5ba2\u6237\u7aef\u4f1a\u8bfb\u53d6\u6307\u5b9a\u7684 SQL \u811a\u672c\u6587\u4ef6\uff0c\u5e76\u6267\u884c\u5176\u4e2d\u5305\u542b\u7684\u6240\u6709 SQL \u8bed\u53e5\u3002
\u5728\u672c\u6559\u7a0b\u4e2d\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 source
\u547d\u4ee4\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#_4","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#1-mysql","title":"1. MySQL \u6570\u636e\u8f6c\u50a8","text":"\u4f60\u9700\u8981\u62e5\u6709\u5bf9 MySQL \u5b9e\u4f8b\u7684\u5b8c\u5168\u8bbf\u95ee\u6743\u9650\u3002
\u9996\u5148\uff0c\u4f7f\u7528 mysqldump
\u5c06 MySQL \u8868\u7ed3\u6784\u548c\u6570\u636e\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8f6c\u50a8\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089\u5982\u4f55\u4f7f\u7528 mysqldump
\uff0c\u53ef\u53c2\u89c1 mysqldump \u6559\u7a0b\u3002
mysqldump -h IP_ADDRESS -uUSERNAME -pPASSWORD -d DB_NAME1 DB_NAME2 ... OUTPUT_FILE_NAME.SQL\n
\u793a\u4f8b\u5982\u4e0b\uff0c\u4f7f\u7528\u547d\u4ee4\u5c06\u4e00\u4e2a\u547d\u540d\u4e3a test \u6570\u636e\u5e93\u7684\u6240\u6709\u8868\u7ed3\u6784\u548c\u6570\u636e\u8f6c\u50a8\u5230\u4e00\u4e2a\u540d\u4e3a a.sql \u7684\u6587\u4ef6\u4e2d\u3002
mysqldump -h 127.0.0.1 -uroot -proot -d test > a.sql\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#2-matrixone","title":"2. \u5bfc\u5165\u81f3 MatrixOne","text":"\u5c06\u6574\u4e2a\u8868\u7ed3\u6784\u548c\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\u3002
\u6253\u5f00 MySQL \u7ec8\u7aef\u5e76\u8fde\u63a5\u5230 MatrixOne\u3002
\u901a\u8fc7 source
\u547d\u4ee4\u5c06 sql \u6587\u4ef6\u5bfc\u5165 MatrixOne\u3002
mysql> use test;\nmysql> source /YOUR_PATH/a.sql\n
\u5982\u679c sql \u6587\u4ef6\u8f83\u5927\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5728\u540e\u53f0\u8fd0\u884c\u5bfc\u5165\u4efb\u52a1\uff1a
nohup mysql -h 127.0.0.1 -P 6001 -uroot -p111 -e -D test 'source /YOUR_PATH/a.sql' &\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#3","title":"3. \u68c0\u67e5\u6570\u636e","text":"\u5bfc\u5165\u6210\u529f\u540e\uff0c\u4f7f\u7528\u5982\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5bfc\u5165\u7ed3\u679c\uff1a
select * from tool;\n
"},{"location":"MatrixOne/Develop/import-data/bulk-load/using-source/#_5","title":"\u9650\u5236\u8bf4\u660e","text":"MatrixOne 1.2.1 \u7248\u672c\u5df2\u7ecf\u652f\u6301 MySQL \u7684\u5efa\u8868\u8bed\u53e5\uff0c\u56e0\u6b64\u53ef\u4ee5\u987a\u7545\u5730\u5c06 MySQL \u8868\u8fc1\u79fb\u5230 MatrixOne \u4e0a\u3002\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f\uff0c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u517c\u5bb9 MySQL \u90e8\u5206\u5173\u952e\u5b57\uff0c\u5982 engine=
\u7b49\uff0c\u5728 MatrixOne \u4e2d\u4f1a\u88ab\u81ea\u52a8\u5ffd\u7565\uff0c\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u8868\u7ed3\u6784\u7684\u8fc1\u79fb\u3002
\u4f46\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c\u5c3d\u7ba1 MatrixOne \u652f\u6301 MySQL \u5efa\u8868\u8bed\u53e5\uff0c\u5982\u679c\u8fc1\u79fb\u7684\u8868\u4e2d\u5305\u542b\u4e0d\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3001\u89e6\u53d1\u5668\u3001\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ecd\u9700\u8981\u624b\u52a8\u4fee\u6539\u3002\u66f4\u591a\u8be6\u7ec6\u7684\u517c\u5bb9\u6027\u4fe1\u606f\uff0c\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u3002
"},{"location":"MatrixOne/Develop/read-data/cte/","title":"\u516c\u5171\u8868\u8868\u8fbe\u5f0f (CTE)","text":"\u516c\u7528\u8868\u8868\u8fbe\u5f0f\uff08CTE,Common table expression) \u662f\u4e00\u4e2a\u547d\u540d\u7684\u4e34\u65f6\u7ed3\u679c\u96c6\uff0c\u4ec5\u5728\u5355\u4e2a SQL \u8bed\u53e5 (\u4f8b\u5982 SELECT
\uff0cINSERT
\uff0cUPDATE
\u6216 DELETE
) \u7684\u6267\u884c\u8303\u56f4\u5185\u5b58\u5728\u3002
\u4e0e\u6d3e\u751f\u8868\u7c7b\u4f3c\uff0cCTE \u4e0d\u4f5c\u4e3a\u5bf9\u8c61\u5b58\u50a8\uff0c\u4ec5\u5728\u67e5\u8be2\u6267\u884c\u671f\u95f4\u6301\u7eed\uff1b\u4e0e\u6d3e\u751f\u8868\u4e0d\u540c\uff0cCTE \u53ef\u4ee5\u662f\u81ea\u5f15\u7528\uff0c\u4e5f\u53ef\u4ee5\u5728\u540c\u4e00\u67e5\u8be2\u4e2d\u591a\u6b21\u5f15\u7528\u3002\u6b64\u5916\uff0c\u4e0e\u6d3e\u751f\u8868\u76f8\u6bd4\uff0cCTE \u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u53ef\u8bfb\u6027\u548c\u6027\u80fd\u3002
\u5e94\u7528\u573a\u666f\uff1a
\u901a\u7528\u8868\u8868\u8fbe\u5f0f\u5206\u4e3a\u975e\u9012\u5f52\u548c\u9012\u5f52\u4e24\u79cd\u7c7b\u578b\uff1a
WITH <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
WITH RECURSIVE <query_name> AS (\n<query_definition>\n)\nSELECT ... FROM <query_name>;\n
"},{"location":"MatrixOne/Develop/read-data/cte/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/read-data/cte/#cte_1","title":"CTE \u8bed\u53e5\u4f7f\u7528\u793a\u4f8b","text":"\u5047\u8bbe\u6211\u4eec\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a EMPLOYEES
\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u5458\u5de5\u7684\u5c42\u6b21\u7ed3\u6784\u5173\u7cfb\uff0c\u7136\u540e\u4f7f\u7528\u975e\u9012\u5f52 Common Table Expression\uff08CTE\uff09\u548c\u9012\u5f52 CTE \u5206\u522b\u67e5\u8be2\u5458\u5de5\u5c42\u6b21\u7ed3\u6784\u3002
\u9996\u5148\uff0c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a EMPLOYEES
\u8868\u5e76\u63d2\u5165\u4e00\u4e9b\u793a\u4f8b\u6570\u636e\uff1a
CREATE TABLE EMPLOYEES (\nEMPLOYEE_ID INT PRIMARY KEY,\nNAME VARCHAR(50),\nMANAGER_ID INT\n);\n\nINSERT INTO EMPLOYEES (EMPLOYEE_ID, NAME, MANAGER_ID) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Carol', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3),\n(7, 'Grace', 3),\n(8, 'Hannah', 4),\n(9, 'Ian', 4);\n
\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528\u9012\u5f52 CTE \u67e5\u8be2\u5458\u5de5\u5c42\u6b21\u7ed3\u6784\uff1a
WITH RECURSIVE EmployeeHierarchy AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID, 0 AS LEVEL\nFROM EMPLOYEES\nWHERE MANAGER_ID IS NULL\n\nUNION ALL\n\nSELECT e.EMPLOYEE_ID, e.NAME, e.MANAGER_ID, eh.LEVEL + 1\nFROM EMPLOYEES e\nINNER JOIN EmployeeHierarchy eh ON e.MANAGER_ID = eh.EMPLOYEE_ID\n)\nSELECT * FROM EmployeeHierarchy;\n+-------------+--------+------------+-------+\n| employee_id | name | manager_id | level |\n+-------------+--------+------------+-------+\n| 1 | Alice | NULL | 0 |\n| 2 | Bob | 1 | 1 |\n| 3 | Carol | 1 | 1 |\n| 4 | David | 2 | 2 |\n| 5 | Eve | 2 | 2 |\n| 6 | Frank | 3 | 2 |\n| 7 | Grace | 3 | 2 |\n| 8 | Hannah | 4 | 3 |\n| 9 | Ian | 4 | 3 |\n+-------------+--------+------------+-------+\n9 rows in set (0.01 sec)\n
\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528\u975e\u9012\u5f52 CTE \u67e5\u8be2\u5458\u5de5\u4fe1\u606f\uff1a
WITH EmployeeInfo AS (\nSELECT EMPLOYEE_ID, NAME, MANAGER_ID\nFROM EMPLOYEES\n)\nSELECT * FROM EmployeeInfo;\n+-------------+--------+------------+\n| employee_id | name | manager_id |\n+-------------+--------+------------+\n| 1 | Alice | NULL |\n| 2 | Bob | 1 |\n| 3 | Carol | 1 |\n| 4 | David | 2 |\n| 5 | Eve | 2 |\n| 6 | Frank | 3 |\n| 7 | Grace | 3 |\n| 8 | Hannah | 4 |\n| 9 | Ian | 4 |\n+-------------+--------+------------+\n9 rows in set (0.00 sec)\n
\u6211\u4eec\u4f7f\u7528\u4e86\u4e00\u4e2a\u9012\u5f52 CTE EmployeeHierarchy
\uff0c\u5b83\u9996\u5148\u9009\u62e9\u9876\u5c42\u7ecf\u7406\uff08MANAGER_ID IS NULL
\uff09\uff0c\u7136\u540e\u901a\u8fc7\u9012\u5f52\u8fde\u63a5\u627e\u5230\u6bcf\u4e2a\u5458\u5de5\u7684\u76f4\u63a5\u4e0b\u5c5e\uff0c\u540c\u65f6\u8ddf\u8e2a\u5c42\u6b21\u7ea7\u522b\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u901a\u8fc7\u67e5\u8be2 CTE \u6765\u83b7\u53d6\u5458\u5de5\u5c42\u6b21\u7ed3\u6784\u7684\u8be6\u7ec6\u4fe1\u606f\u3002
\u975e\u9012\u5f52 CTE \u793a\u4f8b\u53ea\u662f\u4ece EMPLOYEES
\u8868\u4e2d\u9009\u62e9\u6240\u6709\u5458\u5de5\u7684\u57fa\u672c\u4fe1\u606f\uff0c\u5305\u62ec EMPLOYEE_ID
\u3001NAME
\u548c MANAGER_ID
\u3002
\u6ce8\u610f\uff0c\u9012\u5f52 CTE \u9700\u8981\u4f7f\u7528 RECURSIVE
\u5173\u952e\u5b57\u6765\u58f0\u660e\u3002
\u66f4\u591a\u5173\u4e8e CTE \u7684\u4f7f\u7528\u6587\u6863\uff0c\u53c2\u8003 WITH (Common Table Expressions)
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/","title":"\u591a\u8868\u8fde\u63a5\u67e5\u8be2","text":"\u4e00\u4e9b\u4f7f\u7528\u6570\u636e\u5e93\u7684\u573a\u666f\u4e2d\uff0c\u9700\u8981\u4e00\u4e2a\u67e5\u8be2\u5f53\u4e2d\u4f7f\u7528\u5230\u591a\u5f20\u8868\u7684\u6570\u636e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7 JOIN
\u8bed\u53e5\u5c06\u4e24\u5f20\u6216\u591a\u5f20\u8868\u7684\u6570\u636e\u7ec4\u5408\u5728\u4e00\u8d77\u3002
\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_3","title":"\u6570\u636e\u51c6\u5907","text":"\u4e0b\u8f7d\u6570\u636e\u96c6\uff1a
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
\u521b\u5efa\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff1a
create database d1;\nuse d1;\nCREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL,\nR_NAME CHAR(25) NOT NULL,\nR_COMMENT VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART ( P_PARTKEY INTEGER NOT NULL,\nP_NAME VARCHAR(55) NOT NULL,\nP_MFGR CHAR(25) NOT NULL,\nP_BRAND CHAR(10) NOT NULL,\nP_TYPE VARCHAR(25) NOT NULL,\nP_SIZE INTEGER NOT NULL,\nP_CONTAINER CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY INTEGER NOT NULL,\nS_NAME CHAR(25) NOT NULL,\nS_ADDRESS VARCHAR(40) NOT NULL,\nS_NATIONKEY INTEGER NOT NULL,\nS_PHONE CHAR(15) NOT NULL,\nS_ACCTBAL DECIMAL(15,2) NOT NULL,\nS_COMMENT VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY INTEGER NOT NULL,\nPS_SUPPKEY INTEGER NOT NULL,\nPS_AVAILQTY INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY INTEGER NOT NULL,\nC_NAME VARCHAR(25) NOT NULL,\nC_ADDRESS VARCHAR(40) NOT NULL,\nC_NATIONKEY INTEGER NOT NULL,\nC_PHONE CHAR(15) NOT NULL,\nC_ACCTBAL DECIMAL(15,2) NOT NULL,\nC_MKTSEGMENT CHAR(10) NOT NULL,\nC_COMMENT VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS ( O_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
\u628a\u6570\u636e\u5bfc\u5165\u5230\u6570\u636e\u8868\u4e2d\uff1a
load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u73b0\u5728\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u6570\u636e\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#join","title":"Join \u7c7b\u578b","text":""},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_4","title":"\u5185\u8fde\u63a5","text":"\u5185\u8fde\u63a5\u7684\u8fde\u63a5\u7ed3\u679c\u53ea\u8fd4\u56de\u5339\u914d\u8fde\u63a5\u6761\u4ef6\u7684\u884c\u3002
SELECT <select_list> FROM TableA A INNER JOIN TableB B ON A.Key=B.Key\n
\u5185\u8fde\u63a5\u6709\u4e24\u79cd\u4e66\u5199\u65b9\u5f0f\uff0c\u5728\u7ed3\u679c\u4e0a\u662f\u5b8c\u5168\u7b49\u4ef7\u7684\uff1a
mysql> SELECT l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER,\nORDERS,\nLINEITEM\nWHERE\nc_mktsegment = 'BUILDING'\nAND c_custkey = o_custkey\nAND l_orderkey = o_orderkey\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n| 2456423 | 406181.011100000000 | 1995-03-05 | 0 |\n| 3459808 | 405838.698900000000 | 1995-03-04 | 0 |\n| 492164 | 390324.061000000000 | 1995-02-19 | 0 |\n| 1188320 | 384537.935900000000 | 1995-03-09 | 0 |\n| 2435712 | 378673.055800000000 | 1995-02-26 | 0 |\n| 4878020 | 378376.795200000000 | 1995-03-12 | 0 |\n| 5521732 | 375153.921500000000 | 1995-03-13 | 0 |\n| 2628192 | 373133.309400000000 | 1995-02-22 | 0 |\n| 993600 | 371407.459500000000 | 1995-03-05 | 0 |\n| 2300070 | 367371.145200000000 | 1995-03-13 | 0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n
\u5199\u6210 Join
\u7684\u5f62\u5f0f\uff0c\u8bed\u6cd5\u5982\u4e0b\uff1a
mysql> SELECT l_orderkey,\nSUM(l_extendedprice * (1 - l_discount)) AS revenue,\no_orderdate,\no_shippriority\nFROM\nCUSTOMER\njoin ORDERS on c_custkey = o_custkey\njoin LINEITEM on l_orderkey = o_orderkey\nWHERE\nc_mktsegment = 'BUILDING'\nAND o_orderdate < DATE '1995-03-15'\nAND l_shipdate > DATE '1995-03-15'\nGROUP BY l_orderkey , o_orderdate , o_shippriority\nORDER BY revenue DESC , o_orderdate\nLIMIT 10;\n+------------+---------------------+-------------+----------------+\n| l_orderkey | revenue | o_orderdate | o_shippriority |\n+------------+---------------------+-------------+----------------+\n| 2456423 | 406181.011100000000 | 1995-03-05 | 0 |\n| 3459808 | 405838.698900000000 | 1995-03-04 | 0 |\n| 492164 | 390324.061000000000 | 1995-02-19 | 0 |\n| 1188320 | 384537.935900000000 | 1995-03-09 | 0 |\n| 2435712 | 378673.055800000000 | 1995-02-26 | 0 |\n| 4878020 | 378376.795200000000 | 1995-03-12 | 0 |\n| 5521732 | 375153.921500000000 | 1995-03-13 | 0 |\n| 2628192 | 373133.309400000000 | 1995-02-22 | 0 |\n| 993600 | 371407.459500000000 | 1995-03-05 | 0 |\n| 2300070 | 367371.145200000000 | 1995-03-13 | 0 |\n+------------+---------------------+-------------+----------------+\n10 rows in set (0.20 sec)\n
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_5","title":"\u5916\u8fde\u63a5","text":"\u5916\u8fde\u63a5\u53c8\u5206\u4e3a\u5de6\u8fde\u63a5\u3001\u53f3\u8fde\u63a5\uff0c\u4e24\u8005\u4e4b\u95f4\u662f\u53ef\u4ee5\u5b9e\u73b0\u7b49\u4ef7\u8bed\u4e49\u7684\uff1a
LEFT JOIN
\u5de6\u5916\u8fde\u63a5\u4f1a\u8fd4\u56de\u5de6\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\u884c\uff0c\u4ee5\u53ca\u53f3\u8868\u5f53\u4e2d\u80fd\u591f\u5339\u914d\u8fde\u63a5\u6761\u4ef6\u7684\u503c\uff0c\u5982\u679c\u5728\u53f3\u8868\u5f53\u4e2d\u6ca1\u6709\u627e\u5230\u80fd\u591f\u5339\u914d\u7684\u884c\uff0c\u5219\u4f7f\u7528 NULL \u586b\u5145\u3002
SELECT <select_list> FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key\n
SELECT <select_list> FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL\n
RIGHT JOIN
\u53f3\u5916\u8fde\u63a5\u8fd4\u56de\u53f3\u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u4ee5\u53ca\u5de6\u8868\u5f53\u4e2d\u80fd\u591f\u5339\u914d\u8fde\u63a5\u6761\u4ef6\u7684\u503c\uff0c\u6ca1\u6709\u5339\u914d\u7684\u503c\u5219\u4f7f\u7528 NULL \u586b\u5145\u3002
SELECT <select_list> FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key\n
SELECT <select_list> FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL\n
\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 147457 | 16 |\n| 147458 | 7 |\n| 147459 | 0 |\n| 147460 | 16 |\n| 147461 | 7 |\n| 147462 | 0 |\n| 147463 | 14 |\n| 147464 | 11 |\n| 147465 | 0 |\n| 147466 | 17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n
\u6216\u8005\uff1a
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nORDERS\nRIGHT OUTER JOIN CUSTOMER ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 147457 | 16 |\n| 147458 | 7 |\n| 147459 | 0 |\n| 147460 | 16 |\n| 147461 | 7 |\n| 147462 | 0 |\n| 147463 | 14 |\n| 147464 | 11 |\n| 147465 | 0 |\n| 147466 | 17 |\n+-----------+---------+\n10 rows in set (0.93 sec)\n
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_6","title":"\u5168\u8fde\u63a5","text":"\u5168\u8fde\u63a5\u662f\u5de6\u53f3\u5916\u8fde\u63a5\u7684\u5e76\u96c6\u3002\u8fde\u63a5\u8868\u5305\u542b\u88ab\u8fde\u63a5\u7684\u8868\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u5982\u679c\u7f3a\u5c11\u5339\u914d\u7684\u8bb0\u5f55\uff0c\u5373\u4ee5 NULL \u586b\u5145\u3002
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nFULL JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey limit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 1 | 6 |\n| 2 | 7 |\n| 4 | 20 |\n| 5 | 4 |\n| 7 | 16 |\n| 8 | 13 |\n| 10 | 20 |\n| 11 | 13 |\n| 13 | 18 |\n| 14 | 9 |\n+-----------+---------+\n10 rows in set (0.77 sec)\n
\u5168\u8fde\u63a5\u540c\u6837\u53ef\u4ee5\u901a\u8fc7\u6539\u5199\u7684\u65b9\u5f0f\u83b7\u5f97\u76f8\u540c\u7684\u8bed\u4e49\uff1a
SELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nGROUP BY c_custkey\nUNION\nSELECT\nc_custkey, COUNT(o_orderkey) AS c_count\nFROM\nCUSTOMER\nLEFT OUTER JOIN ORDERS ON (c_custkey = o_custkey\nAND o_comment NOT LIKE '%special%requests%')\nWHERE c_custkey IS NULL\nGROUP BY c_custkey\nlimit 10;\n\n+-----------+---------+\n| c_custkey | c_count |\n+-----------+---------+\n| 147457 | 16 |\n| 147458 | 7 |\n| 147459 | 0 |\n| 147460 | 16 |\n| 147461 | 7 |\n| 147462 | 0 |\n| 147463 | 14 |\n| 147464 | 11 |\n| 147465 | 0 |\n| 147466 | 17 |\n+-----------+---------+\n10 rows in set (1.09 sec)\n
"},{"location":"MatrixOne/Develop/read-data/multitable-join-query/#_7","title":"\u9690\u5f0f\u8fde\u63a5","text":"\u5728 SQL \u8bed\u53e5\u5f53\u4e2d\uff0c\u9664\u4e86\u4f7f\u7528 JOIN
\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7 FROM t1, t2
\u5b50\u53e5\u6765\u8fde\u63a5\u4e24\u5f20\u6216\u591a\u5f20\u8868\uff0c\u901a\u8fc7 WHERE t1.id = t2.id
\u5b50\u53e5\u6765\u6307\u5b9a\u8fde\u63a5\u7684\u6761\u4ef6\u3002
\u672c\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u6765\u5bf9\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
CREATE DATABASE token_demo;\nUSE token_demo;\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#token_count","title":"\u65b0\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a token_count \u7684\u8868","text":"CREATE TABLE token_count (\nid int,\ntoken varchar(100) DEFAULT '' NOT NULL,\ncount int DEFAULT 0 NOT NULL,\nqty int,\nphone char(1) DEFAULT '' NOT NULL,\ntimes datetime DEFAULT '2000-01-01 00:00:00' NOT NULL\n);\nINSERT INTO token_count VALUES (21,'e45703b64de71482360de8fec94c3ade',3,7800,'n','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (22,'e45703b64de71482360de8fec94c3ade',4,5000,'y','1999-12-23 17:22:21');\nINSERT INTO token_count VALUES (18,'346d1cb63c89285b2351f0ca4de40eda',3,13200,'b','1999-12-23 11:58:04');\nINSERT INTO token_count VALUES (17,'ca6ddeb689e1b48a04146b1b5b6f936a',4,15000,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (16,'ca6ddeb689e1b48a04146b1b5b6f936a',3,13200,'b','1999-12-23 11:36:53');\nINSERT INTO token_count VALUES (26,'a71250b7ed780f6ef3185bfffe027983',5,1500,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (24,'4d75906f3c37ecff478a1eb56637aa09',3,5400,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (25,'4d75906f3c37ecff478a1eb56637aa09',4,6500,'y','1999-12-23 17:29:12');\nINSERT INTO token_count VALUES (27,'a71250b7ed780f6ef3185bfffe027983',3,6200,'b','1999-12-27 09:44:24');\nINSERT INTO token_count VALUES (28,'a71250b7ed780f6ef3185bfffe027983',3,5400,'y','1999-12-27 09:44:36');\nINSERT INTO token_count VALUES (29,'a71250b7ed780f6ef3185bfffe027983',4,17700,'b','1999-12-27 09:45:05');\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_4","title":"\u7b80\u5355\u7684\u67e5\u8be2","text":"\u5728 MySQL Client \u7b49\u5ba2\u6237\u7aef\u8f93\u5165\u5e76\u6267\u884c\u5982\u4e0b SQL \u8bed\u53e5\uff1a
mysql> SELECT id, token FROM token_count;\n
\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+\n| id | token |\n+------+----------------------------------+\n| 21 | e45703b64de71482360de8fec94c3ade |\n| 22 | e45703b64de71482360de8fec94c3ade |\n| 18 | 346d1cb63c89285b2351f0ca4de40eda |\n| 17 | ca6ddeb689e1b48a04146b1b5b6f936a |\n| 16 | ca6ddeb689e1b48a04146b1b5b6f936a |\n| 26 | a71250b7ed780f6ef3185bfffe027983 |\n| 24 | 4d75906f3c37ecff478a1eb56637aa09 |\n| 25 | 4d75906f3c37ecff478a1eb56637aa09 |\n| 27 | a71250b7ed780f6ef3185bfffe027983 |\n| 28 | a71250b7ed780f6ef3185bfffe027983 |\n| 29 | a71250b7ed780f6ef3185bfffe027983 |\n+------+----------------------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_5","title":"\u5bf9\u7ed3\u679c\u8fdb\u884c\u7b5b\u9009","text":"\u5982\u679c\u4f60\u9700\u8981\u4ece\u8bf8\u591a\u67e5\u8be2\u5f97\u5230\u7684\u7ed3\u679c\u4e2d\u7b5b\u9009\u51fa\u4f60\u9700\u8981\u7684\u7ed3\u679c\uff0c\u53ef\u4ee5\u901a\u8fc7 WHERE
\u8bed\u53e5\u5bf9\u67e5\u8be2\u7684\u7ed3\u679c\u8fdb\u884c\u8fc7\u6ee4\uff0c\u4ece\u800c\u627e\u5230\u60f3\u8981\u67e5\u8be2\u7684\u90e8\u5206\u3002
\u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 WHERE
\u5b50\u53e5\u6dfb\u52a0\u7b5b\u9009\u7684\u6761\u4ef6\uff1a
mysql> SELECT * FROM token_count WHERE id = 25;\n
\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+-------+------+-------+---------------------+\n| id | token | count | qty | phone | times |\n+------+----------------------------------+-------+------+-------+---------------------+\n| 25 | 4d75906f3c37ecff478a1eb56637aa09 | 4 | 6500 | y | 1999-12-23 17:29:12 |\n+------+----------------------------------+-------+------+-------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_6","title":"\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f","text":"\u4f7f\u7528 ORDER BY
\u8bed\u53e5\u53ef\u4ee5\u8ba9\u67e5\u8be2\u7ed3\u679c\u6309\u7167\u671f\u671b\u7684\u65b9\u5f0f\u8fdb\u884c\u6392\u5e8f\u3002
\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u5bf9 token_count \u8868\u7684\u6570\u636e\u6309\u7167 times \u5217\u8fdb\u884c\u964d\u5e8f (DESC) \u6392\u5e8f\u3002
mysql> SELECT id, token, times FROM token_count ORDER BY times DESC;\n
\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+---------------------+\n| id | token | times |\n+------+----------------------------------+---------------------+\n| 29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n| 28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n| 26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n| 25 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n| 21 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n| 22 | e45703b64de71482360de8fec94c3ade | 1999-12-23 17:22:21 |\n| 18 | 346d1cb63c89285b2351f0ca4de40eda | 1999-12-23 11:58:04 |\n| 17 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n| 16 | ca6ddeb689e1b48a04146b1b5b6f936a | 1999-12-23 11:36:53 |\n+------+----------------------------------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_7","title":"\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u6570\u91cf","text":"\u5982\u679c\u5e0c\u671b\u53ea\u8fd4\u56de\u90e8\u5206\u7ed3\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 LIMIT
\u8bed\u53e5\u9650\u5236\u67e5\u8be2\u7ed3\u679c\u8fd4\u56de\u7684\u8bb0\u5f55\u6570\u3002
mysql> SELECT id, token, times FROM token_count ORDER BY times DESC LIMIT 5;\n
\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
+------+----------------------------------+---------------------+\n| id | token | times |\n+------+----------------------------------+---------------------+\n| 29 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:45:05 |\n| 28 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:36 |\n| 26 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 27 | a71250b7ed780f6ef3185bfffe027983 | 1999-12-27 09:44:24 |\n| 24 | 4d75906f3c37ecff478a1eb56637aa09 | 1999-12-23 17:29:12 |\n+------+----------------------------------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/query-data-single-table/#_8","title":"\u805a\u5408\u67e5\u8be2","text":"\u5982\u679c\u4f60\u60f3\u8981\u5173\u6ce8\u6570\u636e\u6574\u4f53\u7684\u60c5\u51b5\uff0c\u800c\u4e0d\u662f\u90e8\u5206\u6570\u636e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 GROUP BY
\u8bed\u53e5\u914d\u5408\u805a\u5408\u51fd\u6570\uff0c\u6784\u5efa\u4e00\u4e2a\u805a\u5408\u67e5\u8be2\u6765\u5e2e\u52a9\u4f60\u5bf9\u6570\u636e\u7684\u6574\u4f53\u60c5\u51b5\u6709\u4e00\u4e2a\u66f4\u597d\u7684\u4e86\u89e3\u3002
\u6bd4\u5982\u8bf4\uff0c\u4f60\u53ef\u4ee5\u5c06\u57fa\u672c\u4fe1\u606f\u6309\u7167 id\u3001count\u3001times \u5217\u8fdb\u884c\u5206\u7ec4\uff0c\u7136\u540e\u5206\u522b\u7edf\u8ba1\uff1a
mysql> SELECT id, count, times FROM token_count GROUP BY id, count, times\nORDER BY times DESC\nLIMIT 5;\n
\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a
+------+-------+---------------------+\n| id | count | times |\n+------+-------+---------------------+\n| 29 | 4 | 1999-12-27 09:45:05 |\n| 28 | 3 | 1999-12-27 09:44:36 |\n| 26 | 5 | 1999-12-27 09:44:24 |\n| 27 | 3 | 1999-12-27 09:44:24 |\n| 24 | 3 | 1999-12-23 17:29:12 |\n+------+-------+---------------------+\n
"},{"location":"MatrixOne/Develop/read-data/subquery/","title":"\u5b50\u67e5\u8be2","text":"\u672c\u7bc7\u6587\u6863\u5411\u4f60\u4ecb\u7ecd MatrixOne \u7684\u5b50\u67e5\u8be2\u529f\u80fd\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_2","title":"\u6982\u8ff0","text":"\u5b50\u67e5\u8be2\u662f\u5d4c\u5957\u5728\u53e6\u4e00\u4e2a\u67e5\u8be2\u4e2d\u7684 SQL \u8868\u8fbe\u5f0f\uff0c\u501f\u52a9\u5b50\u67e5\u8be2\uff0c\u53ef\u4ee5\u5728\u4e00\u4e2a\u67e5\u8be2\u5f53\u4e2d\u4f7f\u7528\u53e6\u5916\u4e00\u4e2a\u67e5\u8be2\u7684\u67e5\u8be2\u7ed3\u679c\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4ece SQL \u8bed\u53e5\u7ed3\u6784\u4e0a\uff0c\u5b50\u67e5\u8be2\u8bed\u53e5\u4e00\u822c\u6709\u4ee5\u4e0b\u51e0\u79cd\u5f62\u5f0f\uff1a
SELECT (SELECT s1 FROM t2) FROM t1
\u3002SELECT t1.s1 FROM (SELECT s1 FROM t2) t1
\u3002WHERE NOT EXISTS(SELECT ... FROM t2)
\uff0cWHERE t1.a IN (SELECT ... FROM t2)
\u3002WHERE t1.a = ANY(SELECT ... FROM t2)
\u3002WHERE t1.a > (SELECT ... FROM t2)
\u3002\u5173\u4e8e\u5b50\u67e5\u8be2 SQL \u8bed\u53e5\uff0c\u53c2\u89c1 SUBQUERY\u3002
\u53e6\u5916\uff0c\u4ece SQL \u8bed\u53e5\u6267\u884c\u60c5\u51b5\u4e0a\uff0c\u5b50\u67e5\u8be2\u8bed\u53e5\u4e00\u822c\u6709\u4ee5\u4e0b\u4e24\u79cd\u5f62\u5f0f\uff1a
\u5173\u8054\u5b50\u67e5\u8be2\uff08Correlated Subquery\uff09\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u548c\u5916\u5c42\u67e5\u8be2\u4e0d\u76f8\u4e92\u72ec\u7acb\uff0c\u5185\u5c42\u67e5\u8be2\u4e5f\u4f9d\u8d56\u4e8e\u5916\u5c42\u67e5\u8be2\u3002\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u5148\u4ece\u5916\u5c42\u67e5\u8be2\u4e2d\u67e5\u8be2\u4e2d\u4e00\u6761\u8bb0\u5f55\u3002
\u518d\u5c06\u67e5\u8be2\u5230\u7684\u8bb0\u5f55\u653e\u5230\u5185\u5c42\u67e5\u8be2\u4e2d\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u518d\u653e\u5230\u5916\u5c42\u4e2d\u67e5\u8be2\u3002
\u91cd\u590d\u4ee5\u4e0a\u6b65\u9aa4
\u4f8b\u5982\uff1aselect * from tableA where tableA.cloumn < (select column from tableB where tableA.id = tableB.id))
\u65e0\u5173\u8054\u5b50\u67e5\u8be2 (Self-contained Subquery)\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u662f\u5b8c\u5168\u72ec\u7acb\u4e8e\u5916\u5c42\u67e5\u8be2\u7684\u3002\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u4f8b\u5982\uff1aselect * from tableA where tableA.column = (select tableB.column from tableB )
\u5b50\u67e5\u8be2\u7684\u4f5c\u7528\uff1a
JOIN
\u548c UNION
\u6765\u5b9e\u73b0\u7684\u64cd\u4f5c\u3002\u6211\u4eec\u5c06\u4e3e\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5e2e\u52a9\u4f60\u7406\u89e3\u5173\u8054\u5b50\u67e5\u8be2\u548c\u65e0\u5173\u8054\u5b50\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_3","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Develop/read-data/subquery/#_4","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u4e0b\u8f7d\u6570\u636e\u96c6\uff1a
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
\u521b\u5efa\u6570\u636e\u5e93\u548c\u6570\u636e\u8868\uff1a
create database d1;\nuse d1;\nCREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY));\n\nCREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL,\nR_NAME CHAR(25) NOT NULL,\nR_COMMENT VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY));\n\nCREATE TABLE PART ( P_PARTKEY INTEGER NOT NULL,\nP_NAME VARCHAR(55) NOT NULL,\nP_MFGR CHAR(25) NOT NULL,\nP_BRAND CHAR(10) NOT NULL,\nP_TYPE VARCHAR(25) NOT NULL,\nP_SIZE INTEGER NOT NULL,\nP_CONTAINER CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY));\n\nCREATE TABLE SUPPLIER ( S_SUPPKEY INTEGER NOT NULL,\nS_NAME CHAR(25) NOT NULL,\nS_ADDRESS VARCHAR(40) NOT NULL,\nS_NATIONKEY INTEGER NOT NULL,\nS_PHONE CHAR(15) NOT NULL,\nS_ACCTBAL DECIMAL(15,2) NOT NULL,\nS_COMMENT VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY));\n\nCREATE TABLE PARTSUPP ( PS_PARTKEY INTEGER NOT NULL,\nPS_SUPPKEY INTEGER NOT NULL,\nPS_AVAILQTY INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY));\n\nCREATE TABLE CUSTOMER ( C_CUSTKEY INTEGER NOT NULL,\nC_NAME VARCHAR(25) NOT NULL,\nC_ADDRESS VARCHAR(40) NOT NULL,\nC_NATIONKEY INTEGER NOT NULL,\nC_PHONE CHAR(15) NOT NULL,\nC_ACCTBAL DECIMAL(15,2) NOT NULL,\nC_MKTSEGMENT CHAR(10) NOT NULL,\nC_COMMENT VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY));\n\nCREATE TABLE ORDERS ( O_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY));\n\nCREATE TABLE LINEITEM ( L_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER));\n
\u628a\u6570\u636e\u5bfc\u5165\u5230\u6570\u636e\u8868\u4e2d\uff1a
load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u73b0\u5728\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u6570\u636e\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_6","title":"\u65e0\u5173\u8054\u5b50\u67e5\u8be2","text":"\u5bf9\u4e8e\u5c06\u5b50\u67e5\u8be2\u4f5c\u4e3a\u6bd4\u8f83\u8fd0\u7b97\u7b26 (>
/ >=
/ <
/ <=
/ =
/ !=
) \u64cd\u4f5c\u6570\u7684\u8fd9\u7c7b\u65e0\u5173\u8054\u5b50\u67e5\u8be2\u800c\u8a00\uff0c\u5185\u5c42\u5b50\u67e5\u8be2\u53ea\u9700\u8981\u8fdb\u884c\u4e00\u6b21\u67e5\u8be2\uff0cMatrixOne \u5728\u751f\u6210\u6267\u884c\u8ba1\u5212\u9636\u6bb5\u4f1a\u5c06\u5185\u5c42\u5b50\u67e5\u8be2\u6539\u5199\u4e3a\u5e38\u91cf\u3002
mysql> select p.p_name from (select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200) p, partsupp ps where p.p_partkey=ps.ps_partkey and p.p_name like '%pink%' limit 10;\n
\u5728 MatrixOne \u6267\u884c\u4e0a\u8ff0\u67e5\u8be2\u7684\u65f6\u5019\u4f1a\u5148\u6267\u884c\u4e00\u6b21\u5185\u5c42\u5b50\u67e5\u8be2\uff1a
mysql> select * from part where p_brand='Brand#21' and p_retailprice between 1100 and 1200\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+-----------------------------------+\n| p_name |\n+-----------------------------------+\n| olive chartreuse smoke pink tan |\n| olive chartreuse smoke pink tan |\n| olive chartreuse smoke pink tan |\n| olive chartreuse smoke pink tan |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| pink sienna dark bisque turquoise |\n| honeydew orchid cyan magenta pink |\n| honeydew orchid cyan magenta pink |\n+-----------------------------------+\n10 rows in set (0.06 sec)\n
\u5bf9\u4e8e\u5b58\u5728\u6027\u6d4b\u8bd5\u548c\u96c6\u5408\u6bd4\u8f83\u4e24\u79cd\u60c5\u51b5\u4e0b\u7684\u65e0\u5173\u8054\u5217\u5b50\u67e5\u8be2\uff0cMatrixOne \u4f1a\u5c06\u5176\u8fdb\u884c\u6539\u5199\u548c\u7b49\u4ef7\u66ff\u6362\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6267\u884c\u6027\u80fd\u3002
"},{"location":"MatrixOne/Develop/read-data/subquery/#_7","title":"\u5173\u8054\u5b50\u67e5\u8be2","text":"\u5bf9\u4e8e\u5173\u8054\u5b50\u67e5\u8be2\u800c\u8a00\uff0c\u7531\u4e8e\u5185\u5c42\u7684\u5b50\u67e5\u8be2\u5f15\u7528\u5916\u5c42\u67e5\u8be2\u7684\u5217\uff0c\u5b50\u67e5\u8be2\u9700\u8981\u5bf9\u5916\u5c42\u67e5\u8be2\u5f97\u5230\u7684\u6bcf\u4e00\u884c\u90fd\u6267\u884c\u4e00\u904d\uff0c\u4e5f\u5c31\u662f\u8bf4\u5047\u8bbe\u5916\u5c42\u67e5\u8be2\u5f97\u5230\u4e00\u5343\u4e07\u7684\u7ed3\u679c\uff0c\u90a3\u4e48\u5b50\u67e5\u8be2\u4e5f\u4f1a\u88ab\u6267\u884c\u4e00\u5343\u4e07\u6b21\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u67e5\u8be2\u9700\u8981\u6d88\u8017\u66f4\u591a\u7684\u65f6\u95f4\u548c\u8d44\u6e90\u3002
\u56e0\u6b64\u5728\u5904\u7406\u8fc7\u7a0b\u4e2d\uff0cMatrixOne \u4f1a\u5c1d\u8bd5\u5bf9\u5173\u8054\u5b50\u67e5\u8be2\u53bb\u5173\u8054\uff0c\u4ee5\u4ece\u6267\u884c\u8ba1\u5212\u5c42\u9762\u4e0a\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002
mysql> select p_name from part where P_PARTKEY in (select PS_PARTKEY from PARTSUPP where PS_SUPPLYCOST>=500) and p_name like '%pink%' limit 10;\n
MatrixOne \u5728\u5904\u7406\u8be5 SQL \u8bed\u53e5\u662f\u4f1a\u5c06\u5176\u6539\u5199\u4e3a\u7b49\u4ef7\u7684 JOIN
\u67e5\u8be2\uff1a
select p_name from part join partsupp on P_PARTKEY=PS_PARTKEY where PS_SUPPLYCOST>=500 and p_name like '%pink%' limit 10;\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+------------------------------------+\n| p_name |\n+------------------------------------+\n| papaya red almond hot pink |\n| turquoise hot smoke green pink |\n| purple cornsilk red pink floral |\n| pink cyan purple white burnished |\n| sandy dark pink indian cream |\n| powder cornsilk chiffon slate pink |\n| rosy light black pink orange |\n| pink white goldenrod ivory steel |\n| cornsilk dim pink tan sienna |\n| lavender navajo steel sandy pink |\n+------------------------------------+\n10 rows in set (0.23 sec)\n
\u4f5c\u4e3a\u6700\u4f73\u5b9e\u8df5\uff0c\u5728\u5b9e\u9645\u5f00\u53d1\u5f53\u4e2d\uff0c\u4e3a\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\uff0c\u5c3d\u91cf\u9009\u62e9\u7b49\u4ef7\u8ba1\u7b97\u65b9\u6cd5\u8fdb\u884c\u67e5\u8be2\uff0c\u907f\u514d\u4f7f\u7528\u5173\u8054\u5b50\u67e5\u8be2\u7684\u65b9\u5f0f\u8fdb\u884c\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Develop/read-data/views/","title":"\u89c6\u56fe","text":"\u672c\u7bc7\u6587\u6863\u5411\u4f60\u4ecb\u7ecd MatrixOne \u7684\u89c6\u56fe\u529f\u80fd\u3002
"},{"location":"MatrixOne/Develop/read-data/views/#_2","title":"\u6982\u8ff0","text":"\u89c6\u56fe\u4f5c\u4e3a\u4e00\u4e2a\u865a\u62df\u8868\uff0c\u8fdb\u884c\u5b58\u50a8\u67e5\u8be2\uff0c\u5728\u8c03\u7528\u65f6\u4ea7\u751f\u7ed3\u679c\u96c6\u3002
\u89c6\u56fe\u7684\u4f5c\u7528\uff1a
\u7b80\u5316\u7528\u6237\u64cd\u4f5c\uff1a\u89c6\u56fe\u673a\u5236\u4f7f\u7528\u6237\u53ef\u4ee5\u5c06\u6ce8\u610f\u529b\u96c6\u4e2d\u5728\u6240\u5173\u5fc3\u5730\u6570\u636e\u4e0a\u3002\u5982\u679c\u8fd9\u4e9b\u6570\u636e\u4e0d\u662f\u76f4\u63a5\u6765\u81ea\u57fa\u672c\u8868\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u89c6\u56fe\uff0c\u4f7f\u6570\u636e\u5e93\u770b\u8d77\u6765\u7ed3\u6784\u7b80\u5355\u3001\u6e05\u6670\uff0c\u5e76\u4e14\u53ef\u4ee5\u7b80\u5316\u7528\u6237\u7684\u6570\u636e\u67e5\u8be2\u64cd\u4f5c\u3002
\u4ee5\u591a\u79cd\u89d2\u5ea6\u770b\u5f85\u540c\u4e00\u6570\u636e\uff1a\u89c6\u56fe\u673a\u5236\u80fd\u4f7f\u4e0d\u540c\u7684\u7528\u6237\u4ee5\u4e0d\u540c\u7684\u65b9\u5f0f\u770b\u5f85\u540c\u4e00\u6570\u636e\uff0c\u5f53\u8bb8\u591a\u4e0d\u540c\u79cd\u7c7b\u7684\u7528\u6237\u5171\u4eab\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u65f6\uff0c\u8fd9\u79cd\u7075\u6d3b\u6027\u662f\u975e\u5e38\u5fc5\u8981\u7684\u3002
\u5bf9\u91cd\u6784\u6570\u636e\u5e93\u63d0\u4f9b\u4e86\u4e00\u5b9a\u7a0b\u5ea6\u7684\u903b\u8f91\u72ec\u7acb\u6027\uff1a\u6570\u636e\u7684\u7269\u7406\u72ec\u7acb\u6027\u662f\u6307\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0d\u4f9d\u8d56\u4e8e\u6570\u636e\u5e93\u7684\u7269\u7406\u7ed3\u6784\u3002\u6570\u636e\u7684\u903b\u8f91\u72ec\u7acb\u6027\u662f\u6307\u5f53\u6570\u636e\u5e93\u91cd\u6784\u9020\u65f6\uff0c\u5982\u589e\u52a0\u65b0\u7684\u5173\u7cfb\u6216\u5bf9\u539f\u6709\u7684\u5173\u7cfb\u589e\u52a0\u65b0\u7684\u5b57\u6bb5\uff0c\u7528\u6237\u7684\u5e94\u7528\u7a0b\u5e8f\u4e0d\u4f1a\u53d7\u5f71\u54cd\u3002\u5c42\u6b21\u6570\u636e\u5e93\u548c\u7f51\u72b6\u6570\u636e\u5e93\u4e00\u822c\u80fd\u8f83\u597d\u5730\u652f\u6301\u6570\u636e\u7684\u7269\u7406\u72ec\u7acb\u6027\uff0c\u800c\u5bf9\u4e8e\u903b\u8f91\u72ec\u7acb\u6027\u5219\u4e0d\u80fd\u5b8c\u5168\u7684\u652f\u6301\u3002
\u4f60\u9700\u8981\u786e\u8ba4\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86\u4ee5\u4e0b\u4efb\u52a1\uff1a
\u65b0\u5efa\u4e24\u5f20\u8868\uff0c\u65b9\u4fbf\u540e\u7eed\u4e3a\u4f7f\u7528\u89c6\u56fe\u505a\u51c6\u5907\uff1a
CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\n
\u53ef\u4ee5\u67e5\u770b\u4e00\u4e0b\u8868 t00 \u7684\u7ed3\u6784\uff1a
mysql> select * from t00;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n+------+\n
\u53ef\u4ee5\u67e5\u770b\u4e00\u4e0b\u8868 t01 \u7684\u7ed3\u6784\uff1a
> select * from t01;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n
"},{"location":"MatrixOne/Develop/read-data/views/#_5","title":"\u521b\u5efa\u89c6\u56fe","text":"\u4f60\u53ef\u4ee5\u901a\u8fc7 CREATE VIEW
\u8bed\u53e5\u6765\u5c06\u67d0\u4e2a\u8f83\u4e3a\u590d\u6742\u7684\u67e5\u8be2\u5b9a\u4e49\u4e3a\u89c6\u56fe\uff0c\u5176\u8bed\u6cd5\u5982\u4e0b\uff1a
CREATE VIEW view_name AS query;\n
\u521b\u5efa\u7684\u89c6\u56fe\u540d\u79f0\u4e0d\u80fd\u4e0e\u5df2\u6709\u7684\u89c6\u56fe\u6216\u8868\u91cd\u540d\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\nQuery OK, 0 rows affected (0.02 sec)\n
"},{"location":"MatrixOne/Develop/read-data/views/#_6","title":"\u67e5\u8be2\u89c6\u56fe","text":"\u89c6\u56fe\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u4fbf\u53ef\u4ee5\u4f7f\u7528 SELECT
\u8bed\u53e5\u50cf\u67e5\u8be2\u4e00\u822c\u6570\u636e\u8868\u4e00\u6837\u67e5\u8be2\u89c6\u56fe\u3002
mysql> SELECT * FROM v0;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n| 2 | NULL |\n+------+------+\n
"},{"location":"MatrixOne/Develop/read-data/views/#_7","title":"\u83b7\u53d6\u89c6\u56fe\u76f8\u5173\u4fe1\u606f","text":"\u4f7f\u7528 SHOW CREATE TABLE|VIEW view_name
\u8bed\u53e5\uff1a
mysql> SHOW CREATE VIEW v0;\n+------+----------------------------------------------------------------------------+\n| View | Create View |\n+------+----------------------------------------------------------------------------+\n| v0 | CREATE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+----------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/read-data/views/#_8","title":"\u5220\u9664\u89c6\u56fe","text":"\u901a\u8fc7 DROP VIEW view_name;
\u8bed\u53e5\u53ef\u4ee5\u5220\u9664\u5df2\u7ecf\u521b\u5efa\u7684\u89c6\u56fe\u3002
mysql> DROP VIEW v0;\n
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/","title":"\u65f6\u95f4\u7a97\u53e3","text":"\u5728\u65f6\u5e8f\u573a\u666f\u4e2d\uff0c\u6570\u636e\u901a\u5e38\u662f\u6d41\u5f0f\u7684\uff0c\u6d41\u6570\u636e\u901a\u5e38\u662f\u65e0\u7a77\u65e0\u5c3d\u7684\uff0c\u6211\u4eec\u65e0\u6cd5\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u6570\u636e\u6e90\u4f1a\u7ee7\u7eed/\u505c\u6b62\u53d1\u9001\u6570\u636e\uff0c\u6240\u4ee5\u5728\u6d41\u4e0a\u5904\u7406\u805a\u5408\u4e8b\u4ef6\uff08count\u3001sum \u7b49\uff09\u7684\u5904\u7406\u65b9\u5f0f\u4e0e\u6279\u5904\u7406\u4e2d\u7684\u5904\u7406\u65b9\u5f0f\u4f1a\u6709\u6240\u5dee\u5f02\u3002\u5728\u65f6\u5e8f\u6570\u636e\u6d41\u4e0a\u4e00\u822c\u7528\u65f6\u95f4\u7a97\u53e3\uff08Windows\uff09\u6765\u9650\u5b9a\u805a\u5408\u7684\u8303\u56f4\uff0c\u4f8b\u5982\u201c\u8fc7\u53bb 2 \u5206\u949f\u7f51\u7ad9\u70b9\u51fb\u91cf\u7684\u8ba1\u6570\u201d\u3002\u65f6\u95f4\u7a97\u53e3\u7684\u6982\u5ff5\u76f8\u5f53\u4e8e\u5e2e\u6211\u4eec\u6839\u636e\u91c7\u96c6\u65f6\u95f4\u6536\u96c6\u4e86\u4e00\u5f20\u6709\u9650\u6570\u636e\u7684\u52a8\u6001\u8868\uff0c\u6211\u4eec\u53ef\u4ee5\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u805a\u5408\u8ba1\u7b97\u3002\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u8fd9\u4e2a\u7a97\u53e3\u4f1a\u5411\u524d\u6ed1\u52a8\uff0c\u6301\u7eed\u6355\u6349\u65b0\u7684\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\u3002
\u65f6\u95f4\u7a97\u53e3\u5206\u4e3a Tumble Window\uff08\u7ffb\u6eda\u7a97\u53e3\uff09\u548c Sliding Window\uff08\u6ed1\u52a8\u7a97\u53e3\uff09\u3002Tumble Window \u7684\u65f6\u95f4\u7a97\u53e3\u957f\u5ea6\u56fa\u5b9a\uff0c\u6bcf\u4e2a\u7a97\u53e3\u65f6\u95f4\u4e0d\u91cd\u53e0\u3002\u800c Sliding Window \u7684\u65f6\u95f4\u7a97\u53e3\u957f\u5ea6\u4e5f\u56fa\u5b9a\uff0c\u4f46\u662f\u7a97\u53e3\u4e4b\u95f4\u6709\u91cd\u53e0\u90e8\u5206\uff0c\u53ef\u4ee5\u66f4\u9891\u7e41\u5730\u6355\u6349\u6570\u636e\u53d8\u5316\u3002
\u7528\u6237\u4f7f\u7528\u65f6\u95f4\u7a97\u53e3\u529f\u80fd\u65f6\uff0c\u53ef\u4ee5\u5728\u6bcf\u4e2a\u65f6\u95f4\u7a97\u53e3\u5185\u505a\u8ba1\u7b97\uff0c\u7a97\u53e3\u968f\u7740\u65f6\u95f4\u7684\u6d41\u52a8\u5411\u524d\u6ed1\u52a8\u3002\u5728\u5b9a\u4e49\u8fde\u7eed\u67e5\u8be2\u7684\u65f6\u5019\u9700\u8981\u6307\u5b9a\u65f6\u95f4\u7a97\u53e3\u7684\u5927\u5c0f\u548c\u4e0b\u4e2a\u7a97\u53e3\u5411\u524d\u7684\u589e\u91cf\u65f6\u95f4\u3002
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/#downsampling","title":"\u964d\u91c7\u6837 (Downsampling)","text":"\u964d\u91c7\u6837\u662f\u6307\u4ece\u5927\u91cf\u6570\u636e\u4e2d\u63d0\u53d6\u8f83\u5c0f\u3001\u7ba1\u7406\u6027\u66f4\u5f3a\u7684\u6570\u636e\u5b50\u96c6\u7684\u8fc7\u7a0b\u3002\u8fd9\u5728\u5904\u7406\u5927\u89c4\u6a21\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u65f6\u5c24\u4e3a\u91cd\u8981\uff0c\u53ef\u4ee5\u51cf\u5c11\u5b58\u50a8\u9700\u6c42\uff0c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\uff0c\u5e76\u5728\u6570\u636e\u53ef\u89c6\u5316\u4e2d\u63d0\u4f9b\u66f4\u6e05\u6670\u7684\u8d8b\u52bf\u56fe\u3002\u65f6\u95f4\u7a97\u53e3\u529f\u80fd\u662f\u6570\u636e\u5e93\u5b9e\u73b0\u964d\u91c7\u6837\u529f\u80fd\u7684\u6838\u5fc3\u80fd\u529b\uff0c\u901a\u8fc7\u5b9a\u4e49\u65f6\u95f4\u7a97\u53e3\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6bcf\u4e2a\u7a97\u53e3\u5185\u5bf9\u6570\u636e\u8fdb\u884c\u805a\u5408\uff0c\u4ece\u800c\u5b9e\u73b0\u964d\u91c7\u6837\u3002\u65f6\u95f4\u7a97\u53e3\u7684\u5927\u5c0f\u548c\u6ed1\u52a8\u8ddd\u79bb\u51b3\u5b9a\u4e86\u964d\u91c7\u6837\u7684\u7c92\u5ea6\u3002
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/#_2","title":"\u65f6\u5e8f\u8868\u4e0e\u65f6\u95f4\u7a97\u53e3\u8bed\u6cd5","text":"\u5728 MatrixOne \u4e2d\uff0c\u65f6\u95f4\u7a97\u53e3\u9700\u8981\u7ed3\u5408\u65f6\u5e8f\u8868\u6765\u4f7f\u7528\uff0c\u65f6\u5e8f\u8868\u662f\u6307\u5efa\u8868\u65f6\u5fc5\u987b\u4ee5 ts
\u5217\u4e3a\u4e3b\u952e\u7684\u8868\uff0c\u4e14\u7c7b\u578b\u4e3a timestamp
.
DDL Clause:\nCREATE TABLE TS_TBL (ts timestamp(6) primary key, SIGNAL1 FLOAT, SIGNAL2 DOUBLE, ...);\n\ntime_window_clause:\nINTERVAL(timestamp_col, interval_val, time_unit) [SLIDING (sliding_val)] [fill_clause]\n\ntime_unit:\nSECOND | MINUTE | HOUR | DAY\n\nfill_clause:\nFILL(NONE | PREV | NEXT | NULL | VALUE, val | LINEAR)\n
\u521b\u5efa\u65f6\u5e8f\u8868\u7684\u65f6\u5019 ts
\u5217\u53ef\u4ee5\u6307\u5b9a timestamp
\u7684\u7cbe\u5ea6\uff0c\u6700\u5927\u4e3a timestamp(6)
\uff08\u5fae\u79d2\u7ea7\u522b\uff09\u3002
INTERVAL \u8bed\u53e5\u4e2d\u7684\u53c2\u6570\u542b\u4e49\uff1a
INTERVAL (timestamp_col, interval_val) \u4f5c\u7528\u4e8e\u6570\u636e\u4ea7\u751f\u76f8\u5f53\u65f6\u95f4\u5468\u671f interval_val \u7a97\u53e3\uff0cSLIDING \u7528\u4ee5\u6307\u5b9a\u7a97\u53e3\u5411\u524d\u6ed1\u52a8\u7684 sliding_val \u65f6\u95f4\u8ddd\u79bb\u3002
\u5f53 interval_val \u7b49\u4e8e sliding_val \u65f6\u4e3a Tumble window\u3002
\u5f53 interval_val \u5927\u4e8e sliding_val \u65f6\u4e3a Sliding window\u3002
\u5176\u4ed6\u4f7f\u7528\u8bf4\u660e\uff1a
\u4f7f\u7528\u793a\u4f8b\uff1a
\u8fd9\u4e2a\u793a\u4f8b\u6f14\u793a\u5982\u4f55\u5728 10 \u5206\u949f\u7684\u65f6\u95f4\u7a97\u53e3\u5185\uff0c\u6bcf 5 \u5206\u949f\u6ed1\u52a8\u4e00\u6b21\uff0c\u7ed9\u51fa\u6bcf 5 \u5206\u949f\u7684\u6e29\u5ea6\u6700\u5927\u6700\u5c0f\u503c\u3002
mysql> drop table if exists sensor_data;\nCREATE TABLE sensor_data (ts timestamp(3) primary key, temperature FLOAT);\nINSERT INTO sensor_data VALUES('2023-08-01 00:00:00', 25.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:05:00', 26.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:15:00', 28.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:20:00', 30.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:25:00', 27.0);\nINSERT INTO sensor_data VALUES('2023-08-01 00:30:00', null);\nINSERT INTO sensor_data VALUES('2023-08-01 00:35:00', null);\nINSERT INTO sensor_data VALUES('2023-08-01 00:40:00', 28);\nINSERT INTO sensor_data VALUES('2023-08-01 00:45:00', 38);\nINSERT INTO sensor_data VALUES('2023-08-01 00:50:00', 31);\ninsert into sensor_data values('2023-07-31 23:55:00', 22);\nmysql> select _wstart, _wend, max(temperature), min(temperature) from sensor_data where ts > \"2023-08-01 00:00:00.000\" and ts < \"2023-08-01 00:50:00\" interval(ts, 10, minute) sliding(5, minute);\n+-------------------------+-------------------------+------------------+------------------+\n| _wstart | _wend | max(temperature) | min(temperature) |\n+-------------------------+-------------------------+------------------+------------------+\n| 2023-08-01 00:00:00.000 | 2023-08-01 00:10:00.000 | 26 | 26 |\n| 2023-08-01 00:05:00.000 | 2023-08-01 00:15:00.000 | 26 | 26 |\n| 2023-08-01 00:10:00.000 | 2023-08-01 00:20:00.000 | 28 | 28 |\n| 2023-08-01 00:15:00.000 | 2023-08-01 00:25:00.000 | 30 | 28 |\n| 2023-08-01 00:20:00.000 | 2023-08-01 00:30:00.000 | 30 | 27 |\n| 2023-08-01 00:25:00.000 | 2023-08-01 00:35:00.000 | 27 | 27 |\n| 2023-08-01 00:30:00.000 | 2023-08-01 00:40:00.000 | NULL | NULL |\n| 2023-08-01 00:35:00.000 | 2023-08-01 00:45:00.000 | 28 | 28 |\n| 2023-08-01 00:40:00.000 | 2023-08-01 00:50:00.000 | 38 | 28 |\n| 2023-08-01 00:45:00.000 | 2023-08-01 00:55:00.000 | 38 | 38 |\n+-------------------------+-------------------------+------------------+------------------+\n10 rows in set (0.04 sec)\n
"},{"location":"MatrixOne/Develop/read-data/window-function/time-window/#_3","title":"\u63d2\u503c","text":"\u5728\u5904\u7406\u65f6\u5e8f\u6570\u636e\u65f6\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u7f3a\u5931\u503c\u7684\u60c5\u51b5\u3002\u63d2\u503c\uff08FILL\uff09\u529f\u80fd\u5141\u8bb8\u6211\u4eec\u4ee5\u591a\u79cd\u65b9\u5f0f\u586b\u5145\u8fd9\u4e9b\u7f3a\u5931\u503c\uff0c\u786e\u4fdd\u6570\u636e\u7684\u8fde\u7eed\u6027\u548c\u5b8c\u6574\u6027\uff0c\u8fd9\u5bf9\u4e8e\u6570\u636e\u5206\u6790\u548c\u964d\u91c7\u6837\u8fc7\u7a0b\u81f3\u5173\u91cd\u8981\u3002\u65f6\u95f4\u7a97\u53e3\u7684 FIll
\u5b50\u53e5\u4f5c\u7528\u4e8e\u586b\u5145\u805a\u5408\u7ed3\u679c\u3002
MatrixOne \u63d0\u4f9b\u591a\u79cd\u63d2\u503c\u65b9\u6cd5\uff0c\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u6570\u636e\u5904\u7406\u9700\u6c42\uff1a
\u4f7f\u7528\u793a\u4f8b\uff1a
\u8fd9\u4e2a\u793a\u4f8b\u5728\u4e4b\u524d\u90a3\u5f20\u8868\u7684\u57fa\u7840\u4e0a\u589e\u52a0\u4e86\u63d2\u503c\u903b\u8f91\uff0c\u4f1a\u5c06 NULL \u503c\u586b\u5145\u3002
select _wstart(ts), _wend(ts), max(temperature), min(temperature) from sensor_data where ts > \"2023-08-01 00:00:00.000\" and ts < \"2023-08-01 00:50:00.000\" interval(ts, 10, minute) sliding(5, minute) fill(prev);\n_wstart | _wend | max(temperature) | min(temperature) |\n==================================================================================================\n2023-08-01 00:00:00.000 | 2023-08-01 00:10:00.000 | 26.0000000 | 26.0000000 |\n2023-08-01 00:05:00.000 | 2023-08-01 00:15:00.000 | 26.0000000 | 26.0000000 |\n2023-08-01 00:10:00.000 | 2023-08-01 00:20:00.000 | 28.0000000 | 28.0000000 |\n2023-08-01 00:15:00.000 | 2023-08-01 00:25:00.000 | 30.0000000 | 28.0000000 |\n2023-08-01 00:20:00.000 | 2023-08-01 00:30:00.000 | 30.0000000 | 27.0000000 |\n2023-08-01 00:25:00.000 | 2023-08-01 00:35:00.000 | 27.0000000 | 27.0000000 |\n2023-08-01 00:30:00.000 | 2023-08-01 00:40:00.000 | 27.0000000 | 27.0000000 |\n2023-08-01 00:35:00.000 | 2023-08-01 00:45:00.000 | 28.0000000 | 28.0000000 |\n2023-08-01 00:40:00.000 | 2023-08-01 00:50:00.000 | 38.0000000 | 28.0000000 |\n2023-08-01 00:45:00.000 | 2023-08-01 00:55:00.000 | 38.0000000 | 38.0000000 |\n
"},{"location":"MatrixOne/Develop/read-data/window-function/window-function/","title":"\u7a97\u53e3\u51fd\u6570","text":"\u7a97\u53e3\u51fd\u6570\uff08Window Function\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u51fd\u6570\uff0c\u5b83\u80fd\u591f\u5728\u67e5\u8be2\u7ed3\u679c\u96c6\u7684\u67d0\u4e2a\u7a97\u53e3\uff08Window\uff09\u4e0a\u6267\u884c\u8ba1\u7b97\u64cd\u4f5c\u3002\u7a97\u53e3\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u5206\u7ec4\u3001\u6392\u5e8f\u548c\u805a\u5408\u64cd\u4f5c\uff0c\u540c\u65f6\u8fd8\u80fd\u591f\u5728\u6bcf\u4e2a\u7a97\u53e3\u5185\u8ba1\u7b97\u6bcf\u884c\u6570\u636e\u7684\u76f8\u5173\u503c\uff0c\u800c\u65e0\u9700\u6539\u53d8\u7ed3\u679c\u96c6\u7684\u884c\u6570\u3002\u5373\u901a\u8fc7\u7a97\u53e3\u51fd\u6570\uff0c\u53ef\u4ee5\u5728\u4e0d\u5f15\u5165\u989d\u5916\u7684\u5b50\u67e5\u8be2\u6216\u8fde\u63a5\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\uff0c\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u7075\u6d3b\u7684\u5206\u6790\u548c\u5904\u7406\u3002
SQL \u7a97\u53e3\u51fd\u6570\u5728\u591a\u79cd\u4e1a\u52a1\u573a\u666f\u4e2d\u90fd\u6709\u5176\u5e7f\u6cdb\u7684\u5e94\u7528\uff1a
\u884c\u5185\u6bd4\u8f83\uff1a\u5c06\u6bcf\u4e00\u884c\u7684\u67d0\u4e2a\u503c\u4e0e\u540c\u4e00\u7ec4\u5185\u7684\u5176\u4ed6\u884c\u8fdb\u884c\u6bd4\u8f83\uff0c\u4f8b\u5982\u8ba1\u7b97\u6bcf\u4e2a\u5458\u5de5\u7684\u85aa\u6c34\u4e0e\u90e8\u95e8\u5e73\u5747\u85aa\u6c34\u7684\u5dee\u503c\u3002\u8fd9\u65f6\u5019\uff0c\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528\u7a97\u53e3\u51fd\u6570\u3002
\u6570\u636e\u6392\u540d\uff1a\u7a97\u53e3\u51fd\u6570\u53ef\u4ee5\u65b9\u4fbf\u5730\u751f\u6210\u6570\u636e\u7684\u6392\u540d\u4fe1\u606f\uff0c\u4f8b\u5982\uff0c\u4f60\u60f3\u8981\u67e5\u770b\u9500\u552e\u989d\u7684\u6392\u540d\uff0c\u53ef\u4ee5\u4f7f\u7528 RANK()
\u6216\u8005 ROW_NUMBER()
\u51fd\u6570\u3002
\u6eda\u52a8\u8ba1\u7b97\uff1a\u8ba1\u7b97\u79fb\u52a8\u5e73\u5747\u3002\u4f60\u53ef\u4ee5\u5b9a\u4e49\u7a97\u53e3\u51fd\u6570\u7684\u7a97\u53e3\u8303\u56f4\uff0c\u7136\u540e\u8fdb\u884c\u6eda\u52a8\u8ba1\u7b97\u3002
\u5927\u591a\u6570\u805a\u5408\u51fd\u6570\u4e5f\u53ef\u4ee5\u7528\u4f5c\u7a97\u53e3\u51fd\u6570\uff0c\u4f8b\u5982\uff0cSUM()
\u3001AVG()
\u3001COUNT()
\u8fd9\u4e9b\u805a\u5408\u51fd\u6570\u53ef\u4ee5\u4e0e\u7a97\u53e3\u51fd\u6570\u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u5728\u7a97\u53e3\u5185\u8ba1\u7b97\u67d0\u4e2a\u5217\u7684\u603b\u548c\u3001\u5e73\u5747\u503c\u6216\u8ba1\u6570\u3002MatrixOne \u652f\u6301\u7684\u53ef\u505a\u7a97\u53e3\u51fd\u6570\u7684\u805a\u5408\u51fd\u6570\u548c\u53c2\u8003\u6587\u6863\u53c2\u89c1\uff1a
\u5176\u4ed6\u7a97\u53e3\u51fd\u6570\u53c2\u89c1\u4e0b\u8868\uff1a
\u4f7f\u7528\u7a97\u53e3\u51fd\u6570\u901a\u5e38\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u5b9a\u4e49\u7a97\u53e3\uff08Window\uff09\uff1a\u901a\u8fc7\u4f7f\u7528 OVER \u5b50\u53e5\u6765\u5b9a\u4e49\u7a97\u53e3\u7684\u8303\u56f4\uff0c\u53ef\u4ee5\u6307\u5b9a\u7a97\u53e3\u7684\u6392\u5e8f\u89c4\u5219\u3001\u5206\u533a\u65b9\u5f0f\u548c\u884c\u8303\u56f4\u7b49\u3002
\u7f16\u5199\u7a97\u53e3\u51fd\u6570\uff1a\u5728 SELECT
\u8bed\u53e5\u4e2d\uff0c\u5c06\u7a97\u53e3\u51fd\u6570\u4e0e\u5176\u4ed6\u5217\u4e00\u8d77\u5217\u51fa\uff0c\u6307\u5b9a\u9700\u8981\u5728\u7a97\u53e3\u5185\u8ba1\u7b97\u7684\u5217\u548c\u64cd\u4f5c\u3002
\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528\u7a97\u53e3\u51fd\u6570\u8ba1\u7b97\u6bcf\u4e2a\u90e8\u95e8\u7684\u9500\u552e\u603b\u989d\u548c\u90e8\u95e8\u5185\u6bcf\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u6392\u540d\uff1a
CREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\nSELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR | Charlie | 850 | 1650 | 1 |\n| HR | Alice | 800 | 1650 | 2 |\n| Marketing | Jane | 1200 | 2200 | 1 |\n| Marketing | John | 1000 | 2200 | 2 |\n| Sales | Bob | 1100 | 2000 | 1 |\n| Sales | Alex | 900 | 2000 | 2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0cPARTITION BY
\u5b50\u53e5\u7528\u4e8e\u5c06\u7ed3\u679c\u96c6\u6309\u90e8\u95e8\u5206\u533a\uff0c\u7136\u540e SUM()
\u51fd\u6570\u8ba1\u7b97\u6bcf\u4e2a\u90e8\u95e8\u7684\u9500\u552e\u603b\u989d\u3002\u540c\u65f6\uff0cORDER BY
\u5b50\u53e5\u6307\u5b9a\u6309\u9500\u552e\u989d\u964d\u5e8f\u6392\u5217\uff0cRANK()
\u51fd\u6570\u6839\u636e\u9500\u552e\u989d\u4e3a\u6bcf\u4e2a\u90e8\u95e8\u5185\u7684\u5458\u5de5\u5206\u914d\u6392\u540d\u3002
\u672c\u7bc7\u6587\u7ae0\u7b80\u8981\u6982\u8ff0\u4e86 MatrixOne \u7684\u6570\u636e\u5e93\u6a21\u5f0f\u3002\u672c\u7bc7\u6982\u8ff0\u4e3b\u8981\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u76f8\u5173\u672f\u8bed\u548c\u540e\u7eed\u7684\u6570\u636e\u8bfb\u5199\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#-","title":"\u5173\u952e\u672f\u8bed - \u6570\u636e\u5e93\u6a21\u5f0f","text":"\u6570\u636e\u5e93\u6a21\u5f0f (Schema)\uff1a\u672c\u7bc7\u6587\u7ae0\u6240\u63d0\u5230\u7684\u6570\u636e\u5e93\u6a21\u5f0f\u7b49\u540c\u4e8e\u903b\u8f91\u5bf9\u8c61\u6570\u636e\u5e93\uff0c\u4e0e MySQL \u4e00\u6837\uff0c\u4e0d\u505a\u533a\u5206\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#database","title":"\u6570\u636e\u5e93 Database","text":"MatrixOne \u6570\u636e\u5e93\u6216 MatrixOne Database\uff0c\u4e3a\u8868\u7684\u96c6\u5408\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 SHOW DATABASES;
\u67e5\u770b MatrixOne \u6240\u5305\u542b\u7684\u9ed8\u8ba4\u6570\u636e\u5e93\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 CREATE DATABASE database_name;
\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u3002
MatrixOne \u6240\u6307\u7684\u8868\u6216 Table\uff0c\u4ece\u5c5e\u4e8e MatrixOne \u7684\u67d0\u4e2a\u6570\u636e\u5e93\u3002
\u8868\u5305\u542b\u6570\u636e\u884c\u3002\u6bcf\u884c\u6570\u636e\u4e2d\u7684\u6bcf\u4e2a\u503c\u90fd\u5c5e\u4e8e\u4e00\u4e2a\u7279\u5b9a\u7684\u5217\u3002\u6bcf\u5217\u90fd\u53ea\u5141\u8bb8\u5355\u4e00\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#index","title":"\u7d22\u5f15 Index","text":"\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u6570\u636e\u5e93\u8868\u683c\u4e2d\u7684\u6570\u636e\u3002\u5b83\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u672c\u76ee\u5f55\uff0c\u5305\u542b\u6709\u5173\u8868\u683c\u4e2d\u5404\u884c\u6570\u636e\u7684\u6307\u9488\uff0c\u4f7f\u5f97\u67e5\u8be2\u53ef\u4ee5\u66f4\u5feb\u901f\u5730\u5b9a\u4f4d\u5230\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u6570\u636e\u3002
\u6570\u636e\u5e93\u4e2d\u5e38\u7528\u7684\u7d22\u5f15\u7c7b\u578b\u5305\u62ec\u4e3b\u952e\u7d22\u5f15\u3001\u6b21\u7ea7\u7d22\u5f15\u7b49\u3002\u5176\u4e2d\uff0c\u552f\u4e00\u7d22\u5f15\u7528\u4e8e\u4fdd\u8bc1\u7279\u5b9a\u5217\u6216\u5217\u7ec4\u5408\u7684\u552f\u4e00\u6027\uff0c\u666e\u901a\u7d22\u5f15\u7528\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\uff0c\u5168\u6587\u7d22\u5f15\u5219\u7528\u4e8e\u5728\u6587\u672c\u6570\u636e\u4e2d\u8fdb\u884c\u5168\u6587\u68c0\u7d22\u3002
\u7d22\u5f15\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u7c7b\u578b\uff0c\u5206\u522b\u4e3a\uff1a
Note: \u5f53\u524d MatrixOne \u4ec5\u652f\u6301\u4e3b\u952e\u7d22\u5f15\uff08Primary Key\uff09\u3002
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#_2","title":"\u5176\u4ed6\u5bf9\u8c61","text":"MatrixOne \u652f\u6301\u4e00\u4e9b\u548c\u8868\u540c\u7ea7\u7684\u5bf9\u8c61\uff1a
MatrixOne \u73b0\u5728\u652f\u6301\u5b58\u50a8\u548c\u67e5\u8be2\u5411\u91cf\u3002\u5411\u91cf\u662f\u901a\u5e38\u7531 AI \u6a21\u578b\uff08\u5982\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff09\u751f\u6210\u7684\u6570\u5b57\u5217\u8868\u3002
Note: \u5f53\u524d MatrixOne \u4ec5\u652f\u6301\u63d2\u5165\u548c\u67e5\u8be2\u5411\u91cf\u6570\u636e\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u5411\u91cf
"},{"location":"MatrixOne/Develop/schema-design/1.1-overview/#_4","title":"\u8bbf\u95ee\u63a7\u5236","text":"MatrixOne \u652f\u6301\u57fa\u4e8e\u7528\u6237\u6216\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u89d2\u8272\u6216\u76f4\u63a5\u6307\u5411\u7528\u6237\uff0c\u4ece\u800c\u6388\u4e88\u7528\u6237\u67e5\u770b\u3001\u4fee\u6539\u6216\u5220\u9664\u6570\u636e\u5bf9\u8c61\u548c\u6570\u636e\u6a21\u5f0f\u7684\u6743\u9650\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 MatrixOne \u4e2d\u7684\u6743\u9650\u63a7\u5236\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-database/","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"\u672c\u7bc7\u6587\u6863\u4e2d\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u6765\u521b\u5efa\u6570\u636e\u5e93\uff0c\u53ca\u521b\u5efa\u6570\u636e\u5e93\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219\u3002
Note
\u6b64\u5904\u4ec5\u5bf9 CREATE DATABASE
\u8bed\u53e5\u8fdb\u884c\u7b80\u5355\u63cf\u8ff0\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE DATABASE\u3002
\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u5728 MatrixOne \u4e2d\u6570\u636e\u5e93\u5bf9\u8c61\u53ef\u4ee5\u5305\u542b\u8868\u3001\u89c6\u56fe\u7b49\u5bf9\u8c61\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-database/#_4","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"\u53ef\u4f7f\u7528 CREATE DATABASE
\u8bed\u53e5\u6765\u521b\u5efa\u6570\u636e\u5e93\u3002
CREATE DATABASE IF NOT EXISTS `modatabase`;\n
\u6b64\u8bed\u53e5\u4f1a\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a modatabase \u7684\u6570\u636e\u5e93\uff08\u5982\u679c\u5c1a\u4e0d\u5b58\u5728\uff09\u3002
\u8981\u67e5\u770b\u96c6\u7fa4\u4e2d\u7684\u6570\u636e\u5e93\uff0c\u53ef\u5728\u547d\u4ee4\u884c\u6267\u884c\u4e00\u6761 SHOW DATABASES
\u8bed\u53e5\uff1a
SHOW DATABASES;\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+--------------------+\n| Database |\n+--------------------+\n| mo_catalog |\n| system |\n| system_metrics |\n| mysql |\n| information_schema |\n| modatabase |\n+--------------------+\n
"},{"location":"MatrixOne/Develop/schema-design/create-database/#_5","title":"\u6570\u636e\u5e93\u521b\u5efa\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219","text":"\u4f60\u53ef\u4ee5\u4f7f\u7528 CREATE DATABASE
\u8bed\u53e5\u6765\u521b\u5efa\u6570\u636e\u5e93\uff0c\u5e76\u4e14\u5728 SQL \u4f1a\u8bdd\u4e2d\u4f7f\u7528 USE {databasename};
\u8bed\u53e5\u6765\u4f7f\u7528\u4f60\u6240\u521b\u5efa\u7684\u6570\u636e\u5e93\u3002
\u79df\u6237\u6216\u7528\u6237\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u3001\u89d2\u8272\u6216\u5b50\u7ea7\u7528\u6237\u65f6\uff0c\u53ea\u8d4b\u4e88\u79df\u6237\u6216\u7528\u6237\u5fc5\u8981\u7684\u6743\u9650\uff0c\u53c2\u89c1 MatrixOne \u4e2d\u7684\u6743\u9650\u63a7\u5236\u3002
\u4f60\u5df2\u7ecf\u51c6\u5907\u5b8c\u6bd5 modatabase \u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u5c06\u8868\u6dfb\u52a0\u5230\u8be5\u6570\u636e\u5e93\u4e2d\uff0c\u53c2\u89c1\u4e0b\u4e00\u7ae0\u8282\u521b\u5efa\u8868\u3002
\u5728\u975e\u4e3b\u952e\u4e0a\u6807\u8bc6\u7684\u7d22\u5f15\uff0c\u6b21\u7ea7\u7d22\u5f15\u4e5f\u79f0\u4e3a\u975e\u805a\u96c6\u7d22\u5f15\uff08non-clustered index\uff09\uff0c\u7528\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u548c\u52a0\u901f\u6570\u636e\u68c0\u7d22\u3002\u6b21\u7ea7\u7d22\u5f15\u5e76\u4e0d\u76f4\u63a5\u5b58\u50a8\u8868\u6570\u636e\uff0c\u800c\u662f\u5bf9\u6570\u636e\u7684\u4e00\u90e8\u5206\uff08\u5982\u67d0\u4e2a\u5217\uff09\u5efa\u7acb\u7d22\u5f15\uff0c\u4ece\u800c\u5141\u8bb8\u6570\u636e\u5e93\u7cfb\u7edf\u5feb\u901f\u5b9a\u4f4d\u8868\u4e2d\u5305\u542b\u7279\u5b9a\u503c\u7684\u884c\u3002
\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\u53ef\u4ee5\u5e2e\u52a9\u52a0\u901f\u67e5\u8be2\u64cd\u4f5c\uff0c\u7279\u522b\u662f\u5728\u5bf9\u5927\u578b\u8868\u8fdb\u884c\u67e5\u8be2\u65f6\u3002\u6b21\u7ea7\u7d22\u5f15\u8fd8\u53ef\u4ee5\u7528\u4e8e\u652f\u6301\u6392\u5e8f\u3001\u5206\u7ec4\u548c\u8fde\u63a5\u64cd\u4f5c\uff0c\u8fd9\u4e9b\u64cd\u4f5c\u901a\u5e38\u9700\u8981\u5bf9\u8868\u4e2d\u7684\u4e00\u90e8\u5206\u6570\u636e\u8fdb\u884c\u6392\u5e8f\u6216\u8005\u5339\u914d\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#_3","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\u79cd\u662f\u5728\u5efa\u8868\u7684\u65f6\u5019\u5c31\u5efa\u7acb KEY
\u6b21\u7ea7\u7d22\u5f15\uff0c\u53e6\u4e00\u79cd\u53ef\u4ee5\u5728\u5efa\u8868\u540e\u901a\u8fc7 CREATE INDEX
\u6216\u8005 ALTER TABLE ADD index
\u8bed\u53e5\u52a8\u6001\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\uff0c\u6307\u5b9a\u7d22\u5f15\u6240\u9488\u5bf9\u7684\u5217\u4ee5\u53ca\u5176\u4ed6\u7d22\u5f15\u9009\u9879\u3002
\u8bed\u6cd5\u7ed3\u6784\u5206\u522b\u4e3a\uff1a
CREATE TABLE table_name (\ncol1 int primary key, col2 int, KEY index_name (col2) );\n\nCREATE INDEX index_name ON table_name (column_name);\n\nALTER TABLE ADD INDEX index_name ON table_name (column_name);\n
\u5176\u4e2d\uff0cindex_name
\u662f\u7d22\u5f15\u7684\u540d\u79f0\uff0ctable_name
\u662f\u8981\u5728\u5176\u4e0a\u521b\u5efa\u7d22\u5f15\u7684\u8868\u683c\u540d\u79f0\uff0c\u800c column_name
\u662f\u7528\u4e8e\u521b\u5efa\u7d22\u5f15\u7684\u5217\u540d\u3002
\u4f8b\u5982\uff0c\u5982\u679c\u8981\u5728\u540d\u4e3a employees
\u7684\u8868\u683c\u7684 last_name
\u5217\u4e0a\u521b\u5efa\u4e00\u4e2a\u6b21\u7ea7\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\uff1a
CREATE INDEX idx_lastname ON employees (last_name);\n
\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\uff1a\u53ef\u4ee5\u5728\u67e5\u8be2\u8bed\u53e5\u4e2d\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\u6765\u5b9a\u4f4d\u6570\u636e\u884c\u3002SQL \u67e5\u8be2\u4f18\u5316\u5668\u4f1a\u81ea\u52a8\u9009\u62e9\u5408\u9002\u7684\u7d22\u5f15\u6765\u6267\u884c\u67e5\u8be2\u64cd\u4f5c\uff0c\u4ee5\u83b7\u5f97\u6700\u4f73\u6027\u80fd\u3002\u5982\uff1a
SELECT * FROM employees WHERE last_name = 'Smith';\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u67e5\u8be2\u4f18\u5316\u5668\u4f1a\u4f7f\u7528 idx_lastname
\u7d22\u5f15\u6765\u5b9a\u4f4d last_name
\u4e3a Smith
\u7684\u6570\u636e\u884c\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u521b\u5efa\u7d22\u5f15\u4f1a\u589e\u52a0\u6570\u636e\u5e93\u7684\u5b58\u50a8\u548c\u7ef4\u62a4\u6210\u672c\uff0c\u5e76\u4e14\u5728\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u6570\u636e\u65f6\u4e5f\u53ef\u80fd\u4f1a\u5f71\u54cd\u6027\u80fd\u3002\u56e0\u6b64\uff0c\u5728\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\u65f6\u9700\u8981\u4ed4\u7ec6\u8003\u8651\u5176\u5bf9\u6570\u636e\u5e93\u6027\u80fd\u7684\u5f71\u54cd\uff0c\u5e76\u8fdb\u884c\u5fc5\u8981\u7684\u4f18\u5316\u548c\u8c03\u6574\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#sql","title":"SQL \u793a\u4f8b","text":"CREATE TABLE users (id INT PRIMARY KEY,\nname VARCHAR(50),\nage INT,\nemail VARCHAR(50)\n);\n-- \u6211\u4eec\u53ef\u4ee5\u5728\u8868\u683c\u4e0a\u521b\u5efa\u4e00\u4e2a\u6b21\u7ea7\u7d22\u5f15\u6765\u52a0\u5feb\u6309\u540d\u5b57\u67e5\u8be2\u7528\u6237\u7684\u901f\u5ea6\nCREATE INDEX idx_users_name ON users(name);\n-- \u63d2\u5165\u4e00\u4e9b\u6570\u636e\nINSERT INTO users VALUES ('1', 'John', '30', 'john@gmail.com');\nINSERT INTO users VALUES ('2', 'Tommy', '50', 'tom@gmail.com');\nINSERT INTO users VALUES ('3', 'Ann', '33', 'ann@gmail.com');\n-- \u6267\u884c\u5982\u4e0b\u67e5\u8be2\uff0c\u6570\u636e\u5e93\u53ef\u4ee5\u4f7f\u7528\u6b21\u7ea7\u7d22\u5f15\u6765\u5feb\u901f\u5730\u67e5\u627e\u6240\u6709\u540d\u5b57\u4e3a\u201cJohn\u201d\u7684\u7528\u6237\uff0c\u800c\u4e0d\u5fc5\u626b\u63cf\u6574\u4e2a\u8868\u683c\u3002\nmysql> SELECT * FROM users WHERE name = 'John';\n+------+------+------+----------------+\n| id | name | age | email |\n+------+------+------+----------------+\n| 1 | John | 30 | john@gmail.com |\n+------+------+------+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Develop/schema-design/create-secondary-index/#_5","title":"\u590d\u5408\u6b21\u7ea7\u7d22\u5f15","text":"MatrixOne \u4e5f\u652f\u6301\u590d\u5408\u6b21\u7ea7\u7d22\u5f15\uff0c\u5373\u5728\u4e24\u4e2a\u6216\u66f4\u591a\u5217\u4e0a\u521b\u5efa\u7684\u7d22\u5f15\u3002\u5b83\u5141\u8bb8\u5728\u4e00\u4e2a\u7d22\u5f15\u4e2d\u5305\u542b\u591a\u4e2a\u5217\uff0c\u4ece\u800c\u4f18\u5316\u6d89\u53ca\u8fd9\u4e9b\u5217\u7684\u67e5\u8be2\u3002
\u5bf9\u4e8e\u8de8\u591a\u4e2a\u5217\u7684\u67e5\u8be2\uff0c\u590d\u5408\u7d22\u5f15\u53ef\u4ee5\u5927\u5e45\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002\u5b83\u4eec\u5728\u6267\u884c\u6392\u5e8f\u548c\u8fc7\u6ee4\u4efb\u52a1\u65f6\u7279\u522b\u6709\u6548\uff0c\u5c24\u5176\u662f\u5f53\u8fd9\u4e9b\u64cd\u4f5c\u6d89\u53ca\u5230\u591a\u4e2a\u5b57\u6bb5\u65f6\u3002\u5982\u679c\u67e5\u8be2\u53ea\u6d89\u53ca\u7d22\u5f15\u4e2d\u7684\u5217\uff0c\u6570\u636e\u5e93\u53ef\u4ee5\u76f4\u63a5\u4ece\u7d22\u5f15\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u800c\u65e0\u9700\u8bbf\u95ee\u8868\u4e2d\u7684\u884c\uff0c\u8fd9\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002
\u590d\u5408\u6b21\u7ea7\u7d22\u5f15\u4f7f\u7528\u6ce8\u610f\u4e8b\u9879\uff1a
\u5047\u8bbe\u6709\u4e00\u4e2a\u8ba2\u5355\u8868 orders
\uff0c\u5176\u4e2d\u5305\u542b customer_id
, order_date
, \u548c status
\u5217\u3002\u4e3a\u4e86\u4f18\u5316\u6d89\u53ca\u8fd9\u4e9b\u5217\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u590d\u5408\u7d22\u5f15\uff1a
CREATE INDEX idx_customer_date_status ON orders(customer_id, order_date, status);\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5982\u679c\u6709\u57fa\u4e8e customer_id
\u548c order_date
\u7684\u67e5\u8be2\uff0c\u8fd9\u4e2a\u590d\u5408\u7d22\u5f15\u4f1a\u975e\u5e38\u6709\u7528\u3002\u7136\u800c\uff0c\u5982\u679c\u67e5\u8be2\u53ea\u6d89\u53ca order_date
\uff0c\u8fd9\u4e2a\u590d\u5408\u7d22\u5f15\u53ef\u80fd\u4e0d\u4f1a\u88ab\u6709\u6548\u5229\u7528\uff0c\u56e0\u4e3a order_date
\u4e0d\u662f\u7d22\u5f15\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5217\u3002
MatrixOne \u6682\u65f6\u4e0d\u652f\u6301 Online DDL\u3002\u52a8\u6001\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\uff0c\u65e0\u8bba\u662f ALTER TABLE ADD INDEX
\u8fd8\u662f CREATE INDEX
\u90fd\u4f1a\u5bfc\u81f4\u539f\u8868\u4e0a\u9501\uff0c\u5176\u4ed6\u4e8b\u52a1\u7684 DML \u64cd\u4f5c\u4f1a\u88ab\u963b\u585e (INSERT, UPDATE,DELETE, SELECT FOR UPDATE)\u3002
MatrixOne \u76ee\u524d\u4e0d\u652f\u6301 FULLTEXT \u53ca SPATIAL \u7d22\u5f15\u3002
CTAS(Create Table As Select)\uff0c\u662f\u4e00\u79cd SQL \u8bed\u53e5\uff0c\u7528\u4e8e\u57fa\u4e8e\u73b0\u6709\u8868\u6216\u67e5\u8be2\u7ed3\u679c\u5feb\u901f\u521b\u5efa\u4e00\u4e2a\u65b0\u8868 (\u590d\u5236\u8868\uff09\u3002CTAS \u8bed\u53e5\u6267\u884c\u65f6\uff0c\u4f1a\u6839\u636e SELECT \u5b50\u53e5\u751f\u6210\u7684\u6570\u636e\u76f4\u63a5\u521b\u5efa\u4e00\u4e2a\u65b0\u8868\uff0c\u5e76\u4e14\u65b0\u8868\u7684\u5217\u7ed3\u6784\u548c\u6570\u636e\u7c7b\u578b\u4f1a\u4e0e SELECT \u5b50\u53e5\u4e2d\u7684\u7ed3\u679c\u96c6\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_1","title":"\u5e94\u7528\u573a\u666f","text":"CTAS \u7684\u5e94\u7528\u573a\u666f\u975e\u5e38\u5e7f\u6cdb\uff0c\u4e3b\u8981\u5305\u62ec\uff1a
\u6570\u636e\u8fc1\u79fb\uff1a\u4f7f\u7528 CTAS \u53ef\u4ee5\u5feb\u901f\u5730\u5c06\u6570\u636e\u4ece\u4e00\u4e2a\u8868\u8fc1\u79fb\u5230\u53e6\u4e00\u4e2a\u8868\uff0c\u540c\u65f6\u53ef\u4ee5\u6539\u53d8\u8868\u7684\u5b58\u50a8\u7ed3\u6784\u548c\u5206\u5e03\u7b56\u7565\uff0c\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u67e5\u8be2\u548c\u5b58\u50a8\u9700\u6c42\u3002
\u6570\u636e\u5907\u4efd\uff1aCTAS \u53ef\u4ee5\u7528\u6765\u521b\u5efa\u6570\u636e\u7684\u5907\u4efd\u526f\u672c\uff0c\u8fd9\u5bf9\u4e8e\u6570\u636e\u6062\u590d\u548c\u5386\u53f2\u6570\u636e\u5206\u6790\u975e\u5e38\u6709\u7528\u3002
\u8868\u7ed3\u6784\u53d8\u66f4\uff1a\u5f53\u9700\u8981\u4fee\u6539\u8868\u7ed3\u6784\uff08\u5982\u6dfb\u52a0\u6216\u5220\u9664\u5217\u3001\u66f4\u6539\u6570\u636e\u7c7b\u578b\u7b49\uff09\u65f6\uff0cCTAS \u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868\u6765\u53cd\u6620\u8fd9\u4e9b\u66f4\u6539\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u539f\u59cb\u8868\u3002
\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\uff1a\u5728\u6570\u636e\u79d1\u5b66\u9879\u76ee\u4e2d\uff0cCTAS \u53ef\u4ee5\u7528\u4e8e\u51c6\u5907\u6570\u636e\u96c6\uff0c\u521b\u5efa\u9002\u5408\u673a\u5668\u5b66\u4e60\u6a21\u578b\u8bad\u7ec3\u7684\u5e72\u51c0\u3001\u683c\u5f0f\u5316\u7684\u6570\u636e\u8868\u3002
CTAS \u662f\u4e00\u79cd\u9ad8\u6548\u7684 SQL \u64cd\u4f5c\uff0c\u5b83\u901a\u8fc7\u7b80\u5316\u6570\u636e\u7ba1\u7406\u6d41\u7a0b\u548c\u589e\u5f3a\u64cd\u4f5c\u7684\u7075\u6d3b\u6027\uff0c\u5927\u5e45\u63d0\u5347\u4e86\u6570\u636e\u5904\u7406\u548c\u5206\u6790\u7684\u6548\u7387\u3002\u4f46\u5728\u5e94\u7528 CTAS \u65f6\uff0c\u9700\u8981\u8003\u8651\u5230\u76ee\u6807\u6570\u636e\u5e93\u7cfb\u7edf\u5bf9 CTAS \u7684\u652f\u6301\u7a0b\u5ea6\u53ca\u5176\u5bf9\u7cfb\u7edf\u6027\u80fd\u7684\u6f5c\u5728\u5f71\u54cd\uff0c\u4ee5\u4fdd\u8bc1\u6570\u636e\u540c\u6b65\u548c\u64cd\u4f5c\u7684\u51c6\u786e\u6027\u548c\u6709\u6548\u6027\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#ctas_2","title":"\u5982\u4f55\u4f7f\u7528 CTAS","text":""},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_3","title":"\u8bed\u6cd5","text":"CTAS
\u8bed\u53e5\u901a\u5e38\u91c7\u7528\u4ee5\u4e0b\u5f62\u5f0f\uff1a
CREATE [TEMPORARY] TABLE table_name as select
\u6709\u5173\u66f4\u591a\u7684\u8bed\u6cd5\u8bf4\u660e\uff0c\u8bf7\u67e5\u770b\u7ae0\u8282 Create Table As Select
"},{"location":"MatrixOne/Develop/schema-design/create-table-as-select/#_4","title":"\u6848\u4f8b","text":"\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u7535\u5b50\u5546\u52a1\u5e73\u53f0\uff0c\u5e76\u4e14\u6211\u4eec\u60f3\u8981\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u8868\u6765\u5206\u6790\u6bcf\u4e2a\u8ba2\u5355\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u8ba2\u5355\u53f7\u3001\u5ba2\u6237 ID\u3001\u8ba2\u5355\u65e5\u671f\u3001\u4ea7\u54c1 ID\u3001\u4ea7\u54c1\u6570\u91cf\u548c\u4ea7\u54c1\u4ef7\u683c\u3002
CREATE TABLE orders(\norder_id int auto_increment PRIMARY KEY,\ncustomer_id int,\norder_date date,\nproduct_id int,\nquantity int,\nprice float\n);\n\nINSERT INTO orders(customer_id,order_date,product_id,quantity,price) values(30,\"2023-04-01\",5001,2,19.99);\nINSERT INTO orders(customer_id,order_date,product_id,quantity,price) values(40,\"2023-04-02\",5002,1,29.99);\nINSERT INTO orders(customer_id,order_date,product_id,quantity,price) values(30,\"2023-04-03\",5001,1,19.99);\n\nmysql> select * from orders;\n+----------+-------------+------------+------------+----------+-------+\n| order_id | customer_id | order_date | product_id | quantity | price |\n+----------+-------------+------------+------------+----------+-------+\n| 1 | 30 | 2023-04-01 | 5001 | 2 | 19.99 |\n| 2 | 40 | 2023-04-02 | 5002 | 1 | 29.99 |\n| 3 | 30 | 2023-04-03 | 5001 | 1 | 19.99 |\n+----------+-------------+------------+------------+----------+-------+\n3 rows in set (0.00 sec)\n\n--\u4e3a\u4e86\u4fbf\u4e8e\u5206\u6790\uff0c\u6211\u4eec\u60f3\u8981\u5c06\u6bcf\u4e2a\u8ba2\u5355\u7684\u603b\u4ef7\u683c\u8ba1\u7b97\u51fa\u6765\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u8ba2\u5355\u53f7\u3001\u5ba2\u6237 ID\u3001\u8ba2\u5355\u65e5\u671f\u548c\u8ba2\u5355\u603b\u4ef7\u683c\u3002\nCREATE TABLE orders_analysis AS\nSELECT order_id,\ncustomer_id,\norder_date,\nproduct_id,\nquantity,\nprice,\nCAST((quantity * price) AS float) AS total_price\nFROM orders;\n\nmysql> select * from orders_analysis;\n+----------+-------------+------------+------------+----------+-------+-------------+\n| order_id | customer_id | order_date | product_id | quantity | price | total_price |\n+----------+-------------+------------+------------+----------+-------+-------------+\n| 1 | 30 | 2023-04-01 | 5001 | 2 | 19.99 | 39.98 |\n| 2 | 40 | 2023-04-02 | 5002 | 1 | 29.99 | 29.99 |\n| 3 | 30 | 2023-04-03 | 5001 | 1 | 19.99 | 19.99 |\n+----------+-------------+------------+------------+----------+-------+-------------+\n3 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cCTAS \u8bed\u53e5\u4e0d\u4ec5\u590d\u5236\u4e86\u539f\u59cb\u8868\u4e2d\u7684\u5217\uff0c\u800c\u4e14\u8fd8\u6dfb\u52a0\u4e86\u4e00\u4e2a\u65b0\u7684\u8ba1\u7b97\u5217 total_price\uff0c\u8be5\u5217\u901a\u8fc7\u5c06\u6bcf\u4e2a\u8ba2\u5355\u7684\u4ea7\u54c1\u6570\u91cf\u4e58\u4ee5\u4ef7\u683c\u6765\u8ba1\u7b97\u8ba2\u5355\u884c\u9879\u7684\u603b\u4ef7\u683c\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u5c31\u5f97\u5230\u4e86\u4e00\u4e2a\u9002\u5408\u8fdb\u884c\u9500\u552e\u5206\u6790\u7684\u65b0\u8868\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528\u4e8e\u751f\u6210\u62a5\u544a\u6216\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u6570\u636e\u5206\u6790\u3002
\u8fd9\u4e2a\u4f8b\u5b50\u5c55\u793a\u4e86 CTAS \u5728\u6570\u636e\u8f6c\u6362\u548c\u51c6\u5907\u65b9\u9762\u7684\u5f3a\u5927\u80fd\u529b\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\u5728\u521b\u5efa\u65b0\u8868\u7684\u540c\u65f6\u8fdb\u884c\u6570\u636e\u7684\u6e05\u6d17\u548c\u8f6c\u6362\uff0c\u4ece\u800c\u4e3a\u6570\u636e\u5206\u6790\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/","title":"\u521b\u5efa\u8868","text":"\u672c\u7bc7\u6587\u6863\u4e2d\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 SQL \u6765\u521b\u5efa\u8868\u3002\u4e0a\u4e00\u7bc7\u6587\u6863\u4e2d\u4ecb\u7ecd\u4e86\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a modatabase \u7684\u6570\u636e\u5e93\uff0c\u672c\u7bc7\u6587\u6863\u6211\u4eec\u4ecb\u7ecd\u5728\u8fd9\u4e2a\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u8868\u3002
Note
\u6b64\u5904\u4ec5\u5bf9 CREATE TABLE
\u8bed\u53e5\u8fdb\u884c\u7b80\u5355\u63cf\u8ff0\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE TABLE\u3002
\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u8868\u662f MatrixOne \u6570\u636e\u5e93\u96c6\u7fa4\u4e2d\u7684\u4e00\u79cd\u903b\u8f91\u5bf9\u8c61\uff0c\u5b83\u4ece\u5c5e\u4e8e\u67d0\u4e2a\u6570\u636e\u5e93\uff0c\u7528\u4e8e\u4fdd\u5b58\u6570\u636e\u3002
\u8868\u4ee5\u884c\u548c\u5217\u7684\u5f62\u5f0f\u7ec4\u7ec7\u6570\u636e\u8bb0\u5f55\uff0c\u4e00\u5f20\u8868\u81f3\u5c11\u6709\u4e00\u5217\u3002\u82e5\u5728\u8868\u4e2d\u5b9a\u4e49\u4e86 n \u4e2a\u5217\uff0c\u90a3\u4e48\u6bcf\u4e00\u884c\u6570\u636e\u90fd\u5c06\u62e5\u6709\u4e0e\u8fd9 n \u4e2a\u5217\u4e2d\u6570\u636e\u683c\u5f0f\u5b8c\u5168\u4e00\u81f4\u7684\u5b57\u6bb5\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_4","title":"\u547d\u540d\u8868","text":"\u521b\u5efa\u4e00\u4e2a\u6709\u5b9e\u9645\u610f\u4e49\u7684\u8868\u540d\u79f0\uff0c\u542b\u6709\u5173\u952e\u8bcd\u6216\u7f16\u53f7\u89c4\u8303\u7684\u8868\u540d\u79f0\uff0c\u9075\u5faa\u547d\u540d\u89c4\u8303\uff0c\u65b9\u4fbf\u67e5\u627e\u548c\u4f7f\u7528\u3002
CREATE TABLE
\u8bed\u53e5\u901a\u5e38\u91c7\u7528\u4ee5\u4e0b\u5f62\u5f0f\uff1a
CREATE TABLE {table_name} ({elements});\n
\u53c2\u6570\u63cf\u8ff0
\u5217\u4ece\u5c5e\u4e8e\u8868\uff0c\u6bcf\u5f20\u8868\u90fd\u81f3\u5c11\u6709\u4e00\u5217\u3002\u5217\u901a\u8fc7\u5c06\u6bcf\u884c\u4e2d\u7684\u503c\u5206\u6210\u4e00\u4e2a\u4e2a\u5355\u4e00\u6570\u636e\u7c7b\u578b\u7684\u5c0f\u5355\u5143\u6765\u4e3a\u8868\u63d0\u4f9b\u7ed3\u6784\u3002
\u5217\u5b9a\u4e49\u901a\u5e38\u4f7f\u7528\u4ee5\u4e0b\u5f62\u5f0f\uff1a
{column_name} {data_type} {column_qualification}\n
\u53c2\u6570\u63cf\u8ff0
\u8fd9\u91cc\u4ecb\u7ecd\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a NATION \u7684\u8868\u6765\u5b58\u50a8 modatabase \u5e93\u4e2d\u7684\u7528\u6237\u4fe1\u606f\u3002
\u53ef\u4ee5\u4e3a NATION \u8868\u6dfb\u52a0\u4e00\u4e9b\u5217\u3002
CREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152)\n);\n
\u793a\u4f8b\u89e3\u91ca
\u4e0b\u8868\u5c06\u89e3\u91ca\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u7684\u5b57\u6bb5\uff1a
\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b \u4f5c\u7528 \u89e3\u91ca N_NATIONKEY INTEGER \u6c11\u65cf\u7684\u552f\u4e00\u6807\u8bc6 \u6240\u6709\u6807\u8bc6\u90fd\u5e94\u8be5\u662f INTEGER \u7c7b\u578b\u7684 N_NAME CHAR \u6c11\u65cf\u540d\u5b57 \u6c11\u65cf\u7684\u540d\u79f0\u90fd\u662f char \u7c7b\u578b\uff0c\u4e14\u4e0d\u8d85\u8fc7 25 \u5b57\u7b26 N_REGIONKEY INTEGER \u5730\u533a\u533a\u53f7\uff0c\u552f\u4e00\u6807\u8bc6 \u6240\u6709\u6807\u8bc6\u90fd\u5e94\u8be5\u662f INTEGER \u7c7b\u578b\u7684 N_COMMENT VARCHAR comment \u4fe1\u606f varchar \u7c7b\u578b\uff0c\u4e14\u4e0d\u8d85\u8fc7 152 \u5b57\u7b26MatrixOne \u652f\u6301\u8bb8\u591a\u5176\u4ed6\u7684\u5217\u6570\u636e\u7c7b\u578b\uff0c\u5305\u542b\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u65f6\u95f4\u7b49\uff0c\u53c2\u89c1\u6570\u636e\u7c7b\u578b\u3002
\u521b\u5efa\u4e00\u4e2a\u590d\u6742\u8868
\u521b\u5efa\u4e00\u5f20 ORDERS \u8868\u3002
CREATE TABLE ORDERS(\nO_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n
\u8fd9\u5f20\u8868\u6bd4 NATION \u8868\u5305\u542b\u66f4\u591a\u7684\u6570\u636e\u7c7b\u578b\uff1a
\u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b \u4f5c\u7528 \u89e3\u91ca O_TOTALPRICE DECIMAL \u7528\u4e8e\u6807\u8bb0\u4ef7\u683c \u7cbe\u5ea6\u4e3a 15\uff0c\u6bd4\u4f8b\u4e3a 2\uff0c\u5373\u7cbe\u5ea6\u4ee3\u8868\u5b57\u6bb5\u6570\u503c\u7684\u603b\u4f4d\u6570\uff0c\u800c\u6bd4\u4f8b\u4ee3\u8868\u5c0f\u6570\u70b9\u540e\u6709\u591a\u5c11\u4f4d\uff0c\u4f8b\u5982\uff1adecimal(5,2)\uff0c\u5373\u7cbe\u5ea6\u4e3a 5\uff0c\u6bd4\u4f8b\u4e3a 2 \u65f6\uff0c\u5176\u53d6\u503c\u8303\u56f4\u4e3a -999.99 \u5230 999.99\u3002decimal(6,1) \uff0c\u5373\u7cbe\u5ea6\u4e3a 6\uff0c\u6bd4\u4f8b\u4e3a 1 \u65f6\uff0c\u5176\u53d6\u503c\u8303\u56f4\u4e3a -99999.9 \u5230 99999.9\u3002 O_ORDERDATE DATE \u65e5\u671f\u503c \u8ba2\u5355\u4ea7\u751f\u7684\u65e5\u671f"},{"location":"MatrixOne/Develop/schema-design/create-table/#_6","title":"\u9009\u62e9\u4e3b\u952e","text":"\u4e3b\u952e\u662f\u4e00\u4e2a\u6216\u4e00\u7ec4\u5217\uff0c\u8fd9\u4e2a\u7531\u6240\u6709\u4e3b\u952e\u5217\u7ec4\u5408\u8d77\u6765\u7684\u503c\u662f\u6570\u636e\u884c\u7684\u552f\u4e00\u6807\u8bc6\u3002
\u4e3b\u952e\u5728 CREATE TABLE
\u8bed\u53e5\u4e2d\u5b9a\u4e49\u3002\u4e3b\u952e\u7ea6\u675f\u8981\u6c42\u6240\u6709\u53d7\u7ea6\u675f\u7684\u5217\u4ec5\u5305\u542b\u975e NULL
\u503c\u3002
\u4e00\u4e2a\u8868\u53ef\u4ee5\u6ca1\u6709\u4e3b\u952e\uff0c\u4e3b\u952e\u4e5f\u53ef\u4ee5\u662f\u975e\u6574\u6570\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_7","title":"\u6dfb\u52a0\u5217\u7ea6\u675f","text":"\u9664\u4e3b\u952e\u7ea6\u675f\u5916\uff0cMatrixOne \u8fd8\u652f\u6301\u5176\u4ed6\u7684\u5217\u7ea6\u675f\uff0c\u5982\uff1a\u975e\u7a7a\u7ea6\u675f NOT NULL\u3001\u9ed8\u8ba4\u503c DEFAULT \u7b49\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_8","title":"\u586b\u5145\u9ed8\u8ba4\u503c","text":"\u5982\u9700\u5728\u5217\u4e0a\u8bbe\u7f6e\u9ed8\u8ba4\u503c\uff0c\u8bf7\u4f7f\u7528 DEFAULT
\u7ea6\u675f\u3002\u9ed8\u8ba4\u503c\u5c06\u53ef\u4ee5\u4f7f\u4f60\u65e0\u9700\u6307\u5b9a\u6bcf\u4e00\u5217\u7684\u503c\uff0c\u5c31\u53ef\u4ee5\u63d2\u5165\u6570\u636e\u3002
\u4f60\u53ef\u4ee5\u5c06 DEFAULT
\u4e0e\u652f\u6301\u7684 SQL \u51fd\u6570\u7ed3\u5408\u4f7f\u7528\uff0c\u5c06\u9ed8\u8ba4\u503c\u7684\u8ba1\u7b97\u79fb\u51fa\u5e94\u7528\u5c42\uff0c\u4ece\u800c\u8282\u7701\u5e94\u7528\u5c42\u7684\u8d44\u6e90\uff08\u5f53\u7136\uff0c\u8ba1\u7b97\u6240\u6d88\u8017\u7684\u8d44\u6e90\u5e76\u4e0d\u4f1a\u51ed\u7a7a\u6d88\u5931\uff0c\u53ea\u662f\u88ab\u8f6c\u79fb\u5230\u4e86 MatrixOne \u96c6\u7fa4\u4e2d\uff09\u3002\u8fd9\u91cc\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u4f8b\u5b50\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a
create table t1(a int default (1), b int);\ninsert into t1(b) values(1), (1);\n> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n| 1 | 1 |\n+------+------+\n2 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0ca \u7684\u503c\u9ed8\u8ba4\u662f 1\u3002
\u4f60\u4e5f\u53ef\u4ee5\u5c06\u9ed8\u8ba4\u503c\u8bbe\u7f6e\u4e3a\u63d2\u5165\u503c\u65f6\u7684\u65f6\u95f4\uff0c\u53c2\u8003\u4e0b\u9762\u7684\u7b80\u5355\u7684\u793a\u4f8b\uff1a
-- \u521b\u5efa\u8868\u5e76\u8bbe\u7f6e\u9ed8\u8ba4\u503c\u4e3a\u5f53\u524d\u65f6\u95f4\nCREATE TABLE t2 (\nid INT PRIMARY KEY,\nname VARCHAR(50),\ncreated_at DATETIME DEFAULT NOW()\n);\n\nINSERT INTO t2 (id, name) VALUES\n(1, 'John'),\n(2, 'Jane'),\n(3, 'Mike');\n\n> SELECT * FROM t2;\n+------+------+---------------------+\n| id | name | created_at |\n+------+------+---------------------+\n| 1 | John | 2023-07-10 11:57:27 |\n| 2 | Jane | 2023-07-10 11:57:27 |\n| 3 | Mike | 2023-07-10 11:57:27 |\n+------+------+---------------------+\n3 rows in set (0.00 sec)\n
\u6267\u884c\u4e0a\u8ff0\u63d2\u5165\u8bed\u53e5\u540e\uff0c\u6bcf\u884c\u7684 created_at
\u5217\u90fd\u4f1a\u88ab\u81ea\u52a8\u8bbe\u7f6e\u4e3a\u5f53\u524d\u65f6\u95f4\u3002
\u5982\u679c\u4f60\u9700\u8981\u9632\u6b62\u5217\u4e2d\u51fa\u73b0\u91cd\u590d\u503c\uff0c\u90a3\u4f60\u53ef\u4ee5\u4f7f\u7528 UNIQUE
\u7ea6\u675f\u3002
\u4f8b\u5982\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u6c11\u65cf\u6807\u8bb0\u7684\u503c\u552f\u4e00\uff0c\u53ef\u4ee5\u8fd9\u6837\u6539\u5199 NATION \u8868\u7684\u521b\u5efa SQL\uff1a
CREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nUNIQUE KEY (N_NATIONKEY)\n);\n
\u5982\u679c\u4f60\u5728 NATION \u8868\u4e2d\u5c1d\u8bd5\u63d2\u5165\u76f8\u540c\u7684 N_NATIONKEY\uff0c\u5c06\u8fd4\u56de\u9519\u8bef\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_10","title":"\u9632\u6b62\u7a7a\u503c","text":"\u5982\u679c\u4f60\u9700\u8981\u9632\u6b62\u5217\u4e2d\u51fa\u73b0\u7a7a\u503c\uff0c\u90a3\u5c31\u53ef\u4ee5\u4f7f\u7528 NOT NULL
\u7ea6\u675f\u3002
\u8fd8\u662f\u4f7f\u7528\u6c11\u65cf\u540d\u79f0\u6765\u4e3e\u4f8b\u5b50\uff0c\u9664\u4e86\u6c11\u65cf\u6807\u8bb0\u7684\u503c\u552f\u4e00\uff0c\u8fd8\u5e0c\u671b\u6c11\u65cf\u540d\u79f0\u4e0d\u53ef\u4e3a\u7a7a\uff0c\u4e8e\u662f\u6b64\u5904\u53ef\u4ee5\u8fd9\u6837\u5199 NATION \u8868\u7684\u521b\u5efa SQL\uff1a
CREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n
"},{"location":"MatrixOne/Develop/schema-design/create-table/#show-tables","title":"\u6267\u884c SHOW TABLES
\u8bed\u53e5","text":"\u9700\u67e5\u770b modatabase \u6570\u636e\u5e93\u4e0b\u7684\u6240\u6709\u8868\uff0c\u53ef\u4f7f\u7528 SHOW TABLES
\u8bed\u53e5\uff1a
SHOW TABLES IN `modatabase`;\n
\u8fd0\u884c\u7ed3\u679c\u4e3a\uff1a
+----------------------+\n| tables_in_modatabase |\n+----------------------+\n| nation |\n| orders |\n+----------------------+\n
"},{"location":"MatrixOne/Develop/schema-design/create-table/#_11","title":"\u521b\u5efa\u8868\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219","text":""},{"location":"MatrixOne/Develop/schema-design/create-table/#_12","title":"\u547d\u540d\u8868\u65f6\u5e94\u9075\u5b88\u7684\u89c4\u5219","text":"\u4f7f\u7528\u5b8c\u5168\u9650\u5b9a\u7684\u8868\u540d\u79f0\uff08\u4f8b\u5982\uff1aCREATE TABLE {database_name}.{table_name}
\uff09\u3002\u8fd9\u662f\u56e0\u4e3a\u4f60\u5728\u4e0d\u6307\u5b9a\u6570\u636e\u5e93\u540d\u79f0\u65f6\uff0cMatrixOne \u5c06\u4f7f\u7528\u4f60 SQL \u4f1a\u8bdd\u4e2d\u7684\u5f53\u524d\u6570\u636e\u5e93\u3002\u82e5\u4f60\u672a\u5728 SQL \u4f1a\u8bdd\u4e2d\u4f7f\u7528 USE {databasename};
\u6765\u6307\u5b9a\u6570\u636e\u5e93\uff0cMatrixOne \u5c06\u4f1a\u8fd4\u56de\u9519\u8bef\u3002
\u8bf7\u4f7f\u7528\u6709\u610f\u4e49\u7684\u8868\u540d\uff0c\u4f8b\u5982\uff0c\u82e5\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u8868\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u540d\u79f0\uff1auser\uff0ct_user\uff0cusers \u7b49\uff0c\u6216\u9075\u5faa\u4f60\u516c\u53f8\u6216\u7ec4\u7ec7\u7684\u547d\u540d\u89c4\u8303\u3002\u5982\u679c\u4f60\u7684\u516c\u53f8\u6216\u7ec4\u7ec7\u6ca1\u6709\u76f8\u5e94\u7684\u547d\u540d\u89c4\u8303\uff0c\u53ef\u53c2\u8003\u8868\u547d\u540d\u89c4\u8303\u3002
\u591a\u4e2a\u5355\u8bcd\u4ee5\u4e0b\u5212\u7ebf\u5206\u9694\uff0c\u4e0d\u63a8\u8350\u8d85\u8fc7 32 \u4e2a\u5b57\u7b26\u3002
\u4e0d\u540c\u4e1a\u52a1\u6a21\u5757\u7684\u8868\u5355\u72ec\u5efa\u7acb DATABASE\uff0c\u5e76\u589e\u52a0\u76f8\u5e94\u6ce8\u91ca\u3002
JOIN
\u7684\u5b57\u6bb5\uff0c\u6570\u636e\u7c7b\u578b\u4fdd\u969c\u7edd\u5bf9\u4e00\u81f4\uff0c\u907f\u514d\u9690\u5f0f\u8f6c\u6362\u3002\u4e34\u65f6\u8868\uff08temporary table\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u8868\uff0c\u5b83\u5728\u521b\u5efa\u540e\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u53ef\u89c1\u3002\u5728\u5f53\u524d\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u6570\u636e\u5e93\u81ea\u52a8\u5220\u9664\u4e34\u65f6\u8868\u5e76\u91ca\u653e\u6240\u6709\u7a7a\u95f4\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 DROP TABLE
\u5220\u9664\u4e34\u65f6\u8868\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e34\u65f6\u8868\u5728\u4e00\u6b21\u4f1a\u8bdd\u4e2d\u4fdd\u5b58\u4e00\u4e9b\u4e2d\u95f4\u7ed3\u679c\uff0c\u4f8b\u5982\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u591a\u6b21\u67e5\u8be2\u8fd9\u4e9b\u7ed3\u679c\uff0c\u6216\u8005\u8fd9\u4e9b\u7ed3\u679c\u662f\u5176\u4ed6\u67e5\u8be2\u7684\u5b50\u96c6\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#_3","title":"\u4e34\u65f6\u8868\u7684\u4f18\u70b9","text":"\u4e34\u65f6\u8868\u5728\u6570\u636e\u5e93\u8bbe\u8ba1\u4e2d\u5177\u6709\u591a\u79cd\u7528\u9014\u548c\u4f18\u70b9\uff1a
\u6570\u636e\u9694\u79bb\uff1a\u4e34\u65f6\u8868\u5728\u6bcf\u4e2a\u4f1a\u8bdd\u6216\u4e8b\u52a1\u4e2d\u662f\u72ec\u7acb\u7684\u3002\u8fd9\u610f\u5473\u7740\uff0c\u4e24\u4e2a\u76f8\u540c\u540d\u79f0\u7684\u4e34\u65f6\u8868\u53ef\u4ee5\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u4f1a\u8bdd\u4e2d\u5b58\u5728\uff0c\u5e76\u4e14\u4e0d\u4f1a\u4e92\u76f8\u5f71\u54cd\u3002
\u7b80\u5316\u590d\u6742\u67e5\u8be2\uff1a\u5982\u679c\u4e00\u4e2a\u67e5\u8be2\u975e\u5e38\u590d\u6742\uff0c\u6d89\u53ca\u5230\u591a\u4e2a\u8054\u63a5\u548c\u5b50\u67e5\u8be2\uff0c\u90a3\u4e48\u53ef\u4ee5\u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5230\u4e34\u65f6\u8868\u4e2d\uff0c\u7136\u540e\u5728\u8fd9\u4e2a\u4e34\u65f6\u8868\u4e0a\u8fdb\u884c\u64cd\u4f5c\uff0c\u4ece\u800c\u7b80\u5316\u67e5\u8be2\u548c\u63d0\u9ad8\u6027\u80fd\u3002
\u63d0\u9ad8\u6027\u80fd\uff1a\u5bf9\u4e8e\u5927\u6570\u636e\u96c6\u7684\u590d\u6742\u67e5\u8be2\uff0c\u5c06\u6570\u636e\u4fdd\u5b58\u5728\u4e34\u65f6\u8868\u4e2d\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002\u56e0\u4e3a\u4e34\u65f6\u8868\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\uff0c\u6240\u4ee5\u8bbf\u95ee\u901f\u5ea6\u5feb\u3002
\u4fdd\u62a4\u6570\u636e\uff1a\u4f7f\u7528\u4e34\u65f6\u8868\u53ef\u4ee5\u907f\u514d\u5bf9\u539f\u59cb\u6570\u636e\u8fdb\u884c\u4fee\u6539\u3002\u5f53\u4f60\u9700\u8981\u6267\u884c\u53ef\u80fd\u4f1a\u6539\u53d8\u539f\u59cb\u6570\u636e\u7684\u64cd\u4f5c\u65f6\uff0c\u53ef\u4ee5\u5148\u5c06\u6570\u636e\u5b58\u5165\u4e34\u65f6\u8868\uff0c\u7136\u540e\u5728\u4e34\u65f6\u8868\u4e0a\u8fdb\u884c\u64cd\u4f5c\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u8bef\u6539\u539f\u59cb\u6570\u636e\u3002
\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\uff1a\u4e34\u65f6\u8868\u5728\u4e0d\u518d\u9700\u8981\u65f6\u4f1a\u81ea\u52a8\u5220\u9664\uff0c\u8fd9\u6837\u53ef\u4ee5\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\u3002
\u6709\u52a9\u4e8e\u8c03\u8bd5\uff1a\u5728\u590d\u6742\u7684\u5d4c\u5957\u67e5\u8be2\u4e2d\uff0c\u4e34\u65f6\u8868\u53ef\u4ee5\u7528\u6765\u5b58\u50a8\u4e2d\u95f4\u7ed3\u679c\uff0c\u4ee5\u5e2e\u52a9\u8c03\u8bd5\u548c\u9a8c\u8bc1\u6bcf\u4e00\u6b65\u7684\u8f93\u51fa\u7ed3\u679c\u3002
\u8bf7\u6ce8\u610f\uff0c\u4e34\u65f6\u8868\u5e76\u975e\u4e07\u80fd\u7684\uff0c\u5b83\u4eec\u4e5f\u6709\u4e00\u4e9b\u9650\u5236\uff0c\u6bd4\u5982\u53ea\u80fd\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u8bbf\u95ee\uff0c\u800c\u4e14\u4e00\u65e6\u4f1a\u8bdd\u7ed3\u675f\uff0c\u4e34\u65f6\u8868\u5c31\u4f1a\u6d88\u5931\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-temporary-table/#_4","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u4f7f\u7528\u4e34\u65f6\u8868\u7684\u8bed\u6cd5\u4e0e\u5e38\u89c4\u8868\u76f8\u540c\uff0c\u53ea\u662f\u5728\u521b\u5efa\u8868\u7684\u8bed\u53e5\u524d\u9762\u6dfb\u52a0\u4e86 TEMPORARY \u5173\u952e\u5b57\uff1a
CREATE TEMPORARY TABLE temp_table_name (column_list);\n
\u4f60\u53ef\u4ee5\u5728\u4e34\u65f6\u8868\u548c\u5e38\u89c4\u8868\u4e2d\u4f7f\u7528\u76f8\u540c\u7684\u8868\u540d\uff0c\u800c\u4e0d\u4f1a\u4ea7\u751f\u51b2\u7a81\uff0c\u56e0\u4e3a\u5b83\u4eec\u5b9e\u9645\u4e0a\u662f\u5728\u4e0d\u540c\u7684\u547d\u540d\u7a7a\u95f4\u4e2d\u3002\u4f46\u662f\uff0c\u5728\u540c\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\uff0c\u4e24\u4e2a\u4e34\u65f6\u8868\u4e0d\u80fd\u5171\u4eab\u76f8\u540c\u7684\u540d\u79f0\u3002
Note
DROP TABLE
\u8bed\u53e5\uff0c\u8fd9\u4e2a\u65f6\u5019\u5220\u9664\u7684\u53ef\u80fd\u662f\u6c38\u4e45\u8868\u800c\u4e0d\u662f\u4e34\u65f6\u8868\uff0c\u8fd9\u79cd\u7ed3\u679c\u662f\u4e0d\u53ef\u9884\u6599\u7684\u3002SHOW TABLES
\u547d\u4ee4\u663e\u793a\u6570\u636e\u8868\u5217\u8868\u65f6\uff0c\u4f60\u4e5f\u65e0\u6cd5\u770b\u5230\u4e34\u65f6\u8868\u5217\u8868\u3002-- \u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u8868 'temp_employees'\nCREATE TEMPORARY TABLE temp_employees (\nemployee_id INT AUTO_INCREMENT, -- \u81ea\u589e\u7684\u5458\u5de5 ID\nfirst_name VARCHAR(50), -- \u5458\u5de5\u540d\nlast_name VARCHAR(50), -- \u5458\u5de5\u59d3\nemail VARCHAR(100), -- \u5458\u5de5\u7535\u5b50\u90ae\u4ef6\u5730\u5740\nPRIMARY KEY (employee_id) -- \u8bbe\u5b9a 'employee_id' \u4e3a\u4e3b\u952e\n);\n\n-- \u5411 'temp_employees' \u8868\u4e2d\u63d2\u5165\u4e00\u4e9b\u6570\u636e\nINSERT INTO temp_employees (first_name, last_name, email)\nVALUES ('John', 'Doe', 'john.doe@example.com'),\n('Jane', 'Doe', 'jane.doe@example.com'),\n('Jim', 'Smith', 'jim.smith@example.com'),\n('Jack', 'Johnson', 'jack.johnson@example.com'),\n('Jill', 'Jackson', 'jill.jackson@example.com');\n\n-- \u67e5\u8be2\u4e34\u65f6\u8868\uff0c\u67e5\u770b\u6240\u6709\u5458\u5de5\u4fe1\u606f\nSELECT * FROM temp_employees;\n+-------------+------------+-----------+--------------------------+\n| employee_id | first_name | last_name | email |\n+-------------+------------+-----------+--------------------------+\n| 1 | John | Doe | john.doe@example.com |\n| 2 | Jane | Doe | jane.doe@example.com |\n| 3 | Jim | Smith | jim.smith@example.com |\n| 4 | Jack | Johnson | jack.johnson@example.com |\n| 5 | Jill | Jackson | jill.jackson@example.com |\n+-------------+------------+-----------+--------------------------+\n5 rows in set (0.01 sec)\n\n-- \u6ce8\u610f\uff1a\u5728\u8fd9\u4e2a\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u4e34\u65f6\u8868 'temp_employees' \u5c06\u88ab\u81ea\u52a8\u5220\u9664\n
"},{"location":"MatrixOne/Develop/schema-design/create-view/","title":"\u521b\u5efa\u89c6\u56fe","text":""},{"location":"MatrixOne/Develop/schema-design/create-view/#_2","title":"\u4ec0\u4e48\u662f\u89c6\u56fe","text":"\u89c6\u56fe\uff08View\uff09\u662f\u4e00\u4e2a\u57fa\u4e8e SQL \u8bed\u53e5\u7684\u7ed3\u679c\u96c6\u7684\u53ef\u89c6\u5316\u3001\u53ea\u8bfb\u7684\u865a\u62df\u8868\uff0c\u5176\u5185\u5bb9\u7531\u67e5\u8be2\u5b9a\u4e49\u3002\u4e0e\u666e\u901a\u8868\uff08\u5b58\u50a8\u6570\u636e\u7684\u8868\uff09\u4e0d\u540c\uff0c\u89c6\u56fe\u4e0d\u5305\u542b\u6570\u636e\uff0c\u4ec5\u4ec5\u662f\u57fa\u4e8e\u57fa\u8868\uff08\u88ab\u67e5\u8be2\u7684\u8868\uff09\u7684\u67e5\u8be2\u7ed3\u679c\u7684\u683c\u5f0f\u5316\u663e\u793a\u3002\u4f60\u53ef\u4ee5\u628a\u89c6\u56fe\u770b\u4f5c\u662f\u4e00\u5f20\u8868\u7684\u7a97\u53e3\uff0c\u8fd9\u4e2a\u7a97\u53e3\u4e2d\u7684\u6570\u636e\u53cd\u6620\u5728\u5176\u4ed6\u8868\u4e0a\u3002\u5f53\u67e5\u8be2\u89c6\u56fe\u65f6\uff0c\u6570\u636e\u5e93\u4f1a\u5c06\u8be5\u89c6\u56fe\u7684 SQL \u67e5\u8be2\u5e94\u7528\u5230\u5176\u57fa\u7840\u8868\u4e0a\u3002
"},{"location":"MatrixOne/Develop/schema-design/create-view/#_3","title":"\u89c6\u56fe\u7684\u4f18\u70b9","text":"\u7b80\u5316\u67e5\u8be2\uff1a\u5bf9\u4e8e\u590d\u6742\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u521b\u5efa\u89c6\u56fe\u6765\u9690\u85cf\u67e5\u8be2\u7684\u590d\u6742\u6027\uff0c\u53ea\u9700\u8981\u4ece\u89c6\u56fe\u4e2d\u9009\u62e9\u6570\u636e\uff0c\u800c\u4e0d\u9700\u8981\u8bb0\u4f4f\u590d\u6742\u7684\u67e5\u8be2\u8bed\u53e5\u3002
\u589e\u52a0\u989d\u5916\u7684\u5b89\u5168\u5c42\uff1a\u89c6\u56fe\u53ef\u4ee5\u9650\u5236\u7528\u6237\u8bbf\u95ee\u67d0\u4e9b\u6570\u636e\u5e93\u5b57\u6bb5\uff0c\u53ea\u5c55\u793a\u4ed6\u4eec\u9700\u8981\u770b\u5230\u7684\u5b57\u6bb5\uff0c\u8fd9\u6837\u53ef\u4ee5\u4fdd\u62a4\u6570\u636e\u7684\u5b89\u5168\u3002
\u4fdd\u6301\u6570\u636e\u4e00\u81f4\u6027\uff1a\u5982\u679c\u591a\u4e2a\u67e5\u8be2\u9700\u8981\u7528\u5230\u76f8\u540c\u7684\u67e5\u8be2\u5b50\u53e5\uff0c\u90a3\u4e48\u521b\u5efa\u89c6\u56fe\u53ef\u4ee5\u4fdd\u6301\u6570\u636e\u4e00\u81f4\u6027\u3002
\u903b\u8f91\u62bd\u8c61\uff1a\u89c6\u56fe\u53ef\u4ee5\u8868\u793a\u57fa\u8868\u6570\u636e\u7684\u6709\u7528\u90e8\u5206\uff0c\u6216\u8005\u6c47\u603b\uff0c\u4ee5\u53ca\u4ece\u51e0\u4e2a\u8868\u7ec4\u5408\u800c\u6765\u7684\u4fe1\u606f\u3002
\u4f46\u662f\u89c6\u56fe\u4e5f\u6709\u7f3a\u70b9\uff1a
\u6027\u80fd\uff1a\u4ece\u6570\u636e\u5e93\u89c6\u56fe\u67e5\u8be2\u6570\u636e\u53ef\u80fd\u4f1a\u5f88\u6162\uff0c\u7279\u522b\u662f\u5982\u679c\u89c6\u56fe\u662f\u57fa\u4e8e\u5176\u4ed6\u89c6\u56fe\u521b\u5efa\u7684\u3002
\u4f9d\u8d56\u5176\u4ed6\u8868\uff1a\u5c06\u6839\u636e\u6570\u636e\u5e93\u7684\u57fa\u7840\u8868\u521b\u5efa\u4e00\u4e2a\u89c6\u56fe\u3002\u5e76\u4e0d\u662f\u6240\u6709\u7684\u89c6\u56fe\u90fd\u652f\u6301\u5bf9\u6570\u636e\u8fdb\u884c\u66f4\u65b0\uff0c\u8fd9\u4e3b\u8981\u53d6\u51b3\u4e8e\u89c6\u56fe\u7684\u5b9a\u4e49\u4ee5\u53ca\u5b83\u7684\u57fa\u7840\u8868\u3002
\u5728\u9605\u8bfb\u672c\u9875\u9762\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u51c6\u5907\u4ee5\u4e0b\u4e8b\u9879\uff1a
\u521b\u5efa\u89c6\u56fe\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a
CREATE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;\n
\u521b\u5efa\u89c6\u56fe\u540e\uff0c\u4f60\u53ef\u4ee5\u50cf\u67e5\u8be2\u5176\u4ed6\u8868\u4e00\u6837\u67e5\u8be2\u89c6\u56fe\uff1a
SELECT column1, column2, ...\nFROM view_name;\n
"},{"location":"MatrixOne/Develop/schema-design/create-view/#_6","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 'orders' \u7684\u8868\nCREATE TABLE orders (\norder_id INT AUTO_INCREMENT,\ncustomer_id INT,\norder_date DATE,\norder_amount DOUBLE,\nPRIMARY KEY (order_id)\n);\n\n-- \u5411 'orders' \u8868\u4e2d\u63d2\u5165\u4e00\u4e9b\u6570\u636e\nINSERT INTO orders (customer_id, order_date, order_amount)\nVALUES (1, '2023-01-01', 99.99),\n(1, '2023-01-03', 29.99),\n(2, '2023-01-03', 49.99),\n(3, '2023-01-05', 89.99),\n(1, '2023-01-07', 59.99),\n(2, '2023-01-07', 19.99);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 'order_summary' \u7684\u89c6\u56fe\uff0c\u5b83\u5c55\u793a\u6bcf\u4e2a\u5ba2\u6237\u7684\u603b\u8ba2\u5355\u6570\u91cf\u548c\u603b\u8ba2\u5355\u91d1\u989d\nCREATE VIEW order_summary AS\nSELECT customer_id, COUNT(*) as order_count, SUM(order_amount) as total_amount\nFROM orders\nGROUP BY customer_id;\n\n-- \u67e5\u8be2\u89c6\u56fe\nmysql> SELECT *\nFROM order_summary;\n+-------------+-------------+--------------+\n| customer_id | order_count | total_amount |\n+-------------+-------------+--------------+\n| 1 | 3 | 189.97 |\n| 2 | 2 | 69.98 |\n| 3 | 1 | 89.99 |\n+-------------+-------------+--------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/schema-design/overview/","title":"\u6570\u636e\u5e93\u6a21\u5f0f\u8bbe\u8ba1\u6982\u8ff0","text":"\u672c\u7bc7\u6587\u7ae0\u7b80\u8981\u6982\u8ff0\u4e86 MatrixOne \u7684\u6570\u636e\u5e93\u6a21\u5f0f\u3002\u672c\u7bc7\u6982\u8ff0\u4e3b\u8981\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u76f8\u5173\u672f\u8bed\u548c\u540e\u7eed\u7684\u6570\u636e\u8bfb\u5199\u793a\u4f8b\u3002
"},{"location":"MatrixOne/Develop/schema-design/overview/#-","title":"\u5173\u952e\u672f\u8bed - \u6570\u636e\u5e93\u6a21\u5f0f","text":"\u6570\u636e\u5e93\u6a21\u5f0f (Schema)\uff1a\u672c\u7bc7\u6587\u7ae0\u6240\u63d0\u5230\u7684\u6570\u636e\u5e93\u6a21\u5f0f\u7b49\u540c\u4e8e\u903b\u8f91\u5bf9\u8c61\u6570\u636e\u5e93\uff0c\u4e0e MySQL \u4e00\u6837\uff0c\u4e0d\u505a\u533a\u5206\u3002
"},{"location":"MatrixOne/Develop/schema-design/overview/#database","title":"\u6570\u636e\u5e93 Database","text":"MatrixOne \u6570\u636e\u5e93\u6216 MatrixOne Database\uff0c\u4e3a\u8868\u7684\u96c6\u5408\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 SHOW DATABASES;
\u67e5\u770b MatrixOne \u6240\u5305\u542b\u7684\u9ed8\u8ba4\u6570\u636e\u5e93\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 CREATE DATABASE database_name;
\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u3002
MatrixOne \u6240\u6307\u7684\u8868\u6216 Table\uff0c\u4ece\u5c5e\u4e8e MatrixOne \u7684\u67d0\u4e2a\u6570\u636e\u5e93\u3002
\u8868\u5305\u542b\u6570\u636e\u884c\u3002\u6bcf\u884c\u6570\u636e\u4e2d\u7684\u6bcf\u4e2a\u503c\u90fd\u5c5e\u4e8e\u4e00\u4e2a\u7279\u5b9a\u7684\u5217\u3002\u6bcf\u5217\u90fd\u53ea\u5141\u8bb8\u5355\u4e00\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/overview/#index","title":"\u7d22\u5f15 Index","text":"\u7d22\u5f15\u662f\u4e00\u79cd\u6570\u636e\u7ed3\u6784\uff0c\u7528\u4e8e\u5feb\u901f\u67e5\u627e\u6570\u636e\u5e93\u8868\u683c\u4e2d\u7684\u6570\u636e\u3002\u5b83\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u672c\u76ee\u5f55\uff0c\u5305\u542b\u6709\u5173\u8868\u683c\u4e2d\u5404\u884c\u6570\u636e\u7684\u6307\u9488\uff0c\u4f7f\u5f97\u67e5\u8be2\u53ef\u4ee5\u66f4\u5feb\u901f\u5730\u5b9a\u4f4d\u5230\u6ee1\u8db3\u7279\u5b9a\u6761\u4ef6\u7684\u6570\u636e\u3002
\u6570\u636e\u5e93\u4e2d\u5e38\u7528\u7684\u7d22\u5f15\u7c7b\u578b\u5305\u62ec\u4e3b\u952e\u7d22\u5f15\u3001\u6b21\u7ea7\u7d22\u5f15\u7b49\u3002\u5176\u4e2d\uff0c\u552f\u4e00\u7d22\u5f15\u7528\u4e8e\u4fdd\u8bc1\u7279\u5b9a\u5217\u6216\u5217\u7ec4\u5408\u7684\u552f\u4e00\u6027\uff0c\u666e\u901a\u7d22\u5f15\u7528\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\uff0c\u5168\u6587\u7d22\u5f15\u5219\u7528\u4e8e\u5728\u6587\u672c\u6570\u636e\u4e2d\u8fdb\u884c\u5168\u6587\u68c0\u7d22\u3002
\u7d22\u5f15\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u7c7b\u578b\uff0c\u5206\u522b\u4e3a\uff1a
MatrixOne \u652f\u6301\u4e00\u4e9b\u548c\u8868\u540c\u7ea7\u7684\u5bf9\u8c61\uff1a
MatrixOne \u73b0\u5728\u652f\u6301\u5b58\u50a8\u548c\u67e5\u8be2\u5411\u91cf\u3002\u5411\u91cf\u662f\u901a\u5e38\u7531 AI \u6a21\u578b\uff08\u5982\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff09\u751f\u6210\u7684\u6570\u5b57\u5217\u8868\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u5411\u91cf
"},{"location":"MatrixOne/Develop/schema-design/overview/#_4","title":"\u8bbf\u95ee\u63a7\u5236","text":"MatrixOne \u652f\u6301\u57fa\u4e8e\u7528\u6237\u6216\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u89d2\u8272\u6216\u76f4\u63a5\u6307\u5411\u7528\u6237\uff0c\u4ece\u800c\u6388\u4e88\u7528\u6237\u67e5\u770b\u3001\u4fee\u6539\u6216\u5220\u9664\u6570\u636e\u5bf9\u8c61\u548c\u6570\u636e\u6a21\u5f0f\u7684\u6743\u9650\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 MatrixOne \u4e2d\u7684\u6743\u9650\u63a7\u5236\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/","title":"AUTO INCREMENT \u81ea\u589e\u7ea6\u675f","text":"\u81ea\u589e\u7ea6\u675f\uff08Auto-Increment Constraint\uff09\u662f MatrixOne \u4e00\u79cd\u7528\u4e8e\u81ea\u52a8\u4e3a\u8868\u4e2d\u7684\u5217\u751f\u6210\u552f\u4e00\u6807\u8bc6\u503c\u7684\u7279\u6027\u3002\u5b83\u5141\u8bb8\u4f60\u5728\u63d2\u5165\u65b0\u884c\u65f6\uff0c\u81ea\u52a8\u4e3a\u6307\u5b9a\u7684\u81ea\u589e\u5217\u751f\u6210\u4e00\u4e2a\u9012\u589e\u7684\u552f\u4e00\u503c\u3002\u8fd9\u5728\u8bb8\u591a\u60c5\u51b5\u4e0b\u975e\u5e38\u6709\u7528\uff0c\u4f8b\u5982\u7528\u4f5c\u4e3b\u952e\u6216\u6807\u8bc6\u7b26\u3002
\u81ea\u589e\u7ea6\u675f\u7279\u6027
\u81ea\u589e\u7ea6\u675f\u53ef\u4ee5\u7b80\u5316\u6807\u8bc6\u7b26\u7684\u751f\u6210\u548c\u7ba1\u7406\u3002\u5728\u4f7f\u7528\u81ea\u589e\u5217\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a
\u8bf7\u6839\u636e\u5177\u4f53\u7684\u8868\u7ed3\u6784\u548c\u9700\u6c42\uff0c\u4f7f\u7528\u81ea\u589e\u7ea6\u675f\u6765\u7b80\u5316\u6807\u8bc6\u7b26\u7684\u751f\u6210\u548c\u7ba1\u7406\uff0c\u5e76\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u552f\u4e00\u6027\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u521b\u5efa\u8868\u65f6\uff0c\u53ef\u4ee5\u4e3a\u4e00\u4e2a\u5217\u5b9a\u4e49\u81ea\u589e\u7ea6\u675f\u3002\u901a\u5e38\uff0c\u81ea\u589e\u5217\u7684\u6570\u636e\u7c7b\u578b\u4e3a\u6574\u6570\u7c7b\u578b\uff08\u5982 INT
\u6216 BIGINT
\uff09\u3002\u5728\u521b\u5efa\u8868\u65f6\uff0c\u4f7f\u7528 AUTO_INCREMENT
\u5173\u952e\u5b57\u4e3a\u5217\u6dfb\u52a0\u81ea\u589e\u7ea6\u675f\u3002
CREATE TABLE table_name (\ncolumn_name data_type AUTO_INCREMENT,\n...\nPRIMARY KEY (primary_key_column)\n);\n
table_name
\uff1a\u8868\u7684\u540d\u79f0\u3002column_name
\uff1a\u8981\u5b9a\u4e49\u4e3a\u81ea\u589e\u7684\u5217\u7684\u540d\u79f0\u3002data_type
\uff1a\u5217\u7684\u6570\u636e\u7c7b\u578b\uff0c\u901a\u5e38\u4e3a\u6574\u6570\u7c7b\u578b\uff08\u5982 INT
\u6216 BIGINT
\uff09\u3002primary_key_column
\uff1a\u8868\u7684\u4e3b\u952e\u5217\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u521b\u5efa\u5e26\u6709\u81ea\u589e\u5217\u7684\u8868\u7684\u793a\u4f8b\uff1a
-- \u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a `employees` \u7684\u8868\uff0c\u5176\u4e2d `id` \u5217\u88ab\u5b9a\u4e49\u4e3a\u81ea\u589e\u5217\u3002`id` \u5217\u7684\u6570\u636e\u7c7b\u578b\u4e3a `INT`\uff0c\u5e76\u901a\u8fc7 `AUTO_INCREMENT` \u5173\u952e\u5b57\u6307\u5b9a\u4e86\u81ea\u589e\u7ea6\u675f\u3002\u8868\u7684\u4e3b\u952e\u8bbe\u7f6e\u4e3a `id` \u5217\nCREATE TABLE employees (\nid INT AUTO_INCREMENT,\nname VARCHAR(50),\ndepartment VARCHAR(50),\nPRIMARY KEY (id)\n);\n\n-- \u63d2\u5165\u6570\u636e\uff0c\u5e76\u8ba9\u81ea\u589e\u5217\u81ea\u52a8\u751f\u6210\u552f\u4e00\u7684\u6807\u8bc6\u503c\uff0c\u6ca1\u6709\u4e3a `id` \u5217\u6307\u5b9a\u503c\uff0c\u800c\u662f\u901a\u8fc7\u63d2\u5165\u6570\u636e\u65f6\u81ea\u52a8\u4e3a `id` \u5217\u751f\u6210\u9012\u589e\u7684\u552f\u4e00\u503c\u3002\u6bcf\u6b21\u63d2\u5165\u65b0\u884c\u65f6\uff0c`id` \u5217\u7684\u503c\u5c06\u81ea\u52a8\u9012\u589e\u3002\n\nINSERT INTO employees (name, department)\nVALUES ('John Doe', 'HR'),\n('Jane Smith', 'Marketing'),\n('Mike Johnson', 'IT');\n\n-- `id` \u5217\u7684\u503c\u81ea\u52a8\u9012\u589e\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u65b0\u63d2\u5165\u7684\u884c\u751f\u6210\u552f\u4e00\u7684\u6807\u8bc6\u503c\u3002\nmysql> SELECT * FROM employees;\n+------+--------------+------------+\n| id | name | department |\n+------+--------------+------------+\n| 1 | John Doe | HR |\n| 2 | Jane Smith | Marketing |\n| 3 | Mike Johnson | IT |\n+------+--------------+------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/auto-increment-integrity/#_3","title":"\u9650\u5236","text":"ALTER TABLE
\u4fee\u6539\u81ea\u589e\u503c\u7684\u8d77\u59cb\u503c\u548c\u9012\u589e\u6b65\u957f\u3002set @@auto_increment_increment=n
\u6765\u8bbe\u7f6e\u9012\u589e\u6b65\u957f\uff0c\u4e5f\u4ec5\u8bed\u6cd5\u652f\u6301\u4f7f\u7528 set @@auto_increment_offset=n
\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u81ea\u589e\u5217\u521d\u59cb\u503c\uff0c\u4f46\u5b9e\u9645\u4e0a\u5e76\u4e0d\u751f\u6548\uff1b\u5f53\u524d\u652f\u6301\u8bbe\u7f6e\u81ea\u589e\u5217\u7684\u521d\u59cb\u503c AUTO_INCREMENT=n
\uff0c\u4f46\u6b65\u957f\u4ecd\u7136\u9ed8\u8ba4\u4e3a 1\u3002FOREIGN KEY \u5916\u952e\u7ea6\u675f\u5141\u8bb8\u8868\u5185\u6216\u8de8\u8868\u4ea4\u53c9\u5f15\u7528\u76f8\u5173\u6570\u636e\uff0c\u6709\u52a9\u4e8e\u4fdd\u6301\u76f8\u5173\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
\u5f53\u5efa\u7acb\u5916\u952e\u65f6\uff0cMatrixone \u9ed8\u8ba4\u4f1a\u68c0\u67e5\u5916\u952e\u7ea6\u675f\u7684\u5b8c\u6574\u6027\u3002\u5982\u9700\u7981\u7528\u5916\u952e\u7ea6\u675f\u68c0\u67e5\uff0c\u8bf7\u53c2\u8003\u7ae0\u8282\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u3002
\u9075\u5faa\u89c4\u5219
\u5b9a\u4e49\u5916\u952e\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e0b\u5217\u89c4\u5219\uff1a
\u4e3b\u8868\u5fc5\u987b\u5df2\u7ecf\u5b58\u5728\u4e8e\u6570\u636e\u5e93\u4e2d\uff0c\u6216\u8005\u662f\u5f53\u524d\u6b63\u5728\u521b\u5efa\u7684\u8868\u3002\u5982\u679c\u662f\u540e\u4e00\u79cd\u60c5\u51b5\uff0c\u5219\u4e3b\u8868\u4e0e\u4ece\u8868\u662f\u540c\u4e00\u4e2a\u8868\uff0c\u8fd9\u6837\u7684\u8868\u79f0\u4e3a\u81ea\u53c2\u7167\u8868\uff0c\u8fd9\u79cd\u7ed3\u6784\u79f0\u4e3a\u81ea\u53c2\u7167\u5b8c\u6574\u6027\u3002
\u5fc5\u987b\u4e3a\u4e3b\u8868\u5b9a\u4e49\u4e3b\u952e\u3002
\u4e3b\u952e\u4e0d\u80fd\u5305\u542b\u7a7a\u503c\uff0c\u4f46\u5141\u8bb8\u5728\u5916\u952e\u4e2d\u51fa\u73b0\u7a7a\u503c\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ea\u8981\u5916\u952e\u7684\u6bcf\u4e2a\u975e\u7a7a\u503c\u51fa\u73b0\u5728\u6307\u5b9a\u7684\u4e3b\u952e\u4e2d\uff0c\u8fd9\u4e2a\u5916\u952e\u7684\u5185\u5bb9\u5c31\u662f\u6b63\u786e\u7684\u3002
\u5728\u4e3b\u8868\u7684\u8868\u540d\u540e\u9762\u6307\u5b9a\u5217\u540d\u6216\u5217\u540d\u7684\u7ec4\u5408\u3002\u8fd9\u4e2a\u5217\u6216\u5217\u7684\u7ec4\u5408\u5fc5\u987b\u662f\u4e3b\u8868\u7684\u4e3b\u952e\u6216\u5019\u9009\u952e\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u76ee\u5fc5\u987b\u548c\u4e3b\u8868\u7684\u4e3b\u952e\u4e2d\u5217\u7684\u6570\u76ee\u76f8\u540c\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u548c\u4e3b\u8868\u4e3b\u952e\u4e2d\u5bf9\u5e94\u5217\u7684\u6570\u636e\u7c7b\u578b\u76f8\u540c\u3002
\u5916\u952e\u7684\u503c\u5fc5\u987b\u8ddf\u4e3b\u8868\u4e3b\u952e\u7684\u503c\u4fdd\u6301\u4e00\u81f4\u3002
\u5916\u952e\u7279\u6027
\u5916\u952e\u81ea\u5f15\u7528\uff1a\u662f\u6307\u4e00\u4e2a\u8868\u4e2d\u7684\u5217\u5f15\u7528\u540c\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\u3002\u8fd9\u79cd\u8bbe\u8ba1\u901a\u5e38\u7528\u4e8e\u8868\u793a\u5c42\u7ea7\u5173\u7cfb\u6216\u7236\u5b50\u5173\u7cfb\uff0c\u6bd4\u5982\u7ec4\u7ec7\u7ed3\u6784\u3001\u5206\u7c7b\u76ee\u5f55\u7b49\u3002
\u591a\u5217\u5916\u952e\uff1a\u8fd9\u79cd\u5916\u952e\u662f\u5728\u4e00\u4e2a\u8868\u4e2d\u4e24\u4e2a\u6216\u66f4\u591a\u7684\u5217\u8054\u5408\u8d77\u6765\u5f15\u7528\u53e6\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fd9\u4e9b\u5217\u5171\u540c\u5b9a\u4e49\u4e86\u5bf9\u53e6\u4e00\u4e2a\u8868\u7684\u5f15\u7528\u3002\u5b83\u4eec\u5fc5\u987b\u4ee5\u7ec4\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u4e14\u9700\u8981\u540c\u65f6\u6ee1\u8db3\u5916\u952e\u7ea6\u675f\u3002
\u591a\u5c42\u5916\u952e\uff1a\u8fd9\u79cd\u60c5\u51b5\u901a\u5e38\u6d89\u53ca\u5230\u4e09\u4e2a\u6216\u66f4\u591a\u7684\u8868\uff0c\u5e76\u4e14\u5b83\u4eec\u4e4b\u95f4\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u3002\u4e00\u4e2a\u8868\u7684\u5916\u952e\u53ef\u4ee5\u662f\u53e6\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\uff0c\u800c\u8fd9\u4e2a\u8868\u7684\u5916\u952e\u53c8\u53ef\u4ee5\u662f\u7b2c\u4e09\u4e2a\u8868\u7684\u4e3b\u952e\uff0c\u5f62\u6210\u591a\u5c42\u5916\u952e\u7684\u60c5\u51b5\u3002
\u5916\u952e\u662f\u5728\u5b50\u8868\u4e2d\u5b9a\u4e49\u7684\uff0c\u57fa\u672c\u7684\u5916\u952e\u7ea6\u675f\u8bed\u6cd5\u5982\u4e0b\uff1a
> CREATE TABLE child_table (\n ...,\n foreign_key_column data_type,\n FOREIGN KEY (foreign_key_column) REFERENCES parent_table (parent_key_column)\n [ON DELETE reference_option]\n [ON UPDATE reference_option]\n);\n\nreference_option:\n RESTRICT | CASCADE | SET NULL | NO ACTION\n
\u53c2\u6570\u91ca\u4e49
\u5728\u4e0a\u8ff0\u5916\u952e\u7ea6\u675f\u7684\u8bed\u6cd5\u7ed3\u6784\u4e2d\uff0c\u4ee5\u4e0b\u662f\u5404\u4e2a\u53c2\u6570\u7684\u91ca\u4e49\uff1a
child_table
\uff1a\u5b50\u8868\u7684\u540d\u79f0\uff0c\u5373\u5305\u542b\u5916\u952e\u7684\u8868\u3002foreign_key_column
\uff1a\u5b50\u8868\u4e2d\u7528\u4e8e\u5f15\u7528\u7236\u8868\u7684\u5916\u952e\u5217\u7684\u540d\u79f0\u3002data_type
\uff1a\u5916\u952e\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002parent_table
\uff1a\u88ab\u5f15\u7528\u7684\u7236\u8868\u7684\u540d\u79f0\u3002parent_key_column
\uff1a\u7236\u8868\u4e2d\u7528\u4e8e\u5efa\u7acb\u5173\u7cfb\u7684\u4e3b\u952e\u5217\u7684\u540d\u79f0\u3002[ON DELETE reference_option]
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a\u5728\u5220\u9664\u7236\u8868\u4e2d\u7684\u8bb0\u5f55\u65f6\u6267\u884c\u7684\u64cd\u4f5c\u3002
RESTRICT
\uff1a\u5982\u679c\u5728\u5f15\u7528\u8868\u4e2d\u6709\u76f8\u5173\u7684\u5916\u952e\u6570\u636e\u5b58\u5728\uff0c\u4e0d\u5141\u8bb8\u5220\u9664\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u6765\u9632\u6b62\u8bef\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u7ef4\u62a4\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
CASCADE
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u540c\u65f6\u5220\u9664\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u7ea7\u8054\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002
SET NULL
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5c06\u5916\u952e\u5217\u7684\u503c\u8bbe\u7f6e\u4e3a NULL\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u5728\u5220\u9664\u5f15\u7528\u6570\u636e\u65f6\u4fdd\u7559\u5916\u952e\u6570\u636e\uff0c\u4f46\u65ad\u5f00\u4e0e\u5f15\u7528\u6570\u636e\u7684\u5173\u8054\u3002
NO ACTION
\uff1a\u8868\u793a\u4e0d\u91c7\u53d6\u4efb\u4f55\u64cd\u4f5c\uff0c\u53ea\u662f\u68c0\u67e5\u662f\u5426\u6709\u5173\u8054\u6570\u636e\u5b58\u5728\u3002\u8fd9\u7c7b\u4f3c\u4e8e RESTRICT
\uff0c\u4f46\u53ef\u80fd\u5728\u67d0\u4e9b\u6570\u636e\u5e93\u4e2d\u6709\u5fae\u5c0f\u7684\u5dee\u5f02\u3002
[ON UPDATE reference_option]
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a\u5728\u66f4\u65b0\u7236\u8868\u4e2d\u7684\u8bb0\u5f55\u65f6\u6267\u884c\u7684\u64cd\u4f5c\u3002\u53ef\u80fd\u7684\u503c\u4e0e [ON DELETE reference_option]
\u76f8\u540c\u3002
\u8fd9\u4e9b\u53c2\u6570\u4e00\u8d77\u5b9a\u4e49\u4e86\u5916\u952e\u7ea6\u675f\uff0c\u5b83\u4eec\u786e\u4fdd\u4e86\u5b50\u8868\u4e0e\u7236\u8868\u4e4b\u95f4\u7684\u6570\u636e\u5b8c\u6574\u6027\u5173\u7cfb\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#_2","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#1","title":"\u793a\u4f8b 1","text":"-- \u521b\u5efa\u540d\u4e3a t1 \u7684\u8868\uff0c\u5305\u542b\u4e24\u5217\uff1aa \u548c b\u3002a \u5217\u4e3a int \u7c7b\u578b\u5e76\u8bbe\u4e3a\u4e3b\u952e\uff0cb \u5217\u4e3a varchar \u7c7b\u578b\uff0c\u957f\u5ea6\u4e3a 5\ncreate table t1(a int primary key, b varchar(5));\n\n-- \u521b\u5efa\u540d\u4e3a t2 \u7684\u8868\uff0c\u5305\u542b\u4e09\u5217\uff1aa\u3001b \u548c c\u3002a \u5217\u4e3a int \u7c7b\u578b\uff0cb \u5217\u4e3a varchar \u7c7b\u578b\uff0c\u957f\u5ea6\u4e3a 5\u3002c \u5217\u4e3a int \u7c7b\u578b\uff0c\u5e76\u4e14\u88ab\u8bbe\u5b9a\u4e3a\u5916\u952e\uff0c\u4e0e t1 \u8868\u7684 a \u5217\u5efa\u7acb\u5173\u7cfb\ncreate table t2(a int ,b varchar(5), c int, foreign key(c) references t1(a));\n\n-- \u5728 t1 \u8868\u4e2d\u63d2\u5165\u4e24\u884c\u6570\u636e\uff1a(101, 'abc') \u548c (102, 'def')\nmysql> insert into t1 values(101,'abc'),(102,'def');\nQuery OK, 2 rows affected (0.01 sec)\n\n-- \u5728 t2 \u8868\u4e2d\u63d2\u5165\u4e24\u884c\u6570\u636e\uff1a(1, 'zs1', 101) \u548c (2, 'zs2', 102)\uff0c\u5176\u4e2d\u7684 101 \u548c 102 \u662f t1 \u8868\u7684\u4e3b\u952e\nmysql> insert into t2 values(1,'zs1',101),(2,'zs2',102);\nQuery OK, 2 rows affected (0.01 sec)\n\n-- \u5728 t2 \u8868\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff1a(3, 'xyz', null)\uff0c\u5176\u4e2d\u7684 null \u8868\u793a\u8fd9\u884c\u6570\u636e\u5728 c \u5217\uff08\u5373\u5916\u952e\u5217\uff09\u6ca1\u6709\u5173\u8054\u7684\u4e3b\u952e\nmysql> insert into t2 values(3,'xyz',null);\nQuery OK, 1 row affected (0.01 sec)\n\n-- \u5c1d\u8bd5\u5728 t2 \u8868\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff1a(3, 'xxa', 103)\uff0c\u4f46\u662f 103 \u5728 t1 \u8868\u7684\u4e3b\u952e\u4e2d\u4e0d\u5b58\u5728\uff0c\u56e0\u6b64\u63d2\u5165\u5931\u8d25\uff0c\u8fdd\u53cd\u4e86\u5916\u952e\u7ea6\u675f\nmysql> insert into t2 values(3,'xxa',103);\nERROR 20101 (HY000): internal error: Cannot add or update a child row: a foreign key constraint fails\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0ct2 \u7684 c \u5217\u53ea\u80fd\u5f15\u7528 t1 \u4e2d a \u5217\u7684\u503c\u6216\u7a7a\u503c\uff0c\u56e0\u6b64\u63d2\u5165 t2 \u7684\u524d 3 \u884c\u64cd\u4f5c\u90fd\u80fd\u591f\u6210\u529f\u63d2\u5165\uff0c\u4f46\u662f\u7b2c 4 \u884c\u4e2d\u7684 103 \u5e76\u4e0d\u662f t1 \u4e2d a \u5217\u7684\u67d0\u4e2a\u503c\uff0c\u8fdd\u53cd\u4e86\u5916\u952e\u7ea6\u675f\uff0c\u56e0\u6b64\u63d2\u5165\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#2-","title":"\u793a\u4f8b 2 - \u5916\u952e\u81ea\u5f15\u7528","text":"-- \u521b\u5efa\u540d\u4e3a categories \u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5546\u54c1\u5206\u7c7b\u4fe1\u606f\nCREATE TABLE categories (\nid INT AUTO_INCREMENT PRIMARY KEY,--id \u662f\u4e3b\u952e\uff0c\u7528\u4e8e\u552f\u4e00\u6807\u8bc6\u6bcf\u4e2a\u5206\u7c7b\nname VARCHAR(255) NOT NULL,--name \u662f\u5206\u7c7b\u7684\u540d\u79f0\nparent_id INT,\nFOREIGN KEY (parent_id) REFERENCES categories(id)--parent_id \u662f\u4e00\u4e2a\u5916\u952e\uff0c\u5b83\u5f15\u7528\u4e86 categories \u8868\u4e2d\u7684 id \u5217\n);\n\n--parent_id \u5217\u5141\u8bb8\u6211\u4eec\u6307\u5b9a\u4e00\u4e2a\u5206\u7c7b\u7684\u7236\u5206\u7c7b\u3002\u5982\u679c\u6ca1\u6709\u7236\u5206\u7c7b\uff08\u5373\u9876\u7ea7\u5206\u7c7b\uff09\uff0cparent_id \u53ef\u4ee5\u8bbe\u7f6e\u4e3a NULL\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u63d2\u5165\u4e00\u4e9b\u6570\u636e\u6765\u5c55\u793a\u8fd9\u79cd\u5c42\u7ea7\u5173\u7cfb\uff1a\n\n--\u63d2\u5165\u9876\u7ea7\u5206\u7c7b\nmysql> INSERT INTO categories (name) VALUES ('Electronics'),('Books');\nQuery OK, 2 rows affected (0.01 sec)\n\n--\u63d2\u5165\u5b50\u5206\u7c7b\nmysql> INSERT INTO categories (name, parent_id) VALUES ('Laptops', 1),('Smartphones', 1),('Science Fiction', 2),('Mystery', 2);\nQuery OK, 4 rows affected (0.01 sec)\n\nmysql> select * from categories;\n+------+-----------------+-----------+\n| id | name | parent_id |\n+------+-----------------+-----------+\n| 1 | Electronics | NULL |\n| 2 | Books | NULL |\n| 3 | Laptops | 1 |\n| 4 | Smartphones | 1 |\n| 5 | Science Fiction | 2 |\n| 6 | Mystery | 2 |\n+------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u4e86\u521b\u5efa\u540d\u4e3a categories
\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5546\u54c1\u5206\u7c7b\u4fe1\u606f\uff0c\u9996\u5148\u63d2\u5165\u4e86\u4e24\u4e2a\u9876\u7ea7\u5206\u7c7b Electronics
\u548c Books
\u3002\u7136\u540e\uff0c\u6211\u4eec\u4e3a\u6bcf\u4e2a\u9876\u7ea7\u5206\u7c7b\u6dfb\u52a0\u4e86\u5b50\u5206\u7c7b\uff0c\u6bd4\u5982 Laptops
\u548c Smartphones
\u662f Electronics
\u7684\u5b50\u5206\u7c7b\uff0c\u800c Science Fiction
\u548c Mystery
\u662f Books
\u7684\u5b50\u5206\u7c7b\u3002
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"Student\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5b66\u751f\u4fe1\u606f\nCREATE TABLE Student (\nStudentID INT, -- \u5b66\u751f ID \u5b57\u6bb5\uff0c\u6574\u578b\nName VARCHAR(100), -- \u5b66\u751f\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nPRIMARY KEY (StudentID) -- \u5c06 StudentID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"Course\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u8bfe\u7a0b\u4fe1\u606f\nCREATE TABLE Course (\nCourseID INT, -- \u8bfe\u7a0b ID \u5b57\u6bb5\uff0c\u6574\u578b\nCourseName VARCHAR(100), -- \u8bfe\u7a0b\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nPRIMARY KEY (CourseID) -- \u5c06 CourseID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"StudentCourse\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5b66\u751f\u9009\u8bfe\u4fe1\u606f\nCREATE TABLE StudentCourse (\nStudentID INT, -- \u5b66\u751f ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e Student \u8868\u7684 StudentID \u5b57\u6bb5\u5bf9\u5e94\nCourseID INT, -- \u8bfe\u7a0b ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e Course \u8868\u7684 CourseID \u5b57\u6bb5\u5bf9\u5e94\nPRIMARY KEY (StudentID, CourseID), -- \u5c06 StudentID \u548c CourseID \u7684\u7ec4\u5408\u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\nFOREIGN KEY (StudentID) REFERENCES Student(StudentID), -- \u8bbe\u7f6e StudentID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 Student \u8868\u7684 StudentID \u5b57\u6bb5\nFOREIGN KEY (CourseID) REFERENCES Course(CourseID) -- \u8bbe\u7f6e CourseID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 Course \u8868\u7684 CourseID \u5b57\u6bb5\n);\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u4e00\u4e2a\u662f\u5b66\u751f\u8868 (Student)\uff0c\u4e00\u4e2a\u662f\u8bfe\u7a0b\u8868 (Course)\uff0c\u8fd8\u6709\u4e00\u4e2a\u9009\u8bfe\u8868 (StudentCourse) \u7528\u4e8e\u8bb0\u5f55\u54ea\u4e2a\u5b66\u751f\u9009\u62e9\u4e86\u54ea\u95e8\u8bfe\u7a0b\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u9009\u8bfe\u8868\u4e2d\u7684\u5b66\u751f ID \u548c\u8bfe\u7a0b ID \u53ef\u4ee5\u4f5c\u4e3a\u5916\u952e\uff0c\u5171\u540c\u5f15\u7528\u5b66\u751f\u8868\u548c\u8bfe\u7a0b\u8868\u7684\u4e3b\u952e\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/foreign-key-constraints/#4-","title":"\u793a\u4f8b 4 - \u591a\u5c42\u5916\u952e","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"Country\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u56fd\u5bb6\u4fe1\u606f\nCREATE TABLE Country (\nCountryID INT, -- \u56fd\u5bb6 ID \u5b57\u6bb5\uff0c\u6574\u578b\nCountryName VARCHAR(100), -- \u56fd\u5bb6\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nPRIMARY KEY (CountryID) -- \u5c06 CountryID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"State\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u5dde/\u7701\u4efd\u4fe1\u606f\nCREATE TABLE State (\nStateID INT, -- \u5dde/\u7701\u4efd ID \u5b57\u6bb5\uff0c\u6574\u578b\nStateName VARCHAR(100), -- \u5dde/\u7701\u4efd\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nCountryID INT, -- \u56fd\u5bb6 ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e Country \u8868\u7684 CountryID \u5b57\u6bb5\u5bf9\u5e94\nPRIMARY KEY (StateID), -- \u5c06 StateID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\nFOREIGN KEY (CountryID) REFERENCES Country(CountryID) -- \u8bbe\u7f6e CountryID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 Country \u8868\u7684 CountryID \u5b57\u6bb5\n);\n\n-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\"City\"\u7684\u8868\uff0c\u7528\u4e8e\u5b58\u50a8\u57ce\u5e02\u4fe1\u606f\nCREATE TABLE City (\nCityID INT, -- \u57ce\u5e02 ID \u5b57\u6bb5\uff0c\u6574\u578b\nCityName VARCHAR(100), -- \u57ce\u5e02\u540d\u5b57\u5b57\u6bb5\uff0c\u6700\u5927\u957f\u5ea6 100 \u7684\u5b57\u7b26\u4e32\nStateID INT, -- \u5dde/\u7701\u4efd ID \u5b57\u6bb5\uff0c\u6574\u578b\uff0c\u4e0e State \u8868\u7684 StateID \u5b57\u6bb5\u5bf9\u5e94\nPRIMARY KEY (CityID), -- \u5c06 CityID \u8bbe\u5b9a\u4e3a\u8fd9\u4e2a\u8868\u7684\u4e3b\u952e\nFOREIGN KEY (StateID) REFERENCES State(StateID) -- \u8bbe\u7f6e StateID \u5b57\u6bb5\u4e3a\u5916\u952e\uff0c\u5f15\u7528 State \u8868\u7684 StateID \u5b57\u6bb5\n);\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6709\u4e09\u4e2a\u8868\uff0c\u56fd\u5bb6\u8868 (Country)\uff0c\u5dde/\u7701\u4efd\u8868 (State)\uff0c\u57ce\u5e02\u8868 (City)\u3002\u5dde/\u7701\u4efd\u8868\u6709\u4e00\u4e2a\u5b57\u6bb5 CountryID\uff0c\u8fd9\u662f\u56fd\u5bb6\u8868\u7684\u4e3b\u952e\uff0c\u540c\u65f6\u4e5f\u662f\u5dde/\u7701\u4efd\u8868\u7684\u5916\u952e\u3002\u57ce\u5e02\u8868\u6709\u4e00\u4e2a\u5b57\u6bb5 StateID\uff0c\u8fd9\u662f\u5dde/\u7701\u4efd\u8868\u7684\u4e3b\u952e\uff0c\u540c\u65f6\u4e5f\u662f\u57ce\u5e02\u8868\u7684\u5916\u952e\u3002\u8fd9\u5c31\u5f62\u6210\u4e86\u4e00\u79cd\u591a\u5c42\u5916\u952e\u7684\u60c5\u51b5\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/","title":"NOT NULL \u975e\u7a7a\u7ea6\u675f","text":"NOT NULL \u7ea6\u675f\u53ef\u7528\u4e8e\u9650\u5236\u4e00\u4e2a\u5217\u4e2d\u4e0d\u80fd\u5305\u542b NULL \u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/not-null-constraints/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"> column_name data_type NOT NULL;\n
\u4f60\u65e0\u6cd5\u5411\u5305\u542b NOT NULL
\u7ea6\u675f\u7684\u5217\u4e2d\u63d2\u5165 NULL
\u503c\uff0c\u6216\u66f4\u65b0\u65e7\u503c\u4e3a NULL
\u3002
create table t1(a int not null,b int);\nmysql> insert into t1 values(null,1);\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\nmysql> insert into t1 values(1,null);\nQuery OK, 1 row affected (0.01 sec)\nmysql> update t1 set a=null where a=1;\nERROR 3819 (HY000): constraint violation: Column 'a' cannot be null\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u56e0\u4e3a a \u5217\u5b58\u5728\u975e\u7a7a\u7ea6\u675f\uff0c\u56e0\u6b64\u7b2c 1 \u6761\u63d2\u5165\u8bed\u53e5\u4f1a\u6267\u884c\u5931\u8d25\uff0c\u7b2c 2 \u6761\u8bed\u53e5\u6ee1\u8db3 a \u5217\u7684\u975e\u7a7a\u7ea6\u675f\uff0cb \u5217\u4e0d\u5b58\u5728\u975e\u7a7a\u7ea6\u675f\uff0c\u56e0\u6b64\u53ef\u4ee5\u6210\u529f\u63d2\u5165\u3002\u800c\u66f4\u65b0\u8bed\u53e5\u56e0\u4e3a\u89e6\u53d1\u4e86 a \u5217\u7684\u975e\u7a7a\u7ea6\u675f\uff0c\u56e0\u6b64\u66f4\u65b0\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/","title":"\u7ea6\u675f\u6982\u8ff0","text":"\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\uff0c\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u7684\u6b63\u786e\u6027\u3001\u5b8c\u6574\u6027\u3001\u6709\u6548\u6027\uff0c\u5728\u5efa\u8868\u8bed\u53e5\u4e2d\uff0c\u4f1a\u5bf9\u67d0\u4e9b\u5217\u52a0\u5165\u9650\u5236\u6761\u4ef6\uff0c\u786e\u4fdd\u6570\u636e\u5e93\u5185\u5b58\u50a8\u7684\u4fe1\u606f\u9075\u4ece\u4e00\u5b9a\u7684\u4e1a\u52a1\u89c4\u5219\uff0c\u8fd9\u4e9b\u9650\u5236\u6761\u4ef6\u88ab\u79f0\u4e3a\u7ea6\u675f\u3002\u4f8b\u5982\uff0c\u5982\u679c DML \u8bed\u53e5\u7684\u6267\u884c\u7ed3\u679c\u8fdd\u53cd\u4e86\u5b8c\u6574\u6027\u7ea6\u675f\uff08Integrity Constraint\uff09\uff0c\u5c06\u56de\u6eda\u8bed\u53e5\u5e76\u8fd4\u56de\u9519\u8bef\u6d88\u606f\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/overview-of-integrity-constraint-types/#_2","title":"\u5b8c\u6574\u6027\u7ea6\u675f\u7c7b\u578b","text":"MatrixOne \u5b58\u5728\u591a\u79cd\u7ea6\u675f\uff0c\u4e0d\u540c\u7684\u7ea6\u675f\u5bf9\u4e8e\u6570\u636e\u5e93\u884c\u4e3a\u6709\u7740\u4e0d\u540c\u7684\u9650\u5236\u3002\u76ee\u524d\u652f\u6301\u7684\u7ea6\u675f\u90fd\u662f\u8868\u7ea7\u522b\u7684\u7ea6\u675f\uff1a
\u975e\u7a7a\u7ea6\u675f\u662f\u6307\uff0c\u67d0\u4e00\u5217\u7684\u6570\u636e\u4e0d\u80fd\u51fa\u73b0\u7a7a\u503c\uff08NULL\uff09\uff0c\u8fdd\u53cd\u4e86\u8be5\u9650\u5236\u6761\u4ef6\u7684\u6570\u636e\u4e0d\u80fd\u88ab\u63d2\u5165\u6216\u66f4\u65b0\u5728\u5bf9\u5e94\u5217\u4e2d\u3002\u5728 MatrixOne \u4e2d\uff0c\u4e00\u5f20\u8868\u5141\u8bb8\u6709\u96f6\u4e2a\u3001\u4e00\u4e2a\u6216\u591a\u4e2a\u975e\u7a7a\u7ea6\u675f\u3002
\u552f\u4e00\u952e\u7ea6\u675f\u662f\u6307\uff0c\u5728\u4e00\u5f20\u8868\u4e2d\u5b58\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u7ec4\u5408\u4e2d\uff0c\u88ab\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u884c\u5728\u6b64\u5217\uff08\u6216\u5217\u96c6\uff09\u7684\u503c\u662f\u552f\u4e00\u7684\u3002\u5728 MatrixOne \u4e2d\uff0c\u4e00\u5f20\u8868\u4e2d\u5141\u8bb8\u5b58\u5728\u96f6\u4e2a\u3001\u4e00\u4e2a\u6216\u591a\u4e2a\u552f\u4e00\u952e\u7ea6\u675f\uff0c\u4f46\u4e0e\u5176\u4ed6\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u7684\u552f\u4e00\u952e\u7ea6\u675f\u4e5f\u5fc5\u987b\u975e\u7a7a\u3002
\u4e3b\u952e\u7ea6\u675f\u662f\u6307\uff0c\u5728\u4e00\u5f20\u8868\u4e2d\u5b58\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u7ec4\u5408\u4e2d\uff0c\u6bcf\u4e00\u6570\u636e\u884c\u90fd\u53ef\u4ee5\u7531\u67d0\u4e00\u4e2a\u952e\u503c\u552f\u4e00\u5730\u786e\u5b9a\u4e14\u975e\u7a7a\u7684\uff0c\u5e76\u4e14\u4e3b\u952e\u7ea6\u675f\u5728\u4e00\u5f20\u8868\u4e2d\u6700\u591a\u53ea\u80fd\u6709 1 \u4e2a\u3002
\u5916\u952e\u7ea6\u675f\u662f\u6307\uff0c\u5728\u4e00\u5f20\u8868\u4e2d\u5b58\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u7ec4\u5408\u4e2d\uff0c\u88ab\u53e6\u4e00\u5f20\u8868\u4e2d\u7684\u67d0\u4e00\u5217\u6216\u591a\u5217\u6240\u5f15\u7528\uff0c\u88ab\u5f15\u7528\u8868\u901a\u5e38\u79f0\u4e3a\u7236\u8868\uff0c\u5f15\u7528\u8868\u79f0\u4e3a\u5b50\u8868\u3002\u5b50\u8868\u5f15\u7528\u7236\u8868\u7684\u5bf9\u5e94\u5217\u7684\u6570\u636e\uff0c\u53ea\u80fd\u662f\u7236\u8868\u7684\u6570\u636e\u6216\u7a7a\u503c\uff0c\u8fd9\u79cd\u7ea6\u675f\u88ab\u79f0\u4e3a\u5916\u952e\u7ea6\u675f\u3002
\u81ea\u589e\u7ea6\u675f\u662f\u4e00\u79cd\u7528\u4e8e\u5728\u8868\u4e2d\u81ea\u52a8\u4e3a\u4e00\u4e2a\u5217\u751f\u6210\u552f\u4e00\u6807\u8bc6\u503c\u7684\u7279\u6027\u3002\u5b83\u5141\u8bb8\u4f60\u5728\u63d2\u5165\u65b0\u884c\u65f6\uff0c\u81ea\u52a8\u4e3a\u6307\u5b9a\u7684\u81ea\u589e\u5217\u751f\u6210\u4e00\u4e2a\u9012\u589e\u7684\u552f\u4e00\u503c\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/","title":"PRIMARY KEY \u4e3b\u952e\u7ea6\u675f","text":"PRIMARY KEY \u7ea6\u675f\u53ef\u7528\u4e8e\u786e\u4fdd\u8868\u5185\u7684\u6bcf\u4e00\u6570\u636e\u884c\u90fd\u53ef\u4ee5\u7531\u67d0\u4e00\u4e2a\u952e\u503c\u552f\u4e00\u5730\u786e\u5b9a\u3002 \u5e76\u4e14\u6bcf\u4e2a\u6570\u636e\u5e93\u8868\u4e0a\u6700\u591a\u53ea\u80fd\u5b9a\u4e49\u4e00\u4e2a PRIMARY KEY
\u7ea6\u675f\u3002
\u9075\u5faa\u89c4\u5219
\u5b9a\u4e49\u4e3b\u952e\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e0b\u5217\u89c4\u5219\uff1a
\u552f\u4e00\u6027\uff1a\u4e3b\u952e\u5217\u7684\u503c\u5fc5\u987b\u662f\u552f\u4e00\u7684\uff0c\u5373\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u90fd\u5fc5\u987b\u5177\u6709\u4e0d\u540c\u7684\u4e3b\u952e\u503c\u3002
\u975e\u7a7a\u6027\uff1a\u4e3b\u952e\u5217\u7684\u503c\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u5373\u5b83\u4eec\u4e0d\u80fd\u5305\u542b NULL \u503c\u3002
\u4e0d\u53ef\u66f4\u6539\u6027\uff1a\u4e3b\u952e\u5217\u7684\u503c\u5728\u63d2\u5165\u540e\u4e0d\u80fd\u88ab\u66f4\u6539\u6216\u66f4\u65b0\u3002\u8fd9\u662f\u4e3a\u4e86\u4fdd\u6301\u4e3b\u952e\u7684\u552f\u4e00\u6027\u3002\u5982\u679c\u786e\u5b9e\u9700\u8981\u66f4\u6539\u4e3b\u952e\u503c\uff0c\u901a\u5e38\u9700\u8981\u5148\u5220\u9664\u539f\u59cb\u884c\uff0c\u7136\u540e\u63d2\u5165\u5177\u6709\u65b0\u4e3b\u952e\u503c\u7684\u65b0\u884c\u3002
\u6700\u5c0f\u6027\uff1a\u4e3b\u952e\u53ef\u4ee5\u7531\u5355\u4e2a\u5217\u6216\u591a\u4e2a\u5217\u7ec4\u5408\u800c\u6210\u3002\u590d\u5408\u4e3b\u952e\u53ef\u4ee5\u7528\u4e8e\u552f\u4e00\u6807\u8bc6\u884c\uff0c\u4f46\u5b83\u4eec\u7684\u590d\u5408\u503c\u5fc5\u987b\u552f\u4e00\uff0c\u4e0d\u80fd\u5b58\u5728\u91cd\u590d\u7ec4\u5408\u3002
\u5f15\u7528\u5b8c\u6574\u6027\uff1a\u4e3b\u952e\u901a\u5e38\u7528\u4f5c\u5916\u952e\uff08Foreign Key\uff09\u7684\u5f15\u7528\u3002
\u81ea\u52a8\u521b\u5efa\u7d22\u5f15\uff1a\u4e3b\u952e\u5217\u4f1a\u81ea\u52a8\u521b\u5efa\u7d22\u5f15\uff0c\u4ee5\u63d0\u9ad8\u68c0\u7d22\u6027\u80fd\u3002
> column_name data_type PRIMARY KEY;\n
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#_2","title":"\u793a\u4f8b","text":"mysql> create table t1(a int primary key, b int, c int, primary key(b,c));\nERROR 20301 (HY000): invalid input: more than one primary key defined\nmysql> create table t2(a int, b int, c int, primary key(b,c));\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t3(a int, b int, c int, primary key(a));\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,1);\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> insert into t2 values(1,1,2);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> insert into t3 values(2,1,1);\nQuery OK, 1 row affected (0.01 sec)\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0ct1 \u5305\u542b\u4e86\u4e24\u7ec4\u4e3b\u952e\uff0c\u56e0\u6b64\u521b\u5efa\u5931\u8d25\u3002t2 \u548c t3 \u53ea\u6709\u4e00\u7ec4\u4e3b\u952e\uff0c\u56e0\u6b64\u53ef\u4ee5\u521b\u5efa\u3002\u56db\u6761\u63d2\u5165\u8bed\u53e5\u90fd\u6ca1\u6709\u8fdd\u53cd\u7ea6\u675f\uff0c\u5747\u53ef\u6210\u529f\u6267\u884c\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/primary-key-constraints/#_3","title":"\u9650\u5236","text":"MatrixOne \u6682\u4e0d\u652f\u6301\u5220\u9664 PRIMARY KEY
\u7ea6\u675f\u3002
UNIQUE KEY \u7ea6\u675f\u53ef\u7528\u4e8e\u786e\u4fdd\u5c06\u8981\u88ab\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u884c\u7684\u5217\u6216\u5217\u7ec4\u7684\u503c\u662f\u552f\u4e00\u7684\uff0c\u8868\u7684\u4efb\u610f\u4e24\u884c\u7684\u67d0\u5217\u6216\u67d0\u4e2a\u5217\u96c6\u7684\u503c\u4e0d\u91cd\u590d\uff0c\u5e76\u4e14\u552f\u4e00\u952e\u7ea6\u675f\u4e5f\u5fc5\u987b\u975e\u7a7a\u3002
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"> column_name data_type UNIQUE KEY;\n
"},{"location":"MatrixOne/Develop/schema-design/data-integrity/unique-key-constraints/#_2","title":"\u793a\u4f8b","text":"create table t1(a int unique key, b int, c int, unique key(b,c));\nmysql> insert into t1 values(1,1,1);\nQuery OK, 1 row affected (0.01 sec)\nmysql> insert into t1 values(2,1,1);\nERROR 20307 (HY000): Duplicate entry '3a15013a1501' for key '__mo_index_idx_col'\nmysql> insert into t1 values(1,1,2);\nERROR 20307 (HY000): Duplicate entry '1' for key '__mo_index_idx_col'\n
\u793a\u4f8b\u89e3\u91ca\uff1a\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5b58\u5728\u4e24\u4e2a\u552f\u4e00\u952e\u7ea6\u675f\u5217 a \u4e0e\u5217 (b,c)\u3002\u5728\u63d2\u5165\u6570\u636e\u65f6\uff0c\u7b2c 2 \u6761\u63d2\u5165\u8bed\u53e5\u8fdd\u53cd\u4e86 (b,c) \u7684\u552f\u4e00\u7ea6\u675f\uff0c\u4e0e\u7b2c 1 \u6761\u63d2\u5165\u503c\u91cd\u590d\uff0c\u56e0\u6b64\u63d2\u5165\u5931\u8d25\u3002\u7b2c 3 \u6761\u63d2\u5165\u8bed\u53e5\u8fdd\u53cd\u4e86\u5217 a \u7684\u7ea6\u675f\uff0c\u4e5f\u56e0\u6b64\u63d2\u5165\u5931\u8d25\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/","title":"UDF-Python-\u8fdb\u9636","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 UDF \u8fdb\u9636\u529f\u80fd\uff0c\u5305\u62ec\u4ee5 phython \u6587\u4ef6\u3001whl \u5305\u6784\u5efa UDF\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_2","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus), \u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
#To check with Python installation and its version\npython3 -V\n
Note
\u82e5\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u540c\u65f6\u62e5\u6709 Pyhon2 \u548c Python3\uff0c\u4f7f\u7528 UDF \u524d\u9700\u8981\u5168\u5c40\u914d\u7f6e\u4e3a Python3\uff0c\u4f8b\u5982\u53ef\u4ee5\u901a\u8fc7\u91cd\u547d\u540d /usr/bin/python
\uff0c\u7136\u540e\u5728\u8be5\u5904\u521b\u5efa\u540c\u540d\u7684 python3 \u8f6f\u94fe\u6765\u5b9e\u73b0\u5168\u5c40\u914d\u7f6e\uff0c\u76f8\u5173\u547d\u4ee4\u793a\u4f8b\uff1a
mv /usr/bin/python /usr/bin/python.bak\nln -s /usr/local/python3/bin/python3 /usr/bin/python\n
\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff1a
pip3 install protobuf\npip3 install grpcio\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u6309\u7167\u5feb\u901f\u5f00\u59cb\u7ae0\u8282\u7684\u6b65\u9aa4\u4f7f\u7528 mo_ctl \u5b8c\u6210 MatrixOne \u7684\u90e8\u7f72\u3002\u90e8\u7f72\u5b8c\u6210\u540e\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u4fee\u6539 mo_ctl \u7684\u914d\u7f6e\uff1a
mo_ctl set_conf MO_CONF_FILE=\"\\${MO_PATH}/matrixone/etc/launch-with-python-udf-server/launch.toml\"\n
\u4fee\u6539\u914d\u7f6e\u540e\u9700\u8981\u542f\u52a8\uff08\u6216\u91cd\u542f\uff09MatrixOne \u670d\u52a1\u6765\u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u4f8b\u5982\u4f7f\u7528 mo_ctl \u542f\u52a8 MatrixOne \u670d\u52a1\uff1a
mo_ctl start\n
\u5f85 MatrixOne \u670d\u52a1\u6b63\u5e38\u542f\u52a8\uff08\u82e5 MatrixOne \u662f\u9996\u6b21\u542f\u52a8\uff0c\u540e\u53f0\u521d\u59cb\u5316\u4f1a\u9700\u8981\u5341\u79d2\u5de6\u53f3\u7684\u65f6\u95f4\uff0c\u521d\u59cb\u5316\u5b8c\u6210\u540e\u624d\u53ef\u8fde\u63a5\uff09\u3002\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u8bbf\u95ee MatrixOne \u670d\u52a1\uff1a
mo_ctl connect\n
\u8fde\u63a5\u6210\u529f\u540e\u5c06\u8fdb\u5165 mysql client \u547d\u4ee4\u884c\u5de5\u5177\u3002
\u5d4c\u5165\u5f0f UDF \u5c06\u51fd\u6570\u4f53\u76f4\u63a5\u5199\u5728 SQL \u4e2d\uff0c\u82e5\u51fd\u6570\u903b\u8f91\u5341\u5206\u590d\u6742\uff0c\u4f1a\u8ba9 SQL \u8bed\u53e5\u81a8\u80c0\u4e14\u4e0d\u5229\u4e8e\u4ee3\u7801\u7684\u7ef4\u62a4\u3002\u4e3a\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06 UDF \u51fd\u6570\u4f53\u7f16\u5199\u5728\u5916\u90e8\u5355\u72ec\u7684 Python \u6587\u4ef6\u4e2d\uff0c\u7136\u540e\u901a\u8fc7\u5bfc\u5165 Python \u6587\u4ef6\u7684\u65b9\u5f0f\u5728 MatrixOne \u4e2d\u521b\u5efa\u51fd\u6570\u3002
\u51c6\u5907\u597d python \u6587\u4ef6
\u53ef\u5c06\u539f SQL \u51fd\u6570\u4f53\u4e2d\u7684 python \u4ee3\u7801\u7f16\u5199\u5728 /opt/add_func.py
\u6587\u4ef6\u5185\uff1a
def add(a, b):\n return a + b\n
\u521b\u5efa UDF \u51fd\u6570
\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u6765\u521b\u5efa\u51fd\u6570\uff0c\u6211\u4eec\u4f7f\u7528 import \u5173\u952e\u5b57\u6765\u5bfc\u5165\u6307\u5b9a\u8def\u5f84\u4e0b\u7684 add_func.py \u6587\u4ef6\u3002
create or replace function py_add_2(a int, b int) returns int language python import '/opt/add_func.py' -- python \u6587\u4ef6\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7684\u7edd\u5bf9\u8def\u5f84\nhandler 'add';\n
\u8c03\u7528 UDF \u51fd\u6570
\u51fd\u6570\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u53ef\u4f7f\u7528\u51fd\u6570\u540d + \u5339\u914d\u7c7b\u578b\u7684\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528 UDF \u51fd\u6570\uff0c\u4f8b\u5982\uff1a
select py_add_2(12345,23456);\n+-------------------------+\n| py_add(12345, 23456) |\n+-------------------------+\n| 35801 |\n+-------------------------+\n1 row in set (0.02 sec)\n
WHL file \u662f\u7528\u4e8e python \u5206\u53d1\u7684\u6807\u51c6\u5185\u7f6e\u5305\u683c\u5f0f\uff0c\u5141\u8bb8\u5728\u4e0d\u6784\u5efa\u6e90\u4ee3\u7801\u5206\u53d1\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u5b89\u88c5\u5305\uff0cWHL file \u672c\u8d28\u4e0a\u662f ZIP \u6587\u4ef6\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_3","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u5728\u6784\u5efa whl \u5305\u524d\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u5de5\u5177\uff1a
pip install setuptools wheel\n# setuptools\uff1a\u7528\u4e8e\u6784\u5efa\u548c\u6253\u5305 Python \u5e93\n# wheel\uff1a\u7528\u4e8e\u751f\u6210.whl \u6587\u4ef6\n
\u6309\u7167\u5982\u4e0b\u7684\u6587\u4ef6\u7ed3\u6784\u521b\u5efa\u6587\u4ef6\u4ee5\u53ca\u5185\u5bb9
\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684 Python \u5de5\u7a0b\u76ee\u5f55 func_add
\uff08\u6587\u4ef6\u5939\u540d\u79f0\u53ef\u4efb\u610f\u547d\u540d\uff09\uff0c\u5176\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a
func_add/\n\u251c\u2500\u2500 add_udf.py\n\u2514\u2500\u2500 setup.py\n
\u5176\u4e2d\uff0cadd_udf.py
\u662f\u53ef\u6b63\u5e38\u53ef\u6267\u884c\u7684 Python \u4ee3\u7801\u6587\u4ef6\uff0c\u7528\u6765\u5b9e\u73b0\u51fd\u6570\u65b9\u6cd5\u4f53\u903b\u8f91\uff0c\u4e5f\u53ef\u5c06\u5176\u89c6\u4e3a\u4e00\u4e2a\u6a21\u5757\uff08module\uff09\u3002add_udf.py
\u4e2d\u7684\u4ee3\u7801\u4f8b\u5982\uff1a
# function\n\ndef add(a, b):\n return a + b\n
setup.py
\u6587\u4ef6\u7528\u6765\u5b9a\u4e49\u5e93\u7684\u5143\u6570\u636e\u548c\u914d\u7f6e\u4fe1\u606f\u7b49\uff0c\u4ee3\u7801\u4f8b\u5982\uff1a
# setup.py\n\nfrom setuptools import setup\n\nsetup(\nname=\"udf\",\nversion=\"1.0.0\",\n# \u5305\u542b\u51fd\u6570\u4f53\u7684 python \u6587\u4ef6\u540d\u53bb\u6389\u62d3\u5c55\u540d.py \u540e\u5373\u4e3a\u6a21\u5757\u540d\npy_modules=[\"add_udf\"]\n)\n
\u6784\u5efa whl \u5305
\u5de5\u7a0b\u6587\u4ef6\u7f16\u5199\u5c31\u4f4d\u540e\uff0c\u5728 func_add
\u76ee\u5f55\u5185\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u6784\u5efa wheel \u5305\uff1a
python setup.py bdist_wheel\n
\u6253\u5305\u5b8c\u6210\u540e\uff0c\u4f1a\u5728 func_add/dist
\u76ee\u5f55\u4e0b\u751f\u6210 udf-1.0.0-py3-none-any.whl
\u6587\u4ef6\u3002
\u521b\u5efa UDF \u51fd\u6570
\u5c06 whl \u5305\u62f7\u8d1d\u81f3\u89c4\u5212\u4e2d\u7684\u51fd\u6570\u5b58\u653e\u76ee\u5f55\uff0c\u4f8b\u5982\u8def\u5f84\u4e3a\uff1a/opt/udf/udf-1.0.0-py3-none-any.whl
\uff0c\u5728\u521b\u5efa\u8bed\u53e5\u4e2d\u4f7f\u7528\u8be5 whl \u5305\u521b\u5efa UDF \u51fd\u6570\uff0c\u521b\u5efa\u8bed\u53e5\u793a\u4f8b\u5982\u4e0b\uff1a
create or replace function py_add_3(a int, b int) returns int language python import '/opt/udf/udf-1.0.0-py3-none-any.whl' -- wheel \u5305\u6240\u5728\u76ee\u5f55\nhandler 'add_udf.add'; -- \u6307\u5b9a\u8c03\u7528 whl \u5305\u4e2d add_udf \u6a21\u5757\u7684 add \u51fd\u6570\n
\u8c03\u7528 UDF \u51fd\u6570
\u51fd\u6570\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u53ef\u4f7f\u7528\u51fd\u6570\u540d + \u5339\u914d\u7c7b\u578b\u7684\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528 UDF \u51fd\u6570\uff0c\u4f8b\u5982\uff1a
select py_add_3(12345,23456);\n+-------------------------+\n| py_add(12345, 23456) |\n+-------------------------+\n| 35801 |\n+-------------------------+\n1 row in set (0.02 sec)\n
\u5728\u90e8\u5206\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u4f1a\u5e0c\u671b python \u51fd\u6570\u4e00\u6b21\u6027\u63a5\u6536\u591a\u4e2a\u5143\u7ec4\u6765\u63d0\u9ad8\u8fd0\u884c\u6548\u7387\u3002\u5982\u5728\u6a21\u578b\u63a8\u7406\u65f6\uff0c\u6211\u4eec\u901a\u5e38\u662f\u4ee5\u4e00\u4e2a batch \u4e3a\u5355\u4f4d\u8fdb\u884c\uff0c\u8fd9\u91cc\u7684 batch \u5373\u4e3a\u5143\u7ec4\u7684 vector\uff0cMatrixOne \u63d0\u4f9b\u51fd\u6570\u7684 vector \u9009\u9879\u6765\u5904\u7406\u8fd9\u79cd\u60c5\u51b5\u3002\u6211\u4eec\u4ecd\u4ee5 py_add \u51fd\u6570\u4e3a\u4f8b\uff0c\u6765\u5c55\u793a vector \u9009\u9879\u7684\u7528\u6cd5\u3002
\u5728 udf_test \u5e93\u4e0b\u521b\u5efa\u4e00\u5f20\u540d\u4e3a grades \u7684\u6570\u636e\u8868\uff1a
create table grades(chinese int,math int);\n
\u63d2\u5165\u51e0\u6761\u6d4b\u8bd5\u6570\u636e\uff1a
insert into grades values(97,100),(85,89),(79,99);\n
\u67e5\u770b\u4e0b\u8868\u91cc\u7684\u6570\u636e\uff1a
select * from grades;\n+---------+------+\n| chinese | math |\n+---------+------+\n| 97 | 100 |\n| 85 | 89 |\n| 79 | 99 |\n+---------+------+\n
\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u521b\u5efa UDF \u51fd\u6570 \u6211\u4eec\u4f7f\u7528 add.vector = True
\u6765\u6807\u8bb0 python \u51fd\u6570 add \u63a5\u6536\u4e24\u4e2a int \u5217\u8868\uff08vector\uff09\u800c\u4e0d\u662f int \u503c\uff1a
create or replace function py_add_4(a int, b int) returns int language python as $$\ndef add(a, b): # a, b are list\nreturn [a[i] + b[i] for i in range(len(a))]\nadd.vector = True\n$$\nhandler 'add';\n
\u8c03\u7528 UDF \u51fd\u6570
\u540c\u6837\u901a\u8fc7\u51fd\u6570\u540d\u548c\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528\u51fd\u6570\uff0c\u8be5\u5904\u7684\u53c2\u6570\u5217\u8868\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 grades \u8868\u4e2d\u7684\u4e24\u4e2a\u6574\u6570\u5b57\u6bb5\u5217\uff0c\u4f8b\u5982\uff1a
select py_add_4(chinese,math) as Total from grades;\n+-------+\n| Total |\n+-------+\n| 197 |\n| 174 |\n| 178 |\n+-------+\n
\u4f7f\u7528 vector \u9009\u9879\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u81ea\u7531\u7684\u9009\u62e9\u51fd\u6570\u7684\u5904\u7406\u5f62\u5f0f\uff0c\u4f8b\u5982\u4e00\u6b21\u4e00\u5143\u7ec4\uff0c\u6216\u8005\u4e00\u6b21\u591a\u5143\u7ec4\u3002
\u672c\u8282\u4ee5\u201c\u4fe1\u7528\u5361\u6b3a\u8bc8\u68c0\u6d4b\u201d\u4e3a\u4f8b\uff0c\u8bb2\u8ff0\u4e86 python UDF \u5728\u673a\u5668\u5b66\u4e60\u63a8\u7406\u6d41\u6c34\u7ebf\u4e2d\u7684\u5e94\u7528\u3002\uff08\u76f8\u5173\u4ee3\u7801\u8be6\u89c1 github-demo\uff0c\u5305\u542b\u4ee5\u4e0b\u5373\u5c06\u4e0b\u8f7d\u548c\u7f16\u5199\u7684\u6587\u4ef6\uff09
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_5","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u786e\u4fdd\u672c\u5730 python \u73af\u5883\u5df2\u5b89\u88c5\u4e86 numpy \u548c scikit-learn \u4ee5\u53ca joblib\u3002
pip install numpy\npip install scikit-learn\npip install joblib\n
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_6","title":"\u80cc\u666f\u53ca\u6570\u636e","text":"\u4fe1\u7528\u5361\u516c\u53f8\u9700\u8981\u8bc6\u522b\u6b3a\u8bc8\u4ea4\u6613\uff0c\u4ee5\u9632\u6b62\u5ba2\u6237\u7684\u4fe1\u7528\u5361\u88ab\u4ed6\u4eba\u6076\u610f\u4f7f\u7528\u3002\uff08\u8be6\u89c1 kaggle Credit Card Fraud Detection\uff09
\u6570\u636e\u96c6\u5305\u542b\u4e86 2013 \u5e74 9 \u6708\u6b27\u6d32\u6301\u5361\u4eba\u4f7f\u7528\u4fe1\u7528\u5361\u8fdb\u884c\u7684\u4ea4\u6613\u8bb0\u5f55\u3002\u6570\u636e\u683c\u5f0f\u5982\u4e0b\uff1a
\u5217\u540d \u7c7b\u578b \u542b\u4e49 Time int \u6b64\u4ea4\u6613\u4e0e\u6570\u636e\u96c6\u4e2d\u7684\u7b2c\u4e00\u4e2a\u4ea4\u6613\u4e4b\u95f4\u7ecf\u8fc7\u7684\u79d2\u6570 V1\uff5eV28 double \u4f7f\u7528 PCA \u63d0\u53d6\u7684\u7279\u5f81\uff08\u4ee5\u4fdd\u62a4\u7528\u6237\u8eab\u4efd\u548c\u654f\u611f\u7279\u5f81\uff09 Amount double \u4ea4\u6613\u91d1\u989d Class int 1: \u6b3a\u8bc8\u4ea4\u6613\uff0c0: \u975e\u6b3a\u8bc8\u4ea4\u6613\u6211\u4eec\u628a\u6570\u636e\u6309\u7167 8: 1: 1 \u7684\u6bd4\u4f8b\u5212\u5206\u4e3a\u8bad\u7ec3\u96c6\u3001\u9a8c\u8bc1\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002\u7531\u4e8e\u8bad\u7ec3\u8fc7\u7a0b\u4e0d\u662f\u672c\u6587\u7684\u91cd\u70b9\uff0c\u4e0d\u5728\u6b64\u5904\u8fdb\u884c\u8fc7\u591a\u7684\u4ecb\u7ecd\u3002
\u6211\u4eec\u628a\u6d4b\u8bd5\u96c6\u5f53\u4f5c\u751f\u4ea7\u8fc7\u7a0b\u4e2d\u65b0\u51fa\u73b0\u7684\u6570\u636e\u5b58\u50a8\u5230 MO \u4e2d\uff0c\u53ef\u4ee5\u70b9\u51fb\u6b64\u5904\u83b7\u5f97 ddl.sql
\u6587\u4ef6\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5bfc\u5165\u6570\u636e\u8868\u4ee5\u53ca\u90e8\u5206\u6d4b\u8bd5\u6570\u636e\uff1a
source /your_download_path/ddl.sql\n
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#python-whl","title":"\u51c6\u5907 python-whl \u5305","text":"\u7f16\u5199 detection.py
:
# coding = utf-8\n# -*- coding:utf-8 -*-\nimport decimal\nimport os\nfrom typing import List\n\nimport joblib\nimport numpy as np\n\nmodel_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'model_with_scaler')\n\n\ndef detect(featuresList: List[List[int]], amountList: List[decimal.Decimal]) -> List[bool]:\n model_with_scaler = joblib.load(model_path)\n\n columns_features = np.array(featuresList)\n column_amount = np.array(amountList, dtype='float').reshape(-1, 1)\n column_amount = model_with_scaler['amount_scaler'].transform(column_amount)\n data = np.concatenate((columns_features, column_amount), axis=1)\n predictions = model_with_scaler['model'].predict(data)\n return [pred == 1 for pred in predictions.tolist()]\n\n\ndetect.vector = True\n
\u7f16\u5199 __init__.py
:
# coding = utf-8\n# -*- coding:utf-8 -*-\nfrom .detection import detect\n
\u70b9\u51fb\u4e0b\u8f7d\u5df2\u7ecf\u8bad\u7ec3\u597d\u7684\u6a21\u578b model_with_scaler
\u7f16\u5199 setup.py
:
# coding = utf-8\n# -*- coding:utf-8 -*-\nfrom setuptools import setup, find_packages\n\nsetup(\n name=\"detect\",\n version=\"1.0.0\",\n packages=find_packages(),\n package_data={\n 'credit': ['model_with_scaler']\n },\n)\n
\u5c06\u4e0a\u8ff0\u6587\u4ef6\u7ec4\u7ec7\u6210\u4e0b\u65b9\u7684\u7ed3\u6784\uff1a
|-- demo/\n |-- credit/\n |-- __init__.py\n |-- detection.py # \u63a8\u7406\u51fd\u6570\n|-- model_with_scaler # \u6a21\u578b\n|-- setup.py\n
\u8fdb\u5165\u76ee\u5f55 demo
\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6784\u5efa wheel \u5305 detect-1.0.0-py3-none-any.whl\uff1a
python setup.py bdist_wheel
\u521b\u5efa udf \u51fd\u6570\uff1a
create or replace function py_detect(features json, amount decimal) returns bool language python import 'your_code_path/detect-1.0.0-py3-none-any.whl' -- \u66ff\u6362\u4e3a wheel \u5305\u6240\u5728\u76ee\u5f55\nhandler 'credit.detect'; -- credit module \u4e0b\u7684 detect \u51fd\u6570\n
\u8c03\u7528 udf \u51fd\u6570\u8fdb\u884c\u6b3a\u8bc8\u68c0\u6d4b\uff1a
select id, py_detect(features, amount) as is_fraud from credit_card_transaction limit 10;\n
\u8f93\u51fa\uff1a
+---------+----------+\n| id | is_fraud |\n+---------+----------+\n| 1 | false |\n| 2 | false |\n| 3 | true |\n| 4 | false |\n| 5 | false |\n| 6 | false |\n| 7 | false |\n| 8 | true |\n| 9 | false |\n| 10 | false |\n+---------+----------+\n
\u81f3\u6b64\uff0c\u6211\u4eec\u5df2\u7ecf\u5728 MO \u4e2d\u5b8c\u6210\u4e86\u4fe1\u7528\u5361\u6b3a\u8bc8\u68c0\u6d4b\u4efb\u52a1\u7684\u63a8\u7406\u3002
\u901a\u8fc7\u8be5\u6848\u4f8b\u53ef\u4ee5\u770b\u51fa\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u4f7f\u7528 python UDF \u6765\u5904\u7406 SQL \u89e3\u51b3\u4e0d\u4e86\u7684\u4efb\u52a1\u3002Python UDF \u65e2\u6269\u5c55\u4e86 SQL \u7684\u8bed\u4e49\uff0c\u53c8\u907f\u514d\u4e86\u6211\u4eec\u624b\u52a8\u7f16\u5199\u6570\u636e\u79fb\u52a8\u548c\u8f6c\u6362\u7684\u7a0b\u5e8f\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u5f00\u53d1\u6548\u7387\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python-advanced/#_7","title":"\u53c2\u8003\u6587\u6863","text":"\u6709\u5173 MatrixOne \u4e2d UDF \u7684\u57fa\u7840\u7528\u6cd5\uff0c\u53c2\u89c1 UDF \u57fa\u7840\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u521b\u5efa\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u521b\u5efa UDF\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u5220\u9664\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u5220\u9664 UDF\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python/","title":"UDF-Python","text":"\u60a8\u53ef\u4ee5\u4f7f\u7528 Python \u7f16\u5199\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570 (UDF) \u7684\u5904\u7406\u7a0b\u5e8f\u3002\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u7b80\u5355 Python UDF\uff0c\u5305\u62ec\u4f7f\u7528\u73af\u5883\u8981\u6c42\u3001UDF \u521b\u5efa\u3001\u67e5\u770b\u3001\u4f7f\u7528\u548c\u5220\u9664\u3002
"},{"location":"MatrixOne/Develop/udf/udf-python/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Develop/udf/udf-python/#_2","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus), \u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
#To check with Python installation and its version\npython3 -V\n
Note
\u82e5\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u540c\u65f6\u62e5\u6709 Pyhon2 \u548c Python3\uff0c\u4f7f\u7528 UDF \u524d\u9700\u8981\u5168\u5c40\u914d\u7f6e\u4e3a Python3\uff0c\u4f8b\u5982\u53ef\u4ee5\u901a\u8fc7\u91cd\u547d\u540d /usr/bin/python
\uff0c\u7136\u540e\u5728\u8be5\u5904\u521b\u5efa\u540c\u540d\u7684 python3 \u8f6f\u94fe\u6765\u5b9e\u73b0\u5168\u5c40\u914d\u7f6e\uff0c\u76f8\u5173\u547d\u4ee4\u793a\u4f8b\uff1a
mv /usr/bin/python /usr/bin/python.bak\nln -s /usr/local/python3/bin/python3 /usr/bin/python\n
\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff0c\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 protobuf
\u548c grpcio
\u5de5\u5177\uff1a
pip3 install protobuf\npip3 install grpcio\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u6309\u7167\u5feb\u901f\u5f00\u59cb\u7ae0\u8282\u7684\u6b65\u9aa4\u4f7f\u7528 mo_ctl \u5b8c\u6210 MatrixOne \u7684\u90e8\u7f72\u3002\u90e8\u7f72\u5b8c\u6210\u540e\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u4fee\u6539 mo_ctl \u7684\u914d\u7f6e\uff1a
mo_ctl set_conf MO_CONF_FILE=\"\\${MO_PATH}/matrixone/etc/launch-with-python-udf-server/launch.toml\"\n
\u4fee\u6539\u914d\u7f6e\u540e\u9700\u8981\u542f\u52a8\uff08\u6216\u91cd\u542f\uff09MatrixOne \u670d\u52a1\u6765\u4f7f\u914d\u7f6e\u751f\u6548\uff0c\u4f8b\u5982\u4f7f\u7528 mo_ctl \u542f\u52a8 MatrixOne \u670d\u52a1\uff1a
mo_ctl start\n
\u5f85 MatrixOne \u670d\u52a1\u6b63\u5e38\u542f\u52a8\uff08\u82e5 MatrixOne \u662f\u9996\u6b21\u542f\u52a8\uff0c\u540e\u53f0\u521d\u59cb\u5316\u4f1a\u9700\u8981\u5341\u79d2\u5de6\u53f3\u7684\u65f6\u95f4\uff0c\u521d\u59cb\u5316\u5b8c\u6210\u540e\u624d\u53ef\u8fde\u63a5\uff09\u3002\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u8bbf\u95ee MatrixOne \u670d\u52a1\uff1a
mo_ctl connect\n
\u8fde\u63a5\u6210\u529f\u540e\u5c06\u8fdb\u5165 mysql client \u547d\u4ee4\u884c\u5de5\u5177\u3002
MatrixOne \u652f\u6301\u5728 SQL \u4e2d\u901a\u8fc7 AS \u5173\u952e\u5b57\u76f4\u63a5\u4f7f\u7528 Python \u4ee3\u7801\u7f16\u5199\u51fd\u6570\u4f53\u6765\u521b\u5efa UDF\uff0c\u4ee5\u8fd9\u79cd\u5f62\u5f0f\u521b\u5efa\u7684 UDF \u88ab\u79f0\u4e3a\u5d4c\u5165\u5f0f UDF\u3002
\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u5e93
\u5728\u521b\u5efa UDF \u51fd\u6570\u4e4b\u524d\uff0c\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u6d4b\u8bd5\u5e93\uff1a
mysql> create database udf_test;\nQuery 0k, 1 row affected (0.02 sec)\nmysql> use udf_test;\nDatabase changed\n
\u521b\u5efa UDF \u51fd\u6570
\u5728\u76ee\u6807\u5e93\u5185\uff0c\u53ef\u6267\u884c CREATE \u547d\u4ee4\u914d\u5408 Python \u8bed\u53e5\u521b\u5efa UDF \u51fd\u6570\u3002\u4f8b\u5982\u4f7f\u7528\u5982\u4e0b SQL \u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a py_add \u7684\u51fd\u6570\uff0c\u5b9a\u4e49\u53c2\u6570\u5217\u8868\u63a5\u6536\u4e24\u4e2a\u7c7b\u578b\u4e3a int \u7684\u53c2\u6570\uff0c\u51fd\u6570\u529f\u80fd\u662f\u8fd4\u56de\u4e24\u4e2a\u53c2\u6570\u7684\u548c\uff0c\u5177\u4f53\u7684\u51fd\u6570\u903b\u8f91\u5728 as \u540e\u7684 python \u4ee3\u7801\u4e2d\uff0c\u7136\u540e\uff0c\u4f7f\u7528 handler \u5173\u952e\u5b57\u6307\u5b9a\u8c03\u7528\u7684 python \u51fd\u6570\u540d\u79f0\uff1a
create or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\n
Note
\u5f53\u524d\u7248\u672c matrixone \u4e0d\u4f1a\u5728\u521b\u5efa UDF \u65f6\u68c0\u67e5 python \u8bed\u6cd5\uff0c\u7528\u6237\u9700\u8981\u81ea\u884c\u4fdd\u8bc1 python \u8bed\u6cd5\u7684\u6b63\u786e\u6027\uff0c\u5426\u5219\u5728\u6267\u884c\u540e\u7eed\u6267\u884c\u51fd\u6570\u65f6\u4f1a\u62a5\u9519\u3002
\u8c03\u7528 UDF \u51fd\u6570
\u51fd\u6570\u521b\u5efa\u5b8c\u6210\u540e\uff0c\u53ef\u4f7f\u7528\u51fd\u6570\u540d + \u5339\u914d\u7c7b\u578b\u7684\u53c2\u6570\u5217\u8868\u6765\u8c03\u7528 UDF \u51fd\u6570\uff0c\u4f8b\u5982\uff1a
select py_add(12345,23456);\n+-------------------------+\n| py_add(12345, 23456) |\n+-------------------------+\n| 35801 |\n+-------------------------+\n1 row in set (0.02 sec)\n
\u53ef\u901a\u8fc7 drop function
\u547d\u4ee4\u5bf9\u5df2\u521b\u5efa\u7684 UDF \u51fd\u6570\u8fdb\u884c\u5220\u9664\u3002MatrixOne \u901a\u8fc7 \u51fd\u6570\u540d(\u53c2\u6570\u5217\u8868)
\u6765\u5b8c\u6574\u6807\u8bc6\u4e00\u4e2a UDF \u51fd\u6570\uff0c\u56e0\u6b64\u5220\u9664 UDF \u51fd\u6570\u65f6\u9700\u8981\u663e\u5f0f\u6307\u5b9a\u51fd\u6570\u540d\u4e0e\u53c2\u6570\u5217\u8868\uff0c\u4f8b\u5982\uff1a
drop function py_add(int, int);\n
"},{"location":"MatrixOne/Develop/udf/udf-python/#udf_2","title":"\u67e5\u770b UDF","text":"\u5df2\u521b\u5efa UDF \u51fd\u6570\u7684\u4fe1\u606f\u4f1a\u4fdd\u5b58\u5728 MatrixOne \u7684\u5143\u6570\u636e\u4e2d\uff0c\u53ef\u901a\u8fc7\u67e5\u8be2\u7cfb\u7edf\u8868 mo_catalog.mo_user_defined_function
\u6765\u83b7\u53d6 MatrixOne \u4e2d\u5df2\u6709\u7684 UDF \u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\uff1a
mysql> select * from mo_catalog.mo_user_defined_function\\G\n*************************** 1. row ***************************\nfunction_id: 9000016\nname: py_add\nowner: 0\nargs: [{\"name\": \"a\", \"type\": \"int\"}, {\"name\": \"b\", \"type\": \"int\"}]\nrettype: int\nbody: {\"handler\":\"add\",\"import\":false,\"body\":\"\\ndef add(a, b):\\n return a + b\\n\"}\nlanguage: python\ndb: udf_test\ndefiner: root\nmodified_time: 2023-12-26 13:59:39\ncreated_time: 2023-12-26 13:59:39\ntype: FUNCTION\nsecurity_type: DEFINER\ncomment: character_set_client: utf8mb4\ncollation_connection: utf8mb4_0900_ai_ci\ndatabase_collation: utf8mb4_0900_ai_ci\n
"},{"location":"MatrixOne/Develop/udf/udf-python/#_3","title":"\u53c2\u8003\u6587\u6863","text":"\u6709\u5173 MatrixOne \u4e2d UDF \u7684\u8fdb\u9636\u7528\u6cd5\uff0c\u53c2\u89c1 UDF \u8fdb\u9636\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u521b\u5efa\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u521b\u5efa UDF\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u5220\u9664\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u5220\u9664 UDF\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/","title":"\u90e8\u7f72\u5e38\u89c1\u95ee\u9898","text":""},{"location":"MatrixOne/FAQs/deployment-faqs/#_2","title":"\u73af\u5883\u76f8\u5173","text":"\u90e8\u7f72 MatrixOne \u6240\u9700\u7684\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u662f\u4ec0\u4e48\uff1f
\u5bf9\u4e8e\u4f4e\u7248\u672c\u5185\u6838\u7684 Linux \u7cfb\u7edf\uff0c\u5982\u679c\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u5b89\u88c5\u90e8\u7f72\u65b9\u5f0f\uff0c\u63a8\u8350\u4f7f\u7528\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u8fdb\u884c\u90e8\u7f72\uff0c\u8be6\u60c5\u53ef\u89c1\u5355\u673a\u90e8\u7f72 Matrixone \u6982\u8ff0\u4e2d\u7684\u63a8\u8350\u5b89\u88c5\u73af\u5883\u7ae0\u8282\u3002
\u53ef\u4ee5\u5728\u7ea2\u5e3d\u7cfb\uff0c\u6bd4\u5982 CentOS 7 \u4e0b\u6b63\u5e38\u4f7f\u7528 MatrixOne \u5417\uff1f
MatrixOne \u5bf9\u64cd\u4f5c\u7cfb\u7edf\u7684\u8981\u6c42\u4e0d\u4e25\u683c\uff0c\u652f\u6301\u5728 CentOS 7 \u4e0b\u4f7f\u7528\uff0c\u4f46 CentOS 7 \u5728 24 \u5e74 6 \u6708\u5e95\u5c31\u505c\u6b62\u7ef4\u62a4\u4e86\uff0c\u63a8\u8350\u5927\u5bb6\u4f7f\u7528\u66f4\u65b0\u7248\u672c\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002
MatrixOne \u662f\u5426\u652f\u6301\u5728\u56fd\u4ea7\u73af\u5883\u4e0b\u90e8\u7f72\uff1f
\u5bf9\u4e8e\u56fd\u4ea7\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u82af\u7247\uff0c\u82af\u7247\u6211\u4eec\u5df2\u7ecf\u9002\u914d\u8fc7\u9cb2\u9e4f\u548c\u6d77\u5149\uff0c\u64cd\u4f5c\u7cfb\u7edf\u5df2\u7ecf\u9002\u914d\u8fc7\u94f6\u6cb3\u9e92\u9e9f\uff0c\u6b27\u62c9\uff0c\u9e92\u9e9f\u4fe1\u5b89\u3002
\u6211\u53ef\u4ee5\u5728\u54ea\u91cc\u90e8\u7f72 MatrixOne\uff1f
MatrixOne \u53ef\u4ee5\u672c\u5730\u90e8\u7f72\u3001\u516c\u5171\u4e91\u3001\u79c1\u6709\u4e91\u6216 kubernetes \u4e0a\u3002
MatrixOne \u662f\u5426\u652f\u6301\u5728\u963f\u91cc\u4e91 ecs \u670d\u52a1\u5668\u4e0a\u5206\u5e03\u5f0f\u90e8\u7f72\u5417\uff1f
\u76ee\u524d\u9700\u8981\u57fa\u4e8e ECS \u642d\u5efa K8S \u6216\u8005\u4f7f\u7528\u963f\u91cc\u4e91 ACK \u624d\u80fd\u8fdb\u884c\u5206\u5e03\u5f0f\u90e8\u7f72\u3002
\u96c6\u7fa4\u90e8\u7f72\u53ea\u652f\u6301 K8s \u5417\uff1f\u80fd\u4e0d\u80fd\u7269\u7406\u5206\u5e03\u5f0f\u672c\u5730\u90e8\u7f72\uff1f
\u5982\u679c\u63d0\u524d\u6ca1\u6709 k8s \u548c minio \u73af\u5883\u7684\u8bdd\u3002\u6211\u4eec\u7684\u5b89\u88c5\u5de5\u5177\u4f1a\u81ea\u5e26 k8s \u548c minio\uff0c\u4e5f\u53ef\u4ee5\u5728\u7269\u7406\u673a\u4e00\u952e\u90e8\u7f72\u3002
MatrixOne \u76ee\u524d\u8fd8\u4e0d\u652f\u6301\u975e k8s \u7248\u672c\u4e3b\u4ece\u914d\u7f6e\uff0c\u540e\u7eed\u4f1a\u652f\u6301\u3002
\u751f\u4ea7\u73af\u5883\u53ea\u80fd\u7528 k8s \u6a21\u5f0f\u90e8\u7f72\u5417\uff1f
\u662f\u7684\uff0c\u4e3a\u4e86\u5f97\u5230\u5206\u5e03\u5f0f\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u6269\u5c55\u6027\uff0c\u6211\u4eec\u63a8\u8350\u751f\u4ea7\u7cfb\u7edf\u662f\u7528 k8s \u90e8\u7f72\uff0c\u5047\u5982\u6ca1\u6709\u73b0\u6210\u7684 k8s\uff0c\u53ef\u4ee5\u4f7f\u7528\u6258\u7ba1 k8s \u8fdb\u884c\u90e8\u7f72\uff0c\u964d\u4f4e\u590d\u6742\u5ea6\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/#_3","title":"\u786c\u4ef6\u76f8\u5173","text":"MatrixOne \u5bf9\u90e8\u7f72\u786c\u4ef6\u7684\u914d\u7f6e\u8981\u6c42\u5982\u4f55\uff1f
\u5355\u673a\u5b89\u88c5\u60c5\u51b5\u4e0b\uff0cMatrixOne \u5f53\u524d\u53ef\u4ee5\u8fd0\u884c\u5728 Intel x86-64 \u548c ARM \u67b6\u6784\u7684 64 \u4f4d\u901a\u7528\u786c\u4ef6\u670d\u52a1\u5668\u5e73\u53f0\u4e0a\u3002
\u5bf9\u4e8e\u5f00\u53d1\u3001\u6d4b\u8bd5\u548c\u751f\u4ea7\u73af\u5883\u7684\u670d\u52a1\u5668\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u548c\u5efa\u8bae\u5982\u4e0b\uff1a
ARM \u67b6\u6784\u7684 Macbook M1/M2 \u4e5f\u9002\u5408\u5f00\u53d1\u73af\u5883\u3002
\u5206\u5e03\u5f0f\u5b89\u88c5\u60c5\u51b5\u4e0b\uff0cMatrixOne \u5bf9\u4e8e\u5f00\u53d1\u3001\u6d4b\u8bd5\u548c\u751f\u4ea7\u73af\u5883\u7684\u670d\u52a1\u5668\u786c\u4ef6\u914d\u7f6e\u8981\u6c42\u548c\u5efa\u8bae\u53ef\u4ee5\u53c2\u8003\u96c6\u7fa4\u62d3\u6251\u89c4\u5212\u6982\u8ff0\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/#_4","title":"\u914d\u7f6e\u76f8\u5173","text":"\u5b89\u88c5\u65f6\u9700\u8981\u66f4\u6539\u4ec0\u4e48\u8bbe\u7f6e\u5417\uff1f
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5b89\u88c5\u65f6\uff0c\u4f60\u65e0\u9700\u66f4\u6539\u4efb\u4f55\u8bbe\u7f6e\u3002launch.toml
\u9ed8\u8ba4\u8bbe\u7f6e\u5b8c\u5168\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c MatrixOne\u3002\u4f46\u662f\u5982\u679c\u4f60\u9700\u8981\u81ea\u5b9a\u4e49\u76d1\u542c\u7aef\u53e3\u3001IP \u5730\u5740\u3001\u5b58\u50a8\u6570\u636e\u6587\u4ef6\u8def\u5f84\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539\u76f8\u5e94\u7684 cn.toml
\u3001tn.toml
\u6216 log.toml
\uff0c\u8fd9\u4e9b\u6587\u4ef6\u5185\u53c2\u6570\u914d\u7f6e\u8be6\u60c5\u53ef\u53c2\u8003\u901a\u7528\u53c2\u6570\u914d\u7f6e
\u5f53\u6211\u60f3\u5c06 MatrixOne \u7684\u6570\u636e\u76ee\u5f55\u4fdd\u5b58\u5230\u6211\u6307\u5b9a\u7684\u6587\u4ef6\u76ee\u5f55\u4e2d\uff0c\u6211\u5e94\u8be5\u5982\u4f55\u64cd\u4f5c\uff1f
\u5f53\u4f60\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne\uff0c\u4f60\u53ef\u4ee5\u5c06\u4f60\u6307\u5b9a\u7684\u6570\u636e\u76ee\u5f55\u6302\u8f7d\u81f3 Docker \u5bb9\u5668\uff0c\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
\u5f53\u4f60\u4f7f\u7528\u6e90\u7801\u6216\u4e8c\u8fdb\u5236\u5305\u7f16\u8bd1\u5e76\u542f\u52a8 MatrixOne\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u9ed8\u8ba4\u6570\u636e\u76ee\u5f55\u8def\u5f84\uff1a\u6253\u5f00 MatrixOne \u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 matrixone/etc/launch-with-proxy
\uff0c\u4fee\u6539 cn.toml
\u3001tn.toml
\u548c log.toml
\u4e09\u4e2a\u6587\u4ef6\u5185\u7684\u914d\u7f6e\u53c2\u6570 data-dir = \"./mo-data\"
\u4e3a data-dir = \"your_local_path\"
\uff0c\u4fdd\u5b58\u540e\u91cd\u542f MatrixOne \u5373\u53ef\u751f\u6548\u3002
\u4e8c\u8fdb\u5236\u5305\u5b89\u88c5\u53ef\u4ee5\u901a\u8fc7 mo_ctl \u7ba1\u7406\u5417\uff1f
\u901a\u8fc7\u8bbe\u7f6e MO_PATH \u914d\u7f6e\u4e8c\u8fdb\u5236\u5305\u7684\u8def\u5f84\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528 mo_ctl \u8fdb\u884c\u7ba1\u7406\u4e86\u3002
mo_ctl \u5de5\u5177\u662f\u5426\u652f\u6301\u6e90\u7801\u90e8\u7f72\u5347\u7ea7
\u901a\u8fc7 upgrade \u547d\u4ee4\u53ef\u4ee5\u6307\u5b9a\u5bf9\u5e94\u7684\u7248\u672c\u6216\u8005 commitid \u8fdb\u884c\u7ec6\u7c92\u5ea6\u5347\u7ea7\uff0c\u9700\u8981\u6ce8\u610f\u7684\u8bbe\u7f6e\u5f53\u524d\u7248\u672c MO_PATH\uff0c\u4ee5\u53ca\u7f16\u8bd1\u73af\u5883\u3002
mo_ctl \u5de5\u5177\u662f\u5426\u652f\u6301\u90e8\u7f72 matrixOne \u96c6\u7fa4
\u5f53\u524d\u8fd8\u4e0d\u652f\u6301\uff0c\u540e\u7eed\u8003\u8651\u52a0\u5165\u96c6\u7fa4\u90e8\u7f72\u548c\u7ba1\u7406\u3002
helm \u5b89\u88c5 operator\uff0c\u600e\u4e48\u6837\u770b\u662f\u5426\u5b89\u88c5\u6210\u529f\u4e86\uff1f
\u4f7f\u7528 helm list -A \u5c31\u53ef\u4ee5\u67e5\u770b\u3002
helm \u65b9\u5f0f\u90e8\u7f72\u7684 operator \u5982\u4f55\u8fdb\u884c\u5378\u8f7d\uff1f
\u901a\u8fc7 helm uninstall \u547d\u4ee4\u6307\u5b9a\u540d\u79f0\u548c\u547d\u540d\u7a7a\u95f4\u8fdb\u884c\u5378\u8f7d\u3002
operator \u7684\u7248\u672c\u5728\u90e8\u7f72\u7684\u662f\u5426\u6709\u8981\u6c42\uff1f
operator \u662f\u7528\u6765\u7ba1\u7406 matrixOne \u96c6\u7fa4\u7684\uff0c\u6240\u4ee5 operator \u7248\u672c\u5c3d\u91cf\u4e0e\u96c6\u7fa4\u7684\u7248\u672c\u4fdd\u6301\u4e00\u81f4\uff0c\u6bd4\u5982\u6211\u4eec\u5b89\u88c5\u4e86 1.0.0-rc2 \u8fd9\u4e2a\u7248\u672c\u7684\u96c6\u7fa4\uff0c\u5bf9\u5e94\u63d0\u524d\u5b89\u88c5\u7684 operator \u7248\u672c\u4e5f\u5e94\u8be5\u4e3a 1.0.0-rc2\u3002\u5982\u672a\u627e\u5230\u7248\u672c\u4e00\u81f4\u7684 operator\uff0c\u5efa\u8bae\u4f7f\u7528\u76f8\u8fd1\u7248\u672c\u7684 operator\u3002
"},{"location":"MatrixOne/FAQs/deployment-faqs/#_6","title":"\u62a5\u9519\u76f8\u5173","text":"\u5f53\u6211\u5b89\u88c5\u5b8c\u6210 MySQL \u5ba2\u6237\u7aef\u540e\uff0c\u6253\u5f00\u7ec8\u7aef\u8fd0\u884c mysql
\u4ea7\u751f\u62a5\u9519 command not found: mysql
\uff0c\u6211\u8be5\u5982\u4f55\u89e3\u51b3\uff1f
\u4ea7\u751f\u8fd9\u4e2a\u62a5\u9519\u662f\u73af\u5883\u53d8\u91cf\u672a\u8bbe\u7f6e\u7684\u539f\u56e0\uff0c\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
Linux \u73af\u5883MacOS \u73af\u5883echo 'export PATH=\"/path/to/mysql/bin:$PATH\"' >> ~/.bash_profile\nsource ~/.bash_profile\n
\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684/path/to/mysql/bin
\u66ff\u6362\u4e3a\u4f60\u7cfb\u7edf\u4e2d MySQL \u7684\u5b89\u88c5\u8def\u5f84\u3002\u4e00\u822c\u662f /usr/local/mysql/bin
, \u5982\u679c\u4f60\u4e0d\u786e\u5b9a MySQL \u7684\u5b89\u88c5\u8def\u5f84\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u627e\u5230\uff1a
whereis mysql\n
macOS 10 \u4e4b\u540e\u5c06 zsh
\u4f5c\u4e3a\u9ed8\u8ba4 shell
\uff0c\u6b64\u5904\u4f7f\u7528zsh\u505a\u793a\u4f8b\uff0c\u82e5\u4f7f\u7528\u5176\u4ed6 shell
\u53ef\u81ea\u884c\u8f6c\u6362\u3002
echo export PATH=/path/to/mysql/bin:$PATH >> ~/.zshrc\nsource ~/.zshrc\n
\u5c06\u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684/path/to/mysql/bin
\u66ff\u6362\u4e3a\u4f60\u7cfb\u7edf\u4e2d MySQL \u7684\u5b89\u88c5\u8def\u5f84\u3002\u4e00\u822c\u662f /usr/local/mysql/bin
, \u5982\u679c\u4f60\u4e0d\u786e\u5b9a MySQL \u7684\u5b89\u88c5\u8def\u5f84\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u627e\u5230\uff1a
whereis mysql\n
\u5f53\u6211\u5b89\u88c5\u9009\u62e9\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u6784\u5efa MatrixOne \u65f6\uff0c\u4ea7\u751f\u4e86\u4ee5\u4e0b\u9519\u8bef\u6216\u6784\u5efa\u5931\u8d25\u63d0\u793a\uff0c\u6211\u8be5\u5982\u4f55\u7ee7\u7eed\uff1f
\u62a5\u9519\uff1aGet \"https://proxy.golang.org/........\": dial tcp 142.251.43.17:443: i/o timeout
\u7531\u4e8e MatrixOne \u9700\u8981\u8bb8\u591a GO \u5e93\u4f5c\u4e3a\u4f9d\u8d56\u9879\uff0c\u6240\u4ee5\u5b83\u5728\u6784\u5efa\u65f6\uff0c\u4f1a\u540c\u65f6\u4e0b\u8f7d GO \u5e93\u3002\u4e0a\u8ff0\u6240\u793a\u7684\u62a5\u9519\u662f\u4e0b\u8f7d\u8d85\u65f6\u7684\u9519\u8bef\uff0c\u4e3b\u8981\u539f\u56e0\u662f\u7f51\u7edc\u95ee\u9898\u3002
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u9700\u8981\u8bbe\u7f6e\u4f60\u7684 GO \u73af\u5883\u5230\u4e00\u4e2a\u4e2d\u56fd\u7684\u955c\u50cf\u7f51\u7ad9\uff0c\u4ee5\u52a0\u5feb GO \u5e93\u7684\u4e0b\u8f7d\u3002
\u5982\u679c\u4f60\u901a\u8fc7 go env
\u68c0\u67e5\u4f60\u7684 GO \u73af\u5883\uff0c\u4f60\u53ef\u80fd\u4f1a\u770b\u5230 GOPROXY=\"https://proxy.golang.org,direct\"
\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u8fdb\u884c\u4e0b\u9762\u8bbe\u7f6e\uff1a
go env -w GOPROXY=https://goproxy.cn,direct\n
\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0cmake build
\u5e94\u8be5\u5f88\u5feb\u5c31\u80fd\u5b8c\u6210\u3002
\u5f53\u6211\u901a\u8fc7 MO-Tester \u5bf9 MatrixOne \u8fdb\u884c\u6d4b\u8bd5\u65f6\uff0c\u6211\u5982\u4f55\u89e3\u51b3\u4ea7\u751f\u7684 too many open files
\u9519\u8bef\uff1f
\u4e3a\u4e86\u5bf9 MatrixOne \u8fdb\u884c\u6d4b\u8bd5\uff0cMO-Tester \u4f1a\u5feb\u901f\u5730\u6253\u5f00\u548c\u5173\u95ed\u8bb8\u591a SQL \u6587\u4ef6\uff0c\u4e8e\u662f\u5f88\u5feb\u5c31\u8fbe\u5230 Linux \u548c MacOS \u7cfb\u7edf\u7684\u6700\u5927\u6253\u5f00\u6587\u4ef6\u9650\u5236\uff0c\u8fd9\u5c31\u662f\u5bfc\u81f4 too many open files
\u9519\u8bef\u7684\u539f\u56e0\u3002
ulimit -n 65536\n
\u8bbe\u7f6e\u5b8c\u6210\u540e\uff0c\u5c06\u4e0d\u4f1a\u51fa\u73b0 too many open files
\u9519\u8bef\u3002
\u6211\u7684 PC \u662f M1 \u82af\u7247\uff0c\u5f53\u6211\u8fdb\u884c SSB \u6d4b\u8bd5\u65f6\uff0c\u53d1\u73b0\u65e0\u6cd5\u7f16\u8bd1\u6210\u529f ssb-dbgen
\u786c\u4ef6\u914d\u7f6e\u4e3a M1 \u82af\u7247\u7684 PC \u5728\u7f16\u8bd1 ssb-dbgen
\u4e4b\u524d\uff0c\u8fd8\u9700\u8981\u8fdb\u884c\u5982\u4e0b\u914d\u7f6e\uff1a
\u4e0b\u8f7d\u5e76\u5b89\u88c5 GCC11\u3002
\u8f93\u5165\u547d\u4ee4\uff0c\u786e\u8ba4 gcc-11 \u662f\u5426\u6210\u529f\uff1a
gcc-11 -v\n
\u5982\u4e0b\u7ed3\u679c\uff0c\u8868\u793a\u6210\u529f\uff1a
Using built-in specs.\nCOLLECT_GCC=gcc-11\nCOLLECT_LTO_WRAPPER=/opt/homebrew/Cellar/gcc@11/11.3.0/bin/../libexec/gcc/aarch64-apple-darwin21/11/lto-wrapper\nTarget: aarch64-apple-darwin21\nConfigured with: ../configure --prefix=/opt/homebrew/opt/gcc@11 --libdir=/opt/homebrew/opt/gcc@11/lib/gcc/11 --disable-nls --enable-checking=release --with-gcc-major-version-only --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-11 --with-gmp=/opt/homebrew/opt/gmp --with-mpfr=/opt/homebrew/opt/mpfr --with-mpc=/opt/homebrew/opt/libmpc --with-isl=/opt/homebrew/opt/isl --with-zstd=/opt/homebrew/opt/zstd --with-pkgversion='Homebrew GCC 11.3.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --build=aarch64-apple-darwin21 --with-system-zlib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk\nThread model: posix\nSupported LTO compression algorithms: zlib zstd\ngcc version 11.3.0 (Homebrew GCC 11.3.0)\n
\u624b\u52a8\u4fee\u6539 ssb-dbgen \u76ee\u5f55\u4e0b\u7684 bm_utils.c \u914d\u7f6e\u6587\u4ef6\uff1a
\u5c06\u7b2c 41 \u884c\u7684 #include <malloc.h>
\u4fee\u6539\u4e3a #include <sys/malloc.h>
\u5c06\u7b2c 398 \u884c\u7684 open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT|O_LARGEFILE,0644);
\u4fee\u6539\u4e3a open(fullpath, ((*mode == 'r')?O_RDONLY:O_WRONLY)|O_CREAT,0644);
\u624b\u52a8\u4fee\u6539 ssb-dbgen \u76ee\u5f55\u4e0b\u7684 varsub.c \u914d\u7f6e\u6587\u4ef6\uff1a
#include <malloc.h>
\u4fee\u6539\u4e3a #include <sys/malloc.h>
\u624b\u52a8\u4fee\u6539 ssb-dbgen \u76ee\u5f55\u4e0b\u7684 makefile \u914d\u7f6e\u6587\u4ef6\uff1a
CC = gcc
\u4fee\u6539\u4e3a CC = gcc-11
\u518d\u6b21\u8fdb\u5165 ssb-dbgen \u76ee\u5f55\uff0c\u8fdb\u884c\u7f16\u8bd1\uff1a
cd ssb-dbgen\nmake\n
\u67e5\u770b ssb-dbgen \u76ee\u5f55\uff0c\u751f\u6210 dbgen \u53ef\u6267\u884c\u6587\u4ef6\uff0c\u8868\u793a\u7f16\u8bd1\u6210\u529f\u3002
\u6211\u5148\u5728 main \u5206\u652f\u6784\u5efa\u4e86 MatrixOne\uff0c\u73b0\u5728\u5207\u6362\u5230\u5176\u4ed6\u7248\u672c\u518d\u8fdb\u884c\u6784\u5efa\u51fa\u73b0 panic
\u5f53 MatrixOne \u7248\u672c\u5207\u6362\u6d89\u53ca\u5230 0.8.0 \u4e4b\u524d\u7684\u7248\u672c\u5e76\u4e14\u4f7f\u7528 make build
\u547d\u4ee4\u7684\u65f6\u5019\u53ef\u80fd\u4f1a\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u662f MatrixOne \u6570\u636e\u5b58\u50a8\u683c\u5f0f\u5347\u7ea7\u9020\u6210\u7684\u4e0d\u517c\u5bb9\u95ee\u9898\uff0c\u4f46\u81ea 0.8.0 \u7684\u7248\u672c\u5f00\u59cb\u4f1a\u6301\u7eed\u517c\u5bb9\u3002
Note
\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5f3a\u70c8\u5efa\u8bae\u4f60\u91cd\u65b0\u5b89\u88c5\u6700\u65b0\u7a33\u5b9a\u7248\u7684 MatrixOne \u7248\u672c\u4ee5\u5b9e\u73b0\u540e\u7eed\u7684\u6570\u636e\u517c\u5bb9\uff0c\u540c\u65f6\u63a8\u8350\u4f7f\u7528 mo_ctl \u5de5\u5177\u8fdb\u884c\u5feb\u901f\u6784\u5efa\u548c\u542f\u52a8\u3002
\u5177\u4f53\u6765\u8bf4\uff0c\u5728 MatrixOne \u7248\u672c 0.8.0 \u4e4b\u524d\u65f6\uff0c\u6267\u884c make build
\u540e\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u540d\u4e3a mo-data \u7684\u6570\u636e\u76ee\u5f55\u6587\u4ef6\uff0c\u7528\u4e8e\u5b58\u653e\u6570\u636e\u3002\u5982\u679c\u4f60\u518d\u5207\u6362\u5230\u5176\u4ed6\u5206\u652f\u4e0a\u5e76\u91cd\u65b0\u8fdb\u884c make build
\u7684\u65f6\u5019\uff0c\u7cfb\u7edf\u5e76\u4e0d\u4f1a\u81ea\u52a8\u5220\u9664 mo-data \u6570\u636e\u76ee\u5f55\uff0c\u6b64\u65f6\u7531\u4e8e\u6570\u636e\u683c\u5f0f\u4e0d\u517c\u5bb9\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4 panic \u60c5\u51b5\u53d1\u751f\u3002
\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f60\u9700\u8981\u5148\u6e05\u7406 mo-data \u6570\u636e\u76ee\u5f55\uff08\u5373\u6267\u884c rm -rf mo-data
\u547d\u4ee4\uff09\uff0c\u7136\u540e\u518d\u91cd\u65b0\u6784\u5efa MatrixOne\u3002
\u4ee5\u4e0b\u53c2\u8003\u4ee3\u7801\u793a\u4f8b\u4f7f\u7528\u8f83\u65e9\u7684\u6784\u5efa\u6d41\u7a0b\uff1a
[root ~]# cd matrixone // \u8fdb\u5165 matrixone \u6587\u4ef6\u76ee\u5f55\n[root ~]# git branch // \u67e5\u770b\u5f53\u524d\u5206\u652f\n* 0.8.0\n[root ~]# make build // \u6784\u5efa matrixone\n... // \u6b64\u5904\u7701\u7565\u6784\u5efa\u8fc7\u7a0b\u4ee3\u7801\u3002\u5982\u679c\u4f60\u6b64\u65f6\u60f3\u8981\u5207\u6362\u5230\u5176\u4ed6\u7248\u672c\uff0c\u4f8b\u5982 0.7.0 \u7248\u672c\n[root ~]# git checkout 0.7.0 // \u5207\u6362\u5230 0.7.0 \u7248\u672c\n[root ~]# rm -rf mo-data // \u6e05\u7406\u6570\u636e\u76ee\u5f55\n[root ~]# make build // \u6784\u5efa matrixone\n... // \u6b64\u5904\u7701\u7565\u6784\u5efa\u8fc7\u7a0b\u4ee3\u7801\n
\u6211\u4f7f\u7528\u5e26 CN \u6807\u7b7e\u7684\u65b9\u5f0f\u8fde proxy\uff0c\u767b\u5f55 MatrixOne \u96c6\u7fa4\u51fa\u73b0\u5bc6\u7801\u9a8c\u8bc1\u9519\u8bef\u7684\u63d0\u793a
\u95ee\u9898\u539f\u56e0\uff1a\u8fde\u63a5\u5b57\u7b26\u4e32\u4e66\u5199\u6709\u8bef\u3002\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u652f\u6301\u6269\u5c55\u7528\u6237\u540d\uff08username\uff09\u5b57\u6bb5\uff0c\u5728\u7528\u6237\u540d\uff08username\uff09\u540e\u6dfb\u52a0 ?
\uff0c?
\u540e\u53ef\u4ee5\u8ddf\u968f CN \u7ec4\u6807\u7b7e\uff0cCN \u7ec4\u6807\u7b7e\u7684 key \u548c value \u4e4b\u95f4\u7528 =
\u95f4\u9694\uff0c\u591a\u4e2a key-value \u4e4b\u95f4\u7528\u9017\u53f7 ,
\u95f4\u9694\u3002
\u89e3\u51b3\u65b9\u6cd5\uff1a\u8bf7\u53c2\u8003\u4ee5\u4e0b\u793a\u4f8b\u3002
\u5047\u8bbe\u5728\u4f60\u7684 MatrixOne \u7684 mo.yaml
\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0cCN \u7ec4\u7684\u914d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a
## \u4ec5\u5c55\u793a\u90e8\u5206\u4ee3\u7801\n...\n- cacheVolume:\nsize: 100Gi\ncnLabels:\n- key: workload\nvalues:\n- bk\n...\n
\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u96c6\u7fa4\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u793a\u4f8b\uff1amysql -u root?workload=bk -p111 -h 10.206.16.10 -P 31429
\u3002\u5176\u4e2d\uff0cworkload=bk
\u4e3a CN \u6807\u7b7e\uff0c\u4f7f\u7528 =
\u8fde\u63a5\u3002
\u5b89\u88c5\u6700\u65b0\u7684 operator\uff0c\u4e00\u76f4\u6709\u4e00\u4e2a\u53eb job-bucket \u7684 pod \u8d77\u4e0d\u6765\uff0c\u8bf7\u95ee\u5e94\u8be5\u600e\u4e48\u6392\u67e5\uff1f
\u53ef\u4ee5\u770b\u770b\u662f\u5426\u6ca1\u6709 secret\u3002\u53ef\u80fd\u662f\u6ca1\u6709\u914d\u7f6e minio \u8fde\u63a5\u4fe1\u606f\u5bfc\u81f4\u6ca1\u529e\u6cd5\u8fde\u63a5 minio\u3002
\u540c\u7406\uff0c\u4f7f\u7528 mo-dump
\u5de5\u5177\u5bfc\u51fa\u6570\u636e\u7684\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u793a\u4f8b\uff1amo-dump -u \"dump?workload=bk\" -h 10.206.16.10 -P 31429 -db tpch_10g > /tmp/mo/tpch_10g.sql
\u3002
\u4ec0\u4e48\u662f MatrixOne\uff1f
MatrixOne \u662f\u4e00\u6b3e\u9762\u5411\u672a\u6765\u7684\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0c\u901a\u8fc7\u8d85\u878d\u5408\u6570\u636e\u5f15\u64ce\u652f\u6301\u4e8b\u52a1/\u5206\u6790/\u6d41\u5904\u7406\u7b49\u6df7\u5408\u5de5\u4f5c\u8d1f\u8f7d\uff0c\u901a\u8fc7\u5f02\u6784\u4e91\u539f\u751f\u67b6\u6784\u652f\u6301\u8de8\u673a\u623f\u534f\u540c/\u591a\u5730\u534f\u540c/\u4e91\u8fb9\u534f\u540c\u3002MatrixOne \u5e0c\u671b\u7b80\u5316\u6570\u636e\u7cfb\u7edf\u5f00\u53d1\u548c\u8fd0\u7ef4\u7684\u6210\u672c\uff0c\u6d88\u51cf\u590d\u6742\u7cfb\u7edf\u95f4\u7684\u6570\u636e\u788e\u7247\uff0c\u6253\u7834\u6570\u636e\u878d\u5408\u7684\u5404\u79cd\u8fb9\u754c\u3002 \u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e MatrixOne \u7684\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u6d4f\u89c8 MatrixOne \u7b80\u4ecb\u3002
MatrixOne \u662f\u57fa\u4e8e MySQL \u6216\u8005\u5176\u4ed6\u6570\u636e\u5e93\u5f00\u53d1\u7684\u5417\uff1f
MatrixOne \u662f\u4e00\u4e2a\u4ece\u96f6\u6253\u9020\u7684\u5168\u65b0\u6570\u636e\u5e93\u3002MatrixOne \u517c\u5bb9 MySQL \u7684\u90e8\u5206\u8bed\u6cd5\u4e0e\u8bed\u4e49\uff0c\u5e76\u4e14\u5728\u672a\u6765\u5c06\u4f1a\u4ea7\u751f\u66f4\u591a\u4e0e MySQL \u4e0d\u540c\u7684\u8bed\u4e49\uff0c\u4ee5\u4fbf\u6211\u4eec\u5c06\u4e4b\u6253\u9020\u4e3a\u4e00\u6b3e\u66f4\u5f3a\u5927\u7684\u8d85\u878d\u5408\u6570\u636e\u5e93\u3002 \u5173\u4e8e\u4e0e MySQL \u7684\u517c\u5bb9\u6027\uff0c\u60a8\u53ef\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u3002
MatrixOne \u4f7f\u7528\u4ec0\u4e48\u7f16\u7a0b\u8bed\u8a00\u5f00\u53d1\u7684\uff1f
MatrixOne \u76ee\u524d\u4e3b\u8981\u4f7f\u7528 Golang \u4f5c\u4e3a\u6700\u4e3b\u8981\u7684\u7f16\u7a0b\u8bed\u8a00\u3002
\u76ee\u524d\u8fde\u63a5 MatrixOne \u652f\u6301\u54ea\u4e9b\u7f16\u7a0b\u8bed\u8a00\uff1f
MatrixOne \u652f\u6301 Java\u3001Python\u3001Golang \u8bed\u8a00\u548c ORM \u8fde\u63a5\uff0c\u5176\u4ed6\u8bed\u8a00\u4e5f\u53ef\u4ee5\u5c06 MO \u5f53\u4f5c MySQL \u6765\u8fdb\u884c\u8fde\u63a5\u3002
MatrixOne \u5217\u5b58\u4f7f\u7528\u4ec0\u4e48\u538b\u7f29\u7b97\u6cd5\uff1f
MatrixOne \u5217\u5b58\u76ee\u524d\u4f7f\u7528\u7684\u662f LZ4 \u538b\u7f29\u7b97\u6cd5\uff0c\u4e14\u4e0d\u652f\u6301\u901a\u8fc7\u914d\u7f6e\u4fee\u6539\u3002
\u8bf7\u95ee\u4f4e\u7248\u672c\u80fd\u5426\u5347\u7ea7\u5230\u6700\u65b0\u7684\u7248\u672c\uff1f
MatrixOne 0.8.0 \u53ca\u4ee5\u4e0a\u7248\u672c\u7686\u53ef\u4f7f\u7528 mo_ctl upgrade latest
\u4ece\u4f4e\u7248\u672c\u76f4\u63a5\u5347\u7ea7\u81f3\u6700\u65b0\u7248\u672c\uff0c\u60a8\u53ef\u53c2\u8003 mo_ctl \u5de5\u5177\u30020.8.0 \u4e4b\u524d\u7684\u7248\u672c\u5982\u6709\u5347\u7ea7\u9700\u8981\uff0c\u5efa\u8bae\u5907\u4efd\u6570\u636e\uff0c\u8fdb\u884c\u91cd\u88c5\u540e\u5bfc\u5165\u3002
\u73b0\u5728 MatrixOne \u53d1\u7a33\u5b9a\u7248\u4e86\u5417\uff1f\u63a8\u8350\u4f7f\u7528\u54ea\u4e2a\u7248\u672c\uff1f
MatrixOne \u73b0\u5df2\u53d1\u5e03 1.2.1 \u7248\u672c\uff0c\u5728\u7a33\u5b9a\u6027\u4e0a\u6211\u4eec\u505a\u4e86\u5927\u91cf\u7684\u4f18\u5316\u5de5\u4f5c\uff0c\u5df2\u7ecf\u53ef\u4ee5\u7528\u4e8e\u751f\u4ea7\u4e1a\u52a1\uff0c\u6b22\u8fce\u5927\u5bb6\u8bd5\u7528\u53cd\u9988\u3002
\u6709\u6ca1\u6709 MatrixOne \u4e91\u7248\u672c\uff1f\u60f3\u5feb\u901f\u6d4b\u8bd5\u770b\u770b
\u6709\u7684\u3002\u73b0 mo cloud \u5df2\u7ecf\u5f00\u59cb\u516c\u6d4b\u3002\u8be6\u60c5\u67e5\u770b MatrixOne Cloud \u6587\u6863
"},{"location":"MatrixOne/FAQs/product-faqs/#_3","title":"\u67b6\u6784\u76f8\u5173","text":"MatrixOne \u7684\u6743\u9650\u4e5f\u662f\u57fa\u4e8e RBAC \u6a21\u578b\u8bbe\u8ba1\u7684\u5417\uff1f\u53ef\u4e0d\u53ef\u4ee5\u5c06\u6743\u9650\u76f4\u63a5\u6388\u4e88\u5230\u7528\u6237\uff1f
MatrixOne \u7684\u6743\u9650\u7ba1\u7406\u662f\u7ed3\u5408\u4e86\u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236 (RBAC\uff0cRole-based access control) \u548c\u81ea\u4e3b\u8bbf\u95ee\u63a7\u5236 (DAC\uff0cDiscretionary access control) \u4e24\u79cd\u5b89\u5168\u6a21\u578b\u8bbe\u8ba1\u548c\u5b9e\u73b0\u7684\uff0c\u4e0d\u652f\u6301\u5c06\u6743\u9650\u76f4\u63a5\u6388\u4e88\u7528\u6237\uff0c\u9700\u8981\u901a\u8fc7\u89d2\u8272\u8fdb\u884c\u6388\u6743\u3002
\u9ad8\u53ef\u7528\u67b6\u6784\u8981\u600e\u4e48\u7528\uff1f
MatrixOne \u7684\u5355\u673a\u7248\u76ee\u524d\u8fd8\u6ca1\u6709\u9ad8\u53ef\u7528\u67b6\u6784\uff0c\u4e3b\u4ece\u7248\u7684\u9ad8\u53ef\u7528\u67b6\u6784\u8fd8\u5728\u8bbe\u8ba1\u4e2d\u3002\u5206\u5e03\u5f0f\u7248\u672c\u6765\u5c31\u662f\u9ad8\u53ef\u7528\u7684\uff0ck8s \u548c s3 \u672c\u6765\u5c31\u90fd\u662f\u9ad8\u53ef\u7528\u67b6\u6784\u3002MatrixOne \u7684\u8282\u70b9\u91cc cn \u548c tn \u90fd\u662f\u65e0\u72b6\u6001\u7684\uff0c\u6302\u4e86\u53ef\u4ee5\u968f\u65f6\u62c9\u8d77\uff0clog service \u6709\u72b6\u6001\uff0c\u5b83\u7684 3 \u8282\u70b9\u662f\u63d0\u4f9b\u4e00\u4e2a raft group \u7684\u5206\u5e03\u5f0f\u67b6\u6784\uff0c\u6302 1 \u4e2a\u6ca1\u5173\u7cfb\uff0c\u7ee7\u7eed\u8fd0\u884c\uff0c\u6302 2 \u4e2a\u7cfb\u7edf\u624d\u4f1a\u4e0d\u53ef\u7528\u3002
k8s \u96c6\u7fa4\u8282\u70b9\u5f53\u524d tn \u8282\u70b9\u662f\u5426\u652f\u6301\u6269\u5bb9\uff1f
MatrixOne \u5f53\u524d tn \u8282\u70b9\u8fd8\u4e0d\u652f\u6301\u6269\u5bb9\u3002
\u5404\u4e2a\u7ec4\u4ef6\u90fd\u662f\u505a\u4ec0\u4e48\u7528\u7684\uff1f\u6700\u5c0f\u5316\u9700\u8981\u90e8\u7f72\u90fd\u591a\u5c11\u4e2a\u5b9e\u4f8b\uff1f\u540e\u671f\u80fd\u652f\u6301\u4e0d\u505c\u670d\u65e0\u611f\u6269\u5bb9\u5417\uff1f
MatrixOne \u6838\u5fc3\u7684\u7ec4\u4ef6\u6709 4 \u4e2a\uff0cproxy\uff0ccn\uff0ctn\uff0clog service\u3002cn \u5c31\u662f\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9\uff0ctn \u662f\u4e8b\u52a1\u8282\u70b9\uff0clog service \u662f\u4e8b\u52a1\u7684\u65e5\u5fd7\uff0c\u76f8\u5f53\u4e8e WAL\u3002proxy \u662f\u7528\u6765\u505a\u8d1f\u8f7d\u5747\u8861\u548c\u8d44\u6e90\u7ec4\u7ba1\u7406\u7684\u3002\u5982\u679c\u90fd\u6df7\u5408\u90e8\u7f72\u7684\u8bdd\u53ef\u4ee5\u5728 3 \u53f0\u7269\u7406\u673a/\u865a\u62df\u673a\u641e\u5b9a\u3002\u53ef\u4ee5\u65e0\u611f\u6269\u5bb9\uff0cmo \u662f\u5b58\u7b97\u5206\u79bb\u7684\uff0c\u5b58\u50a8\u7684\u6269\u5bb9\u5c31\u662f s3 \u7684\u6269\u5bb9\u3002\u8ba1\u7b97\u7684\u6269\u5bb9\u5c31\u662f cn\uff0c\u672c\u8eab\u57fa\u4e8e k8s\uff0ccn \u65e0\u72b6\u6001\uff0c\u800c\u4e14\u662f\u5bb9\u5668\uff0c\u53ef\u4ee5\u5feb\u901f\u6269\u5bb9\u3002
\u591a\u79df\u6237\u4e4b\u95f4\u662f\u5982\u4f55\u5b9e\u73b0\u8d44\u6e90\u9694\u79bb\u7684\uff1f
MatrixOne \u7684\u8d44\u6e90\u9694\u79bb\u6838\u5fc3\u662f ACCOUNT \u53ef\u4ee5\u5bf9\u5e94\u5230 CN Set \u7684\u8d44\u6e90\u7ec4\u4e0a\uff0c\u6216\u8005\u53ef\u4ee5\u8ba4\u4e3a\u79df\u6237\u7684\u9694\u79bb\u5c31\u662f CN \u7684\u5bb9\u5668\u9694\u79bb\u3002\u9664\u4e86\u591a\u79df\u6237\u53ef\u4ee5\u5206\u914d\u4e0d\u540c\u8d44\u6e90\u7ec4\u4ee5\u5916\uff0c\u5355\u4e2a\u79df\u6237\u5185\u90e8\u4e5f\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u7c7b\u578b\u8fdb\u4e00\u6b65\u5206\u914d CN \u8d44\u6e90\u7ec4\uff0c\u8fdb\u884c\u66f4\u7ec6\u7c92\u5ea6\u7684\u63a7\u5236\u3002\u5173\u4e8e\u8d44\u6e90\u9694\u79bb\u7684\u5b8c\u6574\u63cf\u8ff0\uff0c\u60a8\u53ef\u53c2\u89c1\u8d1f\u8f7d\u4e0e\u79df\u6237\u9694\u79bb
MySQL \u4e2d\u7684\u8868\u5f15\u64ce\u80fd\u76f4\u63a5\u8fc1\u79fb\u5417\uff1f\u517c\u5bb9 InnoDB \u7b49\u5f15\u64ce\u5417\uff1f
MatrixOne \u4e0d\u652f\u6301 MySQL \u7684 InnoDB\uff0cMyISAM \u7b49\u5f15\u64ce\uff0c\u4f46\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 MySQL \u7684\u8bed\u53e5\uff0cMatrixOne \u4f1a\u5ffd\u7565\u8fd9\u4e9b\u5f15\u64ce\uff0c\u5728 MatrixOne \u4e2d\u4ec5\u6709 TAE \u4e00\u79cd\u5b58\u50a8\u5f15\u64ce\uff0c\u5b83\u662f\u5b8c\u5168\u72ec\u7acb\u7814\u53d1\u7684\uff0c\u53ef\u4ee5\u53cb\u597d\u7684\u9002\u7528\u4e8e\u5404\u7c7b\u573a\u666f\uff0c\u65e0\u9700\u4f7f\u7528 ENGINE=XXX \u6765\u66f4\u6362\u5f15\u64ce\u3002
"},{"location":"MatrixOne/FAQs/product-faqs/#_4","title":"\u529f\u80fd\u76f8\u5173","text":"MatrxOne \u652f\u6301\u54ea\u4e9b\u5e94\u7528\uff1f
MatrixOne \u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u6781\u81f4\u7684 HTAP \u670d\u52a1\uff0cMatrixOne \u53ef\u4ee5\u88ab\u5e94\u7528\u5728\u4f01\u4e1a\u6570\u636e\u4e2d\u53f0\uff0c\u5927\u6570\u636e\u5206\u6790\u7b49\u573a\u666f\u4e2d\u3002
MatrixOne \u517c\u5bb9\u54ea\u4e2a\u6570\u636e\u5e93\uff1f
MatrixOne \u5728\u4f7f\u7528\u4e0a\u4fdd\u6301\u5bf9 MySQL 8.0 \u7684\u9ad8\u5ea6\u517c\u5bb9\uff0c\u5305\u62ec SQL \u8bed\u6cd5\uff0c\u4f20\u8f93\u534f\u8bae\uff0c\u64cd\u4f5c\u7b26\u4e0e\u51fd\u6570\u7b49\u7b49\u3002\u4e0e MySQL 8.0 \u517c\u5bb9\u6027\u7684\u5dee\u5f02\u5217\u8868\u53ef\u4ee5\u8be6\u7ec6\u53c2\u8003 MySQL \u517c\u5bb9\u6027\u5217\u8868\u3002
\u5bf9 MySQL \u7684\u517c\u5bb9\u6027\u600e\u4e48\u6837\uff0cBI \u91cc\u76f4\u63a5\u5f53 MySQL \u7528\u5417\uff1f
MatrixOne \u4e0e MySQL 8.0 \u5177\u6709\u9ad8\u5ea6\u7684\u517c\u5bb9\u6027\uff0c\u65e0\u8bba\u5728\u901a\u4fe1\u534f\u8bae\uff0cSQL \u8bed\u6cd5\uff0c\u8fde\u63a5\u5de5\u5177\uff0c\u8fd8\u662f\u5f00\u53d1\u6a21\u5f0f\u4e0a\uff0c\u90fd\u4e0e MySQL \u57fa\u672c\u4e00\u81f4\u3002\u7ba1\u7406\u548c\u751f\u6001\u5de5\u5177\u5f88\u591a\u4e5f\u90fd\u53ef\u4ee5\u590d\u7528 MySQL \u7684\u5de5\u5177\u3002BI \u91cc\u53ef\u4ee5\u76f4\u63a5\u5f53 MySQL \u7528\uff0c\u8be6\u60c5\u8bf7\u53c2\u8003\u901a\u8fc7 FineBI \u5b9e\u73b0 MatrixOne \u7684\u53ef\u89c6\u5316\u62a5\u8868\uff0c\u901a\u8fc7\u6c38\u6d2a BI \u5b9e\u73b0 MatrixOne \u7684\u53ef\u89c6\u5316\u62a5\u8868\uff0c\u901a\u8fc7 Superset \u5b9e\u73b0 MatrixOne \u53ef\u89c6\u5316\u76d1\u63a7\u3002
"},{"location":"MatrixOne/FAQs/product-faqs/#_5","title":"\u6570\u636e\u5e93\u5bf9\u6bd4\u76f8\u5173","text":"MatrixOne \u5355\u673a\u548c MySQL \u6027\u80fd\u5bf9\u6bd4\u5982\u4f55\uff1f
MatrixOne \u5355\u673a\u7248\u672c\u5728 TP \u6027\u80fd\u4e0a\u4e0e MySQL \u76f8\u6bd4\u7565\u5dee\uff0c\u4f46\u5728 Load\uff0c\u6d41\u5f0f\u5199\u5165\uff0c\u5206\u6790\u67e5\u8be2\u4e0a\u6027\u80fd\u8fdc\u8d85\u8fc7 MySQL\u3002
\u4e0e HTAP \u6570\u636e\u5e93 TiDB \u6709\u4ec0\u4e48\u533a\u522b\uff1f
MatrixOne \u4e0e TiDB \u7684\u67b6\u6784\u4e0d\u4e00\u6837\u3002MatrixOne \u662f\u5b58\u7b97\u5206\u79bb\u7684\uff0c\u662f\u57fa\u4e8e\u4e91\u7684 share storage \u67b6\u6784\uff0c\u6570\u636e\u90fd\u5728\u4e00\u4e2a\u5730\u65b9\uff0c\u53ea\u5b58\u4e00\u4efd\uff0c\u662f\u7528\u4e00\u4e2a\u5f15\u64ce\u5b9e\u73b0\u7684 HTAP\u3002\u800c TiDB \u662f Share nothing \u67b6\u6784\uff0c\u6570\u636e\u8981\u5206\u7247\uff0cTiKV \u505a TP\uff0cTiFlash \u505a AP\uff0c\u4f7f\u7528\u4e24\u4e2a\u5f15\u64ce\u52a0\u4e86\u4e2a ETL \u505a\u5230\u7684 HTAP\uff0c\u6570\u636e\u4e5f\u8981\u5b58\u4e24\u4efd\u3002
"},{"location":"MatrixOne/FAQs/product-faqs/#_6","title":"\u5176\u5b83","text":"MatrixOne \u662f\u4e00\u4e2a\u5b8c\u5168\u5728 Github \u4e0a\u8fdb\u884c\u7684\u5f00\u6e90\u9879\u76ee\uff0c\u6b22\u8fce\u6240\u6709\u5f00\u53d1\u8005\u7684\u8d21\u732e\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u6211\u4eec\u7684\u8d21\u732e\u6307\u5357\u3002
\u76ee\u524d\uff0cMatrixOne \u6587\u6863\u662f\u83b7\u53d6 MatrixOne \u76f8\u5173\u77e5\u8bc6\u6700\u91cd\u8981\u3001\u6700\u53ca\u65f6\u7684\u9014\u5f84\u3002\u6b64\u5916\uff0c\u6211\u4eec\u5728 Slack \u548c\u5fae\u4fe1\u8fd8\u6709\u4e00\u4e9b\u6280\u672f\u4ea4\u6d41\u7fa4\u3002\u5982\u6709\u4efb\u4f55\u9700\u6c42\uff0c\u8bf7\u8054\u7cfb opensource@matrixorigin.io\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/","title":"SQL \u5e38\u89c1\u95ee\u9898","text":""},{"location":"MatrixOne/FAQs/sql-faqs/#_1","title":"\u57fa\u672c\u529f\u80fd\u76f8\u5173","text":"MatrixOne \u5bf9\u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u654f\u611f\u5417\uff1f
MatrixOne \u9ed8\u8ba4\u5bf9\u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff0c\u5e76\u652f\u6301\u901a\u8fc7 lower_case_table_names \u53c2\u6570\u6765\u8fdb\u884c\u5927\u5c0f\u5199\u654f\u611f\u7684\u652f\u6301\uff0c\u5bf9\u4e8e\u53c2\u6570\u7684\u8be6\u7ec6\u4ecb\u7ecd\u53ef\u53c2\u89c1\u5927\u5c0f\u5199\u654f\u611f\u652f\u6301
MatrixOne \u652f\u6301\u54ea\u4e9b SQL \u8bed\u53e5\uff1f
MatrixOne \u76ee\u524d\u652f\u6301\u7684 SQL \u8bed\u53e5\u53ef\u4ee5\u53c2\u8003 SQL \u8bed\u53e5\u7684\u5206\u7c7b\u3002
MatrixOne \u652f\u6301\u54ea\u4e9b\u6570\u636e\u7c7b\u578b\uff1f
MatrixOne \u76ee\u524d\u652f\u6301\u5e38\u7528\u7684\u6574\u578b\uff0c\u6d6e\u70b9\u6570\uff0c\u5b57\u7b26\u4e32\uff0c\u65f6\u95f4\u65e5\u671f\uff0c\u5e03\u5c14\uff0c\u679a\u4e3e\uff0c\u4e8c\u8fdb\u5236\uff0cJSON \u7c7b\u578b\uff0c\u8bf7\u53c2\u8003\u6570\u636e\u7c7b\u578b\u6982\u89c8\u3002
MatrixOne \u652f\u6301\u4ec0\u4e48\u7c7b\u578b\u7684\u5b57\u7b26\u96c6\uff1f
MatrixOne \u9ed8\u8ba4\u652f\u6301 UTF-8 \u5b57\u7b26\u96c6\uff0c\u4e14\u76ee\u524d\u53ea\u652f\u6301 UTF-8\u3002
MatrixOne \u652f\u6301\u54ea\u4e9b\u7ea6\u675f\u548c\u7d22\u5f15\uff1f
MatrixOne \u76ee\u524d\u652f\u6301\u4e3b\u952e (Primary Key), \u552f\u4e00 (Unique Key), \u975e\u7a7a (Not Null)\uff0c\u5916\u952e (Foreign Key)\uff0c\u81ea\u589e\u7ea6\u675f (Auto Increment) \u53ca\u6b21\u7ea7\u7d22\u5f15\uff08Secondary Index\uff09\u3002\u6b21\u7ea7\u7d22\u5f15\u76ee\u524d\u4ec5\u5b9e\u73b0\u8bed\u6cd5\u652f\u6301\uff0c\u6ca1\u6709\u52a0\u901f\u4f5c\u7528\u3002 \u53e6\u5916 MatrixOne \u8fd8\u63d0\u4f9b\u4e86\u9488\u5bf9\u65e0\u4e3b\u952e\u8868\u7684\u6392\u5e8f\u952e (Cluster by), \u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u63d0\u524d\u9488\u5bf9\u9700\u8981\u67e5\u8be2\u7684\u5217\u8fdb\u884c\u6392\u5e8f\uff0c\u52a0\u901f\u67e5\u8be2\u3002
MatrixOne \u652f\u6301\u54ea\u4e9b\u67e5\u8be2\u7c7b\u578b\uff1f
MatrixOne \u652f\u6301\u5927\u90e8\u5206\u5e38\u7528 SQL \u67e5\u8be2\uff1a
\u57fa\u7840\u67e5\u8be2\uff1a\u652f\u6301\u5e38\u89c1\u7684\u5206\u7ec4\uff0c\u53bb\u91cd\uff0c\u8fc7\u6ee4\uff0c\u6392\u5e8f\uff0c\u9650\u5b9a\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u7b49\u57fa\u7840\u67e5\u8be2\u80fd\u529b\u3002
\u9ad8\u7ea7\u67e5\u8be2\uff1a\u652f\u6301\u89c6\u56fe\uff0c\u5b50\u67e5\u8be2\uff0c\u8054\u63a5\uff0c\u7ec4\u5408\uff0c\u516c\u5171\u8868\u8868\u8fbe\u5f0f\uff08CTE\uff09\uff0c\u7a97\u53e3\u51fd\u6570\uff0cPrepare \u9884\u5904\u7406\u7b49\u9ad8\u7ea7\u67e5\u8be2\u80fd\u529b\u3002
\u805a\u5408\u51fd\u6570\uff1a\u652f\u6301\u5e38\u89c1\u7684 AVG\uff0cCOUNT\uff0cMIN\uff0cMAX\uff0cSUM \u7b49\u805a\u5408\u51fd\u6570\u3002
\u7cfb\u7edf\u51fd\u6570\u53ca\u64cd\u4f5c\u7b26\uff1a\u652f\u6301\u5e38\u89c1\u7684\u5b57\u7b26\u4e32\uff0c\u65e5\u671f\u65f6\u95f4\uff0c\u6570\u5b66\u51fd\u6570\u53ca\u5e38\u89c1\u64cd\u4f5c\u7b26\u3002
MatrixOne \u6709\u54ea\u4e9b\u4fdd\u7559\u5173\u952e\u5b57\uff1f
MatrixOne \u7684\u4fdd\u7559\u5173\u952e\u5b57\u5217\u8868\u53ef\u53c2\u89c1\u5173\u952e\u5b57\u3002
\u5c06\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\uff0c\u5426\u5219\u5c06\u4ea7\u751f\u62a5\u9519\u3002\u5c06\u975e\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u65e0\u9700\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\u3002
MatrixOne \u652f\u4e0d\u652f\u6301\u7269\u5316\u89c6\u56fe\uff1f
MatrixOne \u76ee\u524d\u4e0d\u652f\u6301\u7269\u5316\u89c6\u56fe\uff0c\u5728\u76ee\u524d\u7684 AP \u6027\u80fd\u652f\u6491\u4e0b\uff0c\u76f4\u63a5\u8fdb\u884c\u5206\u6790\u4e5f\u53ef\u4ee5\u83b7\u5f97\u8f83\u9ad8\u7684\u5206\u6790\u4f53\u9a8c\u3002\u7269\u5316\u89c6\u56fe\u529f\u80fd\u4e5f\u5df2\u7ecf\u5728 MatrixOne \u7684 Roadmap \u4e2d\uff0c\u5982\u679c\u60a8\u5bf9\u7269\u5316\u89c6\u56fe\u6709\u521a\u6027\u8f83\u9ad8\u7684\u9700\u6c42\uff0c\u6b22\u8fce\u7ed9\u6211\u4eec\u63d0 Issue \u6765\u63cf\u8ff0\u60a8\u7684\u573a\u666f\uff1ahttps://github.com/matrixorigin/matrixone/issues
MatrixOne \u652f\u4e0d\u652f\u6301 Geometry\uff1f
\u76ee\u524d\u8fd8\u4e0d\u652f\u6301\uff0c\u540e\u7eed\u4f1a\u652f\u6301\u3002
MatrixOne \u4e2d\u7684\u51fd\u6570\u548c\u5173\u952e\u5b57\u662f\u5426\u533a\u5206\u5927\u5c0f\u5199\uff1f
\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u5728 MatrixOne \u4e2d\uff0c\u53ea\u6709\u4e00\u79cd\u60c5\u51b5\u9700\u8981\u533a\u5206\u5927\u5c0f\u5199\uff1a\u5982\u679c\u4f60\u521b\u5efa\u7684\u8868\u548c\u5c5e\u6027\u5e26\u6709 ``\uff0c`` \u4e2d\u7684\u540d\u79f0\u9700\u8981\u6ce8\u610f\u5927\u5c0f\u5199\u3002\u67e5\u8be2\u8fd9\u4e2a\u8868\u540d\u6216\u5c5e\u6027\u540d\uff0c\u90a3\u4e48\u8868\u540d\u548c\u5c5e\u6027\u540d\u4e5f\u9700\u8981\u88ab\u5305\u542b\u5728``\u91cc\u3002
MatrixOne \u662f\u5426\u652f\u6301\u4e8b\u52a1\uff1f\u652f\u6301\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u662f\u4ec0\u4e48\uff1f
MatrixOne \u652f\u6301 ACID\uff08\u539f\u5b50\u6027\u3001\u4e00\u81f4\u6027\u3001\u9694\u79bb\u6027\u3001\u6301\u4e45\u6027\uff09\u7684\u4e8b\u52a1\u80fd\u529b\uff0c\u652f\u6301\u60b2\u89c2\u548c\u4e50\u89c2\u4e8b\u52a1\uff0c\u9ed8\u8ba4\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u3002\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u7684\u65f6\u5019\u4f1a\u91c7\u7528 Read Committed \u9694\u79bb\u7ea7\u522b\uff0c\u5207\u6362\u6210\u4e50\u89c2\u4e8b\u52a1\u7684\u65f6\u5019\u4f1a\u91c7\u7528 Snapshot Isolation \u9694\u79bb\u7ea7\u522b\u3002
MatrixOne \u4e2d\u7684\u51fd\u6570\u548c\u5173\u952e\u5b57\u662f\u5426\u533a\u5206\u5927\u5c0f\u5199\uff1f
\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u5728 MatrixOne \u4e2d\uff0c\u53ea\u6709\u4e00\u79cd\u60c5\u51b5\u9700\u8981\u533a\u5206\u5927\u5c0f\u5199\uff1a\u5982\u679c\u4f60\u521b\u5efa\u7684\u8868\u548c\u5c5e\u6027\u5e26\u6709 ``\uff0c`` \u4e2d\u7684\u540d\u79f0\u9700\u8981\u6ce8\u610f\u5927\u5c0f\u5199\u3002\u67e5\u8be2\u8fd9\u4e2a\u8868\u540d\u6216\u5c5e\u6027\u540d\uff0c\u90a3\u4e48\u8868\u540d\u548c\u5c5e\u6027\u540d\u4e5f\u9700\u8981\u88ab\u5305\u542b\u5728``\u91cc\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/#_2","title":"\u6570\u636e\u5bfc\u5165/\u5bfc\u51fa\u76f8\u5173","text":"\u5982\u4f55\u5c06\u6570\u636e\u5bfc\u5165\u5230 MatrixOne \u4e2d\uff1f
MatrixOne \u652f\u6301\u4e0e MySQL \u76f8\u540c\u7684 INSERT
\u6570\u636e\u63d2\u5165\u8bed\u53e5\uff0c\u53ef\u4ee5\u901a\u8fc7 INSERT
\u8fdb\u884c\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u540c\u65f6\u4e5f\u652f\u6301 LOAD DATA
\u7684\u79bb\u7ebf\u6279\u91cf\u5bfc\u5165\u8bed\u53e5\u3002
\u5982\u4f55\u5c06\u6570\u636e\u4ece MatrixOne \u5bfc\u51fa\u5230\u6587\u4ef6\uff1f
\u5728 MatrixOne \u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 mo-dump
\u8fd9\u4e2a\u4e8c\u8fdb\u5236\u5de5\u5177\u628a\u6570\u636e\u5bfc\u51fa\u6210 SQL \u6216\u8005 csv \u6587\u4ef6\uff0c\u6216\u8005\u4f7f\u7528 SELECT INTO
\u5bfc\u51fa csv
\u6587\u4ef6\u3002
\u5982\u4f55\u901a\u8fc7 mo-dump \u5de5\u5177\u53ea\u5bfc\u51fa\u8868\u7ed3\u6784\uff1f
\u53ef\u4ee5\u5728\u5bfc\u51fa\u547d\u4ee4\u540e\u52a0-no-data \u53c2\u6570\uff0c\u6307\u5b9a\u4e0d\u5bfc\u51fa\u6570\u636e\u3002
\u4f7f\u7528 load data \u5bfc\u5165\u7684 json \u5bf9\u8c61\u4e2d\u7f3a\u5c11\u67d0\u4e9b\u5b57\u6bb5\uff0c\u5bfc\u5165\u4f1a\u62a5\u9519\u5417\uff1f
\u4f1a\u62a5\u9519\uff0c\u5bfc\u5165 json \u4e2d\uff0c\u5b57\u6bb5\u591a\u4e8e\u8868\u4e2d\u5b57\u6bb5\uff0c\u53ef\u4ee5\u6b63\u5e38\u5bfc\u5165\uff0c\u4e0d\u8fc7\u591a\u51fa\u5b57\u6bb5\u4f1a\u88ab\u5ffd\u7565\uff0c\u5982\u679c\u5c11\u4e8e\u7684\u8bdd\uff0c\u5219\u65e0\u6cd5\u5bfc\u5165\u3002
\u5728\u6267\u884c source \u5bfc\u5165\u7684\u65f6\u5019\u5bfc\u5165\u6587\u4ef6\u662f\u5426\u53ef\u4ee5\u5199\u76f8\u5bf9\u8def\u5f84\uff1f
\u53ef\u4ee5\uff0c\u4f46\u662f\u662f\u76f8\u5bf9\u4e8e\u60a8\u4f7f\u7528 mysql \u5ba2\u6237\u7aef\u7684\u5f53\u524d\u8def\u5f84\uff0c\u9632\u6b62\u51fa\u9519\uff0c\u8fd8\u662f\u5efa\u8bae\u5199\u5168\u8def\u5f84\uff0c\u53e6\u9700\u6ce8\u610f\u6587\u4ef6\u6743\u9650\u95ee\u9898\u3002
\u4f7f\u7528 load data \u547d\u4ee4\u5bfc\u5165\u4e00\u4e2a\u5927\u6587\u4ef6\u65f6\u6bd4\u8f83\u8017\u65f6\uff0c\u80fd\u5426\u4f18\u5316\u5462\uff1f
\u60a8\u53ef\u4ee5\u5728\u5bfc\u5165\u65f6\u5019\u6307\u5b9a PARALLEL \u4e3a true \u5f00\u542f\u5e76\u884c\u5bfc\u5165\uff0c\u4f8b\u5982\uff0c\u5bf9\u4e8e 2 \u4e2a G \u7684\u5927\u6587\u4ef6\uff0c\u4f7f\u7528\u4e24\u4e2a\u7ebf\u7a0b\u53bb\u8fdb\u884c\u52a0\u8f7d\uff0c\u7b2c 2 \u4e2a\u7ebf\u7a0b\u5148\u62c6\u5206\u5b9a\u4f4d\u5230 1G \u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u4e00\u76f4\u5f80\u540e\u8bfb\u53d6\u5e76\u8fdb\u884c\u52a0\u8f7d\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u505a\u5230\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u53d6\u5927\u6587\u4ef6\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u8bfb\u53d6 1G \u7684\u6570\u636e\u3002\u4e5f\u53ef\u4ee5\u81ea\u5df1\u5207\u5206\u6570\u636e\u6587\u4ef6\u3002
load data \u5bfc\u5165\u6709\u4e8b\u52a1\u5417\uff1f
\u6240\u6709\u7684 load \u8bed\u53e5\u90fd\u662f\u6709\u4e8b\u52a1\u7684\u3002
source \u5bfc\u5165 sql \u65f6\u6d89\u53ca\u89e6\u53d1\u5668\u548c\u5b58\u50a8\u8fc7\u7a0b\u4f1a\u6267\u884c\u751f\u6548\u5417\uff1f
\u76ee\u524d\u5982\u679c sql \u4e2d\u5b58\u5728\u4e0d\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3001\u89e6\u53d1\u5668\u3001\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ecd\u9700\u8981\u624b\u52a8\u4fee\u6539\uff0c\u5426\u5219\u6267\u884c\u4f1a\u62a5\u9519\u3002
mo-dump \u652f\u6301\u6279\u91cf\u5bfc\u51fa\u591a\u4e2a\u6570\u636e\u5e93\u5417\uff1f
\u76ee\u524d\u4ec5\u652f\u6301\u5bfc\u51fa\u5355\u4e2a\u6570\u636e\u5e93\u7684\u5907\u4efd\uff0c\u5982\u679c\u4f60\u6709\u591a\u4e2a\u6570\u636e\u5e93\u9700\u8981\u5907\u4efd\uff0c\u9700\u8981\u624b\u52a8\u8fd0\u884c mo-dump \u591a\u6b21\u3002
MatrixOne \u652f\u6301\u4ece Minio \u5bfc\u5165\u6570\u636e\u5417\uff1f
\u662f\u652f\u6301\u7684\uff0cload data \u547d\u4ee4\u652f\u6301\u4ece\u672c\u5730\u6587\u4ef6\u3001S3 \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u4ee5\u53ca S3 \u517c\u5bb9\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u4e2d\u5bfc\u5165\u6570\u636e\u5230 matrixone \u4e2d\uff0c \u800c Minio \u4e5f\u662f\u57fa\u4e8e S3 \u534f\u8bae\u7684\uff0c\u6240\u4ee5\u4e5f\u662f\u652f\u6301\u7684\uff0c\u8be6\u60c5\u53c2\u89c1\u672c\u5730\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165\u6570\u636e
MatrixOne \u5bfc\u5165\u5bfc\u51fa\u6570\u636e\u65f6\uff0c\u5982\u679c\u51fa\u73b0\u7f16\u7801\u95ee\u9898\uff0c\u5bfc\u81f4\u6570\u636e\u4e71\u7801\uff0c\u6211\u4eec\u4e00\u822c\u662f\u600e\u4e48\u89e3\u51b3\u7684
\u7531\u4e8e matrixone \u9ed8\u8ba4\u53ea\u652f\u6301 UTF8 \u8fd9\u4e00\u79cd\u7f16\u7801\u4e14\u65e0\u6cd5\u66f4\u6539\uff0c\u6240\u4ee5\u5728\u5bfc\u5165\u6570\u636e\u65f6\u5982\u679c\u51fa\u73b0\u4e86\u4e71\u7801\uff0c\u6211\u4eec\u5c31\u4e0d\u80fd\u901a\u8fc7\u4fee\u6539\u6570\u636e\u5e93\u548c\u8868\u7684\u5b57\u7b26\u96c6\u6765\u89e3\u51b3\uff0c\u53ef\u4ee5\u8bd5\u7740\u8f6c\u6362\u6570\u636e\u7f16\u7801\u4e3a UTF8\u3002\u5e38\u89c1\u7684\u8f6c\u6362\u5de5\u5177\u6709 iconv \u548c recode\uff0c\u6bd4\u5982\uff1a\u5c06 GBK \u7f16\u7801\u7684\u6570\u636e\u8f6c\u6362\u4e3a UTF-8 \u7f16\u7801\uff1aiconv -f GBK -t UTF8 t1.sql > t1_utf8.sql\u3002
MatrixOne \u5bfc\u5165\u5bfc\u51fa\u65f6\uff0c\u9700\u8981\u54ea\u4e9b\u6743\u9650\uff1f
\u5982\u679c\u662f\u79df\u6237\u7ba1\u7406\u5458\u7684\u8bdd\uff0c\u901a\u8fc7\u9ed8\u8ba4\u89d2\u8272\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u5bfc\u5165\u3001\u5bfc\u51fa\u64cd\u4f5c\u3002\u666e\u901a\u7528\u6237\u7684\u8bdd\uff0c\u5bfc\u5165\u65f6\uff0c\u9700\u8981\u5bfc\u5165\u8868\u7684 'insert' \u6743\u9650\uff1bselect...into outfile \u65b9\u5f0f\u5bfc\u51fa\u65f6\uff0c\u9700\u8981\u5bfc\u51fa\u8868\u7684 'select' \u6743\u9650\uff1bmo-dump \u5bfc\u51fa\u65f6\uff0c\u9700\u8981\u6240\u6709\u8868 (table.) \u7684 'select' \u6743\u9650\u548c\u6240\u6709\u5e93 (database.) \u7684 'show tables' \u6743\u9650\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/#_3","title":"\u6743\u9650\u76f8\u5173","text":"\u666e\u901a\u7528\u6237\u80fd\u6388\u4e88 MOADMIN \u89d2\u8272\u5417\uff1f
\u4e0d\u53ef\u4ee5\u7684\uff0cMOADMIN \u4e3a\u6700\u9ad8\u7684\u96c6\u7fa4\u7ba1\u7406\u5458\u6743\u9650\uff0c\u53ea\u6709 root \u7528\u6237\u62e5\u6709\u3002
"},{"location":"MatrixOne/FAQs/sql-faqs/#_4","title":"\u5176\u5b83","text":"MatrixOne \u4e2d\u7684 sql_mode
\u662f\u4ec0\u4e48\uff1f
MatrixOne \u9ed8\u8ba4\u7684 sql_mode
\u662f MySQL \u4e2d\u7684 only_full_group_by
\u3002\u56e0\u6b64\u9ed8\u8ba4\u67e5\u8be2\u8bed\u6cd5\u4e2d\u6240\u6709 select
\u7684\u5b57\u6bb5\uff0c\u9664\u805a\u5408\u51fd\u6570\u4e2d\u7684\u5b57\u6bb5\uff0c\u90fd\u5fc5\u987b\u5728 group by
\u4e2d\u51fa\u73b0\u3002\u4f46\u662f MatrixOne \u4e5f\u652f\u6301\u4fee\u6539 sql_mode
\u4ee5\u517c\u5bb9\u4e0d\u5b8c\u5168\u89c4\u8303\u7684 group by
\u8bed\u6cd5\u3002
MatrixOne \u4e2d show tables \u65e0\u6cd5\u67e5\u770b\u4e34\u65f6\u8868\uff0c\u5982\u4f55\u67e5\u770b\u662f\u5426\u521b\u5efa\u6210\u529f\uff1f
\u76ee\u524d\u53ef\u4ee5\u901a\u8fc7 \"show create table \u4e34\u65f6\u8868\u540d\" \u6765\u67e5\u770b\uff0c\u7531\u4e8e\u4e34\u65f6\u8868\u5728\u521b\u5efa\u540e\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u53ef\u89c1\uff0c\u5728\u5f53\u524d\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u6570\u636e\u5e93\u81ea\u52a8\u5220\u9664\u4e34\u65f6\u8868\u5e76\u91ca\u653e\u6240\u6709\u7a7a\u95f4\uff0c\u5728\u5b83\u7684\u751f\u547d\u5468\u671f\u5185\u6211\u4eec\u901a\u5e38\u662f\u53ef\u4ee5\u4eba\u4e3a\u611f\u77e5\u7684\u3002
\u5982\u4f55\u67e5\u770b\u6211\u7684 Query \u6267\u884c\u8ba1\u5212\uff1f
\u8981\u67e5\u770b MatrixOne \u5bf9\u7ed9\u5b9a\u67e5\u8be2\u7684\u6267\u884c\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528 EXPLAIN
\u8bed\u53e5\uff0c\u5b83\u5c06\u6253\u5370\u51fa\u67e5\u8be2\u8ba1\u5212\u3002
EXPLAIN SELECT col1 FROM tbl1;
MatrixOne \u517c\u5bb9 MySQL\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u6216\u5176\u4ed6\u65b9\u5f0f\u8fde\u63a5 MatrixOne\u3002\u53c2\u52a0 MySQL \u517c\u5bb9\u6027\u548c\u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
"},{"location":"MatrixOne/Get-Started/basic-sql/#sql","title":"\u4ec0\u4e48\u662f SQL \u8bed\u8a00\uff1f","text":"SQL (Structured Query Language: \u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00) \u662f\u7528\u4e8e\u7ba1\u7406\u5173\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff08RDBMS\uff09\u3002SQL \u7684\u8303\u56f4\u5305\u62ec\u6570\u636e\u63d2\u5165\u3001\u67e5\u8be2\u3001\u66f4\u65b0\u548c\u5220\u9664\uff0c\u6570\u636e\u5e93\u6a21\u5f0f\u521b\u5efa\u548c\u4fee\u6539\uff0c\u4ee5\u53ca\u6570\u636e\u8bbf\u95ee\u63a7\u5236\u3002
"},{"location":"MatrixOne/Get-Started/basic-sql/#matrixone-sql_1","title":"MatrixOne \u7684 SQL \u90fd\u5206\u4e3a\u54ea\u51e0\u7c7b\uff1f","text":"SQL \u8bed\u8a00\u901a\u5e38\u6309\u7167\u529f\u80fd\u5212\u5206\u6210\u4ee5\u4e0b\u7684 6 \u4e2a\u90e8\u5206\uff1a
DDL (Data Definition Language)\uff1a\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff0c\u7528\u6765\u5b9a\u4e49\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5305\u62ec\u5e93\u3001\u8868\u3001\u89c6\u56fe\u7b49\u3002\u4f8b\u5982\uff0cCREATE
\uff0cALTER
\uff0c\u548c DROP
\u7b49\u3002
DML (Data Manipulation Language)\uff1a\u6570\u636e\u4fee\u6539\u8bed\u8a00\uff0c\u7528\u6765\u4fee\u6539\u548c\u4e1a\u52a1\u76f8\u5173\u7684\u8bb0\u5f55\u3002\u4f8b\u5982\uff0cSELECT
\uff0cDELETE
\uff0c\u6216 INSERT
\u7b49\u3002
DQL (Data Query Language)\uff1a\u6570\u636e\u67e5\u8be2\u8bed\u8a00\uff0c\u7528\u6765\u67e5\u8be2\u7ecf\u8fc7\u6761\u4ef6\u7b5b\u9009\u7684\u8bb0\u5f55\u3002\u4f8b\u5982\uff0cSELECT...FROM...[WHERE]
\u8fd9\u79cd\u591a\u4e2a\u5b50\u53e5\u7ec4\u5408\u800c\u6210\u7684 SQL \u8bed\u53e5\u3002
TCL\uff08Transaction Control Language\uff09\uff1a\u4e8b\u52a1\u63a7\u5236\u8bed\u8a00\uff0c\u7528\u4e8e\u4e8b\u52a1\u7ba1\u63a7\u3002\u4f8b\u5982\uff0cCOMMIT
\uff0cROLLBACK
\uff0c\u6216 SET TRANSACTION
\u7b49\u3002
DCL (Data Control Language)\uff1a\u6570\u636e\u63a7\u5236\u8bed\u8a00\uff0c\u7528\u6765\u5206\u914d\u4e0e\u56de\u6536\u8d44\u6e90\uff0c\u521b\u5efa\u548c\u9610\u8ff0\u7528\u6237\u4e0e\u89d2\u8272\uff0c\u6388\u6743\u548c\u56de\u6536\u6743\u9650\u3002\u4f8b\u5982\uff0cCREATET ACCOUNT
\uff0cDROP ACCOUNT
\uff0c\u6216 GRANT
\u7b49\u3002
\u5176\u4ed6\uff1a\u5728 MatrixOne \u4e2d\uff0c\u5176\u4ed6\u7c7b\u578b\u7684\u7ba1\u7406\u8bed\u8a00\u662f\u6307\u4e0e\u6570\u636e\u6ca1\u6709\u76f4\u63a5\u5173\u8054\uff0c\u5bf9\u6570\u636e\u5e93\u53c2\u6570\u3001\u8d44\u6e90\u5206\u914d\u7684\u83b7\u53d6\u4e0e\u4fee\u6539\u7684\u603b\u79f0\u3002\u4f8b\u5982\uff0cSHOW
\uff0cSET variable
\uff0c\u6216 KILL
\u7b49\u3002
MatrixOne \u4e2d\u7684\u6570\u636e\u5e93\u662f\u8868\u7684\u96c6\u5408\u3002
SHOW DATABASES
\u8bed\u53e5\uff1aSHOW DATABASES;\n
CREATE DATABASE db_name [options];
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aCREATE DATABASE dbdemo;\n
\u6216\uff1a
CREATE DATABASE IF NOT EXISTS dbdemo;\n
\u6dfb\u52a0 IF NOT EXISTS
\u6761\u4ef6\u53ef\u4ee5\u9632\u6b62\u9519\u8bef\u3002
USE dbdemo;\n
SHOW TABLES
\u8bed\u53e5\u67e5\u770b\u6570\u636e\u5e93\u4e2d\u6240\u6709\u7684\u8868\uff0c\u4f8b\u5982\uff1aSHOW TABLES FROM dbdemo;\n
DROP DATABASE
\u8bed\u53e5\uff1aDROP DATABASE dbdemo;\n
"},{"location":"MatrixOne/Get-Started/basic-sql/#_2","title":"\u521b\u5efa\u3001\u67e5\u770b\u548c\u5220\u9664\u8868","text":"CREATE TABLE
\u8bed\u53e5\uff1aCREATE TABLE table_name column_name data_type constraint;\n
\u4f8b\u5982\uff0c\u8981\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a person \u7684\u8868\uff0c\u5305\u62ec\u7f16\u53f7\u3001\u540d\u5b57\u3001\u751f\u65e5\u7b49\u5b57\u6bb5\uff0c\u53ef\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a
CREATE TABLE person (\nid INT(11),\nname VARCHAR(255),\nbirthday DATE\n);\n
SHOW CREATE
\u8bed\u53e5\uff1aSHOW CREATE table person;\n
\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
+--------+-----------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n| person | CREATE TABLE `person` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`birthday` DATE DEFAULT NULL\n) |\n+--------+-----------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
DROP TABLE
\u8bed\u53e5\uff1aDROP TABLE person;\n
"},{"location":"MatrixOne/Get-Started/basic-sql/#_3","title":"\u589e\u52a0\u3001\u5220\u9664\u3001\u4fee\u6539\u8868\u8bb0\u5f55","text":"\u901a\u7528\u7684 DML \u5373\u589e\u5220\u6539\u8868\u8bb0\u5f55\uff0c\u57fa\u672c\u7684\u8bed\u53e5\u4e3a INSERT
\uff0cUPDATE
\u3001REPLACE
\u548c DELETE
\u3002
INSERT
\u8bed\u53e5\uff1aINSERT INTO person VALUES(1,'tom','20170912');\n
INSERT
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aINSERT INTO person(id,name) VALUES('2','bob');\n
UPDATE
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aUPDATE person SET birthday='20180808' WHERE id=2;\n
UPDATE
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aREPLACE INTO person SET birthday='20180809' WHERE id=2;\n
DELETE
\u8bed\u53e5\uff0c\u4f8b\u5982\uff1aDELETE FROM person WHERE id=2;\n
Note
UPDATE
\u548c DELETE
\u64cd\u4f5c\u5982\u679c\u4e0d\u5e26 WHERE
\u8fc7\u6ee4\u6761\u4ef6\u5219\u662f\u5bf9\u5168\u8868\u8fdb\u884c\u64cd\u4f5c\u3002
DQL \u7528\u4e8e\u4ece\u4e00\u4e2a\u8868\u6216\u591a\u4e2a\u8868\u68c0\u7d22\u6240\u9700\u7684\u6570\u636e\u884c\u3002
SELECT
\u8bed\u53e5\uff1aSELECT * FROM person;\n
\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
+------+------+------------+\n| id | name | birthday |\n+------+------+------------+\n| 1 | tom | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
SELECT
\u8bed\u53e5\u52a0\u4e0a\u8981\u67e5\u8be2\u7684\u5217\u540d\uff1aSELECT name FROM person;\n+------+\n| name |\n+------+\n| tom |\n+------+\n1 rows in set (0.00 sec)\n
\u4f7f\u7528 WHERE
\u5b50\u53e5\uff0c\u5bf9\u6240\u6709\u8bb0\u5f55\u8fdb\u884c\u662f\u5426\u7b26\u5408\u6761\u4ef6\u7684\u7b5b\u9009\u540e\u518d\u8fd4\u56de\u3002\u4f8b\u5982\uff1a
SELECT * FROM person where id<5;\n
\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
+------+------+------------+\n| id | name | birthday |\n+------+------+------------+\n| 1 | tom | 2017-09-12 |\n+------+------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Get-Started/basic-sql/#_5","title":"\u521b\u5efa\u3001\u6388\u6743\u548c\u5220\u9664\u7528\u6237","text":"\u5982\u679c\u4f60\u5b89\u88c5\u90e8\u7f72\u5355\u673a\u7248\u7684 MatrixOne\uff0c\u8fde\u63a5\u767b\u5f55 MatrixOne \u65f6\uff0c\u4f60\u672c\u8eab\u4fbf\u5177\u6709\u6700\u9ad8\u6743\u9650\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u5185\u5bb9\u521b\u5efa\u7528\u6237\u5e76\u6388\u6743\uff0c\u4ee5\u4fbf\u4f53\u9a8c MatrixOne \u96c6\u7fa4\u7684\u6743\u9650\u7ba1\u7406\u529f\u80fd\u3002
CREATE USER
\u8bed\u53e5\u521b\u5efa\u4e00\u4e2a\u7528\u6237 mouser\uff0c\u5bc6\u7801\u4e3a 111\uff1a> CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n
> CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n
> GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n
> GRANT create table on database * to role_r1;\nQuery OK, 0 rows affected (0.03 sec)\n
> SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account `mouser`@`localhost` |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n
\u4f60\u53ef\u4ee5\u770b\u5230\u4f60\u5df2\u7ecf\u6210\u529f\u628a\u5728 dbdemo \u6570\u636e\u5e93\u91cc\u5efa\u8868\u7684\u6743\u9650\u6388\u4e88\u7ed9\u4e86 mouser\u3002
DROP USER mouser;\n
\u6743\u9650\u7ba1\u7406\u662f\u6570\u636e\u5e93\u4e2d\u4f53\u7cfb\u5e9e\u5927\u4f46\u662f\u975e\u5e38\u6709\u7528\u7684\u529f\u80fd\uff0c\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u66f4\u591a\uff0c\u53c2\u89c1\u6743\u9650\u7ba1\u7406\u3002
"},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/","title":"\u5355\u673a\u90e8\u7f72 MatrixOne","text":"\u5355\u673a\u7248 MatrixOne \u9002\u7528\u573a\u666f\u5373\u662f\u4f7f\u7528\u5355\u53f0\u5f00\u53d1\u673a\u5668\u90e8\u7f72 MatrixOne\uff0c\u4f53\u9a8c MatrixOne \u7684\u57fa\u672c\u529f\u80fd\uff0c\u4e0e\u5355\u673a\u7248\u4f7f\u7528\u4e00\u4e2a MySQL \u57fa\u672c\u76f8\u540c\u3002
"},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#_1","title":"\u5b89\u88c5\u73af\u5883","text":""},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#_2","title":"\u63a8\u8350\u5b89\u88c5\u73af\u5883","text":"\u4f5c\u4e3a\u4e00\u6b3e\u5f00\u6e90\u6570\u636e\u5e93\uff0cMatrixOne \u76ee\u524d\u652f\u6301\u4e3b\u6d41\u7684 Linux \u548c MacOS \u7cfb\u7edf\u3002\u4e3a\u4e86\u5feb\u901f\u4e0a\u624b\uff0c\u672c\u6587\u6863\u4e2d\u4f18\u5148\u63a8\u8350\u5982\u4e0b\u786c\u4ef6\u89c4\u683c\uff1a
\u64cd\u4f5c\u7cfb\u7edf \u64cd\u4f5c\u7cfb\u7edf\u7248\u672c CPU \u5185\u5b58 Debian 11 \u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GB Ubuntu 20.04 \u53ca\u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GB CentOS 7 \u53ca\u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GB macOS Monterey 12.3 \u53ca\u4ee5\u4e0a x86 / ARM CPU\uff1b4 \u6838 16 GBNote
\u5982\u679c\u60a8\u5f53\u524d\u4f7f\u7528\u7684 Linux \u7cfb\u7edf\u5185\u6838\u7248\u672c\u8f83\u4f4e\uff08\u4f4e\u4e8e 5.0\uff09\uff0c\u7531\u4e8e linux \u5185\u6838\u7684\u9650\u5236\uff0c\u4f7f\u7528\u57fa\u4e8e glibc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u8fdb\u884c Matrixone \u7684\u90e8\u7f72\u65f6\u53ef\u80fd\u4f1a\u62a5\u4e0e glibc \u76f8\u5173\u7684\u9519\u8bef\uff0c\u8fd9\u65f6\u5019\u60a8\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u90e8\u7f72\u4e2d\u7684\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u8fdb\u884c\u90e8\u7f72\u3002musl libc \u662f\u4e00\u4e2a\u4e3a Linux \u7cfb\u7edf\u8bbe\u8ba1\u7684\u8f7b\u91cf\u7ea7 C \u6807\u51c6\u5e93\uff0c\u4f7f\u7528 musl libc \u6253\u5305\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u8ba9\u4f60\u751f\u6210\u4e0d\u4f9d\u8d56\u4e8e\u7cfb\u7edf C \u5e93\u7684\u9759\u6001\u4e8c\u8fdb\u5236\u6587\u4ef6\u3002\u6b64\u5916\uff0c\u7531\u4e8e CentOS 8 \u5df2\u7ecf\u505c\u6b62\u5b98\u65b9\u652f\u6301\uff0c\u4e14 CentOS 7 \u4e5f\u5c06\u5728 2024 \u5e74 6 \u6708 30 \u65e5\u7ed3\u675f\u7ef4\u62a4\u5468\u671f\uff0c\u76ee\u524d\u4f7f\u7528\u8fd9\u4e9b\u7248\u672c\u7684\u7528\u6237\u53ef\u80fd\u4f1a\u9762\u4e34\u4e00\u4e9b\u98ce\u9669\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5efa\u8bae\u7528\u6237\u4f7f\u7528\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u3002
\u4f60\u4e5f\u53ef\u4ee5\u67e5\u9605\u786c\u4ef6\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u8981\u6c42\uff0c\u67e5\u770b\u66f4\u591a\u5173\u4e8e\u786c\u4ef6\u89c4\u683c\u63a8\u8350\uff0c\u9009\u7528\u5408\u9002\u7684\u786c\u4ef6\u73af\u5883\u3002
"},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#_3","title":"\u652f\u6301\u56fd\u4ea7\u7cfb\u7edf","text":"\u4f5c\u4e3a\u4e00\u6b3e\u56fd\u4ea7\u6570\u636e\u5e93\uff0cMatrixOne \u76ee\u524d\u80fd\u591f\u4e0e\u4ee5\u4e0b\u56fd\u4ea7\u64cd\u4f5c\u7cfb\u7edf\u517c\u5bb9\u5e76\u63d0\u4f9b\u652f\u6301\uff1a
\u64cd\u4f5c\u7cfb\u7edf \u64cd\u4f5c\u7cfb\u7edf\u7248\u672c CPU \u5185\u5b58 OpenCloudOS v8.0 / v9.0 x86 CPU\uff1b4 \u6838 16 GB openEuler 20.03 x86 / ARM CPU\uff1b4 \u6838 16 GB TencentOS Server v2.4 / v3.1 x86 CPU\uff1b4 \u6838 16 GB \u7edf\u4fe1 V20 ARM CPU\uff1b4 \u6838 16 GB \u94f6\u6cb3\u9e92\u9e9f V10 ARM CPU\uff1b4 \u6838 16 GB \u9e92\u9e9f\u4fe1\u5b89 v3.0 x86 / ARM CPU\uff1b4 \u6838 16 GBNOTE: \u652f\u6301\u7684\u56fd\u4ea7 CPU \u6709\u817e\u4e91 S2500\u3001FT2000+/64\u3001\u9cb2\u9e4f 916\u3001\u9cb2\u9e4f 920 \u548c\u6d77\u5149 H620-G30
"},{"location":"MatrixOne/Get-Started/install-standalone-matrixone/#macos","title":"\u5728 macOS \u4e0a\u90e8\u7f72","text":"\u4f60\u53ef\u4ee5\u5728\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\u4e2d\u9009\u62e9\u6700\u9002\u5408\u4f60\u7684\u4e00\u79cd\uff0c\u5728 macOS \u4e0a\u5b89\u88c5\u5e76\u8fde\u63a5 MatrixOne\uff1a
\u4f60\u53ef\u4ee5\u5728\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\u4e2d\u9009\u62e9\u6700\u9002\u5408\u4f60\u7684\u4e00\u79cd\uff0c\u5728 Linux \u4e0a\u5b89\u88c5\u5e76\u8fde\u63a5 MatrixOne\uff1a
\u66f4\u591a\u6709\u5173\u8fde\u63a5 MatrixOne \u7684\u65b9\u5f0f\uff0c\u53c2\u89c1\uff1a
\u5e38\u89c1\u7684\u5b89\u88c5\u548c\u90e8\u7f72\u95ee\u9898\uff0c\u53c2\u89c1\u5b89\u88c5\u548c\u90e8\u7f72\u5e38\u89c1\u95ee\u9898\u3002
\u5173\u4e8e\u5206\u5e03\u5f0f\u90e8\u7f72 MatrixOne\uff0c\u53c2\u89c1 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u6e90\u4ee3\u7801\u5728 Linux \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002\u6211\u4eec\u5c06\u91c7\u7528 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u7684 Linux \u7cfb\u7edf\u3002\u672c\u6587\u4ee5 Debian11.1 x86 \u67b6\u6784\u4e3a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5b8c\u6210\u5168\u6d41\u7a0b\u3002\u5982\u679c\u4f7f\u7528 Ubuntu \u7cfb\u7edf\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u9ed8\u8ba4\u6ca1\u6709 root \u6743\u9650\uff0c\u5efa\u8bae\u5168\u6d41\u7a0b\u547d\u4ee4\u90fd\u52a0 sudo
\u8fdb\u884c\u3002
\u901a\u8fc7\u6e90\u7801\u5b89\u88c5\u53ca\u4f7f\u7528\u5355\u673a\u7248 MatrixOne\uff0c\u9700\u8981\u4f9d\u8d56\u4e8e\u4ee5\u4e0b\u4e00\u4e9b\u8f6f\u4ef6\u5305\u3002
\u4f9d\u8d56\u8f6f\u4ef6 \u7248\u672c golang 1.22.3 \u53ca\u4ee5\u4e0a gcc gcc8.5 \u53ca\u4ee5\u4e0a git 2.20 \u53ca\u4ee5\u4e0a MySQL Client 8.0 \u53ca\u4ee5\u4e0a"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1","title":"\u6b65\u9aa4 1: \u5b89\u88c5\u4f9d\u8d56","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-go","title":"1. \u5b89\u88c5\u90e8\u7f72 Go \u8bed\u8a00","text":"\u70b9\u51fb Go Download and install \u5165\u5230 Go \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 Go \u8bed\u8a00\u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 Go \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 go version
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff1a
go version go1.22.3 linux/amd64\n
Debian11.1 \u4e2d\u4e00\u822c\u5df2\u7ecf\u81ea\u5e26 9.0 \u4ee5\u4e0a\u7248\u672c\u7684 GCC\uff0c\u53ef\u4ee5\u5148\u7528\u4ee5\u4e0b\u547d\u4ee4\u9a8c\u8bc1 GCC \u73af\u5883\u662f\u5426\u9700\u8981\u5b89\u88c5\u3002
gcc -v\nbash: gcc: command not found\n
\u5982\u4ee3\u7801\u6240\u793a\uff0c\u672a\u663e\u793a GCC \u7684\u7248\u672c\uff0c\u5219\u8868\u793a GCC \u7684\u73af\u5883\u9700\u8981\u5b89\u88c5\u3002
\u70b9\u51fb GCC Download and install \u5165\u5230 GCC \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 GCC \u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 GCC \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 gcc -v
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff08\u53ea\u5c55\u793a\u90e8\u5206\u4ee3\u7801\uff09\uff1a
Using built-in specs.\nCOLLECT_GCC=gcc\n...\nThread model: posix\ngcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC)\n
\u68c0\u67e5 Git \u662f\u5426\u5df2\u652f\u6301\u3002\u5982\u4ee3\u7801\u6240\u793a\uff0c\u672a\u663e\u793a git \u7684\u7248\u672c\uff0c\u5219\u8868\u793a git \u9700\u8981\u5b89\u88c5\u3002
git version\n-bash: git: command not found\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Git\u3002
sudo apt install git\n
\u9a8c\u8bc1 Git \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 git version
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff1a
git version\ngit version 2.40.0\n
Debian11.1 \u7248\u672c\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5 MySQL Client\uff0c\u56e0\u6b64\u9700\u8981\u624b\u52a8\u4e0b\u8f7d\u5b89\u88c5\u3002
\u5b89\u88c5 MySQL Client \u9700\u8981\u7528\u5230 wget
\u4e0b\u8f7d\u5de5\u5177\uff0cwget
\u662f\u7528\u6765\u4ece\u6307\u5b9a\u7684 URL \u4e0b\u8f7d\u6587\u4ef6\u3002\u4f9d\u6b21\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5b89\u88c5 wget
\uff1a
## \u66f4\u65b0\u8f6f\u4ef6\u6e90\u5217\u8868\u7f13\u5b58\nsudo apt update\n## \u5b89\u88c5 wget\nsudo apt install wget\n
\u5b89\u88c5\u5b8c\u6210\u540e\u8bf7\u8f93\u5165\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u9a8c\u8bc1\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c\uff08\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801\uff09\u5982\u4e0b\uff1a
GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n
\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 MySQL Client\uff1a
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
\u6267\u884c\u547d\u4ee4 mysql --version
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff0c\u5b89\u88c5\u6210\u529f\u7ed3\u679c\u5982\u4e0b\uff1a
mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
Note
\u6570\u636e\u5e93\u7cfb\u7edf\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff08\u5982 TPC-H 100G \u6d4b\u8bd5\uff09\uff0c\u4f1a\u4f7f\u7528\u5185\u5b58\u6620\u5c04\u6587\u4ef6\u6765\u63d0\u9ad8 I/O \u6027\u80fd\u3002Linux \u7cfb\u7edf\u53c2\u6570 vm.max_map_count \u5b9a\u4e49\u4e86\u8fdb\u7a0b\u53ef\u4ee5\u62e5\u6709\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u6570\u91cf\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u8bbe\u7f6e\u5f97\u592a\u4f4e\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u53ef\u80fd\u65e0\u6cd5\u521b\u5efa\u8db3\u591f\u7684\u5185\u5b58\u6620\u5c04\u533a\u57df\u6765\u5904\u7406\u5176\u65e5\u5e38\u64cd\u4f5c\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u5e93\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5982\u5185\u5b58\u4e0d\u8db3 (OOM) \u548c\u8fdb\u7a0b\u5d29\u6e83\u3002\u4e3a\u4e86\u63d0\u9ad8 Matrixone \u5728 Linux \u4e2d\u8fd0\u884c\u7684\u7a33\u5b9a\u6027\uff0c\u5efa\u8bae\u5c06 vm.max_map_count \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u8f83\u9ad8\u7684\u503c\uff0c\u63a8\u8350\u503c\u4e3a 262144\uff0c\u8fd9\u4e2a\u503c\u9002\u7528\u4e8e\u5927\u591a\u6570\u9700\u8981\u5927\u91cf\u5185\u5b58\u6620\u5c04\u7684\u573a\u666f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 sysctl -w vm.max_map_count = 262144
\u4f7f\u5176\u4e34\u65f6\u751f\u6548\uff0c\u6216\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 /etc/sysctl.conf
\u4f7f\u5176\u6c38\u4e45\u751f\u6548\u3002
mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#1-mo_ctl","title":"1. \u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\uff1a
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n
\u5b89\u88c5\u5b8c\u6210\u4ee5\u540e\uff0c\u901a\u8fc7 mo_ctl
\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a
> mo_ctl\n Usage : mo_ctl [option_1] [option_2]\n\n [option_1] : available: auto_backup | auto_clean_logs | backup | clean_backup | clean_logs | connect | csv_convert | ddl_convert | deploy | get_branch | get_cid | get_conf | help | monitor | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | version | watchdog\n auto_backup : setup a crontab task to backup your databases automatically\n auto_clean_logs : set up a crontab task to clean system log table data automatically\n backup : create a backup of your databases manually\n build_image : build an MO image from source code\n clean_backup : clean old backups older than conf 31 days manually\n clean_logs : clean system log table data manually\n connect : connect to mo via mysql client using connection info configured\n csv_convert : convert a csv file to a sql file in format \"insert into values\" or \"load data inline format='csv'\"\n ddl_convert : convert a ddl file to mo format from other types of database\n deploy : deploy mo onto the path configured\n get_branch : upgrade or downgrade mo from current version to a target commit id or stable version\n get_cid : print mo git commit id from the path configured\n get_conf : get configurations\n help : print help information\n monitor : monitor system related operations\n pprof : collect pprof information\n precheck : check pre-requisites for mo_ctl\n restart : a combination operation of stop and start\n set_conf : set configurations\n sql : execute sql from string, or a file or a path containg multiple files\n start : start mo-service from the path configured\n status : check if there's any mo process running on this machine\n stop : stop all mo-service processes found on this machine\n uninstall : uninstall mo from path MO_PATH=/Users/admin/mo//matrixone\n upgrade : upgrade or downgrade mo from current version to a target commit id or stable version\n version : show mo_ctl and matrixone version\n watchdog : setup a watchdog crontab task for mo-service to keep it alive\n e.g. : mo_ctl status\n\n [option_2] : Use \" mo_ctl [option_1] help \" to get more info\n e.g. : mo_ctl deploy help\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#2-mo_ctl_1","title":"2. \u8bbe\u7f6e mo_ctl \u7684\u914d\u7f6e\u53c2\u6570","text":"mo_ctl \u5de5\u5177\u4e2d\u6709\u90e8\u5206\u53c2\u6570\u53ef\u80fd\u9700\u8981\u4f60\u8fdb\u884c\u8c03\u6574\u8bbe\u7f6e\uff0c\u901a\u8fc7 mo_ctl get_conf
\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u5f53\u524d\u53c2\u6570\u3002
root@VM-16-2-debian:~# mo_ctl get_conf\n2023-08-23 18:23:35.444 UTC+0800 [INFO] Below are all configurations set in conf file /root/mo_ctl/conf/env.sh\nMO_PATH=\"/data/mo/\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.22.3\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"v1.2.1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n
\u4e00\u822c\u53ef\u80fd\u4f1a\u9700\u8981\u8c03\u6574\u7684\u53c2\u6570\u5982\u4e0b\uff1a
mo_ctl set_conf MO_PATH=\"yourpath\" # \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u7684MatrixOne\u4e0b\u8f7d\u8def\u5f84\nmo_ctl set_conf MO_GIT_URL=\"https://githubfast.com/matrixorigin/matrixone.git\" #\u9488\u5bf9github\u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\u95ee\u9898\uff0c\u8bbe\u7f6e\u955c\u50cf\u4e0b\u8f7d\u5730\u5740\nmo_ctl set_conf MO_DEFAULT_VERSION=\"v1.2.1\" # \u8bbe\u7f6e\u6240\u4e0b\u8f7d\u7684MatrixOne\u7248\u672c\nmo_ctl set_conf MO_DEPLOY_MODE=git #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u6e90\u7801\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u4e00\u952e\u5b89\u88c5 MatrixOne","text":"\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/matrixone/logs/
\u4e2d\u3002
root@VM-16-2-debian:~# mo_ctl start\n2023-07-07_09:55:01 [INFO] No mo-service is running\n2023-07-07_09:55:01 [INFO] Starting mo-service: cd /data/mo/matrixone/matrixone/ && /data/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo/matrixone/matrixone/etc/launch/launch.toml >/data/mo/matrixone/logs/stdout-20230707_095501.log 2>/data/mo/matrixone/logs/stderr-20230707_095501.log\n2023-07-07_09:55:01 [INFO] Wait for 2 seconds\n2023-07-07_09:55:03 [INFO] At least one mo-service is running. Process info:\n2023-07-07_09:55:03 [INFO] root 748128 1 2 09:55 ? 00:00:00 /data/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /data/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_09:55:03 [INFO] Pids:\n2023-07-07_09:55:03 [INFO] 748128\n2023-07-07_09:55:03 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method1/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
root@VM-16-2-debian:~# mo_ctl connect\n2023-07-07_10:30:20 [INFO] Checking connectivity\n2023-07-07_10:30:20 [INFO] Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u5728 Linux \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\uff0c\u8fd9\u79cd\u5b89\u88c5\u65b9\u6848\u65e0\u9700\u5b89\u88c5\u524d\u7f6e\u4f9d\u8d56\u548c\u7f16\u8bd1\u6e90\u7801\u5305\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u7684 Linux \u7cfb\u7edf\u3002\u672c\u6587\u4ee5 Debian11.1 x86 \u67b6\u6784\u4e3a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u5b8c\u6210\u5168\u6d41\u7a0b\u3002\u5982\u679c\u4f7f\u7528 Ubuntu \u7cfb\u7edf\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u9ed8\u8ba4\u6ca1\u6709 root \u6743\u9650\uff0c\u5efa\u8bae\u5168\u6d41\u7a0b\u547d\u4ee4\u90fd\u52a0 sudo
\u8fdb\u884c\u3002
\u901a\u8fc7\u4e8c\u8fdb\u5236\u5305\u90e8\u7f72\u548c\u5b89\u88c5 MatrixOne\uff0c\u4ec5\u9700\u5b89\u88c5 MySQL Client
\u5de5\u5177\u3002
Tips: \u5efa\u8bae\u4f60\u4e0b\u8f7d\u5b89\u88c5\u8fd9\u4e24\u4e2a\u4e0b\u8f7d\u5de5\u5177\u5176\u4e2d\u4e4b\u4e00\uff0c\u65b9\u4fbf\u540e\u7eed\u901a\u8fc7\u547d\u4ee4\u884c\u4e0b\u8f7d MySQL Client
\u548c\u4e8c\u8fdb\u5236\u5305\u3002
wget
\u5b89\u88c5 curl
wget
\u5de5\u5177\u7528\u6765\u4ece\u6307\u5b9a\u7684 URL \u4e0b\u8f7d\u6587\u4ef6\u3002wget
\u662f\u4e13\u95e8\u7684\u6587\u4ef6\u4e0b\u8f7d\u5de5\u5177\uff0c\u5b83\u975e\u5e38\u7a33\u5b9a\uff0c\u800c\u4e14\u4e0b\u8f7d\u901f\u5ea6\u5feb\u3002\u4f9d\u6b21\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5b89\u88c5 wget
\uff1a
## \u66f4\u65b0\u8f6f\u4ef6\u6e90\u5217\u8868\u7f13\u5b58\nsudo apt udpate\n## \u5b89\u88c5 wget\nsudo apt install wget\n
\u5b89\u88c5\u5b8c\u6210\u540e\u8bf7\u8f93\u5165\u4e0b\u9762\u7684\u547d\u4ee4\u8fdb\u884c\u9a8c\u8bc1\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
GNU Wget 1.21.3 built on linux-gnu.\n...\nCopyright (C) 2015 Free Software Foundation, Inc.\n...\n
curl
\u662f\u4e00\u4e2a\u5229\u7528 URL \u89c4\u5219\u5728\u547d\u4ee4\u884c\u4e0b\u5de5\u4f5c\u7684\u6587\u4ef6\u4f20\u8f93\u5de5\u5177\u3002curl
\u662f\u7efc\u5408\u4f20\u8f93\u5de5\u5177\uff0c\u652f\u6301\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d\u3002
\u8fdb\u5165\u5230Curl\u5b98\u7f51\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5 curl
\u3002 \u9a8c\u8bc1 curl
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
curl --version\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
curl 7.84.0 (x86_64-pc-linux-gnu) libcurl/7.84.0 OpenSSL/1.1.1k-fips zlib/1.2.11\nRelease-Date: 2022-06-27\n...\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-mysql-client","title":"2. \u5b89\u88c5 MySQL Client","text":"\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
\u6267\u884c\u547d\u4ee4 mysql --version
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff0c\u5b89\u88c5\u6210\u529f\u7ed3\u679c\u5982\u4e0b\uff1a
mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
Note
\u6570\u636e\u5e93\u7cfb\u7edf\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff08\u5982 TPC-H 100G \u6d4b\u8bd5\uff09\uff0c\u4f1a\u4f7f\u7528\u5185\u5b58\u6620\u5c04\u6587\u4ef6\u6765\u63d0\u9ad8 I/O \u6027\u80fd\u3002Linux \u7cfb\u7edf\u53c2\u6570 vm.max_map_count \u5b9a\u4e49\u4e86\u8fdb\u7a0b\u53ef\u4ee5\u62e5\u6709\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u6570\u91cf\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u8bbe\u7f6e\u5f97\u592a\u4f4e\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u53ef\u80fd\u65e0\u6cd5\u521b\u5efa\u8db3\u591f\u7684\u5185\u5b58\u6620\u5c04\u533a\u57df\u6765\u5904\u7406\u5176\u65e5\u5e38\u64cd\u4f5c\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u5e93\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5982\u5185\u5b58\u4e0d\u8db3 (OOM) \u548c\u8fdb\u7a0b\u5d29\u6e83\u3002\u4e3a\u4e86\u63d0\u9ad8 Matrixone \u5728 Linux \u4e2d\u8fd0\u884c\u7684\u7a33\u5b9a\u6027\uff0c\u5efa\u8bae\u5c06 vm.max_map_count \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u8f83\u9ad8\u7684\u503c\uff0c\u63a8\u8350\u503c\u4e3a 262144\uff0c\u8fd9\u4e2a\u503c\u9002\u7528\u4e8e\u5927\u591a\u6570\u9700\u8981\u5927\u91cf\u5185\u5b58\u6620\u5c04\u7684\u573a\u666f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 sysctl -w vm.max_map_count = 262144
\u4f7f\u5176\u4e34\u65f6\u751f\u6548\uff0c\u6216\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 /etc/sysctl.conf
\u4f7f\u5176\u6c38\u4e45\u751f\u6548\u3002
\u6211\u4eec\u63d0\u4f9b\u4e86\u4e24\u7c7b\u4e8c\u8fdb\u5236\u5305\uff1a\u4e00\u7c7b\u662f\u4f9d\u6258 glibc \u6784\u5efa\u7684\uff0c\u53e6\u4e00\u7c7b\u662f\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u3002\u5bf9\u4e8e\u4f7f\u7528\u8f83\u65e7\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u57fa\u4e8e musl libc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305\u6765\u8fdb\u884c\u90e8\u7f72\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u89e3\u91ca\u4e24\u79cd\u5b89\u88c5\u5305\u7684\u4e0b\u8f7d\u6d41\u7a0b\uff1a
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#glibc","title":"\u57fa\u4e8e glibc \u6784\u5efa\u7684\u4e8c\u8fdb\u5236\u5305","text":"\u4e0b\u8f7d\u65b9\u5f0f\u4e00\uff1awget
\u5de5\u5177\u4e0b\u8f7d\u5b89\u88c5\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e09\uff1a\u9875\u9762\u4e0b\u8f7d x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-x86_64.zip\nunzip mo-v1.2.1-linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-arm64.zip\nunzip mo-v1.2.1-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-x86_64.zip\nunzip mo-v1.2.--linux-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-arm64.zip\nunzip mo-v1.2.1-linux-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-linux-xxx.zip\n
\u5982\u679c\u4f60\u60f3\u901a\u8fc7\u66f4\u76f4\u89c2\u7684\u9875\u9762\u4e0b\u8f7d\u7684\u65b9\u5f0f\u4e0b\u8f7d\uff0c\u76f4\u63a5\u70b9\u51fb\u8fdb\u5165\u7248\u672c 1.2.1\uff0c\u4e0b\u62c9\u627e\u5230 Assets \u680f\uff0c\u70b9\u51fb\u5b89\u88c5\u5305 mo-v1.2.1-linux-x86_64.zip \u6216\u8005 mo-v1.2.1-linux-arm64.zip \u4e0b\u8f7d\u518d\u4f7f\u7528 unzip
\u547d\u4ee4\u89e3\u538b\u5373\u53ef\u3002
wget
\u5de5\u5177\u4e0b\u8f7d\u5b89\u88c5\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e09\uff1a\u9875\u9762\u4e0b\u8f7d x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-x86_64.zip\nunzip mo-v1.2.1-musl-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-arm64.zip\nunzip mo-v1.2.1-musl-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-x86_64.zip\nunzip mo-v1.2.1-musl-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-arm64.zip\nunzip mo-v1.2.1-musl-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-musl-xxx.zip\n
\u5982\u679c\u4f60\u60f3\u901a\u8fc7\u66f4\u76f4\u89c2\u7684\u9875\u9762\u4e0b\u8f7d\u7684\u65b9\u5f0f\u4e0b\u8f7d\uff0c\u76f4\u63a5\u70b9\u51fb\u8fdb\u5165\u7248\u672c 1.2.1\uff0c\u4e0b\u62c9\u627e\u5230 Assets \u680f\uff0c\u70b9\u51fb\u5b89\u88c5\u5305 mo-v1.2.1-musl-x86_64.zip \u6216\u8005 mo-v1.2.1-musl-arm64.zip \u4e0b\u8f7d\u518d\u4f7f\u7528 unzip
\u547d\u4ee4\u89e3\u538b\u5373\u53ef\u3002
mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#1-mo_ctl","title":"1. \u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && bash +x ./install.sh\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#2-mo_ctl","title":"2. \u8bbe\u7f6e mo_ctl \u7684\u914d\u7f6e\u53c2\u6570","text":"\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_PATH=\"/yourpath/mo-v1.2.1-xx-xx\" #\u8bbe\u7f6eMatrixOne\u8def\u5f84\u4e3a\u4e8c\u8fdb\u5236\u89e3\u538b\u6587\u4ef6\u76ee\u5f55\nmo_ctl set_conf MO_CONF_FILE=\"/yourpath/mo-v1.2.1-xx-xx/etc/launch/launch.toml\" #\u8bbe\u7f6eMatrixOne\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\nmo_ctl set_conf MO_DEPLOY_MODE=binary #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u4e8c\u8fdb\u5236\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/mo-v1.2.1-xx-xx/matrixone/logs/
\u4e2d\u3002
> mo_ctl start\n2024-03-07 14:34:04.942 UTC+0800 [INFO] No mo-service is running\n2024-03-07 14:34:04.998 UTC+0800 [INFO] Get conf succeeded: MO_DEPLOY_MODE=\"binary\"\n2024-03-07 14:34:05.024 UTC+0800 [INFO] GO memory limit(Mi): 14745\n2024-03-07 14:34:05.072 UTC+0800 [INFO] Starting mo-service: cd /Users/admin/mo-v1.2.1-linux-arm64/ && GOMEMLIMIT=14745MiB /Users/admin/mo-v1.2.1-linux-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-linux-arm64/etc/launch/launch.toml >/Users/admin/mo-v1.2.1-linux-arm64/matrixone/logs/stdout-20240307_143405.log 2>/Users/admin/mo-v1.2.1-linux-arm64/matrixone/logs/stderr-20240307_143405.log\n2024-03-07 14:34:05.137 UTC+0800 [INFO] Wait for 2 seconds\n2024-03-07 14:34:07.261 UTC+0800 [INFO] At least one mo-service is running. Process info: \n 501 27145 1 0 2:34\u4e0b\u5348 ?? 0:00.18 /Users/admin/mo-v1.2.1-linux-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-linux-arm64/etc/launch/launch.toml\n2024-03-07 14:34:07.284 UTC+0800 [INFO] List of pid(s): \n27145\n2024-03-07 14:34:07.308 UTC+0800 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method2/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
> mo_ctl connect\n2024-03-07 14:34:59.902 UTC+0800 [INFO] Checking connectivity\n2024-03-07 14:34:59.942 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 426\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 Docker \u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#1","title":"\u6b65\u9aa4 1\uff1a\u524d\u7f6e\u6761\u4ef6","text":""},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#docker_1","title":"\u5b89\u88c5 docker","text":"\u70b9\u51fb Get Docker\uff0c\u8fdb\u5165 Docker \u7684\u5b98\u65b9\u6587\u6863\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4e0b\u8f7d\u5b89\u88c5\u5bf9\u5e94\u7684 Docker\uff0cDocker \u7248\u672c\u63a8\u8350\u9009\u62e9\u5728 20.10.18 \u53ca\u4ee5\u4e0a\uff0c\u4e14\u5c3d\u91cf\u4fdd\u6301 Docker client \u548c Docker server \u7684\u7248\u672c\u4e00\u81f4\u3002
\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4e0b\u8ff0\u4ee3\u7801\u884c\u786e\u8ba4 Docker \u7248\u672c\uff0c\u9a8c\u8bc1 Docker \u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a
docker --version\n
\u5b89\u88c5\u6210\u529f\uff0c\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
Docker version 20.10.18, build 100c701\n
\u5728\u4f60\u7ec8\u7aef\u91cc\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8 Docker \u5e76\u67e5\u770b\u8fd0\u884c\u72b6\u6001\u662f\u5426\u6210\u529f\uff1a
systemctl start docker\nsystemctl status docker\n
\u8868\u793a Docker \u6b63\u5728\u8fd0\u884c\u7684\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff0c\u51fa\u73b0 Active: active (running)
\u5373\u8868\u793a Docker \u5df2\u7ecf\u5728\u8fd0\u884c\u4e2d\u3002
docker.service - Docker Application Container Engine\n Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)\n Active: active (running) since Sat 2022-11-26 17:48:32 CST; 6s ago\n Docs: https://docs.docker.com\n Main PID: 234496 (dockerd)\n Tasks: 8\n Memory: 23.6M\n
Debian11.1 \u7248\u672c\u9ed8\u8ba4\u6ca1\u6709\u5b89\u88c5 MySQL Client\uff0c\u56e0\u6b64\u9700\u8981\u624b\u52a8\u4e0b\u8f7d\u5b89\u88c5\u3002
\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb\nsudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb\nsudo apt update\nsudo apt install mysql-client\n
\u6267\u884c\u547d\u4ee4 mysql --version
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff0c\u5b89\u88c5\u6210\u529f\u7ed3\u679c\u5982\u4e0b\uff1a
mysql --version\nmysql Ver 8.0.33 for Linux on x86_64 (MySQL Community Server - GPL)\n
Note
\u6570\u636e\u5e93\u7cfb\u7edf\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff08\u5982 TPC-H 100G \u6d4b\u8bd5\uff09\uff0c\u4f1a\u4f7f\u7528\u5185\u5b58\u6620\u5c04\u6587\u4ef6\u6765\u63d0\u9ad8 I/O \u6027\u80fd\u3002Linux \u7cfb\u7edf\u53c2\u6570 vm.max_map_count \u5b9a\u4e49\u4e86\u8fdb\u7a0b\u53ef\u4ee5\u62e5\u6709\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u6570\u91cf\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u8bbe\u7f6e\u5f97\u592a\u4f4e\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u53ef\u80fd\u65e0\u6cd5\u521b\u5efa\u8db3\u591f\u7684\u5185\u5b58\u6620\u5c04\u533a\u57df\u6765\u5904\u7406\u5176\u65e5\u5e38\u64cd\u4f5c\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u6570\u636e\u5e93\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\uff0c\u5982\u5185\u5b58\u4e0d\u8db3 (OOM) \u548c\u8fdb\u7a0b\u5d29\u6e83\u3002\u4e3a\u4e86\u63d0\u9ad8 Matrixone \u5728 Linux \u4e2d\u8fd0\u884c\u7684\u7a33\u5b9a\u6027\uff0c\u5efa\u8bae\u5c06 vm.max_map_count \u8bbe\u7f6e\u4e3a\u4e00\u4e2a\u8f83\u9ad8\u7684\u503c\uff0c\u63a8\u8350\u503c\u4e3a 262144\uff0c\u8fd9\u4e2a\u503c\u9002\u7528\u4e8e\u5927\u591a\u6570\u9700\u8981\u5927\u91cf\u5185\u5b58\u6620\u5c04\u7684\u573a\u666f\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 sysctl -w vm.max_map_count = 262144
\u4f7f\u5176\u4e34\u65f6\u751f\u6548\uff0c\u6216\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 /etc/sysctl.conf
\u4f7f\u5176\u6c38\u4e45\u751f\u6548\u3002
\u6b64\u8282\u4ecb\u7ecd\u4f7f\u7528 docker \u76f4\u63a5\u62c9\u53d6 MatrixOne \u955c\u50cf\u548c\u4f7f\u7528 mo_ctl \u5de5\u5177\u4e24\u79cd\u90e8\u7f72\u65b9\u5f0f
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#docker_2","title":"docker \u90e8\u7f72","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u4ece Docker Hub \u4e2d\u62c9\u53d6 MatrixOne \u955c\u50cf\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff0c\u6216\u5f00\u53d1\u7248\u672c\u955c\u50cf\uff0c\u5f53 Tag \u4e3a latest
\u65f6\u83b7\u53d6\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002
docker pull matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.2.1\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\n
\u83b7\u53d6\u6700\u65b0\u5f00\u53d1\u7248\u672c\u7684\u955c\u50cf\uff0c\u53c2\u89c1Docker Hub\uff0c\u627e\u5230\u6700\u65b0Tag\uff0c\u62c9\u53d6\u955c\u50cf\u3002\u62c9\u53d6\u955c\u50cf\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u5f00\u53d1\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n
Note: \u5982\u4e0a\u9762\u4ee3\u7801\u6240\u793a\uff0cnightly \u4e3a\u6807\u8bc6\u7684 Tag \u7248\u672c\u6bcf\u5929\u90fd\u8fdb\u884c\u66f4\u65b0\uff0c\u8bf7\u6ce8\u610f\u83b7\u53d6\u6700\u65b0\u7684\u955c\u50cf\u3002
\u82e5 Docker \u7248\u672c\u4f4e\u4e8e 20.10.18 \u6216\u8005 Docker client \u548c Docker server \u7684\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u63a8\u8350\u540c\u65f6\u5347\u7ea7\u5230 Docker \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u540e\u518d\u5c1d\u8bd5\u3002\u82e5\u575a\u6301\u4f7f\u7528\uff0c\u9700\u8981\u5728 docker run
\u547d\u4ee4\u4e2d\u52a0\u4e0a\u53c2\u6570 --privileged=true
\uff0c\u5982\uff1a
docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.2.1\n
\u5982\u9700\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u6216\u914d\u7f6e\u81ea\u5b9a\u4e49\u6587\u4ef6\uff0c\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#mo_ctl","title":"mo_ctl \u90e8\u7f72","text":"mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_CONTAINER_DATA_HOST_PATH=\"/yourpath/mo/\" # \u5bbf\u4e3b\u673amo\u7684\u6570\u636e\u76ee\u5f55\nmo_ctl set_conf MO_CONTAINER_IMAGE=\"matrixorigin/matrixone:1.2.1\" # \u8bbe\u7f6e\u955c\u50cf\uff0c\u56fd\u5185\u7684\u53ef\u4ee5\u7528registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1 \nmo_ctl set_conf MO_DEPLOY_MODE=docker #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3adocker\u90e8\u7f72\u65b9\u5f0f\n
\u4ee5\u4e0b\u4e3a\u53ef\u9009\u53c2\u6570\uff1a
MO_CONTAINER_NAME=\"mo\" # mo \u5bb9\u5668\u540d\nMO_CONTAINER_PORT=\"6001\" # mo \u7aef\u53e3\u53f7\nMO_CONTAINER_DEBUG_PORT=\"12345\" #\u5bb9\u5668\u5185 debug \u7aef\u53e3\nMO_CONTAINER_CONF_HOST_PATH=\"\" # \u5bbf\u4e3b\u673a mo \u7684\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff0c\u9700\u8981\u53c2\u8003\nMO_CONTAINER_CONF_CON_FILE=\"/etc/quickstart/launch.toml\" # \u5bb9\u5668\u5185\u914d\u7f6e\u6587\u4ef6\nMO_CONTAINER_LIMIT_MEMORY=\"\" # \u5185\u5b58\u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1am\nMO_CONTAINER_MEMORY_RATIO=90 # \u5982\u679c\u4e0d\u8bbe\u7f6e\u5185\u5b58\u5927\u5c0f\uff0c\u5c31\u4f1a\u6839\u636e\u8fd9\u4e2a\u503c\u6765\u8bbe\u7f6e\u4e3b\u673a\u7684 x% \u5185\u5b58\uff0c\u9ed8\u8ba4 90%\nMO_CONTAINER_AUTO_RESTART=\"yes\" # \u662f\u5426\u8bbe\u7f6e\u5bb9\u5668\u81ea\u52a8\u91cd\u542f\nMO_CONTAINER_LIMIT_CPU=\"\" # cpu \u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1a\u6838\u6570\nMO_CONTAINER_EXTRA_MOUNT_OPTION=\"\" #\u989d\u5916\u7684\u6302\u8f7d\u53c2\u6570\uff0c\u6bd4\u5982 -v xx:xx:xx\n
\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
mo_ctl start\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u8fde\u63a5 MatrixOne","text":"\u9664\u4e86\u53ef\u4ee5\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u6765\u8fde\u63a5 MatrixOne\uff0c\u5728\u5df2\u90e8\u7f72 mo_ctl \u5de5\u5177\u7684\u60c5\u51b5\u4e0b\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 mo_ctl \u5de5\u5177\u6765\u8fde\u63a5 MatrixOne\u3002\u6b64\u8282\u4ecb\u7ecd\u4e24\u79cd\u8fde\u63a5\u65b9\u5f0f\u7684\u5177\u4f53\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#mysql","title":"MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u8fde\u63a5","text":"mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: # \u521d\u59cb\u5bc6\u7801\u9ed8\u8ba4\u4e3a 111\n
\u8fde\u63a5\u6210\u529f\u5c06\u8fd4\u56de\u4ee5\u4e0b\u4fe1\u606f\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5982\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
\u76ee\u524d\uff0cMatrixOne \u53ea\u652f\u6301 TCP \u76d1\u542c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-linux/install-on-linux-method3/#mo_ctl_1","title":"mo_ctl \u5de5\u5177\u8fde\u63a5","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
mo_ctl connect\n2024-03-08 11:13:34.347 UTC+0800 [INFO] Checking connectivity\n2024-03-08 11:13:34.420 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5849\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u6e90\u4ee3\u7801\u5728 macOS \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002\u6211\u4eec\u5c06\u91c7\u7528 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u7684 macOS \u7cfb\u7edf\uff0c\u672c\u6587\u4ee5 Macbook M1 ARM \u7248\u672c\u4e3a\u4f8b\u5b50\u5c55\u793a\u6574\u4e2a\u90e8\u7f72\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#_1","title":"\u524d\u7f6e\u4f9d\u8d56\u53c2\u8003","text":"\u901a\u8fc7\u6e90\u7801\u5b89\u88c5\u53ca\u4f7f\u7528\u5355\u673a\u7248 MatrixOne\uff0c\u9700\u8981\u4f9d\u8d56\u4e8e\u4ee5\u4e0b\u4e00\u4e9b\u8f6f\u4ef6\u5305\u3002
\u4f9d\u8d56\u8f6f\u4ef6 \u7248\u672c golang 1.22.3 \u53ca\u4ee5\u4e0a gcc/clang gcc8.5 \u53ca\u4ee5\u4e0a\uff0cclang13.0 \u53ca\u4ee5\u4e0a git 2.20 \u53ca\u4ee5\u4e0a MySQL Client 8.0 \u53ca\u4ee5\u4e0a"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#1","title":"\u6b65\u9aa4 1\uff1a\u5b89\u88c5\u4f9d\u8d56","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#1-go","title":"1. \u5b89\u88c5\u90e8\u7f72 Go \u8bed\u8a00","text":"\u70b9\u51fb Go Download and install \u8fdb\u5165\u5230 Go \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 Go \u8bed\u8a00\u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 Go \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 go version
\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u884c\u793a\u4f8b\u5982\u4e0b\uff1a
> go version\ngo version go1.22.3 darwin/arm64\n
macOS \u4e2d\u4e00\u822c\u5df2\u7ecf\u81ea\u5e26 Clang \u7f16\u8bd1\u5668\uff0c\u5176\u4e0e GCC \u57fa\u672c\u8d77\u5230\u76f8\u540c\u4f5c\u7528\u3002\u9a8c\u8bc1 GCC/Clang \u73af\u5883\u662f\u5426\u9700\u8981\u5b89\u88c5\uff1a
gcc -v\nbash: gcc: command not found\n
\u5982\u4ee3\u7801\u6240\u793a\uff0c\u672a\u663e\u793a GCC \u6216 Clang \u7684\u7248\u672c\uff0c\u5219\u8868\u793a GCC/Clang \u7684\u73af\u5883\u9700\u8981\u5b89\u88c5\u3002
\u4f60\u53ef\u4ee5\u9009\u62e9\u70b9\u51fb GCC Download and install \u8fdb\u5165\u5230 GCC \u7684\u5b98\u65b9\u6587\u6863\uff0c\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5\u6b65\u9aa4\u5b8c\u6210 GCC \u7684\u5b89\u88c5\u3002\u6216\u8005\u4e5f\u53ef\u4ee5\u901a\u8fc7 Apple \u5b98\u65b9\u7684 Xcode \u8fdb\u884c Clang \u7684\u5b89\u88c5\u3002
\u9a8c\u8bc1 GCC/Clang \u662f\u5426\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee3\u7801 gcc -v
\uff0c\u65e0\u8bba\u663e\u793a\u7684\u662f Clang \u6216\u8005 GCC \u7248\u672c\u5747\u8bf4\u660e\u5b89\u88c5\u6210\u529f\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
Apple clang version 14.0.3 (clang-1403.0.22.14.1)\nTarget: arm64-apple-darwin22.5.0\nThread model: posix\nInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin\n
\u901a\u8fc7\u5b98\u65b9\u6587\u6863\u5b89\u88c5 Git\u3002
\u4f7f\u7528 git version
\u68c0\u67e5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff0c\u5b89\u88c5\u6210\u529f\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
> git version\ngit version 2.40.0\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#4-mysql-client","title":"4. \u5b89\u88c5 MySQL Client","text":"\u70b9\u51fb MySQL Community Downloads\uff0c\u8fdb\u5165\u5230 MySQL \u5ba2\u6237\u7aef\u4e0b\u8f7d\u5b89\u88c5\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\u73af\u5883\uff0c\u4e0b\u62c9\u9009\u62e9 Select Operating System > macOS\uff0c\u518d\u4e0b\u62c9\u9009\u62e9 Select OS Version\uff0c\u6309\u9700\u9009\u62e9\u4e0b\u8f7d\u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u73af\u5883\u53d8\u91cf\uff1a
\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
vim ~/.bash_profile\n
\u56de\u8f66\u6267\u884c\u4e0a\u9762\u7684\u547d\u4ee4\u540e\uff0c\u5373\u8fdb\u5165\u4e86 bash_profile\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 i \u8fdb\u5165 insert \u72b6\u6001\uff0c\u5373\u53ef\u5728\u6587\u4ef6\u4e0b\u65b9\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
export PATH=${PATH}:/usr/local/mysql/bin\n
\u8f93\u5165\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 esc \u9000\u51fa insert \u72b6\u6001\uff0c\u5e76\u5728\u6700\u4e0b\u65b9\u8f93\u5165 :wq
\u4fdd\u5b58\u9000\u51fa\u3002
\u6267\u884c\u547d\u4ee4 source ~/.bash_profile
\uff0c\u56de\u8f66\u6267\u884c\uff0c\u8fd0\u884c\u73af\u5883\u53d8\u91cf\u3002
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff1a
\u6267\u884c\u547d\u4ee4 mysql --version
\uff0c\u5b89\u88c5\u6210\u529f\u63d0\u793a\uff1amysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)
\u3002
mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u5148\u5b89\u88c5 wget
\u4e0b\u8f7d\u5de5\u5177\uff1a\u8fdb\u5165\u5230 Homebrew \u9875\u9762\u6309\u7167\u6b65\u9aa4\u63d0\u793a\uff0c\u5148\u5b89\u88c5 Homebrew\uff0c\u518d\u5b89\u88c5 wget
\u3002\u9a8c\u8bc1 wget
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c\uff08\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801\uff09\u5982\u4e0b\uff1a
GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1\u3002\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\uff1a
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u5b89\u88c5\u5b8c\u6210\u4ee5\u540e\uff0c\u901a\u8fc7 mo_ctl
\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\uff0c\u6210\u529f\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
> mo_ctl\n Usage : mo_ctl [option_1] [option_2]\n\n [option_1] : available: auto_backup | auto_clean_logs | backup | clean_backup | clean_logs | connect | csv_convert | ddl_convert | deploy | get_branch | get_cid | get_conf | help | monitor | pprof | precheck | restart | set_conf | sql | start | status | stop | uninstall | upgrade | version | watchdog\n auto_backup : setup a crontab task to backup your databases automatically\n auto_clean_logs : set up a crontab task to clean system log table data automatically\n backup : create a backup of your databases manually\n build_image : build an MO image from source code\n clean_backup : clean old backups older than conf 31 days manually\n clean_logs : clean system log table data manually\n connect : connect to mo via mysql client using connection info configured\n csv_convert : convert a csv file to a sql file in format \"insert into values\" or \"load data inline format='csv'\"\n ddl_convert : convert a ddl file to mo format from other types of database\n deploy : deploy mo onto the path configured\n get_branch : upgrade or downgrade mo from current version to a target commit id or stable version\n get_cid : print mo git commit id from the path configured\n get_conf : get configurations\n help : print help information\n monitor : monitor system related operations\n pprof : collect pprof information\n precheck : check pre-requisites for mo_ctl\n restart : a combination operation of stop and start\n set_conf : set configurations\n sql : execute sql from string, or a file or a path containg multiple files\n start : start mo-service from the path configured\n status : check if there's any mo process running on this machine\n stop : stop all mo-service processes found on this machine\n uninstall : uninstall mo from path MO_PATH=/Users/admin/mo//matrixone\n upgrade : upgrade or downgrade mo from current version to a target commit id or stable version\n version : show mo_ctl and matrixone version\n watchdog : setup a watchdog crontab task for mo-service to keep it alive\n e.g. : mo_ctl status\n\n [option_2] : Use \" mo_ctl [option_1] help \" to get more info\n e.g. : mo_ctl deploy help\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#mo_ctl","title":"\u8bbe\u7f6e mo_ctl \u7684\u914d\u7f6e\u53c2\u6570","text":"mo_ctl \u5de5\u5177\u4e2d\u6709\u90e8\u5206\u53c2\u6570\u53ef\u80fd\u9700\u8981\u4f60\u8fdb\u884c\u8c03\u6574\u8bbe\u7f6e\uff0c\u901a\u8fc7 mo_ctl get_conf
\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u5f53\u524d\u53c2\u6570\u3002
> mo_ctl get_conf\n2023-07-07_15:31:24 [INFO] Below are all configurations set in conf file /Users/username/mo_ctl/conf/env.sh\nMO_PATH=\"/Users/username/mo/matrixone\"\nMO_LOG_PATH=\"${MO_PATH}/matrixone/logs\"\nMO_HOST=\"127.0.0.1\"\nMO_PORT=\"6001\"\nMO_USER=\"root\"\nMO_PW=\"111\"\nMO_DEPLOY_MODE=\"host\"\nMO_REPO=\"matrixorigin/matrixone\"\nMO_IMAGE_PREFIX=\"nightly\"\nMO_IMAGE_FULL=\"\"\nMO_CONTAINER_NAME=\"mo\"\nMO_CONTAINER_PORT=\"6001\"\nMO_CONTAINER_DEBUG_PORT=\"12345\"\nCHECK_LIST=(\"go\" \"gcc\" \"git\" \"mysql\" \"docker\")\nGCC_VERSION=\"8.5.0\"\nCLANG_VERSION=\"13.0\"\nGO_VERSION=\"1.22.3\"\nMO_GIT_URL=\"https://github.com/matrixorigin/matrixone.git\"\nMO_DEFAULT_VERSION=\"v1.2.1\"\nGOPROXY=\"https://goproxy.cn,direct\"\nSTOP_INTERVAL=\"5\"\nSTART_INTERVAL=\"2\"\nMO_DEBUG_PORT=\"9876\"\nMO_CONF_FILE=\"${MO_PATH}/matrixone/etc/launch/launch.toml\"\nRESTART_INTERVAL=\"2\"\nPPROF_OUT_PATH=\"/tmp/pprof-test/\"\nPPROF_PROFILE_DURATION=\"30\"\n
\u9700\u8981\u8c03\u6574\u7684\u53c2\u6570\u5982\u4e0b\uff1a
mo_ctl set_conf MO_PATH=\"yourpath\" # \u8bbe\u7f6e\u81ea\u5b9a\u4e49\u7684MatrixOne\u4e0b\u8f7d\u8def\u5f84\nmo_ctl set_conf MO_GIT_URL=\"https://githubfast.com/matrixorigin/matrixone.git\" #\u9488\u5bf9github\u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\u95ee\u9898\uff0c\u8bbe\u7f6e\u955c\u50cf\u4e0b\u8f7d\u5730\u5740\nmo_ctl set_conf MO_DEFAULT_VERSION=\"v1.2.1\" # \u8bbe\u7f6e\u6240\u4e0b\u8f7d\u7684MatrixOne\u7248\u672c\nmo_ctl set_conf MO_DEPLOY_MODE=git #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u6e90\u7801\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u4e00\u952e\u5b89\u88c5 MatrixOne","text":"\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/matrixone/logs/
\u4e2d\u3002
> mo_ctl start\n2023-07-07_15:33:45 [INFO] No mo-service is running\n2023-07-07_15:33:45 [INFO] Starting mo-service: cd /Users/username/mo/matrixone/matrixone/ && /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml >/Users/username/mo/matrixone/matrixone/logs/stdout-20230707_153345.log 2>/Users/username/mo/matrixone/matrixone/logs/stderr-20230707_153345.log\n2023-07-07_15:33:45 [INFO] Wait for 2 seconds\n2023-07-07_15:33:48 [INFO] At least one mo-service is running. Process info:\n2023-07-07_15:33:48 [INFO] 501 66932 1 0 3:33PM ?? 0:00.27 /Users/username/mo/matrixone/matrixone/mo-service -daemon -debug-http :9876 -launch /Users/username/mo/matrixone/matrixone/etc/launch/launch.toml\n2023-07-07_15:33:48 [INFO] Pids:\n2023-07-07_15:33:48 [INFO] 66932\n2023-07-07_15:33:48 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method1/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
> mo_ctl connect\n2023-07-07_10:30:20 [INFO] Checking connectivity\n2023-07-07_10:30:20 [INFO] Ok, connecting for user ...\nmysql: [Warning] Using a password on the command line interface can be insecure.\nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 15\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2023, Oracle and/or its affiliates.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u4e8c\u8fdb\u5236\u5305\u5728 macOS \u73af\u5883\u4e2d\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\uff0c\u8fd9\u79cd\u5b89\u88c5\u65b9\u6848\u65e0\u9700\u5b89\u88c5\u524d\u7f6e\u4f9d\u8d56\u548c\u7f16\u8bd1\u6e90\u7801\u5305\uff0c\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7 mo_ctl \u5de5\u5177\u5e2e\u52a9\u6211\u4eec\u8fdb\u884c\u90e8\u7f72\u4e0e\u7ba1\u7406 MatrixOne\u3002
MatrixOne \u652f\u6301 x86 \u53ca ARM \u4e24\u79cd\u67b6\u6784\u7684 macOS \u7cfb\u7edf\uff0c\u672c\u6587\u4ee5 Macbook M1 ARM \u7248\u672c\u4e3a\u4f8b\u5c55\u793a\u6574\u4e2a\u90e8\u7f72\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#_1","title":"\u524d\u7f6e\u4f9d\u8d56\u53c2\u8003","text":"\u901a\u8fc7\u4e8c\u8fdb\u5236\u5305\u90e8\u7f72\u548c\u5b89\u88c5 MatrixOne\uff0c\u4ec5\u9700\u5b89\u88c5 MySQL Client
\u5de5\u5177\u3002
\u70b9\u51fb MySQL Community Downloads\uff0c\u8fdb\u5165\u5230 MySQL \u5ba2\u6237\u7aef\u4e0b\u8f7d\u5b89\u88c5\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\u73af\u5883\uff0c\u4e0b\u62c9\u9009\u62e9 Select Operating System > macOS\uff0c\u518d\u4e0b\u62c9\u9009\u62e9 Select OS Version\uff0c\u6309\u9700\u9009\u62e9\u4e0b\u8f7d\u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u73af\u5883\u53d8\u91cf\uff1a
vim ~/.bash_profile\n
export PATH=${PATH}:/usr/local/mysql/bin\n
\u8f93\u5165\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 esc \u9000\u51fa insert \u72b6\u6001\uff0c\u5e76\u5728\u6700\u4e0b\u65b9\u8f93\u5165 :wq
\u4fdd\u5b58\u9000\u51fa\u3002
\u6267\u884c\u547d\u4ee4 source ~/.bash_profile
\uff0c\u56de\u8f66\u6267\u884c\uff0c\u8fd0\u884c\u73af\u5883\u53d8\u91cf\u3002
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff1a
\u6267\u884c\u547d\u4ee4 mysql --version
\uff0c\u5b89\u88c5\u6210\u529f\u63d0\u793a\uff1amysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)
\u3002
Tips: \u5efa\u8bae\u4f60\u4e0b\u8f7d\u5b89\u88c5\u8fd9\u4e24\u4e2a\u4e0b\u8f7d\u5de5\u5177\u5176\u4e2d\u4e4b\u4e00\uff0c\u65b9\u4fbf\u540e\u7eed\u901a\u8fc7\u547d\u4ee4\u884c\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u3002
\u5b89\u88c5wget
\u5b89\u88c5 curl
wget
\u5de5\u5177\u7528\u6765\u4ece\u6307\u5b9a\u7684 URL \u4e0b\u8f7d\u6587\u4ef6\u3002wget
\u662f\u4e13\u95e8\u7684\u6587\u4ef6\u4e0b\u8f7d\u5de5\u5177\uff0c\u5b83\u975e\u5e38\u7a33\u5b9a\uff0c\u800c\u4e14\u4e0b\u8f7d\u901f\u5ea6\u5feb\u3002
\u8fdb\u5165\u5230Homebrew\u9875\u9762\u6309\u7167\u6b65\u9aa4\u63d0\u793a\uff0c\u5148\u5b89\u88c5 Homebrew\uff0c\u518d\u5b89\u88c5 wget
\u3002 \u9a8c\u8bc1 wget
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
wget -V\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
GNU Wget 1.21.3 \u5728 darwin21.3.0 \u4e0a\u7f16\u8bd1\u3002\n...\nCopyright \u00a9 2015 Free Software Foundation, Inc.\n...\n
curl
\u662f\u4e00\u4e2a\u5229\u7528 URL \u89c4\u5219\u5728\u547d\u4ee4\u884c\u4e0b\u5de5\u4f5c\u7684\u6587\u4ef6\u4f20\u8f93\u5de5\u5177\u3002curl
\u662f\u7efc\u5408\u4f20\u8f93\u5de5\u5177\uff0c\u652f\u6301\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d\u3002
\u8fdb\u5165\u5230Curl\u5b98\u7f51\u6309\u7167\u5b98\u65b9\u6307\u5bfc\u5b89\u88c5 curl
\u3002 \u9a8c\u8bc1 curl
\u662f\u5426\u5b89\u88c5\u6210\u529f\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff1a
curl --version\n
\u5b89\u88c5\u6210\u529f\u7ed3\u679c(\u4ec5\u5c55\u793a\u4e00\u90e8\u5206\u4ee3\u7801)\u5982\u4e0b\uff1a
curl 7.84.0 (x86_64-apple-darwin22.0) libcurl/7.84.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0\nRelease-Date: 2022-06-27\n...\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#2_1","title":"2. \u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u5e76\u89e3\u538b","text":"\u4e0b\u8f7d\u65b9\u5f0f\u4e00\u548c\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\u9700\u8981\u5148\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177 wget
\u6216 curl
\uff0c\u5982\u679c\u4f60\u672a\u5b89\u88c5\uff0c\u8bf7\u5148\u81ea\u884c\u5b89\u88c5\u4e0b\u8f7d\u5de5\u5177\u3002
wget
\u5de5\u5177\u4e0b\u8f7d\u5b89\u88c5\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e8c\uff1acurl
\u5de5\u5177\u4e0b\u8f7d\u4e8c\u8fdb\u5236\u5305\u4e0b\u8f7d\u65b9\u5f0f\u4e09\uff1a\u9875\u9762\u4e0b\u8f7d x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-x86_64.zip\nunzip mo-v1.2.1-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
wget https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-arm64.zip\nunzip mo-v1.2.1-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
wget https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-xxx.zip\n
x86 \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-x86_64.zip\nunzip mo-v1.2.1-darwin-x86_64.zip\n
ARM \u67b6\u6784\u7cfb\u7edf\u5b89\u88c5\u5305\uff1a
curl -OL https://github.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-arm64.zip\nunzip mo-v1.2.1-darwin-arm64.zip\n
\u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u5730\u5740\u4e0b\u8f7d\u955c\u50cf\u5305\uff1a
curl -OL https://githubfast.com/matrixorigin/matrixone/releases/download/v1.2.1/mo-v1.2.1-darwin-xxx.zip\n
\u5982\u679c\u4f60\u60f3\u901a\u8fc7\u66f4\u76f4\u89c2\u7684\u9875\u9762\u4e0b\u8f7d\u7684\u65b9\u5f0f\u4e0b\u8f7d\uff0c\u76f4\u63a5\u70b9\u51fb\u8fdb\u5165\u7248\u672c 1.2.1\uff0c\u4e0b\u62c9\u627e\u5230 Assets \u680f\uff0c\u70b9\u51fb\u5b89\u88c5\u5305 mo-v1.2.1-darwin-x86_64.zip \u6216 mo-v1.2.1-darwin-arm64.zip \u4e0b\u8f7d\u5373\u53ef\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#3-mo_ctl","title":"\u6b65\u9aa4 3\uff1a\u5b89\u88c5 mo_ctl \u5de5\u5177","text":"mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_PATH=\"/yourpath/mo-v1.2.1-xx-xx\" #\u8bbe\u7f6eMatrixOne\u8def\u5f84\u4e3a\u4e8c\u8fdb\u5236\u89e3\u538b\u6587\u4ef6\u76ee\u5f55\nmo_ctl set_conf MO_CONF_FILE=\"/yourpath/mo-v1.2.1-xx-xx/etc/launch/launch.toml\" #\u8bbe\u7f6eMatrixOne\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\nmo_ctl set_conf MO_DEPLOY_MODE=binary #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3a\u4e8c\u8fdb\u5236\u90e8\u7f72\u65b9\u5f0f\n
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#4-matrixone","title":"\u6b65\u9aa4 4\uff1a\u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl start
\u547d\u4ee4\u4e00\u952e\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u5982\u679c\u8fd0\u884c\u6b63\u5e38\u5c06\u51fa\u73b0\u4ee5\u4e0b\u65e5\u5fd7\u3002MatrixOne \u7684\u76f8\u5173\u8fd0\u884c\u65e5\u5fd7\u4f1a\u5728 /yourpath/mo-v1.2.1-xx-xx/matrixone/logs/
\u4e2d\u3002
> mo_ctl start\n2024-03-07 14:34:04.942 UTC+0800 [INFO] No mo-service is running\n2024-03-07 14:34:04.998 UTC+0800 [INFO] Get conf succeeded: MO_DEPLOY_MODE=\"binary\"\n2024-03-07 14:34:05.024 UTC+0800 [INFO] GO memory limit(Mi): 14745\n2024-03-07 14:34:05.072 UTC+0800 [INFO] Starting mo-service: cd /Users/admin/mo-v1.2.1-darwin-arm64/ && GOMEMLIMIT=14745MiB /Users/admin/mo-v1.2.1-darwin-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-darwin-arm64/etc/launch/launch.toml >/Users/admin/mo-v1.2.1-darwin-arm64/matrixone/logs/stdout-20240307_143405.log 2>/Users/admin/mo-v1.2.1-darwin-arm64/matrixone/logs/stderr-20240307_143405.log\n2024-03-07 14:34:05.137 UTC+0800 [INFO] Wait for 2 seconds\n2024-03-07 14:34:07.261 UTC+0800 [INFO] At least one mo-service is running. Process info: \n 501 27145 1 0 2:34\u4e0b\u5348 ?? 0:00.18 /Users/admin/mo-v1.2.1-darwin-arm64/mo-service -daemon -debug-http :9876 -launch /Users/admin/mo-v1.2.1-darwin-arm64/etc/launch/launch.toml\n2024-03-07 14:34:07.284 UTC+0800 [INFO] List of pid(s): \n27145\n2024-03-07 14:34:07.308 UTC+0800 [INFO] Start succeeded\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method2/#5-matrixone","title":"\u6b65\u9aa4 5\uff1a\u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
> mo_ctl connect\n2024-03-07 14:34:59.902 UTC+0800 [INFO] Checking connectivity\n2024-03-07 14:34:59.942 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 426\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql>\n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528 Docker \u90e8\u7f72\u5355\u673a\u7248 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#1","title":"\u6b65\u9aa4 1\uff1a\u524d\u7f6e\u6761\u4ef6","text":""},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#docker_1","title":"\u5b89\u88c5 docker","text":"\u70b9\u51fb Get Docker\uff0c\u8fdb\u5165 Docker \u7684\u5b98\u65b9\u6587\u6863\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4e0b\u8f7d\u5b89\u88c5\u5bf9\u5e94\u7684 Docker\uff0cDocker \u7248\u672c\u63a8\u8350\u9009\u62e9\u5728 20.10.18 \u53ca\u4ee5\u4e0a\uff0c\u4e14\u5c3d\u91cf\u4fdd\u6301 Docker client \u548c Docker server \u7684\u7248\u672c\u4e00\u81f4\u3002
\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u4e0b\u8ff0\u4ee3\u7801\u884c\u786e\u8ba4 Docker \u7248\u672c\uff0c\u9a8c\u8bc1 Docker \u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a
docker --version\n
\u5b89\u88c5\u6210\u529f\uff0c\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
Docker version 20.10.18, build 100c701\n
\u76f4\u63a5\u6253\u5f00\u4f60\u672c\u5730 Docker \u5ba2\u6237\u7aef\uff0c\u542f\u52a8 Docker\u3002
\u70b9\u51fb MySQL Community Downloads\uff0c\u8fdb\u5165\u5230 MySQL \u5ba2\u6237\u7aef\u4e0b\u8f7d\u5b89\u88c5\u9875\u9762\uff0c\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\u73af\u5883\uff0c\u4e0b\u62c9\u9009\u62e9 Select Operating System > macOS\uff0c\u518d\u4e0b\u62c9\u9009\u62e9 Select OS Version\uff0c\u6309\u9700\u9009\u62e9\u4e0b\u8f7d\u5b89\u88c5\u5305\u8fdb\u884c\u5b89\u88c5\u3002
\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u73af\u5883\u53d8\u91cf\uff1a
\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
vim ~/.bash_profile\n
\u56de\u8f66\u6267\u884c\u4e0a\u9762\u7684\u547d\u4ee4\u540e\uff0c\u5373\u8fdb\u5165\u4e86 bash_profile\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 i \u8fdb\u5165 insert \u72b6\u6001\uff0c\u5373\u53ef\u5728\u6587\u4ef6\u4e0b\u65b9\u8f93\u5165\u5982\u4e0b\u547d\u4ee4\uff1a
export PATH=${PATH}:/usr/local/mysql/bin\n
\u8f93\u5165\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u952e\u76d8\u4e0a\u7684 esc \u9000\u51fa insert \u72b6\u6001\uff0c\u5e76\u5728\u6700\u4e0b\u65b9\u8f93\u5165 :wq
\u4fdd\u5b58\u9000\u51fa\u3002
\u6267\u884c\u547d\u4ee4 source ~/.bash_profile
\uff0c\u56de\u8f66\u6267\u884c\uff0c\u8fd0\u884c\u73af\u5883\u53d8\u91cf\u3002
\u6d4b\u8bd5 MySQL \u662f\u5426\u53ef\u7528\uff1a
\u6267\u884c\u547d\u4ee4 mysql --version
\uff0c\u5b89\u88c5\u6210\u529f\u63d0\u793a\uff1amysql Ver 8.0.31 for macos12 on arm64 (MySQL Community Server - GPL)
\u3002
\u6b64\u8282\u4ecb\u7ecd\u4f7f\u7528 docker \u76f4\u63a5\u62c9\u53d6 MatrixOne \u955c\u50cf\u548c\u4f7f\u7528 mo_ctl \u5de5\u5177\u90e8\u7f72\u4e24\u79cd\u65b9\u5f0f
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#docker_2","title":"docker \u90e8\u7f72","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u4ece Docker Hub \u4e2d\u62c9\u53d6 MatrixOne \u955c\u50cf\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff0c\u6216\u5f00\u53d1\u7248\u672c\u955c\u50cf\uff0c\u5f53 Tag \u4e3a latest
\u65f6\u83b7\u53d6\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002
docker pull matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.2.1\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u7a33\u5b9a\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\n
\u83b7\u53d6\u6700\u65b0\u5f00\u53d1\u7248\u672c\u7684\u955c\u50cf\uff0c\u53c2\u89c1Docker Hub\uff0c\u627e\u5230\u6700\u65b0Tag\uff0c\u62c9\u53d6\u955c\u50cf\u3002\u62c9\u53d6\u955c\u50cf\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a
docker pull matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:nightly-commitnumber\n
\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u4e2d\u56fd\u5927\u9646\u7684\u7f51\u7edc\uff0c\u4f60\u53ef\u4ee5\u62c9\u53d6\u963f\u91cc\u4e91\u4e0a\u7684 MatrixOne \u5f00\u53d1\u7248\u672c\u955c\u50cf\uff1a
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\ndocker run -d -p 6001:6001 --name matrixone registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-commitnumber\n
Note: \u5982\u4e0a\u9762\u4ee3\u7801\u6240\u793a\uff0cnightly \u4e3a\u6807\u8bc6\u7684 Tag \u7248\u672c\u6bcf\u5929\u90fd\u8fdb\u884c\u66f4\u65b0\uff0c\u8bf7\u6ce8\u610f\u83b7\u53d6\u6700\u65b0\u7684\u955c\u50cf\u3002
\u82e5 Docker \u7248\u672c\u4f4e\u4e8e 20.10.18 \u6216\u8005 Docker client \u548c Docker server \u7684\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u63a8\u8350\u540c\u65f6\u5347\u7ea7\u5230 Docker \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u540e\u518d\u5c1d\u8bd5\u3002\u82e5\u575a\u6301\u4f7f\u7528\uff0c\u9700\u8981\u5728 docker run
\u547d\u4ee4\u4e2d\u52a0\u4e0a\u53c2\u6570 --privileged=true
\uff0c\u5982\uff1a
docker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.2.1\n
\u5982\u9700\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u6216\u914d\u7f6e\u81ea\u5b9a\u4e49\u6587\u4ef6\uff0c\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#mo_ctl","title":"mo_ctl \u90e8\u7f72","text":"mo_ctl \u662f\u4e00\u4e2a\u90e8\u7f72\u5b89\u88c5\u548c\u7ba1\u7406 MatrixOne \u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u5bf9 MatrixOne \u8fdb\u884c\u5404\u7c7b\u64cd\u4f5c\u3002\u5982\u9700\u83b7\u53d6\u5b8c\u6574\u7684\u4f7f\u7528\u7ec6\u8282\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u4e00\u952e\u5b89\u88c5 mo_ctl \u5de5\u5177\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo -u $(whoami) bash +x ./install.sh\n
\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8c03\u6574\u53c2\u6570\uff1a
mo_ctl set_conf MO_CONTAINER_DATA_HOST_PATH=\"/yourpath/mo/\" # \u5bbf\u4e3b\u673amo\u7684\u6570\u636e\u76ee\u5f55\nmo_ctl set_conf MO_CONTAINER_IMAGE=\"matrixorigin/matrixone:1.2.1\" # \u8bbe\u7f6e\u955c\u50cf\uff0c\u56fd\u5185\u7684\u53ef\u4ee5\u7528registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:1.2.1\nmo_ctl set_conf MO_DEPLOY_MODE=docker #\u8bbe\u7f6eMatrixOne\u90e8\u7f72\u65b9\u5f0f\uff0c\u6b64\u4e3adocker\u90e8\u7f72\u65b9\u5f0f\n
\u4ee5\u4e0b\u4e3a\u53ef\u9009\u53c2\u6570\uff1a
MO_CONTAINER_NAME=\"mo\" # mo \u5bb9\u5668\u540d\nMO_CONTAINER_PORT=\"6001\" # mo \u7aef\u53e3\u53f7\nMO_CONTAINER_DEBUG_PORT=\"12345\" #\u5bb9\u5668\u5185 debug \u7aef\u53e3\nMO_CONTAINER_CONF_HOST_PATH=\"\" # \u5bbf\u4e3b\u673a mo \u7684\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff0c\u9700\u8981\u53c2\u8003\nMO_CONTAINER_CONF_CON_FILE=\"/etc/quickstart/launch.toml\" # \u5bb9\u5668\u5185\u914d\u7f6e\u6587\u4ef6\nMO_CONTAINER_LIMIT_MEMORY=\"\" # \u5185\u5b58\u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1am\nMO_CONTAINER_MEMORY_RATIO=90 # \u5982\u679c\u4e0d\u8bbe\u7f6e\u5185\u5b58\u5927\u5c0f\uff0c\u5c31\u4f1a\u6839\u636e\u8fd9\u4e2a\u503c\u6765\u8bbe\u7f6e\u4e3b\u673a\u7684 x% \u5185\u5b58\uff0c\u9ed8\u8ba4 90%\nMO_CONTAINER_AUTO_RESTART=\"yes\" # \u662f\u5426\u8bbe\u7f6e\u5bb9\u5668\u81ea\u52a8\u91cd\u542f\nMO_CONTAINER_LIMIT_CPU=\"\" # cpu \u7684\u9650\u5236\uff0c\u5355\u4f4d\uff1a\u6838\u6570\nMO_CONTAINER_EXTRA_MOUNT_OPTION=\"\" #\u989d\u5916\u7684\u6302\u8f7d\u53c2\u6570\uff0c\u6bd4\u5982 -v xx:xx:xx\n
\u6839\u636e\u60a8\u7684\u9700\u8981\uff0c\u9009\u62e9\u6700\u65b0\u7684\u5f00\u53d1\u7248\u672c\uff0c\u8fd8\u662f\u83b7\u5f97\u7a33\u5b9a\u7248\u672c\u7684\u4ee3\u7801\u3002
\u901a\u8fc7 MatrixOne (\u5f00\u53d1\u7248\u672c) \u4ee3\u7801\u5b89\u88c5\u901a\u8fc7 MatrixOne (\u7a33\u5b9a\u7248\u672c) \u4ee3\u7801\u5b89\u88c5main \u5206\u652f\u662f\u9ed8\u8ba4\u5206\u652f\uff0c\u4e3b\u5206\u652f\u4e0a\u7684\u4ee3\u7801\u603b\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e0d\u591f\u7a33\u5b9a\u3002
mo_ctl deploy main\n
mo_ctl deploy v1.2.1\n
mo_ctl start\n
Note
\u9996\u6b21\u542f\u52a8 MatrixOne \u5927\u81f4\u9700\u8981\u82b1\u8d39 20 \u81f3 30 \u79d2\u7684\u65f6\u95f4\uff0c\u5728\u7a0d\u4f5c\u7b49\u5f85\u540e\uff0c\u4f60\u4fbf\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3 MatrixOne\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#3-matrixone","title":"\u6b65\u9aa4 3\uff1a\u8fde\u63a5 MatrixOne","text":"\u9664\u4e86\u53ef\u4ee5\u4f7f\u7528 MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u6765\u8fde\u63a5 MatrixOne\uff0c\u5728\u5df2\u90e8\u7f72 mo_ctl \u5de5\u5177\u7684\u60c5\u51b5\u4e0b\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 mo_ctl \u5de5\u5177\u6765\u8fde\u63a5 MatrixOne\u3002\u6b64\u8282\u4ecb\u7ecd\u4e24\u79cd\u8fde\u63a5\u65b9\u5f0f\u7684\u5177\u4f53\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#mysql","title":"MySQL \u547d\u4ee4\u884c\u5ba2\u6237\u7aef\u8fde\u63a5","text":"mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: # \u521d\u59cb\u5bc6\u7801\u9ed8\u8ba4\u4e3a 111\n
\u8fde\u63a5\u6210\u529f\u5c06\u8fd4\u56de\u4ee5\u4e0b\u4fe1\u606f\uff1a
>mysql -h 127.0.0.1 -P 6001 -uroot -p\nEnter password: \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5982\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
\u76ee\u524d\uff0cMatrixOne \u53ea\u652f\u6301 TCP \u76d1\u542c\u3002
"},{"location":"MatrixOne/Get-Started/install-on-macos/install-on-macos-method3/#mo_ctl_1","title":"mo_ctl \u5de5\u5177\u8fde\u63a5","text":"\u901a\u8fc7 mo_ctl connect
\u547d\u4ee4\u4e00\u952e\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
\u8fd9\u6761\u547d\u4ee4\u5c06\u8c03\u7528 MySQL Client \u5de5\u5177\u81ea\u52a8\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\u3002
mo_ctl connect\n2024-03-08 11:13:34.347 UTC+0800 [INFO] Checking connectivity\n2024-03-08 11:13:34.420 UTC+0800 [INFO] Ok, connecting for user ... \nWelcome to the MySQL monitor. Commands end with ; or \\g.\nYour MySQL connection id is 5849\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\n\nCopyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql> \n
Note
\u4e0a\u8ff0\u7684\u8fde\u63a5\u548c\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7 root
\u548c\u5bc6\u7801 111
\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002\u4fee\u6539\u767b\u5f55\u7528\u6237\u540d\u6216\u5bc6\u7801\u540e\u91cd\u65b0\u767b\u5f55\u540c\u6837\u9700\u8981\u901a\u8fc7 mo_ctl set_conf
\u7684\u65b9\u5f0f\u8bbe\u7f6e\u65b0\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u8be6\u60c5\u53ef\u4ee5\u53c2\u8003 mo_ctl \u5de5\u5177\u6307\u5357\u3002
\u5b8c\u6210 MatrixOne \u642d\u5efa\u548c\u8fde\u63a5\u540e\uff0c\u9996\u6b21\u6267\u884c\u65f6\uff0cMatrixOne \u4f1a\u81ea\u52a8\u751f\u6210\u4ee5\u4e0b\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u653e\u5404\u7c7b\u6570\u636e\u6587\u4ef6\u6216\u5143\u6570\u636e\u4fe1\u606f\u3002
\u8fdb\u5165 matrixone \u76ee\u5f55\u6267\u884c ls
\u67e5\u770b\u76ee\u5f55\u7ed3\u6784\uff0c\u76f8\u5173\u76ee\u5f55\u7ed3\u6784\u4ee5\u53ca\u7528\u9014\u5982\u4e0b\uff1a
matrixone \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne \u4e3b\u76ee\u5f55 |-- etc \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- quickstart \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 |-- mo-data \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u6570\u636e\u6587\u4ef6\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- local \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u672c\u5730 fileservice \u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- cnservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//cn \u8282\u70b9\u4fe1\u606f\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- tnservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//tn \u8282\u70b9\u4fe1\u606f\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- etl \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5916\u90e8\u8868\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- sys \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5916\u90e8\u8868\u4fe1\u606f\u5f52\u5c5e\u4e8e\u54ea\u4e2a\u79df\u6237 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- logs \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u7c7b\u578b \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5e74\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u6708\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5929\u6570 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u8def\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- merged \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u8fc7\u5f80\u5916\u90e8\u8868\u4fe1\u606f\u7684\u5408\u5e76\u8bb0\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 2022 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5e74\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 10 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u6708\u4efd \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 27 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u7684\u5929\u6570 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- metric \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- rawlog \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- statement_info \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u7edf\u8ba1\u4fe1\u606f\u5bf9\u5e94\u8868\u7684\u5b58\u50a8\u8def\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- logservice \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice \u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |-- 7c4dccb4-4d3c-41f8-b482-5251dc7a41bf \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//logservice \u8282\u70b9\u5bf9\u5e94\u76ee\u5f55\uff08\u968f\u673a\u751f\u6210 uuid\uff09 \u2502\u00a0\u00a0\u00a0\u00a0 |--hostname \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//MatrixOne \u7684\u670d\u52a1\u5668\u57df\u540d \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- 00000000000000000001 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5feb\u7167\u4fdd\u5b58\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- exported-snapshot \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5bfc\u51fa\u5feb\u7167\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- snapshot-part-n \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u5feb\u7167\u5206\u90e8\u4fdd\u5b58\u76ee\u5f55 \u2502\u00a0\u00a0\u00a0\u00a0 |\u00a0\u00a0 |-- tandb \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//bootstrap \u4fe1\u606f\u4fdd\u5b58\u76ee\u5f55 |-- s3 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0//\u6570\u636e\u4fdd\u5b58\u76ee\u5f55
"},{"location":"MatrixOne/Maintain/mount-data-by-docker/","title":"\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5728\u4f7f\u7528 Docker \u542f\u52a8 MatrixOne \u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u4f55\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u6216\u81ea\u5b9a\u4e49\u914d\u7f6e\u6587\u4ef6\u5230 Docker \u5bb9\u5668\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cDocker \u4e0d\u80fd\u5bf9\u5df2\u7ecf\u542f\u52a8\u8fc7\u7684\u5bb9\u5668\u8fdb\u884c\u6302\u8f7d\uff0c\u82e5\u60f3\u8981\u6302\u8f7d\u6570\u636e\u76ee\u5f55\u5219\u9700\u8981\u91cd\u65b0\u521b\u5efa\u4e00\u4e2a Docker \u5bb9\u5668\u3002
"},{"location":"MatrixOne/Maintain/mount-data-by-docker/#_1","title":"\u6302\u8f7d\u6570\u636e\u76ee\u5f55","text":"\u53c2\u8003\u4ee5\u4e0b\u8be6\u7ec6\u6b65\u9aa4\uff0c\u6302\u8f7d\u672c\u5730\u6570\u636e\u76ee\u5f55\u5230 Docker \u5bb9\u5668\uff1a
\u5728\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u7a7a\u76ee\u5f55 ${local_data_path}/mo-data\uff0c\u5176\u4e2d ${local_data_path} \u4e3a\u4f60\u7684\u672c\u5730\u6587\u4ef6\u5939\u8def\u5f84\u3002\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
mkdir ${local_data_path}/mo-data\n
\u628a\u672c\u5730\u7a7a\u76ee\u5f55 ${local_data_path}/mo-data \u6302\u8f7d\u5230 Docker \u5bb9\u5668\u76ee\u5f55 /mo-data \u4e0b\uff0c\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
sudo docker run --name <name> -d -p 6001:6001 -v ${local_data_path}/mo-data:/mo-data:rw matrixorigin/matrixone:1.2.1\n
\u53c2\u6570 \u63cf\u8ff0 ${local_data_path}/mo-data:/mo-data \u6302\u8f7d\u672c\u5730\u6570\u636e\u76ee\u5f55 ${local_data_path}/mo-data \u5230\u5bb9\u5668 /mo-data \u6587\u4ef6\u5939 Tips: \u9700\u8981\u6302\u8f7d\u7684\u672c\u5730\u6570\u636e\u76ee\u5f55\u5fc5\u987b\u4e3a\u7a7a\u76ee\u5f55\u3002 \u5982\u679c\u4f60\u9700\u8981\u4fee\u6539\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\uff0c\u5efa\u8bae\u4f60\u5148\u5c06 Docker \u5185\u7684\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u62f7\u8d1d\u5230\u4f60\u672c\u5730\u76ee\u5f55\uff0c\u7136\u540e\u5c06\u5b58\u653e\u914d\u7f6e\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u6302\u8f7d\u5230 Docker \u5bb9\u5668\u76ee\u5f55\u4e0b\uff0c\u53c2\u8003\u4ee5\u4e0b\u8be6\u7ec6\u6b65\u9aa4\uff0c\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6\u5230 Docker \u5bb9\u5668\uff1a
\u9996\u5148\u542f\u52a8\u4e00\u4e2a MatrixOne \u7684\u5bb9\u5668\u5b9e\u4f8b\uff0c\u8fd9\u4e2a\u5bb9\u5668\u5b9e\u4f8b\u5c06\u63d0\u4f9b\u4e00\u5957\u6807\u51c6\u7684\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\uff1a
docker run -d -p 6001:6001 --name matrixone matrixorigin/matrixone:1.2.1\n
\u67e5\u770b Docker \u5df2\u7ecf\u542f\u52a8\u7684 MatrixOne \u7684 containerID\uff0c\u5e76\u5c06\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55\u62f7\u8d1d\u5230\u672c\u5730\u76ee\u5f55\u7684 ${local_config_path} \u76ee\u5f55\u4e0b\uff1a
docker ps\ndocker cp <containerID>:/etc/launch ${local_config_path}\n
\u62f7\u8d1d\u5b8c\u6210\u540e\uff0c\u5173\u505c\u5e76\u9500\u6bc1\u5f53\u524d\u7684 MatrixOne\uff1a
docker stop <containerID>\ndocker rm <containerID>\n
\uff08\u9009\u505a\uff09\u82e5\u9700\u8981\u4fee\u6539\u542f\u52a8\u914d\u7f6e\u6587\u4ef6\uff0c\u5219\u4fee\u6539\u672c\u5730\u76ee\u5f55 ${local_config_path}/launch \u4e0b\u7684\u914d\u7f6e\u6587\u4ef6\u5e76\u4fdd\u5b58\u3002
\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6\u5230 Docker \u5bb9\u5668\u76ee\u5f55\uff0c\u540c\u65f6\u521b\u5efa\u5e76\u542f\u52a8 MatrixOne\uff0c\u6302\u8f7d\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a
sudo docker run --name <name> -d -p 6001:6001 -v ${local_config_path}/launch:/etc/launch:rw --entrypoint \"/mo-service\" matrixorigin/matrixone:1.2.1 -launch /etc/launch/launch.toml\n
\u53c2\u6570 \u63cf\u8ff0 ${local_config_path}/launch:/etc/launch \u6302\u8f7d\u672c\u5730\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55 ${local_config_path}/launch \u5230\u5bb9\u5668 /etc/launch \u6587\u4ef6\u5939 --entrypoint \"/mo-service\" \u5bb9\u5668\u5165\u53e3\u547d\u4ee4\uff0c\u5373\u8ba9\u5bb9\u5668\u542f\u52a8 MatrixOne \u670d\u52a1 -launch /etc/launch/launch.toml \u5bb9\u5668\u5165\u53e3\u547d\u4ee4\u5bf9\u5e94\u7684\u547d\u4ee4\u53c2\u6570\uff0c\u5373\u4f7f\u7528\u5bb9\u5668\u5185 /etc/launch/launch.toml \u542f\u52a8\u914d\u7f6e\u6587\u4ef6\u542f\u52a8 MatrixOne \u670d\u52a1 Note
\u82e5 Docker \u7248\u672c\u4f4e\u4e8e 20.10.18 \u6216\u8005 Docker client \u548c Docker server \u7684\u7248\u672c\u4e0d\u4e00\u81f4\uff0c\u63a8\u8350\u540c\u65f6\u5347\u7ea7\u5230 Docker \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u540e\u518d\u5c1d\u8bd5\u3002\u82e5\u575a\u6301\u4f7f\u7528\uff0c\u9700\u8981\u5728 ```docker run``` \u547d\u4ee4\u4e2d\u52a0\u4e0a\u53c2\u6570 ```--privileged=true```\uff0c\u5982\uff1a\n\n```bash\ndocker run -d -p 6001:6001 --name matrixone --privileged=true matrixorigin/matrixone:1.2.1\n```\n
\u66f4\u591a\u5173\u4e8e Docker run \u7684\u6307\u4ee4\u91ca\u4e49\uff0c\u8fd0\u884c\u547d\u4ee4 docker run --help
\u8fdb\u884c\u67e5\u770b\u3002
\u6570\u636e\u5e93\u5907\u4efd\u4e0e\u6062\u590d\u662f\u4efb\u4f55\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u7684\u6838\u5fc3\u64cd\u4f5c\u4e4b\u4e00\uff0c\u4e5f\u662f\u6570\u636e\u5b89\u5168\u4e0e\u53ef\u7528\u6027\u7684\u91cd\u8981\u4fdd\u969c\u3002MatrixOne \u4e5f\u63d0\u4f9b\u4e86\u7075\u6d3b\u4e14\u5f3a\u5927\u7684\u6570\u636e\u5e93\u5907\u4efd\u4e0e\u6062\u590d\u529f\u80fd\uff0c\u4ee5\u786e\u4fdd\u7528\u6237\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u6301\u7eed\u6027\u3002\u672c\u6587\u5c06\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u5907\u4efd\u4e0e\u6062\u590d\u7684\u91cd\u8981\u6027\u3001\u5907\u4efd\u7b56\u7565\u3001\u5907\u4efd\u65b9\u6cd5\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#_1","title":"\u5907\u4efd\u548c\u6062\u590d\u7b56\u7565","text":"\u5728\u4e0d\u540c\u707e\u96be\u6062\u590d\u60c5\u51b5\u4e0b\uff0c\u53ef\u4f7f\u7528\u6570\u636e\u5e93\u5907\u4efd\u6062\u590d\u8fd0\u884c\u72b6\u6001\u3002
\u4ee5\u4e0b\u662f\u9488\u5bf9\u4e0d\u540c\u60c5\u51b5\u7684\u5907\u4efd\u6062\u590d\u65b9\u6cd5\uff1a
\u64cd\u4f5c\u7cfb\u7edf\u5d29\u6e83\uff1a
\u7535\u6e90\uff08\u68c0\u6d4b\uff09\u5931\u8d25\uff1a
\u6587\u4ef6\u7cfb\u7edf\u5d29\u6e83\uff1a
\u786c\u4ef6\u95ee\u9898\uff08\u786c\u76d8\u3001\u4e3b\u677f\u7b49\uff09\uff1a
\u9488\u5bf9\u5907\u4efd\u6062\u590d\u53ef\u4ee5\u9075\u5faa\u4ee5\u4e0b\u7b56\u7565\uff1a
\u5907\u4efd\u9891\u7387: \u786e\u5b9a\u5907\u4efd\u7684\u9891\u7387\uff0c\u901a\u5e38\u5206\u4e3a\u5168\u91cf\u5907\u4efd\u548c\u589e\u91cf\u5907\u4efd\u3002\u5168\u91cf\u5907\u4efd\u4f1a\u5360\u7528\u66f4\u591a\u5b58\u50a8\u7a7a\u95f4\u548c\u65f6\u95f4\uff0c\u4f46\u6062\u590d\u901f\u5ea6\u8f83\u5feb\uff0c\u800c\u589e\u91cf\u5907\u4efd\u5219\u66f4\u52a0\u7ecf\u6d4e\u3002
\u5907\u4efd\u5b58\u50a8: \u9009\u62e9\u5b89\u5168\u7684\u5907\u4efd\u5b58\u50a8\u4f4d\u7f6e\uff0c\u786e\u4fdd\u5907\u4efd\u6570\u636e\u4e0d\u6613\u53d7\u5230\u7834\u574f\u6216\u4e22\u5931\u3002\u901a\u5e38\u4f7f\u7528\u79bb\u7ebf\u5b58\u50a8\u4ecb\u8d28\u6216\u4e91\u5b58\u50a8\u6765\u5b58\u653e\u5907\u4efd\u3002
\u5907\u4efd\u4fdd\u7559\u671f: \u786e\u5b9a\u5907\u4efd\u6570\u636e\u7684\u4fdd\u7559\u671f\uff0c\u4ee5\u4fbf\u5728\u9700\u8981\u65f6\u8fdb\u884c\u5386\u53f2\u6570\u636e\u7684\u68c0\u7d22\u548c\u6062\u590d\u3002\u6839\u636e\u6cd5\u89c4\u548c\u4e1a\u52a1\u9700\u6c42\uff0c\u5236\u5b9a\u76f8\u5e94\u7684\u6570\u636e\u4fdd\u7559\u653f\u7b56\u3002
\u65e0\u8bba\u4f55\u79cd\u6062\u590d\u60c5\u51b5\uff0c\u5e94\u9075\u5faa\u4ee5\u4e0b\u539f\u5219\uff1a
MatrixOne \u63d0\u4f9b\u591a\u79cd\u5907\u4efd\u65b9\u5f0f\uff0c\u53ef\u6839\u636e\u6570\u636e\u5e93\u9700\u6c42\u3001\u6027\u80fd\u3001\u8d44\u6e90\u548c\u6062\u590d\u65f6\u95f4\u7b49\u56e0\u7d20\uff0c\u7efc\u5408\u8003\u8651\u9009\u62e9\u9002\u5f53\u5907\u4efd\u65b9\u6cd5\u3002
MatrixOne \u6570\u636e\u5e93\u63d0\u4f9b\u4e86\u591a\u79cd\u5907\u4efd\u5de5\u5177\uff0c\u4ee5\u6ee1\u8db3\u4e0d\u540c\u573a\u666f\u548c\u9700\u6c42\uff1a
mo-dump: \u7528\u4e8e\u5bfc\u51fa\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u548c\u6a21\u5f0f\u3002\u5b83\u751f\u6210\u53ef\u6062\u590d\u7684 SQL \u811a\u672c\uff0c\u7528\u4e8e\u903b\u8f91\u5907\u4efd\u3002
mo-backup: \u7528\u4e8e\u7269\u7406\u5907\u4efd\u548c\u6062\u590d\u3002mo-backup
\u662f MatrixOne \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u5e2e\u52a9\u4f60\u4fdd\u62a4\u5176 MatrixOne \u6570\u636e\u5e93\uff0c\u5e76\u5728\u9700\u8981\u65f6\u8fdb\u884c\u53ef\u9760\u7684\u6062\u590d\u64cd\u4f5c\u3002
!!! note mo-backup \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#_3","title":"\u903b\u8f91\u5907\u4efd\u4e0e\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#select-into-outfile","title":"\u4f7f\u7528SELECT INTO OUTFILE
\u5907\u4efd","text":"\u4f7f\u7528 SELECT ... INTO OUTFILE
\u547d\u4ee4\u5c06\u68c0\u7d22\u7684\u6570\u636e\u6309\u683c\u5f0f\u5bfc\u51fa\u5230\u6587\u4ef6\uff0c\u5bfc\u51fa\u7684\u6587\u4ef6\u7531 MatrixOne \u670d\u52a1\u521b\u5efa\uff0c\u4ec5\u5728 MatrixOne \u670d\u52a1\u5668\u4e3b\u673a\u4e0a\u3002\u4e0d\u652f\u6301\u5bfc\u51fa\u81f3\u5ba2\u6237\u7aef\u6587\u4ef6\u7cfb\u7edf\uff0c\u5bfc\u51fa\u76ee\u5f55\u52ff\u91cd\u540d\u6587\u4ef6\uff0c\u907f\u514d\u65b0\u6587\u4ef6\u8986\u76d6\u3002
\u64cd\u4f5c\u6b65\u9aa4\u53ca\u793a\u4f8b\uff0c\u53c2\u89c1 SELECT INTO...OUTFILE
mo-dump
\u5907\u4efd","text":"MatrixOne \u652f\u6301\u4f7f\u7528 mo-dump
\u5de5\u5177\u8fdb\u884c\u903b\u8f91\u5907\u4efd\uff0c\u751f\u6210\u53ef\u7528\u4e8e\u91cd\u65b0\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u6570\u636e\u7684 SQL \u8bed\u53e5\u3002
\u64cd\u4f5c\u6b65\u9aa4\u53ca\u793a\u4f8b\uff0c\u53c2\u89c1 mo-dump \u5de5\u5177\u5199\u51fa
MatrixOne \u652f\u6301\u4f7f\u7528 LOAD DATA
\u547d\u4ee4\u5c06\u5927\u91cf\u884c\u63d2\u5165\u6570\u636e\u5e93\u8868\uff0c\u4e5f\u652f\u6301\u4f7f\u7528 SOURCE
\u547d\u4ee4\u5bfc\u5165\u8868\u7ed3\u6784\u548c\u6570\u636e\u81f3\u6574\u4e2a\u6570\u636e\u5e93\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u8003\u6279\u91cf\u5bfc\u5165
"},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#_5","title":"\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/backup-restore-overview/#mo_br","title":"\u4f7f\u7528mo_br
\u5907\u4efd\u4e0e\u6062\u590d","text":"MatrixOne \u652f\u6301\u4f7f\u7528 mo_br
\u5de5\u5177\u8fdb\u884c\u5e38\u89c4\u7269\u7406\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u3002
\u64cd\u4f5c\u6b65\u9aa4\u53ca\u793a\u4f8b\uff0c\u53c2\u89c1 mo-br \u4f7f\u7528\u6307\u5357
MatrixOne \u652f\u6301\u4f7f\u7528 SQL \u8fdb\u884c\u5feb\u7167\u5907\u4efd\u4e0e\u6062\u590d\u3002
\u6709\u5173\u4f7f\u7528 SQL \u8fdb\u884c\u5feb\u7167\u5907\u4efd\u4e0e\u6062\u590d\u7684\u65b9\u6cd5\uff0c\u8bf7\u53c2\u8003\u6587\u6863\uff1a
\u7269\u7406\u5907\u4efd\u662f\u5c06\u6570\u636e\u5e93\u6587\u4ef6\u76f4\u63a5\u590d\u5236\u5230\u5907\u4efd\u4ecb\u8d28\uff08\u5982\u78c1\u5e26\u3001\u786c\u76d8\u7b49\uff09\u4e0a\u7684\u8fc7\u7a0b\u3002\u6b64\u65b9\u5f0f\u5c06\u6570\u636e\u5e93\u7684\u6240\u6709\u7269\u7406\u6570\u636e\u5757\u590d\u5236\u5230\u5907\u4efd\u4ecb\u8d28\uff0c\u5305\u62ec\u6570\u636e\u6587\u4ef6\u3001\u63a7\u5236\u6587\u4ef6\u548c\u91cd\u505a\u65e5\u5fd7\u6587\u4ef6\u7b49\u3002\u5907\u4efd\u7684\u6570\u636e\u662f\u5b9e\u9645\u5b58\u50a8\u5728\u78c1\u76d8\u4e0a\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u6062\u590d\u64cd\u4f5c\u901a\u5e38\u8fc5\u901f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_4","title":"\u5feb\u7167\u5907\u4efd","text":"\u6570\u636e\u5e93\u5feb\u7167\u5907\u4efd\u4e3a\u7269\u7406\u5907\u4efd\u7684\u4e00\u79cd\u5f62\u5f0f\uff0c\u4f46\u533a\u522b\u4e8e\u4f20\u7edf\u7684\u7269\u7406\u5907\u4efd\uff0c\u5b83\u901a\u8fc7\u6355\u6349\u6570\u636e\u5e93\u5728\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u53ea\u8bfb\u9759\u6001\u89c6\u56fe\u6765\u521b\u5efa\u6570\u636e\u7684\u5373\u65f6\u526f\u672c\u3002\u8fd9\u79cd\u5907\u4efd\u65b9\u5f0f\u5229\u7528\u589e\u91cf\u5b58\u50a8\u673a\u5236\uff0c\u4ec5\u8bb0\u5f55\u81ea\u4e0a\u4e00\u4e2a\u5feb\u7167\u4ee5\u6765\u53d1\u751f\u53d8\u5316\u7684\u6570\u636e\u5757\uff0c\u4ece\u800c\u9ad8\u6548\u5730\u4f7f\u7528\u5b58\u50a8\u7a7a\u95f4\u3002\u5feb\u7167\u5907\u4efd\u652f\u6301\u5feb\u901f\u6062\u590d\uff0c\u56e0\u4e3a\u5b83\u4eec\u63d0\u4f9b\u4e86\u6570\u636e\u5e93\u7684\u5b8c\u6574\u4e00\u81f4\u6027\u89c6\u56fe\uff0c\u9002\u7528\u4e8e\u6570\u636e\u4fdd\u62a4\u3001\u62a5\u544a\u751f\u6210\u3001\u5206\u6790\u548c\u5176\u4ed6\u9700\u8981\u6570\u636e\u4e00\u81f4\u6027\u7684\u573a\u666f\u3002\u6b64\u5916\uff0c\u5b83\u4eec\u901a\u5e38\u4f9d\u8d56\u4e8e\u5e95\u5c42\u5b58\u50a8\u7cfb\u7edf\u7684\u5feb\u7167\u529f\u80fd\uff0c\u80fd\u591f\u5728\u4e0d\u5f71\u54cd\u6570\u636e\u5e93\u6b63\u5e38\u8fd0\u884c\u7684\u60c5\u51b5\u4e0b\uff0c\u4e3a\u6570\u636e\u5e93\u63d0\u4f9b\u4e00\u4e2a\u5b89\u5168\u7684\u6570\u636e\u8bbf\u95ee\u526f\u672c\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_5","title":"\u903b\u8f91\u5907\u4efd","text":"\u903b\u8f91\u5907\u4efd\u662f\u901a\u8fc7 SQL \u8bed\u53e5\u5907\u4efd\u6570\u636e\u5e93\u4e2d\u7684\u903b\u8f91\u5bf9\u8c61\uff08\u5982\u8868\u3001\u7d22\u5f15\u3001\u5b58\u50a8\u8fc7\u7a0b\u7b49\uff09\u3002\u8fd9\u79cd\u5907\u4efd\u65b9\u5f0f\u5c06\u903b\u8f91\u5bf9\u8c61\u7684\u5b9a\u4e49\u548c\u6570\u636e\u5bfc\u51fa\u81f3\u5907\u4efd\u6587\u4ef6\uff0c\u4f46\u4e0d\u6d89\u53ca\u6570\u636e\u5e93\u6587\u4ef6\u7684\u4e8c\u8fdb\u5236\u6570\u636e\u3002\u867d\u7136\u6062\u590d\u901f\u5ea6\u8f83\u6162\uff0c\u5907\u4efd\u6570\u636e\u901a\u5e38\u66f4\u6613\u9605\u8bfb\u548c\u4fee\u6539\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_6","title":"\u533a\u522b","text":"\u6570\u636e\u7269\u7406\u5907\u4efd\u3001\u903b\u8f91\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u662f\u4e09\u79cd\u4e0d\u540c\u7684\u6570\u636e\u4fdd\u62a4\u7b56\u7565\uff1a\u7269\u7406\u5907\u4efd\u901a\u8fc7\u76f4\u63a5\u590d\u5236\u6570\u636e\u5e93\u7684\u5b58\u50a8\u6587\u4ef6\u6765\u521b\u5efa\u6570\u636e\u5e93\u7684\u4e00\u4e2a\u5b8c\u6574\u526f\u672c\uff0c\u9002\u7528\u4e8e\u5feb\u901f\u6062\u590d\u548c\u5927\u89c4\u6a21\u6570\u636e\u8fc1\u79fb\uff1b\u903b\u8f91\u5907\u4efd\u5219\u5bfc\u51fa\u6570\u636e\u5e93\u7684\u903b\u8f91\u7ed3\u6784\uff0c\u5982 SQL \u8bed\u53e5\uff0c\u4ee5\u6587\u672c\u5f62\u5f0f\u5b58\u50a8\u6570\u636e\u548c\u7ed3\u6784\uff0c\u4fbf\u4e8e\u8de8\u5e73\u53f0\u548c\u7248\u672c\u7684\u6570\u636e\u8fc1\u79fb\uff1b\u800c\u5feb\u7167\u5907\u4efd\u662f\u6570\u636e\u5e93\u5728\u67d0\u4e00\u65f6\u523b\u7684\u53ea\u8bfb\u89c6\u56fe\uff0c\u5229\u7528\u589e\u91cf\u5b58\u50a8\u6280\u672f\u8bb0\u5f55\u53d8\u5316\uff0c\u9002\u7528\u4e8e\u5feb\u901f\u6062\u590d\u81f3\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u72b6\u6001\uff0c\u901a\u5e38\u4f9d\u8d56\u4e8e\u5b58\u50a8\u7cfb\u7edf\u7684\u652f\u6301\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_7","title":"\u5168\u91cf\u5907\u4efd\u3001\u589e\u91cf\u5907\u4efd\u4e0e\u5dee\u5f02\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_8","title":"\u5168\u91cf\u5907\u4efd","text":"\u5168\u91cf\u5907\u4efd\u5c06\u6574\u4e2a\u6570\u636e\u96c6\u5907\u4efd\u81f3\u5b58\u50a8\u8bbe\u5907\uff0c\u5305\u62ec\u6240\u6709\u6587\u4ef6\u548c\u6587\u4ef6\u5939\u3002\u5c3d\u7ba1\u901a\u5e38\u8017\u65f6\u957f\u4e14\u9700\u8981\u5927\u5b58\u50a8\u7a7a\u95f4\uff0c\u4f46\u53ef\u5b8c\u5168\u8fd8\u539f\u6570\u636e\uff0c\u65e0\u9700\u5176\u4ed6\u5907\u4efd\u6587\u4ef6\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_9","title":"\u589e\u91cf\u5907\u4efd","text":"\u589e\u91cf\u5907\u4efd\u4ec5\u5907\u4efd\u6700\u8fd1\u66f4\u6539\u6216\u65b0\u589e\u7684\u6587\u4ef6\u6216\u6570\u636e\u5757\u3002\u4ec5\u5907\u4efd\u4e0a\u6b21\u5907\u4efd\u4ee5\u6765\u7684\u53d8\u66f4\uff0c\u901a\u5e38\u5907\u4efd\u65f6\u95f4\u548c\u5b58\u50a8\u7a7a\u95f4\u8f83\u5c11\u3002\u901a\u5e38\u5728\u5b9a\u671f\u5168\u91cf\u5907\u4efd\u4e4b\u95f4\u6267\u884c\uff0c\u4ee5\u786e\u4fdd\u5907\u4efd\u6570\u636e\u4fdd\u6301\u6700\u65b0\u3002\u6062\u590d\u6570\u636e\u9700\u4f7f\u7528\u6240\u6709\u589e\u91cf\u5907\u4efd\u548c\u6700\u65b0\u5168\u91cf\u5907\u4efd\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_10","title":"\u5dee\u5f02\u5907\u4efd","text":"\u5dee\u5f02\u5907\u4efd\u662f\u5907\u4efd\u81ea\u4e0a\u6b21\u5b8c\u6574\u5907\u4efd\u4ee5\u6765\u53d1\u751f\u53d8\u5316\u7684\u6570\u636e\uff0c\u56e0\u6b64\u5907\u4efd\u6570\u636e\u91cf\u8f83\u589e\u91cf\u5907\u4efd\u5927\uff0c\u5907\u4efd\u65f6\u95f4\u8f83\u957f\u3002\u6062\u590d\u6570\u636e\u65f6\uff0c\u53ea\u9700\u5148\u6062\u590d\u6700\u8fd1\u7684\u5b8c\u6574\u5907\u4efd\uff0c\u518d\u6062\u590d\u6700\u8fd1\u7684\u5dee\u5f02\u5907\u4efd\u5373\u53ef\u3002\u7531\u4e8e\u4e0d\u4f9d\u8d56\u4e4b\u524d\u5907\u4efd\u6570\u636e\uff0c\u6062\u590d\u65f6\u95f4\u8f83\u77ed\uff0c\u5907\u4efd\u548c\u6062\u590d\u8fc7\u7a0b\u76f8\u5bf9\u7b80\u5355\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_11","title":"\u5168\u91cf\u5907\u4efd\u3001\u589e\u91cf\u5907\u4efd\u4e0e\u5dee\u5f02\u5907\u4efd\u7684\u533a\u522b","text":"\u7269\u7406\u6062\u590d\u662f\u5229\u7528\u7269\u7406\u5907\u4efd\u8fdb\u884c\u6570\u636e\u5e93\u6062\u590d\u3002\u901a\u5e38\u7528\u4e8e\u4e25\u91cd\u6545\u969c\u5982\u786c\u76d8\u6545\u969c\u3001\u64cd\u4f5c\u7cfb\u7edf\u6545\u969c\u6216\u6587\u4ef6\u7cfb\u7edf\u6545\u969c\u3002\u5728\u7269\u7406\u6062\u590d\u4e2d\uff0c\u4f7f\u7528\u4e13\u4e1a\u6062\u590d\u5de5\u5177\u6216\u8f6f\u4ef6\u8bfb\u53d6\u5907\u4efd\u6587\u4ef6\u6216\u5b58\u50a8\u4ecb\u8d28\u4e2d\u5b9e\u9645\u6570\u636e\u5757\uff0c\u5e76\u5c1d\u8bd5\u4fee\u590d\u635f\u574f\u5757\u3002
\u7269\u7406\u6062\u590d\u4f18\u52bf\u5728\u4e8e\u5feb\u901f\u8fd8\u539f\u6570\u636e\u5e93\uff0c\u56e0\u65e0\u9700\u6267\u884c SQL \u8bed\u53e5\u6216\u5176\u4ed6\u9ad8\u5c42\u64cd\u4f5c\uff0c\u76f4\u63a5\u5904\u7406\u6570\u636e\u5757\u3002\u6b64\u5916\uff0c\u7269\u7406\u6062\u590d\u80fd\u8fd8\u539f\u6240\u6709\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5305\u62ec\u8868\u3001\u7d22\u5f15\u3001\u5b58\u50a8\u8fc7\u7a0b\u7b49\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/key-concepts/#_14","title":"\u5b8c\u5168\u6062\u590d\u4e0e\u4e0d\u5b8c\u5168\u6062\u590d","text":"\u5bf9\u4e8e\u4f01\u4e1a\u800c\u8a00\uff0c\u6bcf\u5929\u90fd\u4f1a\u4ea7\u751f\u5927\u91cf\u6570\u636e\uff0c\u90a3\u4e48\u5bf9\u4e8e\u6570\u636e\u5e93\u7684\u5907\u4efd\u5c31\u975e\u5e38\u91cd\u8981\u3002\u5728\u7cfb\u7edf\u5d29\u6e83\u6216\u8005\u786c\u4ef6\u6545\u969c\uff0c\u53c8\u6216\u8005\u7528\u6237\u8bef\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u6062\u590d\u6570\u636e\u5e76\u91cd\u542f\u7cfb\u7edf\uff0c\u4e0d\u4f1a\u9020\u6210\u6570\u636e\u4e22\u5931\u3002
\u53e6\u5916\uff0c\u6570\u636e\u5907\u4efd\u4e5f\u4f5c\u4e3a\u5347\u7ea7 MatrixOne \u5b89\u88c5\u4e4b\u524d\u7684\u4fdd\u969c\uff0c\u540c\u65f6\u6570\u636e\u5907\u4efd\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06 MatrixOne \u5b89\u88c5\u8f6c\u79fb\u5230\u53e6\u4e00\u4e2a\u7cfb\u7edf\u3002
MatrixOne \u652f\u6301\u901a\u8fc7 mo-dump
\u5b9e\u7528\u7a0b\u5e8f\u8fdb\u884c\u903b\u8f91\u5907\u4efd\u3002modump
\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5b9e\u7528\u7a0b\u5e8f\uff0c\u7528\u4e8e\u751f\u6210 MatrixOne \u6570\u636e\u5e93\u7684\u903b\u8f91\u5907\u4efd\u3002\u5b83\u751f\u6210\u53ef\u7528\u4e8e\u91cd\u65b0\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u6570\u636e\u7684 SQL \u8bed\u53e5\u3002\u4f60\u53ef\u4ee5\u5728 mo-dump \u7ae0\u8282\u4e2d\u67e5\u627e\u5b83\u7684\u8bed\u6cd5\u8bf4\u660e\u548c\u4f7f\u7528\u6307\u5357\u3002
\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bb2\u8ff0\u5982\u4f55\u4f7f\u7528 mo-dump
\u5b9e\u7528\u7a0b\u5e8f\u5b8c\u6210\u6570\u636e\u5907\u4efd\u548c\u8fd8\u539f\u7684\u8fc7\u7a0b\u3002
\u53c2\u89c1 mo-dump \u5de5\u5177\u5199\u51fa\u7ae0\u8282\uff0c\u5b8c\u6210 mo-dump
\u5de5\u5177\u7684\u90e8\u7f72\u3002
\u793a\u4f8b\u5982\u4e0b\uff0c\u4f7f\u7528\u4ee5\u4e0b SQL \u521b\u5efa\u7684\u6570\u636e\u5e93 t \u53ca\u5176\u8868 t1\uff1a
DROP DATABASE IF EXISTS `t`;\nCREATE DATABASE `t`;\nUSE `t`;\ncreate table t1\n(\n c1 int primary key auto_increment,\n c2 tinyint not null default 4,\n c3 smallint,\n c4 bigint,\n c5 tinyint unsigned,\n c6 smallint unsigned,\n c7 int unsigned,\n c8 bigint unsigned,\n c9 float,\n c10 double,\n c11 date,\n c12 datetime,\n c13 timestamp on update current_timestamp,\n c14 char,\n c15 varchar,\n c16 json,\n c17 decimal,\n c18 text,\n c19 blob,\n c20 uuid\n);\ninsert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, '2019-01-01', '2019-01-01 00:00:00', '2019-01-01 00:00:00', 'a', 'a', '{\"a\":1}','1212.1212', 'a', 'aza', '00000000-0000-0000-0000-000000000000');\n
\u5982\u679c\u8981\u751f\u6210\u5355\u4e2a\u6570\u636e\u5e93\u7684\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u547d\u540d\u4e3a t \u7684\u6570\u636e\u5e93\u7684\u5907\u4efd\uff0c\u5176\u4e2d\u5305\u542b t.sql \u6587\u4ef6\u4e2d\u7684\u7ed3\u6784\u548c\u6570\u636e\u3002
./mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db t > t.sql\n
\u5982\u679c\u8981\u5728\u6570\u636e\u5e93\u4e2d\u751f\u6210\u5355\u4e2a\u8868\u7684\u5907\u4efd\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u751f\u6210\u547d\u540d\u4e3a t \u7684\u6570\u636e\u5e93\u7684 t1 \u8868\u7684\u5907\u4efd\uff0c\u5176\u4e2d\u5305\u542b t.sql \u6587\u4ef6\u4e2d\u7684\u7ed3\u6784\u548c\u6570\u636e\u3002
./mo-dump -u root -p 111 -db t -tbl t1 > t1.sql\n
Note
\u5982\u679c\u4f60\u60f3\u751f\u6210\u591a\u4e2a\u6570\u636e\u5e93/\u8868\u7684\u5907\u4efd\uff0c\u9700\u8981\u5728\u6570\u636e\u5e93\u540d/\u8868\u540d\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002
\u5c06\u5bfc\u51fa\u7684 sql \u6587\u4ef6\u6062\u590d\u81f3 MatrixOne \u6570\u636e\u5e93\u76f8\u5bf9\u7b80\u5355\u3002\u8981\u6062\u590d\u4f60\u7684\u6570\u636e\u5e93\uff0c\u4f60\u5fc5\u987b\u5148\u521b\u5efa\u4e00\u4e2a\u7a7a\u6570\u636e\u5e93\uff0c\u5e76\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fdb\u884c\u6062\u590d\u3002
\u5c06 MatrixOne \u4e0e MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u81f3\u540c\u4e00\u670d\u52a1\u5668\u4e0a\uff0c\u5e76\u786e\u4fdd\u5bfc\u51fa\u7684 sql \u6587\u4ef6\u4e5f\u5728\u540c\u4e00\u670d\u52a1\u5668\u4e0a\u3002
mysql> create database t if not exists;\nmysql> source /YOUR_SQL_FILE_PATH/t.sql\n
\u6210\u529f\u6267\u884c\u4ee5\u4e0a\u547d\u4ee4\u540e\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u68c0\u67e5\u662f\u5426\u5728\u547d\u540d\u4e3a t \u6570\u636e\u5e93\u4e0a\u521b\u5efa\u4e86\u6240\u6709\u5bf9\u8c61\u3002
mysql> use t;\nmysql> show tables;\nmysql> select count(*) from t1;\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/","title":"mo_br \u5907\u4efd\u4e0e\u6062\u590d","text":"\u5bf9\u4e8e\u4f01\u4e1a\u800c\u8a00\uff0c\u6bcf\u5929\u90fd\u4f1a\u4ea7\u751f\u5927\u91cf\u6570\u636e\uff0c\u90a3\u4e48\u5bf9\u4e8e\u6570\u636e\u5e93\u7684\u5907\u4efd\u5c31\u975e\u5e38\u91cd\u8981\u3002\u5728\u7cfb\u7edf\u5d29\u6e83\u6216\u8005\u786c\u4ef6\u6545\u969c\uff0c\u53c8\u6216\u8005\u7528\u6237\u8bef\u64cd\u4f5c\u7684\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u6062\u590d\u6570\u636e\u5e76\u91cd\u542f\u7cfb\u7edf\uff0c\u4e0d\u4f1a\u9020\u6210\u6570\u636e\u4e22\u5931\u3002
\u53e6\u5916\uff0c\u6570\u636e\u5907\u4efd\u4e5f\u4f5c\u4e3a\u5347\u7ea7 MatrixOne \u5b89\u88c5\u4e4b\u524d\u7684\u4fdd\u969c\uff0c\u540c\u65f6\u6570\u636e\u5907\u4efd\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5c06 MatrixOne \u5b89\u88c5\u8f6c\u79fb\u5230\u53e6\u4e00\u4e2a\u7cfb\u7edf\u3002
MatrixOne \u652f\u6301\u901a\u8fc7 mo_br
\u5b9e\u7528\u5de5\u5177\u8fdb\u884c\u7269\u7406\u5907\u4efd\u3002mo_br
\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u5b9e\u7528\u7a0b\u5e8f\uff0c\u7528\u4e8e\u751f\u6210 MatrixOne \u6570\u636e\u5e93\u7684\u7269\u7406\u5907\u4efd\u3002\u5b83\u751f\u6210\u53ef\u7528\u4e8e\u91cd\u65b0\u521b\u5efa\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u6570\u636e\u7684 SQL \u8bed\u53e5\u3002
\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bb2\u8ff0\u5982\u4f55\u4f7f\u7528 mo_br
\u5b9e\u7528\u7a0b\u5e8f\u5b8c\u6210\u6570\u636e\u5907\u4efd\u548c\u8fd8\u539f\u7684\u8fc7\u7a0b\u3002
mo_br backup\n --host\n --port \n --user \n --password \n --backup_dir s3|filesystem \n //s3 oss minio\n --endpoint\n --access_key_id \n --secret_access_key \n --bucket \n --filepath\n --region \n --compression \n --role_arn \n --is_minio\n --parallelism \n //filesystem\n --path\n --parallelism\n --meta_path \n //\u589e\u91cf\u5907\u4efd\u9700\u8981\n --backup_type\n --base_id\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 backup_dir \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002s3 \u6216 filesystem endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5230 s3 \u7684\u670d\u52a1\u7684 URL access_key_id \u5907\u4efd\u5230 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230 s3 \u7684 Secret access key bucket \u5907\u4efd\u5230\u7684 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u5907\u4efd\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 region \u5907\u4efd\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression \u5907\u4efd\u5230 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 role_arn \u5907\u4efd\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 is_minio \u6307\u5b9a\u5907\u4efd\u5230\u7684 s3 \u662f\u5426\u4e3a minio path \u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u8def\u5f84 parallelism \u5e76\u884c\u5ea6 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 backup_type \u6307\u5b9a\u5907\u4efd\u7c7b\u578b\u4e3a\u589e\u91cf\u5907\u4efd\uff0cincremental\u3002 base_id \u4e0a\u6b21\u4e00\u6b21\u5907\u4efd\u7684 ID\uff0c\u4e3b\u8981\u7528\u4e8e\u786e\u5b9a\u4e0a\u6b21\u5907\u4efd\u7684\u65f6\u95f4\u6233\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_3","title":"\u793a\u4f8b","text":"./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\"\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"s3\" --endpoint \"http://127.0.0.1:9000\" --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\" --bucket \"bucket1\" --filepath \"/backup1\" --is_minio\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\" --backup_type \"incremental\" --base_id \"xxx\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_4","title":"\u67e5\u770b\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_5","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br list\n -- ID\n //\u8981\u67e5\u8be2\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key \n --not_check_data \n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_check_data \u53ea\u67e5\u770b meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u67e5\u770b\u5907\u4efd\u6570\u636e\u3002\u9ed8\u8ba4\u4e0d\u5e26\u8fd9\u4e2a\u53c2\u6570\u7684\uff0c\u5c31\u662f\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u3002\u5f53\u524d\u53ea\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_6","title":"\u793a\u4f8b","text":"./mo_br list\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n| 01108122-10f9-11ef-9359-26dd28356ef2 | 8.3 MB | BackupDir: filesystem Path: | 2024-05-13 15:18:28 +0800 | 3.394437375s | 2024-05-13 15:18:32 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n
./mo_br list 4d21b228-10dd-11ef-9497-26dd28356ef2\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n\nChecking the backup data(currently,no checksum)...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/log.toml_018f70d1-3100-7762-b28b-8f85ac4ed3cd\ncheck: config/tn.toml_018f70d1-310e-78fc-ac96-aa5e06981bd7\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_7","title":"\u5220\u9664\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_8","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br delete ID \n //\u8981\u5220\u9664\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key\n --not_delete_data\n --meta_path\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u5220\u9664\u7684\u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_delete_data \u53ea\u5220\u9664 meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u5220\u9664\u5907\u4efd\u6570\u636e\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_9","title":"\u793a\u4f8b","text":"./mo_br delete e4cade26-3139-11ee-8631-acde48001122\n
./mo_br delete e4cade26-3139-11ee-8631-acde48001122 --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_10","title":"\u6062\u590d\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_11","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br restore ID\n //\u8bfb\u53d6\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id\n --backup_secret_access_key \n\n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath \n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u6062\u590d\u7684 ID backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730\u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6//\u6062\u590d\u3002\nmo_br restore\n --backup_dir s3|filesystem \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --backup_endpoint \n --backup_access_key_id \n --backup_secret_access_key\n --backup_bucket\n --backup_filepath\n --backup_region \n --backup_compression \n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path \n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath\n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 \u6216 filesystem restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730 matrixone \u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_12","title":"\u793a\u4f8b","text":"\u4ece\u6587\u4ef6\u7cfb\u7edf\u6062\u590d\u5230\u6587\u4ef6\u7cfb\u7edf
\u6b65\u9aa4\u4e00\uff1a\u505c\u6b62 mo\uff0c\u5220\u9664 mo-data
\u6b65\u9aa4\u4e8c\uff1a\u6267\u884c\u4ee5\u4e0b\u6062\u590d\u547d\u4ee4
./mo_br restore fb26fd88-41bc-11ee-93f8-acde48001122 --restore_dir filesystem --restore_path \"your_mopath\"\n
\u6062\u590d\u540e\u4f1a\u5728 matrixone \u751f\u6210\u65b0\u7684 mo-data \u6587\u4ef6
\u6b65\u9aa4\u4e09\uff1a\u542f\u52a8 mo
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_13","title":"\u6821\u9a8c\u5907\u4efd\u7684\u6821\u9a8c\u7801","text":"\u8bfb\u53d6\u5907\u4efd\u6587\u4ef6\u5939\u4e2d\u7684\u6bcf\u4e2a\u6587\u4ef6\u53ca\u5176 sha256 \u6587\u4ef6\u3002\u8ba1\u7b97\u6587\u4ef6\u7684 sha256 \u503c\u5e76\u4e0e sha256 \u6587\u4ef6\u503c\u5bf9\u6bd4\u3002sha256 \u6587\u4ef6\u662f\u5728\u6587\u4ef6\u521b\u5efa\u6216\u66f4\u65b0\u65f6\uff0c\u521b\u5efa\u7684\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_14","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br check ID\n //\u6821\u9a8c\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id string\n --backup_secret_access_key string\n --meta_path string \u6307\u5b9ameta\u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684mo_br.meta\u6587\u4ef6\u3002\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002mo_br check\n --backup_dir s3|filesystem \n //s3 \n --backup_endpoint\n --backup_access_key_id\n --backup_secret_access_key \n --backup_bucket\n --backup_filepath \n --backup_region \n --backup_compression\n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path\n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u5907\u4efd\u6240\u5728\u7684\u8def\u5f84\u7c7b\u578b\uff0c\u5728\u6ca1\u6709\u6307\u5b9a ID \u65f6\uff0c\u5fc5\u987b\u8981\u6307\u5b9a\u3002s3 \u6216 filesystem backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_15","title":"\u793a\u4f8b","text":"./mo_br check 1614f462-126c-11ef-9af3-26dd28356ef3\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| 1614f462-126c-11ef-9af3-26dd28356ef3 | 126 MB | BackupDir: filesystem Path: | 2024-05-15 11:34:28 +0800 | 22.455633916s | 2024-05-15 11:34:50 +0800 |\n| | | /Users/admin/soft/incbackup/back2 | | | |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n\nChecking the backup data...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\n...\n
(base) admin@admindeMacBook-Pro mo-backup % ./mo_br check --backup_dir filesystem --backup_path /Users/admin/soft/incbackup/back2\n2024/05/15 11:40:30.011160 +0800 INFO malloc/malloc.go:42 malloc {\"max buffer size\": 1073741824, \"num shards\": 16, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 23}\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\ncheck: config/log.toml_018f7a50-d30c-7ed0-85bc-191e9f1eb753\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#_16","title":"\u6700\u4f73\u5b9e\u8df5","text":"\u4e0b\u9762\u6211\u4eec\u5c06\u901a\u8fc7\u51e0\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u6765\u8bb2\u8ff0\u5982\u4f55\u4f7f\u7528 mo_br \u8fdb\u884c\u6570\u636e\u7684\u5907\u4efd\u4e0e\u8fd8\u539f
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#1","title":"\u793a\u4f8b 1 \u5168\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback1\"\n\nBackup ID\n 25536ff0-126f-11ef-9902-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| 25536ff0-126f-11ef-9902-26dd28356ef3 | 65 MB | BackupDir: filesystem Path: | 2024-05-15 11:56:44 +0800 | 8.648091083s | 2024-05-15 11:56:53 +0800 | 1715745404915410000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback1 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 25536ff0-126f-11ef-9902-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback1\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\nrestore tae file path ./mo-data/shared, parallelism 1, parallel count num: 1\nrestore file num: 1, total file num: 733, cost : 549\u00b5s\nCopy tae file 1\n 018f7a41-1881-7999-bbd6-858c3d4acc18_00000 => mo-data/shared/018f7a41-1881-7999-bbd6-858c3d4acc18_00000\n ... \n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-backup-restore/#2","title":"\u793a\u4f8b 2 \u589e\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\"\n\nBackup ID\n 2289638c-1284-11ef-85e4-26dd28356ef3\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\" --backup_type \"incremental\" --base_id \"2289638c-1284-11ef-85e4-26dd28356ef3\"\n\nBackup ID\n 81531c5a-1284-11ef-9ba3-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| 2289638c-1284-11ef-85e4-26dd28356ef3 | 70 MB | BackupDir: filesystem Path: | 2024-05-15 14:26:59 +0800 | 9.927034917s | 2024-05-15 14:27:09 +0800 | 1715754419668571000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n| 81531c5a-1284-11ef-9ba3-26dd28356ef3 | 72 MB | BackupDir: filesystem Path: | 2024-05-15 14:29:38 +0800 | 2.536263666s | 2024-05-15 14:29:41 +0800 | 1715754578690660000-1 | incremental |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n
\u5bf9\u6bd4\u589e\u91cf\u5907\u4efd\u548c\u5168\u91cf\u5907\u4efd\u7684\u7684\u8017\u65f6 (Duration)\uff0c\u53ef\u4ee5\u770b\u5230\u589e\u91cf\u5907\u4efd\u8017\u65f6\u8f83\u5c11\u3002
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 81531c5a-1284-11ef-9ba3-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\n2024/05/15 14:35:27.910925 +0800 INFO malloc/malloc.go:43 malloc {\"max buffer size\": 2147483648, \"num shards\": 8, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 22}\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback2\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\n...\n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/","title":"mo_br \u5e38\u89c4\u7269\u7406\u5907\u4efd\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#_1","title":"\u539f\u7406\u6982\u8ff0","text":"\u6570\u636e\u5e93\u5e38\u89c4\u7269\u7406\u5907\u4efd\u662f\u76f4\u63a5\u590d\u5236\u6570\u636e\u5e93\u7684\u7269\u7406\u5b58\u50a8\u6587\u4ef6\uff0c\u5305\u62ec\u6570\u636e\u6587\u4ef6\u3001\u65e5\u5fd7\u6587\u4ef6\u548c\u63a7\u5236\u6587\u4ef6\u7b49\uff0c\u4ee5\u521b\u5efa\u6570\u636e\u5e93\u7684\u4e00\u4e2a\u72ec\u7acb\u526f\u672c\u3002\u8fd9\u4e00\u8fc7\u7a0b\u901a\u5e38\u5728\u6587\u4ef6\u7cfb\u7edf\u7ea7\u522b\u8fdb\u884c\uff0c\u53ef\u4ee5\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7684\u547d\u4ee4\u5b9e\u73b0\uff0c\u751f\u6210\u7684\u5907\u4efd\u662f\u6570\u636e\u5e93\u7684\u5b8c\u6574\u5907\u4efd\uff0c\u5305\u542b\u4e86\u6240\u6709\u7684\u6570\u636e\u548c\u5bf9\u8c61\u3002\u5907\u4efd\u6587\u4ef6\u53ef\u4ee5\u5b58\u50a8\u5728\u591a\u79cd\u4ecb\u8d28\u4e0a\uff0c\u5e76\u53ef\u901a\u8fc7\u538b\u7f29\u548c\u52a0\u5bc6\u6765\u8282\u7701\u7a7a\u95f4\u548c\u63d0\u9ad8\u5b89\u5168\u6027\u3002\u5728\u6062\u590d\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06\u8fd9\u4e9b\u6587\u4ef6\u590d\u5236\u5230\u9700\u8981\u7684\u4f4d\u7f6e\uff0c\u4ece\u800c\u5feb\u901f\u5730\u6062\u590d\u6574\u4e2a\u6570\u636e\u5e93\u3002\u6b64\u5916\uff0c\u7269\u7406\u5907\u4efd\u652f\u6301\u8de8\u5e73\u53f0\u8fc1\u79fb\uff0c\u9002\u7528\u4e8e\u707e\u96be\u6062\u590d\u548c\u6570\u636e\u5e93\u8fc1\u79fb\u573a\u666f\uff0c\u4f46\u53ef\u80fd\u9700\u8981\u8f83\u591a\u7684\u5b58\u50a8\u7a7a\u95f4\u548c\u65f6\u95f4\u3002
\u5168\u91cf\u5907\u4efd\u662f\u6307\u5907\u4efd\u6570\u636e\u5e93\u4e2d\u6240\u6709\u6570\u636e\u7684\u5907\u4efd\u8fc7\u7a0b\u3002\u5b83\u521b\u5efa\u4e86\u4e00\u4e2a\u6570\u636e\u5e93\u7684\u5b8c\u6574\u526f\u672c\uff0c\u8fd9\u901a\u5e38\u9700\u8981\u66f4\u591a\u7684\u5b58\u50a8\u7a7a\u95f4\u548c\u66f4\u957f\u7684\u65f6\u95f4\u6765\u5b8c\u6210\u3002\u7531\u4e8e\u5305\u542b\u4e86\u6240\u6709\u6570\u636e\uff0c\u5168\u91cf\u5907\u4efd\u5728\u6062\u590d\u65f6\u8f83\u4e3a\u7b80\u5355\uff0c\u53ef\u4ee5\u76f4\u63a5\u6062\u590d\u5230\u5907\u4efd\u65f6\u7684\u72b6\u6001\u3002
\u589e\u91cf\u5907\u4efd\u662f\u6307\u5907\u4efd\u81ea\u4e0a\u6b21\u5907\u4efd\u4ee5\u6765\u53d1\u751f\u53d8\u5316\u7684\u6570\u636e\u3002\u5b83\u53ea\u590d\u5236\u5728\u4e24\u6b21\u5907\u4efd\u4e4b\u95f4\u6709\u4fee\u6539\u7684\u6570\u636e\u5757\u6216\u6570\u636e\u6587\u4ef6\uff0c\u56e0\u6b64\u5907\u4efd\u96c6\u901a\u5e38\u8f83\u5c0f\uff0c\u5907\u4efd\u901f\u5ea6\u8f83\u5feb\u3002\u589e\u91cf\u5907\u4efd\u53ef\u4ee5\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\u548c\u5907\u4efd\u65f6\u95f4\uff0c\u4f46\u5728\u6570\u636e\u6062\u590d\u65f6\u53ef\u80fd\u66f4\u590d\u6742\uff0c\u56e0\u4e3a\u9700\u8981\u4f9d\u6b21\u5e94\u7528\u4e00\u7cfb\u5217\u589e\u91cf\u5907\u4efd\u6765\u6062\u590d\u5230\u6700\u65b0\u72b6\u6001\u3002
MatrixOne \u652f\u6301\u4f7f\u7528 mo_br
\u8fdb\u884c\u589e\u91cf\u548c\u5168\u91cf\u7269\u7406\u5907\u4efd\u6062\u590d\uff1a
Note
mo_br \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#_2","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#1","title":"\u793a\u4f8b 1 \u5168\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback1\"\n\nBackup ID\n 25536ff0-126f-11ef-9902-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n| 25536ff0-126f-11ef-9902-26dd28356ef3 | 65 MB | BackupDir: filesystem Path: | 2024-05-15 11:56:44 +0800 | 8.648091083s | 2024-05-15 11:56:53 +0800 | 1715745404915410000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback1 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+------------+\n
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 25536ff0-126f-11ef-9902-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback1\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\nrestore tae file path ./mo-data/shared, parallelism 1, parallel count num: 1\nrestore file num: 1, total file num: 733, cost : 549\u00b5s\nCopy tae file 1\n 018f7a41-1881-7999-bbd6-858c3d4acc18_00000 => mo-data/shared/018f7a41-1881-7999-bbd6-858c3d4acc18_00000\n ... \n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-physical-backup-restore/#2","title":"\u793a\u4f8b 2 \u589e\u91cf\u5907\u4efd\u6062\u590d","text":"create database db1;\ncreate database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\"\n\nBackup ID\n 2289638c-1284-11ef-85e4-26dd28356ef3\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"/Users/admin/soft/backuppath/syncback2\" --backup_type \"incremental\" --base_id \"2289638c-1284-11ef-85e4-26dd28356ef3\"\n\nBackup ID\n 81531c5a-1284-11ef-9ba3-26dd28356ef3\n\n./mo_br list\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME | BACKUPTS | BACKUPTYPE |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n| 2289638c-1284-11ef-85e4-26dd28356ef3 | 70 MB | BackupDir: filesystem Path: | 2024-05-15 14:26:59 +0800 | 9.927034917s | 2024-05-15 14:27:09 +0800 | 1715754419668571000-1 | full |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n| 81531c5a-1284-11ef-9ba3-26dd28356ef3 | 72 MB | BackupDir: filesystem Path: | 2024-05-15 14:29:38 +0800 | 2.536263666s | 2024-05-15 14:29:41 +0800 | 1715754578690660000-1 | incremental |\n| | | /Users/admin/soft/backuppath/syncback2 | | | | | |\n+--------------------------------------+-------+----------------------------------------+---------------------------+--------------+---------------------------+-----------------------+-------------+\n
\u5bf9\u6bd4\u589e\u91cf\u5907\u4efd\u548c\u5168\u91cf\u5907\u4efd\u7684\u7684\u8017\u65f6 (Duration)\uff0c\u53ef\u4ee5\u770b\u5230\u589e\u91cf\u5907\u4efd\u8017\u65f6\u8f83\u5c11\u3002
drop database db1;\ncreate database db3;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db2 |\n| db3 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
mo_ctl stop\nrm -rf /Users/admin/soft/matrixone/mo-data\n\n./mo_br restore 81531c5a-1284-11ef-9ba3-26dd28356ef3 --restore_dir filesystem --restore_path \"/Users/admin/soft/matrixone\"\n2024/05/15 14:35:27.910925 +0800 INFO malloc/malloc.go:43 malloc {\"max buffer size\": 2147483648, \"num shards\": 8, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 22}\nFrom:\n BackupDir: filesystem\n Path: /Users/admin/soft/backuppath/syncback2\n\nTo\n BackupDir: filesystem\n Path: /Users/admin/soft/matrixone\n\nTaePath\n ./mo-data/shared\n...\n
mo_ctl start\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n9 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6062\u590d\u6210\u529f\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/","title":"mo_br \u5de5\u5177\u8fdb\u884c\u5feb\u7167\u5907\u4efd\u6062\u590d","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#_1","title":"\u5feb\u7167\u5907\u4efd\u6062\u590d\u5b9e\u73b0\u539f\u7406","text":"\u6570\u636e\u5e93\u5feb\u7167\u5907\u4efd\u6062\u590d\u901a\u8fc7\u521b\u5efa\u6570\u636e\u5e93\u5728\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u53ea\u8bfb\u9759\u6001\u89c6\u56fe\uff0c\u8fd9\u4e2a\u89c6\u56fe\u88ab\u79f0\u4e3a\u5feb\u7167\u3002\u5feb\u7167\u5229\u7528\u5b58\u50a8\u7cfb\u7edf\u7684\u5199\u65f6\u590d\u5236\uff08COW\uff09\u6280\u672f\uff0c\u4ec5\u5728\u539f\u59cb\u6570\u636e\u9875\u88ab\u4fee\u6539\u524d\u590d\u5236\u5e76\u5b58\u50a8\u8be5\u9875\uff0c\u4ece\u800c\u751f\u6210\u6570\u636e\u5e93\u5728\u5feb\u7167\u521b\u5efa\u65f6\u523b\u7684\u72b6\u6001\u526f\u672c\u3002\u5728\u9700\u8981\u6062\u590d\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u9009\u53d6\u5feb\u7167\u4e2d\u7684\u6570\u636e\u5e76\u5c06\u5176\u590d\u5236\u6216\u6062\u590d\u5230\u65b0\u7684\u6216\u73b0\u6709\u7684\u6570\u636e\u5e93\u4e2d\u3002\u5feb\u7167\u6587\u4ef6\u6700\u521d\u5f88\u5c0f\uff0c\u968f\u7740\u6e90\u6570\u636e\u5e93\u7684\u66f4\u6539\u800c\u9010\u6e10\u589e\u957f\uff0c\u56e0\u6b64\u9700\u8981\u76d1\u63a7\u5176\u5927\u5c0f\u5e76\u5728\u5fc5\u8981\u65f6\u8fdb\u884c\u7ba1\u7406\u3002\u5feb\u7167\u5fc5\u987b\u4e0e\u6e90\u6570\u636e\u5e93\u4f4d\u4e8e\u540c\u4e00\u670d\u52a1\u5668\u5b9e\u4f8b\uff0c\u5e76\u4e14\u7531\u4e8e\u5b83\u4eec\u662f\u53ea\u8bfb\u7684\uff0c\u4e0d\u80fd\u76f4\u63a5\u5728\u5176\u4e0a\u8fdb\u884c\u5199\u64cd\u4f5c\u3002\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5feb\u7167\u6062\u590d\u64cd\u4f5c\u4f1a\u8986\u76d6\u5f53\u524d\u6570\u636e\uff0c\u56e0\u6b64\u9700\u8981\u8c28\u614e\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#_2","title":"\u5e94\u7528\u573a\u666f","text":"\u6570\u636e\u5e93\u5feb\u7167\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5728\u591a\u79cd\u573a\u666f\u4e0b\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u53ef\u7528\u6027\u548c\u6027\u80fd\u3002\u4ee5\u4e0b\u4e3a\u5feb\u7167\u7684\u4e00\u4e9b\u5e94\u7528\u573a\u666f\uff1a
\u6570\u636e\u5907\u4efd\u4e0e\u6062\u590d\uff1a\u5feb\u7167\u53ef\u4ee5\u4f5c\u4e3a\u6570\u636e\u5e93\u5907\u4efd\u7684\u4e00\u79cd\u65b9\u5f0f\uff0c\u5b83\u5141\u8bb8\u5728\u4e0d\u505c\u6b62\u6570\u636e\u5e93\u670d\u52a1\u7684\u60c5\u51b5\u4e0b\u521b\u5efa\u6570\u636e\u5e93\u7684\u53ea\u8bfb\u526f\u672c\uff0c\u7528\u4e8e\u6570\u636e\u5907\u4efd\u548c\u6062\u590d\u3002
\u62a5\u8868\u548c\u6570\u636e\u5206\u6790\uff1a\u5728\u9700\u8981\u6570\u636e\u5e93\u4fdd\u6301\u9759\u6001\u72b6\u6001\u8fdb\u884c\u62a5\u8868\u751f\u6210\u6216\u6570\u636e\u5206\u6790\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5feb\u7167\u6765\u907f\u514d\u5f71\u54cd\u5728\u7ebf\u4e8b\u52a1\u5904\u7406\u3002
\u5f00\u53d1\u548c\u6d4b\u8bd5\uff1a\u5728\u5f00\u53d1\u65b0\u529f\u80fd\u6216\u6d4b\u8bd5\u7cfb\u7edf\u524d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5feb\u7167\u521b\u5efa\u6570\u636e\u5e93\u7684\u4e00\u4e2a\u526f\u672c\uff0c\u4ee5\u4fbf\u6d4b\u8bd5\u53ef\u4ee5\u5728\u4e0d\u5f71\u54cd\u751f\u4ea7\u73af\u5883\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u3002
\u6570\u636e\u8fc1\u79fb\uff1a\u5728\u6570\u636e\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5feb\u7167\u6765\u786e\u4fdd\u6570\u636e\u7684\u4e00\u81f4\u6027\uff0c\u907f\u514d\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u7684\u6570\u636e\u53d8\u66f4\u3002
\u9ad8\u5371\u64cd\u4f5c\u4fdd\u62a4\uff1a\u5728\u6267\u884c\u53ef\u80fd\u5bf9\u6570\u636e\u5e93\u7a33\u5b9a\u6027\u9020\u6210\u5f71\u54cd\u7684\u64cd\u4f5c\uff08\u5982\u6570\u636e\u5e93\u5347\u7ea7\u3001\u7ed3\u6784\u53d8\u66f4\u7b49\uff09\u4e4b\u524d\uff0c\u53ef\u4ee5\u521b\u5efa\u5feb\u7167\uff0c\u4ee5\u4fbf\u5728\u64cd\u4f5c\u5931\u8d25\u65f6\u80fd\u591f\u5feb\u901f\u6062\u590d\u3002
MatrixOne \u652f\u6301\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u8fdb\u884c\u79df\u6237\u7ea7\u522b\u7684\u5feb\u7167\u5907\u4efd\u6062\u590d\uff1a
\u672c\u7bc7\u6587\u6863\u4e3b\u8981\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 mo_br
\u8fdb\u884c\u79df\u6237\u7ea7\u522b\u5feb\u7167\u5907\u4efd\u6062\u590d\u3002
Note
mo_br \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#_3","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne
\u5df2\u5b8c\u6210 mo_br \u5de5\u5177\u90e8\u7f72
create db if not exists snapshot_read;\nuse snapshot_read;\ncreate table test_snapshot_read (a int);\nINSERT INTO test_snapshot_read (a) VALUES(1), (2), (3), (4), (5),(6), (7), (8), (9), (10), (11), (12),(13), (14), (15), (16), (17), (18), (19), (20),(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),(31), (32), (33), (34), (35), (36), (37), (38), (39), (40),(41), (42), (43), (44), (45), (46), (47), (48), (49), (50),(51), (52), (53), (54), (55), (56), (57), (58), (59), (60),(61), (62), (63), (64), (65), (66), (67), (68), (69), (70),(71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90),(91), (92), (93), (94), (95), (96), (97), (98), (99), (100);\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"sp_01\" --account \"sys\" \n\n./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsp_01 2024-05-10 02:06:08.01635 account sys \n
delete from snapshot_read.test_snapshot_read where a <= 50;\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 50 |\n+----------+\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --table \"test_snapshot_read\" --sname \"sp_01\"\n
mysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#2","title":"\u793a\u4f8b 2 \u6570\u636e\u5e93\u7ea7\u522b\u6062\u590d","text":"create db if not exists snapshot_read;\nuse snapshot_read;\ncreate table test_snapshot_read (a int);\nINSERT INTO test_snapshot_read (a) VALUES(1), (2), (3), (4), (5),(6), (7), (8), (9), (10), (11), (12),(13), (14), (15), (16), (17), (18), (19), (20),(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),(31), (32), (33), (34), (35), (36), (37), (38), (39), (40),(41), (42), (43), (44), (45), (46), (47), (48), (49), (50),(51), (52), (53), (54), (55), (56), (57), (58), (59), (60),(61), (62), (63), (64), (65), (66), (67), (68), (69), (70),(71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90),(91), (92), (93), (94), (95), (96), (97), (98), (99), (100);\ncreate table test_snapshot_read_1(a int);\nINSERT INTO test_snapshot_read_1 (a) VALUES(1), (2), (3), (4), (5),(6), (7), (8), (9), (10), (11), (12),(13), (14), (15), (16), (17), (18), (19), (20),(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),(31), (32), (33), (34), (35), (36), (37), (38), (39), (40),(41), (42), (43), (44), (45), (46), (47), (48), (49), (50),(51), (52), (53), (54), (55), (56), (57), (58), (59), (60),(61), (62), (63), (64), (65), (66), (67), (68), (69), (70),(71), (72), (73), (74), (75), (76), (77), (78), (79), (80), (81), (82), (83), (84), (85), (86), (87), (88), (89), (90),(91), (92), (93), (94), (95), (96), (97), (98), (99), (100);\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 200 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from snapshot_read.test_snapshot_read_1;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n1 row in set (0.01 sec)\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"sp_02\" --account \"sys\"\n\n./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsp_02 2024-05-10 02:47:15.638519 account sys \n
delete from snapshot_read.test_snapshot_read where a <= 50;\ndelete from snapshot_read.test_snapshot_read_1 where a >= 50;\n\nmysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from snapshot_read.test_snapshot_read_1;\n+----------+\n| count(*) |\n+----------+\n| 49 |\n+----------+\n1 row in set (0.01 sec)\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --sname \"sp_02\"\n
mysql> select count(*) from snapshot_read.test_snapshot_read;\n+----------+\n| count(*) |\n+----------+\n| 200 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from snapshot_read.test_snapshot_read_1;\n+----------+\n| count(*) |\n+----------+\n| 100 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr-snapshot-backup-restore/#3","title":"\u793a\u4f8b 3 \u79df\u6237\u7ea7\u522b\u6062\u590d","text":"\u79df\u6237\u7ea7\u522b\u6062\u590d
create database if not exists snapshot_read;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| snapshot_read |\n| system |\n| system_metrics |\n+--------------------+\n8 rows in set (0.00 sec)\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"sp_03\" --account \"sys\"\n\n./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsp_03 2024-05-11 03:20:16.065685 account sys \n
drop database snapshot_read;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.01 sec)\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\" --new_account \"acc2\" --new_admin_name \"admin\" --new_admin_password \"111\";\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mo_debug |\n| mo_task |\n| mysql |\n| snapshot_read |\n| system |\n| system_metrics |\n+--------------------+\n8 rows in set (0.00 sec)\n
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| snapshot_read |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/","title":"mo_br \u5907\u4efd\u4e0e\u6062\u590d","text":"\u6570\u636e\u5e93\u7269\u7406\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u662f\u4e24\u79cd\u91cd\u8981\u7684\u6570\u636e\u4fdd\u62a4\u7b56\u7565\uff0c\u5b83\u4eec\u5728\u5f88\u591a\u573a\u666f\u4e0b\u90fd\u53d1\u6325\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002\u7269\u7406\u5907\u4efd\u901a\u8fc7\u590d\u5236\u6570\u636e\u5e93\u7684\u7269\u7406\u6587\u4ef6\uff0c\u5982\u6570\u636e\u6587\u4ef6\u548c\u65e5\u5fd7\u6587\u4ef6\uff0c\u80fd\u591f\u5b9e\u73b0\u5feb\u901f\u548c\u5b8c\u6574\u7684\u6570\u636e\u5e93\u6062\u590d\uff0c\u7279\u522b\u9002\u5408\u4e8e\u6570\u636e\u5e93\u6574\u4f53\u8fc1\u79fb\u6216\u707e\u96be\u6062\u590d\u7684\u60c5\u51b5\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u5feb\u7167\u5907\u4efd\u901a\u8fc7\u8bb0\u5f55\u6570\u636e\u5728\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u72b6\u6001\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u5feb\u901f\u4e14\u5b58\u50a8\u6548\u7387\u9ad8\u7684\u5907\u4efd\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u9700\u8981\u8fdb\u884c\u65f6\u95f4\u70b9\u6062\u590d\u6216\u53ea\u8bfb\u67e5\u8be2\u64cd\u4f5c\u7684\u573a\u666f\uff0c\u5982\u751f\u6210\u62a5\u544a\u6216\u8fdb\u884c\u6570\u636e\u5206\u6790\u3002\u7269\u7406\u5907\u4efd\u7684\u6062\u590d\u53ef\u80fd\u9700\u8981\u8f83\u957f\u65f6\u95f4\uff0c\u800c\u5feb\u7167\u5907\u4efd\u5219\u53ef\u4ee5\u63d0\u4f9b\u5feb\u901f\u7684\u6570\u636e\u8bbf\u95ee\uff0c\u4e24\u8005\u7ed3\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u4e3a\u6570\u636e\u5e93\u63d0\u4f9b\u5168\u9762\u7684\u4fdd\u62a4\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002
MatrixOne \u652f\u6301\u901a\u8fc7 mo_br
\u5b9e\u7528\u5de5\u5177\u8fdb\u884c\u5e38\u89c4\u7269\u7406\u5907\u4efd\u548c\u5feb\u7167\u5907\u4efd\u3002\u672c\u7ae0\u8282\u5c06\u4ecb\u7ecd mo_br
\u7684\u4f7f\u7528\u65b9\u6cd5\u3002
Note
mo_br \u4f01\u4e1a\u7ea7\u670d\u52a1\u7684\u7269\u7406\u5907\u4efd\u4e0e\u6062\u590d\u5de5\u5177\uff0c\u4f60\u9700\u8981\u8054\u7cfb\u4f60\u7684 MatrixOne \u5ba2\u6237\u7ecf\u7406\uff0c\u83b7\u53d6\u5de5\u5177\u4e0b\u8f7d\u8def\u5f84\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_1","title":"\u53c2\u8003\u547d\u4ee4\u6307\u5357","text":"help - \u6253\u5370\u53c2\u8003\u6307\u5357
./mo_br help\nthe backup and restore tool for the matrixone\n\nUsage:\n mo_br [flags]\n mo_br [command]\n\nAvailable Commands:\n backup backup the matrixone data\n check check the backup\n completion Generate the autocompletion script for the specified shell\n delete delete the backup\n help Help about any command\n list search the backup\n restore restore the matrixone data\n snapshot Manage snapshots\n\nFlags:\n --config string config file (default \"./mo_br.toml\")\n -h, --help help for mo_br\n --log_file string log file (default \"console\")\n --log_level string log level (default \"error\")\n\nUse \"mo_br [command] --help\" for more information about a command.\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_2","title":"\u7269\u7406\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_3","title":"\u521b\u5efa\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_4","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br backup\n --host\n --port \n --user \n --password \n --backup_dir s3|filesystem \n //s3 oss minio\n --endpoint\n --access_key_id \n --secret_access_key \n --bucket \n --filepath\n --region \n --compression \n --role_arn \n --is_minio\n --parallelism \n //filesystem\n --path\n --parallelism\n --meta_path \n //\u589e\u91cf\u5907\u4efd\u9700\u8981\n --backup_type\n --base_id\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 backup_dir \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002s3 \u6216 filesystem endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5230 s3 \u7684\u670d\u52a1\u7684 URL access_key_id \u5907\u4efd\u5230 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230 s3 \u7684 Secret access key bucket \u5907\u4efd\u5230\u7684 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u5907\u4efd\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 region \u5907\u4efd\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df compression \u5907\u4efd\u5230 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 role_arn \u5907\u4efd\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 is_minio \u6307\u5b9a\u5907\u4efd\u5230\u7684 s3 \u662f\u5426\u4e3a minio path \u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u8def\u5f84 parallelism \u5e76\u884c\u5ea6 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 backup_type \u6307\u5b9a\u5907\u4efd\u7c7b\u578b\u4e3a\u589e\u91cf\u5907\u4efd\uff0cincremental\u3002 base_id \u4e0a\u6b21\u4e00\u6b21\u5907\u4efd\u7684 ID\uff0c\u4e3b\u8981\u7528\u4e8e\u786e\u5b9a\u4e0a\u6b21\u5907\u4efd\u7684\u65f6\u95f4\u6233\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_5","title":"\u793a\u4f8b","text":"./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\"\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"s3\" --endpoint \"http://127.0.0.1:9000\" --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\" --bucket \"bucket1\" --filepath \"/backup1\" --is_minio\n
./mo_br backup --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --backup_dir \"filesystem\" --path \"yourpath\" --backup_type \"incremental\" --base_id \"xxx\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_6","title":"\u67e5\u770b\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_7","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br list\n -- ID\n //\u8981\u67e5\u8be2\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key \n --not_check_data \n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_check_data \u53ea\u67e5\u770b meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u67e5\u770b\u5907\u4efd\u6570\u636e\u3002\u9ed8\u8ba4\u4e0d\u5e26\u8fd9\u4e2a\u53c2\u6570\u7684\uff0c\u5c31\u662f\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u3002\u5f53\u524d\u53ea\u4f1a\u68c0\u67e5\u5907\u4efd\u7684\u6587\u4ef6\u662f\u5426\u5b58\u5728\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_8","title":"\u793a\u4f8b","text":"./mo_br list\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n| 01108122-10f9-11ef-9359-26dd28356ef2 | 8.3 MB | BackupDir: filesystem Path: | 2024-05-13 15:18:28 +0800 | 3.394437375s | 2024-05-13 15:18:32 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n
./mo_br list 4d21b228-10dd-11ef-9497-26dd28356ef2\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n| 4d21b228-10dd-11ef-9497-26dd28356ef2 | 586 kB | BackupDir: filesystem Path: | 2024-05-13 12:00:12 +0800 | 1.700945333s | 2024-05-13 12:00:13 +0800 |\n| | | /Users/admin/soft/backup | | | |\n+--------------------------------------+--------+--------------------------------+---------------------------+--------------+---------------------------+\n\nChecking the backup data(currently,no checksum)...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/log.toml_018f70d1-3100-7762-b28b-8f85ac4ed3cd\ncheck: config/tn.toml_018f70d1-310e-78fc-ac96-aa5e06981bd7\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_9","title":"\u5220\u9664\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_10","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br delete ID \n //\u8981\u5220\u9664\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --access_key_id \n --secret_access_key\n --not_delete_data\n --meta_path\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u5220\u9664\u7684\u5907\u4efd\u7684 ID access_key_id \u5907\u4efd\u5230\u7684 s3 \u7684 Access key ID secret_access_key \u5907\u4efd\u5230\u7684 s3 \u7684 Secret access key not_delete_data \u53ea\u5220\u9664 meta \u4e2d\u7684\u4fe1\u606f\u3002\u4e0d\u5220\u9664\u5907\u4efd\u6570\u636e\u3002 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_11","title":"\u793a\u4f8b","text":"./mo_br delete e4cade26-3139-11ee-8631-acde48001122\n
./mo_br delete e4cade26-3139-11ee-8631-acde48001122 --access_key_id \"S0kwLuB4JofVEIAxWTqf\" --secret_access_key \"X24O7t3hccmqUZqvqvmLN8464E2Nbr0DWOu9Qs5A\"\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_12","title":"\u6062\u590d\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_13","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br restore ID\n //\u8bfb\u53d6\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id\n --backup_secret_access_key \n\n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath \n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e ID \u8981\u6062\u590d\u7684 ID backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730\u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6//\u6062\u590d\u3002\nmo_br restore\n --backup_dir s3|filesystem \u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u5907\u4efd\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --backup_endpoint \n --backup_access_key_id \n --backup_secret_access_key\n --backup_bucket\n --backup_filepath\n --backup_region \n --backup_compression \n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path \n //\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84 restore_directory\n --restore_dir s3|filesystem \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002\n //s3 \n --restore_endpoint \n --restore_access_key_id \n --restore_secret_access_key \n --restore_bucket \n --restore_filepath\n --restore_region \n --restore_compression \n --restore_role_arn \n --restore_is_minio\n //filesystem\n --restore_path \n --dn_config_path \n --meta_path \n --checksum\n --parallelism\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 restore_dir \u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u7c7b\u578b\u3002\u6307\u5b9a\u6062\u590d\u7684\u76ee\u6807\u8def\u5f84\u65f6\u4f7f\u7528\u3002s3 \u6216 filesystem restore_endpoint \u8fde\u63a5\u5230\u6062\u590d\u5230 S3 \u670d\u52a1\u7684 URL restore_access_key_id \u6062\u590d\u5230 s3 \u7684 Access key ID restore_secret_access_key \u6062\u590d\u5230 s3 \u7684 Secret access key restore_bucket \u6062\u590d\u5230 s3 \u9700\u8981\u8bbf\u95ee\u7684\u6876 restore_filepath \u6062\u590d\u5230 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 restore_region \u6062\u590d\u5230 s3 \u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u533a\u57df restore_compression \u6062\u590d\u5230 s3 \u7684 S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 restore_role_arn \u6062\u590d\u5230 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 restore_is_minio \u6307\u5b9a\u6062\u590d\u5230\u7684 s3 \u662f\u5426\u662f minio restore_path \u6062\u590d\u5230\u672c\u5730 matrixone \u7684\u8def\u5f84 dn_config_path dn \u914d\u7f6e\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002 checksum \u6062\u590d\u7684\u65f6\u5019 tae \u6587\u4ef6\u590d\u5236\u7684\u5e76\u884c\u5ea6\uff0c\u9ed8\u8ba4\u662f 1 parallelism \u5e76\u884c\u5ea6"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_14","title":"\u793a\u4f8b","text":"\u4ece\u6587\u4ef6\u7cfb\u7edf\u6062\u590d\u5230\u6587\u4ef6\u7cfb\u7edf
\u6b65\u9aa4\u4e00\uff1a\u505c\u6b62 mo\uff0c\u5220\u9664 mo-data
\u6b65\u9aa4\u4e8c\uff1a\u6267\u884c\u4ee5\u4e0b\u6062\u590d\u547d\u4ee4
./mo_br restore fb26fd88-41bc-11ee-93f8-acde48001122 --restore_dir filesystem --restore_path \"your_mopath\"\n
\u6062\u590d\u540e\u4f1a\u5728 matrixone \u751f\u6210\u65b0\u7684 mo-data \u6587\u4ef6
\u6b65\u9aa4\u4e09\uff1a\u542f\u52a8 mo
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_15","title":"\u6821\u9a8c\u5907\u4efd\u7684\u6821\u9a8c\u7801","text":"\u8bfb\u53d6\u5907\u4efd\u6587\u4ef6\u5939\u4e2d\u7684\u6bcf\u4e2a\u6587\u4ef6\u53ca\u5176 sha256 \u6587\u4ef6\u3002\u8ba1\u7b97\u6587\u4ef6\u7684 sha256 \u503c\u5e76\u4e0e sha256 \u6587\u4ef6\u503c\u5bf9\u6bd4\u3002sha256 \u6587\u4ef6\u662f\u5728\u6587\u4ef6\u521b\u5efa\u6216\u66f4\u65b0\u65f6\uff0c\u521b\u5efa\u7684\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_16","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br check ID\n //\u6821\u9a8c\u6307\u5b9aID\u7684\u5907\u4efd\u6570\u636e\u3002\u5982\u679c\u5907\u4efd\u5728s3(oss minio)\u4e0a\u65f6\uff0c\u9700\u8981\u6307\u5b9a\n --backup_access_key_id string\n --backup_secret_access_key string\n --meta_path string \u6307\u5b9ameta\u6587\u4ef6\u4f4d\u7f6e\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684mo_br.meta\u6587\u4ef6\u3002\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002mo_br check\n --backup_dir s3|filesystem \n //s3 \n --backup_endpoint\n --backup_access_key_id\n --backup_secret_access_key \n --backup_bucket\n --backup_filepath \n --backup_region \n --backup_compression\n --backup_role_arn \n --backup_is_minio\n //filesystem\n --backup_path\n --meta_path \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e backup_dir \u5907\u4efd\u6240\u5728\u7684\u8def\u5f84\u7c7b\u578b\uff0c\u5728\u6ca1\u6709\u6307\u5b9a ID \u65f6\uff0c\u5fc5\u987b\u8981\u6307\u5b9a\u3002s3 \u6216 filesystem backup_endpoint \u8fde\u63a5\u5230\u5907\u4efd\u5728 s3 \u7684\u7684 URL backup_access_key_id \u5907\u4efd\u5728 s3 \u7684 Access key ID backup_secret_access_key \u5907\u4efd\u5728 s3 \u7684 Secret access key backup_bucket \u5907\u4efd\u5728 s3 \u7684\u6876 backup_filepath \u5907\u4efd\u5728 s3 \u7684\u76f8\u5bf9\u6587\u4ef6\u8def\u5f84 backup_region \u5907\u4efd\u5728 s3 \u7684\u670d\u52a1\u533a\u57df backup_compression \u5907\u4efd\u5728 s3 \u7684\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\u3002 backup_role_arn \u5907\u4efd\u5728 s3 \u7684\u89d2\u8272\u7684\u8d44\u6e90\u540d\u79f0\u3002 backup_is_minio \u6307\u5b9a\u5907\u4efd\u7684 s3 \u662f\u5426\u662f minio backup_path \u672c\u5730\u5907\u4efd\u7684\u8def\u5f84 meta_path \u6307\u5b9a meta \u6587\u4ef6\u4f4d\u7f6e\u3002\u53ea\u80fd\u662f\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u8def\u5f84\u3002\u5982\u679c\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u662f\u540c\u4e00\u76ee\u5f55\u4e0b\u7684 mo_br.meta \u6587\u4ef6\u3002"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_17","title":"\u793a\u4f8b","text":"./mo_br check 1614f462-126c-11ef-9af3-26dd28356ef3\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| ID | SIZE | PATH | AT TIME | DURATION | COMPLETE TIME |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n| 1614f462-126c-11ef-9af3-26dd28356ef3 | 126 MB | BackupDir: filesystem Path: | 2024-05-15 11:34:28 +0800 | 22.455633916s | 2024-05-15 11:34:50 +0800 |\n| | | /Users/admin/soft/incbackup/back2 | | | |\n+--------------------------------------+--------+-----------------------------------+---------------------------+---------------+---------------------------+\n\nChecking the backup data...\n\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\n...\n
(base) admin@admindeMacBook-Pro mo-backup % ./mo_br check --backup_dir filesystem --backup_path /Users/admin/soft/incbackup/back2\n2024/05/15 11:40:30.011160 +0800 INFO malloc/malloc.go:42 malloc {\"max buffer size\": 1073741824, \"num shards\": 16, \"classes\": 23, \"min class size\": 128, \"max class size\": 1048576, \"buffer objects per class\": 23}\ncheck: /backup_meta\ncheck: /mo_meta\ncheck: hakeeper/hk_data\ncheck: tae/tae_list\ncheck: tae/tae_sum\ncheck: config/launch.toml_018f7a50-d300-7017-8580-150edf08733e\ncheck: config/log.toml_018f7a50-d30c-7ed0-85bc-191e9f1eb753\n...\n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_18","title":"\u5feb\u7167\u5907\u4efd","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_19","title":"\u521b\u5efa\u5feb\u7167","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_20","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br snapshot create\n --host\n --port \n --user\n --password \n --level \n --account \n --sname \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 level \u5feb\u7167\u5907\u4efd\u7684\u8303\u56f4\uff0c\u6682\u53ea\u652f\u6301 account account \u5feb\u7167\u5907\u4efd\u7684\u79df\u6237\u5bf9\u8c61\u540d sname \u5feb\u7167\u540d\u79f0"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_21","title":"\u793a\u4f8b","text":"./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"snapshot_01\" --account \"sys\"\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --level \"account\" --sname \"snapshot_02\" --account \"acc1\" \n
\u666e\u901a\u79df\u6237\u521b\u5efa\u5feb\u7167\uff1a
create account acc1 admin_name admin IDENTIFIED BY '111';\n
./mo_br snapshot create --host \"127.0.0.1\" --port 6001 --user \"acc1#admin\" --password \"111\" --level \"account\" --account \"acc1\" --sname \"snapshot_03\"\n
mo_br snapshot show\n --host\n --port \n --user \n --password \n --account \n --db \n --table \n --sname \n --beginTs \n --endTs\n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 account \u8981\u7b5b\u9009\u7684\u79df\u6237\u540d\uff0c\u4ec5\u9650 sys \u7ba1\u7406\u5458\u4f7f\u7528 db \u8981\u7b5b\u9009\u7684\u6570\u636e\u5e93\u540d table \u8981\u7b5b\u9009\u7684\u8868\u540d sname \u8981\u7b5b\u9009\u7684\u5feb\u7167\u540d\u79f0 beginTs \u8981\u7b5b\u9009\u7684\u5feb\u7167\u65f6\u95f4\u6233\u7684\u5f00\u59cb\u65f6\u95f4 endTs \u8981\u7b5b\u9009\u7684\u5feb\u7167\u65f6\u95f4\u6233\u7684\u7ed3\u675f\u65f6\u95f4"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_24","title":"\u793a\u4f8b","text":"./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsnapshot_02 2024-05-11 02:29:23.07401 account acc1 \nsnapshot_01 2024-05-11 02:26:03.462462 account sys \n
./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"acc1#admin\" --password \"111\"\nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsnapshot_03 2024-05-11 02:29:31.572512 account acc1 \n
./mo_br snapshot show --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"acc1\" --beginTs \"2024-05-11 00:00:00\" \nSNAPSHOT NAME TIMESTAMP SNAPSHOT LEVEL ACCOUNT NAME DATABASE NAME TABLE NAME \nsnapshot_02 2024-05-11 02:29:23.07401 account acc1 \n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_25","title":"\u5220\u9664\u5feb\u7167","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_26","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br snapshot drop\n --host\n --port \n --user \n --password \n --sname \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 sname \u8981\u7b5b\u9009\u7684\u5feb\u7167\u540d\u79f0"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_27","title":"\u793a\u4f8b","text":"./mo_br snapshot drop --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --sname \"snapshot_01\"\n
./mo_br snapshot drop --host \"127.0.0.1\" --port 6001 --user \"acc1#admin\" --password \"111\" --sname \"snapshot_03\" \n
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_28","title":"\u6062\u590d\u5feb\u7167","text":""},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_29","title":"\u8bed\u6cd5\u7ed3\u6784","text":"mo_br snapshot restore\n --host \n --port \n --user \n --password \n --sname \n --account \n --db \n --table \n --newaccount \n --newaccountadmin \n --newaccountpwd \n
\u53c2\u6570\u8bf4\u660e
\u53c2\u6570 \u8bf4\u660e host \u76ee\u6807 MatrixOne \u7684 IP port \u7aef\u53e3\u53f7 user \u7528\u6237 password \u7528\u6237\u7684\u5bc6\u7801 sname \u8981\u6062\u590d\u7684\u5feb\u7167\u540d\u79f0 account \u8981\u6062\u590d\u7684\u79df\u6237\u540d\uff0c\u4ec5\u9650 sys \u7ba1\u7406\u5458\u4f7f\u7528 db \u8981\u6062\u590d\u7684\u6570\u636e\u5e93\u540d table \u8981\u6062\u590d\u7684\u8868\u540d newaccount \u65b0\u521b\u5efa\u7684\u79df\u6237\u540d newaccountadmin \u79df\u6237\u7ba1\u7406\u5458 newaccountpwd \u79df\u6237\u7ba1\u7406\u5458\u5bc6\u7801NOTE: \u53ea\u6709\u7cfb\u7edf\u79df\u6237\u624d\u53ef\u4ee5\u6267\u884c\u6062\u590d\u6570\u636e\u5230\u65b0\u79df\u6237\uff0c\u4e14\u53ea\u5141\u8bb8\u79df\u6237\u7ea7\u522b\u7684\u6062\u590d\u3002
"},{"location":"MatrixOne/Maintain/backup-restore/mobr-backup-restore/mobr/#_30","title":"\u793a\u4f8b","text":"./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --table \"test_snapshot_read\" --sname \"sp_01\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --db \"snapshot_read\" --sname \"sp_02\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\"\n
./mo_br snapshot restore --host \"127.0.0.1\" --port 6001 --user \"dump\" --password \"111\" --account \"sys\" --sname \"sp_03\" --new_account \"acc2\" --new_admin_name \"admin\" --new_admin_password \"111\";\n
"},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/","title":"\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
MatrixOne \u4fdd\u6301\u4e86\u5bf9 MySQL \u8bed\u6cd5\u7684\u9ad8\u5ea6\u517c\u5bb9\uff0c\u56e0\u6b64\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u65e0\u9700\u5176\u4ed6\u64cd\u4f5c\uff0c\u53ef\u5b9e\u73b0\u65e0\u7f1d\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e2d\uff0c\u6570\u636e\u7c7b\u578b\u5728\u4fdd\u6301\u4e0e MySQL \u547d\u540d\u4e00\u81f4\u7684\u60c5\u51b5\u4e0b\uff0c\u5728\u7cbe\u5ea6\u4e0e\u8303\u56f4\u4e0a\uff0c\u4e0e MySQL \u5b58\u5728\u6709\u7740\u7ec6\u5fae\u7684\u5dee\u5f02\uff0c\u5177\u4f53\u53ef\u53c2\u89c1\u6570\u636e\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-mysql-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece MySQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL \u70b9\u51fb\u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a tpch_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u8fde\u63a5 MatrixOne\uff0c\u5e76\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
\u6253\u5f00 DBeaver\uff0c\u4ece MySQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
mysqldump
\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089\u5982\u4f55\u4f7f\u7528 mysqldump
\uff0c\u53ef\u53c2\u89c1 mysqldump \u6559\u7a0b\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece MySQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece MySQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a tpch_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/tpch_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u4f7f\u7528 mysqldump
\u5c06 MySQL \u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\u6587\u4ef6\u3002\u8bf7\u786e\u4fdd\u4f60\u5bf9 filepath \u8def\u5f84\u5177\u6709\u5199\u6743\u9650\uff0c\u5e76\u68c0\u67e5 secure_file_priv
\u914d\u7f6e\uff1a
mysqldump -u root -p -t -T /{filepath} tpch --fields-terminated-by='|'\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 mysqldump
\u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 mysqldump
\u5bfc\u51fa\u6570\u636e\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u5c3d\u91cf\u5927\uff0cnet_buffer_length
\u8fd9\u4e2a\u53c2\u6570\u5c3d\u91cf\u5728 10mb \u8d77\u6b65\uff1a
mysqldump -t tpch -uroot -p --net_buffer_length=10m > tpch_data.sql\n
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff0c\u671f\u95f4\u4f1a\u6709\u62a5\u9519\u4fe1\u606f\uff0c\u4f46\u662f\u4e0d\u5f71\u54cd\u6570\u636e\u7684\u63d2\u5165\uff1a
source '/YOUR_PATH/tpch_data.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u5982\u679c\u4f60\u662f\u65b0\u624b\uff0c\u60f3\u5c1d\u8bd5\u8fc1\u79fb\u5c0f\u6570\u636e\u91cf\u7684\u6570\u636e\uff0c\u53ef\u53c2\u89c1\u4f7f\u7528 source
\u547d\u4ee4\u6279\u91cf\u5bfc\u5165\u6570\u636e\u3002
MatrixOne 1.2.1 \u7248\u672c\u5df2\u7ecf\u652f\u6301 MySQL \u7684\u5efa\u8868\u8bed\u53e5\uff0c\u56e0\u6b64\u53ef\u4ee5\u987a\u7545\u5730\u5c06 MySQL \u8868\u8fc1\u79fb\u5230 MatrixOne \u4e0a\u3002\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f\uff0c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u517c\u5bb9 MySQL \u90e8\u5206\u5173\u952e\u5b57\uff0c\u5982 engine=
\u7b49\uff0c\u5728 MatrixOne \u4e2d\u4f1a\u88ab\u81ea\u52a8\u5ffd\u7565\uff0c\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u8868\u7ed3\u6784\u7684\u8fc1\u79fb\u3002
\u4f46\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u662f\uff0c\u5c3d\u7ba1 MatrixOne \u652f\u6301 MySQL \u5efa\u8868\u8bed\u53e5\uff0c\u5982\u679c\u8fc1\u79fb\u7684\u8868\u4e2d\u5305\u542b\u4e0d\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3001\u89e6\u53d1\u5668\u3001\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ecd\u9700\u8981\u624b\u52a8\u4fee\u6539\u3002\u66f4\u591a\u8be6\u7ec6\u7684\u517c\u5bb9\u6027\u4fe1\u606f\uff0c\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/","title":"\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
Oracle \u662f\u5168\u7403\u76ee\u524d\u6700\u5e7f\u6cdb\u4f7f\u7528\u7684\u5546\u4e1a\u6570\u636e\u5e93\uff0c\u5176\u4f7f\u7528\u573a\u666f\u4e0e\u6d41\u884c\u5ea6\u90fd\u5e38\u5e74\u9ad8\u5c45 DBEngine \u7b2c\u4e00\u540d\uff0cMatrixOne \u540c\u6837\u53ef\u4ee5\u652f\u6301\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u7684\u573a\u666f\u3002\u6839\u636e Oracle \u7684\u6570\u636e\u91cf\u5927\u5c0f\uff0c\u672c\u6587\u4f9d\u7136\u63a8\u8350\u4f7f\u7528\u5728\u7ebf\u4e0e\u79bb\u7ebf\u4e24\u79cd\u6a21\u5f0f\u8fdb\u884c\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e0e Oracle \u81ea\u5e26\u7684\u6570\u636e\u7c7b\u578b\u5b58\u5728\u7740\u8f83\u591a\u7684\u5dee\u5f02\uff0c\u8fd9\u4e9b\u5dee\u5f02\u6709\u4e9b\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u7c7b\u578b\u6765\u66ff\u6362\uff0c\u6709\u4e9b\u5219\u6682\u65f6\u65e0\u6cd5\u652f\u6301\uff0c\u5177\u4f53\u5217\u8868\u5982\u4e0b\uff1a
Oracle MatrixOne varchar2 \u4f7f\u7528 text \u66ff\u6362 nchar/nvarcahr \u4f7f\u7528 char/varchar \u66ff\u6362 NUMBER(3,0), NUMBER(5,0) \u4f7f\u7528 smallint \u66ff\u6362 NUMBER(10,0) \u4f7f\u7528 int \u66ff\u6362 NUMBER(38,0) \u4f7f\u7528 bitint \u66ff\u6362 NUMBER(n,p) (p>0) \u4f7f\u7528 decimal(n,p) \u66ff\u6362 binary_float/binary_double \u4f7f\u7528 float/double \u66ff\u6362 long \u4f7f\u7528 text \u66ff\u6362 long raw \u4f7f\u7528 blob \u66ff\u6362 raw \u4f7f\u7528 varbinary \u66ff\u6362 clob/nclob \u4f7f\u7528 text \u66ff\u6362 bfile \u6682\u4e0d\u652f\u6301 rowid/urowid \u6682\u4e0d\u652f\u6301 user-defined types \u6682\u4e0d\u652f\u6301 any \u6682\u4e0d\u652f\u6301 xml \u6682\u4e0d\u652f\u6301 spatial \u6682\u4e0d\u652f\u6301"},{"location":"MatrixOne/Migrate/migrate-from-oracle-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u901a\u8fc7 DBeaver\uff0c\u5c06\u6e90\u7aef\u7684\u6570\u636e\u6309\u6279\u6b21\u83b7\u53d6\uff0c\u518d\u5c06\u6570\u636e\u4ee5 INSERT
\u7684\u65b9\u5f0f\uff0c\u63d2\u5165\u5230\u76ee\u6807\u5e93\u3002\u5982\u679c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u62a5\u9519 heap \u7a7a\u95f4\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6bcf\u4e2a\u6279\u6b21\u83b7\u53d6\u5e76\u63d2\u5165\u6570\u636e\u7684\u89c4\u6a21\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a oracle_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u66ff\u6362 oracle_ddl.sql \u6587\u4ef6\u5185 MatrixOne \u4e0d\u652f\u6301\u7684\u5173\u952e\u5b57\uff1a
# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n#MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece Oracle \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a oracle_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u66ff\u6362 oracle_ddl.sql \u6587\u4ef6\u5185 MatrixOne \u4e0d\u652f\u6301\u7684\u5173\u952e\u5b57\uff1a
# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n\n#MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' '/CHECK (/d' /YOUR_PATH/oracle_ddl.sql\nsed -i '' '/CREATE UNIQUE INDEX/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(3,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(5,0)/smallint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(10,0)/int/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER(38,0)/bigint/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/NUMBER/decimal/g' /YOUR_PATH/oracle_ddl.sql\nsed -i '' 's/VARCHAR2/varchar/g' /YOUR_PATH/oracle_ddl.sql\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/oracle_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u4f7f\u7528 DBeaver \u5148\u5c06 Oracle \u7684\u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff0c\u5e76\u4f7f\u7528 MatrixOne \u7684\u5e76\u884c\u52a0\u8f7d\u529f\u80fd\u5c06\u6570\u636e\u8fc1\u79fb\u81f3 MatrixOne\uff1a
\u6253\u5f00 DBeaver\uff0c\u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff0c\u5c06 Oracle \u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\u6587\u4ef6\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9 CSV\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1a
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 DBeaver \u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 DBeaver \u5bfc\u51fa\u6570\u636e\uff1a\u6253\u5f00 DBeaver\uff0c\u4ece Oracle \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e > SQL\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u53c2\u6570\u6bcf\u6761\u8bed\u53e5\u7684\u6570\u636e\u884c\u6570\u8bbe\u7f6e\u4e3a 5000\uff1a
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff1a
source '/YOUR_PATH/oracle_data.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece PostgreSQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
PostgreSQL \u662f\u76ee\u524d\u5168\u4e16\u754c\u6700\u5148\u8fdb\u7684\u5f00\u6e90\u5173\u7cfb\u578b\u6570\u636e\u5e93\u4e4b\u4e00\uff0c\u62e5\u6709\u8005\u6781\u5176\u5b8c\u5907\u7684\u6570\u636e\u7c7b\u578b\u3001\u5bf9\u8c61\u7c7b\u578b\u3001SQL \u6a21\u578b\u4ee5\u53ca\u5176\u4ed6\u529f\u80fd\uff0c\u5728\u4f01\u4e1a\u3001\u6559\u80b2\u79d1\u7814\u7b49\u8bf8\u591a\u9886\u57df\u6709\u7740\u91cd\u8981\u7684\u5730\u4f4d\u3002\u6839\u636e PostgreSQL \u7684\u6570\u636e\u91cf\u5927\u5c0f\uff0c\u672c\u6587\u4f9d\u7136\u63a8\u8350\u4f7f\u7528\u5728\u7ebf\u4e0e\u79bb\u7ebf\u4e24\u79cd\u6a21\u5f0f\u8fdb\u884c\u8fc1\u79fb\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e0e PostgreSQL \u81ea\u5e26\u7684\u6570\u636e\u7c7b\u578b\u5b58\u5728\u7740\u8f83\u591a\u7684\u5dee\u5f02\uff0c\u8fd9\u4e9b\u5dee\u5f02\u6709\u4e9b\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u7c7b\u578b\u6765\u66ff\u6362\uff0c\u6709\u4e9b\u5219\u6682\u65f6\u65e0\u6cd5\u652f\u6301\u3002\u540c\u65f6\uff0cPostgreSQL \u652f\u6301\u4e09\u5c42\u903b\u8f91\u7ed3\u6784\uff1aDatabase\uff08\u6570\u636e\u5e93\uff09 - Schema\uff08\u6a21\u5f0f\uff09 - Table\uff08\u8868\uff09\uff0c\u5373\u4f60\u53ef\u4ee5\u5728\u4e00\u4e2a\u6570\u636e\u5e93\u5185\u521b\u5efa\u591a\u4e2a\u6a21\u5f0f\uff0c\u6bcf\u4e2a\u6a21\u5f0f\u5185\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u8868\uff0c\u8fd9\u6837\u7684\u5c42\u7ea7\u7ed3\u6784\u5141\u8bb8\u66f4\u597d\u5730\u7ec4\u7ec7\u548c\u7ba1\u7406\u6570\u636e\uff1b\u800c MatrixOne \u4ec5\u652f\u6301\u4e24\u5c42\u903b\u8f91\u7ed3\u6784\uff1aDatabase\uff08\u6570\u636e\u5e93\uff09 - Table\uff08\u8868\uff09\u3002\u5728 MatrixOne \u4e2d\uff0c\u76f4\u63a5\u5728\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u8868\uff0c\u6240\u4ee5\u6570\u636e\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u4e5f\u4f1a\u5b58\u5728\u4e9b\u8bb8\u4e0d\u540c\u3002
\u6570\u636e\u7c7b\u578b\u5dee\u5f02\u5177\u4f53\u5217\u8868\u5982\u4e0b\uff1a
PostgreSQL MatrixOne serial \u901a\u8fc7\u81ea\u589e\u5217\u66ff\u6362 money \u4f7f\u7528 decimal \u66ff\u6362 bytea \u4f7f\u7528 binary \u6216 varbinary \u66ff\u6362 geometric \u6682\u4e0d\u652f\u6301 network adress \u4f7f\u7528 char \u6216 varchar \u66ff\u6362 bit string \u6682\u4e0d\u652f\u6301 text search \u6682\u4e0d\u652f\u6301 xml \u6682\u4e0d\u652f\u6301 array \u6682\u4e0d\u652f\u6301 composite \u6682\u4e0d\u652f\u6301 range \u6682\u4e0d\u652f\u6301 domain \u6682\u4e0d\u652f\u6301 object identifier \u6682\u4e0d\u652f\u6301 pg_lsn \u6682\u4e0d\u652f\u6301 pseudo \u6682\u4e0d\u652f\u6301"},{"location":"MatrixOne/Migrate/migrate-from-postgresql-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece PostgreSQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u901a\u8fc7 DBeaver\uff0c\u5c06\u6e90\u7aef\u7684\u6570\u636e\u6309\u6279\u6b21\u83b7\u53d6\uff0c\u518d\u5c06\u6570\u636e\u4ee5 INSERT
\u7684\u65b9\u5f0f\uff0c\u63d2\u5165\u5230\u76ee\u6807\u5e93\u3002\u5982\u679c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u62a5\u9519 heap \u7a7a\u95f4\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6bcf\u4e2a\u6279\u6b21\u83b7\u53d6\u5e76\u63d2\u5165\u6570\u636e\u7684\u89c4\u6a21\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece PostgreSQL \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece PostgreSQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL \u70b9\u51fb\u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a pg_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\u7684 DDL\uff1a**
a. \u9996\u5148\uff0c\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5c06 pg_ddl.sql \u6587\u4ef6\u4e2d\u7684 bpchar
\u66ff\u6362\u4e3a char
\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n
b. \u63a5\u4e0b\u6765\uff0c\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\uff0c\u5e76\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230 mysql_ddl.sql \u6587\u4ef6\u4e2d\uff1a
```\n# Linux \u548c MacOS \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5747\u5982\u4e0b\uff1a\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n
c. \u8f6c\u6362\u540e\u7684 DDL \u4f1a\u4fdd\u7559\u539f\u59cb\u7684 Postgresql schema \u540d\u79f0\u3002\u5982\u679c\u6709\u5fc5\u8981\uff0c\u4f60\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06 schema \u540d\u79f0\u66ff\u6362\u4e3a MySQL \u4e2d\u7684\u6570\u636e\u5e93\u540d\u79f0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n
d. \u6700\u540e\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u7edf\u4e00\u5c06 mysql_ddl.sql \u6587\u4ef6\u4e2d\u7684 numeric
\u66ff\u6362\u4e3a decimal
\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b9e\u73b0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
\u8fde\u63a5 MatrixOne\uff0c\u5e76\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
\u6253\u5f00 DBeaver\uff0c\u4ece PostgreSQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
DDL \u8f6c\u8bd1\u5de5\u5177\uff1a\u5728\u8df3\u677f\u673a\u4e0a\u4e0b\u8f7d pg2mysql\u3002
\u5728 PostgreSQL \u670d\u52a1\u5668\u7aef\u5b89\u88c5 pgdump
\u3002\u5982\u679c\u4f60\u4e0d\u719f\u6089\u5982\u4f55\u4f7f\u7528 mysqldump
\uff0c\u53ef\u53c2\u89c1 pgdump \u6559\u7a0b
\u6253\u5f00 DBeaver\uff0c\u4ece PostgreSQL \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL \u70b9\u51fb\u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a pg_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\u7684 DDL\uff1a**
a. \u9996\u5148\uff0c\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u5c06 pg_ddl.sql \u6587\u4ef6\u4e2d\u7684 bpchar
\u66ff\u6362\u4e3a char
\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/bpchar/char/g' pg_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/bpchar/char/g' pg_ddl.sql\n```\n
b. \u63a5\u4e0b\u6765\uff0c\u4f7f\u7528 pg2mysql
\u8f6c\u8bd1\u5de5\u5177\u5c06 pg_ddl.sql \u6587\u4ef6\u8f6c\u6362\u4e3a MySQL \u683c\u5f0f\uff0c\u5e76\u5c06\u8f93\u51fa\u4fdd\u5b58\u5230 mysql_ddl.sql \u6587\u4ef6\u4e2d\uff1a
```\n# Linux \u548c MacOS \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5747\u5982\u4e0b\uff1a\n./pg2mysql.pl < pg_ddl.sql > mysql_ddl.sql\n```\n
c. \u8f6c\u6362\u540e\u7684 DDL \u4f1a\u4fdd\u7559\u539f\u59cb\u7684 Postgresql schema \u540d\u79f0\u3002\u5982\u679c\u6709\u5fc5\u8981\uff0c\u4f60\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06 schema \u540d\u79f0\u66ff\u6362\u4e3a MySQL \u4e2d\u7684\u6570\u636e\u5e93\u540d\u79f0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/{schema_name}/{database_name}/g' mysql_ddl.sql\n```\n
d. \u6700\u540e\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u7edf\u4e00\u5c06 mysql_ddl.sql \u6587\u4ef6\u4e2d\u7684 numeric
\u66ff\u6362\u4e3a decimal
\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b9e\u73b0\uff1a
```\n# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/numeric/decimal/g' mysql_ddl.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/numeric/decimal/g' mysql_ddl.sql\n```\n
\u8fde\u63a5 MatrixOne\uff0c\u5e76\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/mysql_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u5728 PostgreSQL \u6570\u636e\u5e93\u547d\u4ee4\u884c\u73af\u5883\u4e0b\u5c06 PostgreSQL \u7684\u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff1a
postgres=# \\c tpch;\npostgres=# COPY tpch.nation TO '/{filepath}/nation.tbl' DELIMITER '|';\npostgres=# COPY tpch.region TO '/{filepath}/region.tbl' DELIMITER '|';\npostgres=# COPY tpch.customer TO '/{filepath}/customer.tbl' DELIMITER '|';\npostgres=# COPY tpch.part TO '/{filepath}/part.tbl' DELIMITER '|';\npostgres=# COPY tpch.supplier TO '/{filepath}/supplier.tbl' DELIMITER '|';\npostgres=# COPY tpch.partsupp TO '/{filepath}/partsupp.tbl' DELIMITER '|';\npostgres=# COPY tpch.lineitem TO '/{filepath}/lineitem.tbl' DELIMITER '|';\npostgres=# COPY tpch.orders TO '/{filepath}/orders.tbl' DELIMITER '|';\n
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.tbl' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.tbl' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.tbl' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.tbl' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.tbl' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.tbl' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.tbl' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.tbl' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 pgdump
\u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 pgdump
\u5bfc\u51fa\u6570\u636e\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u5c3d\u91cf\u5927\uff0cnet_buffer_length
\u8fd9\u4e2a\u53c2\u6570\u5c3d\u91cf\u5728 10mb \u8d77\u6b65\uff1a
$ pg_dump -U postgres --no-acl --no-owner --inserts --rows-per-insert 5000 --format p --data-only --schema=tpch tpch -f pg_data.sql\n
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff0c\u671f\u95f4\u4f1a\u6709\u62a5\u9519\u4fe1\u606f\uff0c\u4f46\u662f\u4e0d\u5f71\u54cd\u6570\u636e\u7684\u63d2\u5165\uff1a
source '/YOUR_PATH/pg_data.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u5982\u679c\u4f60\u662f\u65b0\u624b\uff0c\u60f3\u5c1d\u8bd5\u8fc1\u79fb\u5c0f\u6570\u636e\u91cf\u7684\u6570\u636e\uff0c\u53ef\u53c2\u89c1\u4f7f\u7528 source
\u547d\u4ee4\u6279\u91cf\u5bfc\u5165\u6570\u636e\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5c06\u6570\u636e\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
SQLServer \u4f5c\u4e3a\u4e00\u6b3e\u6210\u719f\u7684\u5546\u4e1a\u6570\u636e\u5e93\uff0c\u5728\u5404\u4e2a\u884c\u4e1a\u5185\u5747\u6709\u7740\u5e7f\u6cdb\u5730\u4f7f\u7528\uff0c\u5e76\u4e14\u5176\u529f\u80fd\u4e0e\u6027\u80fd\u90fd\u975e\u5e38\u51fa\u4f17\u3002\u4f5c\u4e3a\u4e00\u6b3e\u5173\u7cfb\u578b\u6570\u636e\u5e93\uff0cMatrixOne \u540c\u6837\u652f\u6301\u591a\u79cd\u4ece SQLServer \u800c\u6765\u7684\u6570\u636e\u5e93\u8fc1\u79fb\u6a21\u5f0f\u3002
"},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#_1","title":"\u6570\u636e\u7c7b\u578b\u5dee\u5f02","text":"MatrixOne \u4e0e SQL Server \u5b58\u5728\u7740\u8bf8\u591a\u7c7b\u578b\u4e0a\u7684\u5dee\u5f02\uff0c\u8fd9\u4e9b\u5dee\u5f02\u6709\u4e9b\u53ef\u4ee5\u901a\u8fc7\u5176\u4ed6\u7c7b\u578b\u6765\u66ff\u6362\uff0c\u6709\u4e9b\u5219\u6682\u65f6\u65e0\u6cd5\u652f\u6301\uff0c\u5177\u4f53\u5217\u8868\u5982\u4e0b\uff1a
SQLServer MatrixOne real \u4f7f\u7528 double \u66ff\u6362 money, smallmoney \u4f7f\u7528 decimal \u66ff\u6362 datetimeoffset \u4f7f\u7528 timestmap \u4e0e\u65f6\u533a\u66ff\u6362 nchar/nvarchar/ntext \u4f7f\u7528 char/varchar/text \u66ff\u6362 image \u4f7f\u7528 blob \u66ff\u6362 uniqueidentifier \u4f7f\u7528 uuid \u66ff\u6362 bit \u6682\u4e0d\u652f\u6301 rowversion \u6682\u4e0d\u652f\u6301 hierarchyid \u6682\u4e0d\u652f\u6301 sql_variant \u6682\u4e0d\u652f\u6301 xml \u6682\u4e0d\u652f\u6301 geometry \u6682\u4e0d\u652f\u6301 geography \u6682\u4e0d\u652f\u6301"},{"location":"MatrixOne/Migrate/migrate-from-sqlserver-to-matrixone/#_2","title":"\u5728\u7ebf\u8fc1\u79fb","text":"\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u7b2c\u4e09\u65b9\u5de5\u5177 DBeaver\uff0c\u5c06\u6570\u636e\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u901a\u8fc7 DBeaver\uff0c\u5c06\u6e90\u7aef\u7684\u6570\u636e\u6309\u6279\u6b21\u83b7\u53d6\uff0c\u518d\u5c06\u6570\u636e\u4ee5 INSERT
\u7684\u65b9\u5f0f\uff0c\u63d2\u5165\u5230\u76ee\u6807\u5e93\u3002\u5982\u679c\u5728\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u62a5\u9519 heap \u7a7a\u95f4\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u8c03\u6574\u6bcf\u4e2a\u6279\u6b21\u83b7\u53d6\u5e76\u63d2\u5165\u6570\u636e\u7684\u89c4\u6a21\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece SQL Server \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u5bfc\u51fa\u6570\u636e\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9\u6570\u636e\u5e93\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1b\u5728\u8868\u6620\u5c04\u7a97\u53e3\u9009\u62e9\u76ee\u6807\u5bb9\u5668\uff0c\u76ee\u6807\u5bb9\u5668\u9009\u62e9 MatrixOne \u7684\u6570\u636e\u5e93 tpch\uff1a
\u5728\u62bd\u53d6\u8bbe\u7f6e\u548c\u6570\u636e\u52a0\u8f7d\u8bbe\u7f6e\u7a97\u53e3\uff0c\u8bbe\u7f6e\u9009\u62e9\u62bd\u53d6\u548c\u63d2\u5165\u7684\u6570\u91cf\uff0c\u4e3a\u4e86\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3 \u7b56\u7565\uff0c\u5efa\u8bae\u586b\u5199 5000\uff1a
\u5b8c\u6210\u8bbe\u7f6e\u540e\uff0cDBeaver \u5f00\u59cb\u5bf9\u6570\u636e\u8fdb\u884c\u8fc1\u79fb\uff0c\u5728\u5b8c\u6210\u540e DBeaver \u5c06\u4f1a\u63d0\u793a\u8fc1\u79fb\u6210\u529f\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u672c\u7ae0\u8282\u5c06\u6307\u5bfc\u4f60\u901a\u8fc7\u79bb\u7ebf\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne\u3002
\u5728\u8fd9\u91cc\u4ee5 TPCH \u6570\u636e\u96c6\u4e3a\u4f8b\uff0c\u5c06 TPCH \u6570\u636e\u96c6\u7684 8 \u5f20\u8868\u4ece SQL Server \u8fc1\u79fb\u81f3 MatrixOne\u3002
\u6253\u5f00 DBeaver\uff0c\u4ece SQL Server \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u751f\u6210 SQL > DDL > \u590d\u5236\uff0c\u5148\u5c06\u8fd9\u6bb5 SQL \u590d\u5236\u5230\u4e00\u4e2a\u6587\u672c\u7f16\u8f91\u5668\u5185\uff0c\u7ed9\u6587\u672c\u7f16\u8f91\u5668\u547d\u540d\u4e3a sqlserver_ddl.sql\uff0c\u4fdd\u5b58\u5230\u8df3\u677f\u673a\u672c\u5730\u3002
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5728 MatrixOne \u4e2d\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u548c\u8868\uff1a
create database tpch;\nuse tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n
\u5728 MatrixOne \u4e2d\uff0c\u6709\u4e24\u79cd\u6570\u636e\u8fc1\u79fb\u65b9\u5f0f\u53ef\u4f9b\u9009\u62e9\uff1aINSERT
\u548c LOAD DATA
\u3002\u5f53\u6570\u636e\u91cf\u5927\u4e8e 1GB \u65f6\uff0c\u9996\u5148\u63a8\u8350\u4f7f\u7528 LOAD DATA
\uff0c\u5176\u6b21\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 INSERT
\u3002
\u4f7f\u7528 LOAD DATA
\u5148\u5c06 SQL Server \u7684\u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\uff0c\u5e76\u4f7f\u7528 MatrixOne \u7684\u5e76\u884c LOAD \u529f\u80fd\u5c06\u6570\u636e\u8fc1\u79fb\u81f3 MatrixOne\uff1a
\u6253\u5f00 DBeaver\uff0c\u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e\uff0c\u5c06 SQL Server \u6570\u636e\u8868\u5bfc\u51fa\u4e3a CSV \u683c\u5f0f\u6587\u4ef6\uff1a
\u5728\u8f6c\u5316\u76ee\u6807 > \u5bfc\u51fa\u76ee\u6807\u7a97\u53e3\u9009\u62e9 CSV\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\uff1a
\u8fde\u63a5\u5230 MatrixOne\uff0c\u5c06\u5bfc\u51fa\u7684 CSV \u6570\u636e\u5bfc\u5165\u81f3 MatrixOne\uff1a
mysql> load data infile '/{filepath}/lineitem.txt' INTO TABLE lineitem FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/nation.txt' INTO TABLE nation FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/part.txt' INTO TABLE part FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/customer.txt' INTO TABLE customer FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/orders.txt' INTO TABLE orders FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/supplier.txt' INTO TABLE supplier FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/region.txt' INTO TABLE region FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\nmysql> load data infile '/{filepath}/partsupp.txt' INTO TABLE partsupp FIELDS TERMINATED BY '|' lines TERMINATED BY '\\n' parallel 'true';\n
\u66f4\u591a\u5173\u4e8e LOAD DATA
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
INSERT
\u8bed\u53e5\u9700\u8981\u4f7f\u7528 DBeaver \u5148\u5c06\u903b\u8f91\u8bed\u53e5\u5bfc\u51fa\uff0c\u518d\u5bfc\u5165\u5230 MatrixOne\uff1a
\u4f7f\u7528 DBeaver \u5bfc\u51fa\u6570\u636e\uff1a\u6253\u5f00 DBeaver\uff0c\u4ece SQL Server \u4e2d\u9009\u62e9\u5f85\u8fc1\u79fb\u7684\u8868\uff0c\u9f20\u6807\u53f3\u952e\u70b9\u51fb\u540e\u9009\u62e9\u5bfc\u51fa\u6570\u636e > SQL\uff0c\u4e3a\u4e86\u786e\u4fdd\u63d2\u5165\u65f6\u89e6\u53d1 MatrixOne \u7684\u76f4\u63a5\u5199 S3\uff0c\u5efa\u8bae\u6279\u91cf\u63d2\u5165\u53c2\u6570\u6bcf\u6761\u8bed\u53e5\u7684\u6570\u636e\u884c\u6570\u8bbe\u7f6e\u4e3a 5000\uff1a
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u66ff\u6362 sqlserver_ddl.sql \u6587\u4ef6\u5185 MatrixOne \u4e0d\u652f\u6301\u7684\u5173\u952e\u5b57\uff1a
# Linux \u7cfb\u7edf\u6267\u884c\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i 's/,N/,/g' mssql_data.sql\n\n# MacOS \u7cfb\u7edf\u5219\u4f7f\u7528\u7684\u547d\u4ee4\u5982\u4e0b\uff1a\nsed -i '' 's/,N/,/g' mssql_data.sql\n
\u5728 MatrixOne \u7aef\uff0c\u6267\u884c\u8be5 SQL \u6587\u4ef6\uff1a
ues tpch;\nsource '/YOUR_PATH/sqlserver_ddl.sql'\n
\u66f4\u591a\u5173\u4e8e INSERT
\u7684\u64cd\u4f5c\u793a\u4f8b\uff0c\u53c2\u89c1\u63d2\u5165\u6570\u636e\u3002
\u5b8c\u6210\u8fc1\u79fb\u4e4b\u540e\uff0c\u53ef\u4ee5\u91c7\u7528\u5982\u4e0b\u65b9\u5f0f\u68c0\u67e5\u6570\u636e\uff1a
\u901a\u8fc7 select count(*) from <table_name>
\u6765\u786e\u8ba4\u6e90\u5e93\u4e0e\u76ee\u6807\u5e93\u7684\u6570\u636e\u91cf\u662f\u5426\u4e00\u81f4\u3002
\u901a\u8fc7\u76f8\u5173\u7684\u67e5\u8be2\u5bf9\u6bd4\u7ed3\u679c\uff0c\u4f60\u4e5f\u53ef\u4ee5\u53c2\u89c1\u5b8c\u6210 TPCH \u6d4b\u8bd5\u67e5\u8be2\u793a\u4f8b\uff0c\u8fdb\u884c\u7ed3\u679c\u5bf9\u6bd4\u3002
\u5728\u4f7f\u7528 MatrixOne \u65f6\uff0c\u6709\u65f6\u9700\u8981\u5c06\u6570\u636e\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8fc1\u79fb\u81f3 MatrixOne\u3002\u7531\u4e8e\u4e0d\u540c\u6570\u636e\u5e93\u4e4b\u95f4\u5b58\u5728\u5dee\u5f02\uff0c\u6570\u636e\u8fc1\u79fb\u9700\u8981\u4e00\u4e9b\u989d\u5916\u7684\u5de5\u4f5c\u3002\u4e3a\u4e86\u65b9\u4fbf\u7528\u6237\u5feb\u901f\u5bfc\u5165\u5916\u90e8\u6570\u636e\uff0cMatrixOne \u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177\u548c\u529f\u80fd\u3002
\u4ee5\u4e0b\u662f\u5176\u4e2d\u7684\u4e00\u4e9b\u5e38\u89c1\u7684\u5de5\u5177\u548c\u529f\u80fd\uff1a
"},{"location":"MatrixOne/Migrate/migrate-overview/#load-data","title":"LOAD DATA","text":"\u4e0e MySQL \u7c7b\u4f3c\uff0cMatrixOne \u63d0\u4f9b\u4e86 LOAD DATA \u529f\u80fd\uff0c\u5141\u8bb8\u7528\u6237\u5c06\u5916\u90e8\u7684 CSV \u6587\u4ef6\u6216 JSON \u6587\u4ef6\u5feb\u901f\u5e76\u884c\u5730\u5bfc\u5165\u5230\u4e0e\u8868\u7ed3\u6784\u5339\u914d\u7684\u8868\u4e2d\u3002
"},{"location":"MatrixOne/Migrate/migrate-overview/#source","title":"SOURCE","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 SOURCE \u547d\u4ee4\u5c06\u6570\u636e\u548c\u8868\u7ed3\u6784\u8fc1\u79fb\u5230\u76ee\u6807\u6570\u636e\u5e93\u4e2d\u3002
\u66f4\u591a\u5173\u4e8e\u4f7f\u7528 LOAD DATA \u6216 SOURCE \u8fdb\u884c\u6279\u91cf\u5bfc\u5165\u7684\u6587\u6863\uff0c\u53c2\u89c1\u6279\u91cf\u5bfc\u5165\u3002
"},{"location":"MatrixOne/Migrate/migrate-overview/#_1","title":"\u53c2\u8003\u6587\u6863","text":"MatrixOne \u63d0\u4f9b\u4e86\u4ee5\u4e0b\u6587\u6863\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u4e86\u89e3\u5982\u4f55\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u5c06\u6570\u636e\u8fc1\u79fb\u81f3 MatrixOne\uff1a
\u672c\u6587\u6863\u5217\u51fa\u4e86 MatrixOne \u6700\u65b0\u7248\u672c\u6240\u652f\u6301\u7684\u529f\u80fd\u6e05\u5355\uff0c\u9488\u5bf9\u5e38\u89c1\u4ee5\u53ca\u5728 MatrixOne \u7684\u8def\u7ebf\u56fe\u4e2d\u7684\u529f\u80fd\u4f46\u662f\u76ee\u524d\u4e0d\u652f\u6301\u7684\u529f\u80fd\u4e5f\u5c06\u5217\u51fa\u3002
"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-definition-language-ddl","title":"\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff08Data definition language, DDL\uff09","text":"\u6570\u636e\u5b9a\u4e49\u8bed\u8a00 (DDL) \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u521b\u5efa\u6570\u636e\u5e93 CREATE DATABASE Y \u5220\u9664\u6570\u636e\u5e93 DROP DATABASE Y \u4fee\u6539\u6570\u636e\u5e93 ALTER DATABASE N \u521b\u5efa\u8868 CREATE TABLE Y \u4fee\u6539\u8868 ALTER TABLE E \u4fee\u6539\u8868\u540d RENAME TABLE N\uff0c\u53ef\u7528 ALTER TABLE tbl RENAME TO new_tbl \u66ff\u4ee3 \u5220\u9664\u8868 DROP TABLE Y \u521b\u5efa\u7ea6\u675f CREATE INDEX Y \u5220\u9664\u7ea6\u675f DROP INDEX Y \u4fee\u6539\u5217 MODIFY COLUMN Y \u4e3b\u952e PRIMARY KEY Y \u521b\u5efa\u89c6\u56fe CREATE VIEW Y \u4fee\u6539\u89c6\u56fe ALTER VIEW Y \u5220\u9664\u89c6\u56fe DROP VIEW Y \u6e05\u7a7a\u8868 TRUNCATE TABLE Y \u81ea\u589e\u5217 AUTO_INCREMENT Y \u5e8f\u5217 SEQUENCE Y \u4e34\u65f6\u8868 TEMPORARY TABLE Y \u6d41\u5f0f\u8868 CREATE DYNAMIC TABLE E\uff0c\u90e8\u5206\u652f\u6301 \u5206\u533a\u8868 PARTITION BY E\uff0c\u90e8\u5206\u7c7b\u578b\u652f\u6301 \u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u987a\u5e8f CHARSET\uff0cCOLLATION N\uff0c\u4ec5\u9ed8\u8ba4\u652f\u6301 UTF8"},{"location":"MatrixOne/Overview/matrixone-feature-list/#data-manipulationquery-language-dmldql","title":"\u6570\u636e\u4fee\u6539/\u67e5\u8be2\u8bed\u8a00\uff08Data manipulation/query language, DML/DQL\uff09","text":"SQL \u8bed\u53e5 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) SELECT Y INSERT Y UPDATE Y DELETE Y REPLACE Y INSERT ON DUPLICATE KEY UPDATE Y \u5bfc\u5165\u6570\u636e LOAD DATA Y \u5bfc\u51fa\u6570\u636e SELECT INTO Y \u8fde\u63a5 INNER/LEFT/RIGHT/OUTER JOIN Y \u8054\u5408 UNION, UNION ALL Y EXCEPT, INTERSECT Y GROUP BY, ORDER BY Y \u9884\u6392\u5e8f CLUSTER BY Y \u5b50\u67e5\u8be2 SUBQUERY Y \u516c\u5171\u8868\u8868\u8fbe\u5f0f (Common Table Expressions\uff0cCTE) Y \u4e8b\u52a1\u8bed\u53e5 BEGIN/START TRANSACTION, COMMIT, ROLLBACK Y EXPLAIN Y EXPLAIN ANALYZE Y \u8868\u7ea7\u9501 LOCK/UNLOCK TABLE N \u7528\u6237\u81ea\u5b9a\u4e49\u53d8\u91cf Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#sql","title":"\u9ad8\u7ea7 SQL \u529f\u80fd","text":"\u9ad8\u7ea7 SQL \u529f\u80fd \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u9884\u5904\u7406 PREPARE Y \u5b58\u50a8\u8fc7\u7a0b STORED PROCEDURE N \u89e6\u53d1\u5668 TRIGGER N \u65f6\u95f4\u8c03\u5ea6\u5668 EVENT SCHEDULER N \u81ea\u5b9a\u4e49\u51fd\u6570 UDF Y \u7269\u5316\u89c6\u56fe Materialized VIEW N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_1","title":"\u6d41\u8ba1\u7b97","text":"\u6d41\u8ba1\u7b97\u529f\u80fd \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u52a8\u6001\u8868 E Kafka \u8fde\u63a5\u5668 E \u7269\u5316\u89c6\u56fe N (\u589e\u91cf) \u7269\u5316\u89c6\u56fe N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_2","title":"\u65f6\u5e8f","text":"\u6d41\u8ba1\u7b97\u529f\u80fd \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u65f6\u5e8f\u8868 Y \u6ed1\u52a8\u7a97\u53e3 Y \u964d\u91c7\u6837 Y \u63d2\u503c Y TTL\uff08Time To Live\uff09 N ROLLUP N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_3","title":"\u6570\u636e\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b\u5206\u7c7b \u6570\u636e\u7c7b\u578b \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u6574\u6570\u7c7b\u578b TINYINT/SMALLINT/INT/BIGINT (UNSIGNED) Y BIT N \u6d6e\u70b9\u7c7b\u578b FLOAT Y DOUBLE Y \u5b57\u7b26\u4e32\u7c7b\u578b CHAR Y VARCHAR Y BINARY Y VARBINARY Y TINYTEXT/TEXT/MEDIUMTEXT/LONGTEXT Y ENUM Y SET N \u4e8c\u8fdb\u5236\u7c7b\u578b TINYBLOB/BLOB/MEDIUMBLOB/LONGBLOB Y \u65f6\u95f4\u4e0e\u65e5\u671f DATE Y TIME Y DATETIME Y TIMESTAMP Y YEAR Y Boolean BOOL Y \u5b9a\u70b9\u7c7b\u578b DECIMAL Y\uff0c\u6700\u9ad8\u5230 38 \u4f4d JSON \u7c7b\u578b JSON Y \u5411\u91cf\u7c7b\u578b VECTOR Y \u6570\u7ec4\u7c7b\u578b ARRAY N\uff08\u4e0e MySQL \u4e00\u81f4\uff0c\u5728 JSON \u4e2d\u63d0\u4f9b\u6570\u7ec4\u64cd\u4f5c\uff09 \u4f4d\u56fe\u7c7b\u578b BITMAP N \u7a7a\u95f4\u7c7b\u578b GEOMETRY/POINT/LINESTRING/POLYGON N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_4","title":"\u7d22\u5f15\u4e0e\u7ea6\u675f","text":"\u7d22\u5f15\u4e0e\u7ea6\u675f \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u4e3b\u952e\u7ea6\u675f Y \u590d\u5408\u4e3b\u952e Y \u552f\u4e00\u7ea6\u675f Y \u6b21\u7ea7\u7d22\u5f15 Y \u5411\u91cf\u7d22\u5f15 Y \u5916\u952e\u7ea6\u675f Y \u65e0\u6548\u6570\u636e\u5f3a\u5236\u7ea6\u675f Y ENUM \u548c SET \u7ea6\u675f N \u975e\u7a7a\u7ea6\u675f Y \u81ea\u589e\u7ea6\u675f Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_5","title":"\u4e8b\u52a1","text":"\u4e8b\u52a1 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u60b2\u89c2\u4e8b\u52a1 Y\uff08\u9ed8\u8ba4\u6a21\u5f0f\uff09 \u4e50\u89c2\u4e8b\u52a1 Y \u8de8\u5e93\u4e8b\u52a1 Y \u5206\u5e03\u5f0f\u4e8b\u52a1 Y \u53ef\u91cd\u590d\u8bfb\u9694\u79bb\uff08\u5feb\u7167 SI \u9694\u79bb\uff09 Y \u8bfb\u5df2\u63d0\u4ea4 RC \u9694\u79bb Y\uff08\u9ed8\u8ba4\u6a21\u5f0f\uff09"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_6","title":"\u51fd\u6570\u4e0e\u64cd\u4f5c\u7b26","text":"\u51fd\u6570\u4e0e\u64cd\u4f5c\u7b26 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u805a\u5408\u51fd\u6570 Y \u6570\u503c\u7c7b\u51fd\u6570 Y \u65f6\u95f4\u65e5\u671f\u7c7b\u51fd\u6570 Y \u5b57\u7b26\u4e32\u51fd\u6570 Y Cast \u51fd\u6570 Y \u6d41\u7a0b\u63a7\u5236\u51fd\u6570 E \u7a97\u53e3\u51fd\u6570 Y JSON \u51fd\u6570 Y \u5411\u91cf\u51fd\u6570 Y \u7cfb\u7edf\u51fd\u6570 Y \u5176\u4ed6\u51fd\u6570 Y \u64cd\u4f5c\u7b26 YMatrixOne \u7684\u5b8c\u6574\u51fd\u6570\u5217\u8868\u53ef\u4ee5\u53c2\u89c1\u8be5\u51fd\u6570\u603b\u8868.
"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_7","title":"\u5206\u533a","text":"\u5206\u533a \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) KEY \u5206\u533a E HASH \u5206\u533a E RANGE \u5206\u533a E RANGE COLUMNS \u5206\u533a E LIST \u5206\u533a E LIST COLUMNS \u5206\u533a E"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_8","title":"\u6570\u636e\u5bfc\u5165\u548c\u5bfc\u51fa","text":"\u6570\u636e\u5bfc\u5165\u548c\u5bfc\u51fa \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) INSERT INTO \u5199\u5165 Y SQL \u5bfc\u5165 SOURCE Y \u6587\u4ef6\u5bfc\u5165 LOAD DATA INFILE Y \u6d41\u5f0f\u5bfc\u5165 LOAD DATA INLINE Y \u4ece\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165 Y mo-dump \u5de5\u5177\u5bfc\u51fa SQL/CSV Y SELECT INTO \u5bfc\u51fa CSV/JSON Y mysqldump \u539f\u751f\u5de5\u5177 N"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_9","title":"\u5b89\u5168\u4e0e\u8bbf\u95ee\u63a7\u5236","text":"\u5b89\u5168 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u4f20\u8f93\u5c42\u52a0\u5bc6 TLS Y \u9759\u6001\u52a0\u5bc6 Y \u4ece\u5bf9\u8c61\u5b58\u50a8\u5bfc\u5165 Y \u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236\uff08RBAC\uff09 Y \u591a\u79df\u6237 Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_10","title":"\u5907\u4efd\u548c\u6062\u590d","text":"\u5907\u4efd\u548c\u6062\u590d \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u903b\u8f91\u5907\u4efd\u6062\u590d Y\uff0c\u4ec5\u652f\u6301 mo-dump \u5de5\u5177 \u7269\u7406\u5907\u4efd\u6062\u590d Y\uff0c\u4ec5\u652f\u6301 mobackup \u5de5\u5177 \u5feb\u7167\u5907\u4efd\u6062\u590d Y\uff0c\u652f\u6301 mobackup \u5de5\u5177 \u548c SQL CDC \u540c\u6b65 N\uff08MatrixOne \u4f5c\u4e3a\u6e90\u7aef\u4e0d\u652f\u6301\uff09"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_11","title":"\u7ba1\u7406\u5de5\u5177","text":"\u7ba1\u7406\u5de5\u5177 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u5355\u673a mo_ctl \u90e8\u7f72\u7ba1\u7406 Y \u5206\u5e03\u5f0f mo_ctl \u90e8\u7f72\u7ba1\u7406 E\uff0c\u4ec5\u4f01\u4e1a\u7248 \u53ef\u89c6\u5316\u7ba1\u7406\u5e73\u53f0 E\uff0c\u4ec5\u516c\u6709\u4e91\u7248\u672c \u7cfb\u7edf\u65e5\u5fd7\u8bb0\u5f55 Y \u7cfb\u7edf\u6307\u6807\u76d1\u63a7 Y \u6162\u67e5\u8be2\u65e5\u5fd7 Y SQL \u8bb0\u5f55 Y Kubernetes operator Y"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_12","title":"\u90e8\u7f72\u65b9\u5f0f","text":"\u90e8\u7f72\u65b9\u5f0f \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09/\u5b9e\u9a8c\u7279\u6027 (E) \u5355\u673a\u73af\u5883\u79c1\u6709\u5316\u90e8\u7f72 Y \u5206\u5e03\u5f0f\u73af\u5883\u79c1\u6709\u5316\u90e8\u7f72 Y\uff0c\u81ea\u5efa Kubernetes \u4e0e minIO \u5bf9\u8c61\u5b58\u50a8 \u963f\u91cc\u4e91\u5206\u5e03\u5f0f\u81ea\u5efa\u90e8\u7f72 Y\uff0cACK+OSS \u817e\u8baf\u4e91\u5206\u5e03\u5f0f\u81ea\u5efa\u90e8\u7f72 Y\uff0cTKE+COS AWS \u5206\u5e03\u5f0f\u81ea\u5efa\u90e8\u7f72 Y\uff0cEKS+S3 \u516c\u6709\u4e91 Serverless Y\uff0cMatrixOne Cloud\uff0c\u652f\u6301 AWS\uff0c\u963f\u91cc\u4e91"},{"location":"MatrixOne/Overview/matrixone-feature-list/#orm","title":"\u5e94\u7528\u8fde\u63a5\u5668\u53ca\u5e38\u89c1 ORM","text":"\u5e94\u7528\u8fde\u63a5\u5668 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09 JDBC Y ODBC N pymysql Y go-sql-driver Y MyBatis Y MyBatis-plus Y Spring-JPA Y Hibernate Y GORM Y SQL Alchemy Y\u6ce8\u610f\uff1a\u672a\u5728\u4e0a\u9762\u6807\u660e\u7684\u5e94\u7528\u8fde\u63a5\u5668\u6216\u8005 ORM \u5de5\u5177\u5e76\u4e0d\u4e00\u5b9a\u4e0d\u652f\u6301\uff0cMatrixOne \u672c\u8eab\u5bf9 MySQL 8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u56e0\u6b64\u5982\u679c\u8fde\u63a5 MySQL \u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u7684\u90fd\u57fa\u672c\u53ef\u4ee5\u9002\u914d MatrixOne\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u5c1d\u8bd5\u57fa\u4e8e MySQL \u53ef\u4ee5\u8dd1\u901a\u7684\u6210\u719f\u5de5\u5177\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Overview/matrixone-feature-list/#_13","title":"\u751f\u6001\u5de5\u5177\u9002\u914d","text":"\u5de5\u5177\u79cd\u7c7b \u5de5\u5177\u540d\u79f0 \u652f\u6301\uff08Y\uff09/\u4e0d\u652f\u6301\uff08N\uff09 \u6570\u636e\u5e93\u7ba1\u7406 IDE Navicat Y MySQL Workbench Y DBeaver Y HeidiSQL Y SQLyog Y ETL \u5de5\u5177 DataX Y Canal Y Kettle Y Seatunnel Y FlinkCDC Y \u6d88\u606f\u961f\u5217 Kafka Y \u8ba1\u7b97\u5f15\u64ce Spark Y Flink Y BI \u5de5\u5177 Superset Y Tableau Y FineBI Y \u6c38\u6d2a BI Y Datafor Y \u6570\u636e\u8c03\u5ea6 DolphinScheduler Y \u53ef\u89c6\u5316\u76d1\u63a7 Grafana Y\u6ce8\u610f\uff1a\u672a\u5728\u4e0a\u9762\u6807\u660e\u7684\u751f\u6001\u5de5\u5177\u5e76\u4e0d\u4e00\u5b9a\u4e0d\u652f\u6301\uff0cMatrixOne \u672c\u8eab\u5bf9 MySQL 8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u56e0\u6b64\u5982\u679c\u8fde\u63a5 MySQL \u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u7684\u90fd\u57fa\u672c\u53ef\u4ee5\u9002\u914d MatrixOne\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u5c1d\u8bd5\u57fa\u4e8e MySQL \u53ef\u4ee5\u8dd1\u901a\u7684\u6210\u719f\u5de5\u5177\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/","title":"MatrixOne \u7b80\u4ecb","text":"MatrixOne \u662f\u4e00\u6b3e\u8d85\u878d\u5408\u5f02\u6784\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u901a\u8fc7\u4e91\u539f\u751f\u5316\u548c\u5b58\u50a8\u3001\u8ba1\u7b97\u3001\u4e8b\u52a1\u5206\u79bb\u7684\u67b6\u6784\u6784\u5efa HSTAP \u8d85\u878d\u5408\u6570\u636e\u5f15\u64ce\uff0c\u5b9e\u73b0\u5355\u4e00\u6570\u636e\u5e93\u7cfb\u7edf\u652f\u6301 OLTP\u3001OLAP\u3001\u6d41\u8ba1\u7b97\u7b49\u591a\u79cd\u4e1a\u52a1\u8d1f\u8f7d\uff0c\u5e76\u4e14\u652f\u6301\u516c\u6709\u4e91\u3001\u79c1\u6709\u4e91\u3001\u8fb9\u7f18\u4e91\u90e8\u7f72\u548c\u4f7f\u7528\uff0c\u5b9e\u73b0\u5f02\u6784\u57fa\u7840\u8bbe\u65bd\u7684\u517c\u5bb9\u3002
MatrixOne \u5177\u5907\u5b9e\u65f6 HTAP\uff0c\u591a\u79df\u6237\uff0c\u6d41\u5f0f\u8ba1\u7b97\uff0c\u6781\u81f4\u6269\u5c55\u6027\uff0c\u9ad8\u6027\u4ef7\u6bd4\uff0c\u4f01\u4e1a\u7ea7\u9ad8\u53ef\u7528\u53ca MySQL \u9ad8\u5ea6\u517c\u5bb9\u7b49\u91cd\u8981\u7279\u6027\uff0c\u901a\u8fc7\u4e3a\u7528\u6237\u63d0\u4f9b\u4e00\u7ad9\u5f0f\u8d85\u878d\u5408\u6570\u636e\u89e3\u51b3\u65b9\u6848\uff0c\u53ef\u4ee5\u5c06\u8fc7\u53bb\u7531\u591a\u4e2a\u6570\u636e\u5e93\u5b8c\u6210\u7684\u5de5\u4f5c\u5408\u5e76\u5230\u4e00\u4e2a\u6570\u636e\u5e93\u91cc\uff0c\u4ece\u800c\u7b80\u5316\u5f00\u53d1\u8fd0\u7ef4\uff0c\u6d88\u51cf\u6570\u636e\u788e\u7247\uff0c\u63d0\u9ad8\u5f00\u53d1\u654f\u6377\u5ea6\u3002
MatrixOne \u9002\u7528\u4e8e\u9700\u8981\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u6570\u636e\u89c4\u6a21\u8f83\u5927\uff0c\u8d1f\u8f7d\u6ce2\u52a8\u9891\u7e41\uff0c\u540c\u65f6\u62e5\u6709\u6d41\u7a0b\u578b\u4e1a\u52a1\u548c\u5206\u6790\u578b\u4e1a\u52a1\u7684\u573a\u666f\uff0c\u6bd4\u5982\u79fb\u52a8\u4e92\u8054\u7f51 APP\u3001IoT \u6570\u636e\u5e94\u7528\u3001\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u3001SaaS \u5e73\u53f0\u7b49\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_1","title":"\u6838\u5fc3\u7279\u6027","text":""},{"location":"MatrixOne/Overview/matrixone-introduction/#_2","title":"\u8d85\u878d\u5408\u5f15\u64ce","text":"\u8d85\u878d\u5408\u5f15\u64ce
HTAP \u6570\u636e\u5f15\u64ce\uff0c\u5355\u6570\u636e\u5e93\u5373\u53ef\u652f\u6301 TP\u3001AP\u3001\u65f6\u5e8f\u3001\u673a\u5668\u5b66\u4e60\u7b49\u6df7\u5408\u5de5\u4f5c\u8d1f\u8f7d\u3002
\u5185\u7f6e\u6d41\u5f15\u64ce
\u5185\u7f6e\u6d41\u8ba1\u7b97\u5f15\u64ce\uff0c\u652f\u6301\u5b9e\u65f6\u6570\u636e\u6d41\u5165\u3001\u5b9e\u65f6\u6570\u636e\u8f6c\u6362\u53ca\u5b9e\u65f6\u6570\u636e\u67e5\u8be2\u3002
\u5b58\u7b97\u5206\u79bb\u67b6\u6784
\u5c06\u5b58\u50a8\u3001\u8ba1\u7b97\u3001\u4e8b\u52a1\u4e09\u5c42\u89e3\u8026\uff0c\u901a\u8fc7\u5b8c\u5168\u5bb9\u5668\u5316\u7684\u8bbe\u8ba1\u6765\u5b9e\u73b0\u6781\u81f4\u6269\u5c55\u3002
\u591a\u57fa\u7840\u8bbe\u65bd\u517c\u5bb9
\u652f\u6301\u8de8\u673a\u623f\u534f\u540c/\u591a\u5730\u534f\u540c/\u4e91\u8fb9\u534f\u540c\uff0c\u5b9e\u73b0\u65e0\u611f\u77e5\u6269\u7f29\u5bb9\uff0c\u63d0\u4f9b\u9ad8\u6548\u7edf\u4e00\u7684\u6570\u636e\u7ba1\u7406\u3002
\u9ad8\u6027\u80fd\u6267\u884c\u5f15\u64ce
\u901a\u8fc7 Compute Node \u548c Transaction node \u7684\u7075\u6d3b\u914d\u5408\u517c\u987e\u70b9\u67e5\u8be2\u4e0e\u6279\u5904\u7406\uff0c\u5bf9\u4e8e OLTP \u548c OLAP \u90fd\u5177\u5907\u6781\u81f4\u6027\u80fd\u3002
\u4f01\u4e1a\u7ea7\u9ad8\u53ef\u7528
\u5728\u9886\u5148\u7684 Multi-Raft \u590d\u5236\u72b6\u6001\u673a\u6a21\u578b\u4e0b\u5efa\u7acb\u5f3a\u4e00\u81f4\u5171\u4eab\u65e5\u5fd7\uff0c\u53ef\u5728\u907f\u514d\u6570\u636e\u91cd\u590d\u7684\u540c\u65f6\u4fdd\u8bc1\u96c6\u7fa4\u7684\u9ad8\u53ef\u7528\u3002
\u81ea\u5e26\u591a\u79df\u6237\u529f\u80fd\uff0c\u79df\u6237\u65e2\u76f8\u4e92\u9694\u79bb\uff0c\u72ec\u7acb\u6269\u7f29\u5bb9\u53c8\u53ef\u8fdb\u884c\u7edf\u4e00\u7ba1\u7406\uff0c\u7b80\u5316\u4e0a\u5c42\u5e94\u7528\u7684\u591a\u79df\u6237\u8bbe\u8ba1\u590d\u6742\u5ea6\u3002
MatrixOne \u4e0e MySQL8.0 \u9ad8\u5ea6\u517c\u5bb9\uff0c\u5305\u62ec\u4f20\u8f93\u534f\u8bae\uff0cSQL \u8bed\u6cd5\u548c\u751f\u6001\u5de5\u5177\uff0c\u964d\u4f4e\u4f7f\u7528\u548c\u8fc1\u79fb\u95e8\u69db\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_6","title":"\u9ad8\u6027\u4ef7\u6bd4","text":"\u4ee5\u6210\u672c\u4f4e\u5ec9\u7684\u5bf9\u8c61\u5b58\u50a8\u4f5c\u4e3a\u4e3b\u5b58\u50a8\uff0c\u901a\u8fc7\u7ea0\u5220\u7801\u6280\u672f\u4ec5\u9700\u8981 150% \u5de6\u53f3\u7684\u6570\u636e\u5197\u4f59\u5373\u53ef\u5b9e\u73b0\u9ad8\u53ef\u7528\uff0c\u540c\u65f6\u63d0\u4f9b\u9ad8\u901f\u7f13\u5b58\u80fd\u529b\uff0c\u901a\u8fc7\u51b7\u70ed\u5206\u79bb\u591a\u7ea7\u5b58\u50a8\u65b9\u6848\u517c\u987e\u6210\u672c\u548c\u6027\u80fd\u3002
\u7528\u6237\u53ef\u4ee5\u6839\u636e\u4e1a\u52a1\u60c5\u51b5\u81ea\u7531\u8c03\u6574\u4e3a OLTP \u53ca OLAP \u5206\u914d\u7684\u8d44\u6e90\u6bd4\u4f8b\uff0c\u5b9e\u73b0\u8d44\u6e90\u6700\u5927\u5316\u5229\u7528\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_7","title":"\u4f01\u4e1a\u7ea7\u5b89\u5168\u5408\u89c4","text":"\u7b80\u5316\u6570\u636e\u5f00\u53d1\u548c\u8fd0\u7ef4
\u968f\u7740\u4e1a\u52a1\u53d1\u5c55\uff0c\u4f01\u4e1a\u4f7f\u7528\u7684\u6570\u636e\u5f15\u64ce\u548c\u4e2d\u95f4\u4ef6\u8d8a\u6765\u8d8a\u591a\uff0c\u800c\u6bcf\u4e00\u4e2a\u6570\u636e\u5f15\u64ce\u5e73\u5747\u4f9d\u8d56 5+ \u4e2a\u57fa\u7840\u7ec4\u4ef6\uff0c\u5b58\u50a8 3+ \u4e2a\u6570\u636e\u526f\u672c\uff0c\u6bcf\u4e00\u4e2a\u6570\u636e\u5f15\u64ce\u90fd\u8981\u5404\u81ea\u5b89\u88c5\u3001\u76d1\u63a7\u3001\u8865\u4e01\u548c\u5347\u7ea7\u3002\u8fd9\u4e9b\u90fd\u5bfc\u81f4\u6570\u636e\u5f15\u64ce\u7684\u9009\u578b\u3001\u5f00\u53d1\u53ca\u8fd0\u7ef4\u6210\u672c\u9ad8\u6602\u4e14\u4e0d\u53ef\u63a7\u3002\u5728 MatrixOne \u7684\u4e00\u4f53\u5316\u67b6\u6784\u4e0b\uff0c\u7528\u6237\u4f7f\u7528\u5355\u4e2a\u6570\u636e\u5e93\u5373\u53ef\u670d\u52a1\u591a\u79cd\u6570\u636e\u5e94\u7528\uff0c\u5f15\u5165\u7684\u6570\u636e\u7ec4\u4ef6\u548c\u6280\u672f\u6808\u51cf\u5c11 80%\uff0c\u5927\u5927\u7b80\u5316\u4e86\u6570\u636e\u5e93\u7ba1\u7406\u548c\u7ef4\u62a4\u7684\u6210\u672c\u3002
\u6d88\u51cf\u6570\u636e\u788e\u7247\u548c\u4e0d\u4e00\u81f4
\u5728\u65e2\u6709\u590d\u6742\u7684\u7cfb\u7edf\u67b6\u6784\u5185\uff0c\u5b58\u5728\u591a\u6761\u6570\u636e\u7ba1\u9053\u591a\u4efd\u6570\u636e\u5b58\u50a8\u5197\u4f59\u3002\u6570\u636e\u4f9d\u8d56\u590d\u6742\uff0c\u5bfc\u81f4\u6570\u636e\u66f4\u65b0\u7ef4\u62a4\u590d\u6742\uff0c\u4e0a\u4e0b\u6e38\u6570\u636e\u4e0d\u4e00\u81f4\u95ee\u9898\u9891\u53d1\uff0c\u4eba\u5de5\u6821\u5bf9\u96be\u5ea6\u589e\u5927\u3002MatrixOne \u7684\u9ad8\u5185\u805a\u67b6\u6784\u548c\u72ec\u6709\u7684\u589e\u91cf\u7269\u5316\u89c6\u56fe\u80fd\u529b\uff0c\u4f7f\u5f97\u4e0b\u6e38\u53ef\u4ee5\u652f\u6301\u4e0a\u6e38\u6570\u636e\u7684\u5b9e\u65f6\u66f4\u65b0\uff0c\u6446\u8131\u5197\u4f59\u7684 ETL \u6d41\u7a0b\uff0c\u5b9e\u73b0\u7aef\u5230\u7aef\u5b9e\u65f6\u6570\u636e\u5904\u7406\u3002
\u65e0\u9700\u7ed1\u5b9a\u57fa\u7840\u8bbe\u65bd
\u56e0\u4e3a\u57fa\u7840\u8bbe\u65bd\u7684\u788e\u7247\u5316\uff0c\u4f01\u4e1a\u7684\u79c1\u6709\u5316\u6570\u636e\u96c6\u7fa4\u548c\u516c\u6709\u4e91\u6570\u636e\u96c6\u7fa4\u4e4b\u95f4\u6570\u636e\u67b6\u6784\u548c\u5efa\u8bbe\u65b9\u6848\u5272\u88c2\uff0c\u6570\u636e\u8fc1\u79fb\u6210\u672c\u9ad8\u3002\u800c\u6570\u636e\u4e0a\u4e91\u4e00\u65e6\u9009\u578b\u786e\u5b9a\u6570\u636e\u5e93\u5382\u5546\uff0c\u540e\u7eed\u7684\u96c6\u7fa4\u6269\u5bb9\u3001\u5176\u4ed6\u7ec4\u4ef6\u91c7\u8d2d\u7b49\u90fd\u5c06\u88ab\u65e2\u6709\u5382\u5546\u7ed1\u5b9a\u3002MatrixOne \u63d0\u4f9b\u7edf\u4e00\u7684\u4e91\u8fb9\u57fa\u7840\u67b6\u6784\u548c\u9ad8\u6548\u7edf\u4e00\u7684\u6570\u636e\u7ba1\u7406\uff0c\u4f01\u4e1a\u6570\u636e\u67b6\u6784\u4e0d\u518d\u88ab\u57fa\u7840\u8bbe\u65bd\u7ed1\u5b9a\uff0c\u5b9e\u73b0\u5355\u6570\u636e\u96c6\u7fa4\u8de8\u4e91\u65e0\u611f\u77e5\u6269\u7f29\u5bb9\uff0c\u63d0\u5347\u6027\u4ef7\u6bd4\u3002
\u6781\u901f\u7684\u5206\u6790\u6027\u80fd
\u76ee\u524d\uff0c\u7531\u4e8e\u7f13\u6162\u7684\u590d\u6742\u67e5\u8be2\u6027\u80fd\u4ee5\u53ca\u5197\u4f59\u7684\u4e2d\u95f4\u8868\uff0c\u6570\u636e\u4ed3\u5e93\u5728\u4e1a\u52a1\u654f\u6377\u6027\u4e0a\u7684\u8868\u73b0\u4e0d\u5c3d\u4eba\u610f\uff0c\u5927\u91cf\u5bbd\u8868\u7684\u521b\u5efa\u4e5f\u4e25\u91cd\u5f71\u54cd\u8fed\u4ee3\u901f\u5ea6\u3002MatrixOne \u901a\u8fc7\u7279\u6709\u7684\u56e0\u5b50\u5316\u8ba1\u7b97\u548c\u5411\u91cf\u5316\u6267\u884c\u5f15\u64ce\uff0c\u652f\u6301\u6781\u901f\u7684\u590d\u6742\u67e5\u8be2\uff0c\u5355\u8868\u3001\u661f\u578b\u548c\u96ea\u82b1\u67e5\u8be2\u90fd\u5177\u5907\u6781\u901f\u5206\u6790\u6027\u80fd\u3002
\u50cf TP \u4e00\u6837\u53ef\u9760\u7684 AP \u4f53\u9a8c
\u4f20\u7edf\u6570\u636e\u4ed3\u5e93\u6570\u636e\u66f4\u65b0\u4ee3\u4ef7\u975e\u5e38\u9ad8\uff0c\u5f88\u96be\u505a\u5230\u6570\u636e\u66f4\u65b0\u5373\u53ef\u89c1\u3002\u5728\u8425\u9500\u98ce\u63a7\uff0c\u65e0\u4eba\u9a7e\u9a76\uff0c\u667a\u80fd\u5de5\u5382\u7b49\u5b9e\u65f6\u8ba1\u7b97\u8981\u6c42\u9ad8\u7684\u573a\u666f\u6216\u8005\u4e0a\u6e38\u6570\u636e\u53d8\u5316\u5feb\u7684\u573a\u666f\u4e2d\uff0c\u5f53\u524d\u7684\u5927\u6570\u636e\u5206\u6790\u7cfb\u7edf\u65e0\u6cd5\u652f\u6301\u589e\u91cf\u66f4\u65b0\uff0c\u5f80\u5f80\u9700\u8981\u505a\u5168\u91cf\u7684\u66f4\u65b0\uff0c\u8017\u65f6\u8017\u529b\u3002MatrixOne \u901a\u8fc7\u63d0\u4f9b\u8de8\u5b58\u50a8\u5f15\u64ce\u7684\u9ad8\u6027\u80fd\u5168\u5c40\u5206\u5e03\u5f0f\u4e8b\u52a1\u80fd\u529b\uff0c\u652f\u6301\u6761\u7ea7\u522b\u7684\u5b9e\u65f6\u589e\u91cf\u66f4\u65b0\uff0c\u5728\u4fdd\u8bc1\u6781\u901f\u5206\u6790\u6027\u80fd\u7684\u540c\u65f6\u652f\u6301\u66f4\u65b0\u3001\u5220\u9664\u548c\u5b9e\u65f6\u70b9\u67e5\u8be2\u3002
\u4e0d\u505c\u670d\u81ea\u52a8\u6269\u7f29\u5bb9
\u4f20\u7edf\u6570\u4ed3\u65e0\u6cd5\u517c\u987e\u6027\u80fd\u548c\u7075\u6d3b\u5ea6\uff0c\u6027\u4ef7\u6bd4\u65e0\u6cd5\u505a\u5230\u6700\u4f18\u3002MatrixOne \u57fa\u4e8e\u5b58\u7b97\u5206\u79bb\u7684\u6280\u672f\u67b6\u6784\uff0c\u652f\u6301\u5b58\u50a8\u8282\u70b9\u4e0e\u8ba1\u7b97\u8282\u70b9\u72ec\u7acb\u6269\u7f29\u5bb9\uff0c\u9ad8\u6548\u5e94\u5bf9\u8d1f\u8f7d\u53d8\u5316\u3002
\u4f01\u4e1a\u5e38\u7528\u7684\u4e1a\u52a1\u7cfb\u7edf\uff0c\u5982 OA\uff0cERP\uff0cCRM \u7b49\u7cfb\u7edf\u968f\u7740\u4e1a\u52a1\u7684\u53d1\u5c55\u6570\u636e\u91cf\u589e\u5927\uff0c\u4f20\u7edf\u7684\u5355\u673a\u6570\u636e\u5e93\u65e0\u6cd5\u6ee1\u8db3\u5176\u6027\u80fd\u9700\u6c42\uff0c\u5c24\u5176\u5728\u7279\u6b8a\u65f6\u95f4\u70b9\u7684\u4e1a\u52a1\u5206\u6790\u9700\u6c42\uff0c\u5f88\u591a\u4f01\u4e1a\u4f1a\u4e13\u95e8\u914d\u5907\u4e00\u5957\u5206\u6790\u6570\u636e\u5e93\u7cfb\u7edf\u6765\u6ee1\u8db3\u6708\u672b\uff0c\u5b63\u672b\u7b49\u91cd\u8981\u8282\u70b9\u7684\u7edf\u8ba1\u62a5\u8868\u9700\u6c42\u3002\u8fd9\u79cd\u573a\u666f\u91c7\u7528 MatrixOne \u6570\u636e\u5e93\u53ef\u4ee5\u7528\u4e00\u5957\u6570\u636e\u5e93\u540c\u65f6\u6ee1\u8db3\u4e1a\u52a1\u7cfb\u7edf\u548c\u5206\u6790\u7cfb\u7edf\u7684\u9700\u6c42\uff0c\u540c\u65f6\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u968f\u7740\u4e1a\u52a1\u589e\u957f\u53ef\u4ee5\u65e0\u7f1d\u6269\u5bb9\u3002
\u9488\u5bf9\u4f01\u4e1a\u5178\u578b\u7684 OLAP \u7c7b\u578b\u5e94\u7528\uff0c\u5982\u770b\u677f\u3001BI \u62a5\u8868\u7b49\u5206\u6790\u7cfb\u7edf\uff0c\u5f80\u5f80\u9700\u8981\u8fdb\u884c\u6d77\u91cf\u6570\u636e\u7684\u5206\u6790\uff0c\u6570\u636e\u91cf\u4e00\u65e6\u8f83\u4e3a\u5e9e\u5927\u5219\u4f1a\u9762\u4e34\u6027\u80fd\u74f6\u9888\uff0c\u5bfc\u81f4\u65f6\u6548\u6027\u8f83\u5dee\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u5206\u6790\u6027\u80fd\u548c\u53ef\u6269\u5c55\u80fd\u529b\uff0c\u53ef\u4ee5\u9488\u5bf9\u5404\u7c7b\u590d\u6742\u548c\u6570\u636e\u91cf\u5e9e\u5927\u7684 SQL \u67e5\u8be2\u8fdb\u884c\u52a0\u901f\uff0c\u83b7\u5f97\u79d2\u7ea7\u4f53\u9a8c\u7684\u6548\u679c\uff0c\u63d0\u9ad8\u4f01\u4e1a\u51b3\u7b56\u5206\u6790\u7684\u654f\u6377\u5ea6\u3002
\u968f\u7740\u4f20\u611f\u5668\u548c\u7f51\u7edc\u6280\u672f\u7684\u5927\u91cf\u5e94\u7528\uff0c\u6d77\u91cf\u7684\u5404\u7c7b IoT \u8bbe\u5907\u751f\u4ea7\u4e86\u5927\u91cf\u7684\u6570\u636e\uff0c\u6bd4\u5982\u5236\u9020\u4e1a\u5de5\u5382\u4ea7\u7ebf\uff0c\u65b0\u80fd\u6e90\u6c7d\u8f66\uff0c\u57ce\u5e02\u5b89\u9632\u76d1\u63a7\u6444\u50cf\u5934\u7b49\u7b49\uff0c\u5176\u89c4\u6a21\u53ef\u80fd\u8f7b\u6613\u80fd\u8fbe\u5230\u6570\u767e TB \u751a\u81f3 PB \u7ea7\u522b\uff0c\u800c\u5bf9\u6570\u5b57\u5316\u7684\u9700\u6c42\u4e5f\u8d8a\u6765\u8d8a\u591a\u7684\u8981\u6c42\u4f01\u4e1a\u5b58\u50a8\u548c\u5229\u7528\u8fd9\u4e9b\u6570\u636e\u3002\u4f46\u662f\u4f20\u7edf\u7684\u6570\u636e\u5e93\u65b9\u6848\u65e0\u6cd5\u6ee1\u8db3\u5982\u6b64\u6d77\u91cf\u4e14\u5927\u89c4\u6a21\u7684\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u4ee5\u53ca\u52a0\u5de5\u5e94\u7528\u7684\u573a\u666f\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u6d41\u5f0f\u6570\u636e\u5199\u5165\u548c\u52a0\u5de5\u7684\u80fd\u529b\uff0c\u540c\u65f6\u5f3a\u5927\u7684\u53ef\u6269\u5c55\u6027\u53ef\u4ee5\u9002\u5e94\u4efb\u610f\u89c4\u6a21\u7684\u8d1f\u8f7d\u548c\u6570\u636e\u91cf\uff0c\u53ef\u4ee5\u5b8c\u5168\u6ee1\u8db3\u8be5\u573a\u666f\u7684\u9700\u6c42\u3002
\u4e2d\u5927\u578b\u4f01\u4e1a\u5f80\u5f80\u6709\u5f88\u591a\u5957\u4e1a\u52a1\u7cfb\u7edf\uff0c\u4e3a\u4e86\u7edf\u4e00\u5206\u6790\u548c\u6253\u901a\u5404\u7c7b\u6570\u636e\uff0c\u5f88\u591a\u4f01\u4e1a\u4f1a\u5efa\u8bbe\u4e00\u4e2a\u6253\u901a\u5404\u4e2a\u7cfb\u7edf\u6570\u636e\u6e90\u7684\u6570\u636e\u4e2d\u53f0\uff0c\u4ee5\u5168\u9762\u7684\u4e86\u89e3\u4f01\u4e1a\u7684\u6574\u4f53\u72b6\u51b5\u3002\u4f20\u7edf\u627f\u8f7d\u6570\u636e\u4e2d\u53f0\u7684\u89e3\u51b3\u65b9\u6848\u90fd\u662f\u57fa\u4e8e Hadoop \u4f53\u7cfb\uff0c\u4f46\u662f Hadoop \u7ec4\u4ef6\u6781\u4e3a\u590d\u6742\uff0c\u6709\u8f83\u9ad8\u7684\u5f00\u53d1\u548c\u8fd0\u7ef4\u95e8\u69db\uff0c\u5bf9\u4e8e\u5f88\u591a\u4f01\u4e1a\u6765\u8bf4\u6210\u672c\u592a\u9ad8\u3002MatrixOne \u7684\u4e00\u7ad9\u5f0f HTAP \u67b6\u6784\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u4ee5\u4f7f\u7528 MySQL \u4e00\u6837\u7684\u5f62\u5f0f\u6765\u4f7f\u7528\u4e00\u4e2a\u6570\u636e\u4e2d\u53f0\uff0c\u76f4\u63a5\u5728 MatrixOne \u4e2d\u5bf9\u6d77\u91cf\u6570\u636e\u8fdb\u884c SQL \u5206\u6790\u83b7\u5f97\u62a5\u8868\uff0c\u6781\u5927\u7684\u964d\u4f4e\u4e86\u6210\u672c\u3002
\u5bf9\u4e8e\u6e38\u620f\uff0c\u7535\u5546\uff0c\u6587\u5a31\uff0c\u793e\u4ea4\uff0c\u65b0\u95fb\u7b49\u4e92\u8054\u7c7b\u5e94\u7528\u6765\u8bf4\uff0c\u7528\u6237\u6570\u91cf\u5e9e\u5927\u4e14\u4e1a\u52a1\u6ce2\u52a8\u5267\u70c8\u800c\u9891\u7e41\uff0c\u5728\u70ed\u95e8\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u5019\uff0c\u5f80\u5f80\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u6765\u652f\u6491\u4e1a\u52a1\u9700\u6c42\u3002MatrixOne \u5b8c\u5168\u4e91\u539f\u751f\u5316\u7684\u67b6\u6784\u5177\u5907\u8d85\u5f3a\u7684\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u8ddf\u968f\u4e1a\u52a1\u7684\u53d8\u5316\u81ea\u52a8\u7684\u5feb\u901f\u6269\u7f29\u5bb9\uff0c\u6781\u5927\u7684\u964d\u4f4e\u7528\u6237\u7684\u8fd0\u7ef4\u96be\u5ea6\u3002
\u4f01\u4e1a\u7ea7 SaaS \u5e94\u7528\u5728\u8fd1\u51e0\u5e74\u6210\u7206\u53d1\u5f0f\u7684\u589e\u957f\u8d8b\u52bf\uff0cSaaS \u7684\u5e94\u7528\u5f00\u53d1\u4e2d\u90fd\u9700\u8981\u8003\u8651\u81ea\u5df1\u7684\u591a\u79df\u6237\u6a21\u578b\uff0c\u4f20\u7edf\u7684\u65b9\u6848\u4e2d\u4f1a\u6709\u591a\u79df\u6237\u5171\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u548c\u5355\u79df\u6237\u72ec\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u4e24\u79cd\u6a21\u5f0f\uff0c\u4f46\u662f\u4f1a\u9762\u4e34\u7ba1\u7406\u6210\u672c\u548c\u9694\u79bb\u6027\u7684\u4e24\u96be\u9009\u62e9\u3002MatrixOne \u81ea\u5e26\u591a\u79df\u6237\u80fd\u529b\uff0c\u79df\u6237\u4e4b\u95f4\u5929\u7136\u8d1f\u8f7d\u9694\u79bb\u4e14\u53ef\u4ee5\u72ec\u7acb\u6269\u5c55\uff0c\u540c\u65f6\u53c8\u63d0\u4f9b\u4e86\u7edf\u4e00\u7ba1\u7406\u80fd\u529b\uff0c\u53ef\u4ee5\u517c\u987e\u4f01\u4e1a\u5bf9\u6210\u672c\uff0c\u7ba1\u7406\u7b80\u6613\u5ea6\u548c\u9694\u79bb\u6027\u7684\u9700\u6c42\uff0c\u662f SaaS \u5e94\u7528\u7684\u6700\u4f73\u9009\u62e9\u3002
"},{"location":"MatrixOne/Overview/matrixone-introduction/#_10","title":"\u76f8\u5173\u4fe1\u606f","text":"\u672c\u8282\u63cf\u8ff0\u4e86 MatrixOne \u7684\u57fa\u672c\u4ecb\u7ecd\uff0c\u5982\u679c\u60a8\u60f3\u4e86\u89e3\u5176\u4ed6\u66f4\u591a\u5173\u4e8e MatrixOne \u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u4ee5\u4e0b\u5185\u5bb9\uff1a
MatrixOne \u7684\u6700\u65b0\u7248\u672c\u4e3a 1.2.1\uff0c\u53d1\u5e03\u4e8e 2024 \u5e74 06 \u6708 30 \u65e5\uff0c\u8be6\u60c5\u8bf7\u89c1\uff1a
MatrixOne \u662f\u4e00\u6b3e\u9762\u5411\u672a\u6765\u7684\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0c\u901a\u8fc7\u7b80\u5316\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u5f15\u64ce\uff0c\u8de8\u591a\u4e2a\u6570\u636e\u4e2d\u5fc3\u3001\u4e91\u3001\u8fb9\u7f18\u548c\u5176\u4ed6\u5f02\u6784\u57fa\u7840\u8bbe\u65bd\uff0c\u540c\u65f6\u652f\u6301\u4e8b\u52a1\u6027\uff08OLTP\uff09\u3001\u5206\u6790\u6027\uff08OLAP\uff09\u548c\u6d41\u5f0f\u5de5\u4f5c\uff08Sreaming\uff09\u8d1f\u8f7d\uff0c\u8fd9\u79cd\u591a\u79cd\u5f15\u64ce\u7684\u878d\u5408\uff0c\u79f0\u4e3a HSTAP\u3002
MatrixOne HSTAP \u6570\u636e\u5e93\u5bf9 HTAP \u6570\u636e\u5e93\u8fdb\u884c\u4e86\u91cd\u65b0\u5b9a\u4e49\uff0cHSTAP \u65e8\u5728\u6ee1\u8db3\u5355\u4e00\u6570\u636e\u5e93\u5185\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u548c\u5206\u6790\u5904\u7406\uff08AP\uff09\u7684\u6240\u6709\u9700\u6c42\u3002\u4e0e\u4f20\u7edf\u7684 HTAP \u76f8\u6bd4\uff0cHSTAP \u5f3a\u8c03\u5176\u5185\u7f6e\u7684\u7528\u4e8e\u8fde\u63a5 TP \u548c AP \u8868\u6570\u636e\u6d41\u5904\u7406\u80fd\u529b\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u6570\u636e\u5e93\u53ef\u4ee5\u50cf\u5927\u6570\u636e\u5e73\u53f0\u4e00\u6837\u7075\u6d3b\u7684\u4f7f\u7528\u4f53\u9a8c\u3002\u4e5f\u6070\u6070\u5f97\u76ca\u4e8e\u5927\u6570\u636e\u7684\u7e41\u8363\uff0c\u5f88\u591a\u7528\u6237\u5df2\u7ecf\u719f\u6089\u4e86\u8fd9\u79cd\u4f53\u9a8c\u3002\u7528\u6237\u4f7f\u7528 MatrixOne \u53ea\u9700\u8981\u5c11\u91cf\u7684\u96c6\u6210\u5de5\u4f5c\uff0c\u5373\u53ef\u4ee5\u83b7\u5f97\u8986\u76d6\u6574\u4e2a TP \u548c AP \u573a\u666f\u7684\u4e00\u7ad9\u5f0f\u4f53\u9a8c\uff0c\u540c\u65f6\u53ef\u4ee5\u6446\u8131\u4f20\u7edf\u5927\u6570\u636e\u5e73\u53f0\u7684\u81c3\u80bf\u67b6\u6784\u53ca\u5404\u79cd\u9650\u5236\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone_2","title":"MatrixOne \u67b6\u6784\u5c42\u7ea7","text":"MatrixOne \u5b9e\u73b0\u4e86\u4e09\u4e2a\u72ec\u7acb\u7684\u5c42\u7ea7\uff0c\u6bcf\u4e2a\u5c42\u7ea7\u90fd\u6709\u81ea\u5df1\u7684\u5bf9\u8c61\u5355\u5143\u548c\u5206\u5de5\u3002\u4e0d\u540c\u7c7b\u578b\u7684\u8282\u70b9\u53ef\u4ee5\u81ea\u7531\u4f38\u7f29\uff0c\u4e0d\u518d\u53d7\u5230\u5176\u4ed6\u5c42\u7684\u5236\u7ea6\u3002\u8fd9\u4e09\u4e2a\u5c42\u7ea7\u662f\uff1a
\u5728\u786e\u5b9a\u4e86 TAE \u4f5c\u4e3a\u552f\u4e00\u5b58\u50a8\u5f15\u64ce\u4e4b\u540e\uff0c\u5bf9\u878d\u5408\u540e\u7684 TAE \u5f15\u64ce\u8fdb\u884c\u4e86\u591a\u9879\u8bbe\u8ba1\u4e0a\u7684\u8c03\u6574\uff0c\u624d\u6709\u4e86\u540e\u6765\u7684 TAE \u5b58\u50a8\u5f15\u64ce\u3002\u8fd9\u4e2a\u5f15\u64ce\u5177\u6709\u5982\u4e0b\u4f18\u52bf\uff1a
\u8ba1\u7b97\u5f15\u64ce\u57fa\u4e8e\u517c\u5bb9 MySQL \u7684\u6839\u672c\u76ee\u6807\uff0c\u5bf9\u4e8e\u8282\u70b9\u8c03\u5ea6\u3001\u6267\u884c\u8ba1\u5212\u548c SQL \u80fd\u529b\u6709\u7740\u66f4\u9ad8\u7684\u8981\u6c42\u3002\u9ad8\u6027\u80fd\u8ba1\u7b97\u5f15\u64ce\u65e2\u5177\u5907\u5b9e\u9a8c\u67b6\u6784\u4e2d\u8ba1\u7b97\u5f15\u64ce\u7684 MPP\uff1a
MatrixOne \u67b6\u6784\u5982\u4e0b\u5982\u6240\u793a\uff1a
\u53c2\u7167\u4e0a\u9762\u7684\u56fe\u793a\uff0cMatrixOne \u7684\u4f53\u7cfb\u7ed3\u6784\u5206\u4e3a\u4e94\u5c42\uff0c\u4ee5\u4e0b\u5185\u5bb9\u662f\u4ece\u4e0a\u81f3\u4e0b\u5bf9\u6bcf\u5c42\u7684\u4ecb\u7ecd\uff1a
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#_1","title":"\u96c6\u7fa4\u7ba1\u7406\u5c42","text":"\u8fd9\u4e00\u5c42\u8d1f\u8d23\u96c6\u7fa4\u7ba1\u7406\uff0c\u5728\u4e91\u539f\u751f\u73af\u5883\u4e2d\u4e0e Kubernetes \u4ea4\u4e92\u52a8\u6001\u83b7\u53d6\u8d44\u6e90\uff1b\u5728\u672c\u5730\u90e8\u7f72\u65f6\uff0c\u6839\u636e\u914d\u7f6e\u83b7\u53d6\u8d44\u6e90\u3002\u96c6\u7fa4\u72b6\u6001\u6301\u7eed\u76d1\u63a7\uff0c\u6839\u636e\u8d44\u6e90\u4fe1\u606f\u5206\u914d\u6bcf\u4e2a\u8282\u70b9\u7684\u4efb\u52a1\u3002\u63d0\u4f9b\u7cfb\u7edf\u7ef4\u62a4\u670d\u52a1\u4ee5\u786e\u4fdd\u6240\u6709\u7cfb\u7edf\u7ec4\u4ef6\u5728\u5076\u5c14\u51fa\u73b0\u8282\u70b9\u548c\u7f51\u7edc\u6545\u969c\u7684\u60c5\u51b5\u4e0b\u6b63\u5e38\u8fd0\u884c\uff0c\u5e76\u5728\u5fc5\u8981\u65f6\u91cd\u65b0\u5e73\u8861\u8282\u70b9\u4e0a\u7684\u8d1f\u8f7d\u3002\u96c6\u7fa4\u7ba1\u7406\u5c42\u7684\u4e3b\u8981\u7ec4\u4ef6\u662f\uff1a
Serverless \u5c42\u662f\u4e00\u7cfb\u5217\u65e0\u72b6\u6001\u8282\u70b9\u7684\u603b\u79f0\uff0c\u6574\u4f53\u4e0a\u5305\u542b\u4e09\u7c7b\uff1a
\u4f5c\u4e3a MatrixOne \u7684\u5355\u4e00\u6570\u636e\u6e90 (\u5373 Single source of truth)\uff0c\u6570\u636e\u4e00\u65e6\u5199\u5165\u65e5\u5fd7\u5c42\uff0c\u5219\u5c06\u6c38\u4e45\u5730\u5b58\u50a8\u5728 MatrixOne \u4e2d\u3002\u5b83\u5efa\u7acb\u5728\u6211\u4eec\u4e16\u754c\u7ea7\u7684\u590d\u5236\u72b6\u6001\u673a\u6a21\u578b\u7684\u4e13\u4e1a\u77e5\u8bc6\u4e4b\u4e0a\uff0c\u4ee5\u4fdd\u8bc1\u6211\u4eec\u7684\u6570\u636e\u5177\u6709\u6700\u5148\u8fdb\u7684\u9ad8\u541e\u5410\u91cf\u3001\u9ad8\u53ef\u7528\u6027\u548c\u5f3a\u4e00\u81f4\u6027\u3002\u5b83\u672c\u8eab\u9075\u5faa\u5b8c\u5168\u6a21\u5757\u5316\u548c\u5206\u89e3\u7684\u8bbe\u8ba1\uff0c\u4e5f\u5e2e\u52a9\u89e3\u8026\u5b58\u50a8\u548c\u8ba1\u7b97\u5c42\u7684\u6838\u5fc3\u7ec4\u4ef6\uff0c\u4e0e\u4f20\u7edf\u7684 NewSQL \u67b6\u6784\u76f8\u6bd4\uff0c\u6211\u4eec\u7684\u67b6\u6784\u5177\u6709\u66f4\u9ad8\u7684\u5f39\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#_3","title":"\u5b58\u50a8\u5c42","text":"\u5b58\u50a8\u5c42\u5c06\u6765\u81ea\u65e5\u5fd7\u5c42\u7684\u4f20\u5165\u6570\u636e\u8f6c\u6362\u4e3a\u6709\u6548\u7684\u5f62\u5f0f\uff0c\u4ee5\u4f9b\u5c06\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u548c\u5b58\u50a8\u3002\u5305\u62ec\u4e3a\u5feb\u901f\u8bbf\u95ee\u5df2\u5199\u5165 S3 \u7684\u6570\u636e\u8fdb\u884c\u7684\u7f13\u5b58\u7ef4\u62a4\u7b49\u3002
\u5728 MatrixOne \u4e2d\uff0cTAE\uff08\u5373 Transactional Analytic Engine\uff09\u5b58\u50a8\u5f15\u64ce\u662f\u5b58\u50a8\u5c42\u7684\u4e3b\u8981\u516c\u5f00\u63a5\u53e3\uff0c\u5b83\u53ef\u4ee5\u540c\u65f6\u652f\u6301\u884c\u548c\u5217\u5b58\u50a8\u4ee5\u53ca\u4e8b\u52a1\u5904\u7406\u80fd\u529b\u3002\u6b64\u5916\uff0c\u5b58\u50a8\u5c42\u8fd8\u5305\u62ec\u5176\u4ed6\u5185\u90e8\u4f7f\u7528\u7684\u5b58\u50a8\u529f\u80fd\uff0c\u4f8b\u5982\u6d41\u5a92\u4f53\u7684\u4e2d\u95f4\u5b58\u50a8\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#_4","title":"\u5b58\u50a8\u4f9b\u5e94\u5c42","text":"\u4f5c\u4e3a\u4e0e\u57fa\u7840\u67b6\u6784\u89e3\u8026\u7684 DBMS\uff0cMatrixOne \u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5728 S3/HDFS\u3001\u672c\u5730\u78c1\u76d8\u3001\u672c\u5730\u670d\u52a1\u5668\u3001\u6df7\u5408\u4e91\u6216\u5176\u4ed6\u5404\u7c7b\u578b\u4e91\uff0c\u4ee5\u53ca\u667a\u80fd\u8bbe\u5907\u7684\u5171\u4eab\u5b58\u50a8\u4e2d\u3002\u5b58\u50a8\u4f9b\u5e94\u5c42\u901a\u8fc7\u4e3a\u4e0a\u5c42\u63d0\u4f9b\u4e00\u4e2a\u7edf\u4e00\u7684\u63a5\u53e3\u6765\u8bbf\u95ee\u8fd9\u4e9b\u591a\u6837\u5316\u7684\u5b58\u50a8\u8d44\u6e90\uff0c\u5e76\u4e14\u4e0d\u5411\u4e0a\u5c42\u66b4\u9732\u5b58\u50a8\u7684\u590d\u6742\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#matrixone_4","title":"MatrixOne \u7cfb\u7edf\u7ec4\u4ef6","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e3a\u5b9e\u73b0\u5206\u5e03\u5f0f\u4e0e\u591a\u5f15\u64ce\u7684\u878d\u5408\uff0c\u6784\u5efa\u4e86\u591a\u79cd\u4e0d\u540c\u7684\u7cfb\u7edf\u7ec4\u4ef6\u7528\u4e8e\u5b8c\u6210\u67b6\u6784\u76f8\u5173\u7684\u5c42\u7ea7\u7684\u529f\u80fd\uff1a
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#file-service","title":"File Service","text":"File Service \u662f MatrixOne \u8d1f\u8d23\u6240\u6709\u5b58\u50a8\u4ecb\u8d28\u8bfb\u5199\u7684\u7ec4\u4ef6\u3002\u5b58\u50a8\u4ecb\u8d28\u5305\u62ec\u5185\u5b58\u3001\u78c1\u76d8\u3001\u5bf9\u8c61\u5b58\u50a8\u7b49\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Log Service \u662f MatrixOne \u4e2d\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u4e8b\u52a1\u65e5\u5fd7\u7684\u7ec4\u4ef6\uff0c\u5b83\u5177\u6709\u5982\u4e0b\u529f\u80fd\u7279\u6027\uff1a
Transaction Node\uff08TN)\uff0c\u662f\u7528\u6765\u8fd0\u884c MatrixOne \u7684\u5206\u5e03\u5f0f\u5b58\u50a8\u5f15\u64ce TAE \u7684\u8f7d\u4f53\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Computing Node\uff08CN)\uff0c\u662f Matrixone \u63a5\u6536\u7528\u6237\u8bf7\u6c42\u5e76\u5904\u7406 SQL \u7684\u7ec4\u4ef6\uff0c\u5177\u4f53\u5305\u62ec\u4ee5\u4e0b\u6a21\u5757\uff1a
Stream Engine \u662f MatrixOne \u5185\u7f6e\u7684\u5168\u65b0\u7ec4\u4ef6\uff0c\u65e8\u5728\u652f\u6301\u5b9e\u65f6\u6570\u636e\u67e5\u8be2\u3001\u5904\u7406\u4ee5\u53ca\u589e\u5f3a\u6570\u636e\u5b58\u50a8\uff0c\u7279\u522b\u9488\u5bf9\u4f20\u5165\u7684\u6570\u636e\u6d41\uff08\u6570\u636e\u70b9\u5e8f\u5217\uff09\u3002\u501f\u52a9 Stream Engine\uff0c\u60a8\u80fd\u591f\u4f7f\u7528 SQL \u5b9a\u4e49\u5e76\u6784\u5efa\u6d41\u5904\u7406\u7ba1\u9053\uff0c\u5c06\u5176\u4f5c\u4e3a\u5b9e\u65f6\u6570\u636e\u540e\u7aef\u63d0\u4f9b\u670d\u52a1\uff1b\u540c\u65f6\uff0c\u60a8\u4e5f\u80fd\u591f\u8fd0\u7528 SQL \u67e5\u8be2\u6d41\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4e0e\u975e\u6d41\u5f0f\u6570\u636e\u96c6\u8fdb\u884c\u8054\u63a5\uff0c\u4ece\u800c\u66f4\u8fdb\u4e00\u6b65\u5730\u7b80\u5316\u6574\u4e2a\u6570\u636e\u5806\u6808\u7684\u5904\u7406\u6d41\u7a0b\u3002
"},{"location":"MatrixOne/Overview/architecture/1.1-matrixone-architecture-design/#proxy","title":"Proxy","text":"Proxy \u7ec4\u4ef6\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u4e0e SQL \u8def\u7531\u3002\u5b83\u5177\u6709\u4ee5\u4e0b\u529f\u80fd\uff1a
\u672c\u8282\u4ecb\u7ecd\u4e86 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\u6982\u89c8\u3002\u5176\u4ed6\u4fe1\u606f\u53ef\u53c2\u89c1\uff1a
\u5b89\u88c5\u5355\u673a\u7248 MatrixOne
\u6700\u65b0\u53d1\u5e03\u4fe1\u606f
\u6570\u636e\u7f13\u5b58\u53ca\u51b7\u70ed\u6570\u636e\u5206\u79bb\u662f MatrixOne \u7684\u4e00\u9879\u5173\u952e\u7279\u6027\uff0c\u8be5\u7279\u6027\u5c06\u6570\u636e\u5206\u4e3a\u70ed\u6570\u636e\u548c\u51b7\u6570\u636e\uff0c\u4ee5\u4f7f\u7528\u9891\u7387\u4e3a\u533a\u5206\u6807\u51c6\uff0c\u5e76\u5c06\u5b83\u4eec\u4ee5\u4e0d\u540c\u7684\u5b58\u50a8\u65b9\u5f0f\u8fdb\u884c\u7ba1\u7406\u3002\u8fd9\u4e00\u8bbe\u8ba1\u4f7f\u5f97 MatrixOne \u5728\u4fdd\u6301\u4f18\u5f02\u6027\u80fd\u7684\u540c\u65f6\u4e5f\u7ef4\u6301\u4e86\u8f83\u4f4e\u7684\u8fd0\u884c\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_2","title":"\u6280\u672f\u67b6\u6784","text":"\u5728 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\u4e2d\uff0c\u6709\u4e24\u4e2a\u90e8\u5206\u8d1f\u8d23\u6301\u4e45\u5316\u6570\u636e\u5b58\u50a8\uff0c\u4e00\u4e2a\u662f\u5168\u4f53 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u5171\u4eab\u7684\u5bf9\u8c61\u5b58\u50a8\uff0c\u5b83\u4e5f\u662f\u96c6\u7fa4\u7684\u4e3b\u8981\u5b58\u50a8\u8bbe\u5907\uff1b\u53e6\u4e00\u4e2a\u662f\u5404\u8ba1\u7b97\u8282\u70b9\uff08CN\uff09\u4e0a\u7684\u672c\u5730\u5b58\u50a8\uff0c\u4e3b\u8981\u7528\u4e8e\u6570\u636e\u7f13\u5b58\u3002\u4e3b\u5b58\u50a8\u5305\u542b\u6574\u4e2a\u96c6\u7fa4\u7684\u5168\u91cf\u6570\u636e\uff0c\u800c\u7f13\u5b58\u5219\u4ec5\u4fdd\u5b58\u6700\u8fd1\u67e5\u8be2\u65f6\u4ece\u4e3b\u5b58\u50a8\u4e2d\u63d0\u53d6\u7684\u6570\u636e\u3002\u6b64\u5916\uff0cCN \u8282\u70b9\u7684\u5185\u5b58\u4e5f\u4f5c\u4e3a\u6570\u636e\u7f13\u5b58\u7684\u4e00\u90e8\u5206\u6765\u4f7f\u7528\u3002
\u5f53\u7528\u6237\u53d1\u8d77\u67e5\u8be2\u65f6\uff0c\u7cfb\u7edf\u9996\u5148\u4f1a\u68c0\u67e5\u7528\u6237\u6240\u8fde\u63a5\u7684 CN \u7684\u7f13\u5b58\u4e2d\u662f\u5426\u5df2\u7ecf\u5305\u542b\u6240\u9700\u6570\u636e\u3002\u5982\u679c\u5b58\u5728\uff0c\u7cfb\u7edf\u5c06\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u7ed9\u7528\u6237\uff0c\u67e5\u8be2\u4f18\u5148\u7ea7\u662f\u5148\u5185\u5b58\u540e\u78c1\u76d8\u3002\u5982\u679c\u5728\u5f53\u524d\u8fde\u63a5\u7684 CN \u7684\u7f13\u5b58\u4e2d\u6ca1\u6709\u627e\u5230\u6240\u9700\u6570\u636e\uff0c\u7cfb\u7edf\u4f1a\u67e5\u8be2\u5168\u5c40\u5143\u6570\u636e\u4fe1\u606f\uff0c\u770b\u8be5\u7528\u6237\u5176\u4ed6\u53ef\u7528\u7684 CN \u7f13\u5b58\u4e2d\u662f\u5426\u5b58\u5728\u6240\u9700\u6570\u636e\uff0c\u68c0\u67e5\u987a\u5e8f\u540c\u6837\u662f\u5148\u5185\u5b58\u540e\u78c1\u76d8\u3002\u5982\u679c\u5b58\u5728\uff0c\u7cfb\u7edf\u5c06\u8bf7\u6c42\u8f6c\u5411\u5305\u542b\u6b64\u6570\u636e\u7684 CN\uff0c\u7531\u5b83\u5904\u7406\u8bf7\u6c42\uff0c\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u7528\u6237\u3002\u5982\u679c\u6240\u6709\u53ef\u7528 CN \u7684\u7f13\u5b58\u4e2d\u90fd\u6ca1\u6709\u6240\u67e5\u627e\u7684\u6570\u636e\uff0c\u7cfb\u7edf\u5c06\u53d1\u8d77\u5bf9\u5bf9\u8c61\u5b58\u50a8\u7684\u8bfb\u53d6\u8bf7\u6c42\uff0c\u5e76\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u7528\u6237\u3002
\u5f53\u7528\u6237\u67e5\u8be2\u5bf9\u8c61\u5b58\u50a8\u7684\u6570\u636e\u65f6\uff0c\u67e5\u8be2\u5230\u7684\u6570\u636e\u5757 (block) \u4f1a\u6839\u636e\u7f13\u5b58\u7684\u67e5\u8be2\u987a\u5e8f\uff0c\u4f9d\u6b21\u586b\u5145\u5230\u76f8\u5e94\u4f4d\u7f6e\u3002\u4f8b\u5982\uff0c\u7528\u6237\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u67e5\u8be2\u51fa\u4e86 100M \u7684\u6570\u636e\uff0c\u8fd9 100M \u7684\u6570\u636e\u4f1a\u9996\u5148\u5199\u5165\u7528\u6237\u6240\u8fde\u63a5\u7684 CN \u8282\u70b9\u7684\u5185\u5b58\uff0c\u7136\u540e\u518d\u5199\u5165\u8fd9\u4e2a CN \u8282\u70b9\u7684\u78c1\u76d8\u7f13\u5b58\u3002\u6bcf\u6b21\u6709\u65b0\u67e5\u8be2\u4ea7\u751f\u65f6\uff0c\u90fd\u4f1a\u6309\u7167\u8fd9\u4e2a\u89c4\u5219\u66f4\u65b0\u7f13\u5b58\u4e2d\u7684\u6570\u636e\u3002\u65e0\u8bba\u662f\u5185\u5b58\u8fd8\u662f\u78c1\u76d8\uff0cCN \u7f13\u5b58\u4e2d\u6570\u636e\u7684\u66ff\u6362\u90fd\u9075\u5faa LRU\uff08\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\uff09\u539f\u5219\u3002\u901a\u8fc7\u8fd9\u6837\u7684\u673a\u5236\uff0c\u6700\u65b0\u7684\u6570\u636e\u59cb\u7ec8\u5904\u4e8e\u6700\u6613\u83b7\u53d6\u7684\u4f4d\u7f6e\uff0c\u800c\u76f8\u5bf9\u51b7\u95e8\u7684\u6570\u636e\u5219\u4f1a\u9010\u6b65\u4ece\u7f13\u5b58\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_3","title":"\u4ea7\u54c1\u7279\u6027","text":"\u6570\u636e\u7f13\u5b58\u53ca\u51b7\u70ed\u6570\u636e\u5206\u79bb\u7684\u7279\u6027\u4e3a\u4ea7\u54c1\u5e26\u6765\u4e86\u4e00\u4e9b\u72ec\u7279\u4f18\u52bf\u3002\u4e3a\u4e86\u5177\u4f53\u8bf4\u660e\uff0c\u6211\u4eec\u5c06\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u4f8b\u8fdb\u884c\u5c55\u793a\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_4","title":"\u73af\u5883\u914d\u7f6e","text":"\u672c\u7ae0\u6240\u4ecb\u7ecd\u5230\u7684\u73af\u5883\u5c06\u57fa\u4e8e MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72\u7684\u73af\u5883\uff0c\u8bf7\u786e\u4fdd\u6574\u4e2a MatrixOne \u5df2\u7ecf\u5b89\u88c5\u5b8c\u6bd5\u3002
\u51c6\u5907\u4e00\u4e2a\u540d\u4e3a pe
\u7684\u8868\u683c\u4ee5\u53ca\u5bf9\u5e94\u7684 csv \u6570\u636e\u3002\u8fd9\u4e2a csv \u6570\u636e\u8868\u7684\u5927\u5c0f\u4e3a 35.8MB\uff0c\u5171\u6709 1,048,575 \u884c\u6570\u636e\u3002\u6211\u4eec\u5c06\u4f7f\u7528\u4ee5\u4e0b\u7684 SQL \u8bed\u53e5\u521b\u5efa\u4e24\u4e2a\u6570\u636e\u5e93\uff0c\u5e76\u5c06\u76f8\u540c\u7684\u6570\u636e\u8868\u52a0\u8f7d\u81f3\u8fd9\u4e24\u4e2a\u6570\u636e\u5e93\u4e2d\u7684 pe
\u8868\u3002
create database stock;\ndrop table if exists stock.pe;\ncreate table stock.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n\ncreate database stock2;\ndrop table if exists stock2.pe;\ncreate table stock2.pe (\nts_code VARCHAR(255) DEFAULT null,\ntrade_date VARCHAR(255) DEFAULT null,\npe FLOAT DEFAULT null,\npb FLOAT DEFAULT null\n);\nload data local infile '/XXX/pe.csv' into table stock.pe fields TERMINATED BY '\\t';\n
\u63a5\u4e0b\u6765\u8fdb\u884c\u76f8\u5e94\u7684\u7f13\u5b58\u914d\u7f6e\u3002\u5728 MatrixOne \u7684\u96c6\u7fa4 yaml \u8bbe\u7f6e\u4e2d\uff0cTN\u3001Log Service \u4ee5\u53ca CN \u90fd\u6709\u4e0e\u7f13\u5b58\u76f8\u5173\u7684\u8bbe\u7f6e\uff0c\u4f46\u4f60\u53ea\u9700\u5173\u6ce8\u4e0e\u67e5\u8be2\u76f4\u63a5\u76f8\u5173\u7684 CN \u7f13\u5b58\uff0c\u4e3b\u8981\u7684\u7f13\u5b58\u5927\u5c0f\u7531 memoryCacheSize
\u548c diskCacheSize
\u6765\u7ba1\u7406\u3002
metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n# \u4e2d\u95f4\u914d\u7f6e\u7701\u7565\nsharedStorageCache: # \u914d\u7f6e CN \u7f13\u5b58\u7684\u6838\u5fc3\u53c2\u6570\nmemoryCacheSize: 250Mi # CN \u7684\u5185\u5b58\u7f13\u5b58\uff0cMi \u4ee3\u8868 MB\ndiskCacheSize: 1Gi # CN \u7684\u78c1\u76d8\u7f13\u5b58\uff0cGi \u4ee3\u8868 GB\n
\u5f53\u8fd9\u4e24\u4e2a\u53c2\u6570\u90fd\u88ab\u8bbe\u7f6e\u4e3a \"1\" \u65f6\uff0c\u5373\u4ee3\u8868\u5173\u95ed\u4e86\u7f13\u5b58\uff0cMatrixOne \u7684\u6240\u6709\u67e5\u8be2\u8bf7\u6c42\u5c06\u76f4\u63a5\u4e0e\u5e95\u5c42\u5bf9\u8c61\u5b58\u50a8\u8fdb\u884c\u4ea4\u4e92\uff0c\u67e5\u8be2\u6548\u7387\u5c06\u5927\u5927\u964d\u4f4e\u3002
\u4e3a\u4e86\u7b80\u5316\u5c55\u793a\uff0c\u4f60\u53ef\u4ee5\u5728\u6b64\u5148\u5c06\u5185\u5b58\u7f13\u5b58\u5173\u95ed\uff0c\u4ec5\u8bbe\u7f6e\u4e00\u5b9a\u5927\u5c0f\u7684\u78c1\u76d8\u7f13\u5b58\u3002\u7531\u4e8e\u539f\u59cb\u6570\u636e\u5728\u5165\u5e93\u540e\u4f1a\u6839\u636e\u6570\u636e\u7c7b\u578b\u6709\u4e00\u5b9a\u7684\u538b\u7f29\u6bd4\u4f8b\uff0c\u6240\u4ee5\u4f60\u9700\u8981\u5148\u5c06\u5c06\u78c1\u76d8\u7f13\u5b58\u8bbe\u7f6e\u4e3a 20MB\uff0c\u8fd9\u5927\u6982\u8db3\u4ee5\u5b58\u653e\u538b\u7f29\u540e\u7684 35.8MB \u6570\u636e\u6587\u4ef6\u3002
metadata:\nname: mo\nnamespace: mo-hn\nspec:\ncnGroups:\n- name: cn-set1\n##\u7701\u7565\u4e2d\u95f4\u914d\u7f6e\nsharedStorageCache: #\u8c03\u914d CN \u7f13\u5b58\u7684\u6838\u5fc3\u53c2\u6570\nmemoryCacheSize: \"1\" #CN \u7684\u5185\u5b58\u7f13\u5b58\uff0cMi \u4ee3\u8868 MB\ndiskCacheSize: 20Mi #CN \u7684\u78c1\u76d8\u7f13\u5b58\uff0cGi \u4ee3\u8868 GB\n
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_5","title":"\u67e5\u8be2\u52a0\u901f","text":"\u5b8c\u6210\u4ee5\u4e0a\u8bbe\u7f6e\u5e76\u542f\u52a8 MatrixOne \u96c6\u7fa4\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u591a\u6b21\u67e5\u8be2\u7684\u7ed3\u679c\u6765\u4f53\u9a8c\u7f13\u5b58\u52a0\u901f\u7684\u6548\u679c\u3002\u8fd9\u91cc\uff0c\u4f60\u53ef\u4ee5\u8fde\u7eed\u8fd0\u884c\u591a\u6b21 stock.pe
\u7684\u5168\u8868\u626b\u63cf\u3002
mysql> select * from stock.pe into outfile \"test01.txt\";\nEmpty set (6.53 sec)\n\nmysql> select * from stock.pe into outfile \"test02.txt\";\nEmpty set (4.01 sec)\n\nmysql> select * from stock.pe into outfile \"test03.txt\";\nEmpty set (3.84 sec)\n\nmysql> select * from stock.pe into outfile \"test04.txt\";\nEmpty set (3.96 sec)\n
\u4ece\u4e0a\u8ff0\u7ed3\u679c\u4e2d\uff0c\u4f60\u53ef\u4ee5\u770b\u5230\u7b2c\u4e00\u6b21\u67e5\u8be2\u65f6\uff0c\u7531\u4e8e\u9700\u8981\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u901f\u5ea6\u660e\u663e\u8f83\u6162\u3002\u7136\u800c\uff0c\u5728\u540e\u7eed\u7684\u4e09\u6b21\u67e5\u8be2\u4e2d\uff0c\u7531\u4e8e\u6570\u636e\u5df2\u88ab\u7f13\u5b58\u81f3\u78c1\u76d8\uff0c\u67e5\u8be2\u901f\u5ea6\u663e\u8457\u63d0\u5347\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_6","title":"\u7f13\u5b58\u7f6e\u6362","text":"\u63a5\u4e0b\u6765\uff0c\u4f60\u53ef\u4ee5\u4ea4\u66ff\u8fd0\u884c\u591a\u6b21 stock.pe
\u53ca stock2.pe
\u7684\u5168\u8868\u626b\u63cf\u3002
mysql> select * from stock2.pe into outfile \"test05.txt\";\nEmpty set (5.84 sec)\n\nmysql> select * from stock2.pe into outfile \"test06.txt\";\nEmpty set (4.27 sec)\n\nmysql> select * from stock2.pe into outfile \"test07.txt\";\nEmpty set (4.15 sec)\n\nmysql> select * from stock.pe into outfile \"test08.txt\";\nEmpty set (6.37 sec)\n\nmysql> select * from stock.pe into outfile \"test09.txt\";\nEmpty set (4.14 sec)\n\nmysql> select * from stock.pe into outfile \"test10.txt\";\nEmpty set (3.81 sec)\n
\u4f60\u53ef\u80fd\u4f1a\u6ce8\u610f\u5230\uff0c\u6bcf\u6b21\u5207\u6362\u67e5\u8be2\u7684\u6570\u636e\u8868\u65f6\uff0c\u67e5\u8be2\u6548\u7387\u6709\u663e\u8457\u4e0b\u964d\u3002\u8fd9\u662f\u56e0\u4e3a\u7f13\u5b58\u6709\u7f6e\u6362\u673a\u5236\uff0c\u4f60\u53ea\u8bbe\u5b9a\u4e86\u4e00\u5757\u8f83\u5c0f\u7684\u7f13\u5b58\uff0c\u53ea\u8db3\u591f\u5b58\u653e\u4e00\u5f20\u8868\u7684\u5168\u91cf\u6570\u636e\uff0c\u56e0\u6b64\u6bcf\u6b21\u4ea4\u66ff\u67e5\u8be2\u65f6\uff0c\u65e7\u7684\u7f13\u5b58\u6570\u636e\u4f1a\u88ab\u7f6e\u6362\u51fa\u53bb\uff0c\u65b0\u7684\u67e5\u8be2\u9700\u8981\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u800c\u518d\u6b21\u67e5\u8be2\u65f6\uff0c\u7531\u4e8e\u6570\u636e\u5df2\u88ab\u7f13\u5b58\uff0c\u67e5\u8be2\u901f\u5ea6\u5f97\u5230\u63d0\u5347\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-cold-hot-data-separation/#_7","title":"\u67e5\u8be2\u9884\u70ed","text":"\u5728\u8bb8\u591a\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u7531\u4e8e\u6570\u636e\u91cf\u5e9e\u5927\u6216\u67e5\u8be2\u590d\u6742\uff0c\u6211\u4eec\u5e38\u5e38\u9700\u8981\u52a0\u901f\u67e5\u8be2\u3002\u800c MatrixOne \u7684\u7f13\u5b58\u673a\u5236\u53ef\u4ee5\u901a\u8fc7\u9884\u70ed\u6570\u636e\u6765\u5b9e\u73b0\u67e5\u8be2\u52a0\u901f\u3002
\u4f8b\u5982\uff0c\u4ee5\u4e0b\u7684 SQL \u67e5\u8be2\uff1a
SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT 1;\n
\u5982\u679c\u672a\u8fdb\u884c\u4f18\u5316\uff0c\u76f4\u63a5\u6267\u884c\u7684\u901f\u5ea6\u5982\u4e0b\uff1a
SELECT pe1.ts_code, pe1.pe, pe1.pb\nFROM stock2.pe as pe1\nWHERE pe1.pe = (SELECT min(pe2.pe)\nFROM stock2.pe as pe2\nWHERE pe1.ts_code = pe2.ts_code)\nORDER BY trade_date\nDESC LIMIT\n\n1;\n+-----------+------+--------+\n| ts_code | pe | pb |\n+-----------+------+--------+\n| 000038.SZ | 0 | 1.2322 |\n+-----------+------+--------+\n1 row in set (5.21 sec)\n
\u8fd9\u6761 SQL \u67e5\u8be2\u4ec5\u6d89\u53ca stock2.pe
\u8868\u7684\u67e5\u8be2\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u9884\u5148\u626b\u63cf\u5168\u8868\u6570\u636e\uff0c\u5c06\u8868\u6570\u636e\u9884\u70ed\u5230\u7f13\u5b58\u4e2d\uff0c\u8fd9\u6837\u518d\u8fdb\u884c\u67e5\u8be2\u5c31\u53ef\u4ee5\u5927\u5e45\u63d0\u9ad8\u8fd9\u6761 SQL \u7684\u67e5\u8be2\u901f\u5ea6\u3002
mysql> select * from stock2.pe into outfile \"test11.txt\";\nEmpty set (6.48 sec)\n\nmysql> SELECT pe1.ts_code, pe1.pe, pe1.pb FROM stock2.pe as pe1 WHERE pe1.pe = (SELECT min(pe2.pe) FROM stock2.pe as pe2 WHERE pe1.ts_code = pe2.ts_code) ORDER BY trade_date DESC LIMIT 1;\n+-----------+------+---------+\n| ts_code | pe | pb |\n+-----------+------+---------+\n| 000068.SZ | 0 | 14.6959 |\n+-----------+------+---------+\n1 row in set (2.21 sec)\n
\u6b64\u529f\u80fd\u5c24\u5176\u9002\u7528\u4e8e\u4e00\u4e9b\u56fa\u5b9a\u7684\u62a5\u8868\u8ba1\u7b97\u573a\u666f\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u9884\u70ed\u67e5\u8be2\u6d89\u53ca\u7684\u6570\u636e\uff0c\u7136\u540e\u518d\u8fdb\u884c\u67e5\u8be2\uff0c\u8fd9\u6837\u53ef\u4ee5\u663e\u8457\u63d0\u5347\u67e5\u8be2\u6548\u679c\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/","title":"Logservice \u67b6\u6784\u8be6\u89e3","text":"Logservice \u5728 MatrixOne \u4e2d\u626e\u6f14\u7740\u975e\u5e38\u91cd\u8981\u7684\u89d2\u8272\uff0c\u5b83\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u670d\u52a1\uff0c\u901a\u8fc7 RPC \u7684\u65b9\u5f0f\u4f9b\u5916\u90e8\u7ec4\u4ef6\u4f7f\u7528\uff0c\u7528\u4e8e\u65e5\u5fd7\u7ba1\u7406\u3002
Logservice \u4f7f\u7528\u57fa\u4e8e Raft \u534f\u8bae\u7684 dragonboat \u5e93\uff08multi-raft group \u7684 Go \u8bed\u8a00\u5f00\u6e90\u5b9e\u73b0\uff09\uff0c\u901a\u5e38\u4f7f\u7528\u672c\u5730\u78c1\u76d8\u4ee5\u591a\u526f\u672c\u7684\u65b9\u5f0f\u5b58\u50a8\u65e5\u5fd7\uff0c\u7c7b\u4f3c\u4e8e\u5bf9 WAL\uff08Write-Ahead Log\uff09\u7684\u7ba1\u7406\u3002\u4e8b\u52a1\u7684\u63d0\u4ea4\u53ea\u9700\u8981\u5199\u5165 Logservice \u4e2d\uff0c\u800c\u65e0\u9700\u5c06\u6570\u636e\u5199\u5165 S3\u3002\u53e6\u5916\u7684\u7ec4\u4ef6\u4f1a\u5f02\u6b65\u5730\u5c06\u6570\u636e\u6279\u91cf\u5199\u5165 S3 \u4e0a\u3002\u8fd9\u6837\u7684\u8bbe\u8ba1\u4fdd\u8bc1\u4e86\u4e8b\u52a1\u63d0\u4ea4\u65f6\u7684\u4f4e\u5ef6\u8fdf\uff0c\u5e76\u4e14\u591a\u4e2a\u526f\u672c\u786e\u4fdd\u4e86\u6570\u636e\u7684\u9ad8\u53ef\u9760\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#logservice_1","title":"Logservice \u67b6\u6784","text":"Logservice \u7684\u67b6\u6784\u7531\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u4e24\u90e8\u5206\u7ec4\u6210\u3002\u670d\u52a1\u7aef\u5305\u62ec handler\u3001dragonboat \u548c RSM\uff08Replicated State Machine\uff09\u7b49\u6a21\u5757\uff0c\u800c\u5ba2\u6237\u7aef\u5219\u5305\u542b\u591a\u4e2a\u5173\u952e\u63a5\u53e3\u3002\u5b83\u4eec\u4e4b\u95f4\u7684\u534f\u4f5c\u5173\u7cfb\u5982\u4e0b\u56fe\u6240\u793a\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#_1","title":"\u5ba2\u6237\u7aef","text":"Logservice \u5ba2\u6237\u7aef\u4e3b\u8981\u7531 TN\uff08\u4e8b\u52a1\u8282\u70b9\uff09\u8c03\u7528\uff0c\u5e76\u63d0\u4f9b\u4ee5\u4e0b\u5173\u952e\u63a5\u53e3\uff1a
Close()
\uff1a\u5173\u95ed\u5ba2\u6237\u7aef\u8fde\u63a5\u3002Config()
\uff1a\u83b7\u53d6\u5ba2\u6237\u7aef\u76f8\u5173\u914d\u7f6e\u3002GetLogRecord()
\uff1a\u8fd4\u56de\u4e00\u4e2a pb.LogRecord
\u53d8\u91cf\uff0c\u5176\u4e2d\u5305\u542b 8 \u5b57\u8282\u7684 LSN\uff08\u65e5\u5fd7\u5e8f\u5217\u53f7\uff09\u30014 \u5b57\u8282\u7684\u8bb0\u5f55\u7c7b\u578b\u548c 1 \u4e2a\u7c7b\u578b\u4e3a []byte
\u7684\u6570\u636e\u5b57\u6bb5\u3002\u6570\u636e\u5b57\u6bb5\u5305\u62ec 4 \u5b57\u8282\u7684 pb.UserEntryUpdate
\u30018 \u5b57\u8282\u7684\u526f\u672c TN ID\uff0c\u4ee5\u53ca payload []byte
\u3002Append()
\uff1a\u5c06 pb.LogRecord
\u8ffd\u52a0\u5230 Logservice\uff0c\u5e76\u8fd4\u56de LSN\u3002\u5728\u8c03\u7528\u7aef\uff0c\u53c2\u6570 pb.LogRecord
\u53ef\u4ee5\u590d\u7528\u3002Read()
\uff1a\u4ece Logservice \u4e2d\u8bfb\u53d6\u4ece\u6307\u5b9a firstLsn
\u5f00\u59cb\u7684\u65e5\u5fd7\uff0c\u76f4\u5230\u8fbe\u5230 maxSize
\u4e3a\u6b62\u3002\u8fd4\u56de\u7684 LSN \u4f5c\u4e3a\u4e0b\u4e00\u6b21\u8bfb\u53d6\u7684\u8d77\u70b9\u3002Truncate()
\uff1a\u5220\u9664\u6307\u5b9a LSN \u4e4b\u524d\u7684\u65e5\u5fd7\uff0c\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002GetTruncatedLsn()
\uff1a\u8fd4\u56de\u6700\u8fd1\u5220\u9664\u7684\u65e5\u5fd7\u7684 LSN\u3002GetTSOTimestamp()
\uff1a\u5411 TSO\uff08Timestamp Oracle\uff09\u8bf7\u6c42\u6307\u5b9a\u6570\u91cf\u7684\u65f6\u95f4\u6233\u3002\u8c03\u7528\u8005\u5360\u7528 [returned value, returned value + count]
\u7684\u8303\u56f4\u3002\u76ee\u524d\u8be5\u65b9\u6cd5\u6682\u672a\u4f7f\u7528\u3002Logservice \u5ba2\u6237\u7aef\u901a\u8fc7 MO-RPC \u5411 Logservice \u670d\u52a1\u7aef\u53d1\u9001\u8bf7\u6c42\uff0c\u670d\u52a1\u7aef\u4e0e Raft
/dragonboat
\u8fdb\u884c\u4ea4\u4e92\u5e76\u8fd4\u56de\u7ed3\u679c\u3002
Logservice \u7684\u670d\u52a1\u5668\u7aef\u63a5\u6536\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u5e76\u8fdb\u884c\u5904\u7406\u3002\u5165\u53e3\u51fd\u6570\u4e3a (*Service).handle()
\uff0c\u4e0d\u540c\u7684\u8bf7\u6c42\u4f1a\u8c03\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff1a
(*NodeHost) SyncPropose()
\u65b9\u6cd5\u8fdb\u884c\u540c\u6b65\u63d0\u4ea4 propose \u8bf7\u6c42\u3002\u9700\u8981\u7b49\u5f85\u65e5\u5fd7\u63d0\u4ea4\u5e76\u5e94\u7528\u540e\u624d\u80fd\u8fd4\u56de\uff0c\u8fd4\u56de\u503c\u662f\u6210\u529f\u5199\u5165\u65e5\u5fd7\u540e\u7684 LSN\uff08\u65e5\u5fd7\u5e8f\u5217\u53f7\uff09\u3002(*NodeHost) SyncRead()
\u65b9\u6cd5\u4ece\u72b6\u6001\u673a\u4e2d\u8fdb\u884c\u7ebf\u6027\u8bfb\u53d6\u5230\u5f53\u524d\u7684 LSN\uff0c\u7136\u540e\u6839\u636e LSN \u8c03\u7528 (*NodeHost) QueryRaftLog()
\u65b9\u6cd5\u4ece\u65e5\u5fd7\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u65e5\u5fd7\u6761\u76ee\u3002Bootstrap \u662f\u5728 logservice \u670d\u52a1\u542f\u52a8\u65f6\u8fdb\u884c\u7684\u8fc7\u7a0b\uff0c\u901a\u8fc7 HAKeeper \u5206\u7247\uff08shard ID \u4e3a 0\uff09\u5b8c\u6210\u3002\u5165\u53e3\u51fd\u6570\u4e3a (*Service) BootstrapHAKeeper
\u3002 \u65e0\u8bba\u914d\u7f6e\u4e2d\u8bbe\u7f6e\u4e86\u591a\u5c11\u4e2a\u526f\u672c\uff0c\u6bcf\u4e2a logservice \u8fdb\u7a0b\u5728\u542f\u52a8\u65f6\u90fd\u4f1a\u542f\u52a8\u4e00\u4e2a HAKeeper \u7684\u526f\u672c\u3002\u6bcf\u4e2a\u526f\u672c\u5728\u542f\u52a8\u65f6\u90fd\u4f1a\u8bbe\u7f6e\u6210\u5458\uff08members\uff09\uff0cHAKeeper \u5206\u7247\u4ee5\u8fd9\u4e9b\u6210\u5458\u4f5c\u4e3a\u9ed8\u8ba4\u7684\u526f\u672c\u6570\u542f\u52a8 Raft\u3002 \u5728\u5b8c\u6210 Raft \u7684\u9886\u5bfc\u8005\u9009\u4e3e\u540e\uff0c\u6267\u884c\u8bbe\u7f6e\u521d\u59cb\u96c6\u7fa4\u4fe1\u606f\uff08set initial cluster info
\uff09\uff0c\u8bbe\u7f6e\u65e5\u5fd7\u548c TN \u7684\u5206\u7247\u6570\u4ee5\u53ca\u65e5\u5fd7\u7684\u526f\u672c\u6570\u3002 \u8bbe\u7f6e\u5b8c\u6210\u526f\u672c\u6570\u540e\uff0c\u591a\u4f59\u7684 HAKeeper \u526f\u672c\u5c06\u88ab\u505c\u6b62\u3002
\u8be5\u5fc3\u8df3\u662f\u7531 Logservice\u3001CN \u548c TN \u53d1\u9001\u5230 HAKeeper \u7684\u5fc3\u8df3\uff0c\u800c\u4e0d\u662f Raft \u526f\u672c\u4e4b\u95f4\u7684\u5fc3\u8df3\u3002\u5b83\u4e3b\u8981\u6709\u4e24\u4e2a\u4f5c\u7528\uff1a
Logservice \u7684\u5fc3\u8df3\u6d41\u7a0b\u5982\u4e0b\u56fe\u6240\u793a\uff0cCN \u548c TN \u7684\u6d41\u7a0b\u7c7b\u4f3c\u3002
\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5fc3\u8df3\u6bcf\u79d2\u6267\u884c\u4e00\u6b21\uff0c\u5176\u539f\u7406\u5982\u4e0b\uff1a
(*Service) handleLogHeartbeat()
\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff0c\u5e76\u8c03\u7528 propose \u5c06\u5fc3\u8df3\u53d1\u9001\u5230 Raft\u3002(*stateMachine) handleLogHeartbeat()
\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff0c\u4e3b\u8981\u6267\u884c\u4ee5\u4e0b\u4e24\u4e2a\u4efb\u52a1\uff1a(*LogState) Update()
\u65b9\u6cd5\u66f4\u65b0\u5b58\u50a8\u548c\u5206\u7247\u7684\u4fe1\u606f\u3002ScheduleCommands
\u4e2d\u83b7\u53d6\u547d\u4ee4\uff0c\u5e76\u8fd4\u56de\u7ed9\u53d1\u8d77\u7aef\u6267\u884c\u3002CN \u548c TN \u5411 HAKeeper \u53d1\u9001\u5fc3\u8df3\u7684\u539f\u7406\u4e5f\u7c7b\u4f3c\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#rsm","title":"\u72b6\u6001\u673a\uff08RSM\uff09","text":"Logservice \u548c HAKeeper \u7684\u72b6\u6001\u673a\u90fd\u662f\u57fa\u4e8e\u5185\u5b58\u7684\u72b6\u6001\u673a\u6a21\u578b\uff0c\u6240\u6709\u6570\u636e\u4ec5\u4fdd\u5b58\u5728\u5185\u5b58\u4e2d\u3002\u5b83\u4eec\u90fd\u5b9e\u73b0\u4e86 IStateMachine \u63a5\u53e3\uff0c\u5176\u4e2d\u5173\u952e\u7684\u65b9\u6cd5\u5982\u4e0b\uff1a
Update()
\uff1a\u5728\u5b8c\u6210\u4e00\u6b21 propose \u5e76\u63d0\u4ea4\uff08\u5373\u591a\u6570\u526f\u672c\u5b8c\u6210\u5199\u5165\uff09\u540e\uff0c\u4f1a\u8c03\u7528 Update()
\u65b9\u6cd5\u6765\u66f4\u65b0\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u3002Update()
\u65b9\u6cd5\u7684\u5b9e\u73b0\u7531\u7528\u6237\u5b8c\u6210\uff0c\u5fc5\u987b\u662f\u65e0\u526f\u4f5c\u7528\u7684\uff08Side effect\uff09\uff0c\u5373\u76f8\u540c\u7684\u8f93\u5165\u5fc5\u987b\u5f97\u5230\u76f8\u540c\u7684\u8f93\u51fa\u7ed3\u679c\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u72b6\u6001\u673a\u4e0d\u7a33\u5b9a\u3002Update()
\u65b9\u6cd5\u7684\u7ed3\u679c\u901a\u8fc7 Result \u7ed3\u6784\u8fd4\u56de\uff0c\u5982\u679c\u53d1\u751f\u9519\u8bef\uff0c\u5219 error \u4e0d\u4e3a\u7a7a\u3002Lookup()
\uff1a\u7528\u4e8e\u67e5\u627e\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u3002\u901a\u8fc7 interface{}
\u53c2\u6570\u6307\u5b9a\u8981\u67e5\u627e\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8fd4\u56de\u7684\u7ed3\u679c\u4e5f\u662f interface{}
\u7c7b\u578b\u3002\u56e0\u6b64\uff0c\u7528\u6237\u9700\u8981\u81ea\u5df1\u5b9a\u4e49\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4f20\u5165\u76f8\u5e94\u7684\u6570\u636e\u7c7b\u578b\uff0c\u518d\u8fdb\u884c\u7c7b\u578b\u65ad\u8a00\u3002Lookup() \u662f\u53ea\u8bfb\u65b9\u6cd5\uff0c\u4e0d\u5e94\u4fee\u6539\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u3002SaveSnapshot()
\uff1a\u521b\u5efa\u5feb\u7167\uff0c\u5c06\u72b6\u6001\u673a\u4e2d\u7684\u6570\u636e\u5199\u5165 io.Writer
\u63a5\u53e3\uff0c\u901a\u5e38\u662f\u6587\u4ef6\u53e5\u67c4\u3002\u56e0\u6b64\uff0c\u6700\u7ec8\u4f1a\u4fdd\u5b58\u5230\u672c\u5730\u78c1\u76d8\u6587\u4ef6\u4e2d\u3002ISnapshotFileCollection
\u8868\u793a\u72b6\u6001\u673a\u4ee5\u5916\u7684\u6587\u4ef6\u7cfb\u7edf\u4e2d\u7684\u6587\u4ef6\u5217\u8868\uff08\u5982\u679c\u6709\uff09\uff0c\u8fd9\u4e9b\u6587\u4ef6\u4e5f\u4f1a\u4e00\u5e76\u5b58\u50a8\u5230\u5feb\u7167\u4e2d\u3002\u7b2c\u4e09\u4e2a\u53c2\u6570\u7528\u4e8e\u901a\u77e5\u5feb\u7167\u8fc7\u7a0b\uff0cRaft \u526f\u672c\u5df2\u505c\u6b62\uff0c\u7ec8\u6b62\u5feb\u7167\u64cd\u4f5c\u3002RecoverFromSnapshot()
\uff1a\u6062\u590d\u72b6\u6001\u673a\u6570\u636e\uff0c\u4ece io.Reader
\u4e2d\u8bfb\u53d6\u6700\u65b0\u7684\u5feb\u7167\u6570\u636e\u3002[]SnapshotFile
\u8868\u793a\u4e00\u4e9b\u989d\u5916\u7684\u6587\u4ef6\u5217\u8868\uff0c\u76f4\u63a5\u590d\u5236\u5230\u72b6\u6001\u673a\u6570\u636e\u76ee\u5f55\u4e2d\u3002\u7b2c\u4e09\u4e2a\u53c2\u6570\u7528\u4e8e\u63a7\u5236\uff0c\u5728\u8fdb\u884c Raft \u526f\u672c\u65f6\u4e5f\u505c\u6b62\u6062\u590d\u5feb\u7167\u7684\u64cd\u4f5c\u3002Close()
\uff1a\u5173\u95ed\u72b6\u6001\u673a\uff0c\u6267\u884c\u4e00\u4e9b\u6e05\u7406\u5de5\u4f5c\u3002\u5728 Logservice \u4e2d\uff0c\u4e00\u6b21\u8bfb\u5199\u8bf7\u6c42\u7684\u5927\u81f4\u6d41\u7a0b\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-logservice/#_4","title":"\u5199\u6d41\u7a0b","text":"\u8bfb\u53d6\u6570\u636e\u5206\u4e3a\u4e24\u79cd\u60c5\u51b5\uff1a
\u4ece\u72b6\u6001\u673a\u4e2d\u8bfb\u53d6\u6570\u636e\u3002
\u4ece\u65e5\u5fd7\u6570\u636e\u5e93\uff08log db\uff09\u4e2d\u8bfb\u53d6\u65e5\u5fd7\u6761\u76ee\u3002
\u5f53 logservice \u7684\u65e5\u5fd7\u6761\u76ee\u5728 log db \u4e2d\u4e0d\u65ad\u589e\u957f\u65f6\uff0c\u4f1a\u5bfc\u81f4\u78c1\u76d8\u7a7a\u95f4\u4e0d\u8db3\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5b9a\u671f\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff0c\u8fd9\u901a\u8fc7\u622a\u65ad\uff08truncation\uff09\u6765\u5b8c\u6210\u3002
logservice \u4f7f\u7528\u57fa\u4e8e\u5185\u5b58\u7684\u72b6\u6001\u673a\uff0c\u72b6\u6001\u673a\u4e2d\u53ea\u8bb0\u5f55\u4e86\u4e00\u4e9b\u5143\u6570\u636e\u548c\u72b6\u6001\u4fe1\u606f\uff0c\u4f8b\u5982 tick\u3001state \u548c LSN \u7b49\uff0c\u5e76\u6ca1\u6709\u8bb0\u5f55\u7528\u6237\u6570\u636e\uff0c\u8fd9\u4e9b\u6570\u636e\u7531\u6570\u636e\u8282\u70b9\uff08TN\uff09\u81ea\u5df1\u8bb0\u5f55\u3002\u53ef\u4ee5\u5c06\u5176\u7406\u89e3\u4e3a\u5728\u4e3b\u4ece\u67b6\u6784\u4e2d\uff0c\u72b6\u6001\u673a\u662f\u5206\u79bb\u7684\uff0cTN \u548c logservice \u5206\u522b\u7ef4\u62a4\u5404\u81ea\u7684\u72b6\u6001\u673a\u3002
\u5728\u8fd9\u79cd\u72b6\u6001\u673a\u5206\u79bb\u7684\u8bbe\u8ba1\u4e0b\uff0c\u7b80\u5355\u7684\u5feb\u7167\uff08snapshot\uff09\u673a\u5236\u4f1a\u5bfc\u81f4\u95ee\u9898\uff1a
\u4e3a\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff0c\u5f53\u524d\u7684\u622a\u65ad\u5de5\u4f5c\u6d41\u7a0b\u5982\u4e0b\uff1a
Logtail \u662f CN\uff08Computation Node\uff0c\u8ba1\u7b97\u8282\u70b9\uff09\u4e0e TN\uff08Transaction Node\uff0c\u4e8b\u52a1\u8282\u70b9\uff09\u4e4b\u95f4\u7684\u4e00\u79cd\u65e5\u5fd7\u540c\u6b65\u534f\u8bae\uff0c\u5b83\u4f5c\u4e3a CN \u548c TN \u534f\u540c\u5de5\u4f5c\u7684\u57fa\u7840\u3002\u672c\u6587\u5c06\u6df1\u5165\u4ecb\u7ecd Logtail \u534f\u8bae\u7684\u57fa\u672c\u5b9a\u4f4d\u3001\u534f\u8bae\u5185\u5bb9\u4ee5\u53ca\u4ea7\u751f\u8fc7\u7a0b\u3002
TAE \u662f MatrixOne \u4e91\u539f\u751f\u4e8b\u52a1\u4e0e\u5206\u6790\u5f15\u64ce\uff0c\u4e0e TN \u8282\u70b9\u76f8\u5173\u7684\u804c\u8d23\u76ee\u524d\u5305\u62ec\uff1a
\u5728 1 \u548c 3 \u5b8c\u6210\u65f6\uff0c\u90fd\u4f1a\u4ea7\u751f\u72b6\u6001\u53d8\u5316\uff0c\u4f8b\u5982\u6570\u636e\u6210\u529f\u5199\u5165\u5185\u5b58\u6216\u5bf9\u8c61\u5b58\u50a8\u3002Logtail \u662f\u4e00\u79cd\u65e5\u5fd7\u540c\u6b65\u534f\u8bae\uff0c\u65e8\u5728\u4ee5\u4f4e\u6210\u672c\u7684\u65b9\u5f0f\u540c\u6b65 TN \u7684\u90e8\u5206\u72b6\u6001\uff0c\u4f7f CN \u80fd\u591f\u5728\u672c\u5730\u91cd\u5efa\u6240\u9700\u7684\u53ef\u8bfb\u6570\u636e\u3002\u4f5c\u4e3a MatrixOne \u5b58\u7b97\u5206\u79bb\u67b6\u6784\u7684\u5173\u952e\u534f\u8bae\uff0cLogtail \u5177\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a
Logtail \u652f\u6301\u4e24\u79cd\u83b7\u53d6\u6a21\u5f0f\uff1apull \u548c push\u3002
Logtail \u652f\u6301\u8868\u7ea7\u522b\u7684\u8ba2\u9605\u548c\u6536\u96c6\uff0c\u4f7f\u5176\u5728\u591a CN \u652f\u6301\u65b9\u9762\u66f4\u52a0\u7075\u6d3b\uff0c\u6709\u52a9\u4e8e\u5b9e\u73b0 CN \u8d1f\u8f7d\u7684\u5747\u8861\u3002
Logtail \u534f\u8bae\u5206\u4e3a\u4e24\u4e2a\u90e8\u5206\uff1a\u5185\u5b58\u6570\u636e\u548c\u5143\u6570\u636e\uff0c\u5176\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u6570\u636e\u662f\u5426\u5df2\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002
\u4e00\u6b21\u4e8b\u52a1 commit
\u4ea7\u751f\u7684\u66f4\u65b0\u5728\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u4e4b\u524d\uff0c\u5176\u65e5\u5fd7\u4ee5\u5185\u5b58\u6570\u636e\u7684\u5f62\u5f0f\u5b58\u5728\u4e8e Logtail \u4e2d\u3002\u4efb\u4f55\u6570\u636e\u4e0a\u7684\u4fee\u6539\u90fd\u53ef\u4ee5\u5f52\u7ed3\u4e3a\u63d2\u5165\u548c\u5220\u9664\uff1a
\u663e\u7136\uff0c\u5185\u5b58\u6570\u636e\u4e0d\u80fd\u6c38\u8fdc\u4fdd\u7559\u5728\u5185\u5b58\u4e2d\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u589e\u52a0\u5185\u5b58\u538b\u529b\u3002\u51fa\u4e8e\u65f6\u95f4\u6216\u5bb9\u91cf\u7684\u8003\u8651\uff0c\u5185\u5b58\u6570\u636e\u4f1a\u88ab\u5237\u65b0\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\uff0c\u5f62\u6210\u4e00\u4e2a\u5bf9\u8c61\u3002\u6bcf\u4e2a\u5bf9\u8c61\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5757\uff08block\uff09\u3002\u6570\u636e\u5757\u662f\u8868\u6570\u636e\u7684\u6700\u5c0f\u5b58\u50a8\u5355\u4f4d\uff0c\u6bcf\u4e2a\u5757\u4e2d\u7684\u884c\u6570\u4e0d\u8d85\u8fc7\u56fa\u5b9a\u4e0a\u9650\uff0c\u76ee\u524d\u9ed8\u8ba4\u4e3a 8192 \u884c\u3002\u5237\u65b0\u5b8c\u6210\u540e\uff0cLogtail \u5c06\u5757\u7684\u5143\u6570\u636e\u4f20\u9012\u7ed9 CN\uff0cCN \u6839\u636e\u4e8b\u52a1\u65f6\u95f4\u6233\u8fc7\u6ee4\u51fa\u53ef\u89c1\u7684\u5757\u5217\u8868\uff0c\u8bfb\u53d6\u5757\u4e2d\u7684\u5185\u5bb9\uff0c\u7ed3\u5408\u5185\u5b58\u6570\u636e\uff0c\u5f97\u5230\u67d0\u4e2a\u65f6\u523b\u7684\u5b8c\u6574\u6570\u636e\u89c6\u56fe\u3002
\u4e0a\u8ff0\u8fc7\u7a0b\u662f\u57fa\u7840\u6b65\u9aa4\uff0c\u968f\u7740\u6027\u80fd\u4f18\u5316\u7684\u5f15\u5165\uff0c\u5c06\u5448\u73b0\u66f4\u591a\u7ec6\u8282\uff0c\u4f8b\u5982\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#1-checkpoint","title":"1. \u68c0\u67e5\u70b9\uff08checkpoint\uff09","text":"\u5f53 TN \u8fd0\u884c\u4e00\u6bb5\u65f6\u95f4\u540e\uff0c\u5728\u67d0\u4e2a\u65f6\u523b\u6267\u884c\u68c0\u67e5\u70b9\uff0c\u5373\u5c06\u6b64\u65f6\u4e4b\u524d\u7684\u6240\u6709\u6570\u636e\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u3002\u56e0\u6b64\uff0c\u6240\u6709\u8fd9\u4e9b\u5143\u6570\u636e\u5c06\u88ab\u6574\u7406\u6210\u4e00\u4e2a\u201c\u538b\u7f29\u5305\u201d\u3002\u5f53\u65b0\u542f\u52a8\u7684 CN \u8fde\u63a5\u5230 TN \u5e76\u8bf7\u6c42\u9996\u6b21 Logtail \u65f6\uff0c\u5982\u679c\u8ba2\u9605\u65f6\u95f4\u6233\u5927\u4e8e\u68c0\u67e5\u70b9\u65f6\u95f4\u6233\uff0cTN \u53ef\u4ee5\u901a\u8fc7 Logtail \u76f4\u63a5\u4f20\u9012\u68c0\u67e5\u70b9\u5143\u6570\u636e\uff08\u4e00\u4e2a\u5b57\u7b26\u4e32\uff09\uff0c\u4ece\u800c\u8ba9 CN \u76f4\u63a5\u8bfb\u53d6\u68c0\u67e5\u70b9\u4e4b\u524d\u751f\u6210\u7684\u5757\u4fe1\u606f\uff0c\u51cf\u8f7b\u4e86\u4ece\u5934\u4f20\u9012\u5757\u5143\u6570\u636e\u7684\u7f51\u7edc\u8d1f\u62c5\uff0c\u964d\u4f4e\u4e86 TN \u7684 I/O \u538b\u529b\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#2","title":"2. \u5185\u5b58\u6e05\u7406","text":"\u5f53 TN \u5c06\u5757\u5143\u6570\u636e\u4f20\u9012\u7ed9 CN \u65f6\uff0c\u5c06\u6839\u636e\u5757\u6807\u8bc6\u7b26\u6e05\u7406\u5148\u524d\u4f20\u9012\u7684\u5185\u5b58\u6570\u636e\u3002\u7136\u800c\uff0c\u5728 TN \u5237\u65b0\u4e8b\u52a1\u671f\u95f4\uff0c\u53ef\u80fd\u4f1a\u53d1\u751f\u6570\u636e\u66f4\u65b0\uff0c\u4f8b\u5982\u5237\u65b0\u7684\u5757\u4e0a\u53ef\u80fd\u4f1a\u65b0\u4ea7\u751f\u5220\u9664\u64cd\u4f5c\u3002\u5982\u679c\u7b56\u7565\u662f\u56de\u6eda\u548c\u91cd\u8bd5\uff0c\u90a3\u4e48\u5df2\u7ecf\u5199\u5165\u7684\u6570\u636e\u5c06\u53d8\u5f97\u65e0\u6548\u3002\u5728\u66f4\u65b0\u9891\u7e41\u7684\u8d1f\u8f7d\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u4f1a\u4ea7\u751f\u5927\u91cf\u7684\u56de\u6eda\u64cd\u4f5c\uff0c\u6d6a\u8d39 TN \u8d44\u6e90\u3002\u4e3a\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0cTN \u5c06\u7ee7\u7eed\u63d0\u4ea4\uff0c\u5bfc\u81f4\u5237\u65b0\u4e8b\u52a1\u5f00\u59cb\u540e\u751f\u6210\u7684\u5185\u5b58\u6570\u636e\u65e0\u6cd5\u4ece CN \u4e2d\u5220\u9664\u3002\u5728 Logtail \u7684\u5757\u5143\u4fe1\u606f\u4e2d\u4f20\u9012\u4e00\u4e2a\u65f6\u95f4\u6233\uff0c\u5728\u8fd9\u4e2a\u65f6\u95f4\u6233\u4e4b\u524d\uff0c\u8be5\u5757\u7684\u5185\u5b58\u6570\u636e\u624d\u80fd\u4ece\u5185\u5b58\u4e2d\u6e05\u7406\u3002\u8fd9\u4e9b\u672a\u6e05\u7406\u7684\u66f4\u65b0\u5c06\u5728\u4e0b\u4e00\u6b21\u5237\u65b0\u4e2d\u5f02\u6b65\u5237\u5165\u78c1\u76d8\uff0c\u5e76\u901a\u8fc7 CN \u8fdb\u884c\u5220\u9664\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#3","title":"3. \u66f4\u5feb\u7684\u8bfb\u53d6","text":"\u5df2\u7ecf\u8f6c\u5b58\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u5757\u53ef\u80fd\u4f1a\u7ee7\u7eed\u4ea7\u751f\u5220\u9664\u64cd\u4f5c\uff0c\u56e0\u6b64\u5728\u8bfb\u53d6\u8fd9\u4e9b\u5757\u65f6\uff0c\u9700\u8981\u7ed3\u5408\u5185\u5b58\u4e2d\u7684\u5220\u9664\u6570\u636e\u3002\u4e3a\u4e86\u66f4\u5feb\u5730\u786e\u5b9a\u54ea\u4e9b\u5757\u9700\u8981\u4e0e\u5185\u5b58\u6570\u636e\u7ed3\u5408\uff0cCN \u989d\u5916\u7ef4\u62a4\u4e00\u4e2a\u5757\u7684 Btree \u7d22\u5f15\u3002\u5e94\u7528 Logtail \u65f6\u9700\u8981\u8c28\u614e\u4fee\u6539\u8fd9\u4e2a\u7d22\u5f15\uff0c\u4ee5\u52a0\u5feb\u8bfb\u53d6\u901f\u5ea6\uff1a\u5904\u7406\u5185\u5b58\u6570\u636e\u65f6\u589e\u52a0\u7d22\u5f15\u6761\u76ee\uff0c\u5904\u7406\u5757\u5143\u6570\u636e\u65f6\u51cf\u5c11\u7d22\u5f15\u6761\u76ee\u3002\u53ea\u6709\u5728\u8fd9\u4e2a\u7d22\u5f15\u4e2d\u7684\u5757\u624d\u9700\u8981\u68c0\u67e5\u5185\u5b58\u6570\u636e\uff0c\u5728\u5757\u6570\u91cf\u8f83\u591a\u65f6\uff0c\u8fd9\u5c06\u5e26\u6765\u5de8\u5927\u7684\u6027\u80fd\u63d0\u5347\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#logtail_2","title":"Logtail \u7684\u751f\u6210","text":"\u5982\u524d\u6240\u8ff0\uff0cLogtail \u53ef\u4ee5\u901a\u8fc7 pull \u548c push \u4e24\u79cd\u65b9\u5f0f\u83b7\u53d6\u3002\u8fd9\u4e24\u79cd\u6a21\u5f0f\u5177\u6709\u4e0d\u540c\u7684\u7279\u70b9\uff0c\u4e0b\u9762\u5c06\u5206\u522b\u4ecb\u7ecd\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#1-pull","title":"1. Pull","text":"\u5982\u524d\u6240\u8ff0\uff0cpull \u5b9e\u9645\u4e0a\u662f\u540c\u6b65\u8868\u7684\u5feb\u7167\uff0c\u4ee5\u53ca\u540e\u7eed\u4ea7\u751f\u7684\u589e\u91cf\u65e5\u5fd7\u4fe1\u606f\u3002
\u4e3a\u4e86\u8fbe\u6210\u8fd9\u4e2a\u76ee\u7684\uff0cTN \u7ef4\u62a4\u4e86\u4e00\u4e2a\u6309\u7167\u4e8b\u52a1 prepare \u65f6\u95f4\u6392\u5e8f\u7684 txn handle \u5217\u8868\uff0clogtail table\uff0c\u7ed9\u5b9a\u4efb\u610f\u65f6\u523b\uff0c\u901a\u8fc7\u4e8c\u5206\u67e5\u627e\u5f97\u5230\u8303\u56f4\u5185\u7684 txn handle\uff0c\u518d\u7531 txn handle \u5f97\u5230\u8be5\u4e8b\u52a1\u5728\u54ea\u4e9b block \u4e0a\u505a\u8fc7\u66f4\u65b0\uff0c\u901a\u8fc7\u904d\u5386\u8fd9\u4e9b block\uff0c\u5c31\u80fd\u5f97\u5230\u5b8c\u6574\u7684\u65e5\u5fd7\u3002\u4e3a\u4e86\u52a0\u5feb\u67e5\u627e\u901f\u5ea6\uff0c\u5bf9 txn handle \u505a\u4e86\u5206\u9875\uff0c\u4e00\u4e2a\u9875\u7684 bornTs \u5c31\u662f\u5f53\u524d\u9875\u4e2d\u7684 txn handle \u7684\u6700\u5c0f prepare \u65f6\u95f4\uff0c\u7b2c\u4e00\u5c42\u4e8c\u5206\u7684\u5bf9\u8c61\u5c31\u662f\u8fd9\u4e9b\u9875\u3002
\u57fa\u4e8e logtail table\uff0c\u4ece\u63a5\u6536\u5230 pull \u8bf7\u6c42\uff0c\u4e3b\u8981\u5de5\u4f5c\u8def\u5f84\u5982\u4e0b\uff1a
\u6839\u636e\u5df2\u6709\u7684 checkpoints\uff0c\u8c03\u6574\u8bf7\u6c42\u7684\u65f6\u95f4\u8303\u56f4\uff0c\u66f4\u65e9\u7684\u53ef\u4ee5\u901a\u8fc7 checkpoint \u7ed9\u51fa\u3002
\u53d6 logtail table \u7684\u4e00\u4efd\u5feb\u7167\uff0c\u57fa\u4e8e\u8bbf\u95ee\u8005\u6a21\u5f0f\u7528 RespBuilder \u53bb\u8fed\u4ee3\u8fd9\u4efd\u5feb\u7167\u4e2d\u76f8\u5173\u7684 txn handle\uff0c\u6536\u96c6\u5df2\u63d0\u4ea4\u7684\u65e5\u5fd7\u4fe1\u606f\u3002
\u5c06\u6536\u96c6\u5230\u7684\u65e5\u5fd7\u4fe1\u606f\uff0c\u6309\u7167 logtail \u534f\u8bae\u683c\u5f0f\u8f6c\u6362\uff0c\u4f5c\u4e3a\u54cd\u5e94\u8fd4\u56de\u7ed9 CN\u3002
type RespBuilder interface {\n OnDatabase(database *DBEntry) error\n OnPostDatabase(database *DBEntry) error\n OnTable(table *TableEntry) error\n OnPostTable(table *TableEntry) error\n OnPostSegment(segment *SegmentEntry) error\n OnSegment(segment *SegmentEntry) error\n OnBlock(block *BlockEntry) error\n BuildResp() (api.SyncLogtailResp, error)\n Close()\n}\n
"},{"location":"MatrixOne/Overview/architecture/architecture-logtail/#2-push","title":"2. Push","text":"Push \u7684\u4e3b\u8981\u76ee\u7684\u662f\u66f4\u5b9e\u65f6\u5730 TN \u540c\u6b65\u589e\u91cf\u65e5\u5fd7\u5230 CN\u3002\u6574\u4f53\u6d41\u7a0b\u5206\u4e3a\u8ba2\u9605\u3001\u6536\u96c6\u3001\u63a8\u9001\u4e09\u4e2a\u9636\u6bb5\u3002
\u8ba2\u9605\uff1a\u4e00\u4e2a\u65b0 CN \u542f\u52a8\u540e\u7684\u5fc5\u8981\u6d41\u7a0b\uff0c\u5c31\u662f\u4f5c\u4e3a\u5ba2\u6237\u7aef\uff0c\u548c\u670d\u52a1\u7aef TN \u5efa\u7acb\u4e00\u4e2a RPC stream\uff0c\u5e76\u4e14\u8ba2\u9605 catalog \u76f8\u5173\u8868\uff0c\u5f53 database\u3001table\u3001column \u8fd9\u4e9b\u57fa\u672c\u4fe1\u606f\u540c\u6b65\u5b8c\u6210\u540e\uff0cCN \u624d\u80fd\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002\u5f53 TN \u6536\u5230\u8ba2\u9605\u4e00\u4e2a\u8868\u7684\u8bf7\u6c42\u65f6\uff0c\u5176\u5b9e\u5148\u8d70\u4e00\u904d pull \u6d41\u7a0b\uff0c\u4f1a\u628a\u622a\u6b62\u5230\u4e0a\u6b21 push \u65f6\u95f4\u6233\u524d\u7684\u6240\u6709 Logtail \u90fd\u5305\u542b\u5728\u8ba2\u9605\u54cd\u5e94\u4e2d\u3002\u76ee\u524d\u5bf9\u4e00\u4e2a CN\uff0cLogtail \u7684\u8ba2\u9605\u3001\u53d6\u6d88\u8ba2\u9605\u3001\u6570\u636e\u53d1\u9001\uff0c\u90fd\u53d1\u751f\u5728\u4e00\u6761 RPC stream \u94fe\u63a5\u4e0a\uff0c\u5982\u679c\u5b83\u6709\u4efb\u4f55\u5f02\u5e38\uff0cCN \u4f1a\u8fdb\u5165\u91cd\u8fde\u6d41\u7a0b\uff0c\u76f4\u5230\u6062\u590d\u3002\u4e00\u65e6\u8ba2\u9605\u6210\u529f\uff0c\u540e\u7eed\u7684 Logtail \u5c31\u662f\u63a8\u9001\u589e\u91cf\u65e5\u5fd7\u3002
\u6536\u96c6\uff1a\u5728 TN\uff0c\u4e00\u4e2a\u4e8b\u52a1\u5b8c\u6210 WAL \u5199\u5165\u540e\uff0c\u89e6\u53d1\u56de\u8c03\u6267\u884c\uff0c\u5728\u5f53\u524d\u4e8b\u52a1\u4e2d\u6536\u96c6 Logtail\u3002\u4e3b\u8981\u6d41\u7a0b\u662f\u904d\u5386 workspace \u4e2d\u7684 TxnEntry\uff08\u4e00\u79cd\u4e8b\u52a1\u66f4\u65b0\u7684\u57fa\u672c\u5bb9\u5668\uff0c\u76f4\u63a5\u53c2\u4e0e\u5230 commit pipeline \u4e2d\uff09\uff0c\u4f9d\u636e\u5176\u7c7b\u578b\uff0c\u53d6\u5bf9\u5e94\u7684\u65e5\u5fd7\u4fe1\u606f\u8f6c\u6362\u4e3a Logtail \u534f\u8bae\u7684\u6570\u636e\u683c\u5f0f\u3002\u8fd9\u4e2a\u6536\u96c6\u8fc7\u7a0b\u901a\u8fc7 pipeline\uff0c\u548c WAL \u7684 fysnc \u5e76\u53d1\u6267\u884c\uff0c\u51cf\u5c11\u963b\u585e\u3002
\u63a8\u9001\uff1a\u63a8\u9001\u9636\u6bb5\u4e3b\u8981\u505a\u4e00\u6b21\u8fc7\u6ee4\uff0c\u5982\u679c\u53d1\u73b0\u67d0\u4e2a CN \u6ca1\u6709\u8ba2\u9605\u8be5\u8868\uff0c\u5c31\u8df3\u8fc7\u8be5 CN\uff0c\u907f\u514d\u63a8\u9001\u3002
\u5982\u679c\u4e00\u4e2a\u8868\u957f\u65f6\u95f4\u6ca1\u6709\u66f4\u65b0\u65f6\uff0c\u5982\u4f55\u4f7f CN \u83b7\u77e5\uff1f\u8fd9\u91cc\u5c31\u52a0\u5165\u4e86\u5fc3\u8df3\u673a\u5236\uff0c\u9ed8\u8ba4\u662f 2 ms\uff0cTN \u7684 commit \u961f\u5217\u4e2d\u4f1a\u653e\u5165\u4e00\u4e2a heartbeat \u7684\u7a7a\u4e8b\u52a1\uff0c\u4e0d\u505a\u4efb\u4f55\u5b9e\u8d28\u6027\u5de5\u4f5c\uff0c\u53ea\u6d88\u8017\u65f6\u95f4\u6233\uff0c\u4ece\u800c\u89e6\u53d1\u4e00\u6b21\u5fc3\u8df3 Logtail \u53d1\u9001\uff0c\u544a\u77e5 CN \u6b64\u524d\u7684\u6240\u6709\u8868\u6570\u636e\u5df2\u7ecf\u53d1\u9001\u8fc7\u66f4\u65b0\uff0c\u63a8\u52a8 CN \u4fa7\u7684\u65f6\u95f4\u6233\u6c34\u4f4d\u66f4\u65b0\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/","title":"Matrixone-Operator \u8bbe\u8ba1\u4e0e\u5b9e\u73b0\u8be6\u89e3","text":"MatrixOne \u662f\u4e00\u6b3e\u4e91\u539f\u751f\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u5929\u7136\u9002\u5e94\u4e91\u57fa\u7840\u8bbe\u65bd\u5e76\u9762\u5411\u4e91\u7684\u6210\u672c\u6a21\u578b\u8fdb\u884c\u4f18\u5316\u3002\u800c\u4e0e\u4e00\u822c\u7684 SaaS \u670d\u52a1\u4e0d\u540c\uff0c\u51fa\u4e8e\u5bf9\u6027\u80fd\u548c\u6570\u636e\u5b89\u5168\u7684\u9700\u6c42\uff0c\u5728\u4e25\u8083\u573a\u666f\u4e0b\u6570\u636e\u5e93\u5f80\u5f80\u9700\u8981\u8ddf\u7740\u5e94\u7528\u8d70\uff0c\u4e0e\u5e94\u7528\u8fd0\u884c\u5728\u76f8\u540c\u7684\u57fa\u7840\u8bbe\u65bd\u4e0a\u3002\u4e3a\u4e86\u670d\u52a1\u5c3d\u53ef\u80fd\u591a\u7684\u7528\u6237\uff0cMatrixOne \u9700\u8981\u9002\u914d\u5404\u7c7b\u516c\u6709\u4e91\u3001\u79c1\u6709\u4e91\u4e43\u81f3\u6df7\u5408\u4e91\u3002\u800c\u5176\u4e2d\u7684\u6700\u5927\u516c\u7ea6\u6570\u6b63\u662f Kubernetes\uff08\u4e0b\u6587\u7b80\u79f0 K8S\uff09\u3002\u56e0\u6b64\uff0cMatrixOne \u5c06 K8S \u4f5c\u4e3a\u5206\u5e03\u5f0f\u90e8\u7f72\u65f6\u7684\u9ed8\u8ba4\u8fd0\u884c\u73af\u5883\uff0c\u4ee5\u7edf\u4e00\u65b9\u5f0f\u9002\u914d\u4e0d\u540c\u7684\u4e91\u3002 MatrixOne-Operator \u6b63\u662f MatrixOne \u5728 K8S \u4e0a\u7684\u81ea\u52a8\u5316\u90e8\u7f72\u8fd0\u7ef4\u8f6f\u4ef6\uff0c\u5b83\u6269\u5c55 K8S\uff0c\u4ee5 K8S \u98ce\u683c\u7684\u58f0\u660e\u5f0f API \u5bf9\u5916\u63d0\u4f9b MatrixOne \u96c6\u7fa4\u7684\u8fd0\u7ef4\u7ba1\u7406\u80fd\u529b\u3002
\u8fd9\u7bc7\u6587\u7ae0\u5c06\u89e3\u8bfb MatrixOne-Operator \u7684\u8bbe\u8ba1\u4e0e\u5b9e\u73b0\uff0c\u5e76\u5206\u4eab\u6211\u4eec\u7684\u7ecf\u9a8c\u601d\u8003\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#matrixone-operator_1","title":"MatrixOne-Operator \u8bbe\u8ba1","text":"\u5c3d\u7ba1 K8S \u539f\u751f\u63d0\u4f9b\u4e86 StatefulSet API \u6765\u670d\u52a1\u6709\u72b6\u6001\u5e94\u7528\u7684\u7f16\u6392\uff0c\u4f46\u7531\u4e8e\u4e0d\u540c\u6709\u72b6\u6001\u5e94\u7528\u7684\u5e94\u7528\u5c42\u72b6\u6001\u96be\u4ee5\u8fdb\u884c\u7edf\u4e00\u62bd\u8c61\uff0c\u56e0\u6b64 K8S \u539f\u751f\u5e76\u4e0d\u652f\u6301\u7ba1\u7406\u5e94\u7528\u72b6\u6001\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0cOperator \u6a21\u5f0f\u5e94\u8fd0\u800c\u751f\u3002\u4e00\u4e2a\u5178\u578b\u7684 K8S Operator \u7531 API \u548c\u63a7\u5236\u5668 (Controller) \u4e24\u90e8\u5206\u6784\u6210\uff1a
\u901a\u5e38\u901a\u8fc7 K8S \u7684 CustomResourceDefinition\uff08CRD\uff09\u5bf9\u8c61\u8fdb\u884c\u58f0\u660e\uff0c\u5728\u63d0\u4ea4\u4e00\u4e2a K8S CRD \u5230 K8S \u7684 api-server \u540e\uff0capi-server \u5c31\u4f1a\u5728\u81ea\u8eab\u6ce8\u518c\u4e00\u4e2a\u5bf9\u5e94\u7684 Restful API\u3002\u6240\u6709\u7684 K8SClient \u90fd\u80fd\u4ee5\u7c7b\u4f3c\u64cd\u4f5c\u539f\u751f\u8d44\u6e90\u7684\u65b9\u5f0f\u5bf9\u8fd9\u4e2a\u65b0\u58f0\u660e\u7684 API \u8fdb\u884c GET,LIST, POST, DELETE \u7b49\u64cd\u4f5c\u3002\u6309\u7167\u60ef\u4f8b\uff0c\u6bcf\u4e2a API \u5bf9\u8c61\u5185\u7684\uff0c.spec
\u7ed3\u6784\u7531\u7528\u6237\u7ba1\u7406\uff0c\u7528\u4e8e\u58f0\u660e\u5bf9\u8c61\u7684\u671f\u671b\u72b6\u6001\uff0c.status
\u7ed3\u6784\u5219\u7531\u4e0b\u6587\u7684\u63a7\u5236\u5668\u7ba1\u7406\uff0c\u7528\u4e8e\u5bf9\u5916\u66b4\u9732\u5bf9\u8c61\u7684\u5b9e\u9645\u72b6\u6001\u3002
\u63a7\u5236\u5668\u662f\u4e00\u6bb5\u6301\u7eed\u8fd0\u884c\u7684\u4ee3\u7801\uff0c\u5b83\u76d1\u89c6 (watch) \u4e00\u7cfb\u5217 K8S \u5bf9\u8c61\uff0c\u5305\u62ec\u6211\u4eec\u521a\u521a\u5b9a\u4e49\u7684 API \u5bf9\u8c61\u3002\u7136\u540e\uff0c\u6839\u636e\u8fd9\u4e9b\u5bf9\u8c61\u7684\u671f\u671b\u72b6\u6001\u548c\u4ece\u73b0\u5b9e\u4e2d\u6536\u96c6\u5230\u7684\u5b9e\u9645\u72b6\u6001\uff08\u6ce8\u610f\uff1a\u8fd9\u91cc\u7684\u5b9e\u9645\u72b6\u6001\u662f\u4ece\u73b0\u5b9e\u4e2d\u6536\u96c6\u5230\u518d\u5199\u8fdb .status
\u7684\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u6765\u81ea .status
\uff09\u6267\u884c\u81ea\u52a8\u5316\u64cd\u4f5c\uff0c\u9a71\u52a8\u5b9e\u9645\u72b6\u6001\u5411\u671f\u671b\u72b6\u6001\u8f6c\u79fb\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4f1a\u6301\u7eed\u5faa\u73af\u8fdb\u884c\uff0c\u88ab\u5f62\u8c61\u5730\u79f0\u4f5c\u201c\u63a7\u5236\u5faa\u73af\u201d\uff08control loop\uff09\uff0c\u6709\u4e9b\u5730\u65b9\u4e5f\u4f1a\u7528\u4e00\u4e2a\u66f4\u5177\u53e4\u5178\u4e50\u98ce\u5473\u7684\u8bcd\u201c\u8c03\u8c10\u5faa\u73af\u201d(reconciliation loop)\uff0c\u5de7\u5999\u5730\u548c K8S \u7684\u201c\u7f16\u6392\u201d(Orchestration) \u4e00\u8bcd\u4fdd\u6301\u4e86\u98ce\u5473\u7edf\u4e00\u3002
\u4e0b\u56fe\u4ee5\u7b80\u5316\u540e\u7684 MatrixOneCluster API \u4f5c\u4e3a\u4f8b\u5b50\uff0c\u6982\u62ec\u6027\u5730\u63cf\u8ff0\u4e86\u8fd9\u4e2a\u8fc7\u7a0b\uff1a
MatrixOne-Operator \u4e0d\u4ec5\u63d0\u4f9b MatrixOneCluster \u8fd9\u6837\u7528\u4e8e\u7ba1\u7406 MO \u96c6\u7fa4\u7684\u8d1f\u8f7d\u578b API\uff0c\u8fd8\u63d0\u4f9b\u5907\u4efd\u6062\u590d\u8fd9\u6837\u7684\u4efb\u52a1\u578b API \u548c\u5bf9\u8c61\u5b58\u50a8\u6876\u8fd9\u6837\u7684\u8d44\u6e90\u578b API\u3002\u6bcf\u79cd API \u548c\u5b83\u4eec\u7684\u63a7\u5236\u5668\u5728\u8bbe\u8ba1\u65f6\u90fd\u6709\u72ec\u7279\u7684\u8003\u91cf\uff0c\u4f46\u4e07\u53d8\u4e0d\u79bb\u5176\u5b97\uff0c\u6240\u6709\u7684 API \u548c\u63a7\u5236\u5668\u90fd\u662f\u4ee5\u4e0a\u8ff0\u6a21\u5f0f\u8fdb\u884c\u6784\u5efa\u7684\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u7ee7\u7eed\u63a2\u7d22\u6bcf\u4e2a API \u8bbe\u8ba1\u4e2d\u7684\u53d6\u820d\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#api","title":"\u96c6\u7fa4 API \u8bbe\u8ba1","text":"\u4e00\u4e2a\u5206\u5e03\u5f0f MO \u96c6\u7fa4\u7531\u65e5\u5fd7\u670d\u52a1\u3001\u4e8b\u52a1\u8282\u70b9\u3001\u8ba1\u7b97\u8282\u70b9\u548c Proxy \u7b49\u591a\u4e2a\u7ec4\u4ef6\u7ec4\u6210\uff0c\u5176\u4e2d\u8ba1\u7b97\u8282\u70b9\u8fd8\u6709\u660e\u786e\u7684\u5f02\u6784\u9700\u6c42\u6765\u5b9e\u73b0\u9488\u5bf9\u8d1f\u8f7d\u7684\u673a\u578b\u4f18\u5316\u548c\u8de8\u4e91\u3001\u4e91\u8fb9\u4e00\u4f53\u7b49\u80fd\u529b\u3002\u5c06\u6574\u4e2a\u96c6\u7fa4\u7684\u7ba1\u7406\u90fd\u96c6\u4e2d\u5230\u4e00\u4e2a API \u5bf9\u8c61\u4e2d\u58f0\u660e\u518d\u4f7f\u7528\u4e00\u4e2a\u63a7\u5236\u5668\u8fdb\u884c\u7ba1\u7406\u867d\u7136\u4fbf\u4e8e\u4f7f\u7528\uff0c\u4f46\u5374\u662f\u4ee3\u7801\u7ef4\u62a4\u7684\u5669\u68a6\u3002\u56e0\u6b64\uff0cMatrixOne-Operator \u5728\u8bbe\u8ba1\u4e4b\u521d\u5c31\u660e\u786e\u4e86\u677e\u8026\u5408\u7684\u7ec6\u7c92\u5ea6 API \u8fd9\u4e00\u539f\u5219\uff0c\u8bbe\u8ba1\u4e86 LogSet,CNSet,ProxySet,BucketClaim \u7b49\u804c\u8d23\u660e\u786e\u7684 API \u548c\u5f7c\u6b64\u72ec\u7acb\u7684\u63a7\u5236\u5668\u3002\u4e3a\u4e86\u4fdd\u6301\u6613\u7528\u6027\uff0c\u53c8\u5f15\u5165\u4e86 MatrixOneCluster API\u3002\u8d1f\u8d23 MatrixOneCluster \u63a7\u5236\u5668\u4e0d\u91cd\u590d\u5176\u4ed6\u63a7\u5236\u5668\u7684\u5de5\u4f5c\u2014\u2014\u5f53\u4e00\u5957\u96c6\u7fa4\u9700\u8981\u4e00\u4e2a LogSet \u63d0\u4f9b\u65e5\u5fd7\u670d\u52a1\u65f6\uff0cMatrixOneCluster \u63a7\u5236\u5668\u4ec5\u4ec5\u662f\u521b\u5efa\u4e00\u4e2a LogSet \u5bf9\u8c61\uff0c\u5176\u4f59\u7684\u5de5\u4f5c\u5219\u59d4\u6258\u7ed9 LogSet \u63a7\u5236\u5668\u3002
\u5728\u8fd9\u6837\u7684\u8bbe\u8ba1\u4e0b\uff0c\u867d\u7136 API \u5f88\u591a\uff0c\u4f46\u7528\u6237\u59cb\u7ec8\u53ea\u9700\u8981\u5173\u5fc3 MatrixOneCluster API\uff0c\u800c MatrixOne-Operator \u7684\u5f00\u53d1\u8005\u4e5f\u5728\u6dfb\u52a0\u7279\u6027\u6216\u89e3\u51b3\u95ee\u9898\u65f6\uff0c\u95ee\u9898\u57df\u4e5f\u5f80\u5f80\u4e0d\u5927\u4e8e\u4e00\u4e2a\u7ec6\u7c92\u5ea6\u7684 API \u548c\u63a7\u5236\u5668\u3002
\u5f53\u7136\uff0c\u591a\u4e2a API \u5bf9\u8c61\u95f4\u4f1a\u6709\u67d0\u4e9b\u4f9d\u8d56\u5173\u7cfb\uff0c\u6bd4\u5982\u4e8b\u52a1\u8282\u70b9\u548c\u8ba1\u7b97\u8282\u70b9\u90fd\u4f9d\u8d56\u8fd0\u884c\u4e8e\u65e5\u5fd7\u670d\u52a1\u4e2d\u7684 HAKeeper \u6765\u83b7\u53d6\u96c6\u7fa4\u4fe1\u606f\u8fdb\u884c\u670d\u52a1\u53d1\u73b0\u3002\u8fd9\u8981\u6c42\u90e8\u7f72\u96c6\u7fa4\u65f6\u9996\u5148\u542f\u52a8\u65e5\u5fd7\u670d\u52a1\u5e76\u5b8c\u6210 HAKeeper \u7684 bootstrap \u624d\u80fd\u7ee7\u7eed\u542f\u52a8\u4e8b\u52a1\u8282\u70b9\u548c\u8ba1\u7b97\u8282\u70b9\u3002\u8fd9\u7c7b\u903b\u8f91\u56fa\u7136\u53ef\u4ee5\u7531 MatrixOneCluster \u63a7\u5236\u5668\u5b9e\u73b0\uff0c\u4f46\u8fd9\u4e5f\u610f\u5473\u7740\u6cc4\u9732\u4e86\u5176\u4ed6\u63a7\u5236\u5668\u7684\u4e1a\u52a1\u77e5\u8bc6\uff0c\u5404\u4e2a\u63a7\u5236\u7684\u5b9e\u73b0\u4ecd\u7136\u4ea7\u751f\u4e86\u8026\u5408\u3002\u56e0\u6b64\uff0c\u5728 mo-operator \u4e2d\uff0c\u6211\u4eec\u5c06\u6240\u6709\u7ec4\u4ef6\u95f4\u4ea7\u751f\u4f9d\u8d56\u7684\u4e1a\u52a1\u903b\u8f91\u90fd\u5728\u4f9d\u8d56\u65b9\u8fdb\u884c\u5b9e\u73b0\uff0c\u88ab\u4f9d\u8d56\u65b9\u4ec5\u4ec5\u901a\u8fc7\u7ea6\u5b9a\u4fd7\u6210\u7684 .status
\u5b57\u6bb5\u5bf9\u5916\u66b4\u9732\u81ea\u8eab\u72b6\u6001\u3002\u4e3e\u4f8b\u6765\u8bf4\uff0c\u63a7\u5236\u5668\u5728\u8c03\u8c10\u4e00\u4e2a CNset \u65f6\uff0c\u4f1a\u4e3b\u52a8\u7b49\u5f85 CNSet \u6307\u5411\u7684 LogSet \u5c31\u7eea\u518d\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\uff0c\u800c LogSet \u63a7\u5236\u5668\u548c\u4e0a\u5c42\u7684 MatrixOneCluster \u63a7\u5236\u5668\u90fd\u4e0d\u9700\u8981\u611f\u77e5\u5230\u8fd9\u4ef6\u4e8b\u3002
\u677e\u8026\u5408\u7ec6\u7c92\u5ea6\u7684 API \u80fd\u591f\u5f88\u597d\u5730\u9002\u5e94 CN \u7684\u5f02\u6784\u7f16\u6392\u573a\u666f\u3002\u5728 MatrixOne-Operator \u4e2d\uff0c\u9664\u4e86\u5728 MatrixOneCluster \u4e2d\u58f0\u660e\u591a\u4e2a CN \u7ec4\u6765\u8fdb\u884c\u5f02\u6784\u7f16\u6392\u8fd9\u79cd\u4fbf\u6377\u7528\u6cd5\u4e4b\u5916\uff0c\u8fd8\u80fd\u76f4\u63a5\u521b\u5efa\u4e00\u4e2a CNSet \u6765\u52a0\u5165\u73b0\u6709\u96c6\u7fa4\uff0c\u8fd9\u610f\u5473\u7740\u65b0\u7684 CNSet \u53ef\u4ee5\u90e8\u7f72\u5728\u53e6\u4e00\u5957 K8S \u96c6\u7fa4\u4e2d\uff0c\u914d\u5408\u7f51\u7edc\u5c42\u9762\u7684\u652f\u6301\uff0c\u5c31\u80fd\u8fdb\u884c\u8de8\u4e91\u6216\u4e91\u8fb9\u573a\u666f\u4e0b\u7684 MO \u7f16\u6392\u3002
\u5728\u5404\u4e2a\u63a7\u5236\u5668\u7684\u8fed\u4ee3\u8fc7\u7a0b\u4e2d\uff0cMatrixOne-Operator \u4e5f\u503e\u5411\u4e8e\u901a\u8fc7\u6dfb\u52a0\u65b0\u7684 API \u5bf9\u8c61\u6765\u6dfb\u52a0\u65b0\u7279\u6027\u3002\u6bd4\u5982\uff0c\u5728\u5b9e\u73b0\u5bf9\u8c61\u5b58\u50a8\u7ba1\u7406\u65f6\uff0cMatrixOne-Operator \u9700\u8981\u4fdd\u8bc1\u4e0d\u540c\u96c6\u7fa4\u4f7f\u7528\u7684\u5bf9\u8c61\u5b58\u50a8\u8def\u5f84\u4e4b\u95f4\u6ca1\u6709\u4ea4\u96c6\u5e76\u4e14\u5728\u96c6\u7fa4\u9500\u6bc1\u540e\u81ea\u52a8\u6e05\u7406\u3002MatrixOne-Operator \u7684\u89e3\u51b3\u65b9\u6848\u5c31\u662f\u65b0\u589e\u4e00\u4e2a BucketClaim API\uff0c\u53c2\u8003 K8S PersistentVolumeClaim \u7684\u63a7\u5236\u903b\u8f91\uff0c\u5728\u72ec\u7acb\u7684\u63a7\u5236\u5668\u4e2d\u5b8c\u6210\u4e00\u4e2a\u5bf9\u8c61\u5b58\u50a8\u8def\u5f84\u7684\u751f\u547d\u5468\u671f\u7ba1\u7406\uff0c\u907f\u514d\u590d\u6742\u7684\u7ade\u6001\u6761\u4ef6\u5904\u7406\u548c\u4ee3\u7801\u8026\u5408\u95ee\u9898\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_1","title":"\u63a7\u5236\u5668\u5b9e\u73b0","text":"K8S \u63d0\u4f9b\u4e86 controller-runtime \u5305\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9e\u73b0\u81ea\u5df1\u7684\u63a7\u5236\u5668\uff0c\u4f46\u4e3a\u4e86\u901a\u7528\u6027\uff0c\u63a5\u53e3\u8bbe\u8ba1\u662f\u76f8\u5bf9\u5e95\u5c42\u7684\uff1a
Reconcile(ctx context.Context, req Request)(Result, error)\n
\u63a7\u5236\u5668\u9700\u8981\u5b9e\u73b0 Reconcile \u63a5\u53e3\uff0c\u518d\u901a\u8fc7 controller-runtime \u7684\u63a5\u53e3\u8fdb\u884c\u6ce8\u518c\uff0c\u58f0\u660e\u8981\u76d1\u542c\u7684\u5bf9\u8c61\u4ee5\u53ca\u4e00\u4e9b\u76d1\u542c\u7684\u8fc7\u6ee4\u89c4\u5219\uff0ccontroller-runtime \u5c31\u4f1a\u5728\u6bcf\u6b21\u5bf9\u8c61\u53d1\u751f\u53d8\u5316\u6216\u8005\u91cd\u8bd5 Reconcile \u65f6\u8c03\u7528\u63a7\u5236\u5668\u7684 Reconcile \u65b9\u6cd5\uff0c\u5e76\u5728 req \u53c2\u6570\u4e2d\u4f20\u5165\u76ee\u6807\u5bf9\u8c61\u7684\u6807\u8bc6\u7b26\u3002\u8fd9\u4e2a\u63a5\u53e3\u5185\u4f1a\u5b58\u5728\u4e0d\u5c11\u6a21\u677f\u4ee3\u7801\uff0c\u7528\u4f2a\u4ee3\u7801\u6765\u8868\u793a\u901a\u5e38\u662f\uff1a
func \u8c03\u8c10(\u5bf9\u8c61 A \u7684 Namespace+Name) {\n \u83b7\u53d6\u5bf9\u8c61 A \u7684Spec\n if \u5bf9\u8c61 A \u6b63\u5728\u88ab\u5220\u9664 {\n \u6267\u884c\u6e05\u7406\u903b\u8f91\n \u66f4\u65b0\u6e05\u7406\u8fdb\u5ea6\u5230 A.status\n \u79fb\u9664\u5bf9\u8c61 A \u4e0a\u7684 finalizer\n } else {\n \u4e3a A \u6dfb\u52a0 finalizer\n \u6267\u884c\u8c03\u8c10\u903b\u8f91\n \u66f4\u65b0\u8c03\u8c10\u8fdb\u5ea6\u5230 A.status\n }\n}\n
\u7c7b\u4f3c\u7684\u903b\u8f91\u5728\u5404\u79cd\u793e\u533a\u63a7\u5236\u5668\u5b9e\u73b0\u4e2d\u53cd\u590d\u51fa\u73b0\uff0c\u5e76\u4e14\u5f00\u53d1\u8005\u9700\u8981\u5173\u5fc3\u5f88\u591a\u4e1a\u52a1\u4e4b\u5916\u7684\u5185\u5bb9\uff1a\u6b63\u786e\u5730\u5904\u7406 finalizer \u4ee5\u786e\u4fdd\u8d44\u6e90\u4e0d\u4f1a\u6cc4\u9732\u3001\u5c06\u8fdb\u5ea6\u548c\u9519\u8bef\u53ca\u65f6\u66f4\u65b0\u5230 status \u4e2d\u6765\u63d0\u5347\u53ef\u89c1\u5ea6\u4ee5\u53ca\u66f4\u7ec6\u8282\u7684 logger \u9700\u8981\u5e26 context \u548c kubeClient \u9700\u8981\u5e26 cache \u7b49\u95ee\u9898\u3002
\u7531\u4e8e\u4e0d\u9700\u8981\u8003\u8651\u901a\u7528\u6027\uff0cMatrixOne-Operator \u5185\u8fdb\u884c\u4e86\u66f4\u7279\u5316\u7684\u62bd\u8c61\uff0c\u8bbe\u8ba1\u4e86 Actor \u63a5\u53e3\uff1a
type Actor[T client.Object] interface { \n Observe(*Context[T]) (Action[T], error) \n Finalize(*Context[T]) (done bool, err error) \n}\n\ntype Action[T client.Object] func(*Context[T]) error\n
\u5728\u80cc\u540e\uff0c\u901a\u7528\u7684\u63a7\u5236\u5668\u6846\u67b6\u903b\u8f91\u4f1a\u5904\u7406\u597d\u6240\u6709\u7c7b\u4f3c\u4e0a\u6587\u6a21\u677f\u4ee3\u7801\u7684\u903b\u8f91\u548c\u7ec6\u8282\uff0c\u5728 Context[T] \u5185\u51c6\u5907\u597d\u5f53\u524d\u9700\u8981 reconcile \u7684\u5bf9\u8c61\u548c\u5df2\u7ecf\u5904\u7406\u597d\u4e0a\u4e0b\u6587\u7684 Logger, EventRecorder, KubeClient \u5bf9\u8c61\u3002\u6700\u540e\uff1a
\u5728\u8c03\u8c10\u4e00\u4e2a\u672a\u88ab\u5220\u9664\u7684\u5bf9\u8c61\u65f6\uff0c\u8c03\u7528 Actor.Observe \u8ba9\u771f\u6b63\u7684\u4e1a\u52a1\u903b\u8f91\u6267\u884c\u8c03\u8c10\uff1b
\u5728\u8c03\u8c10\u4e00\u4e2a\u5220\u9664\u4e2d\u5bf9\u8c61\u65f6\uff0c\u8c03\u7528 Actor.Finalize \u6267\u884c\u4e1a\u52a1\u903b\u8f91\u5185\u7684\u8d44\u6e90\u6e05\u7406\u884c\u4e3a\uff0c\u4e0d\u65ad\u91cd\u8bd5\uff0c\u76f4\u5230 Finalize \u8fd4\u56de\u5b8c\u6210\uff0c\u624d\u79fb\u9664\u5bf9\u8c61\u7684 finalizer\u3002
\u4e00\u4e2a\u5bf9\u8c61\u7684\u72b6\u6001\u673a\u5982\u4e0b\uff1a
\u5728\u8fd9\u4e2a\u6d41\u7a0b\u4e0b\uff0c\u4e00\u4e2a\u63a7\u5236\u5668\u5bf9 API \u5bf9\u8c61\u751f\u547d\u5468\u671f\u7ba1\u7406\u4e2d\u7684\u521b\u5efa\u548c\u9500\u6bc1\u4e24\u90e8\u5206\u7684\u5b9e\u73b0\u975e\u5e38\u76f4\u767d\u3002\u65e0\u975e\u662f\u7ed3\u5408 MO \u7684\u8fd0\u7ef4\u77e5\u8bc6\uff0c\u8c03\u7528 K8S \u7684 API \u7533\u8bf7\u5b58\u50a8\u3001\u90e8\u7f72\u5de5\u4f5c\u8d1f\u8f7d\u3001\u914d\u7f6e\u670d\u52a1\u53d1\u73b0\uff1b\u6216\u662f\u53cd\u8fc7\u6765\uff0c\u5728 API \u5904\u4e8e\u5220\u9664\u9636\u6bb5\u65f6\uff0c\u5c06\u521b\u5efa\u7684\u5916\u90e8\u8d44\u6e90\u5168\u90e8\u9500\u6bc1\u3002\u5bf9\u8c61\u7684\u66f4\u65b0\u540e\u7684\u8c03\u8c10\u64cd\u4f5c\u4e5f\u662f\u5e38\u89c4\u7684 diff \u903b\u8f91\uff0c\u4ee5 MatrixOneCluster \u7684\u3002cnSets \u5b57\u6bb5\u4e3a\u4f8b\uff0c\u8c03\u8c10\u6d41\u7a0b\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u4f2a\u4ee3\u7801\u8868\u793a\uff1a
func sync(c MatrixOneCluster) {\n existingCNSets := \u6536\u96c6\u8fd9\u4e2a\u96c6\u7fa4\u7684\u6240\u6709CNSet\n for _, desired := range c.spec.CNSets {\n cnSet := \u6784\u5efaCNSet(desired)\n if _, ok := existingCNSets[cnSet.Name]; ok {\n // 1. CNSet \u5b58\u5728\uff0c\u66f4\u65b0 CNSet\n ....\n // 2. \u6807\u8bb0\u8fd9\u4e2a cnSet \u662f\u671f\u671b\u72b6\u6001\u4e2d\u9700\u8981\u7684\n delete(existingCNSets, cnSet.Name)\n } else {\n // CNSet \u4e0d\u5b58\u5728\uff0c\u521b\u5efa\n ....\n }\n }\n for _, orphan := range existingCNSets {\n // \u5bf9\u4e8e\u5b9e\u9645\u5b58\u5728\u4f46\u671f\u671b\u72b6\u6001\u4e2d\u4e0d\u5b58\u5728\u7684 CNSet\uff0c\u8fdb\u884c\u6e05\u7406\n }\n}\n
\u6bd4\u8f83\u5bb9\u6613\u51fa\u9519\u7684\u662f ConfigMap / Secret \u7684\u66f4\u65b0\u903b\u8f91\uff0cMO \u548c\u5f88\u591a\u5e94\u7528\u4e00\u6837\uff0c\u9700\u8981\u914d\u7f6e\u6587\u4ef6\u5e76\u4e14\u6bcf\u6b21\u914d\u7f6e\u66f4\u65b0\u65f6\u9700\u8981\u91cd\u542f\u91cd\u65b0\u8bfb\u53d6\u914d\u7f6e\uff0c\u800c\u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u7528 K8S \u539f\u751f\u7684 ConfigMap \u5bf9\u8c61\u8fdb\u884c\u5b58\u50a8\u3002\u6709\u4e00\u4e2a\u5bb9\u6613\u8e29\u5751\u7684\u5730\u65b9\u5728\u4e8e ConfigMap \u5bf9\u8c61\u7684\u5185\u5bb9\u662f\u53ef\u53d8\u7684\uff0c\u800c\u5927\u90e8\u5206\u5e94\u7528\u5f80\u5f80\u53ea\u5728\u542f\u52a8\u65f6\u8bfb\u53d6\u4e00\u6b21 ConfigMap \u5185\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u540e\u7eed\u4e0d\u4f1a\u518d reload\u3002\u56e0\u6b64\uff0c\u67e5\u770b Pod \u5f53\u524d\u5f15\u7528\u7684 ConfigMap \u5185\u7684\u5185\u5bb9\u5e76\u4e0d\u80fd\u786e\u5b9a Pod \u76ee\u524d\u4f7f\u7528\u7684\u914d\u7f6e\uff08\u6709\u53ef\u80fd\u5728\u542f\u52a8\u540e ConfigMap \u5185\u5bb9\u53d1\u751f\u4e86\u53d8\u5316\uff09\u3002\u53e6\u5916\uff0c\u5047\u5982\u60f3\u5728 ConfigMap \u53d8\u5316\u540e\u6eda\u52a8\u66f4\u65b0\u5e94\u7528\uff0c\u4e00\u4e2a\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u5c06 ConfigMap \u7684\u5185\u5bb9\u505a\u4e00\u4e2a Hash \u586b\u5230 PodTemplate \u7684 Annotation \u4e2d\uff0c\u6bcf\u6b21\u66f4\u65b0 ConfigMap \u53d8\u5316\u540e\u66f4\u65b0\u8fd9\u4e2a Annotation \u89e6\u53d1\u5e94\u7528\u7684\u6eda\u52a8\u66f4\u65b0\u3002\u4f46\u8fd9\u79cd\u505a\u6cd5\u4e5f\u4f1a\u56e0\u4e3a\u539f\u5730\u4fee\u6539 ConfigMap \u800c\u51fa\u73b0\u975e\u9884\u671f\u7684\u60c5\u51b5\uff1a
\u4ee5\u4e0a\u56fe\u4e3a\u4f8b\uff0c\u5047\u8bbe Annotation \u4e2d\u7684 ConfigMap Hash \u4ece 123 \u66f4\u65b0\u6210\u4e86 321\uff0c\u800c 321 \u542f\u52a8\u540e\u56e0\u4e3a ConfigMap \u914d\u7f6e\u6709\u95ee\u9898\u800c\u65e0\u6cd5 Ready\uff0c\u8fd9\u65f6\u5019\u5728\u5408\u9002\u7684\u7b56\u7565\u914d\u7f6e\u4e0b\uff0c\u6eda\u52a8\u66f4\u65b0\u4f1a\u5361\u4f4f\u907f\u514d\u6545\u969c\u8303\u56f4\u6269\u5927\u3002\u7136\u800c\uff0c\u5c1a\u672a\u66f4\u65b0\u7684 Pod \u5185\u4e5f\u5df2\u7ecf\u8bfb\u5230\u4e86\u65b0\u7248\u672c\u7684 ConfigMap\uff0c\u53ea\u8981\u53d1\u751f\u4e00\u6b21\u5bb9\u5668\u91cd\u542f\u6216 Pod \u91cd\u5efa\uff0c\u5c31\u4f1a\u7acb\u523b\u53d1\u751f\u95ee\u9898\u3002\u8fd9\u548c\u66f4\u65b0\u955c\u50cf\u6216\u5176\u4ed6\u5b57\u6bb5\u7684\u884c\u4e3a\u663e\u7136\u4e0d\u4e00\u6837\uff0c\u66f4\u65b0\u5176\u4ed6\u5b57\u6bb5\u65f6\uff0c\u7eff\u8272\u7684 Pod \u8fd8\u5c5e\u4e8e\u65e7\u7684 ReplicaSet/ControllerRevision\uff0c\u91cd\u542f\u6216\u91cd\u5efa\u90fd\u4e0d\u4f1a\u4f7f\u7528\u65b0\u7248\u672c\u7684\u914d\u7f6e\u542f\u52a8\uff0c\u6545\u969c\u8303\u56f4\u662f\u53ef\u63a7\u7684\u3002
\u95ee\u9898\u7684\u6839\u6e90\u5728\u4e8e ConfigMap \u7684\u5185\u5bb9\u5e76\u4e0d\u5728 Pod \u7684 spec \u5185\uff0c\u76f4\u63a5\u4fee\u6539 ConfigMap \u7684\u5185\u5bb9\u548c Pod \u7684\u4e0d\u53ef\u53d8\u57fa\u7840\u8bbe\u65bd\u539f\u5219\u662f\u51b2\u7a81\u7684\u3002
\u56e0\u6b64\uff0cMatrixOne-Operator \u4e2d\u5c06\u6240\u6709 Pod \u5185\u4f1a\u5f15\u7528\u7684\u5bf9\u8c61\u90fd\u8bbe\u8ba1\u6210\u4e0d\u53ef\u53d8\u7684\uff0c\u4ee5 ConfigMap \u4e3a\u4f8b\uff0c\u6bcf\u6b21\u901a\u8fc7 CRD \u66f4\u65b0\u67d0\u4e2a\u7ec4\u4ef6\u7684\u914d\u7f6e\uff0cMatrixOne-Operator \u90fd\u4f1a\u751f\u6210\u4e00\u4e2a\u65b0\u7684 ConfigMap \u5e76\u5c06\u7ec4\u4ef6\u7684\u6240\u6709\u526f\u672c\u6eda\u52a8\u66f4\u65b0\u5230\u8fd9\u4e2a\u65b0\u7684 ConfigMap \u4e0a\uff1a
\u57fa\u4e8e\u8fd9\u4e2a\u539f\u5219\uff0c\u4efb\u610f\u65f6\u523b\u6211\u4eec\u90fd\u53ef\u4ee5\u901a\u8fc7\u5f53\u524d\u7684 Pod Spec \u660e\u786e\u6240\u6709 Pod \u5185\u7684\u4fe1\u606f\u3002\u6eda\u52a8\u66f4\u65b0\u7684\u95ee\u9898\u4e5f\u8fce\u5203\u800c\u89e3\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_2","title":"\u5e94\u7528\u72b6\u6001\u7ba1\u7406","text":"\u9664\u4e86\u5e94\u7528\u672c\u8eab\u7684\u751f\u547d\u5468\u671f\u7ba1\u7406\u5916\uff0cMatrixOne-Operator \u8fd8\u6709\u4e00\u4e2a\u91cd\u8981\u804c\u8d23\u662f\u7ba1\u7406\u5e94\u7528\u672c\u8eab\u7684\u72b6\u6001\u3002\u4f46\u662f\uff0c\u5206\u5e03\u5f0f\u7cfb\u7edf\u901a\u5e38\u90fd\u4f1a\u57fa\u4e8e\u5fc3\u8df3\u6216\u7c7b\u4f3c\u7684\u673a\u5236\u7ba1\u7406\u81ea\u8eab\u7684\u5e94\u7528\u72b6\u6001\uff0c\u4e3a\u4ec0\u4e48 Operator \u4e2d\u8fd8\u8981\u591a\u6b64\u4e00\u4e3e\u5462\uff1f
\u539f\u56e0\u5728\u4e8e Operator \u7684\u4ee3\u7801\u5185\u62e5\u6709\u5173\u4e8e\u81ea\u52a8\u5316\u8fd0\u7ef4\u7684\u77e5\u8bc6\uff0c\u6bd4\u5982 Operator \u660e\u786e\u5730\u77e5\u9053\u5728\u6eda\u52a8\u66f4\u65b0\u8fc7\u7a0b\u4e2d\u63a5\u4e0b\u6765\u54ea\u4e00\u4e2a Pod \u8981\u88ab\u91cd\u5efa/\u91cd\u542f\u4e86\u3002\u56e0\u6b64\u53ef\u4ee5\u63d0\u524d\u8c03\u6574\u5e94\u7528\u5185\u7684\u72b6\u6001\uff0c\u6bd4\u5982\u5c06 Pod \u4e0a\u7684\u8d1f\u8f7d\u8fdb\u884c\u8fc1\u79fb\uff0c\u6700\u5c0f\u5316\u6eda\u52a8\u66f4\u65b0\u7684\u5f71\u54cd\u3002\u8fd9\u7c7b\u5e94\u7528\u72b6\u6001\u7684\u7ba1\u7406\u903b\u8f91\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u5b9e\u73b0\u65b9\u5f0f\uff1a
\u501f\u52a9 Pod \u672c\u8eab\u7684\u5404\u7c7b\u751f\u547d\u5468\u671f\u94a9\u5b50\uff0c\u6bd4\u5982 InitContainer\u3001PostStart Hook \u548c PreStop Hook\uff0c\u5728\u8fd9\u4e9b\u94a9\u5b50\u5185\u540c\u6b65\u5e94\u7528\u72b6\u6001\u3002
\u5728 Operator \u7684\u8c03\u8c10\u5faa\u73af\u5185\u8c03\u7528\u5e94\u7528\u63a5\u53e3\u8c03\u6574\u5e94\u7528\u72b6\u6001\u3002
\u65b9\u5f0f\u4e00\u5b9e\u73b0\u8d77\u6765\u6bd4\u8f83\u7b80\u5355\uff0c\u65b9\u5f0f\u4e8c\u66f4\u81ea\u6d3b\u81ea\u7531\uff0c\u80fd\u66f4\u597d\u5730\u5e94\u5bf9\u590d\u6742\u573a\u666f\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5728\u7f29\u5bb9 CNSet \u65f6\uff0c\u8981\u5148\u5c06\u88ab\u7f29\u5bb9\u7684 CN Pod \u4e0a\u7684 session \u8fc1\u79fb\u5230\u5176\u4ed6 CN Pod \u4e0a\u518d\u505c\u6b62 CN Pod\u3002\u5047\u5982\u8fd9\u4e2a\u64cd\u4f5c\u653e\u5728 Pod PreStop Hook \u4e2d\uff0c\u90a3\u5c31\u662f\u65e0\u6cd5\u64a4\u9500\u7684\u3002\u800c\u5b9e\u9645\u573a\u666f\u4e2d\uff0c\u786e\u5b9e\u5b58\u5728\u4e00\u7ec4 CN \u5148\u88ab\u7f29\u5bb9\uff0c\u5728\u7f29\u5bb9\u5b8c\u6210\u524d\u53c8\u518d\u6269\u5bb9\u4e0a\u53bb\u7684\u573a\u666f\uff08\u5c24\u5176\u662f\u5728\u5f00\u542f\u4e86\u81ea\u52a8\u4f38\u7f29\u540e\uff09\uff0c\u8fd9\u65f6\u5019\uff0cOperator \u5185\u7684\u8c03\u8c10\u5faa\u73af\u5c31\u53ef\u4ee5\u8ba1\u7b97\u51fa\u6b64\u65f6\u53ef\u4ee5\u76f4\u63a5\u590d\u7528\u4ecd\u7136\u5728\u4e0b\u7ebf\u4e2d\u7684 CN\uff0c\u8c03\u7528 MO \u5185\u90e8\u7684\u7ba1\u7406\u63a5\u53e3\u5c06 CN \u5c06\u8fd9\u4e2a CN \u91cd\u65b0\u6062\u590d\u6210\u670d\u52a1\u72b6\u6001\uff0c\u4e0d\u518d\u5411\u5176\u4ed6 CN \u8fc1\u79fb session \u5e76\u4e14\u91cd\u65b0\u5411 Proxy \u63a5\u53d7\u65b0 session\uff0c\u800c\u4e0d\u9700\u8981\u518d\u6269\u5bb9\u51fa\u4e00\u4e2a\u65b0\u7684 CN\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_3","title":"\u603b\u7ed3","text":"\u4f5c\u4e3a\u6269\u5c55 K8S \u7f16\u6392\u80fd\u529b\u7684\u4e3b\u6d41\u9009\u9879\uff0cOperator \u6a21\u5f0f\u53d1\u5c55\u5230\u4eca\u5929\u5df2\u7ecf\u62e5\u6709\u6210\u719f\u7684\u57fa\u7840\u5e93\u548c\u5de5\u5177\u94fe\uff0c\u793e\u533a\u4e2d\u4e5f\u6709\u5927\u91cf\u7684\u6210\u719f\u5f00\u6e90\u9879\u76ee\u53ef\u4f9b\u53c2\u8003\uff0c\u5728 K8S \u4e0a\u5f00\u53d1\u4e00\u4e2a Operator \u5df2\u7ecf\u4e0d\u518d\u662f\u4e00\u4e2a\u65b0\u9c9c\u7684\u8bdd\u9898\u3002\u4f46\u771f\u6b63\u7684\u590d\u6742\u5ea6\u6c38\u8fdc\u85cf\u5728\u5b9e\u9645\u4e1a\u52a1\u7684\u7ec6\u8282\u4e2d\uff0c\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u9700\u8981\u5bf9\u7ed3\u5408\u5bf9 K8S \u548c\u81ea\u8eab\u4e1a\u52a1\u7cfb\u7edf\u9886\u57df\u77e5\u8bc6\u7684\u5145\u5206\u7406\u89e3\u3002MatrixOne \u4f5c\u4e3a\u4e00\u6b3e\u4e91\u539f\u751f\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u5176\u4e2d\u5f88\u591a\u8bbe\u8ba1\u7406\u5ff5\u548c\u9886\u57df\u77e5\u8bc6\u4e0e\u5176\u4ed6\u4e91\u539f\u751f\u7cfb\u7edf\u5b58\u5728\u5171\u901a\u4e4b\u5904\u3002\u5e0c\u671b\u8fd9\u7bc7\u77ed\u6587\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u4f60\u4e86\u89e3 mo-operator \u7684\u8bbe\u8ba1\u5b9e\u73b0\uff0c\u4e5f\u80fd\u7ed9\u4f60\u5728\u8bbe\u8ba1\u81ea\u5df1\u7684 Operator \u65f6\u63d0\u4f9b\u7ecf\u9a8c\u53c2\u8003\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-matrixone-operator/#_4","title":"\u53c2\u8003\u6587\u6863","text":"\u82e5\u5982\u60f3\u8981\u4e86\u89e3\u5173\u4e8e MatrixOne-Operator \u7684\u90e8\u7f72\u8fd0\u7ef4\uff0c\u8bf7\u53c2\u89c1\u7ae0\u8282 Operator \u7ba1\u7406
"},{"location":"MatrixOne/Overview/architecture/architecture-proxy/","title":"Proxy \u67b6\u6784\u8be6\u89e3","text":"Proxy \u4f5c\u4e3a MatrixOne \u4e2d\u627f\u62c5\u8d1f\u8f7d\u5747\u8861\u4e0e SQL \u8bf7\u6c42\u5206\u53d1\u7684\u552f\u4e00\u7ec4\u4ef6\uff0c\u901a\u8fc7\u5c06 CN \u5206\u7ec4\u6807\u7b7e\u7684\u65b9\u5f0f\uff0c\u642d\u914d Proxy \u7684 SQL \u5206\u53d1\uff0c\u5b9e\u73b0\u4f1a\u8bdd\u7ea7\u522b\u7684 SQL \u8def\u7531\u529f\u80fd\uff0c\u4ece\u800c\u9002\u914d\u591a\u79cd\u573a\u666f\u3002
\u5b83\u7684 SQL \u8bf7\u6c42\u5206\u53d1\u67b6\u6784\u56fe\u793a\u5982\u4e0b\uff1a
\u4f9d\u636e MatrixOne \u5b58\u50a8\u8ba1\u7b97\u5206\u79bb\u7684\u591a CN \u67b6\u6784\u4ee5\u53ca Proxy \u7684\u804c\u8d23\uff0c\u5728 HAKeeper \u4e0e Proxy \u4e2d\u5f15\u5165 CN \u6807\u7b7e\u7ec4\u7684\u6982\u5ff5\uff0c\u5373\u56fa\u5b9a\u540d\u79f0\u548c\u6570\u91cf\u7684 CN \u96c6\u5408\u3002
\u7531\u4e0a\u56fe\u6240\u793a\uff0c\u6280\u672f\u5b9e\u73b0\u6d41\u7a0b\u89e3\u6790\u5982\u4e0b\uff1a
yaml
\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u9009\u9879\uff08\u5305\u62ec\u914d\u7f6e\u3001\u526f\u672c\u6570\u548c\u79df\u6237\uff09\u521b\u5efa\u4e0d\u540c\u7684 CN \u6807\u7b7e\u3002Proxy \u7ec4\u4ef6\u901a\u8fc7\u8fde\u63a5\u4f1a\u8bdd\u53c2\u6570\u5224\u65ad\uff0c\u5c06\u67d0\u4e2a\u4f1a\u8bdd\u8f6c\u53d1\u7ed9\u76f8\u5e94\u7684 CN \u7ec4\uff0c\u5b9e\u73b0 SQL \u8def\u7531\u3002
\u5728\u540c\u4e00\u4e2a CN \u6807\u7b7e\u7ec4\u5185\uff0cProxy \u8d1f\u8d23\u7ec4\u5185\u8d1f\u8f7d\u5747\u8861\u3002
Proxy \u901a\u8fc7\u5206\u6790\u4f1a\u8bdd\u8bf7\u6c42\u4e2d\u7684\u53c2\u6570\u6765\u5224\u65ad\u8bf7\u6c42\u662f\u5426\u5339\u914d CN \u6807\u7b7e\u3002\u5728\u5b9e\u73b0 SQL \u8def\u7531\u65f6\uff0c\u4f1a\u8bdd\u53c2\u6570\u4f1a\u88ab\u7528\u4e8e\u67e5\u627e\u4e0e\u8bf7\u6c42\u5339\u914d\u7684 CN \u6807\u7b7e\u7ec4\u3002\u5177\u4f53\u6765\u8bf4\uff0cProxy \u53ef\u80fd\u4f1a\u68c0\u67e5 CN \u6807\u7b7e\u4e2d\u7684\u7279\u5b9a\u5b57\u6bb5\uff0c\u4f8b\u5982\u79df\u6237\u4fe1\u606f\u3001\u526f\u672c\u6570\u7b49\uff0c\u4ee5\u4fbf\u5c06\u8bf7\u6c42\u8def\u7531\u5230\u9002\u5f53\u7684 CN \u6807\u7b7e\u7ec4\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0cProxy \u53ef\u4ee5\u5b9e\u73b0\u4f1a\u8bdd\u8bf7\u6c42\u4e0e CN \u6807\u7b7e\u7684\u5339\u914d\uff0c\u5e76\u786e\u4fdd\u5c06\u8bf7\u6c42\u8def\u7531\u5230\u6b63\u786e\u7684 CN \u8282\u70b9\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-proxy/#_2","title":"\u53c2\u8003\u6587\u6863","text":"\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u5982\u4f55\u901a\u8fc7 Proxy \u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\uff0c\u53c2\u89c1\u4f7f\u7528 Proxy \u5b9e\u73b0\u79df\u6237\u548c\u8d1f\u8f7d\u72ec\u7acb\u8d44\u6e90\u7ba1\u7406
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/","title":"\u5b58\u50a8\u5f15\u64ce\u67b6\u6784\u8be6\u89e3","text":"MatrixOne \u7684\u5b58\u50a8\u5f15\u64ce\u79f0\u4e3a\u4e8b\u52a1\u5206\u6790\u5f15\u64ce\uff08Transactional Analytical Engine\uff0cTAE\uff09\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_2","title":"\u5b58\u50a8\u5f15\u64ce\u67b6\u6784","text":"TAE \u7684\u6700\u5c0f IO \u5355\u4f4d\u88ab\u79f0\u4e3a\u5217\u5757\uff08Column Block\uff09\uff0c\u76ee\u524d\u56fa\u5b9a\u884c\u6570\u8fdb\u884c\u7ec4\u7ec7\uff0c\u5bf9\u4e8e Blob \u7c7b\u578b\u7684\u5217\uff0c\u6211\u4eec\u8fdb\u884c\u4e86\u7279\u522b\u7684\u5904\u7406\u3002
TAE \u4ee5\u8868\u7684\u5f62\u5f0f\u7ec4\u7ec7\u6570\u636e\uff0c\u6bcf\u4e2a\u8868\u7684\u6570\u636e\u7ed3\u6784\u5316\u4e3a\u4e00\u4e2a LSM\uff08Log-structured Merge-tree\uff09\u6811\u3002\u5f53\u524d TAE \u7684\u5b9e\u73b0\u662f\u4e00\u4e2a\u4e09\u5c42 LSM \u6811\uff0c\u5305\u62ec L0\u3001L1 \u548c L2\u3002\u5176\u4e2d\uff0cL0 \u89c4\u6a21\u8f83\u5c0f\uff0c\u5168\u90e8\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u800c L1 \u548c L2 \u5219\u6301\u4e45\u5316\u5b58\u50a8\u5728\u786c\u76d8\u4e0a\u3002
\u5728 TAE \u4e2d\uff0cL0 \u7531\u88ab\u79f0\u4e3a\u4e34\u65f6\u5757\uff08Transient Block\uff09\u7684\u7ec4\u4ef6\u7ec4\u6210\uff0c\u6570\u636e\u5728\u6b64\u5e76\u672a\u8fdb\u884c\u6392\u5e8f\u3002\u800c L1 \u7531\u5df2\u6392\u5e8f\u5757\uff08Sorted Block\uff09\u7ec4\u6210\uff0c\u5305\u542b\u4e86\u5df2\u7ecf\u6392\u5e8f\u7684\u6570\u636e\u3002\u65b0\u7684\u6570\u636e\u603b\u662f\u88ab\u63d2\u5165\u5230\u6700\u65b0\u7684\u4e34\u65f6\u5757\u4e2d\u3002\u5f53\u63d2\u5165\u7684\u6570\u636e\u4f7f\u5f97\u8be5\u5757\u7684\u884c\u6570\u8d85\u8fc7\u9650\u5236\u65f6\uff0c\u8be5\u5757\u5c06\u8fdb\u884c\u4e3b\u952e\u6392\u5e8f\u540e\u4f5c\u4e3a\u4e00\u4e2a\u5df2\u6392\u5e8f\u5757\u5237\u65b0\u5230 L1\u3002\u5982\u679c\u5df2\u6392\u5e8f\u7684\u5757\u6570\u91cf\u8d85\u8fc7\u4e00\u4e2a\u6bb5\uff08Segment\uff09\u7684\u6700\u5927\u6570\u91cf\uff0c\u4f1a\u4f7f\u7528\u5408\u5e76\u6392\u5e8f\uff08Merge Sort\uff09\u65b9\u6cd5\u6309\u4e3b\u952e\u6392\u5e8f\u5e76\u5199\u5165 L2\u3002
L1 \u548c L2 \u5b58\u50a8\u7684\u90fd\u662f\u6309\u4e3b\u952e\u6392\u5e8f\u7684\u6570\u636e\u3002\u8fd9\u4e24\u5c42\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\uff0cL1 \u786e\u4fdd\u5757\u5185\u90e8\u7684\u6570\u636e\u6309\u4e3b\u952e\u6392\u5e8f\uff0c\u800c L2 \u786e\u4fdd\u6bcf\u4e2a\u6bb5\u5185\u7684\u6570\u636e\u6309\u4e3b\u952e\u6392\u5e8f\u3002\u8fd9\u91cc\u7684\u6bb5\u662f\u4e00\u4e2a\u903b\u8f91\u6982\u5ff5\uff0c\u7b49\u540c\u4e8e\u5176\u4ed6\u5b9e\u73b0\u4e2d\u7684\u884c\u7ec4\uff08Row Group\uff09\u6216\u884c\u96c6\uff08Row Set\uff09\u7b49\u3002\u4e00\u4e2a\u6bb5\u53ef\u4ee5\u6839\u636e\u66f4\u65b0\uff08\u5220\u9664\uff09\u64cd\u4f5c\u7684\u591a\u5c11\u8fdb\u884c\u538b\u7f29\uff0c\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u6bb5\u3002\u540c\u65f6\uff0c\u4e5f\u53ef\u4ee5\u5c06\u591a\u4e2a\u6bb5\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u6bb5\u3002\u8fd9\u4e9b\u64cd\u4f5c\u90fd\u662f\u7531\u540e\u53f0\u7684\u5f02\u6b65\u4efb\u52a1\u5b8c\u6210\uff0c\u5176\u8c03\u5ea6\u7b56\u7565\u4e3b\u8981\u6743\u8861\u5199\u653e\u5927\u548c\u8bfb\u653e\u5927\u4e4b\u95f4\u7684\u5173\u7cfb\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_3","title":"\u529f\u80fd\u7279\u6027","text":"TAE\uff0c\u5982\u4f20\u7edf\u5217\u5b58\u50a8\u5f15\u64ce\u4e00\u6837\uff0c\u5728\u5757\uff08Block\uff09\u548c\u6bb5\uff08Segment\uff09\u7ea7\u522b\u5f15\u5165\u4e86 Zonemap\uff08\u6700\u5c0f/\u6700\u5927\u6570\u636e\uff09\u4fe1\u606f\u3002\u4f5c\u4e3a\u4e00\u4e2a\u652f\u6301\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u7684\u5b58\u50a8\u5f15\u64ce\uff0cTAE \u5b9e\u73b0\u4e86\u5b8c\u6574\u7684\u4e3b\u952e\u7ea6\u675f\u529f\u80fd\uff0c\u5305\u62ec\u652f\u6301\u591a\u5217\u4e3b\u952e\u548c\u5168\u5c40\u81ea\u589e ID\u3002\u6bcf\u4e2a\u8868\u7684\u4e3b\u952e\u90fd\u4f1a\u9ed8\u8ba4\u521b\u5efa\u4e00\u4e2a\u4e3b\u952e\u7d22\u5f15\uff0c\u4e3b\u8981\u7528\u4e8e\u63d2\u5165\u6570\u636e\u65f6\u53bb\u91cd\u4ee5\u6ee1\u8db3\u4e3b\u952e\u7ea6\u675f\uff0c\u4ee5\u53ca\u6839\u636e\u4e3b\u952e\u8fdb\u884c\u8fc7\u6ee4\u3002
\u4e3b\u952e\u53bb\u91cd\u662f\u6570\u636e\u63d2\u5165\u7684\u5173\u952e\u6b65\u9aa4\uff0cTAE \u5728\u4ee5\u4e0b\u4e09\u4e2a\u65b9\u9762\u8fbe\u5230\u5e73\u8861\u6548\u679c\uff1a
\u4ece\u7d22\u5f15\u7c92\u5ea6\u6765\u770b\uff0cTAE \u53ef\u4ee5\u5206\u4e3a\u4e24\u7c7b\uff1a\u8868\u7ea7\u7d22\u5f15\u548c\u6bb5\u7ea7\u7d22\u5f15\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u6709\u4e00\u4e2a\u8868\u7ea7\u7d22\u5f15\uff0c\u6216\u8005\u6bcf\u4e2a\u6bb5\u90fd\u6709\u4e00\u4e2a\u7d22\u5f15\u3002\u7531\u4e8e TAE \u7684\u8868\u6570\u636e\u7531\u591a\u4e2a\u6bb5\u7ec4\u6210\uff0c\u6bcf\u4e2a\u6bb5\u7684\u6570\u636e\u90fd\u4f1a\u7ecf\u5386\u4ece L1 \u5230 L3\uff0c\u4ece\u65e0\u5e8f\u5230\u6709\u5e8f\u7684\u538b\u7f29/\u5408\u5e76\u8fc7\u7a0b\uff0c\u8fd9\u5bf9\u8868\u7ea7\u7d22\u5f15\u4e0d\u53cb\u597d\uff0c\u56e0\u6b64\uff0cTAE \u7684\u7d22\u5f15\u5efa\u7acb\u5728\u6bb5\u7ea7\u3002
\u5728\u6bb5\u7ea7\u7d22\u5f15\u4e2d\uff0c\u6709\u4e24\u79cd\u7c7b\u578b\u7684\u6bb5\uff0c\u4e00\u79cd\u53ef\u4ee5\u8fdb\u884c\u8ffd\u52a0\u4fee\u6539\uff0c\u53e6\u4e00\u79cd\u4e0d\u53ef\u4fee\u6539\u3002\u5bf9\u4e8e\u4e0d\u53ef\u4fee\u6539\u7684\u6bb5\uff0c\u6bb5\u7ea7\u7d22\u5f15\u662f\u4e00\u4e2a\u5305\u542b Bloomfilter \u548c Zonemap \u7684\u4e24\u7ea7\u7ed3\u6784\u3002\u5bf9\u4e8e\u53ef\u8ffd\u52a0\u4fee\u6539\u7684\u6bb5\uff0c\u5b83\u81f3\u5c11\u7531\u4e00\u4e2a\u53ef\u8ffd\u52a0\u7684\u5757\u548c\u591a\u4e2a\u4e0d\u53ef\u8ffd\u52a0\u7684\u5757\u7ec4\u6210\u3002\u53ef\u8ffd\u52a0\u7684\u5757\u7d22\u5f15\u662f\u4e00\u4e2a\u5e38\u9a7b\u5185\u5b58\u7684 ART-tree\uff08Adaptive Radix Tree\uff09\u7ed3\u6784\u548c Zonemap\uff0c\u800c\u4e0d\u53ef\u8ffd\u52a0\u7684\u5219\u662f Bloomfilter \u548c Zonemap\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_5","title":"\u7f13\u5b58\u533a\u7ba1\u7406","text":"\u5728\u7a33\u5b9a\u7684\u5b58\u50a8\u5f15\u64ce\u4e2d\uff0c\u7cbe\u7ec6\u7684\u5185\u5b58\u7ba1\u7406\u79bb\u4e0d\u5f00\u7f13\u5b58\u533a\u7ba1\u7406\u3002\u867d\u7136\u7f13\u5b58\u533a\u7ba1\u7406\u5728\u7406\u8bba\u4e0a\u53ea\u662f\u4e00\u4e2a\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\uff08LRU\uff09\u7f13\u5b58\u7684\u6982\u5ff5\uff0c\u4f46\u6570\u636e\u5e93\u4e0d\u4f1a\u76f4\u63a5\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u9875\u7f13\u5b58\uff08Page Cache\uff09\u6765\u4ee3\u66ff\u7f13\u5b58\u7ba1\u7406\u5668\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u7c7b\u578b\u7684\u6570\u636e\u5e93\u3002
\u5728 MatrixOne \u4e2d\uff0c\u4f7f\u7528\u7f13\u5b58\u7ba1\u7406\u5668\u5bf9\u5185\u5b58\u7f13\u51b2\u533a\u8fdb\u884c\u7ba1\u7406\u3002\u6bcf\u4e2a\u7f13\u51b2\u533a\u8282\u70b9\uff08buffer node\uff09\u5177\u6709\u56fa\u5b9a\u7684\u5927\u5c0f\uff0c\u5e76\u5206\u914d\u7ed9\u4ee5\u4e0b\u56db\u4e2a\u533a\u57df\uff1a
\u6bcf\u4e2a\u7f13\u51b2\u533a\u8282\u70b9\u90fd\u6709 Loaded \u548c Unloaded \u4e24\u79cd\u72b6\u6001\u3002\u5f53\u7528\u6237\u8981\u6c42\u7f13\u5b58\u7ba1\u7406\u5668\u5bf9\u8282\u70b9\u8fdb\u884c\u56fa\u5b9a\uff08Pin\uff09\u64cd\u4f5c\u65f6\uff0c\u5982\u679c\u8282\u70b9\u5904\u4e8e Loaded \u72b6\u6001\uff0c\u5f15\u7528\u8ba1\u6570\u4f1a\u589e\u52a0 1\uff1b\u5982\u679c\u8282\u70b9\u5904\u4e8e Unloaded \u72b6\u6001\uff0c\u5b83\u4f1a\u4ece\u786c\u76d8\u6216\u8fdc\u7a0b\u5b58\u50a8\u4e2d\u8bfb\u53d6\u6570\u636e\uff0c\u5e76\u589e\u52a0\u8282\u70b9\u7684\u5f15\u7528\u8ba1\u6570\u3002\u5f53\u5185\u5b58\u7a7a\u95f4\u4e0d\u8db3\u65f6\uff0c\u7cfb\u7edf\u4f1a\u6309\u7167 LRU \u7b56\u7565\u4ece\u5185\u5b58\u4e2d\u79fb\u9664\u4e00\u4e9b\u8282\u70b9\uff0c\u4ee5\u91ca\u653e\u7a7a\u95f4\u3002\u5f53\u7528\u6237\u53d6\u6d88\u5bf9\u8282\u70b9\u7684\u56fa\u5b9a\uff08Unpin\uff09\u65f6\uff0c\u53ea\u9700\u5173\u95ed\u8282\u70b9\u53e5\u67c4\u3002\u5982\u679c\u5f15\u7528\u8ba1\u6570\u4e3a 0\uff0c\u8be5\u8282\u70b9\u5c06\u6210\u4e3a\u53ef\u80fd\u88ab\u79fb\u9664\u7684\u5019\u9009\u8282\u70b9\uff1b\u5982\u679c\u5f15\u7528\u8ba1\u6570\u5927\u4e8e 0\uff0c\u8be5\u8282\u70b9\u5c06\u4e0d\u4f1a\u88ab\u79fb\u9664\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_6","title":"\u9884\u5199\u65e5\u5fd7\u4e0e\u65e5\u5fd7\u56de\u653e","text":"\u5728 TAE \u4e2d\uff0c\u6211\u4eec\u4f18\u5316\u4e86 redo log \u7684\u5904\u7406\u65b9\u5f0f\uff0c\u4f7f\u5f97\u5217\u5b58\u50a8\u5f15\u64ce\u7684\u9884\u5199\u65e5\u5fd7\uff08WAL\uff0cWrite Ahead Log\uff09\u8bbe\u8ba1\u66f4\u52a0\u9ad8\u6548\u3002\u76f8\u6bd4\u884c\u5b58\u50a8\u5f15\u64ce\uff0cTAE \u53ea\u9700\u8981\u5728\u4e8b\u52a1\u63d0\u4ea4\u65f6\u8bb0\u5f55 redo log\uff0c\u800c\u4e0d\u662f\u6bcf\u6b21\u5199\u64cd\u4f5c\u90fd\u8bb0\u5f55\u3002\u6211\u4eec\u5229\u7528\u7f13\u5b58\u7ba1\u7406\u5668\u964d\u4f4e\u4e86\u8f93\u5165\u8f93\u51fa\uff08IO\uff09\u7684\u4f7f\u7528\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u751f\u547d\u5468\u671f\u77ed\u4e14\u53ef\u80fd\u9700\u8981\u56de\u6eda\u7684\u4e8b\u52a1\uff0c\u6211\u4eec\u907f\u514d\u4e86 IO \u4e8b\u4ef6\u7684\u53d1\u751f\u3002\u6b64\u5916\uff0cTAE \u8fd8\u80fd\u591f\u652f\u6301\u5927\u578b\u6216\u957f\u65f6\u95f4\u7684\u4e8b\u52a1\u3002
TAE \u7684\u9884\u5199\u65e5\u5fd7\u91c7\u7528\u4ee5\u4e0b\u683c\u5f0f\u7684\u65e5\u5fd7\u6761\u76ee\u5934\u90e8\uff08Log Entry Header\uff09\uff1a
\u9879\u76ee \u5b57\u8282\u5927\u5c0f GroupID 4 LSN 8 \u957f\u5ea6 8 \u7c7b\u578b 1\u4e8b\u52a1\u65e5\u5fd7\u6761\u76ee\u5305\u62ec\u4ee5\u4e0b\u7c7b\u578b\uff1a
\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u503c \u8bf4\u660e AC int8 0x10 \u5df2\u63d0\u4ea4\u4e8b\u52a1\u7684\u5b8c\u6574\u5199\u64cd\u4f5c PC int8 0x11 \u5df2\u63d0\u4ea4\u4e8b\u52a1\u7684\u90e8\u5206\u5199\u64cd\u4f5c UC int8 0x12 \u672a\u63d0\u4ea4\u4e8b\u52a1\u7684\u90e8\u5206\u5199\u64cd\u4f5c RB int8 0x13 \u4e8b\u52a1\u56de\u6eda CKP int8 0x40 \u68c0\u67e5\u70b9\u5927\u90e8\u5206\u4e8b\u52a1\u53ea\u6709\u4e00\u4e2a\u65e5\u5fd7\u6761\u76ee\uff0c\u4f46\u66f4\u5927\u6216\u66f4\u957f\u7684\u4e8b\u52a1\u53ef\u80fd\u9700\u8981\u8bb0\u5f55\u591a\u4e2a\u65e5\u5fd7\u6761\u76ee\u3002\u56e0\u6b64\uff0c\u4e00\u4e2a\u4e8b\u52a1\u7684\u65e5\u5fd7\u53ef\u80fd\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a UC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\u548c\u4e00\u4e2a PC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\uff0c\u6216\u8005\u53ea\u6709\u4e00\u4e2a AC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\u3002UC \u7c7b\u578b\u7684\u65e5\u5fd7\u6761\u76ee\u88ab\u5206\u914d\u5230\u4e00\u4e2a\u4e13\u95e8\u7684\u7ec4\u3002
\u5728 TAE \u4e2d\uff0c\u4e8b\u52a1\u65e5\u5fd7\u6761\u76ee\u7684\u6709\u6548\u8f7d\u8377\uff08Payload\uff09\u5305\u542b\u591a\u4e2a\u4e8b\u52a1\u8282\u70b9\u3002\u4e8b\u52a1\u8282\u70b9\u5305\u62ec\u6570\u636e\u64cd\u4f5c\u8bed\u8a00\uff08DML\uff09\u7684\u5220\u9664\u3001\u6dfb\u52a0\u3001\u66f4\u65b0\u64cd\u4f5c\uff0c\u4ee5\u53ca\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff08DDL\uff09\u7684\u521b\u5efa/\u5220\u9664\u8868\u3001\u521b\u5efa/\u5220\u9664\u6570\u636e\u5e93\u7b49\u3002\u6bcf\u4e2a\u4e8b\u52a1\u8282\u70b9\u90fd\u662f\u5df2\u63d0\u4ea4\u65e5\u5fd7\u6761\u76ee\u7684\u5b50\u9879\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u4e8b\u52a1\u65e5\u5fd7\u7684\u4e00\u90e8\u5206\u3002\u6d3b\u52a8\u4e8b\u52a1\u7684\u8282\u70b9\u5171\u4eab\u56fa\u5b9a\u5927\u5c0f\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u5e76\u7531\u7f13\u5b58\u7ba1\u7406\u5668\u8fdb\u884c\u7ba1\u7406\u3002\u5f53\u5269\u4f59\u7a7a\u95f4\u4e0d\u8db3\u65f6\uff0c\u90e8\u5206\u4e8b\u52a1\u8282\u70b9\u4f1a\u88ab\u5378\u8f7d\uff08Unload\uff09\uff0c\u5e76\u5c06\u76f8\u5e94\u7684\u65e5\u5fd7\u6761\u76ee\u4fdd\u5b58\u5728 Redo Log \u4e2d\u3002\u5728\u52a0\u8f7d\u65f6\uff0c\u8fd9\u4e9b\u65e5\u5fd7\u6761\u76ee\u4f1a\u88ab\u56de\u653e\uff0c\u5373\u5e94\u7528\u5230\u76f8\u5e94\u7684\u4e8b\u52a1\u8282\u70b9\u4e2d\u3002
Checkpoint \u662f\u4e00\u79cd\u5b89\u5168\u70b9\uff0c\u5728\u7cfb\u7edf\u91cd\u542f\u671f\u95f4\uff0c\u72b6\u6001\u673a\u53ef\u4ee5\u4ece\u8be5\u70b9\u5f00\u59cb\u5e94\u7528\u65e5\u5fd7\u6761\u76ee\u3002Checkpoint \u4e4b\u524d\u7684\u65e5\u5fd7\u6761\u76ee\u4e0d\u518d\u9700\u8981\uff0c\u5e76\u4f1a\u5728\u9002\u5f53\u7684\u65f6\u673a\u88ab\u7269\u7406\u9500\u6bc1\u3002TAE \u901a\u8fc7\u7ec4\uff08Group\uff09\u6765\u8bb0\u5f55\u6700\u540e\u4e00\u4e2a Checkpoint \u7684\u4fe1\u606f\uff0c\u4f7f\u5f97\u5728\u7cfb\u7edf\u91cd\u542f\u65f6\u53ef\u4ee5\u4ece\u6700\u540e\u4e00\u4e2a Checkpoint \u5f00\u59cb\u8fdb\u884c\u65e5\u5fd7\u56de\u653e\u3002
TAE \u7684 WAL \u548c\u65e5\u5fd7\u56de\u653e\u90e8\u5206\u5df2\u88ab\u72ec\u7acb\u62bd\u8c61\u4e3a\u4e00\u4e2a\u540d\u4e3a logstore \u7684\u4ee3\u7801\u6a21\u5757\u3002\u5b83\u63d0\u4f9b\u4e86\u5bf9\u5e95\u5c42\u65e5\u5fd7\u5b58\u53d6\u64cd\u4f5c\u7684\u62bd\u8c61\uff0c\u53ef\u4ee5\u9002\u914d\u4e0d\u540c\u7684\u5b9e\u73b0\uff0c\u4ece\u5355\u673a\u5230\u5206\u5e03\u5f0f\u3002\u5728\u7269\u7406\u5c42\u9762\uff0clogstore \u7684\u884c\u4e3a\u7c7b\u4f3c\u4e8e\u6d88\u606f\u961f\u5217\u3002\u4ece MatrixOne 0.6 \u7248\u672c\u5f00\u59cb\uff0c\u6211\u4eec\u5c06\u6f14\u8fdb\u4e3a\u4e91\u539f\u751f\u7248\u672c\uff0c\u5e76\u4f7f\u7528\u72ec\u7acb\u7684 shared log \u670d\u52a1\u4f5c\u4e3a\u65e5\u5fd7\u670d\u52a1\u3002\u56e0\u6b64\uff0c\u5728\u5c06\u6765\u7684\u7248\u672c\u4e2d\uff0cTAE \u7684 logstore \u5c06\u8fdb\u884c\u9002\u5f53\u7684\u4fee\u6539\uff0c\u76f4\u63a5\u8bbf\u95ee\u5916\u90e8\u7684 shared log \u670d\u52a1\uff0c\u800c\u4e0d\u4f9d\u8d56\u4e8e\u4efb\u4f55\u672c\u5730\u5b58\u50a8\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#_7","title":"\u4e8b\u52a1\u5904\u7406","text":"TAE \u901a\u8fc7\u91c7\u7528\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff08MVCC\uff09\u673a\u5236\u6765\u4fdd\u8bc1\u4e8b\u52a1\u7684\u9694\u79bb\u6027\u3002\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u914d\u5907\u4e00\u4e2a\u7531\u4e8b\u52a1\u542f\u52a8\u65f6\u95f4\u51b3\u5b9a\u7684\u4e00\u81f4\u6027\u8bfb\u53d6\u89c6\u56fe\uff08\u8bfb\u89c6\u56fe\uff09\uff0c\u56e0\u6b64\u4e8b\u52a1\u5185\u90e8\u8bfb\u53d6\u7684\u6570\u636e\u6c38\u4e0d\u4f1a\u53cd\u6620\u5176\u4ed6\u5e76\u53d1\u4e8b\u52a1\u6240\u505a\u7684\u4fee\u6539\u3002TAE \u63d0\u4f9b\u4e86\u7ec6\u7c92\u5ea6\u7684\u4e50\u89c2\u5e76\u53d1\u63a7\u5236\uff0c\u5728\u5bf9\u540c\u4e00\u884c\u548c\u540c\u4e00\u5217\u8fdb\u884c\u66f4\u65b0\u64cd\u4f5c\u65f6\u624d\u53ef\u80fd\u53d1\u751f\u51b2\u7a81\u3002\u4e8b\u52a1\u4f7f\u7528\u7684\u662f\u5728\u4e8b\u52a1\u5f00\u59cb\u65f6\u5df2\u5b58\u5728\u7684\u503c\u7248\u672c\uff0c\u5e76\u5728\u8bfb\u53d6\u6570\u636e\u65f6\u4e0d\u5bf9\u5176\u8fdb\u884c\u52a0\u9501\u3002\u5f53\u4e24\u4e2a\u4e8b\u52a1\u8bd5\u56fe\u66f4\u65b0\u540c\u4e00\u4e2a\u503c\u65f6\uff0c\u7b2c\u4e8c\u4e2a\u4e8b\u52a1\u4f1a\u56e0\u4e3a\u5199 - \u5199\u51b2\u7a81\u800c\u5931\u8d25\u3002
\u5728 TAE \u7684\u67b6\u6784\u4e2d\uff0c\u4e00\u4e2a\u8868\u7531\u591a\u4e2a\u6bb5\u7ec4\u6210\uff0c\u6bcf\u4e2a\u6bb5\u662f\u591a\u4e2a\u4e8b\u52a1\u5171\u540c\u4ea7\u751f\u7684\u7ed3\u679c\u3002\u56e0\u6b64\uff0c\u4e00\u4e2a\u6bb5\u53ef\u4ee5\u8868\u793a\u4e3a $[T{start}, T{end}]$
\u3002$[T{start}
\u662f\u6700\u65e9\u4e8b\u52a1\u7684\u63d0\u4ea4\u65f6\u95f4\uff0cT{end}]$
\u662f\u6700\u65b0\u4e8b\u52a1\u7684\u63d0\u4ea4\u65f6\u95f4\u3002\u4e3a\u4e86\u80fd\u591f\u538b\u7f29\u6bb5\u5e76\u8fdb\u884c\u5408\u5e76\uff0c\u6211\u4eec\u9700\u8981\u5728\u6bb5\u7684\u8868\u793a\u4e2d\u589e\u52a0\u4e00\u4e2a\u7ef4\u5ea6\u4ee5\u533a\u5206\u7248\u672c\uff0c\u5373 $([T{start} T{end}]
\uff0c[T{create}, T{drop}])$
\u3002$T{create}$
\u662f\u6bb5\u7684\u521b\u5efa\u65f6\u95f4\uff0c$T{drop}$
\u662f\u6bb5\u7684\u5220\u9664\u65f6\u95f4\u3002\u5f53 $T{drop} = 0$
\u65f6\u8868\u793a\u8be5\u6bb5\u672a\u88ab\u4e22\u5f03\u3002\u5757\u7684\u8868\u793a\u65b9\u5f0f\u4e0e\u6bb5 $([T{start}, T{end}]
\uff0c[T{create}, T{drop}])$
\u76f8\u540c\u3002\u4e8b\u52a1\u63d0\u4ea4\u65f6\uff0c\u9700\u8981\u6839\u636e\u63d0\u4ea4\u65f6\u95f4\u6765\u83b7\u53d6\u5b83\u7684\u8bfb\u89c6\u56fe\uff1a$(Txn{commit} \\geqslant T{create})\\bigcap\uff08(T{drop}= 0)\\bigcup\uff08T{drop} > Txn{commit}))$
\u3002
\u6bb5\u7684\u751f\u6210\u548c\u53d8\u5316\u7531\u540e\u53f0\u5f02\u6b65\u4efb\u52a1\u5904\u7406\uff0c\u4e3a\u786e\u4fdd\u6570\u636e\u8bfb\u53d6\u7684\u4e00\u81f4\u6027\uff0cTAE \u5c06\u8fd9\u4e9b\u5f02\u6b65\u4efb\u52a1\u7eb3\u5165\u5230\u4e8b\u52a1\u5904\u7406\u6846\u67b6\u4e2d\uff0c\u5982\u4e0b\u4f8b\u6240\u793a\uff1a
L0 \u5c42\u7684\u5757 $Block1 {L0}$
\u5728 $t1$
\u65f6\u521b\u5efa\uff0c\u5b83\u5305\u542b\u4e86\u6765\u81ea $Txn1
\u3001Txn2
\u3001Txn3
\u3001Txn4$
\u7684\u6570\u636e\u3002$Block1 {L0}$
\u5728 $t11$
\u5f00\u59cb\u6392\u5e8f\uff0c\u5b83\u7684\u8bfb\u89c6\u56fe\u662f\u57fa\u7ebf\u52a0\u4e0a\u4e00\u4e2a\u672a\u63d0\u4ea4\u7684\u66f4\u65b0\u8282\u70b9\u3002\u6392\u5e8f\u548c\u6301\u4e45\u5316\u5757\u53ef\u80fd\u9700\u8981\u8f83\u957f\u65f6\u95f4\u3002\u5728\u63d0\u4ea4\u6392\u5e8f\u7684 $Block2 {L1}$
\u4e4b\u524d\uff0c\u5b58\u5728\u4e24\u4e2a\u5df2\u63d0\u4ea4\u4e8b\u52a1 $Txn5
\u3001Txn6$
\u548c\u4e00\u4e2a\u672a\u63d0\u4ea4\u4e8b\u52a1 $Txn7$
\u3002\u5f53 $Txn7$
\u5728 $t16$
\u63d0\u4ea4\u65f6\uff0c\u5c06\u5931\u8d25\uff0c\u56e0\u4e3a $Block1 {L0}$
\u5df2\u7ecf\u88ab\u7ec8\u6b62\u3002\u5728 $(t11, t16)$
\u671f\u95f4\u63d0\u4ea4\u7684\u66f4\u65b0\u8282\u70b9 $Txn5
\u3001Txn6$
\u5c06\u88ab\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u7684\u66f4\u65b0\u8282\u70b9\uff0c\u5b83\u5c06\u4e0e $Block2 {L1}$
\u5728 $t16$
\u65f6\u4e00\u540c\u63d0\u4ea4\u3002
\u538b\u7f29\u8fc7\u7a0b\u4f1a\u7ec8\u6b62\u4e00\u7cfb\u5217\u5757\u6216\u6bb5\uff0c\u5e76\u539f\u5b50\u6027\u5730\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5757\u6216\u6bb5\uff08\u6216\u5efa\u7acb\u7d22\u5f15\uff09\u3002\u4e0e\u5e38\u89c4\u4e8b\u52a1\u76f8\u6bd4\uff0c\u6b64\u8fc7\u7a0b\u901a\u5e38\u9700\u8981\u66f4\u957f\u7684\u65f6\u95f4\uff0c\u800c\u6211\u4eec\u4e0d\u5e0c\u671b\u963b\u6b62\u6d89\u53ca\u7684\u5757\u6216\u6bb5\u7684\u66f4\u65b0\u6216\u5220\u9664\u4e8b\u52a1\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u6269\u5c55\u4e86\u8bfb\u89c6\u56fe\uff0c\u5c06\u5757\u548c\u6bb5\u7684\u5143\u6570\u636e\u7eb3\u5165\u5176\u4e2d\u3002\u5728\u63d0\u4ea4\u5e38\u89c4\u4e8b\u52a1\u65f6\uff0c\u4e00\u65e6\u68c0\u6d4b\u5230\u5199\u64cd\u4f5c\u5bf9\u5e94\u7684\u5757\uff08\u6216\u6bb5\uff09\u7684\u5143\u6570\u636e\u5df2\u66f4\u6539\uff08\u63d0\u4ea4\uff09\uff0c\u8be5\u4e8b\u52a1\u5c06\u5931\u8d25\u3002\u5bf9\u4e8e\u538b\u7f29\u4e8b\u52a1\uff0c\u5176\u5199\u64cd\u4f5c\u5305\u62ec\u5757\uff08\u6216\u6bb5\uff09\u7684\u8f6f\u5220\u9664\u548c\u6dfb\u52a0\u3002\u5728\u4e8b\u52a1\u6267\u884c\u671f\u95f4\uff0c\u6bcf\u6b21\u5199\u5165\u64cd\u4f5c\u90fd\u4f1a\u68c0\u6d4b\u662f\u5426\u5b58\u5728\u5199 - \u5199\u51b2\u7a81\u3002\u4e00\u65e6\u51b2\u7a81\u53d1\u751f\uff0c\u4e8b\u52a1\u5c06\u88ab\u63d0\u524d\u7ec8\u6b62\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-tae/#mvcc","title":"MVCC\uff08\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09","text":"\u6570\u636e\u5e93\u7684\u7248\u672c\u5b58\u50a8\u673a\u5236\u51b3\u5b9a\u4e86\u7cfb\u7edf\u5982\u4f55\u4fdd\u5b58\u4e0d\u540c\u7248\u672c\u7684\u5143\u7ec4\u4ee5\u53ca\u6bcf\u4e2a\u7248\u672c\u6240\u5305\u542b\u7684\u4fe1\u606f\u3002TAE \u521b\u5efa\u4e86\u4e00\u4e2a\u79f0\u4e3a\u7248\u672c\u94fe\u7684\u65e0\u9501\u94fe\u8868\uff0c\u5b83\u57fa\u4e8e\u6570\u636e\u5143\u7ec4\u7684\u6307\u9488\u5b57\u6bb5\u3002\u7248\u672c\u94fe\u4f7f\u5f97\u6570\u636e\u5e93\u80fd\u591f\u51c6\u786e\u5730\u5b9a\u4f4d\u5230\u6240\u9700\u5143\u7ec4\u7684\u7248\u672c\u3002\u56e0\u6b64\uff0c\u7248\u672c\u6570\u636e\u7684\u5b58\u50a8\u673a\u5236\u662f\u6570\u636e\u5e93\u5b58\u50a8\u5f15\u64ce\u8bbe\u8ba1\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u8003\u8651\u56e0\u7d20\u3002
\u4e00\u79cd\u89e3\u51b3\u65b9\u6848\u662f\u91c7\u7528\u8ffd\u52a0\u6a21\u5f0f\uff08Append Only\uff09\u673a\u5236\uff0c\u5c06\u4e00\u4e2a\u8868\u7684\u6240\u6709\u5143\u7ec4\u7248\u672c\u5b58\u50a8\u5728\u540c\u4e00\u4e2a\u5b58\u50a8\u7a7a\u95f4\u4e2d\u3002\u7531\u4e8e\u65e0\u6cd5\u7ef4\u62a4\u4e00\u4e2a\u65e0\u9501\u7684\u53cc\u5411\u94fe\u8868\uff0c\u7248\u672c\u94fe\u53ea\u80fd\u6307\u5411\u4e00\u4e2a\u65b9\u5411\uff0c\u8981\u4e48\u662f\u4ece\u65e7\u5230\u65b0\uff08O2N\uff09\uff0c\u8981\u4e48\u662f\u4ece\u65b0\u5230\u65e7\uff08N2O\uff09\u3002
\u53e6\u4e00\u79cd\u7c7b\u4f3c\u7684\u65b9\u6848\u88ab\u79f0\u4e3a\u65f6\u5149\u65c5\u884c\uff08Time-Travel\uff09\uff0c\u5b83\u5c06\u7248\u672c\u94fe\u7684\u4fe1\u606f\u5355\u72ec\u5b58\u653e\uff0c\u800c\u4e3b\u8868\u5219\u7ef4\u62a4\u4e3b\u7248\u672c\u7684\u6570\u636e\u3002
\u7b2c\u4e09\u79cd\u65b9\u6848\u662f\u5728\u4e3b\u8868\u4e2d\u7ef4\u62a4\u5143\u7ec4\u7684\u4e3b\u7248\u672c\uff0c\u5e76\u5728\u5355\u72ec\u7684\u589e\u91cf\u5b58\u50a8\u4e2d\u7ef4\u62a4\u4e00\u7cfb\u5217\u589e\u91cf\u7248\u672c\u3002\u5728\u66f4\u65b0\u73b0\u6709\u5143\u7ec4\u65f6\uff0c\u6570\u636e\u5e93\u4ece\u589e\u91cf\u5b58\u50a8\u4e2d\u83b7\u53d6\u4e00\u6bb5\u8fde\u7eed\u7684\u7a7a\u95f4\uff0c\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u589e\u91cf\u7248\u672c\uff0c\u8be5\u589e\u91cf\u7248\u672c\u4ec5\u5305\u542b\u88ab\u4fee\u6539\u5c5e\u6027\u7684\u539f\u59cb\u503c\uff0c\u800c\u4e0d\u662f\u6574\u4e2a\u5143\u7ec4\u3002\u7136\u540e\u6570\u636e\u5e93\u76f4\u63a5\u5bf9\u4e3b\u8868\u4e2d\u7684\u4e3b\u7248\u672c\u8fdb\u884c\u539f\u5730\u66f4\u65b0\u3002
\u4ee5\u4e0a\u5404\u79cd\u65b9\u6848\u90fd\u6709\u5176\u7279\u70b9\uff0c\u5e76\u5bf9\u5b83\u4eec\u5728 OLTP \u5de5\u4f5c\u8d1f\u8f7d\u4e2d\u7684\u8868\u73b0\u4ea7\u751f\u5f71\u54cd\u3002\u5bf9\u4e8e LSM \u6811\u6765\u8bf4\uff0c\u7531\u4e8e\u5176\u5929\u7136\u7684\u8ffd\u52a0\u6a21\u5f0f\u7ed3\u6784\uff0c\u56e0\u6b64\u66f4\u63a5\u8fd1\u7b2c\u4e00\u79cd\u65b9\u6848\u3002\u4f46\u662f\u7248\u672c\u94fe\u7684\u94fe\u8868\u53ef\u80fd\u4e0d\u4f1a\u663e\u73b0\u3002
TAE \u76ee\u524d\u9009\u62e9\u4e86\u7b2c\u4e09\u79cd\u65b9\u6848\u7684\u53d8\u4f53\uff1a
\u5728\u5927\u91cf\u66f4\u65b0\u7684\u60c5\u51b5\u4e0b\uff0cLSM \u6811\u7ed3\u6784\u7684\u65e7\u7248\u672c\u6570\u636e\u4f1a\u5bfc\u81f4\u5927\u91cf\u7684\u8bfb\u653e\u5927\u3002\u800c TAE \u7684\u7248\u672c\u94fe\u7531\u7f13\u51b2\u533a\u7ba1\u7406\u5668\u7ef4\u62a4\uff0c\u5f53\u9700\u8981\u88ab\u66ff\u6362\u65f6\uff0c\u5b83\u4f1a\u4e0e\u4e3b\u8868\u6570\u636e\u5408\u5e76\uff0c\u91cd\u65b0\u751f\u6210\u65b0\u7684\u5757\u3002\u56e0\u6b64\uff0c\u5728\u8bed\u4e49\u4e0a\uff0c\u5b83\u662f\u539f\u5730\u66f4\u65b0\uff0c\u4f46\u5728\u5b9e\u73b0\u4e0a\u662f\u5199\u65f6\u590d\u5236\uff0c\u8fd9\u5bf9\u4e8e\u4e91\u5b58\u50a8\u6765\u8bf4\u662f\u5fc5\u9700\u7684\u3002\u91cd\u65b0\u751f\u6210\u7684\u65b0\u5757\u7684\u8bfb\u653e\u5927\u8f83\u5c11\uff0c\u8fd9\u5bf9\u4e8e\u9891\u7e41\u66f4\u65b0\u540e\u7684 AP \u67e5\u8be2\u66f4\u6709\u5229\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/","title":"\u4e8b\u52a1\u4e0e\u9501\u673a\u5236\u5b9e\u73b0\u8be6\u89e3","text":"\u672c\u6587\u5c06\u5411\u4f60\u4ecb\u7ecd MatrixOne \u7684\u4e8b\u52a1\u4e0e\u9501\u673a\u5236\u7684\u5b9e\u73b0\u7ec6\u8282\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#matrixone","title":"MatrixOne \u4e8b\u52a1\u7279\u6027","text":"MatrixOne \u9ed8\u8ba4\u652f\u6301\u60b2\u89c2\u4e8b\u52a1\u4ee5\u53ca\u8bfb\u5df2\u63d0\u4ea4\uff08Read Committed\uff09\u9694\u79bb\u7ea7\u522b\u3002\u540c\u65f6\u4e5f\u652f\u6301\u57fa\u4e8e\u5feb\u7167\u9694\u79bb\uff08Snapshot Isolation\uff09\u7684\u4e50\u89c2\u4e8b\u52a1\u3002\u4f46\u4e50\u89c2\u4e8b\u52a1\u548c\u60b2\u89c2\u4e8b\u52a1\u4e0d\u80fd\u540c\u65f6\u8fd0\u884c\u3002\u5728\u96c6\u7fa4\u4e2d\uff0c\u8981\u4e48\u4f7f\u7528\u60b2\u89c2\u4e8b\u52a1\u6a21\u578b\uff0c\u8981\u4e48\u4f7f\u7528\u4e50\u89c2\u4e8b\u52a1\u6a21\u578b\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#matrixone_1","title":"MatrixOne \u4e8b\u52a1\u67b6\u6784","text":"MatrixOne \u96c6\u7fa4\u7531\u4e09\u4e2a\u5185\u7f6e\u670d\u52a1\u6784\u6210\uff1aCN\uff08Compute Node\uff09\u3001TN\uff08Transaction Node\uff09\u3001LogService\uff0c\u4ee5\u53ca\u4e00\u4e2a\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#cn-compute-node","title":"CN (Compute Node)","text":"CN \u662f\u8ba1\u7b97\u8282\u70b9\uff0c\u8d1f\u8d23\u6267\u884c\u5927\u90e8\u5206\u8ba1\u7b97\u5de5\u4f5c\u3002\u6bcf\u4e2a\u4e8b\u52a1\u5ba2\u6237\u7aef\uff08\u5982 JDBC \u6216 MySQL \u5ba2\u6237\u7aef\uff09\u90fd\u4f1a\u4e0e\u4e00\u4e2a CN \u5efa\u7acb\u8fde\u63a5\uff0c\u53d1\u8d77\u7684\u4e8b\u52a1\u5c06\u5728\u76f8\u5e94\u7684 CN \u4e0a\u521b\u5efa\u3002\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u4f1a\u5728 CN \u4e0a\u5206\u914d\u4e00\u4e2a\u5de5\u4f5c\u7a7a\u95f4\uff0c\u7528\u4e8e\u5b58\u50a8\u4e8b\u52a1\u7684\u4e34\u65f6\u6570\u636e\u3002\u5f53\u4e8b\u52a1\u63d0\u4ea4\u65f6\uff0c\u5de5\u4f5c\u7a7a\u95f4\u4e2d\u7684\u6570\u636e\u5c06\u88ab\u53d1\u9001\u5230 TN \u8282\u70b9\u4ee5\u8fdb\u884c\u63d0\u4ea4\u5904\u7406\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#tn-transaction-node","title":"TN (Transaction Node)","text":"TN \u662f\u4e8b\u52a1\u8282\u70b9\uff0c\u8d1f\u8d23\u5904\u7406\u6240\u6709 CN \u8282\u70b9\u4e0a\u7684\u4e8b\u52a1\u63d0\u4ea4\u3002TN \u8282\u70b9\u7684\u804c\u8d23\u5305\u62ec\u5c06\u4e8b\u52a1\u7684\u63d0\u4ea4\u65e5\u5fd7\u5199\u5165 LogService\uff0c\u5e76\u5c06\u63d0\u4ea4\u7684\u6570\u636e\u5199\u5165\u5185\u5b58\u3002\u5f53\u5185\u5b58\u6570\u636e\u8fbe\u5230\u4e00\u5b9a\u6761\u4ef6\u65f6\uff0cTN \u8282\u70b9\u4f1a\u5c06\u63d0\u4ea4\u7684\u6570\u636e\u5199\u5165\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\uff0c\u5e76\u6e05\u7406\u76f8\u5173\u7684\u65e5\u5fd7\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#logservice","title":"LogService","text":"LogService \u662f\u65e5\u5fd7\u8282\u70b9\uff0c\u7c7b\u4f3c\u4e8e TN \u8282\u70b9\u7684 Write-Ahead Logging\uff08WAL\uff09\u7cfb\u7edf\u3002\u5b83\u4f7f\u7528 Raft \u534f\u8bae\u5c06\u65e5\u5fd7\u5b58\u50a8\u4e3a\u591a\u4e2a\u526f\u672c\uff0c\u4ee5\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u5f3a\u4e00\u81f4\u6027\u3002MatrixOne \u968f\u65f6\u53ef\u4ee5\u901a\u8fc7 LogService \u6765\u6062\u590d TN \u8282\u70b9\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cLogService \u4e2d\u5b58\u50a8\u7684\u65e5\u5fd7\u5e76\u4e0d\u4f1a\u65e0\u9650\u589e\u957f\u3002\u5f53\u65e5\u5fd7\u5927\u5c0f\u8fbe\u5230\u4e00\u5b9a\u9608\u503c\u65f6\uff0cTN \u4f1a\u5c06 LogService \u4e2d\u7684\u65e5\u5fd7\u5bf9\u5e94\u7684\u6570\u636e\u5199\u5165\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\uff0c\u5e76\u622a\u65ad LogService \u4e2d\u7684\u65e5\u5fd7\u3002\u8fd9\u622a\u65ad\u540e\u7684\u65e5\u5fd7\u6570\u636e\u88ab\u79f0\u4e3a \"LogTail\"\uff0c\u52a0\u4e0a\u5916\u90e8\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u6570\u636e\u6784\u6210\u4e86 MatrixOne \u6570\u636e\u5e93\u7684\u5168\u90e8\u6570\u636e\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_2","title":"\u65f6\u949f\u65b9\u6848","text":"MatrixOne \u91c7\u7528 HLC\uff08Hybrid Logical Clocks\uff09\u65f6\u949f\u65b9\u6848\uff0c\u5e76\u4e0e\u5185\u7f6e\u7684 MORPC\uff08MatrixOne Remote Procedure Call\uff09\u96c6\u6210\uff0c\u7528\u4e8e\u5b9e\u73b0 CN \u548c TN \u8282\u70b9\u4e4b\u95f4\u7684\u65f6\u949f\u540c\u6b65\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_3","title":"\u4e8b\u52a1\u7684\u8bfb\u64cd\u4f5c","text":"\u4e8b\u52a1\u7684\u8bfb\u64cd\u4f5c\u53d1\u751f\u5728 CN \u8282\u70b9\uff0c\u5b83\u53ef\u4ee5\u67e5\u770b MVCC\uff08\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09\u4e2d\u7684\u6570\u636e\u7248\u672c\uff0c\u8fd9\u53d6\u51b3\u4e8e\u4e8b\u52a1\u7684\u5feb\u7167\u65f6\u95f4\u6233\uff08SnapshotTS\uff09\u3002
\u4e00\u65e6\u4e8b\u52a1\u786e\u5b9a\u4e86\u5176 SnapshotTS\uff0c\u5b83\u9700\u8981\u8bbf\u95ee\u4e24\u4e2a\u6570\u636e\u96c6\uff1a\u4e00\u4e2a\u5b58\u50a8\u5728\u5bf9\u8c61\u5b58\u50a8\u4e2d\uff0c\u53e6\u4e00\u4e2a\u5b58\u50a8\u5728 LogTail \u4e2d\u3002\u5bf9\u8c61\u5b58\u50a8\u4e2d\u7684\u6570\u636e\u53ef\u4ee5\u88ab CN \u76f4\u63a5\u8bbf\u95ee\uff0c\u5e76\u63d0\u4f9b\u4e86\u7f13\u5b58\u4ee5\u63d0\u9ad8\u6570\u636e\u8bfb\u53d6\u7684\u6027\u80fd\u3002\u800c LogTail \u4e2d\u7684\u6570\u636e\u5206\u5e03\u5728 TN \u8282\u70b9\u7684\u5185\u5b58\u4e2d\u3002
\u5728\u4ee5\u5f80\u7684\u7248\u672c\u4e2d\uff0cCN \u8282\u70b9\u91c7\u7528 \"Pull \u6a21\u5f0f\"\uff0c\u5373\u53ea\u6709\u5728\u4e8b\u52a1\u5f00\u59cb\u540e\u624d\u4e3b\u52a8\u4e0e TN \u540c\u6b65 LogTail \u6570\u636e\uff0c\u8fd9\u5bfc\u81f4\u4e86\u6027\u80fd\u8f83\u5dee\u3001\u5ef6\u8fdf\u8f83\u9ad8\u548c\u541e\u5410\u91cf\u8f83\u4f4e\u7684\u95ee\u9898\u3002\u4f46\u4ece 0.8 \u7248\u672c\u5f00\u59cb\uff0cMatrixOne \u5f15\u5165\u4e86 \"Push \u6a21\u5f0f\"\uff0c\u5176\u4e2d LogTail \u7684\u540c\u6b65\u4e0d\u518d\u5728\u4e8b\u52a1\u5f00\u59cb\u65f6\u53d1\u8d77\uff0c\u800c\u662f\u91c7\u7528 CN \u7ea7\u522b\u7684\u8ba2\u9605\u65b9\u5f0f\uff0cTN \u8282\u70b9\u5728\u6bcf\u6b21 LogTail \u53d8\u5316\u65f6\u5c06\u589e\u91cf\u7684 LogTail \u540c\u6b65\u7ed9\u8ba2\u9605\u7684 CN \u8282\u70b9\u3002
\u5728 Push \u6a21\u5f0f\u4e0b\uff0c\u6bcf\u4e2a CN \u8282\u70b9\u4f1a\u4e0d\u65ad\u63a5\u6536\u6765\u81ea TN \u8282\u70b9\u7684 LogTail \u63a8\u9001\uff0c\u5e76\u5728 CN \u8282\u70b9\u4e0a\u7ef4\u62a4\u4e0e TN \u8282\u70b9\u76f8\u540c\u7684\u5185\u5b58\u6570\u636e\u7ed3\u6784\uff0c\u4ee5\u53ca\u6700\u540e\u4e00\u6b21\u6d88\u8d39\u7684 LogTail \u65f6\u95f4\u6233\u3002\u4e00\u65e6\u4e8b\u52a1\u7684 SnapshotTS \u786e\u5b9a\uff0c\u53ea\u9700\u8981\u7b49\u5f85\u6700\u540e\u4e00\u6b21\u6d88\u8d39\u7684 LogTail \u7684\u65f6\u95f4\u6233\u5927\u4e8e\u6216\u7b49\u4e8e SnapshotTS\uff0c\u5c31\u8868\u793a CN \u62e5\u6709\u5b8c\u6574\u7684 SnapshotTS \u6570\u636e\u96c6\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_4","title":"\u6570\u636e\u53ef\u89c1\u6027","text":"\u4e8b\u52a1\u80fd\u591f\u8bfb\u53d6\u7684\u6570\u636e\u53d6\u51b3\u4e8e\u5176 SnapshotTS\u3002
\u5982\u679c\u6bcf\u4e2a\u4e8b\u52a1\u90fd\u4f7f\u7528\u6700\u65b0\u7684\u65f6\u95f4\u6233\u4f5c\u4e3a SnapshotTS\uff0c\u90a3\u4e48\u8be5\u4e8b\u52a1\u53ef\u4ee5\u8bfb\u53d6\u5728\u5176\u4e4b\u524d\u63d0\u4ea4\u7684\u4efb\u4f55\u6570\u636e\u3002\u8fd9\u5c06\u786e\u4fdd\u8bfb\u53d6\u7684\u6570\u636e\u59cb\u7ec8\u662f\u6700\u65b0\u7684\uff0c\u4f46\u4e5f\u4f1a\u4ed8\u51fa\u4e00\u4e9b\u6027\u80fd\u4ee3\u4ef7\u3002
\u5728 Pull \u6a21\u5f0f\u4e0b\uff0c\u9700\u8981\u7b49\u5f85 TN \u8282\u70b9\u540c\u6b65 SnapshotTS \u4e4b\u524d\u7684\u6240\u6709\u4e8b\u52a1\u90fd\u5df2\u63d0\u4ea4\u3002\u5feb\u7167 TS \u8d8a\u65b0\uff0c\u9700\u8981\u7b49\u5f85\u7684\u4e8b\u52a1\u63d0\u4ea4\u8d8a\u591a\uff0c\u4ece\u800c\u5bfc\u81f4\u5ef6\u8fdf\u8f83\u9ad8\u3002
\u5728 Push \u6a21\u5f0f\u4e0b\uff0cCN \u8282\u70b9\u9700\u8981\u7b49\u5f85 SnapshotTS \u4e4b\u524d\u7684\u6240\u6709\u4e8b\u52a1\u7684 Commit \u7684 LogTail \u88ab\u6d88\u8d39\u3002\u4e5f\u662f\u8d8a\u65b0\u7684 SnapshotTS \u9700\u8981\u7b49\u5f85\u7684\u4e8b\u52a1\u63d0\u4ea4\u8d8a\u591a\uff0c\u4ece\u800c\u5bfc\u81f4\u8f83\u9ad8\u7684\u5ef6\u8fdf\u3002
\u7136\u800c\uff0c\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u5e76\u4e0d\u9700\u8981\u59cb\u7ec8\u8bfb\u53d6\u6700\u65b0\u6570\u636e\u3002MatrixOne \u76ee\u524d\u63d0\u4f9b\u4e86\u4e24\u79cd\u6570\u636e\u65b0\u9c9c\u5ea6\u7ea7\u522b\uff1a
\u4f7f\u7528\u5f53\u524d\u65f6\u95f4\u6233\u4f5c\u4e3a SnapshotTS\uff0c\u4ee5\u59cb\u7ec8\u67e5\u770b\u6700\u65b0\u6570\u636e\u3002
\u4f7f\u7528 CN \u8282\u70b9\u5df2\u6d88\u8d39\u5b8c\u7684\u6700\u5927 LogTail \u65f6\u95f4\u6233\u4f5c\u4e3a SnapshotTS\u3002
\u5bf9\u4e8e\u7b2c\u4e8c\u79cd\u65b9\u5f0f\uff0c\u5b83\u7684\u597d\u5904\u5728\u4e8e\u4e8b\u52a1\u51e0\u4e4e\u6ca1\u6709\u5ef6\u8fdf\uff0c\u53ef\u4ee5\u7acb\u5373\u5f00\u59cb\u8bfb\u5199\u6570\u636e\uff0c\u56e0\u4e3a\u6240\u9700\u7684 LogTail \u6570\u636e\u90fd\u5df2\u51c6\u5907\u5c31\u7eea\uff0c\u6027\u80fd\u548c\u5ef6\u8fdf\u8868\u73b0\u826f\u597d\u3002\u4f46\u662f\uff0c\u8fd9\u4e5f\u5e26\u6765\u4e00\u4e2a\u95ee\u9898\uff0c\u5982\u679c\u540c\u4e00\u6570\u636e\u5e93\u8fde\u63a5\u4e0a\u7684\u591a\u4e2a\u4e8b\u52a1\uff0c\u540e\u4e00\u4e2a\u4e8b\u52a1\u53ef\u80fd\u65e0\u6cd5\u770b\u5230\u524d\u4e00\u4e2a\u4e8b\u52a1\u7684\u5199\u5165\u64cd\u4f5c\uff0c\u56e0\u4e3a\u540e\u4e00\u4e2a\u4e8b\u52a1\u5f00\u59cb\u65f6\uff0cTN \u8282\u70b9\u5c1a\u672a\u5c06\u524d\u4e00\u4e2a\u4e8b\u52a1\u7684 Commit \u7684 LogTail \u63a8\u9001\u5230\u5f53\u524d CN \u8282\u70b9\uff0c\u4ece\u800c\u5bfc\u81f4\u540e\u4e00\u4e2a\u4e8b\u52a1\u4f7f\u7528\u8f83\u65e7\u7684 SnapshotTS\uff0c\u65e0\u6cd5\u770b\u5230\u524d\u4e00\u4e2a\u4e8b\u52a1\u7684\u5199\u5165\u3002
\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cMatrixOne \u7ef4\u62a4\u4e86\u4e24\u4e2a\u65f6\u95f4\u6233\uff1a\u5f53\u524d CN \u8282\u70b9\u7684\u6700\u540e\u4e00\u4e2a\u4e8b\u52a1\u7684 CommitTS\uff08CNCommitTS\uff09\u548c\u5f53\u524d\u4f1a\u8bdd\uff08\u6570\u636e\u5e93\u8fde\u63a5\uff09\u7684\u6700\u540e\u4e00\u4e2a\u4e8b\u52a1\u7684 CommitTS\uff08SessionCommitTS\uff09\u3002\u6b64\u5916\uff0cMatrixOne \u63d0\u4f9b\u4e86\u4e24\u79cd\u6570\u636e\u53ef\u89c1\u6027\u7ea7\u522b\uff08\u5c06\u5f53\u524d CN \u8282\u70b9\u6d88\u8d39\u7684\u6700\u5927 LogTail \u7684\u65f6\u95f4\u6233\u79f0\u4e3a LastLogTailTS\uff09\uff1a
\u4f1a\u8bdd\u7ea7\u522b\u7684\u6570\u636e\u53ef\u89c1\u6027\uff0c\u4f7f\u7528 Max(SessionCommitTS, LastLogTailTS) \u4f5c\u4e3a\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u4ee5\u4fdd\u8bc1\u540c\u4e00\u4f1a\u8bdd\u4e2d\u53d1\u751f\u7684\u4e8b\u52a1\u6570\u636e\u7684\u53ef\u89c1\u6027\u3002
CN \u7ea7\u522b\u7684\u6570\u636e\u53ef\u89c1\u6027\uff0c\u4f7f\u7528 Max(CNCommitTS, LastLogTailTS) \u4f5c\u4e3a\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u4ee5\u4fdd\u8bc1\u540c\u4e00 CN \u8282\u70b9\u4e0a\u53d1\u751f\u7684\u4e8b\u52a1\u6570\u636e\u7684\u53ef\u89c1\u6027\u3002
\u524d\u9762\u7684\u7ae0\u8282\u4e3b\u8981\u4ecb\u7ecd\u4e86 MatrixOne \u4e8b\u52a1\u7684\u5904\u7406\uff0cMatrixOne \u4e4b\u524d\u4ec5\u652f\u6301 SI \u9694\u79bb\u7ea7\u522b\uff0c\u57fa\u4e8e MVCC \u5b9e\u73b0\uff0c\u6570\u636e\u5177\u6709\u591a\u4e2a\u7248\u672c\u3002\u7136\u800c\uff0c\u73b0\u5728 MatrixOne \u8fd8\u652f\u6301 RC\uff08Read Committed\uff09\u9694\u79bb\u7ea7\u522b\u3002
\u8981\u5728\u591a\u7248\u672c\u4e0a\u5b9e\u73b0 RC \u9694\u79bb\u7ea7\u522b\uff0c\u5bf9\u4e8e SI \u4e8b\u52a1\uff0c\u9700\u8981\u7ef4\u62a4\u4e00\u81f4\u7684\u5feb\u7167\uff0c\u4e0d\u7ba1\u4f55\u65f6\u8bfb\u53d6\uff0c\u90fd\u80fd\u770b\u5230\u76f8\u540c\u7684\u6570\u636e\u3002\u4f46\u662f RC \u9700\u8981\u67e5\u770b\u6700\u65b0\u63d0\u4ea4\u7684\u6570\u636e\uff0c\u8fd9\u76f8\u5f53\u4e8e\u4e00\u81f4\u7684\u5feb\u7167\u4e0d\u518d\u662f\u4e8b\u52a1\u751f\u547d\u5468\u671f\u5185\u7684\uff0c\u800c\u662f\u9488\u5bf9\u6bcf\u4e2a\u67e5\u8be2\u7684\u3002\u6bcf\u6b21\u67e5\u8be2\u5f00\u59cb\u65f6\uff0c\u4f7f\u7528\u5f53\u524d\u65f6\u95f4\u6233\u4f5c\u4e3a\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u4ee5\u786e\u4fdd\u67e5\u8be2\u53ef\u4ee5\u770b\u5230\u4e4b\u524d\u63d0\u4ea4\u7684\u6570\u636e\u3002
\u5728 RC \u6a21\u5f0f\u4e0b\uff0c\u5bf9\u4e8e\u5e26\u6709\u66f4\u65b0\u7684\u8bed\u53e5\uff08UPDATE\u3001DELETE\u3001SELECT FOR UPDATE\uff09\uff0c\u4e00\u65e6\u51fa\u73b0\u5199 - \u5199\u51b2\u7a81\uff0c\u5373\u610f\u5473\u7740\u5176\u4ed6\u5e76\u53d1\u4e8b\u52a1\u5df2\u4fee\u6539\u4e86\u67e5\u8be2\u6240\u6d89\u53ca\u7684\u6570\u636e\u3002\u7531\u4e8e RC \u9700\u8981\u770b\u5230\u6700\u65b0\u7684\u5199\u5165\uff0c\u56e0\u6b64\u5982\u679c\u51fa\u73b0\u51b2\u7a81\u4e8b\u52a1\u5df2\u63d0\u4ea4\uff0c\u5fc5\u987b\u66f4\u65b0\u4e8b\u52a1\u7684 SnapshotTS\uff0c\u7136\u540e\u91cd\u8bd5\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_5","title":"\u60b2\u89c2\u4e8b\u52a1","text":"\u672c\u7ae0\u4ecb\u7ecd MatrixOne \u5982\u4f55\u5b9e\u73b0\u60b2\u89c2\u4e8b\u52a1\u4ee5\u53ca\u76f8\u5173\u8bbe\u8ba1\u8003\u8651\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_6","title":"\u9700\u8981\u89e3\u51b3\u7684\u6838\u5fc3\u95ee\u9898","text":"MatrixOne \u5b9e\u73b0\u60b2\u89c2\u4e8b\u52a1\u9700\u8981\u89e3\u51b3\u4e00\u4e9b\u5173\u952e\u95ee\u9898\uff1a
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_7","title":"\u63d0\u4f9b\u9501\u670d\u52a1","text":"\u9501\u670d\u52a1\u7528\u4e8e\u9501\u5b9a\u5355\u4e2a\u8bb0\u5f55\u3001\u8303\u56f4\u751a\u81f3\u6574\u4e2a\u8868\u3002\u5f53\u4e8b\u52a1\u5728\u8bfb/\u5199\u64cd\u4f5c\u4e2d\u9700\u8981\u9501\u5b9a\u8d44\u6e90\u65f6\uff0c\u5982\u679c\u53d1\u73b0\u9501\u51b2\u7a81\uff0c\u9700\u8981\u5b9e\u73b0\u9501\u7b49\u5f85\u3002\u5f53\u5f62\u6210\u6b7b\u9501\u73af\u8def\u65f6\uff0c\u9700\u8981\u6709\u6b7b\u9501\u68c0\u6d4b\u673a\u5236\u6765\u89e3\u9664\u6b7b\u9501\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_8","title":"\u53ef\u6269\u5c55\u7684\u9501\u670d\u52a1\u6027\u80fd","text":"MatrixOne \u7684\u4e8b\u52a1\u53ef\u80fd\u53d1\u751f\u5728\u4efb\u4f55 CN \u8282\u70b9\u3002\u5f53\u591a\u4e2a\u8282\u70b9\u540c\u65f6\u8bbf\u95ee\u9501\u670d\u52a1\u65f6\uff0c\u9501\u670d\u52a1\u7684\u6027\u80fd\u5fc5\u987b\u5177\u5907\u53ef\u6269\u5c55\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#tn-commit","title":"\u53bb\u6389 TN \u8282\u70b9 Commit \u9636\u6bb5\u7684\u51b2\u7a81\u68c0\u6d4b","text":"\u5728\u60b2\u89c2\u6a21\u5f0f\u4e0b\uff0cMatrixOne \u96c6\u7fa4\u4e2d\u5b58\u5728\u591a\u4e2a TN \u8282\u70b9\uff0c\u56e0\u6b64\u9700\u8981\u786e\u4fdd\u53ef\u4ee5\u5b89\u5168\u5730\u53bb\u9664 Commit \u9636\u6bb5\u7684\u51b2\u7a81\u68c0\u6d4b\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_9","title":"\u9501\u670d\u52a1","text":"MatrixOne \u5df2\u7ecf\u5b9e\u73b0\u4e86 LockService \u6765\u63d0\u4f9b\u9501\u670d\u52a1\uff0c\u5305\u62ec\u52a0\u9501\u3001\u89e3\u9501\u3001\u9501\u51b2\u7a81\u68c0\u6d4b\u3001\u9501\u7b49\u5f85\u4ee5\u53ca\u6b7b\u9501\u68c0\u6d4b\u7684\u529f\u80fd\u3002
LockService \u5e76\u4e0d\u662f\u4e00\u4e2a\u72ec\u7acb\u90e8\u7f72\u7684\u7ec4\u4ef6\uff0c\u800c\u662f\u4e00\u4e2a CN \u7684\u7ec4\u4ef6\u3002\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u6bcf\u4e2a CN \u7684 LockService \u5b9e\u4f8b\u90fd\u80fd\u611f\u77e5\u5230\u5176\u4ed6 LockService \u5b9e\u4f8b\uff0c\u534f\u8c03\u6574\u4e2a\u96c6\u7fa4\u4e2d\u7684 LockService \u4e00\u8d77\u5de5\u4f5c\u3002\u6bcf\u4e2a CN \u53ea\u4f1a\u8bbf\u95ee\u5f53\u524d\u8282\u70b9\u7684 LockService \u5b9e\u4f8b\uff0c\u4e0d\u4f1a\u611f\u77e5\u5230\u5176\u4ed6 LockService \u5b9e\u4f8b\u3002\u5bf9\u4e8e CN \u6765\u8bf4\uff0c\u5f53\u524d\u8282\u70b9\u7684 LockService \u8868\u73b0\u5f97\u5c31\u50cf\u662f\u4e00\u4e2a\u672c\u5730\u7684\u7ec4\u4ef6\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#locktable","title":"LockTable","text":"\u9501\u4fe1\u606f\u5b58\u50a8\u5728\u4e00\u4e2a\u540d\u4e3a LockTable \u7684\u7ec4\u4ef6\u4e2d\uff0c\u4e00\u4e2a LockService \u53ef\u4ee5\u5305\u542b\u591a\u4e2a LockTable\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u7b2c\u4e00\u6b21\u8bbf\u95ee\u67d0\u4e2a\u8868\u7684\u9501\u670d\u52a1\u65f6\uff0cLockService \u4f1a\u521b\u5efa\u4e00\u4e2a LockTable \u5b9e\u4f8b\uff0c\u8fd9\u4e2a LockTable \u5c06\u88ab\u9644\u52a0\u5230\u5f53\u524d CN \u7684 LockService \u5b9e\u4f8b\u4e2d\u3002\u5728\u6574\u4e2a\u96c6\u7fa4\u4e2d\uff0c\u4e00\u4e2a LockTable \u5c06\u4f1a\u6709\u4e00\u4e2a\u672c\u5730 LockTable \u548c\u591a\u4e2a\u8fdc\u7a0b LockTable \u5b9e\u4f8b\u3002\u53ea\u6709\u672c\u5730 LockTable \u624d\u771f\u6b63\u4fdd\u5b58\u9501\u4fe1\u606f\uff0c\u8fdc\u7a0b LockTable \u5145\u5f53\u8bbf\u95ee\u672c\u5730 LockTable \u7684\u4ee3\u7406\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#locktableallocator","title":"LockTableAllocator","text":"LockTableAllocator \u662f\u7528\u4e8e\u5206\u914d LockTable \u7684\u7ec4\u4ef6\uff0c\u5b83\u5728\u5185\u5b58\u4e2d\u8bb0\u5f55\u4e86 MatrixOne \u96c6\u7fa4\u4e2d\u6240\u6709 LockTable \u7684\u5206\u5e03\u60c5\u51b5\u3002
LockTableAllocator \u4e0d\u662f\u4e00\u4e2a\u72ec\u7acb\u90e8\u7f72\u7684\u7ec4\u4ef6\uff0c\u5b83\u662f TN \u7684\u4e00\u4e2a\u7ec4\u4ef6\u3002\u7531\u4e8e LockTable \u548c LockService \u7684\u7ed1\u5b9a\u662f\u53ef\u53d8\u7684\uff0c\u6bd4\u5982 LockTableAllocator \u68c0\u6d4b\u5230\u67d0\u4e2a CN \u4e0b\u7ebf\uff0c\u7ed1\u5b9a\u5173\u7cfb\u5c06\u53d1\u751f\u53d8\u5316\uff0c\u6bcf\u6b21\u7ed1\u5b9a\u5173\u7cfb\u53d8\u5316\u65f6\uff0c\u7ed1\u5b9a\u7248\u672c\u53f7\u90fd\u4f1a\u589e\u52a0\u3002
\u5728\u4e8b\u52a1\u5f00\u59cb\u548c\u4e8b\u52a1\u63d0\u4ea4\u7684\u65f6\u95f4\u7a97\u53e3\u5185\uff0cLockTable \u548c LockService \u7684\u7ed1\u5b9a\u5173\u7cfb\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u8fd9\u79cd\u4e0d\u4e00\u81f4\u53ef\u80fd\u4f1a\u5f15\u53d1\u6570\u636e\u51b2\u7a81\uff0c\u4ece\u800c\u5bfc\u81f4\u60b2\u89c2\u4e8b\u52a1\u6a21\u578b\u5931\u6548\u3002\u56e0\u6b64\uff0cLockTableAllocator \u662f TN \u7684\u7ec4\u4ef6\uff0c\u4f1a\u5728\u5904\u7406\u4e8b\u52a1\u63d0\u4ea4\u4e4b\u524d\u68c0\u67e5\u7ed1\u5b9a\u5173\u7cfb\u662f\u5426\u6709\u53d8\u5316\uff0c\u5982\u679c\u53d1\u73b0\u67d0\u4e2a\u4e8b\u52a1\u8bbf\u95ee\u7684
LockTable \u7684\u7ed1\u5b9a\u5173\u7cfb\u5df2\u8fc7\u65f6\uff0c\u5c06\u4e2d\u6b62\u8be5\u4e8b\u52a1\u4ee5\u786e\u4fdd\u6b63\u786e\u6027\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_10","title":"\u5206\u5e03\u5f0f\u6b7b\u9501\u68c0\u6d4b","text":"\u6240\u6709\u6d3b\u52a8\u4e8b\u52a1\u6240\u6301\u6709\u7684\u9501\u5206\u5e03\u5728\u591a\u4e2a LockService \u7684\u672c\u5730 LockTable \u4e2d\uff0c\u56e0\u6b64\u9700\u8981\u4e00\u79cd\u5206\u5e03\u5f0f\u6b7b\u9501\u68c0\u6d4b\u673a\u5236\u3002
\u6bcf\u4e2a LockService \u90fd\u6709\u4e00\u4e2a\u6b7b\u9501\u68c0\u6d4b\u6a21\u5757\uff0c\u5176\u68c0\u6d4b\u673a\u5236\u5927\u81f4\u5982\u4e0b\uff1a
\u4e3a\u6bcf\u4e2a\u9501\u5728\u5185\u5b58\u4e2d\u7ef4\u62a4\u4e00\u4e2a\u7b49\u5f85\u961f\u5217\uff1b
\u5f53\u53d1\u751f\u65b0\u7684\u51b2\u7a81\u65f6\uff0c\u9700\u8981\u5c06\u4e8b\u52a1\u6dfb\u52a0\u5230\u9501\u6301\u6709\u8005\u7684\u7b49\u5f85\u961f\u5217\u4e2d\uff1b
\u542f\u52a8\u5f02\u6b65\u4efb\u52a1\uff0c\u9012\u5f52\u67e5\u627e\u7b49\u5f85\u961f\u5217\u4e2d\u6240\u6709\u4e8b\u52a1\u6301\u6709\u7684\u9501\uff0c\u68c0\u67e5\u662f\u5426\u5b58\u5728\u7b49\u5f85\u73af\u8def\u3002\u5982\u679c\u9047\u5230\u8fdc\u7a0b\u4e8b\u52a1\u7684\u9501\uff0c\u4f7f\u7528 RPC \u83b7\u53d6\u8fdc\u7a0b\u4e8b\u52a1\u6301\u6709\u7684\u6240\u6709\u9501\u4fe1\u606f\u3002
\u6574\u4e2a\u9501\u670d\u52a1\u7684\u5173\u952e\u6570\u636e\u90fd\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u5305\u62ec\u9501\u4fe1\u606f\u3001LockTable \u548c LockService \u7684\u7ed1\u5b9a\u5173\u7cfb\u3002\u5bf9\u4e8e\u672c\u5730 LockTable \u5185\u90e8\u8bb0\u5f55\u7684\u9501\u4fe1\u606f\uff0c\u5982\u679c CN \u5b95\u673a\uff0c\u90a3\u4e48\u4e0e\u8be5 CN \u8fde\u63a5\u7684\u4e8b\u52a1\u5c06\u5931\u8d25\uff0c\u56e0\u4e3a\u6570\u636e\u5e93\u8fde\u63a5\u65ad\u5f00\u3002\u7136\u540e LockTableAllocator \u4f1a\u91cd\u65b0\u5206\u914d LockTable \u548c LockService \u7684\u7ed1\u5b9a\u5173\u7cfb\uff0c\u4ece\u800c\u786e\u4fdd\u6574\u4e2a\u9501\u670d\u52a1\u53ef\u4ee5\u7ee7\u7eed\u63d0\u4f9b\u670d\u52a1\u3002
LockTableAllocator \u8fd0\u884c\u5728 TN \u4e2d\uff0c\u4e00\u65e6 TN \u5b95\u673a\uff0cHAKeeper \u4f1a\u4fee\u590d\u4e00\u4e2a\u65b0\u7684 TN\uff0c\u5bfc\u81f4\u6240\u6709\u7ed1\u5b9a\u5173\u7cfb\u5931\u6548\u3002\u8fd9\u610f\u5473\u7740\u5f53\u524d\u6d3b\u52a8\u7684\u6240\u6709\u4e8b\u52a1\u90fd\u4f1a\u56e0\u7ed1\u5b9a\u5173\u7cfb\u4e0d\u5339\u914d\u800c\u63d0\u4ea4\u5931\u8d25\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-transaction-lock/#_12","title":"\u5982\u4f55\u4f7f\u7528\u9501\u670d\u52a1","text":"\u4e3a\u4e86\u66f4\u597d\u5730\u4f7f\u7528\u9501\u670d\u52a1\uff0cMatrixOne \u5b9e\u73b0\u4e86\u4e00\u4e2a Lock \u7b97\u5b50\uff0c\u8d1f\u8d23\u8c03\u7528\u548c\u5904\u7406\u9501\u670d\u52a1\u3002
\u5728 SQL \u7684\u8ba1\u5212\u9636\u6bb5\uff0c\u5982\u679c\u662f\u60b2\u89c2\u4e8b\u52a1\uff0c\u4f1a\u5904\u7406\u76f8\u5e94\u7684\u60c5\u51b5\uff0c\u7136\u540e\u5728\u6267\u884c\u9636\u6bb5\uff0c\u5728\u5408\u9002\u7684\u4f4d\u7f6e\u63d2\u5165 Lock \u7b97\u5b50\u3002
\u5bf9\u4e8e INSERT
\u63d2\u5165\u64cd\u4f5c\uff0c\u8ba1\u5212\u9636\u6bb5\u4f1a\u5728\u5176\u4ed6 Insert \u7b97\u5b50\u4e4b\u524d\u9996\u5148\u63d2\u5165 Lock \u7b97\u5b50\uff0c\u540e\u7eed\u6267\u884c\u65f6\uff0c\u53ea\u6709\u5728\u6210\u529f\u83b7\u53d6\u9501\u540e\u624d\u4f1a\u6267\u884c\u540e\u7eed\u7b97\u5b50\u3002
\u5bf9\u4e8e DELETE
\u5220\u9664\u64cd\u4f5c\uff0c\u4e0e\u63d2\u5165\u7c7b\u4f3c\uff0c\u8ba1\u5212\u9636\u6bb5\u4f1a\u5728\u5176\u4ed6 Delete \u7b97\u5b50\u4e4b\u524d\u63d2\u5165 Lock \u7b97\u5b50\uff0c\u7136\u540e\u53ea\u6709\u5728\u6210\u529f\u83b7\u53d6\u9501\u540e\u624d\u4f1a\u6267\u884c\u540e\u7eed\u7b97\u5b50\u3002
\u5bf9\u4e8e UPDATE
\u66f4\u65b0\u64cd\u4f5c\uff0c\u8ba1\u5212\u9636\u6bb5\u4f1a\u88ab\u62c6\u5206\u6210 Delete+Insert\uff0c\u56e0\u6b64\u4f1a\u6709\u4e24\u6b21\u9501\u5b9a\u9636\u6bb5\uff08\u5982\u679c\u672a\u4fee\u6539\u4e3b\u952e\uff0c\u5219\u4f1a\u4f18\u5316\u4e3a\u4e00\u6b21\u9501\u5b9a\uff0cInsert \u9636\u6bb5\u5c06\u4e0d\u4f1a\u9501\u5b9a\uff09\u3002
WAL\uff08Write Ahead Log\uff09\u662f\u4e00\u9879\u4e0e\u6570\u636e\u5e93\u539f\u5b50\u6027\u548c\u6301\u4e45\u6027\u76f8\u5173\u7684\u6280\u672f\uff0c\u5728\u4e8b\u52a1\u63d0\u4ea4\u65f6\u628a\u968f\u673a\u5199\u8f6c\u6362\u6210\u987a\u5e8f\u8bfb\u5199\u3002\u4e8b\u52a1\u7684\u66f4\u6539\u968f\u673a\u5730\u53d1\u751f\u5728\u5404\u9875\u4e0a\uff0c\u8fd9\u4e9b\u9875\u5f88\u5206\u6563\uff0c\u968f\u673a\u5199\u7684\u5f00\u9500\u5927\u4e8e\u987a\u5e8f\u5199\uff0c\u4f1a\u964d\u4f4e\u63d0\u4ea4\u7684\u6027\u80fd\u3002WAL \u53ea\u8bb0\u5f55\u4e8b\u52a1\u7684\u66f4\u6539\u64cd\u4f5c\uff0c\u4f8b\u5982\u5728\u67d0\u4e2a block \u4e2d\u589e\u52a0\u4e86\u4e00\u884c\uff0c\u63d0\u4ea4\u4e8b\u52a1\u65f6\u65b0\u7684 WAL entry \u987a\u5e8f\u5730\u5199\u5728 WAL \u6587\u4ef6\u672b\u5c3e\uff0c\u63d0\u4ea4\u4e4b\u540e\u518d\u5f02\u6b65\u5730\u66f4\u65b0\u90a3\u4e9b\u810f\u9875\uff0c\u9500\u6bc1\u5bf9\u5e94\u7684 WAL entry\uff0c\u91ca\u653e\u7a7a\u95f4\u3002
MatrixOne \u7684 WAL \u662f\u7269\u7406\u65e5\u5fd7\uff0c\u5b83\u4f1a\u8bb0\u5f55\u6bcf\u884c\u66f4\u65b0\u53d1\u751f\u7684\u4f4d\u7f6e\uff0c\u6bcf\u6b21\u56de\u653e\u51fa\u6765\uff0c\u6570\u636e\u4e0d\u4ec5\u5728\u903b\u8f91\u4e0a\u76f8\u540c\uff0c\u5728\u5e95\u5c42\u7684\u7ec4\u7ec7\u7ed3\u6784\u4e5f\u662f\u4e00\u6837\u7684\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#commit-pipeline","title":"Commit Pipeline","text":"Commit Pipeline \u662f\u5904\u7406\u4e8b\u52a1\u63d0\u4ea4\u7684\u7ec4\u4ef6\u3002\u63d0\u4ea4\u4e4b\u524d\u8981\u66f4\u65b0 memtable\uff0c\u6301\u4e45\u5316 WAL entry\uff0c\u6267\u884c\u8fd9\u4e9b\u4efb\u52a1\u7684\u8017\u65f6\u51b3\u5b9a\u4e86\u63d0\u4ea4\u7684\u6027\u80fd\u3002\u6301\u4e45\u5316 WAL entry \u6d89\u53ca\u5230 IO\uff0c\u6bd4\u8f83\u8017\u65f6\u3002MatrixOne \u4e2d\u91c7\u7528 commit pipeline\uff0c\u5f02\u6b65\u6301\u4e45\u5316 WAL entry\uff0c\u4e0d\u963b\u585e\u5185\u5b58\u4e2d\u7684\u66f4\u65b0\u3002
\u4e8b\u52a1\u63d0\u4ea4\u7684\u6d41\u7a0b\u662f\uff1a
\u628a\u66f4\u6539\u66f4\u65b0\u5230 memtable \u4e2d\uff0c\u4e8b\u52a1\u8fdb\u5165 commit pipeline \u4e4b\u524d\uff0c\u5148\u5e76\u53d1\u66f4\u65b0 memtable\uff0c\u4e8b\u52a1\u4e4b\u95f4\u4e92\u76f8\u4e0d \u963b\u585e\u3002\u8fd9\u65f6\u8fd9\u4e9b\u66f4\u6539\u7684\u72b6\u6001\u4e3a\u672a\u63d0\u4ea4\uff0c\u5bf9\u4efb\u4f55\u4e8b\u52a1\u4e0d\u53ef\u89c1\uff1b
\u8fdb\u5165 commit pipeline \u68c0\u67e5\u51b2\u7a81\uff1b
\u6301\u4e45\u5316 WAL entry\uff0c\u4ece\u5185\u5b58\u6536\u96c6 WAL entry \u5199\u5230\u540e\u7aef\u3002\u6301\u4e45\u5316 WAL entry \u662f\u5f02\u6b65\u7684\uff0c\u961f\u5217\u91cc\u53ea\u628a WAL entry \u4f20\u7ed9\u540e\u7aef\u5c31\u7acb\u523b\u8fd4\u56de\uff0c\u4e0d\u7528\u7b49\u5f85\u5199\u5165\u6210\u529f\uff0c\u8fd9\u6837\u4e0d\u4f1a\u963b\u585e\u540e\u7eed\u5176\u4ed6\u4e8b\u52a1\u3002\u540e\u7aef\u540c\u65f6\u5904\u7406\u4e00\u6279 entry\uff0c\u901a\u8fc7 Group Commit \u8fdb\u4e00\u6b65\u52a0\u901f\u6301\u4e45\u5316\u3002
\u66f4\u65b0 memtable \u4e2d\u7684\u72b6\u6001\u4f7f\u4e8b\u52a1\u53ef\u89c1\uff0c\u4e8b\u52a1\u6309\u7167\u8fdb\u961f\u5217\u7684\u987a\u5e8f\u4f9d\u6b21\u66f4\u65b0\u72b6\u6001\uff0c\u8fd9\u6837\u4e8b\u52a1\u53ef\u89c1\u7684\u987a\u5e8f\u548c\u961f\u5217\u91cc\u5199 WAL entry \u7684\u987a\u5e8f\u662f\u4e00\u81f4\u7684\u3002
Checkpoint \u5c06\u810f\u6570\u636e\u5199\u5165 Storage\uff0c\u9500\u6bc1\u65e7\u7684 log entry\uff0c\u91ca\u653e\u7a7a\u95f4\u3002MatrixOne \u4e2d\uff0ccheckpoint \u662f\u4e00\u4e2a\u540e\u53f0\u53d1\u8d77\u7684\u4efb\u52a1\uff0c\u5b83\u7684\u6d41\u7a0b\u662f\uff1a
\u9009\u5b9a\u4e00\u4e2a\u5408\u9002\u7684\u65f6\u95f4\u6233\u4f5c\u4e3a checkpoint\uff0c\u7136\u540e\u626b\u63cf\u65f6\u95f4\u6233\u4e4b\u524d\u7684\u4fee\u6539\u3002\u56fe\u4e0a\u7684 t0 \u662f\u4e0a\u4e2a checkpoint\uff0ct1 \u662f\u5f53\u524d\u9009\u5b9a\u7684 checkpoint\u3002[t0,t1] \u4e4b\u95f4\u53d1\u751f\u7684\u66f4\u6539\u9700\u8981\u8f6c\u5b58\u3002
\u8f6c\u5b58 DML \u4fee\u6539\u3002DML \u66f4\u6539\u5b58\u5728 memtable \u4e2d\u7684\u5404\u4e2a block \u4e2d\u3002Logtail Mgr \u662f\u4e00\u4e2a\u5185\u5b58\u6a21\u5757\uff0c\u8bb0\u5f55\u7740\u6bcf\u4e2a\u4e8b\u52a1\u6539\u52a8\u4e86\u54ea\u4e9b block\u3002\u5728 Logtail Mgr \u4e0a\u626b\u63cf [t0,t1] \u4e4b\u95f4\u7684\u4e8b\u52a1\uff0c\u53d1\u8d77\u540e\u53f0\u4e8b\u52a1\u628a\u8fd9\u4e9b block \u8f6c\u5b58\u5230 Storage \u4e0a\uff0c\u5728\u5143\u6570\u636e\u4e2d\u8bb0\u5f55\u5730\u5740\u3002\u8fd9\u6837\uff0c\u6240\u6709 t1 \u524d\u63d0\u4ea4\u7684 DML \u66f4\u6539\u90fd\u80fd\u901a\u8fc7\u5143\u6570\u636e\u4e2d\u7684\u5730\u5740\u67e5\u5230\u3002\u4e3a\u4e86\u53ca\u65f6\u505a checkpoint\uff0c\u4e0d\u8ba9 WAL \u65e0\u9650\u589e\u957f\uff0c\u54ea\u6015\u533a\u95f4\u4e2d block \u53ea\u6539\u52a8\u4e86\u4e00\u884c\uff0c\u4e5f\u9700\u8981\u8f6c\u5b58\u3002
MatrixOne \u7684 WAL \u80fd\u5199\u5728\u5404\u79cd Log Backend \u4e2d\u3002\u6700\u521d\u7684 Log Backend \u57fa\u4e8e\u672c\u5730\u6587\u4ef6\u7cfb\u7edf\u3002\u4e3a\u4e86\u5206\u5e03\u5f0f\u7279\u6027\uff0c\u6211\u4eec\u81ea\u7814\u4e86\u9ad8\u53ef\u9760\u4f4e\u5ef6\u8fdf Log Service \u4f5c\u4e3a\u65b0\u7684 Log Backend\u3002\u6211\u4eec\u4e3a\u9002\u914d\u4e0d\u540c\u7684 log backend\uff0c\u62bd\u8c61\u51fa\u4e00\u4e2a\u865a\u62df\u7684 backend, \u901a\u8fc7\u4e00\u4e9b\u5f88\u8f7b\u91cf\u7684 driver \u5f00\u53d1\uff0c\u5bf9\u63a5\u4e0d\u540c\u7684 backend\u3002
Driver \u9700\u8981\u9002\u914d\u51fa\u8fd9\u4e9b\u63a5\u53e3\uff1a
Append(entry) (Lsn, error)\n
Read(Lsn, maxSize) (entry, Lsn, error)\n
Truncate(lsn Lsn) error\n
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#group-commit","title":"Group Commit","text":"Group Commit \u53ef\u4ee5\u52a0\u901f\u6301\u4e45\u5316 log entry\u3002\u6301\u4e45\u5316 log entry \u6d89\u53ca\u5230 IO\uff0c\u975e\u5e38\u8017\u65f6\uff0c\u7ecf\u5e38\u662f\u63d0\u4ea4\u7684\u74f6\u9888\u3002\u4e3a\u4e86\u964d\u4f4e\u5ef6\u8fdf\uff0c\u6279\u91cf\u5411 Log Backend \u4e2d\u5199\u5165 log entry\u3002\u6bd4\u5982\uff0c\u5728\u6587\u4ef6\u7cfb\u7edf\u4e2d fsync \u8017\u65f6\u5f88\u4e45\u3002\u5982\u679c\u6bcf\u6761 entry \u90fd fsync\uff0c\u4f1a\u8017\u8d39\u5927\u91cf\u65f6\u95f4\u3002\u57fa\u4e8e\u6587\u4ef6\u7cfb\u7edf\u7684 Log Backend \u4e2d\uff0c\u591a\u4e2a entry \u5199\u5b8c\u540e\u7edf\u4e00\u53ea\u505a\u4e00\u6b21 fsync\uff0c\u8fd9\u4e9b entry \u5237\u76d8\u7684\u65f6\u95f4\u6210\u672c\u4e4b\u548c\u8fd1\u4f3c\u4e00\u6761 entry \u5237\u76d8\u7684\u65f6\u95f4\u3002
Log Service \u4e2d\u652f\u6301\u5e76\u53d1\u5199\u5165\uff0c\u5404\u6761 entry \u5237\u76d8\u7684\u65f6\u95f4\u53ef\u4ee5\u91cd\u53e0\uff0c\u8fd9\u4e5f\u80fd\u7f29\u77ed\u5199 entry \u7684\u603b\u65f6\u95f4\uff0c\u63d0\u9ad8\u4e86\u63d0\u4ea4\u7684\u5e76\u53d1\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#log-backend-lsn","title":"\u5904\u7406 Log Backend \u7684\u4e71\u5e8f LSN","text":"\u4e3a\u4e86\u52a0\u901f\uff0c\u5411 Log Backend \u5e76\u53d1\u5199\u5165 entry\uff0c\u5199\u5165\u6210\u529f\u7684\u987a\u5e8f\u548c\u53d1\u51fa\u8bf7\u6c42\u7684\u987a\u5e8f\u4e0d\u4e00\u81f4\uff0c\u5bfc\u81f4 Log Backend \u4e2d\u4ea7\u751f\u7684 LSN \u548c\u4e0a\u5c42\u4f20\u7ed9 Driver \u7684\u903b\u8f91 LSN \u4e0d\u4e00\u81f4\u3002Truncate \u548c\u91cd\u542f\u7684\u65f6\u5019\u8981\u5904\u7406\u8fd9\u4e9b\u4e71\u5e8f LSN\u3002\u4e3a\u4e86\u4fdd\u8bc1 Log Backend \u4e2d\u7684 LSN \u57fa\u672c\u6709\u5e8f\uff0c\u4e71\u5e8f\u7684\u8de8\u5ea6\u4e0d\u8981\u592a\u5927\uff0c\u7ef4\u6301\u4e86\u4e00\u4e2a\u903b\u8f91 LSN \u7684\u7a97\u53e3\uff0c\u5982\u679c\u6709\u5f88\u65e9\u7684 log entry \u6b63\u5728\u5199\u5165\u8fd8\u672a\u6210\u529f\uff0c\u4f1a\u505c\u6b62\u5411 Log Backend \u5199\u5165\u65b0\u7684 entry\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7a97\u53e3\u7684\u957f\u5ea6\u662f 7\uff0c\u56fe\u4e2d\u7684 LSN \u4e3a 13 \u7684 entry \u8fd8\u672a\u8fd4\u56de\uff0c\u5c31\u4f1a\u963b\u585e\u4f4f LSN \u5927\u4e8e\u7b49\u4e8e 20 \u7684 entry\u3002
Log Backend \u4e2d\u901a\u8fc7 truncate \u64cd\u4f5c\u9500\u6bc1\u65e5\u5fd7\uff0c\u9500\u6bc1\u6307\u5b9a LSN \u4e4b\u524d\u7684\u6240\u6709 entry\u3002\u8fd9\u4e2a LSN \u4e4b\u524d\u7684 entry \u6240\u5bf9\u5e94\u7684\u903b\u8f91 LSN \u90fd\u8981\u5c0f\u4e8e\u903b\u8f91 truncate \u70b9\u3002\u6bd4\u5982\u56fe\u4e2d\u903b\u8f91 truncate \u5230 7\uff0c\u8fd9\u6761 entry \u5bf9\u5e94 Log Backend \u4e2d\u7684 11\uff0c\u4f46\u662f Log Backend \u4e2d 5\uff0c6\uff0c7\uff0c10 \u5bf9\u5e94\u7684\u903b\u8f91 LSN \u90fd\u5927\u4e8e 7\uff0c\u4e0d\u80fd\u88ab truncate\u3002Log Backend \u53ea\u80fd truncate 4\u3002
\u91cd\u542f\u65f6\uff0c\u4f1a\u8df3\u8fc7\u5f00\u59cb\u548c\u672b\u5c3e\u90a3\u4e9b\u4e0d\u8fde\u7eed\u7684 entry\u3002\u6bd4\u5982\u56fe\u4e0a\u7684 Log Backend \u5199\u5230 14 \u65f6\uff0c\u6574\u4e2a\u673a\u5668\u65ad\u7535\u4e86\uff0c\u91cd\u542f\u65f6\u4f1a\u6839\u636e\u4e0a\u6b21\u7684 truncate \u4fe1\u606f\u8fc7\u6ee4\u6389\u5f00\u5934 8\uff0c9\uff0c11\u3002\u7b49\u8bfb\u5b8c\u6240\u6709\u7684 entry \u53d1\u73b0 6\uff0c14 \u7684\u903b\u8f91 LSN \u548c\u5176\u4ed6\u7684 entry \u4e0d\u8fde\u7eed\uff0c\u5c31\u4e22\u5f03\u672b\u5c3e\u7684 6 \u548c 14\u3002
"},{"location":"MatrixOne/Overview/architecture/architecture-wal/#matrixone-wal","title":"MatrixOne \u4e2d WAL \u7684\u5177\u4f53\u683c\u5f0f","text":"\u6bcf\u4e2a\u5199\u4e8b\u52a1\u5bf9\u5e94\u4e00\u6761 log entry\uff0c\u7531 LSN\uff0cTransaction Context \u548c\u591a\u4e2a Command \u7ec4\u6210\u3002
+---------------------------------------------------------+\n| Transaction Entry |\n+-----+---------------------+-----------+-----------+- -+\n| LSN | Transaction Context | Command-1 | Command-2 | ... |\n+-----+---------------------+-----------+-----------+- -+\n
LSN\uff1a\u6bcf\u6761 log entry \u5bf9\u5e94\u4e00\u4e2a LSN\u3002LSN \u8fde\u7eed\u9012\u589e\uff0c\u5728\u505a checkpoint \u65f6\u7528\u6765\u5220\u9664 entry\u3002
Transaction Context\uff1a\u8bb0\u5f55\u4e8b\u52a1\u4fe1\u606f
+---------------------------+\n| Transaction Context |\n+---------+----------+------+\n| StartTS | CommitTS | Memo |\n+---------+----------+------+\n
Transaction Commands\uff1a\u4e8b\u52a1\u4e2d\u6bcf\u79cd\u5199\u64cd\u4f5c\u5bf9\u5e94\u4e00\u4e2a\u6216\u591a\u4e2a command\u3002log entry \u4f1a\u8bb0\u5f55\u4e8b\u52a1\u4e2d\u6240\u6709\u7684 command\u3002
Operator Command DDL Update Catalog Insert Update Catalog Append Delete Delete Compact&Merge Update CatalogOperators\uff1aMatrixOne \u4e2d DN \u8d1f\u8d23\u63d0\u4ea4\u4e8b\u52a1\uff0c\u5411 Log Backend \u4e2d\u5199 log entry\uff0c\u505a checkpoint\u3002DN \u652f\u6301\u5efa\u5e93\uff0c\u5220\u5e93\uff0c\u5efa\u8868\uff0c\u5220\u8868\uff0c\u66f4\u65b0\u8868\u7ed3\u6784\uff0c\u63d2\u5165\uff0c\u5220\u9664\uff0c\u540c\u65f6\u540e\u53f0\u4f1a\u81ea\u52a8\u89e6\u53d1\u6392\u5e8f\u3002\u66f4\u65b0\u64cd\u4f5c\u88ab\u62c6\u5206\u6210\u63d2\u5165\u548c\u5220\u9664\u3002
DDL DDL \u5305\u62ec\u5efa\u5e93\uff0c\u5220\u5e93\uff0c\u5efa\u8868\uff0c\u5220\u8868\uff0c\u66f4\u65b0\u8868\u7ed3\u6784\u3002DN \u5728 Catalog \u91cc\u8bb0\u5f55\u4e86\u8868\u548c\u5e93\u7684\u4fe1\u606f\u3002\u5185\u5b58\u91cc\u7684 Catalog \u662f\u4e00\u68f5\u6811\uff0c\u6bcf\u4e2a\u7ed3\u70b9\u662f\u4e00\u6761 catalog entry\u3002catalog entry \u6709 4 \u7c7b\uff0cdatabase\uff0ctable\uff0csegment \u548c block\uff0c\u5176\u4e2d segment \u548c block \u662f\u5143\u6570\u636e\uff0c\u5728\u63d2\u5165\u6570\u636e\u548c\u540e\u53f0\u6392\u5e8f\u7684\u65f6\u5019\u4f1a\u53d8\u66f4\u3002\u6bcf\u6761 database entry \u5bf9\u5e94\u4e00\u4e2a\u5e93\uff0c\u6bcf\u6761 table entry \u5bf9\u5e94\u4e00\u5f20\u8868\u3002\u6bcf\u4e2a DDL \u64cd\u4f5c\u5bf9\u5e94\u4e00\u6761 database/table entry\uff0c\u5728 entry \u91cc\u8bb0\u5f55\u6210 Update Catalog Command\u3002
Insert \u65b0\u63d2\u5165\u7684\u6570\u636e\u8bb0\u5f55\u5728 Append Command \u4e2d\u3002DN \u4e2d\u7684\u6570\u636e\u8bb0\u5f55\u5728 block \u4e2d\uff0c\u591a\u4e2a block \u7ec4\u6210\u4e00\u4e2a segment\u3002\u5982\u679c DN \u4e2d\u6ca1\u6709\u8db3\u591f\u7684 block \u6216 segment \u8bb0\u5f55\u65b0\u63d2\u5165\u7684\u6570\u636e\uff0c\u5c31\u4f1a\u65b0\u5efa\u4e00\u4e2a\u3002\u8fd9\u4e9b\u53d8\u5316\u8bb0\u5f55\u5728 Update Catalog Command \u4e2d\u3002\u5927\u4e8b\u52a1\u4e2d\uff0c\u7531 CN \u76f4\u63a5\u628a\u6570\u636e\u5199\u5165 S3\uff0cDN \u53ea\u63d0\u4ea4\u5143\u6570\u636e\u3002\u8fd9\u6837\uff0cAppend Command \u4e2d\u7684\u6570\u636e\u4e0d\u4f1a\u5f88\u5927\u3002
Delete DN \u8bb0\u5f55 Delete \u53d1\u751f\u7684\u884c\u53f7\u3002\u8bfb\u53d6\u65f6\uff0c\u5148\u8bfb\u6240\u6709\u63d2\u5165\u8fc7\u7684\u6570\u636e\uff0c\u7136\u540e\u518d\u51cf\u53bb\u8fd9\u4e9b\u884c\u3002\u4e8b\u52a1\u4e2d\uff0c\u540c\u4e00\u4e2a block \u4e0a\u6240\u6709\u7684\u5220\u9664\u5408\u5e76\u8d77\u6765\uff0c\u5bf9\u5e94\u4e00\u4e2a Delete Command\u3002
Compact & Merge DN \u540e\u53f0\u53d1\u8d77\u4e8b\u52a1\uff0c\u628a\u5185\u5b58\u91cc\u7684\u6570\u636e\u8f6c\u5b58\u5230 s3 \u4e0a\u3002\u628a S3 \u4e0a\u7684\u6570\u636e\u6309\u4e3b\u952e\u6392\u5e8f\uff0c\u65b9\u4fbf\u8bfb\u7684\u65f6\u5019\u8fc7\u6ee4\u3002compact \u53d1\u751f\u5728\u4e00\u4e2a block \u4e0a\uff0ccompact \u4e4b\u540e block \u5185\u7684\u6570\u636e\u662f\u6709\u5e8f\u7684\u3002merge \u53d1\u751f\u5728 segment \u91cc\uff0c\u4f1a\u6d89\u53ca\u591a\u4e2a block\uff0cmerge \u4e4b\u540e\u6574\u4e2a segment \u5185\u6709\u5e8f\u3002compact/merge \u524d\u540e\u7684\u6570\u636e\u4e0d\u53d8\uff0c\u53ea\u6539\u53d8\u5143\u6570\u636e\uff0c\u5220\u9664\u65e7\u7684 block/segment\uff0c\u521b\u5efa\u65b0\u7684 block/segment\u3002\u6bcf\u6b21\u5220\u9664/\u521b\u5efa\u5bf9\u5e94\u4e00\u6761 Update Catalog Command\u3002
Commands
Catalog \u4ece\u4e0a\u5230\u4e0b\u6bcf\u5c42\u5206\u522b\u662f database\uff0ctable\uff0csegment \u548c block\u3002\u4e00\u6761 Updata Catalog Command \u5bf9\u5e94\u4e00\u6761 Catalog Entry\u3002\u6bcf\u6b21 ddl \u6216\u8005\u8ddf\u65b0\u5143\u6570\u636e\u5bf9\u5e94\u4e00\u6761 Update Catalog Command\u3002Update Catalog Command \u5305\u542b Dest \u548c EntryNode\u3002
+-------------------+\n| Update Catalog |\n+-------+-----------+\n| Dest | EntryNode |\n+-------+-----------+\n
Dest \u662f\u8fd9\u6761 Command \u4f5c\u7528\u7684\u4f4d\u7f6e\uff0c\u8bb0\u5f55\u4e86\u5bf9\u5e94\u7ed3\u70b9\u548c\u4ed6\u7684\u7956\u5148\u7ed3\u70b9\u7684 id\u3002\u91cd\u542f\u7684\u65f6\u5019\u4f1a\u901a\u8fc7 Dest\uff0c\u5728 Catalog \u4e0a\u5b9a\u4f4d\u5230\u64cd\u4f5c\u7684\u4f4d\u7f6e\u3002
Type Dest Update Database database id Update Table database id,table id Update Segment database id,table id,segment id Update Block atabase id,table id,segment id,block idEntryNode \u8bb0\u5f55\u4e86 entry \u7684\u521b\u5efa\u65f6\u95f4\u548c\u5220\u9664\u65f6\u95f4\u3002\u5982\u679c entry \u6ca1\u88ab\u5220\u9664\uff0c\u5220\u9664\u65f6\u95f4\u4e3a 0\u3002\u5982\u679c\u5f53\u524d\u4e8b\u52a1\u6b63\u5728\u521b\u5efa\u6216\u8005\u5220\u9664\uff0c\u5bf9\u5e94\u7684\u65f6\u95f4\u4e3a UncommitTS\u3002
+-------------------+\n| Entry Node |\n+---------+---------+\n| Create@ | Delete@ |\n+---------+---------+\n
\u5bf9\u4e8e segment \u548c block\uff0cEntry Node \u8fd8\u8bb0\u5f55\u4e86 metaLoc\uff0cdeltaLoc\uff0c\u5206\u522b\u662f\u6570\u636e\u548c\u5220\u9664\u8bb0\u5f55\u5728 S3 \u4e0a\u7684\u5730\u5740\u3002
+----------------------------------------+\n | Entry Node |\n +---------+---------+---------+----------+\n | Create@ | Delete@ | metaLoc | deltaLoc |\n +---------+---------+---------+----------+\n
\u5bf9\u4e8e table\uff0cEntry Node \u8fd8\u8bb0\u5f55\u4e86\u8868\u7ed3\u6784 schema\u3002
+----------------------------+\n | Entry Node |\n +---------+---------+--------+\n | Create@ | Delete@ | schema |\n +---------+---------+--------+\n
\u00a0\u00a0\u00a02. \u00a0Append Append Command \u4e2d\u8bb0\u5f55\u4e86\u63d2\u5165\u7684\u6570\u636e\u548c\u548c\u8fd9\u4e9b\u6570\u636e\u7684\u4f4d\u7f6e\u3002
+-------------------------------------------+\n| Append Command |\n+--------------+--------------+- -+-------+\n| AppendInfo-1 | AppendInfo-2 | ... | Batch |\n+--------------+--------------+- -+-------+\n
Batch \u662f\u63d2\u5165\u7684\u6570\u636e\u3002
AppendInfo \u4e00\u4e2a Append Data Command \u4e2d\u7684\u6570\u636e\u53ef\u80fd\u8de8\u591a\u4e2a block\u3002\u6bcf\u4e2a block \u5bf9\u5e94\u4e00\u4e2a Append Info\uff0c\u8bb0\u5f55\u4e86\u6570\u636e\u5728 Command \u7684 Batch \u4e2d\u7684\u4f4d\u7f6e pointer to data\uff0c\u8fd8\u6709\u6570\u636e\u5728 block \u4e2d\u7684\u4f4d\u7f6e destination\u3002
+------------------------------------------------------------------------------+\n| AppendInfo |\n+-----------------+------------------------------------------------------------+\n| pointer to data | destination |\n+--------+--------+-------+----------+------------+----------+--------+--------+\n| offset | length | db id | table id | segment id | block id | offset | length |\n+--------+--------+-------+----------+------------+----------+--------+--------+\n
\u00a0\u00a0\u00a03. \u00a0Delete Command \u6bcf\u4e2a Delete Command \u53ea\u5305\u542b\u4e00\u4e2a block \u4e2d\u7684\u5220\u9664\u3002
+---------------------------+\n| Delete Command |\n+-------------+-------------+\n| Destination | Delete Mask |\n+-------------+-------------+\n
MatrixOne \u662f\u4e00\u6b3e\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\u3002
\u8d85\u878d\u5408\u662f\u6307\u652f\u6491\u591a\u79cd\u8d1f\u8f7d\u7684\u80fd\u529b\u878d\u5408\uff0cMatrixOne \u652f\u6301\u5728\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u4e2d\u652f\u6491\u4e8b\u52a1\u6027\uff08OLTP\uff09\u3001\u5206\u6790\u6027\uff08OLAP\uff09\u548c\u6d41\u5f0f\u5de5\u4f5c\uff08Sreaming\uff09\u8d1f\u8f7d\uff0c\u8fd9\u79cd\u591a\u5de5\u4f5c\u8d1f\u8f7d\u8d1f\u8f7d\u7684\u80fd\u529b\u878d\u5408\uff0c\u6211\u4eec\u79f0\u4e4b\u4e3a HSTAP (Hybrid Streaming & Transaction/Analytical Processing). HSTAP \u6570\u636e\u5e93\u5bf9 HTAP \u6570\u636e\u5e93\u8fdb\u884c\u4e86\u91cd\u65b0\u5b9a\u4e49\uff0cHSTAP \u65e8\u5728\u6ee1\u8db3\u5355\u4e00\u6570\u636e\u5e93\u5185\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u548c\u5206\u6790\u5904\u7406\uff08AP\uff09\u7684\u6240\u6709\u9700\u6c42\u3002\u4e0e\u4f20\u7edf\u7684 HTAP \u76f8\u6bd4\uff0cHSTAP \u5f3a\u8c03\u5176\u5185\u7f6e\u7684\u7528\u4e8e\u8fde\u63a5 TP \u548c AP \u8868\u6570\u636e\u6d41\u5904\u7406\u80fd\u529b\uff0c\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u6570\u636e\u5e93\u53ef\u4ee5\u50cf\u5927\u6570\u636e\u5e73\u53f0\u4e00\u6837\u7075\u6d3b\u7684\u4f7f\u7528\u4f53\u9a8c\u3002\u4e5f\u6070\u6070\u5f97\u76ca\u4e8e\u5927\u6570\u636e\u7684\u7e41\u8363\uff0c\u5f88\u591a\u7528\u6237\u5df2\u7ecf\u719f\u6089\u4e86\u8fd9\u79cd\u4f53\u9a8c\u3002\u7528\u6237\u4f7f\u7528 MatrixOne \u53ea\u9700\u8981\u5c11\u91cf\u7684\u96c6\u6210\u5de5\u4f5c\uff0c\u5373\u53ef\u4ee5\u83b7\u5f97\u8986\u76d6\u6574\u4e2a TP \u548c AP \u573a\u666f\u7684\u4e00\u7ad9\u5f0f\u4f53\u9a8c\uff0c\u540c\u65f6\u53ef\u4ee5\u6446\u8131\u4f20\u7edf\u5927\u6570\u636e\u5e73\u53f0\u7684\u81c3\u80bf\u67b6\u6784\u53ca\u5404\u79cd\u9650\u5236\u3002
\u5f02\u6784\u4e91\u539f\u751f\u662f\u6307\u9762\u5411\u4e91\u539f\u751f\u57fa\u7840\u8bbe\u65bd\uff08K8s \u53ca\u5bf9\u8c61\u5b58\u50a8\uff09\uff0cMatrixOne \u5b8c\u5168\u91cd\u65b0\u8bbe\u8ba1\u4e86\u4e00\u5957\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u5f15\u64ce\uff0c\u53ef\u4ee5\u6ee1\u8db3\u516c\u6709\u4e91\uff0c\u79c1\u6709\u4e91\uff0c\u8fb9\u7f18\u4e91\u7b49\u591a\u79cd\u5355\u4e00\u4e91\u73af\u5883\u53ca\u591a\u79cd\u8de8\u4e91\u73af\u5883\u7684\u90e8\u7f72\u6a21\u5f0f\uff0c\u540c\u65f6\u6700\u5927\u7a0b\u5ea6\u7684\u5229\u7528\u4e91\u539f\u751f\u73af\u5883\u7684\u7279\u70b9\uff0c\u5b9e\u73b0\u5b58\u7b97\u5206\u79bb\u53ca\u7ebf\u6027\u6269\u5c55\u3002\u5728\u4ee5 K8s \u4e3b\u5bfc\u7684\u4e91\u539f\u751f\u73af\u5883\u4e2d\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u4e00\u76f4\u4ee5\u6765\u4f5c\u4e3a\u6709\u72b6\u6001\u7cfb\u7edf\u90fd\u672a\u88ab\u5f88\u597d\u7684\u7edf\u4e00\u7eb3\u7ba1\u8d77\u6765\uff0c\u800c\u662f\u4ecd\u7136\u57fa\u4e8e\u7269\u7406\u673a\u6216\u8005\u865a\u62df\u673a\u7684\u5f62\u5f0f\u72ec\u7acb\u90e8\u7f72\u53ca\u8fd0\u7ef4\uff0c\u6839\u672c\u539f\u56e0\u662f\u56e0\u4e3a\u4f20\u7edf\u7684\u5355\u673a/\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u672a\u6839\u636e\u4e91\u539f\u751f\u73af\u5883\u8fdb\u884c\u6539\u9020\u3002\u800c MatrixOne \u5219\u662f\u4ece 0 \u5f00\u59cb\uff0c\u5b58\u50a8\u4e0e\u8ba1\u7b97\u5f15\u64ce\u5747\u5b8c\u5168\u81ea\u7814\uff0c\u9762\u5411\u4e91\u539f\u751f\u73af\u5883\u8bbe\u8ba1\uff0c\u53ef\u4ee5\u6700\u5927\u7a0b\u5ea6\u7684\u5229\u7528\u5bb9\u5668\u5316\u7684\u8f6f\u4ef6\u5b9a\u4e49\u8d44\u6e90\u4ee5\u53ca\u7075\u6d3b\u8c03\u914d\u7684\u7279\u70b9\uff0c\u5b9e\u73b0\u4e0e\u5e94\u7528\u5c42\u7edf\u4e00\u5230\u540c\u4e00\u5957\u4e91\u539f\u751f\u73af\u5883\u4e2d\u3002\u540c\u65f6\u7531\u4e8e K8s \u672c\u8eab\u7684\u8de8\u4e91\u80fd\u529b\uff0cMatrixOne \u53ef\u4ee5\u65e0\u7f1d\u517c\u5bb9\u5404\u79cd\u5f02\u6784\u7684\u4e91\u53ca IaaS \u73af\u5883\uff0c\u5e76\u4e14\u7075\u6d3b\u5b9e\u73b0\u8de8\u591a\u4e91\u548c\u591a\u7aef\u7684\u90e8\u7f72\u3002
"},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#matrixone_2","title":"MatrixOne \u67b6\u6784\u5c42\u7ea7","text":"\u5982\u4e0b\u56fe\u6240\u793a\uff0cMatrixOne \u6574\u4f53\u662f\u57fa\u4e8e Kubernetes \u800c\u6784\u5efa\uff0c\u5168\u90e8\u662f\u4ee5\u5bb9\u5668\u5316\u7684\u5f62\u5f0f\u6784\u5efa\u53ca\u7ba1\u7406\u3002MatrixOne \u6574\u4f53\u5206\u6210\u4e09\u5c42\u67b6\u6784\uff0c\u5206\u522b\u662f\u8ba1\u7b97\u5c42\uff0c\u4e8b\u52a1\u5c42\uff0c\u5b58\u50a8\u5c42\u3002MatrixOne \u7684\u5b58\u50a8\uff0c\u8ba1\u7b97\u548c\u4e8b\u52a1\u4e09\u5c42\u662f\u5b8c\u5168\u5206\u79bb\u89e3\u8026\u7684\uff0c\u6bcf\u5c42\u90fd\u6709\u81ea\u5df1\u7684\u5bf9\u8c61\u5355\u5143\u548c\u5206\u5de5\uff0c\u4e0d\u540c\u5c42\u7684\u8282\u70b9\u548c\u8d44\u6e90\u5b8c\u5168\u89e3\u8026\uff0c\u72ec\u7acb\u81ea\u7531\u4f38\u7f29\u3002
\u5b58\u50a8\u5c42\uff1aMatrixOne \u9762\u5411\u4e91\u539f\u751f\u73af\u5883\u8bbe\u8ba1\uff0c\u5728\u4e91\u73af\u5883\u4e2d\u5bf9\u8c61\u5b58\u50a8\u5df2\u7ecf\u6210\u4e3a\u4e8b\u5b9e\u4e0a\u7684\u5b58\u50a8\u6807\u51c6\uff0c\u53ef\u9760\u6027\u9ad8\uff0c\u4ef7\u683c\u4f4e\u5ec9\uff0c\u5e76\u4e14\u81ea\u5e26\u8fd1\u4e4e\u65e0\u9650\u6269\u5c55\u80fd\u529b\u3002\u56e0\u6b64 MatrixOne \u9009\u7528\u517c\u5bb9 S3 \u534f\u8bae\u7684\u5bf9\u8c61\u5b58\u50a8\u4f5c\u4e3a\u4e3b\u5b58\u50a8\uff0c\u6240\u6709\u7684\u6570\u636e\u6700\u7ec8\u90fd\u4f1a\u6301\u4e45\u5316\u5230\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002\u76ee\u524d\u4e3b\u6d41\u7684\u516c\u6709\u4e91\u53ca\u79c1\u6709\u5316\u5382\u5546\u5747\u63d0\u4f9b\u4e86\u517c\u5bb9 S3 \u534f\u8bae\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff0cMatrixOne \u5747\u53ef\u4ee5\u65e0\u7f1d\u517c\u5bb9\u3002\u9488\u5bf9\u4e0d\u5e26\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684\u7269\u7406\u673a/\u865a\u62df\u673a\u73af\u5883\uff0c\u53ef\u4ee5\u901a\u8fc7\u90e8\u7f72\u5f00\u6e90 Minio \u7684\u5f62\u5f0f\u81ea\u884c\u642d\u5efa\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
\u8ba1\u7b97\u5c42\uff1a\u4ee5\u8ba1\u7b97\u8282\u70b9 Compute Node (\u7b80\u79f0 CN) \u4e3a\u5355\u4f4d\uff0c\u5728 K8s \u91cc\uff0c\u6bcf\u4e2a CN \u90fd\u662f\u4e00\u4e2a\u65e0\u72b6\u6001\u7684\u5bb9\u5668 Pod\uff0c\u53ef\u4ee5\u901a\u8fc7\u8f6f\u4ef6\u5b9a\u4e49\u7684\u65b9\u5f0f\u81ea\u7531\u6307\u5b9a\u8d44\u6e90\u5927\u5c0f\u53ca\u4e2a\u6570\uff0c\u7531 K8s \u8d1f\u8d23\u8d44\u6e90\u4f9b\u7ed9\u3002\u4e3a\u4e86\u52a0\u5feb\u67e5\u8be2\u6027\u80fd\uff0c\u6bcf\u4e2a CN \u8282\u70b9\u4e2d\u4f1a\u6709\u5185\u5b58\u53ca\u672c\u5730\u78c1\u76d8\u7684\u4e24\u7ea7\u7f13\u5b58\uff0c\u65b0\u67e5\u8be2\u8fc7\u7684\u6570\u636e\u4f1a\u7f13\u5b58\u5230 CN \u8282\u70b9\u4e2d\uff0c\u7f6e\u6362\u7b56\u7565\u4e3a LRU\u3002\u7531\u4e8e CN \u8282\u70b9\u5b8c\u5168\u65e0\u72b6\u6001\uff0c\u56e0\u6b64\u53ef\u4ee5\u4efb\u610f\u91cd\u542f\uff0c\u4efb\u610f\u7eb5\u5411\u548c\u6a2a\u5411\u6269\u5c55\uff0c\u4e14\u4f5c\u4e3a\u5bb9\u5668 Pod\uff0cCN \u8282\u70b9\u53ef\u4ee5\u505a\u5230\u79d2\u7ea7\u7684\u5feb\u901f\u6269\u7f29\u5bb9\uff0c\u540c\u65f6\u5728\u53d1\u751f\u4e86\u6545\u969c\u7684\u65f6\u5019\u8fc5\u901f\u91cd\u542f\u6216\u8005\u5207\u6362\u5176\u4ed6 CN\u3002
\u4e8b\u52a1\u5c42\uff1aMatrixOne \u6574\u4f53\u662f\u642d\u5efa\u5728\u5bb9\u5668\u670d\u52a1\u53ca\u5bf9\u8c61\u5b58\u50a8\u4e0a\u7684\u67b6\u6784\uff0c\u8fd9\u4e2a\u67b6\u6784\u5bf9\u4e8e\u63d0\u4f9b OLAP \u670d\u52a1\u662f\u975e\u5e38\u5408\u9002\u7684\uff0cOLAP \u5bf9\u6570\u636e IO \u7684\u5e76\u53d1\u8981\u6c42\u8f83\u4f4e\uff0c\u4e14\u6570\u636e\u5757\u8f83\u5927\u3002\u4f46\u662f\u5982\u679c\u9700\u8981\u63d0\u4f9b\u9ad8\u5e76\u53d1\u5199\u5165\u7684 TP \u80fd\u529b\uff0c\u5b8c\u5168\u57fa\u4e8e\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u65e0\u6cd5\u6ee1\u8db3\u8981\u6c42\u3002\u7531\u4e8e S3 \u534f\u8bae\u7684\u5bf9\u8c61\u5b58\u50a8\u53ea\u80fd\u652f\u6301\u6570\u767e\u7ea7\u522b\u7684 IO \u5e76\u53d1\uff0c\u4e14\u5bf9\u4e8e\u5c0f\u6587\u4ef6\u7684\u8bfb\u5199\u4e0d\u53cb\u597d\u3002\u56e0\u6b64\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cMatrixOne \u4e13\u95e8\u8bbe\u8ba1\u4e86\u4e00\u5c42\u4e8b\u52a1\u5c42\u3002\u4e8b\u52a1\u5c42\u5305\u542b\u4e24\u4e2a\u7ec4\u4ef6\uff0c\u4e8b\u52a1\u8282\u70b9 Transaction Node\uff08\u7b80\u79f0 TN\uff09\u548c\u65e5\u5fd7\u670d\u52a1 Log Service\uff08\u7b80\u79f0 LS\uff09\u3002TN \u548c LS \u4e3b\u8981\u670d\u52a1\u4e8e\u6570\u636e\u5199\u5165\u76f8\u5173\u6d41\u7a0b\u3002
\u5728 MatrixOne \u4e2d\uff0c\u4e3a\u5b9e\u73b0\u5206\u5e03\u5f0f\u4e0e\u591a\u5f15\u64ce\u7684\u878d\u5408\uff0c\u6784\u5efa\u4e86\u591a\u79cd\u4e0d\u540c\u7684\u7cfb\u7edf\u7ec4\u4ef6\u7528\u4e8e\u5b8c\u6210\u67b6\u6784\u76f8\u5173\u7684\u5c42\u7ea7\u7684\u529f\u80fd\uff1a
"},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#file-service","title":"File Service","text":"File Service \u662f MatrixOne \u8d1f\u8d23\u6240\u6709\u5b58\u50a8\u4ecb\u8d28\u8bfb\u5199\u7684\u7ec4\u4ef6\u3002\u5b58\u50a8\u4ecb\u8d28\u5305\u62ec\u5185\u5b58\u3001\u78c1\u76d8\u3001\u5bf9\u8c61\u5b58\u50a8\u7b49\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Log Service \u662f MatrixOne \u4e2d\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u4e8b\u52a1\u65e5\u5fd7\u7684\u7ec4\u4ef6\uff0c\u5b83\u5177\u6709\u5982\u4e0b\u529f\u80fd\u7279\u6027\uff1a
Transaction Node\uff08TN\uff09\uff0c\u662f\u7528\u6765\u8fd0\u884c MatrixOne \u7684\u5206\u5e03\u5f0f\u5b58\u50a8\u5f15\u64ce TAE \u7684\u8f7d\u4f53\uff0c\u5b83\u63d0\u4f9b\u4e86\u5982\u4e0b\u7279\u6027\uff1a
Computing Node\uff08CN\uff09\uff0c\u662f Matrixone \u63a5\u6536\u7528\u6237\u8bf7\u6c42\u5e76\u5904\u7406 SQL \u7684\u7ec4\u4ef6\uff0c\u5177\u4f53\u5305\u62ec\u4ee5\u4e0b\u6a21\u5757\uff1a
Stream Engine \u662f MatrixOne \u5185\u7f6e\u7684\u5168\u65b0\u7ec4\u4ef6\uff0c\u65e8\u5728\u652f\u6301\u5b9e\u65f6\u6570\u636e\u67e5\u8be2\u3001\u5904\u7406\u4ee5\u53ca\u589e\u5f3a\u6570\u636e\u5b58\u50a8\uff0c\u7279\u522b\u9488\u5bf9\u4f20\u5165\u7684\u6570\u636e\u6d41\uff08\u6570\u636e\u70b9\u5e8f\u5217\uff09\u3002\u501f\u52a9 Stream Engine\uff0c\u60a8\u80fd\u591f\u4f7f\u7528 SQL \u5b9a\u4e49\u5e76\u6784\u5efa\u6d41\u5904\u7406\u7ba1\u9053\uff0c\u5c06\u5176\u4f5c\u4e3a\u5b9e\u65f6\u6570\u636e\u540e\u7aef\u63d0\u4f9b\u670d\u52a1\uff1b\u540c\u65f6\uff0c\u60a8\u4e5f\u80fd\u591f\u8fd0\u7528 SQL \u67e5\u8be2\u6d41\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4e0e\u975e\u6d41\u5f0f\u6570\u636e\u96c6\u8fdb\u884c\u8054\u63a5\uff0c\u4ece\u800c\u66f4\u8fdb\u4e00\u6b65\u5730\u7b80\u5316\u6574\u4e2a\u6570\u636e\u5806\u6808\u7684\u5904\u7406\u6d41\u7a0b\u3002
"},{"location":"MatrixOne/Overview/architecture/matrixone-architecture-design/#proxy","title":"Proxy","text":"Proxy \u7ec4\u4ef6\u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u4e0e SQL \u8def\u7531\u3002\u5b83\u5177\u6709\u4ee5\u4e0b\u529f\u80fd\uff1a
\u672c\u8282\u4ecb\u7ecd\u4e86 MatrixOne \u7684\u6574\u4f53\u67b6\u6784\u6982\u89c8\u3002\u5176\u4ed6\u4fe1\u606f\u53ef\u53c2\u89c1\uff1a
\u5b89\u88c5\u5355\u673a\u7248 MatrixOne
\u6700\u65b0\u53d1\u5e03\u4fe1\u606f
MatrixOne \u5185\u7f6e\u6d41\u5f15\u64ce\uff0c\u7528\u4e8e\u5b9e\u65f6\u67e5\u8be2\u3001\u5904\u7406\u548c/\u6216\u4e30\u5bcc\u4f20\u5165\u7684\u4e00\u7cfb\u5217\u6570\u636e\u70b9\uff08\u5373\u6570\u636e\u6d41\uff09\u7684\u6570\u636e\u5b58\u50a8\u3002\u5f00\u53d1\u4eba\u5458\u73b0\u5728\u53ef\u4ee5\u4f7f\u7528 SQL \u6765\u5b9a\u4e49\u548c\u521b\u5efa\u6d41\u5904\u7406\u7ba1\u9053\uff0c\u5e76\u4f5c\u4e3a\u5b9e\u65f6\u6570\u636e\u540e\u7aef\u63d0\u4f9b\u670d\u52a1\uff1b\u5f00\u53d1\u4eba\u5458\u8fd8\u53ef\u4ee5\u4f7f\u7528 SQL \u67e5\u8be2\u6d41\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u4e0e\u975e\u6d41\u5f0f\u6570\u636e\u96c6\u8fde\u63a5\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u7b80\u5316\u6570\u636e\u5806\u6808\u3002
"},{"location":"MatrixOne/Overview/architecture/streaming/#_2","title":"\u6280\u672f\u67b6\u6784","text":"MatrixOne \u6d41\u5f15\u64ce\u6280\u672f\u67b6\u6784\u5982\u4e0b\u6240\u793a\uff1a
MatrixOne \u5df2\u6210\u529f\u5f00\u53d1\u51fa\u4e00\u5957\u9ad8\u6548\u7684\u6d41\u5f0f\u8868\u521b\u5efa\u673a\u5236\uff0c\u76ee\u524d\u7279\u522b\u9488\u5bf9 Kafka \u8fdb\u884c\u4e86\u6df1\u5ea6\u6574\u5408\u3002\u6b64\u4e3e\u65e8\u5728\u4f18\u5316\u5927\u89c4\u6a21\u65f6\u5e8f\u6570\u636e\u573a\u666f\u4e0b\u7684\u6d41\u5f0f\u6570\u636e\u5904\u7406\u80fd\u529b\u3002
\u4ece\u6280\u672f\u7ec6\u8282\u6765\u770b\uff0cMatrixOne \u901a\u8fc7 Source \u529f\u80fd\u5b9e\u73b0\u4e0e\u5916\u90e8\u6d41\u5f0f\u6570\u636e\u6e90\u7684\u9ad8\u6548\u8fde\u63a5\u4e0e\u96c6\u6210\u3002\u901a\u8fc7\u52a8\u6001\u8868\u4e0e Source \u7684\u94fe\u63a5\uff0cMatrixOne \u4e0d\u4ec5\u80fd\u591f\u5b9e\u73b0\u6570\u636e\u7684\u6301\u4e45\u5316\u5b58\u50a8\uff0c\u8fd8\u80fd\u5bf9\u6d41\u5165\u6570\u636e\u6267\u884c\u590d\u6742\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u5347\u6570\u636e\u5904\u7406\u7684\u7075\u6d3b\u6027\u548c\u6548\u7387\u3002
"},{"location":"MatrixOne/Overview/architecture/streaming/#source","title":"Source","text":"\u5728 MatrixOne \u7684\u67b6\u6784\u4e2d\uff0cSource \u626e\u6f14\u7740\u5173\u952e\u89d2\u8272\uff0c\u5b83\u662f\u5916\u90e8\u6570\u636e\u6d41\u4e0e MatrixOne \u6570\u636e\u5e93\u8868\u4e4b\u95f4\u7684\u6865\u6881\u3002\u901a\u8fc7\u5b9e\u73b0\u7cbe\u786e\u7684\u8fde\u63a5\u4e0e\u6570\u636e\u6620\u5c04\u673a\u5236\uff0cSource \u4e0d\u4ec5\u786e\u4fdd\u4e86\u6570\u636e\u6d41\u7684\u65e0\u7f1d\u5bf9\u63a5\uff0c\u800c\u4e14\u4fdd\u969c\u4e86\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\u3002
\u6bcf\u5f53\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Source \u5b9e\u4f8b\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u540c\u540d\u7684 Source \u8868\u3002\u8fd9\u4e2a\u8868\u88ab\u8bbe\u8ba1\u4e3a\u4e34\u65f6\u6027\u6570\u636e\u5b58\u50a8\u7a7a\u95f4\uff0c\u80fd\u591f\u5bb9\u7eb3\u6240\u6709\u6d41\u5165\u7684\u6570\u636e\uff0c\u5e76\u652f\u6301\u6570\u636e\u7684\u52a8\u6001\u589e\u957f\u548c\u5b9e\u65f6\u66f4\u65b0\u3002
\u76ee\u524d MatrixOne \u4ec5\u652f\u6301\u8fde\u63a5\u5230 Kafka\uff0c\u5e76\u4f7f\u7528 JSON \u6570\u636e\u8fdb\u884c\u6620\u5c04\uff0c\u4ee5\u4e0b\u662f\u521b\u5efa Source \u7684\u8bed\u6cd5\uff1a
CREATE [OR REPLACE] SOURCE [IF NOT EXISTS] stream_name ( { column_name data_type [KEY | HEADERS | HEADER(key)] } [, ...] )\nWITH ( property_name = expression [, ...]);\n
\u4f8b\u5982\u4f7f\u7528\u4e0b\u9762\u7684 sql \u8bed\u53e5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a stream_test \u7684 source\uff1a
create source stream_test(c1 char(25),c2 varchar(500),c3 text,c4 tinytext,c5 mediumtext,c6 longtext )with(\n\"type\"='kafka',\n\"topic\"= 'test',\n\"partition\" = '0',\n\"value\"= 'json',\n\"bootstrap.servers\"='127.0.0.1:9092' )\n
"},{"location":"MatrixOne/Overview/architecture/streaming/#dynamic-table","title":"\u52a8\u6001\u8868 Dynamic Table","text":"\u52a8\u6001\u8868\uff08Dynamic Table\uff09\u662f MatrixOne \u4e2d\u7684\u4e00\u4e2a\u6570\u636e\u7ba1\u9053\u3002\u52a8\u6001\u8868\u80fd\u591f\u5b9e\u65f6\u6355\u6349\u3001\u5904\u7406\u5e76\u8f6c\u6362\u6d41\u5165\u7684\u6570\u636e\uff0c\u4ece\u800c\u4fdd\u8bc1\u4fe1\u606f\u6d41\u5728\u6574\u4e2a\u7cfb\u7edf\u4e2d\u7684\u5373\u65f6\u66f4\u65b0\u548c\u51c6\u786e\u8868\u8fbe\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4e0d\u4ec5\u63d0\u5347\u4e86\u6570\u636e\u5904\u7406\u7684\u7075\u6d3b\u6027\u548c\u6548\u7387\uff0c\u8fd8\u4f18\u5316\u4e86\u6574\u4e2a\u7cfb\u7edf\u5bf9\u4e8e\u590d\u6742\u6570\u636e\u573a\u666f\u7684\u54cd\u5e94\u80fd\u529b\u548c\u5904\u7406\u6027\u80fd\u3002
\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u8bed\u6cd5\u7ed3\u6784\u521b\u5efa\u52a8\u6001\u8868\uff1a
CREATE DYNAMIC TABLE [IF NOT EXISTS] table_name AS SELECT ... from stream_name ;\n
\u793a\u4f8b\u5982\u4e0b\uff1a
create dynamic table dt_test as select * from stream_test;\n
"},{"location":"MatrixOne/Overview/feature/cost-effective/","title":"\u9ad8\u6027\u4ef7\u6bd4","text":"MatrixOne \u662f\u4e00\u6b3e\u5168\u65b0\u8bbe\u8ba1\u7684\u6570\u636e\u5e93\uff0c\u5176\u67b6\u6784\u8bbe\u8ba1\u7406\u5ff5\u5f3a\u8c03\u9ad8\u6027\u4ef7\u6bd4\u3002MatrixOne \u7684\u9ad8\u6027\u4ef7\u6bd4\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
"},{"location":"MatrixOne/Overview/feature/cost-effective/#htap","title":"\u5355\u96c6\u7fa4\u652f\u6301\u6df7\u5408\u8d1f\u8f7d HTAP","text":"\u968f\u7740\u5927\u6570\u636e\u5e94\u7528\u7684\u5feb\u901f\u666e\u53ca\u4e0e\u591a\u5143\u5316\u53d1\u5c55\uff0c\u4f20\u7edf\u7684\u6570\u636e\u5904\u7406\u65b9\u6848\u8d8a\u6765\u8d8a\u96be\u4ee5\u6ee1\u8db3\u6d77\u91cf\u6570\u636e\u5b9e\u65f6\u5206\u6790\u7684\u9700\u6c42\u3002\u73b0\u4ee3\u6570\u636e\u5e94\u7528\u9700\u6c42\u66f4\u52a0\u503e\u5411\u4e8e\u540c\u65f6\u8003\u8651\u9ad8\u5e76\u53d1\u7684 OLTP \u4e8b\u52a1\u578b\u4e1a\u52a1\u548c\u5927\u89c4\u6a21\u6570\u636e\u7684 OLAP \u5206\u6790\u578b\u4e1a\u52a1\u3002
MatrixOne \u662f\u4e13\u95e8\u8bbe\u8ba1\u7528\u6765\u89e3\u51b3\u6df7\u5408\u8d1f\u8f7d\u95ee\u9898\u7684\u6570\u636e\u5e93\u3002MatrixOne \u80fd\u591f\u5728\u540c\u4e00\u4e2a\u96c6\u7fa4\u4e2d\u540c\u65f6\u652f\u6301 OLTP \u548c OLAP\uff0c\u771f\u6b63\u5b9e\u73b0\u6df7\u5408\u4e8b\u52a1/\u5206\u6790\u5904\u7406\uff08Hybrid Transaction and Analytical Processing\uff0cHTAP\uff09\u3002\u7528\u6237\u4e0d\u518d\u9700\u8981\u5206\u522b\u642d\u5efa OLTP \u548c OLAP \u4e24\u4e2a\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u53ea\u9700\u4e00\u4e2a\u6570\u636e\u5e93\u5c31\u80fd\u652f\u6301\u6df7\u5408\u8d1f\u8f7d\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u4e0d\u4ec5\u907f\u514d\u4e86\u5efa\u8bbe\u548c\u7ef4\u62a4\u4e24\u5957\u7cfb\u7edf\u7684\u6210\u672c\uff0c\u8fd8\u907f\u514d\u4e86\u5c06\u6570\u636e\u4ece OLTP \u7cfb\u7edf\u540c\u6b65\u5230 OLAP \u7cfb\u7edf\u7684 ETL \u8fc7\u7a0b\u3002\u7528\u6237\u80fd\u591f\u5728\u540c\u4e00\u4e2a\u96c6\u7fa4\u4e2d\u65b9\u4fbf\u5730\u5904\u7406\u4e1a\u52a1\u548c\u5206\u6790\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#htap_1","title":"\u5355\u4e00\u5b58\u50a8\u5f15\u64ce\u5b9e\u73b0 HTAP","text":"\u5728\u6570\u636e\u5e93\u9886\u57df\uff0c\u5b9e\u73b0 HTAP \u901a\u5e38\u9700\u8981\u5c06\u4e00\u4e2a OLTP \u5f15\u64ce\u548c\u4e00\u4e2a OLAP \u5f15\u64ce\u5c01\u88c5\u5230\u4e00\u4e2a\u6570\u636e\u5e93\u4ea7\u54c1\u4e2d\u3002\u867d\u7136\u6570\u636e\u5728\u4e24\u4e2a\u5b58\u50a8\u5f15\u64ce\u4e4b\u95f4\u7684\u8f6c\u6362\u8fc7\u7a0b\u5bf9\u7528\u6237\u662f\u9690\u85cf\u7684\uff0c\u7528\u6237\u53ea\u770b\u5230\u4e00\u4e2a\u7edf\u4e00\u7684 SQL \u63a5\u53e3\uff0c\u4f46\u5b9e\u9645\u4e0a\u6570\u636e\u5728\u4e24\u4e2a\u5b58\u50a8\u5f15\u64ce\u5404\u5b58\u4e00\u4efd\uff0c\u786c\u4ef6\u548c\u5b58\u50a8\u6210\u672c\u5e76\u672a\u964d\u4f4e\u3002
\u4e0e\u4e0a\u8ff0\u5f15\u64ce\u5c01\u88c5\u65b9\u5f0f\u4e0d\u540c\uff0cMatrixOne \u5229\u7528\u5355\u4e00\u5b58\u50a8\u5f15\u64ce\u5b9e\u73b0 HTAP\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0cMatrixOne \u901a\u8fc7\u5bf9\u4e0d\u540c\u8ba1\u7b97\u8282\u70b9 CN \u8fdb\u884c\u5206\u7ec4\uff0c\u4ee5\u53ca\u5728\u8d1f\u8f7d\u7684\u8fd0\u884c\u94fe\u8def\u4e0a\u8fdb\u884c\u533a\u5206\uff0c\u5b9e\u73b0\u5355\u5f15\u64ce\u7684 HTAP\u3002\u5f53\u7528\u6237\u7684\u5e94\u7528\u8bf7\u6c42\u8fdb\u5165 MatrixOne \u96c6\u7fa4\u65f6\uff0cProxy \u6a21\u5757\u4f1a\u5c06 OLAP \u7c7b\u7684\u8bf7\u6c42\u5206\u53d1\u5230\u4e13\u95e8\u5904\u7406 OLAP \u7684 CN \u7ec4\u3002\u8fd9\u4e9b\u8bf7\u6c42\u901a\u5e38\u9700\u8981\u5927\u8303\u56f4\u5730\u8bfb\u53d6\u6216\u5199\u5165\u6570\u636e\uff0c\u7531 CN \u8282\u70b9\u76f4\u63a5\u4e0e\u5bf9\u8c61\u5b58\u50a8\u8fdb\u884c\u4ea4\u4e92\u3002\u800c OLTP \u7c7b\u7684\u8bf7\u6c42\uff0c\u5982\u5c0f\u6570\u636e\u91cf\u7684 INSERT
\uff0cUPDATE
\uff0cDELETE
\uff0c\u5219\u4f1a\u901a\u8fc7\u53e6\u4e00\u7ec4\u4e13\u95e8\u5904\u7406 OLTP \u7684 CN \u7ec4\uff0c\u5e76\u7531 TN \u8282\u70b9\u5904\u7406\u4e8b\u52a1\u4fe1\u606f\uff0c\u5e76\u5199\u5165 LogService \u7684\u5171\u4eab\u65e5\u5fd7\u3002TN \u8fd8\u4f1a\u4e0d\u65ad\u5730\u5c06 LogService \u4e2d\u7684\u5c11\u91cf\u4e8b\u52a1\u7c7b\u6570\u636e\u8fdb\u884c\u538b\u7f29\u548c\u5408\u5e76\uff0c\u518d\u5199\u5165\u5bf9\u8c61\u5b58\u50a8\u4e2d\u3002
\u603b\u7684\u6765\u8bf4\uff0c\u7528\u6237\u5199\u5165 MatrixOne \u7684\u6570\u636e\u53ea\u5b58\u5728\u4e00\u4efd\uff0c\u5e76\u901a\u8fc7\u5355\u4e00\u7684\u5b58\u50a8\u5f15\u64ce\u8fdb\u884c\u5904\u7406\uff0c\u5927\u5e45\u5ea6\u964d\u4f4e\u4e86\u5b58\u50a8\u548c\u8ba1\u7b97\u786c\u4ef6\u7684\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#_2","title":"\u7075\u6d3b\u7684\u8d44\u6e90\u5206\u914d\u63d0\u9ad8\u673a\u5668\u5229\u7528\u7387","text":"\u5728\u5b9e\u9645\u7684\u6570\u636e\u5e94\u7528\u4e1a\u52a1\u573a\u666f\u4e2d\uff0c\u7cfb\u7edf\u5927\u90e8\u5206\u65f6\u95f4\u662f\u670d\u52a1\u4e8e\u57fa\u4e8e CRUD \u7684\u4e8b\u52a1\u578b\u4e1a\u52a1\u3002\u7136\u800c\uff0c\u5728\u7279\u5b9a\u7684\u65f6\u95f4\u70b9\uff0c\u5982\u665a\u4e0a\u3001\u6708\u5e95\u6216\u8005\u5e74\u5e95\uff0c\u9700\u8981\u5bf9\u4e00\u6bb5\u65f6\u95f4\u5185\u7684\u603b\u4f53\u6570\u636e\u8fdb\u884c\u5206\u6790\u3002\u8fd9\u65f6\uff0c\u5982\u679c\u7528\u6237\u53ea\u6709\u4e00\u4e2a\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u5c31\u9700\u8981\u4e34\u65f6\u51cf\u5c11\u4e1a\u52a1\u8d1f\u8f7d\uff0c\u6216\u8005\u5728\u4e1a\u52a1\u8d1f\u8f7d\u8f83\u4f4e\u7684\u65f6\u5019\u8fdb\u884c OLAP \u5206\u6790\u4efb\u52a1\u3002\u7136\u800c\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u901a\u5e38\u4f1a\u9762\u4e34\u5206\u6790\u65f6\u95f4\u8fc7\u957f\uff0c\u4e0d\u80fd\u5f71\u54cd\u4e1a\u52a1\u8fd0\u884c\u7684\u957f\u65f6\u95f4\u7b49\u95ee\u9898\u3002\u5982\u679c\u7528\u6237\u4e3a OLAP \u5206\u6790\u578b\u4e1a\u52a1\u5355\u72ec\u90e8\u7f72\u4e00\u5957\u6570\u636e\u5e93\u7cfb\u7edf\uff0c\u4f46\u5b9e\u9645\u7684\u5206\u6790\u578b\u4e1a\u52a1\u5f80\u5f80\u96be\u4ee5\u6700\u5927\u5316\u5229\u7528\uff0c\u4e5f\u4f1a\u5bfc\u81f4\u4e00\u5b9a\u7684\u8d44\u6e90\u6d6a\u8d39\u3002
\u5982\u4e0a\u4e00\u90e8\u5206\u6240\u4ecb\u7ecd\u7684\uff0cMatrixOne \u901a\u8fc7\u5bf9\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9\u8fdb\u884c\u5206\u7ec4\uff0c\u4ee5\u53ca\u5728\u5e95\u5c42\u901a\u8fc7\u4e0d\u540c\u7684\u94fe\u8def\u652f\u6301 OLTP \u548c OLAP \u4e1a\u52a1\uff0c\u5b9e\u73b0 HTAP\u3002\u8fd9\u79cd\u67b6\u6784\u4f7f\u5f97 MatrixOne \u80fd\u591f\u6839\u636e\u5b9e\u9645\u4e1a\u52a1\u9700\u6c42\uff0c\u7075\u6d3b\u5730\u8c03\u6574\u8d44\u6e90\u5206\u914d\uff0c\u4ee5\u6b64\u63d0\u9ad8\u673a\u5668\u5229\u7528\u7387\uff0c\u5b9e\u73b0\u771f\u6b63\u7684\u9ad8\u6027\u4ef7\u6bd4\u3002 \u5982\u679c CRUD \u7c7b\u578b\u7684\u4e1a\u52a1\u9700\u6c42\u8f83\u9ad8\u65f6\uff0c\u4f60\u53ef\u4ee5\u4e3a OLTP \u5206\u914d\u66f4\u591a\u7684 CN \u8282\u70b9\u3002\u76f8\u5e94\u5730\uff0c\u5f53\u5206\u6790\u578b\u4e1a\u52a1\u9700\u6c42\u5347\u9ad8\u65f6\uff0c\u4f60\u53ef\u4ee5\u4e3a OLAP \u5206\u914d\u66f4\u591a\u7684 CN \u8282\u70b9\u3002\u8fd9\u79cd\u8c03\u6574\u5747\u662f\u5168\u52a8\u6001\u53ef\u914d\u7f6e\u7684\u3002
\u4ee5\u4e0b\u56fe\u4e3a\u4f8b\uff0c\u5047\u8bbe\u7528\u6237\u539f\u5148\u9700\u8981 3 \u4e2a\u8ba1\u7b97\u8282\u70b9\u6765\u5904\u7406 OLTP \u4e1a\u52a1\uff0c\u4ee5\u53ca 3 \u4e2a\u8ba1\u7b97\u8282\u70b9\u6765\u5904\u7406 OLAP \u4e1a\u52a1\uff0c\u5e76\u4e14\u8fd9\u4e9b\u786c\u4ef6\u8d44\u6e90\u662f\u5b8c\u5168\u7ed1\u5b9a\u7684\uff0c\u5373\u4e3a OLTP \u670d\u52a1\u7684\u8282\u70b9\u4e0d\u80fd\u4e3a OLAP \u63d0\u4f9b\u670d\u52a1\uff0c\u53cd\u4e4b\u4ea6\u7136\uff0c\u800c\u4e14\u7528\u6237\u5bf9\u673a\u5668\u8d44\u6e90\u7684\u89c4\u5212\u5f80\u5f80\u8d85\u51fa\u5b9e\u9645\u9700\u6c42\u7684\u4e0a\u9650\u3002\u7136\u800c\uff0c\u5728\u5b9e\u9645\u4e1a\u52a1\u4e2d\uff0c\u8fbe\u5230\u5168\u5cf0\u9700\u6c42\u7684\u65f6\u95f4\u76f8\u5f53\u6709\u9650\u3002\u5982\u679c\u8bbe\u8ba1\u4f7f\u7528 MatrixOne \u96c6\u7fa4\u652f\u6301\u8fd9\u4e9b\u4e1a\u52a1\uff0c\u90a3\u4e48\u53ef\u4ee5\u8c03\u6574\u4e3a\u603b\u5171 4 \u4e2a\u8ba1\u7b97\u8282\u70b9\uff0c\u5e73\u65f6 3 \u4e2a\u8282\u70b9\u5904\u7406 OLTP \u4e1a\u52a1\uff0c1 \u4e2a\u8282\u70b9\u5904\u7406 OLAP \u4e1a\u52a1\u3002\u7136\u540e\uff0c\u5728\u6708\u672b\u7b49\u5206\u6790\u9700\u6c42\u9ad8\u5cf0\u65f6\u671f\uff0c\u5219\u53ef\u4ee5\u8c03\u6574\u4e3a 1 \u4e2a\u8ba1\u7b97\u8282\u70b9\u5904\u7406 OLTP \u4e1a\u52a1\uff0c3 \u4e2a\u8ba1\u7b97\u8282\u70b9\u5904\u7406 OLAP \u4e1a\u52a1\uff1b\u9ad8\u5cf0\u8fc7\u540e\u518d\u6062\u590d\u539f\u59cb\u914d\u7f6e\uff0c\u8fd9\u6837\u53ef\u63d0\u9ad8\u673a\u5668\u8d44\u6e90\u4f7f\u7528\u7387 40%\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#_3","title":"\u9ad8\u6548\u4f4e\u6210\u672c\u7684\u5bf9\u8c61\u5b58\u50a8","text":"\u5728\u5b58\u50a8\u5c42\u9762\uff0cMatrixOne \u4e3b\u8981\u91c7\u7528\u5bf9\u8c61\u5b58\u50a8\uff0c\u8be5\u5b58\u50a8\u901a\u8fc7\u4f7f\u7528\u7ea0\u5220\u7801\u539f\u7406\uff0c\u4ec5\u9700\u8981\u4f4e\u81f3 33% \u7684\u5197\u4f59\u5ea6\u5373\u53ef\u4fdd\u8bc1\u6570\u636e\u7684\u9ad8\u53ef\u7528\u6027\u3002\u4e0e\u884c\u4e1a\u5185\u5e38\u89c1\u7684\u901a\u8fc7\u591a\u526f\u672c\u6765\u4fdd\u8bc1\u9ad8\u53ef\u7528\u6027\u7684\u65b9\u6848\u76f8\u6bd4\uff0c\u7ea0\u5220\u7801\u5728\u4fdd\u6301\u540c\u7b49\u53ef\u9760\u6027\u7684\u524d\u63d0\u4e0b\uff0c\u5176\u7a7a\u95f4\u5229\u7528\u7387\u4f18\u4e8e\u591a\u526f\u672c\u65b9\u6848\u3002
\u5728 MatrixOne \u96c6\u7fa4\u4e2d\uff0c\u4ee5\u79c1\u6709\u5316\u90e8\u7f72\u7684 Minio \u5b98\u65b9\u63a8\u8350\u7684\u6700\u5c0f\u914d\u7f6e\uff084 \u8282\u70b9 \u00d7 4 \u78c1\u76d8\uff09\u4e3a\u4f8b\uff0cMatrixOne \u6700\u5c11\u53ef\u4ee5\u652f\u6301 4 \u5757\u78c1\u76d8\u4f5c\u4e3a\u7ea0\u5220\u7801\u78c1\u76d8\uff0c\u4ee5\u53ca 12 \u5757\u78c1\u76d8\u4f5c\u4e3a\u6570\u636e\u78c1\u76d8\u7684\u67b6\u6784\uff0c\u5176\u5197\u4f59\u5ea6\u4e3a 1.33\u3002
\u6b64\u5916\uff0c\u5bf9\u8c61\u5b58\u50a8\u8fd8\u652f\u6301 HDD \u78c1\u76d8\u7b49\u4f4e\u6210\u672c\u5b58\u50a8\u4ecb\u8d28\u3002\u5bf9\u4e8e\u96c6\u7fa4\u8ba1\u7b97\u6027\u80fd\u8981\u6c42\u4e0d\u9ad8\uff0c\u4ee5\u5b58\u50a8\u4e3a\u4e3b\u7684\u4f7f\u7528\u573a\u666f\u4e2d\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u964d\u4f4e\u4f7f\u7528\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#_4","title":"\u5217\u5f0f\u5b58\u50a8\u5e26\u6765\u7684\u9ad8\u6570\u636e\u538b\u7f29\u6bd4","text":"\u7ed3\u6784\u5316\u6570\u636e\u5728\u5b58\u50a8\u65f6\uff0c\u6bcf\u4e00\u5217\u7684\u6570\u636e\u7ed3\u6784\u76f8\u540c\u3002\u5728 MatrixOne \u5b58\u50a8\u5c42\uff0c\u6570\u636e\u4ee5\u5217\u5f0f\u5b58\u50a8\uff0c\u8fd9\u6837\u7684\u7279\u6027\u8ba9\u6570\u636e\u5177\u6709\u66f4\u597d\u7684\u538b\u7f29\u7279\u6027\uff1a
MatrixOne \u603b\u4f53\u7684\u6570\u636e\u538b\u7f29\u7387\u6700\u4f4e\u53ef\u8fbe 1%\uff0c\u5177\u4f53\u538b\u7f29\u7387\u53d7\u5b9e\u9645\u6570\u636e\u7684\u6570\u636e\u7ed3\u6784\u3001\u6570\u636e\u5197\u4f59\u7a0b\u5ea6\u7b49\u591a\u56e0\u7d20\u5f71\u54cd\u3002
\u603b\u7684\u6765\u8bf4\uff0cMatrixOne \u7684\u5217\u5f0f\u5b58\u50a8\u65b9\u5f0f\u5c06\u6781\u5927\u7684\u538b\u7f29\u60a8\u7684\u5b9e\u9645\u5b58\u50a8\u7a7a\u95f4\uff0c\u6781\u5927\u7684\u964d\u4f4e\u60a8\u7684\u5b58\u50a8\u6210\u672c\u3002
"},{"location":"MatrixOne/Overview/feature/cost-effective/#mysql","title":"\u4e0e MySQL \u7684\u517c\u5bb9\u6027","text":"MatrixOne \u5728\u8bed\u6cd5\u3001\u534f\u8bae\u4ee5\u53ca\u751f\u6001\u5de5\u5177\u65b9\u9762\u90fd\u4fdd\u6301\u4e86\u4e0e\u5e02\u573a\u4e0a\u6700\u6d41\u884c\u7684\u5f00\u6e90\u6570\u636e\u5e93 MySQL \u7684\u517c\u5bb9\u6027\uff0c\u8fd9\u4f7f\u5f97\u719f\u6089 MySQL \u6216\u8005\u4ee5\u524d\u4f7f\u7528 MySQL \u7684\u7528\u6237\u80fd\u591f\u4ee5\u6781\u4f4e\u7684\u6210\u672c\u8fdb\u884c\u8fc1\u79fb\u548c\u5b66\u4e60\u3002
\u5173\u4e8e MatrixOne \u4e0e MySQL \u517c\u5bb9\u6027\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 MySQL \u517c\u5bb9\u6027\u7ae0\u8282\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/","title":"MatrixOne \u529f\u80fd\u7279\u6027","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#matrixone_1","title":"MatrixOne \u7279\u6027","text":"\u5728 MatrixOne \u7248\u672c 1.2.1 \u4e2d\uff0c\u5177\u6709\u5982\u4e0b\u7279\u6027\uff0c\u8ba9\u4f60\u5728\u4f7f\u7528 MatrixOne \u7684\u8fc7\u7a0b\u4e2d\u66f4\u52a0\u9ad8\u6548\uff1a
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_1","title":"\u5206\u5e03\u5f0f\u67b6\u6784","text":"\u5728 MatrixOne \u4e2d\uff0c\u91c7\u7528\u4e86\u5206\u5e03\u5f0f\u5b58\u7b97\u5206\u79bb\u7684\u5206\u5e03\u5f0f\u67b6\u6784\uff0c\u5b58\u50a8\u5c42\u3001\u6570\u636e\u5c42\u3001\u8ba1\u7b97\u5c42\u7684\u5206\u79bb\uff0c\u4f7f\u5f97 MatrixOne \u5728\u9047\u5230\u7cfb\u7edf\u8d44\u6e90\u74f6\u9888\u65f6\uff0c\u80fd\u591f\u7075\u6d3b\u5b9e\u73b0\u8282\u70b9\u7684\u6269\u5bb9\u3002\u540c\u65f6\uff0c\u591a\u8282\u70b9\u7684\u67b6\u6784\u4e0b\uff0c\u8d44\u6e90\u53ef\u4ee5\u8fdb\u884c\u66f4\u52a0\u6709\u6548\u7387\u5730\u5206\u914d\uff0c\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u907f\u514d\u4e86\u70ed\u70b9\u4e0e\u8d44\u6e90\u5f81\u7528\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_2","title":"\u4e8b\u52a1\u4e0e\u9694\u79bb","text":"\u5728 MatrixOne \u4e2d\uff0c\u4e8b\u52a1\u91c7\u7528\u4e86\u4e50\u89c2\u4e8b\u52a1\u4e0e\u5feb\u7167\u9694\u79bb\u3002
\u5728\u5206\u5e03\u5f0f\u67b6\u6784\u4e0b\uff0c\u4e50\u89c2\u4e8b\u52a1\u53ef\u4ee5\u901a\u8fc7\u8f83\u5c11\u7684\u51b2\u7a81\u83b7\u5f97\u66f4\u4f18\u7684\u6027\u80fd\u3002\u540c\u65f6\u5728\u5b9e\u73b0\u65b9\u5f0f\u4e0a\uff0c\u80fd\u591f\u5b9e\u73b0\u9694\u79bb\u7ea7\u522b\u66f4\u9ad8\u7684\u5feb\u7167\u9694\u79bb\u3002\u4e3a\u4e86\u4fdd\u8bc1\u4e8b\u52a1\u7684 ACID \u56db\u4e2a\u8981\u7d20\uff0cMatrixOne \u76ee\u524d\u652f\u6301\u4e14\u4ec5\u652f\u6301\u5feb\u7167\u9694\u79bb\u4e00\u79cd\u9694\u79bb\u7ea7\u522b\u3002\u8be5\u9694\u79bb\u7ea7\u522b\u8f83\u5e38\u89c1\u7684\u8bfb\u5df2\u63d0\u4ea4\u76f8\u6bd4\uff0c\u9694\u79bb\u7ea7\u522b\u66f4\u52a0\u4e25\u683c\uff0c\u65e2\u53ef\u4ee5\u6709\u6548\u9632\u6b62\u810f\u8bfb\uff0c\u53c8\u80fd\u591f\u66f4\u597d\u5730\u9002\u914d\u5206\u5e03\u5f0f\u4e50\u89c2\u4e8b\u52a1\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_3","title":"\u4e91\u539f\u751f","text":"MatrixOne \u662f\u4e00\u6b3e\u4e91\u539f\u751f\u7684\u6570\u636e\u5e93\uff0c\u4ece\u5b58\u50a8\u5c42\uff0c\u9002\u914d\u672c\u5730\u78c1\u76d8\u3001AWS S3\u3001NFS \u7b49\u591a\u79cd\u5b58\u50a8\u65b9\u5f0f\uff0c\u901a\u8fc7 File service \u5b9e\u73b0\u4e86\u5bf9\u591a\u79cd\u4e0d\u540c\u7c7b\u578b\u5b58\u50a8\u7684\u65e0\u611f\u77e5\u7ba1\u7406\u3002MatrixOne \u96c6\u7fa4\u53ef\u4ee5\u5728\u591a\u79cd\u57fa\u7840\u8bbe\u65bd\u73af\u5883\u4e0b\u7a33\u5b9a\u8fd0\u884c\uff0c\u65e2\u53ef\u4ee5\u9002\u914d\u4f01\u4e1a\u79c1\u6709\u4e91\uff0c\u53c8\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u516c\u6709\u4e91\u5382\u5546\u73af\u5883\u4e0b\u63d0\u4f9b\u670d\u52a1\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_4","title":"\u8d1f\u8f7d\u5747\u8861","text":"\u5728\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u7684\u67b6\u6784\u4e0b\uff0c\u4e0d\u540c\u8282\u70b9\u4e4b\u95f4\u4e0d\u53ef\u907f\u514d\u5730\u5b58\u5728\u8d1f\u8f7d\u5dee\u5f02\uff0c\u53ef\u80fd\u5bfc\u81f4\u67d0\u4e9b\u4e1a\u52a1\u573a\u666f\u7684\u6027\u80fd\u74f6\u9888\u6216\u90e8\u5206\u8ba1\u7b97\u8d44\u6e90\u95f2\u7f6e\u3002\u56e0\u6b64\uff0cMatrixOne \u4e3a\u786e\u4fdd\u4e0d\u540c\u8282\u70b9\u5728\u8d44\u6e90\u5206\u914d\u4e0a\u5c3d\u91cf\u4fdd\u6301\u63a5\u8fd1\uff0c\u5b9e\u73b0\u4e86\u8ba1\u7b97\u8d44\u6e90\u7684\u8d1f\u8f7d\u5747\u8861\u529f\u80fd\u7279\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#sql","title":"SQL \u8def\u7531","text":"SQL \u8def\u7531\u5e38\u7528\u4e8e\u65e9\u671f\u7684\u5206\u5e93\u5206\u8868\u6570\u636e\u5e93\u573a\u666f\uff0c\u7528\u4e8e\u5728\u6536\u5230\u4e00\u6761 SQL \u8bf7\u6c42\u540e\uff0c\u6839\u636e\u6570\u636e\u5206\u5e03\u60c5\u51b5\uff0c\u786e\u5b9a\u5c06\u8be5\u8bf7\u6c42\u53d1\u9001\u5230\u54ea\u4e2a\u5b9e\u4f8b/\u5e93/\u8868\u3002
\u5728 MatrixOne \u4e2d\uff0c\u867d\u7136\u5b58\u50a8\u5f15\u64ce\u7684\u80fd\u529b\u4e0d\u518d\u9650\u5236\u6570\u636e\u5e93\u89c4\u6a21\uff0c\u4f46\u5728\u591a CN \u7684\u67b6\u6784\u4e0b\uff0c\u4ecd\u7136\u5b58\u5728\u7740\u591a CN \u4e4b\u95f4\u8d1f\u8f7d\u5747\u8861\u548c\u4e0d\u540c\u79df\u6237\u4e4b\u95f4\u8d44\u6e90\u9694\u79bb\u7684\u573a\u666f\u9700\u6c42\u3002\u56e0\u6b64\uff0c\u5728 MatrixOne \u4e2d\uff0c\u5b9e\u73b0\u4e86 SQL \u8def\u7531\u5c06 SQL \u8bf7\u6c42\u6309\u7167\u9884\u5b9a\u4e49\u7684\u89c4\u5219\u53d1\u9001\u5230\u4e0d\u540c CN \u8282\u70b9\u6267\u884c\uff0c\u89e3\u51b3\u4e86\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u65e0\u6cd5\u8d1f\u8f7d\u5927\u91cf\u6570\u636e\u8bbf\u95ee\u8981\u6c42\u7684\u60c5\u51b5\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#_5","title":"\u767d\u540d\u5355","text":"\u767d\u540d\u5355\u662f\u4e00\u9879\u5b89\u5168\u7b56\u7565\uff0c\u7528\u4e8e\u63a7\u5236\u53d7\u9650\u5236\u7684\u8d44\u6e90\u3001\u7cfb\u7edf\u6216\u7f51\u7edc\u7684\u8bbf\u95ee\u3002\u5b83\u57fa\u4e8e\u4e00\u4e2a\u6838\u5fc3\u601d\u60f3\uff0c\u5373\u53ea\u5141\u8bb8\u88ab\u6388\u6743\u548c\u4fe1\u4efb\u7684\u5b9e\u4f53\u8fdb\u884c\u8bbf\u95ee\uff0c\u800c\u62d2\u7edd\u5176\u4ed6\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u5c1d\u8bd5\u3002\u8fd9\u4e9b\u88ab\u6388\u6743\u7684\u5b9e\u4f53\u53ef\u80fd\u5305\u62ec\u7279\u5b9a\u7528\u6237\u3001IP \u5730\u5740\u3001\u7a0b\u5e8f\u6216\u5176\u4ed6\u5b9e\u4f53\u3002\u4e0e\u767d\u540d\u5355\u76f8\u5bf9\u7684\u662f\u9ed1\u540d\u5355\uff0c\u9ed1\u540d\u5355\u7b56\u7565\u6307\u5b9a\u4e00\u7cfb\u5217\u88ab\u7981\u6b62\u7684\u5b9e\u4f53\uff0c\u8fd9\u4e9b\u5b9e\u4f53\u5c06\u88ab\u963b\u6b62\u8bbf\u95ee\u53d7\u9650\u5236\u7684\u8d44\u6e90\u3001\u7cfb\u7edf\u6216\u7f51\u7edc\u3002\u5728\u9ed1\u540d\u5355\u7b56\u7565\u4e0b\uff0c\u672a\u88ab\u5217\u5165\u9ed1\u540d\u5355\u7684\u5b9e\u4f53\u53ef\u4ee5\u8fdb\u884c\u8bbf\u95ee\u3002
\u767d\u540d\u5355\u5177\u6709\u4ee5\u4e0b\u7279\u6027\uff1a
\u5355\u4e00\u96c6\u7fa4\u591a\u79df\u6237\u7684\u65b9\u5f0f\u53ef\u4ee5\u63d0\u4f9b\u8d44\u6e90\u5171\u4eab\u3001\u7b80\u5316\u7ba1\u7406\u3001\u63d0\u9ad8\u53ef\u4f38\u7f29\u6027\u3001\u63d0\u4f9b\u5b89\u5168\u9694\u79bb\u7b49\u597d\u5904\uff0c\u5bf9\u4e8e\u9700\u8981\u540c\u65f6\u4e3a\u591a\u4e2a\u79df\u6237\u63d0\u4f9b\u6570\u636e\u5e93\u670d\u52a1\u7684\u573a\u666f\u975e\u5e38\u6709\u4ef7\u503c\u3002
MatrixOne \u7684\u591a\u79df\u6237\u6a21\u5f0f\u80fd\u591f\u4e3a\u4e0d\u540c\u7684\u79df\u6237\u63d0\u4f9b\u72ec\u7acb\u7684\u6570\u636e\u5e93\u5b9e\u4f8b\uff0c\u5e76\u91c7\u7528\u903b\u8f91\u9694\u79bb\u7684\u65b9\u5f0f\u786e\u4fdd\u5404\u79df\u6237\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u72ec\u7acb\u6027\uff0c\u6709\u6548\u9632\u6b62\u6570\u636e\u6cc4\u9732\u548c\u7be1\u6539\u7684\u98ce\u9669\u3002
"},{"location":"MatrixOne/Overview/feature/feature-overview/#matrixone_2","title":"MatrixOne \u6027\u80fd\u4f18\u52bf","text":""},{"location":"MatrixOne/Overview/feature/feature-overview/#_7","title":"\u9ad8\u6548\u5b58\u50a8","text":"MatrixOne \u9009\u62e9 AWS S3 \u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u6548\u7684\u5b58\u50a8\u65b9\u6848\uff0c\u6ee1\u8db3\u4e86\u4f4e\u6210\u672c\u548c\u51b7\u70ed\u6570\u636e\u5206\u79bb\u8fd9\u4e24\u4e2a\u6838\u5fc3\u9700\u6c42\u3002\u5176\u53ef\u9760\u7684\u53ef\u7528\u6027\u4fdd\u8bc1\u4e86\u516c\u6709\u4e91\u4e2d\u7684\u4f4e\u98ce\u9669\uff0c\u5e76\u63d0\u4f9b\u79c1\u6709\u5316\u90e8\u7f72\u7684\u517c\u5bb9\u7248\u672c\u3002
\u4f5c\u4e3a HTAP \u6570\u636e\u5e93\uff0c\u5b9e\u73b0\u4e86\u4e0d\u540c\u7c7b\u578b\u7684\u5de5\u4f5c\u8d1f\u8f7d\u9694\u79bb\uff1a
\u4f5c\u4e3a HTAP \u6570\u636e\u5e93\uff0c\u4e0d\u540c\u4e1a\u52a1\u573a\u666f\u7684\u6bd4\u4f8b\u5728\u4e0d\u65ad\u52a8\u6001\u53d8\u5316\uff0c\u5bf9\u8d44\u6e90\u7684\u914d\u6bd4\u4e5f\u6709\u7740\u66f4\u9ad8\u7684\u8981\u6c42\u3002\u65e7\u67b6\u6784\u4e0b\u7684\u8d44\u6e90\u5206\u914d\u6a21\u5f0f\u6ce8\u5b9a\u65e0\u6cd5\u5b9e\u73b0\u7075\u6d3b\u8c03\u6574\uff0c\u9700\u8981\u5bf9\u5404\u4e2a\u8282\u70b9\u5b9e\u73b0\u66f4\u52a0\u7cbe\u7ec6\u5316\u7684\u7ba1\u7406\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a
\u6570\u636e\u5e93\u7684\u9ad8\u53ef\u7528\u6027\u662f\u4f01\u4e1a\u5173\u952e\u9700\u6c42\uff0c\u5b83\u4fdd\u8bc1\u4e86\u7cfb\u7edf\u7684\u6301\u7eed\u53ef\u7528\u6027\u3001\u6570\u636e\u7684\u5b89\u5168\u6027\uff0c\u4ee5\u53ca\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002MatrixOne \u4f5c\u4e3a\u4e00\u6b3e\u9ad8\u53ef\u7528\u6027\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u80fd\u6ee1\u8db3\u4f01\u4e1a\u7684\u9700\u6c42\u3002\u672c\u6587\u6863\u65e8\u5728\u4ecb\u7ecd MatrixOne \u7684\u9ad8\u53ef\u7528\u6027\u7279\u6027\uff0c\u5305\u62ec\u6545\u969c\u6062\u590d\u3001\u6570\u636e\u5197\u4f59\u3001\u8d1f\u8f7d\u5747\u8861\u7b49\u5173\u952e\u529f\u80fd\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_2","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u4f01\u4e1a\u5bf9\u6570\u636e\u5e93\u9ad8\u53ef\u7528\u6027\u7684\u9700\u6c42\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
\u6301\u7eed\u53ef\u7528\u6027\uff1a\u4f01\u4e1a\u9700\u8981\u786e\u4fdd\u5176\u5173\u952e\u4e1a\u52a1\u6570\u636e\u5e93\u7684\u6301\u7eed\u8fd0\u884c\uff0c\u4ee5\u9632\u6b62\u957f\u65f6\u95f4\u7684\u7cfb\u7edf\u4e2d\u65ad\u6216\u670d\u52a1\u4e0d\u53ef\u7528\uff0c\u8fd9\u6837\u53ef\u4ee5\u4fdd\u8bc1\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u548c\u7528\u6237\u6ee1\u610f\u5ea6\u3002
\u6545\u969c\u6062\u590d\uff1a\u5f53\u6570\u636e\u5e93\u53d1\u751f\u6545\u969c\u65f6\uff0c\u80fd\u5feb\u901f\u5e76\u81ea\u52a8\u5730\u8fdb\u884c\u6545\u969c\u68c0\u6d4b\u548c\u5207\u6362\uff0c\u4ece\u800c\u51cf\u5c11\u7cfb\u7edf\u7684\u4e2d\u65ad\u65f6\u95f4\uff0c\u786e\u4fdd\u670d\u52a1\u7684\u8fde\u7eed\u6027\u548c\u53ef\u9760\u6027\u3002
\u6570\u636e\u4fdd\u62a4\u548c\u6062\u590d\uff1a\u6570\u636e\u662f\u4f01\u4e1a\u7684\u91cd\u8981\u8d44\u4ea7\uff0c\u56e0\u6b64\u9700\u8981\u5b9a\u671f\u5907\u4efd\u6570\u636e\u5e93\uff0c\u5e76\u80fd\u591f\u5feb\u901f\u6062\u590d\u6570\u636e\uff0c\u4ee5\u5e94\u5bf9\u610f\u5916\u7684\u6570\u636e\u4e22\u5931\u6216\u635f\u574f\u3002
\u8de8\u5730\u57df\u5bb9\u707e\uff1a\u5bf9\u4e8e\u5173\u952e\u4e1a\u52a1\uff0c\u53ef\u80fd\u9700\u8981\u5728\u4e0d\u540c\u7684\u5730\u7406\u533a\u57df\u8bbe\u7acb\u6570\u636e\u4e2d\u5fc3\uff0c\u5b9e\u73b0\u8de8\u5730\u57df\u5bb9\u707e\uff0c\u4ee5\u5e94\u5bf9\u81ea\u7136\u707e\u5bb3\u3001\u7f51\u7edc\u4e2d\u65ad\u6216\u533a\u57df\u6027\u6545\u969c\u3002
MatrixOne \u901a\u8fc7\u7ea0\u5220\u7801\u8fdb\u884c\u6570\u636e\u5197\u4f59\u6821\u9a8c\uff0c\u540c\u6b65\u4e8b\u52a1\u65e5\u5fd7\u91c7\u7528 Raft \u534f\u8bae\uff0c\u53ea\u6709\u591a\u6570\u6d3e\u5199\u5165\u6210\u529f\uff0c\u4e8b\u52a1\u624d\u80fd\u63d0\u4ea4\uff0c\u8fd9\u786e\u4fdd\u4e86\u6570\u636e\u7684\u5f3a\u4e00\u81f4\u6027\uff0c\u5373\u4f7f\u5c11\u6570\u526f\u672c\u53d1\u751f\u6545\u969c\u4e5f\u4e0d\u5f71\u54cd\u6570\u636e\u7684\u53ef\u7528\u6027\u3002MatrixOne \u7684\u9ad8\u53ef\u7528\u6027\u6ee1\u8db3\u91d1\u878d\u884c\u4e1a 4 \u7ea7\u6807\u51c6\uff08RPO=0\uff0cRTO<30min\uff09\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_4","title":"\u6280\u672f\u67b6\u6784","text":"MatrixOne \u7684\u6574\u4f53\u6280\u672f\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u6211\u4eec\u4f1a\u6839\u636e\u4e0d\u540c\u7684\u7ec4\u4ef6\u6a21\u5757\uff0c\u5206\u522b\u4ecb\u7ecd\u5b83\u4eec\u7684\u9ad8\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_5","title":"\u8d44\u6e90\u8c03\u5ea6\u5c42","text":"MatrixOne \u7684\u6280\u672f\u67b6\u6784\u662f\u5b8c\u5168\u4e91\u539f\u751f\u5316\u7684\uff0c\u6240\u6709\u7684\u6280\u672f\u7ec4\u4ef6\u90fd\u4ee5\u5bb9\u5668\u5316\u7684\u5f62\u5f0f\u8fd0\u884c\u5728 Kubernetes \u4e0a\u3002\u901a\u8fc7\u91c7\u7528\u591a\u4e3b\u591a\u4ece\u7684\u90e8\u7f72\u65b9\u6848\uff0cKubernetes \u96c6\u7fa4\u53ef\u4ee5\u4fdd\u8bc1\u8fde\u7eed\u53ef\u7528\u6027\u3002\u5177\u4f53\u7684\u90e8\u7f72\u62d3\u6251\u53ca\u65b9\u6848\u53ef\u53c2\u8003 Kubernetes \u5b98\u65b9\u65b9\u6848\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_6","title":"\u5b58\u50a8\u5c42","text":"\u5728\u5b58\u50a8\u5c42\uff0cMatrixOne \u91c7\u7528\u5bf9\u8c61\u5b58\u50a8\uff0c\u63a8\u8350\u4f7f\u7528 Minio \u8fdb\u884c\u90e8\u7f72\u3002MinIO \u4f5c\u4e3a\u4e00\u6b3e\u6210\u719f\u7684\u5206\u5e03\u5f0f\u5bf9\u8c61\u5b58\u50a8\u65b9\u6848\uff0c\u9700\u8981\u4fdd\u8bc1\u6570\u636e\u670d\u52a1\u7684\u9ad8\u53ef\u7528\u6027\u548c\u6570\u636e\u6587\u4ef6\u7684\u5b8c\u6574\u4e00\u81f4\u6027\u3002MinIO \u96c6\u7fa4\u7684\u67b6\u6784\u662f\u5206\u5e03\u5f0f\u7684\uff0c\u5c06\u6570\u636e\u5b58\u50a8\u5728\u591a\u4e2a\u8282\u70b9\u4e0a\uff0c\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u5bb9\u9519\u6027\u3002\u540c\u65f6\uff0cMinIO \u96c6\u7fa4\u4f7f\u7528 Erasure Coding \u6280\u672f\u4fdd\u8bc1\u6570\u636e\u7684\u53ef\u9760\u6027\u548c\u53ef\u7528\u6027\u3002\u5f53\u67d0\u4e2a\u8282\u70b9\u53d1\u751f\u6545\u969c\u65f6\uff0c\u5176\u4ed6\u8282\u70b9\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u7f16\u7801\u526f\u672c\u6062\u590d\u4e22\u5931\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_7","title":"\u5171\u4eab\u65e5\u5fd7","text":"\u5171\u4eab\u65e5\u5fd7\u7ec4\u4ef6 LogService \u662f MatrixOne \u4e2d\u552f\u4e00\u62e5\u6709\u5206\u5e03\u5f0f\u4e8b\u52a1\u72b6\u6001\u7684\u7ec4\u4ef6\u3002\u8fd9\u662f\u4e00\u4e2a\u7531\u4e09\u4e2a\u8282\u70b9\u7ec4\u6210\uff0c\u9075\u5faa Raft \u534f\u8bae\u7684\u67b6\u6784\uff0c\u5373\u4f7f\u4e00\u4e2a\u8282\u70b9\u5931\u6548\uff0c\u4e5f\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\u5b83\u8d1f\u8d23\u5bf9\u6574\u4e2a MatrixOne \u96c6\u7fa4\u7684\u670d\u52a1\u8fdb\u884c\u6700\u7ec8\u4e00\u81f4\u6027\u7684\u4fdd\u969c\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_8","title":"\u4e8b\u52a1\u5c42","text":"\u4e8b\u52a1\u5c42\u7ec4\u4ef6 Transaction node \u8d1f\u8d23\u5bf9\u4e8b\u52a1\u64cd\u4f5c\u8fdb\u884c\u51b2\u7a81\u68c0\u6d4b\u4ee5\u53ca\u4ef2\u88c1\uff0c\u5b83\u662f\u4e00\u4e2a\u65e0\u72b6\u6001\u7684\u8282\u70b9\u3002\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0cKubernetes \u53ef\u4ee5\u968f\u65f6\u62c9\u8d77\uff0c\u5728\u79d2\u7ea7\u65f6\u95f4\u5185\u5c31\u80fd\u6062\u590d\u6b63\u5e38\uff0c\u4fdd\u8bc1\u6301\u7eed\u53ef\u7528\u6027\u3002\u76ee\u524d\u7248\u672c\u7684 Transaction node \u4ec5\u652f\u6301\u5355\u8282\u70b9\u8fd0\u884c\uff0c\u540e\u7eed\u4f1a\u589e\u52a0\u591a Transaction node \u65b9\u6848\uff0c\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#_9","title":"\u8ba1\u7b97\u5c42","text":"\u8ba1\u7b97\u5c42\u7ec4\u4ef6 Compute Node \u8d1f\u8d23\u524d\u7aef Query \u7684\u89e3\u6790\uff0c\u4ee5\u53ca\u6267\u884c\u8ba1\u5212\u7684\u751f\u6210\u548c\u6267\u884c\u3002\u5b83\u4e5f\u662f\u4e00\u4e2a\u65e0\u72b6\u6001\u7684\u8282\u70b9\uff0c\u5982\u679c\u51fa\u73b0\u6545\u969c\uff0cKubernetes \u53ef\u4ee5\u968f\u65f6\u62c9\u8d77\uff0c\u5728\u79d2\u7ea7\u65f6\u95f4\u5185\u6062\u590d\u6b63\u5e38\uff0c\u4fdd\u8bc1\u6301\u7eed\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/high-availability/#proxy","title":"Proxy","text":"\u8d44\u6e90\u8c03\u5ea6\u5c42\u4e2d\u7684 Proxy \u7ec4\u4ef6\u8d1f\u8d23\u5bf9\u8ba1\u7b97\u8282\u70b9 CN \u8fdb\u884c\u5206\u7ec4\uff0c\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb\uff0c\u4ee5\u53ca\u5728 CN \u7ec4\u5185\u5b9e\u73b0\u7528\u6237\u8fde\u63a5\u7ea7\u522b\u7684\u8d1f\u8f7d\u5747\u8861\u3002Proxy \u8fd0\u884c\u65f6\u4ee5\u591a\u526f\u672c\u4e92\u4e3a\u5907\u4efd\u7684\u5f62\u5f0f\u4fdd\u8bc1\u9ad8\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/","title":"\u6df7\u5408\u8d1f\u8f7d HTAP","text":"MatrixOne \u662f\u4e00\u6b3e\u80fd\u591f\u652f\u6301 HTAP\uff08Hybrid Transaction Analytical Processing\uff09\u6df7\u5408\u8d1f\u8f7d\u5904\u7406\u7684\u6570\u636e\u5e93\uff0c\u65e8\u5728\u63d0\u4f9b\u6ee1\u8db3\u5355\u4e00\u6570\u636e\u5e93\u5185\u4e8b\u52a1\u5904\u7406\uff08TP\uff09\u548c\u5206\u6790\u5904\u7406\uff08AP\uff09\u6240\u6709\u9700\u6c42\u7684\u89e3\u51b3\u65b9\u6848\u3002\u51ed\u501f\u5176\u5b58\u50a8\u548c\u8ba1\u7b97\u4e8b\u52a1\u7684\u89e3\u8026\u67b6\u6784\uff0cMatrixOne \u80fd\u591f\u5728\u540c\u4e00\u6570\u636e\u5f15\u64ce\u4e2d\u540c\u65f6\u652f\u6301\u5728\u7ebf\u4ea4\u6613\u548c\u5b9e\u65f6\u7edf\u8ba1\u5206\u6790\uff0c\u540c\u65f6\u63d0\u4f9b\u9ad8\u6548\u7684\u8d44\u6e90\u9694\u79bb\u673a\u5236\u3002\u8fd9\u79cd\u8bbe\u8ba1\u5927\u5927\u4fdd\u7559\u4e86\u6570\u636e\u7684\u65b0\u9c9c\u5ea6\uff0c\u7701\u53bb\u4e86\u5728\u8bb8\u591a\u4e1a\u52a1\u573a\u666f\u4e2d\u6784\u5efa\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u7684\u6b65\u9aa4\uff0c\u4ece\u800c\u5e2e\u52a9\u5ba2\u6237\u5b9e\u73b0\u5176\u4e1a\u52a1\u4ef7\u503c\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_1","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u968f\u7740\u4f01\u4e1a\u4e1a\u52a1\u89c4\u6a21\u7684\u6269\u5927\uff0c\u6570\u636e\u91cf\u7684\u4e0d\u65ad\u589e\u957f\uff0c\u4ee5\u53ca\u4e1a\u52a1\u7cfb\u7edf\u7684\u65e5\u76ca\u590d\u6742\uff0c\u4f20\u7edf\u7684\u5728\u7ebf\u6570\u636e\u5e93\u4e0d\u5f97\u4e0d\u9762\u5bf9\u62c6\u5206\u7684\u95ee\u9898\u3002\u7136\u800c\uff0c\u62c6\u5206\u540e\u7684\u67b6\u6784\u5e76\u4e0d\u80fd\u6ee1\u8db3\u4e00\u4e9b\u9700\u8981\u5173\u8054\u7edf\u8ba1\u548c\u5b9e\u65f6\u5206\u6790\u7684\u9700\u6c42\u3002\u6b64\u65f6\uff0c\u7c7b\u4f3c\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u7684\u4ea7\u54c1\u5e94\u8fd0\u800c\u751f\u3002\u7136\u800c\uff0c\u7531\u4e8e\u5b9e\u65f6\u6570\u636e\u4ed3\u5e93\u7684\u67b6\u6784\u590d\u6742\uff0c\u6210\u672c\u9ad8\u6602\uff0c\u5e76\u975e\u6240\u6709\u7684\u4f01\u4e1a\u90fd\u80fd\u6784\u5efa\u4e00\u6574\u5957\u751f\u6001\u94fe\u8def\u3002MatrixOne \u7684 HTAP \u6a21\u5f0f\u5e94\u8fd0\u800c\u751f\uff0c\u5b83\u53ef\u4ee5\u4f7f\u7528\u4e00\u5957\u5f15\u64ce\u5728\u652f\u6301\u9ad8\u5e76\u53d1\u5728\u7ebf\u541e\u5410\u7684\u540c\u65f6\uff0c\u63d0\u4f9b\u6d77\u91cf\u6570\u636e\u7684\u5b9e\u65f6\u5728\u7ebf\u5206\u6790\u80fd\u529b\uff0c\u4e3a\u4f01\u4e1a\u63d0\u5347\u6548\u7387\u3001\u6301\u7eed\u521b\u65b0\u63d0\u4f9b\u4e86\u52a8\u529b\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_2","title":"\u529f\u80fd\u4f18\u52bf","text":"MatrixOne \u901a\u8fc7\u6a21\u5757\u5316\u7684\u5b58\u50a8\u3001\u8ba1\u7b97\u548c\u4e8b\u52a1\u67b6\u6784\uff0c\u591a\u7ea7\u5b58\u50a8\u4f53\u7cfb\uff0c\u4ee5\u53ca\u8d1f\u8f7d\u5904\u7406\u94fe\u8def\u9694\u79bb\u7684\u6a21\u5f0f\u6765\u5b9e\u73b0 HTAP\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_4","title":"\u5b58\u50a8\u3001\u8ba1\u7b97\u3001\u4e8b\u52a1\u6a21\u5757\u5316\u5206\u79bb","text":"MatrixOne \u7684\u6574\u4f53\u6280\u672f\u67b6\u6784\u91c7\u7528\u5b8c\u5168\u7684\u5b58\u50a8\u548c\u8ba1\u7b97\u5206\u79bb\u67b6\u6784\u3002\u901a\u8fc7\u6a21\u5757\u5316\u8bbe\u8ba1\uff0c\u5c06\u6570\u636e\u5e93\u7684\u8ba1\u7b97\u3001\u5b58\u50a8\u3001\u4e8b\u52a1\u5904\u7406\u5206\u79bb\u4e3a\u5355\u72ec\u7684\u6a21\u5757\uff0c\u4ece\u800c\u7ec4\u5efa\u51fa\u4e00\u5957\u5404\u7ec4\u4ef6\u90fd\u5177\u6709\u72ec\u7acb\u4f38\u7f29\u80fd\u529b\u7684\u6570\u636e\u5e93\u7cfb\u7edf\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff0cMatrixOne \u7531\u4e09\u4e2a\u72ec\u7acb\u5c42\u7ea7\u6784\u6210\uff1a
\u5982\u4e0a\u4e00\u7ae0\u8282\u4e2d\u56fe\u793a\u6240\u793a\uff0cMatrixOne \u7684\u5b58\u50a8\u4f53\u7cfb\u7531\u5168\u91cf\u6570\u636e\u5171\u4eab\u5b58\u50a8\u3001\u5c11\u91cf\u5171\u4eab\u65e5\u5fd7\u548c\u8ba1\u7b97\u8282\u70b9\u7684\u65e0\u72b6\u6001\u7f13\u5b58\u7ec4\u6210\u3002
\u7528\u6237\u8bf7\u6c42\u9996\u5148\u4f1a\u8fdb\u5165 MatrixOne \u96c6\u7fa4\u5e76\u901a\u8fc7 Proxy \u6a21\u5757\u3002Proxy \u662f\u7528\u4e8e\u5b9e\u73b0\u8ba1\u7b97\u8282\u70b9\u5206\u7ec4\u548c\u9694\u79bb\u7684\u6a21\u5757\u3002\u8be5\u6a21\u5757\u901a\u8fc7\u914d\u7f6e\u5c06\u8ba1\u7b97\u8282\u70b9 CN \u5206\u4e3a\u82e5\u5e72\u7ec4\uff0c\u5e76\u7528\u6807\u7b7e\u533a\u5206\u5404\u79cd\u79df\u6237\u6216\u8d1f\u8f7d\uff0c\u8ba9\u7528\u6237\u80fd\u591f\u6839\u636e\u4e0d\u540c\u7684\u4e1a\u52a1\u9700\u6c42\u8bbe\u5b9a\u4e0d\u540c\u7684 CN \u7ec4\u5904\u7406\u4e0d\u540c\u7684\u4e1a\u52a1\u3002
\u6709\u5173 Proxy \u5bf9 CN \u5206\u7ec4\u4f7f\u7528\u7684\u5177\u4f53\u64cd\u4f5c\uff0c\u53ef\u4ee5\u53c2\u8003\u4f7f\u7528 Proxy \u7ba1\u7406 CN \u7ec4\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#tpap","title":"TP/AP \u8d1f\u8f7d\u94fe\u8def\u9694\u79bb","text":"\u5728\u6267\u884c\u5c42\u9762\uff0cMatrixOne \u4f1a\u6839\u636e\u8bf7\u6c42\u7c7b\u578b\u5c06\u5176\u8def\u7531\u5230\u4e0d\u540c\u7684\u5904\u7406\u94fe\u8def\uff0c\u4ece\u800c\u5b9e\u73b0 OLTP \u548c OLAP \u7684\u9694\u79bb\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u6839\u636e\u8bfb\u5199\u8bf7\u6c42\u7684\u5904\u7406\u65b9\u5f0f\u6765\u8be6\u7ec6\u89e3\u91ca\u5982\u4f55\u5b9e\u73b0\u8d1f\u8f7d\u9694\u79bb\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_8","title":"\u5199\u8bf7\u6c42\u5904\u7406","text":"\u5982\u56fe\u6240\u793a\uff0c\u5904\u7406\u5199\u8bf7\u6c42\uff08INSERT/UPDATE/DELETE\uff09\u65f6\uff1a
CN \u8282\u70b9\u4f1a\u542f\u52a8\u4e00\u4e2a\u4e8b\u52a1\uff0c\u5e76\u68c0\u67e5\u5199\u5165\u8bf7\u6c42\u662f\u5426\u6709\u4e3b\u952e\u51b2\u7a81\u6216\u5176\u4ed6\u4e8b\u52a1\u76f8\u5173\u95ee\u9898\uff0c\u5982\u679c\u6709\uff0c\u5219\u76f4\u63a5\u5411\u7528\u6237\u8fd4\u56de\u9519\u8bef\u3002
\u63a5\u4e0b\u6765\uff0cCN \u4f1a\u6839\u636e\u5199\u8bf7\u6c42\u7684\u6570\u636e\u91cf\u5927\u5c0f\u6765\u51b3\u5b9a\u64cd\u4f5c\u7684\u94fe\u8def\u3002\u5982\u679c\u6570\u636e\u91cf\u6ca1\u6709\u8d85\u8fc7\u8bbe\u5b9a\u7684\u9608\u503c\uff08\u901a\u5e38\u4e3a 10MB\uff09\uff0c\u5219 CN \u8282\u70b9\u4f1a\u5c06\u6570\u636e\u53d1\u9001\u7ed9 TN \u8282\u70b9\uff0cTN \u8282\u70b9\u4f1a\u8fdb\u884c\u5199\u5199\u51b2\u7a81\u68c0\u6d4b\u548c\u4e8b\u52a1\u4ef2\u88c1\u7b49\u64cd\u4f5c\uff0c\u786e\u4fdd\u65e0\u8bef\u540e\uff0c\u5c06\u8fd9\u4e9b\u6570\u636e\u4ee5\u65e5\u5fd7\u5f62\u5f0f\u5199\u5165 LogService\uff0c\u5f62\u6210 Logtail\u3002
\u66f4\u65b0\u7684 Logtail \u5c06\u5373\u65f6\u63a8\u9001\u7ed9\u8ba2\u9605\u4e86 Logtail \u6570\u636e\u7684 CN \u8282\u70b9\uff0c\u4ee5\u4fbf\u67e5\u8be2\u3002\u5982\u679c\u6570\u636e\u91cf\u8d85\u8fc7\u9608\u503c\uff0c\u5219 CN \u8282\u70b9\u4f1a\u76f4\u63a5\u5c06\u6570\u636e\u5199\u5165\u5bf9\u8c61\u5b58\u50a8\uff0c\u5e76\u5c06\u63d0\u4ea4 commit \u4fe1\u606f\u53d1\u9001\u7ed9 TN\uff0cTN \u8282\u70b9\u4f1a\u8fdb\u884c\u5199\u5199\u51b2\u7a81\u68c0\u6d4b\u548c\u4e8b\u52a1\u4ef2\u88c1\u7b49\u64cd\u4f5c\uff0c\u5728\u786e\u8ba4\u65e0\u8bef\u540e\uff0c\u63d0\u4ea4\u4e8b\u52a1\u3002
\u4ece\u4e0a\u56fe\u53ef\u77e5\uff0c\u5c11\u91cf\u6570\u636e\u7684 OLTP \u7c7b\u578b\u5199\u5165\u8bf7\u6c42\u4f1a\u7ecf\u8fc7 CN \u81f3 TN \u518d\u81f3 LogService \u7684\u5904\u7406\u94fe\u8def\uff0c\u800c\u5927\u6570\u636e\u91cf\u7684\u5199\u5165\u8bf7\u6c42\uff0c\u5982 Load \u7b49\uff0c\u5219\u4f1a\u4e3b\u8981\u7ecf\u8fc7 CN \u81f3 S3\uff0c\u4ee5\u53ca\u5c11\u91cf\u7684 CN \u81f3 TN\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_9","title":"\u8bfb\u8bf7\u6c42\u5904\u7406","text":"\u5982\u56fe\u6240\u793a\uff0c\u5904\u7406\u8bfb\u8bf7\u6c42\u65f6\uff0cCN \u8282\u70b9\u4f1a\u9996\u5148\u67e5\u770b\u5df2\u8ba2\u9605\u7684 Logtail \u6570\u636e\uff0c\u5982\u679c\u6570\u636e\u76f4\u63a5\u547d\u4e2d Logtail\uff0c\u5219\u8bf4\u660e\u6570\u636e\u4f4d\u4e8e\u6700\u65b0\u7684\u4e00\u90e8\u5206\u5199\u5165\u6570\u636e\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56de\u3002\u5982\u679c\u6ca1\u6709\u547d\u4e2d Logtail\uff0cCN \u4f1a\u68c0\u67e5\u81ea\u5df1\u53ca\u5176\u4ed6\u53ef\u89c1 CN \u7684\u7f13\u5b58\uff0c\u5982\u679c\u547d\u4e2d\u7f13\u5b58\uff0c\u5c06\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c\u3002\u5982\u679c\u6ca1\u6709\u547d\u4e2d\u7f13\u5b58\uff0cCN \u4f1a\u901a\u8fc7\u5206\u6790\u6267\u884c\u8ba1\u5212\u5224\u65ad\u662f\u5426\u9700\u8981\u5927\u91cf\u8bfb\u53d6\u6570\u636e\uff0c\u5982\u679c\u8d85\u8fc7\u4e00\u5b9a\u7684\u9608\u503c\uff08\u5982 200 \u4e2a block size\uff09\u5219\u7531\u591a\u4e2a CN \u8282\u70b9\u5e76\u884c\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u8bfb\u53d6\uff0c\u5982\u679c\u672a\u8d85\u8fc7\u9608\u503c\u5219\u7531\u5355\u4e2a CN \u8282\u70b9\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u8bfb\u53d6\u3002
\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u65e0\u8bba\u662f OLTP \u8fd8\u662f OLAP \u7684\u8bfb\u8bf7\u6c42\uff0c\u90fd\u4f1a\u7ecf\u8fc7 CN \u81f3 S3 \u7684\u5904\u7406\u94fe\u8def\u3002\u901a\u8fc7 Proxy \u5bf9 CN \u8282\u70b9\u7684\u9694\u79bb\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5b9e\u73b0 CN \u7684\u9694\u79bb\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_10","title":"\u5e94\u7528\u573a\u666f","text":"\u65e0\u8bba\u5728\u91d1\u878d\u3001\u7535\u4fe1\u3001\u5236\u9020\u4e1a\u8fd8\u662f\u4e92\u8054\u7f51\u3001\u79d1\u6280\u7b49\u65b0\u5174\u884c\u4e1a\uff0cHTAP \u90fd\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\u3002
\u4f8b\u5982\uff0c\u5728\u91d1\u878d\u9886\u57df\uff0cHTAP \u6570\u636e\u5e93\u53ef\u4ee5\u6ee1\u8db3\u9ad8\u901f\u4ea4\u6613\u5904\u7406\u548c\u5b9e\u65f6\u98ce\u9669\u7ba1\u7406\u7684\u9700\u6c42\uff0c\u652f\u6301\u91d1\u878d\u4ea4\u6613\u7684\u9ad8\u541e\u5410\u91cf\u548c\u4f4e\u5ef6\u8fdf\u8981\u6c42\uff0c\u540c\u65f6\u63d0\u4f9b\u5b9e\u65f6\u6570\u636e\u5206\u6790\u529f\u80fd\uff0c\u4ee5\u652f\u6301\u51b3\u7b56\u5236\u5b9a\u548c\u98ce\u9669\u76d1\u63a7\u3002
\u5728\u7535\u4fe1\u884c\u4e1a\uff0cHTAP \u6570\u636e\u5e93\u53ef\u7528\u4e8e\u5b9e\u65f6\u8ba1\u8d39\u548c\u7f51\u7edc\u4f18\u5316\uff0c\u80fd\u5904\u7406\u5927\u91cf\u5b9e\u65f6\u6570\u636e\uff0c\u8ffd\u8e2a\u7528\u6237\u901a\u4fe1\u548c\u7f51\u7edc\u6d3b\u52a8\uff0c\u540c\u65f6\u652f\u6301\u5b9e\u65f6\u5206\u6790\u548c\u667a\u80fd\u51b3\u7b56\uff0c\u4ee5\u6539\u5584\u670d\u52a1\u8d28\u91cf\u3001\u7f51\u7edc\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002
\u5728\u7269\u8054\u7f51\u9886\u57df\uff0cHTAP \u6570\u636e\u5e93\u53ef\u7528\u4e8e\u8bbe\u5907\u7ba1\u7406\u548c\u5b9e\u65f6\u76d1\u63a7\uff0c\u80fd\u5904\u7406\u5927\u91cf\u4f20\u611f\u5668\u6570\u636e\u548c\u8bbe\u5907\u72b6\u6001\u4fe1\u606f\uff0c\u5e76\u63d0\u4f9b\u5b9e\u65f6\u8bbe\u5907\u76d1\u63a7\u548c\u7ba1\u7406\u529f\u80fd\uff0c\u8fd9\u5bf9\u4e8e\u7269\u8054\u7f51\u7cfb\u7edf\u7684\u5b9e\u65f6\u51b3\u7b56\u3001\u8fdc\u7a0b\u6545\u969c\u8bca\u65ad\u548c\u9884\u6d4b\u7ef4\u62a4\u5177\u6709\u91cd\u8981\u610f\u4e49\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_11","title":"\u91d1\u878d\u5b9e\u65f6\u98ce\u63a7\u7cfb\u7edf","text":"\u67d0\u94f6\u884c\u4f5c\u4e3a\u4e00\u5bb6\u9886\u5148\u7684\u57ce\u5e02\u5546\u4e1a\u94f6\u884c\uff0c\u5176\u4fe1\u7528\u5361\u4e1a\u52a1\u62e5\u6709\u4e00\u5957\u5b9e\u65f6\u98ce\u63a7\u7cfb\u7edf\uff0c\u8be5\u7cfb\u7edf\u4e3b\u8981\u8d1f\u8d23\u76d1\u63a7\u548c\u8bc4\u4f30\u4fe1\u7528\u5361\u4ea4\u6613\uff0c\u8bc6\u522b\u4ea4\u6613\u98ce\u9669\u5e76\u53ca\u65f6\u91c7\u53d6\u9650\u5236\u63aa\u65bd\u3002
\u4ee5\u4e0b\u8868\u683c\u5c55\u793a\u4e86\u8fd9\u5957\u7cfb\u7edf\u7684\u6838\u5fc3\u4e1a\u52a1\u9700\u6c42\u573a\u666f\u4ee5\u53ca MatrixOne \u7684 HTAP \u5982\u4f55\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\uff1a
\u6838\u5fc3\u4e1a\u52a1\u9700\u6c42 \u4e1a\u52a1\u7c7b\u578b MatrixOne \u7684 HTAP \u80fd\u529b \u5b9e\u65f6\u83b7\u53d6\u4ea4\u6613\u6570\u636e \u5feb\u901f\u4e14\u4f4e\u5ef6\u8fdf\u7684\u6570\u636e\u5199\u5165 MatrixOne \u80fd\u591f\u9ad8\u6548\u5e76\u53d1\u5730\u5199\u5165\u6d77\u91cf\u6570\u636e\uff0c\u901a\u8fc7\u6269\u5c55\u591a CN \u8282\u70b9\u548c\u5bf9\u8c61\u5b58\u50a8\u6765\u8fdb\u4e00\u6b65\u63d0\u5347\u6027\u80fd\u3002 \u79bb\u7ebf\u8ba1\u7b97\u5927\u91cf\u6570\u636e\u6307\u6807\uff0c\u5206\u6790\u7528\u6237\u884c\u4e3a\u53ca\u98ce\u9669\u56e0\u7d20 \u590d\u6742\u7684\u5206\u6790\u67e5\u8be2\uff0c\u9700\u8981\u5904\u7406 TB \u7ea7\u522b\u7684\u6570\u636e MatrixOne \u5177\u5907\u5904\u7406\u6d77\u91cf\u661f\u578b\u548c\u96ea\u82b1\u578b\u6570\u636e\u5206\u6790\u7684\u80fd\u529b\uff0c\u901a\u8fc7\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u53ef\u4ee5\u7ebf\u6027\u63d0\u5347\u5206\u6790\u80fd\u529b\u3002 \u5b9e\u65f6\u5206\u6790\u4ea4\u6613\u6570\u636e\uff0c\u8ba1\u7b97\u98ce\u9669\u6307\u6807 \u5178\u578b\u7684 AP \u4e1a\u52a1\uff0c\u9700\u8981\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u8ba1\u7b97\u6570\u636e\u7ed3\u679c MatrixOne \u7684\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\u80fd\u591f\u6ee1\u8db3\u5927\u89c4\u6a21\u6570\u636e\u62a5\u8868\u7684\u8ba1\u7b97\u9700\u6c42\uff0c\u540c\u65f6\u63d0\u4f9b\u5feb\u901f\u7684\u6570\u636e\u8bfb\u53d6\u6027\u80fd\u3002 \u9762\u5bf9\u9891\u7e41\u4e14\u5267\u70c8\u7684\u4e1a\u52a1\u6ce2\u52a8 \u9700\u8981\u7075\u6d3b\u7684\u6269\u5c55\u6027\u67b6\u6784\u6765\u5e94\u5bf9\u5927\u7684\u8d1f\u8f7d\u6ce2\u52a8 MatrixOne \u7684\u5b58\u50a8\u548c\u8ba1\u7b97\u5206\u79bb\u67b6\u6784\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u80fd\u5728\u4e1a\u52a1\u6ce2\u52a8\u65f6\u5feb\u901f\u6269\u7f29\u5bb9\u4ee5\u5339\u914d\u4e1a\u52a1\u9700\u6c42\u3002"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_12","title":"\u7535\u4fe1\u4e1a\u52a1\u7ba1\u7406\u7cfb\u7edf","text":"\u67d0\u4f01\u4e1a\u662f\u4e00\u5bb6\u7701\u7ea7\u7535\u4fe1\u8fd0\u8425\u5546\uff0c\u670d\u52a1\u7528\u6237\u6570\u91cf\u8fbe\u6570\u5343\u4e07\uff0c\u4e3b\u8981\u63d0\u4f9b\u7535\u8bdd\u901a\u4fe1\u670d\u52a1\uff0c\u9700\u8981\u540c\u65f6\u652f\u6491\u6d77\u91cf\u7528\u6237\u7684\u4f7f\u7528\u548c\u7edf\u8ba1\u5206\u6790\u3002
\u4ee5\u4e0b\u8868\u683c\u5c55\u793a\u4e86\u8fd9\u5957\u7cfb\u7edf\u7684\u6838\u5fc3\u4e1a\u52a1\u573a\u666f\u4ee5\u53ca MatrixOne \u7684 HTAP \u5982\u4f55\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\uff1a
\u6838\u5fc3\u4e1a\u52a1\u573a\u666f \u4e1a\u52a1\u7c7b\u578b MatrixOne \u7684 HTAP \u89e3\u51b3\u65b9\u6848 \u67e5\u8be2\u7528\u6237\u8bdd\u8d39\u7f34\u5b58\u60c5\u51b5\u5e76\u5b9e\u65f6\u505c\u673a \u9ad8\u5e76\u53d1\u7684\u77ed\u5c0f\u4e8b\u52a1\uff0c\u9700\u8981\u4f4e\u5ef6\u8fdf MatrixOne \u5177\u5907 OLTP \u80fd\u529b\uff0c\u591a CN \u8282\u70b9\u5206\u5e03\u5f0f\u67b6\u6784\u53ef\u4ee5\u786e\u4fdd\u5728\u9ad8\u5e76\u53d1\u4e0b\u7684\u7a33\u5b9a\u6027\u80fd\uff0c\u540c\u65f6\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u3002 \u7528\u6237\u5145\u503c\u540e\u5b9e\u65f6\u66f4\u65b0\u8d26\u6237\u4f59\u989d \u9ad8\u5e76\u53d1\u7684\u77ed\u5c0f\u4e8b\u52a1\uff0c\u9700\u8981\u4f4e\u5ef6\u8fdf MatrixOne \u7684 TP \u80fd\u529b\u53ef\u4ee5\u6ee1\u8db3\u9ad8\u5e76\u53d1\u4e14\u4f4e\u5ef6\u8fdf\u7684 TP \u9700\u6c42\uff0c\u540c\u65f6\u5206\u5e03\u5f0f\u591a CN \u8282\u70b9\u67b6\u6784\u63d0\u4f9b\u8d1f\u8f7d\u5747\u8861\u7279\u6027\u3002 \u6279\u91cf\u8c03\u6574\u7528\u6237\u5957\u9910\u5e76\u5728\u4e0b\u6708\u751f\u6548 \u8d85\u5927\u4e8b\u52a1\uff0c\u9700\u8981\u9ad8\u6027\u80fd MatrixOne \u53ef\u76f4\u63a5\u5199\u5165 S3\uff0c\u907f\u514d\u4e86 Logservice \u5728\u9ad8\u5e76\u53d1\u4e0b\u7684\u4e89\u7528\uff0c\u4ece\u800c\u5b9e\u73b0\u5feb\u901f\u6279\u91cf\u7684\u6570\u636e\u5199\u5165\u3002 \u5bf9\u7528\u6237\u6570\u636e\u8fdb\u884c\u65e5\u3001\u5468\u3001\u6708\u3001\u5b63\u5ea6\u548c\u5e74\u5ea6\u7edf\u8ba1 \u5178\u578b\u7684 AP \u4e1a\u52a1\uff0c\u9700\u8981\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u8ba1\u7b97\u6570\u636e\u7ed3\u679c MatrixOne \u7684\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\u80fd\u6ee1\u8db3\u5927\u89c4\u6a21\u6570\u636e\u62a5\u8868\u7684\u8ba1\u7b97\u9700\u6c42\uff0c\u540c\u65f6\u63d0\u4f9b\u5feb\u901f\u7684\u6570\u636e\u8bfb\u53d6\u6027\u80fd\u3002"},{"location":"MatrixOne/Overview/feature/key-feature-htap/#_13","title":"\u5236\u9020\u751f\u4ea7\u6267\u884c\u7cfb\u7edf","text":"\u67d0\u4f01\u4e1a\u662f\u4e00\u5bb6\u7535\u5b50\u4ea7\u54c1\u5236\u9020\u5546\uff0c\u62e5\u6709\u6570\u5341\u6761\u5404\u7c7b\u6d88\u8d39\u7535\u5b50\u4ea7\u54c1\u7684\u751f\u4ea7\u7ebf\u3002\u5176\u751f\u4ea7\u5236\u9020\u6267\u884c\uff08MES\uff09\u7cfb\u7edf\u9700\u8981\u5bf9\u751f\u4ea7\u7ebf\u4e0a\u7684\u4eba\u5458\u3001\u673a\u5668\u3001\u7269\u6599\u548c\u6d41\u7a0b\u8fdb\u884c\u7ba1\u7406\uff0c\u540c\u65f6\u5b9a\u671f\u5206\u6790\u751f\u4ea7\u6548\u7387\u548c\u80fd\u8017\u7b49\u95ee\u9898\u3002
\u4ee5\u4e0b\u8868\u683c\u5c55\u793a\u4e86\u8fd9\u5957\u7cfb\u7edf\u7684\u6838\u5fc3\u4e1a\u52a1\u573a\u666f\u4ee5\u53ca MatrixOne \u7684 HTAP \u5982\u4f55\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\uff1a
\u6838\u5fc3\u4e1a\u52a1\u573a\u666f \u4e1a\u52a1\u7c7b\u578b MatrixOne \u7684 HTAP \u89e3\u51b3\u65b9\u6848 \u7ba1\u7406\u751f\u4ea7\u3001\u4ed3\u50a8\u548c\u8d28\u91cf \u9ad8\u5e76\u53d1\u77ed\u5c0f\u4e8b\u52a1\uff0c\u9700\u8981\u4f4e\u5ef6\u8fdf MatrixOne \u5177\u5907 OLTP \u80fd\u529b\uff0c\u5206\u5e03\u5f0f\u591a CN \u8282\u70b9\u53ef\u4ee5\u786e\u4fdd\u5728\u9ad8\u5e76\u53d1\u4e0b\u7684\u7a33\u5b9a\u6027\u80fd\uff0c\u540c\u65f6\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861\u3002 \u5b9e\u65f6\u91c7\u96c6\u5927\u91cf\u673a\u5668\u751f\u4ea7\u6570\u636e \u9ad8\u5e76\u53d1\u591a\u6570\u636e\u7c7b\u578b\u7684\u6570\u636e\u5199\u5165 MatrixOne \u80fd\u591f\u9ad8\u6548\u5e76\u53d1\u5730\u5199\u5165\u6d77\u91cf\u6570\u636e\uff0c\u901a\u8fc7\u6269\u5c55\u591a CN \u8282\u70b9\u548c\u5bf9\u8c61\u5b58\u50a8\u6765\u8fdb\u4e00\u6b65\u63d0\u5347\u6027\u80fd\u3002 \u5206\u6790\u6d77\u91cf\u5386\u53f2\u751f\u4ea7\u8bb0\u5f55\u7684\u6eaf\u6e90 \u9700\u8981\u5bf9\u6d77\u91cf\u79bb\u7ebf\u6570\u636e\u8fdb\u884c\u591a\u7ef4\u67e5\u8be2\u5206\u6790 MatrixOne \u5177\u5907\u5904\u7406\u6d77\u91cf\u661f\u578b\u548c\u96ea\u82b1\u578b\u6570\u636e\u5206\u6790\u7684\u80fd\u529b\uff0c\u901a\u8fc7\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u53ef\u4ee5\u7ebf\u6027\u63d0\u5347\u5206\u6790\u80fd\u529b\u3002 \u5b9e\u65f6\u67e5\u8be2\u751f\u4ea7\u6548\u7387\u3001\u80fd\u8017\u548c\u8bbe\u5907\u72b6\u6001 \u6781\u5feb\u7684 Ad-hoc \u4ea4\u4e92\u5f0f\u5206\u6790 MatrixOne \u652f\u6301\u5404\u79cd\u590d\u6742 SQL \u67e5\u8be2\uff0c\u901a\u8fc7\u591a CN \u8282\u70b9\u5e76\u884c\u8ba1\u7b97\u53ef\u4ee5\u5b9e\u73b0\u5b9e\u65f6\u5206\u6790\u3002"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/","title":"\u591a\u79df\u6237","text":"MatrixOne \u7684\u8bbe\u8ba1\u91c7\u7528\u4e86\u5355\u4e00\u96c6\u7fa4\u591a\u79df\u6237\u7684\u65b9\u5f0f\u3002\u5728\u8fd9\u4e2a\u8bbe\u8ba1\u4e2d\uff0c\u79df\u6237\uff08Account\uff09\u662f\u4e00\u4e2a\u903b\u8f91\u6982\u5ff5\uff0c\u4f5c\u4e3a\u8d44\u6e90\u5206\u914d\u548c\u6570\u636e\u5e93\u7ba1\u7406\u7684\u5355\u4f4d\u3002MatrixOne \u7684\u591a\u79df\u6237\u6a21\u5f0f\u80fd\u591f\u4e3a\u4e0d\u540c\u7684\u79df\u6237\u63d0\u4f9b\u72ec\u7acb\u7684\u6570\u636e\u5e93\u5b9e\u4f8b\uff0c\u5e76\u91c7\u7528\u903b\u8f91\u9694\u79bb\u7684\u65b9\u5f0f\u786e\u4fdd\u5404\u79df\u6237\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u72ec\u7acb\u6027\uff0c\u6709\u6548\u9632\u6b62\u6570\u636e\u6cc4\u9732\u548c\u7be1\u6539\u7684\u98ce\u9669\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_2","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u5728\u4f01\u4e1a\u7684\u4e1a\u52a1\u53d1\u5c55\u5230\u4e00\u5b9a\u89c4\u6a21\uff0c\u6570\u636e\u91cf\u4e0d\u65ad\u589e\u957f\u7684\u540c\u65f6\uff0c\u4e1a\u52a1\u90e8\u95e8\u6216\u9879\u76ee\u7ec4\u589e\u52a0\uff0c\u4f01\u4e1a\u53ef\u4ee5\u6839\u636e\u5404\u81ea\u7684\u4e1a\u52a1\u9700\u6c42\u548c\u89c4\u6a21\uff0c\u8fdb\u884c\u7075\u6d3b\u7684\u79df\u6237\u7ba1\u7406\uff0c\u6ee1\u8db3\u4e0d\u540c\u7684\u4e1a\u52a1\u90e8\u95e8\u6216\u9879\u76ee\u7ec4\u7684\u72ec\u7acb\u6027\u8981\u6c42\u3002\u5728 MatrixOne \u7684\u591a\u79df\u6237\u6a21\u5f0f\u4e0b\uff0c\u4f01\u4e1a\u53ef\u4ee5\u8f7b\u677e\u7ba1\u7406\u5404\u79df\u6237\u7684\u6570\u636e\u8d44\u6e90\uff0c\u4ece\u800c\u4f7f\u5f97\u6570\u636e\u5206\u6790\u3001\u62a5\u544a\u7b49\u4e1a\u52a1\u6d41\u7a0b\u66f4\u52a0\u6d41\u7545\u548c\u51c6\u786e\u3002\u540c\u65f6\uff0c\u8fd9\u79cd\u65b9\u5f0f\u8fd8\u6709\u52a9\u4e8e\u4f01\u4e1a\u63d0\u9ad8\u4e1a\u52a1\u6548\u7387\uff0c\u964d\u4f4e\u7ba1\u7406\u6210\u672c\uff0c\u5b9e\u73b0\u4f01\u4e1a\u8d44\u6e90\u7684\u6700\u5927\u5316\u5229\u7528\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_3","title":"\u529f\u80fd\u4f18\u52bf","text":"\u964d\u4f4e\u8fd0\u8425\u6210\u672c\uff1a\u591a\u4e2a\u7528\u6237\u53ef\u4ee5\u5171\u4eab\u4e00\u4e2a\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u907f\u514d\u4e86\u591a\u5957\u96c6\u7fa4\u7684\u90e8\u7f72\u548c\u7ba1\u7406\uff0c\u4ece\u800c\u51cf\u5c11\u786c\u4ef6\u548c\u8f6f\u4ef6\u7684\u6295\u5165\u6210\u672c\u3002
\u8d44\u6e90\u53ca\u8d1f\u8f7d\u9694\u79bb\uff1a\u591a\u79df\u6237\u6a21\u5f0f\u63d0\u9ad8\u4e86\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u53ef\u9760\u6027\uff0c\u4e0d\u540c\u7528\u6237\u7684\u6570\u636e\u548c\u8d1f\u8f7d\u76f8\u4e92\u9694\u79bb\uff0c\u5373\u4f7f\u67d0\u4e2a\u7528\u6237\u7684\u6570\u636e\u51fa\u73b0\u95ee\u9898\u6216\u8d1f\u8f7d\u8fc7\u9ad8\uff0c\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u7528\u6237\u3002
\u52a8\u6001\u8d44\u6e90\u5206\u914d\uff1a\u591a\u79df\u6237\u8fd8\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u53ef\u6269\u5c55\u6027\uff0c\u6bcf\u4e2a\u79df\u6237\u53ef\u4ee5\u72ec\u7acb\u6269\u5c55\u6216\u6536\u7f29\u81ea\u5df1\u7684\u8d44\u6e90\uff0c\u9762\u5bf9\u4e0d\u540c\u7ea7\u522b\u7684\u8d1f\u8f7d\u53ef\u4ee5\u5b9e\u73b0\u8d44\u6e90\u4f7f\u7528\u7684\u6700\u5927\u5316\u3002
\u79df\u6237\u7edf\u4e00\u7ba1\u7406\uff1a\u867d\u7136\u6bcf\u4e2a\u79df\u6237\u4e4b\u95f4\u662f\u9694\u79bb\u4e14\u72ec\u7acb\u8fd0\u884c\u7684\uff0c\u4f46\u7ba1\u7406\u4eba\u5458\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u79df\u6237\u5bf9\u5176\u4ed6\u79df\u6237\u8fdb\u884c\u7edf\u4e00\u7684\u7ba1\u7406\uff0c\u6bd4\u5982\u5feb\u901f\u521b\u5efa\u65b0\u79df\u6237\uff0c\u6279\u91cf\u5220\u9664\u8001\u79df\u6237\u7b49\u3002
\u79df\u6237\u6570\u636e\u5171\u4eab\uff1a\u5728\u67d0\u4e9b\u8054\u90a6\u7edf\u8ba1\u67e5\u8be2\u7684\u573a\u666f\u4e0b\uff0c\u79df\u6237\u4e4b\u95f4\u9700\u8981\u8fdb\u884c\u6570\u636e\u5171\u4eab\u3002MatrixOne \u63d0\u4f9b\u5b8c\u6574\u7684\u79df\u6237\u6570\u636e\u5206\u4eab\u53ca\u8ba2\u9605\u7684\u673a\u5236\uff0c\u6ee1\u8db3\u66f4\u7075\u6d3b\u7684\u4e1a\u52a1\u5206\u6790\u9700\u6c42\u3002
\u8de8\u5730\u57df\u90e8\u7f72\uff1a\u5728\u4e00\u4e9b\u4e1a\u52a1\u8de8\u5f88\u591a\u5730\u57df\u7684\u573a\u666f\u4e0b\uff0c\u79df\u6237\u9700\u8981\u4e0e\u5730\u57df\u8fdb\u884c\u5173\u8054\uff0c\u63d0\u4f9b\u5c31\u8fd1\u7684\u670d\u52a1\u3002MatrixOne \u652f\u6301\u540c\u4e00\u4e2a\u96c6\u7fa4\u4e0b\u4e0d\u540c\u7684\u79df\u6237\u5206\u5e03\u5728\u4e0d\u540c\u7684\u5730\u57df\u4e0a\uff0c\u5c31\u8fd1\u5bf9\u4e1a\u52a1\u8fdb\u884c\u670d\u52a1\u3002
MatrixOne \u7684\u591a\u79df\u6237\u7cfb\u7edf\u5305\u542b\u4e24\u79cd\u7c7b\u578b\u4e0d\u540c\u7684\u79df\u6237\uff1a\u7cfb\u7edf\uff08sys\uff09\u79df\u6237\u548c\u666e\u901a\u79df\u6237\u3002\u7cfb\u7edf\u79df\u6237\u662f\u7531 MatrixOne \u96c6\u7fa4\u5185\u7f6e\u7684\uff0c\u96c6\u7fa4\u542f\u52a8\u540e\u7cfb\u7edf\u4f1a\u9ed8\u8ba4\u767b\u5f55\u8be5\u79df\u6237\u3002\u8be5\u79df\u6237\u7684\u4e3b\u8981\u804c\u8d23\u5305\u62ec\uff1a
\u76f8\u6bd4\u4e4b\u4e0b\uff0c\u666e\u901a\u79df\u6237\u5219\u662f\u7531\u7cfb\u7edf\u79df\u6237\u521b\u5efa\u7684\u3002\u5728\u4f7f\u7528\u65f6\uff0c\u666e\u901a\u79df\u6237\u53ef\u4ee5\u88ab\u89c6\u4e3a\u4e00\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\uff0c\u9700\u8981\u6307\u5b9a\u79df\u6237\u540d\u79f0\u624d\u80fd\u8fde\u63a5\u3002\u666e\u901a\u79df\u6237\u5177\u5907\u5982\u4e0b\u7279\u6027\uff1a
MatrixOne \u7684\u5206\u5e03\u5f0f\u96c6\u7fa4\u91c7\u7528 Proxy \u6a21\u5757\u548c CN \u8d44\u6e90\u7ec4\u6280\u672f\u67b6\u6784\u5b9e\u73b0\u4e86\u591a\u79df\u6237\u8d44\u6e90\u9694\u79bb\u3002
\u5f53\u7528\u6237\u8fde\u63a5\u65f6\uff0c\u8fde\u63a5\u4f1a\u7ecf\u8fc7 Proxy \u6a21\u5757\uff0cProxy \u4f1a\u6839\u636e CN \u7684\u79df\u6237\u6807\u7b7e\u4fe1\u606f\u5c06\u8fde\u63a5\u8f6c\u53d1\u5230\u5bf9\u5e94 CN \u8d44\u6e90\u7ec4\u4e0a\u7684\u67d0\u4e2a CN \u4e0a\uff0c\u6839\u636e\u8d1f\u8f7d\u5747\u8861\u7684\u539f\u5219\u9009\u62e9\u8d1f\u8f7d\u6700\u8f7b\u7684 CN\u3002\u5728 MatrixOne \u96c6\u7fa4\u67b6\u6784\u4e2d\uff0cCN \u662f\u4ee5\u5bb9\u5668\u5316\u90e8\u7f72\u7684\uff0c\u56e0\u6b64 CN \u4e4b\u95f4\u5177\u6709\u9694\u79bb\u6027\u3002\u4e00\u4e2a\u79df\u6237\u4f7f\u7528\u7684 CN \u8d44\u6e90\u7ec4\u662f\u4e00\u7ec4\u6253\u4e0a\u8be5\u79df\u6237\u6807\u7b7e\u7684 CN\u3002\u5982\u679c\u8d44\u6e90\u4e0d\u8db3\uff0c\u9700\u8981\u8fdb\u884c\u6269\u5c55\uff0c\u53ef\u4ee5\u901a\u8fc7\u6c34\u5e73\u6269\u5c55\u8be5 CN \u8d44\u6e90\u7ec4\u6765\u6ee1\u8db3\u9700\u6c42\uff0c\u800c\u4e0d\u4f1a\u62a2\u5360\u5176\u4ed6 CN \u8d44\u6e90\u7ec4\u7684\u8d44\u6e90\u3002
\u8be5\u67b6\u6784\u56fe\u5982\u4e0b\u6240\u793a\uff1a
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_6","title":"\u5e94\u7528\u573a\u666f","text":"MatrixOne \u7684\u591a\u79df\u6237\u80fd\u529b\u53ef\u5728\u4ee5\u4e0b\u591a\u4e2a\u5e94\u7528\u573a\u666f\u4e2d\u4f53\u73b0\u4f18\u52bf\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#saas","title":"\u591a\u79df\u6237 SaaS \u5e94\u7528","text":"\u5728\u4e3a\u5927\u91cf\u4f01\u4e1a\u5ba2\u6237\u63d0\u4f9b\u670d\u52a1\u7684 SaaS \u5e94\u7528\u4e2d\uff0c\u591a\u79df\u6237\u6a21\u578b\u8bbe\u8ba1\u662f\u975e\u5e38\u5173\u952e\u7684\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_7","title":"\u4f20\u7edf\u67b6\u6784","text":"\u4f20\u7edf\u7684\u591a\u79df\u6237\u67b6\u6784\u5728\u6570\u636e\u5e93\u5c42\u9762\u4e3a\u6bcf\u4e2a\u79df\u6237\u5b58\u50a8\u548c\u7ba1\u7406\u6570\u636e\u3002\u901a\u5e38\u6709\u591a\u79cd\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5982\u5171\u4eab\u6570\u636e\u5e93\u6a21\u5f0f\uff08\u6bcf\u4e2a\u79df\u6237\u5171\u4eab\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u4f46\u62e5\u6709\u81ea\u5df1\u7684\u6570\u636e\u8868/\u5217\uff09\u6216\u72ec\u7acb\u6570\u636e\u5e93\u6a21\u5f0f\uff08\u6bcf\u4e2a\u79df\u6237\u62e5\u6709\u81ea\u5df1\u7684\u6570\u636e\u5e93\uff09\u3002
\u8fd9\u4e24\u79cd\u4f20\u7edf\u6a21\u5f0f\u90fd\u5b58\u5728\u4e00\u5b9a\u6311\u6218\uff1a
MatrixOne \u7684\u591a\u79df\u6237\u80fd\u529b\u5e26\u6765\u4e86\u5168\u65b0\u7684\u67b6\u6784\u65b9\u5f0f\u3002\u79df\u6237\u4ecd\u7136\u5171\u4eab\u4e00\u4e2a MatrixOne \u96c6\u7fa4\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u79df\u6237\u8fdb\u884c\u7edf\u4e00\u7684\u79df\u6237\u8fd0\u7ef4\u548c\u7ba1\u7406\u3002\u53e6\u5916\uff0c\u901a\u8fc7\u81ea\u5e26\u7684\u591a\u79df\u6237\u80fd\u529b\u5b9e\u73b0\u6570\u636e\u53ca\u8d44\u6e90\u7684\u9694\u79bb\uff0c\u540c\u65f6\u6bcf\u4e2a\u79df\u6237\u53ef\u4ee5\u72ec\u7acb\u8fdb\u884c\u8d44\u6e90\u6269\u7f29\u5bb9\uff0c\u8fdb\u4e00\u6b65\u964d\u4f4e\u8fd0\u7ef4\u96be\u5ea6\u3002\u8fd9\u79cd\u65b9\u5f0f\u4e0d\u4ec5\u6ee1\u8db3\u5bf9\u9694\u79bb\u6027\u7684\u9700\u6c42\uff0c\u8fd8\u80fd\u6ee1\u8db3\u4f4e\u8d44\u6e90\u548c\u8fd0\u7ef4\u6210\u672c\u7684\u9700\u6c42\u3002
\u591a\u79df\u6237\u6a21\u5f0f \u6570\u636e\u9694\u79bb\u7a0b\u5ea6 \u8d44\u6e90\u6210\u672c \u8d44\u6e90\u9694\u79bb\u7a0b\u5ea6 \u8fd0\u7ef4\u590d\u6742\u5ea6 \u79df\u6237\u5171\u4eab\u6570\u636e\u5e93\u6a21\u5f0f \u4f4e \u4f4e \u4f4e \u4f4e \u79df\u6237\u72ec\u7acb\u6570\u636e\u5e93\u6a21\u5f0f \u9ad8 \u9ad8 \u9ad8 \u9ad8 MatrixOne \u6a21\u5f0f \u9ad8 \u4f4e \u9ad8 \u4f4e"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_8","title":"\u5fae\u670d\u52a1\u5e94\u7528\u67b6\u6784","text":"\u5fae\u670d\u52a1\u5e94\u7528\u67b6\u6784\u662f\u4e00\u79cd\u901a\u8fc7\u5f00\u53d1\u4e00\u7cfb\u5217\u5c0f\u578b\u670d\u52a1\u6765\u5b9e\u73b0\u4e00\u4e2a\u5e94\u7528\u7684\u8f6f\u4ef6\u67b6\u6784\u6a21\u5f0f\u3002\u6bcf\u4e2a\u5c0f\u578b\u670d\u52a1\u901a\u5e38\u5728\u81ea\u5df1\u7684\u8fdb\u7a0b\u4e2d\u8fd0\u884c\uff0c\u5e76\u901a\u8fc7\u8f7b\u91cf\u7ea7\u7684 HTTP API \u8fdb\u884c\u901a\u8baf\u3002\u8fd9\u4e9b\u670d\u52a1\u901a\u5e38\u4ee5\u4e1a\u52a1\u6a21\u5757\u4e3a\u754c\u9650\uff0c\u53ef\u4ee5\u5355\u72ec\u5f00\u53d1\u90e8\u7f72\uff0c\u5e76\u4f7f\u7528\u81ea\u52a8\u5316\u7684\u90e8\u7f72\u5de5\u5177\u8fdb\u884c\u53d1\u5e03\u3002\u5fae\u670d\u52a1\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f01\u4e1a\u66f4\u5feb\u5730\u63a8\u51fa\u65b0\u4ea7\u54c1\u548c\u670d\u52a1\uff0c\u4f7f\u5f97\u5f00\u53d1\u56e2\u961f\u4e0e\u4e1a\u52a1\u76ee\u6807\u4fdd\u6301\u4e00\u81f4\u3002
\u4e0e SaaS \u5e94\u7528\u4e0d\u540c\uff0c\u5fae\u670d\u52a1\u5e94\u7528\u540c\u6837\u4f1a\u9762\u4e34\u6570\u636e\u5e93\u5171\u4eab\u6216\u72ec\u7acb\u7684\u95ee\u9898\u3002\u901a\u5e38\u5efa\u8bae\u4e3a\u6bcf\u4e2a\u5fae\u670d\u52a1\u51c6\u5907\u4e00\u4e2a\u5355\u72ec\u7684\u6570\u636e\u5e93\uff0c\u8fd9\u79cd\u6a21\u5f0f\u66f4\u9002\u5408\u5fae\u670d\u52a1\u67b6\u6784\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u670d\u52a1\u90fd\u662f\u72ec\u7acb\u5f00\u53d1\u3001\u90e8\u7f72\u548c\u6269\u5c55\u7684\u3002\u5f53\u9700\u8981\u5347\u7ea7\u6216\u66f4\u6539\u6570\u636e\u67b6\u6784\u65f6\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u670d\u52a1\u3002\u5f53\u9700\u8981\u5bf9\u67d0\u4e2a\u670d\u52a1\u8fdb\u884c\u6269\u5c55\u65f6\uff0c\u4e5f\u53ef\u4ee5\u5bf9\u8be5\u670d\u52a1\u8fdb\u884c\u5c40\u90e8\u6269\u5bb9\u3002\u6b64\u5916\uff0c\u5982\u679c\u67d0\u4e9b\u670d\u52a1\u9700\u8981\u7279\u6b8a\u7684\u6570\u636e\u5e93\u80fd\u529b\uff0c\u5982 Elastic Search \u6216\u5411\u91cf\u641c\u7d22\u7b49\uff0c\u8fd9\u79cd\u6a21\u5f0f\u4e5f\u63d0\u4f9b\u4e86\u66f4\u7075\u6d3b\u7684\u53ef\u80fd\u6027\u3002
\u7136\u800c\uff0c\u5fae\u670d\u52a1\u6700\u7ec8\u670d\u52a1\u4e8e\u540c\u4e00\u4e2a\u4e1a\u52a1\uff0c\u4e0d\u540c\u670d\u52a1\u4e4b\u95f4\u5fc5\u7136\u9700\u8981\u5171\u4eab\u6570\u636e\uff0c\u56e0\u6b64\u4e5f\u4f1a\u9047\u5230\u4e0e SaaS \u5e94\u7528\u591a\u79df\u6237\u76f8\u540c\u7684\u56f0\u5883\u3002
MatrixOne \u63d0\u4f9b\u7684\u591a\u79df\u6237\u80fd\u529b\u53ef\u4ee5\u5f88\u597d\u5730\u5e73\u8861\u8fd9\u4e24\u4e2a\u77db\u76fe\u70b9\uff0c\u65e2\u53ef\u4ee5\u4fdd\u8bc1\u6bcf\u4e2a\u5fae\u670d\u52a1\u7684\u6570\u636e\u548c\u8d44\u6e90\u6269\u5c55\u72ec\u7acb\u6027\uff0c\u53c8\u53ef\u4ee5\u4fdd\u6301\u4e00\u5b9a\u7684\u5171\u4eab\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_9","title":"\u96c6\u56e2\u5b50\u516c\u53f8/\u4e1a\u52a1\u90e8\u95e8","text":"\u8bb8\u591a\u96c6\u56e2\u516c\u53f8\u91c7\u7528\u533a\u57df\u5b50\u516c\u53f8\u6216\u4e1a\u52a1\u90e8\u95e8\u6765\u5206\u79bb\u4e1a\u52a1\uff0c\u8fd9\u4e9b\u5b50\u516c\u53f8\u548c\u4e1a\u52a1\u90e8\u95e8\u901a\u5e38\u90fd\u662f\u72ec\u7acb\u8fd0\u4f5c\u7684\uff0c\u62e5\u6709\u5b8c\u6574\u7684\u751f\u4ea7\u3001\u9500\u552e\u548c\u6280\u672f\u652f\u6301\u56e2\u961f\uff0c\u8fd8\u4f1a\u4f7f\u7528\u81ea\u5df1\u7684 IT \u7cfb\u7edf\u3002\u7136\u800c\uff0c\u96c6\u56e2\u516c\u53f8\u9700\u8981\u5168\u9762\u638c\u63e1\u5b50\u516c\u53f8\u7684\u4e1a\u52a1\u72b6\u51b5\uff0c\u56e0\u6b64\u9700\u8981\u5b50\u516c\u53f8\u5b9a\u671f\u4e0a\u62a5\u5927\u91cf\u4e1a\u52a1\u6570\u636e\u3002
\u8fd9\u79cd IT \u67b6\u6784\u5728\u6570\u636e\u5e93\u8bbe\u8ba1\u65b9\u9762\u9762\u4e34\u4e0e\u524d\u4e24\u79cd\u573a\u666f\u5b8c\u5168\u76f8\u540c\u7684\u95ee\u9898\uff0c\u5373\u5171\u4eab\u548c\u9694\u79bb\u4e4b\u95f4\u9700\u8981\u6743\u8861\u3002\u6b64\u5916\uff0c\u5728\u8fd9\u79cd\u573a\u666f\u4e2d\u8fd8\u9700\u8981\u8003\u8651\u5730\u7406\u4f4d\u7f6e\u56e0\u7d20\uff0c\u5b50\u516c\u53f8\u901a\u5e38\u6709\u81ea\u5df1\u7684\u533a\u57df\u5c5e\u6027\uff0c\u9700\u8981\u5728\u9644\u8fd1\u63d0\u4f9b\u670d\u52a1\u3002\u4f8b\u5982\uff0c\u5236\u9020\u4f01\u4e1a\u901a\u5e38\u4f4d\u4e8e\u5317\u4e0a\u5e7f\u6df1\u7b49\u5927\u57ce\u5e02\uff0c\u4f46\u662f\u5404\u4e2a\u5de5\u5382\u53ef\u80fd\u5206\u6563\u5728\u4e0d\u540c\u7684\u4e8c\u4e09\u7ebf\u57ce\u5e02\uff0c\u8fd9\u4e9b\u5de5\u5382\u9700\u8981\u4e0e ERP\u3001MES \u7b49\u7cfb\u7edf\u7d27\u5bc6\u914d\u5408\u3002\u56e0\u6b64\uff0c\u8fd9\u4e9b\u7cfb\u7edf\u5f80\u5f80\u9700\u8981\u5728\u5de5\u5382\u672c\u5730\u90e8\u7f72\uff0c\u800c\u603b\u90e8\u9700\u8981\u6e05\u695a\u5730\u638c\u63e1\u5404\u4e2a\u5de5\u5382\u7684\u60c5\u51b5\uff0c\u56e0\u6b64\u8fd9\u4e9b\u7cfb\u7edf\u9700\u8981\u5411\u96c6\u56e2\u516c\u53f8\u4e0a\u62a5\u6570\u636e\u3002\u4f20\u7edf\u7684\u90e8\u7f72\u67b6\u6784\u901a\u5e38\u91c7\u7528\u72ec\u7acb\u90e8\u7f72\u6570\u636e\u5e93\u7684\u65b9\u6cd5\uff0c\u800c\u6570\u636e\u540c\u6b65\u548c\u4e0a\u62a5\u5219\u7531\u5e94\u7528\u5c42\u5b9e\u73b0\u3002
MatrixOne \u7684\u591a\u79df\u6237\u80fd\u529b\u53ef\u4ee5\u5f88\u597d\u5730\u89e3\u51b3\u6570\u636e\u5e93\u5171\u4eab/\u9694\u79bb\u7684\u56f0\u5883\u3002\u7531\u4e8e\u53ef\u4ee5\u5c06\u79df\u6237\u9700\u8981\u7684 CN \u8282\u70b9\u5c31\u8fd1\u90e8\u7f72\u5230\u5b50\u516c\u53f8\u6240\u5728\u5730\u533a\uff0c\u5728\u7f51\u7edc\u8fde\u901a\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4e0e\u96c6\u56e2\u516c\u53f8\u7684\u5176\u4ed6\u7ec4\u4ef6\u5929\u7136\u5f62\u6210\u4e00\u4e2a\u96c6\u7fa4\uff0c\u65e2\u65b9\u4fbf\u672c\u5730\u5316\u4e1a\u52a1\u4f7f\u7528\uff0c\u4e5f\u6ee1\u8db3\u9ad8\u6548\u6570\u636e\u4e0a\u62a5\u548c\u7edf\u8ba1\u7684\u9700\u6c42\u3002
"},{"location":"MatrixOne/Overview/feature/key-feature-multi-accounts/#_10","title":"\u53c2\u8003\u6587\u6863","text":"\u66f4\u591a\u5173\u4e8e\u591a\u79df\u6237\u7684\u6587\u6863\u53ef\u4ee5\u53c2\u89c1\uff1a
\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u5bf9\u6bd4\u5e76\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u7684 MySQL \u6a21\u5f0f\u4ee5\u53ca\u539f\u751f MySQL \u6570\u636e\u5e93\u7684\u517c\u5bb9\u6027\u4fe1\u606f\u3002
MatrixOne \u4e0e MySQL 8.0 \u7684\u534f\u8bae\uff0c\u4ee5\u53ca MySQL 8.0 \u5e38\u7528\u7684\u529f\u80fd\u548c\u8bed\u6cd5\u90fd\u5177\u6709\u9ad8\u5ea6\u7684\u517c\u5bb9\u6027\u3002\u6b64\u5916\uff0cMatrixOne \u4e5f\u5bf9\u5e38\u89c1\u7684 MySQL \u5468\u8fb9\u5de5\u5177\u63d0\u4f9b\u4e86\u652f\u6301\uff0c\u5982 Navicat\uff0cMySQL Workbench\uff0cJDBC \u7b49\u3002\u7136\u800c\uff0c\u7531\u4e8e MatrixOne \u7684\u6280\u672f\u67b6\u6784\u4e0d\u540c\uff0c\u4e14\u4ecd\u5904\u4e8e\u53d1\u5c55\u548c\u5b8c\u5584\u9636\u6bb5\uff0c\u56e0\u6b64\u6709\u4e00\u4e9b\u529f\u80fd\u5c1a\u672a\u5f97\u5230\u652f\u6301\u3002\u672c\u8282\u5c06\u4e3b\u8981\u4ece\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\u8be6\u8ff0 MatrixOne \u6570\u636e\u5e93\u7684 MySQL \u6a21\u5f0f\u4e0e\u539f\u751f MySQL \u6570\u636e\u5e93\u7684\u533a\u522b\uff1a
ENCRYPTION
\u76ee\u524d\u8bed\u6cd5\u652f\u6301\u4f46\u4e0d\u751f\u6548\u3002ALTER DATABASE
\u3002utf8mb4
\u5b57\u7b26\u96c6\u548c utf8mb4_bin
\u6392\u5e8f\u89c4\u5219\uff0c\u65e0\u6cd5\u66f4\u6539\u3002ENGINE=
\uff0c\u4f46 MatrixOne \u4f1a\u76f4\u63a5\u5ffd\u7565 ENGINE=
\u3002CHANGE [COLUMN]
\uff0cMODIFY [COLUMN]
\uff0cRENAME COLUMN
\uff0cADD [CONSTRAINT [symbol]] PRIMARY KEY
\uff0cDROP PRIMARY KEY
\u548c ALTER COLUMN ORDER BY
\u53ef\u4ee5\u5728 ALTER TABLE \u8bed\u53e5\u4e2d\u81ea\u7531\u7ec4\u5408\u4f7f\u7528\uff0c\u4f46\u4e0d\u652f\u6301\u4e0e\u5176\u4ed6\u5b50\u53e5\u4e00\u8d77\u4f7f\u7528\u3002ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002CREATE TABLE ... CLUSTER BY...
\u6240\u5efa\u7684\u8868\uff0c\u4e0d\u652f\u6301\u4f7f\u7528 ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002PARTITION
\u76f8\u5173\u7684\u64cd\u4f5c\u3002Cluster by column
\u5b57\u53e5\uff0c\u5bf9\u67d0\u5217\u8fdb\u884c\u9884\u6392\u5e8f\u52a0\u901f\u67e5\u8be2\u3002with check option
\u5b50\u53e5\u3002DEFINER
\u4e0e SQL SECURITY
\u5b50\u53e5\u3002auto_increment
\u4e0e sequence
\u4e0d\u80fd\u4e00\u8d77\u7528\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002TRIGGER
\uff0cFUNCTION
\uff0cEVENT
\uff0cPROCEDURE
\uff0cENGINE
\u7b49\u3002SHOW STATUS/PRIVILEGES
\u7b49\u3002SHOW GRANTS
\uff0cSHOW ERRORS
\uff0cSHOW VARIABLES
\uff0cSHOW PROCESSLIST
\u3002SHOW BACKEND SERVERS
\uff0cSHOW ACCOUNTS
\uff0cSHOW ROLES
\uff0cSHOW NODE LIST
\u7b49\u3002ROLE
\uff0cSQL_MODE
\uff0cTIME_ZONE
\u3002SELECT...FOR UPDATE
\u5f53\u524d\u4ec5\u652f\u6301\u5355\u8868\u67e5\u8be2\u3002
LOW_PRIORITY
\uff0cDELAYED
\uff0cHIGH_PRIORITY
\u7b49\u4fee\u9970\u7b26\u3002LOW_PRIORITY
\u548c IGNORE
\u4fee\u9970\u7b26\u3002LOW_PRIORITY
\uff0cQUICK
\uff0cIGNORE
\u7b49\u4fee\u9970\u7b26\u3002IN
\u7684\u591a\u5c42\u5173\u8054\u5b50\u67e5\u8be2\u3002SET
\uff0c\u4f46\u53ea\u652f\u6301 SET columns_name=nullif(expr1,expr2)
\u7684\u5f62\u5f0f\u3002LOAD DATA LOCAL
\uff0c\u4f46\u5728\u8fde\u63a5\u65f6\u5fc5\u987b\u52a0\u5165 --local-infile
\u53c2\u6570\u3002JSONlines
\u6587\u4ef6\uff0c\u4f46\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u7279\u6b8a\u7684\u8bed\u6cd5\u3002Explain
\u548c Explain Analyze
\u6253\u5370\u683c\u5f0f\u5747\u53c2\u7167 PostgreSQL\uff0c\u4e0e MySQL \u6709\u8f83\u5927\u4e0d\u540c\u3002REPLACE
\u8bed\u53e5\u4e0d\u652f\u6301\u4f7f\u7528 VALUES row_constructor_list
\u53c2\u6570\u63d2\u5165\u7684\u4e00\u7ec4\u503c\u6784\u6210\u7684\u884c\u3002'1000-01-01 00:00:00'
\u5230 '9999-12-31 23:59:59'
\uff0cMatrixOne \u7684\u6700\u5927\u8303\u56f4\u4e3a '0001-01-01 00:00:00'
\u5230 '9999-12-31 23:59:59'
\u3002'1970-01-01 00:00:01.000000'
UTC \u5230 '2038-01-19 03:14:07.999999'
UTC\uff0cMatrixOne \u7684\u6700\u5927\u8303\u56f4 '0001-01-01 00:00:00'
UTC \u5230 '9999-12-31 23:59:59'
UTC\u3002IN
, Between and
\u53ca Like
\u8bed\u53e5\u4e2d\u6682\u65f6\u4e0d\u751f\u6548\u3002ON CASCADE DELETE
\u7ea7\u8054\u5220\u9664\u3002KEY
\uff0cHASH
\uff0cRANGE
\uff0cRANGE COLUMNS
\uff0cLIST
\uff0cLIST COLUMNS
\u516d\u79cd\u5206\u533a\u7c7b\u578b\u3002KEY
\uff0cHASH
\u4e24\u79cd\u5206\u533a\u88c1\u526a\uff0c\u5176\u4ed6\u56db\u79cd\u6682\u672a\u5b9e\u73b0\u3002ADD/DROP/TRUNCATE PARTITION
\u6682\u672a\u652f\u6301\u3002RANK
\uff0cDENSE_RANK
\uff0cROW_NUMBER
\u3002JSON_UNQUOTE
\uff0cJSON_QUOTE
\uff0cJSON_EXTRACT
\u3002CURRENT_ROLE_NAME()
\uff0cCURRENT_ROLE()
\uff0cCURRENT_USER_NAME()
\uff0cCURRENT_USER
\uff0cPURGE_LOG()
\u3002ENGINE=XXX
\u6765\u66f4\u6362\u5f15\u64ce\u3002ALTER USER
\u65b9\u6cd5\u4fee\u6539\u5bc6\u7801\u3002LOAD
\u6587\u4ef6\u6388\u6743\u7ba1\u7406\u3002CREATE STAGE
\u90e8\u5206\u652f\u6301 SELECT INTO
\u6587\u4ef6\u6388\u6743\u7ba1\u7406\u3002LOCK/UNLOCK TABLE
\u3002lower_case_table_names
\u6709 2 \u79cd\u6a21\u5f0f\uff0c\u9ed8\u8ba4\u4e3a 1\u3002sql_mode
\u53ea\u652f\u6301 ONLY_FULL_GROUP_BY
\u4e00\u79cd\u6a21\u5f0fmysql
\u548c information_schema
\u8fd9\u4e24\u4e2a\u7cfb\u7edf\u5e93\u6574\u4f53\u517c\u5bb9\u4e86 MySQL \u7684\u4f7f\u7528\u6a21\u5f0f\u3002system_metrics
\u7cfb\u7edf\u5e93\u6536\u96c6\u548c\u5b58\u50a8\u4e86\u4e00\u7cfb\u5217 MatrixOne \u670d\u52a1\u7684\u8fd0\u884c\u65f6\u72b6\u6001\u76d1\u63a7\u6570\u636e\u3002system
\u7cfb\u7edf\u5e93\u6536\u96c6\u4e86 MatrixOne \u4e2d\u7528\u6237\u548c\u7cfb\u7edf\u6267\u884c\u7684\u5404\u7c7b\u8bed\u53e5\u548c\u7cfb\u7edf\u8fd0\u884c\u65e5\u5fd7\u3002mo_catalog
\u7cfb\u7edf\u5e93\u5b58\u50a8\u4e86 MatrixOne \u4e2d\u7684\u5404\u79cd\u6570\u636e\u5e93\u5bf9\u8c61\u548c\u5143\u6570\u636e\u3002MatrixOne \u662f\u4e00\u6b3e\u8d85\u7ea7\u6574\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0c\u5176\u6574\u4f53\u57fa\u4e8e\u5b58\u50a8\u3001\u8ba1\u7b97\u548c\u4e8b\u52a1\u5206\u79bb\u7684\u67b6\u6784\uff0c\u62e5\u6709\u6781\u81f4\u7684\u5f39\u6027\u6269\u5c55\u80fd\u529b\uff0c\u80fd\u591f\u8fc5\u901f\u5e94\u5bf9\u7528\u6237\u8d1f\u8f7d\u7684\u53d8\u52a8\u3002\u968f\u7740\u6570\u636e\u91cf\u548c\u4e1a\u52a1\u7684\u6269\u5927\uff0c\u4f01\u4e1a\u5bf9\u6570\u636e\u5e93\u6269\u5c55\u6027\u7684\u9700\u6c42\u65e5\u76ca\u589e\u5f3a\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u65e0\u8bba\u7528\u6237\u6570\u636e\u4ece 0 \u589e\u957f\u5230 100TB \u7ea7\u522b\uff0c\u6216\u8005\u5e76\u53d1\u91cf\u4ece\u6570\u767e\u589e\u957f\u5230\u6570\u5341\u4e07\u7ea7\u522b\uff0cMatrixOne \u90fd\u80fd\u901a\u8fc7\u5176\u65e0\u6bd4\u7684\u6269\u5c55\u80fd\u529b\u6ee1\u8db3\u6027\u80fd\u9700\u6c42\u3002
"},{"location":"MatrixOne/Overview/feature/scalability/#_2","title":"\u4e1a\u52a1\u9700\u6c42","text":"\u4f01\u4e1a\u5bf9\u6570\u636e\u5e93\u6269\u5c55\u6027\u7684\u9700\u6c42\u4e3b\u8981\u6e90\u4e8e\u4ee5\u4e0b\u75db\u70b9\uff1a
\u5982\u679c\u6570\u636e\u5e93\u5177\u6709\u826f\u597d\u7684\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f01\u4e1a\u63d0\u9ad8\u6570\u636e\u5904\u7406\u80fd\u529b\uff0c\u4ece\u800c\u6709\u6548\u5e94\u5bf9\u6570\u636e\u91cf\u7684\u589e\u957f\uff0c\u5904\u7406\u5e76\u53d1\u8bf7\u6c42\u7684\u589e\u52a0\uff0c\u5e76\u4fdd\u8bc1\u7cfb\u7edf\u7684\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/scalability/#_3","title":"\u6280\u672f\u67b6\u6784","text":"MatrixOne \u5168\u9762\u91c7\u7528\u4e91\u539f\u751f\u67b6\u6784\uff0c\u6240\u6709\u7684\u7ec4\u4ef6\u90fd\u4ee5\u5bb9\u5668\u5f62\u5f0f\u5b58\u5728\uff0c\u7531 Kubernetes \u8fdb\u884c\u7edf\u4e00\u7ba1\u7406\u3002Kubernetes \u672c\u8eab\u5177\u6709\u5f3a\u5927\u7684\u5bb9\u5668\u7f16\u6392\u548c\u7ba1\u7406\u80fd\u529b\uff0c\u5728 MatrixOne \u4e2d\uff0c\u624b\u52a8\u6269\u5c55\u4ec5\u9700\u8981\u4fee\u6539 Kubernetes \u7684\u914d\u7f6e\u3002
"},{"location":"MatrixOne/Overview/feature/scalability/#_4","title":"\u529f\u80fd\u4f18\u52bf","text":"\u4ece\u4e0a\u56fe\u6280\u672f\u67b6\u6784\u89d2\u5ea6\u770b\uff0cMatrixOne \u7684\u6781\u81f4\u6269\u5c55\u6027\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
\u5206\u5e03\u5f0f\u67b6\u6784\u7684\u7075\u6d3b\u6269\u5c55\uff1aMatrixOne \u91c7\u7528\u4e86\u5206\u5e03\u5f0f\u5b58\u50a8\u548c\u8ba1\u7b97\u5206\u79bb\u7684\u67b6\u6784\uff0c\u5b58\u50a8\u5c42\u3001\u4e8b\u52a1\u5c42\u3001\u8ba1\u7b97\u5c42\u7684\u5206\u79bb\uff0c\u4f7f\u5f97 MatrixOne \u5728\u9047\u5230\u7cfb\u7edf\u8d44\u6e90\u74f6\u9888\u65f6\uff0c\u80fd\u591f\u7075\u6d3b\u5b9e\u73b0\u8282\u70b9\u7684\u6269\u5c55\u3002\u5b58\u50a8\u5c42\u4e3b\u8981\u57fa\u4e8e\u5bf9\u8c61\u5b58\u50a8\uff0c\u90e8\u5206\u57fa\u4e8e\u8ba1\u7b97\u8282\u70b9 CN \u4e0a\u7684\u7f13\u5b58\u3002\u4e8b\u52a1\u5c42\u57fa\u4e8e\u65e0\u72b6\u6001\u7684\u4e8b\u52a1\u8282\u70b9 TN\u3002\u8ba1\u7b97\u5c42\u57fa\u4e8e\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9 CN\u3002\u591a\u8282\u70b9\u7684\u67b6\u6784\u53ef\u4ee5\u66f4\u6709\u6548\u5730\u5206\u914d\u8d44\u6e90\uff0c\u907f\u514d\u70ed\u70b9\u548c\u8d44\u6e90\u4e89\u62a2\u3002
S3 \u5bf9\u8c61\u5b58\u50a8\u7684\u65e0\u9650\u6269\u5c55\u80fd\u529b\uff1aMatrixOne \u7684\u6838\u5fc3\u5b58\u50a8\u5b8c\u5168\u57fa\u4e8e S3 \u5bf9\u8c61\u5b58\u50a8\u3002S3 \u5bf9\u8c61\u5b58\u50a8\u5177\u6709\u5929\u7136\u7684\u9ad8\u53ef\u7528\u6027\u548c\u65e0\u9650\u6269\u5c55\u6027\uff0c\u4f7f\u5f97 MatrixOne \u5728\u6570\u636e\u5b58\u50a8\u65b9\u9762\u5177\u6709\u6781\u9ad8\u7684\u6269\u5c55\u6027\u3002\u65e0\u8bba\u6570\u636e\u89c4\u6a21\u5982\u4f55\u589e\u957f\uff0cMatrixOne \u90fd\u53ef\u4ee5\u901a\u8fc7\u6269\u5c55 S3 \u5b58\u50a8\u6765\u6ee1\u8db3\u9700\u6c42\u3002\u5728\u79c1\u6709\u5316\u90e8\u7f72\u73af\u5883\u4e2d\uff0cMatrixOne \u57fa\u4e8e\u5f00\u6e90\u7684 MinIO \u7ec4\u4ef6\u642d\u5efa S3 \u670d\u52a1\u3002\u5728\u516c\u6709\u4e91\u73af\u5883\u4e2d\uff0cMatrixOne \u53ef\u4ee5\u65e0\u7f1d\u5229\u7528\u516c\u6709\u4e91\u63d0\u4f9b\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u3002
\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u548c\u4e8b\u52a1\u8282\u70b9\uff1aMatrixOne \u7684\u8ba1\u7b97\u8282\u70b9\uff08CN\uff09\u548c\u4e8b\u52a1\u8282\u70b9\uff08TN\uff09\u662f\u65e0\u72b6\u6001\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u53ef\u4ee5\u968f\u65f6\u8fdb\u884c\u6a2a\u5411\u6269\u5c55\u3002\u65e0\u72b6\u6001\u7684\u8bbe\u8ba1\u4f7f\u5f97\u8ba1\u7b97\u548c\u4e8b\u52a1\u8282\u70b9\u4e0d\u9700\u8981\u5b58\u50a8\u4efb\u4f55\u6301\u4e45\u5316\u6570\u636e\uff0c\u4ece\u800c\u53ef\u4ee5\u8f7b\u677e\u6dfb\u52a0\u6216\u5220\u9664\uff0c\u4ee5\u5e94\u5bf9\u4e0d\u540c\u7684\u8d1f\u8f7d\u9700\u6c42\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4f7f\u5f97 MatrixOne \u5728\u5904\u7406\u5927\u89c4\u6a21\u5e76\u53d1\u8bf7\u6c42\u65f6\u5177\u6709\u6781\u9ad8\u7684\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\u3002\uff08\u5f53\u524d 0.8 \u7248\u672c TN \u8282\u70b9\u5c1a\u4e0d\u5177\u5907\u6269\u5c55\u80fd\u529b\uff0c\u4f46\u662f TN \u4e3b\u8981\u5904\u7406\u4e8b\u52a1\u7684\u63d0\u4ea4\u4fe1\u606f\uff0c\u8d1f\u8f7d\u8f83\u4f4e\uff0c\u56e0\u6b64\u5355 TN \u5df2\u8db3\u591f\u5904\u7406\u8f83\u5927\u89c4\u6a21\u7684\u96c6\u7fa4\uff0c\u540e\u7eed\u7248\u672c\u4f1a\u5b8c\u5584 TN \u7684\u6269\u5c55\u6027\uff09\u3002
\u4e0d\u540c\u8d1f\u8f7d\u53ca\u79df\u6237\u7684\u72ec\u7acb\u6269\u7f29\uff1aMatrixOne \u901a\u8fc7 Proxy \u6a21\u5757\u53ef\u4ee5\u5c06\u591a\u4e2a\u8ba1\u7b97\u8282\u70b9\uff08CN\uff09\u8fdb\u884c\u5206\u7ec4\u7ba1\u7406\uff0c\u7ec4\u6210 CN Set\uff0c\u901a\u8fc7\u6807\u7b7e\u6765\u5b9e\u73b0\u6bcf\u7ec4 CN Set \u7684\u72ec\u7acb\u6269\u7f29\u3002\u7528\u6237\u53ef\u4ee5\u5bf9\u4e0d\u540c\u79df\u6237\u6307\u5b9a\u4e0d\u540c\u7684 CN Set\uff0c\u4f7f\u79df\u6237\u4e4b\u95f4\u8d1f\u8f7d\u9694\u79bb\u5e76\u72ec\u7acb\u6269\u5c55\u3002\u4e5f\u53ef\u4ee5\u5bf9\u4e0d\u540c\u8d1f\u8f7d\u6307\u5b9a\u4e0d\u540c\u7684 CN Set\uff0c\u6bd4\u5982\u8bfb\u8d1f\u8f7d\u548c\u5199\u8d1f\u8f7d\uff0c\u6216\u8005\u4e8b\u52a1\u578b\u8d1f\u8f7d\u548c\u5206\u6790\u578b\u8d1f\u8f7d\uff0c\u5b9e\u73b0\u5b83\u4eec\u4e4b\u95f4\u7684\u9694\u79bb\u548c\u72ec\u7acb\u6269\u7f29\u3002
\u968f\u7740\u5b9e\u65f6\u6570\u636e\u5206\u6790\u7684\u5174\u8d77\uff0c\u6d41\u5f0f\u6570\u636e\u5728\u591a\u4e2a\u9886\u57df\u4e2d\u53d8\u5f97\u8d8a\u6765\u8d8a\u91cd\u8981\u3002\u8fd9\u4e9b\u6570\u636e\u6e90\u4e3b\u8981\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u793e\u4ea4\u5a92\u4f53\u5b9e\u65f6\u52a8\u6001\u3001\u5728\u7ebf\u96f6\u552e\u4ea4\u6613\u3001\u5b9e\u65f6\u5e02\u573a\u5206\u6790\u3001\u7f51\u7edc\u5b89\u5168\u76d1\u63a7\u3001\u5373\u65f6\u901a\u8baf\u8bb0\u5f55\uff0c\u4ee5\u53ca\u667a\u80fd\u57ce\u5e02\u57fa\u7840\u8bbe\u65bd\u7684\u5b9e\u65f6\u6570\u636e\u3002\u6d41\u5f0f\u6570\u636e\u7684\u5e94\u7528\u573a\u666f\u5e7f\u6cdb\uff0c\u4f8b\u5982\uff1a
\u6d41\u5f0f\u6570\u636e\u7684\u663e\u8457\u7279\u70b9\u5728\u4e8e\u5176\u5b9e\u65f6\u6027\u548c\u8fde\u7eed\u6027\u3002\u8fd9\u610f\u5473\u7740\u6570\u636e\u662f\u4e0d\u65ad\u751f\u6210\u5e76\u5373\u65f6\u4f20\u8f93\u7684\uff0c\u6bcf\u65f6\u6bcf\u523b\u90fd\u5728\u53cd\u6620\u6700\u65b0\u7684\u60c5\u51b5\u3002\u6b64\u5916\uff0c\u7531\u4e8e\u6570\u636e\u6d41\u7684\u4f53\u91cf\u5e9e\u5927\u4e14\u53d8\u5316\u8fc5\u901f\uff0c\u4f20\u7edf\u7684\u6570\u636e\u5904\u7406\u65b9\u6cd5\u5f80\u5f80\u96be\u4ee5\u5e94\u5bf9\uff0c\u9700\u8981\u66f4\u52a0\u9ad8\u6548\u7684\u5904\u7406\u548c\u5206\u6790\u6280\u672f\u3002\u56e0\u6b64\uff0c\u6d41\u5f0f\u6570\u636e\u5904\u7406\u901a\u5e38\u9700\u8981\uff1a
\u8fd9\u4e9b\u7279\u6027\u4f7f\u5f97\u6d41\u5f0f\u6570\u636e\u5728\u73b0\u4ee3\u6570\u636e\u9a71\u52a8\u7684\u51b3\u7b56\u8fc7\u7a0b\u4e2d\u53d1\u6325\u7740\u65e5\u76ca\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u5feb\u901f\u54cd\u5e94\u548c\u5b9e\u65f6\u6d1e\u5bdf\u7684\u573a\u666f\u4e2d\u3002
"},{"location":"MatrixOne/Overview/feature/stream/#matrixone","title":"MatrixOne \u5728\u6d41\u4e0a\u7684\u80fd\u529b","text":""},{"location":"MatrixOne/Overview/feature/stream/#source","title":"Source","text":"MatrixOne \u901a\u8fc7 Source \u540c\u6b65\u5916\u90e8\u6570\u636e\u6d41\u4e0e MatrixOne \u6570\u636e\u5e93\u8868\u4e4b\u95f4\u7684\u6570\u636e\uff0c\u901a\u8fc7\u5b9e\u73b0\u7cbe\u786e\u7684\u8fde\u63a5\u4e0e\u6570\u636e\u6620\u5c04\u673a\u5236\uff0cSource \u4e0d\u4ec5\u786e\u4fdd\u4e86\u6570\u636e\u6d41\u7684\u65e0\u7f1d\u5bf9\u63a5\uff0c\u800c\u4e14\u4fdd\u969c\u4e86\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\u3002
"},{"location":"MatrixOne/Overview/feature/stream/#dynamic-table","title":"\u52a8\u6001\u8868 Dynamic Table","text":"\u52a8\u6001\u8868\uff08Dynamic Table\uff09\u662f MatrixOne \u5728\u6d41\u4e0a\u80fd\u529b\u7684\u6838\u5fc3\u4f53\u73b0\u3002\u52a8\u6001\u8868\u80fd\u591f\u5b9e\u65f6\u6355\u6349\u3001\u5904\u7406\u5e76\u8f6c\u6362\u6d41\u5165\u5305\u62ec Source \u548c\u666e\u901a\u7684\u6570\u636e\u8868\u7684\u6570\u636e\uff0c\u4ece\u800c\u4fdd\u8bc1\u4fe1\u606f\u6d41\u5728\u6574\u4e2a\u7cfb\u7edf\u4e2d\u7684\u5373\u65f6\u66f4\u65b0\u548c\u51c6\u786e\u8868\u8fbe\u3002\u8fd9\u79cd\u8bbe\u8ba1\u4e0d\u4ec5\u63d0\u5347\u4e86\u6570\u636e\u5904\u7406\u7684\u7075\u6d3b\u6027\u548c\u6548\u7387\uff0c\u8fd8\u4f18\u5316\u4e86\u6574\u4e2a\u7cfb\u7edf\u5bf9\u4e8e\u590d\u6742\u6570\u636e\u573a\u666f\u7684\u54cd\u5e94\u80fd\u529b\u548c\u5904\u7406\u6027\u80fd\u3002
"},{"location":"MatrixOne/Overview/feature/time-series/","title":"\u65f6\u5e8f\u80fd\u529b","text":""},{"location":"MatrixOne/Overview/feature/time-series/#_2","title":"\u65f6\u5e8f\u6570\u636e\u7684\u7279\u70b9","text":"\u968f\u7740\u7269\u8054\u7f51\u7684\u53d1\u5c55\uff0c\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u9700\u6c42\u8d8a\u6765\u8d8a\u591a\uff0c\u6bd4\u5982\u667a\u80fd\u6c7d\u8f66\u4ea7\u751f\u7684\u6570\u636e\uff0c\u5de5\u5382\u7684\u8bbe\u5907\u76d1\u63a7\u3001\u91d1\u878d\u884c\u4e1a\u7684\u4ea4\u6613\u884c\u60c5\u6307\u6807\u6570\u636e\u7b49\u3002\u5e38\u89c1\u7684\u4e1a\u52a1\u573a\u666f\u5305\u62ec\uff1a
\u76d1\u63a7\u8f6f\u4ef6\u7cfb\u7edf\uff1a\u865a\u62df\u673a\u3001\u5bb9\u5668\u3001\u670d\u52a1\u3001\u5e94\u7528\uff1b \u76d1\u63a7\u7269\u7406\u7cfb\u7edf\uff1a\u6c34\u6587\u76d1\u63a7\u3001\u5236\u9020\u4e1a\u5de5\u5382\u4e2d\u7684\u8bbe\u5907\u76d1\u63a7\u3001\u56fd\u5bb6\u5b89\u5168\u76f8\u5173\u7684\u6570\u636e\u76d1\u63a7\u3001\u901a\u8baf\u76d1\u63a7\u3001\u4f20\u611f\u5668\u6570\u636e\u3001\u8840\u7cd6\u4eea\u3001\u8840\u538b\u53d8\u5316\u3001\u5fc3\u7387\u7b49\uff1b \u8d44\u4ea7\u8ddf\u8e2a\u5e94\u7528\uff1a\u6c7d\u8f66\u3001\u5361\u8f66\u3001\u7269\u7406\u5bb9\u5668\u3001\u8fd0\u8d27\u6258\u76d8\uff1b \u91d1\u878d\u4ea4\u6613\u7cfb\u7edf\uff1a\u4f20\u7edf\u8bc1\u5238\u3001\u65b0\u5174\u7684\u52a0\u5bc6\u6570\u5b57\u8d27\u5e01\uff1b \u4e8b\u4ef6\u5e94\u7528\u7a0b\u5e8f\uff1a\u8ddf\u8e2a\u7528\u6237\u3001\u5ba2\u6237\u7684\u4ea4\u4e92\u6570\u636e\uff1b \u5546\u4e1a\u667a\u80fd\u5de5\u5177\uff1a\u8ddf\u8e2a\u5173\u952e\u6307\u6807\u548c\u4e1a\u52a1\u7684\u603b\u4f53\u5065\u5eb7\u60c5\u51b5\uff1b \u4e92\u8054\u7f51\u884c\u4e1a\uff1a\u4e5f\u6709\u7740\u975e\u5e38\u591a\u7684\u65f6\u5e8f\u6570\u636e\uff0c\u4f8b\u5982\u7528\u6237\u8bbf\u95ee\u7f51\u7ad9\u7684\u884c\u4e3a\u8f68\u8ff9\uff0c\u5e94\u7528\u7a0b\u5e8f\u4ea7\u751f\u7684\u65e5\u5fd7\u6570\u636e\u7b49\u3002
\u4e00\u65b9\u9762\u7531\u4e8e\u65f6\u5e8f\u6570\u636e\u5e93\u7684\u65f6\u95f4\u5c5e\u6027\uff0c\u5373\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u4e0d\u65ad\u5730\u4ea7\u751f\u65b0\u7684\u6570\u636e\uff1b\u53e6\u4e00\u65b9\u9762\uff0c\u65f6\u5e8f\u7684\u6570\u636e\u91cf\u5de8\u5927\uff0c\u6bcf\u79d2\u949f\u53ef\u80fd\u8981\u5199\u5165\u5343\u4e07\u3001\u4e0a\u4ebf\u6761\u6570\u636e\u3002\u8fd9\u4e24\u65b9\u9762\u7684\u7279\u6027\u4f7f\u5f97\u65f6\u5e8f\u6570\u636e\u5e93\u5728\u4e00\u4e9b\u4e1a\u52a1\u9700\u6c42\u4e2d\u4f1a\u51fa\u73b0\uff0c\u5e38\u89c1\u7684\u4e1a\u52a1\u9700\u6c42\u6709\uff1a
\u76ee\u524d\u884c\u4e1a\u4e2d\u5df2\u7ecf\u6709\u4e00\u4e9b\u4e13\u7528\u7684 NoSQL \u65f6\u5e8f\u6570\u636e\u5e93\uff0c\u5982 InfluxDB, OpenTSDB, TDEngine \u7b49\uff0c\u800c MatrixOne \u4e0e\u5b83\u4eec\u4e0d\u4e00\u6837\u7684\u5730\u65b9\u5728\u4e8e MatrixOne \u4ecd\u7136\u662f\u4e00\u4e2a\u901a\u7528\u6570\u636e\u5e93\uff0c\u4ee5\u6ee1\u8db3\u5e94\u7528\u5f00\u53d1\u7684\u589e\u5220\u6539\u67e5\u53ca\u6570\u636e\u5206\u6790\u7684 HTAP \u4e3a\u6838\u5fc3\uff0c\u540c\u65f6\u4e5f\u4ecd\u7136\u662f\u4e00\u4e2a\u5173\u7cfb\u578b\u6570\u636e\u7684\u5efa\u6a21\u5f62\u5f0f\uff0c\u4f7f\u7528\u7684\u67e5\u8be2\u8bed\u8a00\u4e5f\u4ecd\u7136\u662f\u7ecf\u5178\u7684 SQL \u8bed\u8a00\uff0cMatrixOne \u662f\u5728\u901a\u7528\u6570\u636e\u5e93\u80fd\u529b\u7684\u57fa\u7840\u589e\u52a0\u4e86\u4e00\u4e9b\u65f6\u5e8f\u76f8\u5173\u7684\u80fd\u529b\uff0c\u5b9a\u4f4d\u4e0a\u6765\u8bf4\u6709\u70b9\u7c7b\u4f3c\u4e8e TimeScaleDB\u3002MatrixOne \u5728\u529f\u80fd\u4e0a\u652f\u6301\u65f6\u95f4\u7a97\u53e3\uff0c\u964d\u91c7\u6837\uff0c\u63d2\u503c\uff0c\u5206\u533a\u7b49\u65f6\u5e8f\u5e38\u89c1\u7684\u80fd\u529b\uff0c\u6027\u80fd\u4e0a\u53ef\u4ee5\u6ee1\u8db3\u65f6\u5e8f\u573a\u666f\u4e2d\u5bf9\u9ad8\u541e\u5410\uff0c\u9ad8\u538b\u7f29\uff0c\u5b9e\u65f6\u5206\u6790\uff0c\u540c\u65f6\u6574\u4f53\u67b6\u6784\u4e0a\u7684\u5f3a\u6269\u5c55\u6027\uff0c\u51b7\u70ed\u5206\u79bb\uff0c\u8bfb\u5199\u5206\u79bb\u7b49\u7279\u70b9\u4e5f\u975e\u5e38\u9002\u5408\u65f6\u5e8f\u76f8\u5173\u7684\u573a\u666f\u4f7f\u7528\uff0c\u540c\u65f6\u4fdd\u6301\u4e86\u4f20\u7edf\u6570\u636e\u5e93\u4e2d\u5bf9\u66f4\u65b0\uff0c\u4e8b\u52a1\u7684\u652f\u6301\u3002\u56e0\u6b64\uff0cMatrixOne \u66f4\u9002\u5408\u9700\u8981\u7528\u666e\u901a\u7684\u5173\u7cfb\u578b\u6570\u636e\u5e93\u8fdb\u884c\u4e1a\u52a1\u5f00\u53d1\uff0c\u4f46\u662f\u540c\u65f6\u6709\u9700\u8981\u6709\u4e00\u5b9a\u65f6\u5e8f\u5904\u7406\u80fd\u529b\u7684\u6df7\u5408\u573a\u666f\u3002
MatrixOne \u7684\u65f6\u5e8f\u80fd\u529b\u4f53\u73b0\u5728\u4ee5\u4e0b\u65b9\u9762\uff1a
\u60a8\u53ef\u4ee5\u7f16\u5199\u7528\u6237\u5b9a\u4e49\u51fd\u6570 (UDF) \u6765\u6269\u5c55\u7cfb\u7edf\uff0c\u4ee5\u6267\u884c MatrixOne \u63d0\u4f9b\u7684\u5185\u7f6e\u7cfb\u7edf\u5b9a\u4e49\u51fd\u6570\u65e0\u6cd5\u6267\u884c\u7684\u64cd\u4f5c\uff0c\u521b\u5efa UDF \u540e\uff0c\u60a8\u53ef\u4ee5\u591a\u6b21\u91cd\u590d\u4f7f\u7528\u5b83\u3002
"},{"location":"MatrixOne/Overview/feature/udf/#udf_1","title":"\u4ec0\u4e48\u662f UDF?","text":"\u5728\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u4e2d\uff0c\u7528\u6237\u5b9a\u4e49\u51fd\u6570\uff08UDF\uff09\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u5141\u8bb8\u7528\u6237\u6839\u636e\u7279\u5b9a\u9700\u6c42\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u3002\u8fd9\u4e9b\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u6267\u884c\u590d\u6742\u7684\u8ba1\u7b97\u3001\u6570\u636e\u8f6c\u6362\u7b49\u53ef\u80fd\u8d85\u51fa\u4e86\u6807\u51c6 SQL \u51fd\u6570\u7684\u8303\u56f4\u7684\u51fd\u6570\u3002
"},{"location":"MatrixOne/Overview/feature/udf/#udf_2","title":"UDF \u7684\u6838\u5fc3\u80fd\u529b","text":"\u5728\u5f53\u524d\u7248\u672c\u4e2d\uff0cMatrixOne \u652f\u6301\u4f7f\u7528 Python \u8bed\u8a00\u7684 UDF\u3002
\u6709\u5173 MatrixOne \u4e2d UDF-python \u7684\u57fa\u7840\u7528\u6cd5\uff0c\u53c2\u89c1 UDF-python \u57fa\u7840\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u4e2d UDF-python \u7684\u8fdb\u9636\u7528\u6cd5\uff0c\u53c2\u89c1 UDF-python \u8fdb\u9636\u7528\u6cd5\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u521b\u5efa\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u521b\u5efa UDF\u3002
\u6709\u5173 MatrixOne \u5bf9 UDF \u5220\u9664\u7684\u5177\u4f53\u53c2\u6570\uff0c\u53c2\u89c1\u5220\u9664 UDF\u3002
"},{"location":"MatrixOne/Overview/matrixone-vs-other_databases/matrixone-positioning/","title":"MatrixOne \u7684\u5b9a\u4f4d","text":"\u5728\u5e9e\u5927\u800c\u590d\u6742\u7684\u6570\u636e\u6280\u672f\u6808\u548c\u5404\u7c7b\u6570\u636e\u5e93\u4ea7\u54c1\u4e2d\uff0cMatrixOne \u7684\u5b9a\u4f4d\u662f\u4e00\u6b3e\u4e3b\u6253\u4e00\u7ad9\u5f0f\u878d\u5408\u80fd\u529b\u548c\u7075\u6d3b\u6269\u5c55\u6027\u7684 SQL \u5173\u7cfb\u578b\u6570\u636e\u5e93\u3002MatrixOne \u7684\u8bbe\u8ba1\u76ee\u6807\u662f\u63d0\u4f9b\u4e00\u4e2a\u4f7f\u7528\u4f53\u9a8c\u5982 MySQL \u4e00\u6837\u7b80\u5355\u7684\u6570\u636e\u5e93\u4ea7\u54c1\uff0c\u53ef\u4ee5\u5904\u7406\u5305\u62ec OLTP \u548c OLAP \u7b49\u5404\u7c7b\u4e1a\u52a1\u8d1f\u8f7d\u548c\u6570\u636e\u7c7b\u578b\uff0c\u540c\u65f6\u80fd\u611f\u77e5\u7528\u6237\u7684\u8d1f\u8f7d\u548c\u6570\u636e\u91cf\u53d8\u5316\u81ea\u52a8\u5316\u7684\u8fdb\u884c\u5feb\u901f\u5f39\u6027\u4f38\u7f29\uff0c\u4ee5\u7b80\u5316\u7528\u6237\u5f53\u524d\u590d\u6742\u7684\u591a\u6570\u636e\u5e93\u4ea7\u54c1+ETL \u7684\u4f20\u7edf\u6570\u636e\u67b6\u6784\u3002
\u5728\u884c\u4e1a\u73b0\u6709\u7684\u6570\u636e\u5e93\u4ea7\u54c1\u4e2d\u6765\u8bf4\u4e0e MatrixOne \u6700\u63a5\u8fd1\u7684\u6570\u636e\u5e93\u4ea7\u54c1\u662f SingleStore\uff0c\u4e24\u8005\u90fd\u91c7\u7528\u7edf\u4e00\u5b58\u50a8\u6a21\u578b\uff0c\u652f\u6301 OLTP\uff0cOLAP \u4ee5\u53ca\u5176\u4ed6\u4e00\u7cfb\u5217\u6570\u636e\u8d1f\u8f7d\u548c\u6570\u636e\u7c7b\u578b\u7684\u878d\u5408\uff0c\u540c\u65f6\u4e5f\u90fd\u4ee5\u4e91\u539f\u751f\u548c\u53ef\u7075\u6d3b\u6269\u5c55\u4f5c\u4e3a\u81ea\u5df1\u7684\u6838\u5fc3\u67b6\u6784\u80fd\u529b\u3002
\u4ece\u67b6\u6784\u4e0a\u6765\u8bf4\uff0cMatrixOne \u662f\u4e00\u6b3e\u5b8c\u5168\u4e91\u539f\u751f\u548c\u5bb9\u5668\u5316\u7684\u6570\u636e\u5e93\uff0cMatrixOne \u501f\u9274\u4e86 Snowflake \u5bf9\u4e91\u539f\u751f\u6570\u636e\u4ed3\u5e93\u7684\u5b58\u7b97\u5206\u79bb\u8bbe\u8ba1\uff0c\u5b8c\u5168\u5c06\u5b58\u50a8\u4ea4\u4e8e\u4e91\u4e0a\u7684\u5171\u4eab\u5b58\u50a8\uff0c\u540c\u65f6\u5c06\u8ba1\u7b97\u5c42\u5b8c\u5168\u6784\u5efa\u6210\u4e86\u65e0\u72b6\u6001\u5316\u7684\u5bb9\u5668\u3002\u540c\u65f6\uff0c\u4e3a\u4e86\u80fd\u9002\u5e94 OLTP \u7c7b\u578b\u8d1f\u8f7d\u5bf9\u5feb\u901f\u5199\u5165\u8bf7\u6c42\u7684\u5904\u7406\uff0cMatrixOne \u589e\u52a0\u4e86 TN \u53ca LogService \u7684\u6982\u5ff5\uff0c\u4ee5\u5757\u5b58\u50a8\u6765\u652f\u6491\u9ad8\u9891\u5199\u5165\uff0c\u901a\u8fc7 Raft \u4e09\u526f\u672c\u4e00\u81f4\u6027\u4fdd\u8bc1\u6765\u786e\u4fdd\u5199\u5165\u65e5\u5fd7 WAL \u7684\u9ad8\u53ef\u7528\uff0c\u540c\u65f6\u518d\u5f02\u6b65\u7684\u5c06 WAL \u843d\u76d8\u5230\u5171\u4eab\u5b58\u50a8\u4e2d\u3002\u4e0e SingleStore \u4e0d\u540c\u4e4b\u5904\u5728\u4e8e SingleStore \u662f\u4ece Share-nothing \u67b6\u6784\u4e0a\u6269\u5c55\u5230\u4e86\u4e91\u539f\u751f\u7684\u5b58\u7b97\u5206\u79bb\u4e0a\uff0c\u5176\u4ec5\u5c06\u51b7\u6570\u636e\u653e\u5165\u5171\u4eab\u5b58\u50a8\uff08\u53ef\u53c2\u8003 SingleStore \u67b6\u6784\u8bba\u6587\uff09\uff0c\u4f9d\u7136\u9700\u8981\u505a\u6570\u636e\u5206\u7247\u548c\u518d\u5e73\u8861\u3002\u800c MatrixOne \u4e0e Snowflake \u4e00\u81f4\uff0c\u5219\u662f\u5b8c\u5168\u57fa\u4e8e\u5171\u4eab\u5b58\u50a8\uff0c\u6ca1\u6709\u4efb\u4f55\u6570\u636e\u5206\u7247\u3002
\u4ece\u8d1f\u8f7d\u7c7b\u578b\u4e0a\u6765\u8bf4\uff0cMatrixOne \u4ee5 HTAP \u4e3a\u57fa\u672c\u6838\u5fc3\uff0c\u9010\u6b65\u6269\u5c55\u81f3\u6d41\u8ba1\u7b97\uff0c\u65f6\u5e8f\u5904\u7406\uff0c\u673a\u5668\u5b66\u4e60\uff0c\u641c\u7d22\u7b49\u591a\u79cd\u8d1f\u8f7d\u7c7b\u578b\u3002\u5728 HTAP \u7684\u6280\u672f\u8def\u7ebf\u4e0a\uff0cMatrixOne \u4e0e\u4ee5 TiDB \u4e3a\u4e3b\u7684\u53cc\u5b58\u50a8\u548c\u8ba1\u7b97\u5f15\u64ce\u8def\u7ebf\u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u662f\u76f4\u63a5\u5728\u5355\u5b58\u50a8\u5f15\u64ce\u548c\u8ba1\u7b97\u5f15\u64ce\u4e0a\u5b9e\u73b0 HTAP\uff0c\u5b58\u50a8\u5f15\u64ce\u4e5f\u662f\u4ee5\u843d\u76d8\u5217\u5b58\u4e3a\u4e3b\uff0c\u5185\u5b58\u884c\u5b58\u4e3a\u8f85\u7684\u67b6\u6784\uff0c\u8fd9\u70b9\u4e0e SingleStore \u4e5f\u8f83\u4e3a\u4e00\u81f4\u3002TiDB \u4e00\u7c7b\u7684\u6280\u672f\u8def\u7ebf\u9700\u8981\u5185\u90e8\u8fdb\u884c\u53cc\u5f15\u64ce\u6570\u636e\u540c\u6b65\uff0c\u540c\u65f6 TP \u4e0e AP \u6570\u636e\u9700\u8981\u5355\u72ec\u5b58\u50a8\uff0c\u800c MatrixOne \u4e0d\u9700\u8981\u505a\u6b64\u540c\u6b65\u53ca\u591a\u4efd\u5b58\u50a8\u3002\u76f8\u6bd4 SingleStore \u5df2\u7ecf\u5bf9\u6d41\u8ba1\u7b97\uff0c\u641c\u7d22\uff0cGIS\uff0c\u673a\u5668\u5b66\u4e60\u7b49 HTAP \u4ee5\u5916\u7684\u5176\u4ed6\u591a\u79cd\u4e1a\u52a1\u7c7b\u578b\u90fd\u6709\u826f\u597d\u652f\u6301\uff0cMatrixOne \u672c\u8eab\u53d1\u5c55\u65f6\u95f4\u8f83\u665a\uff0c\u76ee\u524d\u9664\u4e86 HTAP \u4ee5\u5916\u5bf9\u5176\u4ed6\u8d1f\u8f7d\u7c7b\u578b\u7684\u652f\u6301\u7a0b\u5ea6\u4e0d\u591f\u5b8c\u5584\u3002
OLTP \u662f\u6307\u4e00\u79cd\u9762\u5411\u4e1a\u52a1\u4ea4\u6613\u7684\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u3002OLTP \u6570\u636e\u5e93\u7528\u4e8e\u5904\u7406\u5927\u91cf\u7684\u77ed\u671f\u4ea4\u6613\uff0c\u8fd9\u4e9b\u4ea4\u6613\u901a\u5e38\u662f\u4e00\u4e9b\u65e5\u5e38\u4e1a\u52a1\u64cd\u4f5c\uff0c\u4f8b\u5982\u8ba2\u5355\u5904\u7406\u3001\u5e93\u5b58\u7ba1\u7406\u3001\u94f6\u884c\u4ea4\u6613\u7b49\u3002\u5b83\u53ef\u4ee5\u63d0\u4f9b\u9ad8\u5e76\u53d1\u6027\u80fd\u548c\u5b9e\u65f6\u6570\u636e\u5904\u7406\uff0c\u4ee5\u6ee1\u8db3\u4f01\u4e1a\u5bf9\u5373\u65f6\u6570\u636e\u8bbf\u95ee\u7684\u9700\u6c42\u3002
OLTP \u6570\u636e\u5e93\u7684\u4e3b\u8981\u7279\u5f81\u5982\u4e0b\uff1a
\u7ec6\u7c92\u5ea6\u6570\u636e\u8bbf\u95ee\uff1aOLTP \u6570\u636e\u5e93\u901a\u5e38\u4ee5\u8bb0\u5f55\u4e3a\u5355\u4f4d\u8fdb\u884c\u6570\u636e\u8bbf\u95ee\uff0c\u5b83\u652f\u6301\u9ad8\u6548\u7684\u589e\u3001\u5220\u3001\u6539\u64cd\u4f5c\uff0c\u5e76\u63d0\u4f9b\u5feb\u901f\u7684\u4e8b\u52a1\u63d0\u4ea4\u548c\u56de\u6eda\u529f\u80fd\u3002
\u9ad8\u53ef\u9760\uff1aOLTP \u7cfb\u7edf\u5fc5\u987b\u5728\u53d1\u751f\u4efb\u4f55\u786c\u4ef6\u6216\u8f6f\u4ef6\u6545\u969c\u65f6\u5177\u6709\u6062\u590d\u80fd\u529b\u3002
OLTP \u6570\u636e\u5e93\u6839\u636e\u67b6\u6784\u548c\u6280\u672f\u8def\u7ebf\u7684\u4e0d\u540c\u8fd8\u53ef\u4ee5\u88ab\u5206\u4e3a\u96c6\u4e2d\u5f0f\u6570\u636e\u5e93\uff0c\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u548c\u4e91\u539f\u751f\u6570\u636e\u5e93\u3002
\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e09\u79cd\u5206\u7c7b\u5e76\u6ca1\u6709\u4e25\u683c\u7684\u5212\u5206\u6807\u51c6\uff0c\u5728\u5b9e\u9645\u7684\u53d1\u5c55\u8fc7\u7a0b\u4e2d\u6bcf\u5bb6\u6570\u636e\u5e93\u4e5f\u90fd\u5f00\u59cb\u9010\u6b65\u878d\u5408\u5176\u4ed6\u8def\u7ebf\u4ea7\u54c1\u7684\u80fd\u529b\u3002\u6bd4\u5982 Oracle \u7684 RAC \u67b6\u6784\u5c31\u662f\u5178\u578b\u7684\u5171\u4eab\u5b58\u50a8\u67b6\u6784\uff0c\u5177\u5907\u4e00\u5b9a\u7684\u6269\u5c55\u6027\u3002CockroachDB \u548c TiDB \u7b49\u4ea7\u54c1\u4e5f\u90fd\u5728\u9010\u6b65\u5f80\u4e91\u539f\u751f\u548c\u5171\u4eab\u5b58\u50a8\u65b9\u5411\u6f14\u8fdb\u3002\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0cOLTP \u4f5c\u4e3a\u9700\u6c42\u6700\u5e7f\u6cdb\u7684\u6570\u636e\u5e93\u573a\u666f\uff0c\u4e09\u79cd\u6280\u672f\u8def\u7ebf\u7684\u4ea7\u54c1\u4e5f\u90fd\u6709\u5927\u91cf\u7684\u7528\u6237\u5728\u4f7f\u7528\u3002
"},{"location":"MatrixOne/Overview/matrixone-vs-other_databases/matrixone-vs-oltp/#matrixone-oltp_1","title":"MatrixOne \u7684 OLTP \u7279\u70b9","text":"MatrixOne \u7684\u57fa\u672c\u80fd\u529b\u6ee1\u8db3\u4e00\u822c OLTP \u6570\u636e\u5e93\u7684\u7279\u70b9\u3002
\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u4ece\u67b6\u6784\u548c\u6280\u672f\u8def\u7ebf\u5206\u7c7b\u6765\u8bf4\uff0cMatrixOne \u5c5e\u4e8e\u4e91\u539f\u751f\u6280\u672f\u8def\u7ebf\uff0c\u4e0e Aurora \u66f4\u4e3a\u63a5\u8fd1\uff0c\u76f8\u6bd4\u4e8e Share-nothing \u67b6\u6784\u6700\u5927\u7684\u4f18\u52bf\u662f\u5b58\u50a8\u8ba1\u7b97\u5206\u79bb\u540e\uff0c\u5b58\u50a8\u548c\u8ba1\u7b97\u90fd\u53ef\u4ee5\u6309\u9700\u4f7f\u7528\u3002
\u4e0e Aurora \u4e0d\u540c\u7684\u5730\u65b9\u6709\u4e24\u70b9\uff1a
\u5f53\u7136\uff0cMatrixOne \u5e76\u4e0d\u4ec5\u5c40\u9650\u4e8e OLTP \u80fd\u529b\uff0cMatrixOne \u9002\u914d\u5176\u4ed6\u8d1f\u8f7d\u7684\u80fd\u529b\u4e5f\u4e0e Aurora \u7684\u5b9a\u4f4d\u6709\u663e\u8457\u5dee\u522b\u3002
"},{"location":"MatrixOne/Overview/matrixone-vs-other_databases/matrixone-vs-oltp/#matrixone-mysql","title":"MatrixOne \u4e0e MySQL \u7684\u5bf9\u6bd4","text":"\u7531\u4e8e MatrixOne \u4ee5\u517c\u5bb9 MySQL \u4e3a\u4e3b\u8981\u76ee\u6807\uff0cMySQL \u672c\u8eab\u4e5f\u662f\u4e16\u754c\u4e0a\u6d41\u884c\u5ea6\u6700\u9ad8\u7684\u5f00\u6e90\u6570\u636e\u5e93\u3002MatrixOne \u7684\u7528\u6237\u5f88\u5927\u4e00\u90e8\u5206\u662f\u7531\u4ece\u5f00\u6e90 MySQL \u8fc1\u79fb\u5230 MatrixOne \u7684\uff0c\u56e0\u6b64\u8fd9\u91cc\u6211\u4eec\u5c06 MatrixOne \u4e0e MySQL \u505a\u4e00\u4e2a\u8be6\u7ec6\u7684\u5bf9\u6bd4\u3002
MySQL MatrixOne \u7248\u672c 8.0.37 \u6700\u65b0\u7248\u672c License GPL License Apache License 2.0 \u67b6\u6784 \u96c6\u4e2d\u5f0f\u6570\u636e\u5e93 \u5206\u5e03\u5f0f\u4e91\u539f\u751f\u6570\u636e\u5e93 \u8d1f\u8f7d\u7c7b\u578b OLTP, \u5206\u6790\u578b\u8d1f\u8f7d\u4f9d\u8d56\u4e8e\u4f01\u4e1a\u7248\u7684 Heatwave HTAP\uff0c\u65f6\u5e8f \u5b58\u50a8\u683c\u5f0f \u884c\u5b58 \u5217\u5b58 \u5b58\u50a8\u5f15\u64ce InnoDB/MyIsam TAE \u4ea4\u4e92\u65b9\u5f0f SQL SQL \u90e8\u7f72\u65b9\u5f0f \u5355\u673a\u90e8\u7f72/\u4e3b\u4ece\u90e8\u7f72 \u5355\u673a\u90e8\u7f72/\u4e3b\u4ece\u90e8\u7f72/\u5206\u5e03\u5f0f\u90e8\u7f72/K8s\u90e8\u7f72 \u6a2a\u5411\u6269\u5c55\u80fd\u529b \u4f9d\u8d56\u5206\u5e93\u5206\u8868\u4e2d\u95f4\u4ef6\u5b9e\u73b0 \u5929\u7136\u652f\u6301 \u4e8b\u52a1\u80fd\u529b \u60b2\u89c2\u4e8b\u52a1/\u4e50\u89c2\u4e8b\u52a1+ANSI 4 \u79cd\u9694\u79bb\u7ea7\u522b\uff08InnoDB \u5f15\u64ce\uff09 \u60b2\u89c2\u4e8b\u52a1/\u4e50\u89c2\u4e8b\u52a1+RC/SI \u6570\u636e\u7c7b\u578b \u57fa\u7840\u6570\u503c\uff0c\u65f6\u95f4\u65e5\u671f\uff0c\u5b57\u7b26\uff0cJSON\uff0c\u7a7a\u95f4 \u57fa\u7840\u6570\u503c\uff0c\u65f6\u95f4\u65e5\u671f\uff0c\u5b57\u7b26\uff0cJSON\uff0c\u5411\u91cf \u7d22\u5f15\u548c\u7ea6\u675f \u4e3b\u952e\uff0c\u6b21\u7ea7\u952e\uff0c\u552f\u4e00\u952e\uff0c\u5916\u952e \u4e3b\u952e\uff0c\u6b21\u7ea7\u952e\uff0c\u552f\u4e00\u952e\uff0c\u5916\u952e \u8bbf\u95ee\u63a7\u5236 \u57fa\u4e8e RBAC \u57fa\u4e8e RBAC \u7a97\u53e3\u51fd\u6570 \u57fa\u7840\u7a97\u53e3\u51fd\u6570 \u57fa\u7840\u7a97\u53e3\u51fd\u6570\uff0c\u65f6\u95f4\u6ed1\u52a8\u7a97\u53e3 \u9ad8\u7ea7 SQL \u80fd\u529b \u89e6\u53d1\u5668\uff0c\u5b58\u50a8\u8fc7\u7a0b \u4e0d\u652f\u6301 \u6d41\u8ba1\u7b97 \u4e0d\u652f\u6301 \u6d41\u5f0f\u5199\u5165/kafka\u8fde\u63a5\u5668/\u52a8\u6001\u8868 UDF \u652f\u6301 SQL \u53ca C \u8bed\u8a00\u7684 UDF \u652f\u6301 SQL \u53ca Python \u7684 UDF \u591a\u79df\u6237 \u4e0d\u652f\u6301 \u652f\u6301 \u6570\u636e\u5171\u4eab \u4e0d\u652f\u6301 \u652f\u6301\u79df\u6237\u95f4\u6570\u636e\u5171\u4eab \u7f16\u7a0b\u8bed\u8a00 \u7edd\u5927\u90e8\u5206\u8bed\u8a00 Java\uff0cPython\uff0cGolang \u8fde\u63a5\u5668\u548c ORM \u57fa\u672c\u652f\u6301 \u5e38\u89c1\u53ef\u89c6\u5316\u7ba1\u7406\u5de5\u5177 Navicat\uff0cDBeaver\uff0cMySQL Workbench\uff0cDataGrip\uff0cHeidiSQL \u7b49 \u4e0e MySQL \u4e00\u81f4 \u5907\u4efd\u5de5\u5177 \u903b\u8f91\u5907\u4efd\uff0c\u7269\u7406\u5907\u4efd \u903b\u8f91\u5907\u4efd\uff0c\u7269\u7406\u5907\u4efd\uff0c\u5feb\u7167\u5907\u4efd CDC \u80fd\u529b \u5177\u5907 \u4e0d\u5177\u5907 OLTP \u6027\u80fd \u5355\u673a\u4f18\u79c0\uff0c\u4e0d\u53ef\u6269\u5c55 \u5355\u673a\u826f\u597d\uff0c\u53ef\u6269\u5c55 OLAP \u6027\u80fd \u8f83\u5dee \u4f18\u79c0\uff0c\u53ef\u6269\u5c55 \u5927\u6279\u91cf\u5199\u5165\u6027\u80fd \u8f83\u5dee \u4f18\u79c0\uff0c\u53ef\u6269\u5c55 \u5b58\u50a8\u7a7a\u95f4 \u53d7\u9650\u4e8e\u78c1\u76d8 \u65e0\u9650\u6269\u5c55\u5176\u4ed6\u7ec6\u8282\u53ef\u4ee5\u53c2\u7167 MatrixOne \u7684 MySQL \u517c\u5bb9\u6027\u8be6\u7ec6\u8bf4\u660e\u3002
\u6574\u4f53\u6765\u8bf4\uff0cMatrixOne \u662f\u4e00\u4e2a\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684\u4e91\u539f\u751f HTAP \u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u65e0\u7f1d\u517c\u5bb9\u7edd\u5927\u90e8\u5206\u57fa\u4e8e MySQL \u5f00\u53d1\u7684\u5e94\u7528\u3002\u4e0e\u6b64\u540c\u65f6\uff0cMatrixOne \u5929\u7136\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u4ee5\u53ca\u652f\u6491\u5176\u4ed6\u7c7b\u578b\u4e1a\u52a1\u8d1f\u8f7d\u7684\u80fd\u529b\u3002\u53e6\u5916\uff0c\u57fa\u4e8e MatrixOne \u5b58\u7b97\u5206\u79bb\u548c\u591a\u79df\u6237\u7684\u7279\u6027\uff0c\u7528\u6237\u5728\u8bbe\u8ba1\u5e94\u7528\u67b6\u6784\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u975e\u5e38\u7075\u6d3b\u7684\u5c06\u8fc7\u53bb\u7531\u5e94\u7528\uff0c\u4e2d\u95f4\u4ef6\uff0c\u6216\u8005\u5176\u4ed6\u6570\u636e\u5e93\u6765\u89e3\u51b3\u7684\u8d1f\u8f7d\u9694\u79bb\u95ee\u9898\u6765\u901a\u8fc7 MatrixOne \u4e00\u7ad9\u5f0f\u5b9e\u73b0\u3002
\u5bf9\u4e8e MySQL \u7528\u6237\u800c\u8a00\uff0c\u5982\u679c\u78b0\u5230\u4ee5\u4e0b\u95ee\u9898\u74f6\u9888\u7684\u8bdd\uff0cMatrixOne \u4f1a\u662f\u4e00\u4e2a\u66f4\u5408\u9002\u7684\u9009\u62e9\uff1a
\u5728 MatrixOne \u7684\u6280\u672f\u535a\u5ba2\u4e2d\uff0c\u6211\u4eec\u4e5f\u6709\u8f83\u591a\u5173\u4e8e MySQL \u4e0e MatrixOne \u7684\u5bf9\u6bd4\u548c\u8fc1\u79fb\u4e4b\u7c7b\u7684\u6587\u7ae0\u4f9b\u53c2\u8003\u3002
MatrixOne \u4e0e MySQL \u5168\u9762\u5bf9\u6bd4--\u90e8\u7f72\u7bc7
MatrixOne \u4e0e MySQL \u5168\u9762\u5bf9\u6bd4--\u591a\u79df\u6237\u7bc7
MatrixOne \u4e0e MySQL \u5168\u9762\u5bf9\u6bd4--\u8fc1\u79fb\u7bc7
"},{"location":"MatrixOne/Performance-Tuning/performance-tuning-overview/","title":"SQL \u6027\u80fd\u8c03\u4f18\u65b9\u6cd5\u6982\u8ff0","text":"SQL \u6027\u80fd\u8c03\u4f18\u662f\u4e00\u79cd\u4f18\u5316\u6570\u636e\u5e93\u67e5\u8be2\u548c\u64cd\u4f5c\u7684\u8fc7\u7a0b\uff0c\u65e8\u5728\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u54cd\u5e94\u65f6\u95f4\u3002\u5e38\u89c1\u7684\u51e0\u79cd\u6027\u80fd\u8c03\u4f18\u65b9\u5f0f\u5982\u4e0b\uff1a
\u7d22\u5f15\u4f18\u5316\uff1a\u7d22\u5f15\u53ef\u4ee5\u52a0\u901f\u67e5\u8be2\uff0c\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u3002\u901a\u8fc7\u4f7f\u7528\u6b63\u786e\u7684\u7d22\u5f15\u7c7b\u578b\u3001\u9009\u62e9\u6b63\u786e\u7684\u7d22\u5f15\u5217\u3001\u907f\u514d\u4f7f\u7528\u8fc7\u591a\u7684\u7d22\u5f15\u4ee5\u53ca\u5b9a\u671f\u91cd\u65b0\u6784\u5efa\u7d22\u5f15\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6700\u5927\u5316\u5730\u5229\u7528\u7d22\u5f15\u6765\u63d0\u9ad8\u6027\u80fd\u3002
\u4f18\u5316\u67e5\u8be2\u8bed\u53e5\uff1a\u901a\u8fc7\u4f18\u5316\u67e5\u8be2\u8bed\u53e5\u7684\u7ed3\u6784\u3001\u907f\u514d\u4f7f\u7528\u4e0d\u5fc5\u8981\u7684\u5b50\u67e5\u8be2\u3001\u4f7f\u7528\u66f4\u6709\u6548\u7684 JOIN
\u8bed\u53e5\u3001\u907f\u514d\u4f7f\u7528 OR
\u64cd\u4f5c\u7b26\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u51cf\u5c11\u67e5\u8be2\u6240\u9700\u7684\u65f6\u95f4\u548c\u8d44\u6e90\u3002
\u4f18\u5316\u8868\u7ed3\u6784\uff1a\u4f18\u5316\u8868\u7ed3\u6784\uff0c\u5982\u9009\u62e9\u6b63\u786e\u7684\u6570\u636e\u7c7b\u578b\u3001\u907f\u514d NULL \u503c\u3001\u4f7f\u7528\u5408\u9002\u7684\u7ea6\u675f\u548c\u9ed8\u8ba4\u503c\u3001\u5f52\u4e00\u5316\u548c\u53cd\u5f52\u4e00\u5316\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u51cf\u5c11\u8868\u7684\u5b58\u50a8\u7a7a\u95f4\u548c\u51cf\u5c11\u67e5\u8be2\u7684\u65f6\u95f4\u3002
\u63a7\u5236\u6570\u636e\u91cf\uff1a\u901a\u8fc7\u9650\u5236\u8fd4\u56de\u7684\u6570\u636e\u91cf\u3001\u5206\u9875\u3001\u7f13\u5b58\u3001\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u51cf\u5c11\u67e5\u8be2\u6240\u9700\u7684\u65f6\u95f4\u548c\u8d44\u6e90\u3002
\u4f18\u5316\u670d\u52a1\u5668\u914d\u7f6e\uff1a\u901a\u8fc7\u589e\u52a0\u670d\u52a1\u5668\u7684\u5185\u5b58\u3001\u8c03\u6574\u6570\u636e\u5e93\u53c2\u6570\u3001\u5b9a\u671f\u6e05\u7406\u65e5\u5fd7\u548c\u7f13\u5b58\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u54cd\u5e94\u65f6\u95f4\u3002
\u76d1\u63a7\u548c\u8c03\u8bd5\uff1a\u4f7f\u7528\u6570\u636e\u5e93\u6027\u80fd\u76d1\u63a7\u5de5\u5177\u3001\u8c03\u8bd5 SQL \u67e5\u8be2\u8bed\u53e5\u3001\u67e5\u770b\u6570\u636e\u5e93\u7684\u65e5\u5fd7\u548c\u9519\u8bef\u4fe1\u606f\u7b49\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u53d1\u73b0\u5e76\u89e3\u51b3\u6027\u80fd\u95ee\u9898\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cSQL \u6027\u80fd\u8c03\u4f18\u662f\u4e00\u79cd\u590d\u6742\u7684\u8fc7\u7a0b\uff0c\u9700\u8981\u7efc\u5408\u8003\u8651\u6570\u636e\u5e93\u7684\u7ed3\u6784\u3001\u6570\u636e\u91cf\u3001\u67e5\u8be2\u6a21\u5f0f\u7b49\u591a\u4e2a\u56e0\u7d20\uff0c\u540c\u65f6\u9700\u8981\u4e0d\u65ad\u6d4b\u8bd5\u548c\u9a8c\u8bc1\u4f18\u5316\u7ed3\u679c\uff0c\u624d\u80fd\u6700\u7ec8\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u54cd\u5e94\u65f6\u95f4\u3002
MatrixOne \u5728\u6267\u884c SQL \u8bed\u53e5\u65f6\uff0c\u4f1a\u81ea\u52a8\u89c4\u5212\u5e76\u9009\u62e9\u6700\u4f18\u7684\u6267\u884c\u65b9\u6848\uff0c\u5e76\u975e\u6309\u7167 SQL \u8bed\u53e5\u8fdb\u884c\u67e5\u8be2\uff0c\u5f53\u524d MatrixOne \u652f\u6301\u901a\u8fc7 EXPLAIN \u89e3\u8bfb\u6267\u884c\u8ba1\u5212\u9009\u62e9\u6700\u4f18\u6267\u884c\u65b9\u6848\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff0c\u4e5f\u652f\u6301\u901a\u8fc7\u4f18\u5316\u8868\u7684\u7269\u7406\u6392\u5217\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u3002\u4e3a\u5e2e\u52a9\u4f60\u66f4\u597d\u7684 MatrixOne \u5bf9\u4e8e SQL \u8bed\u53e5\u67e5\u8be2\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff0c\u4f60\u53ef\u4ee5\u67e5\u770b\u4ee5\u4e0b\u6587\u6863\uff1a
Cluster by
\u8fbe\u5230\u6027\u80fd\u8c03\u4f18\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u5b66\u4e60\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u7684\u65b9\u6cd5\u3002\u5f53\u4f60\u786e\u5b9a\u4e86\u6267\u884c\u8ba1\u5212\u6240\u5b58\u5728\u7684\u95ee\u9898\u65f6\uff0c\u6bd4\u5982\u4f18\u5316\u5668\u9009\u62e9\u7684\u4e0d\u662f\u6700\u4f18\u67e5\u8be2\u8ba1\u5212\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 Optimizer Hints \u6765\u63a7\u5236\u6267\u884c\u8ba1\u5212\u7684\u751f\u6210\u3002
Hint
\u63d0\u793a\u6307\u4ee4\u544a\u8bc9\u67e5\u8be2\u4f18\u5316\u5668\u5982\u4f55\u6267\u884c\u67e5\u8be2\u8bed\u53e5\u3002\u901a\u8fc7\u4f7f\u7528\u63d0\u793a\uff0c\u53ef\u4ee5\u4e3a\u67e5\u8be2\u63d0\u4f9b\u6709\u5173\u5982\u4f55\u8bbf\u95ee\u6570\u636e\u7684\u4fe1\u606f\uff0c\u4ee5\u63d0\u9ad8\u67e5\u8be2\u7684\u6027\u80fd\u3002Hint
\u63d0\u793a\u6307\u4ee4\u901a\u5e38\u7528\u4e8e\u8c03\u4f18\u5927\u578b\u6216\u590d\u6742\u7684\u67e5\u8be2\u3002
\u63d0\u793a\u53ef\u4ee5\u7528\u4e8e\u4fee\u6539\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u5305\u62ec\u9009\u62e9\u4e0d\u540c\u7684\u7d22\u5f15\u3001\u4f7f\u7528\u4e0d\u540c\u7684 JOIN
\u7b97\u6cd5\u6216\u6539\u53d8\u8fde\u63a5\u987a\u5e8f\u7b49\u3002
SQL \u4e2d\u7684\u63d0\u793a\u4f7f\u7528\u6ce8\u91ca\u8bed\u6cd5\uff0c\u53ef\u4ee5\u5728\u67e5\u8be2\u8bed\u53e5\u4e2d\u6dfb\u52a0\u7279\u5b9a\u7684\u6ce8\u91ca\u6765\u6307\u5b9a\u63d0\u793a\u3002
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_1","title":"\u8bed\u6cd5\u683c\u5f0f","text":"{DELETE|INSERT|SELECT|UPDATE} /*+ hint [text] [hint[text]]... */\n
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_2","title":"\u8bed\u6cd5\u89e3\u91ca","text":"DELETE
\u3001INSERT
\u3001SELECT
\u3001UPDATE
\u662f SQL \u8bed\u53e5\u7684\u5173\u952e\u5b57\u3002
/*+ */
\u662f SQL \u8bed\u53e5\u4e2d\u7684\u6ce8\u91ca\u7b26\u53f7\u3002
hint
\u662f\u63d0\u793a\u7684\u5177\u4f53\u6307\u4ee4\u3002
text
\u662f\u63d0\u793a\u6307\u4ee4\u7684\u53c2\u6570\u3002
\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 SQL \u63d0\u793a\uff1a
/*+ INDEX (table index) */
\uff1a\u6307\u5b9a\u4f7f\u7528\u7279\u5b9a\u7684\u7d22\u5f15\u6765\u6267\u884c\u67e5\u8be2\u3002
/*+ FULL (table) */
\uff1a\u6307\u5b9a\u6267\u884c\u5168\u8868\u626b\u63cf\u800c\u4e0d\u662f\u4f7f\u7528\u7d22\u5f15\u3002
\u67e5\u8be2\u4f18\u5316\u5668\u9009\u62e9\u4e0d\u5408\u9002\u7684\u6267\u884c\u8ba1\u5212\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 hint
\u63d0\u793a\u6765\u6307\u5b9a\u4e00\u4e2a\u66f4\u597d\u7684\u6267\u884c\u8ba1\u5212\u3002\u4f8b\u5982\uff0c\u5f53\u67e5\u8be2\u6d89\u53ca\u591a\u4e2a\u8868\u65f6\uff0c\u4f18\u5316\u5668\u53ef\u80fd\u4f1a\u9009\u62e9\u9519\u8bef\u7684\u8fde\u63a5\u7b97\u6cd5\u6216\u8fde\u63a5\u987a\u5e8f\uff0c\u4ece\u800c\u5bfc\u81f4\u67e5\u8be2\u7684\u6027\u80fd\u4e0b\u964d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u63d0\u793a\u6765\u6307\u5b9a\u4e00\u4e2a\u66f4\u597d\u7684\u8fde\u63a5\u7b97\u6cd5\u6216\u8fde\u63a5\u987a\u5e8f\u3002
\u5f53\u67e5\u8be2\u5305\u542b\u590d\u6742\u7684\u5b50\u67e5\u8be2\u6216\u805a\u5408\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 hint
\u63d0\u793a\u6765\u4f18\u5316\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002\u7531\u4e8e\u4f18\u5316\u5668\u65e0\u6cd5\u5206\u6790\u590d\u6742\u7684\u5b50\u67e5\u8be2\u6216\u805a\u5408\u51fd\u6570\uff0c\u56e0\u6b64\u53ef\u80fd\u4f1a\u9009\u62e9\u9519\u8bef\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ece\u800c\u5bfc\u81f4\u67e5\u8be2\u7684\u6027\u80fd\u4e0b\u964d\u3002
\u5f53\u67e5\u8be2\u8bbf\u95ee\u7684\u6570\u636e\u91cf\u975e\u5e38\u5927\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 hint
\u63d0\u793a\u6765\u4f18\u5316\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u63d0\u793a\u6765\u6307\u5b9a\u4f7f\u7528\u7279\u5b9a\u7684\u7d22\u5f15\u6216\u8fde\u63a5\u7b97\u6cd5\uff0c\u4ee5\u63d0\u9ad8\u67e5\u8be2\u7684\u6027\u80fd\u3002
MatrixOne \u652f\u6301\u4f7f\u7528 hint
\u63d0\u793a\u7528\u4e8e\u9009\u62e9\u5168\u8868\u626b\u63cf\u6216\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\uff0c\u4ee5\u53ca\u4f18\u5316\u591a\u8868\u8fde\u63a5\u7684\u987a\u5e8f\u3002
\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u53ef\u4ee5\u52a0\u5feb\u67e5\u8be2\u7684\u901f\u5ea6\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5168\u8868\u626b\u63cf\u53ef\u80fd\u6bd4\u4f7f\u7528\u7d22\u5f15\u626b\u63cf\u66f4\u5feb\u3002\u4f8b\u5982\uff0c\u5f53\u67e5\u8be2\u6761\u4ef6\u8fc7\u4e8e\u5bbd\u6cdb\u65f6\uff0c\u4f7f\u7528\u7d22\u5f15\u53ef\u80fd\u4f1a\u53d8\u5f97\u6bd4\u8f83\u7f13\u6162\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u63d0\u793a\u8bed\u6cd5\u6765\u9009\u62e9\u4f7f\u7528\u5168\u8868\u626b\u63cf\u6216\u7d22\u5f15\u626b\u63cf\uff1a
SELECT /*+ INDEX(table_name index_name) */ column_name FROM table_name WHERE ...\n
\u5176\u4e2d\uff0ctable_name \u662f\u8868\u540d\uff0cindex_name \u662f\u7d22\u5f15\u540d\uff0ccolumn_name \u662f\u5217\u540d\u3002\u5982\u679c\u6307\u5b9a\u4e86\u7d22\u5f15\u540d\uff0c\u5219\u67e5\u8be2\u5c06\u4f7f\u7528\u8be5\u7d22\u5f15\u8fdb\u884c\u626b\u63cf\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u7d22\u5f15\u540d\uff0c\u5219\u67e5\u8be2\u5c06\u4f7f\u7528\u5168\u8868\u626b\u63cf\u3002
\u5f53\u67e5\u8be2\u6d89\u53ca\u591a\u4e2a\u8868\u65f6\uff0c\u67e5\u8be2\u4f18\u5316\u5668\u5c06\u5c1d\u8bd5\u9009\u62e9\u6700\u4f18\u7684\u8fde\u63a5\u987a\u5e8f\u3002\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f18\u5316\u5668\u53ef\u80fd\u65e0\u6cd5\u9009\u62e9\u6700\u4f18\u7684\u8fde\u63a5\u987a\u5e8f\uff0c\u4ece\u800c\u5bfc\u81f4\u67e5\u8be2\u7684\u6027\u80fd\u4e0b\u964d\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u63d0\u793a\u8bed\u6cd5\u6765\u4f18\u5316\u591a\u8868\u8fde\u63a5\u7684\u987a\u5e8f\uff1a
SELECT /*+ ORDERED */ column_name FROM table1, table2 WHERE table1.column1 = table2.column2;\n
\u5176\u4e2d\uff0cORDERED \u6307\u5b9a\u4e86\u67e5\u8be2\u5e94\u6309\u7167\u8868\u7684\u987a\u5e8f\u8fde\u63a5\uff0c\u5373\u5148\u8fde\u63a5 table1\uff0c\u518d\u8fde\u63a5 table2\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4f18\u5316\u5668\u9009\u62e9\u9519\u8bef\u7684\u8fde\u63a5\u987a\u5e8f\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u7684\u6027\u80fd\u3002
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_4","title":"\u793a\u4f8b","text":"-- \u65b0\u5efa\u4e00\u4e2a \u540d\u4e3a orders \u7684\u8868\nCREATE TABLE order (\norder_id INT PRIMARY KEY,\ncustomer_id INT,\norder_date DATE,\norder_total DECIMAL(10, 2)\n);\n-- \u63d2\u5165\u6570\u636e\nINSERT INTO order (order_id, customer_id, order_date, order_total)\nVALUES\n(1, 101, '2022-05-10', 100.00),\n(2, 102, '2022-05-09', 150.00),\n(3, 103, '2022-05-08', 200.00),\n(4, 104, '2022-05-07', 50.00);\n-- \u67e5\u8be2\u67d0\u4e2a\u5ba2\u6237\u7684\u6240\u6709\u8ba2\u5355\uff0c\u5e76\u6309\u8ba2\u5355\u65e5\u671f\u964d\u5e8f\u6392\u5217\nSELECT order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n
\u4e3a\u4e86\u4f18\u5316\u8fd9\u4e2a\u67e5\u8be2\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b hint
\u63d0\u793a\uff1a
-- \u4f7f\u7528\u540d\u4e3a idx_customer_id \u7684\u7d22\u5f15\u6765\u6267\u884c\u67e5\u8be2\uff0c\u8fd9\u4e2a\u7d22\u5f15\u662f\u57fa\u4e8e customer_id \u5b57\u6bb5\u521b\u5efa\u7684\nSELECT /*+ INDEX(orders idx_customer_id) */ order_id, order_date, order_total\nFROM orders\nWHERE customer_id = 123\nORDER BY order_date DESC;\n
"},{"location":"MatrixOne/Performance-Tuning/control-execution-plan/optimizer-hints/#_5","title":"\u9650\u5236","text":"\u5f53\u524d /*+ HINT_NAME(t1, t2) */
\u4ec5\u8bed\u6cd5\u5b9e\u73b0\uff0c\u6682\u65e0\u6cd5\u63a7\u5236\u6267\u884c\u8ba1\u5212\u3002
SQL \u67e5\u8be2\u4e2d\u53ef\u80fd\u4f1a\u4f7f\u7528\u805a\u5408\u8ba1\u7b97\uff0c\u53ef\u4ee5\u901a\u8fc7 EXPLAIN \u8bed\u53e5\u6765\u67e5\u770b\u805a\u5408\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#_1","title":"\u793a\u4f8b","text":"\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u805a\u5408\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-aggregation/#hash-aggregation","title":"Hash Aggregation","text":"Hash Aggregation \u7b97\u6cd5\u5728\u6267\u884c\u805a\u5408\u65f6\u4f7f\u7528 Hash \u8868\u5b58\u50a8\u4e2d\u95f4\u7ed3\u679c\u3002\u6b64\u7b97\u6cd5\u91c7\u7528\u591a\u7ebf\u7a0b\u5e76\u53d1\u4f18\u5316\uff0c\u6267\u884c\u901f\u5ea6\u5feb\uff0c\u4f46\u4e0e Stream Aggregation \u7b97\u6cd5\u76f8\u6bd4\u4f1a\u6d88\u8017\u8f83\u591a\u5185\u5b58\u3002
\u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528 Hash Aggregation \u7684\u4f8b\u5b50\uff1a
> SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+----------+\n| count(*) |\n+----------+\n| 9 |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_AGG() */ count(*) FROM t1;\n+-------------------------------------------------+\n| QUERY PLAN |\n+-------------------------------------------------+\n| Project |\n| -> Aggregate |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on db1.t1 |\n| Aggregate Functions: starcount(1) |\n+-------------------------------------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/","title":"\u7528 EXPLAIN \u67e5\u770b JOIN \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212","text":"SQL \u67e5\u8be2\u4e2d\u53ef\u80fd\u4f1a\u4f7f\u7528 JOIN \u8fdb\u884c\u8868\u8fde\u63a5\uff0c\u53ef\u4ee5\u901a\u8fc7 EXPLAIN \u8bed\u53e5\u6765\u67e5\u770b JOIN \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#_1","title":"\u793a\u4f8b","text":"\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb JOIN \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-joins/#hash-join","title":"Hash Join","text":"\u5728 Hash Join
\u64cd\u4f5c\u4e2d\uff0cMatrixOne \u9996\u5148\u8bfb\u53d6\u8868 t1 \u4e0e t2 \u4e2d\u76f8\u5bf9\u8f83\u5c0f\u7684\u4e00\u4e2a\u8868\u5bf9\u5176\u4e2d\u6bcf\u4e2a\u9700\u8981\u88ab\u8fde\u63a5\u7684\u503c\u4f7f\u7528\u54c8\u5e0c\u51fd\u6570\uff0c\u5f97\u5230\u4e00\u4e2a\u54c8\u5e0c\u8868\uff1b\u7136\u540e\u5bf9\u53e6\u4e00\u4e2a\u8868\u7684\u6bcf\u4e00\u884c\u8fdb\u884c\u626b\u63cf\u5e76\u8ba1\u7b97\u54c8\u5e0c\u503c\uff0c\u4e0e\u4e0a\u4e00\u6b65\u751f\u6210\u7684\u54c8\u5e0c\u8868\u8fdb\u884c\u6bd4\u5bf9\uff0c\u5982\u679c\u6709\u7b26\u5408\u8fde\u63a5\u6807\u51c6\u7684\u503c\uff0c\u5219\u6839\u636e\u8fde\u63a5\u8c13\u8bcd\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\u8868\u3002
MatrixOne \u4e2d\u7684 Hash Join \u7b97\u5b50\u662f\u591a\u7ebf\u7a0b\u7684\uff0c\u5e76\u4e14\u53ef\u4ee5\u5e76\u53d1\u6267\u884c\u3002
\u4e0b\u9762\u662f\u4e00\u4e2a Hash Join
\u793a\u4f8b\uff1a
> SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt | id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 1 | 1 | 4 | 3 | 1113.32 | 111332 | 1113 | hello | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 1 | 1 | 4 | 3 | 1113.32 | 111332 | 1113 | hello | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 2 | 2 | 5 | 2 | 2252.05 | 225205 | 2252 | bye | sub query | 2022-04-28 | 2022-04-28 22:40:11 | 2 | 2 | 5 | 2 | 2252.05 | 225205 | 2252 | bye | sub query | 2022-04-28 | 2022-04-28 22:40:11 |\n| 3 | 6 | 6 | 3 | 3663.21 | 366321 | 3663 | hi | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 3 | 6 | 6 | 3 | 3663.21 | 366321 | 3663 | hi | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 | 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 | 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 | 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 | 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 | 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n9 rows in set (0.00 sec)\n\nmysql> EXPLAIN SELECT /*+ HASH_JOIN(t1, t2) */ * FROM t1, t2 WHERE t1.id = t2.id;\n+------------------------------------+\n| QUERY PLAN |\n+------------------------------------+\n| Project |\n| -> Join |\n| Join Type: INNER |\n| Join Cond: (t1.id = t2.id) |\n| -> Table Scan on db1.t1 |\n| -> Table Scan on db1.t2 |\n+------------------------------------+\n6 rows in set (0.01 sec)\n
MatrixOne \u4f1a\u6309\u7167\u4ee5\u4e0b\u987a\u5e8f\u6267\u884c Hash Join
\u7b97\u5b50\uff1a
(t1.id = t2.id)
\u3002\u6267\u884c\u8ba1\u5212\uff08execution plan\uff0c\u4e5f\u53eb\u67e5\u8be2\u8ba1\u5212\u6216\u8005\u89e3\u91ca\u8ba1\u5212\uff09\u662f\u6570\u636e\u5e93\u6267\u884c SQL \u8bed\u53e5\u7684\u5177\u4f53\u6b65\u9aa4\uff0c\u4f8b\u5982\u901a\u8fc7\u7d22\u5f15\u8fd8\u662f\u5168\u8868\u626b\u63cf\u8bbf\u95ee\u8868\u4e2d\u7684\u6570\u636e\uff0c\u8fde\u63a5\u67e5\u8be2\u7684\u5b9e\u73b0\u65b9\u5f0f\u548c\u8fde\u63a5\u7684\u987a\u5e8f\u7b49\uff1b\u6267\u884c\u8ba1\u5212\u6839\u636e\u4f60\u7684\u8868\u3001\u5217\u3001\u7d22\u5f15\u548c WHERE
\u5b50\u53e5\u4e2d\u7684\u6761\u4ef6\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u53ef\u4ee5\u544a\u8bc9\u4f60\u8fd9\u4e2a\u67e5\u8be2\u5c06\u4f1a\u88ab\u5982\u4f55\u6267\u884c\u6216\u8005\u5df2\u7ecf\u88ab\u5982\u4f55\u6267\u884c\u8fc7\uff0c\u53ef\u4ee5\u5728\u4e0d\u8bfb\u53d6\u6240\u6709\u884c\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u5bf9\u5de8\u5927\u8868\u7684\u67e5\u8be2\uff1b\u53ef\u4ee5\u5728\u4e0d\u6bd4\u8f83\u884c\u7684\u6bcf\u4e2a\u7ec4\u5408\u7684\u60c5\u51b5\u4e0b\u6267\u884c\u6d89\u53ca\u591a\u4e2a\u8868\u7684\u8fde\u63a5\u3002\u5982\u679c SQL \u8bed\u53e5\u6027\u80fd\u4e0d\u591f\u7406\u60f3\uff0c\u9996\u5148\u5e94\u8be5\u67e5\u770b\u5b83\u7684\u6267\u884c\u8ba1\u5212\u3002\u548c\u5927\u591a\u6570\u6210\u719f\u7684\u6570\u636e\u5e93\u4ea7\u54c1\u4e00\u6837\uff0cMatrixOne \u6570\u636e\u5e93\u4e5f\u63d0\u4f9b\u4e86\u8fd9\u4e00\u5206\u6790\u67e5\u8be2\u8bed\u53e5\u6027\u80fd\u7684\u529f\u80fd\u3002
MatrixOne \u67e5\u8be2\u4f18\u5316\u5668\u5bf9\u8f93\u5165\u7684 SQL \u67e5\u8be2\u8bed\u53e5\u901a\u8fc7\u6267\u884c\u8ba1\u5212\u800c\u9009\u62e9\u51fa\u6548\u7387\u6700\u9ad8\u7684\u4e00\u79cd\u6267\u884c\u65b9\u6848\u3002\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6267\u884c\u8ba1\u5212\u770b\u5230 SQL \u4ee3\u7801\u4e2d\u90a3\u4e9b\u6548\u7387\u6bd4\u8f83\u4f4e\u7684\u5730\u65b9\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-overview/#explain","title":"\u4f7f\u7528EXPLAIN
\u67e5\u8be2\u6267\u884c\u8ba1\u5212","text":"\u4f7f\u7528 EXPLAIN
\u53ef\u67e5\u770b MatrixOne \u6267\u884c\u67d0\u6761 SQL \u8bed\u53e5\u65f6\u7684\u6267\u884c\u8ba1\u5212\u3002
EXPLAIN
\u53ef\u4ee5\u548c SELECT
\u3001DELETE
\u3001INSERT
\u3001REPLACE
\u3001UPDATE
\u8bed\u53e5\u7ed3\u5408\u4f7f\u7528\u3002\u5f53 EXPLAIN
\u4e0e\u53ef\u89e3\u91ca\u7684\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u65f6\uff0cMatrixOne \u4f1a\u89e3\u91ca\u5b83\u5c06\u5982\u4f55\u5904\u7406\u8be5\u8bed\u53e5\uff0c\u5305\u62ec\u6709\u5173\u8868\u5982\u4f55\u8fde\u63a5\u4ee5\u53ca\u8fde\u63a5\u987a\u5e8f\u7684\u4fe1\u606f\u3002
Note
\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u65f6\uff0c\u4e3a\u907f\u514d\u8f93\u51fa\u7ed3\u679c\u5728\u7ec8\u7aef\u4e2d\u6362\u884c\uff0c\u53ef\u5148\u6267\u884c pager less -S
\u547d\u4ee4\u3002\u6267\u884c\u547d\u4ee4\u540e\uff0c\u65b0\u7684 EXPLAIN
\u7684\u8f93\u51fa\u7ed3\u679c\u4e0d\u518d\u6362\u884c\uff0c\u53ef\u6309\u53f3\u7bad\u5934 \u2192 \u952e\u6c34\u5e73\u6eda\u52a8\u9605\u8bfb\u8f93\u51fa\u7ed3\u679c\u3002
\u4e0b\u9762\u7684\u4f8b\u5b50\u5e2e\u52a9\u4f60\u4e86\u89e3 EXPLAIN
\u3002
\u6570\u636e\u51c6\u5907\uff1a
CREATE TABLE t (id INT NOT NULL PRIMARY KEY auto_increment, a INT NOT NULL, pad1 VARCHAR(255), INDEX(a));\nINSERT INTO t VALUES (1, 1, 'aaa'),(2,2, 'bbb');\nEXPLAIN SELECT * FROM t WHERE a = 1;\n
\u8fd4\u56de\u7ed3\u679c\uff1a
+--------------------------------+\n| QUERY PLAN |\n+--------------------------------+\n| Project |\n| -> Table Scan on db1.t |\n| Filter Cond: (t.a = 1) |\n+--------------------------------+\n3 rows in set (0.01 sec)\n
EXPLAIN
\u5b9e\u9645\u4e0d\u4f1a\u6267\u884c\u67e5\u8be2\u3002EXPLAIN ANALYZE
\u53ef\u7528\u4e8e\u5b9e\u9645\u6267\u884c\u67e5\u8be2\u5e76\u663e\u793a\u6267\u884c\u8ba1\u5212\u3002\u5982\u679c MatrixOne \u6240\u9009\u7684\u6267\u884c\u8ba1\u5212\u975e\u6700\u4f18\uff0c\u53ef\u7528 EXPLAIN
\u6216 EXPLAIN ANALYZE
\u6765\u8fdb\u884c\u8bca\u65ad\u3002
EXPLAIN \u8f93\u51fa\u5206\u6790
QUERY PLAN\uff0c\u5373\u672c\u6b21\u6267\u884c\u7684\u4e3b\u9898\uff0c\u67e5\u8be2\u8ba1\u5212
Filter Cond\uff1a\u8fc7\u6ee4\u6761\u4ef6
Table Scan\uff1a\u5bf9\u67d0\u4e2a\u5168\u8868\u8fdb\u884c\u626b\u63cf
Project \u4e3a\u8fd9\u6b21\u67e5\u8be2\u8fc7\u7a0b\u4e2d\u7684\u6267\u884c\u987a\u5e8f\u7684\u7236\u8282\u70b9\uff0cProject \u7684\u7ed3\u6784\u662f\u6811\u72b6\u7684\uff0c\u5b50\u8282\u70b9\u8ba1\u7b97\u5b8c\u6210\u540e\u201c\u6d41\u5165\u201d\u7236\u8282\u70b9\u3002\u7236\u8282\u70b9\u3001\u5b50\u8282\u70b9\u548c\u540c\u7ea7\u8282\u70b9\u53ef\u80fd\u5e76\u884c\u6267\u884c\u67e5\u8be2\u7684\u4e00\u90e8\u5206\u3002
\u8303\u56f4\u67e5\u8be2
\u5728 WHERE/HAVING/ON
\u6761\u4ef6\u4e2d\uff0cMatrixOne \u4f18\u5316\u5668\u4f1a\u5206\u6790\u4e3b\u952e\u6216\u7d22\u5f15\u952e\u7684\u67e5\u8be2\u8fd4\u56de\u3002\u5982\u6570\u5b57\u3001\u65e5\u671f\u7c7b\u578b\u7684\u6bd4\u8f83\u7b26\uff0c\u5982\u5927\u4e8e\u3001\u5c0f\u4e8e\u3001\u7b49\u4e8e\u4ee5\u53ca\u5927\u4e8e\u7b49\u4e8e\u3001\u5c0f\u4e8e\u7b49\u4e8e\uff0c\u5b57\u7b26\u7c7b\u578b\u7684 LIKE
\u7b26\u53f7\u7b49\u3002
MatrixOne \u4f1a\u6267\u884c\u591a\u79cd\u5b50\u67e5\u8be2\u76f8\u5173\u7684\u4f18\u5316\uff0c\u4ee5\u63d0\u5347\u5b50\u67e5\u8be2\u7684\u6267\u884c\u6027\u80fd\u3002\u672c\u6587\u6863\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u89c1\u5b50\u67e5\u8be2\u7684\u4f18\u5316\u65b9\u5f0f\uff0c\u4ee5\u53ca\u5982\u4f55\u89e3\u8bfb EXPLAIN \u8bed\u53e5\u8fd4\u56de\u7684\u6267\u884c\u8ba1\u5212\u4fe1\u606f\u3002
\u4ece SQL \u8bed\u53e5\u6267\u884c\u60c5\u51b5\u4e0a\uff0c\u5b50\u67e5\u8be2\u8bed\u53e5\u4e00\u822c\u6709\u4ee5\u4e0b\u4e24\u79cd\u5f62\u5f0f\uff1a
\u65e0\u5173\u8054\u5b50\u67e5\u8be2 (Self-contained Subquery)\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u662f\u5b8c\u5168\u72ec\u7acb\u4e8e\u5916\u5c42\u67e5\u8be2\u7684\u3002
\u4f8b\u5982\uff1aselect * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);
\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u5148\u6267\u884c\u5185\u5c42\u67e5\u8be2\uff1a(select t2.id from t2 where t2.id>=3)
\u3002
\u5f97\u5230\u5185\u5c42\u67e5\u8be2\u7684\u7ed3\u679c\u540e\u5e26\u5165\u5916\u5c42\uff0c\u518d\u6267\u884c\u5916\u5c42\u67e5\u8be2\u3002
\u5173\u8054\u5b50\u67e5\u8be2\uff08Correlated Subquery\uff09\uff1a\u6570\u636e\u5e93\u5d4c\u5957\u67e5\u8be2\u4e2d\u5185\u5c42\u67e5\u8be2\u548c\u5916\u5c42\u67e5\u8be2\u4e0d\u76f8\u4e92\u72ec\u7acb\uff0c\u5185\u5c42\u67e5\u8be2\u4e5f\u4f9d\u8d56\u4e8e\u5916\u5c42\u67e5\u8be2\u3002
\u4f8b\u5982\uff1aSELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6267\u884c\u987a\u5e8f\u4e3a\uff1a
\u5148\u4ece\u5916\u5c42\u67e5\u8be2\u4e2d\u67e5\u8be2\u4e2d\u4e00\u6761\u8bb0\u5f55\uff1aSELECT * FROM t1 WHERE id
\u3002
\u518d\u5c06\u67e5\u8be2\u5230\u7684\u8bb0\u5f55\u653e\u5230\u5185\u5c42\u67e5\u8be2\u4e2d\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u518d\u653e\u5230\u5916\u5c42\u4e2d\u67e5\u8be2\u3002
\u91cd\u590d\u4ee5\u4e0a\u6b65\u9aa4
\u4f46\u662f MatrixOne \u5728\u5904\u7406\u8be5 SQL \u8bed\u53e5\u65f6\u4f1a\u5c06\u5176\u6539\u5199\u4e3a\u7b49\u4ef7\u7684 JOIN
\u67e5\u8be2\uff1aselect t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;
\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u5b50\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-subqueries/#_2","title":"\u65e0\u5173\u8054\u5b50\u67e5\u8be2","text":"> select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 3 | 6 | 6 | 3 | 3663.21 | 366321 | 3663 | hi | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n7 rows in set (0.02 sec)\n\n> explain select * from t1 where t1.id in (select t2.id from t2 where t2.id>=3);\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Join |\n| Join Type: SEMI |\n| Join Cond: (t1.id = t2.id) |\n| -> Table Scan on db1.t1 |\n| -> Table Scan on db1.t2 |\n| Filter Cond: (t2.id >= 3) |\n+-----------------------------------------+\n7 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u6267\u884c\u8ba1\u5212\u7684\u6267\u884c\u987a\u5e8f\u662f\uff1a
\u5148\u6267\u884c\u5185\u5c42\u67e5\u8be2\uff1a(select t2.id from t2 where t2.id>=3)
\u3002
\u5f97\u5230\u5185\u5c42\u67e5\u8be2\u7684\u7ed3\u679c\u540e\u5e26\u5165\u5916\u5c42\uff0c\u518d\u6267\u884c\u5916\u5c42\u67e5\u8be2\u3002
> SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 4 | 7 | 1 | 5 | 4715.22 | 471522 | 4715 | good morning | my subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n6 rows in set (0.01 sec)\n\nmysql> explain SELECT * FROM t1 WHERE id in (SELECT id FROM t2 WHERE t1.ti = t2.ti and t2.id>=4);\n+---------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------+\n| Project |\n| -> Join |\n| Join Type: SEMI |\n| Join Cond: ((t1.ti = t2.ti) IS TRUE), (t1.id = t2.id) |\n| -> Table Scan on db1.t1 |\n| -> Table Scan on db1.t2 |\n| Filter Cond: (t2.id >= 4) |\n+---------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
MatrixOne \u5728\u5904\u7406\u8be5 SQL \u8bed\u53e5\u65f6\u4f1a\u5c06\u5176\u6539\u5199\u4e3a\u7b49\u4ef7\u7684 JOIN
\u67e5\u8be2\uff1aselect t1.* from t1 join t2 on t1.id=t2.id where t2.id>=4;
\uff0c\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u6267\u884c\u8ba1\u5212\u7684\u6267\u884c\u987a\u5e8f\u662f\uff1a
\u5148\u6267\u884c\u8fc7\u6ee4\u67e5\u8be2 where t2.id>=4;
\u3002
\u518d\u626b\u63cf\u8868 Table Scan on db1.t2
\uff0c\u5c06\u7ed3\u679c\u201c\u6d41\u5165\u201d\u7236\u8282\u70b9\u540e\uff0c
\u626b\u63cf\u8868 Table Scan on db1.t1
\u3002
\u6700\u540e\u6267\u884c JOIN
\u67e5\u8be2\u3002
EXPLAIN
\u8bed\u53e5\u8fd4\u56de\u7684\u7ed3\u679c\u4f1a\u663e\u793a\u89c6\u56fe\u5f15\u7528\u7684\u8868\uff0c\u800c\u4e0d\u662f\u89c6\u56fe\u672c\u8eab\u7684\u540d\u79f0\u3002\u8fd9\u662f\u56e0\u4e3a\u89c6\u56fe\u662f\u4e00\u5f20\u865a\u62df\u8868\uff0c\u672c\u8eab\u5e76\u4e0d\u5b58\u50a8\u4efb\u4f55\u6570\u636e\u3002\u89c6\u56fe\u7684\u5b9a\u4e49\u4f1a\u548c\u67e5\u8be2\u8bed\u53e5\u7684\u5176\u4f59\u90e8\u5206\u5728 SQL \u4f18\u5316\u8fc7\u7a0b\u4e2d\u8fdb\u884c\u5408\u5e76\u3002
\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb VIEW \u7684\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists t1;\n> create table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> drop table if exists t2;\n> create table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\n> insert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\n> insert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\n> create view v1 as select * from (select * from t1) sub where id > 4;\n> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n
\u5982\u4e0a\u8ff0\u793a\u4f8b\u6240\u793a\uff0c\u65b0\u5efa\u4e86\u4e00\u4e2a\u547d\u540d\u4e3a v1 \u7684 VIEW\uff0c\u5e76\u67e5\u8be2 v1 \u7684\u7ed3\u679c\u3002\u90a3\u4e48\u6211\u4eec\u770b\u4e00\u4e0b\u8fd9\u4e2a\u89c6\u56fe\u7684\u6267\u884c\u8fc7\u7a0b\uff1a
> explain select * from v1;\n+----------------------------------+\n| QUERY PLAN |\n+----------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Filter Cond: (t1.id > 4) |\n+----------------------------------+\n3 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230 Project \u4e3a\u8fd9\u6b21\u67e5\u8be2\u8fc7\u7a0b\u4e2d\u7684\u6267\u884c\u987a\u5e8f\u7684\u7236\u8282\u70b9\uff0c\u9996\u5148\u662f\u4ece\u7f29\u8fdb\u6700\u591a\u7684\u5b50\u8282\u70b9\u5f00\u59cb\u8ba1\u7b97\uff0c\u5b8c\u6210\u540e\u201c\u6d41\u5165\u201d\u5b83\u7684\u4e0a\u5c42\u7236\u8282\u70b9\uff0c\u6700\u7ec8\u201c\u6d41\u5165\u201dProject \u7236\u8282\u70b9\u3002
\u5148\u6267\u884c\uff1a
\u518d\u6267\u884c\uff1a
\u4e0b\u9762\u7684\u67e5\u8be2\u7684\u6267\u884c\u65b9\u5f0f\u4e0e\u4e0a\u8ff0\u6267\u884c\u65b9\u5f0f\u7c7b\u4f3c\uff1a
> explain select * from (select * from t1) sub where id > 4;\n+----------------------------------+\n| QUERY PLAN |\n+----------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Filter Cond: (t1.id > 4) |\n+----------------------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/","title":"\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u6267\u884c\u8ba1\u5212","text":"SQL \u662f\u4e00\u79cd\u58f0\u660e\u6027\u8bed\u8a00\uff0c\u56e0\u6b64\u65e0\u6cd5\u901a\u8fc7 SQL \u8bed\u53e5\u76f4\u63a5\u5224\u65ad\u4e00\u6761\u67e5\u8be2\u7684\u6267\u884c\u662f\u5426\u6709\u6548\u7387\uff0c\u4f46\u662f\u53ef\u4ee5\u4f7f\u7528 EXPLAIN
\u8bed\u53e5\u67e5\u770b\u5f53\u524d\u7684\u6267\u884c\u8ba1\u5212\u3002
\u6211\u4eec\u8fd9\u91cc\u51c6\u5907\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5e2e\u52a9\u4f60\u7406\u89e3\u4f7f\u7528 EXPLAIN \u89e3\u8bfb\u6267\u884c\u8ba1\u5212\u3002
> drop table if exists a;\n> create table a(a int);\n> insert into a values(1),(2),(3),(4),(5),(6),(7),(8);\n> select count(*) from a where a>=2 and a<=8;\n+----------+\n| count(*) |\n+----------+\n| 7 |\n+----------+\n1 row in set (0.00 sec)\n\n> explain select count(*) from a where a>=2 and a<=8;\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Aggregate |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on db1.a |\n| Filter Cond: (a.a >= 2), (a.a <= 8) |\n+---------------------------------------------------+\n5 rows in set (0.01 sec)\n
\u4ee5\u4e0a\u662f\u8be5\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u7ed3\u679c\u3002\u4ece Filter Cond
\u7b97\u5b50\u5f00\u59cb\u5411\u4e0a\u770b\uff0c\u67e5\u8be2\u7684\u6267\u884c\u8fc7\u7a0b\u5982\u4e0b\uff1a
Filter Cond
\uff1a\u5373\u8fc7\u6ee4\u51fa\u6570\u636e\u5b57\u6bb5\u4e3a a
\u4e14\u5927\u4e8e\u7b49\u4e8e 2\uff0c\u5c0f\u4e8e\u7b49\u4e8e 8 \u7684\u6574\u6570\uff0c\u6309\u7167\u8ba1\u7b97\u63a8\u7406\uff0c\u5e94\u8be5\u4e3a (2),(3),(4),(5),(6),(7),(8)
\u3002\u6700\u7ec8\uff0c\u5f97\u5230\u67e5\u8be2\u7ed3\u679c\u4e3a 7\uff0c\u5373 count(*)
= 7\u3002
EXPLAIN \u8bed\u53e5\u53ea\u8fd4\u56de\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u5e76\u4e0d\u6267\u884c\u8be5\u67e5\u8be2\u3002\u82e5\u8981\u83b7\u53d6\u5b9e\u9645\u7684\u6267\u884c\u65f6\u95f4\uff0c\u53ef\u6267\u884c\u8be5\u67e5\u8be2\uff0c\u6216\u4f7f\u7528 EXPLAIN ANALYZE \u8bed\u53e5\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#explain-analyze","title":"\u4ec0\u4e48\u662f EXPLAIN ANALYZE","text":"EXPLAIN ANALYZE \u662f\u4e00\u4e2a\u7528\u4e8e\u67e5\u8be2\u7684\u5206\u6790\u5de5\u5177\uff0c\u5b83\u5c06\u5411\u4f60\u663e\u793a SQL \u5728\u67e5\u8be2\u4e0a\u82b1\u8d39\u7684\u65f6\u95f4\u4ee5\u53ca\u539f\u56e0\u3002\u5b83\u5c06\u8ba1\u5212\u67e5\u8be2\u3001\u68c0\u6d4b\u5b83\u5e76\u6267\u884c\u5b83\uff0c\u540c\u65f6\u8ba1\u7b97\u884c\u6570\u5e76\u6d4b\u91cf\u5728\u6267\u884c\u8ba1\u5212\u7684\u5404\u4e2a\u70b9\u82b1\u8d39\u7684\u65f6\u95f4\u3002\u6267\u884c\u5b8c\u6210\u540e\uff0cEXPLAIN ANALYZE \u5c06\u6253\u5370\u8ba1\u5212\u548c\u6d4b\u91cf\u7ed3\u679c\uff0c\u800c\u4e0d\u662f\u67e5\u8be2\u7ed3\u679c\u3002
\u9664\u4e86\u6b63\u5e38 EXPLAIN \u5c06\u6253\u5370\u7684\u67e5\u8be2\u8ba1\u5212\u548c\u4f30\u8ba1\u6210\u672c\u4e4b\u5916\uff0cEXPLAIN ANALYZE \u8fd8\u6253\u5370\u6267\u884c\u8ba1\u5212\u4e2d\u5404\u4e2a\u8fed\u4ee3\u5668\u7684\u5b9e\u9645\u6210\u672c\u3002
"},{"location":"MatrixOne/Performance-Tuning/explain/explain-walkthrough/#_3","title":"\u5982\u4f55\u4f7f\u7528\u5b83\uff1f","text":"\u8fd9\u91cc\u8fd8\u662f\u7ee7\u7eed\u4f7f\u7528\u4e0a\u8ff0\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff1a
> explain analyze select count(*) from a where a>=2 and a<=8;\n+---------------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------------------------------------------------------------------------------+\n| Project |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=8bytes OutputSize=8bytes MemorySize=8bytes |\n| -> Aggregate |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=7 outputRows=1 InputSize=28bytes OutputSize=8bytes MemorySize=16bytes |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on db1.a |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=8 outputRows=7 InputSize=32bytes OutputSize=28bytes MemorySize=75bytes |\n| Filter Cond: (a.a >= 2), (a.a <= 8) |\n+---------------------------------------------------------------------------------------------------------------------------------------+\n8 rows in set (0.00 sec)\n
\u4ece\u6253\u5370\u7684\u6267\u884c\u7ed3\u679c\u6765\u770b\uff0c\u5f53\u5206\u522b\u6267\u884c\u805a\u5408\u8ba1\u7b97\u548c\u626b\u63cf\u8868\u65f6\uff0c\u90fd\u4f1a\u5f97\u51fa\u4ee5\u4e0b\u51e0\u4e2a\u6d4b\u91cf\u503c\uff0c\u8fd9\u4e9b\u6d4b\u91cf\u503c\u53ef\u4ee5\u4f5c\u4e3a\u53c2\u8003\u9879\uff1a
\u901a\u8fc7\u5728\u8fd9\u4e9b\u4fe1\u606f\uff0c\u4f60\u53ef\u4ee5\u5206\u6790\u67e5\u8be2\u5e76\u7406\u89e3\u5b83\u4eec\u4e3a\u4f55\u662f\u8fd9\u6837\u7684\u8868\u73b0\uff0c\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\u8fdb\u884c\u63a2\u7d22\uff1a
\u6267\u884c\u8fd9\u4e9b\u67e5\u8be2\uff0c\u9700\u8981\u82b1\u8d39\u591a\u4e45\uff1f\u4f60\u53ef\u4ee5\u67e5\u770b\u603b\u8017\u65f6\u3002
\u4e3a\u4ec0\u4e48\u6267\u884c\u5f53\u524d\u7684\u67e5\u8be2\u8ba1\u5212\uff0c\u800c\u4e0d\u662f\u5176\u4ed6\u7684\u6267\u884c\u8ba1\u5212\uff1f\u4f60\u53ef\u4ee5\u67e5\u770b\u884c\u8ba1\u6570\u5668\u3002\u5f53\u4f30\u8ba1\u884c\u6570\u4e0e\u5b9e\u9645\u884c\u6570\u4e4b\u95f4\u7684\u5de8\u5927\u5dee\u5f02\uff08\u5373\uff0c\u51e0\u4e2a\u6570\u91cf\u7ea7\u6216\u66f4\u591a\uff09\u65f6\uff0c\u8bf4\u660e\u4f18\u5316\u5668\u6839\u636e\u4f30\u8ba1\u9009\u62e9\u8ba1\u5212\uff0c\u4f46\u67e5\u770b\u5b9e\u9645\u6267\u884c\u53ef\u4ee5\u65b9\u4fbf\u4f60\u5f97\u77e5\u5230\u5e95\u54ea\u4e2a\u6267\u884c\u8ba1\u5212\u66f4\u597d\u3002
\u6240\u4ee5\u4f7f\u7528 EXPLAIN ANALYZE \u5c31\u662f\u5206\u6790\u67e5\u8be2\u6267\u884c\u3002
\u4ece\u4e0a\u9762\u7684\u8f93\u51fa\u7ed3\u679c\u6765\u770b\uff0c\u6267\u884c\u4ee5\u4e0a\u793a\u4f8b\u67e5\u8be2\u8017\u65f6 0.00 \u79d2\uff0c\u8bf4\u660e\u6267\u884c\u6027\u80fd\u8f83\u4e3a\u7406\u60f3\u3002\u4e5f\u7531\u4e8e\u6211\u4eec\u8fd9\u6b21\u793a\u4f8b\u4e2d\u6267\u884c\u7684\u67e5\u8be2\u7b80\u5355\uff0c\u6ee1\u8db3\u8f83\u9ad8\u7684\u6267\u884c\u6027\u80fd\u3002
\u66f4\u591a\u5173\u4e8e EXPLAIN ANALYZE \u7684\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 EXPLAIN ANALYZE\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/","title":"\u901a\u8fc7\u6269\u5c55 CN \u63d0\u5347\u6027\u80fd","text":"MatrixOne \u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u6570\u636e\u5e93\uff0c\u6700\u663e\u8457\u7684\u7279\u70b9\u662f\u53ef\u4ee5\u901a\u8fc7\u8282\u70b9\u6269\u5c55\u6765\u63d0\u5347\u7cfb\u7edf\u6574\u4f53\u6027\u80fd\u3002\u5728 MatrixOne \u7684\u5b58\u7b97\u5206\u79bb\u67b6\u6784\u4e2d\uff0cCN \u662f\u65e0\u72b6\u6001\u7684\u8ba1\u7b97\u8282\u70b9\uff0c\u5feb\u901f\u6269\u5c55 CN \u8282\u70b9\u662f\u6574\u4e2a\u96c6\u7fa4\u6027\u80fd\u63d0\u5347\u7684\u6838\u5fc3\u3002
\u901a\u5e38\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e24\u79cd\u65b9\u6cd5\u5bf9 CN \u8fdb\u884c\u6269\u5c55\uff1a
\u5782\u76f4\u6269\u5c55 CN \u8282\u70b9\uff1a\u901a\u8fc7\u8c03\u6574\u5355\u4e2a CN \u8282\u70b9\u7684\u8d44\u6e90\u6765\u63d0\u5347\u6027\u80fd\u3002\u8fd9\u5305\u62ec\u5bf9\u6574\u4e2a CN \u8d44\u6e90\u548c\u7f13\u5b58\u7684\u63d0\u5347\u3002
\u6c34\u5e73\u6269\u5c55 CN \u8282\u70b9\uff1a\u901a\u8fc7\u589e\u52a0 CN \u8282\u70b9\u6570\u91cf\u6765\u63d0\u5347\u6027\u80fd\u3002
\u4e00\u4e2a\u6700\u5c0f\u578b\u7684 MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u67b6\u6784\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u7528\u6237\u7684\u67e5\u8be2\u8bf7\u6c42\u4e3b\u8981\u7531 CN \u627f\u62c5\u8ba1\u7b97\u5de5\u4f5c\uff0c\u56e0\u6b64 CN \u8282\u70b9\u7684\u8d44\u6e90\u5927\u5c0f\u4e0e\u7b97\u529b\u6210\u6b63\u6bd4\uff0c\u6700\u76f4\u63a5\u7684\u6269\u5c55\u65b9\u6cd5\u5c31\u662f\u5782\u76f4\u6269\u5c55\u5355\u4e2a CN \u8282\u70b9\u7684\u8d44\u6e90\u3002\u540c\u65f6\uff0c\u67e5\u8be2\u7684\u6570\u636e\u7f13\u5b58\u5728 CN \u7684\u7f13\u5b58\u4e2d\uff0c\u4f5c\u4e3a\u70ed\u6570\u636e\u3002\u5982\u679c\u547d\u4e2d\u7f13\u5b58\uff0c\u67e5\u8be2\u5c31\u53ef\u4ee5\u76f4\u63a5\u4ece\u7f13\u5b58\u4e2d\u8fd4\u56de\uff0c\u800c\u4e0d\u5fc5\u4ece\u5bf9\u8c61\u5b58\u50a8\u4e2d\u83b7\u53d6\u51b7\u6570\u636e\u3002\u7f13\u5b58\u53ea\u6709\u5728\u8d85\u8fc7\u5bb9\u91cf\u4e0a\u9650\u540e\u624d\u4f1a\u4ee5 LRU \u7b97\u6cd5\u66ff\u6362\u5176\u4e2d\u6570\u636e\uff0c\u56e0\u6b64\u7f13\u5b58\u5927\u5c0f\u5bf9\u63d0\u5347\u6027\u80fd\u4e5f\u6709\u5e2e\u52a9\u3002
\u6b64\u5916\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6c34\u5e73\u6269\u5c55 CN \u8282\u70b9\u6765\u63d0\u5347\u6027\u80fd\u3002\u6c34\u5e73\u6269\u5c55\u6709\u4e24\u4e2a\u6280\u672f\u7279\u6027\u53ef\u4ee5\u63d0\u5347\u6027\u80fd\u3002\u9996\u5148\uff0c\u591a\u4e2a\u7528\u6237\u8fde\u63a5\u8bf7\u6c42\u53ef\u4ee5\u5206\u6563\u5230\u4e0d\u540c CN \u8282\u70b9\uff0c\u4ece\u800c\u5206\u6563\u6bcf\u4e2a CN \u7684\u8d1f\u8f7d\u3002\u5176\u6b21\uff0c\u4e0d\u540c CN \u8282\u70b9\u4e5f\u6709\u4e0d\u540c\u7684\u7f13\u5b58\u3002\u5f53\u6536\u5230\u67e5\u8be2\u8bf7\u6c42\u7684 CN \u8282\u70b9\u53d1\u73b0\u8bf7\u6c42\u6570\u636e\u4e0d\u5728\u5176\u7f13\u5b58\u4e2d\u65f6\uff0c\u4f1a\u901a\u8fc7\u5143\u6570\u636e\u627e\u5230\u542b\u6709\u8bf7\u6c42\u6570\u636e\u7f13\u5b58\u7684 CN \u8282\u70b9\uff0c\u5e76\u5c06\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u5b83\u8fdb\u884c\u5904\u7406\uff0c\u63d0\u9ad8\u7f13\u5b58\u547d\u4e2d\u7387\u3002
MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7ec4\u4ef6\u7684\u6269\u5c55\u53ef\u4ee5\u901a\u8fc7 Operator \u5b8c\u6210\uff0c\u64cd\u4f5c\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003 MatrixOne \u96c6\u7fa4\u7684\u6269\u7f29\u5bb9\u7ae0\u8282\u3002\u8bf7\u6ce8\u610f\uff0c\u5782\u76f4\u6269\u5c55 CN \u8282\u70b9\u9700\u8981\u5728\u5355\u4e2a\u8282\u70b9\u4e0a\u8fdb\u884c\uff0c\u800c\u6c34\u5e73\u6269\u5c55 CN \u8282\u70b9\u9700\u8981\u5728\u591a\u4e2a\u8282\u70b9\u4e0a\u8fdb\u884c\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-CN-extensions/#_1","title":"\u64cd\u4f5c\u65b9\u6cd5","text":"MatrixOne \u5206\u5e03\u5f0f\u96c6\u7fa4\u7ec4\u4ef6\u7684\u6269\u5c55\u90fd\u53ef\u4ee5\u901a\u8fc7 Operator \u6765\u5b8c\u6210\uff0c\u5177\u4f53\u7684\u64cd\u4f5c\u65b9\u6cd5\u53ef\u4ee5\u53c2\u8003 MatrixOne \u96c6\u7fa4\u7684\u6269\u7f29\u5bb9\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-cluster-by/","title":"\u4f7f\u7528 Cluster by \u8bed\u53e5\u8c03\u4f18","text":"Cluster by
\u662f\u4e00\u79cd\u5e38\u7528\u7684\u6027\u80fd\u8c03\u4f18\u6280\u672f\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f18\u5316\u67e5\u8be2\u7684\u6267\u884c\u6548\u7387\u3002\u672c\u6587\u5c06\u89e3\u91ca\u5982\u4f55\u4f7f\u7528 Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u3002
Cluster by
\uff1f","text":"Cluster by
\u662f\u4e00\u79cd\u7528\u4e8e\u4f18\u5316\u8868\u7684\u7269\u7406\u6392\u5217\u65b9\u5f0f\u7684\u547d\u4ee4\u3002\u5728\u5efa\u8868\u65f6\u4f7f\u7528 Cluster by
\u547d\u4ee4\uff0c\u5bf9\u4e8e\u65e0\u4e3b\u952e\u7684\u8868\uff0c\u53ef\u4ee5\u6309\u7167\u6307\u5b9a\u7684\u5217\u5bf9\u8868\u8fdb\u884c\u7269\u7406\u6392\u5e8f\uff0c\u5e76\u5c06\u6570\u636e\u884c\u91cd\u65b0\u6392\u5217\u6210\u4e0e\u8be5\u5217\u7684\u503c\u7684\u987a\u5e8f\u76f8\u540c\u7684\u987a\u5e8f\u3002\u8fd9\u79cd\u7269\u7406\u6392\u5e8f\u6709\u52a9\u4e8e\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002
\u4ee5\u4e0b\u662f\u4f7f\u7528 Cluster by
\u7684\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\uff1a
Cluster by
\u4e0d\u80fd\u548c\u4e3b\u952e\u540c\u65f6\u5b58\u5728\uff0c\u5426\u5219\u4f1a\u8bed\u6cd5\u62a5\u9519\u3002
Cluster by
\u53ea\u80fd\u5728\u5efa\u8868\u65f6\u6307\u5b9a\uff0c\u4e0d\u652f\u6301\u52a8\u6001\u521b\u5efa\u3002
\u4e0b\u9762\u662f Cluster by
\u7684\u4f7f\u7528\u8bed\u6cd5\uff1a
create table() cluster by col;
create table() cluster by (col1, col2);
Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff1f","text":"\u4f7f\u7528 Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a
\u786e\u5b9a\u9700\u8981\u6392\u5e8f\u7684\u5217\u3002
\u9996\u5148\u9700\u8981\u786e\u5b9a\u9700\u8981\u6392\u5e8f\u7684\u5217\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u53ef\u4ee5\u9009\u62e9\u90a3\u4e9b\u7ecf\u5e38\u7528\u4e8e\u8fc7\u6ee4\u7684\u5217\u3002\u5bf9\u4e8e\u5177\u6709\u65f6\u95f4\u5e8f\u5217\u7279\u5f81\u7684\u6570\u636e\uff0c\u65f6\u95f4\u5217\u662f\u5e38\u7528\u7684\u6392\u5e8f\u5217\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6709\u4e00\u4e2a\u8ba2\u5355\u8868\uff0c\u53ef\u4ee5\u5c06\u8ba2\u5355\u6309\u7167\u65f6\u95f4\u8fdb\u884c\u6392\u5e8f\u3002
\u6267\u884c Cluster by
\u547d\u4ee4\u3002
\u4e00\u65e6\u786e\u5b9a\u4e86\u6392\u5e8f\u5217\uff0c\u5c31\u53ef\u4ee5\u5728\u5efa\u8868\u65f6\u6267\u884c Cluster by
\u547d\u4ee4\u5bf9\u8868\u8fdb\u884c\u6392\u5e8f\u3002
\u4e0b\u9762\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u793a\u4f8b\uff1a
create table t1(a int, b int, c varchar(10)) cluster by(a,b,c);\ndesc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | NULL | | |\n| b | INT(32) | YES | | NULL | | |\n| c | VARCHAR(10) | YES | | NULL | | |\n+-------+-------------+------+------+---------+-------+---------+\n3 rows in set (0.02 sec)\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a t1 \u7684\u8868\u3002\u7136\u540e\uff0c\u4f7f\u7528 CLUSTER \u547d\u4ee4\u6309\u7167 a\uff0cb\uff0cc \u5217\u5bf9\u8868\u8fdb\u884c\u7269\u7406\u6392\u5e8f\u3002\u8fd9\u6837\uff0c\u6240\u6709\u7684\u6570\u636e\u884c\u5c06\u6309\u7167 a\uff0cb\uff0cc \u5217\u7684\u503c\u7684\u987a\u5e8f\u6392\u5217\u3002
\u5bf9\u4e8e Cluster by
\u591a\u5217\u7684\u60c5\u51b5\uff0c\u7b2c\u4e00\u5217\u5c06\u53d6\u5f97\u6700\u597d\u7684\u67e5\u8be2\u52a0\u901f\u6548\u679c\uff0c\u56e0\u4e3a\u7b2c\u4e00\u5217\u7684\u6570\u636e\u5206\u5e03\u662f\u5b8c\u5168\u6709\u5e8f\u7684\u3002\u53ea\u6709\u5728\u7b2c\u4e00\u5217\u76f8\u540c\u7684\u60c5\u51b5\u4e0b\uff0c\u5269\u4e0b\u7684\u6570\u636e\u4f1a\u6309\u7167\u7b2c\u4e8c\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u6240\u4ee5\u7b2c\u4e8c\u5217\u7684\u67e5\u8be2\u52a0\u901f\u6548\u679c\u4f1a\u5f31\u4e8e\u7b2c\u4e00\u5217\uff0c\u4e4b\u540e\u7684\u5217\u4f1a\u4f9d\u6b21\u9012\u51cf\u3002\u6240\u4ee5 Cluster by
\u901a\u5e38\u4e0d\u63a8\u8350\u6307\u5b9a\u592a\u591a\u5217\uff0c\u4e00\u822c 3-4 \u5217\u5373\u53ef\u3002
\u9996\u5148\u57fa\u6570\u662f\u6307\u67d0\u4e00\u5217\u4e0a\u4e0d\u540c\u503c\u7684\u6570\u91cf\u3002\u4f8b\u5982\u6027\u522b\uff0c\u7531\u4e8e\u53ea\u6709\u4e24\u4e2a\u503c\uff0c\u5c31\u662f\u5f88\u5178\u578b\u7684\u4f4e\u57fa\u6570\u5217\u3002\u4f8b\u5982\u8eab\u4efd\u8bc1\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u90fd\u4e0d\u4f1a\u91cd\u590d\uff0c\u5c31\u662f\u9ad8\u57fa\u6570\u5217\u3002\u5982\u679c\u5c06\u9ad8\u57fa\u6570\u5217\u653e\u5728 Cluster by
\u7b2c\u4e00\u5217\uff0c\u6574\u5f20\u8868\u7684\u6570\u636e\u5206\u5e03\u5df2\u7ecf\u5b8c\u5168\u5728\u7b2c\u4e00\u5217\u4e0a\u6392\u597d\u5e8f\u4e86\uff0c\u5bfc\u81f4\u540e\u7eed\u7684\u5217\u4e0d\u8d77\u4f5c\u7528\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5efa\u8bae\u4f7f\u7528 Cluster by
\u5355\u5217\uff0c\u6216\u8005\u5c06\u9ad8\u57fa\u6570\u5217\u5355\u72ec\u5efa\u7d22\u5f15\uff0c\u4e0d\u8981\u653e\u5728 Cluster by
\u4e2d\u3002
Cluster by
\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879","text":"Cluster by
\u53ef\u80fd\u9700\u8981\u5f88\u957f\u65f6\u95f4\u5f53\u5bf9\u5927\u8868\u8fdb\u884c Cluster by
\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u5f88\u957f\u65f6\u95f4\u624d\u80fd\u5b8c\u6210\u3002\u8fd9\u662f\u56e0\u4e3a\u8be5\u64cd\u4f5c\u9700\u8981\u91cd\u65b0\u7ec4\u7ec7\u8868\u4e2d\u7684\u6570\u636e\uff0c\u91cd\u65b0\u6392\u5e8f\u5e76\u5b58\u50a8\u3002\u56e0\u6b64\uff0c\u5728\u6267\u884c Cluster by
\u547d\u4ee4\u65f6\uff0c\u9700\u8981\u8003\u8651\u8868\u7684\u5927\u5c0f\u548c\u786c\u4ef6\u914d\u7f6e\u3002
Cluster by
\u53ef\u80fd\u4f1a\u5f71\u54cd\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u7684\u6027\u80fd\u7531\u4e8e\u4f7f\u7528 Cluster by
\u4f1a\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u7269\u7406\u6392\u5e8f\uff0c\u56e0\u6b64\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u7684\u6027\u80fd\u53ef\u80fd\u4f1a\u53d7\u5230\u5f71\u54cd\u3002\u5f53\u8868\u4e2d\u7684\u6570\u636e\u6309\u7167\u67d0\u4e9b\u5217\u6392\u5e8f\u65f6\uff0c\u63d2\u5165\u548c\u66f4\u65b0\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u79fb\u52a8\u8bb8\u591a\u884c\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528 Cluster by
\u65f6\uff0c\u9700\u8981\u8003\u8651\u8fd9\u79cd\u5f71\u54cd\u3002
Cluster by
\u9700\u8981\u5b9a\u671f\u6267\u884c\u4ee5\u4fdd\u6301\u6027\u80fd\u7531\u4e8e\u6570\u636e\u7684\u589e\u957f\u548c\u53d8\u5316\uff0c\u8868\u4e2d\u7684\u6570\u636e\u7269\u7406\u6392\u5e8f\u53ef\u80fd\u4f1a\u5931\u53bb\u6548\u679c\u3002\u56e0\u6b64\uff0c\u9700\u8981\u5b9a\u671f\u6267\u884c Cluster by
\u547d\u4ee4\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u7269\u7406\u6392\u5e8f\u4ecd\u7136\u6709\u6548\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cCluster by
\u547d\u4ee4\u7684\u4f7f\u7528\u9700\u8981\u8c28\u614e\uff0c\u5efa\u8bae\u5728\u6d4b\u8bd5\u73af\u5883\u4e0b\u5148\u8fdb\u884c\u9a8c\u8bc1\uff0c\u4ee5\u786e\u4fdd\u4e0d\u4f1a\u5bf9\u8868\u7684\u6570\u636e\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\u3002
\u5b9a\u4e49\uff1a \u552f\u4e00\u7d22\u5f15\u4e0d\u4ec5\u786e\u4fdd\u4e86\u6570\u636e\u7684\u552f\u4e00\u6027\uff0c\u8fd8\u63d0\u4f9b\u4e86\u67e5\u8be2\u4f18\u5316\u7684\u673a\u4f1a\u3002\u5728\u6709\u552f\u4e00\u6027\u8981\u6c42\u7684\u5217\u4e0a\u521b\u5efa\u7d22\u5f15\u53ef\u4ee5\u52a0\u901f\u67e5\u627e\u548c\u6392\u5e8f\u64cd\u4f5c\u3002
\u4f8b\u5b50\uff1a
users
\u7684\u8868\uff0c\u5176\u4e2d email
\u5217\u9700\u8981\u4fdd\u6301\u552f\u4e00\u3002\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u53ef\u4ee5\u52a0\u5feb\u57fa\u4e8e email
\u7684\u67e5\u627e\u901f\u5ea6\uff1aCREATE UNIQUE INDEX idx_email ON users(email);\n
\u5f53\u901a\u8fc7 email
\u8fdb\u884c\u67e5\u8be2\u65f6\uff0cMatrixOne \u53ef\u4ee5\u5feb\u901f\u5b9a\u4f4d\u5230\u552f\u4e00\u7684\u8bb0\u5f55\u3002
orders
\u8868\u4e2d\uff0c\u8ba2\u5355\u53f7 order_id
\u5e94\u8be5\u662f\u552f\u4e00\u7684\u3002\u5728\u8fd9\u4e2a\u5217\u4e0a\u521b\u5efa\u552f\u4e00\u7d22\u5f15\u5c06\u52a0\u5feb\u57fa\u4e8e\u8ba2\u5355\u53f7\u7684\u641c\u7d22\uff1aCREATE UNIQUE INDEX idx_order_id ON orders(order_id);\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_3","title":"\u6b21\u7ea7\u7d22\u5f15","text":"\u5b9a\u4e49\uff1a \u6b21\u7ea7\u7d22\u5f15\uff08\u975e\u552f\u4e00\u7d22\u5f15\uff09\u5728\u6ca1\u6709\u552f\u4e00\u6027\u8981\u6c42\u7684\u5217\u4e0a\u4f7f\u7528\uff0c\u53ef\u4ee5\u52a0\u901f\u5bf9\u8fd9\u4e9b\u5217\u7684\u67e5\u8be2\u3002
\u4f8b\u5b50\uff1a
products
\u8868\uff0c\u4ea7\u54c1\u53ef\u4ee5\u6309\u7c7b\u522b category
\u5206\u7c7b\u3002\u521b\u5efa\u6b21\u7ea7\u7d22\u5f15\u53ef\u4ee5\u52a0\u901f\u57fa\u4e8e\u7c7b\u522b\u7684\u67e5\u8be2\uff1aCREATE INDEX idx_category ON products(category);\n
\u8fd9\u6837\uff0c\u67e5\u8be2\u7279\u5b9a\u7c7b\u522b\u7684\u4ea7\u54c1\u65f6\uff0cMatrixOne \u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u6765\u5feb\u901f\u8fc7\u6ee4\u7ed3\u679c\u3002
events
\u8868\u4e2d\uff0c\u5982\u679c\u7ecf\u5e38\u9700\u8981\u57fa\u4e8e\u65e5\u671f\u8303\u56f4\u8fdb\u884c\u67e5\u8be2\uff0c\u6bd4\u5982\u67e5\u8be2\u67d0\u4e2a\u6708\u7684\u4e8b\u4ef6\uff0c\u53ef\u4ee5\u5728\u65e5\u671f\u5217 event_date
\u4e0a\u521b\u5efa\u7d22\u5f15\uff1aCREATE INDEX idx_event_date ON events(event_date);\n
\u8fd9\u6837\uff0c\u5bf9\u4e8e\u6d89\u53ca\u65e5\u671f\u8303\u56f4\u7684\u67e5\u8be2\uff0cMatrixOne \u53ef\u4ee5\u9ad8\u6548\u5730\u5b9a\u4f4d\u548c\u7b5b\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u884c\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_4","title":"\u7d22\u5f15\u7b56\u7565","text":"\u9009\u62e9\u6b63\u786e\u7684\u5217\u521b\u5efa\u7d22\u5f15\uff1a \u901a\u5e38\u5728\u7ecf\u5e38\u7528\u4e8e WHERE
\u5b50\u53e5\u3001JOIN
\u6761\u4ef6\u6216\u6392\u5e8f\uff08ORDER BY
\uff09\u7684\u5217\u4e0a\u521b\u5efa\u7d22\u5f15\u3002
\u7ec4\u5408\u7d22\u5f15\uff1a \u5728\u591a\u4e2a\u5217\u4e0a\u7ecf\u5e38\u4e00\u8d77\u67e5\u8be2\u65f6\uff0c\u53ef\u4ee5\u521b\u5efa\u7ec4\u5408\u7d22\u5f15\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7ecf\u5e38\u6839\u636e last_name
\u548c first_name
\u67e5\u8be2 users
\u8868\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u7ec4\u5408\u7d22\u5f15\uff1a
CREATE INDEX idx_name ON users(last_name, first_name);\n
\u6ce8\u610f\u7d22\u5f15\u7684\u7ef4\u62a4\uff1a \u7d22\u5f15\u53ef\u4ee5\u63d0\u5347\u67e5\u8be2\u6027\u80fd\uff0c\u4f46\u8fc7\u591a\u6216\u4e0d\u5fc5\u8981\u7684\u7d22\u5f15\u4f1a\u964d\u4f4e\u66f4\u65b0\u8868\u65f6\u7684\u6027\u80fd\uff0c\u56e0\u4e3a\u7d22\u5f15\u4e5f\u9700\u8981\u66f4\u65b0\u3002\u5408\u7406\u7ef4\u62a4\u548c\u5b9a\u671f\u5ba1\u67e5\u7d22\u5f15\u5f88\u91cd\u8981\u3002
\u4f7f\u7528 EXPLAIN \u5206\u6790\u67e5\u8be2\uff1a \u4f7f\u7528 EXPLAIN
\u8bed\u53e5\u6765\u5206\u6790\u60a8\u7684\u67e5\u8be2\u5982\u4f55\u4f7f\u7528\u7d22\u5f15\u3002\u8fd9\u6709\u52a9\u4e8e\u7406\u89e3\u67e5\u8be2\u7684\u6027\u80fd\u5e76\u4f18\u5316\u7d22\u5f15\u7b56\u7565\u3002
\u4f7f\u7528\u552f\u4e00\u7d22\u5f15\u548c\u6b21\u7ea7\u7d22\u5f15\u53ef\u4ee5\u663e\u8457\u63d0\u5347 MatrixOne \u6570\u636e\u5e93\u7684\u67e5\u8be2\u6548\u7387\u3002\u6b63\u786e\u7406\u89e3\u5e76\u5b9e\u65bd\u7d22\u5f15\u7b56\u7565\uff0c\u662f\u4f18\u5316\u6570\u636e\u5e93\u6027\u80fd\u7684\u5173\u952e\u6b65\u9aa4\u3002\u7d22\u5f15\u4e5f\u5e94\u6839\u636e\u5177\u4f53\u7684\u4f7f\u7528\u573a\u666f\u548c\u67e5\u8be2\u6a21\u5f0f\u6765\u8bbe\u8ba1\u548c\u4f18\u5316\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_6","title":"\u573a\u666f\u4e00\uff1a\u7535\u5546\u7f51\u7ad9\u7684\u4ea7\u54c1\u641c\u7d22","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_7","title":"\u6848\u4f8b\u9700\u6c42","text":"CREATE INDEX idx_product_name ON products(name);\nCREATE INDEX idx_product_category_price ON products(category, price);\n\n-- \u6839\u636e\u4ea7\u54c1\u540d\u79f0\u641c\u7d22\nSELECT * FROM products WHERE name LIKE '%\u67e5\u8be2\u5173\u952e\u5b57%';\n\n-- \u6839\u636e\u7c7b\u522b\u548c\u4ef7\u683c\u8fc7\u6ee4\nSELECT * FROM products WHERE category = '\u7279\u5b9a\u7c7b\u522b' AND price BETWEEN \u4ef7\u683c\u4e0b\u9650 AND \u4ef7\u683c\u4e0a\u9650;\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_9","title":"\u573a\u666f\u4e8c\uff1a\u793e\u4ea4\u5a92\u4f53\u5e73\u53f0\u7684\u7528\u6237\u767b\u5f55","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_10","title":"\u6848\u4f8b\u9700\u6c42","text":"CREATE UNIQUE INDEX idx_username ON users(username);\nCREATE INDEX idx_password ON users(password);\n\n-- \u68c0\u67e5\u7528\u6237\u540d\u548c\u5bc6\u7801\u7684\u5339\u914d\nSELECT * FROM users WHERE username = '\u7528\u6237\u8f93\u5165\u7684\u7528\u6237\u540d' AND password = '\u7528\u6237\u8f93\u5165\u7684\u5bc6\u7801';\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_12","title":"\u573a\u666f\u4e09\uff1a\u8d22\u52a1\u62a5\u544a\u7cfb\u7edf\u7684\u4ea4\u6613\u6570\u636e\u5206\u6790","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-index/#_13","title":"\u6848\u4f8b\u9700\u6c42","text":"CREATE INDEX idx_transaction_date ON transactions(transaction_date);\nCREATE INDEX idx_region_date ON transactions(region, transaction_date);\n\n-- \u6309\u6708\u4efd\u67e5\u8be2\u4ea4\u6613\nSELECT * FROM transactions WHERE transaction_date BETWEEN '\u6708\u4efd\u5f00\u59cb\u65e5\u671f' AND '\u6708\u4efd\u7ed3\u675f\u65e5\u671f';\n\n-- \u6309\u533a\u57df\u548c\u6708\u4efd\u67e5\u8be2\u4ea4\u6613\nSELECT * FROM transactions WHERE region = '\u7279\u5b9a\u533a\u57df' AND transaction_date BETWEEN '\u6708\u4efd\u5f00\u59cb\u65e5\u671f' AND '\u6708\u4efd\u7ed3\u675f\u65e5\u671f';\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/","title":"\u4f7f\u7528\u5206\u533a\u8868\u8c03\u4f18","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_2","title":"\u4ec0\u4e48\u662f\u5206\u533a\u8868\uff1f","text":"\u5206\u533a\u8868\u662f\u6570\u636e\u5e93\u4e2d\u7684\u4e00\u79cd\u6570\u636e\u7ec4\u7ec7\u65b9\u6cd5\uff0c\u5373\u662f\u4e00\u79cd\u8868\u5206\u5272\u65b9\u6cd5\uff0c\u5b83\u5c06\u8868\u6570\u636e\u5206\u6563\u5230\u591a\u4e2a\u5206\u533a\u4e2d\uff0c\u6bcf\u4e2a\u5206\u533a\u76f8\u5f53\u4e8e\u4e00\u4e2a\u72ec\u7acb\u7684\u5c0f\u8868\u3002
MatrixOne \u5c06\u8868\u4e2d\u7684\u6570\u636e\u6839\u636e\u8868\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u7684\u952e\u503c\u5212\u5206\u5230\u4e0d\u540c\u7684\u5b58\u50a8\u5bf9\u8c61\u4e2d\u3002\u8fd9\u4e9b\u5217\u5bf9\u5e94\u7684\u952e\u503c\u79f0\u4e3a\u6570\u636e\u5206\u533a\u6216\u8303\u56f4\u3002
\u6570\u636e\u5206\u533a\u6216\u8303\u56f4\u662f\u8868\u7684\u4e00\u90e8\u5206\uff0c\u5305\u542b\u8868\u884c\u7684\u5b50\u96c6\uff0c\u5e76\u4e0e\u5176\u4ed6\u884c\u96c6\u5206\u5f00\u5b58\u50a8\u3002\u6839\u636e CREATE TABLE
\u8bed\u53e5\u7684 PARTITION BY
\u5b50\u53e5\u4e2d\u63d0\u4f9b\u7684\u89c4\u8303\uff0c\u7ed9\u8868\u4e2d\u7684\u6570\u636e\u5212\u5206\u4e3a\u591a\u4e2a\u6570\u636e\u5206\u533a\u6216\u8303\u56f4\u3002
\u5206\u533a\u8868\u7b80\u5316\u4e86\u8868\u6570\u636e\u7684\u8bfb\u4e0e\u5199\uff0c\u5728\u5206\u533a\u8868\u4e2d\uff0cSQL \u6267\u884c\u7684\u65f6\u5019\uff0c\u4f1a\u4f18\u5148\u5224\u65ad\u6570\u636e\u5bf9\u5e94\u54ea\u4e2a\u5206\u533a\uff0c\u518d\u5bf9\u5bf9\u5e94\u5206\u533a\u8fdb\u884c\u8bfb\u5199\uff0c\u907f\u514d\u4e86\u5bf9\u8868\u5185\u6240\u6709\u6570\u636e\u8fdb\u884c\u64cd\u4f5c\u3002\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u5e26\u6765\u5f88\u591a\u597d\u5904\uff0c\u4f8b\u5982\u52a0\u5feb\u67e5\u8be2\u901f\u5ea6\u3001\u4f18\u5316\u6570\u636e\u7ef4\u62a4\u3001\u63d0\u9ad8\u6570\u636e\u53ef\u7528\u6027\u7b49\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_3","title":"\u5206\u533a\u8868\u7684\u5e94\u7528\u573a\u666f","text":"\u67e5\u8be2\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u4f7f\u67e5\u8be2\u53ea\u9488\u5bf9\u7279\u5b9a\u5206\u533a\u8fdb\u884c\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8868\u662f\u6309\u7167\u65e5\u671f\u5206\u533a\u7684\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u67e5\u8be2\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u5185\u7684\u6570\u636e\uff0c\u800c\u65e0\u9700\u626b\u63cf\u6574\u4e2a\u8868\u3002
\u6570\u636e\u7ef4\u62a4\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u52a0\u5feb\u6570\u636e\u7ef4\u62a4\u7684\u901f\u5ea6\uff0c\u4f8b\u5982\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u3002\u5206\u533a\u8868\u53ef\u4ee5\u901a\u8fc7\u66f4\u6709\u6548\u5730\u5229\u7528 I/O \u548c CPU \u8d44\u6e90\u6765\u51cf\u5c11\u9700\u8981\u5904\u7406\u7684\u6570\u636e\u91cf\uff0c\u4ece\u800c\u63d0\u9ad8\u7ef4\u62a4\u6027\u80fd\u3002
\u5b58\u50a8\u7a7a\u95f4\u4f7f\u7528\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u66f4\u597d\u5730\u7ba1\u7406\u8868\u6570\u636e\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5b58\u50a8\u7a7a\u95f4\u4f7f\u7528\u3002\u4f8b\u5982\uff0c\u5982\u679c\u8868\u6309\u7167\u65f6\u95f4\u5206\u533a\uff0c\u5219\u65e7\u7684\u5206\u533a\u53ef\u4ee5\u8f7b\u677e\u5730\u5220\u9664\u6216\u5f52\u6863\uff0c\u800c\u65e0\u9700\u5f71\u54cd\u5176\u4ed6\u5206\u533a\u7684\u6570\u636e\u3002
\u53ef\u7528\u6027\u548c\u53ef\u9760\u6027\u6027\u80fd\u8c03\u4f18\uff1a\u4f7f\u7528\u5206\u533a\u8868\u53ef\u4ee5\u63d0\u9ad8\u7cfb\u7edf\u7684\u53ef\u7528\u6027\u548c\u53ef\u9760\u6027\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u5907\u4efd\u6216\u590d\u5236\u7279\u5b9a\u5206\u533a\u6765\u589e\u52a0\u7cfb\u7edf\u7684\u6062\u590d\u80fd\u529b\uff0c\u4ece\u800c\u51cf\u5c11\u7cfb\u7edf\u51fa\u73b0\u6545\u969c\u7684\u98ce\u9669\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u968f\u7740\u8868\u5185\u6570\u636e\u7684\u4e0d\u65ad\u589e\u52a0\uff0c\u8868\u7684\u6027\u80fd\u4f1a\u9010\u6e10\u4e0b\u964d\u3002\u4f46\u5982\u679c\u5c06\u540c\u6837\u6570\u636e\u5b58\u50a8\u5728\u5206\u533a\u8868\u4e2d\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u5c06\u4e0d\u540c\u8303\u56f4\u7684\u6570\u636e\u5212\u5206\u5230\u4e0d\u540c\u7684\u5b58\u50a8\u5bf9\u8c61\u4e2d\u6765\u5b9e\u73b0\u6570\u636e\u8bbf\u95ee\u65b9\u5f0f\u7684\u4f18\u5316\u3002
\u4e0e\u5168\u8868\u8bbf\u95ee\u76f8\u6bd4\uff0c\u4f18\u5316\u540e\u7684\u8bbf\u95ee\u65b9\u5f0f\u5c06\u66f4\u4f18\u5148\u8bbf\u95ee\u7279\u5b9a\u5206\u533a\uff0c\u4ece\u800c\u4f7f\u5f97\u6570\u636e\u7684\u589e\u5220\u6539\u67e5\u8bf7\u6c42\u80fd\u591f\u66f4\u6709\u6548\u5730\u5206\u6d41\u5230\u4e0d\u540c\u7684\u5206\u533a\u4e2d\uff0c\u540c\u65f6\u907f\u514d IO \u70ed\u70b9\u7684\u51fa\u73b0\uff0c\u6700\u7ec8\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u63d0\u5347\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_6","title":"\u5982\u4f55\u4f7f\u7528\u5206\u533a\u8868\u8fdb\u884c\u8c03\u4f18","text":"\u4f7f\u7528\u5206\u533a\u8868\u65f6\uff0c\u9700\u8981\u8003\u8651\u4ee5\u4e0b\u524d\u63d0\u6761\u4ef6\u662f\u5426\u6ee1\u8db3\uff1a
\u5206\u533a\u952e\u662f\u7269\u7406\u5212\u5206\u8868\u7684\u5173\u952e\u56e0\u7d20\uff0c\u6b63\u786e\u9009\u62e9\u5206\u533a\u952e\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u8bfb\u5199\u6027\u80fd\u3002
\u5728\u9009\u62e9\u5206\u533a\u952e\u65f6\uff0c\u9700\u8981\u8003\u8651\u4ee5\u4e0b\u56e0\u7d20\uff1a
\u5373\u4f7f\u9009\u62e9\u4e86\u5177\u6709\u9ad8\u57fa\u6570\u548c\u72ec\u7279\u6027\u7684\u5217\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u5982\u679c\u5206\u533a\u7684\u8303\u56f4\u4e0d\u5408\u9002\uff0c\u4ecd\u6709\u53ef\u80fd\u51fa\u73b0\u70ed\u70b9\u5206\u533a\u3002\u56e0\u6b64\uff0c\u5728\u5206\u533a\u7b56\u7565\u4e0a\u9700\u8981\u66f4\u7cbe\u7ec6\u5316\u7684\u7ba1\u7406\u3002
\u5728 MatrixOne \u4e2d\uff0c\u53ef\u4ee5\u652f\u6301\u591a\u79cd\u5bf9\u8868\u7684\u5206\u533a\u6a21\u5f0f\uff0c\u6bcf\u4e2a\u6a21\u5f0f\u5bf9\u5e94\u7684\u5206\u533a\u65b9\u6cd5\u5747\u6709\u4e0d\u540c\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#range","title":"Range \u5206\u533a","text":"\u8303\u56f4\u5206\u533a\u662f\u4e00\u79cd\u57fa\u4e8e\u8fde\u7eed\u503c\u7684\u5206\u533a\u65b9\u5f0f\uff0c\u5206\u533a\u4e4b\u95f4\u5fc5\u987b\u662f\u4e92\u4e0d\u91cd\u53e0\u7684\uff0c\u5206\u533a\u7684\u5b9a\u4e49\u4f7f\u7528 VALUES LESS THAN
\u8fd0\u7b97\u7b26\u3002
\u793a\u4f8b
\u5982\u4e0b\u4e24\u5f20\u8868\uff0c\u5c31\u662f\u5206\u522b\u4ee5\u6574\u6570\u5217\u4e0e\u65e5\u671f\u5217\u4f5c\u4e3a\u5206\u533a\u5217\u4f7f\u7528\uff1a
CREATE TABLE members (\nfirstname VARCHAR(25) NOT NULL,\nlastname VARCHAR(25) NOT NULL,\nusername VARCHAR(16) NOT NULL,\nemail VARCHAR(35),\njoined DATE NOT NULL\n)\nPARTITION BY RANGE COLUMNS(joined) (\nPARTITION p0 VALUES LESS THAN ('1960-01-01'),\nPARTITION p1 VALUES LESS THAN ('1970-01-01'),\nPARTITION p2 VALUES LESS THAN ('1980-01-01'),\nPARTITION p3 VALUES LESS THAN ('1990-01-01')\n)\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u4e2d\uff0c\u5206\u533a\u5217\u7684\u503c\u6ca1\u6709\u5bf9\u5e94\u7684\u5206\u533a\uff0c\u90a3\u4e48\u76f8\u5e94\u7684\u63d2\u5165\u6216\u66f4\u65b0\u64cd\u4f5c\u5c06\u4f1a\u5931\u8d25\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u63d2\u5165\u4e00\u884c joined
\u65e5\u671f\u4e3a 2000-01-01 \u7684\u6570\u636e\uff0c\u4f46\u662f\u56e0\u4e3a\u627e\u4e0d\u5230\u76f8\u5e94\u7684\u5206\u533a\uff0c\u8be5\u64cd\u4f5c\u5c06\u4f1a\u56e0\u4e3a\u65e0\u6cd5\u5b9a\u4f4d\u5206\u533a\u800c\u5931\u8d25\u3002\u56e0\u6b64\uff0c\u5728\u6267\u884c\u63d2\u5165\u6216\u66f4\u65b0\u64cd\u4f5c\u65f6\uff0c\u4e00\u5b9a\u8981\u786e\u4fdd\u5206\u533a\u5217\u7684\u503c\u5c5e\u4e8e\u5bf9\u5e94\u7684\u5206\u533a\u3002
\u8303\u56f4\u5217\u5206\u533a\u53ef\u4ee5\u88ab\u89c6\u4e3a\u8303\u56f4\u5206\u533a\u7684\u4e00\u4e2a\u6269\u5c55\u6216\u53d8\u4f53\uff0c\u5b83\u5141\u8bb8\u4f7f\u7528\u591a\u4e2a\u5217\u7684\u7ec4\u5408\u8303\u56f4\u8fdb\u884c\u66f4\u590d\u6742\u7684\u6570\u636e\u5206\u5272\u3002
\u793a\u4f8b
CREATE TABLE e_orders (\norder_id INT NOT NULL,\ncustomer_id INT NOT NULL,\norder_date DATE NOT NULL,\ncustomer_level INT,\ntotal_amount DECIMAL(10, 2),\nproduct_id INT\n)\nPARTITION BY RANGE COLUMNS(order_date, customer_level) (\nPARTITION p0 VALUES LESS THAN ('2023-01-01', 2),\nPARTITION p1 VALUES LESS THAN ('2023-01-01', 5),\nPARTITION p2 VALUES LESS THAN ('2023-06-01', 2),\nPARTITION p3 VALUES LESS THAN ('2023-06-01', 5),\nPARTITION p4 VALUES LESS THAN (MAXVALUE, MAXVALUE)\n);\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#list","title":"List \u5206\u533a","text":"\u5217\u8868\u5206\u533a\u8981\u6c42\u6bcf\u4e2a\u5206\u533a\u5fc5\u987b\u7531\u660e\u786e\u5b9a\u4e49\u7684\u503c\u5217\u8868\u7ec4\u6210\uff0c\u4e14\u6bcf\u4e2a\u5206\u533a\u7684\u5217\u8868\u6210\u5458\u4e0d\u80fd\u6709\u91cd\u590d\u503c\u3002\u5206\u533a\u952e\u7684\u503c\u5e94\u8be5\u662f\u79bb\u6563\u7684\uff0c\u5373\u5206\u533a\u5b9a\u4e49\u80fd\u591f\u6e05\u6670\u5730\u5217\u51fa\u6240\u6709\u53ef\u80fd\u7684\u503c\u6216\u503c\u7684\u96c6\u5408\u3002
\u793a\u4f8b
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY LIST(store_id) (\nPARTITION pNorth VALUES IN (3,5,6,9,17),\nPARTITION pEast VALUES IN (1,2,10,11,19,20),\nPARTITION pWest VALUES IN (4,12,13,14,18),\nPARTITION pCentral VALUES IN (7,8,15,16)\n);\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u4e2d\uff0c\u5206\u533a\u5217\u7684\u503c\u6ca1\u6709\u5bf9\u5e94\u5206\u533a\uff0c\u5219\u4f1a\u63d2\u5165\u5931\u8d25\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#list-columns","title":"List Columns \u5206\u533a","text":"\u5217\u8868\u5217\u5206\u533a\u53ef\u4ee5\u88ab\u89c6\u4e3a\u5217\u8868\u5206\u533a\u7684\u6269\u5c55\uff0c\u5b83\u5141\u8bb8\u4f7f\u7528\u591a\u5217\u7684\u7ec4\u5408\u503c\u8fdb\u884c\u66f4\u7ec6\u81f4\u7684\u6570\u636e\u5206\u5272\u3002
\u793a\u4f8b
CREATE TABLE orders (\norder_id INT NOT NULL,\norder_date DATE NOT NULL,\ncustomer_id INT NOT NULL,\nregion VARCHAR(10), -- \u5317\u533a\u6216\u5357\u533a\nproduct_type VARCHAR(15), -- \u7535\u5b50\u4ea7\u54c1\u3001\u5bb6\u5c45\u7528\u54c1\namount DECIMAL(10, 2)\n)\nPARTITION BY LIST COLUMNS(region, product_type) (\nPARTITION pNorthElectronics VALUES IN (('\u5317\u533a', '\u7535\u5b50\u4ea7\u54c1')),\nPARTITION pNorthHomeGoods VALUES IN (('\u5317\u533a', '\u5bb6\u5c45\u7528\u54c1')),\nPARTITION pSouthElectronics VALUES IN (('\u5357\u533a', '\u7535\u5b50\u4ea7\u54c1')),\nPARTITION pSouthHomeGoods VALUES IN (('\u5357\u533a', '\u5bb6\u5c45\u7528\u54c1'))\n);\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#hash","title":"Hash \u5206\u533a","text":"\u54c8\u5e0c\u5206\u533a\u901a\u5e38\u7528\u4e8e\u5c06\u6570\u636e\u5747\u5300\u5206\u5e03\u5728\u4e0d\u540c\u7684\u5206\u533a\u4e2d\u3002\u5e38\u89c1\u7684\u54c8\u5e0c\u5206\u533a\u6709 HASH \u51fd\u6570\u5206\u533a\u548c KEY \u51fd\u6570\u5206\u533a\u3002
\u5728 HASH \u51fd\u6570\u5206\u533a\u4e2d\uff0c\u5fc5\u987b\u660e\u786e\u6307\u5b9a\u7528\u4e8e\u5206\u533a\u7684\u5217\u6216\u8868\u8fbe\u5f0f\uff0c\u8be5\u5217\u6216\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u5fc5\u987b\u662f\u6574\u6570\uff0c\u5e76\u4e14\u5efa\u8bae\u660e\u786e\u6307\u5b9a\u5206\u533a\u6570\u91cf\uff0c\u8be5\u6570\u91cf\u5fc5\u987b\u662f\u6b63\u6574\u6570\u3002
\u793a\u4f8b
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH( YEAR(hired) )\nPARTITIONS 4;\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#key","title":"Key \u5206\u533a","text":"\u5728\u4f7f\u7528 KEY \u51fd\u6570\u5206\u533a\u65f6\uff0c\u6570\u636e\u5e93\u670d\u52a1\u5185\u90e8\u63d0\u4f9b\u4e86\u81ea\u6709\u7684\u54c8\u5e0c\u65b9\u5f0f\u8fdb\u884c\u5206\u533a\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u663e\u5f0f\u5b9a\u4e49\u5206\u533a\u6570\u91cf\u3002\u4e0e HASH \u51fd\u6570\u5206\u533a\u4e0d\u540c\u7684\u662f\uff0cKEY \u51fd\u6570\u5206\u533a\u652f\u6301\u9664\u5927\u5bf9\u8c61\u7c7b\u578b\uff08TEXT/BLOB\uff09\u4e4b\u5916\u7684\u6240\u6709\u7c7b\u578b\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u800c\u4e14\u4e0d\u4e00\u5b9a\u9700\u8981\u6307\u5b9a\u5206\u533a\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u8bed\u53e5\u521b\u5efa\u4e00\u4e2a\u5206\u533a\u952e\u4e3a s1 \u7684\u8868\uff1a
\u793a\u4f8b
CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY(s1);\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u5206\u533a\u952e\u662f\u8be5\u8868\u7684\u4e3b\u952e\u5217\uff0c\u90a3\u4e48\u5728\u4e0d\u663e\u5f0f\u6307\u5b9a\u5206\u533a\u952e\u65f6\uff0c\u7cfb\u7edf\u4f1a\u9ed8\u8ba4\u4ee5\u4e3b\u952e\u5217\u4f5c\u4e3a\u5206\u533a\u952e\u3002\u4f8b\u5982\uff1a
CREATE TABLE tm1 (\ns1 CHAR(32) PRIMARY KEY\n)\nPARTITION BY KEY();\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-by/#_9","title":"\u9650\u5236","text":"List / List column \u6682\u4e0d\u652f\u6301\u5206\u533a\u88c1\u526a\u3002
Range/ Range Columns \u6682\u4e0d\u652f\u6301\u5206\u533a\u88c1\u526a\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/","title":"\u5206\u533a\u88c1\u526a","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_1","title":"\u5206\u533a\u88c1\u526a","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_2","title":"\u6982\u8ff0","text":"\u5206\u533a\u88c1\u526a\uff08Partition Pruning\uff09\u662f\u6570\u636e\u5e93\u67e5\u8be2\u4f18\u5316\u7684\u4e00\u4e2a\u8fc7\u7a0b\uff0c\u5b83\u80fd\u591f\u8bc6\u522b\u5e76\u6392\u9664\u90a3\u4e9b\u4e0d\u5fc5\u8981\u7684\u5206\u533a\uff0c\u4ece\u800c\u51cf\u5c11\u67e5\u8be2\u9700\u8981\u626b\u63cf\u7684\u6570\u636e\u91cf\u3002\u5f53\u6267\u884c\u4e00\u4e2a\u67e5\u8be2\u65f6\uff0c\u5982\u679c\u67e5\u8be2\u6761\u4ef6\u4e0e\u8868\u7684\u5206\u533a\u952e\u76f8\u5173\u8054\uff0c\u6570\u636e\u5e93\u7cfb\u7edf\u80fd\u591f\u81ea\u52a8\u786e\u5b9a\u5e76\u4ec5\u8bbf\u95ee\u5305\u542b\u76f8\u5173\u6570\u636e\u7684\u5206\u533a\uff0c\u800c\u5ffd\u7565\u5176\u5b83\u5206\u533a\u4ee5\u5927\u5e45\u51cf\u5c11\u6240\u9700\u8ba1\u7b97\u7684\u6570\u636e\u91cf\u3002
\u4f8b\u5982\uff1a
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\nPRIMARY KEY(col1, col3)\n) PARTITION BY KEY(col1, col3) PARTITIONS 4;\n\nINSERT INTO t1 VALUES\n(1, '1980-12-17', 7369),\n(2, '1981-02-20', 7499),\n(3, '1981-02-22', 7521),\n(4, '1981-04-02', 7566),\n(5, '1981-09-28', 7654),\n(6, '1981-05-01', 7698),\n(7, '1981-06-09', 7782),\n(8, '0087-07-13', 7788),\n(9, '1981-11-17', 7839),\n(10, '1981-09-08', 7844),\n(11, '2007-07-13', 7876),\n(12, '1981-12-03', 7900),\n(13, '1987-07-13', 7980),\n(14, '2001-11-17', 7981),\n(15, '1951-11-08', 7982),\n(16, '1927-10-13', 7983),\n(17, '1671-12-09', 7984),\n(18, '1981-11-06', 7985),\n(19, '1771-12-06', 7986),\n(20, '1985-10-06', 7987),\n(21, '1771-10-06', 7988),\n(22, '1981-10-05', 7989),\n(23, '2001-12-04', 7990),\n(24, '1999-08-01', 7991),\n(25, '1951-11-08', 7992),\n(26, '1927-10-13', 7993),\n(27, '1971-12-09', 7994),\n(28, '1981-12-09', 7995),\n(29, '2001-11-17', 7996),\n(30, '1981-12-09', 7997),\n(31, '2001-11-17', 7998),\n(32, '2001-11-17', 7999);\n\nmysql> EXPLAIN VERBOSE SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);\n+-----------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| -> Table Scan on db1.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| Table: 't1' (0:'col1', 1:'col2', 2:'col3') |\n| Hit Partition: p0, p2 |\n| Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |\n+-----------------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
\u8be5\u67e5\u8be2\u901a\u8fc7\u88c1\u526a\u5206\u533a\uff0c\u4ec5\u626b\u63cf\u4e86 p0 \u548c p2 \u5206\u533a\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#key","title":"\u5206\u533a\u88c1\u526a\u5728 KEY \u5206\u533a\u8868\u4e0a\u7684\u5e94\u7528","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#key_1","title":"\u9002\u7528\u7684 KEY \u5206\u533a\u8868\u573a\u666f","text":"\u53ea\u6709\u4e0e\u5206\u533a\u952e\u5339\u914d\u7684\u7b49\u503c\u6bd4\u8f83\u67e5\u8be2\u6761\u4ef6\u624d\u80fd\u652f\u6301 KEY \u5206\u533a\u8868\u7684\u88c1\u526a\u3002
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT PRIMARY KEY\n) PARTITION BY KEY(col3) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM t1 WHERE col3 = 7990 OR col3 = 7988;\n+-------------------------------------------------------------+\n| QUERY PLAN |\n+-------------------------------------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Hit Partition: p0, p1 |\n| Filter Cond: ((t1.col3 = 7990) or (t1.col3 = 7988)) |\n+-------------------------------------------------------------+\n4 rows in set (0.01 sec)\n
\u5728\u8fd9\u4e2a SQL \u4e2d\uff0c\u6761\u4ef6 col3 = 7990
\u53ef\u4ee5\u786e\u5b9a\u6240\u6709\u7ed3\u679c\u90fd\u4f4d\u4e8e\u5206\u533a p0 \u4e0a\u3002\u6761\u4ef6 col3 = 7988
\u53ef\u4ee5\u786e\u5b9a\u6240\u6709\u7ed3\u679c\u90fd\u4f4d\u4e8e\u5206\u533a p1 \u4e0a\u3002\u7531\u4e8e\u8fd9\u4e24\u4e2a\u6761\u4ef6\u7684\u5173\u7cfb\u662f OR\uff0c\u56e0\u6b64\u53ea\u9700\u8981\u626b\u63cf p0 \u548c p1 \u4e24\u4e2a\u5206\u533a\uff0c\u5206\u533a\u88c1\u526a\u7684\u7ed3\u679c\u662f p0 \u548c p1\u3002
Key \u5206\u533a\u7531\u4e8e\u5185\u90e8\u4f7f\u7528\u54c8\u5e0c\u7b97\u6cd5\u9020\u6210\u7684\u65e0\u5e8f\u6027\uff0c\u4e0d\u9002\u7528\u4e8e\u8fde\u7eed\u67e5\u8be2\uff0c\u5982 between
\u3001> < >= <=
\u7b49\u6761\u4ef6\uff0c\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col3 >= 7782;\n+----------------------------------------+\n| QUERY PLAN |\n+----------------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| Filter Cond: (t1.col3 >= 7782) |\n+----------------------------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_4","title":"\u573a\u666f\u4e8c","text":"\u5bf9\u4e8e\u53ea\u80fd\u5728\u6267\u884c\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u83b7\u53d6\u8fc7\u6ee4\u6761\u4ef6\u7684\u573a\u666f\uff0c\u65e0\u6cd5\u5229\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col3 = (SELECT col3 FROM t2 WHERE t1.col3 = t2.col3 AND t2.col1 < 5);\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Filter |\n| Filter Cond: (t1.col3 = t2.col3) |\n| -> Join |\n| Join Type: SINGLE |\n| Join Cond: (t1.col3 = t2.col3) |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| -> Table Scan on db1.t2 |\n| Hit Partition: all partitions |\n| Filter Cond: (t2.col1 < 5) |\n+---------------------------------------------------+\n11 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u6bcf\u8bfb\u53d6\u4e00\u884c\u6570\u636e\uff0c\u90fd\u4f1a\u4ece\u5b50\u67e5\u8be2\u4e2d\u83b7\u53d6\u7ed3\u679c\u5e76\u6784\u5efa\u7b49\u503c\u8fc7\u6ee4\u6761\u4ef6 col3 = ?
\u3002\u7136\u800c\uff0c\u5206\u533a\u88c1\u526a\u53ea\u5728\u67e5\u8be2\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u751f\u6548\uff0c\u800c\u4e0d\u662f\u6267\u884c\u9636\u6bb5\uff0c\u56e0\u6b64\u65e0\u6cd5\u8fdb\u884c\u5206\u533a\u88c1\u526a\u3002
Hash \u5206\u533a\u8868\u7684\u4f7f\u7528\u65b9\u5f0f\u4e0e Key \u5206\u533a\u8868\u57fa\u672c\u76f8\u540c\uff0c\u53ea\u6709\u7b49\u503c\u6bd4\u8f83\u67e5\u8be2\u6761\u4ef6\u624d\u80fd\u652f\u6301 Hash \u5206\u533a\u8868\u7684\u88c1\u526a\u3002
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH(store_id) PARTITIONS 4;\n\nINSERT INTO employees VALUES\n(10001, 'Georgi', 'Facello', '1953-09-02','1986-06-26',120, 1),\n(10002, 'Bezalel', 'Simmel', '1964-06-02','1985-11-21',150, 7),\n(10003, 'Parto', 'Bamford', '1959-12-03','1986-08-28',140, 3),\n(10004, 'Chirstian', 'Koblick', '1954-05-01','1986-12-01',150, 3),\n(10005, 'Kyoichi', 'Maliniak', '1955-01-21','1989-09-12',150, 18),\n(10006, 'Anneke', 'Preusig', '1953-04-20','1989-06-02',150, 15),\n(10007, 'Tzvetan', 'Zielinski', '1957-05-23','1989-02-10',110, 6),\n(10008, 'Saniya', 'Kalloufi', '1958-02-19','1994-09-15',170, 10),\n(10009, 'Sumant', 'Peac', '1952-04-19','1985-02-18',110, 13),\n(10010, 'Duangkaew', 'Piveteau', '1963-06-01','1989-08-24',160, 10),\n(10011, 'Mary', 'Sluis', '1953-11-07','1990-01-22',120, 8),\n(10012, 'Patricio', 'Bridgland', '1960-10-04','1992-12-18',120, 7),\n(10013, 'Eberhardt', 'Terkki', '1963-06-07','1985-10-20',160, 17),\n(10014, 'Berni', 'Genin', '1956-02-12','1987-03-11',120, 15),\n(10015, 'Guoxiang', 'Nooteboom', '1959-08-19','1987-07-02',140, 8),\n(10016, 'Kazuhito', 'Cappelletti', '1961-05-02','1995-01-27',140, 2),\n(10017, 'Cristinel', 'Bouloucos', '1958-07-06','1993-08-03',170, 10),\n(10018, 'Kazuhide', 'Peha', '1954-06-19','1987-04-03',170, 2),\n(10019, 'Lillian', 'Haddadi', '1953-01-23','1999-04-30',170, 13),\n(10020, 'Mayuko', 'Warwick', '1952-12-24','1991-01-26',120, 1),\n(10021, 'Ramzi', 'Erde', '1960-02-20','1988-02-10',120, 9),\n(10022, 'Shahaf', 'Famili', '1952-07-08','1995-08-22',130, 10),\n(10023, 'Bojan', 'Montemayor', '1953-09-29','1989-12-17',120, 5),\n(10024, 'Suzette', 'Pettey', '1958-09-05','1997-05-19',130, 4),\n(10025, 'Prasadram', 'Heyers', '1958-10-31','1987-08-17',180, 8),\n(10026, 'Yongqiao', 'Berztiss', '1953-04-03','1995-03-20',170, 4),\n(10027, 'Divier', 'Reistad', '1962-07-10','1989-07-07',180, 10),\n(10028, 'Domenick', 'Tempesti', '1963-11-26','1991-10-22',110, 11),\n(10029, 'Otmar', 'Herbst', '1956-12-13','1985-11-20',110, 12),\n(10030, 'Elvis', 'Demeyer', '1958-07-14','1994-02-17',110, 1),\n(10031, 'Karsten', 'Joslin', '1959-01-27','1991-09-01',110, 10),\n(10032, 'Jeong', 'Reistad', '1960-08-09','1990-06-20',120, 19),\n(10033, 'Arif', 'Merlo', '1956-11-14','1987-03-18',120, 14),\n(10034, 'Bader', 'Swan', '1962-12-29','1988-09-21',130, 16),\n(10035, 'Alain', 'Chappelet', '1953-02-08','1988-09-05',130, 3),\n(10036, 'Adamantios', 'Portugali', '1959-08-10','1992-01-03',130, 14),\n(10037, 'Pradeep', 'Makrucki', '1963-07-22','1990-12-05',140, 12),\n(10038, 'Huan', 'Lortz', '1960-07-20','1989-09-20',140, 7),\n(10039, 'Alejandro', 'Brender', '1959-10-01','1988-01-19',110, 20),\n(10040, 'Weiyi', 'Meriste', '1959-09-13','1993-02-14',140, 17);\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: p0 |\n| Filter Cond: (employees.store_id = 10) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a SQL \u4e2d\uff0c\u7531\u4e8e\u5206\u533a\u8868\u7684\u5206\u533a\u952e\u4e3a store_id
\uff0c\u6761\u4ef6 store_id = 10
\u53ef\u4ee5\u786e\u5b9a\u6240\u6709\u7ed3\u679c\u90fd\u5728\u4e00\u4e2a\u5206\u533a\u4e2d\u3002\u6570\u503c 10 \u7ecf\u8fc7 Hash \u540e\u786e\u5b9a\u4f4d\u4e8e\u5206\u533a p0 \u4e2d\u3002\u56e0\u6b64\u53ea\u9700\u8981\u626b\u63cf\u5206\u533a p0\uff0c\u65e0\u9700\u8bbf\u95ee\u7edd\u5bf9\u4e0d\u5305\u542b\u76f8\u5173\u7ed3\u679c\u7684 p1\u3001p2\u3001p3 \u5206\u533a\u3002\u4ece\u6267\u884c\u8ba1\u5212\u4e2d\u53ef\u89c1\uff0c\u53ea\u51fa\u73b0\u4e00\u4e2a TableScan
\u7b97\u5b50\uff0c\u5176\u4e2d\u6307\u5b9a\u4e86 Hit Partition
\u4e3a p0\uff0c\u786e\u4fdd\u4e86\u5206\u533a\u88c1\u526a\u7684\u751f\u6548\u3002
HASH \u5206\u533a\u7531\u4e8e\u5185\u90e8\u4f7f\u7528\u54c8\u5e0c\u7b97\u6cd5\u9020\u6210\u7684\u65e0\u5e8f\u6027\uff0c\u4e0d\u9002\u7528\u4e8e\u8fde\u7eed\u67e5\u8be2\uff0c\u5982 between
\u3001> < >= <=
\u7b49\u6761\u4ef6\uff0c\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n)\nPARTITION BY HASH(store_id) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id > 15;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: all partitions |\n| Filter Cond: (employees.store_id > 15) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a SQL \u4e2d\uff0c\u6761\u4ef6 store_id > 15
\u65e0\u6cd5\u786e\u5b9a\u5bf9\u5e94\u7684 Hash \u5206\u533a\uff0c\u56e0\u6b64\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
\u5bf9\u4e8e\u53ea\u80fd\u5728\u6267\u884c\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u83b7\u53d6\u8fc7\u6ee4\u6761\u4ef6\u7684\u573a\u666f\uff0c\u65e0\u6cd5\u5229\u7528\u5206\u533a\u88c1\u526a\u4f18\u5316\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col1 = (SELECT store_id FROM employees WHERE employees.store_id = t1.col1 AND employees.id = 10010);\n+---------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------+\n| Project |\n| -> Filter |\n| Filter Cond: (t1.col1 = employees.store_id) |\n| -> Join |\n| Join Type: SINGLE |\n| Join Cond: (t1.col1 = employees.store_id) |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| -> Table Scan on db1.employees |\n| Hit Partition: all partitions |\n| Filter Cond: (employees.id = 10010) |\n+---------------------------------------------------------+\n11 rows in set (0.01 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u6bcf\u8bfb\u53d6\u4e00\u884c\u6570\u636e\uff0c\u90fd\u4f1a\u4ece\u5b50\u67e5\u8be2\u4e2d\u83b7\u53d6\u7ed3\u679c\u5e76\u6784\u5efa\u7b49\u503c\u8fc7\u6ee4\u6761\u4ef6 col3 = ?
\uff0c\u7136\u800c\uff0c\u5206\u533a\u88c1\u526a\u4ec5\u5728\u67e5\u8be2\u8ba1\u5212\u751f\u6210\u9636\u6bb5\u751f\u6548\uff0c\u800c\u4e0d\u662f\u6267\u884c\u9636\u6bb5\uff0c\u56e0\u6b64\u65e0\u6cd5\u8fdb\u884c\u5206\u533a\u88c1\u526a\u3002
\u76ee\u524d\uff0c\u4e0d\u652f\u6301\u5c06\u51fd\u6570\u8868\u8fbe\u5f0f\u7528\u4f5c Hash \u5206\u533a\u8868\u8fbe\u5f0f\u7684\u5206\u533a\u88c1\u526a\u3002
CREATE TABLE t3 (\ncol1 INT,\ncol2 CHAR(10),\ncol3 DATETIME\n) PARTITION BY HASH (YEAR(col3)) PARTITIONS 4;\n\nINSERT INTO t3 VALUES\n(10001, 'Georgi', '1999-04-05 11:01:02'),\n(10002, 'Bezalel', '2004-04-03 13:11:10'),\n(10003, 'Parto', '1997-04-05 11:01:02'),\n(10004, 'Chirstian', '2004-04-03 13:11:10'),\n(10005, 'Mary', '1998-04-05 11:01:02'),\n(10006, 'Patricio', '2004-04-03 13:11:10'),\n(10007, 'Eberhardt', '1953-09-02 13:11:10'),\n(10008, 'Kazuhide', '1986-06-26 19:21:10'),\n(10009, 'Tempesti', '1956-11-14 08:11:10'),\n(10010, 'Nooteboom', '1987-03-18 23:11:10');\n\nmysql> EXPLAIN SELECT * FROM t3 WHERE YEAR(col3) = 1999;\n+---------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------+\n| Project |\n| -> Table Scan on db1.t3 |\n| Hit Partition: all partitions |\n| Filter Cond: (YEAR(t3.col3) = 1999) |\n+---------------------------------------------+\n4 rows in set (0.00 sec)\n\nmysql> SELECT * FROM t3 WHERE YEAR(col3) = 1999;\n+-------+--------+---------------------+\n| col1 | col2 | col3 |\n+-------+--------+---------------------+\n| 10001 | Georgi | 1999-04-05 11:01:02 |\n+-------+--------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#_8","title":"\u5206\u533a\u526a\u88c1\u7684\u6027\u80fd\u8c03\u4f18\u793a\u4f8b","text":""},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#1-key","title":"\u793a\u4f8b 1: KEY \u5206\u533a\u8868\u7684\u7b49\u503c\u6761\u4ef6","text":"CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\nPRIMARY KEY(col1, col3)\n) PARTITION BY KEY(col1, col3) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM t1 WHERE col1 = 1 AND col3 = 7369;\n+------------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------------+\n| Project |\n| -> Table Scan on db2.t1 |\n| Hit Partition: p0 |\n| Filter Cond: (t1.col3 = 7369), (t1.col1 = 1) |\n+------------------------------------------------------+\n5 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u7ecf\u8fc7\u5206\u533a\u88c1\u526a\u540e\uff0c\u53ea\u4f1a\u8bbf\u95ee\u5206\u533a p0\uff0c\u56e0\u4e3a\u67e5\u8be2\u6761\u4ef6\u4e0e p0 \u4e2d\u7684\u6570\u636e\u5339\u914d\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#2-key-or","title":"\u793a\u4f8b 2: KEY \u5206\u533a\u8868\u7684 OR \u6761\u4ef6","text":"mysql> EXPLAIN SELECT * FROM t1 WHERE (col1 = 1 AND col3 = 7369) OR (col1 = 6 AND col3 = 7698);\n+-----------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| -> Table Scan on db2.t1 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t1.col1, t1.col2, t1.col3 |\n| Table: 't1' (0:'col1', 1:'col2', 2:'col3') |\n| Hit Partition: p0, p2 |\n| Filter Cond: (((t1.col1 = 1) and (t1.col3 = 7369)) or ((t1.col1 = 6) and (t1.col3 = 7698))) |\n+-----------------------------------------------------------------------------------------------------+\n7 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u88c1\u526a\u4e86\u5206\u533a p0 \u548c p2\uff0c\u56e0\u4e3a\u67e5\u8be2\u6761\u4ef6\u4e0e\u8fd9\u4e24\u4e2a\u5206\u533a\u4e2d\u7684\u6570\u636e\u5339\u914d\u3002
"},{"location":"MatrixOne/Performance-Tuning/optimization-concepts/through-partition/through-partition-pruning/#3-hash","title":"\u793a\u4f8b 3: HASH \u5206\u533a\u8868\u7684\u7b49\u503c\u6761\u4ef6","text":"CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT,\nstore_id INT\n) PARTITION BY HASH(store_id) PARTITIONS 4;\n\nmysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: p0 |\n| Filter Cond: (employees.store_id = 10) |\n+------------------------------------------------+\n4 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a\u67e5\u8be2\u4e2d\uff0c\u53ea\u6709\u5206\u533a p0 \u5305\u542b\u4e0e\u6761\u4ef6 store_id = 10
\u5339\u914d\u7684\u6570\u636e\uff0c\u56e0\u6b64\u53ea\u626b\u63cf\u4e86 p0 \u5206\u533a\u3002
mysql> EXPLAIN SELECT * FROM employees WHERE store_id = 10 OR store_id = 15;\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Table Scan on db1.employees |\n| Hit Partition: p0, p3 |\n| Filter Cond: ((employees.store_id = 10) or (employees.store_id = 15)) |\n+---------------------------------------------------+\n5 rows in set (0.00 sec)\n
\u8fd9\u4e2a\u67e5\u8be2\u88c1\u526a\u4e86 p0 \u548c p3 \u5206\u533a\uff0c\u56e0\u4e3a\u8fd9\u4e24\u4e2a\u5206\u533a\u4e2d\u5305\u542b\u4e86\u4e0e\u6761\u4ef6 store_id = 10 OR store_id = 15
\u5339\u914d\u7684\u6570\u636e\u3002
mysql> EXPLAIN SELECT * FROM t1 WHERE col1 > 5;\n+------------------------------------------------+\n| QUERY PLAN |\n+------------------------------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n| Hit Partition: all partitions |\n| Filter Cond: (t1.col1 > 5) |\n| Block Filter Cond: (t1.col1 > 5) |\n+------------------------------------------------+\n5 rows in set (0.00 sec)\n
\u5728\u8fd9\u4e2a\u67e5\u8be2\u4e2d\uff0c\u6761\u4ef6 col1 > 5
\u65e0\u6cd5\u786e\u5b9a\u5bf9\u5e94\u7684\u5206\u533a\uff0c\u56e0\u6b64\u65e0\u6cd5\u4f7f\u7528\u5206\u533a\u88c1\u526a\u3002
MatrixOne \u7684\u5206\u533a\u8868\u652f\u6301\u56db\u79cd\u5206\u533a\u5f62\u5f0f\uff1aKey\u3001Hash\u3001Range\u3001List\uff1a
MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u662f MatrixOne \u5b58\u50a8\u7cfb\u7edf\u4fe1\u606f\u7684\u5730\u65b9\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b83\u4eec\u8bbf\u95ee\u7cfb\u7edf\u4fe1\u606f\u3002MatrixOne \u5728\u521d\u59cb\u5316\u65f6\u521b\u5efa\u4e86 6 \u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\uff1amo_catalog
\u3001information_schema
\u3001system_metrcis
\u3001system
\u3001mysql
\u548c mo_task
\u3002mo_task
\u5f53\u524d\u6b63\u5728\u5f00\u53d1\u4e2d\uff0c\u6682\u65f6\u5bf9\u4f60\u6240\u8fdb\u884c\u7684\u64cd\u4f5c\u4e0d\u4f1a\u4ea7\u751f\u76f4\u63a5\u5f71\u54cd\u3002\u672c\u6587\u6863\u4e2d\u63cf\u8ff0\u4e86\u5176\u4ed6\u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u51fd\u6570\u3002
\u7cfb\u7edf\u53ea\u80fd\u4fee\u6539\u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\uff0c\u4f60\u4ec5\u80fd\u4ece\u4e2d\u8fdb\u884c\u8bfb\u53d6\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Reference/System-tables/#mo_catalog","title":"mo_catalog
\u6570\u636e\u5e93","text":"mo_catalog
\u7528\u4e8e\u5b58\u50a8 MatrixOne \u5bf9\u8c61\u7684\u5143\u6570\u636e\uff0c\u5982\uff1a\u6570\u636e\u5e93\u3001\u8868\u3001\u5217\u3001\u7cfb\u7edf\u53d8\u91cf\u3001\u79df\u6237\u3001\u7528\u6237\u548c\u89d2\u8272\u3002
\u4ece MatrixOne 0.6 \u7248\u672c\u5373\u5f15\u5165\u4e86\u591a\u79df\u6237\u7684\u6982\u5ff5\uff0c\u9ed8\u8ba4\u7684 sys
\u79df\u6237\u548c\u5176\u4ed6\u79df\u6237\u7684\u884c\u4e3a\u7565\u6709\u4e0d\u540c\u3002\u670d\u52a1\u4e8e\u591a\u79df\u6237\u7ba1\u7406\u7684\u7cfb\u7edf\u8868 mo_account
\u4ec5\u5bf9 sys
\u79df\u6237\u53ef\u89c1\uff1b\u5176\u4ed6\u79df\u6237\u770b\u4e0d\u5230\u6b64\u8868\u3002
mo_indexes
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 id BIGINT UNSIGNED(64) \u7d22\u5f15 ID table_id BIGINT UNSIGNED(64) \u7d22\u5f15\u6240\u5728\u8868\u7684 ID database_id BIGINT UNSIGNED(64) \u7d22\u5f15\u6240\u5728\u6570\u636e\u5e93\u7684 ID name VARCHAR(64) \u7d22\u5f15\u7684\u540d\u5b57 type VARCHAR(11) \u7d22\u5f15\u7684\u7c7b\u578b\uff0c\u5305\u62ec\u4e3b\u952e\u7d22\u5f15\uff08PRIMARY\uff09\uff0c\u552f\u4e00\u7d22\u5f15\uff08UNIQUE\uff09\uff0c\u6b21\u7ea7\u7d22\u5f15\uff08MULTIPLE algo VARCHAR(11) \u521b\u5efa\u7d22\u5f15\u7684\u7b97\u6cd5 algo_table_type VARCHAR(11) \u591a\u8868\u7d22\u5f15\u7684\u9690\u85cf\u8868\u7c7b\u578b algo_params VARCHAR(2048) \u7d22\u5f15\u7b97\u6cd5\u53c2\u6570 is_visible TINYINT(8) \u7d22\u5f15\u662f\u5426\u53ef\u89c1\uff0c1 \u4e3a\u53ef\u89c1\uff0c0 \u4e0d\u53ef\u89c1\uff08\u76ee\u524d MatrixOne \u7684\u7d22\u5f15\u5168\u90e8\u4e3a\u53ef\u89c1\u7d22\u5f15\uff09 hidden TINYINT(8) \u7d22\u5f15\u662f\u5426\u4e3a\u9690\u85cf\u7d22\u5f15\uff0c1 \u4e3a\u9690\u85cf\u7d22\u5f15\uff0c0 \u4e3a\u975e\u9690\u85cf\u7d22\u5f15 comment VARCHAR(2048) \u7d22\u5f15\u7684\u6ce8\u91ca\u4fe1\u606f column_name VARCHAR(256) \u7d22\u5f15\u7684\u7ec4\u6210\u5217\u7684\u5217\u540d ordinal_position INT UNSIGNED(32) \u7d22\u5f15\u4e2d\u7684\u5217\u5e8f\u53f7\uff0c\u4ece 1 \u5f00\u59cb options TEXT(0) \u7d22\u5f15\u7684 options \u9009\u9879\u4fe1\u606f index_table_name VARCHAR(5000) \u8be5\u7d22\u5f15\u5bf9\u5e94\u7684\u7d22\u5f15\u8868\u7684\u8868\u540d\uff0c\u76ee\u524d\u53ea\u6709\u552f\u4e00\u7d22\u5f15\u542b\u6709\u7d22\u5f15\u8868"},{"location":"MatrixOne/Reference/System-tables/#mo_table_partitions","title":"mo_table_partitions
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 table_id BIGINT UNSIGNED(64) \u5f53\u524d\u5206\u533a\u8868\u7684 ID database_id BIGINT UNSIGNED(64) \u5f53\u524d\u5206\u533a\u8868\u6240\u5c5e\u7684\u6570\u636e\u5e93\u7684 ID number SMALLINT UNSIGNED(16) \u5f53\u524d\u5206\u533a\u7f16\u53f7\u3002\u6240\u6709\u5206\u533a\u90fd\u6309\u7167\u5b9a\u4e49\u7684\u987a\u5e8f\u8fdb\u884c\u7d22\u5f15\uff0c\u5176\u4e2d 1 \u662f\u5206\u914d\u7ed9\u7b2c\u4e00\u4e2a\u5206\u533a\u7684\u6570\u5b57 name VARCHAR(64) \u5206\u533a\u7684\u540d\u79f0 partition_type VARCHAR(50) \u5b58\u653e\u8868\u7684\u5206\u533a\u7c7b\u578b\u4fe1\u606f\uff0c\u5982\u679c\u662f\u5206\u533a\u8868\uff0c\u5176\u503c\u679a\u4e3e\u4e3a\"KEY\"\uff0c \"LINEAR_KEY\"\uff0c\"HASH\"\uff0c\"LINEAR_KEY_51\"\uff0c\"RANGE\"\uff0c\"RANGE_COLUMNS\"\uff0c\"LIST\"\uff0c\"LIST_COLUMNS\"\uff1b\u5982\u679c\u4e0d\u662f\u5206\u533a\u8868\uff0cpartition_type \u7684\u503c\u4e3a\u7a7a\u5b57\u7b26\u4e32\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\u3002 partition_expression VARCHAR(2048) \u521b\u5efa\u5206\u533a\u8868\u7684\u7684 CREATE TABLE
\u6216 ALTER TABLE
\u8bed\u53e5\u4e2d\u4f7f\u7528\u7684\u5206\u533a\u51fd\u6570\u7684\u8868\u8fbe\u5f0f\u3002 description_utf8 TEXT(0) \u6b64\u5217\u7528\u4e8e RANGE
\u548c LIST
\u5206\u533a\u3002\u5bf9\u4e8e RANGE
\u5206\u533a\uff0c\u5b83\u5305\u542b\u5206\u533a\u7684 VALUES LESS THAN
\u5b50\u53e5\u4e2d\u8bbe\u7f6e\u7684\u503c\uff0c\u8be5\u503c\u53ef\u4ee5\u662f\u6574\u6570\u6216 MAXVALUE
\u3002\u5bf9\u4e8e LIST
\u5206\u533a\uff0c\u6b64\u5217\u5305\u542b\u5206\u533a\u7684 values in
\u5b50\u53e5\u4e2d\u5b9a\u4e49\u7684\u503c\uff0c\u8be5\u5b50\u53e5\u662f\u9017\u53f7\u5206\u9694\u7684\u6574\u6570\u503c\u5217\u8868\u3002\u5bf9\u4e8e\u4e0d\u662f RANGE
\u6216 LIST
\u7684\u5206\u533a\uff0c\u6b64\u5217\u59cb\u7ec8\u4e3a NULL\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\uff0c\u6b64\u5217\u4e3a NULL comment VARCHAR(2048) \u6ce8\u91ca\u7684\u6587\u672c\u3002\u5426\u5219\uff0c\u6b64\u503c\u4e3a\u7a7a\u3002 options TEXT(0) \u5206\u533a\u7684\u9009\u9879\u4fe1\u606f\uff0c\u6682\u4e3a NULL
partition_table_name VARCHAR(1024) \u5f53\u524d\u5206\u533a\u5bf9\u5e94\u7684\u5206\u533a\u5b50\u8868\u540d\u5b57"},{"location":"MatrixOne/Reference/System-tables/#mo_user","title":"mo_user
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 user_id int \u7528\u6237 ID\uff0c\u4e3b\u952e user_host varchar(100) \u7528\u6237\u4e3b\u673a\u5730\u5740 user_name varchar(100) \u7528\u6237\u540d authentication_string varchar(100) \u5bc6\u7801\u52a0\u5bc6\u7684\u8ba4\u8bc1\u5b57\u7b26\u4e32 status varchar(8) \u5f00\u542f\u3001\u9501\u5b9a\u3001\u5931\u6548 created_time timestamp \u7528\u6237\u521b\u5efa\u65f6\u95f4 expired_time timestamp \u7528\u6237\u8fc7\u671f\u65f6\u95f4 login_type varchar(16) ssl/\u5bc6\u7801/\u5176\u4ed6 creator int \u521b\u5efa\u6b64\u7528\u6237\u7684\u521b\u5efa\u8005 ID owner int \u6b64\u7528\u6237\u7684\u7ba1\u7406\u5458 ID default_role int \u6b64\u7528\u6237\u7684\u9ed8\u8ba4\u89d2\u8272 ID"},{"location":"MatrixOne/Reference/System-tables/#mo_account-sys","title":"mo_account
\u8868 (\u4ec5 sys
\u79df\u6237\u53ef\u89c1)","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 account_id int unsigned \u79df\u6237 ID\uff0c\u4e3b\u952e account_name varchar(100) \u79df\u6237\u540d status varchar(100) \u5f00\u542f/\u6682\u505c/\u9650\u5236 created_time timestamp \u521b\u5efa\u65f6\u95f4 comments varchar(256) \u6ce8\u91ca suspended_time TIMESTAMP \u4fee\u6539\u79df\u6237\u72b6\u6001\u7684\u65f6\u95f4 version bigint unsigned \u5f53\u524d\u79df\u6237\u7248\u672c\u72b6\u6001"},{"location":"MatrixOne/Reference/System-tables/#mo_database","title":"mo_database
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 dat_id bigint unsigned \u4e3b\u952e ID datname varchar(100) \u6570\u636e\u5e93\u540d\u79f0 dat_catalog_name varchar(100) \u6570\u636e\u5e93 catalog \u540d\u79f0\uff0c\u9ed8\u8ba4def
dat_createsql varchar(100) \u521b\u5efa\u6570\u636e\u5e93 SQL \u8bed\u53e5 owner int unsigned \u89d2\u8272 ID creator int unsigned \u7528\u6237 ID created_time timestamp \u521b\u5efa\u65f6\u95f4 account_id int unsigned \u79df\u6237 ID dat_type varchar(23) \u6570\u636e\u5e93\u7c7b\u578b\uff0c\u666e\u901a\u5e93\u6216\u8ba2\u9605\u5e93"},{"location":"MatrixOne/Reference/System-tables/#mo_role","title":"mo_role
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 role_id int unsigned \u89d2\u8272 ID\uff0c\u4e3b\u952e role_name varchar(100) \u89d2\u8272\u540d\u79f0 creator int unsigned \u7528\u6237 ID owner int unsigned MatrixOne \u7ba1\u7406\u5458/\u79df\u6237\u7ba1\u7406\u5458\u62e5\u6709\u8005 ID created_time timestamp \u521b\u5efa\u65f6\u95f4 comments text \u6ce8\u91ca"},{"location":"MatrixOne/Reference/System-tables/#mo_user_grant","title":"mo_user_grant
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 role_id int unsigned \u88ab\u6388\u6743\u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e user_id int unsigned \u83b7\u5f97\u6388\u6743\u89d2\u8272\u7684\u7528\u6237 ID\uff0c\u8054\u5408\u4e3b\u952e granted_time timestamp \u6388\u6743\u65f6\u95f4 with_grant_option bool \u662f\u5426\u5141\u8bb8\u83b7\u5f97\u6388\u6743\u7528\u6237\u518d\u6388\u6743\u7ed9\u5176\u4ed6\u7528\u6237\u6216\u89d2\u8272"},{"location":"MatrixOne/Reference/System-tables/#mo_role_grant","title":"mo_role_grant
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 granted_id int \u88ab\u6388\u4e88\u7684\u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e grantee_id int \u8981\u6388\u4e88\u5176\u4ed6\u89d2\u8272\u7684\u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e operation_role_id int \u64cd\u4f5c\u89d2\u8272 ID operation_user_id int \u64cd\u4f5c\u7528\u6237 ID granted_time timestamp \u6388\u6743\u65f6\u95f4 with_grant_option bool \u662f\u5426\u5141\u8bb8\u83b7\u5f97\u6388\u6743\u89d2\u8272\u518d\u6388\u6743\u7ed9\u5176\u4ed6\u7528\u6237\u6216\u89d2\u8272"},{"location":"MatrixOne/Reference/System-tables/#mo_role_privs","title":"mo_role_privs
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 role_id int unsigned \u89d2\u8272 ID\uff0c\u8054\u5408\u4e3b\u952e role_name varchar(100) \u89d2\u8272\u540d\uff1aaccountadmin/public obj_type varchar(16) \u5bf9\u8c61\u7c7b\u578b\uff1aaccount/database/table\uff0c\u8054\u5408\u4e3b\u952e obj_id bigint unsigned \u5bf9\u8c61 ID\uff0c\u8054\u5408\u4e3b\u952e privilege_id int \u6743\u9650 ID\uff0c\u8054\u5408\u4e3b\u952e privilege_name varchar(100) \u6743\u9650\u540d\uff1a\u6743\u9650\u5217\u8868 privilege_level varchar(100) \u6743\u9650\u7ea7\u522b\uff0c\u8054\u5408\u4e3b\u952e operation_user_id int unsigned \u64cd\u4f5c\u7528\u6237 ID granted_time timestamp \u6388\u6743\u65f6\u95f4 with_grant_option bool \u662f\u5426\u5141\u8bb8\u6388\u6743"},{"location":"MatrixOne/Reference/System-tables/#mo_user_defined_function","title":"mo_user_defined_function
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 function_id INT(32) \u51fd\u6570\u7684 ID\uff0c\u4e3b\u952e name VARCHAR(100) \u51fd\u6570\u7684\u540d\u79f0 owner INT UNSIGNED(32) \u521b\u5efa\u51fd\u6570\u7684\u89d2\u8272 ID args TEXT(0) \u51fd\u6570\u7684\u53c2\u6570\u5217\u8868 rettype VARCHAR(20) \u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b body TEXT(0) \u51fd\u6570\u7684\u51fd\u6570\u4f53 language VARCHAR(20) \u51fd\u6570\u6240\u4f7f\u7528\u7684\u8bed\u8a00 db VARCHAR(100) \u51fd\u6570\u6240\u5728\u7684\u6570\u636e\u5e93 definer VARCHAR(50) \u5b9a\u4e49\u51fd\u6570\u7684\u7528\u6237\u540d\u79f0 modified_time TIMESTAMP(0) \u51fd\u6570\u6700\u540e\u4e00\u6b21\u4fee\u6539\u7684\u65f6\u95f4 created_time TIMESTAMP(0) \u51fd\u6570\u7684\u521b\u5efa\u65f6\u95f4 type VARCHAR(10) \u51fd\u6570\u7684\u7c7b\u578b\uff0c\u9ed8\u8ba4 FUNCTION security_type VARCHAR(10) \u5b89\u5168\u5904\u7406\u65b9\u5f0f\uff0c\u7edf\u4e00\u503c DEFINER comment VARCHAR(5000) \u521b\u5efa\u51fd\u6570\u7684\u6ce8\u91ca character_set_client VARCHAR(64) \u5ba2\u6237\u7aef\u5b57\u7b26\u96c6\uff1autf8mb4 collation_connection VARCHAR(64) \u8fde\u63a5\u6392\u5e8f\uff1autf8mb4_0900_ai_ci database_collation VARCHAR(64) \u6570\u636e\u5e93\u8fde\u63a5\u6392\u5e8f\uff1autf8mb4_0900_ai_ci"},{"location":"MatrixOne/Reference/System-tables/#mo_mysql_compatibility_mode","title":"mo_mysql_compatibility_mode
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 configuration_id INT(32) \u914d\u7f6e\u9879 id\uff0c\u81ea\u589e\u5217\uff0c\u4f5c\u4e3a\u4e3b\u952e\u533a\u5206\u4e0d\u540c\u7684\u914d\u7f6e account_id INT(32) \u914d\u7f6e\u6240\u5728\u7684\u79df\u6237 id account_name VARCHAR(300) \u914d\u7f6e\u6240\u5728\u7684\u79df\u6237\u540d\u79f0 dat_name VARCHAR(5000) \u914d\u7f6e\u6240\u5728\u7684\u6570\u636e\u5e93\u540d\u79f0 variable_name VARCHAR(300) \u53d8\u91cf\u7684\u540d\u5b57 variable_value VARCHAR(5000) \u53d8\u91cf\u7684\u503c system_variables BOOL(0) \u662f\u5426\u4e3a\u7cfb\u7edf\u53d8\u91cf (\u9664\u4e86\u7cfb\u7edf\u53d8\u91cf\uff0c\u8fd8\u6dfb\u52a0\u7684\u6709\u517c\u5bb9\u6027\u53d8\u91cf\uff09"},{"location":"MatrixOne/Reference/System-tables/#mo_pubs","title":"mo_pubs
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 pub_name VARCHAR(64) \u53d1\u5e03\u540d\u79f0 database_name VARCHAR(5000) \u53d1\u5e03\u6570\u636e\u7684\u540d\u79f0 database_id BIGINT UNSIGNED(64) \u53d1\u5e03\u6570\u636e\u5e93\u7684 ID\uff0c\u4e0e mo_database \u8868\u4e2d\u7684 dat_id \u5bf9\u5e94 all_table BOOL(0) \u53d1\u5e03\u5e93\u662f\u5426\u5305\u542b database_id \u5bf9\u5e94\u6570\u636e\u5e93\u5185\u7684\u6240\u6709\u8868 table_list TEXT(0) \u5728\u975e all table \u65f6\uff0c\u53d1\u5e03\u5e93\u5185\u5305\u542b\u7684\u8868\u6e05\u5355\uff0c\u8868\u540d\u4e0e database_id \u5bf9\u5e94\u6570\u636e\u5e93\u4e0b\u7684\u8868\u4e00\u4e00\u5bf9\u5e94 account_list TEXT(0) \u5728\u975e all account \u65f6\uff0c\u5141\u8bb8\u8ba2\u9605\u8be5\u53d1\u5e03\u5e93\u7684 account \u6e05\u5355 created_time TIMESTAMP(0) \u521b\u5efa\u53d1\u5e03\u5e93\u7684\u65f6\u95f4 owner INT UNSIGNED(32) \u521b\u5efa\u53d1\u5e03\u5e93\u5bf9\u5e94\u7684\u89d2\u8272 ID creator INT UNSIGNED(32) \u521b\u5efa\u53d1\u5e03\u5e93\u5bf9\u5e94\u7684\u7528\u6237 ID comment TEXT(0) \u521b\u5efa\u53d1\u5e03\u5e93\u7684\u5907\u6ce8\u4fe1\u606f"},{"location":"MatrixOne/Reference/System-tables/#mo_stages","title":"mo_stages
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 stage_id INT UNSIGNED(32) \u6570\u636e\u9636\u6bb5 ID stage_name VARCHAR(64) \u6570\u636e\u9636\u6bb5\u540d\u79f0 url TEXT(0) \u5bf9\u8c61\u5b58\u50a8\u7684\u8def\u5f84\uff08\u4e0d\u542b\u8ba4\u8bc1\uff09\u3001\u6587\u4ef6\u7cfb\u7edf\u7684\u8def\u5f84 stage_credentials TEXT(0) \u8ba4\u8bc1\u4fe1\u606f\uff0c\u52a0\u5bc6\u540e\u4fdd\u5b58 stage_status VARCHAR(64) ENABLED/DISABLED \u9ed8\u8ba4\uff1aDISABLED created_time TIMESTAMP(0) \u521b\u5efa\u65f6\u95f4 comment TEXT(0) \u6ce8\u91ca"},{"location":"MatrixOne/Reference/System-tables/#mo_sessions","title":"mo_sessions
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 node_id VARCHAR(65535) MatrixOne \u8282\u70b9\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002\u4e00\u7ecf\u542f\u52a8\uff0c\u4e0d\u53ef\u66f4\u6539\u3002 conn_id INT UNSIGNED \u5728 MatrixOne \u4e2d\u4e0e\u5ba2\u6237\u7aef TCP \u8fde\u63a5\u76f8\u5173\u7684\u552f\u4e00\u7f16\u53f7\uff0c\u7531 Hakeeper \u81ea\u52a8\u751f\u6210\u3002 session_id VARCHAR(65535) \u7528\u4e8e\u6807\u8bc6\u4f1a\u8bdd\u7684\u552f\u4e00 UUID\u3002\u6bcf\u4e2a\u65b0\u4f1a\u8bdd\u90fd\u4f1a\u751f\u6210\u4e00\u4e2a\u65b0\u7684 UUID\u3002 account VARCHAR(65535) \u79df\u6237\u7684\u540d\u79f0\u3002 user VARCHAR(65535) \u7528\u6237\u7684\u540d\u79f0\u3002 host VARCHAR(65535) CN \u8282\u70b9\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u3002 db VARCHAR(65535) \u6267\u884c SQL \u65f6\u4f7f\u7528\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002 session_start VARCHAR(65535) \u4f1a\u8bdd\u521b\u5efa\u7684\u65f6\u95f4\u6233\u3002 command VARCHAR(65535) MySQL \u547d\u4ee4\u7684\u7c7b\u578b\uff0c\u5982 COM_QUERY\u3001COM_STMT_PREPARE\u3001COM_STMT_EXECUTE \u7b49\u3002 info VARCHAR(65535) \u6267\u884c\u7684 SQL \u8bed\u53e5\u3002\u4e00\u4e2a SQL \u4e2d\u53ef\u80fd\u5305\u542b\u591a\u4e2a\u8bed\u53e5\u3002 txn_id VARCHAR(65535) \u76f8\u5173\u4e8b\u52a1\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 statement_id VARCHAR(65535) SQL \u8bed\u53e5\u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff08UUID\uff09\u3002 statement_type VARCHAR(65535) SQL \u8bed\u53e5\u7684\u7c7b\u578b\uff0c\u5982 SELECT\u3001INSERT\u3001UPDATE \u7b49\u3002 query_type VARCHAR(65535) SQL \u8bed\u53e5\u7684\u79cd\u7c7b\uff0c\u5982 DQL\uff08\u6570\u636e\u67e5\u8be2\u8bed\u8a00\uff09\u3001TCL\uff08\u4e8b\u52a1\u63a7\u5236\u8bed\u8a00\uff09\u7b49\u3002 sql_source_type VARCHAR(65535) SQL \u8bed\u53e5\u7684\u6765\u6e90\uff0c\u5982\u5916\u90e8\u6216\u5185\u90e8\u3002 query_start VARCHAR(65535) SQL \u8bed\u53e5\u5f00\u59cb\u6267\u884c\u7684\u65f6\u95f4\u6233\u3002 client_host VARCHAR(65535) \u5ba2\u6237\u7aef\u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u53f7\u3002 role VARCHAR(65535) \u7528\u6237\u7684\u89d2\u8272\u540d\u79f0\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_configurations","title":"mo_configurations
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 node_type VARCHAR(65535) \u8282\u70b9\u7684\u7c7b\u578b\uff1acn\uff08\u8ba1\u7b97\u8282\u70b9\uff09\u3001tn\uff08\u4e8b\u52a1\u8282\u70b9\uff09\u3001log\uff08\u65e5\u5fd7\u8282\u70b9\uff09\u3001proxy\uff08\u4ee3\u7406\uff09\u3002 node_id VARCHAR(65535) \u8282\u70b9\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 name VARCHAR(65535) \u914d\u7f6e\u9879\u7684\u540d\u79f0\uff0c\u53ef\u80fd\u4f1a\u9644\u5e26\u5d4c\u5957\u7ed3\u6784\u524d\u7f00\u3002 current_value VARCHAR(65535) \u914d\u7f6e\u9879\u7684\u5f53\u524d\u6570\u503c\u3002 default_value VARCHAR(65535) \u914d\u7f6e\u9879\u7684\u9ed8\u8ba4\u6570\u503c\u3002 internal VARCHAR(65535) \u8868\u793a\u914d\u7f6e\u53c2\u6570\u662f\u5426\u4e3a\u5185\u90e8\u53c2\u6570\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_locks","title":"mo_locks
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 cn_id VARCHAR(65535) cn \u7684 uuid txn_id VARCHAR(65535) \u6301\u6709\u9501\u7684\u4e8b\u52a1\u3002 table_id VARCHAR(65535) \u52a0\u9501\u7684\u8868\u3002 lock_key VARCHAR(65535) \u9501\u7c7b\u578b\u3002\u53ef\u4ee5\u662f point
\u6216 range
\u3002 lock_content VARCHAR(65535) \u9501\u5b9a\u7684\u5185\u5bb9\uff0c\u4ee5 16 \u8fdb\u5236\u8868\u793a\u3002\u5bf9\u4e8e range
\u9501\uff0c\u8868\u793a\u4e00\u4e2a\u533a\u95f4\uff1b\u5bf9\u4e8e point
\u9501\uff0c\u8868\u793a\u5355\u4e2a\u503c\u3002 lock_mode VARCHAR(65535) \u9501\u6a21\u5f0f\u3002\u53ef\u4ee5\u662f shared
\u6216 exclusive
\u3002 lock_status VARCHAR(65535) \u9501\u72b6\u6001\uff0c\u53ef\u80fd\u4e3a wait
\u3001acquired
\u6216 none
\u3002wait\u3002\u6ca1\u6709\u4e8b\u52a1\u6301\u6709\u9501\uff0c\u4f46\u6709\u4e8b\u52a1\u7b49\u5728\u9501\u4e0a\u3002acquired\u3002\u6709\u4e8b\u52a1\u6301\u6709\u9501\u3002none\u3002\u6ca1\u6709\u4e8b\u52a1\u6301\u6709\u9501\uff0c\u4e5f\u6ca1\u6709\u4e8b\u52a1\u7b49\u5728\u9501\u4e0a\u3002 lock_wait VARCHAR(65535) \u5728\u6b64\u9501\u4e0a\u7b49\u5f85\u7684\u4e8b\u52a1\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_variables","title":"mo_variables
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 configuration_id INT(32) \u81ea\u589e\u5217\uff0c\u7528\u4e8e\u552f\u4e00\u6807\u8bc6\u6bcf\u4e2a\u914d\u7f6e\u9879\u3002 account_id INT(32) \u6807\u8bc6\u79df\u6237\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 account_name VARCHAR(300) \u79df\u6237\u7684\u540d\u79f0\u3002 dat_name VARCHAR(5000) \u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 variable_name VARCHAR(300) \u914d\u7f6e\u53d8\u91cf\u7684\u540d\u79f0\u3002 variable_value VARCHAR(5000) \u914d\u7f6e\u53d8\u91cf\u7684\u6570\u503c\u3002 system_variables BOOL(0) \u6307\u793a\u914d\u7f6e\u53d8\u91cf\u662f\u5426\u4e3a\u7cfb\u7edf\u7ea7\u522b\u7684\u53d8\u91cf\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_transactions","title":"mo_transactions
\u89c6\u56fe","text":"\u5217\u540d \u6570\u636e\u7c7b\u578b \u63cf\u8ff0 cn_id VARCHAR(65535) \u552f\u4e00\u6807\u8bc6 CN\uff08Compute Node\uff09\u7684 ID\u3002 txn_id VARCHAR(65535) \u552f\u4e00\u6807\u8bc6\u4e8b\u52a1\u7684 ID\u3002 create_ts VARCHAR(65535) \u8bb0\u5f55\u4e8b\u52a1\u521b\u5efa\u65f6\u95f4\u6233\uff0c\u9075\u5faa RFC3339Nano \u683c\u5f0f (\"2006-01-02T15:04:05.999999999Z07:00\")\u3002 snapshot_ts VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684\u5feb\u7167\u65f6\u95f4\u6233\uff0c\u4ee5\u7269\u7406\u65f6\u95f4\u548c\u903b\u8f91\u65f6\u95f4\u7684\u5f62\u5f0f\u8868\u793a\u3002 prepared_ts VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684 prepared \u65f6\u95f4\u6233\uff0c\u4ee5\u7269\u7406\u65f6\u95f4\u548c\u903b\u8f91\u65f6\u95f4\u7684\u5f62\u5f0f\u8868\u793a\u3002 commit_ts VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684 commit \u65f6\u95f4\u6233\uff0c\u4ee5\u7269\u7406\u65f6\u95f4\u548c\u903b\u8f91\u65f6\u95f4\u7684\u5f62\u5f0f\u8868\u793a\u3002 txn_mode VARCHAR(65535) \u6807\u8bc6\u4e8b\u52a1\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u60b2\u89c2\u4e8b\u52a1\u6216\u4e50\u89c2\u4e8b\u52a1\u3002 isolation VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684\u9694\u79bb\u7ea7\u522b\uff0c\u53ef\u4ee5\u662f SI\uff08Snapshot Isolation\uff09\u6216 RC\uff08Read Committed\uff09\u3002 user_txn VARCHAR(65535) \u6307\u793a\u7528\u6237\u4e8b\u52a1\uff0c\u5373\u7528\u6237\u901a\u8fc7\u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u5e76\u6267\u884c\u7684 SQL \u64cd\u4f5c\u6240\u521b\u5efa\u7684\u4e8b\u52a1\u3002 txn_status VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u7684\u5f53\u524d\u72b6\u6001\uff0c\u53ef\u80fd\u7684\u53d6\u503c\u5305\u62ec active\uff08\u6d3b\u8dc3\uff09\u3001committed\uff08\u5df2\u63d0\u4ea4\uff09\u3001aborting\uff08\u4e2d\u6b62\u4e2d\uff09\u3001aborted\uff08\u5df2\u4e2d\u6b62\uff09\u3002\u5728\u5206\u5e03\u5f0f\u4e8b\u52a1 2PC \u6a21\u5f0f\u4e0b\uff0c\u8fd8\u4f1a\u5305\u62ec prepared\uff08\u5df2\u51c6\u5907\uff09\u548c committing\uff08\u63d0\u4ea4\u4e2d\uff09\u3002 table_id VARCHAR(65535) \u8868\u793a\u4e8b\u52a1\u6240\u6d89\u53ca\u7684\u8868\u7684 ID\u3002 lock_key VARCHAR(65535) \u8868\u793a\u9501\u7684\u7c7b\u578b\uff0c\u53ef\u4ee5\u662f range\uff08\u8303\u56f4\u9501\uff09\u6216 point\uff08\u70b9\u9501\uff09\u3002 lock_content VARCHAR(65535) point \u9501\u65f6\u8868\u793a\u5355\u4e2a\u503c\uff0crange \u9501\u65f6\u8868\u793a\u8303\u56f4\uff0c\u901a\u5e38\u4ee5 \"low - high\" \u5f62\u5f0f\u8868\u793a\u3002\u8bf7\u6ce8\u610f\uff0c\u4e8b\u52a1\u53ef\u80fd\u6d89\u53ca\u591a\u4e2a\u9501\uff0c\u4f46\u6b64\u5904\u4ec5\u5c55\u793a\u7b2c\u4e00\u4e2a\u9501\u3002 lock_mode VARCHAR(65535) \u8868\u793a\u9501\u7684\u6a21\u5f0f\uff0c\u53ef\u4ee5\u662f\u4e92\u65a5\u9501\uff08exclusive\uff09\u6216\u5171\u4eab\u9501\uff08shared\uff09\u3002"},{"location":"MatrixOne/Reference/System-tables/#mo_columns","title":"mo_columns
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 att_uniq_name varchar(256) \u4e3b\u952e\u3002\u9690\u85cf\u7684\u590d\u5408\u4e3b\u952e\uff0c\u683c\u5f0f\u7c7b\u4f3c\u4e8e \"${att_relname_id}-${attname}\" account_id int unsigned \u79df\u6237 ID att_database_id bigint unsigned \u6570\u636e\u5e93 ID att_database varchar(256) \u6570\u636e Name att_relname_id bigint unsigned \u8868 ID att_relname varchar(256) \u6b64\u5217\u6240\u5c5e\u7684\u8868\u3002\uff08\u53c2\u8003 mo_tables.relname\uff09 attname varchar(256) \u5217\u540d atttyp varchar(256) \u6b64\u5217\u7684\u6570\u636e\u7c7b\u578b (\u5220\u9664\u7684\u5217\u4e3a 0 )\u3002 attnum int \u5217\u6570\u3002\u666e\u901a\u5217\u4ece 1 \u5f00\u59cb\u7f16\u53f7\u3002 att_length int \u7c7b\u578b\u7684\u5b57\u8282\u6570 attnotnull tinyint(1) \u8868\u793a\u4e00\u4e2a\u975e\u7a7a\u7ea6\u675f\u3002 atthasdef tinyint(1) \u6b64\u5217\u6709\u9ed8\u8ba4\u8868\u8fbe\u5f0f\u6216\u751f\u6210\u8868\u8fbe\u5f0f\u3002 att_default varchar(1024) \u9ed8\u8ba4\u8868\u8fbe\u5f0f attisdropped tinyint(1) \u6b64\u5217\u5df2\u5220\u9664\uff0c\u4e0d\u518d\u6709\u6548\u3002\u5220\u9664\u7684\u5217\u4ecd\u7136\u7269\u7406\u4e0a\u5b58\u5728\u4e8e\u8868\u4e2d\uff0c\u4f46\u89e3\u6790\u5668\u4f1a\u5ffd\u7565\u5b83\uff0c\u56e0\u6b64\u4e0d\u80fd\u901a\u8fc7 SQL \u8bbf\u95ee\u5b83\u3002 att_constraint_type char(1) p = \u4e3b\u952e\u7ea6\u675fn=\u65e0\u7ea6\u675f att_is_unsigned tinyint(1) \u662f\u5426\u672a\u7f72\u540d att_is_auto_increment tinyint(1) \u662f\u5426\u81ea\u589e att_comment varchar(1024) \u6ce8\u91ca att_is_hidden tinyint(1) \u662f\u5426\u9690\u85cf attr_has_update tinyint(1) \u6b64\u5217\u542b\u6709\u66f4\u65b0\u8868\u8fbe\u5f0f attr_update varchar(1024) \u66f4\u65b0\u8868\u8fbe\u5f0f attr_is_clusterby tinyint(1) \u6b64\u5217\u662f\u5426\u4f5c\u4e3a cluster by \u5173\u952e\u5b57\u6765\u5efa\u8868 attr_seqnum SMALLINT UNSIGNED(0) \u6bcf\u4e2a\u5217\u7684\u5e8f\u5217\u53f7 attr_enum varchar(65535) \u82e5\u8fd9\u4e2a\u5217\u7684\u7c7b\u578b\u4e3a ENUM\uff0c\u5219\u8868\u793a\u8be5\u5217\u4ee3\u8868\u7684 ENUM \u7c7b\u578b\u7684\u503c\uff0c\u5426\u5219\u4e3a\u7a7a"},{"location":"MatrixOne/Reference/System-tables/#mo_tables","title":"mo_tables
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 rel_id bigint unsigned \u4e3b\u952e\uff0c\u8868 ID relname varchar(100) \u8868\u3001\u7d22\u5f15\u3001\u89c6\u56fe\u7b49\u7684\u540d\u79f0 reldatabase varchar(100) \u5305\u542b\u6b64\u5173\u7cfb\u7684\u6570\u636e\u5e93\uff0c\u53c2\u8003 mo_database.datname reldatabase_id bigint unsigned \u5305\u542b\u6b64\u5173\u7cfb\u7684\u6570\u636e\u5e93 ID\uff0c\u53c2\u8003 mo_database.datid relpersistence varchar(100) p = \u6c38\u4e45\u8868 t = \u4e34\u65f6\u8868 relkind varchar(100) r = \u666e\u901a\u8868 e = \u5916\u90e8\u8868 i = \u7d22\u5f15 S = \u5e8f\u5217 v = \u89c6\u56fe m = \u7269\u5316\u89c6\u56fe rel_comment varchar(100) \u8868\u6ce8\u91ca rel_createsql varchar(100) \u521b\u5efa\u8868 SQL \u8bed\u53e5 created_time timestamp \u521b\u5efa\u65f6\u95f4 creator int unsigned \u521b\u5efa\u8005 ID owner int unsigned \u521b\u5efa\u8005\u7684\u9ed8\u8ba4\u89d2\u8272 ID account_id int unsigned \u79df\u6237 id partitioned blob \u6309\u8bed\u53e5\u5206\u533a partition_info blob \u5206\u533a\u4fe1\u606f viewdef blob \u89c6\u56fe\u5b9a\u4e49\u8bed\u53e5 constraint varchar(5000) \u4e0e\u8868\u76f8\u5173\u7684\u7ea6\u675f rel_version INT UNSIGNED(0) \u4e3b\u952e\uff0c\u8868\u7684\u7248\u672c\u53f7 catalog_version INT UNSIGNED(0) \u7cfb\u7edf\u8868\u7684\u7248\u672c\u53f7"},{"location":"MatrixOne/Reference/System-tables/#system_metrics","title":"system_metrics
\u6570\u636e\u5e93","text":"system_metrics
\u6536\u96c6 SQL \u8bed\u53e5\u3001CPU \u548c\u5185\u5b58\u8d44\u6e90\u4f7f\u7528\u7684\u72b6\u6001\u548c\u7edf\u8ba1\u4fe1\u606f\u3002
metrics
\u8868\u4e00\u4e9b\u76f8\u540c\u7684\u5217\u7c7b\u578b\uff0c\u8fd9\u4e9b\u8868\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
collecttime\uff1a\u6536\u96c6\u65f6\u95f4\u3002
value\uff1a\u91c7\u96c6 metrics
\u7684\u503c\u3002
node\uff1a\u8868\u793a MatrixOne \u8282\u70b9\u7684 uuid\u3002
role\uff1aMatrixOne \u8282\u70b9\u89d2\u8272\uff0c\u5305\u62ec CN\u3001TN \u548c Log\u3002
account\uff1a\u9ed8\u8ba4\u4e3a\u201csys\u201d\u79df\u6237\uff0c\u5373\u89e6\u53d1 SQL \u8bf7\u6c42\u7684\u8d26\u6237\u3002
type\uff1aSQL \u7c7b\u578b\uff0c\u53ef\u4ee5\u662f select
\uff0cinsert
\uff0cupdate
\uff0cdelete
\uff0cother
\u7c7b\u578b\u3002
metric
\u8868","text":"\u5217\u5c5e\u6027 \u7c7b\u578b \u63cf\u8ff0 metric_name VARCHAR(128) \u6307\u6807\u540d\u79f0\uff0c\u4f8b\u5982\uff1asql_statement_total\uff0cserver_connections\uff0cprocess_cpu_percent\uff0csys_memory_used \u7b49 collecttime DATETIME \u6307\u6807\u6570\u636e\u6536\u96c6\u65f6\u95f4 value DOUBLE \u6307\u6807\u503c node VARCHAR(36) MatrixOne \u8282\u70b9 uuid role VARCHAR(32) MatrixOne \u8282\u70b9\u89d2\u8272 account VARCHAR(128) \u79df\u6237\u540d\u79f0\uff0c\u9ed8\u8ba4 sys
type VARCHAR(32) SQL \u7c7b\u578b\uff0c\u4f8b\u5982\uff1aINSERT\uff0cSELECT\uff0cUPDATE \u4ee5\u4e0b\u8868\u4e3a metric
\u8868\u7684\u89c6\u56fe\uff1a
sql_statement_total
\u8868\uff1a\u6267\u884c SQL \u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002sql_statement_errors
\u8868\uff1a\u6267\u884c\u9519\u8bef\u7684 SQL \u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002sql_transaction_total
\u8868\uff1a\u4e8b\u52a1\u6027 SQL \u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002sql_transaction_errors
\u8868\uff1a\u9519\u8bef\u6267\u884c\u7684\u4e8b\u52a1\u6027\u8bed\u53e5\u7684\u8ba1\u6570\u5668\u3002server_connections
\u8868\uff1a\u670d\u52a1\u5668\u8fde\u63a5\u6570\u3002server_storage_usage
\uff1a\u670d\u52a1\u5668\u5b58\u50a8\u4f7f\u7528\u60c5\u51b5\u3002process_cpu_percent
\u8868\uff1aCPU \u8fdb\u7a0b\u7e41\u5fd9\u767e\u5206\u6bd4\u3002process_resident_memory_bytes
\u8868\uff1a\u9a7b\u7559\u5185\u5b58\u91cf\uff0c\u5355\u4f4d\u4e3a\u5b57\u8282\u3002process_open_fds
\u8868\uff1a\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6570\u91cf\u3002sys_cpu_seconds_total
\u8868\uff1a\u7cfb\u7edf CPU \u65f6\u95f4\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7531\u6838\u6570\u6807\u51c6\u5316\u3002sys_cpu_combined_percent
\u8868\uff1a\u7cfb\u7edf CPU \u7e41\u5fd9\u767e\u5206\u6bd4\uff0c\u6240\u6709\u903b\u8f91\u6838\u7684\u5e73\u5747\u503c\u3002sys_memory_used
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u5df2\u4f7f\u7528\u7684\u7cfb\u7edf\u5185\u5b58\u3002sys_memory_available
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u7684\u53ef\u7528\u7cfb\u7edf\u5185\u5b58\u3002sys_disk_read_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u8bfb\u53d6\u7cfb\u7edf\u76d8\u3002sys_disk_write_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u5199\u5165\u7cfb\u7edf\u76d8\u3002sys_net_recv_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u63a5\u6536\u7684\u7cfb\u7edf\u7f51\u7edc\u3002sys_net_sent_bytes
\u8868\uff1a\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u53d1\u9001\u7684\u7cfb\u7edf\u7f51\u7edc\u3002system
\u6570\u636e\u5e93","text":"System
\u6570\u636e\u5e93\u5b58\u50a8 MatrixOne \u5386\u53f2 SQL \u8bed\u53e5\u3001\u7cfb\u7edf\u65e5\u5fd7\u3001\u9519\u8bef\u4fe1\u606f\u3002
statement_info
\u8868","text":"statement_info
\u8868\u8bb0\u5f55\u7528\u6237\u548c\u7cfb\u7edf\u7684 SQL \u8bed\u53e5\u548c\u8be6\u7ec6\u4fe1\u606f\u3002
rawlog
\u8868","text":"rawlog
\u8868\u8bb0\u5f55\u4e86\u975e\u5e38\u8be6\u7ec6\u7684\u7cfb\u7edf\u65e5\u5fd7\u3002
\u5176\u4ed6 3 \u4e2a\u8868\uff08log_info
\u3001span_info
\u548c error_info
\uff09\u662f statement_info
\u548c rawlog
\u8868\u7684\u89c6\u56fe\u3002
information_schema
\u6570\u636e\u5e93","text":"Information Schema \u63d0\u4f9b\u4e86\u4e00\u79cd ANSI \u6807\u51c6\u65b9\u5f0f\uff0c\u7528\u4e8e\u67e5\u770b\u7cfb\u7edf\u7684\u5143\u6570\u636e\u3002MatrixOne \u9664\u4e86\u4e3a MySQL \u517c\u5bb9\u6027\u800c\u5305\u542b\u7684\u8868\u4e4b\u5916\uff0c\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u81ea\u5b9a\u4e49\u7684 information_schema
\u8868\u3002
\u8bb8\u591a INFORMATION_SCHEMA
\u8868\u90fd\u6709\u76f8\u5e94\u7684 SHOW
\u547d\u4ee4\u3002\u67e5\u8be2 INFORMATION_SCHEMA
\u53ef\u4ee5\u5728\u8868\u4e4b\u95f4\u8fdb\u884c\u8fde\u63a5\u3002
SHOW PROCESSLIST
\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002 USER_PRIVILEGES \u5217\u4e3e\u4e86\u4e0e\u5f53\u524d\u7528\u6237\u5173\u8054\u7684\u6743\u9650\u3002 SCHEMATA \u63d0\u4f9b\u4e86\u4e0e\u6267\u884c SHOW DATABASES
\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002 CHARACTER_SETS \u63d0\u4f9b\u4e86\u670d\u52a1\u5668\u652f\u6301\u7684\u5b57\u7b26\u96c6\u5217\u8868\u3002 TRIGGERS \u63d0\u4f9b\u4e86\u4e0e\u6267\u884c SHOW TRIGGERS
\u7c7b\u4f3c\u7684\u4fe1\u606f\u3002 TABLES \u63d0\u4f9b\u4e86\u5f53\u524d\u7528\u6237\u53ef\u4ee5\u67e5\u770b\u7684\u8868\u5217\u8868\u3002\u7c7b\u4f3c\u4e8e\u6267\u884cSHOW TABLES
\u3002 PARTITIONS \u63d0\u4f9b\u4e86\u8868\u7684\u5206\u533a\u4fe1\u606f\u3002 VIEWS \u63d0\u4f9b\u6709\u5173\u6570\u636e\u5e93\u4e2d\u89c6\u56fe\u7684\u4fe1\u606f\u3002 ENGINES \u63d0\u4f9b\u4e86\u652f\u6301\u7684\u5b58\u50a8\u5f15\u64ce\u5217\u8868\u3002 ROUTINES \u63d0\u4f9b\u6709\u5173\u5b58\u50a8\u5b58\u50a8\u8fc7\u7a0b\u7684\u4e00\u4e9b\u4fe1\u606f\u3002 PARAMETERS \u8868\u63d0\u4f9b\u4e86\u5b58\u50a8\u8fc7\u7a0b\u7684\u53c2\u6570\u548c\u8fd4\u56de\u503c\u7684\u4fe1\u606f\u3002 KEYWORDS \u63d0\u4f9b\u6709\u5173\u6570\u636e\u5e93\u4e2d\u5173\u952e\u5b57\u4fe1\u606f\uff0c\u8be6\u60c5\u53c2\u89c1\u5173\u952e\u5b57\u3002"},{"location":"MatrixOne/Reference/System-tables/#character_sets","title":"CHARACTER_SETS
\u8868","text":"CHARACTER_SETS
\u8868\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
CHARACTER_SET_NAME
\uff1a\u5b57\u7b26\u96c6\u7684\u540d\u79f0\u3002DEFAULT_COLLATE_NAME
\uff1a\u5b57\u7b26\u96c6\u7684\u9ed8\u8ba4\u6392\u5e8f\u89c4\u5219\u540d\u79f0\u3002DESCRIPTION
\uff1a\u5b57\u7b26\u96c6\u7684\u63cf\u8ff0\u3002MAXLEN
\uff1a\u5728\u6b64\u5b57\u7b26\u96c6\u4e2d\u5b58\u50a8\u5b57\u7b26\u6240\u9700\u7684\u6700\u5927\u957f\u5ea6\u3002COLUMNS
\u89c6\u56fe","text":"COLUMNS
\u89c6\u56fe\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
TABLE_CATALOG
\uff1a\u542b\u6709\u8be5\u5217\u7684\u8868\u6240\u5c5e\u7684\u76ee\u5f55\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a def
\u3002TABLE_SCHEMA
\uff1a\u542b\u6709\u5217\u7684\u8868\u6240\u5728\u7684\u6a21\u5f0f\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u5305\u542b\u5217\u7684\u8868\u7684\u540d\u79f0\u3002COLUMN_NAME
\uff1a\u5217\u7684\u540d\u79f0\u3002ORDINAL_POSITION
\uff1a\u8868\u4e2d\u5217\u7684\u4f4d\u7f6e\u3002COLUMN_DEFAULT
\uff1a\u5217\u7684\u9ed8\u8ba4\u503c\u3002\u5982\u679c\u663e\u5f0f\u9ed8\u8ba4\u503c\u4e3a NULL
\uff0c\u6216\u8005\u5982\u679c\u5217\u5b9a\u4e49\u4e0d\u5305\u542b default
\u5b50\u53e5\uff0c\u5219\u6b64\u503c\u4e3a NULL
\u3002IS_NULLABLE
\uff1a\u5217\u662f\u5426\u53ef\u4ee5\u4e3a\u7a7a\u3002\u5982\u679c\u8be5\u5217\u53ef\u4ee5\u5b58\u50a8\u7a7a\u503c\uff0c\u5219\u8be5\u503c\u4e3a YES
\uff1b\u5426\u5219\u4e3a NO
\u3002DATA_TYPE
\uff1a\u5217\u4e2d\u7684\u6570\u636e\u7c7b\u578b\u3002CHARACTER_MAXIMUM_LENGTH
\uff1a\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5217\uff0c\u5b57\u7b26\u7684\u6700\u5927\u957f\u5ea6\u3002CHARACTER_OCTET_LENGTH
\uff1a\u5bf9\u4e8e\u5b57\u7b26\u4e32\u5217\uff0c\u6700\u5927\u957f\u5ea6\uff08\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff09\u3002NUMERIC_PRECISION
\uff1a\u6570\u5b57\u7c7b\u578b\u5217\u7684\u6570\u5b57\u7cbe\u5ea6\u3002NUMERIC_SCALE
\uff1a\u6570\u5b57\u7c7b\u578b\u5217\u7684\u6570\u5b57\u6bd4\u4f8b\u3002DATETIME_PRECISION
\uff1a\u5bf9\u4e8e\u65f6\u95f4\u7c7b\u578b\u5217\uff0c\u5c0f\u6570\u79d2\u7cbe\u5ea6\u3002CHARACTER_SET_NAME
\uff1a\u5b57\u7b26\u4e32\u5217\u7684\u5b57\u7b26\u96c6\u540d\u79f0\u3002COLLATION_NAME
\uff1a\u5b57\u7b26\u4e32\u5217\u7684\u6392\u5e8f\u89c4\u5219\u7684\u540d\u79f0\u3002COLUMN_TYPE
\uff1a\u5217\u7c7b\u578b\u3002COLUMN_KEY
\uff1a\u8be5\u5217\u662f\u5426\u88ab\u7d22\u5f15\u3002\u8be5\u5b57\u6bb5\u53ef\u80fd\u5177\u6709\u4ee5\u4e0b\u503c\uff1aEmpty
\uff1a\u6b64\u5217\u672a\u7f16\u5165\u7d22\u5f15\uff0c\u6216\u8005\u6b64\u5217\u5df2\u7f16\u5165\u7d22\u5f15\u5e76\u4e14\u662f\u591a\u5217\u975e\u552f\u4e00\u7d22\u5f15\u4e2d\u7684\u7b2c\u4e8c\u5217\u3002PRI
\uff1a\u6b64\u5217\u662f\u4e3b\u952e\u6216\u591a\u4e2a\u4e3b\u952e\u4e4b\u4e00\u3002UNI
\uff1a\u6b64\u5217\u662f\u552f\u4e00\u7d22\u5f15\u7684\u7b2c\u4e00\u5217\u3002MUL
\uff1a\u8be5\u5217\u662f\u975e\u552f\u4e00\u7d22\u5f15\u7684\u7b2c\u4e00\u5217\uff0c\u5176\u4e2d\u5141\u8bb8\u7ed9\u5b9a\u503c\u591a\u6b21\u51fa\u73b0\u3002EXTRA
\uff1a\u7ed9\u5b9a\u5217\u7684\u4efb\u4f55\u9644\u52a0\u4fe1\u606f\u3002PRIVILEGES
\uff1a\u5f53\u524d\u7528\u6237\u6240\u62e5\u6709\u7684\u5bf9\u8be5\u5217\u7684\u6743\u9650\u3002COLUMN_COMMENT
\uff1a\u5217\u5b9a\u4e49\u4e2d\u5305\u542b\u7684\u63cf\u8ff0\u3002GENERATION_EXPRESSION
\uff1a\u5bf9\u4e8e\u751f\u6210\u7684\u5217\uff0c\u6b64\u503c\u663e\u793a\u7528\u4e8e\u8ba1\u7b97\u5217\u503c\u7684\u8868\u8fbe\u5f0f\u3002\u5bf9\u4e8e\u975e\u751f\u6210\u5217\uff0c\u8be5\u503c\u4e3a\u7a7a\u3002SRS_ID
\uff1a\u6b64\u503c\u9002\u7528\u4e8e\u7a7a\u95f4\u5217\u3002\u5b83\u5305\u542b\u5217 SRID
\u503c\uff0c\u8be5\u503c\u8868\u793a\u4e3a\u5b58\u50a8\u5728\u8be5\u5217\u4e2d\u7684\u503c\u63d0\u4f9b\u4e00\u4e2a\u7a7a\u95f4\u53c2\u8003\u7cfb\u7edf\u3002ENGINES
\u8868","text":"ENGINES
\u8868\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
ENGINE
\uff1a\u5b58\u50a8\u5f15\u64ce\u7684\u540d\u79f0\u3002SUPPORT
\uff1a\u670d\u52a1\u5668\u5bf9\u5b58\u50a8\u5f15\u64ce\u7684\u652f\u6301\u7ea7\u522b\u3002COMMENT
\uff1a\u5bf9\u5b58\u50a8\u5f15\u64ce\u7684\u7b80\u77ed\u8bc4\u8bba\u3002TRANSACTIONS
\uff1a\u5b58\u50a8\u5f15\u64ce\u662f\u5426\u652f\u6301\u4e8b\u52a1\u3002XA
\uff1a\u5b58\u50a8\u5f15\u64ce\u662f\u5426\u652f\u6301 XA \u4e8b\u52a1\u3002SAVEPOINTS
\uff1a\u5b58\u50a8\u5f15\u64ce\u662f\u5426\u652f\u6301 savepoints
\u3002PARTITIONS
\u89c6\u56fe","text":"PARTITIONS
\u89c6\u56fe\u4e2d\u7684\u5217\u63cf\u8ff0\u5982\u4e0b\uff1a
TABLE_CATALOG
\uff1a\u542b\u6709\u8be5\u5217\u7684\u8868\u6240\u5c5e\u7684\u76ee\u5f55\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a def\u3002TABLE_SCHEMA
\uff1a\u542b\u6709\u5217\u7684\u8868\u6240\u5728\u7684\u6a21\u5f0f\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u5305\u542b\u5217\u7684\u8868\u7684\u540d\u79f0\u3002PARTITION_NAME
\uff1a\u5206\u533a\u540d\u79f0\u3002SUBPARTITION_NAME
\uff1a\u5982\u679c PARTITIONS
\u8868\u4e2d\u7684\u884c\u8868\u793a\u4e00\u4e2a\u5b50\u5206\u533a\uff0c\u5219\u4e3a\u8be5\u5b50\u5206\u533a\u7684\u540d\u79f0\uff1b\u5426\u5219\u4e3a\u7a7a\u3002PARTITION_ORDINAL_POSITION
\uff1a\u6240\u6709\u5206\u533a\u6309\u7167\u5b83\u4eec\u88ab\u5b9a\u4e49\u7684\u987a\u5e8f\u8fdb\u884c\u7d22\u5f15\uff0c\u5176\u4e2d 1 \u8868\u793a\u5206\u914d\u7ed9\u7b2c\u4e00\u4e2a\u5206\u533a\u7684\u7f16\u53f7\u3002\u968f\u7740\u5206\u533a\u7684\u589e\u52a0\u3001\u5220\u9664\u548c\u91cd\u65b0\u7ec4\u7ec7\uff0c\u7d22\u5f15\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\uff1b\u8be5\u5217\u4e2d\u663e\u793a\u7684\u7f16\u53f7\u53cd\u6620\u4e86\u5f53\u524d\u7684\u987a\u5e8f\uff0c\u8003\u8651\u4e86\u4efb\u4f55\u7d22\u5f15\u53d8\u5316\u3002SUBPARTITION_ORDINAL_POSITION
\uff1a\u5728\u7ed9\u5b9a\u5206\u533a\u5185\uff0c\u5b50\u5206\u533a\u7684\u7d22\u5f15\u548c\u91cd\u65b0\u7d22\u5f15\u65b9\u5f0f\u4e0e\u8868\u5185\u5206\u533a\u7684\u65b9\u5f0f\u76f8\u540c\u3002PARTITION_METHOD
\uff1a\u53d6\u503c\u4e4b\u4e00\u4e3a RANGE
\u3001LIST
\u3001HASH
\u3001LINEAR HASH
\u3001KEY
\u6216 LINEAR KEY
\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\u3002SUBPARTITION_METHOD
\uff1a\u53d6\u503c\u4e4b\u4e00\u4e3a HASH
\u3001LINEAR HASH
\u3001KEY
\u6216 LINEAR KEY
\u3002PARTITION_EXPRESSION
\uff1a\u5728\u521b\u5efa\u8868\u7684 CREATE TABLE
\u6216 ALTER TABLE
\u8bed\u53e5\u4e2d\u4f7f\u7528\u7684\u5206\u533a\u51fd\u6570\u8868\u8fbe\u5f0f\uff0c\u7528\u4e8e\u521b\u5efa\u8868\u7684\u5f53\u524d\u5206\u533a\u65b9\u6848\u3002SUBPARTITION_EXPRESSION
\uff1a\u8fd9\u4e0e PARTITION_EXPRESSION
\u7c7b\u4f3c\uff0c\u7528\u4e8e\u5b9a\u4e49\u8868\u7684\u5b50\u5206\u533a\u65b9\u5f0f\uff0c\u5982\u679c\u8868\u6ca1\u6709\u5b50\u5206\u533a\uff0c\u5219\u8be5\u5217\u4e3a\u7a7a\u3002PARTITION_DESCRIPTION
\uff1a\u6b64\u5217\u9002\u7528\u4e8e RANGE
\u548c LIST
\u5206\u533a\u3002\u5bf9\u4e8e RANGE
\u5206\u533a\uff0c\u5b83\u5305\u542b\u5728\u5206\u533a\u7684 VALUES LESS THAN
\u5b50\u53e5\u4e2d\u8bbe\u7f6e\u7684\u503c\uff0c\u53ef\u4ee5\u662f\u6574\u6570\u6216 MAXVALUE
\u3002\u5bf9\u4e8e LIST
\u5206\u533a\uff0c\u6b64\u5217\u5305\u542b\u5728\u5206\u533a\u7684 VALUES IN
\u5b50\u53e5\u4e2d\u5b9a\u4e49\u7684\u503c\uff0c\u8fd9\u662f\u4e00\u7ec4\u9017\u53f7\u5206\u9694\u7684\u6574\u6570\u503c\u3002\u5bf9\u4e8e PARTITION_METHOD
\u4e0d\u662f RANGE
\u6216 LIST
\u7684\u5206\u533a\uff0c\u6b64\u5217\u59cb\u7ec8\u4e3a\u7a7a\u3002Note: MatrixOne \u6682\u4e0d\u652f\u6301 RANGE
\u548c LIST
\u5206\u533a\u3002TABLE_ROWS
\uff1a\u5206\u533a\u4e2d\u7684\u8868\u884c\u6570\u3002AVG_ROW_LENGTH
\uff1a\u5b58\u50a8\u5728\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u4e2d\u7684\u884c\u7684\u5e73\u5747\u957f\u5ea6\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3002\u8fd9\u4e0e DATA_LENGTH
\u9664\u4ee5 TABLE_ROWS
\u5f97\u5230\u7684\u7ed3\u679c\u76f8\u540c\u3002DATA_LENGTH
\uff1a\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u4e2d\u5b58\u50a8\u7684\u6240\u6709\u884c\u7684\u603b\u957f\u5ea6\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\uff1b\u5373\u5b58\u50a8\u5728\u5206\u533a\u6216\u5b50\u5206\u533a\u4e2d\u7684\u5b57\u8282\u603b\u6570\u3002MAX_DATA_LENGTH
: \u5206\u533a\u4e2d\u6570\u636e\u7684\u6700\u5927\u957f\u5ea6INDEX_LENGTH
\uff1a\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u7684\u7d22\u5f15\u6587\u4ef6\u957f\u5ea6\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3002DATA_FREE
\uff1a\u5206\u914d\u7ed9\u5206\u533a\u6216\u5b50\u5206\u533a\u4f46\u672a\u4f7f\u7528\u7684\u5b57\u8282\u6570\u3002CREATE_TIME
\uff1a\u5206\u533a\u6216\u5b50\u5206\u533a\u521b\u5efa\u7684\u65f6\u95f4\u3002UPDATE_TIME
\uff1a\u5206\u533a\u6216\u5b50\u5206\u533a\u4e0a\u6b21\u4fee\u6539\u7684\u65f6\u95f4\u3002CHECK_TIME
\uff1a\u5c5e\u4e8e\u6b64\u5206\u533a\u6216\u5b50\u5206\u533a\u7684\u8868\u6700\u540e\u4e00\u6b21\u68c0\u67e5\u7684\u65f6\u95f4\u3002CHECKSUM
\uff1a\u6821\u9a8c\u548c\u503c\uff0c\u5982\u679c\u6709\u7684\u8bdd\uff1b\u5426\u5219\u4e3a\u7a7a\u3002PARTITION_COMMENT
\uff1a\u5982\u679c\u5206\u533a\u6709\u6ce8\u91ca\uff0c\u5219\u4e3a\u6ce8\u91ca\u7684\u6587\u672c\u3002\u5982\u679c\u6ca1\u6709\uff0c\u5219\u8be5\u503c\u4e3a\u7a7a\u3002\u5206\u533a\u6ce8\u91ca\u7684\u6700\u5927\u957f\u5ea6\u5b9a\u4e49\u4e3a 1024 \u4e2a\u5b57\u7b26\uff0cPARTITION_COMMENT
\u5217\u7684\u663e\u793a\u5bbd\u5ea6\u4e5f\u4e3a 1024 \u4e2a\u5b57\u7b26\uff0c\u4ee5\u4e0e\u6b64\u9650\u5236\u76f8\u7b26\u3002NODEGROUP
\uff1a\u8be5\u5206\u533a\u6240\u5c5e\u7684\u8282\u70b9\u7ec4\u3002TABLESPACE_NAME
\uff1a\u8be5\u5206\u533a\u6240\u5c5e\u7684\u8868\u7a7a\u95f4\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a DEFAULT
\u3002PROCESSLIST
\u89c6\u56fe","text":"PROCESSLIST
\u89c6\u56fe\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
NODE_ID
\uff1aCN \u8282\u70b9 UUIDCONN_ID
\uff1a\u7528\u6237\u8fde\u63a5\u7684 IDSESSION_ID
\uff1a\u4f1a\u8bdd\u7684 IDACCOUNT
\uff1a\u79df\u6237\u540dUSER
\uff1a\u7528\u6237\u540dHOST
\uff1aCN \u8282\u70b9\u7684\u76d1\u542c\u5730\u5740DB
\uff1a\u5f53\u524d\u8fde\u63a5\u7684\u6570\u636e\u5e93SESSION_START
\uff1asession \u521b\u5efa\u65f6\u95f4COMMAND
\uff1a\u8bed\u53e5\u7684 MySQL \u534f\u8bae CommandINFO
\uff1a\u6b63\u5728\u5904\u7406\u7684 SQL \u8bed\u53e5TXN_ID
\uff1a\u4e8b\u52a1 IDSTATEMENT_ID
\uff1a\u8bed\u53e5 IDSTATEMENT_TYPE
\uff1a\u8bed\u53e5\u7c7b\u578b\uff0cSelect/Update/Delete \u7b49QUERY_TYPR
\uff1a\u67e5\u8be2\u7c7b\u578b\uff0cDQL/DDL/DML \u7b49SQL_SOURCE_TYPE
\uff1aSQL \u8bed\u53e5\u6e90\u7c7b\u578b\uff0c\u5916\u90e8\u6216\u8005\u5185\u90e8 SQL\uff1aexternal_sql/internal_sqlQUERY_START
\uff1a\u67e5\u8be2\u5f00\u59cb\u65f6\u95f4CLIENT_HOST
\uff1a\u5ba2\u6237\u7aef\u5730\u5740SCHEMATA
\u89c6\u56fe","text":"SCHEMATA
\u89c6\u56fe\u63d0\u4f9b\u6709\u5173\u6570\u636e\u5e93\u7684\u4fe1\u606f\uff0c\u6570\u636e\u7b49\u540c\u4e8e SHOW DATABASES
\u8bed\u53e5\u7684\u7ed3\u679c\u3002SCHEMATA
\u89c6\u56fe\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
CATALOG_NAME
\uff1a\u6570\u636e\u5e93\u6240\u5c5e\u7684\u76ee\u5f55\u3002SCHEMA_NAME
\uff1a\u6570\u636e\u5e93\u540d\u79f0\u3002DEFAULT_CHARACTER_SET_NAME
\uff1a\u6570\u636e\u5e93\u7684\u9ed8\u8ba4\u5b57\u7b26\u96c6\u3002DEFAULT_COLLATION_NAME
\uff1a\u6570\u636e\u5e93\u7684\u9ed8\u8ba4\u6392\u5e8f\u89c4\u5219\u3002SQL_PATH
\uff1a\u6b64\u9879\u7684\u503c\u59cb\u7ec8\u4e3a NULL
\u3002DEFAULT_TABLE_ENCRYPTION
\uff1a\u5b9a\u4e49\u6570\u636e\u5e93\u548c\u901a\u7528\u8868\u7a7a\u95f4\u7684 default encryption \u8bbe\u7f6e\u3002TABLES
\u89c6\u56fe","text":"TABLES
\u89c6\u56fe\u4e2d\u5217\u7684\u63cf\u8ff0\u5982\u4e0b\uff1a
TABLE_CATALOG
\uff1a\u8868\u6240\u5c5e\u76ee\u5f55\u7684\u540d\u79f0\u3002\u8be5\u503c\u59cb\u7ec8\u4e3a def
\u3002TABLE_SCHEMA
\uff1a\u8868\u6240\u5c5e\u7684\u6a21\u5f0f\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u8868\u7684\u540d\u79f0\u3002TABLE_TYPE
\uff1a\u8868\u7684\u7c7b\u578b\u3002\u57fa\u672c\u8868\u7c7b\u578b\u4e3a BASE TABLE
\uff0c\u89c6\u56fe\u8868\u7c7b\u578b\u4e3a VIEW
\uff0cINFORMATION_SCHEMA
\u8868\u7c7b\u578b\u4e3a SYSTEM VIEW
\u3002ENGINE
\uff1a\u5b58\u50a8\u5f15\u64ce\u7684\u7c7b\u578b\u3002VERSION
\uff1a\u7248\u672c\u3002\u9ed8\u8ba4\u503c\u4e3a 10
\u3002ROW_FORMAT
\uff1a\u884c\u5b58\u50a8\u683c\u5f0f\u3002\u503c\u4e3a Fixed
\uff0cDynamic
\uff0cCompressed
\uff0cRedundant
\uff0cCompact
\u3002TABLE_ROWS
\uff1a\u7edf\u8ba1\u8868\u4e2d\u7684\u884c\u6570\u3002\u5bf9\u4e8e INFORMATION_SCHEMA
\u8868\uff0cTABLE_ROWS
\u4e3a NULL
\u3002AVG_ROW_LENGTH
\uff1a\u8868\u7684\u5e73\u5747\u884c\u957f\u5ea6\u3002AVG_ROW_LENGTH
= DATA_LENGTH
/ TABLE_ROWS
\u3002DATA_LENGTH
\uff1a\u6570\u636e\u957f\u5ea6\u3002DATA_LENGTH
= TABLE_ROWS
* \u5143\u7ec4\u4e2d\u5217\u7684\u5b58\u50a8\u957f\u5ea6\u4e4b\u548c\u3002MAX_DATA_LENGTH
\uff1a\u6700\u5927\u6570\u636e\u957f\u5ea6\u3002\u8be5\u503c\u5f53\u524d\u4e3a 0
\uff0c\u8868\u793a\u6570\u636e\u957f\u5ea6\u6ca1\u6709\u4e0a\u9650\u3002INDEX_LENGTH
\uff1a\u7d22\u5f15\u957f\u5ea6\u3002INDEX_LENGTH
= TABLE_ROWS
* \u7d22\u5f15\u5143\u7ec4\u4e2d\u5217\u7684\u957f\u5ea6\u603b\u548c\u3002DATA_FREE
\uff1a\u6570\u636e\u7247\u6bb5\u3002\u8be5\u503c\u5f53\u524d\u4e3a 0
\u3002AUTO_INCREMENT
\uff1a\u81ea\u589e\u4e3b\u952e\u7684\u5f53\u524d\u6b65\u957f\u3002CREATE_TIME
\uff1a\u521b\u5efa\u8868\u7684\u65f6\u95f4\u3002UPDATE_TIME
\uff1a\u8868\u66f4\u65b0\u7684\u65f6\u95f4\u3002CHECK_TIME
\uff1a\u68c0\u67e5\u8868\u7684\u65f6\u95f4\u3002TABLE_COLLATION
\uff1a\u8868\u4e2d\u5b57\u7b26\u4e32\u7684\u6392\u5e8f\u89c4\u5219\u3002CHECKSUM
\uff1a\u6821\u9a8c\u548c\u3002CREATE_OPTIONS
\uff1a\u521b\u5efa\u9009\u9879\u3002TABLE_COMMENT
\uff1a\u8868\u683c\u7684\u6ce8\u91ca\u548c\u6ce8\u91ca\u3002USER_PRIVILEGES
\u8868","text":"USER_PRIVILEGES
\u8868\u63d0\u4f9b\u4e86\u5173\u4e8e\u5168\u5c40\u6743\u9650\u7684\u4fe1\u606f\u3002
USER_PRIVILEGES
\u8868\u4e2d\u7684\u5b57\u6bb5\u63cf\u8ff0\u5982\u4e0b\uff1a
GRANTEE
\uff1a\u6388\u6743\u7528\u6237\u540d\uff0c\u683c\u5f0f\u4e3a 'user_name'@'host_name'
\u3002TABLE_CATALOG
\uff1a\u8868\u6240\u5c5e\u7684\u76ee\u5f55\u7684\u540d\u79f0\u3002\u503c\u4e3a def
\u3002PRIVILEGE_TYPE
\uff1a\u8981\u6388\u4e88\u7684\u6743\u9650\u7c7b\u578b\u3002\u6bcf\u884c\u53ea\u663e\u793a\u4e00\u79cd\u6743\u9650\u7c7b\u578b\u3002IS_GRANTABLE
\uff1a\u5982\u679c\u4f60\u6709 GRANT OPTION
\u6743\u9650\uff0c\u8be5\u503c\u4e3a YES
\uff0c\u6ca1\u6709 GRANT OPTION
\u6743\u9650\uff0c\u8be5\u503c\u4e3a NO
\u3002VIEWS
\u89c6\u56fe","text":"TABLE_CATALOG
\uff1a\u89c6\u56fe\u6240\u5c5e\u76ee\u5f55\u7684\u540d\u79f0\u3002\u503c\u4e3a def
\u3002TABLE_SCHEMA
\uff1a\u89c6\u56fe\u6240\u5c5e\u7684\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002TABLE_NAME
\uff1a\u89c6\u56fe\u7684\u540d\u79f0\u3002VIEW_DEFINITION
\uff1a\u63d0\u4f9b\u89c6\u56fe\u5b9a\u4e49\u7684 SELECT
\u8bed\u53e5\u3002\u5305\u542b\u4e86\u5728 SHOW Create VIEW
\u751f\u6210\u7684\u521b\u5efa\u8868\u5217\u4e2d\u770b\u5230\u7684\u5927\u90e8\u5206\u5185\u5bb9\u3002CHECK_OPTION
\uff1aCHECK_OPTION
\u5c5e\u6027\u7684\u503c\u3002\u503c\u4e3a NONE
\u3001CASCADE
\u6216 LOCAL
\u3002IS_UPDATABLE
\uff1a\u5728 CREATE VIEW
\u65f6\u8bbe\u7f6e\u4e00\u4e2a\u540d\u4e3a\u89c6\u56fe\u53ef\u66f4\u65b0\u6027\u6807\u5fd7\u7684\u6807\u5fd7\uff0c\u5982\u679c UPDATE \u548c DELETE\uff08\u4ee5\u53ca\u7c7b\u4f3c\u7684\u64cd\u4f5c\uff09\u5bf9\u89c6\u56fe\u5408\u6cd5\uff0c\u5219\u6807\u5fd7\u8bbe\u7f6e\u4e3a YES\uff08true\uff09
\u3002\u5426\u5219\uff0c\u6807\u5fd7\u8bbe\u7f6e\u4e3a NO\uff08false\uff09
\u3002DEFINER
\uff1a\u521b\u5efa\u89c6\u56fe\u7684\u7528\u6237\u7684\u5e10\u6237\uff0c\u683c\u5f0f\u4e3a username@hostname
\u3002SECURITY_TYPE
\uff1a\u89c6\u56fe SQL SECURITY
\u7279\u6027\u3002\u503c\u4e3a DEFINER
\u6216 INVOKER
\u3002CHARACTER_SET_CLIENT
\uff1a\u521b\u5efa\u89c6\u56fe\u65f6 character_set_client
\u7cfb\u7edf\u53d8\u91cf\u7684\u4f1a\u8bdd\u503c\u3002COLLATION_CONNECTION
\uff1a\u521b\u5efa\u89c6\u56fe\u65f6\uff0ccollation_connection
\u7cfb\u7edf\u53d8\u91cf\u7684\u4f1a\u8bdd\u503c\u3002INDEX_COMMENT
\uff1a\u521b\u5efa\u7d22\u5f15\u65f6\u4e3a\u5177\u6709 comment \u5c5e\u6027\u7684\u7d22\u5f15\u63d0\u4f9b\u7684\u4efb\u4f55\u6ce8\u91ca\u3002IS_VISIBLE
\uff1a\u7d22\u5f15\u5bf9\u4f18\u5316\u5668\u662f\u5426\u53ef\u89c1\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49 EXPRESSION
\uff1a\u8868\u793a\u7d22\u5f15\u4e2d\u7684\u8868\u8fbe\u5f0f\u6216\u51fd\u6570\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49STATISTICS
\u89c6\u56fe","text":"\u83b7\u53d6\u6709\u5173\u6570\u636e\u5e93\u8868\u7d22\u5f15\u548c\u7edf\u8ba1\u4fe1\u606f\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u68c0\u67e5\u7d22\u5f15\u662f\u5426\u552f\u4e00\uff0c\u4e86\u89e3\u7d22\u5f15\u4e2d\u7684\u5217\u987a\u5e8f\uff0c\u4ee5\u53ca\u4f30\u8ba1\u7d22\u5f15\u4e2d\u7684\u552f\u4e00\u503c\u6570\u91cf\u3002
TABLE_CATALOG
\uff1a\u8868\u7684\u76ee\u5f55\u540d\u79f0\uff08\u59cb\u7ec8\u4e3a 'def'\uff09\u3002TABLE_SCHEMA
\uff1a\u8868\u6240\u5c5e\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002TABLE_NAME
\uff1a\u8868\u7684\u540d\u79f0\u3002NON_UNIQUE
\uff1a\u6307\u793a\u7d22\u5f15\u662f\u5426\u5141\u8bb8\u91cd\u590d\u503c\u3002\u5982\u679c\u4e3a 0\uff0c\u5219\u7d22\u5f15\u662f\u552f\u4e00\u7d22\u5f15\u3002INDEX_SCHEMA
\uff1a\u7d22\u5f15\u6240\u5c5e\u7684\u6570\u636e\u5e93\u540d\u79f0\u3002INDEX_NAME
\uff1a\u7d22\u5f15\u7684\u540d\u79f0\u3002SEQ_IN_INDEX
\uff1a\u5217\u5728\u7d22\u5f15\u4e2d\u7684\u4f4d\u7f6e\u3002COLUMN_NAME
\uff1a\u5217\u7684\u540d\u79f0\u3002COLLATION
\uff1a\u5217\u7684\u6392\u5e8f\u89c4\u5219\u3002CARDINALITY
\uff1a\u7d22\u5f15\u4e2d\u552f\u4e00\u503c\u7684\u6570\u91cf\u4f30\u8ba1\u3002SUB_PART
\uff1a\u7d22\u5f15\u90e8\u5206\u957f\u5ea6\u3002\u5bf9\u4e8e\u6574\u4e2a\u5217\uff0c\u8be5\u503c\u4e3a NULL\u3002PACKED
\uff1a\u6307\u793a\u662f\u5426\u4f7f\u7528\u538b\u7f29\u5b58\u50a8\u7684\u503c\u3002NULLABLE
\uff1a\u6307\u793a\u5217\u662f\u5426\u5141\u8bb8 NULL \u503c\u3002INDEX_TYPE
\uff1a\u7d22\u5f15\u7684\u7c7b\u578b\uff08\u5982 BTREE\u3001HASH \u7b49\uff09\u3002COMMENT
\uff1a\u7d22\u5f15\u7684\u6ce8\u91ca\u4fe1\u606f\u3002INDEX_COMMENT
\uff1a\u521b\u5efa\u7d22\u5f15\u65f6\u4e3a\u5177\u6709 comment \u5c5e\u6027\u7684\u7d22\u5f15\u63d0\u4f9b\u7684\u4efb\u4f55\u6ce8\u91ca\u3002IS_VISIBLE
\uff1a\u7d22\u5f15\u5bf9\u4f18\u5316\u5668\u662f\u5426\u53ef\u89c1\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49 EXPRESSION
\uff1a\u8868\u793a\u7d22\u5f15\u4e2d\u7684\u8868\u8fbe\u5f0f\u6216\u51fd\u6570\u3002\u76ee\u524d\u8be5\u5b57\u6bb5\u5728 mo \u4e2d\u6ca1\u6709\u610f\u4e49mysql
\u6570\u636e\u5e93","text":""},{"location":"MatrixOne/Reference/System-tables/#_1","title":"\u6388\u6743\u7cfb\u7edf\u8868","text":"\u6388\u6743\u7cfb\u7edf\u8868\u5305\u542b\u4e86\u5173\u4e8e\u7528\u6237\u5e10\u6237\u53ca\u5176\u6743\u9650\u4fe1\u606f\uff1a
user
\u7528\u6237\u5e10\u6237\u3001\u5168\u5c40\u6743\u9650\u548c\u5176\u4ed6\u975e\u6743\u9650\u5217\u3002
db
\uff1a\u6570\u636e\u5e93\u7ea7\u6743\u9650\u3002
tables_priv
\uff1a\u8868\u7ea7\u6743\u9650\u3002
columns_priv
\uff1a\u5217\u7ea7\u6743\u9650\u3002
procs_priv
\uff1a\u5b58\u50a8\u8fc7\u7a0b\u548c\u5b58\u50a8\u51fd\u6570\u7684\u6743\u9650\u3002
\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd MatrixOne \u4e2d\u7684\u6743\u9650\u5206\u7c7b\u3002
MatrixOne \u7684\u8bbf\u95ee\u63a7\u5236\u6743\u9650\u5206\u4e3a\u7cfb\u7edf\u6743\u9650\u548c\u5bf9\u8c61\u6743\u9650\uff0c\u5728\u6388\u4e88\u89d2\u8272\u6743\u9650\u65f6\u53ef\u505a\u53c2\u8003\u3002
"},{"location":"MatrixOne/Reference/access-control-type/#_1","title":"\u7cfb\u7edf\u6743\u9650","text":"\u7cfb\u7edf\u6743\u9650\u4e3a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u7528\u6237\u540d\u4e3a root\uff09\u7684\u6743\u9650\uff0c\u5b83\u53ef\u4ee5\u521d\u59cb\u5316\u6240\u62e5\u6709\u7684\u6743\u9650\u3002\u96c6\u7fa4\u7ba1\u7406\u5458\u53ef\u4ee5\u521b\u5efa\u3001\u5220\u9664\u5176\u4ed6\u79df\u6237\uff0c\u5e76\u7ba1\u7406\u79df\u6237\uff1b\u96c6\u7fa4\u7ba1\u7406\u5458\u4e0d\u80fd\u7ba1\u7406\u5176\u4ed6\u79df\u6237\u4e0b\u7684\u5176\u4ed6\u8d44\u6e90\u3002
\u6743\u9650 \u542b\u4e49 CREATE ACCOUNT \u521b\u5efa\u79df\u6237\uff0c\u4ec5\u96c6\u7fa4\u7ba1\u7406\u5458\u62e5\u6709 DROP ACCOUNT \u5220\u9664\u79df\u6237\uff0c\u4ec5\u96c6\u7fa4\u7ba1\u7406\u5458\u62e5\u6709 ALTER ACCOUNT \u7ba1\u7406\u79df\u6237\u8d44\u6e90\uff0c\u4ec5\u96c6\u7fa4\u7ba1\u7406\u5458\u62e5\u6709"},{"location":"MatrixOne/Reference/access-control-type/#_2","title":"\u5bf9\u8c61\u6743\u9650","text":"\u5bf9\u8c61\u6743\u9650\u53ef\u4ee5\u6309\u7167\u8d4b\u6743\u7684\u5bf9\u8c61\u7ec6\u5206\u4e3a\u79df\u6237\u6743\u9650\u3001\u7528\u6237\u6743\u9650\u3001\u89d2\u8272\u6743\u9650\u3001\u6570\u636e\u5e93\u6743\u9650\u3001\u8868\u6743\u9650\u3001\u53d1\u5e03\u8ba2\u9605\u6743\u9650\u3002
"},{"location":"MatrixOne/Reference/access-control-type/#_3","title":"\u79df\u6237\u6743\u9650","text":"\u62e5\u6709\u79df\u6237\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 CREATE USER \u521b\u5efa\u7528\u6237 DROP USER \u5220\u9664\u7528\u6237 ALTER USER \u4fee\u6539\u7528\u6237 CREATE ROLE \u521b\u5efa\u89d2\u8272 DROP ROLE \u5220\u9664\u89d2\u8272 CREATE DATABASE \u521b\u5efa\u6570\u636e\u5e93 DROP DATABASE \u5220\u9664\u6570\u636e\u5e93 SHOW DATABASES \u67e5\u770b\u5f53\u524d\u79df\u6237\u4e0b\u6240\u6709\u6570\u636e\u5e93 CONNECT \u5141\u8bb8\u4f7f\u7528use [database | role]
\uff0c\u53ef\u6267\u884c\u4e0d\u6d89\u53ca\u5177\u4f53\u5bf9\u8c61\u7684 SELECT
MANAGE GRANTS \u6743\u9650\u7ba1\u7406\u3002\u5305\u62ec\u89d2\u8272\u6388\u6743\u3001\u89d2\u8272\u7ee7\u627f\u7684\u6743\u9650 ALL [PRIVILEGES] Account \u7684\u6240\u6709\u6743\u9650 OWNERSHIP Account \u7684\u6240\u6709\u6743\u9650\uff0c\u53ef\u4ee5\u901a\u8fc7 WITH GRANT OPTION
\u8bbe\u7f6e\u6743\u9650"},{"location":"MatrixOne/Reference/access-control-type/#_4","title":"\u7528\u6237\u6743\u9650","text":"\u62e5\u6709\u7528\u6237\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 Ownership \u7ba1\u7406\u7528\u6237\u6240\u6709\u7684\u6743\u9650\uff0c\u5305\u62ec\u4fee\u6539\u7528\u6237\u4fe1\u606f\u3001\u5bc6\u7801\u3001\u5220\u9664\u7528\u6237\uff0c\u4e14\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u6743\u9650\u4f20\u9012\u7ed9\u5176\u4ed6\u89d2\u8272\u3002"},{"location":"MatrixOne/Reference/access-control-type/#_5","title":"\u89d2\u8272\u6743\u9650","text":"\u62e5\u6709\u89d2\u8272\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 Ownership \u7ba1\u7406\u89d2\u8272\u7684\u6240\u6709\u6743\u9650\uff0c\u5305\u62ec\u4fee\u6539\u89d2\u8272\u540d\u79f0\u3001\u63cf\u8ff0\u3001\u5220\u9664\u89d2\u8272\uff0c\u4e14\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u6743\u9650\u4f20\u9012\u7ed9\u5176\u4ed6\u89d2\u8272\u3002"},{"location":"MatrixOne/Reference/access-control-type/#_6","title":"\u6570\u636e\u5e93\u6743\u9650","text":"\u62e5\u6709\u6570\u636e\u5e93\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 SHOW TABLES \u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u4e0b\u6240\u6709\u8868 CREATE TABLE \u5efa\u8868\u6743\u9650 DROP TABLE \u5220\u8868\u6743\u9650 CREATE VIEW \u521b\u5efa\u89c6\u56fe\u6743\u9650\uff0c\u65e0\u5bf9\u5e94\u6743\u9650\u65f6\u521b\u5efa\u89c6\u56fe\u65e0\u6cd5\u67e5\u8be2 DROP VIEW \u5220\u9664\u89c6\u56fe ALTER TABLE \u4fee\u6539\u8868\u6743\u9650 ALTER VIEW \u4fee\u6539\u89c6\u56fe\u6743\u9650\uff0c\u65e0\u5bf9\u5e94\u6743\u9650\u65f6\u65e0\u6cd5\u4fee\u6539\u89c6\u56fe ALL [PRIVILEGES] \u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650 OWNERSHIP \u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\uff0c\u9644\u52a0WITH GRANT OPTION
"},{"location":"MatrixOne/Reference/access-control-type/#_7","title":"\u8868\u6743\u9650","text":"\u62e5\u6709\u8868\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 SELECT \u5bf9\u8868\u6267\u884cSELECT
\u547d\u4ee4 INSERT \u5bf9\u8868\u6267\u884c INSERT
\u547d\u4ee4 UPDATE \u5bf9\u8868\u6267\u884c UPDATE
\u547d\u4ee4 TRUNCATE \u5bf9\u8868\u6267\u884c TRUNCATE TABLE
\u547d\u4ee4 DELETE \u5bf9\u8868\u6267\u884c DELETE
\u547d\u4ee4 REFERENCE \u5141\u8bb8\u5c06\u8868\u5f15\u7528\u4e3a\u5916\u952e\u7ea6\u675f\u7684\u552f\u4e00/\u4e3b\u952e\u8868\u3002\u901a\u8fc7 DESCRIBE
\u6216 SHOW
\u547d\u4ee4\u67e5\u770b\u8868\u7684\u7ed3\u6784 INDEX \u521b\u5efa\u5220\u9664 INDEX ALL \u6307\u5b9a\u8868\u7684\u6240\u6709\u6743\u9650 OWNERSHIP \u6307\u5b9a\u8868\u7684\u6240\u6709\u6743\u9650\uff0c\u9644\u52a0 WITH GRANT OPTION
"},{"location":"MatrixOne/Reference/access-control-type/#_8","title":"\u8868\u6267\u884c\u6743\u9650","text":"\u62e5\u6709\u8868\u6267\u884c\u6743\u9650\u7684\u5bf9\u8c61\u53ef\u4ee5\u62e5\u6709\u4ee5\u4e0b\u6743\u9650\uff1a
\u6743\u9650 \u542b\u4e49 EXECUTE \u5141\u8bb8\u6267\u884c\u51fd\u6570\u6216\u5b58\u50a8\u8fc7\u7a0b\u7684\u6743\u9650"},{"location":"MatrixOne/Reference/access-control-type/#_9","title":"\u53d1\u5e03\u8ba2\u9605\u6743\u9650","text":"\u5728 MatrixOne \u4e2d\uff0c\u53d1\u5e03\u8ba2\u9605\u662f\u5bf9 MatrixOne \u4e2d\u6307\u5b9a\u6570\u636e\u5e93\u53d1\u8d77\u7684\u6570\u636e\u5171\u4eab\u8bbf\u95ee\u3002
Note: \u5f53\u524d MatrixOne \u4e2d\u4ec5\u652f\u6301 moadmin \u548c accountadmin \u89d2\u8272\u624d\u53ef\u4ee5\u8fdb\u884c\u53d1\u5e03\u8ba2\u9605\u64cd\u4f5c\u3002
\u53d1\u5e03\u7aef\uff0c\u5373\u53d1\u5e03\u5171\u4eab\u3001\u540c\u6b65\u6570\u636e\u7684\u4e00\u65b9\u3002
\u6743\u9650 \u542b\u4e49 CREATE PUBLICATION \u521b\u5efa\u53d1\u5e03 ALTER PUBLICATION \u4fee\u6539\u53d1\u5e03 DROP PUBLICATION \u5220\u9664\u53d1\u5e03 SHOW PUBLICATION \u67e5\u770b\u53d1\u5e03 SHOW CREATE PUBLICATION \u67e5\u770b\u521b\u5efa\u53d1\u5e03\u8bed\u53e5\u8ba2\u9605\u7aef\uff0c\u5373\u83b7\u53d6\u5df2\u5171\u4eab\u3001\u540c\u6b65\u6570\u636e\u7684\u4e00\u65b9\u3002
\u6743\u9650 \u542b\u4e49 CREATE DATABASE db_name FROM account_name PUBLICATION \u521b\u5efa\u8ba2\u9605 SHOW SUBSCRIPTIONS \u67e5\u770b\u8ba2\u9605"},{"location":"MatrixOne/Reference/Data-Types/blob-text-type/","title":"BLOB \u548c TEXT \u6570\u636e\u7c7b\u578b","text":"BLOB
BLOB
\u662f\u53ef\u4ee5\u5b58\u50a8\u53ef\u53d8\u6570\u91cf\u7684\u5927\u6570\u636e\u4e8c\u8fdb\u5236\u5bf9\u8c61\u3002
BLOB
\u503c\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff08\u5b57\u8282\u5b57\u7b26\u4e32\uff09\uff0c\u5bf9\u5e94\u4e8c\u8fdb\u5236\u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u89c4\u5219\uff0c\u6bd4\u8f83\u548c\u6392\u5e8f\u57fa\u4e8e\u5217\u503c\u4e2d\u5b57\u8282\u7684\u6570\u503c\u3002
TEXT
TEXT
\u4e3a\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff08\u5b57\u7b26\u4e32\uff09\uff0c\u7528\u4e8e\u5b58\u50a8\u6240\u6709\u7c7b\u578b\u7684\u6587\u672c\u6570\u636e\u3002\u5b83\u4eec\u5177\u6709\u4e8c\u8fdb\u5236\u4ee5\u5916\u7684\u5b57\u7b26\u96c6\uff0c\u5e76\u4e14\u57fa\u4e8e\u5b57\u7b26\u96c6\u7684\u6392\u5e8f\u89c4\u5219\u5bf9\u503c\u8fdb\u884c\u6392\u5e8f\u548c\u6bd4\u8f83\u3002\u5173\u4e8e BLOB \u548c TEXT
\u5982\u679c\u4e3a BLOB
\u6216 TEXT
\u5217\u5206\u914d\u7684\u503c\u8d85\u8fc7\u8be5\u5217\u7684\u6700\u5927\u957f\u5ea6\uff0c\u5219\u8be5\u503c\u8d85\u51fa\u957f\u5ea6\u7684\u90e8\u5206\u5c06\u88ab\u622a\u65ad\u5e76\u751f\u6210\u544a\u8b66\u3002\u5982\u679c\u622a\u65ad\u7684\u662f\u975e\u7a7a\u683c\u5b57\u7b26\uff0c\u4f1a\u53d1\u751f\u9519\u8bef\uff08\u800c\u4e0d\u662f\u544a\u8b66\uff09\u5e76\u7981\u6b62\u63d2\u5165\u503c\u3002\u5bf9\u4e8e TEXT
\uff0c\u622a\u65ad\u63d2\u5165\u5230 TEXT
\u5217\u7684\u503c\u4e2d\u591a\u4f59\u7684\u5c3e\u90e8\u7a7a\u683c\u65f6\uff0c\u603b\u662f\u4f1a\u751f\u6210\u544a\u8b66\u3002
MatrixOne \u652f\u6301\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362\uff0c\u4e0b\u8868\u5217\u51fa\u4e86\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u652f\u6301\u60c5\u51b5\uff1a
cast
\u51fd\u6570\uff0c\u8fdb\u884c\u663e\u5f0f\u8f6c\u6362\u3002cast
\u51fd\u6570\uff0c\u8fdb\u884c\u9690\u5f0f\u8f6c\u6362\uff0c\u5373\u5f3a\u5236\u8f6c\u6362\u3002MatrixOne \u7684\u6570\u636e\u7c7b\u578b\u4e0e MySQL \u6570\u636e\u7c7b\u578b\u7684\u5b9a\u4e49\u4e00\u81f4\uff0c\u53ef\u53c2\u8003\uff1a https://dev.mysql.com/doc/refman/8.0/en/data-types.html
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_2","title":"\u6574\u6570\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u6700\u5c0f\u503c \u6700\u5927\u503c TINYINT 1 byte -128 127 SMALLINT 2 byte -32768 32767 INT 4 byte -2147483648 2147483647 BIGINT 8 byte -9223372036854775808 9223372036854775807 TINYINT UNSIGNED 1 byte 0 255 SMALLINT UNSIGNED 2 byte 0 65535 INT UNSIGNED 4 byte 0 4294967295 BIGINT UNSIGNED 8 byte 0 18446744073709551615"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_3","title":"\u793a\u4f8b","text":"-- Create a table named \"inttable\" with 2 attributes of a \"tinyint\", a \"tinyint unsigned\",\ncreate table inttable ( a tinyint not null default 1, tinyint8 tinyint unsigned primary key);\ninsert into inttable (tinyint8) values (0),(255), (0xFE), (253);\n\nmysql> select * from inttable order by 2 asc;\n+------+----------+\n| a | tinyint8 |\n+------+----------+\n| 1 | 0 |\n| 1 | 253 |\n| 1 | 254 |\n| 1 | 255 |\n+------+----------+\n4 rows in set (0.03 sec)\n
-- Create a table named \"inttable\" with 2 attributes of a \"smallint\", a \"smallint unsigned\",\ndrop table inttable;\ncreate table inttable ( a smallint not null default 1, smallint16 smallint unsigned);\ninsert into inttable (smallint16) values (0),(65535), (0xFFFE), (65534), (65533);\n\nmysql> select * from inttable;\n+------+------------+\n| a | smallint16 |\n+------+------------+\n| 1 | 0 |\n| 1 | 65535 |\n| 1 | 65534 |\n| 1 | 65534 |\n| 1 | 65533 |\n+------+------------+\n5 rows in set (0.01 sec)\n
-- Create a table named \"inttable\" with 2 attributes of a \"int\", a \"int unsigned\",\ndrop table inttable;\ncreate table inttable ( a int not null default 1, int32 int unsigned primary key);\ninsert into inttable (int32) values (0),(4294967295), (0xFFFFFFFE), (4294967293), (4294967291);\n\nmysql> select * from inttable order by a desc, 2 asc;\n+------+------------+\n| a | int32 |\n+------+------------+\n| 1 | 0 |\n| 1 | 4294967291 |\n| 1 | 4294967293 |\n| 1 | 4294967294 |\n| 1 | 4294967295 |\n+------+------------+\n5 rows in set (0.01 sec)\n
-- Create a table named \"inttable\" with 2 attributes of a \"bigint\", a \"bigint unsigned\",\ndrop table inttable;\ncreate table inttable ( a bigint, big bigint unsigned primary key );\ninsert into inttable values (122345515, 0xFFFFFFFFFFFFE), (1234567, 0xFFFFFFFFFFFF0);\n\nmysql> select * from inttable;\n+-----------+------------------+\n| a | big |\n+-----------+------------------+\n| 122345515 | 4503599627370494 |\n| 1234567 | 4503599627370480 |\n+-----------+------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_4","title":"\u6d6e\u70b9\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u7cbe\u5ea6 \u6700\u5c0f\u503c \u6700\u5927\u503c \u8bed\u6cd5\u8868\u793a FLOAT32 4 bytes 23 bits -3.40282e+038 3.40282e+038 FLOAT(M, D) M \u8868\u793a\u7684\u662f\u6700\u5927\u957f\u5ea6\uff0cD \u8868\u793a\u7684\u663e\u793a\u7684\u5c0f\u6570\u4f4d\u6570\u3002M \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< M <=255\uff09\u3002 D \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< D <=30\uff09\uff0c\u4e14 M >= D\u3002 \u5e26\u7cbe\u5ea6\u7684\u6d6e\u70b9\u6570\u5c55\u793a\u51fa\u8981\u6c42\u7cbe\u5ea6\u7684\u4f4d\u6570\uff0c\u5728\u4f4d\u6570\u4e0d\u8db3\u65f6\uff0c\u4f1a\u8fdb\u884c\u672b\u5c3e\u8865 0\u3002 FLOAT64 8 bytes 53 bits -1.79769e+308 1.79769e+308 DOUBLE(M, D) M \u8868\u793a\u7684\u662f\u6700\u5927\u957f\u5ea6\uff0cD \u8868\u793a\u7684\u663e\u793a\u7684\u5c0f\u6570\u4f4d\u6570\u3002M \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< M <=255\uff09\u3002 D \u7684\u53d6\u503c\u8303\u56f4\u4e3a\uff081=< D <=30\uff09\uff0c\u4e14 M >= D\u3002 \u5e26\u7cbe\u5ea6\u7684\u6d6e\u70b9\u6570\u5c55\u793a\u51fa\u8981\u6c42\u7cbe\u5ea6\u7684\u4f4d\u6570\uff0c\u5728\u4f4d\u6570\u4e0d\u8db3\u65f6\uff0c\u4f1a\u8fdb\u884c\u672b\u5c3e\u8865 0\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_5","title":"\u793a\u4f8b","text":"-- Create a table named \"floatt1\" with precision, a trailing zero is added when the number of bits falls short\ncreate table floatt1(a float(5, 2));\ninsert into floatt1 values(1), (2.5), (3.56), (4.678);\n\nmysql> select * from floatt1;\n+------+\n| a |\n+------+\n| 1.00 |\n| 2.50 |\n| 3.56 |\n| 4.68 |\n+------+\n4 rows in set (0.00 sec)\n\n-- Create a table named \"floattable\" with 1 attributes of a \"float\"\ncreate table floattable ( a float not null default 1, big float(20,5) primary key);\ninsert into floattable (big) values (-1),(12345678.901234567),(92233720368547.75807);\n\nmysql> select * from floattable order by a desc, big asc;\n+------+----------------------+\n| a | big |\n+------+----------------------+\n| 1 | -1.00000 |\n| 1 | 12345679.00000 |\n| 1 | 92233718038528.00000 |\n+------+----------------------+\n3 rows in set (0.01 sec)\n\nmysql> select min(big),max(big),max(big)-1 from floattable;\n+----------+----------------------+----------------+\n| min(big) | max(big) | max(big) - 1 |\n+----------+----------------------+----------------+\n| -1.00000 | 92233718038528.00000 | 92233718038527 |\n+----------+----------------------+----------------+\n1 row in set (0.05 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_6","title":"\u4e8c\u8fdb\u5236\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u6700\u5c0f\u503c \u6700\u5927\u503c \u8bed\u6cd5\u8868\u793a \u63cf\u8ff0 BIT 1bytes 0 18446744073709551615 BIT(M) \u5b58\u50a8 bit \u6570\u636e\u7684\u6570\u636e\u7c7b\u578b\uff0cM \u652f\u6301\u7684\u8303\u56f4\uff1a1 \u5230 64\u3002M \u9ed8\u8ba4\u4e3a 1\uff0c\u5982\u679c\u5b58\u50a8\u7684\u6570\u636e\u4e0d\u8db3 M bits\uff0c\u5219\u9760\u5de6\u8865 0 \u8865\u9f50\u957f\u5ea6"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_7","title":"\u793a\u4f8b","text":"create table t1 (a bit);\nmysql> desc t1;--bit(M) \u9ed8\u8ba4 M \u4e3a 1\n+-------+--------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+--------+------+------+---------+-------+---------+\n| a | BIT(1) | YES | | NULL | | |\n+-------+--------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\ncreate table t2 (a bit(8));\n\n-- \u7528 bit-value literal \u8bed\u6cd5\u8d4b\u503c\ninsert into t2 values (0b1);\ninsert into t2 values (b'1');\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x01 |\n| 0x01 |\n+------------+\n2 rows in set (0.00 sec)\n\ntruncate table t2;\n\n--\u7528 hex-value literal \u8bed\u6cd5\u8d4b\u503c\ninsert into t2 values (0x10);\ninsert into t2 values (x'10');\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x10 |\n| 0x10 |\n+------------+\n2 rows in set (0.00 sec)\n\ntruncate table t2;\n\n--\u652f\u6301\u7528 int \u7c7b\u578b\u8d4b\u503c\uff0c\u4f46\u662f int \u7684\u4e8c\u8fdb\u5236\u8868\u793a\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7 bit \u7c7b\u578b\u7684\u957f\u5ea6\ninsert into t2 values (255);--a = b'11111111'\nmysql> insert into t2 values (256);--256 \u7684 2 \u8fdb\u5236\u8868\u793a\u957f\u5ea6\u8d85\u8fc7 8\nERROR 20301 (HY000): invalid input: data too long, type width = 8, val = 100000000\n\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0xFF |\n+------------+\n1 row in set (0.00 sec)\n\ntruncate table t2;\n\n--\u6d6e\u70b9\u578b\u6570\u636e\uff0c\u4f1a\u5148\u5c06\u6d6e\u70b9\u578b\u56db\u820d\u4e94\u5165\u8f6c\u6210 int \u578b\uff0c\u7136\u540e\u6309\u7167 int \u7c7b\u578b\u8d4b\u503c\ninsert into t2 values (2.1);--a = b'00000010'\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x02 |\n+------------+\n1 row in set (0.00 sec)\n\ntruncate table t2;\n\n--\u5b57\u7b26\u578b\u6570\u636e\u5b58\u50a8\u7684\u662f\u5176\u7f16\u7801\u503c\uff0c\u540c\u6837\u6574\u4e2a\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u7684\u7f16\u7801\u603b\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7 bit \u7c7b\u578b\ninsert into t2 values ('a');--a = b'01100001' \nmysql> insert into t2 values ('\u554a');--utf8('\u554a') = 0xe5958a\uff1b\nERROR 20301 (HY000): invalid input: data too long, type width = 8, val = 111001011001010110001010\n\nmysql> select * from t2;\n+------------+\n| a |\n+------------+\n| 0x61 |\n+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_8","title":"\u5b57\u7b26\u4e32\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u957f\u5ea6 \u8bed\u6cd5\u8868\u793a \u63cf\u8ff0 char 24 bytes 0 ~ 4294967295 CHAR \u5b9a\u957f\u5b57\u7b26\u4e32 varchar 24 bytes 0 ~ 4294967295 VARCHAR \u53d8\u957f\u5b57\u7b26\u4e32 binary 255 bytes 0 ~ 65535 BINARY(M) \u7c7b\u4f3c\u4e8e CHAR\uff0c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32 varbinary 255 bytes 0 ~ 65535 VARBINARY(M) \u7c7b\u4f3c\u4e8e VARCHAR\uff0c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32 text 1 GB other types mapping TEXT \u957f\u6587\u672c\u6570\u636e\uff0c\u4e0d\u533a\u5206 TINY TEXT\u3001MEDIUM TEXT \u548c LONG TEXT blob 1 GB other types mapping BLOB \u4e8c\u8fdb\u5236\u7684\u957f\u6587\u672c\u6570\u636e\uff0c\u4e0d\u533a\u5206 TINY BLOB\u3001MEDIUM BLOB \u548c LONGBLOB enum 1 byte \u6216 2 bytes 0 ~ 65535 enum \u4e00\u4e2a\u679a\u4e3e\u7c7b\u578b\u3002\u5b83\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u5bf9\u8c61\uff0c\u53ea\u80fd\u4ece value1
\u3001value2
\u7b49\u503c\u5217\u8868\u4e2d\u9009\u62e9\u4e00\u4e2a\u503c\uff0c\u6216\u8005\u662f NULL
\u6216\u7279\u6b8a\u7684 '' \u9519\u8bef\u503c\u3002\u679a\u4e3e\u503c\u5728\u5185\u90e8\u8868\u793a\u4e3a\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_9","title":"\u793a\u4f8b","text":"-- Create a table named \"names\" with 2 attributes of a \"varchar\" and a \"char\"\ncreate table names(name varchar(255),age char(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+-------+------+\n| name | age |\n+-------+------+\n| Abby | 24 |\n| Bob | 25 |\n| Carol | 23 |\n| Dora | 29 |\n+-------+------+\n4 rows in set (0.00 sec)\n
-- Create a table named \"names\" with 2 attributes of a \"VARBINARY\" and a \"BINARY\"\ncreate table names(name varbinary(255),age binary(255));\ninsert into names(name, age) values('Abby', '24');\ninsert into names(name, age) values(\"Bob\", '25');\ninsert into names(name, age) values('Carol', \"23\");\ninsert into names(name, age) values(\"Dora\", \"29\");\n\nmysql> select name,age from names;\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| name | age |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| 0x41626279 | 0x323400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x426F62 | 0x323500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x4361726F6C | 0x323300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n| 0x446F7261 | 0x323900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |\n+--------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n4 rows in set (0.01 sec)\n
-- Create a table named \"texttest\" with 1 attribute of a \"text\"\ncreate table texttest (a text);\ninsert into texttest values('abcdef');\ninsert into texttest values('_bcdef');\ninsert into texttest values('a_cdef');\ninsert into texttest values('ab_def');\ninsert into texttest values('abc_ef');\ninsert into texttest values('abcd_f');\ninsert into texttest values('abcde_');\n\nmysql> select * from texttest where a like 'ab\\_def' order by 1 asc;\n+--------+\n| a |\n+--------+\n| ab_def |\n+--------+\n1 row in set (0.01 sec)\n
-- Create a table named \"blobtest\" with 1 attribute of a \"blob\"\ncreate table blobtest (a blob);\ninsert into blobtest values('abcdef');\ninsert into blobtest values('_bcdef');\ninsert into blobtest values('a_cdef');\ninsert into blobtest values('ab_def');\ninsert into blobtest values('abc_ef');\ninsert into blobtest values('abcd_f');\ninsert into blobtest values('abcde_');\n\nmysql> select * from blobtest where a like 'ab\\_def' order by 1 asc;\n+----------------+\n| a |\n+----------------+\n| 0x61625F646566 |\n+----------------+\n1 row in set (0.01 sec)\n
-- Create a table named \"enumtest\" with 1 attribute of a \"enum\"\nCREATE TABLE enumtest (color ENUM('red', 'green', 'blue'));\nINSERT INTO enumtest (color) VALUES ('red');\nmysql> SELECT * FROM enumtest WHERE color = 'green';\n+-------+\n| color |\n+-------+\n| green |\n+-------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#json","title":"JSON \u6570\u636e\u7c7b\u578b","text":"JSON \u6570\u636e\u7c7b\u578b \u89e3\u91ca \u5bf9\u8c61 \u5bf9\u8c61\u4f7f\u7528 {}
\u62ec\u8d77\u6765\uff0c\u5143\u7d20\u4e4b\u95f4\u7528 ,
\u5206\u9694\u3002JSON \u5bf9\u8c61\u4e2d\u7684\u503c/\u952e\u53ef\u4ee5\u4e3a String\u3001Nubmber\u3001Bool\u3001\u65f6\u95f4\u3002 \u6570\u7ec4 \u6570\u7ec4\u4f7f\u7528 []
\u62ec\u8d77\u6765\uff0c\u5143\u7d20\u4e4b\u95f4\u7528\u9017\u53f7 ,
\u5206\u9694\u3002JSON \u6570\u7ec4\u4e2d\u503c\u53ef\u4ee5\u4e3a String\u3001Nubmber\u3001Bool\u3001\u65f6\u95f4\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_10","title":"\u793a\u4f8b","text":"-- Create a table named \"jsontest\" with 1 attribute of a \"json\"\ncreate table jsontest (a json,b int);\ninsert into jsontest values ('{\"t1\":\"a\"}',1),('{\"t1\":\"b\"}',2);\n\nmysql> select * from jsontest;\n+-------------+------+\n| a | b |\n+-------------+------+\n| {\"t1\": \"a\"} | 1 |\n| {\"t1\": \"b\"} | 2 |\n+-------------+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_11","title":"\u65f6\u95f4\u4e0e\u65e5\u671f\u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u7cbe\u5ea6 \u6700\u5c0f\u503c \u6700\u5927\u503c \u8bed\u6cd5\u8868\u793a Time 8 byte microsecond -2562047787:59:59.999999 2562047787:59:59.999999 hh:mm:ss.ssssss Date 4 byte day 0001-01-01 9999-12-31 YYYY-MM-DD/YYYYMMDD DateTime 8 byte microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYY-MM-DD hh:mi:ssssss TIMESTAMP 8 byte microsecond 0001-01-01 00:00:00.000000 9999-12-31 23:59:59.999999 YYYYMMDD hh:mi:ss.ssssss \u65f6\u95f4\u4e0e\u65e5\u671f\u90e8\u5206\u7c7b\u578b\u652f\u6301\u5728\u63d2\u5165\u6570\u636e\u65f6\u6dfb\u52a0\u4ee5\u4e0b hint \u503c\uff1a
Time
\uff1a{t 'xx'}\uff0c{time 'xx'}
Date
\uff1a{d 'xx'}\uff0c{date 'xx'}
TIMESTAMP
\uff1a{ts 'xx'}\uff0c{timestamp 'xx'}
-- Create a table named \"timetest\" with 1 attributes of a \"time\"\ncreate table time_02(t1 time);\ninsert into time_02 values(200),(time'23:29:30'),({t'12:11:12'}),('');\n\nmysql> select * from time_02;\n+----------+\n| t1 |\n+----------+\n| 00:02:00 |\n| 23:29:30 |\n| 12:11:12 |\n| NULL |\n+----------+\n4 rows in set (0.01 sec)\n
-- Create a table named \"datetest\" with 1 attributes of a \"date\"\ncreate table datetest (a date not null, primary key(a));\ninsert into datetest values ({d'2022-01-01'}), ('20220102'),(date'2022-01-03'),({d now()});\nmysql> select * from datetest;\n+------------+\n| a |\n+------------+\n| 2022-01-01 |\n| 2022-01-02 |\n| 2022-01-03 |\n| 2024-03-19 |\n+------------+\n4 rows in set (0.00 sec)\n
-- Create a table named \"datetimetest\" with 1 attributes of a \"datetime\"\ncreate table datetimetest (a datetime(0) not null, primary key(a));\ninsert into datetimetest values ('20200101000000'), ('2022-01-02'), ('2022-01-02 00:00:01'), ('2022-01-02 00:00:01.512345');\n\nmysql> select * from datetimetest order by a asc;\n+---------------------+\n| a |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 00:00:00 |\n| 2022-01-02 00:00:01 |\n| 2022-01-02 00:00:02 |\n+---------------------+\n4 rows in set (0.02 sec)\n
-- Create a table named \"timestamptest\" with 1 attribute of a \"timestamp\"\ncreate table timestamptest (a timestamp(0) not null, primary key(a));\ninsert into timestamptest values ('20200101000000'), (timestamp'2022-01-02 11:30:40'), ({ts'2022-01-02 00:00:01'}), ({ts current_timestamp});\n\nmysql> select * from timestamptest;\n+---------------------+\n| a |\n+---------------------+\n| 2020-01-01 00:00:00 |\n| 2022-01-02 11:30:40 |\n| 2022-01-02 00:00:01 |\n| 2024-03-19 17:22:08 |\n+---------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#bool","title":"Bool \u7c7b\u578b","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 True 1 byte False 1 byte"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_13","title":"\u793a\u4f8b","text":"-- Create a table named \"booltest\" with 2 attribute of a \"boolean\" and b \"bool\"\ncreate table booltest (a boolean,b bool);\ninsert into booltest values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from booltest;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#decimal","title":"\u5b9a\u70b9\u7c7b\u578b Decimal","text":"\u6570\u636e\u7c7b\u578b \u5b58\u50a8\u7a7a\u95f4 \u7cbe\u5ea6 \u8bed\u6cd5\u8868\u793a Decimal64 8 byte 18 \u4f4d Decimal(N,S) N \u8868\u793a\u6570\u5b57\u4f4d\u6570\u7684\u603b\u6570\uff0c\u8303\u56f4\u662f (1 ~ 18)\uff0c\u5c0f\u6570\u70b9\u548c -\uff08\u8d1f\u6570\uff09\u7b26\u53f7\u4e0d\u5305\u62ec\u5728 N \u4e2d\u3002\u5982\u679c N \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u503c\u5e94\u8be5\u53d6\u6700\u5927\uff0c\u5373\u53d6\u503c 18\u3002S \u8868\u793a\u662f\u5c0f\u6570\u70b9\uff08\u6807\u5ea6\uff09\u540e\u9762\u7684\u4f4d\u6570\uff0c\u8303\u56f4\u662f (0 ~ N)\u5982\u679c S \u662f 0\uff0c\u5219\u503c\u6ca1\u6709\u5c0f\u6570\u70b9\u6216\u5206\u6570\u90e8\u5206\u3002\u5982\u679c S \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u662f 0\uff0c\u4f8b\u5982 Decimal(10)\uff0c\u7b49\u540c\u4e8e Decimal(10, 0) \u4f8b\u5982 Decimal(10,8)\uff0c\u5373\u8868\u793a\u6570\u5b57\u603b\u957f\u5ea6\u4e3a 10\uff0c\u5c0f\u6570\u4f4d\u4e3a 8\u3002 Decimal128 16 byte 38 \u4f4d Decimal(N,S) N \u8868\u793a\u6570\u5b57\u4f4d\u6570\u7684\u603b\u6570\uff0c\u8303\u56f4\u662f (18 ~ 38)\uff0c\u5c0f\u6570\u70b9\u548c -\uff08\u8d1f\u6570\uff09\u7b26\u53f7\u4e0d\u5305\u62ec\u5728 N \u4e2d\u3002\u5982\u679c N \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u503c\u5e94\u8be5\u53d6\u6700\u5927\uff0c\u5373\u53d6\u503c 38\u3002S \u8868\u793a\u662f\u5c0f\u6570\u70b9\uff08\u6807\u5ea6\uff09\u540e\u9762\u7684\u4f4d\u6570\uff0c\u8303\u56f4\u662f (0 ~ N)\u5982\u679c S \u662f 0\uff0c\u5219\u503c\u6ca1\u6709\u5c0f\u6570\u70b9\u6216\u5206\u6570\u90e8\u5206\u3002\u5982\u679c S \u88ab\u7701\u7565\uff0c\u9ed8\u8ba4\u662f 0\uff0c\u4f8b\u5982 Decimal(20)\uff0c\u7b49\u540c\u4e8e Decimal(20, 0)\u3002\u4f8b\u5982 Decimal(20,19)\uff0c\u5373\u8868\u793a\u6570\u5b57\u603b\u957f\u5ea6\u4e3a 20\uff0c\u5c0f\u6570\u4f4d\u4e3a 19\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_14","title":"\u793a\u4f8b","text":"-- Create a table named \"decimalTest\" with 2 attribute of a \"decimal\" and b \"decimal\"\ncreate table decimalTest(a decimal(6,3), b decimal(24,18));\ninsert into decimalTest values(123.4567, 123456.1234567891411241355);\n\nmysql> select * from decimalTest;\n+---------+---------------------------+\n| a | b |\n+---------+---------------------------+\n| 123.457 | 123456.123456789141124136 |\n+---------+---------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#uuid","title":"UUID \u7c7b\u578b","text":"UUID \u7c7b\u578b \u89e3\u91ca UUID \u7531 32 \u4e2a 16 \u8fdb\u5236\u6570\u5b57\u548c 4 \u4e2a\u8fde\u5b57\u7b26\u2018-\u2019\u7ec4\u6210 UUID \u503c\uff0c\u5f62\u5f0f\u4e3a 8-4-4-4-12\uff0c\u6807\u51c6\u7684 UUID \u793a\u4f8b\uff1aa0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
\u3002"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_15","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 't1' \u7684\u65b0\u8868\uff0c\u5e76\u8bbe\u7f6e 'a' \u5217\u4e3a UUID \u7c7b\u578b\uff0c\u540c\u65f6\u5c06 'a' \u5217\u8bbe\u7f6e\u4e3a\u4e3b\u952e\ncreate table t1(a uuid primary key);\n\n-- \u5411 't1' \u8868\u7684 'a' \u5217\u63d2\u5165\u4e00\u4e2a\u65b0\u7684 UUID \u503c\ninsert into t1 values (uuid());\n\n-- \u67e5\u8be2 't1' \u8868\u4e2d 'a' \u5217\u7684\u503c\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u540e\u7684\u957f\u5ea6\nmysql> select length(cast(a as varchar)) from t1;\n+----------------------------+\n| length(cast(a as varchar)) |\n+----------------------------+\n| 36 |\n+----------------------------+\n1 row in set (0.01 sec)\n\n-- \u67e5\u8be2 t1 \u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u5176\u503c\u662f\u4e00\u4e2a UUID\nmysql> select * from t1;\n+--------------------------------------+\n| a |\n+--------------------------------------+\n| 948d8e4e-1b00-11ee-b656-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_16","title":"\u5411\u91cf\u6570\u636e\u7c7b\u578b","text":"\u7c7b\u578b \u89e3\u91ca vecf32 \u5411\u91cf\u5217\u7c7b\u578b\u4e3a float32 vecf64 \u5411\u91cf\u5217\u7c7b\u578b\u4e3a float64"},{"location":"MatrixOne/Reference/Data-Types/data-types/#_17","title":"\u793a\u4f8b","text":"create table t1(n1 vecf32(3), n2 vecf64(2));\ninsert into t1 values(\"[1,2,3]\",'[4,5]');\n\nmysql> select * from t1;\n+-----------+--------+\n| n1 | n2 |\n+-----------+--------+\n| [1, 2, 3] | [4, 5] |\n+-----------+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/enum-type/","title":"ENUM \u7c7b\u578b","text":"ENUM
\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684\u5217\u8868\uff0cENUM
\u7528\u4e8e\u5b58\u50a8\u4e00\u7ec4\u9884\u5b9a\u4e49\u7684\u79bb\u6563\u503c\u3002\u5b83\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u5177\u6709\u79bb\u6563\u503c\u7684\u7c7b\u578b\uff0c\u6bcf\u4e2a\u679a\u4e3e\u5e38\u91cf\u90fd\u4ee3\u8868\u4e86\u4e00\u4e2a\u7279\u5b9a\u7684\u503c\u3002
ENUM
\u6570\u636e\u7c7b\u578b\u5217\u9002\u5408\u5b58\u50a8\u72b6\u6001\u548c\u6807\u8bc6\u7b49\u6709\u9650\u6570\u91cf\u7684\u56fa\u5b9a\u503c\u7684\u6570\u636e\u3002
ENUM
\u6570\u636e\u7c7b\u578b\u5177\u6709\u4ee5\u4e0b\u4f18\u70b9\uff1a
ENUM ('value1', 'value2', ..., 'valuen')\n
\u4f8b\u5982\uff0c\u5b9a\u4e49 ENUM \u5217\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
CREATE TABLE table_name (\n...\ncol ENUM ('value1','value2','value3'),\n...\n);\n
"},{"location":"MatrixOne/Reference/Data-Types/enum-type/#_2","title":"\u8bed\u6cd5\u89e3\u91ca","text":"ENUM
\u662f\u4e00\u4e2a\u5173\u952e\u5b57\uff0c\u7528\u6765\u58f0\u660e\u4e00\u4e2a\u679a\u4e3e\u7c7b\u578b\u3002ENUM
\u7c7b\u578b\u7684\u53ef\u9009\u9879\u5217\u8868\uff0c\u4f7f\u7528 ENUM \u7c7b\u578b\u7684\u5217\u7684\u503c\u53ea\u80fd\u662f\u4e0a\u9762\u503c\u4e2d\u7684\u5176\u4e2d\u4e00\u4e2a\u3002Note: \u5728 ENUM
\u6570\u636e\u7c7b\u578b\u4e2d\uff0c\u4f60\u53ef\u4ee5\u62e5\u6709\u591a\u4e2a\u679a\u4e3e\u503c\u3002\u4f46\u662f\uff0c\u5efa\u8bae\u5c06\u679a\u4e3e\u503c\u7684\u6570\u91cf\u4fdd\u6301\u5728 20 \u4ee5\u4e0b\u3002
ENUM
\u7c7b\u578b\u7684\u503c\u5fc5\u987b\u4ece\u4e00\u4e2a\u9884\u5b9a\u4e49\u7684\u503c\u5217\u8868\u4e2d\u9009\u62e9\uff0c\u4e0b\u9762\u7684\u4f8b\u5b50\u5c06\u5e2e\u52a9\u4f60\u7406\u89e3\uff1a
CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue'),\nPRIMARY KEY (id)\n);\n
\u4e0a\u8ff0\u8bed\u53e5\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a enumtable
\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u540d\u4e3a color
\u7684\u679a\u4e3e\u7c7b\u578b\u5b57\u6bb5\u3002color
\u5b57\u6bb5\u7684\u503c\u5fc5\u987b\u4e3a red
\u3001green
\u6216 blue
\u4e2d\u7684\u4e00\u4e2a\u3002\u540c\u65f6\uff0c\u6309\u7167\u5217\u5b9a\u4e49\u65f6\u7684\u987a\u5e8f\uff0cred
\u3001green
\u548c blue
\u7684\u7d22\u5f15\u5206\u522b\u4e3a 1\uff0c2\uff0c3\u3002
\u5f53\u5411\u679a\u4e3e\u7c7b\u578b\u7684\u5b57\u6bb5\u4e2d\u63d2\u5165\u6570\u636e\u65f6\uff0c\u53ea\u80fd\u63d2\u5165\u9884\u5b9a\u4e49\u7684\u679a\u4e3e\u503c\u6216\u8005 NULL
\u3002\u5982\u679c\u63d2\u5165\u7684\u503c\u4e0d\u5728\u9884\u5b9a\u4e49\u7684\u5217\u8868\u4e2d\uff0c\u5219\u4ea7\u751f\u62a5\u9519\u3002\u4f8b\u5982\uff1a
INSERT INTO enumtable (id, color) VALUES ('01', 'red');\n-- 'red' \u5728\u9884\u5b9a\u4e49\u7684\u5217\u8868\u4e2d\uff0c\u63d2\u5165\u6210\u529f\nINSERT INTO enumtable (id, color) VALUES ('02', 'yellow');\n-- 'yellow' \u4e0d\u5728\u9884\u5b9a\u4e49\u7684\u5217\u8868\u4e2d\uff0c\u5219\u4f1a\u4ea7\u751f\u62a5\u9519\nINSERT INTO enumtable (id, color) VALUES ('03', NULL);\n-- \u679a\u4e3e\u6210\u5458\u5e76\u6ca1\u6709\u5b9a\u4e49 not null\uff0c\u63d2\u5165\u6210\u529f\n
\u9664\u4e86\u679a\u4e3e\u503c\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u679a\u4e3e\u6210\u5458\u7684\u6570\u5b57\u7d22\u5f15\u5c06\u6570\u636e\u63d2\u5165\u5230 ENUM \u5217\u4e2d\u3002\u4f8b\u5982\uff1a
INSERT INTO enumtable (id, color) VALUES ('04', 2);\n-- \u7531\u4e8e `green` \u7684\u7d22\u5f15\u662f 2\uff0c\u6240\u4ee5\u8fd9\u6761\u6570\u636e\u63d2\u5165\u6210\u529f\n
\u5047\u5982\u5efa\u8868\u65f6\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86 color
\u5217 NOT NULL
\uff1a
CREATE TABLE enumtable (\nid INT NOT NULL AUTO_INCREMENT,\ncolor ENUM('red', 'green', 'blue') NOT NULL,\nPRIMARY KEY (id)\n);\n
\u5f53\u63d2\u5165\u4e00\u4e2a\u65b0\u884c\u800c\u4e0d\u6307\u5b9a color \u5217\u7684\u503c\u65f6\uff0cMatrixOne \u5c06\u4f7f\u7528\u7b2c\u4e00\u4e2a\u679a\u4e3e\u6210\u5458\u4f5c\u4e3a\u9ed8\u8ba4\u503c\uff1a
INSERT INTO enumtable (id) VALUES ('05');\n-- \u8fd9\u91cc\u5c06\u7ed9 id \u4e3a 05 \u7684\u5217\u6307\u5b9a\u7b2c\u4e00\u4e2a\u679a\u4e3e\u6210\u5458 `red` \u4e3a\u9ed8\u8ba4\u503c\n
"},{"location":"MatrixOne/Reference/Data-Types/enum-type/#mysql","title":"\u4e0e MySQL \u7684\u5dee\u5f02","text":"\u4e0e MySQL \u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u7684 ENUM \u7c7b\u578b\u5728 WHERE \u6761\u4ef6\u91cc\u53ea\u80fd\u8ddf\u5b57\u7b26\u4e32\u7c7b\u578b\u8fdb\u884c\u6bd4\u8f83\u3002
\u53ef\u4ee5\u770b\u8fd9\u4e2a\u4f8b\u5b50\uff1a
update orders set status= 2 where status='Processing';`\n
\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u4f60\u9700\u8981\u5c06 status
\u4e3a Processing
\u7684\u884c\u7684 status
\u66f4\u65b0\u4e3a 2\u3002\u7531\u4e8e ENUM \u7c7b\u578b\u7684\u7279\u6027\uff0c\u5728 WHERE \u6761\u4ef6\u4e2d\uff0cMatrixOne \u5c06 2 \u9690\u5f0f\u5730\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32 2
\uff0c\u7136\u540e\u4e0e Processing
\u8fdb\u884c\u6bd4\u8f83\u3002
ALTER TABLE
\u8bed\u53e5\u91cd\u5efa\u8868\u3002Decimal \u6570\u636e\u7c7b\u578b\u7528\u6765\u5b58\u50a8\u7cbe\u786e\u7684\u6570\u503c\u3002\u7cbe\u786e\u6570\u503c\u7c7b\u578b\u5728\u9700\u8981\u7528\u5230\u975e\u5e38\u51c6\u786e\u7684\u6570\u503c\u7cbe\u5ea6\u7684\u573a\u666f\u4e0b\u4f7f\u7528\uff0c\u6bd4\u5982\u94f6\u884c\u8d26\u6237\u6570\u5b57\uff0c\u6216\u8005\u4e25\u8c28\u7684\u79d1\u5b66\u8ba1\u7b97\u7b49\u3002 \u5728 Decimal \u7684\u5217\u540d\u58f0\u660e\u4e2d\uff0c\u6574\u6570\u548c\u5c0f\u6570\u90e8\u5206\u4e00\u822c\u90fd\u4f1a\u8fdb\u884c\u58f0\u660e\u3002\u6bd4\u5982\u4ee5\u4e0b\u4f8b\u5b50\uff1a
salary DECIMAL(5,2)\n
\u5728\u8fd9\u4e2a\u6848\u4f8b\u4e2d\uff0c5 \u662f\u6709\u6548\u6570\u5b57\u4f4d\u6570\uff0c2 \u662f\u5c0f\u6570\u4f4d\u3002\u6574\u6570\u7cbe\u5ea6\u8868\u793a\u6570\u503c\u90e8\u5206\u5b58\u50a8\u7684\u6709\u6548\u4f4d\u6570\uff0c\u5c0f\u6570\u7cbe\u5ea6\u8868\u793a\u5c0f\u6570\u90e8\u5206\u5b58\u50a8\u7684\u6709\u6548\u4f4d\u6570\u3002 \u6807\u51c6 SQL \u8981\u6c42 DECIMAL(5,2) \u9700\u8981\u5b58\u50a8 5 \u4f4d\u6570\u5b57\uff0c2 \u4f4d\u5c0f\u6570\uff0c\u56e0\u6b64\u5982\u679c\u4ee5\u8be5\u5f62\u5f0f\u8868\u793a\u7684\u5de5\u8d44\u5217\u6570\u5b57\u53d6\u503c\u8303\u56f4\u5e94\u8be5\u5728 -999.99 \u5230 999.99 \u4e4b\u95f4\u3002 \u5728 MatrixOne \u7684\u8bed\u6cd5\u4e2d\uff0cDECIMAL(M) \u4e0e DECIMAL(M,0) \u662f\u76f8\u540c\u7684\u3002\u5982\u679c\u76f4\u63a5\u53ea\u58f0\u660e DECIMAL \u7684\u8bdd\uff0c\u8bed\u6cd5\u4e5f\u5c06\u89e3\u6790\u6210 DECIMAL(M,0) \u7684\u5f62\u5f0f\uff0cM \u7684\u9ed8\u8ba4\u503c\u4e3a 10\u3002 \u5982\u679c\u5c0f\u6570\u7cbe\u5ea6\u4e3a 0 \u7684\u8bdd\uff0cDECIMAL \u76f8\u5f53\u4e8e\u7eaf\u6574\u6570\uff0c\u4e0d\u542b\u4efb\u4f55\u5c0f\u6570\u3002 MatrixOne \u4e2d DECIMAL \u7c7b\u578b\u7684\u6700\u5927\u4f4d\u6570\u4e3a 38 \u4f4d\u3002\u53e6\u5916 DECIMAL \u4e2d\u6307\u5b9a\u7684\u6574\u6570\u6216\u5c0f\u6570\u4f4d\u6570\u5728\u5b9e\u9645\u5217\u88ab\u8d4b\u503c\u7684\u65f6\u5019\u8d85\u51fa\u6307\u5b9a\u8303\u56f4\uff0c\u5b9e\u9645\u6570\u503c\u5c06\u4f1a\u88ab\u81ea\u52a8\u8f6c\u6362\u6210\u76f8\u5e94\u7cbe\u5ea6\u3002
"},{"location":"MatrixOne/Reference/Data-Types/fixed-point-types/#decimal","title":"Decimal \u6570\u636e\u7c7b\u578b\u7279\u70b9","text":"\u8be5\u90e8\u5206\u5185\u5bb9\u4e3b\u8981\u4ecb\u7ecd Decimal \u6570\u636e\u7c7b\u578b\u7684\u4e00\u4e9b\u7279\u70b9\uff0c\u5c24\u5176\u662f\u5728\u4f4d\u6570\u7cbe\u5ea6\u548c\u5b58\u50a8\u5f62\u5f0f\u4e0a\u7684\u3002
DECIMAL \u5217\u7684\u58f0\u660e\u8bed\u6cd5\u662f DECIMAL(M, D)\uff0cM \u662f\u6709\u6548\u6570\u5b57\u7684\u4f4d\u6570\uff0c\u53d6\u503c\u8303\u56f4\u662f 1 \u5230 38\uff0cD \u662f\u5c0f\u6570\u4f4d\u6570\uff0c\u53d6\u503c\u8303\u56f4\u662f 1 \u5230 38\uff0c\u4f46\u662f\u4e0d\u80fd\u5927\u4e8e M\u3002 \u5982\u679c\u4e0d\u6307\u5b9a D\uff0c\u9ed8\u8ba4\u4e3a 0\u3002\u5982\u679c\u4e0d\u6307\u5b9a M\uff0c\u9ed8\u8ba4\u4e3a 10\u3002
DECIMAL \u5217\u7684\u6570\u503c\u4ee5\u4e8c\u8fdb\u5236\u7684\u5f62\u5f0f\u8fdb\u884c\u5b58\u50a8\uff0c\u5728 MatrixOne \u5185\u90e8\uff0c\u53ea\u6709 decimal64 \u548c decimal128 \u8fd9\u4e24\u79cd\u8868\u793a\u5f62\u5f0f\u3002\u5728 0-18 \u4f4d\u7cbe\u5ea6\u5185\uff0c\u4e00\u4e2a Decimal \u6570\u503c\u5360\u7528 8 \u4e2a\u5b57\u8282\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5728 19-38 \u4f4d\u7cbe\u5ea6\u5185\uff0c\u4e00\u4e2a Decimal \u6570\u503c\u5360\u7528 16 \u4e2a\u5b57\u8282\u7684\u5b58\u50a8\u7a7a\u95f4\u3002
\u4f4d\u6570 \u5b57\u8282\u6570 0-18 8 \u4e2a\u5b57\u8282 19-38 16 \u4e2a\u5b57\u8282\u5bf9\u4e8e\u8be6\u7ec6\u7684 Decimal \u7c7b\u578b\u5b9e\u73b0\u65b9\u6cd5\uff0c\u53ef\u4ee5\u53c2\u8003 Decimal \u7684\u8bbe\u8ba1\u6587\u6863\u3002
"},{"location":"MatrixOne/Reference/Data-Types/json-type/","title":"JSON \u6570\u636e\u7c7b\u578b","text":"MatrixOne \u652f\u6301\u7531 RFC 7159 \u5b9a\u4e49\u7684\u539f\u751f JSON \u6570\u636e\u7c7b\u578b\uff0c\u53ef\u4ee5\u6709\u6548\u8bbf\u95ee JSON\uff08JavaScript \u5bf9\u8c61\u8868\u793a\u6cd5\uff09\u6587\u6863\u4e2d\u7684\u6570\u636e\u3002\u4e0e\u5c06 JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u5b58\u50a8\u5728\u5b57\u7b26\u4e32\u5217\u4e2d\u76f8\u6bd4\uff0cJSON \u6570\u636e\u7c7b\u578b\u5177\u6709\u4ee5\u4e0b\u4f18\u52bf\uff1a
\u81ea\u52a8\u9a8c\u8bc1\u5b58\u50a8\u5728 JSON \u5217\u4e2d\u7684 JSON \u6587\u6863\u3002\u65e0\u6548\u7684\u6587\u6863\u4f1a\u4ea7\u751f\u62a5\u9519\u3002
\u81ea\u52a8\u4f18\u5316\u5b58\u50a8\u683c\u5f0f\u3002\u5b58\u50a8\u5728 JSON \u5217\u4e2d\u7684 JSON \u6587\u6863\u8f6c\u6362\u4e3a\u5141\u8bb8\u5bf9\u6587\u6863\u5143\u7d20\u8fdb\u884c\u5feb\u901f\u8bfb\u53d6\u8bbf\u95ee\u7684\u5185\u90e8\u683c\u5f0f\u3002\u5f53\u670d\u52a1\u5668\u5fc5\u987b\u8bfb\u53d6\u4ee5\u8fd9\u79cd\u4e8c\u8fdb\u5236\u683c\u5f0f\u5b58\u50a8\u7684 JSON \u503c\u65f6\uff0c\u4e0d\u9700\u8981\u4ece\u6587\u672c\u4e2d\u89e3\u6790\u8be5\u503c\u3002\u4e8c\u8fdb\u5236\u683c\u5f0f\u7684\u7ed3\u6784\u4f7f\u670d\u52a1\u5668\u80fd\u591f\u76f4\u63a5\u901a\u8fc7\u952e\u6216\u6570\u7ec4\u7d22\u5f15\u67e5\u627e\u5b50\u5bf9\u8c61\u6216\u5d4c\u5957\u503c\u3002
\u5b58\u50a8 JSON \u6587\u6863\u6240\u9700\u7684\u5b58\u50a8\u7a7a\u95f4\u4e0e BLOB
\u6216 TEXT
\u5927\u81f4\u76f8\u540c\u3002
JSON \u7c7b\u578b\u6709 JSON \u6570\u7ec4\u548c JSON \u5bf9\u8c61\u3002
[]
\u5b57\u7b26\u5185\u7684\u503c\u5217\u8868\uff0c\u5982\uff1a[\"abc\", 10, null, true, false]\n
{}
\u5b57\u7b26\u5185\uff0c\u5982\uff1a{\"k1\": \"value\", \"k2\": 10}\n
JSON \u6570\u7ec4\u548c\u5bf9\u8c61\u53ef\u4ee5\u5305\u542b\u6807\u91cf\u503c\uff0c\u5373\u5b57\u7b26\u4e32\u6216\u6570\u5b57\u3001JSON \u7a7a\u5b57\u9762\u91cf\u6216 JSON \u5e03\u5c14\u771f\u6216\u5047\u5b57\u9762\u91cf\u3002JSON \u5bf9\u8c61\u4e2d\u7684\u952e\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u3002JSON \u4e5f\u5141\u8bb8\u65f6\u95f4\uff08\u65e5\u671f\uff0c\u65e5\u671f\u65f6\u95f4\uff09\u6807\u91cf\u503c\u3002\u5982\uff1a
[\"12:18:29.000000\", \"2015-07-29\", \"2015-07-29 12:18:29.000000\"]\n
\u5728 JSON \u6570\u7ec4\u5143\u7d20\u548c JSON \u5bf9\u8c61\u952e\u503c\u4e2d\u53ef\u5d4c\u5957\uff0c\u5982\uff1a
[99, {\"id\": \"HK500\", \"cost\": 75.99}, [\"hot\", \"cold\"]]\n{\"k1\": \"value\", \"k2\": [10, 20]}\n
"},{"location":"MatrixOne/Reference/Data-Types/json-type/#json_2","title":"JSON \u503c\u7684\u89c4\u8303\u5316","text":"\u5f53\u4e00\u4e2a\u5b57\u7b26\u4e32\u88ab\u89e3\u6790\u4e3a\u6709\u6548\u7684 JSON \u6587\u6863\u65f6\uff0c\u5b83\u4e5f\u4f1a\u88ab\u89c4\u8303\u5316\u3002\u8fd9\u8868\u793a\u610f\u5473\u7740\u5177\u6709\u4e0e\u7a0d\u540e\u5728\u6587\u6863\u4e2d\u627e\u5230\u7684\u952e\u91cd\u590d\u7684\u952e\u7684\u6210\u5458\uff0c\u4ece\u5de6\u5230\u53f3\u8bfb\u53d6\uff0c\u5c06\u88ab\u4e22\u5f03\u3002\u8fd9\u610f\u5473\u7740\u4ece\u5de6\u5f80\u53f3\u8bfb\u53d6\u65f6\uff0c\u540e\u9762\u51fa\u73b0\u7684\u91cd\u590d\u7684\u7684\u952e\u503c\u5c06\u88ab\u5ffd\u7565\u3002
\u5c06\u503c\u63d2\u5165 JSON \u5217\u65f6\u6267\u884c\u89c4\u8303\u5316\uff0c\u5982\u4e0b\u6240\u793a\uff1a
CREATE TABLE t1 (c1 JSON);\nINSERT INTO t1 VALUES\n('{\"x\": 17, \"x\": \"red\"}'),\n('{\"x\": 17, \"x\": \"red\", \"x\": [3, 5, 7]}');\n\nmysql> SELECT c1 FROM t1;\n+------------------+\n| c1 |\n+------------------+\n| {\"x\": \"red\"} |\n| {\"x\": [3, 5, 7]} |\n+------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/uuid-type/","title":"UUID \u7c7b\u578b","text":"UUID \u662f\u4e00\u79cd\u901a\u7528\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u5b83\u7531 32 \u4f4d\u5341\u516d\u8fdb\u5236\u6570\u5b57\u4ee5\u53ca 4 \u4f4d\u8fde\u5b57\u7b26\u7ec4\u6210\u3002UUID \u5177\u6709\u5168\u5c40\u7684\u552f\u4e00\u6027\uff0c\u800c\u4e0d\u662f\u6570\u636e\u5e93\u4e2d\u7684\u552f\u4e00\u6027\uff0c\u5373\u4f7f\u662f\u5728\u4e24\u4e2a\u672a\u8fde\u63a5\u7684\u72ec\u7acb\u8fd0\u884c\u7684\u8bbe\u5907\u4e0a\u6267\u884c UUID \u8c03\u7528\uff0c\u9884\u8ba1\u4f1a\u751f\u6210\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u3002UUID \u5e38\u5e38\u88ab\u7528\u6765\u4e3a\u5bf9\u5e94\u884c\u751f\u6210\u7684\u4e00\u4e2a\u968f\u673a\u503c\uff0c\u4ee5\u786e\u4fdd\u6bcf\u6761\u8bb0\u5f55\u7684\u552f\u4e00\u6027\u3002UUID \u9002\u5408\u5728\u96c6\u7fa4\u73af\u5883\u4e2d\u4f5c\u4e3a\u552f\u4e00\u6807\u8bc6\u7b26\u3002
Info
\u5c3d\u7ba1 UUID()
\u503c\u552f\u4e00\uff0c\u4f46\u5b83\u4eec\u5e76\u975e\u662f\u4e0d\u53ef\u731c\u6d4b\u6216\u4e0d\u53ef\u9884\u6d4b\u7684\u3002\u5982\u679c\u9700\u8981\u4e0d\u53ef\u9884\u6d4b\u6027\uff0c\u5219\u5e94\u4ee5\u5176\u4ed6\u65b9\u5f0f\u751f\u6210 UUID \u503c\u3002
UUID()
\u8fd4\u56de\u4e00\u4e2a\u7b26\u5408 RFC 4122 \u6807\u51c6\u7684\u7248\u672c 1 UUID \u7684\u503c\uff0c\u4e3a 128 \u4f4d\u6570\u5b57\uff0c\u5b83\u8868\u793a\u662f\u4e00\u4e2a utf8mb3 \u7531\u4e94\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u5373 aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\uff0c\u683c\u5f0f\u89e3\u91ca\u5982\u4e0b\uff1a
\u524d\u4e09\u4e2a\u6570\u5b57\u662f\u4ece\u65f6\u95f4\u6233\u7684\u4f4e\u3001\u4e2d\u548c\u9ad8\u90e8\u5206\u751f\u6210\u7684\u3002\u9ad8\u4f4d\u90e8\u5206\u8fd8\u5305\u62ec UUID \u7248\u672c\u53f7\u3002
\u7b2c\u56db\u4e2a\u6570\u5b57\u4fdd\u7559\u65f6\u95f4\u552f\u4e00\u6027\uff0c\u4ee5\u9632\u65f6\u95f4\u6233\u503c\u5931\u53bb\u5355\u4e00\u6027\uff08\u4f8b\u5982\uff0c\u590f\u4ee4\u65f6\uff09\u3002
\u7b2c\u4e94\u4e2a\u6570\u5b57\u662f\u7a7a\u95f4\u552f\u4e00\u6027\u7684 IEEE 802 \u8282\u70b9\u53f7\u3002\u5982\u679c\u540e\u8005\u4e0d\u53ef\u7528\uff08\u4f8b\u5982\uff0c\u56e0\u4e3a\u4e3b\u673a\u8bbe\u5907\u6ca1\u6709\u4ee5\u592a\u7f51\u5361\uff0c\u6216\u8005\u4e0d\u77e5\u9053\u5982\u4f55\u5728\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u627e\u5230\u63a5\u53e3\u7684\u786c\u4ef6\u5730\u5740\uff09\uff0c\u5219\u7528\u968f\u673a\u6570\u4ee3\u66ff\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e0\u6cd5\u4fdd\u8bc1\u7a7a\u95f4\u552f\u4e00\u6027\u3002\u7136\u800c\uff0c\u7b2c\u4e94\u4f4d\u6570\u5b57\u91cd\u5408\u7684\u6982\u7387\u5f88\u4f4e\u3002
UUID \u7c7b\u578b\u652f\u6301\u7684 SQL \u8bed\u53e5\uff1a
CREATE
\u8bed\u53e5\uff1a\u53ef\u4ee5\u521b\u5efa\u5177\u6709 UUID \u7c7b\u578b\u5b57\u6bb5\u7684\u8868\u3002INSERT
/UPDATE
/DELETE
\u8bed\u53e5\uff1a\u5141\u8bb8\u5bf9 UUID \u7c7b\u578b\u7684\u6570\u636e\u8fdb\u884c\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u3002SELECT
\u8bed\u53e5\uff1a\u53ef\u4ee5\u67e5\u8be2 UUID \u7c7b\u578b\u5b57\u6bb5\uff0c\u67e5\u8be2\u7ed3\u679c\u5728\u5ba2\u6237\u7aef\u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u5c55\u793a\u3002UUID \u7c7b\u578b\u652f\u6301\u7684 SQL \u8bed\u53e5\u5b50\u53e5\uff1a
ORDER BY
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u4f5c\u6392\u5e8f\u6761\u4ef6\u3002WHERE
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u5728 WHERE
\u5b50\u53e5\u4e2d\uff0c\u652f\u6301\u6bd4\u8f83\u64cd\u4f5c\u3002HAVING
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u5728 HAVING
\u5b50\u53e5\u4e2d\uff0c\u652f\u6301\u6bd4\u8f83\u64cd\u4f5c\u3002GROUP BY
\u5b50\u53e5\uff1aUUID \u7c7b\u578b\u5b57\u6bb5\u53ef\u4ee5\u7528\u4f5c GROUP BY
\u7684\u5206\u7ec4\u6761\u4ef6\u3002\u5176\u4ed6\u652f\u6301\u7684 UUID \u7c7b\u578b\u529f\u80fd\uff1a
mysql> select uuid();\n+--------------------------------------+\n| uuid() |\n+--------------------------------------+\n| 4aa4f4de-1b00-11ee-b656-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\n-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868 't1'\uff0c\u5305\u542b\u4e24\u4e2a\u5217 'a' \u548c 'b'\uff0c\u5217 'a' \u7684\u7c7b\u578b\u4e3a INT\uff0c\u5217 'b' \u7684\u7c7b\u578b\u4e3a float\ncreate table t1(a INT, b float);\n\n-- \u5411\u8868 't1' \u63d2\u5165\u4e24\u884c\u6570\u636e\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\n-- \u67e5\u8be2 't1' \u8868\u7684\u884c\u6570\uff0c\u5e76\u751f\u6210\u6bcf\u4e00\u884c\u7684 uuid() \u51fd\u6570\u7684\u957f\u5ea6\uff0c\u6ce8\u610f\u8fd9\u91cc uuid() \u51fd\u6570\u751f\u6210\u7684\u662f\u4e00\u4e2a\u65b0\u7684 UUID\uff0c\n-- \u4e0d\u4f9d\u8d56\u4e8e 't1' \u8868\u7684\u4efb\u4f55\u6570\u636e\uff0c\u8fd4\u56de\u7684\u957f\u5ea6\u4e3a 36\uff0c\u56e0\u4e3a UUID \u662f\u4e00\u4e2a\u5305\u542b 32 \u4e2a\u5b57\u7b26\u548c 4 \u4e2a\u77ed\u5212\u7ebf\u7684 36 \u4e2a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\nmysql> SELECT length(uuid()) FROM t1;\n\n+----------------+\n| length(uuid()) |\n+----------------+\n| 36 |\n| 36 |\n+----------------+\n2 rows in set (0.00 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 't1' \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u540d\u4e3a 'a' \u7684\u5217\uff0c\u6570\u636e\u7c7b\u578b\u4e3a VARCHAR\uff0c\u6700\u5927\u957f\u5ea6\u4e3a 20\ncreate table t1(a varchar(20));\n\n-- \u5728 't1' \u8868\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0c 'a' \u5217\u7684\u503c\u4e3a '123123sdafsdf'\ninsert into t1 values('123123sdafsdf');\n\n-- \u4ece 't1' \u8868\u4e2d\u9009\u62e9\u6240\u6709\u7684\u884c\uff0c\u5e76\u8fd4\u56de\u6bcf\u4e00\u884c\u7684 'a' \u5217\u7684\u503c\uff0c\u4ee5\u53ca\u4e00\u4e2a\u65b0\u751f\u6210\u7684 UUID \u503c\nmysql> select uuid(),a from t1;\n+--------------------------------------+---------------+\n| uuid() | a |\n+--------------------------------------+---------------+\n| 664f1a96-1981-11ee-a041-5ad2460dea50 | 123123sdafsdf |\n+--------------------------------------+---------------+\n1 row in set (0.01 sec)\n
-- \u521b\u5efa\u540d\u4e3a namelists \u7684\u8868\uff0c\u5305\u542b id \u548c name \u4e24\u4e2a\u5b57\u6bb5\nCREATE TABLE namelists (\nid UUID DEFAULT uuid() PRIMARY KEY, -- id \u5b57\u6bb5\u662f UUID \u7c7b\u578b\uff0c\u9ed8\u8ba4\u503c\u4e3a uuid() \u51fd\u6570\u751f\u6210\u7684 UUID \u503c\uff0c\u4f5c\u4e3a\u4e3b\u952e\nname VARCHAR NOT NULL -- name \u5b57\u6bb5\u662f VARCHAR \u7c7b\u578b\uff0c\u4e0d\u80fd\u4e3a\u7a7a\n);\nINSERT INTO namelists (name) VALUES ('Tom'), ('Jane'), ('Bob');\nmysql> select * from namelists;\n+--------------------------------------+--------+\n| id | name |\n+--------------------------------------+--------+\n| 61400e9c-1bbc-11ee-b512-5ad2460dea50 | Tom |\n| 61400ea6-1bbc-11ee-b512-5ad2460dea50 | Jane |\n| 61400ea6-1bbc-11ee-b513-5ad2460dea50 | Bob |\n+--------------------------------------+--------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/","title":"\u5411\u91cf\u7c7b\u578b","text":"\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u5411\u91cf\u901a\u5e38\u662f\u4e00\u7ec4\u6570\u5b57\uff0c\u5b83\u4eec\u4ee5\u7279\u5b9a\u7684\u65b9\u5f0f\u6392\u5217\uff0c\u4ee5\u8868\u793a\u67d0\u79cd\u6570\u636e\u6216\u7279\u5f81\u3002\u8fd9\u4e9b\u5411\u91cf\u53ef\u4ee5\u662f\u4e00\u7ef4\u6570\u7ec4\u3001\u591a\u7ef4\u6570\u7ec4\u6216\u5177\u6709\u66f4\u9ad8\u7ef4\u5ea6\u7684\u6570\u636e\u7ed3\u6784\u3002MatrixOne \u652f\u6301\u5411\u91cf\u6570\u636e\u7c7b\u578b\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5411\u91cf\u88ab\u8bbe\u8ba1\u6210\u4e00\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u7c7b\u4f3c\u4e8e\u7f16\u7a0b\u8bed\u8a00\u4e2d\u7684 Array \u6570\u7ec4 (MatrixOne \u76ee\u524d\u8fd8\u4e0d\u652f\u6301\u6570\u7ec4\u7c7b\u578b)\uff0c\u4f46\u662f\u662f\u4e00\u79cd\u8f83\u4e3a\u7279\u6b8a\u7684\u6570\u7ec4\u7c7b\u578b\u3002\u9996\u5148\uff0c\u5b83\u662f\u4e00\u4e2a\u4e00\u7ef4\u6570\u7ec4\u7c7b\u578b\uff0c\u610f\u5473\u7740\u5b83\u4e0d\u80fd\u7528\u6765\u6784\u5efa Matrix \u77e9\u9635\u3002\u53e6\u5916\u76ee\u524d\u4ec5\u652f\u6301 float32
\u53ca float64
\u7c7b\u578b\u7684\u5411\u91cf\uff0c\u5206\u522b\u79f0\u4e4b\u4e3a vecf32
\u4e0e vecf64
\u800c\u4e0d\u652f\u6301\u5b57\u7b26\u4e32\u7c7b\u578b\u548c\u6574\u578b\u7c7b\u578b\u7684\u6570\u5b57\u3002
\u521b\u5efa\u4e00\u4e2a\u5411\u91cf\u5217\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u5411\u91cf\u5217\u7684\u7ef4\u5ea6\u5927\u5c0f\uff0c\u5982 vecf32(3)\uff0c\u8fd9\u4e2a\u7ef4\u5ea6\u5373\u5411\u91cf\u7684\u6570\u7ec4\u7684\u957f\u5ea6\u5927\u5c0f\uff0c\u6700\u5927\u53ef\u652f\u6301\u5230 65,535 \u7ef4\u5ea6\u3002
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#sql","title":"\u5982\u4f55\u5728 SQL \u4e2d\u4f7f\u7528\u5411\u91cf\u7c7b\u578b","text":"\u4f7f\u7528\u5411\u91cf\u7684\u8bed\u6cd5\u4e0e\u5e38\u89c4\u5efa\u8868\u3001\u63d2\u5165\u6570\u636e\u3001\u67e5\u8be2\u6570\u636e\u76f8\u540c\u3002
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#_2","title":"\u521b\u5efa\u5411\u91cf\u5217","text":"\u4f60\u53ef\u4ee5\u6309\u7167\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u521b\u5efa\u4e86\u4e24\u4e2a\u5411\u91cf\u5217\uff0c\u4e00\u4e2a\u662f Float32 \u7c7b\u578b\uff0c\u53e6\u4e00\u4e2a\u662f Float64 \u7c7b\u578b\uff0c\u5e76\u4e14\u53ef\u4ee5\u5c06\u4e24\u4e2a\u5411\u91cf\u5217\u7684\u7ef4\u5ea6\u90fd\u8bbe\u7f6e\u4e3a 3\u3002
\u76ee\u524d\u5411\u91cf\u7c7b\u578b\u4e0d\u80fd\u4f5c\u4e3a\u4e3b\u952e\u6216\u8005\u552f\u4e00\u952e\u3002
create table t1(a int, b vecf32(3), c vecf64(3));\n
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#_3","title":"\u63d2\u5165\u5411\u91cf","text":"MatrixOne \u652f\u6301\u4ee5\u4e24\u79cd\u683c\u5f0f\u63d2\u5165\u5411\u91cf\u3002
\u6587\u672c\u683c\u5f0f
insert into t1 values(1, \"[1,2,3]\", \"[4,5,6]\");\n
\u4e8c\u8fdb\u5236\u683c\u5f0f
\u5982\u679c\u4f60\u60f3\u4f7f\u7528 Python NumPy \u6570\u7ec4\uff0c\u53ef\u4ee5\u901a\u8fc7\u5bf9\u6570\u7ec4\u8fdb\u884c\u5341\u516d\u8fdb\u5236\u7f16\u7801\uff0c\u800c\u4e0d\u662f\u5c06\u5176\u8f6c\u6362\u4e3a\u9017\u53f7\u5206\u9694\u7684\u6587\u672c\u683c\u5f0f\uff0c\u76f4\u63a5\u5c06\u8be5 NumPy \u6570\u7ec4\u63d2\u5165 MatrixOne\u3002\u5728\u63d2\u5165\u7ef4\u5ea6\u8f83\u9ad8\u7684\u5411\u91cf\u65f6\uff0c\u8fd9\u79cd\u65b9\u5f0f\u901f\u5ea6\u66f4\u5feb\u3002
insert into t1 (a, b) values (2, cast(unhex(\"7e98b23e9e10383b2f41133f\") as blob));\n-- \"7e98b23e9e10383b2f41133f\" \u8868\u793a []float32{0.34881967, 0.0028086076, 0.5752134}\u7684\u5c0f\u7aef\u5341\u516d\u8fdb\u5236\u7f16\u7801\n
"},{"location":"MatrixOne/Reference/Data-Types/vector-type/#_4","title":"\u67e5\u8be2\u5411\u91cf","text":"\u5411\u91cf\u5217\u540c\u6837\u53ef\u4ee5\u4ee5\u4e24\u79cd\u683c\u5f0f\u8bfb\u53d6\u3002
\u6587\u672c\u683c\u5f0f
mysql> select a, b from t1;\n+------+---------------------------------------+\n| a | b |\n+------+---------------------------------------+\n| 1 | [1, 2, 3] |\n| 2 | [0.34881967, 0.0028086076, 0.5752134] |\n+------+---------------------------------------+\n2 rows in set (0.00 sec)\n
\u4e8c\u8fdb\u5236\u683c\u5f0f
\u5982\u679c\u4f60\u9700\u8981\u5c06\u5411\u91cf\u7ed3\u679c\u96c6\u76f4\u63a5\u8bfb\u53d6\u5230 NumPy \u6570\u7ec4\u4e2d\uff0c\u4ee5\u6700\u5c0f\u7684\u8f6c\u6362\u6210\u672c\uff0c\u4e8c\u8fdb\u5236\u683c\u5f0f\u975e\u5e38\u6709\u7528\u3002
mysql> select hex(b) from t1;\n+--------------------------+\n| hex(b) |\n+--------------------------+\n| 0000803f0000004000004040 |\n| 7e98b23e9e10383b2f41133f |\n+--------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/timestamp-initialization/","title":"TIMESTAMP \u548c DATETIME \u7684\u81ea\u52a8\u521d\u59cb\u5316\u548c\u66f4\u65b0","text":"TIMESTAMP
\u548c DATETIME
\u5217\u53ef\u4ee5\u81ea\u52a8\u521d\u59cb\u5316\u5e76\u66f4\u65b0\u4e3a\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\uff08\u5373\u5f53\u524d\u65f6\u95f4\u6233\uff09\u3002
\u5bf9\u4e8e\u8868\u4e2d\u7684\u4efb\u4f55 TIMESTAMP
\u6216 DATETIME
\u5217\uff0c\u4f60\u53ef\u4ee5\u5c06\u5f53\u524d\u65f6\u95f4\u6233\u6307\u5b9a\u4e3a\u9ed8\u8ba4\u503c\u3001\u81ea\u52a8\u66f4\u65b0\u503c\u6216\u4e24\u8005\u5747\u53ef\uff1a
\u5bf9\u4e8e\u672a\u4e3a\u5217\u6307\u5b9a\u503c\u7684\u63d2\u5165\u884c\uff0c\u5c06\u81ea\u52a8\u521d\u59cb\u5316\u7684\u5217\u8bbe\u7f6e\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002
\u5f53\u884c\u4e2d\u4efb\u4f55\u5176\u4ed6\u5217\u7684\u503c\u4ece\u5f53\u524d\u503c\u8fdb\u884c\u66f4\u6539\u65f6\uff0c\u81ea\u52a8\u66f4\u65b0\u5217\u5c06\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002\u5982\u679c\u6240\u6709\u5176\u4ed6\u5217\u90fd\u8bbe\u7f6e\u4e3a\u5f53\u524d\u503c\uff0c\u5219\u81ea\u52a8\u66f4\u65b0\u7684\u5217\u4fdd\u6301\u4e0d\u53d8\u3002\u82e5\u8981\u9632\u6b62\u81ea\u52a8\u66f4\u65b0\u7684\u5217\u5728\u5176\u4ed6\u5217\u66f4\u6539\u65f6\u66f4\u65b0\uff0c\u8bf7\u663e\u5f0f\u5c06\u5176\u8bbe\u7f6e\u4e3a\u5f53\u524d\u503c\u3002\u8981\u66f4\u65b0\u81ea\u52a8\u66f4\u65b0\u7684\u5217\uff0c\u5373\u4f7f\u5176\u4ed6\u5217\u6ca1\u6709\u66f4\u6539\uff0c\u4e5f\u8981\u663e\u5f0f\u5730\u5c06\u5176\u8bbe\u7f6e\u4e3a\u5b83\u5e94\u8be5\u5177\u6709\u7684\u503c (\u4f8b\u5982\uff0c\u5c06\u5176\u8bbe\u7f6e\u4e3a CURRENT_TIMESTAMP
)\u3002
\u8981\u6307\u5b9a\u81ea\u52a8\u5c5e\u6027\uff0c\u8bf7\u5728\u5217\u5b9a\u4e49\u4e2d\u4f7f\u7528 DEFAULT CURRENT_TIMESTAMP
\u548c ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\u3002\u4e24\u4e2a\u5b50\u53e5\u5982\u679c\u540c\u65f6\u5b9a\u4e49\u4e00\u4e2a\u5217\uff0c\u5b83\u4eec\u7684\u987a\u5e8f\u53ef\u4e92\u6362\uff0c\u4e0d\u5f71\u54cd\u903b\u8f91\u8ba1\u7b97\u3002\u53e6\u5916\uff0cCURRENT_TIMESTAMP
\u4e0e CURRENT_TIMESTAMP()
\u6216\u8005 NOW()
\u610f\u4e49\u4e00\u81f4\u3002
DEFAULT CURRENT_TIMESTAMP
\u548c ON UPDATE CURRENT_TIMESTAMP
\u7684\u4f7f\u7528\u662f\u7279\u5b9a\u4e8e TIMESTAMP
\u548c DATETIME
\u7684\u3002DEFAULT
\u5b50\u53e5\u8fd8\u53ef\u7528\u4e8e\u6307\u5b9a\u5e38\u91cf\uff08\u975e\u81ea\u52a8\uff09\u9ed8\u8ba4\u503c\uff08\u4f8b\u5982\uff0cDEFAULT 0
\u6216 DEFAULT '2000-01-01 00:00:00'
\uff09\u3002
TIMESTAMP
\u6216 DATETIME
\u5217\u5b9a\u4e49\u53ef\u4ee5\u4e3a\u9ed8\u8ba4\u503c\u548c\u81ea\u52a8\u66f4\u65b0\u503c\u6307\u5b9a\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u4ec5\u6307\u5b9a\u5176\u4e2d\u4e00\u4e2a\uff0c\u6216\u8005\u4e24\u8005\u90fd\u4e0d\u6307\u5b9a\u3002\u4e0d\u540c\u7684\u5217\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u81ea\u52a8\u5c5e\u6027\u7ec4\u5408\u3002\u4ee5\u4e0b\u89c4\u5219\u63cf\u8ff0\u4e86\u8fd9\u4e9b\u53ef\u80fd\u6027\uff1a
DEFAULT CURRENT_TIMESTAMP
\u548c ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\u65f6\uff0c\u5217\u7684\u9ed8\u8ba4\u503c\u662f\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u5e76\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n);\n
DEFAULT
\u5b50\u53e5\uff0c\u4e0d\u4f7f\u7528 ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\uff0c\u8be5\u5217\u5177\u6709\u7ed9\u5b9a\u7684\u9ed8\u8ba4\u503c\uff0c\u4f46\u4e0d\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002\u9ed8\u8ba4\u503c\u53d6\u51b3\u4e8e DEFAULT
\u5b50\u53e5\u662f\u6307\u5b9a CURRENT_TIMESTAMP
\u8fd8\u662f\u5e38\u91cf\u503c\u3002\u4f7f\u7528 CURRENT_TIMESTAMP
\uff0c\u9ed8\u8ba4\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u3002
CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n dt DATETIME DEFAULT CURRENT_TIMESTAMP\n);\n
\u5bf9\u4e8e\u5e38\u91cf\uff0c\u9ed8\u8ba4\u503c\u662f\u7ed9\u5b9a\u503c\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8be5\u5217\u6ca1\u6709\u81ea\u52a8\u5c5e\u6027\u3002
CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT 0,\n dt DATETIME DEFAULT 0\n);\n
ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\u548c\u5e38\u91cf DEFAULT
\u5b50\u53e5\uff0c\u8be5\u5217\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\u5e76\u4f7f\u7528\u7ed9\u5b9a\u7684\u5e38\u91cf\u9ed8\u8ba4\u503c\u3002CREATE TABLE t1 (\n ts TIMESTAMP DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP,\n dt DATETIME DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP\n);\n
ON UPDATE CURRENT_TIMESTAMP
\u5b50\u53e5\uff0c\u4f46\u4e0d\u4f7f\u7528 DEFAULT
\u5b50\u53e5\u65f6\uff0c\u5217\u4f1a\u81ea\u52a8\u66f4\u65b0\u4e3a\u5f53\u524d\u65f6\u95f4\u6233\uff0c\u4f46\u5176\u9ed8\u8ba4\u503c\u6ca1\u6709\u5f53\u524d\u65f6\u95f4\u6233\u3002TIMESTAMP
\u7684\u9ed8\u8ba4\u503c\u4e3a 0\uff1b\u82e5\u4f7f\u7528 NULL
\u5c5e\u6027\u5b9a\u4e49\uff0c\u5219\u9ed8\u8ba4\u503c\u4e3a NULL
\u3002
CREATE TABLE t1 (\n ts1 TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- default 0\n ts2 TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP -- default NULL\n);\n
DATETIME
\u7684\u9ed8\u8ba4\u503c\u4e3a NULL
\uff1b\u82e5\u4f7f\u7528 NOT NULL
\u5c5e\u6027\u5b9a\u4e49\uff0c\u5219\u9ed8\u8ba4\u503c\u4e3a 0\u3002
CREATE TABLE t1 (\n dt1 DATETIME ON UPDATE CURRENT_TIMESTAMP, -- default NULL\n dt2 DATETIME NOT NULL ON UPDATE CURRENT_TIMESTAMP -- default 0\n);\n
"},{"location":"MatrixOne/Reference/Data-Types/date-time-data-types/year-type/","title":"YEAR \u7c7b\u578b","text":"YEAR \u7c7b\u578b\u662f\u7528\u4e8e\u8868\u793a\u5e74\u4efd\u503c\u7684 1 \u5b57\u8282\u7c7b\u578b\u3002\u53ef\u4ee5\u58f0\u660e\u4e3a YEAR\uff0c\u5176\u9690\u5f0f\u663e\u793a\u5bbd\u5ea6\u4e3a 4 \u4e2a\u5b57\u7b26\uff0c\u6216\u7b49\u6548\u5730\u58f0\u660e\u4e3a YEAR(4)
\uff0c\u663e\u5f0f\u6307\u5b9a\u663e\u793a\u5bbd\u5ea6\u4e3a 4\u3002
MatrixOne \u4ee5 YYYY \u683c\u5f0f\u663e\u793a YEAR \u503c\uff0c\u8303\u56f4\u4ece 0001 \u5e74\u5230 9999 \u5e74\u3002
YEAR \u63a5\u53d7\u5404\u79cd\u683c\u5f0f\u7684\u8f93\u5165\u503c\uff1a
NOW()
\u3002\u7531\u4e8e\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\u7f3a\u4e4f\u4e16\u7eaa\u6570\u503c\uff0c\u5176\u542b\u4e49\u4e0d\u591f\u660e\u786e\u3002\u4e3a\u4e86\u5185\u90e8\u5b58\u50a8\u7684\u4e00\u81f4\u6027\uff0cMatrixOne \u5fc5\u987b\u5c06\u8fd9\u4e9b\u65e5\u671f\u503c\u89e3\u91ca\u4e3a 4 \u4f4d\u6570\u5b57\u5f62\u5f0f\u3002
\u5bf9\u4e8e DATETIME\u3001DATE \u548c TIMESTAMP \u7c7b\u578b\uff0cMatrixOne \u9075\u5faa\u4ee5\u4e0b\u89c4\u5219\u89e3\u91ca\u5177\u6709\u4e0d\u660e\u786e\u5e74\u4efd\u503c\u7684\u65e5\u671f\uff1a
\u4e0b\u9762\u662f\u5173\u4e8e\u6d89\u53ca 2 \u4f4d\u5e74\u4efd\u65e5\u671f\u7684\u4f8b\u5b50\uff1a
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a event_date
\u7684 DATETIME \u7c7b\u578b\u7684\u5217\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u65e5\u671f\u503c\uff1a
\u6839\u636e\u89c4\u5219\uff0c\u65e5\u671f\u503c\u4e2d\u7684 2 \u4f4d\u5e74\u4efd\u88ab\u89e3\u91ca\u4e3a\uff1a
23-05-06 \u88ab\u89e3\u91ca\u4e3a 0023 \u5e74 5 \u6708 6 \u65e5\u3002
\u89e3\u91ca DATE \u7c7b\u578b\u7684\u65e5\u671f\uff1a
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a birth_date
\u7684 DATE \u7c7b\u578b\u7684\u5217\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u65e5\u671f\u503c\uff1a
\u6839\u636e\u89c4\u5219\uff0c\u65e5\u671f\u503c\u4e2d\u7684 2 \u4f4d\u5e74\u4efd\u88ab\u89e3\u91ca\u4e3a\uff1a
88-03-17 \u88ab\u89e3\u91ca\u4e3a 0088 \u5e74 3 \u6708 17 \u65e5\u3002
\u89e3\u91ca YEAR \u7c7b\u578b\u7684\u65e5\u671f\uff1a
\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a graduation_year
\u7684 YEAR \u7c7b\u578b\u7684\u5217\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u5e74\u4efd\u503c\uff1a
\u6839\u636e\u89c4\u5219\uff0c\u5e74\u4efd\u503c\u4e2d\u7684 2 \u4f4d\u5e74\u4efd\u88ab\u89e3\u91ca\u4e3a\uff1a
\u672c\u6587\u6863\u5217\u51fa\u4e86 MatrixOne \u6700\u65b0\u7248\u672c\u6240\u652f\u6301\u7684\u51fd\u6570\u6e05\u5355\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_2","title":"\u805a\u5408\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 ANY_VALUE() \u5728\u53c2\u6570\u8303\u56f4\u5185\u4efb\u9009\u4e00\u4e2a\u503c\u8fd4\u56de AVG() \u8ba1\u7b97\u53c2\u6570\u5217\u7684\u7b97\u672f\u5e73\u5747\u503c\u3002 BITMAP \u4e00\u7ec4\u7528\u4e8e\u5904\u7406\u4f4d\u56fe\u7684\u5185\u7f6e\u51fd\u6570\uff0c\u4e3b\u8981\u7528\u4e8e\u8ba1\u7b97\u4e0d\u540c\u503c BIT_AND() \u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u4e0e BIT_OR() \u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u6216 BIT_XOR() \u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u5f02\u6216 COUNT() \u8ba1\u7b97\u4e86\u67e5\u8be2\u7ed3\u679c\u7684\u8bb0\u5f55\u6570 GROUP_CONCAT() \u5c06\u901a\u8fc7\u5217\u6216\u8005\u8868\u8fbe\u5f0f\u6307\u5b9a\u7684\u5185\u5bb9\u8fde\u63a5\u8d77\u6765 MAX() \u8fd4\u56de\u4e00\u7ec4\u503c\u7684\u6700\u5927\u503c MEDIAN() \u8fd4\u56de\u4e00\u7ec4\u6570\u503c\u7684\u4e2d\u503c MIN() \u8fd4\u56de\u4e00\u7ec4\u503c\u7684\u6700\u5c0f\u503c STDDEV_POP() \u7528\u4e8e\u8ba1\u7b97\u603b\u4f53\u6807\u51c6\u5dee SUM() \u7528\u4e8e\u8ba1\u7b97\u4e00\u7ec4\u503c\u7684\u548c VARIANCE() \u7528\u4e8e\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee VAR_POP() \u7528\u4e8e\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_3","title":"\u65e5\u671f\u65f6\u95f4\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 CONVERT_TZ() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u65e5\u671f\u65f6\u95f4\u4ece\u4e00\u4e2a\u65f6\u533a\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u65f6\u533a\u3002 CURDATE() \u8fd4\u56de\u5f53\u524d\u65e5\u671f\u7684 YYYY-MM-DD \u683c\u5f0f\u7684\u503c CURRENT_TIMESTAMP() \u5c06\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss \u6216 YYYYMMDDhhmmss \u7684\u683c\u5f0f\u8fd4\u56de DATE() \u5c06 DATE \u6216\u8005 DATETIME \u683c\u5f0f\u7684\u8f93\u5165\u4e2d\u7684\u65e5\u671f\u90e8\u5206\u622a\u53d6\u51fa\u6765\u3002 DATE_ADD() \u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1a\u4ece\u6307\u5b9a\u65e5\u671f\u4e2d\u52a0\u4e0a\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694 DATE_FORMAT() \u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65e5\u671f\u503c DATE_SUB() \u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1a\u4ece\u6307\u5b9a\u65e5\u671f\u4e2d\u51cf\u53bb\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694 DATEDIFF() \u8fd4\u56de\u4e24\u4e2a\u65e5\u671f\u4e4b\u95f4\u7684\u5929\u6570 DAY() \u8fd4\u56de\u67d0\u65e5\u671f\u4e3a\u5f53\u6708\u7684\u7b2c\u51e0\u53f7 DAYOFYEAR() \u8fd4\u56de\u65e5\u671f\u6240\u5bf9\u5e94\u5728\u4e00\u5e74\u4e2d\u7684\u5929\u6570 EXTRACT() \u4ece\u65e5\u671f\u4e2d\u63d0\u53d6\u90e8\u5206\u5185\u5bb9 HOUR() \u8fd4\u56de\u65f6\u95f4\u7684\u5c0f\u65f6\u6570 FROM_UNIXTIME() \u628a\u5185\u90e8 UNIX \u65f6\u95f4\u6233\u503c\u8f6c\u6362\u4e3a\u666e\u901a\u683c\u5f0f\u7684\u65e5\u671f\u65f6\u95f4\u503c\uff0c\u4ee5 YYYY-MM-DD HH:MM:SS \u6216 YYYYMMDDHHMMSS \u683c\u5f0f\u6765\u663e\u793a MINUTE() \u8fd4\u56de\u65f6\u95f4\u53c2\u6570\u7684\u5206\u949f MONTH() \u8fd4\u56de\u65e5\u671f\u53c2\u6570\u7684\u6708\u4efd NOW() \u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002 SECOND() \u8fd4\u56de\u65f6\u95f4\u53c2\u6570\u7684\u79d2\u6570 STR_TO_DATE() \u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b SYSDATE() \u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002 TIME() \u63d0\u53d6\u65f6\u95f4\u6216\u65e5\u671f\u65f6\u95f4\u7684\u65f6\u95f4\u90e8\u5206\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de TIMEDIFF() \u8fd4\u56de\u4e24\u4e2a\u65f6\u95f4\u53c2\u6570\u4e4b\u95f4\u7684\u5dee\u503c TIMESTAMP() \u5c06\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u53c2\u6570\u4f5c\u4e3a\u65e5\u671f\u65f6\u95f4\u503c\u8fd4\u56de TIMESTAMPDIFF() \u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u5728\u7ed9\u5b9a\u7684\u65f6\u95f4\u5355\u4f4d\u5185\uff0c\u4ece\u7b2c\u4e00\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u5230\u7b2c\u4e8c\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694 TO_DATE() \u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b TO_DAYS() \u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u4e0e\u516c\u5386\u65e5\u5386\u7684\u5f00\u59cb\u65e5\u671f\uff080000 \u5e74 1 \u6708 1 \u65e5\uff09\u4e4b\u95f4\u7684\u5929\u6570\u5dee TO_SECONDS() \u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4 expr \u4e0e\u516c\u5143 0 \u5e74 1 \u6708 1 \u65e5 0 \u65f6 0 \u5206 0 \u79d2\u4e4b\u95f4\u7684\u79d2\u6570\u5dee UNIX_TIMESTAMP \u8fd4\u56de\u81ea 1970-01-01 00:00:00 UTC \u81f3\u6307\u5b9a\u65f6\u95f4\u7684\u79d2\u6570 UTC_TIMESTAMP() \u5c06\u5f53\u524d UTC \u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss \u6216 YYYYMMDDhhmmss \u7684\u683c\u5f0f\u8fd4\u56de WEEK() \u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u7684\u5468\u6570 WEEKDAY() \u8fd4\u56de\u65e5\u671f\u7684\u5de5\u4f5c\u65e5\u7d22\u5f15\uff080 = \u661f\u671f\u4e00\uff0c1 = \u661f\u671f\u4e8c\uff0c... 6 = \u661f\u671f\u65e5\uff09 YEAR() \u8fd4\u56de\u4e86\u7ed9\u5b9a\u65e5\u671f\u7684\u5e74\u4efd"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_4","title":"\u6570\u5b66\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 ABS() \u7528\u4e8e\u6c42\u53c2\u6570\u7684\u7edd\u5bf9\u503c ACOS() \u7528\u4e8e\u6c42\u7ed9\u5b9a\u6570\u503c\u7684\u4f59\u5f26\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09 ATAN() \u7528\u4e8e\u6c42\u7ed9\u5b9a\u6570\u503c\u7684\u53cd\u6b63\u5207\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09 CEIL() \u7528\u4e8e\u6c42\u4e0d\u5c0f\u4e8e\u53c2\u6570\u7684\u6700\u5c0f\u6574\u6570\u3002 COS() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5f26\u503c\u3002 COT() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5207\u503c\u3002 EXP() \u7528\u4e8e\u6c42\u4ee5\u81ea\u7136\u5e38\u6570 e \u4e3a\u5e95\u7684 number \u7684\u6307\u6570\u3002 FLOOR() \u7528\u4e8e\u6c42\u4e0d\u5927\u4e8e\u67d0\u4e2a\u6570\u5b57\u7684\u76f8\u5e94\u6570\u4f4d\u7684\u6570\u3002 LN() \u7528\u4e8e\u6c42\u53c2\u6570\u7684\u81ea\u7136\u5bf9\u6570 LOG() \u7528\u4e8e\u6c42\u53c2\u6570\u7684\u81ea\u7136\u5bf9\u6570 LOG2() \u7528\u4e8e\u6c42\u4ee5 2 \u4e3a\u5e95\u53c2\u6570\u7684\u5bf9\u6570 LOG10() \u7528\u4e8e\u6c42\u4ee5 10 \u4e3a\u5e95\u53c2\u6570\u7684\u5bf9\u6570 PI() \u7528\u4e8e\u6c42\u6570\u5b66\u5e38\u91cf \u03c0 (pi) POWER() POWER(X, Y) \u7528\u4e8e\u6c42 X \u7684 Y \u6b21\u65b9\u6307\u6570\u503c ROUND() \u7528\u4e8e\u6c42\u67d0\u4e2a\u6570\u5b57\u5728\u7279\u5b9a\u4f4d\u6570\u56db\u820d\u4e94\u5165\u540e\u7684\u6570\u503c RAND() \u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684 Float64 \u7c7b\u578b\u7684\u968f\u673a\u6570 SIN() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5f26\u503c SINH() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u53cc\u66f2\u6b63\u5f26\u503c TAN() \u7528\u4e8e\u6c42\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5207\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_5","title":"\u5b57\u7b26\u4e32\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 BIN() \u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u7684\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002 BIT_LENGTH() \u8fd4\u56de\u5b57\u7b26\u4e32 str \u7684\u957f\u5ea6\uff0c\u5355\u4f4d\u4e3a bit\u3002 CHAR_LENGTH() \u4ee5\u5b57\u7b26\u4e3a\u5355\u4f4d\u8fd4\u56de\u5b57\u7b26\u4e32 str \u7684\u957f\u5ea6 CONCAT() \u5c06\u591a\u4e2a\u5b57\u7b26\u4e32\uff08\u6216\u4ec5\u542b\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\uff09\u8fde\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32 CONCAT_WS() \u4ee3\u8868 Concatenate With Separator\uff0c\u662f CONCAT() \u7684\u4e00\u79cd\u7279\u6b8a\u5f62\u5f0f\u3002 EMPTY() \u5224\u65ad\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u3002 ENDSWITH() \u68c0\u67e5\u662f\u5426\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e\u3002 FIELD() \u8fd4\u56de\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e32 str \u5728\u5b57\u7b26\u4e32\u5217\u8868 (str1,str2,str3,...) \u4e2d\u7684\u4f4d\u7f6e FIND_IN_SET() \u5728\u9017\u53f7\u5206\u9694\u7684\u5b57\u7b26\u4e32\u5217\u8868\u4e2d\u67e5\u627e\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u4f4d\u7f6e\u3002 FORMAT() \u7528\u4e8e\u5c06\u6570\u5b57\u683c\u5f0f\u8bbe\u7f6e\u4e3a \"#,###,###.##\" \u683c\u5f0f\uff0c\u5e76\u56db\u820d\u4e94\u5165\u5230\u5c0f\u6570\u70b9\u540e\u4e00\u4f4d\u3002 FROM_BASE64() \u7528\u4e8e\u5c06 Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u56de\u539f\u59cb\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff08\u6216\u6587\u672c\u6570\u636e\uff09\u3002 HEX() \u8fd4\u56de\u53c2\u6570\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u5f62\u5f0f INSTR() \u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u5728\u7ed9\u5b9a\u5b57\u7b26\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u3002 LCASE() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\u3002 LEFT() \u8fd4\u56de str \u5b57\u7b26\u4e32\u4e2d\u6700\u5de6\u8fb9\u7684\u957f\u5ea6\u5b57\u7b26\u3002 LENGTH() \u8fd4\u56de\u4e86\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002 LOCATE() \u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u6240\u5728\u4f4d\u7f6e\u7684\u51fd\u6570\u3002 LOWER() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\u3002 LPAD() \u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u5de6\u4fa7\u586b\u5145\u3002 LTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u524d\u90e8\u7a7a\u683c\u53bb\u9664\uff0c\u8fd4\u56de\u5904\u7406\u540e\u7684\u5b57\u7b26\u3002 MD5() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u751f\u6210\u4e00\u4e2a 32 \u5b57\u7b26\u957f\u7684\u5341\u516d\u8fdb\u5236 MD5 \u54c8\u5e0c\u503c\u3002 OCT() \u8fd4\u56de\u53c2\u6570\u7684\u516b\u8fdb\u5236\u503c\u7684\u5b57\u7b26\u4e32 REPEAT() \u7528\u4e8e\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u91cd\u590d n \u6b21\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32 REVERSE() \u5c06 str \u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u987a\u5e8f\u7ffb\u8f6c\u8f93\u51fa\u3002 RPAD() \u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u53f3\u4fa7\u586b\u5145 RTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u540e\u65b9\u7a7a\u683c\u53bb\u9664 SHA1()/SHA() \u7528\u4e8e\u8ba1\u7b97\u5e76\u8fd4\u56de\u7ed9\u5b9a\u5b57\u7b26\u4e32\u7684 SHA-1 \u54c8\u5e0c\u503c\u3002 SHA2() \u8fd4\u56de\u8f93\u5165\u5b57\u7b26\u4e32\u7684 SHA2 \u54c8\u5e0c\u503c\u3002 SPACE() \u8fd4\u56de N \u4e2a\u7a7a\u683c\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u3002 SPLIT_PART() \u7528\u4e8e\u5728\u7ed9\u5b9a\u7684\u5206\u9694\u7b26\u57fa\u7840\u4e0a\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u5206\u89e3\u6210\u591a\u4e2a\u90e8\u5206 STARTSWITH() \u5b57\u7b26\u4e32\u5982\u679c\u4ee5\u6307\u5b9a\u524d\u7f00\u5f00\u59cb\u8fd4\u56de 1\uff0c\u5426\u5219\u5219\u8fd4\u56de 0\u3002 SUBSTRING() \u8fd4\u56de\u4e00\u4e2a\u4ece\u6307\u5b9a\u4f4d\u7f6e\u5f00\u59cb\u7684\u5b50\u5b57\u7b26\u4e32 SUBSTRING_INDEX() \u4ee5\u5206\u9694\u7b26\u4e3a\u7d22\u5f15\uff0c\u83b7\u53d6\u4e0d\u540c\u7d22\u5f15\u4f4d\u7684\u5b57\u7b26\u3002 TO_BASE64() \u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32 TRIM() \u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5220\u9664\u4e0d\u9700\u8981\u7684\u5b57\u7b26\u3002 UCASE() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\u3002 UNHEX() \u7528\u4e8e\u5c06\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u76f8\u5e94\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002 UPPER() \u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_6","title":"\u6b63\u5219\u8868\u8fbe\u5f0f","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 NOT REGEXP() \u7528\u4e8e\u6d4b\u8bd5\u4e00\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e0d\u5339\u914d\u6307\u5b9a\u7684\u6b63\u5219\u8868\u8fbe\u5f0f REGEXP_INSTR() \u8fd4\u56de\u5339\u914d\u5230\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002 REGEXP_LIKE() \u7528\u4e8e\u5224\u65ad\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e0e\u63d0\u4f9b\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5339\u914d REGEXP_REPLACE() \u7528\u4e8e\u5c06\u5339\u914d\u7ed9\u5b9a\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u65b0\u5b57\u7b26\u4e32 REGEXP_SUBSTR() \u7528\u4e8e\u8fd4\u56de\u5b57\u7b26\u4e32\u53c2\u6570\u4e2d\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u53c2\u6570\u7684\u5b50\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_7","title":"\u5411\u91cf\u7c7b\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 \u57fa\u672c\u64cd\u4f5c\u7b26 \u5411\u91cf\u7684\u52a0\u6cd5 (+)\u3001\u51cf\u6cd5 (-)\u3001\u4e58\u6cd5 (*) \u548c\u9664\u6cd5 (/) SQRT() \u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u6839 ABS() \u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u7684\u7edd\u5bf9\u503c CAST() \u7528\u4e8e\u663e\u5f0f\u5c06\u4e00\u4e2a\u5411\u91cf\u4ece\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b SUMMATION() \u8fd4\u56de\u5411\u91cf\u4e2d\u6240\u6709\u5143\u7d20\u7684\u603b\u548c INNER_PRODUCT() \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u5185\u79ef/\u70b9\u79ef CLUSTER_CENTERS() \u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u5217\u7684 K \u4e2a\u805a\u7c7b\u4e2d\u5fc3 COSINE_DISTANCE() \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u8ddd\u79bb\u3002 COSINE_SIMILARITY() \u8861\u91cf\u4e86\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u5939\u89d2\u7684\u4f59\u5f26\u503c\uff0c\u901a\u8fc7\u5b83\u4eec\u5728\u591a\u7ef4\u7a7a\u95f4\u4e2d\u7684\u63a5\u8fd1\u7a0b\u5ea6\u6765\u8868\u793a\u5b83\u4eec\u7684\u76f8\u4f3c\u6027 L2_DISTANCE() \u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb L1_NORM() \u7528\u4e8e\u8ba1\u7b97 l1/\u66fc\u54c8\u987f/TaxiCab \u8303\u6570 L2_NORM() \u7528\u4e8e\u8ba1\u7b97 l2/\u6b27\u51e0\u91cc\u5f97\u8303\u6570 NORMALIZE_L2() \u7528\u4e8e\u6267\u884c\u6b27\u51e0\u91cc\u5f97\u5f52\u4e00\u5316 SUBVECTOR() \u7528\u4e8e\u4ece\u5411\u91cf\u4e2d\u63d0\u53d6\u5b50\u5411\u91cf VECTOR_DIMS() \u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u7684\u7ef4\u5ea6"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_8","title":"\u8868\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 UNNEST() \u7528\u4e8e\u5c06 JSON \u7c7b\u578b\u6570\u636e\u5185\u7684\u6570\u7ec4\u7c7b\u578b\u7684\u5217\u6216\u53c2\u6570\u5c55\u5f00\u4e3a\u4e00\u4e2a\u8868"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_9","title":"\u7a97\u53e3\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 DENSE_RANK() \u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d RANK() \u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d ROW_UNMBER() \u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u5e8f\u53f7"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#json","title":"JSON \u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 JSON_EXTRACT() \u4ece JSON \u6587\u6863\u8fd4\u56de\u6570\u636e JSON_QUOTE() \u5f15\u7528 JSON \u6587\u6863 JSON_UNQUOTE() \u53d6\u6d88\u5f15\u7528 JSON \u6587\u6863"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_10","title":"\u7cfb\u7edf\u8fd0\u7ef4\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 CURRENT_ROLE_NAME() \u7528\u4e8e\u67e5\u8be2\u5f53\u524d\u767b\u5f55\u7684\u7528\u6237\u6240\u62e5\u6709\u7684\u89d2\u8272\u7684\u540d\u79f0\u3002 CURRENT_ROLE() \u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u7684\u89d2\u8272\u3002 CURRENT_USER_NAME() \u7528\u4e8e\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u767b\u5f55\u7684\u7528\u6237\u540d\u79f0\u3002 CURRENT_USER() \u8fd4\u56de\u5f53\u524d\u7528\u6237\u8d26\u6237 PURGE_LOG() \u7528\u4e8e\u5220\u9664\u8bb0\u5f55\u4e8e MatrixOne \u6570\u636e\u5e93\u7cfb\u7edf\u8868\u4e2d\u7684\u65e5\u5fd7\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/matrixone-function-list/#_11","title":"\u5176\u4ed6\u51fd\u6570","text":"\u51fd\u6570\u540d\u79f0 \u4f5c\u7528 SAMPLE() \u4e3b\u8981\u7528\u4e8e\u5feb\u901f\u7f29\u51cf\u67e5\u8be2\u8303\u56f4 SERIAL_EXTRACT() \u7528\u4e8e\u63d0\u53d6\u5e8f\u5217/\u5143\u7ec4\u503c\u4e2d\u7684\u5404\u4e2a\u5143\u7d20 SLEEP() \u5c06\u5f53\u524d\u67e5\u8be2\u6682\u505c\uff08\u7761\u7720\uff09\u6307\u5b9a\u7684\u79d2\u6570 UUID() \u8fd4\u56de\u6839\u636e RFC 4122 \u751f\u6210\u56fd\u9645\u901a\u7528\u552f\u4e00\u6807\u8bc6\u7b26"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/","title":"ANY_VALUE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ANY_VALUE
\u5728\u8303\u56f4\u5185\u4efb\u9009\u4e00\u4e2a\u503c\u8fd4\u56de\u3002
> ANY_VALUE(arg)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e arg \u53ef\u4e3a\u4efb\u610f\u7c7b\u578b\u3002\u5f53 arg \u4e3a NULL \u65f6\uff0c\u8be5\u884c\u4e0d\u53c2\u4e0e\u8ba1\u7b97\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/any-value/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de\u7c7b\u578b\u548c\u8f93\u5165\u7c7b\u578b\u76f8\u540c\u3002
\u8bf4\u660e\uff1aANY_VALUE
\u7684\u6267\u884c\u7ed3\u679c\u5177\u6709\u4e0d\u786e\u5b9a\u6027\uff0c\u76f8\u540c\u7684\u8f93\u5165\u53ef\u80fd\u5f97\u5230\u4e0d\u540c\u7684\u6267\u884c\u7ed3\u679c\u3002
> create table t1(\n-> a int,\n-> b int,\n-> c int\n-> );\n> create table t2(\n-> a int,\n-> b int,\n-> c int\n-> );\n> insert into t1 values(1,10,34),(2,20,14);\n> insert into t2 values(1,-10,-45);\n> select ANY_VALUE(t1.b) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+-----------------+\n| any_value(t1.b) |\n+-----------------+\n| 10 |\n| 20 |\n+-----------------+\n2 rows in set (0.01 sec)\n> select 3+(5*ANY_VALUE(t1.b)) from t1 left join t2 on t1.c=t1.b and t1.a=t1.c group by t1.a;\n+---------------------------+\n| 3 + (5 * any_value(t1.b)) |\n+---------------------------+\n| 53 |\n| 103 |\n+---------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/","title":"AVG","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"AVG()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u7528\u4e8e\u8ba1\u7b97\u53c2\u6570\u5217\u7684\u7b97\u672f\u5e73\u5747\u503c\u3002
> AVG(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/avg/#_4","title":"\u8fd4\u56de\u503c","text":"\u4ee5 Double
\u7c7b\u578b\u8fd4\u56de\u8be5\u5217\u7684\u7b97\u672f\u5e73\u5747\u503c\u3002 \u82e5\u8f93\u5165\u53c2\u6570\u4e3a\u7a7a\uff0c\u5219\u8fd4\u56de NaN
\u503c\u3002
> drop table if exists tbl1;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select avg(col_1c) from tbl1;\n+-------------+\n| avg(col_1c) |\n+-------------+\n| 3.5 |\n+-------------+\n\n> select sum(col_1d) as s1,avg(col_1d) as a3 from tbl1 group by col_1e order by s1 desc;\n+------+------+\n| s1 | a3 |\n+------+------+\n| 21 | 10.5 |\n| 18 | 9 |\n| 10 | 10 |\n| 8 | 8 |\n+------+------+\n\n> select avg(col_1d) as a1 from tbl1 where col_1d < 13 group by col_1e order by a1;\n+------+\n| a1 |\n+------+\n| 8 |\n| 9 |\n| 10 |\n| 10.5 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/","title":"BIT_AND","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BIT_AND() \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u4e0e\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> BIT_AND(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr UINT \u7c7b\u578b\u7684\u5217"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_and/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_AND(number) FROM t1 GROUP BY id;\n+------+-----------------+\n| id | bit_and(number) |\n+------+-----------------+\n| a | 0 |\n| b | 1 |\n+------+-----------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/","title":"BIT_OR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BIT_OR() \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u6216\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> BIT_OR(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr UINT \u7c7b\u578b\u7684\u5217"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_or/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, BIT_OR(number) FROM t1 GROUP BY id;\n+------+----------------+\n| id | bit_or(number) |\n+------+----------------+\n| a | 111 |\n| b | 11 |\n+------+----------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/","title":"BIT_XOR","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BIT_XOR() \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u4e86\u5217\u4e2d\u6240\u6709\u4f4d\u7684\u6309\u4f4d\u5f02\u6216\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> BIT_XOR(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr UINT \u7c7b\u578b\u7684\u5217"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bit_xor/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1 (id CHAR(1), number INT);\n> INSERT INTO t1 VALUES\n('a',111),('a',110),('a',100),\n('a',000),('b',001),('b',011);\n\n> select id, bit_xor(number) from t1 group by id;\n+------+-----------------+\n| id | bit_xor(number) |\n+------+-----------------+\n| a | 101 |\n| b | 10 |\n+------+-----------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/","title":"BITMAP \u51fd\u6570","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BITMAP
\u51fd\u6570\u662f\u4e00\u7ec4\u7528\u4e8e\u5904\u7406\u4f4d\u56fe\uff08bitmap\uff09\u7684\u5185\u7f6e\u51fd\u6570\uff0cbitmap \u662f\u5b58\u50a8\u4e3a\u4e8c\u8fdb\u5236\u6570\u636e\u7c7b\u578b\u7684\u8fde\u7eed\u5185\u5b58\u7247\u6bb5\u3002\u8fd9\u4e9b\u51fd\u6570\u7279\u522b\u9002\u7528\u4e8e\u5904\u7406\u5c42\u6b21\u5316\u805a\u5408\uff08\u5982\u591a\u4e2a\u5206\u7ec4\u96c6\u5408\uff09\u65f6\u7684\u4e0d\u540c\u503c\uff08distinct values\uff09\u7684\u8ba1\u6570\uff0c\u8fd4\u56de\u7ed3\u679c\u4e0e count(distinct)
\u4e00\u81f4\uff0c\u4f46\u66f4\u9ad8\u6548\u3002
\u6211\u4eec\u53ef\u4ee5\u53ea\u4f7f\u7528\u4e00\u4e2a bit \u4f4d\u6807\u8bc6\u4e00\u4e2a\u5143\u7d20\u7684\u5b58\u5728\u4e0e\u5426\uff0c\u5b58\u5728\u4e3a 1\uff0c\u4e0d\u5b58\u5728\u5219\u4e3a 0\uff0c\u7528 bitmap \u7684\u7b2c n \u4e2a bit \u6765\u8bb0\u5f55\u8fd9\u4e2a\u5143\u7d20\u662f\u5426\u5b58\u5728\u3002
\u6211\u4eec\u89c4\u5b9a bitmap \u6700\u5927\u5bbd\u5ea6\u4e3a 32768(2^15 = 4K)\uff0c\u5bf9\u4e8e\u975e\u8d1f\u6574\u6570 n\uff0c\u53d6\u5176\u4f4e 15 \u4f4d\uff08\u4e8c\u8fdb\u5236\uff09\u4f5c\u4e3a\u5728 bitmap \u7684\u4f4d\u7f6e\uff0c\u5176\u5b83\u9ad8\u4f4d\u4f5c\u4e3a\u4f4d\u56fe\u6876 (bitmap bucket) \u7684\u7f16\u53f7\u3002\u4e0b\u56fe\u4e3a bitmap \u7684\u903b\u8f91\u56fe\uff1a
\u6bcf\u4e2a bucket \u662f\u4e00\u4e2a bitmap\uff0c\u7531\u4e8e\u5404\u4e2a bucket \u662f\u6b63\u4ea4\u7684\uff0c\u6bcf\u4e2a bucket \u505a\u8fd0\u7b97 (or\uff0cbit_count) \u53ef\u4ee5\u53ea\u5728\u5f53\u524d bucket \u4e2d\u8fdb\u884c\uff0c\u800c\u4e0d\u5fc5\u5173\u5fc3\u5176\u5b83 bucket\u3002
\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684 BITMAP
\u51fd\u6570\u53ca\u5176\u7528\u6cd5\uff1a
BITMAP_BUCKET_NUMBER()
\u51fd\u6570\u7684\u76ee\u7684\u662f\u786e\u5b9a\u7ed9\u5b9a\u503c\u6240\u5c5e\u7684 bucket \u7684\u7f16\u53f7\u3002bucket \u662f\u4e00\u4e2a\u66f4\u5927\u7684\u4f4d\u96c6\u5408\uff0c\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u4f4d\uff0c\u6bcf\u4e2a\u4f4d\u4ee3\u8868\u6570\u636e\u96c6\u4e2d\u7684\u4e00\u4e2a\u7279\u5b9a\u503c\u3002\u8fd9\u4e2a\u51fd\u6570\u8fd4\u56de bucket \u7684\u7f16\u53f7\u3002\u4e00\u4e2a bucket \u7f16\u53f7\u901a\u5e38\u7528\u4e8e\u5728\u6267\u884c\u805a\u5408\u64cd\u4f5c\u65f6\u5bf9 bitmap \u8fdb\u884c\u5206\u7ec4\u3002
> BITMAP_BUCKET_NUMBER(numeric_expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e numeric_expr \u5fc5\u9700\u7684\u3002\u53ef\u4ee5 cast \u6210\u975e\u8d1f\u6574\u578b\u7684\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT bitmap_bucket_number(0);-- \u8fd4\u56de 0\uff0c\u8868\u793a\u5c5e\u4e8e\u7b2c\u4e00\u4e2a bucket\uff0c\u7b2c\u4e00\u4e2a bucket \u8bb0\u5f55 0-32767 \u7684\u4f4d\u7f6e\n+-------------------------+\n| bitmap_bucket_number(0) |\n+-------------------------+\n| 0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bucket_number(32767);-- \u8fd4\u56de 0\uff0c\u56e0\u4e3a 32767 \u5c5e\u4e8e\u7b2c\u4e00\u4e2a bucket \u7684\u672b\u5c3e\u4f4d\u7f6e\n+-----------------------------+\n| bitmap_bucket_number(32767) |\n+-----------------------------+\n| 0 |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bucket_number(32768);-- \u8fd4\u56de 1\uff0c\u56e0\u4e3a 32768 \u5c5e\u4e8e\u7b2c\u4e8c\u4e2a bucket \u7684\u8d77\u59cb\u4f4d\u7f6e\n+-----------------------------+\n| bitmap_bucket_number(32768) |\n+-----------------------------+\n| 1 |\n+-----------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#bitmap_bit_position","title":"BITMAP_BIT_POSITION","text":"BITMAP_BIT_POSITION()
\u51fd\u6570\u7528\u4e8e\u8fd4\u56de\u7ed9\u5b9a\u503c\u5728 bucket \u4e2d\u7684\u76f8\u5bf9\u4f4d\u4f4d\u7f6e\uff08\u4ece 0 \u5f00\u59cb\u7d22\u5f15\u5230 32767 \u7ed3\u675f\uff09\u3002\u4e0e BITMAP_BUCKET_NUMBER()
\u914d\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u552f\u4e00\u6807\u8bc6 bitmap \u4e2d\u7684\u4efb\u4f55\u6570\u5b57\u3002\u56e0\u4e3a\u5b9e\u9645 BITMAP_BIT_POSITION()
\u6807\u8bb0\u53c2\u6570\u7684\u4f4e 15 \u4f4d\uff08\u4ee5\u4e8c\u8fdb\u5236\u8868\u793a\uff09\uff0cBITMAP_BUCKET_NUMBER()
\u6807\u8bb0\u53c2\u6570\u7684\u9ad8\u4f4d\u3002
BITMAP_BIT_POSITION(numeric_expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_6","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e numeric_expr \u5fc5\u9700\u7684\u3002\u53ef\u4ee5 cast \u6210\u975e\u8d1f\u6574\u578b\u7684\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_7","title":"\u793a\u4f8b","text":"mysql> SELECT bitmap_bit_position(0);-- \u8fd4\u56de 0\uff0c\u56e0\u4e3a 0 \u5728\u7b2c\u4e00\u4e2a bucket \u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\n+------------------------+\n| bitmap_bit_position(0) |\n+------------------------+\n| 0 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bit_position(32767);-- \u8fd4\u56de 32767\uff0c\u56e0\u4e3a 32767 \u5728\u7b2c\u4e00\u4e2a bucket \u4e2d\u7684\u4f4d\u7f6e\u662f\u6700\u540e\u4e00\u4e2a\n+----------------------------+\n| bitmap_bit_position(32767) |\n+----------------------------+\n| 32767 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bit_position(32768);-- \u8fd4\u56de 0\uff0c\u56e0\u4e3a 32768 \u5728\u7b2c\u4e8c\u4e2a bucket \u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\n+----------------------------+\n| bitmap_bit_position(32768) |\n+----------------------------+\n| 0 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n--40000 \u7684\u4e8c\u8fdb\u5236\u4e3a\uff1a1001110001000000\uff0cbitmap_bit_position \u8bb0\u5f55\u4f4e 15 \u4f4d\uff1a001110001000000\uff0cbitmap_bucket_number \u8bb0\u5f55\u9ad8\u4f4d\uff1a1\nmysql> select bin(bitmap_bucket_number(40000)), bin(bitmap_bit_position(40000)),bin(40000);\n+----------------------------------+---------------------------------+------------------+\n| bin(bitmap_bucket_number(40000)) | bin(bitmap_bit_position(40000)) | bin(40000) |\n+----------------------------------+---------------------------------+------------------+\n| 1 | 1110001000000 | 1001110001000000 |\n+----------------------------------+---------------------------------+------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#bitmap_count","title":"BITMAP_COUNT","text":"BITMAP_COUNT()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97 bitmap \u4e2d\u8bbe\u7f6e\u4e3a 1 \u7684\u4f4d\u7684\u6570\u91cf\uff0c\u4ece\u800c\u5f97\u5230\u4e0d\u540c\u503c\u7684\u603b\u6570\u3002\u8fd9\u76f8\u5f53\u4e8e\u5bf9 bitmap \u6267\u884c COUNT(DISTINCT)
\u64cd\u4f5c\uff0c\u4f46\u901a\u5e38\u6bd4\u4f20\u7edf\u7684 COUNT(DISTINCT)
\u67e5\u8be2\u66f4\u5feb\u3002
BITMAP_COUNT()
\u51fd\u6570\u4e00\u822c\u7ed3\u5408\u4e0b\u8ff0\u7684 BITMAP_CONSTRUCT_AGG()
\u3001BITMAP_OR_AGG()
\u51fd\u6570\u4f7f\u7528\u3002
BITMAP_CONSTRUCT_AGG()
\u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u5b83\u5728\u6570\u636e\u5e93\u4e2d\u7528\u4e8e\u6784\u5efa bitmap\u3002
\u5f53\u9700\u8981\u5bf9\u4e00\u7ec4\u5bc6\u96c6\u7684\u975e\u91cd\u590d\u6574\u6570\u503c\u8fdb\u884c\u8ba1\u6570\u65f6\uff0cBITMAP_CONSTRUCT_AGG()
\u51fd\u6570\u975e\u5e38\u6709\u7528\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u9ad8\u6548\u5730\u5c06\u8fd9\u4e9b\u503c\u8f6c\u6362\u4e3a bitmap \u5f62\u5f0f\u3002
BITMAP_CONSTRUCT_AGG( <bit_position> )\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_9","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e bit_position \u5fc5\u9700\u7684\u3002\u5728 bitmap \u4e2d\u7684\u4f4d\u7f6e\uff08BITMAP_BIT_POSITION \u51fd\u6570\u8fd4\u56de\uff09"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_10","title":"\u793a\u4f8b","text":"CREATE TABLE t1 ( n1 int);\nINSERT INTO t1 VALUES(0),(1),(1),(32767);--\u63d2\u5165 [0,32767] \u5185\u7684\u6570\u636e\n\nmysql> select * from t1;\n+-------+\n| n1 |\n+-------+\n| 0 |\n| 1 |\n| 1 |\n| 32767 |\n+-------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1)) AS bitmap FROM t1;\n+------------------------+\n| bitmap |\n+------------------------+\n| :0 ? |\n+------------------------+\n1 row in set (0.00 sec)\n
Note
bitmap \u5217\u5305\u542b bitmap \u7684\u7269\u7406\u8868\u793a\u5f62\u5f0f\uff0c\u4e0d\u53ef\u8bfb\u3002\u4e3a\u4e86\u786e\u5b9a\u54ea\u4e9b\u4f4d\u88ab\u8bbe\u7f6e\uff0c\u6211\u4eec\u5e94\u7ed3\u5408\u4f7f\u7528 BITMAP
\u51fd\u6570\uff08\u800c\u4e0d\u662f\u81ea\u5df1\u68c0\u67e5\u4e8c\u8fdb\u5236\u503c\uff09\u3002
mysql> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS n1_discnt FROM t1;--bitmap \u4e2d\u8bbe\u7f6e\u4e3a 1 \u7684\u6570\u91cf\n+-----------+\n| n1_discnt |\n+-----------+\n| 3 |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT count(DISTINCT n1) AS n1_discnt FROM t1;--\u8fd4\u56de\u4e00\u81f4\n+-----------+\n| n1_discnt |\n+-----------+\n| 3 |\n+-----------+\n1 row in set (0.01 sec)\n\nINSERT INTO t1 VALUES(32768),(32769),(65535);--\u63d2\u5165\u5927\u4e8e 32767 \u7684\u6570\u636e\n\nmysql> select * from t1;\n+-------+\n| n1 |\n+-------+\n| 0 |\n| 1 |\n| 1 |\n| 32767 |\n| 32768 |\n| 32769 |\n| 65535 |\n+-------+\n7 rows in set (0.01 sec)\n\n--\u7ed3\u679c\u4e0e\u7b2c\u4e00\u6b21\u63d2\u5165\u4e00\u6837\uff0c\u56e0\u4e3a bucket_bit_position = n1 % 32768\uff0c\u7b2c\u4e8c\u6b21\u63d2\u5165\u7684\u6570\u636e\u4e0e\u7b2c\u4e00\u6b21\u63d2\u5165\u7684\u6570\u636e\u4f4d\u4e8e\u4e0d\u540c bucket \u7684\u76f8\u540c\u4f4d\u7f6e\uff0c\u6240\u4ee5\u88ab\u53bb\u91cd\u4e86\u3002\nmysql> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS n1_discnt FROM t1;\n+-----------+\n| t1_bitmap |\n+-----------+\n| 3 |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT bitmap_bit_position(0),bitmap_bit_position(1),bitmap_bit_position(32767),bitmap_bit_position(32768),bitmap_bit_position(65535);\n+------------------------+------------------------+----------------------------+----------------------------+----------------------------+\n| bitmap_bit_position(0) | bitmap_bit_position(1) | bitmap_bit_position(32767) | bitmap_bit_position(32768) | bitmap_bit_position(65535) |\n+------------------------+------------------------+----------------------------+----------------------------+----------------------------+\n| 0 | 1 | 32767 | 0 | 32767 |\n+------------------------+------------------------+----------------------------+----------------------------+----------------------------+\n1 row in set (0.00 sec)\n
\u56e0\u6b64\u5982\u679c\u8981\u5bf9\u5927\u4e8e 32767 \u7684\u6570\u636e\u53bb\u91cd\u9700\u7ed3\u5408 BITMAP_BUCKET_NUMBER()
\u51fd\u6570\u3002
--\u4ee5 bucket \u5206\u7ec4\uff0c\u7b2c\u4e00\u4e2a bucket \u91cc\u9762\u6709\u4e09\u4e2a\u975e\u91cd\u590d\u6570\uff080,1,32767),\u7b2c\u4e8c\u4e2a bucket \u91cc\u6709\u4e09\u4e2a\u975e\u91cd\u590d\u6570 (32768,32769,65535)\u3002\nmysql> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS t1_bitmap FROM t1 GROUP BY BITMAP_BUCKET_NUMBER(n1);\n+-----------+\n| t1_bitmap |\n+-----------+\n| 3 |\n| 3 |\n+-----------+\n2 rows in set (0.01 sec)\n\n--\u7ed3\u5408 sum() \u51fd\u6570\u8ba1\u7b97 n1 \u7684\u975e\u91cd\u590d\u503c\nmysql> SELECT SUM(t1_bitmap) FROM (\n-> SELECT bitmap_count(BITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(n1))) AS t1_bitmap\n-> FROM t1 -> GROUP BY BITMAP_BUCKET_NUMBER(n1)\n-> );\n+----------------+\n| sum(t1_bitmap) |\n+----------------+\n| 6 |\n+----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#bitmap_or_agg","title":"BITMAP_OR_AGG","text":"BITMAP_OR_AGG()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u591a\u4e2a bitmap \u7684\u6309\u4f4d\u6216\uff08OR\uff09\u7ed3\u679c\u3002\u901a\u5e38\u7528\u4e8e\u5408\u5e76\u591a\u4e2a bitmap\uff0c\u4ee5\u4fbf\u5728\u4e00\u4e2a bitmap \u4e2d\u8868\u793a\u6240\u6709\u8f93\u5165 bitmap \u7684\u7ec4\u5408\u4fe1\u606f\u3002
\u5f53\u9700\u8981\u5bf9\u4e0d\u540c\u7ef4\u5ea6\u7684\u6570\u636e\u8fdb\u884c\u96c6\u5408\u5e76\u96c6\u64cd\u4f5c\u65f6\uff0cBITMAP_OR_AGG()
\u5341\u5206\u6709\u7528\uff0c\u5c24\u5176\u662f\u5728\u6570\u636e\u4ed3\u5e93\u548c\u5206\u6790\u578b\u67e5\u8be2\u4e2d\u3002
BITMAP_OR_AGG( bitmap )\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_12","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e bitmap \u5fc5\u9700\u7684\u3002\u6240\u6709 bitmap \u6309\u4f4d\u6216\u5408\u5e76\u5f97\u5230\u7684 bitmap\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/bitmap/#_13","title":"\u793a\u4f8b","text":"--\u521b\u5efa\u4e00\u5f20\u8868\uff0c\u7528\u6765\u5b58\u50a8\u4f5c\u8005\u51fa\u7248\u4e66\u7c4d\u7684\u4fe1\u606f\uff0c\u5305\u542b\u4f5c\u8005\u540d\u79f0\uff0c\u51fa\u7248\u5e74\u4efd\u548c\u4e66\u7c4d id\nCREATE TABLE book_table(\nid int auto_increment primary key,\nauthor varchar(100),\npub_year varchar(100),\nbook_id int\n);\nINSERT INTO book_table(author,pub_year,book_id) VALUES\n('A \u4f5c\u8005','2020',1),('A \u4f5c\u8005','2020',1),('A \u4f5c\u8005','2020',32768),\n('A \u4f5c\u8005','2021',32767),('A \u4f5c\u8005','2021',32768),('A \u4f5c\u8005','2021',65536),\n('B \u4f5c\u8005','2020',2),('B \u4f5c\u8005','2020',10),('B \u4f5c\u8005','2020',32769),\n('B \u4f5c\u8005','2021',5),('B \u4f5c\u8005','2021',65539);\n\nmysql> select * from book_table;\n+------+----------+----------+---------+\n| id | author | pub_year | book_id |\n+------+----------+----------+---------+\n| 1 | A \u4f5c\u8005 | 2020 | 1 |\n| 2 | A \u4f5c\u8005 | 2020 | 1 |\n| 3 | A \u4f5c\u8005 | 2020 | 32768 |\n| 4 | A \u4f5c\u8005 | 2021 | 32767 |\n| 5 | A \u4f5c\u8005 | 2021 | 32768 |\n| 6 | A \u4f5c\u8005 | 2021 | 65536 |\n| 7 | B \u4f5c\u8005 | 2020 | 2 |\n| 8 | B \u4f5c\u8005 | 2020 | 10 |\n| 9 | B \u4f5c\u8005 | 2020 | 32769 |\n| 10 | B \u4f5c\u8005 | 2021 | 5 |\n| 11 | B \u4f5c\u8005 | 2021 | 65539 |\n+------+----------+----------+---------+\n11 rows in set (0.00 sec)\n\n--\u5b9a\u4e49\u4e00\u5f20\u9884\u8ba1\u7b97\u8868\uff0c\u628a\u7c97\u7c92\u5ea6\u7684\u8ba1\u7b97\u7ed3\u679c\u4fdd\u5b58\u5728\u8868\u4e2d\uff0c\u540e\u7eed\u5404\u79cd\u4e0d\u540c\u7ef4\u5ea6\u805a\u5408\u53ef\u4ee5\u4f7f\u7528\u9884\u8ba1\u7b97\u8868\u4e2d\u7684\u7ed3\u679c\uff0c\u7ecf\u8fc7\u7b80\u5355\u7684\u8ba1\u7b97\u5c31\u53ef\u4ee5\u5f97\u5230\u7ed3\u679c\uff0c\u52a0\u901f\u67e5\u8be2\u3002\nCREATE TABLE precompute AS\nSELECT\nauthor,\npub_year,\nBITMAP_BUCKET_NUMBER(book_id) as bucket,\nBITMAP_CONSTRUCT_AGG(BITMAP_BIT_POSITION(book_id)) as bitmap FROM book_table\nGROUP BY author,pub_year,bucket;\n\nmysql> select * from precompute;\n+---------+----------+--------+----------------------+\n| author | pub_year | bucket | bitmap |\n+---------+----------+--------+----------------------+\n| A\u4f5c\u8005 | 2020 | 0 | :0 |\n| A\u4f5c\u8005 | 2020 | 1 | :0 |\n| A\u4f5c\u8005 | 2021 | 0 | :0 ? |\n| A\u4f5c\u8005 | 2021 | 1 | :0 |\n| A\u4f5c\u8005 | 2021 | 2 | :0 |\n| B\u4f5c\u8005 | 2020 | 0 | :0 |\n| B\u4f5c\u8005 | 2020 | 1 | :0 |\n| B\u4f5c\u8005 | 2021 | 0 | :0 |\n| B\u4f5c\u8005 | 2021 | 2 | :0 |\n+---------+----------+--------+----------------------+\n\n--\u8ba1\u7b97\u5728\u4f5c\u8005\u548c\u51fa\u7248\u5e74\u4efd\u805a\u5408\u60c5\u51b5\u4e0b book_id \u7684\u53bb\u91cd\u6570\u91cf\uff0c\u53cd\u5e94\u7684\u662f\u4f5c\u8005\u5728\u4e0d\u540c\u5e74\u4efd\u51fa\u7248\u4e66\u7c4d\u7c7b\u578b\u7684\u6570\u91cf\u3002\n--sum() \u51fd\u6570\u7d2f\u52a0\u4e0d\u540c bucket \u7684 bitmap \u4e2d 1 \u7684\u6570\u91cf\u3002\n--\u4f8b\u5982\u5f53 author=A \u4f5c\u8005\uff0cpub_year=2020 \u65f6\uff0cbook_id=(1,1,32768)\uff0c\u53bb\u91cd\u540e\u4e3a book_id=(1,32768)\uff0c\u4f46\u662f 1 \u4f4d\u4e8e\u7b2c\u4e00\u4e2a bucket,32768 \u4f4d\u4e8e\u7b2c\u4e8c\u4e2a bucket\uff0c\u6240\u4ee5\u9700\u8981 sum \u4f5c\u7d2f\u52a0\u3002\nmysql> SELECT\n-> author,\n-> pub_year,\n-> SUM(BITMAP_COUNT(bitmap))\n-> FROM precompute\n-> GROUP BY author,pub_year;\n+---------+----------+---------------------------+\n| author | pub_year | sum(bitmap_count(bitmap)) |\n+---------+----------+---------------------------+\n| A\u4f5c\u8005 | 2020 | 2 |\n| A\u4f5c\u8005 | 2021 | 3 |\n| B\u4f5c\u8005 | 2020 | 3 |\n| B\u4f5c\u8005 | 2021 | 2 |\n+---------+----------+---------------------------+\n4 rows in set (0.00 sec)\n\nmysql> SELECT author,pub_year,count( DISTINCT book_id) FROM book_table group by author,pub_year;--\u8fd4\u56de\u4e00\u81f4\n+----------+----------+-------------------------+\n| author | pub_year | count(distinct book_id) |\n+----------+----------+-------------------------+\n| A \u4f5c\u8005 | 2020 | 2 |\n| A \u4f5c\u8005 | 2021 | 3 |\n| B \u4f5c\u8005 | 2020 | 3 |\n| B \u4f5c\u8005 | 2021 | 2 |\n+----------+----------+-------------------------+\n4 rows in set (0.00 sec)\n\n--\u8ba1\u7b97\u5728\u4f5c\u8005\u805a\u5408\u60c5\u51b5\u4e0b book_id \u7684\u53bb\u91cd\u6570\u91cf\uff0c\u53cd\u5e94\u7684\u662f\u4f5c\u8005\u4e00\u5171\u51fa\u7248\u4e66\u7c4d\u7c7b\u578b\u7684\u6570\u91cf\u3002\n--BITMAP_OR_AGG() \u51fd\u6570\u5408\u5e76\u4e0d\u540c\u7ef4\u5ea6\uff08\u76f8\u540c\u4f5c\u8005\u4e0d\u540c\u5e74\u4efd\uff09\u7684 bitmap\u3002\n--\u4f8b\u5982\u5f53 author=A \u4f5c\u8005\uff0cpub_date=2020 \u65f6\uff0cbook_id \u53bb\u91cd\u540e\u4e3a (1,32768)\uff0cpub_date=2021 \u65f6\uff0cbook_id \u53bb\u91cd\u540e\u4e3a (32767,32768,65536)\uff0cBITMAP_OR_AGG \u5bf9\u4e24\u4e2a\u4e0d\u540c\u5e74\u4efd\u7684 bitmap \u505a\u6216\u8fd0\u7b97\u5f97\u5230 book_id=(1,32767,32768,65536)\uff0c\u6700\u540e sum() \u7d2f\u52a0\u4e0d\u540c bucktet \u7684 book_id\u3002\nmysql> SELECT author, SUM(cnt) FROM (\n-> SELECT\n-> author,\n-> BITMAP_COUNT(BITMAP_OR_AGG(bitmap)) cnt\n-> FROM precompute\n-> GROUP BY author,bucket\n-> )\n-> GROUP BY author;\n+---------+----------+\n| author | sum(cnt) |\n+---------+----------+\n| A\u4f5c\u8005 | 4 |\n| B\u4f5c\u8005 | 5 |\n+---------+----------+\n2 rows in set (0.01 sec)\n\nmysql> SELECT author,count(DISTINCT book_id) FROM book_table GROUP BY author;--\u8fd4\u56de\u4e00\u81f4\n+----------+-------------------------+\n| author | count(distinct book_id) |\n+----------+-------------------------+\n| A \u4f5c\u8005 | 4 |\n| B \u4f5c\u8005 | 5 |\n+----------+-------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/","title":"COUNT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#n","title":"\u51fd\u6570\u8bf4\u660e n","text":"COUNT()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u8ba1\u7b97\u4e86\u67e5\u8be2\u7ed3\u679c\u7684\u8bb0\u5f55\u6570\uff0c\u7ed3\u679c\u662f\u4e00\u4e2a BIGINT \u503c\u3002\u5f53\u6ca1\u6709\u5339\u914d\u7684\u884c\u6216 COUNT(NULL)
\u65f6\u8fd4\u56de 0\u3002
> COUNT(expr)\n
> COUNT(distinct column)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#_2","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u67e5\u8be2\u7ed3\u679c\uff0c\u65e2\u53ef\u4ee5\u662f\u5217\u540d\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u51fd\u6570\u6216\u8005\u6570\u5b66\u8fd0\u7b97\u7684\u7ed3\u679c\u3002\u5f53\u4e0d\u5e26 distinct \u53c2\u6570\u65f6\u4e5f\u53ef\u4ee5\u4f7f\u7528`*`\uff0c\u76f4\u63a5\u7edf\u8ba1\u884c\u6570 distinct column \u5bf9\u5217\u4e2d\u91cd\u590d\u503c\u53bb\u91cd\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/count/#_3","title":"\u793a\u4f8b","text":"drop table if exists tbl1,tbl2;\ncreate table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\ninsert into tbl1 values (0,1,1,7,\"a\");\ninsert into tbl1 values (0,1,2,8,\"b\");\ninsert into tbl1 values (0,1,3,9,\"c\");\ninsert into tbl1 values (0,1,4,10,\"D\");\ninsert into tbl1 values (0,1,5,11,\"a\");\ninsert into tbl1 values (0,1,6,12,\"c\");\n\n> select count(col_1b) from tbl1;\n+---------------+\n| count(col_1b) |\n+---------------+\n| 6 |\n+---------------+\n\n> select count(*) from tbl1 where col_1d<10;\n+----------+\n| count(*) |\n+----------+\n| 3 |\n+----------+\n\nmysql> select count(distinct col_1b) from tbl1;\n+------------------------+\n| count(distinct col_1b) |\n+------------------------+\n| 1 |\n+------------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/","title":"GROUP_CONCAT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"GROUP_CONCAT
\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5b83\u5c06\u901a\u8fc7\u5217\u6216\u8005\u8868\u8fbe\u5f0f\u6307\u5b9a\u7684\u5185\u5bb9\u8fde\u63a5\u8d77\u6765\u3002
\u5982\u679c\u7ed3\u679c\u96c6\u6ca1\u6709\u4efb\u4f55\u884c\uff0c\u6b64\u51fd\u6570\u5c06\u8fd4\u56de NULL
\u3002
> GROUP_CONCAT(expr)\n
\u5b8c\u6574\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a
GROUP_CONCAT([DISTINCT] expr [,expr ...]\n [ORDER BY {unsigned_integer | col_name | expr}\n [ASC | DESC] [,col_name ...]]\n [SEPARATOR str_val])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u987b\u53c2\u6570\u3002\u5b83\u6307\u5b9a\u4e86\u8981\u8fde\u63a5\u7684\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5217\u6216\u8868\u8fbe\u5f0f\u3002 DISTINCT \u53ef\u9009\u53c2\u6570\u3002\u5b83\u7528\u4e8e\u6d88\u9664\u91cd\u590d\u503c\u3002 ORDER BY \u53ef\u9009\u53c2\u6570\u3002\u5b83\u7528\u4e8e\u5bf9\u8981\u8fde\u63a5\u7684\u5185\u5bb9\u6392\u5e8f\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5b83\u6309\u5347\u5e8f\u6392\u5e8f\u503c\u3002\u5982\u679c\u8981\u6309\u964d\u5e8f\u5bf9\u503c\u8fdb\u884c\u6392\u5e8f\uff0c\u5219\u9700\u8981\u660e\u786e\u6307\u5b9a DESC
\u9009\u9879\u3002 SEPARATOR \u53ef\u9009\u53c2\u6570\u3002\u8fde\u63a5\u7b26\u3002\u9ed8\u8ba4\u662f ,
\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/group-concat/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de\u503c\u662f\u4e00\u4e2a\u975e\u4e8c\u8fdb\u5236\u6216\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u8fd9\u53d6\u51b3\u4e8e\u53c2\u6570 expr
\u662f\u975e\u4e8c\u8fdb\u5236\u8fd8\u662f\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002
\u5982\u679c\u7ed3\u679c\u96c6\u6ca1\u6709\u4efb\u4f55\u884c\uff0c\u6b64\u51fd\u6570\u5c06\u8fd4\u56de NULL
\u3002
create table t1(a int,b text,c text);\ninsert into t1 values(1,\"a\",\"bc\"),(2,\"ab\",\"c\"),(3,\"aa\",\"bb\"),(3,\"aa\",\"bb\");\n\nmysql> select group_concat(distinct a,b,c separator '|') from t1;\n+-----------------------------------+\n| group_concat(distinct a, b, c, |) |\n+-----------------------------------+\n| 1abc|2abc|3aabb |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1 group by a;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc |\n| abc |\n| aabb |\n+--------------------------------+\n3 rows in set (0.01 sec)\n\nmysql> select group_concat(distinct b,c separator '|') from t1;\n+--------------------------------+\n| group_concat(distinct b, c, |) |\n+--------------------------------+\n| abc|abc|aabb |\n+--------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/","title":"MAX","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MAX()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u8ba1\u7b97\u4e86\u4e00\u7ec4\u503c\u7684\u6700\u5927\u503c\u3002
> MAX(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/max/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de expr
\u5217\u4e2d\u7684\u6700\u5927\u503c\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u5728 MAX()
\u4e2d\u4f7f\u7528\u5b57\u7b26\u4e32\uff0c\u5982\u6b64\u4f1a\u8fd4\u56de\u6700\u5927\u7684\u5b57\u7b26\u4e32\u503c\u3002
> drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select max(col_1d) from tbl1;\n+-------------+\n| max(col_1d) |\n+-------------+\n| 12 |\n+-------------+\n\n> select max(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1 |\n+------+\n| 5 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/","title":"MEDIAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MEDIAN()
\u7528\u4e8e\u8fd4\u56de\u4e00\u7ec4\u6570\u503c\u7684\u4e2d\u503c\uff0c\u5373\u5c06\u4e00\u7ec4\u6570\u503c\u6392\u5e8f\u540e\u8fd4\u56de\u5c45\u4e8e\u4e2d\u95f4\u7684\u6570\u503c\u3002\u5982\u679c\u53c2\u6570\u96c6\u5408\u4e2d\u5305\u542b\u5076\u6570\u4e2a\u6570\u503c\uff0c\u8be5\u51fd\u6570\u5c06\u8fd4\u56de\u4f4d\u4e8e\u4e2d\u95f4\u7684\u4e24\u4e2a\u6570\u7684\u5e73\u5747\u503c\u3002\u53ef\u4ee5\u5c06\u5176\u7528\u4f5c\u805a\u5408\u6216\u5206\u6790\u51fd\u6570\u3002
> MEDIAN(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u6307\u5b9a\u8981\u6c42\u4e2d\u503c\u7684\u6570\u7ec4\u540d\u79f0\uff0c\u53c2\u6570\u7c7b\u578b\u5c5e\u4e8e\u6570\u503c\u6570\u636e\u7c7b\u578b\u6216\u53ef\u4ee5\u9690\u5f0f\u8f6c\u6362\u4e3a\u6570\u5b57\u6570\u636e\u7c7b\u578b\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_4","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8be5\u51fd\u6570\u8fd4\u56de\u4e0e\u53c2\u6570\u7684\u6570\u503c\u6570\u636e\u7c7b\u578b\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/median/#_5","title":"\u793a\u4f8b","text":"mysql> select median(null);\n+--------------+\n| median(null) |\n+--------------+\n| NULL |\n+--------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1 (a int,b int);\ninsert into t1 values (1,null);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,1);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n| 1 |\n+-----------+\n1 row in set (0.01 sec)\n\ninsert into t1 values (1,2);\n\nmysql> select median(b) from t1;\n+-----------+\n| median(b) |\n+-----------+\n| 1.5 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n| 1.5 |\n+-----------+\n1 row in set (0.00 sec)\n\ninsert into t1 values (2,1),(2,2),(2,3),(2,4);\n\nmysql> select median(b) from t1 group by a order by a;\n+-----------+\n| median(b) |\n+-----------+\n| 1.5 |\n| 2.5 |\n+-----------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/","title":"MIN","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MIN()
\u662f\u805a\u5408\u51fd\u6570\u7684\u4e00\u79cd\uff0c\u8ba1\u7b97\u4e86\u4e00\u7ec4\u503c\u7684\u6700\u5c0f\u503c\u3002
> MIN(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/min/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de expr
\u5217\u4e2d\u7684\u6700\u5c0f\u503c\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u5728 MIN()
\u4e2d\u4f7f\u7528\u5b57\u7b26\u4e32\uff0c\u5982\u6b64\u4f1a\u8fd4\u56de\u6700\u5c0f\u7684\u5b57\u7b26\u4e32\u503c\u3002
> drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select min(col_1d) from tbl1;\n+-------------+\n| min(col_1d) |\n+-------------+\n| 7 |\n+-------------+\n\n> select min(col_1c) as m1 from tbl1 where col_1d<12 group by col_1e;\n+------+\n| m1 |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/","title":"STDDEV_POP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"STDDEV_POP(expr) \u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u603b\u4f53\u6807\u51c6\u5dee\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> STDDEV_POP(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/stddev_pop/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\n> INSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ), ('Mitchell Starc', 0, 3);\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n> SELECT STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n\n\n> SELECT STDDEV_POP(RunScored) as Pop_Standard_Deviation FROM t1;\n+------------------------+\n| Pop_Standard_Deviation |\n+------------------------+\n| 16.8762 |\n+------------------------+\n1 row in set (0.02 sec)\n\n> SELECT STDDEV_POP(WicketsTaken) as Pop_Std_Dev_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Dev_Wickets |\n+---------------------+\n| 0.9574 |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/","title":"SUM","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SUM()
\u805a\u5408\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e00\u7ec4\u503c\u7684\u548c\uff08NULL \u503c\u88ab\u5ffd\u7565\uff09\u3002
> SUM(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/sum/#_4","title":"\u8fd4\u56de\u503c","text":"\u8fd4\u56de expr
\u5217\u7684\u6570\u503c\u7684\u548c\uff0c\u82e5\u8f93\u5165\u53c2\u6570\u4e3a Double
\u7c7b\u578b\uff0c\u5219\u8fd4\u56de\u503c\u4e3a Double
\uff0c\u5426\u5219\u4e3a\u6574\u6570\u7c7b\u578b\u3002 \u5982\u679c\u6ca1\u6709\u5339\u914d\u7684\u884c\uff0c\u5219\u8fd4\u56de NULL
\u503c\u3002
> drop table if exists tbl1,tbl2;\n> create table tbl1 (col_1a tinyint, col_1b smallint, col_1c int, col_1d bigint, col_1e char(10) not null);\n> insert into tbl1 values (0,1,1,7,\"a\");\n> insert into tbl1 values (0,1,2,8,\"b\");\n> insert into tbl1 values (0,1,3,9,\"c\");\n> insert into tbl1 values (0,1,4,10,\"D\");\n> insert into tbl1 values (0,1,5,11,\"a\");\n> insert into tbl1 values (0,1,6,12,\"c\");\n\n> select sum(col_1c) from tbl1;\n+-------------+\n| sum(col_1c) |\n+-------------+\n| 21 |\n+-------------+\n\n> select sum(col_1d) as c1 from tbl1 where col_1d < 13 group by col_1e order by c1;\n+------+\n| c1 |\n+------+\n| 8 |\n| 10 |\n| 18 |\n| 21 |\n+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/","title":"VAR_POP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"VAR_POP()
\u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee\u3002\u4e0e VARIANCE()
\u4e3a\u540c\u4e49\u8bcd\u3002
> VAR_POP(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/var_pop/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\nINSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ), ('Mitchell Starc', 0, 3);\n\n-- \u8ba1\u7b97 RunScored \u5217\u7684\u65b9\u5dee\nmysql> SELECT VAR_POP(RunScored) as Pop_Standard_Variance FROM t1;\n+-----------------------+\n| Pop_Standard_Variance |\n+-----------------------+\n| 284.8055555555555 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n-- \u8ba1\u7b97 WicketsTaken \u5217\u7684\u65b9\u5dee\nmysql> SELECT VAR_POP(WicketsTaken) as Pop_Std_Var_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Var_Wickets |\n+---------------------+\n| 0.9166666666666665 |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/","title":"VARIANCE","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"VARIANCE(expr)
\u662f\u4e00\u4e2a\u805a\u5408\u51fd\u6570\uff0c\u8ba1\u7b97\u603b\u4f53\u65b9\u5dee\u3002\u65b9\u5dee\u662f\u7edf\u8ba1\u5b66\u4e2d\u7684\u4e00\u4e2a\u91cd\u8981\u6982\u5ff5\uff0c\u7528\u4e8e\u8861\u91cf\u4e00\u7ec4\u6570\u636e\u503c\u7684\u79bb\u6563\u7a0b\u5ea6\uff0c\u5373\u6570\u636e\u503c\u4e0e\u5176\u5e73\u5747\u503c\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u5982\u679c\u65b9\u5dee\u503c\u8f83\u5927\uff0c\u8bf4\u660e\u6570\u636e\u503c\u4e4b\u95f4\u7684\u5dee\u5f02\u8f83\u5927\uff1b\u53cd\u4e4b\uff0c\u5982\u679c\u65b9\u5dee\u503c\u8f83\u5c0f\uff0c\u8bf4\u660e\u6570\u636e\u503c\u4e4b\u95f4\u7684\u5dee\u5f02\u8f83\u5c0f\u3002
> VARIANCE(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u7684\u5217\u7684\u5217\u540d"},{"location":"MatrixOne/Reference/Functions-and-Operators/Aggregate-Functions/variance/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE t1(PlayerName VARCHAR(100) NOT NULL,RunScored INT NOT NULL,WicketsTaken INT NOT NULL);\nINSERT INTO t1 VALUES('KL Rahul', 52, 0 ),('Hardik Pandya', 30, 1 ),('Ravindra Jadeja', 18, 2 ),('Washington Sundar', 10, 1),('D Chahar', 11, 2 ), ('Mitchell Starc', 0, 3);\n\n-- \u8ba1\u7b97 RunScored \u5217\u7684\u65b9\u5dee\n> SELECT VARIANCE(RunScored) as Pop_Standard_Variance FROM t1;\n+-----------------------+\n| Pop_Standard_Variance |\n+-----------------------+\n| 284.8055555555555 |\n+-----------------------+\n1 row in set (0.01 sec)\n\n-- \u8ba1\u7b97 WicketsTaken \u5217\u7684\u65b9\u5dee\nmysql> SELECT VARIANCE(WicketsTaken) as Pop_Std_Var_Wickets FROM t1;\n+---------------------+\n| Pop_Std_Var_Wickets |\n+---------------------+\n| 0.9166666666666665 |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/","title":"CONVERT_TZ()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CONVERT_TZ()
\u51fd\u6570\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u65e5\u671f\u65f6\u95f4\u4ece\u4e00\u4e2a\u65f6\u533a\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u65f6\u533a\u3002\u5982\u679c\u53c2\u6570\u65e0\u6548\uff0c\u5219\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002
> CONVERT_TZ(dt,from_tz,to_tz)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e dt \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u7684\u7ed9\u5b9a\u65e5\u671f\u65f6\u95f4\u3002 from_tz \u5fc5\u8981\u53c2\u6570\u3002\u5f53\u524d\u65f6\u533a\u7684\u6807\u8bc6 to_tz \u5fc5\u8981\u53c2\u6570\u3002\u65b0\u7684\u65f6\u533a\u7684\u6807\u8bc6"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/convert-tz/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');\n+-------------------------------------------+\n| convert_tz(2004-01-01 12:00:00, GMT, MET) |\n+-------------------------------------------+\n| 2004-01-01 13:00:00 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT CONVERT_TZ('2004-01-01 12:00:00','+00:00','+10:00');\n+-------------------------------------------------+\n| convert_tz(2004-01-01 12:00:00, +00:00, +10:00) |\n+-------------------------------------------------+\n| 2004-01-01 22:00:00 |\n+-------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select convert_tz('2023-12-31 10:28:00','+08:00', 'America/New_York') as dtime;\n+---------------------+\n| dtime |\n+---------------------+\n| 2023-12-30 21:28:00 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> select convert_tz(NULL,'-05:00', '+05:30') as dtime;\n+-------+\n| dtime |\n+-------+\n| NULL |\n+-------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/","title":"CURDATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURDATE()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u7684 YYYY-MM-DD
\u683c\u5f0f\u7684\u503c\u3002
Note
\u4e0e MySQL \u884c\u4e3a\u4e0d\u540c\u7684\u662f\uff1acurdate()+int
\u8868\u793a\u5f53\u524d\u65e5\u671f\u81f3 1970-01-01 \u518d\u52a0\u4e0a int
\uff08\u5929\u6570\uff09\u7684\u603b\u5929\u6570\u3002\u6bd4\u5982\uff0ccurdate()+1
\u8868\u793a\u5f53\u524d\u65e5\u671f\u51cf\u53bb 1970-01-01 \u518d\u52a0 1 \u5929\u3002
> CURDATE()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/curdate/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT CURDATE();\n+------------+\n| curdate() |\n+------------+\n| 2023-02-02 |\n+------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT CURDATE() + 0;\n+---------------+\n| curdate() + 0 |\n+---------------+\n| 19390 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select cast(now() as date)=curdate() q;\n+------+\n| q |\n+------+\n| true |\n+------+\n1 row in set (0.01 sec)\n\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(3);\n\nmysql> select cast(now() as date)=curdate() q from t1;\n+------+\n| q |\n+------+\n| true |\n| true |\n| true |\n+------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/","title":"CURRENT_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURRENT_TIMESTAMP
\u548c CURRENT_TIMESTAMP()
\u662f NOW()
\u7684\u540c\u4e49\u8bcd\u3002
\u5c06\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss
\u6216 YYYYMMDDhhmmss
\u7684\u683c\u5f0f\u8fd4\u56de\uff0c\u8fd4\u56de\u683c\u5f0f\u53d6\u51b3\u4e8e\u51fd\u6570\u662f\u5b57\u7b26\u4e32\u8fd8\u662f\u6570\u5b57\u3002\u53d6\u503c\u4e3a\u5f53\u524d\u4f1a\u8bdd\u6240\u5728\u7684\u65f6\u533a\u3002
> CURRENT_TIMESTAMP([fsp])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u53ef\u9009\u3002\u53c2\u6570 fsp
\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u5206\u79d2\u7cbe\u5ea6\uff0c\u6709\u6548\u503c\u4e3a 0 \u5230 6 \u4e4b\u95f4\u7684\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT CURRENT_TIMESTAMP();\n+----------------------------+\n| current_timestamp() |\n+----------------------------+\n| 2022-09-21 11:46:44.153777 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT NOW();\n+----------------------------+\n| now() |\n+----------------------------+\n| 2022-09-21 12:56:36.915961 |\n+----------------------------+\n1 row in set (0.01 sec)\n
create table t1 (a int primary key, b int, c int, d timestamp default current_timestamp);\ninsert into t1 select 1,1,1,now();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a | b | c | year(d) |\n+------+------+------+---------+\n| 1 | 1 | 1 | 2022 |\n| 2 | 0 | 0 | NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/current-timestamp/#_5","title":"\u9650\u5236","text":"\u8fd0\u7b97\u7b26 +
\u6216 -
\u73b0\u5728\u4e0d\u652f\u6301\u4e0e CURRENT_TIMESTAMP
\u4e00\u8d77\u4f7f\u7528\u3002
DATE_ADD()
\u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1aDATE_ADD()
\u51fd\u6570\u5411\u65e5\u671f\u6dfb\u52a0\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u51fd\u6570\u8fd4\u56de NULL
\u3002
> DATE_ADD(date,INTERVAL expr unit)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 expr \u5fc5\u8981\u53c2\u6570\u3002expr \u53c2\u6570\u662f\u9700\u8981\u6dfb\u52a0\u8fdb date \u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982\u679c expr \u4e3a\u8d1f\u6570\uff0c\u90a3\u4e48\u53ef\u4ee5\u4ee5\u201c-\u201d\u5f00\u5934\u3002 unit \u5fc5\u8981\u53c2\u6570\u3002unit \u53c2\u6570\u53ef\u4ee5\u662f\u4e0b\u5217\u503c\uff1aMICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#_4","title":"\u793a\u4f8b","text":"create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_ADD(OrderDate,INTERVAL 45 DAY) AS OrderPayDate FROM t2;\n+---------+---------------------+\n| orderid | orderpaydate |\n+---------+---------------------+\n| 1 | 2008-12-26 13:23:45 |\n+---------+---------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-add/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65e5\u671f\u503c\u3002\u5982\u679c\u4efb\u4e00\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u51fd\u6570\u8fd4\u56de NULL
\u3002
DATE_FORMAT()
\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d\u5305\u542b\u7531 character_set_connection
\u548c collat\u200b\u200bion_connection
\u7ed9\u51fa\u7684\u5b57\u7b26\u96c6\u548c\u6392\u5e8f\u89c4\u5219\uff0c\u4ee5\u4fbf\u5b83\u53ef\u4ee5\u8fd4\u56de\u5305\u542b\u975e ASCII \u5b57\u7b26\u7684\u6708\u4efd\u548c\u5de5\u4f5c\u65e5\u540d\u79f0\u3002
> DATE_FORMAT(date,format)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 format \u5fc5\u8981\u53c2\u6570\u3002Required. format \u53ef\u7528\u7684\u8bf4\u660e\u7b26\u53ef\u4ee5\u53c2\u52a0\u4e0b\u8868\u8be6\u60c5\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#format","title":"Format \u8bf4\u660e\u7b26","text":"Info
\u4e0b\u8868\u4e2d\u663e\u793a\u7684\u8bf4\u660e\u7b26\u53ef\u7528\u4e8e\u683c\u5f0f\u5b57\u7b26\u4e32\u3002\u5728\u683c\u5f0f\u8bf4\u660e\u7b26\u5b57\u7b26\u4e4b\u524d\u9700\u8981\u52a0 %
\u5b57\u7b26\u3002\u8bf4\u660e\u7b26\u4e5f\u9002\u7528\u4e8e\u51fd\u6570 UNIX_TIMESTAMP()
\u3002
mysql> SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');\n+--------------------------------------------+\n| date_format(2009-10-04 22:23:00, %W %M %Y) |\n+--------------------------------------------+\n| Sunday October 2009 |\n+--------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');\n+--------------------------------------------+\n| date_format(2007-10-04 22:23:00, %H:%i:%s) |\n+--------------------------------------------+\n| 22:23:00 |\n+--------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT Date_format('1900-10-04 22:23:00', '%D %y %a %d %m %b %j');\n+--------------------------------------------------------+\n| date_format(1900-10-04 22:23:00, %D %y %a %d %m %b %j) |\n+--------------------------------------------------------+\n| 4th 00 Thu 04 10 Oct 277 |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1997-10-04 22:23:00', '%H %k %I %r %T %S %w');\n+--------------------------------------------------------+\n| date_format(1997-10-04 22:23:00, %H %k %I %r %T %S %w) |\n+--------------------------------------------------------+\n| 22 22 10 10:23:00 PM 22:23:00 00 6 |\n+--------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT('1999-01-01', '%X %V');\n+--------------------------------+\n| date_format(1999-01-01, %X %V) |\n+--------------------------------+\n| 1998 52 |\n+--------------------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t2 (f1 DATETIME);\nINSERT INTO t2 (f1) VALUES ('2005-01-01');\nINSERT INTO t2 (f1) VALUES ('2005-02-01');\n\nmysql> SELECT Date_format(f1, \"%m\") AS d1,\nDate_format(f1, \"%m\") AS d2\nFROM t2\nORDER BY Date_format(f1, \"%m\");\n+------+------+\n| d1 | d2 |\n+------+------+\n| 01 | 01 |\n| 02 | 02 |\n+------+------+\n2 rows in set (0.00 sec)\n
CREATE TABLE t5 (a int, b date);\nINSERT INTO t5\nVALUES (1,\n'2000-02-05'),\n(2,\n'2000-10-08'),\n(3,\n'2005-01-03'),\n(4,\n'2007-09-01'),\n(5,\n'2022-01-01');\n\nmysql> SELECT * FROM t5\nWHERE b = Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a | b |\n+------+------------+\n| 1 | 2000-02-05 |\n+------+------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT * FROM t5\nWHERE b != Date_format('20000205', '%Y-%m-%d');\n+------+------------+\n| a | b |\n+------+------------+\n| 2 | 2000-10-08 |\n| 3 | 2005-01-03 |\n| 4 | 2007-09-01 |\n| 5 | 2022-01-01 |\n+------+------------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT DATE_FORMAT(\"2009-01-01\",'%W %d %M %Y') as valid_date;\n+--------------------------+\n| valid_date |\n+--------------------------+\n| Thursday 01 January 2009 |\n+--------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-format/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
DATE_SUB()
\u7528\u4e8e\u6267\u884c\u65e5\u671f\u8fd0\u7b97\uff1aDATE_SUB()
\u51fd\u6570\u4ece date \u65e5\u671f\u4e2d\u51cf\u53bb\u6307\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u51fd\u6570\u8fd4\u56de NULL
\u3002
DATE_SUB(date,INTERVAL expr unit)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 expr \u5fc5\u8981\u53c2\u6570\u3002expr \u53c2\u6570\u662f\u9700\u8981\u6dfb\u52a0\u8fdb date \u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982\u679c expr \u4e3a\u8d1f\u6570\uff0c\u90a3\u4e48\u53ef\u4ee5\u4ee5\u201c-\u201d\u5f00\u5934\u3002 unit \u5fc5\u8981\u53c2\u6570\u3002unit \u53c2\u6570\u53ef\u4ee5\u662f\u4e0b\u5217\u503c\uff1aMICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#_4","title":"\u793a\u4f8b","text":"create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT OrderId,DATE_SUB(OrderDate,INTERVAL 5 DAY) AS SubtractDate FROM t2;\n+---------+---------------------+\n| orderid | subtractdate |\n+---------+---------------------+\n| 1 | 2008-11-06 13:23:45 |\n+---------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date-sub/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u5c06 DATE
\u6216\u8005 DATETIME
\u683c\u5f0f\u7684\u8f93\u5165\u4e2d\u7684\u65e5\u671f\u90e8\u5206\u622a\u53d6\u51fa\u6765\u3002
> DATE(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u63d0\u53d6\u65e5\u671f\u7684 date \u6216\u8005 datetime \u683c\u5f0f\u7684\u8f93\u5165\u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01');\ninsert into t1 values('20220101','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59');\n\nmysql> select date(a),date(b) from t1;\n+------------+------------+\n| date(a) | date(b) |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-30 |\n| 2022-06-30 | 2021-12-30 |\n+------------+------------+\n5 rows in set (0.01 sec)\n\nmysql> select date(a),date(date(a)) as dda from t1;\n+------------+------------+\n| date(a) | dda |\n+------------+------------+\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-01 | 2022-01-01 |\n| 2022-01-02 | 2022-01-02 |\n| 2021-12-31 | 2021-12-31 |\n| 2022-06-30 | 2022-06-30 |\n+------------+------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/date/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
DATEDIFF()
\u51fd\u6570\u8fd4\u56de\u4e24\u4e2a\u65e5\u671f\u4e4b\u95f4\u7684\u5929\u6570\u3002
> DATEDIFF(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr1, expr2 \u5fc5\u8981\u53c2\u6570\u3002expr1 \u548c expr2 \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u6216\u65e5\u671f/\u65f6\u95f4\u8868\u8fbe\u5f0f\u3002\u53ea\u6709\u503c\u7684\u65e5\u671f\u90e8\u5206\u53c2\u4e0e\u8ba1\u7b97\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/datediff/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30');\n+-------------------------------------------+\n| datediff(2007-12-31 23:59:59, 2007-12-30) |\n+-------------------------------------------+\n| 1 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATEDIFF('2010-11-30 23:59:59','2010-12-31');\n+-------------------------------------------+\n| datediff(2010-11-30 23:59:59, 2010-12-31) |\n+-------------------------------------------+\n| -31 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n
create table t1(a INT, b date);\ninsert into t1 values(1, \"2012-10-11\");\ninsert into t1 values(2, \"2004-04-24\");\ninsert into t1 values(3, \"2008-12-04\");\ninsert into t1 values(4, \"2012-03-23\");\ninsert into t1 values(5, \"2000-03-23\");\ninsert into t1 values(6, \"2030-03-23\");\ninsert into t1 values(7, \"2040-03-23\");\n\nmysql> SELECT a, DATEDIFF('2022-10-9', b) from t1;\n+------+------------------------+\n| a | datediff(2022-10-9, b) |\n+------+------------------------+\n| 1 | 3650 |\n| 2 | 6742 |\n| 3 | 5057 |\n| 4 | 3852 |\n| 5 | 8235 |\n| 6 | -2722 |\n| 7 | -6375 |\n+------+------------------------+\n7 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/","title":"DAY()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u67d0\u65e5\u671f\u4e3a\u5f53\u6708\u7684\u7b2c\u51e0\u53f7\uff0c\u8303\u56f4\u4e3a 1 \u5230 31\uff1b\u5bf9\u4e8e\u8bf8\u5982 0000-00-00
\u6216 2008-00-00
\u7b49\u5305\u542b 0 \u90e8\u5206\u7684\u65e5\u671f\uff0c\u5219\u8fd4\u56de 0\u3002\u5982\u679c\u65e5\u671f\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> DAY(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/day/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT day('2007-02-03');\n+-----------------+\n| day(2007-02-03) |\n+-----------------+\n| 3 |\n+-----------------+\n1 row in set (0.01 sec)\n
CREATE TABLE t3(c1 TIMESTAMP NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\n\nmysql> SELECT day(c1) from t3;\n+---------+\n| day(c1) |\n+---------+\n| 1 |\n| 31 |\n| 1 |\n| 25 |\n| 29 |\n+---------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/","title":"DAYOFYEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u65e5\u671f\u6240\u5bf9\u5e94\u5728\u4e00\u5e74\u4e2d\u7684\u5929\u6570\uff0c\u8fd4\u56de\u503c\u5728 1-366 \u4e4b\u95f4\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> DAYOFYEAR(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u63d0\u53d6\u5929\u6570\u7684 date \u683c\u5f0f\u7684\u8f93\u5165\u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a date, b datetime,c varchar(30));\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values('2022-01-01','2022-01-01 01:01:01','2022-01-01 01:01:01');\ninsert into t1 values('20220101','2022-01-01 01:01:01','2022-13-13 01:01:01');\ninsert into t1 values('2022-01-02','2022-01-02 23:01:01','2022-01-01 23:01:01');\ninsert into t1 values('2021-12-31','2021-12-30 23:59:59','2021-12-30 23:59:59');\ninsert into t1 values('2022-06-30','2021-12-30 23:59:59','2021-12-30 23:59:59');\n\nmysql> select distinct dayofyear(a) as dya from t1;\n+------+\n| dya |\n+------+\n| 1 |\n| 2 |\n| 365 |\n| 181 |\n+------+\n4 rows in set (0.00 sec)\n\nmysql> select * from t1 where dayofyear(a)>120;\n+------------+---------------------+---------------------+\n| a | b | c |\n+------------+---------------------+---------------------+\n| 2021-12-31 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1 where dayofyear(a) between 1 and 184;\n+------------+---------------------+---------------------+\n| a | b | c |\n+------------+---------------------+---------------------+\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-01-01 01:01:01 |\n| 2022-01-01 | 2022-01-01 01:01:01 | 2022-13-13 01:01:01 |\n| 2022-01-02 | 2022-01-02 23:01:01 | 2022-01-01 23:01:01 |\n| 2022-06-30 | 2021-12-30 23:59:59 | 2021-12-30 23:59:59 |\n+------------+---------------------+---------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/dayofyear/#_5","title":"\u9650\u5236","text":"DAYOFYEAR()
\u53ea\u652f\u6301 date
\u7c7b\u578b\u3002date
\u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002 EXTRACT()
\u51fd\u6570\u662f\u4ece\u65e5\u671f\u4e2d\u63d0\u53d6\u90e8\u5206\u5185\u5bb9\u3002\u5982\u679c\u65e5\u671f\u662f NULL
\u5219\u8fd4\u56de NULL\u3002
> EXTRACT(unit FROM date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 unit \u5fc5\u8981\u53c2\u6570\u3002unit \u53c2\u6570\u53ef\u4ee5\u662f\u4e0b\u5217\u503c\uff1aMICROSECOND SECONDMINUTEHOURDAYWEEKMONTHQUATERYEARSECOND_MICROSECONDMINUTE_MICROSECONDMINUTE_SECONDHOUR_MICROSECONDHOUR_SECONDHOUR_MINUTEDAY_MICROSECONDDAY_SECONDDAY_MINUTEDAY_HOURYEAR_MONTH"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#_4","title":"\u793a\u4f8b","text":"create table t2(orderid int, productname varchar(20), orderdate datetime);\ninsert into t2 values ('1','Jarl','2008-11-11 13:23:44.657');\n\nmysql> SELECT EXTRACT(YEAR FROM OrderDate) AS OrderYear, EXTRACT(MONTH FROM OrderDate) AS OrderMonth FROM t2 WHERE OrderId=1;\n+-----------+------------+\n| orderyear | ordermonth |\n+-----------+------------+\n| 2008 | 11 |\n+-----------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/extract/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
FROM_UNIXTIME()
\u51fd\u6570\u628a\u5185\u90e8 UNIX \u65f6\u95f4\u6233\u503c\u8f6c\u6362\u4e3a\u666e\u901a\u683c\u5f0f\u7684\u65e5\u671f\u65f6\u95f4\u503c\uff0c\u4ee5 YYYY-MM-DD HH:MM:SS \u6216 YYYYMMDDHHMMSS \u683c\u5f0f\u6765\u663e\u793a\u3002\u4e0e UNIX_TIMESTAMP ()
\u51fd\u6570\u4e92\u4e3a\u53cd\u51fd\u6570\u3002
> FROM_UNIXTIME(unix_timestamp[,format])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e format \u53ef\u9009\u53c2\u6570\u3002\u8868\u793a\u8fd4\u56de\u503c\u683c\u5f0f\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\u3002 \u5982\u679c\u7701\u7565 format\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a DATETIME
\u503c\u3002 \u5982\u679c format \u4e3a\u7a7a\uff0c\u5219\u8fd4\u56de NULL
\u3002format \u7528\u4e8e\u683c\u5f0f\u5316\u7ed3\u679c\uff0c\u5176\u65b9\u5f0f\u4e0e DATE_FORMAT()
\u51fd\u6570\u4f7f\u7528\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\u76f8\u540c\u3002\u5982\u679c format \u5df2\u5b58\u5728\u6307\u5b9a\u683c\u5f0f\uff0c\u5219\u8fd4\u56de\u503c\u4e3a VARCHAR
\u3002 unix_timestamp \u5fc5\u8981\u53c2\u6570\u3002\u65f6\u95f4\u6233\uff0c\u53ef\u4ee5\u7528\u6570\u636e\u5e93\u91cc\u7684\u5b58\u50a8\u65f6\u95f4\u6570\u636e\u7684\u5b57\u6bb5\u3002\u5982\u679c unix_timestamp \u4e3a\u7a7a\uff0c\u5219\u8fd4\u56de NULL
\u3002 \u5982\u679c unix_timestamp \u662f\u4e00\u4e2a\u6574\u6570\uff0c\u5219 DATETIME
\u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\u4e3a\u96f6\u3002\u5f53 unix_timestamp \u662f\u5341\u8fdb\u5236\u503c\u65f6\uff0cDATETIME
\u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\u4e0e\u5341\u8fdb\u5236\u503c\u7684\u7cbe\u5ea6\u76f8\u540c\uff0c\u6700\u591a\u53ef\u8fbe 6 \u79d2\u3002\u5f53 unix_timestamp
\u662f\u6d6e\u70b9\u6570\u65f6\uff0cdatetime
\u7684\u5206\u79d2\u7cbe\u5ea6\u4e3a 6\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT FROM_UNIXTIME(1447430881);\n+---------------------------+\n| from_unixtime(1447430881) |\n+---------------------------+\n| 2015-11-14 00:08:01 |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1447430881, '%Y %D %M %h:%i:%s %x');\n+-------------------------------------------------+\n| from_unixtime(1447430881, %Y %D %M %h:%i:%s %x) |\n+-------------------------------------------------+\n| 2015 14th November 12:08:01 2015 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/from-unixtime/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u8fd4\u56de\u65f6\u95f4\u7684\u5c0f\u65f6\u3002\u5bf9\u4e8e\u65f6\u95f4\u503c\uff0c\u8fd4\u56de\u503c\u7684\u8303\u56f4\u662f 0 \u5230 23\u3002\u4f46\u662f\uff0ctime
\u503c\u7684\u8303\u56f4\u5b9e\u9645\u4e0a\u8981\u5927\u5f97\u591a\uff0c\u56e0\u6b64 HOUR
\u53ef\u4ee5\u8fd4\u56de\u5927\u4e8e 23 \u7684\u503c\u3002\u5982\u679c time
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> HOUR(time)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e time \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u65f6\u95f4\u6216\u65f6\u95f4\u6233\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/hour/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select hour(a),hour(b) from t1;\n+---------+---------+\n| hour(a) | hour(b) |\n+---------+---------+\n| 0 | 12 |\n| 12 | 0 |\n| NULL | 23 |\n| 0 | NULL |\n| 14 | 0 |\n| 0 | 12 |\n| 0 | 0 |\n+---------+---------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where hour(a)>hour(b);\n+---------------------+---------------------+\n| a | b |\n+---------------------+---------------------+\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/","title":"MINUTE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de time
\u7684\u5206\u949f\uff0c\u53d6\u503c\u8303\u56f4\u4e3a 0 \u5230 59\uff0c\u5982\u679c time
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> MINUTE(time)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e time \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u65f6\u95f4\u6216\u65f6\u95f4\u6233\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/minute/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT MINUTE('2008-02-03 10:05:03');\n+-----------------------------+\n| minute(2008-02-03 10:05:03) |\n+-----------------------------+\n| 5 |\n+-----------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select minute(a),minute(b) from t1;\n+-----------+-----------+\n| minute(a) | minute(b) |\n+-----------+-----------+\n| 0 | 0 |\n| 32 | 0 |\n| NULL | 10 |\n| 0 | NULL |\n| 11 | 0 |\n| 0 | 0 |\n| 0 | 0 |\n+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select * from t1 where minute(a)<=minute(b);\n+---------------------+---------------------+\n| a | b |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/","title":"MONTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u65e5\u671f\u7684\u6708\u4efd\uff0c\u5bf9\u4e8e 1 \u6708\u5230 12 \u6708\uff0c\u8fd4\u56de\u8303\u56f4\u4e3a 1 \u5230 12\uff1b\u5bf9\u4e8e\u201c0000-00-00\u201d\u6216\u201c2008-00-00\u201d\u7b49\u65e5\u671f\uff0c\u8fd4\u56de 0 \u6708\u4efd\u3002\u5982\u679c date
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> MONTH(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/month/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT MONTH('2008-02-03');\n+-------------------+\n| month(2008-02-03) |\n+-------------------+\n| 2 |\n+-------------------+\n1 row in set (0.02 sec)\n
drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select month(d),month(dt) from t1;\n+----------+-----------+\n| month(d) | month(dt) |\n+----------+-----------+\n| 1 | 1 |\n| 1 | 1 |\n| 2 | 2 |\n| 2 | 2 |\n| 2 | 2 |\n| 3 | 2 |\n| 4 | 4 |\n| 5 | 5 |\n| 6 | 6 |\n| 7 | 7 |\n| 8 | 8 |\n| 9 | 9 |\n| 10 | 10 |\n| 11 | 11 |\n| 12 | 12 |\n| NULL | NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n\nmysql> select month(c),month(vc) from t1;\n+----------+-----------+\n| month(c) | month(vc) |\n+----------+-----------+\n| 12 | 12 |\n| 12 | 12 |\n| 2 | 2 |\n| 2 | 2 |\n| 2 | 2 |\n| 3 | 3 |\n| 4 | 4 |\n| 5 | 5 |\n| 6 | 6 |\n| 7 | 7 |\n| 8 | 8 |\n| 9 | 9 |\n| 10 | 10 |\n| 11 | 11 |\n| 12 | 12 |\n| NULL | NULL |\n+----------+-----------+\n16 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/","title":"NOW()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"NOW()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002
NOW()
\u8fd4\u56de\u8bed\u53e5\u5f00\u59cb\u6267\u884c\u7684\u65f6\u95f4\u3002\u8fd9\u4e0e SYSDATE()
\u7684\u884c\u4e3a\u4e0d\u540c\uff0c\u540e\u8005\u8fd4\u56de\u6267\u884c\u8fc7\u7a0b\u4e2d\u52a8\u6001\u7684\u5b9e\u65f6\u65f6\u95f4\u3002
> NOW(fsp)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u975e\u5fc5\u8981\u53c2\u6570\u3002\u5982\u679c\u7ed9\u5b9a fsp \u53c2\u6570\u4ee5\u6307\u5b9a\u4ece 0 \u5230 6 \u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\uff0c\u5219\u8fd4\u56de\u503c\u5305\u62ec\u8be5\u6570\u5b57\u7684\u5c0f\u6570\u79d2\u90e8\u5206\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/now/#_4","title":"\u793a\u4f8b","text":"mysql> select now();\n+----------------------------+\n| now() |\n+----------------------------+\n| 2024-04-29 08:03:50.479238 |\n+----------------------------+\n1 row in set (0.03 sec)\n\nmysql> select now(6);\n+----------------------------+\n| now(6) |\n+----------------------------+\n| 2024-04-29 08:05:26.528629 |\n+----------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT NOW(), SLEEP(2), NOW();\n+----------------------------+----------+----------------------------+\n| now() | sleep(2) | now() |\n+----------------------------+----------+----------------------------+\n| 2024-04-29 08:17:23.876546 | 0 | 2024-04-29 08:17:23.876546 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.06 sec)\n\nmysql> SELECT SYSDATE(), SLEEP(2), SYSDATE();\n+----------------------------+----------+----------------------------+\n| sysdate() | sleep(2) | sysdate() |\n+----------------------------+----------+----------------------------+\n| 2024-04-29 16:19:21.439725 | 0 | 2024-04-29 16:19:23.440187 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/","title":"SECOND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de time
\u4e2d\u79d2\u7684\u503c\uff0c\u53d6\u503c\u8303\u56f4\u4e3a 0 \u5230 59\uff0c\u5982\u679c time
\u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> SECOND(time)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e time \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u65f6\u95f4\u6216\u65f6\u95f4\u6233\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/second/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a datetime, b timestamp);\ninsert into t1 values(\"2022-07-01\", \"2011-01-31 12:00:00\");\ninsert into t1 values(\"2011-01-31 12:32:11\", \"1979-10-22\");\ninsert into t1 values(NULL, \"2022-08-01 23:10:11\");\ninsert into t1 values(\"2011-01-31\", NULL);\ninsert into t1 values(\"2022-06-01 14:11:09\",\"2022-07-01 00:00:00\");\ninsert into t1 values(\"2022-12-31\",\"2011-01-31 12:00:00\");\ninsert into t1 values(\"2022-06-12\",\"2022-07-01 00:00:00\");\n\nmysql> select second(a),second(b) from t1;\n+-----------+-----------+\n| second(a) | second(b) |\n+-----------+-----------+\n| 0 | 0 |\n| 11 | 0 |\n| NULL | 11 |\n| 0 | NULL |\n| 9 | 0 |\n| 0 | 0 |\n| 0 | 0 |\n+-----------+-----------+\n7 rows in set (0.01 sec)\n\nmysql> select * from t1 where second(a)>=second(b);\n+---------------------+---------------------+\n| a | b |\n+---------------------+---------------------+\n| 2022-07-01 00:00:00 | 2011-01-31 12:00:00 |\n| 2011-01-31 12:32:11 | 1979-10-22 00:00:00 |\n| 2022-06-01 14:11:09 | 2022-07-01 00:00:00 |\n| 2022-12-31 00:00:00 | 2011-01-31 12:00:00 |\n| 2022-06-12 00:00:00 | 2022-07-01 00:00:00 |\n+---------------------+---------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/","title":"STR_TO_DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"STR_TO_DATE()
\u51fd\u6570\u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b\uff0c\u4e0e TO_DATE()
\u540c\u4e49\u3002
\u683c\u5f0f\u5b57\u7b26\u4e32\u53ef\u4ee5\u5305\u542b\u6587\u5b57\u5b57\u7b26\u548c\u4ee5%\u5f00\u5934\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\u3002format \u4e2d\u7684\u5b57\u9762\u5b57\u7b26\u4e0e\u683c\u5f0f\u8bf4\u660e\u7b26\u5fc5\u987b\u4e0e str \u5339\u914d\uff0c\u652f\u6301\u8868\u8fbe\u5f0f\u3002\u5982\u679c\u4e0d\u80fd\u6309\u7167 format \u89e3\u6790 str \u6216\u8005\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL\uff0cSTR_TO_DATE
\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002
\u6709\u5173\u53ef\u4ee5\u4f7f\u7528\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\uff0c\u8bf7\u53c2\u9605 DATE_FORMAT()
\u51fd\u6570\u63cf\u8ff0\u3002
> STR_TO_DATE(str,format)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u8981\u683c\u5f0f\u5316\u4e3a\u65e5\u671f\u7684\u5b57\u7b26\u4e32 (\u8f93\u5165\u5b57\u7b26\u4e32) format \u8981\u4f7f\u7528\u7684\u683c\u5f0f\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/str-to-date/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT STR_TO_DATE('2022-01-06 10:20:30','%Y-%m-%d %H:%i:%s') as result;\n+---------------------+\n| result |\n+---------------------+\n| 2022-01-06 10:20:30 |\n+---------------------+\n1 row in set (0.00 sec) mysql> SELECT STR_TO_DATE('09:30:17','%h:%i:%s');\n+---------------------------------+\n| str_to_date(09:30:17, %h:%i:%s) |\n+---------------------------------+\n| 09:30:17 |\n+---------------------------------+\n1 row in set (0.00 sec)\n\n-- format \u53c2\u6570\u652f\u6301\u8868\u8fbe\u5f0f\nmysql> SELECT str_to_date('2008-01-01',replace('yyyy-MM-dd','yyyy-MM-dd','%Y-%m-%d')) as result;\n+------------+\n| result |\n+------------+\n| 2008-01-01 |\n+------------+\n1 row in set (0.00 sec)\n\n--STR_TO_DATE \u51fd\u6570\u5728\u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32 format \u89e3\u6790\u8f93\u5165\u5b57\u7b26\u4e32 str \u65f6\uff0c\u5ffd\u7565\u8f93\u5165\u5b57\u7b26\u4e32 str \u672b\u5c3e\u7684\u989d\u5916\u5b57\u7b26\nmysql> SELECT STR_TO_DATE('25,5,2022 extra characters','%d,%m,%Y'); +---------------------------------------------------+\n| str_to_date(25,5,2022 extra characters, %d,%m,%Y) |\n+---------------------------------------------------+\n| 2022-05-25 |\n+---------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT STR_TO_DATE('2022','%Y');\n+-----------------------+\n| str_to_date(2022, %Y) |\n+-----------------------+\n| NULL |\n+-----------------------\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/","title":"SYSDATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SYSDATE()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u7684 'YYYY-MM-DD HH:MM:SS' \u683c\u5f0f\u7684\u503c\u3002
SYSDATE()
\u8fd4\u56de\u6267\u884c\u8fc7\u7a0b\u4e2d\u52a8\u6001\u7684\u5b9e\u65f6\u65f6\u95f4\u3002\u8fd9\u4e0e NOW()
\u7684\u884c\u4e3a\u4e0d\u540c\uff0c\u540e\u8005\u8fd4\u56de\u8bed\u53e5\u5f00\u59cb\u6267\u884c\u7684\u65f6\u95f4\u3002
> SYSDATE(fsp)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u975e\u5fc5\u8981\u53c2\u6570\u3002\u5982\u679c\u7ed9\u5b9a fsp \u53c2\u6570\u4ee5\u6307\u5b9a\u4ece 0 \u5230 6 \u7684\u5c0f\u6570\u79d2\u7cbe\u5ea6\uff0c\u5219\u8fd4\u56de\u503c\u5305\u62ec\u8be5\u6570\u5b57\u7684\u5c0f\u6570\u79d2\u90e8\u5206\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/sysdate/#_4","title":"\u793a\u4f8b","text":"mysql> select sysdate();\n+----------------------------+\n| sysdate() |\n+----------------------------+\n| 2024-04-30 10:49:39.554807 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sysdate(6);\n+----------------------------+\n| sysdate(6) |\n+----------------------------+\n| 2024-04-30 10:50:08.452370 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT SYSDATE(), SLEEP(2), SYSDATE();\n+----------------------------+----------+----------------------------+\n| sysdate() | sleep(2) | sysdate() |\n+----------------------------+----------+----------------------------+\n| 2024-04-30 10:50:30.004912 | 0 | 2024-04-30 10:50:32.005203 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.00 sec)\n\nmysql> SELECT NOW(), SLEEP(2), NOW();\n+----------------------------+----------+----------------------------+\n| now() | sleep(2) | now() |\n+----------------------------+----------+----------------------------+\n| 2024-04-30 10:50:47.904309 | 0 | 2024-04-30 10:50:47.904309 |\n+----------------------------+----------+----------------------------+\n1 row in set (2.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/","title":"TIME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u63d0\u53d6\u65f6\u95f4\u6216\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f expr
\u7684\u65f6\u95f4\u90e8\u5206\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u5982\u679c expr
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> TIME(expr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u63d0\u53d6\u65f6\u95f4\u7684 date \u6216\u8005 datetime \u683c\u5f0f\u7684\u8f93\u5165\u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/time/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TIME('2003-12-31 01:02:03');\n+---------------------------+\n| time(2003-12-31 01:02:03) |\n+---------------------------+\n| 01:02:03 |\n+---------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/","title":"TIMEDIFF()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TIMEDIFF()
\u8fd4\u56de\u4e24\u4e2a TIME
\u6216 DATETIME
\u503c\u4e4b\u95f4\u7684\u5dee\u503c\u3002TIMEDIFF()
\u51fd\u6570\u7684\u4e24\u4e2a\u8868\u8fbe\u5f0f\u5fc5\u987b\u4e3a\u76f8\u540c\u7c7b\u578b\u7684\u53c2\u6570\uff0c\u5373 TIME
\u6216 DATETIME
\u3002TIMEDIFF
\u51fd\u6570\u8fd4\u56de\u8868\u793a\u4e3a\u65f6\u95f4\u503c\u7684 expr1 - expr2
\u7684\u7ed3\u679c\u3002
> TIMEDIFF(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr1, expr2 \u5fc5\u8981\u53c2\u6570\u3002expr1 \u548c expr2 \u8868\u8fbe\u5f0f\u9700\u8981\u5177\u6709\u76f8\u540c\u7684\u7c7b\u578b\u3002expr1 \u548c expr2 \u662f\u8f6c\u6362\u4e3a TIME \u6216 DATETIME \u8868\u8fbe\u5f0f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c expr1 \u6216 expr2 \u4e3a NULL \u5219\u8fd4\u56de NULL\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timediff/#_4","title":"\u793a\u4f8b","text":"mysql> select timediff(\"22:22:22\", \"11:00:00\");\n+------------------------------+\n| timediff(22:22:22, 11:00:00) |\n+------------------------------+\n| 11:22:22.000000 |\n+------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select timediff(cast('22:22:22' as time), null);\n+--------------------------------------------+\n| timediff(cast(22:22:22 as time(26)), null) |\n+--------------------------------------------+\n| NULL |\n+--------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select timediff(CAST('2017-08-08 22:22:22' as datetime), CAST('2000-01-02 11:00:00' as datetime));\n+------------------------------------------------------------------------------------------------+\n| timediff(cast(2017-08-08 22:22:22 as datetime(26)), cast(2000-01-02 11:00:00 as datetime(26))) |\n+------------------------------------------------------------------------------------------------+\n| 154283:22:22 |\n+------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
create table time_01(t1 time,t2 time,t3 time);\ninsert into time_01 values(\"-838:59:59.0000\",\"838:59:59.00\",\"22:00:00\");\ninsert into time_01 values(\"0:00:00.0000\",\"0\",\"0:00\");\ninsert into time_01 values(null,NULL,null);\ninsert into time_01 values(\"23\",\"1122\",\"-1122\");\ninsert into time_01 values(\"101412\",\"4\",\"-101219\");\ninsert into time_01 values(\"24:59:09.932823\",\"24:02:00.93282332424\",\"24:20:34.00000000\");\ninsert into time_01 values(\"2022-09-08 12:00:01\",\"019\",\"23403\");\n\nmysql> select * from time_01;\n+------------+-----------+-----------+\n| t1 | t2 | t3 |\n+------------+-----------+-----------+\n| -838:59:59 | 838:59:59 | 22:00:00 |\n| 00:00:00 | 00:00:00 | 00:00:00 |\n| NULL | NULL | NULL |\n| 00:00:23 | 00:11:22 | -00:11:22 |\n| 10:14:12 | 00:00:04 | -10:12:19 |\n| 24:59:10 | 24:02:01 | 24:20:34 |\n| 12:00:01 | 00:00:19 | 02:34:03 |\n+------------+-----------+-----------+\n7 rows in set (0.00 sec)\n\nmysql> select timediff(t1,t2) from time_01;\n+------------------+\n| timediff(t1, t2) |\n+------------------+\n| -1677:59:58 |\n| 00:00:00 |\n| NULL |\n| -00:10:59 |\n| 10:14:08 |\n| 00:57:09 |\n| 11:59:42 |\n+------------------+\n7 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/","title":"TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5355\u4e2a\u53c2\u6570\u65f6\uff0cTIMESTAMP()
\u5c06\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f expr \u4f5c\u4e3a\u65e5\u671f\u65f6\u95f4\u503c\u8fd4\u56de\u3002\u4e24\u4e2a\u53c2\u6570\u65f6\uff0cTIMESTAMP()
\u5c06\u65f6\u95f4\u8868\u8fbe\u5f0f expr2 \u6dfb\u52a0\u5230\u65e5\u671f\u6216 datetime \u8868\u8fbe\u5f0f expr1 \u4e2d\uff0c\u5e76\u5c06\u7ed3\u679c\u4f5c\u4e3a datetime \u503c\u8fd4\u56de\u3002\u5982\u679c expr\u3001expr1 \u6216 expr2 \u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> TIMESTAMP(expr), TIMESTAMP(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002expr \u53c2\u6570\u662f\u9700\u8981\u6dfb\u52a0\u8fdb date \u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982\u679c expr \u4e3a\u8d1f\u6570\uff0c\u90a3\u4e48\u53ef\u4ee5\u4ee5\u201c-\u201d\u5f00\u5934\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TIMESTAMP('2003-12-31');\n+----------------------------+\n| timestamp(2003-12-31) |\n+----------------------------+\n| 2003-12-31 00:00:00.000000 |\n+----------------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t1(c1 DATE NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT TIMESTAMP(c1) FROM t1;\n+----------------------------+\n| timestamp(c1) |\n+----------------------------+\n| 2000-01-01 00:00:00.000000 |\n| 1999-12-31 00:00:00.000000 |\n| 2000-01-01 00:00:00.000000 |\n| 2006-12-25 00:00:00.000000 |\n| 2008-02-29 00:00:00.000000 |\n+----------------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestamp/#_5","title":"\u9650\u5236","text":"TIMESTAMP()
\u6682\u4e0d\u652f\u6301\u53cc\u53c2\u6570\uff0c\u5373\u6682\u4e0d\u652f\u6301 TIMESTAMP(expr1,expr2)
\u3002
TIMESTAMPEDIFF()
\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u5728\u7ed9\u5b9a\u7684\u65f6\u95f4\u5355\u4f4d\u5185\uff0c\u4ece\u7b2c\u4e00\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u5230\u7b2c\u4e8c\u4e2a\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5373 datetime_expr2
\u4e0e datetime_expr1
\u7684\u5dee\u503c\u3002datetime_expr1
\u548c datetime_expr2
\u662f\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u8868\u8fbe\u5f0f\uff1b\u4e00\u4e2a\u8868\u8fbe\u5f0f\u53ef\u4ee5\u662f\u65e5\u671f\uff0c\u53e6\u4e00\u4e2a\u8868\u8fbe\u5f0f\u53ef\u4ee5\u662f\u65e5\u671f\u65f6\u95f4\uff0c\u65e5\u671f\u503c\u88ab\u89c6\u4e3a\u5177\u6709\u65f6\u95f4\u90e8\u5206 00:00:00
\u7684\u65e5\u671f\u65f6\u95f4\u3002
\u5982\u679c datetime_expr1
\u6216 datetime_expr2
\u4e3a NULL
\uff0c\u5219\u6b64\u51fd\u6570\u8fd4\u56de NULL
\u3002
> TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e unit \u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u65f6\u95f4\u95f4\u9694\u7684\u5355\u4f4d\u3002\u8fd9\u53ef\u4ee5\u662f MICROSECOND
\u3001SECOND
\u3001MINUTE
\u3001HOUR
\u3001DAY
\u3001WEEK
\u3001MONTH
\u6216 YEAR
\u7b49\u3002 datetime_expr1,datetime_expr2 \u5fc5\u8981\u53c2\u6570\u3002datetime_expr1 \u548c datetime_expr2 \u8868\u8fbe\u5f0f\u9700\u8981\u5177\u6709\u76f8\u540c\u7684\u7c7b\u578b\u3002datetime_expr1 \u548c datetime_expr2 \u662f\u8f6c\u6362\u4e3a TIME
\u6216 DATETIME
\u8868\u8fbe\u5f0f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c datetime_expr1 \u6216 datetime_expr2 \u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/timestampdiff/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TIMESTAMPDIFF( MICROSECOND, '2017-12-01 12:15:12','2018-01-01 7:18:20');\n+---------------------------------------------------------------------+\n| timestampdiff(microsecond, 2017-12-01 12:15:12, 2018-01-01 7:18:20) |\n+---------------------------------------------------------------------+\n| 2660588000000 |\n+---------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a date, b date);\ninsert into t1 values('2019-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2019-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2020-10-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2021-11-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2022-01-01 12:15:12', '2018-01-01 12:15:12');\ninsert into t1 values('2018-01-01 12:15:12', '2019-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2019-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2020-10-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2021-11-01 12:15:12');\ninsert into t1 values( '2018-01-01 12:15:12', '2022-01-01 12:15:12');\n\nmysql> SELECT a, b, TIMESTAMPDIFF(MICROSECOND, a, b) from t1;\n+------------+------------+----------------------------------+\n| a | b | timestampdiff(microsecond, a, b) |\n+------------+------------+----------------------------------+\n| 2019-11-01 | 2018-01-01 | -57801600000000 |\n| 2019-10-01 | 2018-01-01 | -55123200000000 |\n| 2020-10-01 | 2018-01-01 | -86745600000000 |\n| 2021-11-01 | 2018-01-01 | -120960000000000 |\n| 2022-01-01 | 2018-01-01 | -126230400000000 |\n| 2018-01-01 | 2019-11-01 | 57801600000000 |\n| 2018-01-01 | 2019-10-01 | 55123200000000 |\n| 2018-01-01 | 2020-10-01 | 86745600000000 |\n| 2018-01-01 | 2021-11-01 | 120960000000000 |\n| 2018-01-01 | 2022-01-01 | 126230400000000 |\n+------------+------------+----------------------------------+\n10 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/","title":"TO_DATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_DATE()
\u51fd\u6570\u6309\u7167\u6307\u5b9a\u65e5\u671f\u6216\u65f6\u95f4\u663e\u793a\u683c\u5f0f\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4\u7c7b\u578b\uff0c\u4e0e STR_TO_DATE()
\u540c\u4e49\u3002
\u683c\u5f0f\u5b57\u7b26\u4e32\u53ef\u4ee5\u5305\u542b\u6587\u5b57\u5b57\u7b26\u548c\u4ee5%\u5f00\u5934\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\u3002format \u4e2d\u7684\u5b57\u9762\u5b57\u7b26\u4e0e\u683c\u5f0f\u8bf4\u660e\u7b26\u5fc5\u987b\u4e0e str \u5339\u914d\uff0c\u5982\u679c\u4e0d\u80fd\u6309\u7167 format \u89e3\u6790 str \u6216\u8005\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL\uff0cTO_DATE
\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002
\u6709\u5173\u53ef\u4ee5\u4f7f\u7528\u7684\u683c\u5f0f\u8bf4\u660e\u7b26\uff0c\u8bf7\u53c2\u9605 DATE_FORMATE()
\u51fd\u6570\u63cf\u8ff0\u3002
> TO_DATE(str,format)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u8981\u683c\u5f0f\u5316\u4e3a\u65e5\u671f\u7684\u5b57\u7b26\u4e32 (\u8f93\u5165\u5b57\u7b26\u4e32) format \u8981\u4f7f\u7528\u7684\u683c\u5f0f\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-date/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TO_DATE('2022-01-06 10:20:30','%Y-%m-%d %H:%i:%s') as result;\n+---------------------+\n| result |\n+---------------------+\n| 2022-01-06 10:20:30 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DATE('2022/11/01','%Y/%m/%d');\n+-------------------------------+\n| to_date(2022/11/01, %Y/%m/%d) |\n+-------------------------------+\n| 2022-11-01 |\n+-------------------------\n\n-- format \u53c2\u6570\u652f\u6301\u8868\u8fbe\u5f0f\nmysql> SELECT to_date('2008-01-01',replace('yyyy-MM-dd','yyyy-MM-dd','%Y-%m-%d')) as result;\n+------------+\n| result |\n+------------+\n| 2008-01-01 |\n+------------+\n1 row in set (0.01 sec)\n\n--TO_DATE \u51fd\u6570\u5728\u6839\u636e\u683c\u5f0f\u5b57\u7b26\u4e32 format \u89e3\u6790\u8f93\u5165\u5b57\u7b26\u4e32 str \u65f6\uff0c\u5ffd\u7565\u8f93\u5165\u5b57\u7b26\u4e32 str \u672b\u5c3e\u7684\u989d\u5916\u5b57\u7b26\nmysql> SELECT TO_DATE('25,5,2022 extra characters','%d,%m,%Y'); +-----------------------------------------------+\n| to_date(25,5,2022 extra characters, %d,%m,%Y) |\n+-----------------------------------------------+\n| 2022-05-25 |\n+-----------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DATE('2022','%Y');\n+-------------------+\n| to_date(2022, %Y) |\n+-------------------+\n| NULL |\n+-------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/","title":"TO_DAYS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_DAYS()
\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u4e0e\u516c\u5386\u65e5\u5386\u7684\u5f00\u59cb\u65e5\u671f\uff080000 \u5e74 1 \u6708 1 \u65e5\uff09\u4e4b\u95f4\u7684\u5929\u6570\u5dee\u3002\u5982\u679c date
\u662f NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
Note
0000-00-00
\u548c 0000-01-01
\u8be5\u65e5\u671f\u672c\u8eab\u88ab\u89c6\u4e3a\u65e0\u6548\u3002MatrixOne \u5e74\u4efd\u67e5\u8be2\u5e94\u8be5\u4ece 0001
\u5e74\u5f00\u59cb\u3002\u67e5\u8be2 0000-00-00
\u548c 0000-01-01
\uff0cTO_DAYS()
\u8fd4\u56de\u62a5\u9519\u4fe1\u606f\uff1a
mysql> SELECT TO_DAYS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-00-00\nmysql> SELECT TO_DAYS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-01-01\n
\u5bf9\u4e8e\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\uff0c\u4f8b\u5982\u67e5\u8be2 SELECT TO_DAYS('08-10-07');
\uff0cMatrixOne \u5c06\u5e74\u4efd 08 \u81ea\u52a8\u8865\u5168\u4e3a 0008\uff0c\u4e0e MySQL \u4e0d\u540c\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\u3002
> TO_DAYS(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-days/#_3","title":"\u793a\u4f8b","text":"-- \u67e5\u8be2\u5c06\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u65e5\u671f'2023-07-12'\u4e0e\u516c\u5386\u65e5\u5386\u5f00\u59cb\u65e5\u671f\u4e4b\u95f4\u7684\u5929\u6570\u5dee\u3002\nmysql> SELECT TO_DAYS('2023-07-12');\n+---------------------+\n| to_days(2023-07-12) |\n+---------------------+\n| 739078 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_DAYS('2008-10-07'), TO_DAYS('08-10-07');\n+---------------------+-------------------+\n| to_days(2008-10-07) | to_days(08-10-07) |\n+---------------------+-------------------+\n| 733687 | 3202 |\n+---------------------+-------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/","title":"TO_SECONDS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/to-seconds/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_SECONDS(expr)
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u6216\u65e5\u671f\u65f6\u95f4 expr \u4e0e\u516c\u5143 0 \u5e74 1 \u6708 1 \u65e5 0 \u65f6 0 \u5206 0 \u79d2\u4e4b\u95f4\u7684\u79d2\u6570\u5dee\u3002\u5982\u679c expr
\u662f NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
Note
0000-00-00
\u548c 0000-01-01
\u65e5\u671f\u672c\u8eab\u88ab\u89c6\u4e3a\u65e0\u6548\u3002MatrixOne \u5e74\u4efd\u67e5\u8be2\u5e94\u8be5\u4ece 0001
\u5e74\u5f00\u59cb\u3002\u67e5\u8be2 0000-00-00
\u548c 0000-01-01
\uff0cTO_SECONDS()
\u8fd4\u56de\u62a5\u9519\u4fe1\u606f\uff1a
mysql> SELECT TO_SECONDS('0000-00-00');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-00-00\nmysql> SELECT TO_SECONDS('0000-01-01');\nERROR 20301 (HY000): invalid input: invalid datatime value 0000-01-01\n
\u4e0e TO_DAYS()
\u51fd\u6570\u76f8\u4f3c\uff0c\u4f8b\u5982\u67e5\u8be2 SELECT TO_SECONDS('08-10-07');
\uff0cMatrixOne \u5c06\u5e74\u4efd 08 \u81ea\u52a8\u8865\u5168\u4e3a 0008\uff0c\u4e0e MySQL \u4e0d\u540c\u3002\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u65e5\u671f\u4e2d\u7684\u4e24\u4f4d\u6570\u5e74\u4efd\u3002
> TO_SECONDS(expr)\n
expr
\u662f\u65e5\u671f\u65f6\u95f4\u503c\uff0c\u53ef\u4ee5\u662f DATETIME
\u3001DATE
\u6216 TIMESTAMP
\u7c7b\u578b\u3002
mysql> SELECT TO_SECONDS('0001-01-01');\n+------------------------+\n| to_seconds(0001-01-01) |\n+------------------------+\n| 31622400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2023-07-12 08:30:00');\n+---------------------------------+\n| to_seconds(2023-07-12 08:30:00) |\n+---------------------------------+\n| 63856369800 |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('2007-10-07');\n+------------------------+\n| to_seconds(2007-10-07) |\n+------------------------+\n| 63358934400 |\n+------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_SECONDS('97-10-07');\n+----------------------+\n| to_seconds(97-10-07) |\n+----------------------+\n| 3085257600 |\n+----------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/","title":"UNIX_TIMESTAMP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UNIX_TIMESTAMP()
\u8fd4\u56de\u81ea 1970-01-01 00:00:00 UTC \u81f3\u5f53\u524d\u65f6\u95f4\u7684\u79d2\u6570\u3002
UNIX_TIMESTAMP(date)
\u5c06\u53c2\u6570\u7684\u503c\u8fd4\u56de\u4e3a 1970-01-01 00:00:00 UTC \u81f3 date \u6307\u5b9a\u65f6\u95f4\u7684\u79d2\u6570\u3002
\u5982\u679c\u65e5\u671f\u8d85\u51fa\u8303\u56f4\u4f20\u9012\u7ed9 UNIX_TIMESTAMP()
\uff0c\u5b83\u5c06\u8fd4\u56de 0\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
\u5982\u679c\u6ca1\u6709\u7ed9\u51fa\u53c2\u6570\u6216\u53c2\u6570\u4e0d\u5305\u542b\u5c0f\u6570\u79d2\u90e8\u5206\uff0c\u5219\u8fd4\u56de\u503c\u4e3a\u6574\u6570\uff1b\u5982\u679c\u7ed9\u51fa\u53c2\u6570\u5305\u542b\u5c0f\u6570\u79d2\u90e8\u5206\uff0c\u5219\u8fd4\u56de\u503c\u4e3a DECIMAL
\u3002
> UNIX_TIMESTAMP([date])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u53ef\u9009\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002 date \u53c2\u6570\u53ef\u4ee5\u662f DATE
\u3001DATETIME
\u6216 TIMESTAMP
\u5b57\u7b26\u4e32\uff0c\u4e5f\u53ef\u4ee5\u662f YYMMDD\u3001YYMMDDhhmmss\u3001YYYYMMDD \u6216 YYYYMMDDhhmmss \u683c\u5f0f\u7684\u6570\u5b57\u3002\u5982\u679c date \u53c2\u6570\u5305\u542b\u65f6\u95f4\u90e8\u5206\uff0c\u5219\u5b83\u6709\u9009\u62e9\u5730\u5305\u542b\u79d2\u7684\u5c0f\u6570\u90e8\u5206\u3002 \u5f53 date \u53c2\u6570\u662f TIMESTAMP
\u65f6\uff0cUNIX_TIMESTAMP()
\u76f4\u63a5\u8fd4\u56de\u5185\u90e8\u65f6\u95f4\u6233\u503c\uff0c\u800c\u4e0d\u8fdb\u884c\u9690\u542b\u7684 string-to-Unix-timestamp \u8f6c\u6362\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#utc-unix","title":"\u975e UTC \u65f6\u533a\u7684\u503c\u548c Unix \u65f6\u95f4\u6233\u503c\u4e4b\u95f4\u7684\u8f6c\u6362","text":"\u5982\u679c\u4f7f\u7528 UNIX_TIMESTAMP()
\u548c FROM_UNIXTIME()
\u5728\u975e UTC\uff08Coordinated Universal Time\uff0c\u534f\u8c03\u4e16\u754c\u65f6\uff09\u65f6\u533a\u7684\u503c\u548c Unix \u65f6\u95f4\u6233\u503c\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362\uff0c\u5219\u8f6c\u6362\u662f\u6709\u635f\u7684\uff0c\u56e0\u4e3a\u6620\u5c04\u5728\u4e24\u4e2a\u65b9\u5411\u4e0a\u4e0d\u662f\u4e00\u5bf9\u4e00\u7684\u3002\u4f8b\u5982\uff0c\u7531\u4e8e\u8bf8\u5982\u590f\u4ee4\u65f6 (DST) \u7b49\u672c\u5730\u65f6\u533a\u66f4\u6539\u7684\u7ea6\u5b9a\uff0cUNIX_TIMESTAMP()
\u53ef\u4ee5\u5c06\u5728\u975e UTC \u65f6\u533a\u4e2d\u4e0d\u540c\u7684\u4e24\u4e2a\u503c\u6620\u5c04\u5230\u76f8\u540c\u7684 Unix \u65f6\u95f4\u6233\u503c\u3002FROM_UNIXTIME()
\u5c06\u8be5\u503c\u4ec5\u6620\u5c04\u56de\u539f\u59cb\u503c\u4e4b\u4e00\u3002\u4e0b\u9762\u7684\u793a\u4f8b\uff0c\u5373\uff0c\u4f7f\u7528\u5728 MET
\u65f6\u533a\u4e0d\u540c\u7684\u503c\uff1a
mysql> SET time_zone = 'MET';\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 03:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 03:00:00) |\n+-------------------------------------+\n| 1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2005-03-27 02:00:00');\n+-------------------------------------+\n| unix_timestamp(2005-03-27 02:00:00) |\n+-------------------------------------+\n| 1111885200 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FROM_UNIXTIME(1111885200);\n+---------------------------+\n| from_unixtime(1111885200) |\n+---------------------------+\n| 2005-03-27 03:00:00 |\n+---------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT UNIX_TIMESTAMP(\"2016-07-11\");\n+----------------------------+\n| unix_timestamp(2016-07-11) |\n+----------------------------+\n| 1468188000 |\n+----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19');\n+-------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19) |\n+-------------------------------------+\n| 1447406419 |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT UNIX_TIMESTAMP('2015-11-13 10:20:19.012');\n+-----------------------------------------+\n| unix_timestamp(2015-11-13 10:20:19.012) |\n+-----------------------------------------+\n| 1447406419.012000 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/unix-timestamp/#_5","title":"\u9650\u5236","text":"\u76ee\u524d date \u683c\u5f0f\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
\u5c06\u5f53\u524d UTC \u65f6\u95f4\u4ee5 YYYY-MM-DD hh:mm:ss
\u6216 YYYYMMDDhhmmss
\u7684\u683c\u5f0f\u8fd4\u56de\uff0c\u8fd4\u56de\u683c\u5f0f\u53d6\u51b3\u4e8e\u51fd\u6570\u662f\u5728\u5b57\u7b26\u4e32\u8fd8\u662f\u6570\u5b57\u3002
> UTC_TIMESTAMP, UTC_TIMESTAMP([fsp])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e fsp \u53ef\u9009\u3002\u53c2\u6570 fsp
\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u5206\u79d2\u7cbe\u5ea6\uff0c\u6709\u6548\u503c\u4e3a 0 \u5230 6 \u4e4b\u95f4\u7684\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT UTC_TIMESTAMP();\n+---------------------+\n| utc_timestamp() |\n+---------------------+\n| 2022-09-16 03:37:40 |\n+---------------------+\n1 row in set (0.01 sec)\n\nmysql> select unix_timestamp(utc_timestamp());\n+---------------------------------+\n| unix_timestamp(utc_timestamp()) |\n+---------------------------------+\n| 1663282842 |\n+---------------------------------+\n1 row in set (0.02 sec)\n
create table t1 (ts timestamp);\nset time_zone='+00:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n| 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='+10:30';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(utc_timestamp());\n+-------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(utc_timestamp()) |\n+-------------------------------------------------------------------+\n| 0 |\n+-------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\nset time_zone='-10:00';\n\nmysql> select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());\n+-----------------------------------------------------------------------+\n| unix_timestamp(utc_timestamp()) - unix_timestamp(current_timestamp()) |\n+-----------------------------------------------------------------------+\n| 36000 |\n+-----------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1 (ts) values ('2003-03-30 02:30:00');\n\nmysql> select * from t1;\n+---------------------+\n| ts |\n+---------------------+\n| 2003-03-29 16:30:00 |\n| 2003-03-29 06:00:00 |\n| 2003-03-30 02:30:00 |\n+---------------------+\n3 rows in set (0.00 sec)\n
DROP TABLE IF EXISTS t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT year(a) FROM t1 WHERE a > '2008-01-01';\n+---------+\n| year(a) |\n+---------+\n| 2022 |\n| 2022 |\n| 2022 |\n+---------+\n3 rows in set (0.04 sec)\n
DROP TABLE if exists t1;\ncreate table t1 (a int primary key, b int, c int, d timestamp);\ninsert into t1 select 1,1,1,utc_timestamp();\ninsert into t1 select 2,0,0,null;\n\nmysql> select a,b,c,year(d) from t1;\n+------+------+------+---------+\n| a | b | c | year(d) |\n+------+------+------+---------+\n| 1 | 1 | 1 | 2022 |\n| 2 | 0 | 0 | NULL |\n+------+------+------+---------+\n2 rows in set (0.01 sec)\n
DROP TABLE if exists t1;\nCREATE TABLE t1 (a TIMESTAMP);\nINSERT INTO t1 select (utc_timestamp());\nINSERT INTO t1 select (utc_timestamp());\n\nmysql> SELECT 1 FROM t1 ORDER BY 1;\n+------+\n| 1 |\n+------+\n| 1 |\n| 1 |\n+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/utc-timestamp/#_5","title":"\u9650\u5236","text":"\u6682\u4e0d\u652f\u6301\u64cd\u4f5c\u7b26 +
\u6216 -
\u5bf9 DATETIME BIGINT
\u53c2\u6570\u8fdb\u884c\u8fd0\u7b97\u3002
\u7528\u4e8e\u8ba1\u7b97\u7ed9\u5b9a\u65e5\u671f\u7684\u5468\u6570\u3002\u8be5\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u6307\u5b9a\u65e5\u671f\u6240\u5728\u7684\u5468\u6570\u3002\u5982\u679c date
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> WEEK(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002\u8868\u793a\u8981\u8ba1\u7b97\u5468\u6570\u7684\u65e5\u671f\u3002MatrixOne \u9ed8\u8ba4\u4e00\u5468\u7684\u8d77\u59cb\u65e5\u4e3a\u661f\u671f\u4e00\uff0c\u8fd4\u56de\u503c\u7684\u8303\u56f4\u4e3a 0 \u5230 53\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT WEEK('2008-02-20');\n+------------------+\n| week(2008-02-20) |\n+------------------+\n| 8 |\n+------------------+\n1 row in set (0.01 sec)\n
drop table if exists t1;\nCREATE TABLE t1(c1 DATETIME NOT NULL);\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('1999-12-31');\nINSERT INTO t1 VALUES('2000-01-01');\nINSERT INTO t1 VALUES('2006-12-25');\nINSERT INTO t1 VALUES('2008-02-29');\n\nmysql> SELECT WEEK(c1) FROM t1;\n+----------+\n| week(c1) |\n+----------+\n| 52 |\n| 52 |\n| 52 |\n| 52 |\n| 9 |\n+----------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/week/#_5","title":"\u9650\u5236","text":"MatrixOne \u7684 WEEK()
\u51fd\u6570\u4ec5\u652f\u6301 date
\u53c2\u6570\uff0c\u4e0d\u652f\u6301\u53ef\u9009\u53c2\u6570 [, mode]
\uff0c\u8fd9\u4e00\u70b9\u662f\u4e0e MySQL \u662f\u4e0d\u540c\u7684\u3002
\u8fd4\u56de\u65e5\u671f\u7684\u5de5\u4f5c\u65e5\u7d22\u5f15\uff080 = \u661f\u671f\u4e00\uff0c1 = \u661f\u671f\u4e8c\uff0c... 6 = \u661f\u671f\u65e5\uff09\u3002\u5982\u679c\u65e5\u671f\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> WEEKDAY(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\u3002date \u53c2\u6570\u662f\u5408\u6cd5\u7684\u65e5\u671f\u8868\u8fbe\u5f0f\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/weekday/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT WEEKDAY('2008-02-03 22:23:00');\n+------------------------------+\n| weekday(2008-02-03 22:23:00) |\n+------------------------------+\n| 6 |\n+------------------------------+\n1 row in set (0.03 sec)\n
drop table if exists t1;\ncreate table t1 (id int,d date, dt datetime,c char(10),vc varchar(20));\ninsert into t1 values (1,\"2021-01-13\", \"2021-01-13 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (1,\"2021-01-31\", \"2021-01-31 13:00:00\", \"2021-12-15\", \"2021-12-16\");\ninsert into t1 values (2,\"2022-02-15\", \"2022-02-15 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (2,\"2022-02-28\", \"2022-02-28 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (3,\"2000-02-29\", \"2000-02-29 18:54:29\", \"2021-02-15\", \"2021-02-15\");\ninsert into t1 values (4,\"2023-03-17\", \"2021-02-17 23:54:59\", \"2021-03-17\", \"2021-03-17\");\ninsert into t1 values (5,\"1985-04-18\", \"1985-04-18 00:00:01\", \"1985-04-18\", \"1985-04-18\");\ninsert into t1 values (6,\"1987-05-20\", \"1987-05-20 22:59:59\", \"1987-05-20\", \"1987-05-20\");\ninsert into t1 values (7,\"1989-06-22\", \"1989-06-22 15:00:30\", \"1989-06-22\", \"1989-06-22\");\ninsert into t1 values (8,\"1993-07-25\", \"1987-07-25 03:04:59\", \"1993-07-25\", \"1993-07-25\");\ninsert into t1 values (9,\"1995-08-27\", \"1987-08-27 04:32:33\", \"1995-08-27\", \"1995-08-27\");\ninsert into t1 values (10,\"1999-09-30\", \"1999-09-30 10:11:12\", \"1999-09-30\", \"1999-09-30\");\ninsert into t1 values (11,\"2005-10-30\", \"2005-10-30 18:18:59\", \"2005-10-30\", \"2005-10-30\");\ninsert into t1 values (12,\"2008-11-30\", \"2008-11-30 22:59:59\", \"2008-11-30\", \"2008-11-30\");\ninsert into t1 values (13,\"2013-12-01\", \"2013-12-01 22:59:59\", \"2013-12-01\", \"2013-12-01\");\ninsert into t1 values (14,null, null, null, null);\n\nmysql> select weekday(d),weekday(dt) from t1;\n+------------+-------------+\n| weekday(d) | weekday(dt) |\n+------------+-------------+\n| 2 | 2 |\n| 6 | 6 |\n| 1 | 1 |\n| 0 | 0 |\n| 1 | 1 |\n| 4 | 2 |\n| 3 | 3 |\n| 2 | 2 |\n| 3 | 3 |\n| 6 | 5 |\n| 6 | 3 |\n| 3 | 3 |\n| 6 | 6 |\n| 6 | 6 |\n| 6 | 6 |\n| NULL | NULL |\n+------------+-------------+\n16 rows in set (0.01 sec)\n\nmysql> select weekday(c),weekday(vc) from t1;\n+------------+-------------+\n| weekday(c) | weekday(vc) |\n+------------+-------------+\n| 2 | 3 |\n| 2 | 3 |\n| 0 | 0 |\n| 0 | 0 |\n| 0 | 0 |\n| 2 | 2 |\n| 3 | 3 |\n| 2 | 2 |\n| 3 | 3 |\n| 6 | 6 |\n| 6 | 6 |\n| 3 | 3 |\n| 6 | 6 |\n| 6 | 6 |\n| 6 | 6 |\n| NULL | NULL |\n+------------+-------------+\n16 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/","title":"YEAR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"YEAR()
\u548c TOYEAR()
\u51fd\u6570\u8fd4\u56de\u4e86\u7ed9\u5b9a\u65e5\u671f\u7684\u5e74\u4efd\uff08\u4ece 1000 \u5230 9999\uff09\u3002
> YEAR(date)\n> TOYEAR(date)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e date \u5fc5\u8981\u53c2\u6570\uff0c\u9700\u8981\u63d0\u53d6\u5e74\u4efd\u7684\u65e5\u671f"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a date, b datetime);\ninsert into t1 values('20211223','2021-10-22 09:23:23');\ninsert into t1 values('2021-12-23','2021-10-22 00:23:23');\n\nmysql> select year(a) from t1;\n+---------+\n| year(a) |\n+---------+\n| 2021 |\n| 2021 |\n+---------+\n2 rows in set (0.00 sec)\n
DROP TABLE IF EXISTS t3;\nCREATE TABLE t3(c1 DATE NOT NULL);\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('1999-12-31');\nINSERT INTO t3 VALUES('2000-01-01');\nINSERT INTO t3 VALUES('2006-12-25');\nINSERT INTO t3 VALUES('2008-02-29');\nmysql> SELECT YEAR(c1) FROM t3;\n+----------+\n| year(c1) |\n+----------+\n| 2000 |\n| 1999 |\n| 2000 |\n| 2006 |\n| 2008 |\n+----------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Datetime/year/#_5","title":"\u9650\u5236","text":"\u76ee\u524d\u53ea\u652f\u6301 yyyy-mm-dd
\u548c yyyymmdd
\u7684\u6570\u636e\u683c\u5f0f\u3002
MatrixOne \u652f\u6301\u4ee5\u4e0b JSON \u51fd\u6570\uff1a
\u540d\u79f0 \u63cf\u8ff0 JSON_EXTRACT() \u4ece JSON \u6587\u6863\u8fd4\u56de\u6570\u636e JSON_QUOTE() \u5f15\u7528 JSON \u6587\u6863 JSON_UNQUOTE() \u53d6\u6d88\u5f15\u7528 JSON \u503c"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_extract","title":"JSON_EXTRACT() \u51fd\u6570","text":"JSON EXTRACT
\u662f\u4e00\u4e2a JSON \u67e5\u8be2\u51fd\u6570\uff0c\u53ef\u7528\u4e8e\u67e5\u8be2 JSON \u6587\u6863\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1aselect json_extract(jsonDoc, pathExpression);
pathExpression
\u662f JSON \u8def\u5f84\u8868\u8fbe\u5f0f\uff0c\u5373\u5728 JSON \u6587\u6863\u4e2d\u9009\u62e9\u4e00\u4e2a\u503c\u3002
\u8def\u5f84\u8868\u8fbe\u5f0f\u5bf9\u4e8e\u63d0\u53d6\u90e8\u5206 JSON \u6587\u6863\u6216\u4fee\u6539 JSON \u6587\u6863\u7684\u51fd\u6570\u5f88\u6709\u7528\uff0c\u6307\u5b9a\u5728\u8be5\u6587\u6863\u4e2d\u7684\u54ea\u4e2a\u4f4d\u7f6e\u8fdb\u884c\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u67e5\u8be2\u4ece JSON \u6587\u6863\u4e2d\u63d0\u53d6\u5177\u6709 name \u952e\u7684\u6210\u5458\u7684\u503c\uff1a
mysql> SELECT JSON_EXTRACT('{\"id\": 14, \"name\": \"Aztalan\"}', '$.name');\n+-----------------------------------------------------+\n| json_extract({\"id\": 14, \"name\": \"Aztalan\"}, $.name) |\n+-----------------------------------------------------+\n| \"Aztalan\" |\n+-----------------------------------------------------+\n1 row in set (0.00 sec)\n
\u8def\u5f84\u8868\u8fbe\u5f0f\u5fc5\u987b\u4ee5 $
\u5b57\u7b26\u5f00\u5934\uff1a
,
\u540e\u8ddf\u952e\u540d\uff0c\u4f7f\u7528\u7ed9\u5b9a\u952e\u547d\u540d\u5bf9\u8c61\u4e2d\u7684\u6210\u5458\u3002\u952e\u540d\u9700\u8981\u4f7f\u7528\u53cc\u5f15\u53f7\u5305\u542b\u3002
[N]
\uff1a\u9009\u62e9\u6570\u7ec4\u7684 path \u540e\uff0c\u5c06\u6570\u7ec4\u4e2d\u4f4d\u7f6e N
\u5904\u7684\u503c\u547d\u540d\u3002\u6570\u7ec4\u4f4d\u7f6e\u662f\u4ece\u96f6\u5f00\u59cb\u7684\u6574\u6570\u3002\u5982\u679c\u6570\u7ec4\u662f\u8d1f\u6570\uff0c\u5219\u4ea7\u751f\u62a5\u9519\u3002
\u8def\u5f84\u53ef\u4ee5\u5305\u542b *
\u6216 **
\u901a\u914d\u7b26\uff1a
.[*]
\u8ba1\u7b97 JSON \u5bf9\u8c61\u4e2d\u6240\u6709\u6210\u5458\u7684\u503c\u3002
[*]
\u8ba1\u7b97 JSON \u6570\u7ec4\u4e2d\u6240\u6709\u5143\u7d20\u7684\u503c\u3002
prefix**suffix
\uff1a\u8ba1\u7b97\u4ee5\u547d\u540d\u524d\u7f00\u5f00\u5934\u5e76\u4ee5\u547d\u540d\u540e\u7f00\u7ed3\u5c3e\u7684\u6240\u6709\u8def\u5f84\u3002
\u6587\u6863\u4e2d\u4e0d\u5b58\u5728\u7684\u8def\u5f84\uff08\u6216\u4e0d\u5b58\u5728\u7684\u6570\u636e\uff09\u8bc4\u4f30\u4e3a NULL
\u3002
\u793a\u4f8b\uff1a
\u5982\u4e0b\u4e00\u7ec4 JSON \u6570\u7ec4\uff1a
[3, {\"a\": [5, 6], \"b\": 10}, [99, 100]]\n
$[0]
\u8868\u793a 3\u3002
$[1]
\u8868\u793a {\"a\": [5, 6], \"b\": 10}\u3002
$[2]
\u8868\u793a [99, 100]\u3002
$[3]
\u4e3a NULL (\u6570\u7ec4\u8def\u5f84\u4ece $[0]
\u5f00\u59cb\uff0c\u800c $[3]
\u8868\u793a\u7b2c\u56db\u7ec4\u6570\u636e\uff0c\u8fd9\u7ec4\u6570\u636e\u4e0d\u5b58\u5728)\u3002
\u7531\u4e8e $[1]
\u4e0e $[2]
\u8ba1\u7b97\u4e3a\u975e\u6807\u91cf\u503c\uff0c\u90a3\u4e48\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5d4c\u5957\u3002\u4f8b\u5982\uff1a
$[1].a
\u8868\u793a [5, 6]\u3002
$[1].a[1]
\u8868\u793a 6\u3002
$[1].b
\u8868\u793a 10\u3002
$[2][0]
\u8868\u793a 99\u3002
\u952e\u540d\u5728\u8def\u5f84\u8868\u8fbe\u5f0f\u4e2d\u9700\u8981\u4f7f\u7528\u53cc\u5f15\u53f7\u3002$
\u5f15\u7528\u8fd9\u4e2a\u952e\u503c\uff0c\u4e5f\u9700\u8981\u52a0\u53cc\u5f15\u53f7\uff1a
{\"a fish\": \"shark\", \"a bird\": \"sparrow\"}\n
\u8fd9\u4e24\u4e2a\u952e\u90fd\u5305\u542b\u4e00\u4e2a\u7a7a\u683c\uff0c\u5fc5\u987b\u7528\u5f15\u53f7\u5f15\u8d77\u6765\uff1a
$.\"a fish\"
\u8868\u793a shark
\u3002
$.\"a bird\"
\u8868\u793a sparrow
\u3002
\u4f7f\u7528\u901a\u914d\u7b26 $
\u7684\u8def\u5f84\u53ef\u4ee5\u4e3a\u5305\u542b\u591a\u4e2a\u503c\u7684\u6570\u7ec4\uff1a
mysql> select JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.*') |\n+---------------------------------------------------------+\n| [1, 2, [3, 4, 5]] |\n+---------------------------------------------------------+\n\nmysql> SELECT JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]');\n+------------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": 1, \"b\": 2, \"c\": [3, 4, 5]}', '$.c[*]') |\n+------------------------------------------------------------+\n| [3, 4, 5] |\n+------------------------------------------------------------+\n
\u5728\u4e0b\u8ff0\u793a\u4f8b\u4e2d\uff0c\u8def\u5f84 $**.b
\u8ba1\u7b97\u4e3a\u591a\u4e2a\u8def\u5f84 ($.a.b
\u548c $.c.b
) \u5e76\u751f\u6210\u5339\u914d\u8def\u5f84\u503c\u7684\u6570\u7ec4\uff1a
mysql> select JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b');\n+---------------------------------------------------------+\n| JSON_EXTRACT('{\"a\": {\"b\": 1}, \"c\": {\"b\": 2}}', '$**.b') |\n+---------------------------------------------------------+\n| [null, 1, 2] |\n+---------------------------------------------------------+\n
\u5728\u4e0b\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5c06\u5c55\u793a\u4ece\u5217\u4e2d\u67e5\u8be2 JSON \u503c\uff1a
create table t1 (a json,b int);\ninsert into t1(a,b) values ('{\"a\":1,\"b\":2,\"c\":3}',1);\n\nmysql> select json_extract(t1.a,'$.a') from t1 where t1.b=1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1 |\n+-------------------------+\n1 row in set (0.00 sec)\n\ninsert into t1(a,b) values ('{\"a\":4,\"b\":5,\"c\":6}',2);\n\nmysql> select json_extract(t1.a,'$.b') from t1 where t1.b=2;\n+-------------------------+\n| json_extract(t1.a, $.b) |\n+-------------------------+\n| 5 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> select json_extract(t1.a,'$.a') from t1;\n+-------------------------+\n| json_extract(t1.a, $.a) |\n+-------------------------+\n| 1 |\n| 4 |\n+-------------------------+\n2 rows in set (0.00 sec)\n\ninsert into t1(a,b) values ('{\"a\":{\"q\":[1,2,3]}}',3);\n\nmysql> select json_extract(t1.a,'$.a.q[1]') from t1 where t1.b=3;\n+------------------------------+\n| json_extract(t1.a, $.a.q[1]) |\n+------------------------------+\n| 2 |\n+------------------------------+\n1 row in set (0.01 sec)\n\ninsert into t1(a,b) values ('[{\"a\":1,\"b\":2,\"c\":3},{\"a\":4,\"b\":5,\"c\":6}]',4);\n\nmysql> select json_extract(t1.a,'$[1].a') from t1 where t1.b=4;\n+----------------------------+\n| json_extract(t1.a, $[1].a) |\n+----------------------------+\n| 4 |\n+----------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_quote","title":"JSON_QUOTE() \u51fd\u6570","text":"JSON_QUOTE
\u51fd\u6570\u7528\u4e8e\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u503c\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\u4e2d\u7684\u5b57\u7b26\u4e32\u3002\u901a\u8fc7\u4f7f\u7528\u53cc\u5f15\u53f7\u5305\u88c5\u5b57\u7b26\u4e32\u5e76\u8f6c\u4e49\u5185\u5f15\u53f7\u548c\u5176\u4ed6\u5b57\u7b26\uff0c\u5c06\u5b57\u7b26\u4e32\u4f5c\u4e3a JSON \u503c\u5f15\u7528\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u4f5c\u4e3a utf8mb4
\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002
JSON_QUOTE
\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u751f\u6210\u6709\u6548\u7684 JSON \u5b57\u7b26\u4e32\uff0c\u4ee5\u5305\u542b\u5728 JSON \u6587\u6863\u4e2d\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1aselect JSON_QUOTE(string_value);
string_value
\u662f\u8981\u8f6c\u6362\u4e3a JSON \u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u4e32\u3002\u8be5\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a JSON \u683c\u5f0f\u7684\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d\u539f\u59cb\u5b57\u7b26\u4e32\u5df2\u88ab\u5f15\u53f7\u5305\u56f4\u5e76\u8fdb\u884c\u4e86\u9002\u5f53\u7684\u8f6c\u4e49\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
mysql> SELECT JSON_QUOTE('null'), JSON_QUOTE('\"null\"');\n+------------------+--------------------+\n| json_quote(null) | json_quote(\"null\") |\n+------------------+--------------------+\n| \"null\" | \"\\\"null\\\"\" |\n+------------------+--------------------+\n1 row in set (0.00 sec)\nmysql> SELECT JSON_QUOTE('[1, 2, 3]');\n+-----------------------+\n| json_quote([1, 2, 3]) |\n+-----------------------+\n| \"[1, 2, 3]\" |\n+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_QUOTE('hello world');\n+-------------------------+\n| json_quote(hello world) |\n+-------------------------+\n| \"hello world\" |\n+-------------------------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u539f\u59cb\u5b57\u7b26\u4e32\u88ab\u5f15\u53f7\u5305\u56f4\u5e76\u4e14\u5b57\u7b26\u4e32\u4e2d\u7684\u53cc\u5f15\u53f7\u4e5f\u88ab\u8f6c\u4e49\u4e86\u3002\u8fd9\u6837\uff0c\u53ef\u4ee5\u5c06\u5176\u7528\u4f5c JSON \u683c\u5f0f\u7684\u503c\uff0c\u4f8b\u5982\uff0c\u5c06\u5176\u4f5c\u4e3a JSON \u5bf9\u8c61\u7684\u5c5e\u6027\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Json/json-functions/#json_unquote","title":"JSON_UNQUOTE() \u51fd\u6570","text":"JSON_UNQUOTE()
\u51fd\u6570\u7528\u4e8e\u4ece\u4e00\u4e2a JSON \u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u4e00\u4e2a\u6ca1\u6709\u5f15\u53f7\u7684 JSON \u503c\uff0c\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002
\u5177\u4f53\u6765\u8bf4\uff0cJSON_UNQUOTE()
\u51fd\u6570\u9700\u8981\u4e00\u4e2a JSON
\u5b57\u7b26\u4e32\u4f5c\u4e3a\u8f93\u5165\uff0c\u7136\u540e\u4ece\u4e2d\u63d0\u53d6\u4e00\u4e2a JSON
\u503c\uff0c\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u5982\u679c\u8f93\u5165\u7684 JSON
\u5b57\u7b26\u4e32\u4e0d\u5305\u542b\u6709\u6548\u7684 JSON
\u503c\u6216\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u51fd\u6570\u8fd4\u56de NULL
\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002\u5982\u679c\u503c\u4ee5\u53cc\u5f15\u53f7\u5f00\u59cb\u548c\u7ed3\u675f\uff0c\u4f46\u4e0d\u662f\u6709\u6548\u7684 JSON
\u5b57\u7b26\u4e32\u6587\u5b57\uff0c\u5219\u4f1a\u53d1\u751f\u9519\u8bef\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1aselect JSON_UNQUOTE(string_value);
\u5728\u5b57\u7b26\u4e32\u4e2d\uff0c\u67d0\u4e9b\u5e8f\u5217\u5177\u6709\u7279\u6b8a\u542b\u4e49\uff0c\u8fd9\u4e9b\u5e8f\u5217\u90fd\u4ee5\u53cd\u659c\u6760 () \u5f00\u59cb\uff0c\u79f0\u4e3a\u8f6c\u4e49\u5b57\u7b26\uff0c\u89c4\u5219\u5982\u4e0b\u8868\u3002\u5bf9\u4e8e\u6240\u6709\u5176\u4ed6\u8f6c\u4e49\u5e8f\u5217\uff0c\u53cd\u659c\u6760\u5c06\u88ab\u5ffd\u7565\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8f6c\u4e49\u5b57\u7b26\u88ab\u89e3\u91ca\u4e3a\u6ca1\u6709\u8f6c\u4e49\u3002\u4f8b\u5982\uff0c\\x \u5c31\u662f x\u3002\u8fd9\u4e9b\u5e8f\u5217\u533a\u5206\u5927\u5c0f\u5199\u3002\u4f8b\u5982\uff0c\\b \u88ab\u89e3\u91ca\u4e3a\u9000\u683c\uff0c\u800c \\B \u88ab\u89e3\u91ca\u4e3a B\u3002
\u8f6c\u4e49\u5e8f\u5217 \u6240\u4ee3\u8868\u7684\u5b57\u7b26 \\\" \u53cc\u5f15\u53f7 (\") \\b \u9000\u683c\u7b26 \\f \u6362\u9875\u7b26 \\n \u6362\u884c\u7b26 \\r \u56de\u8f66\u7b26 \\t \u5236\u8868\u7b26 \\ \u53cd\u659c\u6760 () \\uXXXX Unicode \u503c\u4e3a XXXX \u7684 UTF-8 \u5b57\u8282\u793a\u4f8b\u5982\u4e0b\uff1a
mysql> SET @j = '\"abc\"';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-------+------------------+\n| @j | json_unquote(@j) |\n+-------+------------------+\n| \"abc\" | abc |\n+-------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SET @j = '[1, 2, 3]';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT @j, JSON_UNQUOTE(@j);\n+-----------+------------------+\n| @j | json_unquote(@j) |\n+-----------+------------------+\n| [1, 2, 3] | [1, 2, 3] |\n+-----------+------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT JSON_UNQUOTE('\"\\\\t\\\\u0032\"');\n+----------------------------+\n| json_unquote(\"\\\\t\\\\u0032\") |\n+----------------------------+\n| 2 |\n+----------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/","title":"ABS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ABS(X) \u8fd4\u56de X \u7684\u7edd\u5bf9\u503c\uff0c\u6216\u8005 NULL \u5982\u679c X \u662f NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ABS(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b \u8fd4\u56de\u503c\u7c7b\u578b\u4e0e\u8f93\u5165\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/abs/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,-3.1416);\ninsert into t1 values(-1,1.57);\n\nmysql> select abs(a),abs(b) from t1;\n+--------+--------------------+\n| abs(a) | abs(b) |\n+--------+--------------------+\n| 1 | 3.1415998935699463 |\n| 1 | 1.5700000524520874 |\n+--------+--------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/","title":"ACOS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ACOS() \u51fd\u6570\u8fd4\u56de\u7ed9\u5b9a\u6570\u503c\u7684\u4f59\u5f26\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ACOS(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/acos/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float,b int);\ninsert into t1 values(0.5,1);\ninsert into t1 values(-0.5,-1);\n\nmysql> select acos(a),acos(b) from t1;\n+--------------------+-------------------+\n| acos(a) | acos(b) |\n+--------------------+-------------------+\n| 1.0471975511965976 | 0 |\n| 2.0943951023931957 | 3.141592653589793 |\n+--------------------+-------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/","title":"ATAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ATAN() \u51fd\u6570\u8fd4\u56de\u7ed9\u5b9a\u6570\u503c\u7684\u53cd\u6b63\u5207\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ATAN(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/atan/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(0,1);\n\nmysql> select atan(a),atan(tan(b)) from t1;\n+--------------------+--------------------------+\n| atan(a) | atan(tan(b)) |\n+--------------------+--------------------------+\n| 0.7853981633974483 | -0.000002535181590113463 |\n| 0 | 1 |\n+--------------------+--------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/","title":"CEIL()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CEIL(X) \u51fd\u6570\u8fd4\u56de\u4e0d\u5c0f\u4e8e X \u7684\u6700\u5c0f\u6574\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> CEIL(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b \u5bf9 int \u7c7b\u7684\u7edd\u5bf9\u6570\u503c\u7c7b\u578b\uff0c\u8fd4\u56de\u503c\u4e5f\u662f\u76f8\u540c\u7684\u7edd\u5bf9\u6570\u503c\u7c7b\u578b\u3002\u5bf9\u6d6e\u70b9\u6570\u6765\u8bf4\uff0c\u8fd4\u56de\u503c\u4e5f\u662f\u6d6e\u70b9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ceil/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,ceil(b) from t1;\n+------+---------+\n| a | ceil(b) |\n+------+---------+\n| 1 | 1 |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 21 |\n| 5 | 21 |\n| 6 | 14 |\n| 7 | -0 |\n| 8 | -0 |\n| 9 | -0 |\n| 10 | -20 |\n| 11 | -20 |\n| 12 | -13 |\n+------+---------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(ceil(b)) from t1;\n+--------------+\n| sum(ceil(b)) |\n+--------------+\n| 6 |\n+--------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/","title":"COS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COS() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5f26\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> COS(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cos/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select cos(a),cos(b) from t1;\n+--------------------+----------------------+\n| cos(a) | cos(b) |\n+--------------------+----------------------+\n| 0.5403023058681398 | -0.9999999999967865 |\n| 0.5403023058681398 | 0.000796274258662553 |\n+--------------------+----------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/","title":"COT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COT() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u4f59\u5207\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> COT(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/cot/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT COT(12);\n+---------------------+\n| cot(12) |\n+---------------------+\n| -1.5726734063976895 |\n+---------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,12);\n\nmysql> select cot(a), cot(b) from t1;\n+---------------------+---------------------+\n| cot(a) | cot(b) |\n+---------------------+---------------------+\n| 0.6420926159343306 | -394449.0619219334 |\n| -0.6420926159343308 | -1.5726734063976895 |\n+---------------------+---------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/","title":"EXP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"EXP(number) \u51fd\u6570\u8fd4\u56de\u4ee5\u81ea\u7136\u5e38\u6570 e \u4e3a\u5e95\u7684 number \u7684\u6307\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> EXP(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/exp/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(-4, 2.45);\ninsert into t1 values(6, -3.62);\n\nmysql> select exp(a), exp(b) from t1;\n+---------------------+----------------------+\n| exp(a) | exp(b) |\n+---------------------+----------------------+\n| 0.01831563888873418 | 11.588347271798835 |\n| 403.4287934927351 | 0.026782679557672436 |\n+---------------------+----------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/","title":"FLOOR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FLOOR()
\u51fd\u6570\u8fd4\u56de\u4e0d\u5927\u4e8e\u67d0\u4e2a\u6570\u5b57\u7684\u76f8\u5e94\u6570\u4f4d\u7684\u6570\u3002
> FLOOR(number, decimals)\n> FLOOR(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e decimals \u53ef\u9009\u53c2\u6570\uff0c\u4ee3\u8868\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570\u3002\u9ed8\u8ba4\u503c\u4e3a 0\uff0c\u4ee3\u8868\u56db\u820d\u4e94\u5165\u4e3a\u6574\u6570\uff0c\u5f53\u4e3a\u8d1f\u6570\u65f6\u56db\u820d\u4e94\u5165\u5230\u5c0f\u6570\u70b9\u524d\u7684\u6570\u4f4d\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/floor/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,floor(b) from t1;\n+------+----------+\n| a | floor(b) |\n+------+----------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 0 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 13 |\n| 7 | -1 |\n| 8 | -1 |\n| 9 | -1 |\n| 10 | -21 |\n| 11 | -21 |\n| 12 | -14 |\n+------+----------+\n12 rows in set (0.01 sec)\n\nmysql> select sum(floor(b)) from t1;\n+---------------+\n| sum(floor(b)) |\n+---------------+\n| -6 |\n+---------------+\n1 row in set (0.00 sec)\n\nmysql> select a,sum(floor(b)) from t1 group by a order by a;\n+------+---------------+\n| a | sum(floor(b)) |\n+------+---------------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 0 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 13 |\n| 7 | -1 |\n| 8 | -1 |\n| 9 | -1 |\n| 10 | -21 |\n| 11 | -21 |\n| 12 | -14 |\n+------+---------------+\n12 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/","title":"LN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LN(X) \u8fd4\u56de X \u7684\u81ea\u7136\u5bf9\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u662f LOG(X) \u7684\u540c\u4e49\u51fd\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/ln/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LN(X)\n
\u5176\u4ed6\u8bf7\u53c2\u8003 LOG(X)\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/","title":"LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOG(X) \u51fd\u6570\u8fd4\u56de X \u7684\u81ea\u7136\u5bf9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LOG(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(2,8);\n\nmysql> select log(a), log(b) from t1;\n+--------------------+--------------------+\n| log(a) | log(b) |\n+--------------------+--------------------+\n| 0.6931471805599453 | 2.0794415416798357 |\n+--------------------+--------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log/#_5","title":"\u9650\u5236","text":"LOG(X) \u76ee\u524d\u4ec5\u652f\u6301\u5355\u53c2\u6570\u8f93\u5165\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/","title":"LOG10()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOG10(X) \u51fd\u6570\u8fd4\u56de\u4ee5 10 \u4e3a\u5e95 X \u7684\u5bf9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LOG10(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log10/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(10000,3784.159);\ninsert into t1 values(2738,682.325);\n\nmysql> select log10(a),log10(b) from t1;\n+-------------------+--------------------+\n| log10(a) | log10(b) |\n+-------------------+--------------------+\n| 4 | 3.577969368581086 |\n| 3.437433443797971 | 2.8339912916439594 |\n+-------------------+--------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/","title":"LOG2()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOG2(X) \u51fd\u6570\u8fd4\u56de\u4ee5 2 \u4e3a\u5e95 X \u7684\u5bf9\u6570\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LOG2(X)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/log2/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a float, b float);\ninsert into t1 values(1024,17.231);\ninsert into t1 values(4096,23.331);\n\nmysql>select log2(a),log2(b) from t1;\n+---------+-------------------+\n| log2(a) | log2(b) |\n+---------+-------------------+\n| 10 | 4.106934600972237 |\n| 12 | 4.544176200820541 |\n+---------+-------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/","title":"PI()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"PI() \u8fd4\u56de\u6570\u5b66\u5e38\u91cf \u03c0 (pi)\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> PI()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/pi/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(0,0),(-15,-20),(-22,-12.5);\ninsert into t1 values(0,360),(30,390),(90,450),(180,270),(180,180);\n\nmysql> select acos(a*pi()/180) as acosa,acos(b*pi()/180) acosb from t1;\n+--------------------+--------------------+\n| acosa | acosb |\n+--------------------+--------------------+\n| 1.5707963267948966 | 1.5707963267948966 |\n| 1.8356824738191324 | 1.927370391646567 |\n| 1.9648910192076245 | 1.7907312931992256 |\n| 1.5707963267948966 | NULL |\n| 1.0197267436954502 | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n+--------------------+--------------------+\n8 rows in set (0.01 sec)\n\nmysql> select acos(a*pi()/180)*acos(b*pi()/180) as acosab,acos(acos(a*pi()/180)) as c from t1;\n+--------------------+------+\n| acosab | c |\n+--------------------+------+\n| 2.4674011002723395 | NULL |\n| 3.5380400485035204 | NULL |\n| 3.518591835821214 | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n| NULL | NULL |\n+--------------------+------+\n8 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/","title":"POWER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"POWER(X, Y) \u8fd4\u56de X \u7684 Y \u6b21\u65b9\u6307\u6570\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> POWER(X, Y)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e Y \u5fc5\u8981\u53c2\u6570\uff0c\u4efb\u4f55\u5f53\u524d\u652f\u6301\u7684\u6570\u503c\u6570\u636e"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/power/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b int);\ninsert into t1 values(5,-2),(10,3),(100,0),(4,3),(6,-3);\n\nmysql> select power(a,b) from t1;\n+----------------------+\n| power(a, b) |\n+----------------------+\n| 0.04 |\n| 1000 |\n| 1 |\n| 64 |\n| 0.004629629629629629 |\n+----------------------+\n5 rows in set (0.01 sec)\n\nmysql> select power(a,2) as a1, power(b,2) as b1 from t1 where power(a,2) > power(b,2) order by a1 asc;\n+-------+------+\n| a1 | b1 |\n+-------+------+\n| 16 | 9 |\n| 25 | 4 |\n| 36 | 9 |\n| 100 | 9 |\n| 10000 | 0 |\n+-------+------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/","title":"RAND()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"RAND()
\u51fd\u6570\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u4ecb\u4e8e 0 \u548c 1 \u4e4b\u95f4\u7684 Float64 \u7c7b\u578b\u7684\u968f\u673a\u6570\u3002\u5b83\u4e0d\u63a5\u53d7\u4efb\u4f55\u53c2\u6570\uff0c\u6bcf\u6b21\u8c03\u7528\u90fd\u4f1a\u4ea7\u751f\u4e00\u4e2a\u4e0d\u53ef\u9884\u6d4b\u4e14\u4e0d\u91cd\u590d\u7684\u968f\u673a\u6570\u3002
\u5982\u679c\u9700\u8981\u4ece\u8868\u4e2d\u968f\u673a\u9009\u62e9\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528 RAND()
\u51fd\u6570\u751f\u6210\u4e00\u4e2a\u968f\u673a\u6570\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u968f\u673a\u6570\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u4f7f\u7528 ORDER BY
\u8fdb\u884c\u6392\u5e8f\u3002\u4f8b\u5982\uff1a
-- \u4ece\u8868\u4e2d\u968f\u673a\u83b7\u53d6\u6240\u6709\u6570\u636e\uff0c\u5e76\u6309\u7167\u968f\u673a\u987a\u5e8f\u8fdb\u884c\u6392\u5e8f\uff0c\u6bcf\u6b21\u67e5\u8be2\u7ed3\u679c\u7684\u987a\u5e8f\u53ef\u80fd\u90fd\u4e0d\u540c\nSELECT * FROM table ORDER BY RAND();\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> RAND([seed])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e seed \u53ef\u9009\u53c2\u6570\u3002\u662f\u4e00\u4e2a\u6574\u6570\u503c\uff0c\u7528\u4e8e\u6307\u5b9a\u751f\u6210\u968f\u673a\u6570\u65f6\u7684\u79cd\u5b50\u503c\u3002\u5982\u679c\u4e0d\u6307\u5b9a seed
\u53c2\u6570\uff0c\u5219\u9ed8\u8ba4\u4ee5\u5f53\u524d\u65f6\u95f4\u4e3a\u79cd\u5b50\u503c\u3002\u8fd4\u56de\u503c\u7c7b\u578b\u4e0e\u8f93\u5165\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\u3002 MatrixOne \u6682\u4e0d\u652f\u6301\u6307\u5b9a\u79cd\u5b50\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT RAND();\n+---------------------+\n| rand() |\n+---------------------+\n| 0.25193285156620004 |\n+---------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE Users (\nID INT PRIMARY KEY AUTO_INCREMENT,\nUserName VARCHAR(255) NOT NULL,\nEmail VARCHAR(255));\n\nINSERT INTO Users (UserName, Email) VALUES\n('John', 'john@example.com'),\n('Jane', 'jane@example.com'),\n('Alice', 'alice@example.com'),\n('Bob', 'bob@example.com');\n\n-- \u4ece Users \u8868\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u4e2a\u7528\u6237\u7684\u4fe1\u606f\nmysql> SELECT * FROM Users ORDER BY RAND() LIMIT 1;\n+------+----------+-----------------+\n| id | username | email |\n+------+----------+-----------------+\n| 4 | Bob | bob@example.com | -- Bob \u7684\u4fe1\u606f\u88ab\u968f\u673a\u9009\u4e2d\n+------+----------+-----------------+\n1 row in set (0.01 sec)\n\n-- \u518d\u6b21\u6267\u884c\u4e0a\u8ff0\u67e5\u8be2\uff0c\u9009\u4e2d\u7684\u53ef\u80fd\u4f1a\u662f\u53e6\u4e00\u4e2a\u7528\u6237\nmysql> SELECT * FROM Users ORDER BY RAND() LIMIT 1;\n+------+----------+-------------------+\n| id | username | email |\n+------+----------+-------------------+\n| 3 | Alice | alice@example.com | -- Alice \u7684\u4fe1\u606f\u88ab\u968f\u673a\u9009\u4e2d\n+------+----------+-------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/rand/#_5","title":"\u9650\u5236","text":"MatrixOne \u6682\u4e0d\u652f\u6301\u6307\u5b9a RAND(seed)
\u51fd\u6570\u7684\u79cd\u5b50\u503c\uff08\u5373 seed
\u53c2\u6570\uff09\u3002
ROUND()
\u51fd\u6570\u8fd4\u56de\u4e86\u67d0\u4e2a\u6570\u5b57\u5728\u7279\u5b9a\u4f4d\u6570\u56db\u820d\u4e94\u5165\u540e\u7684\u6570\u503c\u3002 \u8be5\u51fd\u6570\u8fd4\u56de\u6307\u5b9a\u4f4d\u6570\u4e0a\u6700\u63a5\u8fd1\u7684\u6570\u5b57\u3002\u5982\u679c\u7ed9\u5b9a\u7684\u6570\u5b57\u4e0e\u5468\u56f4\u7684\u6570\u5b57\u8ddd\u79bb\u76f8\u7b49\uff08\u6bd4\u5982\u4e3a 5\uff09\uff0c\u90a3\u4e48\u5c06\u91c7\u7528\u201cbanker's rounding\u201d\uff08\u94f6\u884c\u8fdb\u4f4d\u6cd5\uff09\u7684\u65b9\u5f0f\u8fdb\u884c\u820d\u5165\u3002
> ROUND(number, decimals)\n> ROUND(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8fdb\u884c\u820d\u5165\u7684\u6570\u503c\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b decimals \u53ef\u9009\u53c2\u6570\uff0c\u8868\u793a\u5c06\u8981\u820d\u5165\u7684\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570\u3002\u9ed8\u8ba4\u503c\u4e3a 0\uff0c\u4ee3\u8868\u820d\u5165\u5230\u6574\u6570\u3002 decimals>0 \u51fd\u6570\u5c06\u820d\u5165\u5230\u5c0f\u6570\u70b9\u540e\u7684\u4f4d\u6570 decimals<0 \u51fd\u6570\u5c06\u820d\u5165\u5230\u5c0f\u6570\u70b9\u524d\u7684\u4f4d\u6570 decimals=0 \u51fd\u6570\u5c06\u820d\u5165\u5230\u6574\u6570"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/round/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int ,b float);\ninsert into t1 values(1,0.5);\ninsert into t1 values(2,0.499);\ninsert into t1 values(3,0.501);\ninsert into t1 values(4,20.5);\ninsert into t1 values(5,20.499);\ninsert into t1 values(6,13.500);\ninsert into t1 values(7,-0.500);\ninsert into t1 values(8,-0.499);\ninsert into t1 values(9,-0.501);\ninsert into t1 values(10,-20.499);\ninsert into t1 values(11,-20.500);\ninsert into t1 values(12,-13.500);\n\nmysql> select a,round(b) from t1;\n+------+----------+\n| a | round(b) |\n+------+----------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 1 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 14 |\n| 7 | -0 |\n| 8 | -0 |\n| 9 | -1 |\n| 10 | -20 |\n| 11 | -20 |\n| 12 | -14 |\n+------+----------+\n12 rows in set (0.00 sec)\n\nmysql> select a,round(b,-1) from t1;\n+------+--------------+\n| a | round(b, -1) |\n+------+--------------+\n| 1 | 0 |\n| 2 | 0 |\n| 3 | 0 |\n| 4 | 20 |\n| 5 | 20 |\n| 6 | 10 |\n| 7 | -0 |\n| 8 | -0 |\n| 9 | -0 |\n| 10 | -20 |\n| 11 | -20 |\n| 12 | -10 |\n+------+--------------+\n12 rows in set (0.01 sec)\n\nmysql> select round(a*b) from t1;\n+--------------+\n| round(a * b) |\n+--------------+\n| 0 |\n| 1 |\n| 2 |\n| 82 |\n| 102 |\n| 81 |\n| -4 |\n| -4 |\n| -5 |\n| -205 |\n| -226 |\n| -162 |\n+--------------+\n12 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/","title":"SIN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SIN() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5f26\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SIN(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sin/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,1.57);\n\nmysql> select sin(a),sin(b) from t1;\n+---------------------+--------------------------+\n| sin(a) | sin(b) |\n+---------------------+--------------------------+\n| 0.8414709848078965 | 0.0000025351815901107472 |\n| -0.8414709848078965 | 0.9999996829736023 |\n+---------------------+--------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/","title":"SINH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SINH() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u53cc\u66f2\u6b63\u5f26\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SINH(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/sinh/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159), (-1,-3.14159);\n\nmysql> select sinh(a), sinh(b) from t1;\n+---------------------+---------------------+\n| sinh(a) | sinh(b) |\n+---------------------+---------------------+\n| 1.1752011936438014 | 11.548709969588323 |\n| -1.1752011936438014 | -11.548709969588323 |\n+---------------------+---------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/","title":"TAN()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TAN() \u51fd\u6570\u8fd4\u56de\u8f93\u5165\u53c2\u6570\uff08\u7528\u5f27\u5ea6\u8868\u793a\uff09\u7684\u6b63\u5207\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> TAN(number)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e number \u5fc5\u8981\u53c2\u6570\uff0c\u53ef\u53d6\u4efb\u610f\u6570\u503c\u6570\u636e\u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/Mathematical/tan/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int,b float);\ninsert into t1 values(1,3.14159);\ninsert into t1 values(-1,-3.14159);\n\nmysql> select tan(a),tan(b) from t1;\n+--------------------+--------------------------+\n| tan(a) | tan(b) |\n+--------------------+--------------------------+\n| 1.557407724654902 | -0.000002535181590118894 |\n| -1.557407724654902 | 0.000002535181590118894 |\n+--------------------+--------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sample/","title":"SAMPLE \u91c7\u6837\u51fd\u6570","text":"SAMPLE \u91c7\u6837\u51fd\u6570\u529f\u80fd\u662f\u5904\u7406\u5927\u91cf\u6570\u636e\u5206\u6790\u7684\u5173\u952e\u5de5\u5177\uff0c\u4e3b\u8981\u7528\u4e8e\u5feb\u901f\u7f29\u51cf\u67e5\u8be2\u8303\u56f4\u3002
SELECT SAMPLE(<column_list>, <N ROWS>/<K PERCENT>) FROM <table> [WHERE ...] [GROUP BY ...] [ORDER BY ...] [LIMIT ...] [OFFSET ...]\n
<column_list>
: \u9009\u62e9\u7684\u5217\u540d\u5217\u8868\u3002<N ROWS>/<K PERCENT>
: \u6307\u5b9a\u8fd4\u56de\u7684\u6837\u672c\u6570\u91cf\uff08N \u884c\uff09\u6216\u767e\u5206\u6bd4\uff08K%\uff09\u3002
\u529f\u80fd\u7279\u70b9
SAMPLE \u51fd\u6570\u4f1a\u5728\u8868\u8fc7\u6ee4\u518d\u6267\u884c\u91c7\u6837\u3002
\u53ef\u4e0e WHERE \u5b50\u53e5\u3001GROUP BY \u5b50\u53e5\u7b49\u7ed3\u5408\u4f7f\u7528\u3002
\u5e94\u7528\u793a\u4f8b
SELECT SAMPLE(a, 100 ROWS) FROM t1; -- \u8fd4\u56de 100 \u4e2a\u968f\u673a\u6837\u672c\nSELECT SAMPLE(a, 0.2 PERCENT) FROM t1; -- \u8fd4\u56de\u7ea6 0.2% \u7684\u6837\u672c\nSELECT SAMPLE(a, 100 ROWS) FROM t1 WHERE a > 1; -- \u5148\u8fc7\u6ee4\u540e\u91c7\u6837\nSELECT a, SAMPLE(b, 100 ROWS) FROM t1 GROUP BY a; -- \u5206\u7ec4\u540e\u91c7\u6837\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/","title":"SERIAL_EXTRACT \u51fd\u6570","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SERIAL_EXTRACT()
\u51fd\u6570\u7528\u4e8e\u63d0\u53d6\u5e8f\u5217/\u5143\u7ec4\u503c\u4e2d\u7684\u5404\u4e2a\u5143\u7d20\uff0c\u9700\u7ed3\u5408\u51fd\u6570 MAX()
\uff0cMIN()
\uff0cSERIAL()
\uff0cSERIAL_NULL()
\u4f7f\u7528\u3002
>SERIAL_EXTRACT(serial_col, pos as type)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e serial_col \u5fc5\u8981\u53c2\u6570\u3002\u4fdd\u5b58 serial/serial_full \u51fd\u6570\u503c\u7684\u4e32\u884c\u5217\u3002\u5982\u9700\u66f4\u6362\u8f93\u51fa\u7c7b\u578b\u53ef\u7ed3\u5408CAST()
\u51fd\u6570\u4f7f\u7528\u3002 pos \u5fc5\u8981\u53c2\u6570\u3002\u8981\u63d0\u53d6\u7684\u5b57\u6bb5\u7684\u4f4d\u7f6e\uff0c0 \u4e3a\u7b2c\u4e00\u4e2a\u3002 type \u5fc5\u8981\u53c2\u6570\u3002\u5bfc\u51fa\u7684\u5143\u7d20\u7684\u539f\u59cb\u7c7b\u578b\u3002\u9700\u8981\u4e0e\u63d0\u53d6\u7684\u5143\u7d20\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/serial_extract/#_4","title":"\u793a\u4f8b","text":"drop table if exists vtab64;\ncreate table vtab64(id int primary key auto_increment,`vecf64_3` vecf64(3),`vecf64_5` vecf64(5));\ninsert into vtab64(vecf64_3,vecf64_5) values(\"[1,NULL,2]\",NULL);\ninsert into vtab64(vecf64_3,vecf64_5) values(NULL,NULL);\ninsert into vtab64(vecf64_3,vecf64_5) values(\"[2,3,4]\",NULL);\ninsert into vtab64(vecf64_3,vecf64_5) values (\"[4,5,6]\",\"[1,2,3,4,5]\");\ninsert into vtab64(vecf64_3,vecf64_5) values (\"[7,8,9]\",\"[2,3,4,5,6]\");\n\nmysql> select * from vtab64;\n+------+-----------+-----------------+\n| id | vecf64_3 | vecf64_5 |\n+------+-----------+-----------------+\n| 1 | NULL | NULL |\n| 2 | [2, 3, 4] | NULL |\n| 3 | [4, 5, 6] | [1, 2, 3, 4, 5] |\n| 4 | [7, 8, 9] | [2, 3, 4, 5, 6] |\n+------+-----------+-----------------+\n4 rows in set (0.01 sec)\n\n--max(max(serial(id, `vecf64_3`, `vecf64_5`)) \u5f97\u5230\u4e00\u4e2a\u6700\u5927\u7684\u5e8f\u5217\u5316\u503c\uff0c\u7136\u540e\u6b63\u5e38\u83b7\u53d6\u5230\u7684 max \u5e94\u8be5\u662f (4,[7, 8, 9],[2, 3, 4, 5, 6]) \u8fd9\u4e00\u6761\u8bb0\u5f55\uff0c\u4f46\u662f 1 \u4ee3\u8868\u7684\u662f\u7b2c\u4e8c\u4e2a\u4f4d\u7f6e\u7684\u503c\uff0c\u6240\u4ee5\u5c31\u662f [7, 8, 9]\nmysql> select serial_extract(max(serial(id, `vecf64_3`, `vecf64_5`)), 1 as vecf64(3)) as a from vtab64;\n+-----------+\n| a |\n+-----------+\n| [7, 8, 9] |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select serial_extract(min(serial(id, `vecf64_3`, `vecf64_5`)), 2 as vecf64(5)) as a from vtab64;\n+-----------------+\n| a |\n+-----------------+\n| [1, 2, 3, 4, 5] |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> select serial_extract(max(serial_full(cast(id as decimal), `vecf64_3`)), 0 as decimal) as a from vtab64;\n+------+\n| a |\n+------+\n| 4 |\n+------+\n1 row in set (0.01 sec)\n\nmysql> select serial_extract(min(serial_full(cast(id as decimal), `vecf64_3`)), 1 as vecf64(3)) as a from vtab64;\n+------+\n| a |\n+------+\n| NULL |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/","title":"SLEEP()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SLEEP()
\u51fd\u6570\u5c06\u5f53\u524d\u67e5\u8be2\u6682\u505c\uff08\u7761\u7720\uff09\u6307\u5b9a\u7684\u79d2\u6570\u3002\u7ed3\u679c\u5c06\u8fd4\u56de 0\u3002
>\nSLEEP(duration)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e duration \u5fc5\u9700\u7684\u3002\u4ee5\u79d2\u4e3a\u5355\u4f4d\u7684\u7761\u7720\u65f6\u957f\u3002\u5b83\u5e94\u8be5\u5927\u4e8e\u6216\u7b49\u4e8e 0\uff0c\u5e76\u4e14\u53ef\u4ee5\u5e26\u6709\u5c0f\u6570\u90e8\u5206\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_4","title":"\u8fd4\u56de\u503c","text":"\u5f53 SLEEP()
\u6b63\u5e38\u8fd4\u56de\u65f6\uff08\u6ca1\u6709\u4e2d\u65ad\uff09\uff0c\u5b83\u8fd4\u56de 0\u3002
\u5f53 SLEEP()
\u88ab\u4e2d\u65ad\u7684\u67e5\u8be2\u8c03\u7528\u552f\u4e00\u7684\u7ed3\u679c\u65f6\uff0c\u5b83\u8fd4\u56de 1 \u5e76\u4e14\u67e5\u8be2\u672c\u8eab\u4e0d\u8fd4\u56de\u9519\u8bef\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
\u5728\u4f1a\u8bdd 1 \u4e2d\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u67e5\u8be2\u5f53\u524d\u7684 connection_id\uff0c\u5e76\u6267\u884c SLEEP()
\u51fd\u6570\uff1a
mysql> select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n| 1476 |\n+-----------------+\n1 row in set (0.03 sec)\nmysql> select sleep(200);\n
\u6b64\u65f6\uff0c\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\uff0c\u4e2d\u65ad\u4f1a\u8bdd 1\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a
mysql> kill 1476;\nQuery OK, 0 rows affected (0.00 sec)\n
\u67e5\u770b\u4f1a\u8bdd 1 \u7684\u7ed3\u679c\uff1a
mysql> select sleep(200);\n+------------+\n| sleep(200) |\n+------------+\n| 1 |\n+------------+\n1 row in set (26.50 sec)\n
\u90e8\u5206\u67e5\u8be2\u88ab\u6253\u65ad\u65f6\uff0cSLEEP() \u8fd4\u56de\u9519\u8bef\uff0c\u4f8b\u5982\uff1a
mysql> SELECT 1 FROM t1 WHERE SLEEP(1000);\nERROR 20101 (HY000): internal error: pipeline closed unexpectedly\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/sleep/#_5","title":"\u793a\u4f8b","text":"-- without interruption\nmysql> SELECT SLEEP(1);\n+----------+\n| sleep(1) |\n+----------+\n| 0 |\n+----------+\n1 row in set (1.01 sec)\n\n-- without interruption\nmysql> SELECT SLEEP(1000);\n+-------------+\n| sleep(1000) |\n+-------------+\n| 0 |\n+-------------+\n1 row in set (18 min 20.87 sec)\n\ncreate table t1 (a int,b int);\ninsert into t1 values (1,1),(1,null);\nmysql> select sleep(a) from t1;\n+----------+\n| sleep(a) |\n+----------+\n| 0 |\n| 0 |\n+----------+\n2 rows in set (2.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/","title":"UUID()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UUID()
\u8fd4\u56de\u6839\u636e RFC 4122 \u751f\u6210\u56fd\u9645\u901a\u7528\u552f\u4e00\u6807\u8bc6\u7b26 UUID(Universally Unique IDentifier)\u3002
UUID \u5728\u7a7a\u95f4\u548c\u65f6\u95f4\u4e0a\u662f\u5168\u7403\u552f\u4e00\u7684\u6570\u5b57\u3002\u5373\u4f7f\u662f\u5728\u4e24\u4e2a\u672a\u8fde\u63a5\u7684\u72ec\u7acb\u8fd0\u884c\u7684\u8bbe\u5907\u4e0a\u6267\u884c UUID \u8c03\u7528\uff0c\u9884\u8ba1\u4f1a\u751f\u6210\u4e24\u4e2a\u4e0d\u540c\u7684\u503c\u3002
Info
\u5c3d\u7ba1 UUID()
\u503c\u552f\u4e00\uff0c\u4f46\u5b83\u4eec\u5e76\u975e\u662f\u4e0d\u53ef\u731c\u6d4b\u6216\u4e0d\u53ef\u9884\u6d4b\u7684\u3002\u5982\u679c\u9700\u8981\u4e0d\u53ef\u9884\u6d4b\u6027\uff0c\u5219\u5e94\u4ee5\u5176\u4ed6\u65b9\u5f0f\u751f\u6210 UUID \u503c\u3002
UUID()
\u8fd4\u56de\u4e00\u4e2a\u7b26\u5408 RFC 4122 \u6807\u51c6\u7684\u7248\u672c 1 UUID \u7684\u503c\uff0c\u4e3a 128 \u4f4d\u6570\u5b57\uff0c\u5b83\u8868\u793a\u662f\u4e00\u4e2a utf8mb3 \u7531\u4e94\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\uff0c\u5373 aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\uff0c\u683c\u5f0f\u89e3\u91ca\u5982\u4e0b\uff1a
\u524d\u4e09\u4e2a\u6570\u5b57\u662f\u4ece\u65f6\u95f4\u6233\u7684\u4f4e\u3001\u4e2d\u548c\u9ad8\u90e8\u5206\u751f\u6210\u7684\u3002\u9ad8\u4f4d\u90e8\u5206\u8fd8\u5305\u62ec UUID \u7248\u672c\u53f7\u3002
\u7b2c\u56db\u4e2a\u6570\u5b57\u4fdd\u7559\u65f6\u95f4\u552f\u4e00\u6027\uff0c\u4ee5\u9632\u65f6\u95f4\u6233\u503c\u5931\u53bb\u5355\u4e00\u6027\uff08\u4f8b\u5982\uff0c\u590f\u4ee4\u65f6\uff09\u3002
\u7b2c\u4e94\u4e2a\u6570\u5b57\u662f\u7a7a\u95f4\u552f\u4e00\u6027\u7684 IEEE 802 \u8282\u70b9\u53f7\u3002\u5982\u679c\u540e\u8005\u4e0d\u53ef\u7528\uff08\u4f8b\u5982\uff0c\u56e0\u4e3a\u4e3b\u673a\u8bbe\u5907\u6ca1\u6709\u4ee5\u592a\u7f51\u5361\uff0c\u6216\u8005\u4e0d\u77e5\u9053\u5982\u4f55\u5728\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u627e\u5230\u63a5\u53e3\u7684\u786c\u4ef6\u5730\u5740\uff09\uff0c\u5219\u7528\u968f\u673a\u6570\u4ee3\u66ff\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u65e0\u6cd5\u4fdd\u8bc1\u7a7a\u95f4\u552f\u4e00\u6027\u3002\u7136\u800c\uff0c\u7b2c\u4e94\u4f4d\u6570\u5b57\u91cd\u5408\u7684\u6982\u7387\u5f88\u4f4e\u3002
UUID \u65e2\u662f\u6570\u636e\u7c7b\u578b\uff0c\u4e5f\u662f\u51fd\u6570\uff0c\u5982\u9700\u4e86\u89e3\u66f4\u591a UUID \u6570\u636e\u7c7b\u578b\uff0c\u53c2\u89c1 UUID \u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> UUID()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a INT, b float);\ninsert into t1 values(12124, -4213.413), (12124, -42413.409);\n\nmysql> SELECT length(uuid()) FROM t1;\n+----------------+\n| length(uuid()) |\n+----------------+\n| 36 |\n| 36 |\n+----------------+\n2 rows in set (0.00 sec)\n\nmysql> SELECT UUID();\n+--------------------------------------+\n| uuid() |\n+--------------------------------------+\n| b293b688-70a7-11ed-a25a-5ad2460dea50 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Other/uuid/#_4","title":"\u9650\u5236","text":"UUID()
\u6682\u65f6\u4e0d\u652f\u6301\u53ef\u9009\u53c2\u6570\uff0c\u5373\u6682\u4e0d\u652f\u6301 UUID([number])
\u3002
BIN()
\u5c06 N \u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u7684\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002\u5176\u4e2d N \u662f\u4e00\u4e2a longlong (BIGINT)
\u6570\u5b57\u3002\u5982\u679c N \u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL
\u3002
> BIN(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002UINT \u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bin/#_4","title":"\u793a\u4f8b","text":"> SELECT bin(1314);\n+-------------+\n| bin(1314) |\n+-------------+\n| 10100100010 |\n+-------------+\n1 row in set (0.01 sec)\n\n> select bin(2e5);\n+--------------------+\n| bin(2e5) |\n+--------------------+\n| 110000110101000000 |\n+--------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/","title":"BIT_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u8fd4\u56de\u5b57\u7b26\u4e32 str \u7684\u957f\u5ea6\uff0c\u5355\u4f4d\u4e3a bit\u3002\u5982\u679c str \u4e3a NULL
\u5219\u8fd4\u56de NULL
\u3002
> BIT_LENGTH(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8ba1\u7b97\u957f\u5ea6\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/bit-length/#_4","title":"\u793a\u4f8b","text":"> SELECT BIT_LENGTH('text');\n+------------------+\n| bit_length(text) |\n+------------------+\n| 32 |\n+------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/","title":"CHAR_LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CHAR_LENGTH
\u4ee5\u5b57\u7b26\u4e3a\u5355\u4f4d\u8fd4\u56de\u5b57\u7b26\u4e32 str
\u7684\u957f\u5ea6\uff0c\u4e00\u4e2a\u591a\u5b57\u8282\u5b57\u7b26\u7b97\u4f5c\u4e00\u4e2a\u5b57\u7b26\u3002\u4e00\u4e2a\u6c49\u5b57\u6240\u5bf9\u5e94\u7684\u5b57\u7b26\u957f\u5ea6\u662f 1\u3002
> CHAR_LENGTH(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/char-length/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8ba1\u7b97\u957f\u5ea6\u7684\u5b57\u7b26\u4e32 note
CHAR_LENGTH
\u4e5f\u53ef\u4ee5\u5199\u4e3a lengthUTF8()
\u3002
> drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('nihao','\u4f60\u597d');\n> select char_length(a), char_length(b) from t1;\n+---------------+---------------+\n| lengthutf8(a) | lengthutf8(b) |\n+---------------+---------------+\n| 5 | 2 |\n+---------------+---------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/","title":"CONCAT_WS()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CONCAT_WS()
\u4ee3\u8868 Concatenate With Separator\uff0c\u662f CONCAT()
\u7684\u4e00\u79cd\u7279\u6b8a\u5f62\u5f0f\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5176\u5b83\u53c2\u6570\u7684\u5206\u9694\u7b26\u3002\u5206\u9694\u7b26\u7684\u4f4d\u7f6e\u653e\u5728\u8981\u8fde\u63a5\u7684\u4e24\u4e2a\u5b57\u7b26\u4e32\u4e4b\u95f4\u3002\u5206\u9694\u7b26\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\uff0c\u4e5f\u53ef\u4ee5\u662f\u5176\u4ed6\u53c2\u6570\u3002\u5982\u679c\u5206\u9694\u7b26\u4e3a NULL
\uff0c\u5219\u7ed3\u679c\u4e3a NULL
\u3002\u51fd\u6570\u4f1a\u5ffd\u7565\u4efb\u4f55\u5206\u9694\u7b26\u53c2\u6570\u540e\u7684 NULL
\u503c\u3002
> CONCAT_WS(separator,str1,str2,...)\n
> CONCAT_WS(separator,str1,NULL,str1,...);\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e Str \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u7ffb\u8f6c\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat-ws/#_4","title":"\u793a\u4f8b","text":"SELECT CONCAT_WS(',','First name','Second name','Last Name');\n+--------------------------------------------------+\n| concat_ws(,, First name, Second name, Last Name) |\n+--------------------------------------------------+\n| First name,Second name,Last Name |\n+--------------------------------------------------+\n1 row in set (0.01 sec)\n> SELECT CONCAT_WS(',','First name',NULL,'Last Name');\n+-------------------------------------------+\n| concat_ws(,, First name, null, Last Name) |\n+-------------------------------------------+\n| First name,Last Name |\n+-------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/","title":"CONCAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CONCAT()
\u5c06\u591a\u4e2a\u5b57\u7b26\u4e32\uff08\u6216\u4ec5\u542b\u6709\u4e00\u4e2a\u5b57\u7b26\u4e32\uff09\u8fde\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u6240\u6709\u53c2\u6570\u90fd\u662f\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u662f\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u5305\u542b\u4efb\u4f55\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002
CONCAT()
\u4e2d\u5982\u679c\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
>\nCONCAT(str1,str2,...)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str1,str2,... \u5fc5\u8981\u53c2\u6570\u3002\u5c06 str1,str2,..
\u8fde\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u3002 \u8bf4\u660e\uff1a\u5982\u679c\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT CONCAT('My', 'S', 'QL');\n+-------------------+\n| concat(My, S, QL) |\n+-------------------+\n| MySQL |\n+-------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CONCAT('My', NULL, 'QL');\n+----------------------+\n| concat(My, null, QL) |\n+----------------------+\n| NULL |\n+----------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/concat/#_5","title":"\u9650\u5236","text":"CONCAT()
\u5f53\u524d\u8fd8\u4e0d\u652f\u6301\u5e26\u5f15\u53f7\u7684\u5b57\u7b26\u4e32\u53c2\u6570\u548c\u6570\u5b57\u53c2\u6570\u3002
\u5224\u65ad\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u5305\u542b\u81f3\u5c11\u4e00\u4e2a\u5b57\u8282\u5219\u4e0d\u4e3a\u7a7a\uff0c\u5373\u4f7f\u662f\u4e00\u4e2a\u7a7a\u683c\u6216\u8005 NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> EMPTY(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0cCHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_4","title":"\u8fd4\u56de\u503c","text":"\u7a7a\u5b57\u7b26\u4e32\u8fd4\u56de 1\uff0c\u975e\u7a7a\u5b57\u7b26\u4e32\u8fd4\u56de 0\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/empty/#_5","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a varchar(255),b varchar(255));\n> insert into t1 values('', 'abcd');\n> insert into t1 values('1111', '');\n> select empty(a),empty(b) from t1;\n+----------+----------+\n| empty(a) | empty(b) |\n+----------+----------+\n| 1 | 0 |\n| 0 | 1 |\n+----------+----------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/","title":"ENDSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u68c0\u67e5\u662f\u5426\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e\u3002\u5b57\u7b26\u4e32\u5982\u679c\u4ee5\u6307\u5b9a\u540e\u7f00\u7ed3\u5c3e\u8fd4\u56de 1\uff0c\u5426\u5219\u5219\u8fd4\u56de 0\u3002\u8be5\u51fd\u6570\u662f\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> ENDSWITH(str,suffix)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002 suffix \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/endswith/#_4","title":"\u8fd4\u56de\u503c","text":"> drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'XI'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'XI');\n> select a,endsWith(b,'a') from t1;\n+------+----------------+\n| a | endswith(b, a) |\n+------+----------------+\n| 1 | 0 |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 0 |\n| 5 | 0 |\n| 6 | 1 |\n+------+----------------+\n> select a,b,c from t1 where endswith(b,'a')=1 and endswith(c,'I')=1;\n+------+---------------+------+\n| a | b | c |\n+------+---------------+------+\n| 3 | Aniket Sharma | XI |\n| 6 | Tapan Samanta | XI |\n+------+---------------+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/","title":"FIELD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FIELD()
\u51fd\u6570\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5b57\u7b26\u4e32 str
\u5728\u5b57\u7b26\u4e32\u5217\u8868 (str1,str2,str3,...) \u4e2d\u7684\u4f4d\u7f6e\u3002
> FIELD(str,str1,str2,str3,...)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u5728\u5217\u8868\u4e2d\u67e5\u627e\u7684\u503c\uff0c\u4e14\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002 str1,str2,str3,... \u5fc5\u8981\u53c2\u6570\u3002\u88ab\u641c\u7d22\u7684\u5217\u8868\u4e2d\u7684\u5404\u4e2a\u5143\u7d20\uff0c\u4e14\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/field/#_4","title":"\u8fd4\u56de\u503c","text":"\u5982\u679c FIELD()
\u7684\u6240\u6709\u53c2\u6570\u90fd\u662f string \u7c7b\u578b\uff0c\u5219\u6240\u6709\u53c2\u6570\u90fd\u4f5c\u4e3a string \u7c7b\u578b\u8fdb\u884c\u6bd4\u8f83\u3002\u5982\u679c\u6240\u6709\u53c2\u6570\u90fd\u662f\u6570\u5b57\uff0c\u5219\u5c06\u5b83\u4eec\u4f5c\u4e3a\u6570\u5b57\u8fdb\u884c\u6bd4\u8f83\u3002\u5982\u679c\u6240\u6709\u53c2\u6570\u90fd\u662f double \u7c7b\u578b\uff0c\u5219\u5c06\u5b83\u4eec\u4f5c\u4e3a double \u7c7b\u578b\u8fdb\u884c\u6bd4\u8f83\u3002
\u5982\u679c\u5728\u5217\u8868\u4e2d\u627e\u5230\u6307\u5b9a\u7684\u503c\uff0cFIELD()
\u51fd\u6570\u8fd4\u56de\u5bf9\u5e94\u7684\u4f4d\u7f6e\u7d22\u5f15\u3002FIELD()
\u51fd\u6570\u8fd4\u56de\u7684\u7d22\u5f15\u7684\u503c\u4ece 1 \u5f00\u59cb\u3002
\u5982\u679c\u5728\u5217\u8868\u4e2d\u627e\u5230\u591a\u4e2a\u6307\u5b9a\u7684\u503c\uff0cFIELD()
\u51fd\u6570\u53ea\u8fd4\u56de\u7b2c\u4e00\u4e2a\u7684\u7d22\u5f15\u503c\u3002
\u5982\u679c\u5728\u5217\u8868\u4e2d\u627e\u4e0d\u5230\u6307\u5b9a\u7684\u503c\uff0cFIELD()
\u51fd\u6570\u8fd4\u56de 0\u3002
\u5982\u679c\u8981\u67e5\u627e\u7684\u503c\u4e3a NULL
\uff0cFIELD()
\u51fd\u6570\u8fd4\u56de 0\u3002
mysql> SELECT FIELD('Bb', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Bb, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n| 2 |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FIELD('Gg', 'Aa', 'Bb', 'Cc', 'Dd', 'Ff');\n+-------------------------------+\n| field(Gg, Aa, Bb, Cc, Dd, Ff) |\n+-------------------------------+\n| 0 |\n+-------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t;\ncreate table t(\ni int,\nf float,\nd double\n);\ninsert into t() values (1, 1.1, 2.2), (2, 3.3, 4.4), (0, 0, 0), (0, null, 0);\n\nmysql> select * from t;\n+------+------+------+\n| i | f | d |\n+------+------+------+\n| 1 | 1.1 | 2.2 |\n| 2 | 3.3 | 4.4 |\n| 0 | 0 | 0 |\n| 0 | NULL | 0 |\n+------+------+------+\n4 rows in set (0.01 sec)\n\nmysql> select field(1, i, f, d) from t;\n+-------------------+\n| field(1, i, f, d) |\n+-------------------+\n| 1 |\n| 0 |\n| 0 |\n| 0 |\n+-------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field(i, f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(i, f, d, 0, 1, 2) |\n+-------------------------+\n| 4 |\n| 5 |\n| 1 |\n| 2 |\n+-------------------------+\n4 rows in set (0.01 sec)\n\nmysql> select field('1', f, d, 0, 1, 2) from t;\n+-------------------------+\n| field(1, f, d, 0, 1, 2) |\n+-------------------------+\n| 4 |\n| 4 |\n| 4 |\n| 4 |\n+-------------------------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/","title":"FIND_IN_SET()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5982\u679c\u5b57\u7b26\u4e32 str \u5728\u7531 N \u4e2a\u5b50\u5b57\u7b26\u4e32\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u5217\u8868 strlist \u4e2d\uff0c\u5219\u8fd4\u56de\u503c\u7684\u8303\u56f4\u5728 1 \u5230 N \u4e4b\u95f4\u3002\u4e00\u4e2a\u5b57\u7b26\u4e32\u5217\u8868\u5c31\u662f\u7531 ,
\u7b26\u53f7\u5206\u5f00\u7684\u5b50\u5b57\u7b26\u4e32\u7ec4\u6210\u3002\u5982\u679c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5e38\u91cf\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f SET
\u7c7b\u578b\u7684\u5217\uff0c\u90a3\u4e48 FIND_IN_SET()
\u51fd\u6570\u5c06\u4f18\u5316\u4e3a\u4f7f\u7528\u4f4d\u8fd0\u7b97\u3002\u5982\u679c str \u4e0d\u5728 strlist \u4e2d\u6216\u8005 strlist \u662f\u7a7a\u5b57\u7b26\u4e32\uff0c\u5219\u8fd4\u56de 0\u3002\u5982\u679c\u4efb\u4e00\u53c2\u6570\u4e3a NULL \u5219\u8fd4\u56de NULL
\u3002\u5982\u679c\u7b2c\u4e00\u4e2a\u53c2\u6570\u5305\u542b\u9017\u53f7 (,)
\u5b57\u7b26\uff0c\u6b64\u51fd\u6570\u5c06\u65e0\u6cd5\u6b63\u5e38\u8fd0\u884c\u3002
> FIND_IN_SET(str,strlist)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002 strlist \u5fc5\u8981\u53c2\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/find-in-set/#_4","title":"\u793a\u4f8b","text":"select find_in_set('b','a,b,c,d');\n+-------------------------+\n| find_in_set(b, a,b,c,d) |\n+-------------------------+\n| 2 |\n+-------------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/","title":"FORMAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FORMAT
\u51fd\u6570\u7528\u4e8e\u5c06\u6570\u5b57\u683c\u5f0f\u8bbe\u7f6e\u4e3a \"#,###,###.##\" \u683c\u5f0f\uff0c\u5e76\u56db\u820d\u4e94\u5165\u5230\u5c0f\u6570\u70b9\u540e\u4e00\u4f4d\u3002\u683c\u5f0f\u5316\u6570\u5b57\u540e\uff0c\u5b83\u5c06\u4ee5\u5b57\u7b26\u4e32\u7684\u5f62\u5f0f\u8fd4\u56de\u503c\u3002
> FORMAT(X,D[,locale])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e X \u5fc5\u8981\u53c2\u6570\u3002X \u662f\u8981\u683c\u5f0f\u5316\u7684\u6570\u5b57\u3002\u5982\u679c X \u662f NULL\uff0c\u51fd\u6570\u5c06\u8fd4\u56de NULL\u3002 D \u5fc5\u8981\u53c2\u6570\u3002D \u662f\u8981\u820d\u5165\u5c0f\u6570\u4f4d\u6570 \u5982\u679c D \u662f 0\uff0c\u5219\u7ed3\u679c\u6ca1\u6709\u5c0f\u6570\u70b9\u6216\u6ca1\u6709\u5c0f\u6570\u90e8\u5206\u3002 \u5982\u679c D \u4e3a NULL\uff0c\u51fd\u6570\u8fd4\u56de NULL\u3002 [,locale] \u53ef\u9009\u53c2\u6570\u3002\u53ef\u9009\u53c2\u6570 [,locale] \u6307\u5b9a\u8981\u4f7f\u7528\u7684\u8bed\u8a00\u73af\u5883\uff0c\u5e76\u4e14\u7528\u4e8e\u786e\u5b9a\u5343\u4e2a\u5206\u9694\u7b26\u548c\u5206\u9694\u7b26\u4e4b\u95f4\u7684\u5206\u7ec4\u3002\u5982\u679c [locale] \u8bbe\u7f6e\u4e3a NULL \u6216\u672a\u6307\u5b9a\uff0c\u5219\u9ed8\u8ba4\u8bed\u8a00\u73af\u5883\u4e3a 'en_US'\u3002[,locale]
\u652f\u6301\u8bed\u8a00\u73af\u5883\u53c2\u6570\u4e0e MySQL \u4e00\u81f4\uff0c\u53c2\u89c1MySQL Server Locale Support\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/format/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT FORMAT(12332.123456, 4);\n+-------------------------+\n| format(12332.123456, 4) |\n+-------------------------+\n| 12,332.1235 |\n+-------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(12332.1,4);\n+--------------------+\n| format(12332.1, 4) |\n+--------------------+\n| 12,332.1000 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,0);\n+--------------------+\n| format(12332.2, 0) |\n+--------------------+\n| 12,332 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(12332.2,2,'de_DE');\n+---------------------------+\n| format(12332.2, 2, de_DE) |\n+---------------------------+\n| 12.332,20 |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(19999999.999999999,4);\n+-------------------------------+\n| format(19999999.999999999, 4) |\n+-------------------------------+\n| 20,000,000.0000 |\n+-------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"en_US\");\n+-----------------------------+\n| format(-.12334.2, 2, en_US) |\n+-----------------------------+\n| -0.12 |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT FORMAT(\"-.12334.2\",\"2\", \"de_CH\");\n+-----------------------------+\n| format(-.12334.2, 2, de_CH) |\n+-----------------------------+\n| -0.12 |\n+-----------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/","title":"FROM_BASE64()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"FROM_BASE64()
\u7528\u4e8e\u5c06 Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u56de\u539f\u59cb\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff08\u6216\u6587\u672c\u6570\u636e\uff09\u3002\u53ef\u4ee5\u89e3\u7801\u4f7f\u7528 TO_BASE64()
\u51fd\u6570\u8fdb\u884c Base64 \u7f16\u7801\u7684\u6570\u636e\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u7ed3\u679c\u4e3a NULL\u3002
> FROM_BASE64(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u7684 Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/from_base64/#_4","title":"\u793a\u4f8b","text":"mysql> select from_base64('MjU1');\n+-------------------+\n| from_base64(MjU1) |\n+-------------------+\n| 255 |\n+-------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_BASE64('abc'), FROM_BASE64(TO_BASE64('abc'));\n+----------------+-----------------------------+\n| to_base64(abc) | from_base64(to_base64(abc)) |\n+----------------+-----------------------------+\n| YWJj | abc |\n+----------------+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> select from_base64(null);\n+-------------------+\n| from_base64(null) |\n+-------------------+\n| NULL |\n+-------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/","title":"HEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5bf9\u4e8e\u5b57\u7b26\u4e32\u53c2\u6570 str\uff0cHEX()
\u8fd4\u56de str \u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002\u5176\u4e2d\uff0cstr \u4e2d\u7684\u6bcf\u4e2a\u5b57\u7b26\u7684\u6bcf\u4e2a\u5b57\u8282\u90fd\u8f6c\u6362\u4e3a\u4e24\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57 (\u591a\u5b57\u8282\u5b57\u7b26\u8f6c\u6362\u6210\u4e24\u4e2a\u4ee5\u4e0a\u7684\u6570\u5b57)\u3002
\u5bf9\u4e8e\u6570\u503c\u53c2\u6570 N\uff0cHEX()
\u8fd4\u56de N \u503c\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u5f62\u5f0f\uff0c\u4e14\u6309\u7167\u6574\u6570\u8fdb\u884c\u8f6c\u6362\u3002\u8fd9\u7b49\u540c\u4e8e CONV(N,10,16)
\uff0c\u76f8\u53cd\u7684\u64cd\u4f5c\u6267\u884c CONV(HEX(N),16,10)
\u3002
\u5bf9\u4e8e NULL
\u53c2\u6570\uff0c\u6b64\u51fd\u6570\u8fd4\u56de NULL
\u3002
> HEX(str), HEX(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u4e3a\u5341\u516d\u8fdb\u5236\u7684\u6570\u5b57\u3002 str \u5fc5\u8981\u53c2\u6570\u3002\u5b57\u7b26\u4e32\uff0c\u5176\u6bcf\u4e2a\u5b57\u7b26\u90fd\u8981\u8f6c\u6362\u4e3a\u4e24\u4e2a\u5341\u516d\u8fdb\u5236\u6570\u5b57\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/hex/#_4","title":"\u793a\u4f8b","text":"> SELECT HEX('abc');\n+----------+\n| hex(abc) |\n+----------+\n| 616263 |\n+----------+\n1 row in set (0.00 sec)\n\n> SELECT HEX(255);\n+----------+\n| hex(255) |\n+----------+\n| FF |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/","title":"INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"INSTR()
\u51fd\u6570\u4e5f\u662f\u7528\u6765\u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u5728\u7ed9\u5b9a\u5b57\u7b26\u4e32\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u3002\u8fd9\u4e2a\u51fd\u6570\u662f\u591a\u5b57\u8282\u5b89\u5168\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u9002\u7528\u4e8e\u5404\u79cd\u5b57\u7b26\u7f16\u7801\uff0c\u5e76\u4e14\u80fd\u6b63\u786e\u5904\u7406\u591a\u5b57\u8282\u5b57\u7b26\uff08\u4f8b\u5982 UTF-8 \u7f16\u7801\u7684\u5b57\u7b26\uff09\u3002
INSTR()
\u51fd\u6570\u4e3b\u8981\u662f\u8fdb\u884c\u6570\u636e\u6e05\u6d17\u548c\u8f6c\u6362\uff0c\u4f8b\u5982\u5f53\u4f60\u9700\u8981\u5728\u6587\u672c\u5b57\u6bb5\u4e2d\u67e5\u627e\u7279\u5b9a\u7684\u5b50\u5b57\u7b26\u4e32\u6216\u6839\u636e\u7279\u5b9a\u7684\u5b57\u7b26\u5206\u5272\u6587\u672c\u5b57\u6bb5\u65f6\u3002\u8fd9\u5bf9\u4e8e\u5904\u7406\u5305\u542b\u67d0\u79cd\u6a21\u5f0f\u6216\u683c\u5f0f\u7684\u6570\u636e\uff08\u5982\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3001\u7535\u8bdd\u53f7\u7801\u7b49\uff09\u975e\u5e38\u6709\u7528\u3002
\u5173\u4e8e\u5927\u5c0f\u5199\u7684\u5904\u7406\uff0cINSTR()
\u51fd\u6570\u53ea\u6709\u5728\u81f3\u5c11\u6709\u4e00\u4e2a\u53c2\u6570\u662f\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u60c5\u51b5\u4e0b\u624d\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5bf9\u4e8e\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0cINSTR()
\u51fd\u6570\u662f\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u8fdb\u884c\u5927\u5c0f\u5199\u654f\u611f\u7684\u6bd4\u8f83\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 BINARY
\u5173\u952e\u5b57\u6765\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u683c\u5f0f\u3002
\u4f8b\u5982\uff1a
SELECT INSTR(BINARY 'abc', 'A');\n
\u4e0a\u8ff0\u67e5\u8be2\u5c06\u8fd4\u56de 0\uff0c\u56e0\u4e3a\u5728\u4e8c\u8fdb\u5236\u683c\u5f0f\u4e0b\uff0c'A' \u548c 'a' \u88ab\u8ba4\u4e3a\u662f\u4e0d\u540c\u7684\u5b57\u7b26\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> INSTR(str,substr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002string
\u662f\u8981\u5728\u5176\u4e2d\u641c\u7d22\u7684\u5b57\u7b26\u4e32\u3002 substr \u5fc5\u8981\u53c2\u6570\u3002substring
\u662f\u4f60\u6b63\u5728\u67e5\u627e\u7684\u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/instr/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT INSTR('foobarbar', 'bar');\n+-----------------------+\n| instr(foobarbar, bar) |\n+-----------------------+\n| 4 |\n+-----------------------+\n1 row in set (0.01 sec)\n
-- -- \u5728\u5b57\u7b26\u4e32 'Hello World' \u4e2d\u67e5\u627e 'o' \u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\uff0cINSTR \u51fd\u6570\u5c06\u8fd4\u56de 5\uff0c\u56e0\u4e3a 'o' \u9996\u6b21\u51fa\u73b0\u5728 'Hello World' \u4e2d\u7684\u7b2c 5 \u4e2a\u4f4d\u7f6e\nmysql> SELECT INSTR('Hello World', 'o');\n+-----------------------+\n| instr(Hello World, o) |\n+-----------------------+\n| 5 |\n+-----------------------+\n1 row in set (0.01 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a t1 \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e24\u4e2a VARCHAR \u7c7b\u578b\u7684\u5217 a \u548c b\nCREATE TABLE t1(a VARCHAR, b VARCHAR);\n\n-- \u5411\u8868 t1 \u63d2\u5165\u4e09\u884c\u6570\u636e\nINSERT INTO t1 VALUES('axa','x'),('abababa','qq'),('qwer','er');\n\n-- \u4ece\u8868 t1 \u4e2d\u9009\u62e9\u6bcf\u4e00\u884c\uff0c\u7136\u540e\u4f7f\u7528 INSTR \u51fd\u6570\u627e\u51fa\u5217 a \u4e2d\u5217 b \u7684\u5b57\u7b26\u4e32\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\nmysql> select instr(a,b) from t1;\n+-------------+\n| instr(a, b) |\n+-------------+\n| 2 |\n| 0 |\n| 3 |\n+-------------+\n3 rows in set (0.01 sec)\n\n-- \u4ece\u8868 t1 \u4e2d\u9009\u62e9\u6bcf\u4e00\u884c\uff0c\u7136\u540e\u4f7f\u7528 INSTR \u51fd\u6570\u627e\u51fa\u5217 a \u4e2d NULL \u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\n-- \u7531\u4e8e NULL \u662f\u672a\u77e5\u503c\uff0c\u6240\u4ee5\u8fd9\u4e2a\u67e5\u8be2\u4f1a\u8fd4\u56de NULL\nmysql> select instr(a,null) from t1;\n+----------------+\n| instr(a, null) |\n+----------------+\n| NULL |\n| NULL |\n| NULL |\n+----------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/","title":"LCASE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LCASE()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\uff0c\u4e3a LOWER()
\u7684\u8fd1\u4e49\u8bcd\u3002
> LCASE(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lcase/#_4","title":"\u793a\u4f8b","text":"mysql> select lcase('HELLO');\n+--------------+\n| lcase(HELLO) |\n+--------------+\n| hello |\n+--------------+\n1 row in set (0.02 sec)\n\nmysql> select lcase('A'),lcase('B'),lcase('C');\n+----------+----------+----------+\n| lcase(A) | lcaser(B) | lcase(C) |\n+----------+----------+----------+\n| a | b | c |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/","title":"LEFT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LEFT()
\u51fd\u6570\u8fd4\u56de str \u5b57\u7b26\u4e32\u4e2d\u6700\u5de6\u8fb9\u7684\u957f\u5ea6\u5b57\u7b26\u3002\u5982\u679c str \u6216 len \u53c2\u6570\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u503c\u3002
> LEFT(str,len)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u63d0\u53d6\u5b50\u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u4e32\u3002 len \u5fc5\u8981\u53c2\u6570\u3002\u662f\u4e00\u4e2a\u6b63\u6574\u6570\uff0c\u6307\u5b9a\u5c06\u4ece\u5de6\u8fb9\u8fd4\u56de\u7684\u5b57\u7b26\u6570\u3002\u5982\u679c len \u4e3a 0 \u6216\u4e3a\u8d1f\uff0c\u5219 LEFT \u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u3002\u5982\u679c len \u5927\u4e8e str \u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff0c\u5219 LEFT \u51fd\u6570\u8fd4\u56de\u6574\u4e2a str \u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/left/#_4","title":"\u793a\u4f8b","text":"mysql> select left('abcde', 3) from dual;\n+----------------+\n| left(abcde, 3) |\n+----------------+\n| abc |\n+----------------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\nCREATE TABLE t1 (str VARCHAR(100) NOT NULL, len INT);\ninsert into t1 values('abcdefghijklmn',3);\ninsert into t1 values(' ABCDEFGH123456', 3);\ninsert into t1 values('ABCDEF GHIJKLMN', 20);\ninsert into t1 values('ABCDEFGHijklmn ', -1);\ninsert into t1 values('ABCDEFGH123456', -35627164);\ninsert into t1 values('', 3);\nmysql> select left(str, len) from t1;\n+------------------+\n| left(str, len) |\n+------------------+\n| abc |\n| A |\n| ABCDEF GHIJKLMN |\n| |\n| |\n| |\n+------------------+\n6 rows in set (0.01 sec)\n\nmysql> select left('sdfsdfsdfsdf', len) from t1;\n+-------------------------+\n| left(sdfsdfsdfsdf, len) |\n+-------------------------+\n| sdf |\n| sdf |\n| sdfsdfsdfsdf |\n| |\n| |\n| sdf |\n+-------------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/","title":"LENGTH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"length()
\u51fd\u6570\u8fd4\u56de\u4e86\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002
> LENGTH(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u60f3\u8981\u8ba1\u7b97\u957f\u5ea6\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/length/#_4","title":"\u793a\u4f8b","text":"> select a,length(a) from t1;\na length(a)\na 1\nab 2\nabc 3\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/","title":"LOCATE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOCATE()
\u51fd\u6570\u662f\u7528\u4e8e\u5728\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u5b50\u5b57\u7b26\u4e32\u6240\u5728\u4f4d\u7f6e\u7684\u51fd\u6570\u3002\u5b83\u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u4f4d\u7f6e\uff0c\u5982\u679c\u672a\u627e\u5230\uff0c\u5219\u8fd4\u56de 0\u3002
\u7531\u4e8e LOCATE()
\u51fd\u6570\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u6574\u6570\u503c\uff0c\u6240\u4ee5\u5b83\u53ef\u4ee5\u5d4c\u5957\u5728\u5176\u4ed6\u51fd\u6570\u91cc\u9762\u4f7f\u7528\uff0c\u6bd4\u5982\u53ef\u4ee5\u7528 substring \u51fd\u6570\u622a\u53d6\u5b57\u7b26\u4e32\u3002
\u5173\u4e8e\u5927\u5c0f\u5199\uff0cLOCATE()
\u51fd\u6570\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
> LOCATE(subtr,str,pos)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e substr \u5fc5\u8981\u53c2\u6570\u3002substring
\u662f\u4f60\u6b63\u5728\u67e5\u627e\u7684\u5b57\u7b26\u4e32\u3002 str \u5fc5\u8981\u53c2\u6570\u3002string
\u662f\u8981\u5728\u5176\u4e2d\u641c\u7d22\u7684\u5b57\u7b26\u4e32\u3002 pos \u975e\u5fc5\u8981\u53c2\u6570\u3002position
\u662f\u8868\u793a\u5f00\u59cb\u67e5\u8be2\u7684\u4f4d\u7f6e\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/locate/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT LOCATE('bar', 'footbarbar');\n+-------------------------+\n| locate(bar, footbarbar) |\n+-------------------------+\n| 5 |\n+-------------------------+\n1 row in set (0.00 sec)\n
mysql>SELECT LOCATE('bar', 'footbarbar',6);\n+----------------------------+\n| locate(bar, footbarbar, 6) |\n+----------------------------+\n| 8 |\n+----------------------------+\n1 row in set (0.00 sec)\n
mysql>SELECT SUBSTRING('hello world',LOCATE('o','hello world'),5);\n+---------------------------------------------------+\n| substring(hello world, locate(o, hello world), 5) |\n+---------------------------------------------------+\n| o wor |\n+---------------------------------------------------+\n1 row in set (0.00 sec)\n
mysql>select locate('a','ABC');\n+----------------+\n| locate(a, ABC) |\n+----------------+\n| 1 |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/","title":"LOWER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LOWER()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5f62\u5f0f\u3002
> LOWER(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lower/#_4","title":"\u793a\u4f8b","text":"mysql> select lower('HELLO');\n+--------------+\n| lower(HELLO) |\n+--------------+\n| hello |\n+--------------+\n1 row in set (0.02 sec)\n\nmysql> select lower('A'),lower('B'),lower('C');\n+----------+----------+----------+\n| lower(A) | lower(B) | lower(C) |\n+----------+----------+----------+\n| a | b | c |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/","title":"LPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u51fd\u6570 LPAD(str,len,padstr) \u5728\u5b57\u7b26\u4e32 str \u5de6\u4fa7\u4f7f\u7528 padstr \u8fdb\u884c\u586b\u5145\uff0c\u76f4\u81f3\u603b\u957f\u5ea6\u4e3a len \u7684\u5b57\u7b26\u4e32\uff0c\u6700\u540e\u8fd4\u56de\u586b\u5145\u540e\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c str \u7684\u957f\u5ea6\u5927\u4e8e len\uff0c\u90a3\u4e48\u6700\u540e\u7684\u957f\u5ea6\u5c06\u7f29\u51cf\u81f3 len\u3002 \u82e5 len \u4e3a\u8d1f\u6570\uff0c\u5219\u8fd4\u56de NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LPAD(str,len,padstr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u88ab\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002 len \u5fc5\u8981\u53c2\u6570\uff0c\u9700\u8981\u586b\u5145\u5230\u7684\u603b\u957f\u5ea6\u3002 padstr \u5fc5\u8981\u53c2\u6570\uff0c\u7528\u4e8e\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/lpad/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,LPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name | LeftPaddedString |\n+------------+-----------------+------------------+\n| 1 | Ananya Majumdar | _ _ _ _IX |\n| 2 | Anushka Samanta | _ _ _ _ X |\n| 3 | Aniket Sharma | _ _ _ _XI |\n| 4 | Anik Das | _ _ _ _ X |\n| 5 | Riya Jain | _ _ _ _IX |\n| 6 | Tapan Samanta | _ _ _ _ X |\n+------------+-----------------+------------------+\n> SELECT Student_id, lpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | Anan |\n| 2 | Anus |\n| 3 | Anik |\n| 4 | Anik |\n| 5 | Riya |\n| 6 | Tapa |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | NULL |\n| 2 | NULL |\n| 3 | NULL |\n| 4 | NULL |\n| 5 | NULL |\n| 6 | NULL |\n+------------+------------------+\n> SELECT Student_id, lpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | |\n| 2 | |\n| 3 | |\n| 4 | |\n| 5 | |\n| 6 | |\n+------------+------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/","title":"LTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"LTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u524d\u90e8\u7a7a\u683c\u53bb\u9664\uff0c\u8fd4\u56de\u5904\u7406\u540e\u7684\u5b57\u7b26\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> LTRIM(char)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e char \u5fc5\u8981\u53c2\u6570\uff0cCHAR \u4e0e VARCHAR \u5747\u53ef"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ltrim/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values(' matrix',' matrixone');\n> select ltrim(a),ltrim(b) from t1;\n\n+----------+-----------+\n| ltrim(a) | ltrim(b) |\n+----------+-----------+\n| matrix | matrixone |\n+----------+-----------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/","title":"MD5()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"MD5()
\u51fd\u6570\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u54c8\u5e0c\u51fd\u6570\uff0c\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684 32 \u5b57\u7b26\u957f\u7684\u5341\u516d\u8fdb\u5236 MD5 \u54c8\u5e0c\u503c\uff0c\u5b83\u53ef\u4ee5\u5c06\u4efb\u610f\u957f\u5ea6\u7684\u8f93\u5165\u6d88\u606f\u8f6c\u6362\u4e3a\u4e00\u4e2a 128 \u4f4d\uff0816 \u5b57\u8282\uff09\u7684\u54c8\u5e0c\u503c\uff0c\u901a\u5e38\u8868\u793a\u4e3a 32 \u4f4d\u7684\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002
> MD5(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/md5/#_4","title":"\u793a\u4f8b","text":"mysql> select md5(\"hello world\");\n+----------------------------------+\n| md5(hello world) |\n+----------------------------------+\n| 5eb63bbbe01eeed093cb22bb8f5acdc3 |\n+----------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select md5(null);\n+-----------+\n| md5(null) |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/","title":"OCT(N)","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u51fd\u6570 OCT(N)
\u8fd4\u56de N \u7684\u516b\u8fdb\u5236\u503c\u7684\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d N \u662f\u4e00\u4e2a longlong(BIGINT) \u7c7b\u578b\u7684\u6570\u5b57\uff0c\u5373\u5c06\u4e00\u4e2a\u6570\u5b57\u4ece\u5341\u8fdb\u5236\u6570\u5b57\u57fa\u6570\u7cfb\u7edf\u8f6c\u6362\u5230\u516b\u8fdb\u5236\u6570\u5b57\u57fa\u6570\u7cfb\u7edf\u3002 \u82e5 N \u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL
\u3002
> OCT(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002UINT \u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/oct/#_4","title":"\u793a\u4f8b","text":"SELECT OCT(12);\n+---------+\n| oct(12) |\n+---------+\n| 14.0000 |\n+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/","title":"REPEAT()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REPEAT()
\u7528\u4e8e\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32 str
\u91cd\u590d count
\u6b21\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c count
\u5c0f\u4e8e 1\uff0c\u5219\u8fd4\u56de\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\u3002\u5982\u679c str
\u6216 count
\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> REPEAT(str,count)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u91cd\u590d\u7684\u5b57\u7b26\u4e32\u3002 count \u5fc5\u8981\u53c2\u6570\u3002\u8981\u91cd\u590d\u7684\u6b21\u6570"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/repeat/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT repeat('abc', -1);\n+-----------------+\n| repeat(abc, -1) |\n+-----------------+\n| |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT repeat('abc', 1), repeat('abc', 2), repeat('abc', 3);\n+----------------+----------------+----------------+\n| repeat(abc, 1) | repeat(abc, 2) | repeat(abc, 3) |\n+----------------+----------------+----------------+\n| abc | abcabc | abcabcabc |\n+----------------+----------------+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/","title":"REVERSE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5c06 str \u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u987a\u5e8f\u7ffb\u8f6c\u8f93\u51fa\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> REVERSE(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e Str \u5fc5\u8981\u53c2\u6570\u3002\u9700\u8981\u7ffb\u8f6c\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/reverse/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a varchar(12),c char(30));\n> insert into t1 values('sdfad ','2022-02-02 22:22:22');\n> insert into t1 values(' sdfad ','2022-02-02 22:22:22');\n> insert into t1 values('adsf sdfad','2022-02-02 22:22:22');\n> insert into t1 values(' sdfad','2022-02-02 22:22:22');\n> select reverse(a),reverse(c) from t1;\n+-------------+---------------------+\n| reverse(a) | reverse(c) |\n+-------------+---------------------+\n| dafds | 22:22:22 20-20-2202 |\n| dafds | 22:22:22 20-20-2202 |\n| dafds fsda | 22:22:22 20-20-2202 |\n| dafds | 22:22:22 20-20-2202 |\n+-------------+---------------------+\n> select a from t1 where reverse(a) like 'daf%';\n+-------------+\n| a |\n+-------------+\n| adsf sdfad |\n| sdfad |\n+-------------+\n> select reverse(a) reversea,reverse(reverse(a)) normala from t1;\n+-------------+-------------+\n| reversea | normala |\n+-------------+-------------+\n| dafds | sdfad |\n| dafds | sdfad |\n| dafds fsda | adsf sdfad |\n| dafds | sdfad |\n+-------------+-------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/","title":"RPAD()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u51fd\u6570 RPAD(str,len,padstr) \u5728\u5b57\u7b26\u4e32 str \u53f3\u4fa7\u4f7f\u7528 padstr \u8fdb\u884c\u586b\u5145\uff0c\u76f4\u81f3\u603b\u957f\u5ea6\u4e3a len \u7684\u5b57\u7b26\u4e32\uff0c\u6700\u540e\u8fd4\u56de\u586b\u5145\u540e\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c str \u7684\u957f\u5ea6\u5927\u4e8e len\uff0c\u90a3\u4e48\u6700\u540e\u7684\u957f\u5ea6\u5c06\u7f29\u51cf\u81f3 len\u3002 \u82e5 len \u4e3a\u8d1f\u6570\uff0c\u5219\u8fd4\u56de NULL\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> RPAD(str,len,padstr)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u88ab\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002 len \u5fc5\u8981\u53c2\u6570\uff0c\u9700\u8981\u586b\u5145\u5230\u7684\u603b\u957f\u5ea6\u3002 padstr \u5fc5\u8981\u53c2\u6570\uff0c\u7528\u4e8e\u586b\u5145\u7684\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rpad/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1(Student_id INT,Student_name VARCHAR(100),Student_Class CHAR(20));\n> INSERT INTO t1\nVALUES\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> SELECT Student_id, Student_name,RPAD(Student_Class, 10, ' _') AS LeftPaddedString FROM t1;\n+------------+-----------------+------------------+\n| Student_id | Student_name | LeftPaddedString |\n+------------+-----------------+------------------+\n| 1 | Ananya Majumdar | IX _ _ _ _ |\n| 2 | Anushka Samanta | X _ _ _ _ |\n| 3 | Aniket Sharma | XI _ _ _ _ |\n| 4 | Anik Das | X _ _ _ _ |\n| 5 | Riya Jain | IX _ _ _ _ |\n| 6 | Tapan Samanta | X _ _ _ _ |\n+------------+-----------------+------------------+\n> SELECT Student_id, rpad(Student_name,4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | Anan |\n| 2 | Anus |\n| 3 | Anik |\n| 4 | Anik |\n| 5 | Riya |\n| 6 | Tapa |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,-4,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | NULL |\n| 2 | NULL |\n| 3 | NULL |\n| 4 | NULL |\n| 5 | NULL |\n| 6 | NULL |\n+------------+------------------+\n> SELECT Student_id, rpad(Student_name,0,'new') AS LeftPaddedString FROM t1;\n+------------+------------------+\n| Student_id | LeftPaddedString |\n+------------+------------------+\n| 1 | |\n| 2 | |\n| 3 | |\n| 4 | |\n| 5 | |\n| 6 | |\n+------------+------------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/","title":"RTRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"RTRIM() \u5c06\u8f93\u5165\u5b57\u7b26\u4e32\u7684\u540e\u65b9\u7a7a\u683c\u53bb\u9664\uff0c\u8fd4\u56de\u5904\u7406\u540e\u7684\u5b57\u7b26\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> RTRIM(char)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e char \u5fc5\u8981\u53c2\u6570\uff0cCHAR \u4e0e VARCHAR \u5747\u53ef"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/rtrim/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> create table t1(a char(8),b varchar(10));\n> insert into t1 values('matrix ','matrixone ');\n> select rtrim(a),rtrim(b) from t1;\n\n+----------+-----------+\n| rtrim(a) | rtrim(b) |\n+----------+-----------+\n| matrix | matrixone |\n+----------+-----------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/","title":"SHA1()/SHA()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SHA1()/SHA()
\u51fd\u6570\u662f\u4e00\u79cd\u52a0\u5bc6\u54c8\u5e0c\u51fd\u6570\uff0c\u7528\u4e8e\u8ba1\u7b97\u5e76\u8fd4\u56de\u7ed9\u5b9a\u5b57\u7b26\u4e32\u7684 SHA-1 \u54c8\u5e0c\u503c\uff0c\u5b83\u5c06\u4efb\u610f\u957f\u5ea6\u7684\u8f93\u5165\u6d88\u606f\u8f6c\u6362\u4e3a\u4e00\u4e2a\u56fa\u5b9a\u957f\u5ea6\uff08160 \u4f4d\uff0c\u5373 20 \u5b57\u8282\uff09\u7684\u54c8\u5e0c\u503c\uff0c\u901a\u5e38\u8868\u793a\u4e3a 40 \u4e2a\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002
> SHA1/SHA(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u52a0\u5bc6\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha1/#_4","title":"\u793a\u4f8b","text":"mysql> select sha1(\"hello world\");\n+------------------------------------------+\n| sha1(hello world) |\n+------------------------------------------+\n| 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed |\n+------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sha(\"hello world\");\n+------------------------------------------+\n| sha(hello world) |\n+------------------------------------------+\n| 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed |\n+------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sha1(null);\n+------------+\n| sha1(null) |\n+------------+\n| NULL |\n+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/","title":"SHA2()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SHA2()
\u52a0\u5bc6\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u8f93\u5165\u5b57\u7b26\u4e32\u7684 SHA2 \u54c8\u5e0c\u503c\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u8981\u6563\u5217\u7684\u660e\u6587\u5b57\u7b26\u4e32\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570\u6307\u793a\u7ed3\u679c\u7684\u6240\u9700\u4f4d\u957f\uff0c\u5176\u503c\u5fc5\u987b\u4e3a 224\u3001256\u3001384\u3001512 \u6216 0\uff08\u76f8\u5f53\u4e8e 256\uff09\uff0c\u5206\u522b\u5bf9\u5e94\u4e86 SHA-224, SHA-256, SHA-384 \u548c SHA-512 \u7b97\u6cd5\u3002\u5982\u679c\u53c2\u6570\u662f NULL \u6216\u8005\u4e0d\u662f\u4e00\u4e2a\u5408\u6cd5\u503c\u5c06\u8fd4\u56de NULL\u3002
> SHA2(str, hash_length)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8ba1\u7b97\u54c8\u5e0c\u503c\u7684\u5b57\u7b26\u4e32 hash_length \u5fc5\u8981\u53c2\u6570\u3002\u54c8\u5e0c\u957f\u5ea6\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/sha2/#_4","title":"\u793a\u4f8b","text":"mysql> select sha2(\"hello world\", 384);\n+--------------------------------------------------------------------------------------------------+\n| sha2(hello world, 384) |\n+--------------------------------------------------------------------------------------------------+\n| fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd |\n+--------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select sha2(null, 512);\n+-----------------+\n| sha2(null, 512) |\n+-----------------+\n| NULL |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql> select sha2(\"abc\", 99);\n+---------------+\n| sha2(abc, 99) |\n+---------------+\n| NULL |\n+---------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/","title":"SPACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SPACE(N) \u8fd4\u56de N \u4e2a\u7a7a\u683c\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_2","title":"\u8bed\u6cd5","text":"> SPACE(N)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e N \u5fc5\u8981\u53c2\u6570\u3002UINT \u7c7b\u578b"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/space/#_4","title":"\u793a\u4f8b","text":"> drop table if exists t1;\n> CREATE TABLE t1\n(\nEmployee_name VARCHAR(100) NOT NULL,\nJoining_Date DATE NOT NULL\n);\n> INSERT INTO t1\n(Employee_name, Joining_Date )\nVALUES\n(' Ananya Majumdar', '2000-01-11'),\n(' Anushka Samanta', '2002-11-10' ),\n(' Aniket Sharma ', '2005-06-11' ),\n(' Anik Das', '2008-01-21' ),\n(' Riya Jain', '2008-02-01' ),\n(' Tapan Samanta', '2010-01-11' ),\n(' Deepak Sharma', '2014-12-01' ),\n(' Ankana Jana', '2018-08-17'),\n(' Shreya Ghosh', '2020-09-10') ;\n> INSERT INTO t1\n(Employee_name, Joining_Date ) values(' ','2014-12-01');\n> select * from t1 where Employee_name=space(5);\n+---------------+--------------+\n| Employee_name | Joining_Date |\n+---------------+--------------+\n| | 2014-12-01 |\n+---------------+--------------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/","title":"SPLIT_PART()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SPLIT_PART()
\u7528\u4e8e\u5728\u7ed9\u5b9a\u7684\u5206\u9694\u7b26\u57fa\u7840\u4e0a\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u5206\u89e3\u6210\u591a\u4e2a\u90e8\u5206\uff0c\u5e76\u8fd4\u56de\u6307\u5b9a\u7684\u90e8\u5206\u3002
\u5982\u679c\u6307\u5b9a\u7684\u90e8\u5206\uff08\u7531 unsigned_integer
\u53c2\u6570\u6307\u5b9a\uff09\u8d85\u51fa\u4e86\u5b9e\u9645\u5b58\u5728\u7684\u90e8\u5206\u6570\u91cf\uff0cSPLIT_PART()
\u5c06\u8fd4\u56de NULL
\u3002
SPLIT_PART()
\u53ea\u4f1a\u4ece\u5de6\u5230\u53f3\u5f00\u59cb\u8ba1\u6570\u90e8\u5206\uff0c\u5982\u679c unsigned_integer
\u4e3a\u8d1f\u6570\uff0c\u5c06\u4f1a\u62a5\u9519\u3002
> SPLIT_PART(expr, delimiter, unsigned_integer)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u5fc5\u8981\u53c2\u6570\u3002\u8981\u88ab\u62c6\u5206\u7684\u5b57\u7b26\u4e32\u3002 delimiter \u5fc5\u8981\u53c2\u6570\u3002\u7528\u4e8e\u5206\u5272\u5b57\u7b26\u4e32\u7684\u5206\u9694\u7b26\u3002 unsigned_integer \u5fc5\u8981\u53c2\u6570\u3002\u8fd9\u662f\u4e00\u4e2a\u6574\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u54ea\u4e2a\u90e8\u5206\u3002\u7b2c\u4e00\u4e2a\u90e8\u5206\u662f 1\uff0c\u7b2c\u4e8c\u4e2a\u90e8\u5206\u662f 2\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/split_part/#_4","title":"\u793a\u4f8b","text":"-- \u62c6\u5206\u5b57\u7b26\u4e32 'axbxc'\uff0c\u5e76\u4f7f\u7528'x'\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u8be5\u51fd\u6570\u5c06\u8fd4\u56de\u5b57\u7b26\u4e32'axbxc'\u7684\u7b2c\u4e00\u90e8\u5206\u3002\u6240\u4ee5\u6267\u884c\u8fd9\u6761 SQL \u8bed\u53e5\u7684\u7ed3\u679c\u662f 'a'\uff0c\u56e0\u4e3a\u5728'x'\u5206\u9694\u7b26\u7684\u57fa\u7840\u4e0a\u5206\u5272\u5b57\u7b26\u4e32'axbxc'\u540e\u7684\u7b2c\u4e00\u90e8\u5206\u662f 'a'\u3002\nmysql> select split_part('axbxc','x',1);\n+-------------------------+\n| split_part(axbxc, x, 1) |\n+-------------------------+\n| a |\n+-------------------------+\n1 row in set (0.00 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868't1'\uff0c\u5b83\u6709\u4e09\u4e2a\u5217\uff1a'a'\uff08varchar \u7c7b\u578b\uff09\uff0c'b'\uff08varchar \u7c7b\u578b\uff09\uff0c\u548c'c'\uff08int \u7c7b\u578b\uff09\u3002\ncreate table t1(a varchar,b varchar,c int);\n-- \u5411't1'\u8868\u4e2d\u63d2\u5165\u591a\u884c\u6570\u636e\ninsert into t1 values('axbxc','x',1),('axbxcxd','x',2),('axbxcxd','x',3),('axbxcxd','xc',1),('axbxcxd','xc',2),('axbxcxd','xc',3),('axbxcxd','asas',1),('axbxcxd','asas',2),(null,'asas',3),('axbxcxd',null,3),('axbxcxd','asas',null),('axxx','x',1),('axxx','x',2);\n-- \u67e5\u8be2\u4f7f\u7528 split_part \u51fd\u6570\u5904\u7406't1'\u8868\u4e2d\u7684\u6bcf\u884c\u6570\u636e\u3002\u5bf9\u4e8e\u6bcf\u884c\uff0c\u5b83\u90fd\u4f1a\u628a'a'\u5217\u7684\u503c\u5206\u5272\u6210\u591a\u4e2a\u90e8\u5206\uff08\u4f7f\u7528'b'\u5217\u7684\u503c\u4f5c\u4e3a\u5206\u9694\u7b26\uff09\uff0c\u7136\u540e\u8fd4\u56de\u6307\u5b9a\u7684\u90e8\u5206\uff08\u7531'c'\u5217\u7684\u503c\u6307\u5b9a\uff09\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u7b2c\u4e00\u884c\u6570\u636e\uff08'axbxc', 'x', 1\uff09\uff0c\u5b83\u4f1a\u8fd4\u56de'a'\uff0c\u56e0\u4e3a'a'\u662f\u5728'x'\u5206\u9694\u7b26\u7684\u57fa\u7840\u4e0a\u5206\u5272\u5b57\u7b26\u4e32'axbxc'\u540e\u7684\u7b2c\u4e00\u90e8\u5206\u3002\nmysql> select split_part(a,b,c) from t1;\n+---------------------+\n| split_part(a, b, c) |\n+---------------------+\n| a |\n| b |\n| c |\n| axb |\n| xd |\n| NULL |\n| axbxcxd |\n| NULL |\n| NULL |\n| NULL |\n| NULL |\n| a |\n| NULL |\n+---------------------+\n13 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/","title":"STARTSWITH()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5b57\u7b26\u4e32\u5982\u679c\u4ee5\u6307\u5b9a\u524d\u7f00\u5f00\u59cb\u8fd4\u56de 1\uff0c\u5426\u5219\u5219\u8fd4\u56de 0\u3002\u8be5\u51fd\u6570\u662f\u5bf9\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> STARTSWITH(str,prefix)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002 prefix \u5fc5\u8981\u53c2\u6570\u3002CHAR \u548c VARCHAR \u7c7b\u578b\u90fd\u652f\u6301\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/startswith/#_4","title":"\u8fd4\u56de\u503c","text":"> drop table if exists t1;\n> create table t1(a int,b varchar(100),c char(20));\n> insert into t1 values\n(1,'Ananya Majumdar', 'IX'),\n(2,'Anushka Samanta', 'X'),\n(3,'Aniket Sharma', 'XI'),\n(4,'Anik Das', 'X'),\n(5,'Riya Jain', 'IX'),\n(6,'Tapan Samanta', 'X');\n> select a,startswith(b,'An') from t1;\n+------+-------------------+\n| a | startswith(b, An) |\n+------+-------------------+\n| 1 | 1 |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 1 |\n| 5 | 0 |\n| 6 | 0 |\n+------+-------------------+\n> select a,b,c from t1 where startswith(b,'An')=1 and startswith(c,'I')=1;\n+------+-----------------+------+\n| a | b | c |\n+------+-----------------+------+\n| 1 | Ananya Majumdar | IX |\n+------+-----------------+------+\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/","title":"SUBSTRING_INDEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u6b64\u51fd\u6570 SUBSTRING_INDEX()
\u4ee5\u5206\u9694\u7b26\u4e3a\u7d22\u5f15\uff0c\u83b7\u53d6\u4e0d\u540c\u7d22\u5f15\u4f4d\u7684\u5b57\u7b26\u3002
\u5982\u679c count \u4e3a\u6b63\uff0c\u5219\u8fd4\u56de\u6700\u540e\u4e00\u4e2a\u5206\u9694\u7b26\u5de6\u4fa7\uff08\u4ece\u5de6\u4fa7\u5f00\u59cb\u8ba1\u6570\uff09\u7684\u6240\u6709\u5185\u5bb9\u3002
\u5982\u679c count \u4e3a\u8d1f\u6570\uff0c\u5219\u8fd4\u56de\u6700\u540e\u4e00\u4e2a\u5206\u9694\u7b26\u53f3\u4fa7\uff08\u4ece\u53f3\u4fa7\u5f00\u59cb\u8ba1\u6570\uff09\u7684\u6240\u6709\u5185\u5bb9\u3002
\u5982\u679c\u53c2\u6570\u4e3a NULL
\uff0cSUBSTRING_INDEX()
\u5c06\u8fd4\u56de NULL
\u3002
> SUBSTRING_INDEX(str,delim,count)\n
\u5373\uff0csubstring_index\uff08\u201c\u5f85\u622a\u53d6\u6709\u7528\u90e8\u5206\u7684\u5b57\u7b26\u4e32\u201d\uff0c\u201c\u622a\u53d6\u6570\u636e\u4f9d\u636e\u7684\u5b57\u7b26\u201d\uff0c\u622a\u53d6\u5b57\u7b26\u7684\u4f4d\u7f6e N\uff09
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5b57\u7b26\u4e32 delim \u5206\u9694\u7b26 count \u8868\u793a delim \u51fa\u73b0\u6b21\u6570\u7684\u6574\u6570\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring-index/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);\n+--------------------------------------+\n| substring_index(www.mysql.com, ., 2) |\n+--------------------------------------+\n| www.mysql |\n+--------------------------------------+\n1 row in set (0.03 sec)\n\nmysql> select substring_index('xyz', 'abc', 9223372036854775808);\n+------------------------------------------------+\n| substring_index(xyz, abc, 9223372036854775808) |\n+------------------------------------------------+\n| xyz |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2);\n+---------------------------------------+\n| substring_index(www.mysql.com, ., -2) |\n+---------------------------------------+\n| mysql.com |\n+---------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('192,168,8,203', ',', 2), ',',-1);\n+--------------------------------------------------------------+\n| substring_index(substring_index(192,168,8,203, ,, 2), ,, -1) |\n+--------------------------------------------------------------+\n| 168 |\n+--------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ncreate table test(a varchar(100), b varchar(20), c int);\ninsert into test values('www.mysql.com', '.', 0);\ninsert into test values('www.mysql.com', '.', 1);\ninsert into test values('www.mysql.com', '.', 2);\ninsert into test values('www.mysql.com', '.', 3);\ninsert into test values('www.mysql.com', '.', 9223372036854775808);\ninsert into test values('www.mysql.com', '.', -1);\ninsert into test values('www.mysql.com', '.', -2);\ninsert into test values('www.mysql.com', '.', -3);\nmysql> select SUBSTRING_INDEX(a, b, c) from test;\n+--------------------------+\n| substring_index(a, b, c) |\n+--------------------------+\n| |\n| www |\n| www.mysql |\n| www.mysql.com |\n| com |\n| mysql.com |\n| www.mysql.com |\n+--------------------------+\n7 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/","title":"SUBSTRING()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SUBSTR()
\u548c MID()
\u90fd\u662f SUBSTRING()
\u7684\u540c\u4e49\u8bcd\u3002 \u4e0d\u5e26 len \u53c2\u6570\u7684\u5199\u6cd5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u4ece pos \u4f4d\u7f6e\u5f00\u59cb\u7684\u5b50\u5b57\u7b26\u4e32\u3002\u5e26 len \u53c2\u6570\u7684\u5199\u6cd5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u4ece pos \u4f4d\u7f6e\u5f00\u59cb\u7684\u957f\u5ea6\u4e3a len \u7684\u5b50\u5b57\u7b26\u4e32\u3002
> SUBSTRING(str,pos)\n> SUBSTR(str,pos,len)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u6bcd\u5b57\u7b26\u4e32\u3002CHAR \u4e0e VARCHAR \u7c7b\u578b\u5747\u53ef\u3002 pos \u5fc5\u8981\u53c2\u6570\uff0c\u5f00\u59cb\u4f4d\u7f6e len \u53ef\u9009\u53c2\u6570\uff0c\u8fd4\u56de\u5b50\u5b57\u7b26\u4e32\u957f\u5ea6"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/substring/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE IF NOT EXISTS t1 (\npub_id varchar(8) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_name varchar(50) COLLATE latin1_general_ci NOT NULL DEFAULT '',\npub_city varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\ncountry_office varchar(25) COLLATE latin1_general_ci NOT NULL DEFAULT '',\nno_of_branch int NOT NULL DEFAULT 0,\nestd date NOT NULL DEFAULT '2000-01-01'\n);\n\n> INSERT INTO t1 (pub_id, pub_name, pub_city, country, country_office, no_of_branch, estd) VALUES\n('P001', 'Jex Max Publication', 'New York', 'USA', 'New York', 15, '1969-12-25'),\n('P002', 'BPP Publication', 'Mumbai', 'India', 'New Delhi', 10, '1985-10-01'),\n('P003', 'New Harrold Publication', 'Adelaide', 'Australia', 'Sydney', 6, '1975-09-05'),\n('P004', 'Ultra Press Inc.', 'London', 'UK', 'London', 8, '1948-07-10'),\n('P005', 'Mountain Publication', 'Houstan', 'USA', 'Sun Diego', 25, '1975-01-01'),\n('P006', 'Summer Night Publication', 'New York', 'USA', 'Atlanta', 10, '1990-12-10'),\n('P007', 'Pieterson Grp. of Publishers', 'Cambridge', 'UK', 'London', 6, '1950-07-15'),\n('P008', 'Novel Publisher Ltd.', 'New Delhi', 'India', 'Bangalore', 10, '2000-01-01');\n\n> SELECT pub_name, SUBSTR(pub_name,4,5) FROM t1 WHERE country='USA';\n+--------------------------+------------------------+\n| pub_name | substr(pub_name, 4, 5) |\n+--------------------------+------------------------+\n| Jex Max Publication | Max |\n| Mountain Publication | ntain |\n| Summer Night Publication | mer N |\n+--------------------------+------------------------+\n3 rows in set (0.04 sec)\n\n> SELECT pub_name, SUBSTR(pub_name,5) FROM t1 WHERE country='USA';\n+--------------------------+----------------------+\n| pub_name | substr(pub_name, 5) |\n+--------------------------+----------------------+\n| Jex Max Publication | Max Publication |\n| Mountain Publication | tain Publication |\n| Summer Night Publication | er Night Publication |\n+--------------------------+----------------------+\n3 rows in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/","title":"TO_BASE64()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TO_BASE64()
\u51fd\u6570\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u4e0d\u662f\u5b57\u7b26\u4e32\uff0c\u5219\u4f1a\u5728\u8f6c\u6362\u4e4b\u524d\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u4e3a NULL\uff0c\u5219\u7ed3\u679c\u4e3a NULL\u3002
\u53ef\u4ee5\u4f7f\u7528 FROM_BASE64()
\u51fd\u6570\u5bf9 Base64 \u7f16\u7801\u5b57\u7b26\u4e32\u8fdb\u884c\u89e3\u7801\u3002
> TO_BASE64(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u8981\u8f6c\u6362\u4e3a Base64 \u7f16\u7801\u7684\u5b57\u7b26\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/to_base64/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT TO_BASE64('abc');\n+----------------+\n| to_base64(abc) |\n+----------------+\n| YWJj |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_BASE64(255);\n+----------------+\n| to_base64(255) |\n+----------------+\n| MjU1 |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT TO_BASE64(null);\n+-----------------+\n| to_base64(null) |\n+-----------------+\n| NULL |\n+-----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/","title":"TRIM()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"TRIM()
\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5220\u9664\u4e0d\u9700\u8981\u7684\u5b57\u7b26\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 LEADING
\uff0cTRAILING
\u6216 BOTH
\u9009\u9879\u660e\u786e\u6307\u793a TRIM()
\u51fd\u6570\u4ece\u5b57\u7b26\u4e32\u4e2d\u5220\u9664\u524d\u5bfc\uff0c\u5c3e\u968f\u6216\u524d\u5bfc\u548c\u5c3e\u968f\u7684\u4e0d\u5fc5\u8981\u7684\u5b57\u7b26\u3002
\u5982\u679c\u4f60\u6ca1\u6709\u6307\u5b9a\u4efb\u4f55\u5185\u5bb9\uff0cTRIM()
\u51fd\u6570\u9ed8\u8ba4\u4f7f\u7528 BOTH
\u9009\u9879\u3002
[remstr]
\u662f\u8981\u5220\u9664\u7684\u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u662f\u4e00\u4e2a\u7a7a\u683c\u3002\u5373\u5982\u679c\u4e0d\u6307\u5b9a\u7279\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u5219 TRIM()
\u51fd\u6570\u4ec5\u5220\u9664\u7a7a\u683c\u3002
> TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u662f\u8981\u5220\u9664\u5b50\u5b57\u7b26 remstr
\u7684\u5b57\u7b26\u4e32\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/trim/#_4","title":"\u793a\u4f8b","text":"mysql> select trim(' abc '), trim('abc '), trim(' abc'), trim('abc');\n+-------------+------------+------------+-----------+\n| trim( abc ) | trim(abc ) | trim( abc) | trim(abc) |\n+-------------+------------+------------+-----------+\n| abc | abc | abc | abc |\n+-------------+------------+------------+-----------+\n1 row in set (0.00 sec)\n\ndrop table if exists t1;\ncreate table t1(a varchar(100), b varchar(100));\ninsert into t1 values('abc', 'abc');\ninsert into t1 values('\u554aabc\u54e6', '\u554aabc\u54e6');\ninsert into t1 values('\u554a\u554ao', 'o');\ninsert into t1 values('\u554a\u554ao', '\u554a');\ninsert into t1 values('\u554a\u554ao', 'o\u554a');\nmysql> select trim(both a from b) from t1;\n+---------------------+\n| trim(both a from b) |\n+---------------------+\n| |\n| |\n| o |\n| \u554a |\n| o\u554a |\n+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select trim(leading a from b) from t1;\n+------------------------+\n| trim(leading a from b) |\n+------------------------+\n| |\n| |\n| o |\n| \u554a |\n| o\u554a |\n+------------------------+\n5 rows in set (0.01 sec)\n\nmysql> select trim(trailing a from b) from t1;\n+-------------------------+\n| trim(trailing a from b) |\n+-------------------------+\n| |\n| |\n| o |\n| \u554a |\n| o\u554a |\n+-------------------------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/","title":"UCASE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UCASE()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\uff0c\u4e3a UPPER()
\u7684\u8fd1\u4e49\u8bcd\u3002
> UCASE(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/ucase/#_4","title":"\u793a\u4f8b","text":"mysql> select ucase('hello');\n+--------------+\n| ucase(hello) |\n+--------------+\n| HELLO |\n+--------------+\n1 row in set (0.03 sec)\n\nmysql> select ucase('a'),ucase('b'),ucase('c');\n+----------+----------+----------+\n| ucase(a) | ucase(b) | ucase(c) |\n+----------+----------+----------+\n| A | B | C |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/","title":"UNHEX()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UNHEX()
\u51fd\u6570\u7528\u4e8e\u5c06\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u76f8\u5e94\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5bf9\u4e8e NULL
\u53c2\u6570\uff0c\u6b64\u51fd\u6570\u8fd4\u56de NULL
\u3002
> UNHEX(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\u3002\u5fc5\u987b\u4e3a\u5408\u6cd5\u7684\u5341\u516d\u8fdb\u5236\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/unhex/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT UNHEX('4d6174726978204f726967696e');\n+-----------------------------------+\n| unhex(4d6174726978204f726967696e) |\n+-----------------------------------+\n| Matrix Origin |\n+-----------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select unhex(NULL);\n+-------------+\n| unhex(null) |\n+-------------+\n| NULL |\n+-------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/","title":"UPPER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UPPER()
\u7528\u4e8e\u5c06\u7ed9\u5b9a\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5927\u5199\u5f62\u5f0f\u3002
> UPPER(str)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e str \u5fc5\u8981\u53c2\u6570\uff0c\u5b57\u6bcd\u5b57\u7b26\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/upper/#_4","title":"\u793a\u4f8b","text":"mysql> select upper('hello');\n+--------------+\n| upper(hello) |\n+--------------+\n| HELLO |\n+--------------+\n1 row in set (0.03 sec)\n\nmysql> select upper('a'),upper('b'),upper('c');\n+----------+----------+----------+\n| upper(a) | upper(b) | upper(c) |\n+----------+----------+----------+\n| A | B | C |\n+----------+----------+----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/","title":"\u6b63\u5219\u8868\u8fbe\u5f0f\u6982\u8ff0","text":"\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u5339\u914d\u6587\u672c\u6a21\u5f0f\u7684\u65b9\u6cd5\u3002\u4f60\u53ef\u4ee5\u5728 LIKE \u8bed\u53e5\u4e2d\u4f7f\u7528\u7b80\u5355\u7684\u901a\u914d\u7b26\uff08\u5982 %\uff0c_\uff09\uff0c\u4f46\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\u4e3a\u4f60\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u7075\u6d3b\u6027\u548c\u5339\u914d\u9009\u9879\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/Regular-Expression-Functions-Overview/#_2","title":"\u4f7f\u7528\u573a\u666f","text":"\u6b63\u5219\u8868\u8fbe\u5f0f\u80fd\u8fdb\u884c\u590d\u6742\u7684\u5b57\u7b26\u4e32\u5339\u914d\u548c\u64cd\u4f5c\uff0c\u4ee5\u4e0b\u5217\u4e3e\u4e00\u4e9b\u5e38\u89c1\u7684\u4f7f\u7528\u573a\u666f\uff1a
\u6570\u636e\u9a8c\u8bc1\uff1a\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u7528\u6765\u9a8c\u8bc1\u6570\u636e\u662f\u5426\u7b26\u5408\u7279\u5b9a\u7684\u683c\u5f0f\uff0c\u4f8b\u5982\u68c0\u67e5\u4e00\u4e2a\u5b57\u6bb5\u662f\u5426\u5305\u542b\u6709\u6548\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3001\u7535\u8bdd\u53f7\u7801\u6216\u8005\u793e\u4f1a\u4fdd\u969c\u53f7\u7b49\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u627e\u51fa\u6240\u6709\u683c\u5f0f\u4e0d\u7b26\u5408\u89c4\u8303\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff1a
SELECT email\nFROM users\nWHERE email NOT REGEXP '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2,}$';\n
\u6570\u636e\u7b5b\u9009\uff1a\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u7528\u6765\u641c\u7d22\u5305\u542b\u6216\u4e0d\u5305\u542b\u7279\u5b9a\u6a21\u5f0f\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u8981\u627e\u51fa\u6240\u6709\u4ee5\u7279\u5b9a\u524d\u7f00\u5f00\u59cb\u7684\u7535\u8bdd\u53f7\u7801\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u5339\u914d\u8fd9\u4e9b\u53f7\u7801\uff1a
SELECT phone_number\nFROM users\nWHERE phone_number REGEXP '^180';\n
\u6570\u636e\u6e05\u6d17\uff1a\u5728\u6570\u636e\u6e05\u6d17\u4e2d\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u4e5f\u975e\u5e38\u6709\u7528\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u6e05\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u3001\u7a7a\u683c\u6216\u8005\u63d0\u53d6\u5b57\u7b26\u4e32\u4e2d\u7684\u6570\u5b57\u7b49\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5b9e\u73b0\u8fd9\u4e9b\u529f\u80fd\uff1a
SELECT REGEXP_REPLACE(name, '[^a-zA-Z]', '')\nFROM users;\n
\u8fd9\u6bb5 SQL \u5c06\u4f1a\u8fd4\u56de name
\u5b57\u6bb5\u4e2d\u6240\u6709\u975e\u5b57\u6bcd\u7684\u5b57\u7b26\u88ab\u66ff\u6362\u6389\u7684\u7ed3\u679c\u3002
\u6587\u672c\u5206\u6790\uff1a\u5982\u679c\u4f60\u6b63\u5728\u8fdb\u884c\u6587\u672c\u5206\u6790\uff0c\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u4f60\u627e\u51fa\u6587\u672c\u4e2d\u7684\u7279\u5b9a\u8bcd\u6c47\u6216\u77ed\u8bed\uff0c\u751a\u81f3\u53ef\u4ee5\u7528\u6765\u8fdb\u884c\u67d0\u4e9b\u5f62\u5f0f\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u3002
\u6b63\u5219\u8868\u8fbe\u5f0f\u4f7f\u7528 POSIX\uff08Portable Operating System Interface\uff09\u6269\u5c55\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u9700\u8981\u6ce8\u610f\u7684\u7279\u6b8a\u5b57\u7b26\uff1a
\u5b57\u7b26 \u8bf4\u660e.
\u5339\u914d\u4efb\u4f55\u5355\u4e2a\u5b57\u7b26\uff08\u9664\u4e86\u6362\u884c\u7b26\uff09 *
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d\u4efb\u610f\u6b21\uff08\u5305\u62ec\u96f6\u6b21\uff09 +
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d\u4e00\u6b21\u6216\u591a\u6b21\u3002 ?
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d\u96f6\u6b21\u6216\u4e00\u6b21\u3002 {n}
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d n \u6b21\u3002 {n,}
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d n \u6b21\u6216\u66f4\u591a\u6b21\u3002 {n,m}
\u8868\u793a\u524d\u9762\u7684\u5143\u7d20\u53ef\u4ee5\u91cd\u590d n \u6b21\u5230 m \u6b21\u3002 ^
\u8868\u793a\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u3002 $
\u8868\u793a\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u675f\u3002 [abc]
\u8868\u793a\u5339\u914d a\u3001b \u6216 c\u3002 [^abc]
\u8868\u793a\u5339\u914d\u4efb\u4f55\u4e0d\u662f a\u3001b \u6216 c \u7684\u5b57\u7b26\u3002 (abc|def)
\u8868\u793a\u5339\u914d abc \u6216 def\u3002 \\d
\u8868\u793a\u5339\u914d\u6570\u5b57 \\s
\u8868\u793a\u5339\u914d\u7a7a\u767d\u5b57\u7b26 \\w
\u8868\u793a\u5339\u914d\u5355\u8bcd\u5b57\u7b26 \\D
\u3001\\S
\u548c \\W
\u8868\u793a\u5339\u914d\u76f8\u53cd\u7684\u5b57\u7b26\u96c6 Note
\u5728\u6b63\u5219\u8868\u8fbe\u5f0f\u4e2d\uff0c\u8fd9\u4e9b\u7279\u6b8a\u5b57\u7b26\u9700\u8981\u4f7f\u7528 \\
\u8fdb\u884c\u8f6c\u4e49\uff0c\u4f8b\u5982 \\\\.
\u8868\u793a\u5339\u914d\u4e00\u4e2a\u5b9e\u9645\u7684 .
\u5b57\u7b26\uff0c\u800c\u4e0d\u662f\u4efb\u4f55\u5b57\u7b26\u3002
MatrixOne \u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u9ed8\u8ba4\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\u3002\u5982\u679c\u4f60\u5e0c\u671b\u8fdb\u884c\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u5339\u914d\uff0c\u53ef\u4ee5\u4f7f\u7528 REGEXP_LIKE(column, pattern, 'i')
\u8fd9\u6837\u7684\u8bed\u6cd5\u3002\u5176\u4e2d i
\u8868\u793a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
\u6b63\u5219\u8868\u8fbe\u5f0f\u51fd\u6570\u5217\u8868
\u540d\u79f0 \u91ca\u4e49 NOT REGEXP REGEXP \u7684\u5426\u5b9a\u8868\u8fbe\u5f0f REGEXP_INSTR() \u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b50\u4e32\u8d77\u59cb\u7d22\u5f15 REGEXP_LIKE() \u5b57\u7b26\u4e32\u662f\u5426\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f REGEXP_REPLACE() \u66ff\u6362\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b50\u5b57\u7b26\u4e32 REGEXP_SUBSTR() \u8fd4\u56de\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b50\u4e32"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/","title":"NOT REGEXP","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"NOT REGEXP
\u7528\u4e8e\u6d4b\u8bd5\u4e00\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e0d\u5339\u914d\u6307\u5b9a\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
\u5982\u679c column_name
\u4e0d\u5339\u914d pattern
\uff0c\u5219\u8fd4\u56de TRUE
\u3002\u5982\u679c\u5339\u914d\uff0c\u5219\u8fd4\u56de FALSE
\u3002
> column_name NOT REGEXP pattern\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/not-regexp/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"column_name
\u662f\u8981\u5339\u914d\u7684\u5b57\u6bb5\u3002
pattern
\u662f\u8981\u5e94\u7528\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
CREATE TABLE example (\nid INT AUTO_INCREMENT,\ntext VARCHAR(255),\nPRIMARY KEY(id)\n);\n\n\nINSERT INTO example (text)\nVALUES ('Hello1'),\n('Hello2'),\n('World'),\n('HelloWorld'),\n('Hello_World'),\n('example'),\n('example1'),\n('example2');\n\nmysql> SELECT * FROM example WHERE text NOT REGEXP '[0-9]';\n+------+-------------+\n| id | text |\n+------+-------------+\n| 3 | World |\n| 4 | HelloWorld |\n| 5 | Hello_World |\n| 6 | example |\n+------+-------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/","title":"REGEXP_INSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_INSTR()
\u8fd4\u56de\u5339\u914d\u5230\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002\u5982\u679c\u6ca1\u6709\u627e\u5230\u5339\u914d\u9879\uff0c\u8be5\u51fd\u6570\u5c06\u8fd4\u56de 0\u3002
> REGEXP_INSTR(expr, pat[, pos[, occurrence[, return_option[, match_type]]]])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-instr/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\u662f\u8981\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002
pat
\u662f\u8981\u5728\u5b57\u7b26\u4e32\u4e2d\u5339\u914d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
pos
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u4ece\u54ea\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u4ece\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002
occurrence
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u7b2c\u51e0\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u8fd4\u56de\u7b2c\u4e00\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002
return_option
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u7684\u4f4d\u7f6e\u662f\u6a21\u5f0f\u5f00\u59cb\u7684\u4f4d\u7f6e\u8fd8\u662f\u7ed3\u675f\u7684\u4f4d\u7f6e\u3002\u5982\u679c\u4e3a 0 \u6216\u7701\u7565\uff0c\u51fd\u6570\u8fd4\u56de\u6a21\u5f0f\u5f00\u59cb\u7684\u4f4d\u7f6e\u3002\u5982\u679c\u4e3a 1\uff0c\u51fd\u6570\u8fd4\u56de\u6a21\u5f0f\u7ed3\u675f\u7684\u4f4d\u7f6e\u4e4b\u540e\u7684\u4f4d\u7f6e\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_INSTR('Hello, my number is 12345.', '[0-9]+');\n+--------------------------------------------------+\n| regexp_instr(Hello, my number is 12345., [0-9]+) |\n+--------------------------------------------------+\n| 21 |\n+--------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('apple', 'z+');\n+-------------------------+\n| regexp_instr(apple, z+) |\n+-------------------------+\n| 0 |\n+-------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World!', 'World');\n+------------------------------------+\n| regexp_instr(Hello, World!, World) |\n+------------------------------------+\n| 8 |\n+------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_INSTR('Hello, World! World!', 'World', 1, 2);\n+-------------------------------------------------+\n| regexp_instr(Hello, World! World!, World, 1, 2) |\n+-------------------------------------------------+\n| 15 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/","title":"REGEXP_LIKE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_LIKE()
\u7528\u4e8e\u5224\u65ad\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e0e\u63d0\u4f9b\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u5339\u914d\u3002\u5982\u679c\u5b57\u7b26\u4e32\u7b26\u5408\u6a21\u5f0f\uff0c\u51fd\u6570\u8fd4\u56de TRUE
\uff0c\u5426\u5219\u8fd4\u56de FALSE
\u3002\u5b83\u7684\u5de5\u4f5c\u65b9\u5f0f\u7c7b\u4f3c\u4e8e REGEXP
\u64cd\u4f5c\u7b26\uff0c\u4f46\u662f\u5b83\u53ef\u4ee5\u63a5\u53d7\u7b2c\u4e09\u4e2a\u53ef\u9009\u53c2\u6570 match_type
\uff0c\u7528\u4e8e\u5b9a\u4e49\u5339\u914d\u7684\u884c\u4e3a\u3002
REGEXP \u548c RLIKE \u662f REGEXP_LIKE()
\u7684\u540c\u4e49\u8bcd\u3002
> REGEXP_LIKE(expr, pat[, match_type])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-like/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\u662f\u8981\u641c\u7d22\u7684\u5b57\u7b26\u4e32\u3002
pat
\u662f\u8981\u5728\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE');\n+-----------------------------------+\n| regexp_like(CamelCase, CAMELCASE) |\n+-----------------------------------+\n| false |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT REGEXP_LIKE('CamelCase', 'CAMELCASE', 'i');\n+--------------------------------------+\n| regexp_like(CamelCase, CAMELCASE, i) |\n+--------------------------------------+\n| true |\n+--------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/","title":"REGEXP_REPLACE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_REPLACE()
\u7528\u4e8e\u5c06\u5339\u914d\u7ed9\u5b9a\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\u7684\u5b57\u7b26\u4e32\u66ff\u6362\u4e3a\u6307\u5b9a\u7684\u65b0\u5b57\u7b26\u4e32\u3002
> REGEXP_REPLACE(expr, pat, repl[, pos[, occurrence[, match_type]]])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-replace/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\u662f\u8981\u66ff\u6362\u7684\u5b57\u7b26\u4e32\u3002
pat
\u8fd9\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u51fd\u6570\u4f1a\u67e5\u627e\u4e0e\u6b64\u6a21\u5f0f\u5339\u914d\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002
repl
\u662f\u66ff\u6362\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u66ff\u6362\u627e\u5230\u7684\u5339\u914d\u5b57\u7b26\u4e32\u3002
pos
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u4ece\u54ea\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u4ece\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002
occurrence
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u66ff\u6362\u7b2c\u51e0\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u8fd4\u56de\u7b2c\u4e00\u6b21\u5339\u914d\u7684\u4f4d\u7f6e\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_REPLACE('Hello, World!', 'World', 'Universe');\n+------------------------------------------------+\n| regexp_replace(Hello, World!, World, Universe) |\n+------------------------------------------------+\n| Hello, Universe! |\n+------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_REPLACE('Cat Dog Cat Dog Cat','Cat', 'Tiger') 'Result';\n+---------------------------+\n| Result |\n+---------------------------+\n| Tiger Dog Tiger Dog Tiger |\n+---------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/","title":"REGEXP_SUBSTR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"REGEXP_SUBSTR()
\u7528\u4e8e\u8fd4\u56de\u5b57\u7b26\u4e32 expr
\u4e2d\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f pat
\u7684\u5b50\u5b57\u7b26\u4e32\u3002
> REGEXP_SUBSTR(expr, pat[, pos[, occurrence[, match_type]]])\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/String/Regular-Expressions/regexp-substr/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"expr
\uff1a\u8fd9\u662f\u539f\u59cb\u7684\u5b57\u7b26\u4e32\uff0c\u5728\u6b64\u5b57\u7b26\u4e32\u4e2d\u67e5\u627e\u5339\u914d\u9879\u3002
pat
\uff1a\u8fd9\u662f\u6b63\u5219\u8868\u8fbe\u5f0f\u6a21\u5f0f\uff0c\u51fd\u6570\u4f1a\u67e5\u627e\u4e0e\u6b64\u6a21\u5f0f\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002
pos
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u4ece\u54ea\u4e2a\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u4ece\u5b57\u7b26\u4e32\u7684\u5f00\u59cb\u4f4d\u7f6e\u5f00\u59cb\u641c\u7d22\u3002
occurrence
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53ef\u9009\u53c2\u6570\uff0c\u6307\u5b9a\u8fd4\u56de\u7b2c\u51e0\u6b21\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u503c\u662f 1\uff0c\u8868\u793a\u8fd4\u56de\u7b2c\u4e00\u6b21\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u6b64\u503c\u4e3a\u975e\u96f6\u503c n\uff0c\u5c06\u8fd4\u56de\u7b2c n \u6b21\u51fa\u73b0\u7684\u5339\u914d\u5b57\u7b26\u4e32\u3002
match_type
\u53c2\u6570\u662f\u4e00\u4e2a\u53ef\u9009\u7684\u5b57\u7b26\u4e32\uff0c\u7528\u4e8e\u6307\u5b9a\u5339\u914d\u7684\u65b9\u5f0f\u3002\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u7531\u4ee5\u4e0b\u5b57\u7b26\u6784\u6210\uff0c\u6bcf\u4e2a\u5b57\u7b26\u6307\u5b9a\u4e00\u79cd\u5339\u914d\u65b9\u5f0f\uff0c\u5b57\u7b26\u7684\u987a\u5e8f\u4e0d\u5f71\u54cd\u7ed3\u679c\uff1a
'c'
\uff1a\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u4e0d\u540c\u7684\u5b57\u7b26\uff09\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5339\u914d\u533a\u5206\u5927\u5c0f\u5199\u3002'i'
\uff1a\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u8fdb\u884c\u5339\u914d\uff08\u5373\uff0c\u5927\u5199\u548c\u5c0f\u5199\u5b57\u6bcd\u88ab\u89c6\u4e3a\u76f8\u540c\u7684\u5b57\u7b26\uff09\u3002'n'
\uff1a\u5141\u8bb8 .
\u7b26\u53f7\u5339\u914d\u6362\u884c\u7b26\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c.
\u7b26\u53f7\u4e0d\u4f1a\u5339\u914d\u6362\u884c\u7b26\u3002'm'
\uff1a\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u591a\u884c\u3002\u5373\uff0c^
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u6216\u4efb\u4f55\u884c\u7684\u5f00\u5934\uff0c$
\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u6216\u4efb\u4f55\u884c\u7684\u7ed3\u5c3e\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c^
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u5f00\u5934\uff0c$
\u53ea\u5339\u914d\u5b57\u7b26\u4e32\u7684\u7ed3\u5c3e\u3002'u'
\uff1a\u5c06\u6a21\u5f0f\u89c6\u4e3a UTF-8 \u5b57\u7b26\u4e32\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6a21\u5f0f\u89c6\u4e3a\u5b57\u8282\u5b57\u7b26\u4e32\u3002mysql> SELECT REGEXP_SUBSTR('1a 2b 3c', '[0-9]a');\n+---------------------------------+\n| regexp_substr(1a 2b 3c, [0-9]a) |\n+---------------------------------+\n| 1a |\n+---------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT REGEXP_SUBSTR('Lend for land', '^C') Result;\n+--------+\n| Result |\n+--------+\n| NULL |\n+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/","title":"UNNEST()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"UNNEST
\u51fd\u6570\u7528\u4e8e\u5c06 JSON \u7c7b\u578b\u6570\u636e\u5185\u7684\u6570\u7ec4\u7c7b\u578b\u7684\u5217\u6216\u53c2\u6570\u5c55\u5f00\u4e3a\u4e00\u4e2a\u8868\u3002\u5b83\u5c06 JSON \u7c7b\u578b\u6570\u636e\u4e2d\u7684\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u62c6\u5206\u6210\u5355\u72ec\u7684\u884c\uff0c\u4f7f\u5f97\u53ef\u4ee5\u5bf9\u6570\u7ec4\u5143\u7d20\u8fdb\u884c\u5355\u72ec\u7684\u5904\u7406\u6216\u4e0e\u5176\u4ed6\u8868\u8fdb\u884c\u8fde\u63a5\u64cd\u4f5c\u3002
\u5f53\u8f93\u5165\u7a7a\u6570\u7ec4\u65f6\uff0cUNNEST
\u51fd\u6570\u8fd4\u56de\u7a7a\u8868\uff0c\u56e0\u4e3a\u6ca1\u6709\u5143\u7d20\u53ef\u4ee5\u5c55\u5f00\u3002
\u5f53\u8f93\u5165 NULL
\u503c\u65f6\uff0cUNNEST
\u51fd\u6570\u8fd4\u56de\u7a7a\u8868\uff0c\u56e0\u4e3a NULL
\u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684\u6570\u7ec4\u3002
> UNNEST(array_expression)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e array_expression \u5fc5\u8981\u53c2\u6570\u3002\u662f\u4e00\u4e2a JSON \u6570\u636e\u5185\u7684\u6570\u7ec4\uff0c\u53ef\u4ee5\u662f\u6570\u7ec4\u5217\u3001\u6570\u7ec4\u5e38\u91cf\u6216\u6570\u7ec4\u51fd\u6570\u7684\u8fd4\u56de\u503c\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Table/unnest/#_4","title":"\u793a\u4f8b","text":"-- \u5c06\u4e00\u4e2a\u5305\u542b JSON \u5bf9\u8c61\u7684\u5b57\u7b26\u4e32\u6570\u7ec4\u8fdb\u884c\u5c55\u5f00\uff0c'{\"a\":1}' \u662f\u4e00\u4e2a\u5305\u542b\u5355\u4e2a\u5143\u7d20\u7684\u5b57\u7b26\u4e32\u6570\u7ec4\u3002\u8fd9\u4e2a\u5143\u7d20\u662f\u4e00\u4e2a\u8868\u793a JSON \u5bf9\u8c61\u7684\u5b57\u7b26\u4e32\u3002\n> select * from unnest('{\"a\":1}') u;\n+----------------+------+------+------+-------+-------+----------+\n| col | seq | key | path | index | value | this |\n+----------------+------+------+------+-------+-------+----------+\n| UNNEST_DEFAULT | 0 | a | $.a | NULL | 1 | {\"a\": 1} |\n+----------------+------+------+------+-------+-------+----------+\n1 row in set (0.00 sec)\n\n-- \u5bf9\u4e00\u4e2a\u5305\u542b\u6574\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4 '[1,2,3]' \u8fdb\u884c\u5c55\u5f00\uff0c\u5e76\u4f7f\u7528\u522b\u540d u \u4ee3\u8868\u5c55\u5f00\u540e\u7684\u5217\u3002\n> select * from unnest('[1,2,3]') u;\n+----------------+------+------+------+-------+-------+-----------+\n| col | seq | key | path | index | value | this |\n+----------------+------+------+------+-------+-------+-----------+\n| UNNEST_DEFAULT | 0 | NULL | $[0] | 0 | 1 | [1, 2, 3] |\n| UNNEST_DEFAULT | 0 | NULL | $[1] | 1 | 2 | [1, 2, 3] |\n| UNNEST_DEFAULT | 0 | NULL | $[2] | 2 | 3 | [1, 2, 3] |\n+----------------+------+------+------+-------+-------+-----------+\n3 rows in set (0.00 sec)\n\n-- \u5bf9\u4e00\u4e2a\u5305\u542b\u6574\u6570\u7684\u5b57\u7b26\u4e32\u6570\u7ec4 '[1,2,3]' \u8fdb\u884c\u5c55\u5f00\uff0c\u5e76\u9009\u62e9\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u4f5c\u4e3a\u7ed3\u679c\u96c6\u7684\u4e00\u90e8\u5206\u8fd4\u56de\u3002'$[0]' \u662f\u4e00\u4e2a\u6307\u5b9a\u8981\u9009\u62e9\u7684\u6570\u7ec4\u5143\u7d20\u7684\u8def\u5f84\u8868\u8fbe\u5f0f\uff0ctrue \u662f\u4e00\u4e2a\u6307\u793a\u662f\u5426\u8fd4\u56de\u8def\u5f84\u7684\u5e03\u5c14\u503c\uff0c\u5e76\u4f7f\u7528\u522b\u540d u \u4ee3\u8868\u5c55\u5f00\u540e\u7684\u5217\u3002\n> select * from unnest('[1,2,3]','$[0]',true) u;\n+----------------+------+------+------+-------+-------+------+\n| col | seq | key | path | index | value | this |\n+----------------+------+------+------+-------+-------+------+\n| UNNEST_DEFAULT | 0 | NULL | $[0] | NULL | NULL | 1 |\n+----------------+------+------+------+-------+-------+------+\n1 row in set (0.00 sec)\n
create table t1 (a json,b int);\ninsert into t1 values ('{\"a\":1,\"b\":[{\"c\":2,\"d\":3},false,4],\"e\":{\"f\":true,\"g\":[null,true,1.1]}}',1);\ninsert into t1 values ('[1,true,false,null,\"aaa\",1.1,{\"t\":false}]',2);\n> select * from t1;\n+---------------------------------------------------------------------------------------+------+\n| a | b |\n+---------------------------------------------------------------------------------------+------+\n| {\"a\": 1, \"b\": [{\"c\": 2, \"d\": 3}, false, 4], \"e\": {\"f\": true, \"g\": [null, true, 1.1]}} | 1 |\n| [1, true, false, null, \"aaa\", 1.1, {\"t\": false}] | 2 |\n+---------------------------------------------------------------------------------------+------+\n2 rows in set (0.00 sec)\n\n-- \u4ece\u8868 t1 \u4e2d\u5c55\u5f00\u6570\u7ec4 t1.a \u7684\u5143\u7d20\uff0c\u5e76\u9009\u62e9\u5c55\u5f00\u540e\u7684\u5143\u7d20\u4f5c\u4e3a\u7ed3\u679c\u96c6\u7684\u4e00\u90e8\u5206\u8fd4\u56de\u3002\"$a\" \u662f\u4e00\u4e2a\u6307\u5b9a\u8981\u9009\u62e9\u7684\u6570\u7ec4\u5143\u7d20\u7684\u8def\u5f84\u8868\u8fbe\u5f0f\uff1btrue \u662f\u4e00\u4e2a\u6307\u793a\u662f\u5426\u8fd4\u56de\u8def\u5f84\u7684\u5e03\u5c14\u503c\uff1b\u4f7f\u7528 f.* \u8868\u793a\u9009\u62e9\u5c55\u5f00\u540e\u7684\u6240\u6709\u5217\uff1bf \u662f UNNEST \u51fd\u6570\u7684\u522b\u540d\uff0c\u4ee3\u8868\u5c55\u5f00\u540e\u7684\u7ed3\u679c\nmysql> select f.* from t1,unnest(t1.a, \"$.a\", true) as f;\n+------+------+------+------+-------+-------+------+\n| col | seq | key | path | index | value | this |\n+------+------+------+------+-------+-------+------+\n| t1.a | 0 | NULL | $.a | NULL | NULL | 1 |\n| t1.a | 0 | NULL | $.a | NULL | NULL | 1 |\n+------+------+------+------+-------+-------+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/","title":"\u7b97\u672f\u8fd0\u7b97\u7b26","text":"MatrixOne \u652f\u6301\u57fa\u672c\u7684\u7b97\u672f\u8fd0\u7b97\u7b26\uff0c\u5982\u5411\u91cf\u95f4\u6216\u5411\u91cf\u548c\u6807\u91cf\u95f4\u7684\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u4e58\u6cd5\u548c\u9664\u6cd5\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u6267\u884c\u9010\u5143\u7d20\u7684\u7b97\u672f\u64cd\u4f5c\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5411\u91cf\u3002
Note
\u51cf\u6cd5\uff08-
\uff09\u3001\u4e58\u6cd5\uff08*
\uff09\u548c\u9664\u6cd5\uff08/
\uff09\u90fd\u4e0e\u52a0\u6cd5\u793a\u4f8b\u7c7b\u4f3c\uff0c\u4e0d\u4f5c\u8d58\u8ff0\u3002
+
\u7528\u4e8e\u5c06\u4e24\u4e2a\u5143\u7d20\u76f8\u52a0\u3002
> SELECT para1 + para2\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_4","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b + \"[1,2,3]\" from vec_table;\n+-------------+\n| b + [1,2,3] |\n+-------------+\n| [2, 4, 6] |\n+-------------+\n1 row in set (0.00 sec)\n\nmysql> select b + 1 from vec_table;\n+-----------+\n| b + 1 |\n+-----------+\n| [2, 3, 4] |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select cast(\"[1,2,3]\" as vecf32(3)) + 5.0;\n+----------------------------------+\n| cast([1,2,3] as vecf32(3)) + 5.0 |\n+----------------------------------+\n| [6, 7, 8] |\n+----------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_5","title":"\u9650\u5236","text":"/
\u7528\u4e8e\u5c06\u4e24\u4e2a\u5411\u91cf\u5143\u7d20\u76f8\u9664\u3002
> SELECT para1 / para2\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_8","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b/b from vec_table;\n+-----------+\n| b / b |\n+-----------+\n| [1, 1, 1] |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> select cast(\"[1,2,3]\" as vecf32(3)) / b from vec_table;;\n+--------------------------------+\n| cast([1,2,3] as vecf32(3)) / b |\n+--------------------------------+\n| [1, 1, 1] |\n+--------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select b/2 from vec_table;\n+---------------+\n| b / 2 |\n+---------------+\n| [0.5, 1, 1.5] |\n+---------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/arithmetic/#_9","title":"\u9650\u5236","text":"CLUSTER_CENTERS()
\u51fd\u6570\u53ef\u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u5217\u7684 K \u4e2a\u805a\u7c7b\u4e2d\u5fc3\u3002\u8fd4\u56de\u4e00\u884c JSON \u6570\u7ec4\u5b57\u7b26\u4e32\uff0c\u5305\u542b\u6240\u6709\u805a\u7c7b\u4e2d\u5fc3\u3002
SELECT cluster_centers(col kmeans 'k, op_type, init_type, normalize') FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cluster_centers/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e col \u5fc5\u9700\u7684\u3002\u8981\u786e\u5b9a\u805a\u7c7b\u4e2d\u5fc3\u7684\u5411\u91cf\u5217\u3002 k \u5fc5\u9700\u7684\u3002\u8981\u5c06\u6570\u636e\u96c6\u5206\u6210\u7684\u7c07\u7684\u6570\u91cf\uff0c\u5927\u4e8e 0\uff0c\u5c0f\u4e8e\u7b49\u4e8e\u603b\u884c\u6570\u3002 op_type \u5fc5\u9700\u7684\u3002\u5728\u805a\u7c7b\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7684\u8ddd\u79bb\u51fd\u6570\u3002\u76ee\u524d\u652f\u6301 vector_l2_ops\u3002 init_type \u5fc5\u9700\u7684\u3002\u8981\u4f7f\u7528\u7684\u521d\u59cb\u5316\u805a\u7c7b\u4e2d\u5fc3\u7b97\u6cd5\u3002\u76ee\u524d\u6211\u4eec\u652f\u6301 random \u548c kmeanspluspus(K-means++)\u3002 normalize \u5fc5\u9700\u7684\u3002\u5e03\u5c14\u503c\uff0c\u8981\u4f7f\u7528\u7684\u805a\u7c7b\u7b97\u6cd5\uff0ctrue \u4ee3\u8868 Spherical Kmeans\uff0cfalse \u4ee3\u8868 Regular Kmeans\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cluster_centers/#_4","title":"\u793a\u4f8b","text":"drop table if exists points;\nCREATE TABLE points (id int auto_increment PRIMARY KEY,coordinate vecf32(2));\ninsert into points(coordinate) VALUES\n(\"[-7.68905443,6.62034649]\"),\n(\"[-9.57651383,-6.93440446]\"),\n(\"[6.82968177,1.1648714]\"),\n(\"[-2.90130578,7.55077118]\"),\n(\"[-5.67841327,-7.28818497]\"),\n(\"[-6.04929137,-7.73619342]\"),\n(\"[-6.27824322,7.22746302]\");\nSET GLOBAL experimental_ivf_index = 1;--\u9700\u8bbe\u7f6e\u53c2\u6570 experimental_ivf_index \u503c\u4e3a 1\uff08\u9ed8\u8ba4 0\uff09\u624d\u80fd\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\n--create index idx_t1 using ivfflat on points(coordinate) lists=1 op_type \"vector_l2_ops\";\n\n-- \u6bcf\u4e2a\u70b9\u4ee3\u8868\u5176\u5728 x \u548c y \u8f74\u4e0a\u7684\u5750\u6807\uff0c\u67e5\u8be2\u805a\u7c7b\u4e2d\u5fc3\uff0c\u4f7f\u7528 Regular Kmeans\n--K-means++\nmysql> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,kmeansplusplus,false') AS centers FROM points;\n+----------------------------------------------------+\n| centers |\n+----------------------------------------------------+\n| [ [-2.5097303, 5.640863],[-7.101406, -7.3195944] ] |\n+----------------------------------------------------+\n1 row in set (0.01 sec)\n\n--KMeans\nmysql> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,random,false') AS centers FROM points;\n+----------------------------------------------------+\n| centers |\n+----------------------------------------------------+\n| [ [-6.362137, -0.09336702],[6.829682, 1.1648715] ] |\n+----------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u6bcf\u4e2a\u70b9\u4ee3\u8868\u7ecf\u7eac\u5ea6\u5750\u6807\uff0c\u67e5\u8be2\u805a\u7c7b\u4e2d\u5fc3\uff0c\u4f7f\u7528 Spherical Kmeans\nmysql> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,kmeansplusplus,true') AS centers FROM points;\n+------------------------------------------------------+\n| centers |\n+------------------------------------------------------+\n| [ [0.70710677, 0.70710677],[0.83512634, 0.5500581] ] |\n+------------------------------------------------------+\n1 row in set (0.00 sec)\n\n--\u53ef\u7ed3\u5408 CROSS JOIN \u548c UNNEST \u8bed\u6cd5\u5c06 JSON \u7c7b\u578b\u6570\u636e\u5185\u7684\u805a\u7c7b\u4e2d\u5fc3\u53d6\u51fa\u6765\u3002\nmysql> SELECT value FROM (\n-> SELECT cluster_centers(coordinate kmeans '2,vector_l2_ops,kmeansplusplus,false') AS centers FROM points\n-> ) AS subquery -> CROSS JOIN UNNEST(subquery.centers) AS u;\n+-------------------------+\n| value |\n+-------------------------+\n| [-2.5097303, 5.640863] |\n| [-7.101406, -7.3195944] |\n+-------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/","title":"COSINE_DISTANCE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COSINE_DISTANCE()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u7684\u4f59\u5f26\u8ddd\u79bb\u3002
\u4f59\u5f26\u8ddd\u79bb\uff08Cosine Distance\uff09\u662f\u4e00\u79cd\u8861\u91cf\u4e24\u4e2a\u5411\u91cf\u5728\u65b9\u5411\u4e0a\u7684\u5dee\u5f02\u7684\u5ea6\u91cf\u65b9\u5f0f\uff0c\u901a\u5e38\u5b9a\u4e49\u4e3a 1 \u51cf\u53bb\u4f59\u5f26\u76f8\u4f3c\u5ea6 (Cosine Similarity)\u3002\u4f59\u5f26\u8ddd\u79bb\u7684\u503c\u8303\u56f4\u5728 0 \u5230 2 \u4e4b\u95f4\u30020 \u8868\u793a\u4e24\u4e2a\u5411\u91cf\u7684\u65b9\u5411\u5b8c\u5168\u76f8\u540c\uff08\u8ddd\u79bb\u6700\u5c0f\uff09\u30022 \u8868\u793a\u4e24\u4e2a\u5411\u91cf\u7684\u65b9\u5411\u5b8c\u5168\u76f8\u53cd\uff08\u8ddd\u79bb\u6700\u5927\uff09\u3002\u5728\u6587\u672c\u5206\u6790\u4e2d\uff0c\u4f59\u5f26\u8ddd\u79bb\u53ef\u4ee5\u7528\u6765\u8861\u91cf\u6587\u6863\u4e4b\u95f4\u7684\u76f8\u4f3c\u6027\u3002\u7531\u4e8e\u5b83\u53ea\u8003\u8651\u5411\u91cf\u7684\u65b9\u5411\u800c\u4e0d\u8003\u8651\u957f\u5ea6\uff0c\u56e0\u6b64\u5bf9\u4e8e\u957f\u6587\u672c\u548c\u77ed\u6587\u672c\u4e4b\u95f4\u7684\u6bd4\u8f83\u662f\u516c\u5e73\u7684\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT COSINE_DISTANCE(vector1, vector2) FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.01 sec)\n\nmysql> select cosine_distance(b,c) from vec_table;\n+-----------------------+\n| cosine_distance(b, c) |\n+-----------------------+\n| 0.0253681538029239 |\n+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> select cosine_distance(b,\"[1,2,3]\") from vec_table;\n+-----------------------------+\n| cosine_distance(b, [1,2,3]) |\n+-----------------------------+\n| 0 |\n+-----------------------------+\n1 row in set (0.00 sec)\n\nmysql> select cosine_distance(b,\"[-1,-2,-3]\") from vec_table;\n+--------------------------------+\n| cosine_distance(b, [-1,-2,-3]) |\n+--------------------------------+\n| 2 |\n+--------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_distance/#_4","title":"\u9650\u5236","text":"\u5728\u4f7f\u7528 COSINE_DISTANCE()
\u51fd\u6570\u65f6\uff0c\u8f93\u5165\u5411\u91cf\u4e0d\u5141\u8bb8\u4e3a 0 \u5411\u91cf\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u51fa\u73b0\u9664\u4ee5\u96f6\u7684\u60c5\u51b5\uff0c\u8fd9\u5728\u6570\u5b66\u4e0a\u662f\u672a\u5b9a\u4e49\u7684\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u8ba4\u4e3a\u96f6\u5411\u91cf\u4e0e\u4efb\u4f55\u5176\u4ed6\u5411\u91cf\u7684\u4f59\u5f26\u76f8\u4f3c\u5ea6\u4e3a 0\uff0c\u56e0\u4e3a\u5b83\u4eec\u4e4b\u95f4\u6ca1\u6709\u4efb\u4f55\u65b9\u5411\u4e0a\u7684\u76f8\u4f3c\u6027\u3002
cosine_similarity()
\u662f\u4f59\u5f26\u76f8\u4f3c\u5ea6\uff0c\u5b83\u8861\u91cf\u4e86\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u5939\u89d2\u7684\u4f59\u5f26\u503c\uff0c\u901a\u8fc7\u5b83\u4eec\u5728\u591a\u7ef4\u7a7a\u95f4\u4e2d\u7684\u63a5\u8fd1\u7a0b\u5ea6\u6765\u8868\u793a\u5b83\u4eec\u7684\u76f8\u4f3c\u6027\uff0c\u5176\u4e2d 1 \u8868\u793a\u5b8c\u5168\u76f8\u4f3c\uff0c-1 \u8868\u793a\u5b8c\u5168\u4e0d\u76f8\u4f3c\u3002\u4f59\u5f26\u76f8\u4f3c\u5ea6\u7684\u8ba1\u7b97\u662f\u901a\u8fc7\u5c06\u4e24\u4e2a\u5411\u91cf\u7684\u5185\u79ef\u9664\u4ee5\u5b83\u4eec\u7684 l2 \u8303\u6570\u7684\u4e58\u79ef\u6765\u5b9e\u73b0\u7684\u3002
> SELECT cosine_similarity(vector1, vector2) AS similarity FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_similarity/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select cosine_similarity(b,\"[1,2,3]\") from vec_table;\n+-------------------------------+\n| cosine_similarity(b, [1,2,3]) |\n+-------------------------------+\n| 1 |\n+-------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/cosine_similarity/#_4","title":"\u9650\u5236","text":"INNER PRODUCT
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u5185\u79ef/\u70b9\u79ef\uff0c\u5b83\u662f\u4e24\u4e2a\u5411\u91cf\u7684\u5bf9\u5e94\u5143\u7d20\u76f8\u4e58\u7136\u540e\u76f8\u52a0\u7684\u7ed3\u679c\u3002
> SELECT inner_product(vector1, vector2) AS result FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/inner_product/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select inner_product(b,\"[1,2,3]\") from vec_table;\n+---------------------------+\n| inner_product(b, [1,2,3]) |\n+---------------------------+\n| 14 |\n+---------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/inner_product/#_4","title":"\u9650\u5236","text":"\u4e24\u4e2a\u53c2\u6570\u5411\u91cf\u5fc5\u987b\u5177\u6709\u76f8\u540c\u7684\u7ef4\u5ea6\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm/","title":"l1_norm()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"l1_norm
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97 l1
/\u66fc\u54c8\u987f/TaxiCab \u8303\u6570\u3002l1
\u8303\u6570\u901a\u8fc7\u5bf9\u5411\u91cf\u5143\u7d20\u7684\u7edd\u5bf9\u503c\u6c42\u548c\u5f97\u5230\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 l1
\u8303\u6570\u6765\u8ba1\u7b97 l1
\u8ddd\u79bb\u3002
l1_distance(a,b) = l1_norm(a-b)\n
\u8fd9\u6837\u7684\u8ba1\u7b97\u65b9\u5f0f\u540c\u6837\u9002\u7528\u4e8e\u4ece l2_Norm
\u8ba1\u7b97 l2
\u8ddd\u79bb\u3002
> SELECT l1_norm(vector) AS result FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l1_norm/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select l1_norm(b) from vec_table;\n+------------+\n| l1_norm(b) |\n+------------+\n| 6 |\n+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/","title":"L2_DISTANCE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"L2_DISTANCE()
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u4e24\u4e2a\u5411\u91cf\u4e4b\u95f4\u7684\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb\u3002\u8fd4\u56de\u4e00\u4e2a FLOAT64 \u7c7b\u578b\u7684\u503c\u3002
L2 \u8ddd\u79bb (l2 distance)\uff0c\u4e5f\u88ab\u79f0\u4e3a\u6b27\u51e0\u91cc\u5f97\u8ddd\u79bb\uff08Euclidean Distance\uff09\uff0c\u662f\u5411\u91cf\u7a7a\u95f4\u4e2d\u6700\u5e38\u7528\u7684\u8ddd\u79bb\u5ea6\u91cf\u65b9\u5f0f\u4e4b\u4e00\u3002\u5b83\u6d4b\u91cf\u7684\u662f\u591a\u7ef4\u7a7a\u95f4\u4e2d\u4e24\u70b9\u4e4b\u95f4\u7684\u76f4\u7ebf\u8ddd\u79bb\u3002l2 distance \u8ddd\u79bb\u5177\u6709\u8bb8\u591a\u5b9e\u9645\u5e94\u7528\uff0c\u5305\u62ec\u673a\u5668\u5b66\u4e60\u3001\u8ba1\u7b97\u673a\u89c6\u89c9\u548c\u7a7a\u95f4\u5206\u6790\u7b49\u9886\u57df\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT L2_DISTANCE(vector, const_vector) FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_distance/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\"),(2, \"[1,1,1]\", \"[2,2,2]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n| 2 | [1, 1, 1] | [2, 2, 2] |\n+------+-----------+-----------+\n2 rows in set (0.00 sec)\n\nmysql> select l2_distance(b,c) from vec_table;\n+--------------------+\n| l2_distance(b, c) |\n+--------------------+\n| 5.196152422706632 |\n| 1.7320508075688772 |\n+--------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm/","title":"l2_norm()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"l2_norm
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97 l2
/\u6b27\u51e0\u91cc\u5f97\u8303\u6570\u3002l2
\u8303\u6570\u901a\u8fc7\u5bf9\u5411\u91cf\u5143\u7d20\u7684\u5e73\u65b9\u548c\u8fdb\u884c\u5e73\u65b9\u6839\u8fd0\u7b97\u5f97\u5230\u3002
> SELECT l2_norm(vector) AS result FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/l2_norm/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select l2_norm(b) from vec_table;\n+--------------------+\n| l2_norm(b) |\n+--------------------+\n| 3.7416573867739413 |\n+--------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/","title":"\u6570\u5b66\u7c7b\u51fd\u6570","text":"\u5411\u91cf\u652f\u6301\u4ee5\u4e0b\u6570\u5b66\u7c7b\u51fd\u6570\uff1a
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#sqrt","title":"SQRT","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_2","title":"\u51fd\u6570\u8bf4\u660e","text":"sqrt
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u6839\u3002
> SELECT sqrt(vector_column) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_4","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684 vecf64 \u7c7b\u578b\u7684\u5411\u91cf\uff0c\u5176\u4e2d\u5305\u542b\u539f\u59cb\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u6839\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_5","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select sqrt(b) from vec_table;\n+---------------------------------------------+\n| sqrt(b) |\n+---------------------------------------------+\n| [1, 1.4142135623730951, 1.7320508075688772] |\n+---------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_6","title":"\u9650\u5236","text":"abs
\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u5411\u91cf\u7684\u7edd\u5bf9\u503c\u3002
> SELECT ABS(vector_column) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_9","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8fd4\u56de\u4e00\u4e2a\u76f8\u540c\u7c7b\u578b\u7684\u65b0\u5411\u91cf\uff0c\u5176\u4e2d\u5305\u542b\u539f\u59cb\u5411\u91cf\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u7edd\u5bf9\u503c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_10","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[-1,-2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-------------+-----------+\n| a | b | c |\n+------+-------------+-----------+\n| 1 | [-1, -2, 3] | [4, 5, 6] |\n+------+-------------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select abs(b) from vec_table;\n+-----------+\n| abs(b) |\n+-----------+\n| [1, 2, 3] |\n+-----------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#cast","title":"CAST","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_11","title":"\u51fd\u6570\u8bf4\u660e","text":"cast \u51fd\u6570\u7528\u4e8e\u663e\u5f0f\u5c06\u4e00\u4e2a\u5411\u91cf\u4ece\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b\u8f6c\u6362\u4e3a\u53e6\u4e00\u4e2a\u5411\u91cf\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_12","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT CAST(vector AS vector_type) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_13","title":"\u53c2\u6570","text":"vector
\uff1a\u8f93\u5165\u5411\u91cf\u3002vector_type
\uff1a\u65b0\u7684\u5411\u91cf\u7c7b\u578b\u3002\u65b0\u7684 vector_type
\u5411\u91cf\u3002
drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select b + cast(\"[1,2,3]\" as vecf32(3)) from vec_table;\n+--------------------------------+\n| b + cast([1,2,3] as vecf32(3)) |\n+--------------------------------+\n| [2, 4, 6] |\n+--------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#summation","title":"SUMMATION","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_16","title":"\u51fd\u6570\u8bf4\u660e","text":"summation
\u51fd\u6570\u8fd4\u56de\u5411\u91cf\u4e2d\u6240\u6709\u5143\u7d20\u7684\u603b\u548c\u3002
> SELECT SUMMATION(vector_column) FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_18","title":"\u8fd4\u56de\u7c7b\u578b","text":"\u8fd4\u56de\u4e00\u4e2a FLOAT64 \u503c\uff0c\u5373\u5411\u91cf\u4e2d\u6240\u6709\u5143\u7d20\u7684\u603b\u548c\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/misc/#_19","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select summation(b) from vec_table;\n+--------------+\n| summation(b) |\n+--------------+\n| 6 |\n+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/","title":"NORMALIZE_L2()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"NORMALIZE_L2()
\u51fd\u6570\u5bf9\u5411\u91cf\u6267\u884c\u6b27\u51e0\u91cc\u5f97\u5f52\u4e00\u5316 (L2 normalization)\u3002
L2 \u8303\u6570\u662f\u5411\u91cf\u5143\u7d20\u5e73\u65b9\u548c\u7684\u5e73\u65b9\u6839\uff0c\u56e0\u6b64 L2 normalization \u7684\u76ee\u7684\u662f\u4f7f\u5411\u91cf\u7684\u957f\u5ea6\uff08\u6216\u8303\u6570\uff09\u4e3a 1\uff0c\u8fd9\u901a\u5e38\u88ab\u79f0\u4e3a\u5355\u4f4d\u5411\u91cf\u3002\u8fd9\u79cd\u5f52\u4e00\u5316\u65b9\u6cd5\u5728\u673a\u5668\u5b66\u4e60\u4e2d\u7279\u522b\u6709\u7528\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u7279\u5f81\u5411\u91cf\u65f6\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6807\u51c6\u5316\u7279\u5f81\u7684\u5c3a\u5ea6\uff0c\u4ece\u800c\u63d0\u9ad8\u7b97\u6cd5\u7684\u6027\u80fd\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SELECT NORMALIZE_L2(vector_column) FROM tbl;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/normalize_l2/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n+------+-----------+-----------+\n1 row in set (0.00 sec)\n\nmysql> select normalize_l2(b) from vec_table;\n+-------------------------------------+\n| normalize_l2(b) |\n+-------------------------------------+\n| [0.26726124, 0.5345225, 0.80178374] |\n+-------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/","title":"SUBVECTOR()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SUBVECTOR()
\u51fd\u6570\u7528\u4e8e\u4ece\u5411\u91cf\u4e2d\u63d0\u53d6\u5b50\u5411\u91cf\u3002
> SUBVECTOR(vec, pos, len)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e vec \u5fc5\u9700\u53c2\u6570\u3002\u4ece\u4e2d\u63d0\u53d6\u5b50\u5411\u91cf\u7684\u6e90\u5411\u91cf pos \u5fc5\u9700\u53c2\u6570\u3002\u5f00\u59cb\u63d0\u53d6\u7684\u4f4d\u7f6e\u3002\u5411\u91cf\u4e2d\u7684\u7b2c\u4e00\u4e2a\u4f4d\u7f6e\u662f 1\uff0c\u5982\u679c pos \u4e3a\u6b63\uff0c\u5219\u51fd\u6570\u4ece\u5411\u91cf\u7684\u5f00\u5934\u63d0\u53d6\u3002\u5982\u679c pos \u4e3a\u8d1f\uff0c\u5219\u63d0\u53d6\u662f\u4ece\u5411\u91cf\u7684\u672b\u5c3e\u5f00\u59cb\u3002 len \u53ef\u9009\u53c2\u6570\u3002\u8981\u63d0\u53d6\u7684\u7ef4\u5ea6\u6570\u3002\u9ed8\u8ba4\u4ece\u4f4d\u7f6e pos \u5f00\u59cb\u5230\u5411\u91cf\u672b\u5c3e\u7684\u5b50\u5411\u91cf\u3002\u5982\u679c len \u5c0f\u4e8e 1\uff0c\u5219\u8fd4\u56de\u7a7a\u5411\u91cf\u3002"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/subvector/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT SUBVECTOR(\"[1,2,3]\", 2);\n+-----------------------+\n| subvector([1,2,3], 2) |\n+-----------------------+\n| [2, 3] |\n+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT SUBVECTOR(\"[1,2,3]\",-1,1);\n+---------------------------+\n| subvector([1,2,3], -1, 1) |\n+---------------------------+\n| [3] |\n+---------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT SUBVECTOR(\"[1,2,3]\",-1,0);\n+---------------------------+\n| subvector([1,2,3], -1, 0) |\n+---------------------------+\n| [] |\n+---------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims/","title":"vector_dims()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"vector_dims
\u51fd\u6570\u7528\u4e8e\u786e\u5b9a\u5411\u91cf\u7684\u7ef4\u5ea6\u3002
> SELECT vector_dims(vector) AS dimension_count FROM table_name;\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Vector/vector_dims/#_3","title":"\u793a\u4f8b","text":"drop table if exists vec_table;\ncreate table vec_table(a int, b vecf32(3), c vecf64(3));\ninsert into vec_table values(1, \"[1,2,3]\", \"[4,5,6]\");\ninsert into vec_table values(2, \"[7,8,9]\", \"[1,2,3]\");\nmysql> select * from vec_table;\n+------+-----------+-----------+\n| a | b | c |\n+------+-----------+-----------+\n| 1 | [1, 2, 3] | [4, 5, 6] |\n| 2 | [7, 8, 9] | [1, 2, 3] |\n+------+-----------+-----------+\n2 row in set (0.00 sec)\n\nmysql> select vector_dims(b) from vec_table;\n+----------------+\n| vector_dims(b) |\n+----------------+\n| 3 |\n| 3 |\n+----------------+\n2 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/","title":"DENSE_RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/dense_rank/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"DENSE_RANK()
\u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\uff0c\u4e0e RANK() \u51fd\u6570\u975e\u5e38\u76f8\u4f3c\u3002DENSE_RANK()
\u51fd\u6570\u9996\u5148\u6839\u636e ORDER BY \u5b50\u53e5\u4e2d\u6307\u5b9a\u7684\u5217\u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\u3002
DENSE_RANK()
\u51fd\u6570\u5904\u7406\u5e73\u5c40\uff08\u5373\u4e24\u884c\u6216\u66f4\u591a\u884c\u5177\u6709\u76f8\u540c\u7684\u503c\uff09\u7684\u65b9\u5f0f\u4e0e RANK()
\u51fd\u6570\u7565\u6709\u4e0d\u540c\u3002\u5728\u5b58\u5728\u5e73\u5c40\u7684\u60c5\u51b5\u4e0b\uff0cDENSE_RANK()
\u4f1a\u4e3a\u5177\u6709\u76f8\u540c\u503c\u7684\u6240\u6709\u884c\u8d4b\u4e88\u76f8\u540c\u7684\u6392\u540d\uff0c\u4f46\u662f\u4e0d\u4f1a\u8df3\u8fc7\u7d27\u968f\u5176\u540e\u7684\u4efb\u4f55\u6392\u540d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e24\u884c\u83b7\u5f97\u6392\u540d 1\uff0c\u90a3\u4e48\u4e0b\u4e00\u884c\u5c06\u83b7\u5f97\u6392\u540d 2\uff0c\u800c\u4e0d\u662f 3\u3002
> DENSE_RANK() OVER (\n [PARTITION BY column_1, column_2, ... ]\n ORDER BY column_3, column_4, ...\n)\n
PARTITION BY
\u5b50\u53e5\u662f\u53ef\u9009\u7684\uff0c\u5b83\u5c06\u6570\u636e\u96c6\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u5355\u72ec\u8ba1\u7b97\u6392\u540d\u3002ORDER BY
\u5b50\u53e5\u5b9a\u4e49\u4e86\u6570\u636e\u96c6\u7684\u6392\u5e8f\u65b9\u5f0f\uff0c\u5373\u6839\u636e\u54ea\u4e00\u5217\u6216\u54ea\u4e9b\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a'SalesTable'\u7684\u8868\uff0c\u5b83\u6709\u4e09\u4e2a\u5b57\u6bb5\uff1a'Department'\uff0c'Employee'\u548c'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- \u5411'SalesTable'\u8868\u63d2\u5165\u6570\u636e\uff0c\u6bcf\u4e00\u884c\u90fd\u5305\u542b\u4e00\u4e2a\u90e8\u95e8\uff08'Department'\uff09\u3001\u4e00\u4e2a\u5458\u5de5\u59d3\u540d\uff08'Employee'\uff09\u548c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff08'Sales'\uff09\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- \u67e5\u8be2'SalesTable'\u8868\uff0c\u8fd4\u56de\u5458\u5de5\u7684\u540d\u5b57\uff0c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff0c\u4ee5\u53ca\u4ed6\u4eec\u7684\u9500\u552e\u6392\u540d\uff08\u4f7f\u7528'DENSE_RANK()'\u51fd\u6570\uff09\n-- \u5728\u8fd9\u4e2a\u67e5\u8be2\u4e2d\uff0c'DENSE_RANK()'\u51fd\u6570\u6839\u636e\u9500\u552e\u989d\u7684\u964d\u5e8f\uff08\u7531'ORDER BY Sales DESC'\u6307\u5b9a\uff09\u5bf9\u6240\u6709\u5458\u5de5\u8fdb\u884c\u6392\u540d\n-- \u5982\u679c\u591a\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u76f8\u540c\uff0c\u4ed6\u4eec\u4f1a\u5f97\u5230\u76f8\u540c\u7684\u6392\u540d\uff0c\u5e76\u4e14\u4e0b\u4e00\u4e2a\u9500\u552e\u989d\u7684\u6392\u540d\u4e0d\u4f1a\u8df3\u8fc7\u3002\u6240\u4ee5\uff0c\u5982\u679c\u6709\u4e24\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u90fd\u662f\u7b2c\u4e00\uff0c\u90a3\u4e48\u4e0b\u4e00\u4e2a\u5458\u5de5\u7684\u6392\u540d\u5c31\u662f\u7b2c\u4e8c\uff0c\u800c\u4e0d\u662f\u7b2c\u4e09\u3002\nmysql> SELECT\nEmployee,\nSales,\nDENSE_RANK() OVER(ORDER BY Sales DESC) FROM\nSalesTable;\n+----------+-------+-----------------------------------------+\n| employee | sales | dense_rank() over (order by sales desc) |\n+----------+-------+-----------------------------------------+\n| Jane | 1200 | 1 |\n| Bob | 1100 | 2 |\n| John | 1000 | 3 |\n| Alex | 900 | 4 |\n| Charlie | 850 | 5 |\n| Alice | 800 | 6 |\n+----------+-------+-----------------------------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/","title":"RANK()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/rank/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"RANK()
\u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\u3002RANK()
\u9996\u5148\u6839\u636e ORDER BY
\u5b50\u53e5\u4e2d\u6307\u5b9a\u7684\u5217\u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u6392\u540d\u3002
RANK()
\u51fd\u6570\u5728\u5904\u7406\u76f8\u540c\u503c\uff08\u5373\u5e73\u5c40\uff09\u7684\u60c5\u51b5\u65f6\uff0c\u6709\u4e00\u4e2a\u7279\u6b8a\u7684\u884c\u4e3a\uff1a\u5f53\u4e24\u884c\u6216\u66f4\u591a\u884c\u5177\u6709\u76f8\u540c\u7684\u503c\u65f6\uff0c\u5b83\u4eec\u5c06\u83b7\u5f97\u76f8\u540c\u7684\u6392\u540d\u3002\u7136\u540e\uff0c\u5b83\u5c06\u8df3\u8fc7\u7d27\u968f\u5176\u540e\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u6392\u540d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4e24\u884c\u83b7\u5f97\u6392\u540d 1\uff0c\u90a3\u4e48\u4e0b\u4e00\u884c\u5c06\u83b7\u5f97\u6392\u540d 3\uff0c\u800c\u4e0d\u662f 2\u3002
> RANK() OVER (\n [PARTITION BY column_1, column_2, ... ]\n ORDER BY column_3, column_4, ...\n)\n
PARTITION BY
\u5b50\u53e5\u662f\u53ef\u9009\u7684\uff0c\u5b83\u5c06\u6570\u636e\u96c6\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u5355\u72ec\u8ba1\u7b97\u6392\u540d\u3002ORDER BY
\u5b50\u53e5\u5b9a\u4e49\u4e86\u6570\u636e\u96c6\u7684\u6392\u5e8f\u65b9\u5f0f\uff0c\u5373\u6839\u636e\u54ea\u4e00\u5217\u6216\u54ea\u4e9b\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868 'SalesTable'\uff0c\u8be5\u8868\u5177\u6709\u4e09\u4e2a\u5b57\u6bb5\uff1a'Department', 'Employee'\u548c 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- \u5411'SalesTable'\u8868\u4e2d\u63d2\u5165\u6570\u636e\uff0c\u6bcf\u884c\u5305\u542b\u4e00\u4e2a\u90e8\u95e8\uff08Department\uff09\u3001\u4e00\u4e2a\u5458\u5de5\uff08Employee\uff09\u548c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff08Sales\uff09\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- \u67e5\u8be2'SalesTable'\u8868\uff0c\u5e76\u8fd4\u56de\u6bcf\u4e2a\u90e8\u95e8\u7684\u6bcf\u4e2a\u5458\u5de5\uff0c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff0c\u4ee5\u53ca\u4ed6\u4eec\u6240\u5728\u90e8\u95e8\u7684\u603b\u9500\u552e\u989d\uff08DepartmentSales\uff09\n-- \u8fd8\u5c06\u8fd4\u56de\u6bcf\u4e2a\u5458\u5de5\u5728\u5176\u6240\u5728\u90e8\u95e8\u7684\u9500\u552e\u989d\u6392\u540d\uff08SalesRank\uff09\n-- \u5bf9\u4e8e\u603b\u9500\u552e\u989d\uff0c\u4f7f\u7528\u7a97\u53e3\u51fd\u6570 SUM()\uff0c\u5e76\u7528'OVER(PARTITION BY Department)'\u5bf9\u6bcf\u4e2a\u90e8\u95e8\u5206\u522b\u8fdb\u884c\u8ba1\u7b97\n-- \u5bf9\u4e8e\u9500\u552e\u989d\u6392\u540d\uff0c\u4f7f\u7528\u7a97\u53e3\u51fd\u6570 RANK()\uff0c\u5e76\u7528'OVER(PARTITION BY Department ORDER BY Sales DESC)'\u5bf9\u6bcf\u4e2a\u90e8\u95e8\u7684\u5458\u5de5\u6839\u636e\u9500\u552e\u989d\u8fdb\u884c\u964d\u5e8f\u6392\u540d\n-- \u5728RANK()\u51fd\u6570\u4e2d\uff0c\u5982\u679c\u4e24\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u76f8\u540c\uff0c\u4ed6\u4eec\u4f1a\u83b7\u5f97\u76f8\u540c\u7684\u6392\u540d\uff0c\u5e76\u4e14\u4e0b\u4e00\u4e2a\u9500\u552e\u989d\u7684\u6392\u540d\u4f1a\u8df3\u8fc7\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6709\u4e24\u4e2a\u5458\u5de5\u7684\u9500\u552e\u989d\u90fd\u662f\u7b2c\u4e00\uff0c\u90a3\u4e48\u4e0b\u4e00\u4e2a\u9500\u552e\u989d\u7684\u6392\u540d\u5c31\u662f\u7b2c\u4e09\uff0c\u800c\u4e0d\u662f\u7b2c\u4e8c\u3002\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nSUM(Sales) OVER(PARTITION BY Department) AS DepartmentSales,\nRANK() OVER(PARTITION BY Department ORDER BY Sales DESC) AS SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------------+-----------+\n| department | employee | sales | DepartmentSales | SalesRank |\n+------------+----------+-------+-----------------+-----------+\n| HR | Charlie | 850 | 1650 | 1 |\n| HR | Alice | 800 | 1650 | 2 |\n| Marketing | Jane | 1200 | 2200 | 1 |\n| Marketing | John | 1000 | 2200 | 2 |\n| Sales | Bob | 1100 | 2000 | 1 |\n| Sales | Alex | 900 | 2000 | 2 |\n+------------+----------+-------+-----------------+-----------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/","title":"ROW_NUMBER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/Window-Functions/row_number/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"ROW_NUMBER()
\u4e3a\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u5e8f\u53f7\uff0c\u4ece 1 \u5f00\u59cb\uff0c\u76f4\u5230\u7ed3\u679c\u96c6\u7684\u6700\u540e\u4e00\u884c\u3002\u5b83\u9996\u5148\u4f1a\u6839\u636e ORDER BY
\u5b50\u53e5\u4e2d\u6307\u5b9a\u7684\u5217\u5bf9\u6570\u636e\u96c6\u8fdb\u884c\u6392\u5e8f\uff0c\u7136\u540e\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u884c\u53f7\u3002
\u4e0e RANK()
\u548c DENSE_RANK()
\u51fd\u6570\u4e0d\u540c\uff0cROW_NUMBER()
\u5728\u5904\u7406\u5e73\u5c40\uff08\u5373\u4e24\u884c\u6216\u66f4\u591a\u884c\u5177\u6709\u76f8\u540c\u7684\u503c\uff09\u65f6\u4f1a\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e0d\u540c\u7684\u884c\u53f7\u3002
> ROW_NUMBER() OVER (\n [PARTITION BY column_1, column_2, ... ]\n ORDER BY column_3, column_4, ...\n)\n
PARTITION BY
\u5b50\u53e5\u662f\u53ef\u9009\u7684\uff0c\u5b83\u5c06\u6570\u636e\u96c6\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u5355\u72ec\u8ba1\u7b97\u884c\u53f7\u3002ORDER BY
\u5b50\u53e5\u5b9a\u4e49\u4e86\u6570\u636e\u96c6\u7684\u6392\u5e8f\u65b9\u5f0f\uff0c\u5373\u6839\u636e\u54ea\u4e00\u5217\u6216\u54ea\u4e9b\u5217\u8fdb\u884c\u6392\u5e8f\u3002\u53ef\u4ee5\u6307\u5b9a\u5347\u5e8f\uff08ASC\uff09\u6216\u964d\u5e8f\uff08DESC\uff09\u6392\u5e8f\u3002-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8868 'SalesTable'\uff0c\u8be5\u8868\u5177\u6709\u4e09\u4e2a\u5b57\u6bb5\uff1a'Department', 'Employee'\u548c 'Sales'\nCREATE TABLE SalesTable (\nDepartment VARCHAR(50),\nEmployee VARCHAR(50),\nSales INT\n);\n\n-- \u5411'SalesTable'\u8868\u4e2d\u63d2\u5165\u6570\u636e\uff0c\u6bcf\u884c\u5305\u542b\u4e00\u4e2a\u90e8\u95e8\uff08Department\uff09\u3001\u4e00\u4e2a\u5458\u5de5\uff08Employee\uff09\u548c\u4ed6\u4eec\u7684\u9500\u552e\u989d\uff08Sales\uff09\nINSERT INTO SalesTable (Department, Employee, Sales) VALUES\n('Marketing', 'John', 1000),\n('Marketing', 'Jane', 1200),\n('Sales', 'Alex', 900),\n('Sales', 'Bob', 1100),\n('HR', 'Alice', 800),\n('HR', 'Charlie', 850);\n\n-- \u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u5458\u5de5\u7684\u9500\u552e\u989d\u6392\u540d\n-- \u4f7f\u7528 ROW_NUMBER() \u51fd\u6570\u6309\u90e8\u95e8\uff08Department\uff09\u5bf9\u5458\u5de5\u7684\u9500\u552e\u989d\uff08Sales\uff09\u8fdb\u884c\u6392\u540d\n-- ROW_NUMBER() \u51fd\u6570\u5c06\u6570\u636e\u96c6\u6309\u7167\u90e8\u95e8\uff08Department\uff09\u5206\u4e3a\u591a\u4e2a\u5206\u533a\uff0c\u7136\u540e\u5728\u6bcf\u4e2a\u5206\u533a\u5185\u90e8\u6309\u7167\u9500\u552e\u989d\uff08Sales\uff09\u7684\u964d\u5e8f\u6392\u5217\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u4e3a\u6bcf\u4e00\u884c\u8d4b\u4e88\u4e00\u4e2a\u552f\u4e00\u7684\u884c\u53f7\uff08SalesRank\uff09\n-- \u6240\u4ee5\uff0c\u6bcf\u4e2a\u90e8\u95e8\u9500\u552e\u989d\u6700\u9ad8\u7684\u5458\u5de5\u5c06\u83b7\u5f97\u884c\u53f7 1\uff0c\u9500\u552e\u989d\u7b2c\u4e8c\u9ad8\u7684\u5458\u5de5\u5c06\u83b7\u5f97\u884c\u53f7 2\uff0c\u4ee5\u6b64\u7c7b\u63a8\nmysql> SELECT\nDepartment,\nEmployee,\nSales,\nROW_NUMBER() OVER (PARTITION BY Department ORDER BY Sales DESC) as SalesRank\nFROM\nSalesTable;\n+------------+----------+-------+-----------+\n| department | employee | sales | SalesRank |\n+------------+----------+-------+-----------+\n| HR | Charlie | 850 | 1 |\n| HR | Alice | 800 | 2 |\n| Marketing | Jane | 1200 | 1 |\n| Marketing | John | 1000 | 2 |\n| Sales | Bob | 1100 | 1 |\n| Sales | Alex | 900 | 2 |\n+------------+----------+-------+-----------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/","title":"CURRENT_ROLE()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u7684\u89d2\u8272\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SELECT CURRENT_ROLE();\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role/#_3","title":"\u793a\u4f8b","text":"mysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin |\n+----------------+\n1 row in set (0.00 sec)\n\n-- \u65b0\u5efa\u4e00\u4e2a\u89d2\u8272\uff0c\u5e76\u4e14\u5207\u6362\u5230\u65b0\u89d2\u8272\ncreate role use_role_1;\ngrant all on database * to use_role_1;\ngrant use_role_1 to root;\nset role use_role_1;\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| use_role_1 |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/","title":"CURRENT_ROLE_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURRENT_ROLE_NAME()
\u7528\u4e8e\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u767b\u5f55\u7684\u7528\u6237\u6240\u62e5\u6709\u7684\u89d2\u8272\u7684\u540d\u79f0\u3002
> CURRENT_ROLE_NAME()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_role_name/#_3","title":"\u793a\u4f8b","text":"mysql> select current_role_name();\n+---------------------+\n| current_role_name() |\n+---------------------+\n| moadmin |\n+---------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/","title":"CURRENT_USER, CURRENT_USER()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u5f53\u524d\u7528\u6237\u8d26\u6237\uff0c\u8fd4\u56de\u7684\u8d26\u6237\u5f62\u5f0f\u4e3a\uff1a\u7528\u6237\u540d@hostname\u3002\u8fd4\u56de\u503c\u662f utf8mb3 \u5b57\u7b26\u96c6\u7684\u5b57\u7b26\u4e32\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SELECT CURRENT_USER();\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user/#_3","title":"\u793a\u4f8b","text":"mysql> select current_user();\n+----------------+\n| current_user() |\n+----------------+\n| root@0.0.0.0 |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/","title":"CURRENT_USER_NAME()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CURRENT_USER_NAME()
\u7528\u4e8e\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u767b\u5f55\u7684\u7528\u6237\u540d\u79f0\u3002
> CURRENT_USER_NAME()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/current_user_name/#_3","title":"\u793a\u4f8b","text":"mysql> select current_user_name();\n+---------------------+\n| current_user_name() |\n+---------------------+\n| root |\n+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/","title":"PURGE_LOG()","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"PURGE_LOG()
\u7528\u4e8e\u5220\u9664\u8bb0\u5f55\u4e8e MatrixOne \u6570\u636e\u5e93\u7cfb\u7edf\u8868\u4e2d\u7684\u65e5\u5fd7\u3002\u8fd4\u56de 0 \u8868\u793a\u5220\u9664\u6210\u529f\uff1b\u5220\u9664\u5931\u8d25\u5219\u8fd4\u56de\u62a5\u9519\u4fe1\u606f\u3002
Note
\u76ee\u524d\uff0c\u4ec5\u6709 root \u7528\u6237\uff08\u5373\u96c6\u7fa4\u7ba1\u7406\u5458\uff0c\u5177\u6709 MOADMIN
\u6743\u9650\uff09\u62e5\u6709\u6267\u884c PURGE_LOG()
\u51fd\u6570\u4ee5\u8fdb\u884c\u65e5\u5fd7\u5220\u9664\u64cd\u4f5c\u7684\u6743\u9650\u3002
> PURGE_LOG('sys_table_name', 'date')\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e 'sys_table_name' \u5f53\u524d\u53ef\u8fdb\u884c\u5220\u9664\u7684\u7cfb\u7edf\u8868\u4ec5\u4e09\u4e2a\uff1ametric\uff0crawlog\uff0cstatement_info\u3002 Note: 'sys_table_name' \u5fc5\u987b\u7528\u5f15\u53f7\u5305\u88f9\u3002 'date' \u9009\u62e9\u65e5\u671f\uff0c\u5220\u9664\u8be5\u65e5\u671f\u4e4b\u524d\u4ea7\u751f\u7684\u65e5\u5fd7\u3002 Note: 'date' \u5fc5\u987b\u7528\u5355\u5f15\u53f7\u5305\u88f9\u3002 Note
MatrixOne \u6709\u4e14\u4ec5\u6709 metric\uff0crawlog\uff0cstatement_info \u4e09\u5f20\u7cfb\u7edf\u65e5\u5fd7\u8868\uff0c\u6709\u5173\u8fd9\u4e09\u5f20\u8868\u7684\u8be6\u7ec6\u4fe1\u606f\u8bf7\u53c2\u8003 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u3002
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/purge_log/#_4","title":"\u793a\u4f8b","text":"-- \u5220\u9664 2023-06-30 \u8fd9\u4e00\u5929\u4e4b\u524d\u7684 statement_info \u7c7b\u578b\u7684\u65e5\u5fd7\nmysql> select purge_log('statement_info', '2023-06-30') a;\n+------+\n| a |\n+------+\n| 0 |\n+------+\n1 row in set (0.01 sec)\n
-- \u67e5\u8be2 metric \u65e5\u5fd7\u91c7\u96c6\u7684\u65f6\u95f4\u548c\u6570\u91cf\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-07 | 20067 |\n| 2023-07-06 | 30246 |\n| 2023-07-05 | 27759 |\n+-------------------+----------+\n3 rows in set (0.04 sec)\n\n-- \u5220\u9664 2023-07-06 \u8fd9\u4e00\u5929\u4e4b\u524d\u7684 rawlog\uff0cstatement_info\uff0c\u548c metric \u4e09\u79cd\u7c7b\u578b\u7684\u65e5\u5fd7\nmysql> select purge_log('rawlog, statement_info, metric', '2023-07-06');\n+-------------------------------------------------------+\n| purge_log(rawlog, statement_info, metric, 2023-07-06) |\n+-------------------------------------------------------+\n| 0 |\n+-------------------------------------------------------+\n1 row in set (0.33 sec)\n\n-- \u518d\u6b21\u67e5\u8be2 2023-07-05\uff0c2023-07-06 \u548c 2023-07-07 \u8fd9\u4e09\u5929\u7684 metric \u65e5\u5fd7\u6570\u91cf\nmysql> select date(collecttime), count(1) from system_metrics.metric group by date(collecttime);\n+-------------------+----------+\n| date(collecttime) | count(1) |\n+-------------------+----------+\n| 2023-07-06 | 30246 |\n| 2023-07-07 | 20121 |\n+-------------------+----------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/","title":"VERSION","text":""},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"VERSION()
\u51fd\u6570\u7528\u4e8e\u83b7\u53d6\u5f53\u524d MatrixOne \u7684\u7248\u672c\u4fe1\u606f\u3002\u8fd9\u4e2a\u51fd\u6570\u901a\u5e38\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u5305\u542b\u4e86 MatrixOne \u7684\u7248\u672c\u53f7\u3002\u5982 8.0.30-MatrixOne-v1.2.1\uff0c\u8868\u793a MatrixOn \u7684\u7248\u672c\u53f7\u662f 8.0.30-MatrixOne-v1.2.1, \u5b83\u7684\u5b9a\u4e49\u662f MySQL \u517c\u5bb9\u7248\u672c\u53f7 (8.0.30) + MatrixOne + MatrixOne \u5185\u6838\u7248\u672c (v1.2.1)\u3002
> VERSION()\n
"},{"location":"MatrixOne/Reference/Functions-and-Operators/system-ops/version/#_3","title":"\u793a\u4f8b","text":"mysql> select version();\n+-------------------------+\n| version() |\n+-------------------------+\n| 8.0.30-MatrixOne-v1.2.1 |\n+-------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Language-Structure/comment/","title":"\u6ce8\u91ca","text":"\u672c\u6587\u6863\u4ecb\u7ecd MatrixOne \u652f\u6301\u7684\u6ce8\u91ca\u8bed\u6cd5\u3002
MatrixOne \u652f\u6301\u4ee5\u4e0b\u6ce8\u91ca\u683c\u5f0f\uff1a
#
\u6ce8\u91ca\uff1amysql> select 100-99; # \u6ce8\u91ca\u5185\u5bb9\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
--
\u6765\u6ce8\u91ca\u4e00\u884c\u3002--
\uff08\u53cc\u7834\u6298\u53f7\uff09\u6ce8\u91ca\u6837\u5f0f\u8981\u6c42\u7b2c\u4e8c\u4e2a\u7834\u6298\u53f7\u540e\u8ddf\u81f3\u5c11\u4e00\u4e2a\u7a7a\u683c\u6216\u63a7\u5236\u5b57\u7b26\uff08\u4f8b\u5982\u7a7a\u683c\u3001\u5236\u8868\u7b26\u3001\u6362\u884c\u7b26\u7b49\uff09\u3002mysql> select 100-99; -- \u6ce8\u91ca\u5185\u5bb9\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
/*
\u5f00\u5934\uff0c\u4ee5 */
\u7ed3\u675f\uff0c\u4e0e C \u8bed\u8a00\u4e2d\u4f7f\u7528\u65b9\u5f0f\u4e00\u6837\u3002\u6b64\u8bed\u6cd5\u4f7f\u6ce8\u91ca\u53ef\u4ee5\u6269\u5c55\u5230\u591a\u884c\u3002mysql> select 100 /* \u6ce8\u91ca\u5185\u5bb9 */ -99;\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
\u6216\uff1a
mysql> select 100\n/*\n\u6ce8\u91ca\u5185\u5bb9\n*/\n-99;\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Language-Structure/comment/#matrixone","title":"MatrixOne \u53ef\u6267\u884c\u7684\u6ce8\u91ca\u8bed\u6cd5","text":"mysql> select 100-99; // This comment continues to the end of line\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.03 sec)\n
\u6216\uff1a
mysql> // This comment continues to the line\n-> select 100-99;\n+----------+\n| 100 - 99 |\n+----------+\n| 1 |\n+----------+\n
mysql> select 100 /*! Specific code */ -99;\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 28 near \" code */ -99\";\n
\u6216\uff1a
mysql> select 100 /*!50110 Specific code */ -99;\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 33 near \" code */ -99\";\n
"},{"location":"MatrixOne/Reference/Language-Structure/comment/#_2","title":"\u9650\u5236","text":"\u672c\u7ae0\u4ecb\u7ecd MatrixOne \u7684\u5173\u952e\u5b57\uff0c\u5728 MatrixOne \u4e2d\u5bf9\u4fdd\u7559\u5173\u952e\u5b57\u548c\u975e\u4fdd\u7559\u5173\u952e\u5b57\u8fdb\u884c\u4e86\u5206\u7c7b\uff0c\u4f60\u5728\u4f7f\u7528 SQL \u8bed\u53e5\u65f6\uff0c\u53ef\u4ee5\u67e5\u9605\u4fdd\u7559\u5173\u952e\u5b57\u548c\u975e\u4fdd\u7559\u5173\u952e\u5b57\u3002
\u5173\u952e\u5b57\u662f SQL \u8bed\u53e5\u4e2d\u5177\u6709\u7279\u6b8a\u542b\u4e49\u7684\u5355\u8bcd\uff0c\u4f8b\u5982 SELECT
\uff0cUPDATE
\uff0cDELETE
\u7b49\u7b49\u3002
\u5c06\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\uff0c\u5426\u5219\u5c06\u4ea7\u751f\u62a5\u9519\uff1a
\\\\\u672a\u5c06\u4fdd\u7559\u5173\u952e\u5b57 select \u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\uff0c\u4ea7\u751f\u62a5\u9519\nmysql> CREATE TABLE select (a INT);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 19 near \" select (a INT)\";\n\n\\\\\u6b63\u786e\u5c06\u4fdd\u7559\u5173\u952e\u5b57 select \u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\nmysql> CREATE TABLE `select` (a INT);\nQuery OK, 0 rows affected (0.02 sec)\n
\u5c06\u975e\u4fdd\u7559\u5173\u952e\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u4f7f\u7528\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\uff0c\u65e0\u9700\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\u3002
\\\\ACCOUNT \u4e3a\u975e\u4fdd\u7559\u5173\u952e\u5b57\uff0c\u53ef\u4ee5\u65e0\u9700\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\nmysql> CREATE TABLE `select` (ACCOUNT int);\nQuery OK, 0 rows affected (0.01 sec)\n
Note
\u4e0e MySQL \u4e0d\u540c\uff0c\u5728 MatrixOne \u4e2d\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u9650\u5b9a\u7b26.\uff0c\u4fdd\u7559\u5173\u952e\u5b57\u5982\u679c\u4e0d\u4f7f\u7528\u53cd\u5f15\u53f7\u5305\u88f9\u4e5f\u4f1a\u4ea7\u751f\u62a5\u9519\uff0c\u5efa\u8bae\u5728\u521b\u5efa\u8868\u548c\u6570\u636e\u5e93\u65f6\uff0c\u907f\u514d\u4f7f\u7528\u4fdd\u7559\u5173\u952e\u5b57\uff1a
mysql> CREATE TABLE test.select (ACCOUNT int);\nERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax; check the manual that corresponds to your MatrixOne server version for the right syntax to use. syntax error at line 1 column 24 near \"select (ACCOUNT int)\";\n
\u4e0b\u9762\u7684\u5217\u8868\u663e\u793a\u4e86 Matrixone \u4e2d\u7684\u4fdd\u7559\u5173\u952e\u5b57\u548c\u975e\u4fdd\u7559\u5173\u952e\u5b57\uff0c\u5176\u4e2d\uff0c\u5728 MySQL \u4e2d\u4e0d\u4e3a\u5173\u952e\u5b57\u7684\u7528 (M) \u6807\u8bb0\u3002
"},{"location":"MatrixOne/Reference/Language-Structure/keywords/#_2","title":"\u4fdd\u7559\u5173\u952e\u5b57","text":""},{"location":"MatrixOne/Reference/Language-Structure/keywords/#a","title":"A","text":"MySQL 8.0 \u7684\u5b8c\u6574\u8bed\u6cd5\u5982\u4e0b\u6240\u793a\uff1a
LOAD DATA\n [LOW_PRIORITY | CONCURRENT] [LOCAL]\n INFILE 'file_name'\n [REPLACE | IGNORE]\n INTO TABLE tbl_name\n [PARTITION (partition_name [, partition_name] ...)]\n [CHARACTER SET charset_name]\n [{FIELDS | COLUMNS}\n [TERMINATED BY 'string']\n [[OPTIONALLY] ENCLOSED BY 'char']\n [ESCAPED BY 'char']\n ]\n [LINES\n [STARTING BY 'string']\n [TERMINATED BY 'string']\n ]\n [IGNORE number {LINES | ROWS}]\n [(col_name_or_user_var\n [, col_name_or_user_var] ...)]\n [SET col_name={expr | DEFAULT}\n [, col_name={expr | DEFAULT}] ...]\n
"},{"location":"MatrixOne/Reference/Limitations/load-data-support/#matrixone","title":"MatrixOne \u6682\u4e0d\u652f\u6301\u7684\u5b57\u6bb5","text":"\u4e0a\u8ff0\u5b8c\u6574\u7684\u8bed\u6cd5\u7ed3\u6784\u4e2d\uff0cMatrixOne \u6682\u8fd8\u4e0d\u652f\u6301\u4ee5\u4e0b\u5b57\u6bb5\uff1a
\"
\u3002\\r\\n
.ignore
, \u8868\u793a\u5b57\u6bb5\u8f6c\u5230\u8868\u4e2d\u5217\u51fa\u9519\u65f6\uff0c\u4e0d\u4f1a\u7ec8\u6b62\u6574\u4e2a load
\uff0c\u4f1a\u8bb0\u5f55 warnings
\u4e2a\u6570\uff0c\u4f46\u4e0d\u8bb0\u5f55 warings
\u5185\u5bb9\uff1b\u4e0d\u52a0 ignore
, \u5b57\u6bb5\u8f6c\u5230\u8868\u4e2d\u5217\u51fa\u9519\u65f6\uff0c\u4f1a\u7ec8\u6b62\u6574\u4e2a load
INTO TABLE tableA FIELDS TERMINATED BY ',' \u5fc5\u987b\uff0c\u8868\u793a\u5b57\u6bb5\u5206\u5272\u7b26\u3002\u901a\u5e38\u662f','\u3002\u800c ssb \u7684\u662f' IGNORE number LINES \u53ef\u9009\uff0c\u8868\u793a\u5ffd\u7565\u6389\u6587\u4ef6\u5f00\u5934\u7684 number \u884c (col0,col1,...,coln); \u53ef\u9009\uff0c\u8868\u793a \u8868\u4e2d\u7684\u5217\u540d\u5217\u8868\u3002\u4f8b\u5982\uff0ccoli
\u5bf9\u5e94\u8868\u4e2d\u7b2c i
\u4e2a\u5217\u3002 \u4f8b\u5982\uff0c\u6570\u636e\u884c field0 field1 field2 ... fieldN
\uff0c\u5bf9\u5e94\u63d2\u5165\u5230\u8868\u5217 (col0, col1, col2 ,...,colN)
\u5982\u679c\u5217 coli \u4ee5'@'\u5f00\u5934\uff0c\u90a3\u4e48 fieldi \u88ab\u4e22\u5f03\uff1b(col0,col1,...,coln) \u53ef\u4ee5\u4e0d\u4e0e\u8868\u4e2d\u7684\u5217\u540d\u987a\u5e8f\u76f8\u540c\u3002fieldi \u7ed1\u5b9a\u5230\u5bf9\u5e94\u7684\u5217\u540d\u3002\u5982\u679c\u6570\u636e\u884c\u7684\u5b57\u6bb5 \u5c11\u4e8e (col0,col1,...,coln) \u6216\u8868\u4e2d\u7684\u5217\u6570\uff0c\u591a\u4f59\u7684\u5b57\u6bb5\u88ab\u4e22\u5f03\u3002\u5982\u679c\u6570\u636e\u884c\u7684\u5b57\u6bb5 \u5c11\u4e8e (col0,col1,...,coln) \u6216\u8868\u4e2d\u7684\u5217\u6570\uff0c\u5c11\u7684\u5217\u8865 NULL\u3002\u5982\u679c load data \u8bed\u6cd5\u4e2d\u6ca1\u6709 (col0,col1,...,coln)\uff0c\u76f8\u5f53\u4e8e \u52a0\u8f7d\u5230\u8868\u4e2d\u7684\u5168\u90e8\u5217\u3002"},{"location":"MatrixOne/Reference/Limitations/load-data-support/#csv","title":"csv \u7684\u683c\u5f0f\u8981\u6c42","text":"\u5b57\u7b26 \u63cf\u8ff0 \u5b57\u6bb5\u5206\u5272\u7b26 \u901a\u5e38\u662f','\uff0c\u4e5f\u53ef\u4ee5\u662f\u5176\u5b83\u5b57\u7b26\uff08\u4e0d\u662f\"
,'\\r','\\n')\u3002\u4f8b\u5982\uff1aSSB \u6570\u636e\u96c6\u5c31\u662f' \u5b57\u6bb5\u5305\u542b\u7b26 \"
\u884c\u7ed3\u675f\u7b26 \\r\\n
\u6216'\\n' \u5b57\u6bb5 NULL \u503c \u5bf9\u4e8e\u503c \\N , \u8868\u793a\u8be5\u5b57\u6bb5\u4e3a NULL\uff0c\u5176\u4ed6\u4efb\u4f55\u60c5\u51b5\u5747\u89c6\u4e3a\u5b57\u7b26\u4e32\u8f93\u5165 \u6ce8\u91ca\u7b26\u53f7 '#' \u4f5c\u4e3a\u7b2c\u4e00\u4e2a\u5b57\u7b26\u7684\u884c\u90fd\u4f1a\u88ab\u8fc7\u6ee4\u6389"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/","title":"MatrixOne \u7684 JDBC \u529f\u80fd\u652f\u6301\u5217\u8868","text":"\u4f7f\u7528 JDBC \u5f00\u53d1\u5e94\u7528\uff0cMatrixOne \u652f\u6301\u4ee5\u4e0b\u7c7b\u548c\u5bf9\u8c61\uff1a
"},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#1-connection","title":"1. Connection\uff08\u7c7b\uff09\uff1a\u83b7\u53d6\u6570\u636e\u5e93\u8fde\u63a5\u5bf9\u8c61","text":""},{"location":"MatrixOne/Reference/Limitations/mo-jdbc-feature-list/#_1","title":"\u7c7b\u4e2d\u7684\u65b9\u6cd5","text":"\u83b7\u53d6\u6267\u884c Sql \u5bf9\u8c61 Statement
\u7ba1\u7406\u4e8b\u52a1
INTERVAL
\u7528\u4e8e\u65e5\u671f\u548c\u65f6\u95f4\u8ba1\u7b97\u3002
INTERVAL
\u53ef\u4ee5\u7528\u4e8e\u51fd\u6570\u8fd0\u7b97 DATE_ADD()
\u548c DATE_SUB()
\u3002
INTERVAL
\u53ef\u4ee5\u518d\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528 +
\u6216 -
\u8fd0\u7b97\u7b26\u6765\u8fdb\u884c\u8fd0\u7b97\u3002
date + INTERVAL expr unit\ndate - INTERVAL expr unit\n
+
\u8fd0\u7b97\u7b26\u7684\u5de6\u8fb9\u6216\u8005\u53f3\u8fb9\uff0c\u53ea\u8981\u5b83\u5176\u4e2d\u4e00\u8fb9\u7684\u8868\u8fbe\u5f0f\u662f\u4e00\u4e2a date
\u6216 datetime
\u503c\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528 INTERVAL expr
\u3002-
\u8fd0\u7b97\u7b26\uff0c\u4ec5\u4ec5\u53ef\u4ee5\u5728 -
\u7684\u53f3\u8fb9\u4f7f\u7528 INTERVAL expr
\u3002> INTERVAL (expr,unit)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e expr \u4efb\u4f55\u6570\u503c\u7c7b\u578b\u4e0e\u5b57\u7b26\u4e32\u5217\u7684\u5217\u540d unit \u8bf4\u660e\u7b26\uff0c\u4f8b\u5982 HOUR\u3001DAY \u6216 WEEK Note
INTERVAL
\u5173\u952e\u5b57\u548c unit
\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
\u4f60\u53ef\u4ee5\u5728 expr
\u4e2d\u4f7f\u7528\u4efb\u4f55\u6807\u70b9\u5206\u9694\u7b26\u3002\u4e0a\u8868\u6240\u793a\u4e3a\u5efa\u8bae\u7684\u5206\u9694\u7b26\u3002
DATE_ADD()
\u548c DATE_SUB()
\u4e00\u8d77\u4f7f\u7528\uff1amysql> SELECT DATE_SUB('2018-05-01',INTERVAL 1 YEAR);\n+-----------------------------------------+\n| date_sub(2018-05-01, interval(1, year)) |\n+-----------------------------------------+\n| 2017-05-01 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2020-12-31 23:59:59', INTERVAL 1 SECOND);\n+----------------------------------------------------+\n| date_add(2020-12-31 23:59:59, interval(1, second)) |\n+----------------------------------------------------+\n| 2021-01-01 00:00:00 |\n+----------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT DATE_ADD('2018-12-31 23:59:59', INTERVAL 1 DAY);\n+-------------------------------------------------+\n| date_add(2018-12-31 23:59:59, interval(1, day)) |\n+-------------------------------------------------+\n| 2019-01-01 23:59:59 |\n+-------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2100-12-31 23:59:59', INTERVAL '1:1' MINUTE_SECOND);\n+-------------------------------------------------------------+\n| date_add(2100-12-31 23:59:59, interval(1:1, minute_second)) |\n+-------------------------------------------------------------+\n| 2101-01-01 00:01:00 |\n+-------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('2025-01-01 00:00:00', INTERVAL '1 1:1:1' DAY_SECOND);\n+--------------------------------------------------------------+\n| date_sub(2025-01-01 00:00:00, interval(1 1:1:1, day_second)) |\n+--------------------------------------------------------------+\n| 2024-12-30 22:58:59 |\n+--------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1900-01-01 00:00:00', INTERVAL '-1 10' DAY_HOUR);\n+----------------------------------------------------------+\n| date_add(1900-01-01 00:00:00, interval(-1 10, day_hour)) |\n+----------------------------------------------------------+\n| 1899-12-30 14:00:00.000000 |\n+----------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_SUB('1998-01-02', INTERVAL 31 DAY);\n+-----------------------------------------+\n| date_sub(1998-01-02, interval(31, day)) |\n+-----------------------------------------+\n| 1997-12-02 |\n+-----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('1992-12-31 23:59:59.000002', INTERVAL '1.999999' SECOND_MICROSECOND);\n+------------------------------------------------------------------------------+\n| date_add(1992-12-31 23:59:59.000002, interval(1.999999, second_microsecond)) |\n+------------------------------------------------------------------------------+\n| 1993-01-01 00:00:01.000001 |\n+------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#2","title":"\u793a\u4f8b 2","text":"+
\u6216 -
\u4e00\u8d77\u4f7f\u7528\uff1amysql> SELECT '2018-12-31 23:59:59' + INTERVAL 1 SECOND;\n+-------------------------------------------+\n| 2018-12-31 23:59:59 + interval(1, second) |\n+-------------------------------------------+\n| 2019-01-01 00:00:00 |\n+-------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT INTERVAL 1 DAY + '2018-12-31';\n+-------------------------------+\n| interval(1, day) + 2018-12-31 |\n+-------------------------------+\n| 2019-01-01 |\n+-------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT '2025-01-01' - INTERVAL 1 SECOND;\n+----------------------------------+\n| 2025-01-01 - interval(1, second) |\n+----------------------------------+\n| 2024-12-31 23:59:59 |\n+----------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#3","title":"\u793a\u4f8b 3","text":"\u5982\u679c\u4f60\u5728\u4e00\u4e2a date
\u503c\u4e0a\u52a0\u4e0a\u6216\u51cf\u53bb\u4e00\u4e2a\u5305\u542b\u65f6\u95f4\u90e8\u5206\u7684\u503c\uff0c\u6267\u884c\u7ed3\u679c\u4f1a\u81ea\u52a8\u8f6c\u6362\u4e3a\u4e00\u4e2a datetime
\u503c\uff1a
mysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 DAY);\n+----------------------------------------+\n| date_add(2023-01-01, interval(1, day)) |\n+----------------------------------------+\n| 2023-01-02 |\n+----------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT DATE_ADD('2023-01-01', INTERVAL 1 HOUR);\n+-----------------------------------------+\n| date_add(2023-01-01, interval(1, hour)) |\n+-----------------------------------------+\n| 2023-01-01 01:00:00 |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#4","title":"\u793a\u4f8b 4","text":"\u5982\u679c\u6dfb\u52a0\u4e86 MONTH
\u3001YEAR_MONTH
\u6216 YEAR
\uff0c\u5e76\u4e14\u6267\u884c\u7ed3\u679c\u7684\u65e5\u671f\u7684\u67d0\u4e00\u5929\u6bd4\u5f53\u6708\u7684\u6700\u5927\u5929\u6570\u5927\uff0c\u5219\u8be5\u5929\u5c06\u88ab\u8c03\u6574\u4e3a\u5f53\u6708\u7684\u6700\u5927\u5929\u6570\uff1a
mysql> SELECT DATE_ADD('2019-01-30', INTERVAL 1 MONTH);\n+------------------------------------------+\n| date_add(2019-01-30, interval(1, month)) |\n+------------------------------------------+\n| 2019-02-28 |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/interval/#5","title":"\u793a\u4f8b 5","text":"date
\u4e0d\u80fd\u7528\u9519\u8bef\u7684\u65e5\u671f\uff0c\u5982\u6267\u884c 2016-07-00 \u6216\u683c\u5f0f\u4e25\u91cd\u9519\u8bef\u7684\u65e5\u671f\uff0c\u5219\u6267\u884c\u4f1a\u62a5\u9519\u3002
mysql> SELECT DATE_ADD('2016-07-00', INTERVAL 1 DAY);\nERROR 20301 (HY000): invalid input: invalid datatime value 2016-07-00\n\nmysql> SELECT '2005-03-32' + INTERVAL 1 MONTH;\nERROR 20301 (HY000): invalid input: invalid datatime value 2005-03-32\n
"},{"location":"MatrixOne/Reference/Operators/operators/operator-precedence/","title":"\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7","text":"\u8fd0\u7b97\u7b26\u4ece\u9ad8\u5230\u4f4e\u7684\u4f18\u5148\u7ea7\u5982\u4e0b\u6240\u793a\u3002\u5728\u540c\u4e00\u884c\u4e2d\u7684\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u76f8\u7b49\u3002
\u4f18\u5148\u7ea7\u4ece\u9ad8\u5230\u4f4e\u6392\u5e8f \u8fd0\u7b97\u7b26 1 INTERVAL 2 BINARY, COLLATE 3 ! 4 - (unary minus), ~ (unary bit inversion) 5 ^ 6 *, /, DIV, %, MOD 7 -, + 8 <<, >> 9 & 10 | 11 = (comparison), <=>, >=, >, <=, <, <>, !=, IS, LIKE, , IN, MEMBER OF 12 BETWEEN, CASE, WHEN, THEN, ELSE 13 NOT 14 AND, && 15 XOR 16 OR, || 17 = (assignment)\u8fd0\u7b97\u7b26 =
\u7684\u4f18\u5148\u7ea7\u53d6\u51b3\u4e8e\u5b83\u662f\u7528\u4f5c\u6bd4\u8f83\u64cd\u4f5c\u7b26\u8fd8\u662f\u8d4b\u503c\u64cd\u4f5c\u7b26\u3002\u5f53\u7528\u4f5c\u6bd4\u8f83\u64cd\u4f5c\u7b26\u65f6\uff0c\u5b83\u4e0e >=
\uff0c>
\uff0c<=
\uff0c<
\uff0c<>
\uff0c!=
\uff0cIS
\uff0cLIKE
\u548c IN()
\u5177\u6709\u76f8\u540c\u7684\u4f18\u5148\u7ea7\u3002
\u5bf9\u4e8e\u5728\u8868\u8fbe\u5f0f\u4e2d\u5177\u6709\u76f8\u540c\u4f18\u5148\u7ea7\u7684\u8fd0\u7b97\u7b26\uff0c\u6c42\u503c\u5c06\u4ece\u5de6\u5230\u53f3\u8fdb\u884c\u8ba1\u7b97\uff0c\u4f46\u8d4b\u503c\u5c06\u4ece\u53f3\u5230\u5de6\u8fdb\u884c\u8ba1\u7b97\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/operators/","title":"\u8fd0\u7b97\u7b26\u6982\u8ff0","text":""},{"location":"MatrixOne/Reference/Operators/operators/operators/#_2","title":"\u7b97\u6570\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 %,MOD \u53d6\u4f59 * \u4e58\u6cd5 + \u52a0\u6cd5 - \u51cf\u6cd5 - \u8d1f\u53f7 / \u9664\u6cd5 DIV \u7528\u4e8e\u6574\u6570\u76f8\u9664"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_3","title":"\u8d4b\u503c\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 = \u7b49\u4e8e\u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u8d4b\u503c"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_4","title":"\u4e8c\u8fdb\u5236\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 & \u4f4d\u8fd0\u7b97\u7b26\u4e0e\uff0c\u6309\u4f4d\u4e0e >> \u4f4d\u79fb\u8fd0\u7b97\u7b26\u53f3\u79fb << \u4f4d\u79fb\u8fd0\u7b97\u7b26\u5de6\u79fb ^ \u6309\u4f4d\u5f02\u6216 | \u4f4d\u8fd0\u7b97\u7b26\u6216\uff0c\u6309\u4f4d\u6216 ~ \u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u4e8c\u8fdb\u5236\u53d6\u53cd"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_5","title":"\u5f3a\u5236\u8f6c\u6362\u51fd\u6570\u548c\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 BINARY() \u5c06\u503c\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u51fd\u6570 CAST() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u5c0f\u6570\u8f6c\u6570\u503c\u548c\u5b57\u7b26\u578b CONVERT() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u65e5\u671f\u548c\u65f6\u95f4\u503c\u3001\u5c0f\u6570\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_6","title":"\u6bd4\u8f83\u51fd\u6570\u548c\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 > \u5927\u4e8e >= \u5927\u4e8e\u7b49\u4e8e < \u5c0f\u4e8e <>,!= \u4e0d\u7b49\u4e8e <= \u5c0f\u4e8e\u7b49\u4e8e = \u7b49\u4e8e BETWEEN ... AND ... \u5728\u4e24\u503c\u4e4b\u95f4 IN() \u5728\u96c6\u5408\u4e2d IS \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0c\u82e5\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u201ctrue\u201d IS NOT \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0cIS \u7684\u5426\u5b9a\u7528\u6cd5 IS NOT NULL \u4e0d\u4e3a\u7a7a IS NULL \u4e3a\u7a7a ISNULL \u4ee3\u66ff=
\u6765\u6d4b\u8bd5\u503c\u662f\u5426\u4e3a NULL
\u3002 LIKE \u6a21\u7cca\u5339\u914d ILIKE \u6a21\u7cca\u5339\u914d\uff0c\u540c LIKE\u3002\u4f46\u5bf9\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002 NOT BETWEEN ... AND ... \u4e0d\u5728\u4e24\u503c\u4e4b\u95f4 NOT IN \u591a\u4e2a XOR
\u6761\u4ef6\u7684\u7b80\u5199 NOT LIKE \u6a21\u7cca\u5339\u914d\uff0cLike \u7684\u5426\u5b9a\u7528\u6cd5 COALESCE \u8fd4\u56de\u7b2c\u4e00\u4e2a\u975e\u7a7a\u503c"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_7","title":"\u63a7\u5236\u6d41\u51fd\u6570","text":"\u540d\u79f0 \u63cf\u8ff0 CASE Case when \u8fd0\u7b97\u7b26 IF() If/else \u8bed\u53e5 IFNULL() If null/else \u8bed\u53e5 NULLIF() expr1 = expr2 \u65f6\u8fd4\u56de NULL\uff0c\u5426\u5219\u8fd4\u56de expr1"},{"location":"MatrixOne/Reference/Operators/operators/operators/#_8","title":"\u903b\u8f91\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 AND,&& \u903b\u8f91\u4e0e NOT,! \u903b\u8f91\u975e OR \u903b\u8f91\u6216 XOR \u903b\u8f91\u5f02\u6216"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/","title":"+","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"+
\u8fd0\u7b97\u7b26\u7528\u4e8e\u52a0\u6cd5\u8fd0\u7b97\u3002
> SELECT value1+value2;\n
> SELECT column1+column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/addition/#_4","title":"\u793a\u4f8b","text":"mysql> select 1123.2333+1233.3331;\n+-----------------------+\n| 1123.2333 + 1233.3331 |\n+-----------------------+\n| 2356.5664 |\n+-----------------------+\n1 row in set (0.01 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1+5 from t2;\n+--------+\n| c1 + 5 |\n+--------+\n| 2 |\n| 6 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1+c2 from t2;\n+---------+\n| c1 + c2 |\n+---------+\n| -1 |\n| 3 |\n+---------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/","title":"\u7b97\u6570\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 %,MOD \u53d6\u4f59 * \u4e58\u6cd5 + \u52a0\u6cd5 - \u51cf\u6cd5 - \u8d1f\u53f7 / \u9664\u6cd5 DIV \u6574\u6570\u76f8\u9664 \u2014 \u5bf9\u4e8e -
\u3001+
\u548c *
\uff0c\u5982\u679c\u4e24\u4e2a\u8fd0\u7b97\u6570\u503c\u90fd\u662f\u6574\u6570\uff0c\u8ba1\u7b97\u7ed3\u679c\u5c06\u4ee5 BIGINT (64 \u4f4d) \u7cbe\u5ea6\u8ba1\u7b97\u3002
\u2014 \u5982\u679c\u4e24\u4e2a\u8fd0\u7b97\u6570\u503c\u90fd\u662f\u6574\u6570\u4e14\u5176\u4e2d\u4efb\u4f55\u4e00\u4e2a\u90fd\u662f\u65e0\u7b26\u53f7\u7684\uff0c\u5219\u7ed3\u679c\u4e3a\u65e0\u7b26\u53f7\u6574\u6570\u3002
\u2014 \u5982\u679c +
\u3001-
\u3001/
\u3001*
\u3001%
\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\u8fd0\u7b97\u6570\u503c\u662f\u4e00\u4e2a\u5b9e\u503c\u6216\u5b57\u7b26\u4e32\u503c\uff0c\u5219\u7ed3\u679c\u7684\u7cbe\u5ea6\u4e3a\u8fd0\u7b97\u6570\u7684\u6700\u5927\u7cbe\u5ea6\u3002
\u5728\u4f7f\u7528 /
\u8fdb\u884c\u9664\u6cd5\u65f6\uff0c\u5f53\u4f7f\u7528\u4e24\u4e2a\u7cbe\u786e\u503c\u8fd0\u7b97\u6570\u65f6\uff0c\u7ed3\u679c\u7684\u7cbe\u5ea6\u8303\u56f4\u662f\u7b2c\u4e00\u4e2a\u8fd0\u7b97\u6570\u503c\u7684\u7cbe\u5ea6\u8303\u56f4\u52a0\u4e0a div_precision_increment
\u7cfb\u7edf\u53d8\u91cf\u7684\u503c\u3002\u4f8b\u5982\uff0c\u8868\u8fbe\u5f0f 5.05 / 0.014 \u7684\u7ed3\u679c\u6709\u4e00\u4e2a\u5c0f\u6570 8 \u4f4d\u7684\u7cbe\u5ea6 (360.71428571)\u3002
\u8fd9\u4e9b\u89c4\u5219\u9002\u7528\u4e8e\u6bcf\u4e2a\u64cd\u4f5c\uff0c\u4f8b\u5982\u5d4c\u5957\u8ba1\u7b97\u53d6\u6bcf\u4e2a\u7ec4\u4ef6\u7684\u7cbe\u5ea6\u3002\u56e0\u6b64\uff0c(14620 / 9432456)/(24250 / 9432456) \u9996\u5148\u89e3\u6790\u4e3a (0.0014)/(0.0026)\uff0c\u6700\u7ec8\u7ed3\u679c\u6709 16 \u4f4d\u5c0f\u6570 (0.6028865979381443)\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/arithmetic-operators-overview/#_2","title":"\u9650\u5236","text":"DIV
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6574\u6570\u9664\u6cd5\u3002
\u5982\u679c\u4e24\u4e2a\u8fd0\u7b97\u6570\u503c\u90fd\u662f\u975e\u6574\u6570\u7c7b\u578b\uff0c\u5219\u4f1a\u5c06\u8fd0\u7b97\u6570\u503c\u8f6c\u6362\u4e3a DECIMAL
\uff0c\u5e76\u5728\u5c06\u7ed3\u679c\u8f6c\u6362\u4e3a BIGINT
\u4e4b\u524d\u4f7f\u7528 DECIMAL
\u7b97\u6cd5\u8fdb\u884c\u9664\u6cd5\u3002\u5982\u679c\u7ed3\u679c\u8d85\u51fa BIGINT
\u8303\u56f4\uff0c\u5219\u4f1a\u53d1\u751f\u9519\u8bef\u3002
> SELECT value1 DIV value2;\n
> SELECT column1 DIV column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/div/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 5 DIV 2, -5 DIV 2, 5 DIV -2, -5 DIV -2;\n+---------+----------+----------+-----------+\n| 5 div 2 | -5 div 2 | 5 div -2 | -5 div -2 |\n+---------+----------+----------+-----------+\n| 2 | -2 | -2 | 2 |\n+---------+----------+----------+-----------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 DIV 3 from t2;\n+----------+\n| c1 div 3 |\n+----------+\n| -1 |\n| 0 |\n+----------+\n2 rows in set (0.00 sec)\n\nmysql> select c1 DIV c2 from t2;\n+-----------+\n| c1 div c2 |\n+-----------+\n| -1 |\n| 0 |\n+-----------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/","title":"/","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"/
\u8fd0\u7b97\u7b26\u7528\u4e8e\u9664\u6cd5\u8fd0\u7b97\u3002
> SELECT value1/value2;\n
> SELECT column1/column2... FROM table_name;\n
\u9664\u6cd5\u8fd0\u7b97\u4e0d\u53ef\u4ee5\u9664\u4ee5 O\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/division/#_4","title":"\u793a\u4f8b","text":"mysql> select 1123.2333/1233.3331;\n+-----------------------+\n| 1123.2333 / 1233.3331 |\n+-----------------------+\n| 0.9107298750 |\n+-----------------------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1/2 from t2;\n+--------+\n| c1 / 2 |\n+--------+\n| -1.5 |\n| 0.5 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1/c2 from t2;\n+---------+\n| c1 / c2 |\n+---------+\n| -1.5 |\n| 0.5 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"-
\u8fd0\u7b97\u7b26\u7528\u4e8e\u51cf\u6cd5\u8fd0\u7b97\u3002
> SELECT value1-value2;\n
> SELECT column1-column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/minus/#_3","title":"\u793a\u4f8b","text":"mysql> select 1123.2333-1233.3331;\n+-----------------------+\n| 1123.2333 - 1233.3331 |\n+-----------------------+\n| -110.09979999999996 |\n+-----------------------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1-5 from t2;\n+--------+\n| c1 - 5 |\n+--------+\n| -8 |\n| -4 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1-c2 from t2;\n+---------+\n| c1 - c2 |\n+---------+\n| -5 |\n| -1 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/","title":"%,MOD","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"%,MOD
\u8fd0\u7b97\u7b26\u7528\u4e8e\u53d6\u4f59\u8fd0\u7b97\u3002\u8fd4\u56de\u7ed3\u679c\u4e3a N \u9664\u4ee5 M \u7684\u4f59\u6570\u3002
> SELECT N % M, N MOD M;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/mod/#_3","title":"\u793a\u4f8b","text":"mysql> select 12 mod 5;\n+--------+\n| 12 % 5 |\n+--------+\n| 2 |\n+--------+\n1 row in set (0.00 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1 mod 2 from t2;\n+--------+\n| c1 % 2 |\n+--------+\n| -1 |\n| 1 |\n+--------+\n2 rows in set (0.01 sec)\n\nmysql> select c1 mod c2 from t2;\n+---------+\n| c1 % c2 |\n+---------+\n| -1 |\n| 1 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/","title":"*","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"*
\u8fd0\u7b97\u7b26\u7528\u4e8e\u4e58\u6cd5\u8fd0\u7b97\u3002
> SELECT value1*value2;\n
> SELECT column1*column2... FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/multiplication/#_4","title":"\u793a\u4f8b","text":"mysql> select 1123.2333*1233.3331;\n+-----------------------+\n| 1123.2333 * 1233.3331 |\n+-----------------------+\n| 1385320.80791223 |\n+-----------------------+\n1 row in set (0.01 sec)\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select c1*2 from t2;\n+--------+\n| c1 * 2 |\n+--------+\n| -6 |\n| 2 |\n+--------+\n2 rows in set (0.00 sec)\n\nmysql> select c1*c2 from t2;\n+---------+\n| c1 * c2 |\n+---------+\n| -6 |\n| 2 |\n+---------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/","title":"-","text":""},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"-
\u4e3a\u8d1f\u53f7\u8fd0\u7b97\u7b26\u3002\u8d1f\u53f7\u8fd0\u7b97\u7b26\u5c06\u8868\u8fbe\u5f0f\u7684\u7b26\u53f7\u4ece\u6b63\u6570\u53cd\u8f6c\u4e3a\u8d1f\u6570\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002
> SELECT -column1, -column2, ...\nFROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/arithmetic-operators/unary-minus/#_3","title":"\u793a\u4f8b","text":"mysql> select -2;\n+------+\n| -2 |\n+------+\n| -2 |\n+------+\n
create table t2(c1 int, c2 int);\ninsert into t2 values (-3, 2);\ninsert into t2 values (1, 2);\n\nmysql> select -c1 from t2;\n+------+\n| -c1 |\n+------+\n| 3 |\n| -1 |\n+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/","title":"\u8d4b\u503c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/assignment-operators-overview/#_1","title":"\u8d4b\u503c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 = \u7b49\u4e8e\u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u8d4b\u503c"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"=
\u8fd0\u7b97\u7b26\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\u7528\u4e8e\u8d4b\u503c\uff1a
\u5728 SET
\u8bed\u53e5\u4e2d\uff0c=
\u88ab\u89c6\u4e3a\u8d4b\u503c\u8fd0\u7b97\u7b26\uff0c\u5373\u8fd0\u7b97\u7b26 =
\u5de6\u4fa7\u7684\u7528\u6237\u53d8\u91cf\u53d6\u5176\u53f3\u4fa7\u7684\u503c\u3002=
\u53f3\u8fb9\u7684\u503c\u53ef\u4ee5\u662f\u6587\u672c\u503c\u3001\u53e6\u4e00\u4e2a\u5b58\u50a8\u503c\u7684\u53d8\u91cf\uff0c\u6216\u8005\u4efb\u4f55\u4ea7\u751f\u6807\u91cf\u503c\u7684\u5408\u6cd5\u8868\u8fbe\u5f0f\uff0c\u4e5f\u53ef\u5305\u62ec\u67e5\u8be2\u7684\u7ed3\u679c (\u524d\u63d0\u662f\u8fd9\u4e2a\u503c\u662f\u6807\u91cf\u503c)\u3002\u53ef\u4ee5\u5728\u540c\u4e00\u4e2a SET
\u8bed\u53e5\u4e2d\u6267\u884c\u591a\u4e2a\u8d4b\u503c\u3002
\u5728 UPDATE
\u8bed\u53e5\u7684 SET
\u5b50\u53e5\u4e2d\uff0c=
\u4e5f\u5145\u5f53\u8d4b\u503c\u8fd0\u7b97\u7b26\u3002\u4f60\u53ef\u4ee5\u5728\u4e00\u4e2a UPDATE
\u8bed\u53e5\u7684\u540c\u4e00\u4e2a SET
\u5b50\u53e5\u4e2d\u8fdb\u884c\u591a\u4e2a\u8d4b\u503c\u3002
\u5728\u5176\u4ed6\u60c5\u51b5\u4e0b\u4e2d\uff0c=
\u4f5c\u4e3a\u6bd4\u8f83\u8fd0\u7b97\u7b26\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN = value1;\n
"},{"location":"MatrixOne/Reference/Operators/operators/assignment-operators/equal/#_4","title":"\u793a\u4f8b","text":"create table t1 (a bigint(3), b bigint(5) primary key);\ninsert into t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 1 |\n| 1 | 2 |\n+------+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bit-functions-and-operators-overview/","title":"\u4e8c\u8fdb\u5236\u8fd0\u7b97\u7b26","text":"\u540d\u79f0 \u63cf\u8ff0 & \u4f4d\u8fd0\u7b97\u7b26\u4e0e\uff0c\u6309\u4f4d\u4e0e >> \u4f4d\u79fb\u8fd0\u7b97\u7b26\u53f3\u79fb << \u4f4d\u79fb\u8fd0\u7b97\u7b26\u5de6\u79fb ^ \u6309\u4f4d\u5f02\u6216 | \u4f4d\u8fd0\u7b97\u7b26\u6216\uff0c\u6309\u4f4d\u6216 ~ \u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u4e8c\u8fdb\u5236\u53d6\u53cd \u4f4d\u51fd\u6570\u548c\u8fd0\u7b97\u7b26\u901a\u5e38\u4e0e\u6574\u6570\u6570\u636e\u7c7b\u578b\u4e00\u8d77\u4f7f\u7528\uff0c\u4e0d\u80fd\u76f4\u63a5\u5e94\u7528\u4e8e\u5176\u4ed6\u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982\uff0cfloat\uff0cdouble \u7b49\u3002\u5373\uff0c\u9700\u8981\u4e0e BIGINT(64 \u4f4d\u6574\u6570) \u53c2\u6570\u4e00\u8d77\u4f7f\u7528\u5e76\u8fd4\u56de BIGINT \u503c\uff0c\u56e0\u6b64\u5b83\u4eec\u7684\u6700\u5927\u8303\u56f4\u4e3a 64 \u4f4d\u3002\u975e BIGINT \u53c2\u6570\u5728\u6267\u884c\u64cd\u4f5c\u4e4b\u524d\u88ab\u8f6c\u6362\u4e3a BIGINT\uff0c\u53ef\u80fd\u6574\u6570\u4f4d\u6570\u4f1a\u88ab\u622a\u65ad\uff0c\u4f8b\u5982\uff0c10.6496 \u548c -10.6496 \u5728\u8f6c\u6362\u5230 INT \u7c7b\u578b\u671f\u95f4\u53ef\u80fd\u4f1a\u88ab\u622a\u65ad\u6216\u8005\u88ab\u820d\u5165\u3002
\u4f4d\u51fd\u6570\u548c\u64cd\u4f5c\u7b26\u5141\u8bb8\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\u5b9e\u53c2 (BINARY\u3001VARBINARY \u548c BLOB \u7c7b\u578b) \u5e76\u8fd4\u56de\u5176\u540c\u7c7b\u578b\u7684\u503c\uff0c\u8fd9\u4f7f\u5b83\u4eec\u80fd\u591f\u63a5\u53d7\u5b9e\u53c2\u5e76\u4ea7\u751f\u5927\u4e8e 64 \u4f4d\u7684\u8fd4\u56de\u503c\u3002\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u53c2\u6570\u5219\u88ab\u8f6c\u6362\u4e3a BIGINT \u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/","title":"&","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"Bitwise AND
\u8fd0\u7b97\u7b26\uff0c\u5bf9\u6bcf\u5bf9\u6bd4\u7279\u4f4d\u6267\u884c\u4e0e\uff08AND\uff09\u64cd\u4f5c\u3002\u53ea\u6709 a \u548c b \u90fd\u662f 1 \u65f6\uff0ca AND b \u624d\u662f 1\u3002Bitwise AND
\u8fd4\u56de\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT value1 & value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-and/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 29 & 15;\n+---------+\n| 29 & 15 |\n+---------+\n| 13 |\n+---------+\n1 row in set (0.06 sec)\n\nCREATE TABLE bitwise (a_int_value INT NOT NULL,b_int_value INT NOT NULL);\nINSERT bitwise VALUES (170, 75); mysql> SELECT a_int_value & b_int_value FROM bitwise; +---------------------------+\n| a_int_value & b_int_value |\n+---------------------------+\n| 10 |\n+---------------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/","title":"~","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u4e8c\u8fdb\u5236\u53d6\u53cd\u3002\u5bf9\u6bcf\u4e00\u4e2a\u6bd4\u7279\u4f4d\u6267\u884c\u975e\uff08NOT\uff09\u64cd\u4f5c\u3002NOT a \u7ed3\u679c\u4e3a a \u7684\u53cd\u8f6c\uff08\u5373\u53cd\u7801\uff09\uff0c\u53c2\u6570\u53ea\u80fd\u662f\u6570\u5b57\u6216 NULL\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT ~value1;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-inversion/#_4","title":"\u793a\u4f8b","text":"mysql> select ~-5;\n+--------+\n| ~ (-5) |\n+--------+\n| 4 |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select ~null;\n+-------+\n| ~null |\n+-------+\n| NULL |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> select ~a, ~b from t1;\n+------+----------------------+\n| ~a | ~b |\n+------+----------------------+\n| 0 | 18446744073709551614 |\n| 4 | 18446744073709551610 |\n+------+----------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/","title":"|","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u4f4d\u8fd0\u7b97\u7b26\u6216\uff0c\u6309\u4f4d\u6216\u3002\u5bf9\u6bcf\u4e00\u5bf9\u6bd4\u7279\u4f4d\u6267\u884c\u6216\uff08OR\uff09\u64cd\u4f5c\u3002\u5982\u679c a \u6216 b \u4e3a 1\uff0c\u5219 a OR b \u7ed3\u679c\u4e3a 1\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT value1 | value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-or/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 29 | 15;\n+---------+\n| 29 | 15 |\n+---------+\n| 31 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n| NULL |\n+----------+\n1 row in set (0.01 sec)\n\nmysql> select null | 2;\n+----------+\n| null | 2 |\n+----------+\n| NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a | 2, b | 2 from t1;\n+-------+-------+\n| a | 2 | b | 2 |\n+-------+-------+\n| -1 | 3 |\n| -5 | 7 |\n+-------+-------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/","title":"^","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u6309\u4f4d\u5f02\u6216\u3002\u5bf9\u6bcf\u4e00\u5bf9\u6bd4\u7279\u4f4d\u6267\u884c\u5f02\u6216\uff08XOR\uff09\u64cd\u4f5c\u3002\u5f53 a \u548c b \u4e0d\u76f8\u540c\u65f6\uff0ca XOR b \u7684\u7ed3\u679c\u4e3a 1\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5982\u679c\u53c2\u6570\u7684\u957f\u5ea6\u4e0d\u76f8\u7b49\uff0c\u5219\u4f1a\u53d1\u751f ER_INVALID_BITWISE_OPERANDS_SIZE
\u9519\u8bef\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
> SELECT value1 ^ value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/bitwise-xor/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 1 ^ 1;\n+-------+\n| 1 ^ 1 |\n+-------+\n| 0 |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> SELECT 1 ^ 0;\n+-------+\n| 1 ^ 0 |\n+-------+\n| 1 |\n+-------+\n1 row in set (0.01 sec)\n\nmysql> SELECT 11 ^ 3;\n+--------+\n| 11 ^ 3 |\n+--------+\n| 8 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select null ^ 2;\n+----------+\n| null ^ 2 |\n+----------+\n| NULL |\n+----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a ^ 2, b ^ 2 from t1;\n+-------+-------+\n| a ^ 2 | b ^ 2 |\n+-------+-------+\n| -3 | 3 |\n| -7 | 7 |\n+-------+-------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/","title":"<<","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u8be5\u64cd\u4f5c\u7b26\u4f1a\u5c06\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u5411\u5de6\u79fb\u52a8\u6307\u5b9a\u7684\u4f4d\u6570\u3002\u5411\u5de6\u88ab\u79fb\u51fa\u7684\u4f4d\u88ab\u4e22\u5f03\uff0c\u53f3\u4fa7\u7528 0 \u8865\u5145\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
\u65e0\u8bba\u53c2\u6570\u7c7b\u578b\u5982\u4f55\uff0c\u79fb\u51fa\u503c\u672b\u5c3e\u7684\u4f4d\u90fd\u4f1a\u5728\u6ca1\u6709\u8b66\u544a\u7684\u60c5\u51b5\u4e0b\u4e22\u5931\u3002\u7279\u522b\u662f\uff0c\u5982\u679c\u79fb\u4f4d\u8ba1\u6570\u5927\u4e8e\u6216\u7b49\u4e8e\u4f4d\u53c2\u6570\u4e2d\u7684\u4f4d\u6570\uff0c\u5219\u7ed3\u679c\u4e2d\u7684\u6240\u6709\u4f4d\u5747\u4e3a 0\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SELECT value1 << value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/left-shift/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 1 << 2;\n+--------+\n| 1 << 2 |\n+--------+\n| 4 |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select -1 << 2;\n+---------+\n| -1 << 2 |\n+---------+\n| -4 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null << 2;\n+-----------+\n| null << 2 |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.01 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a << 2, b << 2 from t1;\n+--------+--------+\n| a << 2 | b << 2 |\n+--------+--------+\n| -4 | 4 |\n| -20 | 20 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/","title":">>","text":""},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"\u8be5\u64cd\u4f5c\u7b26\u4f1a\u5c06\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u6570\u5411\u53f3\u79fb\u52a8\u6307\u5b9a\u7684\u4f4d\u6570\u3002\u5411\u53f3\u88ab\u79fb\u51fa\u7684\u4f4d\u88ab\u4e22\u5f03\uff0c\u5de6\u4fa7\u7528 0 \u8865\u5145\u3002
\u7ed3\u679c\u7c7b\u578b\u53d6\u51b3\u4e8e\u53c2\u6570\u662f\u5426\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6216\u6570\u5b57\uff1a
\u5f53\u53c2\u6570\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5e76\u4e14\u5176\u4e2d\u81f3\u5c11\u4e00\u4e2a\u4e0d\u662f\u5341\u516d\u8fdb\u5236 literal
\u3001\u4f4d literal
\u6216 NULL literal
\u65f6\uff0c\u5219\u8fdb\u884c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u8ba1\u7b97\uff1b\u5426\u5219\u4f1a\u8fdb\u884c\u6570\u503c\u6c42\u503c\u8ba1\u7b97\uff0c\u5e76\u6839\u636e\u9700\u8981\u5c06\u53c2\u6570\u8f6c\u6362\u4e3a\u65e0\u7b26\u53f7 64 \u4f4d\u6574\u6570\u3002
\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u6c42\u503c\u4ea7\u751f\u4e00\u4e2a\u4e0e\u53c2\u6570\u957f\u5ea6\u76f8\u540c\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u6570\u503c\u8ba1\u7b97\u4ea7\u751f\u4e00\u4e2a\u65e0\u7b26\u53f7\u7684 64 \u4f4d\u6574\u6570\u3002
\u65e0\u8bba\u53c2\u6570\u7c7b\u578b\u5982\u4f55\uff0c\u79fb\u51fa\u503c\u672b\u5c3e\u7684\u4f4d\u90fd\u4f1a\u5728\u6ca1\u6709\u8b66\u544a\u7684\u60c5\u51b5\u4e0b\u4e22\u5931\u3002\u7279\u522b\u662f\uff0c\u5982\u679c\u79fb\u4f4d\u8ba1\u6570\u5927\u4e8e\u6216\u7b49\u4e8e\u4f4d\u53c2\u6570\u4e2d\u7684\u4f4d\u6570\uff0c\u5219\u7ed3\u679c\u4e2d\u7684\u6240\u6709\u4f4d\u5747\u4e3a 0\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SELECT value1 >> value2;\n
"},{"location":"MatrixOne/Reference/Operators/operators/bit-functions-and-operators/right-shift/#_4","title":"\u793a\u4f8b","text":"mysql> select 1024 >> 2;\n+-----------+\n| 1024 >> 2 |\n+-----------+\n| 256 |\n+-----------+\n1 row in set (0.01 sec)\n\nmysql> select -5 >> 2;\n+---------+\n| -5 >> 2 |\n+---------+\n| -2 |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select null >> 2;\n+-----------+\n| null >> 2 |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.00 sec)\n\ncreate table t1(a int, b int unsigned);\ninsert into t1 values (-1, 1), (-5, 5);\n\nmysql> select a >> 2, b >> 2 from t1;\n+--------+--------+\n| a >> 2 | b >> 2 |\n+--------+--------+\n| -1 | 0 |\n| -2 | 1 |\n+--------+--------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/","title":"BINARY","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"BINARY()
\u51fd\u6570\u662f\u4e00\u4e2a\u7528\u4e8e\u5c06\u503c\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u51fd\u6570\u3002\u5b83\u901a\u5e38\u7528\u4e8e\u6bd4\u8f83\u6587\u672c\u6216\u5b57\u7b26\u6570\u636e\u65f6\uff0c\u5c06\u5b57\u7b26\u4e32\u89c6\u4e3a\u4e8c\u8fdb\u5236\u6570\u636e\u800c\u4e0d\u662f\u666e\u901a\u7684\u5b57\u7b26\u6570\u636e\u3002\u8fd9\u6837\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u5b57\u7b26\u6570\u636e\u7684\u4e8c\u8fdb\u5236\u6bd4\u8f83\uff0c\u800c\u4e0d\u53d7\u5b57\u7b26\u96c6\u6216\u7f16\u7801\u7684\u5f71\u54cd\u3002
BINARY()
\u51fd\u6570\u5b9e\u73b0\u5bf9\u5b57\u7b26\u6570\u636e\u7684\u4e8c\u8fdb\u5236\u6bd4\u8f83\uff0c\u7528\u4e8e\u5904\u7406\u5927\u5c0f\u5199\u654f\u611f\u7684\u5b57\u7b26\u4e32\u6bd4\u8f83\u7b49\u573a\u666f\u3002
> BINARY value\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#_3","title":"\u76f8\u5173\u53c2\u6570","text":"\u53c2\u6570 \u8bf4\u660e value \u5fc5\u8981\u53c2\u6570\u3002\u5f85\u8f6c\u5316\u7684\u503c\u3002"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/binary/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, password VARCHAR(100) NOT NULL);\n\nINSERT INTO users (username, password) VALUES ('JohnDoe', 'Abcd123'), ('AliceSmith', 'Efgh456'), ('BobJohnson', 'ijkl789');\n\n-- \u4f7f\u7528 BINARY() \u64cd\u4f5c\u7b26\u8fdb\u884c\u5bc6\u7801\u9a8c\u8bc1\uff0cBINARY password = 'Abcd123'\u90e8\u5206\u5c06\u5bc6\u7801\u503c\u89c6\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u8fd9\u6837\u8fdb\u884c\u7684\u6bd4\u8f83\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002\u5982\u679c\u8f93\u5165\u7684\u5bc6\u7801\u4e0e\u6570\u636e\u5e93\u4e2d\u7684\u8bb0\u5f55\u5339\u914d\uff0c\u67e5\u8be2\u5c06\u8fd4\u56de\u76f8\u5e94\u7684\u7528\u6237 id \u548c username\uff0c\u5426\u5219\u5c06\u8fd4\u56de\u7a7a\u7ed3\u679c\u3002\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'Abcd123';\n+------+----------+\n| id | username |\n+------+----------+\n| 1 | JohnDoe |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> SELECT id, username FROM users WHERE username = 'JohnDoe' AND BINARY password = 'abcd123';\nEmpty set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast-functions-and-operators-overview/","title":"\u5f3a\u5236\u8f6c\u6362\u51fd\u6570\u548c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 BINARY() \u5c06\u503c\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u51fd\u6570 CAST() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u5c0f\u6570\u8f6c\u6570\u503c\u548c\u5b57\u7b26\u578b CONVERT() \u5c06\u503c\u8f6c\u6362\u4e3a\u7279\u5b9a\u7c7b\u578b\uff0c\u7528\u4e8e\u65e5\u671f\u548c\u65f6\u95f4\u503c\u3001\u5c0f\u6570\u4e4b\u95f4\u8fdb\u884c\u8f6c\u6362 SERIAL() \u5c06\u8fde\u63a5\u4e32\u5e8f\u5217\u5316\uff0c\u4e0d\u5904\u7406 NULL \u503c SERIAL_FULL() \u5c06\u8fde\u63a5\u4e32\u5e8f\u5217\u5316\uff0c\u5904\u7406 NULL \u503c"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/","title":"CAST","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"CAST()
\u51fd\u6570\u53ef\u4ee5\u5c06\u4efb\u4f55\u7c7b\u578b\u7684\u4e00\u4e2a\u503c\u8f6c\u5316\u4e3a\u53e6\u4e00\u4e2a\u7279\u5b9a\u7c7b\u578b\u3002
> CAST(value AS datatype)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_3","title":"\u76f8\u5173\u53c2\u6570","text":"\u53c2\u6570 \u8bf4\u660e value \u5fc5\u8981\u53c2\u6570\uff0c\u5f85\u8f6c\u5316\u7684\u503c datatype \u5fc5\u8981\u53c2\u6570\uff0c\u76ee\u6807\u6570\u636e\u7c7b\u578b \u76ee\u524d\uff0ccast
\u53ef\u4ee5\u8fdb\u884c\u5982\u4e0b\u8f6c\u6362\uff1a
\u8be6\u7ec6\u7684\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u89c4\u5219\uff0c\u8bf7\u53c2\u89c1\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u3002
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\nCREATE TABLE t1 (a int,b float,c char(1),d varchar(15));\nINSERT INTO t1 VALUES (1,1.5,'1','-2');\n\nmysql> SELECT CAST(a AS FLOAT) a_cast,CAST(b AS UNSIGNED) b_cast,CAST(c AS SIGNED) c_cast, CAST(d AS SIGNED) d_cast from t1;\n+--------+--------+--------+--------+\n| a_cast | b_cast | c_cast | d_cast |\n+--------+--------+--------+--------+\n| 1.0000 | 1 | 1 | -2 |\n+--------+--------+--------+--------+\n\nmysql> SELECT CAST(a AS CHAR) a_cast, CAST(b AS CHAR) b_cast,CAST(c AS DOUBLE) c_cast, CAST(d AS FLOAT) d_cast from t1;\n+--------+--------+--------+---------+\n| a_cast | b_cast | c_cast | d_cast |\n+--------+--------+--------+---------+\n| 1 | 1.5 | 1.0000 | -2.0000 |\n+--------+--------+--------+---------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/cast/#_5","title":"\u9650\u5236","text":"CONVERT()
\u51fd\u6570\u5c06\u4e00\u4e2a\u503c\u8f6c\u6362\u4e3a\u6307\u5b9a\u7684\u6570\u636e\u7c7b\u578b\u6216\u5b57\u7b26\u96c6\u3002
> CONVERT(value, type)\n
\u6216\uff1a
> CONVERT(value USING charset)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#_3","title":"\u76f8\u5173\u53c2\u6570","text":"\u53c2\u6570 \u8bf4\u660e value \u5fc5\u8981\u53c2\u6570\uff0c\u5f85\u8f6c\u5316\u7684\u503c datatype \u5fc5\u8981\u53c2\u6570\uff0c\u76ee\u6807\u6570\u636e\u7c7b\u578b charset \u5fc5\u8981\u53c2\u6570\uff0c\u76ee\u6807\u5b57\u7b26\u96c6 \u76ee\u524d\uff0cconvert
\u53ef\u4ee5\u8fdb\u884c\u5982\u4e0b\u8f6c\u6362\uff1a
mysql> select convert(150,char);\n+-------------------+\n| cast(150 as char) |\n+-------------------+\n| 150 |\n+-------------------+\n1 row in set (0.01 sec)\n
CREATE TABLE t1(a tinyint);\nINSERT INTO t1 VALUES (127);\n\nmysql> SELECT 1 FROM\n-> (SELECT CONVERT(t2.a USING UTF8) FROM t1, t1 t2 LIMIT 1) AS s LIMIT 1;\n+------+\n| 1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/convert/#_5","title":"\u9650\u5236","text":"SERIAL()
\u51fd\u6570\u7528\u4e8e\u5e8f\u5217\u5316\u8fde\u63a5\u4e32\uff0c\u5c06\u5355\u4e2a\u6216\u591a\u4e2a\u5217/\u503c\u7ec4\u5408\u6210\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u8fd4\u56de\u7c7b\u578b\u4e3a VARCHAR
\u3002\u5b83\u7c7b\u4f3c\u4e8e CONCAT()
\uff0c\u4f46\u5728 CONCAT()
\u4e2d\u4e0d\u80fd\u6355\u83b7\u503c\u7684\u7c7b\u578b\u4fe1\u606f\u3002\u4e00\u822c\u642d\u914d SERIAL_EXTRACT()
\u51fd\u6570\u4f7f\u7528\u3002
SERIAL()
\u4e2d\u5982\u679c\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3a NULL\uff0c\u5219\u8fd4\u56de NULL\u3002\u5982\u9700\u5904\u7406 NULL \u503c\uff0c\u53ef\u4f7f\u7528 SERIAL_FULL()
\u3002
> SERIAL(para)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e para \u8981\u5e8f\u5217\u5316\u7684\u5217/\u503c"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial/#_4","title":"\u793a\u4f8b","text":"create table t1(a varchar(3), b int);\ninsert into t1 values(\"ABC\",1);\ninsert into t1 values(\"DEF\",NULL);\n\nmysql> select serial(a,b) from t1;--\u67e5\u8be2\u8fd4\u56de\u4e3a a \u5217\u548c b \u5217\u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\uff0c\u5f53\u6709 NULL \u503c\u65f6\u8f93\u51fa\u4e3a NULL\n+--------------+\n| serial(a, b) |\n+--------------+\n| FABC : |\n| NULL |\n+--------------+\n2 rows in set (0.00 sec)\n\nmysql> select serial(a,'hello') from t1;--\u67e5\u8be2\u8fd4\u56de\u4e3a a \u5217\u548c\u503c hello \u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\n+------------------+\n| serial(a, hello) |\n+------------------+\n| FABC Fhello |\n| FDEF Fhello |\n+------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/","title":"SERIAL_FULL()","text":""},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SERIAL_FULL()
\u7528\u4e8e\u7528\u4e8e\u5e8f\u5217\u5316\u8fde\u63a5\u4e32\uff0c\u5c06\u5355\u4e2a\u6216\u8005\u591a\u4e2a\u5217/\u503c\u7ec4\u5408\u8f6c\u6362\u6210\u4e8c\u8fdb\u5236\u683c\u5f0f\uff0c\u8fd4\u56de\u7c7b\u578b\u4e3a VARCHAR
\uff0c\u4e00\u822c\u642d\u914d SERIAL_EXTRACT()
\u51fd\u6570\u4f7f\u7528\u3002SERIAL_FULL()
\u7c7b\u4f3c\u4e8e SERIAL()
\uff0c\u4f46 SERIAL_FULL()
\u4f1a\u4fdd\u7559 NULL \u503c\u3002
> SERIAL_FULL(para)\n
"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e para \u8981\u5e8f\u5217\u5316\u7684\u5217/\u503c"},{"location":"MatrixOne/Reference/Operators/operators/cast-functions-and-operators/serial_full/#_4","title":"\u793a\u4f8b","text":"create table t1(a varchar(3), b int);\ninsert into t1 values(\"ABC\",1);\ninsert into t1 values(\"DEF\",NULL);\n\nmysql> select serial_full(a,b) from t1;--\u67e5\u8be2\u8fd4\u56de\u4e3a a \u5217\u548c b \u5217\u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\uff0c\u5f53\u6709 NULL \u503c\u65f6\u4fdd\u7559 NULL \u503c\n+-------------------+\n| serial_full(a, b) |\n+-------------------+\n| FABC : |\n| FDEF |\n+-------------------+\n2 rows in set (0.00 sec)\n\nmysql> select serial_full(1.2,'world') ;--\u67e5\u8be2\u8fd4\u56de\u4e3a\u503c 1.2 \u548c\u503c hello \u7ec4\u5408\u5e8f\u5217\u5316\u7684\u7ed3\u679c\n+-------------------------+\n| serial_full(1.2, world) |\n+-------------------------+\n| D? Fworld |\n+-------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/","title":"=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"=
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 =
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u7b49\u4e8e =
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c=
\u8fd0\u7b97\u7b26\u7684\u7ed3\u679c\u8fd4\u56de true
\u3002
> SELECT x = y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/assign-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 = 2;\n+-------+\n| 2 = 2 |\n+-------+\n| true |\n+-------+\n1 row in set (0.01 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID=score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n| 3 | 3 | 3 |\n+--------+------+-------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/","title":"BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"BETWEEN ... AND ...
\u64cd\u4f5c\u7b26\u9009\u53d6\u4ecb\u4e8e\u4e24\u4e2a\u503c\u4e4b\u95f4\u7684\u6570\u636e\u8303\u56f4\u5185\u7684\u503c\u3002\u8fd9\u4e9b\u503c\u53ef\u4ee5\u662f\u6570\u503c\u3001\u6587\u672c\u6216\u8005\u65e5\u671f\u3002\u5982\u679c\u53d6\u503c\u4ecb\u4e8e\u4e24\u503c\u4e4b\u95f4\uff0c\u90a3\u4e48\u8fd4\u56de true
\uff0c\u5426\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
> expr BETWEEN min AND max\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/between/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 2 BETWEEN 1 AND 3, 2 BETWEEN 3 and 1;\n+-------------------+-------------------+\n| 2 between 1 and 3 | 2 between 3 and 1 |\n+-------------------+-------------------+\n| true | false |\n+-------------------+-------------------+\n1 row in set (0.01 sec)\n
create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from t where id between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n| 3 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/","title":"COALESCE()","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"COALESCE (expression_1, expression_2, ...,expression_n)
\u4f9d\u6b21\u53c2\u8003\u5404\u53c2\u6570\u8868\u8fbe\u5f0f\uff0c\u9047\u5230\u975e null
\u503c\u5373\u505c\u6b62\u5e76\u8fd4\u56de\u8be5\u503c\u3002\u5982\u679c\u6240\u6709\u7684\u8868\u8fbe\u5f0f\u90fd\u662f\u7a7a\u503c\uff0c\u6700\u7ec8\u5c06\u8fd4\u56de\u4e00\u4e2a\u7a7a\u503c\u3002
\u4f7f\u7528 COALESCE
\u5728\u4e8e\u5927\u90e8\u5206\u5305\u542b\u7a7a\u503c\u7684\u8868\u8fbe\u5f0f\u6700\u7ec8\u5c06\u8fd4\u56de\u7a7a\u503c\u3002
> COALESCE(value1, value2, ...., value_n)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"Arguments Description value1, value2, value_n Required. The values to test"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/coalesce/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT COALESCE(1)+COALESCE(1);\n+---------------------------+\n| coalesce(1) + coalesce(1) |\n+---------------------------+\n| 2 |\n+---------------------------+\n
drop table if exists t2;\ncreate table t2(a float, b datetime);\ninsert into t2 values (12.345, '2022-02-20 10:10:10.999999');\ninsert into t2 values (3.45646, NULL);\ninsert into t2 values(NULL, '2023-04-03 22:10:29.999999');\ninsert into t2 values (NULL, NULL);\n\nmysql> select * from t2;\n+---------+---------------------+\n| a | b |\n+---------+---------------------+\n| 12.345 | 2022-02-20 10:10:11 |\n| 3.45646 | NULL |\n| NULL | 2023-04-03 22:10:30 |\n| NULL | NULL |\n+---------+---------------------+\nmysql> select coalesce(a, 1.0) from t2;\n+--------------------+\n| coalesce(a, 1.0) |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n| 1 |\n| 1 |\n+--------------------+\nmysql> select coalesce(a, 1) from t2;\n+--------------------+\n| coalesce(a, 1) |\n+--------------------+\n| 12.345000267028809 |\n| 3.4564599990844727 |\n| 1 |\n| 1 |\n+--------------------+\nmysql> select coalesce(b, 2022-01-01) from t2;\n+---------------------------+\n| coalesce(b, 2022 - 1 - 1) |\n+---------------------------+\n| 2022-02-20 10:10:11 |\n| 2020 |\n| 2023-04-03 22:10:30 |\n| 2020 |\n+---------------------------+\n
ORDER BY
\u5b50\u53e5CREATE TABLE t1 ( a INTEGER, b varchar(255) );\nINSERT INTO t1 VALUES (1,'z');\nINSERT INTO t1 VALUES (2,'y');\nINSERT INTO t1 VALUES (3,'x');\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a');\n+-------+\n| min_b |\n+-------+\n| x |\n| y |\n| z |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(min_b, 'a');\n+-------+\n| min_b |\n+-------+\n| x |\n| y |\n| z |\n+-------+\n\nmysql> SELECT MIN(b) AS min_b FROM t1 GROUP BY a ORDER BY COALESCE(MIN(b), 'a') DESC;\n+-------+\n| min_b |\n+-------+\n| z |\n| y |\n| x |\n+-------+\n
Case When
\u5b50\u53e5mysql> select if(1, cast(1111111111111111111 as unsigned), 1) i,case when 1 then cast(1111111111111111111 as unsigned) else 1 end c, coalesce(cast(1111111111111111111 as unsigned), 1) co;\n+---------------------+---------------------+---------------------+\n| i | c | co |\n+---------------------+---------------------+---------------------+\n| 1111111111111111111 | 1111111111111111111 | 1111111111111111111 |\n+---------------------+---------------------+---------------------+\n
IN Subquery
CREATE TABLE ot (col_int_nokey int(11), col_varchar_nokey varchar(1));\nINSERT INTO ot VALUES (1,'x');\nCREATE TABLE it (col_int_key int(11), col_varchar_key varchar(1));\nINSERT INTO it VALUES (NULL,'x'), (NULL,'f');\n\nmysql> SELECT col_int_nokey FROM ot WHERE col_varchar_nokey IN(SELECT col_varchar_key FROM it WHERE coalesce(col_int_nokey, 1) );\n+---------------+\n| col_int_nokey |\n+---------------+\n| 1 |\n+---------------+\n
WHERE
\u5b50\u53e5CREATE TABLE ot1(a INT);\nCREATE TABLE ot2(a INT);\nCREATE TABLE ot3(a INT);\nCREATE TABLE it1(a INT);\nCREATE TABLE it2(a INT);\nCREATE TABLE it3(a INT);\nINSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO ot2 VALUES(0),(2),(4),(6);\nINSERT INTO ot3 VALUES(0),(3),(6);\nINSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7);\nINSERT INTO it2 VALUES(0),(2),(4),(6);\nINSERT INTO it3 VALUES(0),(3),(6);\n\nmysql> SELECT * FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a WHERE COALESCE(ot2.a,0) IN (SELECT a FROM it3);\n+------+------+\n| a | a |\n+------+------+\n| 0 | 0 |\n| 1 | NULL |\n| 3 | NULL |\n| 5 | NULL |\n| 6 | 6 |\n| 7 | NULL |\n+------+------+\n
HAVING
drop table if exists t1;\ncreate table t1(a datetime);\nINSERT INTO t1 VALUES (NULL), ('2001-01-01 00:00:00.12'), ('2002-01-01 00:00:00.567');\n\nmysql> select a from t1 group by a having COALESCE(a)<\"2002-01-01\";\n+---------------------+\n| a |\n+---------------------+\n| 2001-01-01 00:00:00 |\n+---------------------+\n
ON CONDITION
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1(a INT, b varchar(255));\ncreate table t2(a INT, b varchar(255));\ninsert into t1 values(1, \"\u4f60\u597d\"), (3, \"\u518d\u89c1\");\ninsert into t2 values(2, \"\u65e5\u671f\u65f6\u95f4\"), (4, \"\u660e\u5929\");\n> SELECT t1.a, t2.a FROM t1 JOIN t2 ON (length(COALESCE(t1.b)) = length(COALESCE(t2.b)));\n+------+------+\n| a | a |\n+------+------+\n| 1 | 4 |\n| 3 | 4 |\n+------+------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/comparison-functions-and-operators-overview/","title":"\u6bd4\u8f83\u51fd\u6570\u548c\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 > \u5927\u4e8e >= \u5927\u4e8e\u7b49\u4e8e < \u5c0f\u4e8e <>,!= \u4e0d\u7b49\u4e8e <= \u5c0f\u4e8e\u7b49\u4e8e = \u7b49\u4e8e BETWEEN ... AND ... \u5728\u4e24\u503c\u4e4b\u95f4 COALESCE \u8fd4\u56de\u7b2c\u4e00\u4e2a\u975e\u7a7a\u503c IN() \u5728\u96c6\u5408\u4e2d IS \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0c\u82e5\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u201ctrue\u201d IS NOT \u6d4b\u8bd5\u503c\u662f\u5426\u662f\u5e03\u5c14\u503c\uff0cIS \u7684\u5426\u5b9a\u7528\u6cd5 IS NOT NULL \u4e0d\u4e3a\u7a7a IS NULL \u4e3a\u7a7a ISNULL \u4ee3\u66ff =
\u6765\u6d4b\u8bd5\u503c\u662f\u5426\u4e3a NULL
\u3002 LIKE \u6a21\u7cca\u5339\u914d ILIKE \u6a21\u7cca\u5339\u914d\uff0c\u540c LIKE\u3002\u4f46\u5bf9\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002 NOT BETWEEN ... AND ... \u4e0d\u5728\u4e24\u503c\u4e4b\u95f4 NOT IN \u591a\u4e2a XOR
\u6761\u4ef6\u7684\u7b80\u5199 NOT LIKE N \u6a21\u7cca\u5339\u914d\uff0cLike \u7684\u5426\u5b9a\u7528\u6cd5 \u6bd4\u8f83\u8fd0\u7b97\u7684\u7ed3\u679c\u4e3a TRUE
\u3001FALSE
\u6216 NULL
\u3002\u8fd9\u4e9b\u8fd0\u7b97\u5bf9\u6570\u5b57\u548c\u5b57\u7b26\u4e32\u5747\u6709\u6548\u3002\u5b57\u7b26\u4e32\u53ef\u4ee5\u81ea\u52a8\u8f6c\u6362\u4e3a\u6570\u5b57\uff0c\u6570\u5b57\u6839\u636e\u9700\u8981\u81ea\u52a8\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u3002
\u4ee5\u4e0b\u6bd4\u8f83\u8fd0\u7b97\u7b26\u4e0d\u4ec5\u53ef\u4ee5\u7528\u4e8e\u6bd4\u8f83\u6807\u91cf\u8fd0\u7b97\u6570\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u6bd4\u8f83\u884c\u8fd0\u7b97\u6570\uff1a
= > < >= <= <> !=\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/","title":"INTERVAL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"The INTERVAL
operator returns 0 if N < N1, 1 if N < N2 and so on or -1 if N is NULL. All arguments are treated as integers. It is required that N1 < N2 < N3 < ... < Nn for this function to work correctly. This is because a binary search is used (very fast).
> INTERVAL(N,N1,N2,N3,...)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_interval/#_3","title":"\u793a\u4f8b","text":">\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/","title":"ISNULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u53ef\u4ee5\u4f7f\u7528 ISNULL()
\u51fd\u6570\u4ee3\u66ff =
\u6765\u6d4b\u8bd5\u503c\u662f\u5426\u4e3a NULL
\u3002\uff08\u4f7f\u7528 =
\u5c06\u503c\u4e0e NULL
\u8fdb\u884c\u6bd4\u8f83\u59cb\u7ec8\u4f1a\u4ea7\u751f NULL
\u3002\uff09
\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a NULL
\uff0c\u5219\u8be5\u51fd\u6570\u8fd4\u56de true
\u3002\u5426\u5219\uff0c\u5b83\u8fd4\u56de false
\u3002
ISNULL()
\u51fd\u6570\u4e0e IS NULL
\u6bd4\u8f83\u8fd0\u7b97\u7b26\u5171\u4eab\u4e00\u4e9b\u7279\u6b8a\u884c\u4e3a\u3002\u53c2\u89c1 IS NULL
\u7684\u63cf\u8ff0\u3002
> ISNULL(expr)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_isnull/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT ISNULL(1+1);\n+---------------+\n| isnull(1 + 1) |\n+---------------+\n| false |\n+---------------+\n1 row in set (0.01 sec)\n
CREATE TABLE students (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, birth_date DATE );\n\nINSERT INTO students (name, birth_date) VALUES ('John Doe', '2000-05-15'), ('Alice Smith', NULL), ('Bob Johnson', '1999-10-20');\n\n-- \u4f7f\u7528 ISNULL() \u51fd\u6570\u67e5\u627e\u6ca1\u6709\u586b\u5199\u51fa\u751f\u65e5\u671f\u7684\u5b66\u751f\uff1a\nmysql> SELECT * FROM students WHERE ISNULL(birth_date);\n+------+-------------+------------+\n| id | name | birth_date |\n+------+-------------+------------+\n| 2 | Alice Smith | NULL |\n+------+-------------+------------+\n1 row in set (0.00 sec)\n\n-- ISNULL() \u51fd\u6570\u4e5f\u53ef\u4ee5\u7528 IS NULL \u6765\u5b9e\u73b0\u76f8\u540c\u7684\u529f\u80fd\uff0c\u6240\u4ee5\u4ee5\u4e0b\u67e5\u8be2\u4e5f\u662f\u7b49\u6548\u7684\uff1a\nmysql> SELECT * FROM students WHERE birth_date IS NULL;\n+------+-------------+------------+\n| id | name | birth_date |\n+------+-------------+------------+\n| 2 | Alice Smith | NULL |\n+------+-------------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/","title":"STRCMP","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"The STRCMP()
returns 0 if the strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and NULL if either argument is NULL. It returns 1 otherwise.
> STRCMP(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/function_strcmp/#_3","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/","title":">=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":">=
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 >=
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5927\u4e8e\u6216\u7b49\u4e8e >=
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c>=
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x >= y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than-or-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 >= 2;\n+--------+\n| 2 >= 2 |\n+--------+\n| true |\n+--------+\n1 row in set (0.01 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where spID>=userID*score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n| 1 | 1 | 1 |\n+--------+------+-------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/","title":">","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":">
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 >
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5927\u4e8e >
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c>
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x > y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/greater-than/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 > 2;\n+-------+\n| 2 > 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where spID>(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n| 2 | 1 | 4 |\n| 3 | 3 | 3 |\n| 1 | 1 | 5 |\n+------+--------+-------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/","title":"ILIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ILIKE
\u64cd\u4f5c\u7b26\u4e0e LIKE
\u64cd\u4f5c\u7b26\u7528\u6cd5\u76f8\u4f3c\uff0c\u7528\u4e8e\u5728 WHERE \u5b50\u53e5\u4e2d\u641c\u7d22\u5217\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\u3002
ILIKE
\u64cd\u4f5c\u7b26\u4e0e LIKE
\u64cd\u4f5c\u7b26\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\u5927\u5c0f\u5199\u654f\u611f\u6027\u3002\u4f7f\u7528 ILIKE
\u65f6\uff0c\u4e0d\u8bba\u5b57\u7b26\u4e32\u4e2d\u7684\u5b57\u7b26\u662f\u5927\u5199\u8fd8\u662f\u5c0f\u5199\uff0c\u5b83\u4eec\u90fd\u4f1a\u88ab\u89c6\u4e3a\u76f8\u540c\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN ILIKE pattern;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/ilike/#_3","title":"\u793a\u4f8b","text":"drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a ilike '%abC%';\n\nmysql> select * from t1 where a ilike '%abC%';\n+------+\n| a |\n+------+\n| abc |\n| ABC |\n| abC |\n+------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/","title":"IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IN
\u8fd0\u7b97\u7b26\u53ef\u4ee5\u5728 WHERE
\u8bed\u53e5\u4e2d\u6307\u5b9a\u7279\u5b9a\u7684\u591a\u4e2a\u503c\uff0c\u672c\u8d28\u4e0a\u662f\u591a\u4e2a OR
\u6761\u4ef6\u7684\u7b80\u5199\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE column_name IN (value1, value2, ...);\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#_3","title":"\u793a\u4f8b","text":"create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a in (2,4);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 2 | b | 2.001 | 2022-02-09 | 2022-02-09 12:00:00 |\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n\nmysql> select * from t2 where a not in (2,4);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n+------+------+-------+------------+---------------------+\n\nmysql> select * from t2 where b not in ('e',\"f\");\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 2 | b | 2.001 | 2022-02-09 | 2022-02-09 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/in/#_4","title":"\u9650\u5236","text":"IN
\u5de6\u4fa7\u53ea\u652f\u6301\u5e38\u6570\u5217\u8868\u3002IN
\u5de6\u4fa7\u53ea\u652f\u6301\u5355\u5217\u6570\u636e\uff0c\u4e0d\u652f\u6301\u591a\u5217\u7ec4\u6210\u7684\u5143\u7ec4\u3002IN
\u76ee\u524d\u672a\u5bf9 NULL
\u503c\u8fdb\u884c\u5f88\u597d\u5730\u5904\u7406\uff0c\u53f3\u4fa7\u4e0d\u80fd\u4f7f\u7528 NULL
\u503c\u3002IS NOT NULL
\u8fd0\u7b97\u7b26\u7528\u4e8e\u5224\u65ad\u5217\u7684\u503c\u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u503c\u4e0d\u4e3a\u7a7a\uff0c\u5373\u4e0d\u4e3a NULL
\uff0c\u5219\u8fd4\u56de true
\uff0c\u5426\u5219\u8fd4\u56de false
\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e SELECT
\u3001INSERT
\u3001UPDATE
\u6216 DELETE
\u8bed\u53e5\u3002
> expression IS NOT NULL\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not-null/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;\n+---------------+---------------+------------------+\n| 1 is not null | 0 is not null | null is not null |\n+---------------+---------------+------------------+\n| true | true | false |\n+---------------+---------------+------------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\nmysql> select * from t1 where b is NOT NULL;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n+-------+-------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/","title":"IS NOT","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IS NOT
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6d4b\u8bd5\u6570\u503c\u662f\u5426\u4e3a\u5e03\u5c14\u503c\uff0c\u82e5\u4e0d\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002\u5176\u4e2d boolean_value
\u53ef\u4ee5\u4e3a TRUE
\u3001FALSE
\u6216 UNKNOWN
\u3002
> IS NOT boolean_value\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-not/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS NOT TRUE, 0 IS NOT FALSE, NULL IS NOT UNKNOWN;\n+---------------+----------------+---------------------+\n| 1 is not true | 0 is not false | null is not unknown |\n+---------------+----------------+---------------------+\n| false | false | false |\n+---------------+----------------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/","title":"IS NULL","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IS NULL
\u8fd0\u7b97\u7b26\u7528\u4e8e\u5224\u65ad\u5217\u7684\u503c\u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u503c\u4e3a\u7a7a\uff0c\u5373\u4e3a NULL
\uff0c\u5219\u8fd4\u56de true
\uff0c\u5426\u5219\u8fd4\u56de false
\u3002\u5b83\u53ef\u4ee5\u7528\u4e8e SELECT
\u3001INSERT
\u3001UPDATE
\u6216 DELETE
\u8bed\u53e5\u3002
> expression IS NULL\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is-null/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS NULL, 0 IS NULL, NULL IS NULL;\n+-----------+-----------+--------------+\n| 1 is null | 0 is null | null is null |\n+-----------+-----------+--------------+\n| false | false | true |\n+-----------+-----------+--------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\nmysql> select * from t1 where a IS NULL;\n+------+------+\n| a | b |\n+------+------+\n| NULL | NULL |\n+------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/","title":"IS","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IS
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6d4b\u8bd5\u6570\u503c\u662f\u5426\u4e3a\u5e03\u5c14\u503c\uff0c\u82e5\u662f\u5e03\u5c14\u503c\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002\u5176\u4e2d boolean_value
\u53ef\u4ee5\u4e3a TRUE
\u3001FALSE
\u6216 UNKNOWN
\u3002
> IS boolean_value\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/is/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 1 IS TRUE, 0 IS FALSE, NULL IS UNKNOWN;\n+-----------+------------+-----------------+\n| 1 is true | 0 is false | null is unknown |\n+-----------+------------+-----------------+\n| true | true | true |\n+-----------+------------+-----------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select * from t1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\nmysql> select * from t1 where a<=b and a is not NULL;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | true |\n| false | false |\n+-------+-------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/","title":"<=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"<=
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 <=
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5c0f\u4e8e\u6216\u7b49\u4e8e <=
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c<=
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x <= y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than-or-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 <= 2;\n+--------+\n| 2 <= 2 |\n+--------+\n| true |\n+--------+\n1 row in set (0.00 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,score,spID from t1 where userID<=score/spID;\n+--------+-------+------+\n| userid | score | spid |\n+--------+-------+------+\n| 1 | 1 | 1 |\n| 1 | 4 | 2 |\n| 1 | 5 | 1 |\n| 11 | 99 | 5 |\n+--------+-------+------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/","title":"<","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"<
\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u8fd0\u7b97\u3002\u5f53 <
\u5de6\u8fb9\u8fd0\u7b97\u6570\u503c\u5c0f\u4e8e <
\u53f3\u4fa7\u8fd0\u7b97\u6570\u503c\u65f6\uff0c<
\u8fd0\u7b97\u7b26\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> SELECT x < y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/less-than/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 < 2;\n+-------+\n| 2 < 2 |\n+-------+\n| false |\n+-------+\n1 row in set (0.00 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select spID,userID,score from t1 where (userID-1)<spID;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n| 2 | 1 | 4 |\n| 3 | 3 | 3 |\n| 1 | 1 | 5 |\n+------+--------+-------+\n5 rows in set (0.00 sec)\nmysql> select spID,userID,score from t1 where spID<(userID-1);\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 4 | 6 | 10 |\n| 5 | 11 | 99 |\n+------+--------+-------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/","title":"LIKE","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"LIKE
\u64cd\u4f5c\u7b26\u7528\u4e8e\u5728 WHERE
\u5b50\u53e5\u4e2d\u641c\u7d22\u5217\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\u3002
\u6709\u4e24\u4e2a\u901a\u914d\u7b26\u7ecf\u5e38\u4e0e LIKE
\u64cd\u4f5c\u7b26\u4e00\u8d77\u4f7f\u7528\uff1a
\u767e\u5206\u53f7 %
\u901a\u914d\u7b26\uff1a\u8868\u793a\u5339\u914d\u4efb\u610f\u5b57\u7b26\u5e8f\u5217\uff08\u5305\u62ec\u7a7a\u5b57\u7b26\u5e8f\u5217\uff09\u3002
\u4e0b\u5212\u7ebf _
\u901a\u914d\u7b26\uff1a\u8868\u793a\u5339\u914d\u5355\u4e2a\u5b57\u7b26\u3002
te_t
\uff1a\u53ef\u4ee5\u5339\u914d \"text\"\u3001\"test\" \u7b49\u3002\u5176\u4ed6\u5b57\u7b26\uff1aLIKE
\u64cd\u4f5c\u7b26\u5bf9\u5176\u4ed6\u5b57\u7b26\u662f\u5927\u5c0f\u5199\u654f\u611f\u7684\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN LIKE pattern;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/like/#_3","title":"\u793a\u4f8b","text":"drop table t1;\ncreate table t1(a varchar(20));\ninsert into t1 values ('abc'), ('ABC'), ('abC');\nselect * from t1 where a like '%abC%';\n\nmysql> select * from t1 where a like '%abC%';\n+------+\n| a |\n+------+\n| abC |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/","title":"NOT BETWEEN ... AND ...","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NOT BETWEEN ... AND ...
\u64cd\u4f5c\u7b26\u9009\u53d6\u4ecb\u4e8e\u4e24\u4e2a\u503c\u4e4b\u95f4\u7684\u6570\u636e\u8303\u56f4\u5916\u7684\u503c\u3002\u8fd9\u4e9b\u503c\u53ef\u4ee5\u662f\u6570\u503c\u3001\u6587\u672c\u6216\u8005\u65e5\u671f\u3002\u5982\u679c\u53d6\u503c\u4ecb\u4e8e\u4e24\u503c\u4e4b\u95f4\uff0c\u90a3\u4e48\u8fd4\u56de false
\uff0c\u5426\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002
> expr NOT BETWEEN min AND max\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-between/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT 2 NOT BETWEEN 1 AND 3, 2 NOT BETWEEN 3 and 1;\n+-----------------------+-----------------------+\n| 2 not between 1 and 3 | 2 not between 3 and 1 |\n+-----------------------+-----------------------+\n| false | true |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n
create table t (id bigint unsigned, b int);\ninsert into t values(8894754949779693574,1);\ninsert into t values(8894754949779693579,2);\ninsert into t values(17790886498483827171,3);\n\nmysql> select count(*) from t where id>=8894754949779693574 and id =17790886498483827171 order by 1 asc;\n+----------+\n| count(*) |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.00 sec)\n\nmysql> select count(*) from t where id not between 8894754949779693574 and 17790886498483827171;\n+----------+\n| count(*) |\n+----------+\n| 0 |\n+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/","title":"<>,!=","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#_2","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"<>, !=
\u8fd0\u7b97\u7b26\u4ec5\u5f53\u5de6\u64cd\u4f5c\u6570\u4e0d\u7b49\u4e8e\u53f3\u64cd\u4f5c\u6570\u65f6\u8fd4\u56de true
\u3002
> SELECT x <> y;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-equal/#_4","title":"\u793a\u4f8b","text":"mysql> SELECT 2 <> 2;\n+--------+\n| 2 != 2 |\n+--------+\n| false |\n+--------+\n1 row in set (0.01 sec)\n
create table t1 (spID smallint,userID bigint,score int);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\n\nmysql> select userID,spID,score from t1 where userID=spID and userID<>score;\n+--------+------+-------+\n| userid | spid | score |\n+--------+------+-------+\n| 1 | 1 | 5 |\n+--------+------+-------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/","title":"NOT IN","text":""},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NOT IN
\u8fd0\u7b97\u7b26\u53ef\u4ee5\u5728 WHERE
\u8bed\u53e5\u4e2d\u6307\u5b9a\u7279\u5b9a\u7684\u591a\u4e2a\u503c\uff0c\u672c\u8d28\u4e0a\u662f\u591a\u4e2a XOR
\u6761\u4ef6\u7684\u7b80\u5199\u3002
> SELECT column1, column2, ...\nFROM table_name\nWHERE column_name NOT IN (value1, value2, ...);\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#_3","title":"\u793a\u4f8b","text":"create table t2(a int,b varchar(5),c float, d date, e datetime);\ninsert into t2 values(1,'a',1.001,'2022-02-08','2022-02-08 12:00:00');\ninsert into t2 values(2,'b',2.001,'2022-02-09','2022-02-09 12:00:00');\ninsert into t2 values(1,'c',3.001,'2022-02-10','2022-02-10 12:00:00');\ninsert into t2 values(4,'d',4.001,'2022-02-11','2022-02-11 12:00:00');\n\nmysql> select * from t2 where a not in (2,4);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n+------+------+-------+------------+---------------------+\n2 rows in set (0.05 sec)\n\nmysql> select * from t2 where b not in ('e',\"f\");\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 1 | a | 1.001 | 2022-02-08 | 2022-02-08 12:00:00 |\n| 2 | b | 2.001 | 2022-02-09 | 2022-02-09 12:00:00 |\n| 1 | c | 3.001 | 2022-02-10 | 2022-02-10 12:00:00 |\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n4 rows in set (0.09 sec)\n\nmysql> select * from t2 where e not in ('2022-02-09 12:00:00') and a in (4,5);\n+------+------+-------+------------+---------------------+\n| a | b | c | d | e |\n+------+------+-------+------------+---------------------+\n| 4 | d | 4.001 | 2022-02-11 | 2022-02-11 12:00:00 |\n+------+------+-------+------------+---------------------+\n1 row in set (0.05 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-in/#_4","title":"\u9650\u5236","text":"NOT IN
\u5de6\u4fa7\u7684\u5e38\u91cf\u5217\u8868\u3002NOT IN
\u5de6\u8fb9\u53ea\u80fd\u6709\u5355\u5217\uff0c\u4e0d\u80fd\u662f\u591a\u5217\u3002NULL
\u503c\u4e0d\u80fd\u51fa\u73b0\u5728 NOT IN
\u53f3\u4fa7\u7684\u5217\u8868\u4e2d\u3002NOT LIKE
\u64cd\u4f5c\u7b26\u7528\u4e8e\u5728 WHERE
\u4ece\u53e5\u4e2d\u641c\u7d22\u5217\u4e2d\u7684\u6307\u5b9a\u6a21\u5f0f\uff0c\u662f LIKE
\u7684\u5426\u5b9a\u7528\u6cd5\u3002
\u6709\u4e24\u4e2a\u901a\u914d\u7b26\u7ecf\u5e38\u4e0e LIKE
\u64cd\u4f5c\u7b26\u4e00\u8d77\u4f7f\u7528\uff1a
> SELECT column1, column2, ...\nFROM table_name\nWHERE columnN NOT LIKE pattern;\n
"},{"location":"MatrixOne/Reference/Operators/operators/comparison-functions-and-operators/not-like/#_3","title":"\u793a\u4f8b","text":"create table t1 (a char(10));\ninsert into t1 values('abcdef');\ninsert into t1 values('_bcdef');\ninsert into t1 values('a_cdef');\ninsert into t1 values('ab_def');\ninsert into t1 values('abc_ef');\ninsert into t1 values('abcd_f');\ninsert into t1 values('abcde_');\n\nmysql> select * from t1 where a not like 'a%';\n+--------+\n| a |\n+--------+\n| _bcdef |\n+--------+\nmysql> select * from t1 where a not like \"%d_\\_\";\n+--------+\n| a |\n+--------+\n| abcdef |\n| _bcdef |\n| a_cdef |\n| ab_def |\n| abc_ef |\n| abcd_f |\n+--------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/","title":"CASE WHEN","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/case-when/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CASE WHEN
\u8bed\u53e5\u7528\u4e8e\u8ba1\u7b97\u6761\u4ef6\u5217\u8868\u5e76\u8fd4\u56de\u591a\u4e2a\u53ef\u80fd\u7ed3\u679c\u8868\u8fbe\u5f0f\u4e4b\u4e00\uff0cCASE WHEN
\u53ef\u4ee5\u6bd4\u8f83\u7b49\u4e8e\u3001\u8303\u56f4\u7684\u6761\u4ef6\u3002\u9047\u5230\u7b2c\u4e00\u4e2a\u6ee1\u8db3\u6761\u4ef6\u7684\u5373\u8fd4\u56de\uff0c\u4e0d\u518d\u5f80\u4e0b\u6bd4\u8f83\uff0c\u5982\u679c\u6ca1\u6709\u6ee1\u8db3\u7684\u6761\u4ef6\u5219\u8fd4\u56de else
\u91cc\u7684\u7ed3\u679c\uff0c\u5982\u679c\u6ca1\u6709 else
\u5219\u8fd4\u56de NULL
\u3002
CASE \u6709\u4e24\u79cd\u683c\u5f0f\uff0c\u4e24\u79cd\u683c\u5f0f\u90fd\u652f\u6301\u53ef\u9009\u7684 ELSE
\u53c2\u6570\u3002\uff1a
CASE
\u51fd\u6570\u5c06\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e0e\u4e00\u7ec4\u7b80\u5355\u8868\u8fbe\u5f0f\u8fdb\u884c\u6bd4\u8f83\u4ee5\u786e\u5b9a\u7ed3\u679c\u3002CASE
\u641c\u7d22\u51fd\u6570\u8ba1\u7b97\u4e00\u7ec4\u5e03\u5c14\u8868\u8fbe\u5f0f\u6765\u786e\u5b9a\u7ed3\u679c\u3002CASE value WHEN compare_value THEN result [WHEN compare_value THEN result ...] [ELSE result] END\n
\u8fd9\u91cc\u7684 CASE
\u8bed\u6cd5\u8fd4\u56de\u7684\u662f\u7b2c\u4e00\u4e2a value=compare_value
\u4e3a true
\u7684\u5206\u652f\u7684\u7ed3\u679c\u3002
CASE WHEN condition THEN result [WHEN condition THEN result ...] [ELSE result] END\n
\u8fd9\u91cc\u7684 CASE
\u8bed\u6cd5\u8fd4\u56de\u7684\u662f\u7b2c\u4e00\u4e2a condition
\u4e3a true
\u7684\u5206\u652f\u7684\u7ed3\u679c\u3002
\u5982\u679c\u6ca1\u6709\u4e00\u4e2a value=compare_value
\u6216\u8005 condition
\u4e3a true
\uff0c\u90a3\u4e48\u5c31\u4f1a\u8fd4\u56de ELSE
\u5bf9\u5e94\u7684\u7ed3\u679c\uff0c\u5982\u679c\u6ca1\u6709 ELSE
\u5206\u652f\uff0c\u90a3\u4e48\u8fd4\u56de NULL
\u3002
note
CASE
\u8bed\u53e5\u4e0d\u80fd\u6709 ELSE NULL
\u4ece\u53e5, \u5e76\u4e14 CASE
\u8bed\u53e5\u5fc5\u987b\u4ee5 END
\u7ed3\u5c3e\u3002
mysql> SELECT CASE WHEN 1>0 THEN 'true' ELSE 'false' END;\n+------------------------------------------+\n| case when 1 > 0 then true else false end |\n+------------------------------------------+\n| true |\n+------------------------------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t1 (a INT, b INT);\nQuery OK, 0 rows affected (0.01 sec)\n\nINSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3);\nQuery OK, 6 rows affected (0.01 sec)\n\nmysql> SELECT CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END FROM t1 GROUP BY b;\n+-------------------------------------------------------+\n| case when avg(a) >= 0 then Positive else Negative end |\n+-------------------------------------------------------+\n| Positive |\n| Positive |\n| Positive |\n+-------------------------------------------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/flow-control-functions-overview/","title":"\u63a7\u5236\u6d41\u51fd\u6570\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 CASE Case \u8fd0\u7b97\u7b26 IF() If/else \u8bed\u53e5 IFNULL() null if/else \u8bed\u53e5 NULLIF() expr1 = expr2 \u65f6\u8fd4\u56de NULL"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/","title":"IF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"IF()
\u65e2\u53ef\u4ee5\u4f5c\u4e3a\u8868\u8fbe\u5f0f\u7528\uff0c\u4e5f\u53ef\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u4f5c\u4e3a\u6d41\u7a0b\u63a7\u5236\u8bed\u53e5\u4f7f\u7528\u3002
> IF(expr1,expr2,expr3)\n
TRUE
(expr1 <> 0 and expr1 IS NOT NULL)\uff0c\u5219\u7ed3\u679c\u8fd4\u56de expr2\uff1b\u5426\u5219\uff0c\u8fd4\u56de expr3\u3002\u2014 \u5982\u679c expr2 \u6216 expr3 \u4e2d\u53ea\u6709\u4e00\u4e2a\u663e\u5f0f\u4e3a NULL
\uff0c\u5219 If()
\u51fd\u6570\u7684\u7ed3\u679c\u7c7b\u578b\u4e3a\u975e NULL \u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u3002
IF()
\u7684\u9ed8\u8ba4\u8fd4\u56de\u7c7b\u578b (\u5b58\u50a8\u5230\u4e34\u65f6\u8868\u65f6\u53ef\u80fd\u4f1a\u6709\u5f71\u54cd) \u8ba1\u7b97\u5982\u4e0b\uff1a
\u5982\u679c expr2 \u6216 expr3 \u751f\u6210\u7684\u662f\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u4e3a\u5b57\u7b26\u4e32\u3002
\u5982\u679c expr2 \u548c expr3 \u90fd\u662f\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u6709\u4e00\u4e2a\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\uff0c\u5219\u7ed3\u679c\u4e5f\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\u3002
\u5982\u679c expr2 \u6216 expr3 \u751f\u6210\u7684\u662f\u6d6e\u70b9\u503c\uff0c\u5219\u7ed3\u679c\u4e3a\u6d6e\u70b9\u503c\u3002
mysql> SELECT IF(1>2,2,3);\n+-----------------+\n| if(1 > 2, 2, 3) |\n+-----------------+\n| 3 |\n+-----------------+\n1 row in set (0.01 sec)\nmysql> SELECT IF(1<2,'yes','no');\n+--------------------+\n| if(1 < 2, yes, no) |\n+--------------------+\n| yes |\n+--------------------+\n1 row in set (0.00 sec)\n
CREATE TABLE t1 (st varchar(255) NOT NULL, u int(11) NOT NULL);\nINSERT INTO t1 VALUES ('a',1),('A',1),('aa',1),('AA',1),('a',1),('aaa',0),('BBB',0);\n\nmysql> select if(u=1,st,st) s from t1 order by s;\n+------+\n| s |\n+------+\n| A |\n| AA |\n| BBB |\n| a |\n| a |\n| aa |\n| aaa |\n+------+\n7 rows in set (0.00 sec)\n\nmysql> select if(u=1,st,st) s from t1 where st like \"%a%\" order by s;\n+------+\n| s |\n+------+\n| a |\n| a |\n| aa |\n| aaa |\n+------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_if/#_4","title":"\u9650\u5236","text":"\u51fd\u6570 IF
\u6682\u4e0d\u652f\u6301\u53c2\u6570 BIGINT
\u548c VARCHAR
\u3002
\u5982\u679c expr1
\u4e0d\u4e3a NULL
\uff0c\u5219 IFNULL()
\u8fd4\u56de expr1
\uff1b\u5426\u5219\u8fd4\u56de expr2
\u3002
> IFNULL(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_ifnull/#_3","title":"\u793a\u4f8b","text":"mysql> SELECT IFNULL(NULL,10);\n+------------------+\n| ifnull(null, 10) |\n+------------------+\n| 10 |\n+------------------+\n1 row in set (0.01 sec)\n
mysql> SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL);\n+-----------------------------------------+\n| cast(ifnull(null, null) as decimal(38)) |\n+-----------------------------------------+\n| NULL |\n+-----------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/","title":"NULLIF","text":""},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NULLIF()
\u51fd\u6570\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u8868\u8fbe\u5f0f\u7684\u503c\u3002\u5982\u679c expr1
\u548c expr2
\u7684\u503c\u76f8\u7b49\uff0c\u90a3\u4e48 NULLIF()
\u51fd\u6570\u8fd4\u56de NULL
\uff1b\u5426\u5219\uff0c\u8fd4\u56de expr1
\u7684\u503c\u3002\u8fd9\u4e2a\u51fd\u6570\u901a\u5e38\u7528\u4e8e\u5904\u7406\u907f\u514d\u9664\u4ee5\u96f6\u6216\u907f\u514d\u5728\u8ba1\u7b97\u4e2d\u4f7f\u7528\u65e0\u6548\u7684\u503c\u65f6\u4ea7\u751f\u9519\u8bef\u3002
> NULLIF(expr1,expr2)\n
"},{"location":"MatrixOne/Reference/Operators/operators/flow-control-functions/function_nullif/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE employees ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) NOT NULL, salary DECIMAL(10, 2) );\n\nINSERT INTO employees (name, salary) VALUES ('John Doe', 1000), ('Alice Smith', 2000), ('Bob Johnson', 1500);\n\n-- \u4f7f\u7528 NULLIF() \u51fd\u6570\u5c06\u5de5\u8d44\u4e3a\u7279\u5b9a\u503c\u7684\u5458\u5de5\u7684\u5de5\u8d44\u8bbe\u4e3a NULL\u3002NULLIF(salary, 1500) \u51fd\u6570\u5c06\u6bd4\u8f83 salary \u5b57\u6bb5\u7684\u503c\u548c 1500\u3002\u5982\u679c salary \u7684\u503c\u7b49\u4e8e 1500\uff0c\u5219\u8fd4\u56de NULL\uff0c\u5426\u5219\u8fd4\u56de salary \u7684\u503c\u3002\nmysql> SELECT name, salary, NULLIF(salary, 1500) AS adjusted_salary FROM employees;\n+-------------+---------+-----------------+\n| name | salary | adjusted_salary |\n+-------------+---------+-----------------+\n| John Doe | 1000.00 | 1000.00 |\n| Alice Smith | 2000.00 | 2000.00 |\n| Bob Johnson | 1500.00 | |\n+-------------+---------+-----------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/","title":"AND,&&","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"AND,&&
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u4e8e\u903b\u8f91\u4e0e\u8fd0\u7b97\u3002\u5982\u679c\u6240\u6709\u64cd\u4f5c\u6570\u90fd\u975e\u96f6\u4e14\u4e0d\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff1b\u5982\u679c\u4e00\u4e2a\u6216\u591a\u4e2a\u64cd\u4f5c\u6570\u4e3a 0\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\uff1b\u5982\u679c\u4e00\u4e2a\u6216\u591a\u4e2a\u64cd\u4f5c\u6570\u975e\u96f6\u4e14\u4e3a NULL
\uff0c\u5219\u8fd4\u56de NULL
\u3002
> SELECT column_1 AND column_2 FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/and/#_3","title":"\u793a\u4f8b","text":"mysql> select 1 and 1;\n+---------+\n| 1 and 1 |\n+---------+\n| true |\n+---------+\nmysql> select 1 and 0;\n+---------+\n| 1 and 0 |\n+---------+\n| false |\n+---------+\nmysql> select 1 and null;\n+------------+\n| 1 and null |\n+------------+\n| NULL |\n+------------+\nmysql> select null and 0;\n+------------+\n| null and 0 |\n+------------+\n| false |\n+------------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\nmysql> select a and b from t1;\n+---------+\n| a and b |\n+---------+\n| false |\n| false |\n| true |\n| false |\n| NULL |\n+---------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/logical-operators-overview/","title":"\u903b\u8f91\u8fd0\u7b97\u7b26\u6982\u8ff0","text":"\u540d\u79f0 \u63cf\u8ff0 AND,&& \u903b\u8f91\u4e0e NOT,! \u903b\u8f91\u975e OR \u903b\u8f91\u6216 XOR \u903b\u8f91\u5f02\u6216"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/","title":"NOT,!","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"NOT,!
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u4e8e\u903b\u8f91\u975e\u8fd0\u7b97\u3002\u5982\u679c\u64cd\u4f5c\u6570\u4e3a\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff1b\u5982\u679c\u64cd\u4f5c\u6570\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\uff1b\u5982\u679c\u64cd\u4f5c\u6570\u4e3a NOT NUL
\u5219\u8fd4\u56de NULL
\u3002
> NOT|! value\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/not/#_3","title":"\u793a\u4f8b","text":"mysql> select not 0;\n+-------+\n| not 0 |\n+-------+\n| true |\n+-------+\n1 row in set (0.02 sec)\n\nmysql> select ! null;\n+-------+\n| !null |\n+-------+\n| NULL |\n+-------+\n1 row in set (0.00 sec)\n\nmysql> select ! 1;\n+-------+\n| !1 |\n+-------+\n| false |\n+-------+\n1 row in set (0.01 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\nmysql> SELECT * FROM T1;\n+-------+-------+\n| a | b |\n+-------+-------+\n| false | true |\n| true | false |\n| true | true |\n| false | false |\n| NULL | NULL |\n+-------+-------+\n5 rows in set (0.01 sec)\n\nmysql> select not a and not b from t1;\n+-----------------+\n| not a and not b |\n+-----------------+\n| false |\n| false |\n| false |\n| true |\n| NULL |\n+-----------------+\n5 rows in set (0.00 sec)\n\nmysql> select * from t1 where !(a=false);\n+------+-------+\n| a | b |\n+------+-------+\n| true | false |\n| true | true |\n+------+-------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/","title":"OR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"OR,||
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u903b\u8f91\u6216\u8fd0\u7b97\u3002\u5f53\u4e24\u4e2a\u64cd\u4f5c\u6570\u90fd\u975e null
\u65f6\uff0c\u5982\u679c\u64cd\u4f5c\u6570\u540c\u65f6\u4e5f\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff0c\u5426\u5219\u4e3a false
\uff1b\u5bf9\u4e8e NULL
\u64cd\u4f5c\u6570\uff0c\u5982\u679c\u53e6\u4e00\u4e2a\u64cd\u4f5c\u6570\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff0c\u5426\u5219\u4e3a NULL
\uff1b\u5982\u679c\u4e24\u4e2a\u64cd\u4f5c\u6570\u90fd\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a NULL
\u3002
> SELECT column_1 OR column_2 FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/or/#_3","title":"\u793a\u4f8b","text":"mysql> select 1 or 1;\n+--------+\n| 1 or 1 |\n+--------+\n| true |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 1 or 0;\n+--------+\n| 1 or 0 |\n+--------+\n| true |\n+--------+\n1 row in set (0.00 sec)\n\nmysql> select 0 or 0;\n+--------+\n| 0 or 0 |\n+--------+\n| false |\n+--------+\n1 row in set (0.01 sec)\n\nmysql> select 0 or null;\n+-----------+\n| 0 or null |\n+-----------+\n| NULL |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql> select 1 or null;\n+-----------+\n| 1 or null |\n+-----------+\n| true |\n+-----------+\n1 row in set (0.00 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a or b from t1;\n+--------+\n| a or b |\n+--------+\n| true |\n| true |\n| true |\n| false |\n| NULL |\n+--------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/","title":"XOR","text":""},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#_1","title":"\u8fd0\u7b97\u7b26\u8bf4\u660e","text":"XOR
\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4f5c\u4e8e\u903b\u8f91\u5f02\u6216\u8fd0\u7b97\u3002\u5982\u679c\u4efb\u610f\u4e00\u4e2a\u64cd\u4f5c\u6570\u4e3a NULL
\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a NULL
\uff1b\u5bf9\u4e8e\u975e NULL
\u64cd\u4f5c\u6570\uff0c\u5982\u679c\u6709\u5947\u6570\u4e2a\u64cd\u4f5c\u6570\u662f\u975e\u96f6\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\uff0c\u5426\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
a XOR b
\u5728\u6570\u5b66\u8fd0\u7b97\u4e0a\u7b49\u4e8e (a AND (NOT b)) OR ((NOT a) and b)
\u3002
> SELECT column_1 XOR column_2 FROM table_name;\n
"},{"location":"MatrixOne/Reference/Operators/operators/logical-operators/xor/#_3","title":"\u793a\u4f8b","text":"mysql> select 1 xor 1;\n+---------+\n| 1 xor 1 |\n+---------+\n| false |\n+---------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 0;\n+---------+\n| 1 xor 0 |\n+---------+\n| true |\n+---------+\n1 row in set (0.00 sec)\n\nmysql> select 1 xor null;\n+------------+\n| 1 xor null |\n+------------+\n| NULL |\n+------------+\n1 row in set (0.01 sec)\n\nmysql> select 1 xor 1 xor 1;\n+---------------+\n| 1 xor 1 xor 1 |\n+---------------+\n| true |\n+---------------+\n1 row in set (0.00 sec)\n
create table t1 (a boolean,b bool);\ninsert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);\n\nmysql> select a xor b from t1;\n+---------+\n| a xor b |\n+---------+\n| true |\n| true |\n| false |\n| false |\n| NULL |\n+---------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/","title":"SQL \u8bed\u53e5\u7684\u5206\u7c7b","text":"\u5728 MatrixOne \u4e2d\uff0cSQL \u8bed\u53e5\u5305\u542b\u591a\u79cd\u5206\u7c7b\uff0c\u6bcf\u4e00\u79cd\u5206\u7c7b\u7684\u5b9a\u4e49\u4e0e\u5305\u542b\u5185\u5bb9\u6309\u7167\u5982\u4e0b\u63cf\u8ff0\u7684\u6bcf\u4e2a\u90e8\u5206\u6240\u5c55\u793a\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#ddl-","title":"DDL - \u6570\u636e\u5b9a\u4e49\u8bed\u8a00","text":"\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff08Data Definition Language\uff0cDDL\uff09\u662f DBMS \u8bed\u8a00\u7684\u4e00\u79cd\uff0c\u7528\u4e8e\u660e\u786e\u5b9a\u4e49\u6570\u636e\u5bf9\u8c61\u3002\u5728 MatrixOne \u4e2d\uff0cDDL \u8bed\u53e5\u5206\u4e3a\u4e94\u4e2a\u7c7b\u522b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#create-matrixone","title":"CREATE \u8bed\u53e5\uff0c\u521b\u5efa MatrixOne \u4e2d\u5404\u7c7b\u5bf9\u8c61","text":"\u6570\u636e\u4fee\u6539\u8bed\u8a00\uff08Data Manipulation Language, DML\uff09\u7528\u4e8e\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u5305\u62ec\u5bf9\u6570\u636e\u5e93\u4e2d\u7684\u5bf9\u8c61\u548c\u8d44\u6599\u6267\u884c\u8bbf\u95ee\u5de5\u4f5c\u7684\u7f16\u7a0b\u8bed\u53e5\u3002\u5728 MatrixOne \u4e2d\uff0cDML \u5305\u542b\u5982\u4e0b\u5206\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#insert","title":"INSERT \u8bed\u53e5\uff0c\u7528\u4e8e\u5728\u8868\u4e2d\u63d2\u5165\u65b0\u884c","text":"\u67e5\u8be2\u7c7b\u8bed\u53e5\uff08Data Query Language, DQL\uff09\u7528\u4e8e\u68c0\u7d22 MatrixOne \u4e2d\u73b0\u6709\u6570\u636e\u3002\u4ee5 SELECT \u8bed\u53e5\u4e3a\u6838\u5fc3\uff0c\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#_1","title":"\u5355\u8868\u67e5\u8be2\uff0c\u67e5\u8be2\u5c42\u7ea7\u53ea\u6709\u4e00\u5c42\uff0c\u53ea\u6d89\u53ca\u5230\u5355\u8868\u7684\u67e5\u8be2","text":"\u4e8b\u52a1\u8bed\u8a00\u662f MatrixOne \u4e2d\u63d0\u4f9b\u4e8b\u52a1\u7ba1\u63a7\u4e13\u7528\u7684\u8bed\u8a00\uff0c\u5305\u62ec\u5982\u4e0b\u51e0\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#start-transaction-matrixone-begin","title":"START TRANSACTION\uff0c\u5f00\u542f\u4e8b\u52a1\uff0c\u5728 MatrixOne \u4e2d\u53ef\u4ee5\u4f7f\u7528\u5176\u65b9\u8a00 BEGIN \u5b9e\u73b0\u66ff\u4ee3","text":"START TRANSACTION;\n TRANSACTION STATEMENTS\n ```\n\n### COMMIT\uff0c\u63d0\u4ea4\u4e8b\u52a1\uff0c\u7528\u4e8e\u5728 START TRANSACTION \u6216\u975e\u81ea\u52a8\u63d0\u4ea4\u573a\u666f\u4e0b\u5bf9\u4e8b\u52a1\u7684\u663e\u5f0f\u63d0\u4ea4\n
START TRANSACTION; TRANSACTION STATEMENTS COMMIT; OR SET AUTOCOMMIT=0; TRANSACTION STATEMENTS COMMIT; ### ROLLBACK\uff0c\u56de\u6eda\u4e8b\u52a1\uff0c\u7528\u4e8e\u5728 START TRANSACTION \u6216\u975e\u81ea\u52a8\u63d0\u4ea4\u573a\u666f\u4e0b\u5bf9\u4e8b\u52a1\u7684\u663e\u5f0f\u56de\u6eda\n
START TRANSACTION; TRANSACTION STATEMENTS ROLLBACK; OR SET AUTOCOMMIT=0; TRANSACTION STATEMENTS ROLLBACK; ```"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#dcl-","title":"DCL - \u6570\u636e\u63a7\u5236\u8bed\u8a00","text":"\u6570\u636e\u63a7\u5236\u8bed\u8a00\uff08Data Control Language, DCL\uff09\u5305\u62ec\u8d44\u6e90\u7684\u5206\u914d\u4e0e\u56de\u6536\u3001\u7528\u6237\u4e0e\u89d2\u8272\u7684\u521b\u5efa\u4e0e\u5220\u9664\u3001\u6743\u9650\u7684\u6388\u6743\u4e0e\u56de\u6536\uff0c\u5206\u4e3a\u5982\u4e0b\u5206\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#create","title":"CREATE \u8bed\u53e5\uff0c\u7528\u4e8e\u521b\u5efa\u79df\u6237\u3001\u7528\u6237\u4e0e\u89d2\u8272","text":"\u7ba1\u7406\u8bed\u8a00\u5305\u542b\u4e0e\u6570\u636e\u65e0\u76f4\u63a5\u5173\u8054\u7684\u6570\u636e\u5e93\u53c2\u6570\u3001\u8d44\u6e90\u5206\u914d\u7684\u83b7\u53d6\u4e0e\u4fee\u6539\uff0c\u5305\u62ec\u5982\u4e0b\u8bed\u53e5\u79cd\u7c7b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/SQL-Type/#show","title":"SHOW \u8bed\u53e5","text":"\u901a\u8fc7 SHOW \u8bed\u53e5\uff0c\u83b7\u53d6\u4fe1\u606f\uff1a
\u901a\u8fc7 SET \u8bed\u53e5\u7528\u6237\u53ef\u4ee5\u5bf9\u5404\u7c7b\u6570\u636e\u5e93\u53c2\u6570\u8fdb\u884c\u8c03\u6574\uff0c\u5e76\u901a\u8fc7 SHOW \u547d\u4ee4\u5448\u73b0
\u4e2d\u6b62\u67d0\u4e2a\u6570\u636e\u5e93\u8fde\u63a5\u7684\u8bed\u53e5\uff1a
\u7528\u4e8e\u8fde\u63a5\u67d0\u4e2a\u5df2\u5b58\u5728\u7684\u6570\u636e\u5e93\uff1a
\u7528\u4e8e\u67e5\u770b SQL \u6267\u884c\u8ba1\u5212\uff1a
\u51c6\u5907\u4e00\u6761 SQL \u8bed\u53e5\u5e76\u7ed9\u5b83\u5206\u914d\u4e00\u4e2a\u540d\u79f0\uff1a
\u4f7f\u7528 PREPARE \u51c6\u5907\u597d\u7684\u8bed\u53e5\u540d\u79f0\u5e76\u6267\u884c\uff1a
\u91ca\u653e\u4f7f\u7528 PREPARE \u751f\u6210\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u3002\u5728\u91ca\u653e\u9884\u7f16\u8bd1\u8bed\u53e5\u540e\uff0c\u518d\u6b21\u6267\u884c\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u4f1a\u5bfc\u81f4\u9519\u8bef\uff1a
\u4fee\u6539\u79df\u6237\u4fe1\u606f\u3002
Note
> ALTER ACCOUNT [IF EXISTS]\naccount auth_option [COMMENT 'comment_string']\n\nauth_option: {\nADMIN_NAME [=] 'admin_name'\nIDENTIFIED BY 'auth_string'\n}\n\nstatus_option: {\nOPEN\n| SUSPEND\n| RESTRICTED\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#auth_option","title":"auth_option","text":"\u4fee\u6539\u79df\u6237\u7684\u5e10\u53f7\u540d\u548c\u6388\u6743\u65b9\u5f0f\uff0cauth_string
\u8868\u793a\u663e\u5f0f\u8fd4\u56de\u6307\u5b9a\u5bc6\u7801\u3002
\u8bbe\u7f6e\u79df\u6237\u7684\u72b6\u6001\u3002\u4f5c\u4e3a VARCHAR \u7c7b\u578b\u5b58\u50a8\u5728\u7cfb\u7edf\u6570\u636e\u5e93 mo_catalog \u4e0b\u7684 mo_account \u8868\u4e2d\u3002
RESTRICTED
\u72b6\u6001\u4ee5\u540e\uff0c\u8fd9\u4e2a\u79df\u6237\u53ea\u80fd\u5bf9\u6570\u636e\u5e93\u8fdb\u884c SHOW
/DELETE
/SELECT
/USE
/SET
\u64cd\u4f5c\uff0c\u5176\u4ed6\u64cd\u4f5c\u4e0d\u53ef\u4ee5\u4f7f\u7528\u3002RESTRICTED
\u72b6\u6001\u540e\uff0c\u5373\u4f7f\u79df\u6237\u6b63\u5728\u8bbf\u95ee\uff0c\u8bbf\u95ee\u884c\u4e3a\u4e5f\u5c06\u53d7\u5230\u9650\u5236\u3002OPEN
\u5373\u53ef\u89e3\u9664\u9650\u5236\uff0c\u5373\u4f7f\u7528 ALTER ACCOUNT account_name OPEN
\u89e3\u9664\u9650\u5236\u3002\u79df\u6237\u6ce8\u91ca\u4f5c\u4e3a VARCHAR \u7c7b\u578b\u5b58\u50a8\u5728\u7cfb\u7edf\u6570\u636e\u5e93 mo_catalog \u4e0b\u7684 mo_account \u8868\u4e2d\u3002
COMMENT \u53ef\u4ee5\u662f\u4efb\u610f\u5f15\u7528\u7684\u6587\u672c\uff0c\u65b0\u7684 COMMENT \u66ff\u6362\u4efb\u4f55\u73b0\u6709\u7684\u7528\u6237\u6ce8\u91ca\u3002\u5982\u4e0b\u6240\u793a\uff1a
mysql> desc mo_catalog.mo_account;\n+----------------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+----------------+--------------+------+------+---------+-------+---------+\n| account_id | INT | YES | | NULL | | |\n| account_name | VARCHAR(300) | YES | | NULL | | |\n| status | VARCHAR(300) | YES | | NULL | | |\n| created_time | TIMESTAMP | YES | | NULL | | |\n| comments | VARCHAR(256) | YES | | NULL | | |\n| suspended_time | TIMESTAMP | YES | | null | | |\n+----------------+--------------+------+------+---------+-------+---------+\n6 rows in set (0.06 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-account/#_4","title":"\u793a\u4f8b","text":"-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"root1\" \u5bc6\u7801\u4e3a \"111\" \u79df\u6237\nmysql> create account acc1 admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.42 sec)\n-- \u5c06\u79df\u6237\u7684\u521d\u59cb\u5bc6\u7801 \"111\" \u4fee\u6539\u4e3a \"Abcd_1234@1234\"\nmysql> alter account acc1 admin_name \"root1\" identified by \"Abcd_1234@1234\";\nQuery OK, 0 rows affected (0.01 sec)\n-- \u4fee\u6539\u79df\u6237 \"root1\" \u7684\u5907\u6ce8\nmysql> alter account acc1 comment \"new accout\";\nQuery OK, 0 rows affected (0.02 sec)\n-- \u67e5\u770b\u9a8c\u8bc1\u662f\u5426\u7ed9\u79df\u6237 \"root1\" \u589e\u52a0\u4e86 \"new accout\" \u7684\u5907\u6ce8\nmysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| acc1 | root1 | 2023-02-15 06:26:51 | open | NULL | 5 | 34 | 787 | 0.036 | new accout |\n| sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 3767 | 0.599 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n3 rows in set (0.19 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"root1\" \u5bc6\u7801\u4e3a \"111\" \u79df\u6237\nmysql> create account accx admin_name \"root1\" identified by \"111\";\nQuery OK, 0 rows affected (0.27 sec)\n-- \u4fee\u6539\u79df\u6237\u72b6\u6001\u4e3a \"suspend\"\uff0c\u5373\u6682\u505c\u7528\u6237\u8bbf\u95ee MatrixOne\nmysql> alter account accx suspend;\nQuery OK, 0 rows affected (0.01 sec)\n-- \u67e5\u770b\u4e00\u4e0b\u662f\u5426\u4fee\u6539\u72b6\u6001\u6210\u529f\nmysql> show accounts;\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n| accx | root1 | 2023-02-15 06:26:51 | suspend | 2023-02-15 06:27:15 | 5 | 34 | 787 | 0.036 | new accout |\n| sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 3767 | 0.599 | system account |\n+--------------+------------+---------------------+---------+---------------------+----------+-------------+-----------+-------+----------------+\n2 rows in set (0.15 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/","title":"ALTER USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4fee\u6539\u6570\u636e\u5e93\u7528\u6237\u7684\u5c5e\u6027\u548c\u5bc6\u7801\u3002
Note
ALTER USER [IF EXISTS]\n user auth_option\n\nauth_option: {\n IDENTIFIED BY 'auth_string'}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/alter-user/#auth_option","title":"auth_option","text":"\u4fee\u6539\u7528\u6237\u7684\u5e10\u53f7\u540d\u548c\u6388\u6743\u65b9\u5f0f\uff0cauth_string
\u8868\u793a\u663e\u5f0f\u8fd4\u56de\u6307\u5b9a\u5bc6\u7801\u3002
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"admin_1\" \u5bc6\u7801\u4e3a \"123456\" \u7528\u6237\nmysql> create user admin_1 identified by '123456';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u5c06\u7528\u6237\u7684\u521d\u59cb\u5bc6\u7801 \"123456\" \u4fee\u6539\u4e3a \"111111\"\nmysql> alter user 'admin_1' identified by '111111';\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u67e5\u770b\u662f\u5426\u4fee\u6539\u5bc6\u7801\u6210\u529f\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| 0 | localhost | root | 111 | unlock | 2023-04-19 06:37:58 | NULL | PASSWORD | 0 | 0 | 0 |\n| 1 | localhost | root | 111 | unlock | 2023-04-19 06:37:58 | NULL | PASSWORD | 0 | 0 | 0 |\n| 2 | localhost | admin_1 | 111111 | unlock | 2023-04-21 06:21:31 | NULL | PASSWORD | 1 | 0 | 1 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/","title":"CREATE ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4e3a\u5176\u4e2d\u4e00\u4e2a\u96c6\u7fa4\u6210\u5458\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u79df\u6237\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE ACCOUNT [IF NOT EXISTS]\naccount auth_option\n[COMMENT 'comment_string']\n\nauth_option: {\n ADMIN_NAME [=] 'admin_name'\n IDENTIFIED BY 'auth_string'\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-account/#auth_option","title":"auth_option","text":"\u6307\u5b9a\u79df\u6237\u9ed8\u8ba4\u7684\u5e10\u53f7\u540d\u548c\u6388\u6743\u65b9\u5f0f\uff0cauth_string
\u8868\u793a\u663e\u5f0f\u8fd4\u56de\u6307\u5b9a\u5bc6\u7801\u3002
> create account tenant_test admin_name = 'root' identified by '111' comment 'tenant_test';\nQuery OK, 0 rows affected (0.08 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/","title":"CREATE ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u7cfb\u7edf\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u89d2\u8272\u3002
\u521b\u5efa\u89d2\u8272\u540e\uff0c\u53ef\u4ee5\u5c06\u6743\u9650\u6388\u4e88\u8be5\u89d2\u8272\uff0c\u7136\u540e\u518d\u5c06\u8be5\u89d2\u8272\u6388\u4e88\u5176\u4ed6\u89d2\u8272\u6216\u5355\u4e2a\u7528\u6237\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE ROLE [IF NOT EXISTS] role [, role ] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-role/#_3","title":"\u793a\u4f8b","text":"> create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/","title":"CREATE USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u7cfb\u7edf\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7528\u6237\u3002
\u4f7f\u7528 CREATE USER
\uff0c\u4f60\u9700\u8981\u62e5\u6709 CREATE USER
\u6743\u9650\u3002
CREATE USER
\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002> CREATE USER [IF NOT EXISTS]\n user auth_option [, user auth_option] ...\n [DEFAULT ROLE role] \n [COMMENT 'comment_string' | ATTRIBUTE 'json_object']\nauth_option: {\n IDENTIFIED BY 'auth_string'\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u9996\u6b21\u521b\u5efa\u7684\u7528\u6237\u6ca1\u6709\u6743\u9650\uff0c\u9ed8\u8ba4\u89d2\u8272\u4e3a NONE
\u3002\u8981\u5206\u914d\u6743\u9650\u6216\u89d2\u8272\uff0c\u8bf7\u4f7f\u7528 GRANT \u8bed\u53e5\u3002
CREAT USER
\u7684\u57fa\u672c SQL \u8bed\u53e5\u5982\u4e0b\uff1a
create user user_name identified by 'password';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#identified-by-auth_string","title":"IDENTIFIED BY auth_string","text":"CREATE USER
\u5141\u8bb8\u8fd9\u4e9b auth_option
\uff1a
DEFAULT ROLE
\u5b50\u53e5\u5b9a\u4e49\u5f53\u7528\u6237\u8fde\u63a5\u5230 MatrixOne \u5e76\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u65f6\uff0c\u6216\u8005\u5f53\u7528\u6237\u5728\u4f1a\u8bdd\u671f\u95f4\u6267\u884c SET ROLE
\u8bed\u53e5\u65f6\uff0c\u89d2\u8272\u4f1a\u53d8\u4e3a\u6fc0\u6d3b/\u4f7f\u7528\u72b6\u6001\u3002
create user user_name identified by 'password' default role role_rolename;\n
DEFAULT ROLE
\u5b50\u53e5\u5141\u8bb8\u5217\u51fa\u4e00\u4e2a\u6216\u591a\u4e2a\u4ee5\u9017\u53f7\u5206\u9694\u7684\u89d2\u8272\u540d\u79f0\u3002\u8fd9\u4e9b\u89d2\u8272\u5fc5\u987b\u5728\u6267\u884c CREATE USER
\u524d\u5c31\u5df2\u7ecf\u88ab\u521b\u5efa\u597d\uff1b\u5426\u5219\u8be5\u8bed\u53e5\u4f1a\u5f15\u53d1\u9519\u8bef\uff0c\u5e76\u4e14\u521b\u5efa\u7528\u6237\u5931\u8d25\u3002
> create user userx identified by '111';\nQuery OK, 0 rows affected (0.04 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/create-user/#_5","title":"\u9650\u5236","text":"MatrxiOne \u6682\u4e0d\u652f\u6301 CREAT USER COMMENT
\u548c CREAT USER ATTRIBUTE
\u3002
\u5c06\u6307\u5b9a\u7684\u79df\u6237\u4ece\u67d0\u4e2a\u96c6\u7fa4\u6210\u5458\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP ACCOUNT [IF EXISTS] account\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-account/#_3","title":"\u793a\u4f8b","text":"> drop account if exists tenant_test;\nQuery OK, 0 rows affected (0.12 sec)\n
Note
\u5982\u679c\u79df\u6237\u6b63\u5728\u4f1a\u8bdd\u4e2d\uff0c\u5f53\u79df\u6237\u88ab\u79fb\u9664\uff0c\u4f1a\u8bdd\u968f\u5373\u65ad\u5f00\uff0c\u65e0\u6cd5\u518d\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/","title":"DROP ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5c06\u6307\u5b9a\u7684\u89d2\u8272\u4ece\u7cfb\u7edf\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP ROLE [IF EXISTS] role [, role ] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-role/#_3","title":"\u793a\u4f8b","text":"> drop role if exists rolex;\nQuery OK, 0 rows affected (0.02 sec)\n
Note
\u5982\u679c\u4f7f\u7528\u8fd9\u4e2a\u89d2\u8272\u7684\u7528\u6237\u6b63\u5728\u4f1a\u8bdd\u4e2d\uff0c\u5f53\u89d2\u8272\u88ab\u79fb\u9664\uff0c\u4f1a\u8bdd\u968f\u5373\u65ad\u5f00\uff0c\u65e0\u6cd5\u518d\u4f7f\u7528\u8fd9\u4e2a\u89d2\u8272\u8fdb\u884c\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/","title":"DROP USER","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5c06\u6307\u5b9a\u7684\u7528\u6237\u4ece\u7cfb\u7edf\u4e2d\u79fb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP USER [IF EXISTS] user [, user] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/drop-user/#_3","title":"\u793a\u4f8b","text":"> drop user if exists userx;\nQuery OK, 0 rows affected (0.02 sec)\n
Note
\u5982\u679c\u7528\u6237\u6b63\u5728\u4f1a\u8bdd\u4e2d\uff0c\u5f53\u7528\u6237\u88ab\u79fb\u9664\uff0c\u4f1a\u8bdd\u968f\u5373\u65ad\u5f00\uff0c\u65e0\u6cd5\u518d\u8fde\u63a5 MatrixOne\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/","title":"GRANT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"GRANT
\u8bed\u53e5\u5c06\u6743\u9650\u548c\u89d2\u8272\u5206\u914d\u7ed9 MatrixOne \u7528\u6237\u548c\u89d2\u8272\u3002
\u7cfb\u7edf\u6743\u9650\u662f\u521d\u59cb\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\uff08\u5bf9\u5e94\u7684\u662f root \u7528\u6237\uff09\u7684\u6743\u9650\u3002\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\u53ef\u4ee5\u521b\u5efa\u548c\u5220\u9664\u5176\u4ed6\u79df\u6237\uff08Accounts\uff09\uff0c\u7ba1\u7406\u79df\u6237\uff08Accounts\uff09\u3002\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\u4e0d\u80fd\u7ba1\u7406\u5176\u4ed6\u79df\u6237\uff08Accounts\uff09\u540d\u4e0b\u7684\u8d44\u6e90\u3002
\u8981\u4f7f\u7528 GRANT
\u6388\u4e88\u5176\u4ed6\u7528\u6237\u6216\u89d2\u8272\u6743\u9650\uff0c\u4f60\u9996\u5148\u5fc5\u987b\u5177\u6709 WITH GRANT OPTION
\u6743\u9650\uff0c\u5e76\u4e14\u4f60\u5fc5\u987b\u5177\u6709\u4f60\u6b63\u5728\u6388\u4e88\u7684\u6743\u9650\u3002\u4e86\u89e3\u4f60\u5f53\u524d\u89d2\u8272\u7684\u6388\u6743\u60c5\u51b5\u6216\u5176\u4ed6\u89d2\u8272\u7684\u6388\u6743\u60c5\u51b5\uff0c\u8bf7\u4f7f\u7528 SHOW GRANTS
\u8bed\u53e5\uff0c\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 SHOW GRANTS\u3002
REVOKE
\u8bed\u53e5\u4e0e GRANT
\u76f8\u5173\uff0c\u5141\u8bb8\u79df\u6237\u5220\u9664\u7528\u6237\u6743\u9650\u3002\u6709\u5173 REVOKE
\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605 REVOKE\u3002
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a\u96c6\u7fa4\u9ed8\u8ba4\u6709\u4e00\u4e2a root\uff0croot \u9996\u5148\u4f7f\u7528 CREATE ACCOUNT
\u521b\u5efa\u4e00\u4e2a\u65b0\u8d26\u6237\uff0c\u5e76\u5b9a\u4e49\u5b83\u7684\u975e\u7279\u6743\u6743\u9650\uff0c\u4f8b\u5982\u5b83\u7684\u5bc6\u7801\uff0c\u7136\u540e\u79df\u6237\u4f7f\u7528 CREATE USER
\u521b\u5efa\u7528\u6237\u5e76\u4f7f\u7528 GRANT
\u5bf9\u5176\u8d4b\u6743\u3002ALTER ACCOUNT
\u53ef\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u79df\u6237\u7684\u975e\u7279\u6743\u7279\u5f81\u3002REVOKE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u7528\u6237\u7684\u6743\u9650\u7279\u5f81\u3002\u5982\u9700\u4e86\u89e3 MatrixOne \u652f\u6301\u7684\u6743\u9650\u4ee5\u53ca\u4e0d\u540c\u5c42\u7ea7\u7684\u6743\u9650\uff0c\u8bf7\u53c2\u9605 MatrixOne \u6743\u9650\u5206\u7c7b\u3002
GRANT
\u5728\u6210\u529f\u6267\u884c\u540e\uff0c\u5f97\u5230\u7ed3\u679c Query OK, 0 rows affected
\u3002\u8981\u67e5\u770b\u64cd\u4f5c\u4ea7\u751f\u7684\u6743\u9650\uff0c\u8bf7\u4f7f\u7528 SHOW GRANTS
> GRANT\n priv_type [(column_list)]\n [, priv_type [(column_list)]] ...\n ON [object_type] priv_level\n TO user_or_role [, user_or_role] ...\n\nGRANT role [, role] ...\n TO user_or_role [, user_or_role] ...\n [WITH ADMIN OPTION]\n\nobject_type: {\n TABLE\n | FUNCTION\n | PROCEDURE\n}\n\npriv_level: {\n *\n | *.*\n | db_name.*\n | db_name.tbl_name\n | tbl_name\n | db_name.routine_name\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"GRANT
\u8bed\u53e5\u5141\u8bb8\u79df\u6237\uff08Accounts\uff09\u6388\u4e88\u6743\u9650\u548c\u89d2\u8272\uff0c\u8fd9\u4e9b\u6743\u9650\u548c\u89d2\u8272\u53ef\u4ee5\u6388\u4e88\u7528\u6237\u548c\u89d2\u8272\u3002\u8bed\u6cd5\u4f7f\u7528\u8bf4\u660e\u5982\u4e0b\uff1a
GRANT
\u4e0d\u80fd\u5728\u540c\u4e00\u8bed\u53e5\u4e2d\u540c\u65f6\u6388\u4e88\u6743\u9650\u548c\u89d2\u8272\u3002
ON
\u5b50\u53e5\u533a\u5206\u8bed\u53e5\u662f\u5426\u6388\u4e88\u6743\u9650\u6216\u89d2\u8272\uff1a
\u4f7f\u7528 ON
\uff0c\u8be5\u8bed\u53e5\u6388\u4e88\u6743\u9650\u3002
\u5982\u679c\u6ca1\u6709 ON
\uff0c\u5219\u8be5\u8bed\u53e5\u6388\u4e88\u89d2\u8272\u3002
\u5fc5\u987b\u4f7f\u7528\u5355\u72ec\u7684 GRANT
\u8bed\u53e5\u5c06\u6743\u9650\u548c\u89d2\u8272\u5206\u914d\u7ed9\u4e00\u4e2a\u7528\u6237\uff0c\u6bcf\u4e2a GRANT
\u8bed\u53e5\u7684\u8bed\u6cd5\u90fd\u4e0e\u8981\u6388\u4e88\u7684\u5185\u5bb9\u76f8\u9002\u5e94\u3002
\u6570\u636e\u5e93\u6743\u9650\u9002\u7528\u4e8e\u7ed9\u5b9a\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u5bf9\u8c61\u3002\u8981\u5206\u914d\u6570\u636e\u5e93\u7ea7\u6743\u9650\uff0c\u8bf7\u4f7f\u7528 ON db_name *
\u8bed\u6cd5\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
grant all on database * to role1;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_5","title":"\u8868\u6743\u9650","text":"\u8868\u6743\u9650\u9002\u7528\u4e8e\u7ed9\u5b9a\u8868\u4e2d\u7684\u6240\u6709\u5217\u3002\u8981\u5206\u914d\u8868\u7ea7\u6743\u9650\uff0c\u8bf7\u4f7f\u7528 ON db_name.tbl_name
\u8bed\u6cd5\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
grant all on table *.* to role1;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/grant/#_6","title":"\u6388\u6743\u89d2\u8272","text":"\u4e0d\u643a\u5e26 ON
\u5b50\u53e5\u7684 GRANT
\u8bed\u6cd5\u5c06\u8d4b\u6743\u7ed9\u89d2\u8272\uff0c\u800c\u4e0d\u662f\u8d4b\u6743\u7ed9\u4e2a\u4eba\u3002\u89d2\u8272\u662f\u6743\u9650\u7684\u547d\u540d\u96c6\u5408\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
grant role3 to role_user;\n
\u8981\u6388\u6743\u7ed9\u89d2\u8272\u6216\u8005\u8981\u6388\u6743\u7ed9\u7528\u6237\uff0c\u5fc5\u987b\u786e\u4fdd\u7528\u6237\u548c\u89d2\u8272\u90fd\u5b58\u5728\u3002
\u6388\u4e88\u89d2\u8272\u9700\u8981\u8fd9\u4e9b\u6743\u9650\uff1a
> drop user if exists user_prepare_01;\n> drop role if exists role_prepare_1;\n> create user user_prepare_01 identified by '123456';\n> create role role_prepare_1;\n> create database if not exists p_db;\n> grant create table ,drop table on database *.* to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant connect on account * to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant insert,select on table *.* to role_prepare_1;\nQuery OK, 0 rows affected (0.01 sec)\n\n> grant role_prepare_1 to user_prepare_01;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/","title":"REVOKE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5c06\u67d0\u4e2a\u7528\u6237\u6216\u8005\u89d2\u8272\u4e0a\u88ab\u8d4b\u4e88\u7684\u6743\u9650\u6536\u56de\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> REVOKE [IF EXISTS]\n priv_type [(column_list)]\n [, priv_type [(column_list)]] ...\n ON object_type priv_level\n\n> REVOKE [IF EXISTS] role [, role ] ...\n FROM user_or_role [, user_or_role ] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Control-Language/revoke/#_3","title":"\u793a\u4f8b","text":"> CREATE USER mouser IDENTIFIED BY '111';\nQuery OK, 0 rows affected (0.10 sec)\n\n> CREATE ROLE role_r1;\nQuery OK, 0 rows affected (0.05 sec)\n\n> GRANT role_r1 to mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> GRANT create table on database * to role_r1;\nQuery OK, 0 rows affected (0.03 sec)\n\n> SHOW GRANTS for mouser@localhost;\n+-------------------------------------------------------+\n| Grants for mouser@localhost |\n+-------------------------------------------------------+\n| GRANT create table ON database * `mouser`@`localhost` |\n| GRANT connect ON account `mouser`@`localhost` |\n+-------------------------------------------------------+\n2 rows in set (0.02 sec)\n\n> REVOKE role_r1 from mouser;\nQuery OK, 0 rows affected (0.04 sec)\n\n> SHOW GRANT for mouser@localhost;\n+------------------------------------------------+\n| Grants for mouser@localhost |\n+------------------------------------------------+\n| GRANT connect ON account `mouser`@`localhost` |\n+------------------------------------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/","title":"ALTER PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER PUBLICATION
\u4fee\u6539\u53d1\u5e03\u5185\u5bb9\u3002
ALTER PUBLICATION pubname \n [ACCOUNT \n { ALL\n | account_name, [, ... ]\n | ADD account_name, [, ... ]\n | DROP account_name, [, ... ]]\n [COMMENT 'string']\n [DATABASE database_name]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-publication/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nalter publication pub3 account add accx;--\u4fee\u6539\u53d1\u5e03\u8303\u56f4\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication |\n+-------------+-----------------------------------------------------------------------+\n| pub3 | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+----------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+----------------+----------+\n| pub3 | t | 2024-04-24 11:17:37 | 2024-04-24 11:17:44 | acc0,acc1,accx | |\n+-------------+----------+---------------------+---------------------+----------------+----------+\n1 row in set (0.01 sec)\n\nalter publication pub3 comment \"this is pubs\";--\u4fee\u6539\u53d1\u5e03\u5907\u6ce8\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| pub3 | t | 2024-04-24 11:17:37 | 2024-04-24 11:41:43 | acc0,acc1,accx | this is pubs |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n1 row in set (0.00 sec)\n\ncreate database new_pub3;\nalter publication pub3 database new_pub3;--\u4fee\u6539\u53d1\u5e03\u6570\u636e\u5e93\nmysql> show publications;\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n| pub3 | new_pub3 | 2024-04-24 11:17:37 | 2024-04-24 11:43:36 | acc0,acc1,accx | this is pubs |\n+-------------+----------+---------------------+---------------------+----------------+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-reindex/","title":"ALTER REINDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-reindex/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER TABLE ... ALTER REINDEX
\u7528\u4e8e\u5bf9\u5411\u91cf\u8868\u4e2d\u7684\u6570\u636e\u91cd\u65b0\u8fdb\u884c\u5206\u533a\u3002
\u5f53\u5411\u91cf\u8868\u5185\u7684\u6570\u636e\u8bb0\u5f55\u5927\u5e45\u589e\u957f\u65f6\uff0c\u539f\u6709\u7684\u805a\u7c7b\u4e2d\u5fc3\u96c6\u5408\u53ef\u80fd\u4e0d\u518d\u9002\u7528\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u5fc5\u987b\u5bf9\u6570\u636e\u91cd\u65b0\u8fdb\u884c\u7d22\u5f15\u5904\u7406\uff0c\u65e8\u5728\u8bc6\u522b\u51fa\u65b0\u7684\u805a\u7c7b\u4e2d\u5fc3\uff0c\u5e76\u636e\u6b64\u91cd\u65b0\u5212\u5206\u6570\u636e\u96c6\u3002
Note
\u5728\u91cd\u6784\u7d22\u5f15\u671f\u95f4\uff0c\u65e0\u6cd5\u5bf9\u8be5\u8868\u8fdb\u884c\u6570\u636e\u63d2\u5165\u64cd\u4f5c\u3002
LISTS \u7684\u7406\u60f3\u503c\u4e3a\uff1a
> ALTER TABLE table_name ALTER REINDEX index_name LISTS=XX\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-reindex/#_3","title":"\u793a\u4f8b","text":"SET GLOBAL experimental_ivf_index = 1;--\u9700\u8bbe\u7f6e\u53c2\u6570 experimental_ivf_index \u503c\u4e3a 1\uff08\u9ed8\u8ba4 0\uff09\u624d\u80fd\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\ndrop table if exists t1;\ncreate table t1(n1 int,n2 vecf32(3));\ninsert into t1 values(1,\"[1,2,3]\"),(2,\"[2,3,4]\"),(3,\"[3,4,5]\");\ncreate index idx_t1 using ivfflat on t1(n2) lists=2 op_type \"vector_l2_ops\";\n\nmysql> show create table t1;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`n1` INT DEFAULT NULL,\n`n2` VECF32(3) DEFAULT NULL,\nKEY `idx_t1` USING ivfflat (`n2`) lists = 2 op_type 'vector_l2_ops' ) |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show index from t1;\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Index_params | Visible | Expression |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| t1 | 1 | idx_t1 | 1 | n2 | A | 0 | NULL | NULL | YES | ivfflat | | | {\"lists\":\"2\",\"op_type\":\"vector_l2_ops\"} | YES | NULL |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n1 row in set (0.00 sec)\n\nmysql> alter table t1 alter reindex idx_t1 ivfflat lists=100;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> show create table t1;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`n1` INT DEFAULT NULL,\n`n2` VECF32(3) DEFAULT NULL,\nKEY `idx_t1` USING ivfflat (`n2`) lists = 100 op_type 'vector_l2_ops' ) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> show index from t1;\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-------------------------------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Index_params | Visible | Expression |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-------------------------------------------+---------+------------+\n| t1 | 1 | idx_t1 | 1 | n2 | A | 0 | NULL | NULL | YES | ivfflat | | | {\"lists\":\"100\",\"op_type\":\"vector_l2_ops\"} | YES | NULL |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-------------------------------------------+---------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-sequence/","title":"ALTER SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-sequence/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER SEQUENCE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u5e8f\u5217\u3002
> ALTER SEQUENCE [ IF EXISTS ] SEQUENCE_NAME\n[ AS data_type ]\n[ INCREMENT [ BY ] increment ]\n[ MINVALUE minvalue] [ MAXVALUE maxvalue]\n[ START [ WITH ] start ] [ [ NO ] CYCLE ]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-sequence/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"[ IF EXISTS ]
\uff1a\u53ef\u9009\u7684\u5b50\u53e5\uff0c\u8868\u793a\u5982\u679c\u6307\u5b9a\u7684\u5e8f\u5217\u4e0d\u5b58\u5728\uff0c\u4e5f\u4e0d\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\u5982\u679c\u4f7f\u7528\u4e86\u6b64\u5b50\u53e5\uff0c\u7cfb\u7edf\u5c06\u68c0\u67e5\u5e8f\u5217\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5c06\u5ffd\u7565\u4fee\u6539\u8bf7\u6c42\u3002
SEQUENCE_NAME
\uff1a\u8981\u4fee\u6539\u7684\u5e8f\u5217\u7684\u540d\u79f0\u3002
[ AS data_type ]
\uff1a\u53ef\u9009\u5b50\u53e5\uff0c\u5b83\u5141\u8bb8\u60a8\u4e3a\u5e8f\u5217\u6307\u5b9a\u6570\u636e\u7c7b\u578b\u3002\u901a\u5e38\uff0c\u5e8f\u5217\u7684\u6570\u636e\u7c7b\u578b\u662f\u6574\u6570\u3002
[ INCREMENT [ BY ] increment ]
\uff1a\u8fd9\u662f\u6307\u5b9a\u5e8f\u5217\u7684\u589e\u91cf\u503c\u3002\u5e8f\u5217\u7684\u589e\u91cf\u503c\u662f\u5728\u6bcf\u6b21\u9012\u589e\u6216\u9012\u51cf\u65f6\u8981\u6dfb\u52a0\u5230\u5f53\u524d\u503c\u7684\u6570\u91cf\u3002\u5982\u679c\u672a\u6307\u5b9a\u589e\u91cf\u503c\uff0c\u901a\u5e38\u9ed8\u8ba4\u4e3a 1\u3002
[ MINVALUE minvalue ]
\uff1a\u8fd9\u662f\u5e8f\u5217\u7684\u6700\u5c0f\u503c\uff0c\u5b83\u6307\u5b9a\u4e86\u5e8f\u5217\u5141\u8bb8\u7684\u6700\u5c0f\u503c\u3002\u5982\u679c\u6307\u5b9a\u4e86\u6700\u5c0f\u503c\uff0c\u5e8f\u5217\u7684\u5f53\u524d\u503c\u4e0d\u80fd\u4f4e\u4e8e\u6b64\u503c\u3002
[ MAXVALUE maxvalue ]
\uff1a\u8fd9\u662f\u5e8f\u5217\u7684\u6700\u5927\u503c\uff0c\u5b83\u6307\u5b9a\u4e86\u5e8f\u5217\u5141\u8bb8\u7684\u6700\u5927\u503c\u3002\u5982\u679c\u6307\u5b9a\u4e86\u6700\u5927\u503c\uff0c\u5e8f\u5217\u7684\u5f53\u524d\u503c\u4e0d\u80fd\u8d85\u8fc7\u6b64\u503c\u3002
[ START [ WITH ] start ]
\uff1a\u8fd9\u662f\u5e8f\u5217\u7684\u8d77\u59cb\u503c\uff0c\u5b83\u6307\u5b9a\u5e8f\u5217\u7684\u521d\u59cb\u503c\u3002\u5982\u679c\u672a\u6307\u5b9a\u8d77\u59cb\u503c\uff0c\u901a\u5e38\u9ed8\u8ba4\u4e3a 1\u3002
[ [ NO ] CYCLE ]
\uff1a\u53ef\u9009\u5b50\u53e5\uff0c\u7528\u4e8e\u6307\u5b9a\u662f\u5426\u5faa\u73af\u4f7f\u7528\u5e8f\u5217\u503c\u3002\u5982\u679c\u6307\u5b9a\u4e86 NO CYCLE
\uff0c\u5219\u5728\u8fbe\u5230\u6700\u5927\u503c\u6216\u6700\u5c0f\u503c\u540e\uff0c\u5e8f\u5217\u5c06\u505c\u6b62\u9012\u589e\u6216\u9012\u51cf\u3002\u5982\u679c\u672a\u6307\u5b9a\u6b64\u5b50\u53e5\uff0c\u901a\u5e38\u9ed8\u8ba4\u4e3a\u4e0d\u5faa\u73af\u3002
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a alter_seq_01 \u7684\u5e8f\u5217\uff0c\u5c06\u5e8f\u5217\u7684\u589e\u91cf\u8bbe\u7f6e\u4e3a 2\uff0c\u8bbe\u7f6e\u5e8f\u5217\u7684\u6700\u5c0f\u503c\u4e3a 30\uff0c\u6700\u5927\u503c\u4e3a 100\uff0c\u5e76\u542f\u7528\u5faa\u73af\ncreate sequence alter_seq_01 as smallint increment by 2 minvalue 30 maxvalue 100 cycle;\n\nmysql> show sequences;\n+--------------+-----------+\n| Names | Data Type |\n+--------------+-----------+\n| alter_seq_01 | SMALLINT |\n+--------------+-----------+\n1 row in set (0.00 sec)\n\nmysql> alter sequence alter_seq_01 as bigint;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show sequences;\n+--------------+-----------+\n| Names | Data Type |\n+--------------+-----------+\n| alter_seq_01 | BIGINT |\n+--------------+-----------+\n1 row in set (0.00 sec)\n\n-- \u53d6\u6d88\u5e8f\u5217 alter_seq_01 \u7684\u5faa\u73af\nmysql> alter sequence alter_seq_01 no cycle;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 30 | 30 |\n+-----------------------+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 32 | 32 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\n-- \u5c06\u5e8f\u5217 alter_seq_01 \u7684\u8d77\u59cb\u503c\u8bbe\u7f6e\u4e3a 40\nmysql> alter sequence alter_seq_01 start with 40;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 40 | 40 |\n+-----------------------+-----------------------+\n1 row in set (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 42 | 42 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\n-- \u5c06\u5e8f\u5217 alter_seq_01 \u7684\u589e\u91cf\u503c\u8bbe\u7f6e\u4e3a 3\nmysql> alter sequence alter_seq_01 increment by 3;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 40 | 40 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n\nmysql> select nextval('alter_seq_01'),currval('alter_seq_01');\n+-----------------------+-----------------------+\n| nextval(alter_seq_01) | currval(alter_seq_01) |\n+-----------------------+-----------------------+\n| 43 | 43 |\n+-----------------------+-----------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/","title":"ALTER STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER STAGE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u5df2\u547d\u540d\u7684\u5185\u90e8\u6216\u5916\u90e8\u9636\u6bb5\u7684\u5c5e\u6027\u3002
Note
\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u5373 root \u7528\u6237\uff09\u548c\u79df\u6237\u7ba1\u7406\u5458\u53ef\u4ee5\u4fee\u6539\u6570\u636e\u9636\u6bb5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> ALTER STAGE [ IF EXISTS ] { stage_name }\n { StageParams }\n [ directoryTableParams ]\n [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-stage/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"IF EXISTS
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u5728\u4fee\u6539 Stage \u65f6\u68c0\u67e5\u662f\u5426\u5df2\u5b58\u5728\u8981\u4fee\u6539\u7684 Stage\u3002
stage_name
\uff1a\u8981\u4fee\u6539\u7684 Stage \u7684\u540d\u79f0\u3002
StageParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u914d\u7f6e\u53c2\u6570\u3002
endpoint
\uff1aStage \u7684\u8fde\u63a5 URL\uff0c\u6307\u5b9a\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684\u4f4d\u7f6e\u3002\u5bf9\u4e8e\u4e0d\u540c\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff08\u5982 Amazon S3\u3001Aliyun OSS\u3001\u6587\u4ef6\u7cfb\u7edf\u7b49\uff09\uff0c\u8fd9\u4e2a URL \u7684\u5185\u5bb9\u53ef\u80fd\u6709\u6240\u4e0d\u540c\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com
CREDENTIALS
\uff1a\u8fd9\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\uff0c\u5305\u542b\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u6240\u9700\u7684\u51ed\u8bc1\u4fe1\u606f\uff0c\u5982 access_key_id
\u3001secret_access_key
\u7b49\u3002
directoryTableParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u76ee\u5f55\u8868\uff08directory table\uff09\u7684\u914d\u7f6e\u3002
ENABLE
\uff1a\u662f\u5426\u4fee\u6539\u542f\u7528\u76ee\u5f55\u8868\uff0c\u503c\u4e3a TRUE
\u6216 FALSE
\u3002CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL | STATUS | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1 | /Users/Prinz/03testrepo/csv | ENABLED | |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.01 sec)\n\n-- \u4fee\u6539 stage\nmysql> ALTER STAGE stage1 SET COMMENT 'user stage';\n\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+------------+\n| STAGE_NAME | URL | STATUS | COMMENT |\n+------------+-----------------------------+---------+------------+\n| stage1 | /Users/Prinz/03testrepo/csv | ENABLED | user stage |\n+------------+-----------------------------+---------+------------+\n1 row in set (0.00 sec)\n\n-- \u7981\u7528\u540d\u4e3a 'stage1' \u7684\u6570\u636e\u9636\u6bb5\nmysql> ALTER STAGE stage1 SET ENABLE = FALSE;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- \u5c1d\u8bd5\u5c06 user \u8868\u7684\u6570\u636e\u5bfc\u51fa\u5230\u540d\u4e3a 'stage1:/user.csv' \u7684\u6570\u636e\u9636\u6bb5\u4e2d\uff0c\u4f46 stage1 \u5df2\u7ecf\u88ab\u7981\u7528\uff0c\u6240\u4ee5\u5df2\u4e0d\u53ef\u7528\uff0c\u4ea7\u751f\u62a5\u9519\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is invalid, please check\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/","title":"ALTER TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"ALTER TABLE
\u7528\u4e8e\u4fee\u6539\u73b0\u6709\u6570\u636e\u8868\u7ed3\u6784\u3002
ALTER TABLE tbl_name\n [alter_option [, alter_option] ...]\n\nalter_option: {\n table_options\n | ADD [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | ADD [COLUMN] (col_name column_definition,...)\n | ADD {[INDEX | KEY] [index_name]\n [index_option] ...\n | ADD [CONSTRAINT] UNIQUE [INDEX | KEY]\n [index_name][index_option] ...\n | ADD [CONSTRAINT] FOREIGN KEY\n [index_name] (col_name,...)\n reference_definition\n | ADD [CONSTRAINT [symbol]] PRIMARY KEY\n [index_type] (key_part,...)\n | CHANGE [COLUMN] old_col_name new_col_name column_definition\n [FIRST | AFTER col_name]\n | ALTER INDEX index_name {VISIBLE | INVISIBLE}\n | DROP [COLUMN] col_name\n | DROP {INDEX | KEY} index_name\n | DROP FOREIGN KEY fk_symbol\n | DROP PRIMARY KEY\n | RENAME [TO | AS] new_tbl_name\n | MODIFY [COLUMN] col_name column_definition\n [FIRST | AFTER col_name]\n | RENAME COLUMN old_col_name TO new_col_name\n }\n\nkey_part: {col_name [(length)] | (expr)} [ASC | DESC]\nindex_option: {\n COMMENT[=]'string'\n}\ntable_options:\n table_option [[,] table_option] ...\ntable_option: {\n COMMENT [=] 'string'\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"\u4e0b\u9762\u662f\u5404\u4e2a\u53c2\u6570\u7684\u91ca\u4e49\uff1a
ALTER TABLE tbl_name
\uff1a\u8868\u793a\u4fee\u6539\u540d\u4e3a tbl_name
\u7684\u8868\u3002alter_option
\uff1a\u8868\u793a\u53ef\u4ee5\u6267\u884c\u4e00\u4e2a\u6216\u591a\u4e2a\u66f4\u6539\u9009\u9879\uff0c\u7528\u9017\u53f7\u5206\u9694\u3002
table_options
\uff1a\u7528\u4e8e\u8bbe\u7f6e\u6216\u4fee\u6539\u8868\u7684\u9009\u9879\uff0c\u4f8b\u5982\u8868\u7684\u6ce8\u91ca\uff08COMMENT\uff09\u3002ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name]
\uff1a\u5728\u8868\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u65b0\u5217\uff0c\u53ef\u4ee5\u6307\u5b9a\u65b0\u5217\u63d2\u5165\u7684\u4f4d\u7f6e\uff08\u5728\u67d0\u5217\u4e4b\u524d\u6216\u4e4b\u540e\uff09\u3002ADD [COLUMN] (col_name column_definition,...)
\uff1a\u540c\u65f6\u6dfb\u52a0\u591a\u4e2a\u65b0\u5217\u3002ADD {[INDEX | KEY] [index_name] [index_option] ...
\uff1a\u6dfb\u52a0\u4e00\u4e2a\u7d22\u5f15\uff0c\u53ef\u4ee5\u6307\u5b9a\u7d22\u5f15\u540d\u548c\u7d22\u5f15\u9009\u9879\uff08\u4f8b\u5982\uff0c\u6ce8\u91ca\uff09\u3002ADD [CONSTRAINT] UNIQUE [INDEX | KEY] [index_name][index_option] ...
\uff1a\u6dfb\u52a0\u4e00\u4e2a UNIQUE \u7ea6\u675f\u6216 UNIQUE \u7d22\u5f15\u3002ADD [CONSTRAINT] FOREIGN KEY [index_name] (col_name,...) reference_definition
\uff1a\u6dfb\u52a0\u4e00\u4e2a FOREIGN KEY \u7ea6\u675f\u3002ADD [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (key_part,...)
\uff1a\u6dfb\u52a0\u4e3b\u952e\u7ea6\u675f\u3002CHANGE [COLUMN] old_col_name new_col_name column_definition [FIRST | AFTER col_name]
\uff1a\u4fee\u6539\u5217\u5b9a\u4e49\u3001\u5217\u540d\u4e0e\u987a\u5e8f\u3002ALTER INDEX index_name {VISIBLE | INVISIBLE}
\uff1a\u66f4\u6539\u7d22\u5f15\u7684\u53ef\u89c1\u6027\u3002DROP [COLUMN] col_name
\uff1a\u5220\u9664\u4e00\u4e2a\u5217\u3002DROP {INDEX | KEY} index_name
\uff1a\u5220\u9664\u4e00\u4e2a\u7d22\u5f15\u3002DROP FOREIGN KEY fk_symbol
\uff1a\u5220\u9664\u4e00\u4e2a FOREIGN KEY \u7ea6\u675f\u3002DROP PRIMARY KEY
\uff1a\u5220\u9664\u4e3b\u952e\u3002RENAME [TO | AS] new_tbl_name
\uff1a\u91cd\u547d\u540d\u6574\u4e2a\u8868\u3002MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name]
\uff1a\u4fee\u6539\u5217\u5b9a\u4e49\u4e0e\u987a\u5e8f\u3002RENAME COLUMN old_col_name TO new_col_name
\uff1a\u91cd\u547d\u540d\u5217\u3002key_part
\uff1a\u8868\u793a\u7d22\u5f15\u7684\u7ec4\u6210\u90e8\u5206\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u540d\uff08\u5728\u521b\u5efa\u4e00\u4e2a\u6587\u672c\u5217\u7684\u7d22\u5f15\u65f6\uff0c\u4f60\u53ef\u4ee5\u4e3a\u7d22\u5f15\u6307\u5b9a\u4e00\u4e2a\u957f\u5ea6\uff0c\u5b57\u7b26\u957f\u5ea6\u53ef\u53d8\u3002\u5982\u679c\u60a8\u5728\u521b\u5efa\u7d22\u5f15\u65f6\u4f7f\u7528\u5217\u540d\u4e14\u4e0d\u6307\u5b9a\u957f\u5ea6\uff0c\u7d22\u5f15\u5c06\u4f1a\u4f7f\u7528\u6574\u4e2a\u5217\u7684\u503c\u4f5c\u4e3a\u7d22\u5f15\u7ec4\u6210\u90e8\u5206\u3002\u8fd9\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u5bfc\u81f4\u6027\u80fd\u964d\u4f4e\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u8f83\u5927\u6587\u672c\u5217\u6216\u4e8c\u8fdb\u5236\u6570\u636e\u5217\u65f6\u3002\u5bf9\u4e8e\u8f83\u5c0f\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4f8b\u5982\u6574\u6570\u6216\u65e5\u671f\uff0c\u901a\u5e38\u4e0d\u9700\u8981\u6307\u5b9a\u957f\u5ea6\uff09\u3002
index_option
\uff1a\u8868\u793a\u7d22\u5f15\u7684\u9009\u9879\uff0c\u4f8b\u5982\u6ce8\u91ca\uff08COMMENT\uff09\u3002table_options
\uff1a\u8868\u793a\u8868\u7684\u9009\u9879\uff0c\u5982\u8868\u7684\u6ce8\u91ca\uff08COMMENT\uff09\u3002table_option
\uff1a\u5177\u4f53\u7684\u8868\u9009\u9879\uff0c\u4f8b\u5982\u6ce8\u91ca\uff08COMMENT\uff09\u3002-- \u521b\u5efa f1 \u8868\uff0c\u5305\u542b\u4e24\u4e2a\u6574\u6570\u5217\uff1afa\uff08\u4e3b\u952e\uff09\u548c fb\uff08\u5177\u6709\u552f\u4e00\u7ea6\u675f\u7684\u952e\uff09\nCREATE TABLE f1(fa INT PRIMARY KEY, fb INT UNIQUE KEY);\n-- \u521b\u5efa c1 \u8868\uff0c\u5305\u542b\u4e24\u4e2a\u6574\u6570\u5217\uff1aca \u548c cb\nCREATE TABLE c1 (ca INT, cb INT);\n-- \u4e3a c1 \u8868\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a ffa \u7684\u5916\u952e\u7ea6\u675f\uff0c\u5c06 c1 \u8868\u7684 ca \u5217\u4e0e f1 \u8868\u7684 fa \u5217\u76f8\u5173\u8054\nALTER TABLE c1 ADD CONSTRAINT ffa FOREIGN KEY (ca) REFERENCES f1(fa);\n-- \u5411 f1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(2, 2)\nINSERT INTO f1 VALUES (2, 2);\n-- \u5411 c1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- \u5411 c1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(2, 2)\nINSERT INTO c1 VALUES (2, 2);\n-- \u4ece c1 \u8868\u4e2d\u9009\u62e9\u6240\u6709\u8bb0\u5f55\uff0c\u5e76\u6309 ca \u5217\u6392\u5e8f\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca | cb |\n+------+------+\n| 2 | 2 |\n+------+------+\n1 row in set (0.01 sec)\n-- \u4ece c1 \u8868\u4e2d\u5220\u9664\u540d\u4e3a ffa \u7684\u5916\u952e\u7ea6\u675f\nALTER TABLE c1 DROP FOREIGN KEY ffa;\n-- \u5411 c1 \u8868\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a(1, 1)\nINSERT INTO c1 VALUES (1, 1);\n-- \u4ece c1 \u8868\u4e2d\u9009\u62e9\u6240\u6709\u8bb0\u5f55\uff0c\u5e76\u6309 ca \u5217\u6392\u5e8f\nmysql> select ca, cb from c1 order by ca;\n+------+------+\n| ca | cb |\n+------+------+\n| 1 | 1 |\n| 2 | 2 |\n+------+------+\n2 rows in set (0.01 sec)\n
-- \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a 't1' \u7684\u65b0\u8868\uff0c\u5305\u542b\u5217 a\u3001b\u3001c \u548c d\u3002\u5217 'a' \u7684\u6570\u636e\u7c7b\u578b\u4e3a INTEGER\uff0c'b' \u7684\u6570\u636e\u7c7b\u578b\u4e3a CHAR(10)\uff0c'c' \u7684\u6570\u636e\u7c7b\u578b\u4e3a DATE\uff0c'd' \u7684\u6570\u636e\u7c7b\u578b\u4e3a DECIMAL(7,2)\u3002\u5728\u5217 'a' \u548c 'b' \u4e0a\u6dfb\u52a0\u4e86\u4e00\u4e2a\u552f\u4e00\u952e\u3002\nCREATE TABLE t1(a INTEGER, b CHAR(10), c DATE, d DECIMAL(7,2), UNIQUE KEY(a, b));\n\n-- \u67e5\u770b\u8868 't1' \u7684\u7ed3\u6784\u3002\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | NULL | | |\n| b | CHAR(10) | YES | | NULL | | |\n| c | DATE(0) | YES | | NULL | | |\n| d | DECIMAL64(7) | YES | | NULL | | |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- \u5411\u8868 't1' \u63d2\u5165\u4e09\u884c\u6570\u636e\u3002\nINSERT INTO t1 VALUES(1, 'ab', '1980-12-17', 800);\nINSERT INTO t1 VALUES(2, 'ac', '1981-02-20', 1600);\nINSERT INTO t1 VALUES(3, 'ad', '1981-02-22', 500);\n\n-- \u663e\u793a\u8868 't1' \u4e2d\u7684\u6240\u6709\u884c\u3002\nmysql> select * from t1;\n+------+------+------------+---------+\n| a | b | c | d |\n+------+------+------------+---------+\n| 1 | ab | 1980-12-17 | 800.00 |\n| 2 | ac | 1981-02-20 | 1600.00 |\n| 3 | ad | 1981-02-22 | 500.00 |\n+------+------+------------+---------+\n3 rows in set (0.01 sec)\n\n-- \u4fee\u6539\u8868 't1'\uff0c\u5728\u5217 'a' \u548c 'b' \u4e0a\u6dfb\u52a0\u4e3b\u952e 'pk1'\u3002\nmysql> alter table t1 add primary key pk1(a, b);\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u518d\u6b21\u67e5\u770b\u4fee\u6539\u540e\u7684\u8868 't1' \u7684\u7ed3\u6784\u3002\nmysql> desc t1;\n+-------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+--------------+------+------+---------+-------+---------+\n| a | INT(32) | NO | PRI | null | | |\n| b | CHAR(10) | NO | PRI | null | | |\n| c | DATE(0) | YES | | null | | |\n| d | DECIMAL64(7) | YES | | null | | |\n+-------+--------------+------+------+---------+-------+---------+\n4 rows in set (0.01 sec)\n\n-- \u6dfb\u52a0\u4e3b\u952e\u540e\uff0c\u518d\u6b21\u663e\u793a\u8868 't1' \u4e2d\u7684\u6240\u6709\u884c\u3002\nmysql> select * from t1;\n+------+------+------------+---------+\n| a | b | c | d |\n+------+------+------------+---------+\n| 1 | ab | 1980-12-17 | 800.00 |\n| 2 | ac | 1981-02-20 | 1600.00 |\n| 3 | ad | 1981-02-22 | 500.00 |\n+------+------+------------+---------+\n3 rows in set (0.00 sec)\n
CREATE TABLE t1 (a INTEGER PRIMARY KEY, b CHAR(10));\nmysql> desc t1;\n+-------+----------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+----------+------+------+---------+-------+---------+\n| a | INT(32) | NO | PRI | NULL | | |\n| b | CHAR(10) | YES | | NULL | | |\n+-------+----------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\ninsert into t1 values(1, 'ab');\ninsert into t1 values(2, 'ac');\ninsert into t1 values(3, 'ad');\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | ab |\n| 2 | ac |\n| 3 | ad |\n+------+------+\n3 rows in set (0.01 sec)\n\n-- \u4fee\u6539\u8868 't1'\uff0c\u5c06\u5217 'a' \u7684\u540d\u79f0\u6539\u4e3a 'x'\uff0c\u5e76\u5c06\u6570\u636e\u7c7b\u578b\u4fee\u6539\u4e3a VARCHAR(20)\u3002\nmysql> alter table t1 change a x VARCHAR(20);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> desc t1;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| x | VARCHAR(20) | NO | PRI | null | | |\n| b | CHAR(10) | YES | | null | | |\n+-------+-------------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t1;\n+------+------+\n| x | b |\n+------+------+\n| 1 | ab |\n| 2 | ac |\n| 3 | ad |\n+------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-table/#_5","title":"\u9650\u5236","text":"CHANGE [COLUMN]
\uff0cMODIFY [COLUMN]
\uff0cRENAME COLUMN
\uff0cADD [CONSTRAINT [symbol]] PRIMARY KEY
\uff0cDROP PRIMARY KEY
\u548c ALTER COLUMN ORDER BY
\u53ef\u4ee5\u5728 ALTER TABLE \u8bed\u53e5\u4e2d\u81ea\u7531\u7ec4\u5408\u4f7f\u7528\uff0c\u4f46\u6682\u65f6\u4e0d\u652f\u6301\u4e0e\u5176\u4ed6\u5b50\u53e5\u4e00\u8d77\u4f7f\u7528\u3002ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002CREATE TABLE ... CLUSTER BY...
\u6240\u5efa\u7684\u8868\uff0c\u4e0d\u652f\u6301\u4f7f\u7528 ALTER TABLE
\u4fee\u6539\u8868\u7ed3\u6784\u3002ALTER VIEW
\u7528\u4e8e\u66f4\u6539\u89c6\u56fe\u3002
\u5982\u679c\u8bed\u6cd5\u53c2\u6570\u5217\u8868\u4e2d\u547d\u540d\u7684\u89c6\u56fe\u4e0d\u5b58\u5728\uff0c\u5219\u8bed\u53e5\u62a5\u9519\uff1a\u8be5\u89c6\u56fe\u65e0\u6548\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> ALTER VIEW view_name [(column_list)]\n AS select_statement\n [WITH [CASCADED | LOCAL] CHECK OPTION]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/alter-view/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1),(2),(3),(4);\ncreate view v5 as select * from t1;\n\nmysql> select * from v5;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n4 rows in set (0.01 sec)\n\nalter view v5 as select * from t1 where a=1;\n\nmysql> select * from v5;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n\nalter view v5 as select * from t1 where a > 2;\n\nmysql> select * from v5;\n+------+\n| a |\n+------+\n| 3 |\n| 4 |\n+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/","title":"CREATE CLUSTER TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u96c6\u7fa4\u8868\u662f\u6307\u5728\u7cfb\u7edf\u79df\u6237\u4e0b\u7684\u7cfb\u7edf\u5e93 mo_catalog
\u521b\u5efa\u7684\u8868\uff0c\u8be5\u8868\u4f1a\u5728\u5176\u5b83\u79df\u6237\u4e0b\u540c\u65f6\u751f\u6548\u3002\u7cfb\u7edf\u79df\u6237\u4e0b\u53ef\u5bf9\u8be5\u8868\u8fdb\u884c DDL \u4e0e DML \u64cd\u4f5c\uff0c\u5176\u5b83\u79df\u6237\u53ea\u80fd\u8fdb\u884c\u67e5\u8be2\u6216\u57fa\u4e8e\u8be5\u8868\u521b\u5efa\u89c6\u56fe\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u8bb2\u8ff0\u5982\u4f55\u5728 MatrixOne \u6570\u636e\u5e93\u5efa\u7acb\u96c6\u7fa4\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE CLUSTER TABLE [IF NOT EXISTS] tbl_name\n (create_definition,...)\n [table_options]\n [partition_options]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-cluster-table/#_3","title":"\u4f7f\u7528\u8bf4\u660e","text":"\u521b\u5efa\u96c6\u7fa4\u8868\u4ec5\u9650\u4e8e sys \u79df\u6237\u7ba1\u7406\u5458\u89d2\u8272\u624d\u80fd\u521b\u5efa\u3002
sys \u79df\u6237\u7684\u96c6\u7fa4\u8868\u5305\u542b\u6240\u6709\u6570\u636e\uff0c\u5176\u5b83\u79df\u6237\u4e0b\u53ef\u80fd\u53ea\u4f1a\u770b\u5230\u90e8\u5206\u6570\u636e\u3002
\u5728\u96c6\u7fa4\u8868\u4e2d\uff0caccount_id
\u5b57\u6bb5\u662f\u81ea\u52a8\u751f\u6210\u7684\uff0c\u8868\u793a\u5728\u63d2\u5165\u6216 LOAD DATA \u65f6\u6307\u5b9a\u6570\u636e\u7684\u53ef\u89c1\u79df\u6237\u7684 id\uff0c\u6bcf\u6761\u6570\u636e\u53ea\u80fd\u9009\u62e9\u4e00\u4e2a\u53ef\u89c1\u79df\u6237\uff0c\u82e5\u60a8\u60f3\u591a\u4e2a\u79df\u6237\u90fd\u80fd\u67e5\u770b\u8be5\u6570\u636e\uff0c\u9700\u8981\u591a\u6b21\u63d2\u5165\u6307\u5b9a\u4e0d\u540c\u79df\u6237 id\uff0c\u8be5\u5b57\u6bb5\u6570\u636e\u5728\u5176\u5b83\u79df\u6237\u4e2d\u67e5\u8be2\u4e0d\u4f1a\u8fd4\u56de\u3002
\u96c6\u7fa4\u8868\u4e0d\u80fd\u4e3a\u5916\u8868\u6216\u4e34\u65f6\u8868\uff0c\u5728\u6240\u6709\u79df\u6237\u4e0b\u7684\u8868\u7ed3\u6784\u5b8c\u5168\u76f8\u540c\u3002
--\u521b\u5efa\u4e24\u4e2a\u79df\u6237 test1 \u548c test2\nmysql> create account test1 admin_name = 'root' identified by '111' open comment 'tenant_test';\nQuery OK, 0 rows affected (0.44 sec)\n\nmysql> create account test2 admin_name = 'root' identified by '111' open comment 'tenant_test';\nQuery OK, 0 rows affected (0.51 sec)\n\n--\u5728 sys \u79df\u6237\u4e0b\u521b\u5efa\u96c6\u7fa4\u8868\nmysql> use mo_catalog;\nDatabase changed\nmysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> create cluster table t1(a int);\nQuery OK, 0 rows affected (0.01 sec)\n\n--\u67e5\u770b\u79df\u6237 id\nmysql> select * from mo_account;\n+------------+--------------+--------+---------------------+----------------+---------+----------------+\n| account_id | account_name | status | created_time | comments | version | suspended_time |\n+------------+--------------+--------+---------------------+----------------+---------+----------------+\n| 0 | sys | open | 2024-01-11 08:56:57 | system account | 1 | NULL |\n| 6 | test1 | open | 2024-01-15 03:15:40 | tenant_test | 7 | NULL |\n| 7 | test2 | open | 2024-01-15 03:15:48 | tenant_test | 8 | NULL |\n+------------+--------------+--------+---------------------+----------------+---------+----------------+\n3 rows in set (0.01 sec)\n\n--\u5728\u96c6\u7fa4\u8868 t1 \u4e2d\u63d2\u5165\u6570\u636e\u53ea\u5bf9 test1 \u79df\u6237\u53ef\u89c1\nmysql> insert into t1 values(1,6),(2,6),(3,6);\nQuery OK, 3 rows affected (0.01 sec)\n\n--\u5728 sys \u79df\u6237\u4e2d\u67e5\u770b t1 \u7684\u6570\u636e\uff0c\u53ef\u770b\u5230\u5305\u542b`account_id`\u5b57\u6bb5\u5728\u5185\u7684\u6240\u6709\u6570\u636e\nmysql> select * from t1;\n+------+------------+\n| a | account_id |\n+------+------------+\n| 1 | 6 |\n| 2 | 6 |\n| 3 | 6 |\n+------+------------+\n3 rows in set (0.00 sec)\n\n--\u5728 test1 \u79df\u6237\u4e2d\u67e5\u770b t1 \u7684\u6570\u636e\uff0c\u53ef\u4ee5\u770b\u5230\u975e`account_id`\u5b57\u6bb5\u7684\u6570\u636e\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.01 sec)\n\n--\u5728 test2 \u79df\u6237\u4e2d\u67e5\u770b t1 \u7684\u6570\u636e\uff0c\u4e0d\u4f1a\u770b\u5230\u6709\u6570\u636e\nmysql> select * from t1;\nEmpty set (0.01 sec)\n\n--\u5728 test1 \u79df\u6237\u4e2d\u521b\u5efa\u57fa\u4e8e t1 \u7684\u89c6\u56fe\nmysql> create view t1_view as select * from mo_catalog.t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select * from t1_view;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.00 sec)\n\n--\u5728 test2 \u79df\u6237\u4e2d\u521b\u5efa\u57fa\u4e8e t1 \u7684\u89c6\u56fe\nmysql> create view t1_view as select * from mo_catalog.t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select * from t1_view;\nEmpty set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/","title":"CREATE DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE DATABASE
\u8bed\u53e5\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u3002
> CREATE DATABASE [IF NOT EXISTS] <database_name> [create_option] ...\n\n> create_option: [DEFAULT] {\n CHARACTER SET [=] charset_name\n | COLLATE [=] collation_name\n | ENCRYPTION [=] {'Y' | 'N'}\n}\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#_3","title":"\u793a\u4f8b","text":"CREATE DATABASE IF NOT EXISTS test01;\n
\u9884\u671f\u7ed3\u679c
\u4f60\u53ef\u4ee5\u4f7f\u7528 SHOW DATABASES
\u68c0\u67e5\u6570\u636e\u5e93\u662f\u5426\u5df2\u521b\u5efa\u3002
mysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| mo_task |\n| information_schema |\n| mysql |\n| system_metrics |\n| system |\n| test01 |\n| mo_catalog |\n+--------------------+\n10 rows in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u9664\u4e86\u5df2\u5b58\u5728\u7684 6 \u4e2a\u7cfb\u7edf\u6570\u636e\u5e93\u4ee5\u5916\uff0c\u65b0\u7684\u6570\u636e\u5e93 test01 \u5df2\u7ecf\u521b\u5efa\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-database/#_4","title":"\u9650\u5236","text":"UTF-8
\u5b57\u7b26\u96c6\u3002CHARACTER SET
\uff0cCOLLATE
\uff0cENCRYPTION
\u76ee\u524d\u53ef\u4ee5\u4f7f\u7528\u4f46\u65e0\u6cd5\u751f\u6548\u3002CREATE DYNAMIC TABLE
\u5c06\u4e00\u4e2a\u65b0\u7684\u52a8\u6001\u8868\u6dfb\u52a0\u5230\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u3002
CREATE DYNAMIC TABLE [IF NOT EXISTS] table_name AS SELECT ... from stream_name ;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-dynamic-table/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create dynamic table dt_test as select * from stream_test;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-dynamic-table/#_5","title":"\u9650\u5236","text":"\u521b\u5efa\u52a8\u6001\u8868\u65f6\u6682\u4e0d\u652f\u6301\u4f7f\u7528\u805a\u96c6\u51fd\u6570\u3001\u6570\u5b66\u51fd\u6570\u3001\u5b57\u7b26\u4e32\u51fd\u6570\u3001\u65e5\u671f\u51fd\u6570\u4ee5\u53ca limit\u3001offset
\u3001from subquery
\u3001not in/in subquery
\u3001group by
\u3001order by``\u3001having
\u8bed\u53e5\u3002
\u521b\u5efa\u52a8\u6001\u8868\u65f6\u6682\u4e0d\u652f\u6301\u5bf9\u4e24\u4e2a SOURCE \u8868\u7684 join\u3001\u53ef\u4ee5 join SOURCE \u8868\u548c\u666e\u901a\u6570\u636e\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/","title":"CREATE EXTERNAL TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5916\u90e8\u8868\u662f\u6307\u4e0d\u5728\u6570\u636e\u5e93\u91cc\u7684\u8868\uff0c\u662f\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u7684\u4e00\u4e2a\u6309\u7167\u4e00\u5b9a\u683c\u5f0f\u5206\u5272\u7684\u6587\u672c\u6587\u4ef6\uff0c\u6216\u662f\u5176\u4ed6\u7c7b\u578b\u7684\u8868\uff0c\u5bf9 MatrixOne \u6765\u8bf4\u7c7b\u4f3c\u4e8e\u89c6\u56fe\uff0c\u53ef\u4ee5\u5728\u6570\u636e\u5e93\u4e2d\u50cf\u89c6\u56fe\u4e00\u6837\u8fdb\u884c\u67e5\u8be2\u7b49\u64cd\u4f5c\uff0c\u4f46\u662f\u5916\u90e8\u8868\u5728\u6570\u636e\u5e93\u4e2d\u53ea\u6709\u8868\u7ed3\u6784\uff0c\u800c\u6570\u636e\u5b58\u653e\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u8bb2\u8ff0\u5982\u4f55\u5728 MatrixOne \u6570\u636e\u5e93\u5916\u5efa\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_3","title":"\u901a\u7528\u8bed\u6cd5","text":"> CREATE EXTERNAL TABLE [IF NOT EXISTS] [db.]table_name;\n(\n name1 type1,\n name2 type2,\n ...\n)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_4","title":"\u8bed\u6cd5\u793a\u4f8b","text":"## \u521b\u5efa\u6307\u5411\u672c\u5730\u6587\u4ef6\u7684\u5916\u8868\uff08\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff09\ncreate external table t(...) localfile{\"filepath\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## \u521b\u5efa\u6307\u5411\u672c\u5730\u6587\u4ef6\u7684\u5916\u8868\uff08\u4e0d\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff0c\u5219\u4e3aauto\u683c\u5f0f\uff0c\u81ea\u52a8\u68c0\u67e5\u6587\u4ef6\u7684\u683c\u5f0f\uff09\ncreate external table t(...) localfile{\"filepath\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n\n## \u521b\u5efa\u6307\u5411S3\u6587\u4ef6\u7684\u5916\u8868\uff08\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff09\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>', \"compression\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n\n## \u521b\u5efa\u6307\u5411S3\u6587\u4ef6\u7684\u5916\u8868\uff08\u4e0d\u6307\u5b9a\u538b\u7f29\u683c\u5f0f\uff0c\u5219\u4e3aauto\u683c\u5f0f\uff0c\u81ea\u52a8\u68c0\u67e5\u6587\u4ef6\u7684\u683c\u5f0f\uff09\ncreate external table t(...) URL s3option{\"endpoint\"='<string>', \"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"bucket\"='<string>', \"filepath\"='<string>', \"region\"='<string>'} FIELDS TERMINATED BY ',' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_5","title":"\u8bed\u6cd5\u8bf4\u660e","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_6","title":"\u53c2\u6570\u8bf4\u660e","text":"\u53c2\u6570 \u63cf\u8ff0 endpoint \u7ec8\u7aef\u8282\u70b9\u662f\u4f5c\u4e3a AWS Web \u670d\u52a1\u7684\u5165\u53e3\u70b9\u7684 URL\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com access_key_id S3 \u7684 Access key ID secret_access_key S3 \u7684 Secret access key bucket \u9700\u8981\u8bbf\u95ee\u7684\u6876 filepath \u8bbf\u95ee\u6587\u4ef6\u7684\u76f8\u5bf9\u8def\u5f84 region s3 \u6240\u5728\u7684\u533a\u57df compression S3 \u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f\uff0c\u4e3a\u7a7a\u8868\u793a\u975e\u538b\u7f29\u6587\u4ef6\uff0c\u652f\u6301\u7684\u5b57\u6bb5\u6216\u538b\u7f29\u683c\u5f0f\u4e3a\"auto\", \"none\", \"gzip\", \"bzip2\", \"flate\", \"zlib\", \"lz4\" auto \u538b\u7f29\u683c\u5f0f\uff0c\u8868\u793a\u901a\u8fc7\u6587\u4ef6\u540e\u7f00\u540d\u81ea\u52a8\u68c0\u67e5\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f none \u538b\u7f29\u683c\u5f0f\uff0c\u8868\u793a\u4e3a\u975e\u538b\u7f29\u683c\u5f0f\uff0c\u5176\u4f59\u8868\u793a\u6587\u4ef6\u7684\u538b\u7f29\u683c\u5f0f"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_7","title":"\u793a\u4f8b","text":"create external table ex_table_cpk(clo1 tinyint,clo2 smallint,clo3 int,clo4 bigint,clo5 tinyint unsigned,clo6 smallint unsigned,clo7 int unsigned,clo8 bigint unsigned,col9 float,col10 double,col11 varchar(255),col12 Date,col13 DateTime,col14 timestamp,col15 bool,col16 decimal(5,2),col17 text,col18 varchar(255),col19 varchar(255),col20 varchar(255))infile{\"filepath\"='$resources/external_table_file/cpk_table_1.csv'} ;\n
\u66f4\u591a\u5173\u4e8e\u4f7f\u7528\u5916\u8868\u6307\u5b9a S3 \u6587\u4ef6\uff0c\u53c2\u89c1\u4ece S3 \u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u8bfb\u53d6\u6570\u636e\u5e76\u5bfc\u5165 MatrixOne\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-external-table/#_8","title":"\u9650\u5236","text":"\u5f53\u524d MatrixOne \u4ec5\u652f\u6301\u5bf9\u5916\u90e8\u8868\u8fdb\u884c select
\u64cd\u4f5c\uff0c\u6682\u65f6\u8fd8\u4e0d\u652f\u6301\u4f7f\u7528 delete
\u3001insert
\u3001update
\u5bf9\u5916\u90e8\u8868\u63d2\u5165\u6570\u636e\u3002
CREATE FUNCTION...LANGUAGE PYTHON AS
\u7528\u4e8e\u521b\u5efa\u7528\u6237\u81ea\u5b9a\u4e49 Python \u51fd\u6570\u3002\u7528\u6237\u901a\u8fc7\u81ea\u5df1\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u6ee1\u8db3\u5b9a\u5236\u5316\u9700\u6c42\uff0c\u7b80\u5316\u67e5\u8be2\u7684\u7f16\u5199\u3002\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5bfc\u5165\u5916\u90e8 Python \u6587\u4ef6\u6216\u5916\u90e8 whl \u5305\u6765\u521b\u5efa UDF\u3002
\u5728\u90e8\u5206\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u4f1a\u5e0c\u671b python \u51fd\u6570\u4e00\u6b21\u6027\u63a5\u6536\u591a\u4e2a\u5143\u7ec4\u6765\u63d0\u9ad8\u8fd0\u884c\u6548\u7387\uff0cMatrixOne \u63d0\u4f9b\u51fd\u6570\u7684 vector \u9009\u9879\u6765\u5904\u7406\u8fd9\u79cd\u60c5\u51b5\u3002
MatrixOne Python UDF \u76ee\u524d\u4e0d\u652f\u6301\u91cd\u8f7d\uff0c\u51fd\u6570\u540d\u5728\u4e00\u4e2a matrixone \u96c6\u7fa4\u8981\u6c42\u662f\u552f\u4e00\u7684\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-python/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE [ OR REPLACE ] FUNCTION <name> (\n[ <arg_name> <arg_data_type> ] [ , ... ] )\nRETURNS <result_data_type> LANGUAGE PYTHON AS\n$$\n<function_body>\n[ add.vector = True ]\n$$\nHANDLER = '<function_name>'\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-python/#_3","title":"\u7ed3\u6784\u8bf4\u660e","text":"<name>
\uff1a\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u540d\u79f0\u3002
<arg_name> <arg_data_type>
\uff1a\u7528\u4e8e\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u53c2\u6570\uff0c\u8fd9\u91cc\u7684\u53c2\u6570\u53ea\u6709\u540d\u79f0\u548c\u7c7b\u578b\u3002
RETURNS <result_data_type>
\uff1a\u7528\u4e8e\u58f0\u660e\u81ea\u5b9a\u4e49\u51fd\u6570\u8fd4\u56de\u503c\u7684\u6570\u636e\u7c7b\u578b\u3002
<function_body>
\uff1a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u4e3b\u4f53\u90e8\u5206\uff0c\u5fc5\u987b\u5305\u542b\u4e00\u4e2a RETURN \u8bed\u53e5\uff0c\u5176\u4e2d\u7528\u4e8e\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u8fd4\u56de\u503c\u3002
[ add.vector = True ]
\uff1a\u6807\u5fd7 python \u51fd\u6570\u4e00\u6b21\u6027\u63a5\u6536\u591a\u4e2a\u5143\u7ec4\u3002
HANDLIER <function_name>:
\u6307\u5b9a\u8c03\u7528\u7684 python \u51fd\u6570\u540d\u79f0\u3002
\u4e3a\u786e\u4fdd\u7f16\u5199 Python UDF \u8fc7\u7a0b\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u7c7b\u578b\u4e0e MatrixOne \u652f\u6301\u7684\u6570\u636e\u7c7b\u578b\u4fdd\u6301\u4e00\u81f4\uff0c\u60a8\u9700\u8981\u5173\u6ce8\u4e8c\u8005\u95f4\u7684\u6570\u636e\u7c7b\u578b\u6620\u5c04\u5173\u7cfb\uff0c\u5177\u4f53\u6620\u5c04\u5173\u7cfb\u5982\u4e0b\uff1a
MatrixOne \u7c7b\u578b Python \u7c7b\u578b bool bool int8, int16, int32, int64, uint8, uint16, uint32, uint64 int float32, float64 float char, varchar, text, uuid str json str, int, float, list, dict time datetime.timedelta date datetime.date datetime, timestamp datetime.datetime decimal64, decimal128 decimal.Decimal binary, varbinary, blob bytes"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-python/#_5","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
--\u7528 python UDF \u5b9e\u73b0\u4e24\u6570\u4e4b\u548c\ncreate or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\n\n--\u8c03\u7528\u51fd\u6570\nmysql> select py_add(1,2);\n+--------------+\n| py_add(1, 2) |\n+--------------+\n| 3 |\n+--------------+\n1 row in set (0.01 sec)\n
\u793a\u4f8b 2
create or replace function py_helloworld() returns varchar(255) language python as $$\ndef helloworld():\nreturn \"helloworld!\"\n$$\nhandler 'helloworld';\n\nmysql> select py_helloworld();\n+-----------------+\n| py_helloworld() |\n+-----------------+\n| helloworld! |\n+-----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/","title":"CREATE FUNCTION...LANGUAGE SQL AS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE FUNCTION...LANGUAGE SQL AS
\u7528\u4e8e\u521b\u5efa SQL UDF\u3002
SQL \u81ea\u5b9a\u4e49\u51fd\u6570\u662f\u4e00\u79cd\u7528\u6237\u81ea\u5df1\u7f16\u5199\u7684 SQL \u51fd\u6570\uff0c\u53ef\u4ee5\u6839\u636e\u7279\u5b9a\u9700\u6c42\u6267\u884c\u81ea\u5b9a\u4e49\u64cd\u4f5c\u3002\u8fd9\u4e9b\u51fd\u6570\u53ef\u4ee5\u7528\u4e8e\u67e5\u8be2\u3001\u6570\u636e\u8f6c\u6362\u7b49\u4efb\u52a1\uff0c\u4f7f\u5f97 sQL \u4ee3\u7801\u66f4\u52a0\u6a21\u5757\u5316\u548c\u53ef\u7ef4\u62a4\u3002
MatrixOne SQL UDF \u76ee\u524d\u4e0d\u652f\u6301\u91cd\u8f7d\uff0c\u51fd\u6570\u540d\u5728\u4e00\u4e2a matrixone \u96c6\u7fa4\u8981\u6c42\u662f\u552f\u4e00\u7684\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> CREATE [ OR REPLACE ] FUNCTION <name> (\n[ <arg_name> <arg_data_type> ] [ , ... ] )\nRETURNS <result_data_type> LANGUAGE SQL AS 'function_body'\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-function-sql/#_3","title":"\u7ed3\u6784\u8bf4\u660e","text":"<name>
\uff1a\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u540d\u79f0\u3002
<arg_name> <arg_data_type>
\uff1a\u7528\u4e8e\u6307\u5b9a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u53c2\u6570\uff0c\u8fd9\u91cc\u7684\u53c2\u6570\u53ea\u6709\u540d\u79f0\u548c\u7c7b\u578b\u3002
RETURNS <result_data_type>
\uff1a\u7528\u4e8e\u58f0\u660e\u81ea\u5b9a\u4e49\u51fd\u6570\u8fd4\u56de\u503c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b8c\u6574\u7684\u6570\u636e\u7c7b\u578b\u8bf7\u67e5\u770b\u6570\u636e\u7c7b\u578b\u6982\u89c8
function_body
\uff1a\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u4e3b\u4f53\u90e8\u5206\u3002\u7528\u6237\u5fc5\u987b\u4f7f\u7528$1\u3001$2,...\u4ee5\u5f15\u7528\u53c2\u6570\uff0c\u800c\u4e0d\u662f\u5b9e\u9645\u7684\u53c2\u6570\u540d\u79f0\u3002\u51fd\u6570\u4f53\u652f\u6301 select \u8bed\u53e5\uff0c\u4e14\u8fd4\u56de\u503c\u552f\u4e00\uff0c\u5982\u679c sql \u51fd\u6570\u4f53\u4e0d\u662f\u8868\u8fbe\u5f0f\uff0c\u5e76\u4e14\u662f\u8868\u4e0a\u7684 select \u8bed\u53e5\uff0c\u5219\u67e5\u8be2\u5e94\u4f7f\u7528 limit 1 \u6216\u4e0d\u5e26 group by \u5b50\u53e5\u7684\u805a\u5408\u51fd\u6570\u5c06\u5176\u7ed3\u679c\u9650\u5236\u4e3a 1\u3002
\u793a\u4f8b 1
--\u521b\u5efa\u65e0\u53c2 sql \u81ea\u5b9a\u4e49\u51fd\u6570\n\nmysql> create table t1(n1 int);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t1 values(1),(2),(3);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> CREATE FUNCTION t1_fun () RETURNS VARCHAR LANGUAGE SQL AS 'select n1 from t1 limit 1' ;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> select t1_fun();\n+----------+\n| t1_fun() |\n+----------+\n| 1 |\n+----------+\n1 row in set (0.01 sec)\n
\u793a\u4f8b 2
--\u521b\u5efa sql \u81ea\u5b9a\u4e49\u51fd\u6570\u8fd4\u56de\u4e24\u4e2a\u53c2\u6570\u7684\u548c\nmysql> CREATE FUNCTION twoadd (x int, y int) RETURNS int LANGUAGE SQL AS 'select $1 + $2' ;\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> select twoadd(1,2);\n+--------------+\n| twoadd(1, 2) |\n+--------------+\n| 3 |\n+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/","title":"CREATE INDEX USING IVFFLAT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5411\u91cf\u7d22\u5f15\u53ef\u7528\u4e8e\u52a0\u901f\u5bf9\u5305\u542b\u5411\u91cf\u5217\u7684\u8868\u7684 KNN(K-Nearest Neighbors\uff09\u67e5\u8be2\u3002Matrixone \u76ee\u524d\u652f\u6301\u5177\u6709 l2_distance
\u5ea6\u91cf\u7684 IVFFLAT \u5411\u91cf\u7d22\u5f15\u3002
\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a PROBE_LIMIT \u6765\u51b3\u5b9a\u8981\u67e5\u8be2\u7684\u805a\u7c7b\u4e2d\u5fc3\u6570\u91cf\u3002PROBE_LIMIT \u9ed8\u8ba4\u4e3a 1\uff0c\u5373\u4ec5\u626b\u63cf 1 \u4e2a\u805a\u7c7b\u4e2d\u5fc3\u3002\u4f46\u5982\u679c\u60a8\u5c06\u5176\u8bbe\u7f6e\u4e3a\u66f4\u9ad8\u7684\u503c\uff0c\u5b83\u4f1a\u626b\u63cf\u66f4\u591a\u6570\u91cf\u7684\u805a\u7c7b\u4e2d\u5fc3\u548c\u5411\u91cf\uff0c\u8fd9\u4f7f\u5f97\u6027\u80fd\u53ef\u80fd\u4f1a\u4e0b\u964d\u4e00\u70b9\uff0c\u4f46\u51c6\u786e\u7387\u4f1a\u4e0a\u5347\u3002\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u9002\u5f53\u7684\u63a2\u9488\u6570\u91cf\u6765\u5e73\u8861\u67e5\u8be2\u901f\u5ea6\u548c\u53ec\u56de\u7387\u3002PROBE_LIMIT \u7684\u7406\u60f3\u503c\u4e3a\uff1a
> CREATE INDEX index_name\nUSING IVFFLAT\nON tbl_name (col,...)\nLISTS=lists \nOP_TYPE \"vector_l2_ops\"\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"index_name
\uff1a\u7d22\u5f15\u540d\u79f0IVFFLAT
\uff1a\u5411\u91cf\u7d22\u5f15\u7c7b\u578b\uff0c\u76ee\u524d\u652f\u6301 vector_l2_opslists
\uff1a\u7d22\u5f15\u4e2d\u6240\u9700\u7684\u5206\u533a\u6570\uff0c\u5fc5\u987b\u5927\u4e8e 0OP_TYPE
\uff1a\u8981\u4f7f\u7528\u7684\u8ddd\u79bb\u5ea6\u91cfNOTE:
--\u9700\u8bbe\u7f6e\u53c2\u6570 experimental_ivf_index \u503c\u4e3a 1\uff08\u9ed8\u8ba4 0\uff09\u624d\u80fd\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\nSET GLOBAL experimental_ivf_index = 1;\ndrop table if exists t1;\ncreate table t1(coordinate vecf32(2),class char);\n-- \u6709\u4e03\u4e2a\u70b9\uff0c\u6bcf\u4e2a\u70b9\u4ee3\u8868\u5176\u5728 x \u548c y \u8f74\u4e0a\u7684\u5750\u6807\uff0c\u5e76\u4e14\u6bcf\u4e2a\u70b9\u7684 class \u88ab\u6807\u8bb0\u4e3a A \u6216 B\u3002\ninsert into t1 values(\"[2,4]\",\"A\"),(\"[3,5]\",\"A\"),(\"[5,7]\",\"B\"),(\"[7,9]\",\"B\"),(\"[4,6]\",\"A\"),(\"[6,8]\",\"B\"),(\"[8,10]\",\"B\");\n--\u521b\u5efa\u5411\u91cf\u7d22\u5f15\ncreate index idx_t1 using ivfflat on t1(coordinate) lists=1 op_type \"vector_l2_ops\";\n\nmysql> show create table t1;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`coordinate` VECF32(2) DEFAULT NULL,\n`class` CHAR(1) DEFAULT NULL,\nKEY `idx_t1` USING ivfflat (`coordinate`) lists = 1 op_type 'vector_l2_ops' ) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show index from t1;\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Index_params | Visible | Expression |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n| t1 | 1 | idx_t1 | 1 | coordinate | A | 0 | NULL | NULL | YES | ivfflat | | | {\"lists\":\"1\",\"op_type\":\"vector_l2_ops\"} | YES | NULL |\n+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+-----------------------------------------+---------+------------+\n1 row in set (0.01 sec)\n\n--\u8bbe\u7f6e\u626b\u63cf\u7684\u805a\u7c7b\u4e2d\u5fc3\u6570\u91cf\nSET @PROBE_LIMIT=1;\n--\u73b0\u5728\uff0c\u6211\u4eec\u6709\u4e00\u4e2a\u65b0\u70b9\uff0c\u5176\u5750\u6807\u4e3a (4, 4)\uff0c\u6211\u4eec\u60f3\u8981\u4f7f\u7528 KNN \u67e5\u8be2\u6765\u9884\u6d4b\u8fd9\u4e2a\u70b9\u7684\u7c7b\u522b\u3002\nmysql> select * from t1 order by l2_distance(coordinate,\"[4,4]\") asc;\n+------------+-------+\n| coordinate | class |\n+------------+-------+\n| [3, 5] | A |\n| [2, 4] | A |\n| [4, 6] | A |\n| [5, 7] | B |\n| [6, 8] | B |\n| [7, 9] | B |\n| [8, 10] | B |\n+------------+-------+\n7 rows in set (0.01 sec)\n\n--\u6839\u636e\u67e5\u8be2\u7ed3\u679c\u53ef\u9884\u6d4b\u8fd9\u4e2a\u70b9\u7684\u7c7b\u522b\u4e3a A\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index-ivfflat/#_5","title":"\u9650\u5236","text":"\u4e00\u6b21\u53ea\u652f\u6301\u5728\u4e00\u4e2a\u5411\u91cf\u5217\u4e0a\u5efa\u7acb\u5411\u91cf\u7d22\u5f15\uff0c\u5982\u9700\u5728\u591a\u4e2a\u5411\u91cf\u5217\u4e0a\u5efa\u7acb\u5411\u91cf\u7d22\u5f15\uff0c\u53ef\u591a\u6b21\u6267\u884c\u521b\u5efa\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/","title":"CREATE INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728\u8868\u4e2d\u521b\u5efa\u7d22\u5f15\uff0c\u4ee5\u4fbf\u66f4\u52a0\u5feb\u901f\u9ad8\u6548\u5730\u67e5\u8be2\u6570\u636e\u3002
\u4f60\u65e0\u6cd5\u770b\u5230\u7d22\u5f15\uff0c\u7d22\u5f15\u53ea\u80fd\u88ab\u7528\u6765\u52a0\u901f\u641c\u7d22/\u67e5\u8be2\u3002
\u66f4\u65b0\u4e00\u4e2a\u5305\u542b\u7d22\u5f15\u7684\u8868\u9700\u8981\u6bd4\u66f4\u65b0\u4e00\u4e2a\u6ca1\u6709\u7d22\u5f15\u7684\u8868\u82b1\u8d39\u66f4\u591a\u7684\u65f6\u95f4\uff0c\u8fd9\u662f\u7531\u4e8e\u7d22\u5f15\u672c\u8eab\u4e5f\u9700\u8981\u66f4\u65b0\u3002\u56e0\u6b64\uff0c\u7406\u60f3\u7684\u505a\u6cd5\u662f\u4ec5\u4ec5\u5728\u5e38\u5e38\u88ab\u641c\u7d22\u7684\u5217\uff08\u4ee5\u53ca\u8868\uff09\u4e0a\u9762\u521b\u5efa\u7d22\u5f15\u3002
\u7d22\u5f15\u6709\u51e0\u79cd\u5e38\u89c1\u7684\u7c7b\u578b\uff0c\u5206\u522b\u4e3a\uff1a
> CREATE [UNIQUE] INDEX index_name\nON tbl_name (key_part,...)\nCOMMENT 'string'\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#create-unique-index","title":"CREATE UNIQUE INDEX \u8bed\u6cd5","text":"\u5728\u8868\u4e0a\u521b\u5efa\u4e00\u4e2a\u552f\u4e00\u7684\u7d22\u5f15\u3002\u4e0d\u5141\u8bb8\u4f7f\u7528\u91cd\u590d\u7684\u503c\uff1a\u552f\u4e00\u7684\u7d22\u5f15\u610f\u5473\u7740\u4e24\u4e2a\u884c\u4e0d\u80fd\u62e5\u6709\u76f8\u540c\u7684\u7d22\u5f15\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#create-index_1","title":"CREATE INDEX \u8bed\u6cd5","text":"\u5728\u8868\u4e0a\u521b\u5efa\u4e00\u4e2a\u6b21\u7ea7\u7d22\u5f15\u3002\u53ef\u4ee5\u4f7f\u7528\u91cd\u590d\u503c\u548c Null \u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-index/#_4","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(id int PRIMARY KEY,name VARCHAR(255),age int);\ninsert into t1 values(1,\"Abby\", 24);\ninsert into t1 values(2,\"Bob\", 25);\ninsert into t1 values(3,\"Carol\", 23);\ninsert into t1 values(4,\"Dora\", 29);\ncreate unique index idx on t1(name);\nmysql> select * from t1;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Abby | 24 |\n| 2 | Bob | 25 |\n| 3 | Carol | 23 |\n| 4 | Dora | 29 |\n+------+-------+------+\n4 rows in set (0.00 sec)\n\nmysql> show create table t1;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`id` INT NOT NULL,\n`name` VARCHAR(255) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`),\nUNIQUE KEY `idx` (`name`)\n) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n\ncreate table t2 (\ncol1 bigint primary key,\ncol2 varchar(25),\ncol3 float,\ncol4 varchar(50)\n);\ncreate unique index idx on t2(col2) comment 'create varchar index';\ninsert into t2 values(1,\"Abby\", 24,'zbcvdf');\ninsert into t2 values(2,\"Bob\", 25,'zbcvdf');\ninsert into t2 values(3,\"Carol\", 23,'zbcvdf');\ninsert into t2 values(4,\"Dora\", 29,'zbcvdf');\nmysql> select * from t2;\n+------+-------+------+--------+\n| col1 | col2 | col3 | col4 |\n+------+-------+------+--------+\n| 1 | Abby | 24 | zbcvdf |\n| 2 | Bob | 25 | zbcvdf |\n| 3 | Carol | 23 | zbcvdf |\n| 4 | Dora | 29 | zbcvdf |\n+------+-------+------+--------+\n4 rows in set (0.00 sec)\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t2 | CREATE TABLE `t2` (\n`col1` BIGINT NOT NULL,\n`col2` VARCHAR(25) DEFAULT NULL,\n`col3` FLOAT DEFAULT NULL,\n`col4` VARCHAR(50) DEFAULT NULL,\nPRIMARY KEY (`col1`),\nUNIQUE KEY `idx` (`col2`) COMMENT `create varchar index`\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
CREATE TABLE Employees (\nEmployeeID INT PRIMARY KEY,\nFirstName VARCHAR(50),\nLastName VARCHAR(50),\nDepartment VARCHAR(50),\nSalary INT\n);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (1, 'John', 'Doe', 'HR', 50000);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (2, 'Jane', 'Smith', 'IT', 60000);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (3, 'Mark', 'Johnson', 'IT', 55000);\n\nINSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)\nVALUES (4, 'Mary', 'Brown', 'Sales', 48000);\n\nmysql> CREATE INDEX DepartmentIndex ON Employees (Department);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> SELECT * FROM Employees WHERE Department = 'IT';\n+------------+-----------+----------+------------+--------+\n| employeeid | firstname | lastname | department | salary |\n+------------+-----------+----------+------------+--------+\n| 2 | Jane | Smith | IT | 60000 |\n| 3 | Mark | Johnson | IT | 55000 |\n+------------+-----------+----------+------------+--------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/","title":"CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE PUBLICATION
\u5c06\u4e00\u4e2a\u65b0\u7684\u53d1\u5e03\u6dfb\u52a0\u5230\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u3002
CREATE PUBLICATION pubname\n DATABASE database_name ACCOUNT\n [ { ALL\n | account_name, [, ... ] }]\n [ COMMENT 'string']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create database t;\ncreate account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\nmysql> create publication pub1 database t account acc0,acc1;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-publication/#_5","title":"\u9650\u5236","text":"MatrxiOne \u5f53\u524d\u4ec5\u652f\u6301\u4e00\u6b21\u53d1\u5e03\u4e00\u4e2a\u6570\u636e\u5e93\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-replace-view/","title":"CREATE OR REPLACE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-replace-view/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE OR REPLACE VIEW
\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u89c6\u56fe\uff0c\u4e5f\u53ef\u4ee5\u7528\u4f5c\u5f53\u89c6\u56fe\u5df2\u7ecf\u5b58\u5728\u65f6\uff0c\u5219\u66ff\u6362\u5df2\u6709\u7684\u89c6\u56fe\u3002\u8fd9\u8868\u793a\u5728\u89c6\u56fe\u5df2\u7ecf\u5b58\u5728\u65f6\u66f4\u65b0\u89c6\u56fe\u7684\u5b9a\u4e49\uff0c\u800c\u4e0d\u9700\u8981\u5220\u9664\u5df2\u6709\u7684\u89c6\u56fe\u3002
> CREATE OR REPLACE VIEW view_name AS\nSELECT column1, column2, ...\nFROM table_name\nWHERE condition;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-replace-view/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"view_name
\uff1a\u8981\u521b\u5efa\u6216\u66ff\u6362\u7684\u89c6\u56fe\u7684\u540d\u79f0\uff0c\u9700\u8981\u4e3a\u89c6\u56fe\u6307\u5b9a\u4e00\u4e2a\u552f\u4e00\u7684\u540d\u79f0\u3002
AS
\uff1a\u7528\u4e8e\u6307\u793a\u4ee5\u4e0b\u7684\u67e5\u8be2\u8bed\u53e5\u662f\u89c6\u56fe\u7684\u67e5\u8be2\u5b9a\u4e49\u3002
SELECT column1, column2, ...
\uff1a\u5728 AS \u5173\u952e\u5b57\u4e4b\u540e\uff0c\u4f60\u9700\u8981\u6307\u5b9a\u89c6\u56fe\u7684\u67e5\u8be2\u5b9a\u4e49\u3002\u8fd9\u662f\u4e00\u4e2a SELECT \u8bed\u53e5\uff0c\u53ef\u4ee5\u9009\u62e9\u8868\u4e2d\u7684\u7279\u5b9a\u5217\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u8ba1\u7b97\u5b57\u6bb5\u3001\u8868\u8fbe\u5f0f\u7b49\u7b49\u3002\u89c6\u56fe\u4f1a\u5c06\u8fd9\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u4f5c\u4e3a\u5176\u81ea\u8eab\u7684\u6570\u636e\u3002
FROM table_name
\uff1aFROM
\u5b50\u53e5\uff0c\u7528\u4e8e\u6307\u5b9a\u8981\u67e5\u8be2\u7684\u8868\u540d\u3002\u4f60\u53ef\u4ee5\u9009\u62e9\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\uff0c\u5e76\u5728\u89c6\u56fe\u4e2d\u8fdb\u884c\u76f8\u5173\u64cd\u4f5c\u3002
WHERE condition
\uff1a\u53ef\u9009\u7684 WHERE
\u5b50\u53e5\uff0c\u7528\u4e8e\u7b5b\u9009\u67e5\u8be2\u7ed3\u679c\u3002
-- \u521b\u5efa\u8868 t1 \u5305\u62ec\u4e24\u5217 a \u548c b\ncreate table t1 (a int, b int);\n\n-- \u5411\u8868 t1 \u63d2\u5165\u4e09\u884c\u6570\u636e\ninsert into t1 values (1, 11), (2, 22), (3, 33);\n\n-- \u521b\u5efa\u89c6\u56fe v1\uff0c\u8be5\u89c6\u56fe\u5305\u542b\u8868 t1 \u4e2d\u7684\u6240\u6709\u6570\u636e\ncreate view v1 as select * from t1;\n\n-- \u67e5\u8be2\u89c6\u56fe v1 \u7684\u6240\u6709\u6570\u636e\nmysql> select * from v1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 11 |\n| 2 | 22 |\n| 3 | 33 |\n+------+------+\n3 rows in set (0.01 sec)\n\n-- \u67e5\u8be2\u89c6\u56fe v1 \u4e2d\u5217 a \u5927\u4e8e 1 \u7684\u6570\u636e\nmysql> select * from v1 where a > 1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 22 |\n| 3 | 33 |\n+------+------+\n2 rows in set (0.00 sec)\n\n-- \u66ff\u6362\u89c6\u56fe v1\uff0c\u65b0\u7684\u89c6\u56fe\u4ec5\u5305\u542b\u8868 t1 \u4e2d\u5217 a \u5c0f\u4e8e 2 \u7684\u6570\u636e\ncreate or replace view v1 as select * from t1 where a < 2;\n\n-- \u518d\u6b21\u67e5\u8be2\u89c6\u56fe v1\uff0c\u73b0\u5728\u53ea\u5305\u542b\u6ee1\u8db3\u65b0\u6761\u4ef6\u7684\u6570\u636e\nmysql> select * from v1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 11 |\n+------+------+\n1 row in set (0.08 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/","title":"CREATE SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE SEQUENCE
\u7528\u6237\u521b\u5efa\u4e00\u4e2a\u5e8f\u5217\u5bf9\u8c61\u3002\u5e8f\u5217\uff08Sequence\uff09\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u6570\u636e\u5e93\u5bf9\u8c61\uff0c\u5b83\u53ef\u4ee5\u88ab\u7528\u6765\u81ea\u52a8\u751f\u6210\u552f\u4e00\u7684\u6570\u5b57\u5e8f\u5217\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5e8f\u5217\u88ab\u7528\u6765\u4e3a\u4e00\u4e2a\u8868\u7684\u4e3b\u952e\u5b57\u6bb5\u81ea\u52a8\u751f\u6210\u552f\u4e00\u7684\u503c\u3002
CREATE SEQUENCE
\u662f\u4e00\u79cd\u7528\u4e8e\u521b\u5efa\u81ea\u589e\u6570\u5b57\u5e8f\u5217\u7684\u547d\u4ee4\uff0c\u7528\u4e8e\u751f\u6210\u552f\u4e00\u7684\u3001\u8fde\u7eed\u7684\u6570\u5b57\u503c\uff0c\u901a\u5e38\u7528\u4e8e\u4e3a\u4e3b\u952e\u5217\u6216\u5176\u4ed6\u9700\u8981\u81ea\u589e\u6570\u5b57\u7684\u5217\u751f\u6210\u503c\u3002
> CREATE SEQUENCE [ IF NOT EXISTS ] SEQUENCE_NAME\n [ AS data_type ]\n [ INCREMENT [ BY ] increment ]\n [ MINVALUE minvalue] [ MAXVALUE maxvalue]\n [ START [ WITH ] start ] [ [ NO ] CYCLE ]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#data_type","title":"data_type","text":"\u53ef\u9009\u5b50\u53e5 AS data_type
\u6307\u5b9a\u5e8f\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002\u652f\u6301\u6570\u636e\u7c7b\u578b\u4e3a smallint [unsigned]
\u3001integer [unsigned]
\u548c bigint [unsigned]
\uff0c\u9ed8\u8ba4 bigint
\u662f\u9ed8\u8ba4\u503c\u3002\u6570\u636e\u7c7b\u578b\u51b3\u5b9a\u4e86\u5e8f\u5217\u7684\u9ed8\u8ba4\u6700\u5c0f\u503c\u548c\u6700\u5927\u503c\u3002
\u53ef\u9009\u5b50\u53e5 INCREMENT [ BY ] increment
\u6307\u5b9a\u5c06\u54ea\u4e2a\u503c\u6dfb\u52a0\u5230\u5f53\u524d\u5e8f\u5217\u503c\u4ee5\u521b\u5efa\u65b0\u503c\u3002\u6b63\u503c\u5c06\u751f\u6210\u5347\u5e8f\uff0c\u8d1f\u503c\u5c06\u751f\u6210\u964d\u5e8f\uff1b\u9ed8\u8ba4\u503c\u4e3a 1\u3002
\u53ef\u9009\u5b50\u53e5 MINVALUE minvalue
\u786e\u5b9a\u5e8f\u5217\u53ef\u4ee5\u751f\u6210\u7684\u6700\u5c0f\u503c\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6b64\u5b50\u53e5\u6216\u672a\u6307\u5b9a MINVALUE
\uff0c\u5219\u5c06\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002\u5347\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u662f 1\u3002\u964d\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u662f\u6570\u636e\u7c7b\u578b\u7684\u6700\u5c0f\u503c\u3002
\u53ef\u9009\u5b50\u53e5 MAXVALUE maxvalue
\u786e\u5b9a\u5e8f\u5217\u7684\u6700\u5927\u503c\u3002\u5982\u679c\u672a\u63d0\u4f9b\u6b64\u5b50\u53e5\u6216\u672a\u6307\u5b9a MAXVALUE
\uff0c\u5219\u5c06\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002\u5347\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u662f\u6570\u636e\u7c7b\u578b\u7684\u6700\u5927\u503c\u3002\u964d\u5e8f\u5e8f\u5217\u7684\u9ed8\u8ba4\u503c\u4e3a -1\u3002
\u53ef\u9009\u5b50\u53e5 START [ WITH ] start
\u5141\u8bb8\u5e8f\u5217\u4ece\u4efb\u4f55\u5730\u65b9\u5f00\u59cb\u3002\u9ed8\u8ba4\u8d77\u59cb\u503c\u662f\u5347\u5e8f\u5e8f\u5217\u7684\u6700\u5c0f\u503c\u548c\u964d\u5e8f\u5e8f\u5217\u7684\u6700\u5927\u503c\u3002
CYCLE
\u9009\u9879\u5141\u8bb8\u5e8f\u5217\u5728\u5347\u5e8f\u6216\u964d\u5e8f\u5e8f\u5217\u5206\u522b\u8fbe\u5230\u6700\u5927\u503c\u6216\u6700\u5c0f\u503c\u65f6\u56de\u7ed5\u3002\u5982\u679c\u8fbe\u5230\u9650\u5236\uff0c\u5219\u751f\u6210\u7684\u4e0b\u4e00\u4e2a\u6570\u5b57\u5c06\u5206\u522b\u662f\u6700\u5c0f\u503c\u6216\u6700\u5927\u503c\u3002
\u5bf9\u5e8f\u5217\u7684\u503c\u8fdb\u884c\u64cd\u4f5c\uff0c\u4f7f\u7528\u7684\u51fd\u6570\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#nextvalsequence_name","title":"NEXTVAL(sequence_name)
","text":"\u5c06\u5f53\u524d\u503c\u8bbe\u7f6e\u6210\u9012\u589e\u540e\u7684\u503c\uff0c\u5e76\u8fd4\u56de\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#currvalsequence_name","title":"CURRVAL(sequence_name)
","text":"\u8fd4\u56de\u5f53\u524d\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-sequence/#setvalsequence_name-n-b","title":"SETVAL(sequence_name, n [,b])
","text":"\u8bbe\u7f6e\u5f53\u524d\u503c\uff1b
LASTVAL()
","text":"\u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u4e2d\uff0c\u6700\u8fd1\u4e00\u6b21\u7528 NEXTVAL
\u83b7\u53d6\u7684\u4efb\u4f55\u5e8f\u5217\u7684\u503c\uff0c\u4e14 LASTVAL()
\u53ea\u80fd\u88ab NEXTVAL
\u521d\u59cb\u5316\u3002
LASTVAL()
\u53d7 SETVAL(sequence_name, n [,true])
\u6539\u53d8\u5f53\u524d\u503c\u7684\u5f71\u54cd\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a
\u5047\u8bbe\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a seq_id
\u7684 Sequence\uff0c\u8d77\u59cb\u503c\u4e3a 1\uff0c\u6bcf\u6b21\u589e\u52a0 1\uff0c\u6700\u5927\u503c\u4e3a 1000\uff1a
CREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n
\u7136\u540e\u53ef\u4ee5\u4f7f\u7528 NEXTVAL()
\u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff0c\u5e76\u81ea\u52a8\u5c06\u5e8f\u5217\u7684\u8ba1\u6570\u5668\u589e\u52a0 1\uff1a
SELECT NEXTVAL('seq_id');\n
\u63a5\u7740\uff0c\u53ef\u4ee5\u4f7f\u7528 LASTVAL()
\u51fd\u6570\u8fd4\u56de\u5f53\u524d Sequence \u7684\u5f53\u524d\u503c\uff1a
SELECT LASTVAL();\n
\u4e5f\u53ef\u4ee5\u4f7f\u7528 SETVAL()
\u51fd\u6570\u5c06\u5f53\u524d\u503c\u8bbe\u7f6e\u4e3a 30\uff0c\u53c2\u6570 [,b]
\u4e3a true\uff1a
SELECT SETVAL('seq_id', 30);\n
\u7136\u540e\uff0c\u53ef\u4ee5\u518d\u6b21\u4f7f\u7528 NEXTVAL()
\u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff1a
SELECT NEXTVAL('seq_id');\n
\u6b64\u65f6\u5c06\u8fd4\u56de 31\uff0c\u56e0\u4e3a\u5f53\u524d\u503c\u5df2\u7ecf\u88ab\u8bbe\u7f6e\u4e3a 30\uff0cNEXTVAL()
\u51fd\u6570\u5c06\u8fd4\u56de\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c 31\u3002
SELECT LASTVAL();\n
\u4f7f\u7528 LASTVAL()
\u8fd4\u56de\u5f53\u524d Sequence \u7684\u5f53\u524d\u503c\uff0c\u6b64\u65f6\u5c06\u8fd4\u56de 31\u3002
\u4e0a\u8ff0\u793a\u4f8b\u8868\u793a\uff0c\u5982\u679c\u5148\u901a\u8fc7 SETVAL(sequence_name, n [,true])
\u8bbe\u7f6e\u4e86\u5f53\u524d\u503c\uff0c\u518d\u4f7f\u7528 NEXTVAL
\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff0c\u90a3\u4e48\u518d\u6b21\u4f7f\u7528 LASTVAL()
\uff0c\u5219\u8fd4\u56de NEXTVAL
\u83b7\u53d6\u7684\u5e8f\u5217\u7684\u503c\u3002
SEQUENCE
","text":"\u8981\u5728\u8868\u683c\u4e2d\u4f7f\u7528\u5e8f\u5217\uff0c\u9700\u8981\u5b8c\u6210\u4ee5\u4e0b\u6b65\u9aa4\uff1a
\u521b\u5efa\u4e00\u4e2a\u5e8f\u5217\u5bf9\u8c61\uff1a\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \"my_sequence\" \u7684\u5e8f\u5217\uff1a
CREATE SEQUENCE my_sequence;\n
\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e8f\u5217\u5bf9\u8c61\uff0c\u5b83\u5c06\u4ece 1 \u5f00\u59cb\uff0c\u4ee5 1 \u9012\u589e\u3002
\u5c06\u5e8f\u5217\u5e94\u7528\u5230\u8868\u683c\u4e2d\u7684\u5b57\u6bb5\uff1a\u4e3a\u4e86\u5c06\u5e8f\u5217\u5e94\u7528\u5230\u8868\u683c\u4e2d\u7684\u5b57\u6bb5\uff0c\u9700\u8981\u5728\u8868\u683c\u5b9a\u4e49\u4e2d\u6307\u5b9a\u4e00\u4e2a\u9ed8\u8ba4\u503c\u4e3a\u5e8f\u5217\u7684\u4e0b\u4e00\u4e2a\u503c\uff0c\u5982\u4e0b\u6240\u793a\uff1a
CREATE TABLE my_table (\nid INTEGER DEFAULT nextval('my_sequence'),\nname VARCHAR(50));\n
\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\"id\" \u5b57\u6bb5\u5c06\u81ea\u52a8\u4ece\u5e8f\u5217\u4e2d\u83b7\u53d6\u4e0b\u4e00\u4e2a\u552f\u4e00\u7684\u503c\u4f5c\u4e3a\u5176\u9ed8\u8ba4\u503c\u3002
\u63d2\u5165\u6570\u636e\uff1a\u8868\u683c\u548c\u5e8f\u5217\u90fd\u5df2\u7ecf\u5b9a\u4e49\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 INSERT
\u8bed\u53e5\u6765\u5411\u8868\u683c\u4e2d\u63d2\u5165\u6570\u636e\u3002\u5f53\u63d2\u5165\u4e00\u884c\u6570\u636e\u65f6\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a \"id\" \u5b57\u6bb5\u7684\u503c\uff0c\u90a3\u4e48 MatrixOne \u5c06\u4f1a\u81ea\u52a8\u4ece\u5e8f\u5217\u4e2d\u83b7\u53d6\u4e0b\u4e00\u4e2a\u552f\u4e00\u7684\u503c\u4f5c\u4e3a\u5176\u9ed8\u8ba4\u503c\u3002
\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u8bed\u53e5\u5c06\u4f1a\u5411 \"my_table\" \u8868\u683c\u4e2d\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0c\u5e76\u4e14\u81ea\u52a8\u4e3a \"id\" \u5b57\u6bb5\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684\u503c\uff1a
INSERT INTO my_table (name) VALUES ('John');\nINSERT INTO my_table (name) VALUES ('Tom');\n
\u901a\u8fc7\u4f7f\u7528\u5e8f\u5217\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u5728\u8868\u683c\u4e2d\u81ea\u52a8\u5206\u914d\u552f\u4e00\u7684\u6807\u8bc6\u7b26\uff0c\u4ece\u800c\u907f\u514d\u4e86\u624b\u52a8\u5206\u914d\u6807\u8bc6\u7b26\u53ef\u80fd\u5e26\u6765\u7684\u9519\u8bef\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u8bed\u53e5\u8fdb\u884c\u67e5\u8be2\u9a8c\u8bc1\uff1a
mysql> select * from my_table;\n+------+------+\n| id | name |\n+------+------+\n| 1 | John |\n| 2 | Tom |\n+------+------+\n2 rows in set (0.01 sec)\n
Note
\u5728\u8868\u4e2d\u4f7f\u7528 SEQUENCE \u65f6\uff0c\u9700\u8981\u6ce8\u610f auto_increment
\u4e0e sequence
\u4e0d\u80fd\u4e00\u8d77\u7528\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002
-- \u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a \"seq_id\" \u7684\u5e8f\u5217\uff0c\u5b83\u4ece 1 \u5f00\u59cb\uff0c\u6bcf\u6b21\u589e\u52a0 1\uff0c\u6700\u5927\u503c\u4e3a 1000\uff1a\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\n-- \u5728\u521b\u5efa\u5e8f\u5217\u4e4b\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 NEXTVAL \u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\uff0c\u5982\u4e0b\u6240\u793a\uff1a\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 1 |\n+-----------------+\n1 row in set (0.02 sec)\n-- \u6b64\u547d\u4ee4\u5c06\u8fd4\u56de\u5e8f\u5217\u4e2d\u7684\u4e0b\u4e00\u4e2a\u503c\uff08\u4f8b\u5982 1\uff09\uff0c\u5e76\u81ea\u52a8\u5c06\u5e8f\u5217\u7684\u8ba1\u6570\u5668\u589e\u52a0 1\u3002\n\n-- CURRVAL \u51fd\u6570\u8fd4\u56de\u5f53\u524d\u503c\u3002\nmysql> SELECT CURRVAL('seq_id');\n+-----------------+\n| currval(seq_id) |\n+-----------------+\n| 1 |\n+-----------------+\n1 row in set (0.01 sec)\n\n-- \u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u4e2d\uff0c\u6700\u8fd1\u4e00\u6b21\u7528 NEXTVAL \u83b7\u53d6\u7684\u4efb\u4f55\u5e8f\u5217\u7684\u503c\u3002\nmysql> SELECT LASTVAL();\n+-----------+\n| lastval() |\n+-----------+\n| 1 |\n+-----------+\n1 row in set (0.00 sec)\n\n-- \u8bbe\u7f6e\u5f53\u524d\u503c\u4e3a 30\u3002\nmysql> SELECT SETVAL('seq_id', 30);\n+--------------------+\n| setval(seq_id, 30) |\n+--------------------+\n| 30 |\n+--------------------+\n1 row in set (0.02 sec)\n\n-- NEXTVAL \u51fd\u6570\u83b7\u53d6\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\u3002\nmysql> SELECT NEXTVAL('seq_id');\n+-----------------+\n| nextval(seq_id) |\n+-----------------+\n| 31 |\n+-----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/","title":"CREATE SNAPSHOT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE SNAPSHOT
\u547d\u4ee4\u7528\u4e8e\u521b\u5efa\u5feb\u7167\u3002\u7cfb\u7edf\u79df\u6237\u53ef\u4ee5\u7ed9\u81ea\u5df1\u4e5f\u53ef\u4ee5\u7ed9\u666e\u901a\u79df\u6237\u521b\u5efa\u5feb\u7167\uff0c\u4f46\u662f\u666e\u901a\u79df\u6237\u53ea\u80fd\u7ed9\u81ea\u5df1\u521b\u5efa\u5feb\u7167\u3002\u79df\u6237\u521b\u5efa\u7684\u5feb\u7167\u4ec5\u672c\u79df\u6237\u53ef\u89c1\u3002
> CREATE SNAPSHOT snapshot_name FOR ACCOUNT account_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/#_3","title":"\u793a\u4f8b","text":"--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate snapshot sp1 for account sys;\ncreate snapshot sp2 for account acc1;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp2 | 2024-05-10 09:49:08.925908 | account | acc1 | | |\n| sp1 | 2024-05-10 09:48:50.271707 | account | sys | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n2 rows in set (0.00 sec)\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nmysql> create snapshot sp3 for account acc2;--\u666e\u901a\u79df\u6237\u53ea\u80fd\u4e3a\u81ea\u5df1\u5efa\u7acb\u5feb\u7167\nERROR 20101 (HY000): internal error: only sys tenant can create tenant level snapshot for other tenant\n\ncreate snapshot sp3 for account acc1;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp3 | 2024-05-10 09:53:09.948762 | account | acc1 | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-snapshot/#_4","title":"\u9650\u5236","text":"CREATE SOURCE
\u521b\u5efa\u4e00\u4e2a\u5bf9\u6d41\u5f0f\u6570\u636e\u7684\u8fde\u63a5\uff0c\u5e76\u5c06\u4e00\u4e2a\u65b0\u7684 SOURCE \u8868\u6dfb\u52a0\u5230\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u3002
CREATE [OR REPLACE] SOURCE [IF NOT EXISTS] stream_name ( { column_name data_type [KEY | HEADERS | HEADER(key)] } [, ...] )\nWITH ( property_name = expression [, ...]);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-source/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create source stream_test(c1 char(25),c2 varchar(500),c3 text,c4 tinytext,c5 mediumtext,c6 longtext )with(\n\"type\"='kafka',\n\"topic\"= 'test',\n\"partition\" = '0',\n\"value\"= 'json',\n\"bootstrap.servers\"='127.0.0.1:9092' )\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-source/#_5","title":"\u9650\u5236","text":"SOURCE \u8868\u76ee\u524d\u4e0d\u652f\u6301 drop \u548c alter\u3002
\u521b\u5efa SOURCE \u8868\u65f6\u76ee\u524d\u4ec5\u652f\u6301\u8fde\u63a5 kafka\uff0c\u4e14\u4ec5\u652f\u6301\u4f20\u8f93\u6570\u636e\u683c\u5f0f\u4e3a json\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/","title":"CREATE STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE STAGE
\u7528\u4e8e\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u7684\u5185\u90e8\u6216\u5916\u90e8\u6570\u636e\u9636\u6bb5\uff08Stage\uff09\uff0c\u7528\u4e8e\u6570\u636e\u5bfc\u51fa\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u9636\u6bb5\uff0c\u901a\u8fc7\u5c06\u6570\u636e\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\uff0c\u4f60\u53ef\u4ee5\u5c06\u6570\u636e\u6587\u4ef6\u4e0b\u8f7d\u5230\u672c\u5730\u6216\u5c06\u5176\u5b58\u50a8\u5728\u4e91\u5b58\u50a8\u670d\u52a1\u4e2d\u3002
\u5185\u90e8\u9636\u6bb5\uff08Internal Stage\uff09\uff1a\u5185\u90e8\u9636\u6bb5\u5c06\u6570\u636e\u6587\u4ef6\u5b58\u50a8\u5728 MatrixOne \u5185\u90e8\u3002\u5185\u90e8\u9636\u6bb5\u53ef\u4ee5\u662f\u6c38\u4e45\u6027\u7684\u6216\u4e34\u65f6\u6027\u7684\u3002
\u5916\u90e8\u9636\u6bb5\uff08External Stage\uff09\uff1a\u5916\u90e8\u9636\u6bb5\u5f15\u7528\u5b58\u50a8\u5728 MatrixOne \u4e4b\u5916\u4f4d\u7f6e\u7684\u6570\u636e\u6587\u4ef6\u3002\u76ee\u524d\uff0c\u652f\u6301\u4ee5\u4e0b\u4e91\u5b58\u50a8\u670d\u52a1\uff1a
\u5b58\u50a8\u4f4d\u7f6e\u53ef\u4ee5\u662f\u79c1\u6709/\u53d7\u4fdd\u62a4\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u516c\u5f00\u7684\u3002\u4f46\u662f\uff0c\u65e0\u6cd5\u8bbf\u95ee\u9700\u8981\u6062\u590d\u624d\u80fd\u68c0\u7d22\u7684\u5b58\u6863\u4e91\u5b58\u50a8\u7c7b\u522b\u4e2d\u7684\u6570\u636e\u3002
\u5185\u90e8\u6216\u5916\u90e8\u9636\u6bb5\u53ef\u4ee5\u5305\u62ec\u4e00\u4e2a\u76ee\u5f55\u8868\u3002\u76ee\u5f55\u8868\u5728\u4e91\u5b58\u50a8\u4e2d\u5b58\u50a8\u5206\u9636\u6bb5\u6587\u4ef6\u7684\u76ee\u5f55\u3002
\u914d\u7f6e\u4e00\u4e2a\u6307\u5b9a\u8def\u5f84\uff0c\u63a7\u5236\u7528\u6237 SELECT INTO
\u7684\u5199\u5165\u6743\u9650\uff0c\u5728\u521b\u5efa\u4e4b\u540e\uff0c\u7528\u6237\u53ea\u80fd\u5199\u5165\u6307\u5b9a\u7684 STAGE
\u8def\u5f84
\u5982\u679c\u4e0d\u521b\u5efa STAGE
\u6216\u5168\u90e8 STAGE
\u90fd\u5728 DISABLED
\u72b6\u6001\u4e0b\uff0c\u7528\u6237\u53ef\u4ee5\u5728\u64cd\u4f5c\u7cfb\u7edf\u6216\u5bf9\u8c61\u5b58\u50a8\u7684\u6743\u9650\u5141\u8bb8\u60c5\u51b5\u4e0b\uff0c\u5199\u5165\u4efb\u4f55\u8def\u5f84\u3002
\u5982\u679c\u4e0d\u4f7f\u7528 STAGE
\uff0c\u7528\u6237 SELECT INTO
\u65f6\u5fc5\u987b\u5f3a\u884c\u52a0\u5165 credential
\u4fe1\u606f\u3002
Note
> CREATE STAGE [ IF NOT EXISTS ] { stage_name }\n { StageParams }\u0005\n [ directoryTableParams ]\n [ COMMENT = '<string_literal>' ]\n\nStageParams (for Amazon S3) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>', \"filepath\"='<string>', \"region\"='<string>'}\n\nStageParams (for Aliyun OSS) :\nURL = \"endpoint\"='<string>' CREDENTIALS = {\"access_key_id\"='<string>', \"secret_access_key\"='<string>'}\n\nStageParams (for File System) :\nURL= 'filepath'\n\ndirectoryTableParams :\nENABLE = { TRUE | FALSE }\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-stage/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"IF NOT EXISTS
\uff1a\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u5728\u521b\u5efa Stage \u65f6\u68c0\u67e5\u662f\u5426\u5df2\u5b58\u5728\u540c\u540d\u7684 Stage\uff0c\u907f\u514d\u91cd\u590d\u521b\u5efa\u3002
stage_name
\uff1a\u8981\u521b\u5efa\u7684 Stage \u7684\u540d\u79f0\u3002
StageParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u914d\u7f6e\u53c2\u6570\u3002
endpoint
\uff1aStage \u7684\u8fde\u63a5 URL\uff0c\u6307\u5b9a\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u7684\u4f4d\u7f6e\u3002\u5bf9\u4e8e\u4e0d\u540c\u7684\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff08\u5982 Amazon S3\u3001Aliyun OSS\u3001\u6587\u4ef6\u7cfb\u7edf\u7b49\uff09\uff0c\u8fd9\u4e2a URL \u7684\u5185\u5bb9\u53ef\u80fd\u6709\u6240\u4e0d\u540c\u3002\u4f8b\u5982\uff1as3.us-west-2.amazonaws.com
CREDENTIALS
\uff1a\u8fd9\u662f\u4e00\u4e2a JSON \u5bf9\u8c61\uff0c\u5305\u542b\u8fde\u63a5\u5230\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\u6240\u9700\u7684\u51ed\u8bc1\u4fe1\u606f\uff0c
access_key_id
\uff1a\u7528\u4e8e\u8eab\u4efd\u9a8c\u8bc1\u7684\u8bbf\u95ee\u5bc6\u94a5 ID\u3002secret_access_key
\uff1a\u4e0e\u8bbf\u95ee\u5bc6\u94a5 ID \u76f8\u5173\u8054\u7684\u5bc6\u94a5\u3002\"filepath\"='<string>
\uff1a\u6307\u5b9a S3 \u5b58\u50a8\u4e2d\u7684\u6587\u4ef6\u8def\u5f84\u6216\u76ee\u5f55\u3002\"region\"='<string>'
\uff1a\u6307\u5b9a Amazon S3 \u5b58\u50a8\u6240\u5728\u7684 AWS \u533a\u57df\u3002directoryTableParams
\uff1a\u8fd9\u662f\u4e00\u4e2a\u53c2\u6570\u7ec4\uff0c\u7528\u4e8e\u6307\u5b9a Stage \u7684\u76ee\u5f55\u8868\uff08directory table\uff09\u7684\u914d\u7f6e\u3002
ENABLE
\uff1a\u662f\u5426\u542f\u7528\u76ee\u5f55\u8868\uff0c\u503c\u4e3a TRUE
\u6216 FALSE
\u3002CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\n-- \u5f53\u8bbe\u7f6e\u597d\u6570\u636e\u9636\u6bb5\u4ee5\u540e\uff0c\u6570\u636e\u8868\u53ea\u80fd\u5bfc\u51fa\u5230\u6307\u5b9a\u8def\u5f84\uff0c\u5bfc\u51fa\u5230\u5176\u4ed6\u8def\u5f84\u5c06\u62a5\u9519\nmysql> SELECT * FROM user INTO OUTFILE '~/tmp/csv2/user.txt';\nERROR 20101 (HY000): internal error: stage exists, please try to check and use a stage instead\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/","title":"CREATE...FROM...PUBLICATION...","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE...FROM...PUBLICATION...
\u662f\u8ba2\u9605\u65b9\u8ba2\u9605\u4e00\u4e2a\u7531\u53d1\u5e03\u65b9\u521b\u5efa\u7684\u53d1\u5e03\uff0c\u7528\u6765\u83b7\u53d6\u53d1\u5e03\u65b9\u7684\u5171\u4eab\u6570\u636e\u3002
CREATE DATABASE database_name\nFROM account_name\nPUBLICATION pubname;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-subscription/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"-- \u5047\u8bbe\u7cfb\u7edf\u7ba1\u7406\u5458\u521b\u5efa\u4e86\u4e00\u4e2a\u79df\u6237 acc1 \u4e3a\u8ba2\u9605\u65b9\ncreate account acc1 admin_name 'root' identified by '111';\n\n-- \u5047\u8bbe\u4f1a\u8bdd 1 \u4e3a\u53d1\u5e03\u65b9\uff0c\u7531\u53d1\u5e03\u65b9\u5148\u53d1\u5e03\u4e00\u4e2a\u6570\u636e\u5e93\u7ed9\u79df\u6237\ncreate database sys_db_1;\nuse sys_db_1;\ncreate table sys_tbl_1(a int primary key );\ninsert into sys_tbl_1 values(1),(2),(3);\ncreate view v1 as (select * from sys_tbl_1);\ncreate publication sys_pub_1 database sys_db_1;\nmysql> show publications;\n+-------------+----------+---------------------+-------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+-------------+-------------+----------+\n| sys_pub_1 | sys_db_1 | 2024-04-24 11:54:36 | NULL | * | |\n+-------------+----------+---------------------+-------------+-------------+----------+\n1 row in set (0.01 sec)\n\n-- \u518d\u5f00\u542f\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\uff0c\u5047\u8bbe\u4f1a\u8bdd 2 \u4e3a\u8ba2\u9605\u65b9\uff0c\u7531\u8ba2\u9605\u65b9\u8ba2\u9605\u5df2\u53d1\u5e03\u7684\u6570\u636e\u5e93\nmysql -h 127.0.0.1 -P 6001 -u acc1:root -p --\u767b\u5f55\u79df\u6237\u8d26\u53f7\n\ncreate database sub1 from sys publication sys_pub_1;\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| sub1 |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\nmysql> show subscriptions;\n+-----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+-----------+-------------+--------------+---------------------+----------+---------------------+\n| sys_pub_1 | sys | sys_db_1 | 2024-04-24 11:54:36 | sub1 | 2024-04-24 11:56:05 |\n+-----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.01 sec)\n\nmysql> use sub1;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| Tables_in_sub1 |\n+----------------+\n| sys_tbl_1 |\n| v1 |\n+----------------+\n2 rows in set (0.01 sec)\n\nmysql> desc sys_tbl_1;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | NO | PRI | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\nmysql> select * from sys_tbl_1 order by a;\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.01 sec)\n-- \u8ba2\u9605\u6210\u529f\n
Note
\u5982\u679c\u9700\u8981\u53d6\u6d88\u8ba2\u9605\uff0c\u53ef\u4ee5\u76f4\u63a5\u5220\u9664\u5df2\u8ba2\u9605\u7684\u6570\u636e\u5e93\u540d\u79f0\uff0c\u4f7f\u7528 DROP DATABASE
\u3002
CREATE TABLE AS SELECT
\u547d\u4ee4\u901a\u8fc7\u590d\u5236 SELECT
\u67e5\u8be2\u4e2d\u6307\u5b9a\u7684\u73b0\u6709\u8868\u4e2d\u7684\u5217\u5b9a\u4e49\u548c\u5217\u6570\u636e\u6765\u521b\u5efa\u65b0\u8868\u3002\u7136\u800c\uff0c\u5b83\u4e0d\u4f1a\u590d\u5236\u539f\u8868\u7684\u7ea6\u675f\u3001\u7d22\u5f15\u3001\u89c6\u56fe\u6216\u5176\u4ed6\u975e\u6570\u636e\u5c5e\u6027\u3002
> CREATE [TEMPORARY] TABLE [ IF NOT EXISTS ] table_name\n[ (column_name [, ...] ) ] AS {query}\n\nQuery can be any select statement in MO syntax.\n\nSELECT\n[ALL | DISTINCT ]\nselect_expr [, select_expr] [[AS] alias] ...\n[INTO variable [, ...]]\n[FROM table_references\n[WHERE where_condition]\n[GROUP BY {col_name | expr | position}\n[ASC | DESC]]\n[HAVING where_condition]\n[ORDER BY {col_name | expr | position}\n[ASC | DESC]] [ NULLS { FIRST | LAST } ]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-as-select/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"ALL\uff1a\u9ed8\u8ba4\u9009\u9879\uff0c\u8868\u793a\u8fd4\u56de\u6240\u6709\u5339\u914d\u7684\u884c\uff0c\u5305\u62ec\u91cd\u590d\u884c\u3002
DISTINCT\uff1a\u8868\u793a\u53ea\u8fd4\u56de\u552f\u4e00\u7684\u884c\uff0c\u5373\u53bb\u9664\u91cd\u590d\u884c\u3002
select_expr\uff1a\u8868\u793a\u8981\u9009\u62e9\u7684\u5217\u6216\u8868\u8fbe\u5f0f\u3002
AS alias\uff1a\u4e3a\u9009\u62e9\u7684\u5217\u6216\u8868\u8fbe\u5f0f\u6307\u5b9a\u4e00\u4e2a\u522b\u540d\u3002
[INTO variable[, ...]\uff1a\u7528\u4e8e\u5c06\u67e5\u8be2\u7ed3\u679c\u5b58\u50a8\u5728\u4e00\u4e2a\u53d8\u91cf\u4e2d\uff0c\u800c\u4e0d\u662f\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002
[FROM table_references]\uff1a\u6307\u5b9a\u4ece\u54ea\u4e2a\u8868\u6216\u54ea\u4e9b\u8868\u4e2d\u68c0\u7d22\u6570\u636e\u3002table_references \u53ef\u4ee5\u662f\u4e00\u4e2a\u8868\u540d\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u5305\u542b\u591a\u4e2a\u8868\u7684\u590d\u6742\u8868\u8fbe\u5f0f\uff08\u5982\u8fde\u63a5\uff09\u3002
[WHERE where_condition]\uff1a\u7528\u4e8e\u8fc7\u6ee4\u7ed3\u679c\u96c6\uff0c\u53ea\u8fd4\u56de\u6ee1\u8db3 where_condition \u6761\u4ef6\u7684\u884c\u3002
[GROUP BY {col_name | expr | position} [ASC | DESC]]\uff1a\u7528\u4e8e\u5c06\u7ed3\u679c\u96c6\u6309\u7167\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u6216\u8868\u8fbe\u5f0f\u8fdb\u884c\u5206\u7ec4\uff1bASC \u548c DESC \u7528\u4e8e\u6307\u5b9a\u5206\u7ec4\u5185\u884c\u7684\u6392\u5e8f\u65b9\u5f0f\u3002
[HAVING where_condition]\uff1a\u5728\u5206\u7ec4\u540e\u5bf9\u5206\u7ec4\u8fdb\u884c\u8fc7\u6ee4\u3002\u901a\u5e38\u4e0e GROUP BY \u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u8fc7\u6ee4\u6389\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u5206\u7ec4\u3002
[ORDER BY {col_name | expr | position} [ASC | DESC] [NULLS {FIRST | LAST}]]\uff1a\u7528\u4e8e\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u6392\u5e8f; ASC \u548c DESC \u7528\u4e8e\u6307\u5b9a\u6392\u5e8f\u65b9\u5f0f\u3002
[NULLS {FIRST | LAST}]\uff1a\u7528\u4e8e\u6307\u5b9a\u5982\u4f55\u5904\u7406 NULL \u503c\u5728\u6392\u5e8f\u4e2d\u7684\u4f4d\u7f6e\u3002
[LIMIT {[offset,] row_count | row_count OFFSET offset}]\uff1a\u7528\u4e8e\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570\u3002offset \u6307\u5b9a\u4ece\u7ed3\u679c\u96c6\u7684\u54ea\u4e00\u884c\u5f00\u59cb\u8fd4\u56de\uff0c0 \u4e3a\u7b2c\u4e00\u884c\u3002row_count \u6307\u5b9a\u8fd4\u56de\u7684\u884c\u6570\u3002
\u5728 Matrixone
\u4e2d\uff0c\u6267\u884c CREATE TABLE AS SELECT
\u8bed\u53e5\u9700\u8981\u5177\u6709\u81f3\u5c11\u4ee5\u4e0b\u6743\u9650\uff1a
CREATE
\u6743\u9650\uff1a\u7528\u6237\u9700\u8981\u5177\u6709\u521b\u5efa\u8868\u7684\u6743\u9650\uff0c\u8fd9\u53ef\u4ee5\u901a\u8fc7 CREATE
\u6743\u9650\u6765\u5b9e\u73b0\u3002
INSERT
\u6743\u9650\uff1a\u7531\u4e8e CREATE TABLE AS SELECT
\u8bed\u53e5\u5c06\u9009\u62e9\u7684\u6570\u636e\u63d2\u5165\u5230\u65b0\u8868\u4e2d\uff0c\u56e0\u6b64\u7528\u6237\u8fd8\u9700\u8981\u5177\u6709\u5411\u76ee\u6807\u8868\u63d2\u5165\u6570\u636e\u7684\u6743\u9650\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7 INSERT
\u6743\u9650\u6765\u5b9e\u73b0\u3002
SELECT
\u6743\u9650\uff1a\u7528\u6237\u9700\u8981\u80fd\u591f\u9009\u62e9\u6e90\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff0c\u56e0\u6b64\u9700\u8981\u5177\u6709 SELECT \u6743\u9650\u3002
\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6743\u9650\u76f8\u5173\u7684\u64cd\u4f5c\uff0c\u8bf7\u67e5\u770b Matrixone \u6743\u9650\u5206\u7c7b\u5217\u8868\u548c grant \u8bf4\u660e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-as-select/#_5","title":"\u793a\u4f8b","text":"create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> create table t2 as select *from t1;--\u6574\u8868\u590d\u5236\nQuery OK, 3 rows affected (0.02 sec)\n\nmysql> desc t2;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | 123 | | |\n| b | CHAR(5) | YES | | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t2;\n+------------+------+\n| a | b |\n+------------+------+\n| 1 | 1 |\n| 2 | 2 |\n| 2147483647 | max |\n+------------+------+\n3 rows in set (0.00 sec)\n
create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> CREATE table test as select a as alias_a from t1;--\u4e3a\u9009\u62e9\u5217\u6307\u5b9a\u522b\u540d\nQuery OK, 3 rows affected (0.02 sec)\n\nmysql> desc test;\n+---------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+---------+---------+------+------+---------+-------+---------+\n| alias_a | INT(32) | YES | | 123 | | |\n+---------+---------+------+------+---------+-------+---------+\n1 row in set (0.01 sec)\n\nmysql> select * from test;\n+------------+\n| alias_a |\n+------------+\n| 1 |\n| 2 |\n| 2147483647 |\n+------------+\n3 rows in set (0.01 sec)\n
create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> create table t3 as select * from t1 where 1=2;--\u53ea\u590d\u5236\u5b57\u6bb5\uff0c\u4e0d\u590d\u5236\u6570\u636e\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> desc t3;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | 123 | | |\n| b | CHAR(5) | YES | | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t3;\nEmpty set (0.00 sec)\n
create table t1(a int default 123, b char(5));\nINSERT INTO t1 values (1, '1'),(2,'2'),(0x7fffffff, 'max');\n\nmysql> CREATE table t4(n1 int unique) as select max(a) from t1;--\u4ee5\u539f\u8868\u6570\u636e\u805a\u5408\u503c\u4f5c\u4e3a\u65b0\u8868\u7684\u5217\nQuery OK, 1 row affected (0.03 sec)\n\nmysql> desc t4;\n+--------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+--------+---------+------+------+---------+-------+---------+\n| n1 | INT(32) | YES | UNI | NULL | | |\n| max(a) | INT(32) | YES | | NULL | | |\n+--------+---------+------+------+---------+-------+---------+\n2 rows in set (0.01 sec)\n\nmysql> select * from t4;\n+------+------------+\n| n1 | max(a) |\n+------+------------+\n| NULL | 2147483647 |\n+------+------------+\n1 row in set (0.00 sec)\n
create table t5(n1 int,n2 int,n3 int);\ninsert into t5 values(1,1,1),(1,1,1),(3,3,3);\n\nmysql> create table t5_1 as select distinct n1 from t5;--\u53bb\u9664\u91cd\u590d\u884c\nQuery OK, 2 rows affected (0.02 sec)\n\nmysql> select * from t5_1;\n+------+\n| n1 |\n+------+\n| 1 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n
create table t6(n1 int,n2 int,n3 int);\ninsert into t6 values(1,1,3),(2,2,2),(3,3,1);\n\nmysql> create table t6_1 as select * from t6 order by n3;--\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u6392\u5e8f\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> select * from t6_1;\n+------+------+------+\n| n1 | n2 | n3 |\n+------+------+------+\n| 3 | 3 | 1 |\n| 2 | 2 | 2 |\n| 1 | 1 | 3 |\n+------+------+------+\n3 rows in set (0.01 sec)\n
create table t7(n1 int,n2 int,n3 int);\ninsert into t7 values(1,1,3),(1,2,2),(2,3,1),(2,3,1),(3,3,1);\n\nmysql> CREATE TABLE t7_1 AS SELECT n1 FROM t7 GROUP BY n1 HAVING count(n1)>1;--\u5bf9\u7ed3\u679c\u96c6\u8fdb\u884c\u5206\u7ec4\nQuery OK, 2 rows affected (0.02 sec)\n\nmysql> mysql> select * from t7_1;\n+------+\n| n1 |\n+------+\n| 1 |\n| 2 |\n+------+\n2 rows in set (0.01 sec)\n
create table t8(n1 int,n2 int,n3 int);\ninsert into t8 values(1,1,1),(2,2,2),(3,3,3);\n\nmysql> CREATE TABLE t8_1 AS SELECT * FROM t8 limit 1 offset 1;--\u6307\u5b9a\u4ece\u7ed3\u679c\u96c6\u7684\u7b2c\u4e8c\u884c\u5f00\u59cb\u8fd4\u56de\uff0c\u8fd4\u56de\u884c\u6570\u4e3a 1\n\nmysql> select * from t8_1;\n+------+------+------+\n| n1 | n2 | n3 |\n+------+------+------+\n| 2 | 2 | 2 |\n+------+------+------+\n1 row in set (0.00 sec)\n
create table t9 (a int primary key, b varchar(5) unique key);\ncreate table t9_1 (\na int primary key,\nb varchar(5) unique,\nc int , d int,\nforeign key(c) references t9(a),\nINDEX idx_d(d)\n);\ninsert into t9 values (101,'abc'),(102,'def');\ninsert into t9_1 values (1,'zs1',101,1),(2,'zs2',102,1);\n\nmysql> create table t9_2 as select * from t9_1;\n\nmysql> show create table t9_1;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t9_1 | CREATE TABLE `t9_1` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` INT DEFAULT NULL,\n`d` INT DEFAULT NULL,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nKEY `idx_d` (`d`),\nCONSTRAINT `018f27eb-0b33-7289-a3c2-af479b1833b1` FOREIGN KEY (`c`) REFERENCES `t9` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> show create table t9_2;--\u6e90\u8868\u5e26\u7ea6\u675f\u6216\u8005\u7d22\u5f15\uff0cCTAS \u521b\u5efa\u7684\u65b0\u8868\u9ed8\u8ba4\u4e0d\u4f1a\u5e26\u6709\u539f\u8868\u7684\u7ea6\u675f\u548c\u7d22\u5f15\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| t9_2 | CREATE TABLE `t9_2` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` INT DEFAULT NULL,\n`d` INT DEFAULT NULL\n) |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n--\u5982\u679c\u5e0c\u671b\u65b0\u8868\u5e26\u6709\u539f\u8868\u5e26\u7ea6\u675f\u548c\u7d22\u5f15\uff0c\u5219\u53ef\u4ee5\u5728\u5efa\u8868\u540e\u6dfb\u52a0\nALTER TABLE t9_2 ADD PRIMARY KEY (a);\nALTER TABLE t9_2 ADD UNIQUE KEY (b);\nALTER TABLE t9_2 ADD FOREIGN KEY (c) REFERENCES t9 (a);\nALTER TABLE t9_2 ADD INDEX idx_d3 (d);\n\nmysql> show create table t9_2;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t9_2 | CREATE TABLE `t9_2` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` INT DEFAULT NULL,\n`d` INT DEFAULT NULL,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nKEY `idx_d3` (`d`),\nCONSTRAINT `018f282d-4563-7e9d-9be5-79c0d0e8136d` FOREIGN KEY (`c`) REFERENCES `t9` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-like/","title":"CREATE TABLE ... LIKE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-like/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE TABLE ... LIKE
\u6839\u636e\u53e6\u4e00\u4e2a\u8868\u7684\u5b9a\u4e49\u521b\u5efa\u4e00\u4e2a\u7a7a\u8868\uff0c\u5b83\u4f1a\u590d\u5236\u539f\u59cb\u8868\u7684\u7ed3\u6784\uff0c\u4f46\u4e0d\u4f1a\u590d\u5236\u539f\u59cb\u8868\u4e2d\u5b58\u50a8\u7684\u6570\u636e\u3002
CREATE TABLE new_tbl LIKE orig_tbl;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table-like/#_3","title":"\u793a\u4f8b","text":"create table test1 (a int primary key, b varchar(5) unique key);\ncreate table test2 (a int primary key,b varchar(5) unique key,c double DEFAULT 0, d char,e int, foreign key(e) references foreign01(a), unique index(c,d));\ninsert into test1 values (101,'abc'),(102,'def');\ninsert into test2 values (1,'zs1',1,'a',101),(2,'zs2',2,'b',102);\n\nmysql> create table test3 like test2;\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> show CREATE TABLE test2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| test2 | CREATE TABLE `test2` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT NULL,\n`c` DOUBLE DEFAULT 0,\n`d` CHAR(1) DEFAULT NULL,\n`e` INT DEFAULT NULL,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nUNIQUE KEY `c` (`c`,`d`),\nCONSTRAINT `018eb74f-38f3-7eb4-80c1-95d9c65de706` FOREIGN KEY (`e`) REFERENCES `foreign01` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> show CREATE TABLE test3;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| test3 | CREATE TABLE `test3` (\n`a` INT NOT NULL,\n`b` VARCHAR(5) DEFAULT null,\n`c` DOUBLE DEFAULT 0,\n`d` CHAR(1) DEFAULT null,\n`e` INT DEFAULT null,\nPRIMARY KEY (`a`),\nUNIQUE KEY `b` (`b`),\nUNIQUE KEY `c` (`c`,`d`),\nCONSTRAINT `018eb74f-38f3-7eb4-80c1-95d9c65de706` FOREIGN KEY (`e`) REFERENCES `foreign01` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from test2;\n+------+------+------+------+------+\n| a | b | c | d | e |\n+------+------+------+------+------+\n| 1 | zs1 | 1 | a | 101 |\n| 2 | zs2 | 2 | b | 102 |\n+------+------+------+------+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from test3;\nEmpty set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/","title":"CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CREATE TABLE
\u8bed\u53e5\u7528\u4e8e\u5728\u5f53\u524d\u6240\u9009\u6570\u636e\u5e93\u521b\u5efa\u4e00\u5f20\u65b0\u8868\u3002
> CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name\n (create_definition,...)\n [table_options]\n [partition_options]\n\ncreate_definition: {\n col_name column_definition\n | [CONSTRAINT [symbol]] PRIMARY KEY\n [index_type] (key_part,...)\n [index_option] ...\n | [CONSTRAINT [symbol]] FOREIGN KEY\n [index_name] (col_name,...)\n reference_definition\n}\n\ncolumn_definition: {\n data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]\n [AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]\n [COMMENT 'string']\n [reference_definition]\n | data_type\n [[PRIMARY] KEY]\n [COMMENT 'string']\n [reference_definition]\n}\n\nreference_definition:\n REFERENCES tbl_name (key_part,...)\n [ON DELETE reference_option]\n [ON UPDATE reference_option]\n\nreference_option:\n RESTRICT | CASCADE | SET NULL | NO ACTION\n\ntable_options:\n table_option [[,] table_option] ...\n\ntable_option: {\n | AUTO_INCREMENT [=] value\n | COMMENT [=] 'string'\n | START TRANSACTION\n}\n\npartition_options:\n PARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)}\n | RANGE{(expr) | COLUMNS(column_list)}\n | LIST{(expr) | COLUMNS(column_list)} }\n [PARTITIONS num]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n [VALUES\n {LESS THAN {(expr | value_list) | MAXVALUE}\n |\n IN (value_list)}]\n [COMMENT [=] 'string' ]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"\u521b\u5efa\u8868\u65f6\u53ef\u4ee5\u4f7f\u7528\u7684\u5404\u79cd\u53c2\u6570\u548c\u9009\u9879\uff0c\u5305\u62ec\u8868\u7684\u521b\u5efa\u3001\u5217\u7684\u5b9a\u4e49\u3001\u7ea6\u675f\u3001\u9009\u9879\u548c\u5206\u533a\u7b49\u3002
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
\uff1a\u8fd9\u662f\u521b\u5efa\u8868\u7684\u57fa\u672c\u8bed\u6cd5\u3002TEMPORARY
\u5173\u952e\u5b57\u8868\u793a\u521b\u5efa\u4e34\u65f6\u8868\uff0cIF NOT EXISTS
\u8868\u793a\u5982\u679c\u8868\u4e0d\u5b58\u5728\u5219\u521b\u5efa\uff0ctbl_name
\u662f\u8981\u521b\u5efa\u7684\u8868\u7684\u540d\u79f0\u3002
(create_definition,...)
\uff1a\u8fd9\u662f\u5217\u5b9a\u4e49\u7684\u90e8\u5206\uff0c\u7528\u6765\u5b9a\u4e49\u8868\u7684\u5404\u4e2a\u5217\u4ee5\u53ca\u76f8\u5173\u5c5e\u6027\u3002
[table_options]
\uff1a\u8fd9\u662f\u8868\u7ea7\u522b\u7684\u9009\u9879\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u8868\u7684\u5b58\u50a8\u5f15\u64ce\u3001\u5b57\u7b26\u96c6\u7b49\u53c2\u6570\u3002
[partition_options]
\uff1a\u8fd9\u662f\u7528\u4e8e\u5206\u533a\u8868\u7684\u9009\u9879\uff0c\u7528\u6765\u5b9a\u4e49\u5206\u533a\u65b9\u5f0f\u548c\u5206\u533a\u952e\u3002
create_definition
\u90e8\u5206\u7528\u4e8e\u5b9a\u4e49\u6bcf\u4e00\u5217\u7684\u5c5e\u6027\uff0c\u5b83\u53ef\u4ee5\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1a
col_name column_definition
\uff1a\u5b9a\u4e49\u5177\u4f53\u5217\u540d\u4ee5\u53ca\u5217\u7684\u5c5e\u6027\uff0c\u5305\u62ec\u6570\u636e\u7c7b\u578b\u3001\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a\u3001\u9ed8\u8ba4\u503c\u7b49\u3002
[CONSTRAINT [symbol]] PRIMARY KEY
\uff1a\u5b9a\u4e49\u4e3b\u952e\u7ea6\u675f\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u7ea6\u675f\u540d\u79f0\u548c\u4e3b\u952e\u7684\u5217\u3002
[CONSTRAINT [symbol]] FOREIGN KEY
\uff1a\u5b9a\u4e49\u5916\u952e\u7ea6\u675f\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u7ea6\u675f\u540d\u79f0\u3001\u5916\u952e\u7684\u5217\u4ee5\u53ca\u53c2\u8003\u7684\u8868\u3002
column_definition
\u90e8\u5206\u7528\u4e8e\u5177\u4f53\u5217\u7684\u5b9a\u4e49\uff0c\u53ef\u4ee5\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1a
data_type [NOT NULL | NULL] [DEFAULT {literal | (expr)} ]
\uff1a\u5b9a\u4e49\u5217\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4ee5\u53ca\u662f\u5426\u5141\u8bb8\u4e3a\u7a7a\u548c\u9ed8\u8ba4\u503c\u3002
[AUTO_INCREMENT] [UNIQUE [KEY]] [[PRIMARY] KEY]
\uff1a\u8bbe\u7f6e\u81ea\u589e\u3001\u552f\u4e00\u548c\u4e3b\u952e\u7ea6\u675f\u3002
[COMMENT 'string']
\uff1a\u8bbe\u7f6e\u5217\u7684\u6ce8\u91ca\u3002
[reference_definition]
\uff1a\u53ef\u9009\u7684\u5f15\u7528\u5b9a\u4e49\uff0c\u7528\u4e8e\u5b9a\u4e49\u5916\u952e\u7ea6\u675f\u3002
reference_definition
\u90e8\u5206\u7528\u4e8e\u5b9a\u4e49\u5916\u952e\u5f15\u7528\uff0c\u5305\u62ec\u4ee5\u4e0b\u5185\u5bb9\uff1a
REFERENCES tbl_name (key_part,...)
\uff1a\u6307\u5b9a\u5916\u952e\u5f15\u7528\u7684\u8868\u548c\u5217\u3002
[ON DELETE reference_option]
\uff1a\u8bbe\u7f6e\u5728\u5220\u9664\u65f6\u7684\u5916\u952e\u64cd\u4f5c\u3002
[ON UPDATE reference_option]
\uff1a\u8bbe\u7f6e\u5728\u66f4\u65b0\u65f6\u7684\u5916\u952e\u64cd\u4f5c\u3002
reference_option
\u8868\u793a\u5916\u952e\u64cd\u4f5c\u7684\u9009\u9879\uff0c\u53ef\u4ee5\u662f RESTRICT
\u3001CASCADE
\u3001SET NULL
\u6216 NO ACTION
\u3002
table_options
\u90e8\u5206\u7528\u4e8e\u8bbe\u7f6e\u8868\u7ea7\u522b\u7684\u9009\u9879\uff0c\u5305\u62ec\u81ea\u589e\u7684\u521d\u59cb\u503c\u3001\u8868\u7684\u6ce8\u91ca\u7b49\u3002
partition_options
\u90e8\u5206\u7528\u4e8e\u5b9a\u4e49\u5206\u533a\u8868\u7684\u9009\u9879\uff0c\u5305\u62ec\u5206\u533a\u65b9\u5f0f\u3001\u5206\u533a\u952e\u4ee5\u53ca\u5206\u533a\u6570\u7b49\u3002
\u66f4\u8be6\u7ec6\u7684\u53c2\u6570\u8bed\u6cd5\u91ca\u4e49\u8bf7\u53c2\u89c1\u4e0b\u6587\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#temporary","title":"TEMPORARY","text":"\u5728\u521b\u5efa\u8868\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 TEMPORARY
\u5173\u952e\u5b57\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u8868\u3002TEMPORARY
\u8868\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u53ef\u89c1\uff0c\u5728\u4f1a\u8bdd\u5173\u95ed\u65f6\u81ea\u52a8\u5220\u9664\u3002\u8fd9\u8868\u793a\u4e24\u4e2a\u4e0d\u540c\u7684\u4f1a\u8bdd\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u4e34\u65f6\u8868\u540d\uff0c\u800c\u4e0d\u4f1a\u5f7c\u6b64\u51b2\u7a81\u6216\u4e0e\u540c\u540d\u7684\u73b0\u6709\u975e\u4e34\u65f6\u8868\u51b2\u7a81\u3002(\u5728\u5220\u9664\u4e34\u65f6\u8868\u4e4b\u524d\uff0c\u4f1a\u9690\u85cf\u73b0\u6709\u8868\u3002)
\u5220\u9664\u6570\u636e\u5e93\u4f1a\u81ea\u52a8\u5220\u9664\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u7684\u6240\u6709 TEMPORARY
\u8868\u3002
\u521b\u5efa\u4f1a\u8bdd\u53ef\u4ee5\u5bf9\u8868\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\uff0c\u4f8b\u5982 DROP table
\u3001INSERT
\u3001UPDATE
\u6216 SELECT
\u3002
\u53ef\u4ee5\u4f7f\u7528 comment
\u9009\u9879\u6307\u5b9a\u5217\u6216\u6574\u5f20\u8868\u7684\u6ce8\u91ca\uff1a
CREATE TABLE [IF NOT EXISTS] [db.]table_name [comment = \"comment of table\"];
\u4e2d\u7684 comment
\u4e3a\u6574\u5f20\u8868\u7684\u6ce8\u91ca\uff0c\u6700\u957f 2049 \u4e2a\u5b57\u7b26\u3002(name1 type1 [comment 'comment of column'],...)
\u4e2d\u7684 comment
\u4e3a\u6307\u5b9a\u5217\u7684\u6ce8\u91ca\uff1a\u6700\u957f 1024 \u4e2a\u5b57\u7b26\u3002\u4f7f\u7528 SHOW CREATE TABLE
\u548c SHOW FULL COLUMNS
\u8bed\u53e5\u663e\u793a\u6ce8\u91ca\u5185\u5bb9\u3002\u6ce8\u91ca\u5185\u5bb9\u4e5f\u663e\u793a\u5728 INFORMATION_SCHEMA.COLUMN_COMMENT
\u5217\u4e2d\u3002
AUTO_INCREMENT
\uff1a\u8868\u7684\u521d\u59cb\u503c\uff0c\u521d\u59cb\u503c\u9ed8\u8ba4\u4ece 1 \u5f00\u59cb\uff0c\u6bcf\u6761\u65b0\u7eaa\u5f55\u9012\u589e 1\uff0c\u4e14\u6570\u636e\u5217\u7684\u503c\u5fc5\u987b\u552f\u4e00\u3002
AUTO_INCREMENT
\u7684\u5217\uff0c\u9700\u4e3a\u6574\u6570\u6216\u8005\u6d6e\u70b9\u6570\u636e\u7c7b\u578b\u3002\u81ea\u589e\u5217\u9700\u8981\u8bbe\u7f6e\u4e3a NOT NULL
\uff0c\u5426\u5219\u4f1a\u76f4\u63a5\u5b58\u50a8 NULL
\u3002\u5f53\u4f60\u5c06 NULL\uff08\u63a8\u8350\uff09\u6216 0 \u503c\u63d2\u5165\u7d22\u5f15\u7684 AUTO_INCREMENT
\u5217\u65f6\uff0c\u8be5\u5217\u5c06\u8bbe\u7f6e\u4e3a\u4e0b\u4e00\u4e2a\u5e8f\u5217\u503c\u3002\u901a\u5e38\u8fd9\u662f value+1\uff0c\u5176\u4e2d value \u662f\u8868\u4e2d\u5f53\u524d\u5217\u7684\u6700\u5927\u503c\u3002
\u6bcf\u4e2a\u8868\u53ea\u80fd\u6709\u4e00\u4e2a AUTO_INCREMENT
\u5217\uff0c\u5b83\u5fc5\u987b\u53ef\u4ee5\u88ab\u7d22\u5f15\uff0c\u4e14\u4e0d\u80fd\u8bbe\u7f6e\u9ed8\u8ba4\u503c\u3002AUTO_INCREMENT
\u5217\u9700\u8981\u542b\u6709\u6b63\u6570\u503c\uff0c\u5982\u679c\u63d2\u5165\u4e00\u4e2a\u8d1f\u6570\u88ab\u5224\u65ad\u4e3a\u63d2\u5165\u4e00\u4e2a\u975e\u5e38\u5927\u7684\u6b63\u6570\uff0c\u8fd9\u6837\u505a\u662f\u4e3a\u4e86\u907f\u514d\u6570\u5b57\u51fa\u73b0\u7cbe\u5ea6\u95ee\u9898\uff0c\u5e76\u786e\u4fdd\u4e0d\u4f1a\u610f\u5916\u51fa\u73b0\u5305\u542b 0 \u7684 AUTO_INCREMENT
\u5217\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 AUTO_INCREMENT
\u5c5e\u6027\u6765\u5b9a\u4e49\u81ea\u589e\u5217\u7684\u8d77\u59cb\u503c\u3002\u5982\u679c\u8981\u8bbe\u7f6e\u81ea\u589e\u5217\u7684\u8d77\u59cb\u503c\u4e3a 10\uff0c\u53ef\u4ee5\u5728\u521b\u5efa\u8868\u65f6\u4f7f\u7528 AUTO_INCREMENT
\u5173\u952e\u5b57\uff0c\u5e76\u5728\u540e\u9762\u6307\u5b9a\u8d77\u59cb\u503c\u3002
\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u8868\u5e76\u5b9a\u4e49\u81ea\u589e\u5217\u7684\u8d77\u59cb\u503c\u4e3a 10\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\uff1a
-- \u8bbe\u7f6e\ncreate table t1(id int auto_increment primary key) auto_increment = 10;\n
\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cid
\u5217\u662f\u81ea\u589e\u5217\uff0c\u5176\u8d77\u59cb\u503c\u4e3a 10\uff0c\u5f53\u5411\u8868\u4e2d\u63d2\u5165\u65b0\u8bb0\u5f55\u65f6\uff0cid
\u5217\u7684\u503c\u5c06\u4ece 10 \u5f00\u59cb\uff0c\u6bcf\u6b21\u81ea\u52a8\u9012\u589e 1\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a AUTO_INCREMENT
\u7684\u8d77\u59cb\u503c\uff0c\u9ed8\u8ba4\u8d77\u59cb\u503c\u4e3a 1\uff0c\u6bcf\u6b21\u81ea\u52a8\u9012\u589e 1\u3002
Note
set @@auto_increment_offset=n
\u6765\u8bbe\u7f6e\u81ea\u589e\u5217\u521d\u59cb\u503c\uff0c\u5b9e\u9645\u5e76\u4e0d\u751f\u6548\u3002PRIMARY KEY
\u5373\u4e3b\u952e\u7ea6\u675f\uff0c\u7528\u4e8e\u552f\u4e00\u6807\u793a\u8868\u4e2d\u7684\u6bcf\u6761\u6570\u636e\u3002 \u4e3b\u952e\u5fc5\u987b\u5305\u542b UNIQUE
\u503c\uff0c\u4e0d\u80fd\u5305\u542b NULL
\u503c\u3002 \u5f53\u524d\u7248\u672c\u4e00\u4e2a\u8868\u53ea\u80fd\u6709\u4e00\u4e2a\u4e3b\u952e\uff0c\u8fd9\u4e2a\u4e3b\u952e\u53ef\u4ee5\u7531\u4e00\u4e2a\u5217\u7ec4\u6210\uff0c\u4e5f\u53ef\u4ee5\u7531\u591a\u4e2a\u5217\u7ec4\u6210\u3002
\u4ee5\u4e0b SQL \u8bed\u53e5\u5728\u521b\u5efa Persons
\u8868\u65f6\uff0c\u5728\u5176\u4e2d\u7684 ID
\u5217\u521b\u5efa\u4e3b\u952e\uff1a
> CREATE TABLE Persons (\n ID int NOT NULL,\n LastName varchar(255) NOT NULL,\n FirstName varchar(255),\n Age int,\n PRIMARY KEY (ID)\n);\n
Note
\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u53ea\u6709\u4e00\u4e2a\u4e3b\u952e\uff0c\u5e76\u4e14\u5176\u4e2d\u4ec5\u5305\u542b\u4e86\u4e00\u5217\uff08ID
\uff09
\u800c\u4e0b\u9762 SQL \u8bed\u53e5\u5728\u521b\u5efa Students
\u8868\u65f6\uff0c\u5728\u5176\u4e2d\u7684 ID
\u548c LastName
\u5217\u521b\u5efa\u4e3b\u952e\uff1a
> CREATE TABLE Students (\n ID int NOT NULL,\n LastName varchar(255) NOT NULL,\n FirstName varchar(255),\n Age int,\n PRIMARY KEY (ID,LastName)\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#foreign-key","title":"FOREIGN KEY","text":"FOREIGN KEY \u7ea6\u675f\uff0c\u5373\u5916\u952e\u7ea6\u675f\uff0c\u662f\u8868\u7684\u4e00\u4e2a\u7279\u6b8a\u5b57\u6bb5\uff0c\u7ecf\u5e38\u4e0e\u4e3b\u952e\u7ea6\u675f\u4e00\u8d77\u4f7f\u7528\u3002\u5916\u952e\u7ea6\u675f\u662f\u7528\u4e8e\u9632\u6b62\u7834\u574f\u8868\u4e4b\u95f4\u94fe\u63a5\u7684\u884c\u4e3a\u3002\u5bf9\u4e8e\u4e24\u4e2a\u5177\u6709\u5173\u8054\u5173\u7cfb\u7684\u8868\u800c\u8a00\uff0c\u76f8\u5173\u8054\u5b57\u6bb5\u4e2d\u4e3b\u952e\u6240\u5728\u7684\u8868\u5c31\u662f\u4e3b\u8868\uff08\u7236\u8868\uff09\uff0c\u5916\u952e\u6240\u5728\u7684\u8868\u5c31\u662f\u4ece\u8868\uff08\u5b50\u8868\uff09\u3002\u5916\u952e\u7528\u6765\u5efa\u7acb\u4e3b\u8868\u4e0e\u4ece\u8868\u7684\u5173\u8054\u5173\u7cfb\uff0c\u4e3a\u4e24\u4e2a\u8868\u7684\u6570\u636e\u5efa\u7acb\u8fde\u63a5\uff0c\u7ea6\u675f\u4e24\u4e2a\u8868\u4e2d\u6570\u636e\u7684\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\u3002
FOREIGN KEY \u7ea6\u675f\u4e5f\u80fd\u9632\u6b62\u975e\u6cd5\u6570\u636e\u63d2\u5165\u5916\u952e\u5217\uff0c\u56e0\u4e3a\u5b83\u5fc5\u987b\u662f\u5b83\u6307\u5411\u7684\u90a3\u4e2a\u8868\u4e2d\u7684\u503c\u4e4b\u4e00\u3002
\u5b9a\u4e49\u5916\u952e\u65f6\uff0c\u9700\u8981\u9075\u5b88\u4e0b\u5217\u89c4\u5219\uff1a
\u5fc5\u987b\u4e3a\u4e3b\u8868\u5b9a\u4e49\u4e3b\u952e\u3002
\u5728\u4e3b\u8868\u7684\u8868\u540d\u540e\u9762\u6307\u5b9a\u5217\u540d\u6216\u5217\u540d\u7684\u7ec4\u5408\u3002\u8fd9\u4e2a\u5217\u6216\u5217\u7684\u7ec4\u5408\u5fc5\u987b\u662f\u4e3b\u8868\u7684\u4e3b\u952e\u6216\u5019\u9009\u952e\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u76ee\u5fc5\u987b\u548c\u4e3b\u8868\u7684\u4e3b\u952e\u4e2d\u5217\u7684\u6570\u76ee\u76f8\u540c\u3002
\u5916\u952e\u4e2d\u5217\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u548c\u4e3b\u8868\u4e3b\u952e\u4e2d\u5bf9\u5e94\u5217\u7684\u6570\u636e\u7c7b\u578b\u76f8\u540c\u3002
\u4e0b\u9762\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u8fdb\u884c\u8bf4\u660e\u901a\u8fc7 FOREIGN KEY \u548c PRIMARY KEY \u5173\u8054\u7236\u8868\u4e0e\u5b50\u8868\uff1a
\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u7236\u8868\uff0c\u5b57\u6bb5 a \u4e3a\u4e3b\u952e\uff1a
create table t1(a int primary key,b varchar(5));\ninsert into t1 values(101,'abc'),(102,'def');\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 101 | abc |\n| 102 | def |\n+------+------+\n2 rows in set (0.00 sec)\n
\u7136\u540e\u521b\u5efa\u4e00\u4e2a\u5b50\u8868\uff0c\u5b57\u6bb5 c \u4e3a\u5916\u952e\uff0c\u5173\u8054\u7236\u8868\u5b57\u6bb5 a\uff1a
create table t2(a int ,b varchar(5),c int, foreign key(c) references t1(a));\ninsert into t2 values(1,'zs1',101),(2,'zs2',102);\ninsert into t2 values(3,'xyz',null);\nmysql> select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | zs1 | 101 |\n| 2 | zs2 | 102 |\n| 3 | xyz | NULL |\n+------+------+------+\n3 rows in set (0.00 sec)\n
\u53e6\u5916\uff0c[ON DELETE reference_option]
\u548c [ON UPDATE reference_option]
\u5728\u5b9a\u4e49\u5916\u952e\u5173\u7cfb\u65f6\u7528\u4e8e\u6307\u5b9a\u5728\u5220\u9664\u7236\u8868\u4e2d\u7684\u8bb0\u5f55\u65f6\u6267\u884c\u7684\u64cd\u4f5c\u3002\u8fd9\u4e24\u4e2a\u53c2\u6570\u4e3b\u8981\u7528\u4e8e\u7ef4\u62a4\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u4e00\u81f4\u6027\uff1a
ON DELETE reference_option
\uff1a\u8fd9\u4e2a\u53c2\u6570\u6307\u5b9a\u4e86\u5728\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5e94\u8be5\u5982\u4f55\u5904\u7406\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u5e38\u89c1\u7684\u9009\u9879\u5305\u62ec\uff1a
RESTRICT
\uff1a\u5982\u679c\u5728\u5f15\u7528\u8868\u4e2d\u6709\u76f8\u5173\u7684\u5916\u952e\u6570\u636e\u5b58\u5728\uff0c\u4e0d\u5141\u8bb8\u5220\u9664\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u6765\u9632\u6b62\u8bef\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u7ef4\u62a4\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002
CASCADE
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u540c\u65f6\u5220\u9664\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u7ea7\u8054\u5220\u9664\u5173\u8054\u6570\u636e\uff0c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002
SET NULL
\uff1a\u5f53\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u5220\u9664\u65f6\uff0c\u5c06\u5916\u952e\u5217\u7684\u503c\u8bbe\u7f6e\u4e3a NULL\u3002\u8fd9\u53ef\u4ee5\u7528\u4e8e\u5728\u5220\u9664\u5f15\u7528\u6570\u636e\u65f6\u4fdd\u7559\u5916\u952e\u6570\u636e\uff0c\u4f46\u65ad\u5f00\u4e0e\u5f15\u7528\u6570\u636e\u7684\u5173\u8054\u3002
NO ACTION
\uff1a\u8868\u793a\u4e0d\u91c7\u53d6\u4efb\u4f55\u64cd\u4f5c\uff0c\u53ea\u662f\u68c0\u67e5\u662f\u5426\u6709\u5173\u8054\u6570\u636e\u5b58\u5728\u3002\u8fd9\u7c7b\u4f3c\u4e8e RESTRICT
\uff0c\u4f46\u53ef\u80fd\u5728\u67d0\u4e9b\u6570\u636e\u5e93\u4e2d\u6709\u5fae\u5c0f\u7684\u5dee\u5f02\u3002
ON UPDATE reference_option
\uff1a\u8fd9\u4e2a\u53c2\u6570\u6307\u5b9a\u4e86\u5728\u5f15\u7528\u8868\u4e2d\u7684\u6570\u636e\u88ab\u66f4\u65b0\u65f6\uff0c\u5e94\u8be5\u5982\u4f55\u5904\u7406\u4e0e\u4e4b\u5173\u8054\u7684\u5916\u952e\u6570\u636e\u3002\u5e38\u89c1\u7684\u9009\u9879\u7c7b\u4f3c\u4e8e ON DELETE reference_option
\uff0c\u7528\u6cd5\u4e5f\u7c7b\u4f3c\uff0c\u53ea\u662f\u9488\u5bf9\u6570\u636e\u66f4\u65b0\u64cd\u4f5c\u3002
\u53c2\u89c1\u4e0b\u9762\u7684\u793a\u4f8b\uff1a
\u5047\u8bbe\u6709\u4e24\u5f20\u8868 Orders
\u548c Customers
\uff0cOrders
\u8868\u4e2d\u6709\u4e00\u4e2a\u5916\u952e\u5217 customer_id
\u5f15\u7528 Customers
\u8868\u4e2d\u7684 id
\u5217\u3002\u5982\u679c\u5728 Customers
\u8868\u4e2d\u7684\u67d0\u4e2a\u5ba2\u6237\u88ab\u5220\u9664\uff0c\u540c\u65f6\u4e5f\u5e0c\u671b\u5220\u9664\u5173\u8054\u7684\u8ba2\u5355\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528 ON DELETE CASCADE
\u3002
CREATE TABLE Customers (\nid INT PRIMARY KEY,\nname VARCHAR(50)\n);\n\nCREATE TABLE Orders (\nid INT PRIMARY KEY,\norder_number VARCHAR(10),\ncustomer_id INT,\nFOREIGN KEY (customer_id) REFERENCES Customers(id) ON DELETE CASCADE\n);\n
\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5f53 Customers
\u8868\u4e2d\u7684\u67d0\u4e2a\u5ba2\u6237\u88ab\u5220\u9664\u65f6\uff0c\u5173\u8054\u7684\u8ba2\u5355\u6570\u636e\u4e5f\u4f1a\u88ab\u7ea7\u8054\u5220\u9664\uff0c\u4ee5\u7ef4\u62a4\u6570\u636e\u7684\u5b8c\u6574\u6027\u3002\u540c\u6837\u7684\uff0cON UPDATE
\u53c2\u6570\u4e5f\u53ef\u4ee5\u7528\u7c7b\u4f3c\u7684\u65b9\u5f0f\u6765\u5904\u7406\u66f4\u65b0\u64cd\u4f5c\u3002
\u6709\u5173\u6570\u636e\u5b8c\u6574\u6027\u7ea6\u675f\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\u6570\u636e\u5b8c\u6574\u6027\u7ea6\u675f\u6982\u8ff0\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#cluster-by","title":"Cluster by","text":"Cluster by
\u662f\u4e00\u79cd\u7528\u4e8e\u4f18\u5316\u8868\u7684\u7269\u7406\u6392\u5217\u65b9\u5f0f\u7684\u547d\u4ee4\u3002\u5728\u5efa\u8868\u65f6\u4f7f\u7528 Cluster by
\u547d\u4ee4\uff0c\u5bf9\u4e8e\u65e0\u4e3b\u952e\u7684\u8868\uff0c\u53ef\u4ee5\u6309\u7167\u6307\u5b9a\u7684\u5217\u5bf9\u8868\u8fdb\u884c\u7269\u7406\u6392\u5e8f\uff0c\u5e76\u5c06\u6570\u636e\u884c\u91cd\u65b0\u6392\u5217\u6210\u4e0e\u8be5\u5217\u7684\u503c\u7684\u987a\u5e8f\u76f8\u540c\u7684\u987a\u5e8f\u3002\u4f7f\u7528 Cluster by
\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd\u3002
create table() cluster by col;
create table() cluster by (col1, col2);
Note: Cluster by
\u4e0d\u80fd\u548c\u4e3b\u952e\u540c\u65f6\u5b58\u5728\uff0c\u5426\u5219\u4f1a\u8bed\u6cd5\u62a5\u9519\uff1bCluster by
\u53ea\u80fd\u5728\u5efa\u8868\u65f6\u6307\u5b9a\uff0c\u4e0d\u652f\u6301\u52a8\u6001\u521b\u5efa\u3002
\u66f4\u591a\u5173\u4e8e\u4f7f\u7528 Cluster by
\u8fdb\u884c\u6027\u80fd\u8c03\u4f18\uff0c\u53c2\u89c1\u4f7f\u7528 Cluster by \u8bed\u53e5\u8c03\u4f18.
partition_options:\n PARTITION BY\n { [LINEAR] HASH(expr)\n | [LINEAR] KEY [ALGORITHM={1 | 2}] (column_list)\n [PARTITIONS num]\n [(partition_definition [, partition_definition] ...)]\n\npartition_definition:\n PARTITION partition_name\n [VALUES\n {LESS THAN {(expr | value_list) | MAXVALUE}\n |\n IN (value_list)}]\n [COMMENT [=] 'string' ]\n
\u5206\u533a\u53ef\u4ee5\u88ab\u4fee\u6539\u3001\u5408\u5e76\u3001\u6dfb\u52a0\u5230\u8868\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u4ece\u8868\u4e2d\u5220\u9664\u3002
\u00b7 \u548c\u5355\u4e2a\u78c1\u76d8\u6216\u6587\u4ef6\u7cfb\u7edf\u5206\u533a\u76f8\u6bd4\uff0c\u53ef\u4ee5\u5b58\u50a8\u66f4\u591a\u7684\u6570\u636e\u3002
\u00b7 \u4f18\u5316\u67e5\u8be2\u3002
\u00b7 \u5bf9\u4e8e\u5df2\u7ecf\u8fc7\u671f\u6216\u8005\u4e0d\u9700\u8981\u4fdd\u5b58\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5220\u9664\u4e0e\u8fd9\u4e9b\u6570\u636e\u6709\u5173\u7684\u5206\u533a\u6765\u5feb\u901f\u5220\u9664\u6570\u636e\u3002
\u00b7 \u8de8\u591a\u4e2a\u78c1\u76d8\u6765\u5206\u6563\u6570\u636e\u67e5\u8be2\uff0c\u4ee5\u83b7\u5f97\u66f4\u5927\u7684\u67e5\u8be2\u541e\u5410\u91cf\u3002
\u5206\u533a\u8bed\u6cd5\u4ee5 PARTITION BY
\u5f00\u5934\u3002\u8be5\u5b50\u53e5\u5305\u542b\u7528\u4e8e\u786e\u5b9a\u5206\u533a\u7684\u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u4ece 1 \u5230 num \u7684\u6574\u6570\u503c\uff0c\u5176\u4e2d num \u662f\u5206\u533a\u7684\u6570\u76ee\u3002
\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\uff0c\u7ecf\u5e38\u4f1a\u9047\u5230\u50cf\u4f1a\u5458\u8868\u8fd9\u79cd\u6ca1\u6709\u660e\u663e\u53ef\u4ee5\u5206\u533a\u7684\u7279\u5f81\u5b57\u6bb5\u7684\u5927\u8868\u3002\u4e3a\u4e86\u628a\u8fd9\u7c7b\u7684\u6570\u636e\u8fdb\u884c\u5206\u533a\u6253\u6563\uff0cMatrixOne \u63d0\u4f9b\u4e86 HASH
\u5206\u533a\u3002\u57fa\u4e8e\u7ed9\u5b9a\u7684\u5206\u533a\u4e2a\u6570\uff0c\u5c06\u6570\u636e\u5206\u914d\u5230\u4e0d\u540c\u7684\u5206\u533a\uff0cHASH
\u5206\u533a\u53ea\u80fd\u9488\u5bf9\u6574\u6570\u8fdb\u884c HASH
\uff0c\u5bf9\u4e8e\u975e\u6574\u5f62\u7684\u5b57\u6bb5\u5219\u901a\u8fc7\u8868\u8fbe\u5f0f\u5c06\u5176\u8f6c\u6362\u6210\u6574\u6570\u3002
\u00b7 HASH \u5206\u533a\uff0c\u57fa\u4e8e\u7ed9\u5b9a\u7684\u5206\u533a\u4e2a\u6570\uff0c\u628a\u6570\u636e\u5206\u914d\u5230\u4e0d\u540c\u7684\u5206\u533a\u3002
\u00b7 Expr \u662f\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u8868\u5217\u7684\u8868\u8fbe\u5f0f\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE t1 (col1 INT, col2 CHAR(5))\n PARTITION BY HASH(col1);\n\nCREATE TABLE t1 (col1 INT, col2 CHAR(5), col3 DATETIME)\n PARTITION BY HASH ( YEAR(col3) );\n
\u00b7 KEY \u5206\u533a\uff0c\u6309\u7167\u67d0\u4e2a\u5b57\u6bb5\u53d6\u4f59\u3002\u5206\u533a\u5bf9\u8c61\u5fc5\u987b\u4e3a\u5217\uff0c\u4e0d\u80fd\u662f\u57fa\u4e8e\u5217\u7684\u8868\u8fbe\u5f0f\uff0c\u4e14\u5141\u8bb8\u591a\u5217\u3002KEY \u5206\u533a\u5217\u53ef\u4ee5\u4e0d\u6307\u5b9a\uff0c\u9ed8\u8ba4\u4e3a\u4e3b\u952e\u5217\u6216\u8005\u552f\u4e00\u952e\u5217\uff0c\u65e0\u4e3b\u952e\u548c\u552f\u4e00\u952e\u7684\u60c5\u51b5\u4e0b\uff0c\u5219\u5fc5\u987b\u663e\u6027\u6307\u5b9a\u5217\u3002
\u7c7b\u4f3c\u4e8e HASH
\u3002column_list
\u53c2\u6570\u53ea\u662f\u4e00\u4e2a\u5305\u542b 1 \u4e2a\u6216\u591a\u4e2a\u8868\u5217\u7684\u5217\u8868\uff08\u6700\u5927\u503c\uff1a16\uff09\u3002\u4e0b\u9762\u7684\u793a\u4f8b\u4e3a\u4e00\u4e2a\u6309 KEY
\u5206\u533a\u7684\u7b80\u5355\u8868\uff0c\u6709 4 \u4e2a\u5206\u533a\uff1a
CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n PARTITION BY KEY(col3)\n PARTITIONS 4;\n
\u5bf9\u4e8e\u6309 KEY
\u5206\u533a\u7684\u8868\uff0c\u53ef\u4ee5\u4f7f\u7528 LINEAR KEY
\u6765\u8fdb\u884c\u7ebf\u6027\u5206\u533a\u3002\u8fd9\u4e0e\u4f7f\u7528 HASH
\u5206\u533a\u7684\u8868\u5177\u6709\u76f8\u540c\u7684\u6548\u679c\u3002\u4e0b\u9762\u7684\u793a\u4f8b\u4e3a\u4f7f\u7528 LINEAR KEY
\u7ebf\u6027\u5206\u533a\u5728 5 \u4e2a\u5206\u533a\u4e4b\u95f4\u5206\u914d\u6570\u636e\uff1a
CREATE TABLE tk (col1 INT, col2 CHAR(5), col3 DATE)\n PARTITION BY LINEAR KEY(col3)\n PARTITIONS 5;\n
RANGE
\u5206\u533a\uff1a\u57fa\u4e8e\u4e00\u4e2a\u7ed9\u5b9a\u8fde\u7eed\u533a\u95f4\u8303\u56f4\uff0c\u628a\u6570\u636e\uff08\u6216\u8005\u53ef\u4ee5\u8bf4\u662f\u591a\u884c\uff09\u5206\u914d\u5230\u4e0d\u540c\u7684\u5206\u533a\u3002\u6700\u5e38\u89c1\u7684\u662f\u57fa\u4e8e\u65f6\u95f4\u5b57\u6bb5\u3002\u57fa\u4e8e\u5206\u533a\u7684\u5217\u6700\u597d\u662f\u6574\u578b\uff0c\u5982\u679c\u65e5\u671f\u578b\u7684\u53ef\u4ee5\u4f7f\u7528\u51fd\u6570\u8f6c\u6362\u4e3a\u6574\u578b\u3002
\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cexpr \u4f7f\u7528\u4e00\u7ec4 VALUES LESS THAN
\u8fd0\u7b97\u7b26\u663e\u793a\u4e00\u7cfb\u5217\u503c\u3002\u4f7f\u7528\u8303\u56f4\u5206\u533a\u65f6\uff0c\u4f60\u5fc5\u987b\u4f7f\u7528 VALUES LESS THAN
\u5b9a\u4e49\u81f3\u5c11\u4e00\u4e2a\u5206\u533a\uff0c\u4e14\u4e0d\u80fd\u5c06 VALUES IN
\u4e0e\u8303\u56f4\u5206\u533a\u4e00\u8d77\u4f7f\u7528\u3002
VALUES LESS THAN MAXVALUE
\u7528\u4e8e\u6307\u5b9a\u5c0f\u4e8e\u6307\u5b9a\u6700\u5927\u503c\u7684\u201c\u5269\u4f59\u201d\u503c\u3002
\u5b50\u53e5\u6392\u5217\u65b9\u5f0f\u4e3a\uff1a\u6bcf\u4e2a\u8fde\u7eed\u7684 VALUES LESS THAN
\u4e2d\u6307\u5b9a\u7684\u4e0a\u9650\u5927\u4e8e\u524d\u4e00\u4e2a\u7684\u4e0a\u9650\uff0c\u5f15\u7528 MAXVALUE
\u7684\u90a3\u4e2a\u5728\u5217\u8868\u4e2d\u6392\u5728\u6700\u540e\u3002
RANGE COLUMNS(column_list)
\u4e3a RANGE
\u7684\u53e6\u4e00\u79cd\u5f62\u5f0f\uff0c\u5e38\u7528\u4f5c\u4e3a\u4f7f\u7528\u591a\u4e2a\u5217\u4e0a\u7684\u8303\u56f4\u6761\u4ef6\uff08\u5373\uff0c\u8bf8\u5982 WHERE a = 1 AND b < 10 \u6216 WHERE a = 1 AND b = 10 AND c < 10
\uff09\u4e4b\u7c7b\u7684\u6761\u4ef6\u5bf9\u67e5\u8be2\u8fdb\u884c\u5206\u533a\u4fee\u526a\u3002\u5b83\u4f7f\u4f60\u80fd\u591f\u901a\u8fc7\u4f7f\u7528 COLUMNS
\u5b50\u53e5\u4e2d\u7684\u5217\u5217\u8868\u548c\u6bcf\u4e2a PARTITION ... VALUES LESS THAN (value_list)
\u5206\u533a\u5b9a\u4e49\u5b50\u53e5\u4e2d\u7684\u4e00\u7ec4\u5217\u503c\u6765\u6307\u5b9a\u591a\u4e2a\u5217\u4e2d\u7684\u503c\u8303\u56f4\u3002\uff08\u5728\u6700\u7b80\u5355\u7684\u60c5\u51b5\u4e0b\uff0c\u8be5\u96c6\u5408\u7531\u5355\u4e2a\u5217\u7ec4\u6210\u3002\uff09column_list
\u548c value_list
\u4e2d\u53ef\u4ee5\u5f15\u7528\u7684\u6700\u5927\u5217\u6570\u4e3a 16\u3002
column_list
\u4f7f\u7528\uff1a
column_list
\u53ef\u4ee5\u53ea\u5305\u542b\u5217\u540d\u3002BLOB
\u3001TEXT
\u3001SET
\u3001ENUM
\u3001BIT
\u6216\u7a7a\u95f4\u6570\u636e\u7c7b\u578b\u7684\u5217\uff1b\u4e5f\u4e0d\u5141\u8bb8\u4f7f\u7528\u6d6e\u70b9\u6570\u7c7b\u578b\u7684\u5217\u3002\u4e5f\u4e0d\u53ef\u4ee5\u5728 COLUMNS
\u5b50\u53e5\u4e2d\u4f7f\u7528\u51fd\u6570\u6216\u7b97\u672f\u8868\u8fbe\u5f0f\u3002\u5206\u533a\u5b9a\u4e49\u8bf4\u660e\uff1a
VALUES LESS THAN
\u5b50\u53e5\u7684\u503c\u5217\u8868\u5fc5\u987b\u5305\u542b\u4e0e COLUMNS
\u5b50\u53e5\u4e2d\u5217\u51fa\u7684\u5217\u76f8\u540c\u6570\u91cf\u7684\u503c\u3002NULL
\u4e0d\u80fd\u51fa\u73b0\u5728 VALUES LESS THAN
\u4e2d\u7684\u4efb\u4f55\u503c\u3002\u53ef\u4ee5\u5bf9\u9664\u7b2c\u4e00\u5217\u4ee5\u5916\u7684\u7ed9\u5b9a\u5217\u591a\u6b21\u4f7f\u7528 MAXVALUE
\uff0c\u5982\u4e0b\u4f8b\u6240\u793a\uff1aCREATE TABLE rc (\n a INT NOT NULL,\n b INT NOT NULL\n)\nPARTITION BY RANGE COLUMNS(a,b) (\n PARTITION p0 VALUES LESS THAN (10,5),\n PARTITION p1 VALUES LESS THAN (20,10),\n PARTITION p2 VALUES LESS THAN (50,MAXVALUE),\n PARTITION p3 VALUES LESS THAN (65,MAXVALUE),\n PARTITION p4 VALUES LESS THAN (MAXVALUE,MAXVALUE)\n);\n
LIST
\u5206\u533a\u548c RANGE
\u5206\u533a\u7c7b\u4f3c\uff0c\u533a\u522b\u5728\u4e8e LIST
\u662f\u679a\u4e3e\u503c\u5217\u8868\u7684\u96c6\u5408\uff0cRANGE
\u662f\u8fde\u7eed\u7684\u533a\u95f4\u503c\u7684\u96c6\u5408\u3002\u4e8c\u8005\u5728\u8bed\u6cd5\u65b9\u9762\u975e\u5e38\u7684\u76f8\u4f3c\u3002
\u5206\u533a\u4f7f\u7528\uff1a
LIST
\u5206\u533a\u5217\u662f\u975e null \u5217\uff0c\u5426\u5219\u63d2\u5165 null \u503c\u5982\u679c\u679a\u4e3e\u5217\u8868\u91cc\u9762\u4e0d\u5b58\u5728 null \u503c\u4f1a\u63d2\u5165\u5931\u8d25\uff0c\u8fd9\u70b9\u548c\u5176\u5b83\u7684\u5206\u533a\u4e0d\u4e00\u6837\uff0cRANGE
\u5206\u533a\u4f1a\u5c06\u5176\u4f5c\u4e3a\u6700\u5c0f\u5206\u533a\u503c\u5b58\u50a8\uff0cHASH
\u6216 KEY
\u5206\u4e3a\u4f1a\u5c06\u5176\u8f6c\u6362\u6210 0 \u5b58\u50a8\uff0c\u56e0\u4e3a LIST
\u5206\u533a\u53ea\u652f\u6301\u6574\u578b\uff0c\u975e\u6574\u578b\u5b57\u6bb5\u9700\u8981\u901a\u8fc7\u51fd\u6570\u8f6c\u6362\u6210\u6574\u5f62\u3002LIST
\u5206\u533a\u65f6\uff0c\u4f60\u5fc5\u987b\u4f7f\u7528 VALUES IN
\u5b9a\u4e49\u81f3\u5c11\u4e00\u4e2a\u5206\u533a\uff0c\u4e14\u4e0d\u80fd\u5c06 VALUES LESS THAN
\u4e0e PARTITION BY LIST
\u4e00\u8d77\u4f7f\u7528\u3002\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE client_firms (\n id INT,\n name VARCHAR(35)\n)\nPARTITION BY LIST (id) (\n PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21),\n PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22),\n PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23),\n PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24)\n);\n
LIST COLUMNS(column_list)
\u662f LIST
\u7684\u53e6\u4e00\u79cd\u4e66\u5199\u5f62\u5f0f\uff0c\u7528\u4e8e\u591a\u5217\u4e0a\u7684\u6bd4\u8f83\u6761\u4ef6\uff08\u5373\uff0c\u5177\u6709\u8bf8\u5982 WHERE a = 5 AND b = 5 \u6216 WHERE a = 1 AND b = 10 AND c = 5
\u4e4b\u7c7b\u7684\u6761\u4ef6\uff09\u5bf9\u67e5\u8be2\u8fdb\u884c\u5206\u533a\u4fee\u526a\u3002\u901a\u8fc7\u4f7f\u7528 COLUMNS
\u5b50\u53e5\u4e2d\u7684\u5217\u5217\u8868\u548c\u6bcf\u4e2a PARTITION ... VALUES IN
(value_list) \u5206\u533a\u5b9a\u4e49\u5b50\u53e5\u4e2d\u7684\u4e00\u7ec4\u5217\u503c\u6765\u6307\u5b9a\u591a\u4e2a\u5217\u4e2d\u7684\u503c\u3002
LIST COLUMNS(column_list)
\u4e2d\u4f7f\u7528\u7684\u5217\u5217\u8868\u548c VALUES IN(value_list)
\u4e2d\u4f7f\u7528\u7684\u503c\u5217\u8868\u7684\u6570\u636e\u7c7b\u578b\u89c4\u5219\u4e0e RANGE COLUMNS(column_list)
\u4e2d\u4f7f\u7528\u7684\u5217\u5217\u8868\u7684\u89c4\u5219 VALUES LESS THAN(value_list)
\u4e2d\u4f7f\u7528\u7684\u503c\u5217\u8868\u89c4\u5219\u76f8\u540c\uff0c\u4f46\u5728 VALUES IN
\u5b50\u53e5\u4e2d\uff0c\u4e0d\u5141\u8bb8\u4f7f\u7528 MAXVALUE
\uff0c\u53ef\u4ee5\u4f7f\u7528 NULL
\u3002
\u4e0e PARTITION BY LIST COLUMNS
\u4e00\u8d77\u4f7f\u7528\u7684 VALUES IN
\u503c\u5217\u8868\u4e0e\u4e0e PARTITION BY LIST
\u4e00\u8d77\u4f7f\u7528\u65f6\u7684\u503c\u5217\u8868\u6709\u4e00\u4e2a\u91cd\u8981\u533a\u522b\u3002\u5f53\u4e0e PARTITION BY LIST COLUMNS
\u4e00\u8d77\u4f7f\u7528\u65f6\uff0cVALUES IN
\u5b50\u53e5\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u5fc5\u987b\u662f\u4e00\u7ec4\u5217\u503c\uff1b\u6bcf\u4e2a\u96c6\u5408\u4e2d\u7684\u503c\u7684\u6570\u91cf\u5fc5\u987b\u4e0e COLUMNS
\u5b50\u53e5\u4e2d\u4f7f\u7528\u7684\u5217\u6570\u76f8\u540c\uff0c\u5e76\u4e14\u8fd9\u4e9b\u503c\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u4e0e\u5217\u7684\u6570\u636e\u7c7b\u578b\u5339\u914d\uff08\u5e76\u4e14\u4ee5\u76f8\u540c\u7684\u987a\u5e8f\u51fa\u73b0\uff09\u3002\u5728\u6700\u7b80\u5355\u7684\u60c5\u51b5\u4e0b\uff0c\u8be5\u96c6\u5408\u7531\u4e00\u5217\u7ec4\u6210\u3002\u5728 column_list
\u548c\u7ec4\u6210 value_list
\u7684\u5143\u7d20\u4e2d\u53ef\u4ee5\u4f7f\u7528\u7684\u6700\u5927\u5217\u6570\u662f 16\u3002
\u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE lc (\n a INT NULL,\n b INT NULL\n)\nPARTITION BY LIST COLUMNS(a,b) (\n PARTITION p0 VALUES IN( (0,0), (NULL,NULL) ),\n PARTITION p1 VALUES IN( (0,1), (0,2), (0,3), (1,1), (1,2) ),\n PARTITION p2 VALUES IN( (1,0), (2,0), (2,1), (3,0), (3,1) ),\n PARTITION p3 VALUES IN( (1,3), (2,2), (2,3), (3,2), (3,3) )\n);\n
\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528 PARTITIONS num
\u5b50\u53e5\u6307\u5b9a\u5206\u533a\u6570\uff0c\u5176\u4e2d num
\u662f\u5206\u533a\u6570\u3002\u5982\u679c\u4f7f\u7528\u6b64\u5b50\u53e5\u7684\u540c\u65f6\uff0c\u4e5f\u4f7f\u7528\u4e86\u5176\u4ed6 PARTITION
\u5b50\u53e5\uff0c\u90a3\u4e48 num
\u5fc5\u987b\u7b49\u4e8e\u4f7f\u7528 PARTITION
\u5b50\u53e5\u58f0\u660e\u7684\u5206\u533a\u7684\u603b\u6570\u3002
CREATE TABLE test(a int, b varchar(10));\nINSERT INTO test values(123, 'abc');\n\nmysql> SELECT * FROM test;\n+------+---------+\n| a | b |\n+------+---------+\n| 123 | abc |\n+------+---------+\n
create table t2 (a int, b int) comment = \"\u4e8b\u5b9e\u8868\";\n\nmysql> show create table t2;\n+-------+---------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------+\n| t2 | CREATE TABLE `t2` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL\n) COMMENT='\u4e8b\u5b9e\u8868', |\n+-------+---------------------------------------------------------------------------------------+\n
create table t3 (a int comment '\u5217\u7684\u6ce8\u91ca', b int) comment = \"table\";\n\nmysql> SHOW CREATE TABLE t3;\n+-------+----------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------+\n| t3 | CREATE TABLE `t3` (\n`a` INT DEFAULT NULL COMMENT '\u5217\u7684\u6ce8\u91ca',\n`b` INT DEFAULT NULL\n) COMMENT='table', |\n+-------+----------------------------------------------------------------------------------------------------------+\n
CREATE TABLE tp1 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp1;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp1 | CREATE TABLE `tp1` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u4e0d\u6307\u5b9a\u5206\u533a\u6570\nCREATE TABLE tp2 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY KEY(col3);\n\nmysql> SHOW CREATE TABLE tp2;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp2 | CREATE TABLE `tp2` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u6307\u5b9a\u5206\u533a\u7b97\u6cd5\nCREATE TABLE tp3\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY ALGORITHM = 1 (col3);\n\n\nmysql> show create table tp3;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n| tp3 | CREATE TABLE `tp3` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 1 (col3) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u6307\u5b9a\u5206\u533a\u7b97\u6cd5\u53ca\u5206\u533a\u6570\nCREATE TABLE tp4 (col1 INT, col2 CHAR(5), col3 DATE) PARTITION BY LINEAR KEY ALGORITHM = 1 (col3) PARTITIONS 5;\n\nmysql> SHOW CREATE TABLE tp4;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp4 | CREATE TABLE `tp4` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear key algorithm = 1 (col3) partitions 5 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u591a\u5217\u5206\u533a\nCREATE TABLE tp5\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY KEY(col1, col2) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp5;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp5 | CREATE TABLE `tp5` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by key algorithm = 2 (col1, col2) partitions 4 |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa\u4e3b\u952e\u5217\u5206\u533a\nCREATE TABLE tp6\n(\ncol1 INT NOT NULL PRIMARY KEY,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL\n) PARTITION BY KEY(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp6;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp6 | CREATE TABLE `tp6` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by key algorithm = 2 (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa HASH \u5206\u533a\nCREATE TABLE tp7\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1);\n\nmysql> SHOW CREATE TABLE tp7;\n+-------+------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------+\n| tp7 | CREATE TABLE `tp7` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) |\n+-------+------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa HASH \u5206\u533a\u65f6\u6307\u5b9a\u5206\u533a\u6570\nCREATE TABLE tp8\n(\ncol1 INT,\ncol2 CHAR(5)\n) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp8;\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n| tp8 | CREATE TABLE `tp8` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa\u5206\u533a\u65f6\uff0c\u6307\u5b9a\u5206\u533a\u7c92\u5ea6\nCREATE TABLE tp9\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATETIME\n) PARTITION BY HASH (YEAR(col3));\n\nmysql> SHOW CREATE TABLE tp9;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n| tp9 | CREATE TABLE `tp9` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATETIME DEFAULT NULL\n) partition by hash (year(col3)) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa\u5206\u533a\u65f6\uff0c\u6307\u5b9a\u5206\u533a\u7c92\u5ea6\u548c\u5206\u533a\u6570\u91cf\nCREATE TABLE tp10\n(\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n) PARTITION BY LINEAR HASH( YEAR(col3)) PARTITIONS 6;\n\nmysql> SHOW CREATE TABLE tp10;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp10 | CREATE TABLE `tp10` (\n`col1` INT DEFAULT NULL,\n`col2` CHAR(5) DEFAULT NULL,\n`col3` DATE DEFAULT NULL\n) partition by linear hash (year(col3)) partitions 6 |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa\u5206\u533a\u65f6\uff0c\u4f7f\u7528\u4e3b\u952e\u5217\u4f5c\u4e3a HASH \u5206\u533a\nCREATE TABLE tp12 (col1 INT NOT NULL PRIMARY KEY, col2 DATE NOT NULL, col3 INT NOT NULL, col4 INT NOT NULL) PARTITION BY HASH(col1) PARTITIONS 4;\n\nmysql> SHOW CREATE TABLE tp12;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp12 | CREATE TABLE `tp12` (\n`col1` INT NOT NULL,\n`col2` DATE NOT NULL,\n`col3` INT NOT NULL,\n`col4` INT NOT NULL,\nPRIMARY KEY (`col1`)\n) partition by hash (col1) partitions 4 |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u521b\u5efa RANGE \u5206\u533a\uff0c\u5e76\u5212\u5206\u5206\u533a\u8303\u56f4\nCREATE TABLE tp13 (id INT NOT NULL PRIMARY KEY, fname VARCHAR(30), lname VARCHAR(30), hired DATE NOT NULL DEFAULT '1970-01-01', separated DATE NOT NULL DEFAULT '9999-12-31', job_code INT NOT NULL, store_id INT NOT NULL) PARTITION BY RANGE (id) (PARTITION p0 VALUES LESS THAN (6), PARTITION p1 VALUES LESS THAN (11), PARTITION p2 VALUES LESS THAN (16), PARTITION p3 VALUES LESS THAN (21));\n\nmysql> SHOW CREATE TABLE tp13;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp13 | CREATE TABLE `tp13` (\n`id` INT NOT NULL,\n`fname` VARCHAR(30) DEFAULT NULL,\n`lname` VARCHAR(30) DEFAULT NULL,\n`hired` DATE DEFAULT '1970-01-01',\n`separated` DATE DEFAULT '9999-12-31',\n`job_code` INT NOT NULL,\n`store_id` INT NOT NULL,\nPRIMARY KEY (`id`)\n) partition by range(id) (partition p0 values less than (6), partition p1 values less than (11), partition p2 values less than (16), partition p3 values less than (21)) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nCREATE TABLE tp14 (id INT NOT NULL, fname VARCHAR(30), lname VARCHAR(30), hired DATE NOT NULL DEFAULT '1970-01-01', separated DATE NOT NULL DEFAULT '9999-12-31', job_code INT, store_id INT) PARTITION BY RANGE ( YEAR(separated) ) ( PARTITION p0 VALUES LESS THAN (1991), PARTITION p1 VALUES LESS THAN (1996), PARTITION p2 VALUES LESS THAN (2001), PARTITION p3 VALUES LESS THAN MAXVALUE);\n\nmysql> SHOW CREATE TABLE tp14;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp14 | CREATE TABLE `tp14` (\n`id` INT NOT NULL,\n`fname` VARCHAR(30) DEFAULT NULL,\n`lname` VARCHAR(30) DEFAULT NULL,\n`hired` DATE DEFAULT '1970-01-01',\n`separated` DATE DEFAULT '9999-12-31',\n`job_code` INT DEFAULT NULL,\n`store_id` INT DEFAULT NULL\n) partition by range(year(separated)) (partition p0 values less than (1991), partition p1 values less than (1996), partition p2 values less than (2001), partition p3 values less than (MAXVALUE)) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u4f7f\u7528\u591a\u5217\u4f5c\u4e3a RANGE \u5206\u533a\uff0c\u5e76\u6307\u5b9a\u5206\u533a\u8303\u56f4\nCREATE TABLE tp15 (a INT NOT NULL, b INT NOT NULL) PARTITION BY RANGE COLUMNS(a,b) PARTITIONS 4 (PARTITION p0 VALUES LESS THAN (10,5), PARTITION p1 VALUES LESS THAN (20,10), PARTITION p2 VALUES LESS THAN (50,20), PARTITION p3 VALUES LESS THAN (65,30));\n\nmysql> SHOW CREATE TABLE tp15;\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp15 | CREATE TABLE `tp15` (\n`a` INT NOT NULL,\n`b` INT NOT NULL\n) partition by range columns (a, b) partitions 4 (partition p0 values less than (10, 5), partition p1 values less than (20, 10), partition p2 values less than (50, 20), partition p3 values less than (65, 30)) |\n+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n\n-- \u521b\u5efa LIST \u5206\u533a\nCREATE TABLE tp16 (id INT PRIMARY KEY, name VARCHAR(35), age INT unsigned) PARTITION BY LIST (id) (PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21), PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22), PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23), PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24));\n\nmysql> SHOW CREATE TABLE tp16;\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp16 | CREATE TABLE `tp16` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(35) DEFAULT NULL,\n`age` INT UNSIGNED DEFAULT NULL,\nPRIMARY KEY (`id`)\n) partition by list(id) (partition r0 values in (1, 5, 9, 13, 17, 21), partition r1 values in (2, 6, 10, 14, 18, 22), partition r2 values in (3, 7, 11, 15, 19, 23), partition r3 values in (4, 8, 12, 16, 20, 24)) |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nCREATE TABLE tp17 (id INT, name VARCHAR(35), age INT unsigned) PARTITION BY LIST (id) (PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21), PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22), PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23), PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24));\n\nmysql> SHOW CREATE TABLE tp17;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp17 | CREATE TABLE `tp17` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(35) DEFAULT NULL,\n`age` INT UNSIGNED DEFAULT NULL\n) partition by list(id) (partition r0 values in (1, 5, 9, 13, 17, 21), partition r1 values in (2, 6, 10, 14, 18, 22), partition r2 values in (3, 7, 11, 15, 19, 23), partition r3 values in (4, 8, 12, 16, 20, 24)) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\n-- \u4f7f\u7528\u591a\u5217\u4f5c\u4e3a LIST \u5206\u533a\nCREATE TABLE tp18 (a INT NULL,b INT NULL) PARTITION BY LIST COLUMNS(a,b) (PARTITION p0 VALUES IN( (0,0), (NULL,NULL) ), PARTITION p1 VALUES IN( (0,1), (0,2), (0,3), (1,1), (1,2) ), PARTITION p2 VALUES IN( (1,0), (2,0), (2,1), (3,0), (3,1) ), PARTITION p3 VALUES IN( (1,3), (2,2), (2,3), (3,2), (3,3) ));\n\nmysql> SHOW CREATE TABLE tp18;\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| tp18 | CREATE TABLE `tp18` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL\n) partition by list columns (a, b) (partition p0 values in ((0, 0), (null, null)), partition p1 values in ((0, 1), (0, 2), (0, 3), (1, 1), (1, 2)), partition p2 values in ((1, 0), (2, 0), (2, 1), (3, 0), (3, 1)), partition p3 values in ((1, 3), (2, 2), (2, 3), (3, 2), (3, 3))) |\n+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1(a bigint primary key auto_increment, b varchar(10));\ninsert into t1(b) values ('bbb');\ninsert into t1 values (3, 'ccc');\ninsert into t1(b) values ('bbb1111');\n\nmysql> select * from t1 order by a;\n+------+---------+\n| a | b |\n+------+---------+\n| 1 | bbb |\n| 3 | ccc |\n| 4 | bbb1111 |\n+------+---------+\n3 rows in set (0.01 sec)\n\ninsert into t1 values (2, 'aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a | b |\n+------+----------+\n| 1 | bbb |\n| 2 | aaaa1111 |\n| 3 | ccc |\n| 4 | bbb1111 |\n+------+----------+\n4 rows in set (0.00 sec)\n\ninsert into t1(b) values ('aaaa1111');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a | b |\n+------+----------+\n| 1 | bbb |\n| 2 | aaaa1111 |\n| 3 | ccc |\n| 4 | bbb1111 |\n| 5 | aaaa1111 |\n+------+----------+\n5 rows in set (0.01 sec)\n\ninsert into t1 values (100, 'xxxx');\ninsert into t1(b) values ('xxxx');\n\nmysql> select * from t1 order by a;\n+------+----------+\n| a | b |\n+------+----------+\n| 1 | bbb |\n| 2 | aaaa1111 |\n| 3 | ccc |\n| 4 | bbb1111 |\n| 5 | aaaa1111 |\n| 100 | xxxx |\n| 101 | xxxx |\n+------+----------+\n7 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-table/#_5","title":"\u9650\u5236","text":"ALTER TABLE table_name DROP PRIMARY KEY
\u8bed\u53e5\u5220\u9664\u8868\u4e2d\u7684\u4e3b\u952e\u3002ALTER TABLE table_name AUTO_INCREMENT = n;
\u8bed\u53e5\u4fee\u6539\u81ea\u589e\u5217\u521d\u59cb\u503c\u3002set @@auto_increment_increment=n
\u6765\u8bbe\u7f6e\u9012\u589e\u6b65\u957f\uff0c\u4e5f\u4ec5\u8bed\u6cd5\u652f\u6301\u4f7f\u7528\u7cfb\u7edf\u53d8\u91cf set @@auto_increment_offset=n
\u6765\u8bbe\u7f6e\u9ed8\u8ba4\u81ea\u589e\u5217\u521d\u59cb\u503c\uff0c\u4f46\u5b9e\u9645\u4e0a\u5e76\u4e0d\u751f\u6548\uff1b\u5f53\u524d\u652f\u6301\u8bbe\u7f6e\u81ea\u589e\u5217\u7684\u521d\u59cb\u503c AUTO_INCREMENT=n
\uff0c\u4f46\u6b65\u957f\u4ecd\u7136\u9ed8\u8ba4\u4e3a 1\u3002\u89c6\u56fe\u662f\u57fa\u4e8e SQL \u8bed\u53e5\u7684\u7ed3\u679c\u96c6\u7684\u53ef\u89c6\u5316\u7684\u8868\u3002
\u89c6\u56fe\u5305\u542b\u884c\u548c\u5217\uff0c\u5c31\u50cf\u4e00\u4e2a\u771f\u5b9e\u7684\u8868\u3002\u89c6\u56fe\u4e2d\u7684\u5b57\u6bb5\u5c31\u662f\u6765\u81ea\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5e93\u4e2d\u7684\u771f\u5b9e\u7684\u8868\u4e2d\u7684\u5b57\u6bb5\u3002
\u60a8\u53ef\u4ee5\u5411\u89c6\u56fe\u6dfb\u52a0 SQL \u51fd\u6570\uff0cWHERE
\u6216\u8005 JOIN
\u8bed\u53e5\uff0c\u4e5f\u540c\u6837\u53ef\u4ee5\u5448\u73b0\u6570\u636e\uff0c\u7c7b\u4f3c\u4e8e\u8fd9\u4e9b\u6570\u636e\u6765\u81ea\u4e8e\u67d0\u4e2a\u5355\u4e00\u7684\u8868\u4e00\u6837\u3002
CREATE VIEW
\u8bed\u53e5\u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u89c6\u56fe\u3002
> CREATE [ OR REPLACE ] VIEW view_name AS\n SELECT column1, column2, ...\n FROM table_name\n WHERE condition;\n
Note
\u89c6\u56fe\u603b\u662f\u663e\u793a\u6700\u65b0\u7684\u6570\u636e\u3002\u6bcf\u5f53\u4f60\u67e5\u8be2\u89c6\u56fe\u65f6\uff0c\u6570\u636e\u5e93\u5f15\u64ce\u901a\u8fc7\u4f7f\u7528\u89c6\u56fe\u7684 SQL \u8bed\u53e5\u91cd\u5efa\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/create-view/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE t00(a INTEGER);\nINSERT INTO t00 VALUES (1),(2);\nCREATE TABLE t01(a INTEGER);\nINSERT INTO t01 VALUES (1);\nCREATE OR REPLACE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n\nmysql> SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a);\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n| 2 | NULL |\n+------+------+\n2 rows in set (0.01 sec)\n\nmysql> SELECT * FROM v0 WHERE b >= 0;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 1 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> SHOW CREATE VIEW v0;\n+------+---------------------------------------------------------------------------------------+\n| View | Create View |\n+------+---------------------------------------------------------------------------------------+\n| v0 | CREATE OR REPLACE VIEW v0 AS SELECT t00.a, t01.a AS b FROM t00 LEFT JOIN t01 USING(a) |\n+------+---------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
drop table if exists t1;\ncreate table t1 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t1 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t1 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\ndrop table if exists t2;\ncreate table t2 (id int,ti tinyint unsigned,si smallint,bi bigint unsigned,fl float,dl double,de decimal,ch char(20),vch varchar(20),dd date,dt datetime);\ninsert into t2 values(1,1,4,3,1113.32,111332,1113.32,'hello','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(2,2,5,2,2252.05,225205,2252.05,'bye','sub query','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(3,6,6,3,3663.21,366321,3663.21,'hi','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(4,7,1,5,4715.22,471522,4715.22,'good morning','my subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(5,1,2,6,51.26,5126,51.26,'byebye',' is subquery?','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(6,3,2,1,632.1,6321,632.11,'good night','maybe subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(7,4,4,3,7443.11,744311,7443.11,'yes','subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(8,7,5,8,8758.00,875800,8758.11,'nice to meet','just subquery','2022-04-28','2022-04-28 22:40:11');\ninsert into t2 values(9,8,4,9,9849.312,9849312,9849.312,'see you','subquery','2022-04-28','2022-04-28 22:40:11');\n\nmysql> select * from (select * from t1) sub where id > 4;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.01 sec)\n\ncreate view v1 as select * from (select * from t1) sub where id > 4;\ncreate view v2 as select ti as t,fl as f from (select * from t1) sub where dl <> 4;\ncreate view v3 as select * from (select ti as t,fl as f from t1 where dl <> 4) sub;\ncreate view v4 as select id,min(ti) from (select * from t1) sub group by id;\ncreate view v5 as select * from (select id,min(ti) from (select * from t1) t1 group by id) sub;\n\nmysql> select * from v1;\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| id | ti | si | bi | fl | dl | de | ch | vch | dd | dt |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n| 5 | 1 | 2 | 6 | 51.26 | 5126 | 51 | byebye | is subquery? | 2022-04-28 | 2022-04-28 22:40:11 |\n| 6 | 3 | 2 | 1 | 632.1 | 6321 | 632 | good night | maybe subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 7 | 4 | 4 | 3 | 7443.11 | 744311 | 7443 | yes | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 8 | 7 | 5 | 8 | 8758 | 875800 | 8758 | nice to meet | just subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n| 9 | 8 | 4 | 9 | 9849.312 | 9849312 | 9849 | see you | subquery | 2022-04-28 | 2022-04-28 22:40:11 |\n+------+------+------+------+----------+---------+------+--------------+----------------+------------+---------------------+\n5 rows in set (0.00 sec)\n\nmysql> select * from v2;\n+------+----------+\n| t | f |\n+------+----------+\n| 1 | 1113.32 |\n| 2 | 2252.05 |\n| 6 | 3663.21 |\n| 7 | 4715.22 |\n| 1 | 51.26 |\n| 3 | 632.1 |\n| 4 | 7443.11 |\n| 7 | 8758 |\n| 8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v3;\n+------+----------+\n| t | f |\n+------+----------+\n| 1 | 1113.32 |\n| 2 | 2252.05 |\n| 6 | 3663.21 |\n| 7 | 4715.22 |\n| 1 | 51.26 |\n| 3 | 632.1 |\n| 4 | 7443.11 |\n| 7 | 8758 |\n| 8 | 9849.312 |\n+------+----------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v4;\n+------+---------+\n| id | min(ti) |\n+------+---------+\n| 1 | 1 |\n| 2 | 2 |\n| 3 | 6 |\n| 4 | 7 |\n| 5 | 1 |\n| 6 | 3 |\n| 7 | 4 |\n| 8 | 7 |\n| 9 | 8 |\n+------+---------+\n9 rows in set (0.00 sec)\n\nmysql> select * from v5;\n+------+---------+\n| id | min(ti) |\n+------+---------+\n| 1 | 1 |\n| 2 | 2 |\n| 3 | 6 |\n| 4 | 7 |\n| 5 | 1 |\n| 6 | 3 |\n| 7 | 4 |\n| 8 | 7 |\n| 9 | 8 |\n+------+---------+\n9 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/","title":"DROP DATABASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8be5\u8bed\u53e5\u7528\u4e8e\u5220\u9664\u4e00\u4e2a\u6570\u636e\u5e93\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP DATABASE [IF EXISTS] <database_name>\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-database/#_3","title":"\u793a\u4f8b","text":"CREATE DATABASE test01;\n\nmysql> DROP DATABASE test01;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function/","title":"DROP FUNCTION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP FUNCTION
\u8bed\u53e5\u8868\u793a\u5220\u9664\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\u3002
> DROP FUNCTION <name> ([<arg_data_type> ]\u2026 )\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-function/#_3","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
--\u5220\u9664\u6709\u53c2\u51fd\u6570\n\ncreate or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\n\nmysql> select py_add(1,2);\n+--------------+\n| py_add(1, 2) |\n+--------------+\n| 3 |\n+--------------+\n1 row in set (0.01 sec)\n\n--\u5f53\u6211\u4eec\u4e0d\u518d\u9700\u8981\u8be5\u51fd\u6570\u65f6\uff0c\u53ef\u4ee5\u5c06\u5176\u5220\u9664\ndrop function py_add(int, int);\n
\u793a\u4f8b 2
--\u5220\u9664\u65e0\u53c2\u51fd\u6570\nmysql> CREATE FUNCTION t1_fun () RETURNS VARCHAR LANGUAGE SQL AS 'select n1 from t1 limit 1' ;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> drop function t1_fun();\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/","title":"DROP INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8be5\u8bed\u53e5\u7528\u4e8e\u4ece\u5f53\u524d\u6240\u9009\u7684\u8868\u4e2d\u5220\u9664\u7d22\u5f15\uff0c\u5982\u679c\u7d22\u5f15\u4e0d\u5b58\u5728\u5219\u4f1a\u62a5\u9519\uff0c\u9664\u975e\u4f7f\u7528 IF EXISTS
\u4fee\u9970\u7b26\u3002
> DROP INDEX index_name ON tbl_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-index/#_3","title":"\u793a\u4f8b","text":"create table t5(a int, b int, unique key(a));\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------+\n| t5 | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\ncreate index b on t5(b);\nmysql> show create table t5;\n+-------+-------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------+\n| t5 | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`),\nKEY `b` (`b`)\n) |\n+-------+-------------------------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n\ndrop index b on t5;\nmysql> show create table t5;\n+-------+----------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------+\n| t5 | CREATE TABLE `t5` (\n`a` INT DEFAULT NULL,\n`b` INT DEFAULT NULL,\nUNIQUE KEY `a` (`a`)\n) |\n+-------+----------------------------------------------------------------------------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/","title":"DROP PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP PUBLICATION
\u5c06\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u53d1\u5e03\u5220\u9664\u3002
DROP PUBLICATION pubname;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-publication/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+------+----------+\n| Name | Database |\n+------+----------+\n| pub3 | t |\n+------+----------+\n1 row in set (0.00 sec)\n\nmysql> drop publication pub3;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show publications;\nEmpty set (0.00 sec)
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/","title":"DROP SEQUENCE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP SEQUENCE
\u7528\u4e8e\u5220\u9664\u5e8f\u5217\u3002\u5b83\u5141\u8bb8\u4f60\u5220\u9664\u5148\u524d\u4f7f\u7528 CREATE SEQUENCE
\u547d\u4ee4\u521b\u5efa\u7684\u5e8f\u5217\u3002
\u5220\u9664\u5e8f\u5217\u4f1a\u5c06\u5e8f\u5217\u7684\u6240\u6709\u5c5e\u6027\u548c\u503c\u90fd\u5220\u9664\u3002\u56e0\u6b64\uff0c\u5728\u5220\u9664\u5e8f\u5217\u4e4b\u524d\uff0c\u5fc5\u987b\u786e\u4fdd\u6ca1\u6709\u4efb\u4f55\u8868\u4ecd\u5728\u4f7f\u7528\u8be5\u5e8f\u5217\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> DROP SEQUENCE [ IF EXISTS ] SEQUENCE_NAME [, ...]\n [IF EXISTS]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-sequence/#_3","title":"\u793a\u4f8b","text":"-- \u5220\u9664\u4e86\u540d\u4e3a \"seq_id\" \u7684\u5e8f\u5217\nDROP SEQUENCE seq_id;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-snapshot/","title":"DROP SNAPSHOT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-snapshot/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP SNAPSHOT
\u7528\u4e8e\u5220\u9664\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u7684\u5feb\u7167\u3002
> DROP SNAPSHOT snapshot_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-snapshot/#_3","title":"\u793a\u4f8b","text":"create snapshot sp1 for account sys;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp1 | 2024-05-10 09:55:11.601605 | account | sys | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n1 row in set (0.01 sec)\n\ndrop snapshot sp1;\n\nmysql> show snapshots;\nEmpty set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/","title":"DROP STAGE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP STAGE
\u7528\u4e8e\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664\u4e00\u4e2a\u5df2\u547d\u540d\u7684\u5185\u90e8\u6216\u5916\u90e8\u6570\u636e\u9636\u6bb5\u3002\u6570\u636e\u9636\u6bb5\u662f\u7528\u4e8e\u52a0\u8f7d\u6570\u636e\u4ece\u6587\u4ef6\u5230\u6570\u636e\u5e93\u8868\u4e2d\uff0c\u6216\u5c06\u6570\u636e\u4ece\u6570\u636e\u5e93\u8868\u5bfc\u51fa\u5230\u6587\u4ef6\u7684\u4e34\u65f6\u5b58\u50a8\u533a\u57df\u3002\u4f7f\u7528 DROP STAGE
\u547d\u4ee4\u53ef\u4ee5\u5c06\u4e0d\u518d\u9700\u8981\u7684\u6570\u636e\u9636\u6bb5\u4ece\u6570\u636e\u5e93\u4e2d\u79fb\u9664\uff0c\u4ece\u800c\u91ca\u653e\u5b58\u50a8\u7a7a\u95f4\u5e76\u907f\u514d\u4ea7\u751f\u989d\u5916\u7684\u5b58\u50a8\u8d39\u7528\u3002
Note
\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u5373 root \u7528\u6237\uff09\u548c\u79df\u6237\u7ba1\u7406\u5458\u53ef\u4ee5\u5220\u9664\u6570\u636e\u9636\u6bb5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"-- \u5220\u9664\u5185\u90e8\u9636\u6bb5\n> DROP STAGE [IF EXISTS] {internal_stage_name};\n\n-- \u5220\u9664\u5916\u90e8\u9636\u6bb5\n> DROP STAGE [IF EXISTS] {external_stage_name};\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-stage/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\n-- \u5220\u9664 stage1\nmysql> drop stage stage1;\nQuery OK, 0 rows affected (0.01 sec)\n\n-- stage1 \u5df2\u7ecf\u88ab\u5220\u9664\uff0c\u6570\u636e\u9636\u6bb5\u4e0d\u53ef\u7528\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\nERROR 20101 (HY000): internal error: stage 'stage1' is not exists, please check\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/","title":"DROP TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8be5\u8bed\u53e5\u7528\u4e8e\u4ece\u5f53\u524d\u6240\u9009\u7684\u6570\u636e\u5e93\u4e2d\u5220\u9664\u8868\uff0c\u5982\u679c\u8868\u4e0d\u5b58\u5728\u5219\u4f1a\u62a5\u9519\uff0c\u9664\u975e\u4f7f\u7528 IF EXISTS
\u4fee\u9970\u7b26\u3002
> DROP TABLE [IF EXISTS] [db.]name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-table/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE table01(a int);\n\nmysql> DROP TABLE table01;\nQuery OK, 0 rows affected (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/","title":"DROP VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DROP VIEW
\u8bed\u53e5\u8868\u793a\u5220\u9664\u89c6\u56fe\u3002
\u5982\u679c\u8bed\u6cd5\u53c2\u6570\u5217\u8868\u4e2d\u547d\u540d\u7684\u4efb\u4f55\u89c6\u56fe\u90fd\u4e0d\u5b58\u5728\uff0c\u5219\u8bed\u53e5\u62a5\u9519\uff0c\u5e76\u63d0\u793a\u65e0\u6cd5\u5220\u9664\u8fd9\u4e9b\u4e0d\u5b58\u5728\u7684\u89c6\u56fe\uff0c\u5e76\u4e14\u4e0d\u505a\u4efb\u4f55\u66f4\u6539\u3002
IF EXISTS
\u5b50\u53e5\u8868\u793a\u9632\u6b62\u56e0\u4e0d\u5b58\u5728\u7684\u89c6\u56fe\u800c\u53d1\u751f\u9519\u8bef\u3002\u7ed9\u51fa\u8be5\u5b50\u53e5\u65f6\uff0c\u5c06\u4e3a\u6bcf\u4e2a\u4e0d\u5b58\u5728\u7684\u89c6\u56fe\u751f\u6210\u4e00\u4e2a NOTE
\u3002
> DROP VIEW [IF EXISTS]\n view_name [, view_name] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/drop-view/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT);\nCREATE VIEW v1 AS SELECT * FROM t1;\n\nmysql> DROP VIEW v1;\nQuery OK, 0 rows affected (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/","title":"RESTORE ACCOUNT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"RESTORE ACCOUNT
\u6839\u636e\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u7684\u5feb\u7167\u5c06\u79df\u6237/\u6570\u636e\u5e93/\u8868\u6062\u590d\u5230\u67d0\u4e2a\u65f6\u95f4\u6233\u5bf9\u5e94\u7684\u72b6\u6001\u3002
> RESTORE ACCOUNT account_name [DATABASE database_name [TABLE table_name]] FROM SNAPSHOT snapshot_name [TO ACCOUNT account_name];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/#_3","title":"\u793a\u4f8b","text":"--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nCREATE database db1;\nCREATE database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.00 sec)\n\ncreate snapshot acc1_snap1 for account acc1;--\u521b\u5efa\u5feb\u7167\ndrop database db1;--\u5220\u9664\u6570\u636e\u5e93 db1,db2\ndrop database db2;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n5 rows in set (0.01 sec)\n\nrestore account acc1 FROM snapshot acc1_snap1;--\u6062\u590d\u79df\u6237\u7ea7\u522b\u5feb\u7167\n\nmysql> show databases;--\u6062\u590d\u6210\u529f\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| db2 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.01 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nCREATE database db1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.00 sec)\n\ncreate snapshot acc1_db_snap1 for account acc1;--\u521b\u5efa\u5feb\u7167\ndrop database db1;--\u5220\u9664\u6570\u636e\u5e93 db1\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\nrestore account acc1 database db1 FROM snapshot acc1_db_snap1;--\u6062\u590d\u6570\u636e\u5e93\u7ea7\u522b\u5feb\u7167\n\nmysql> show databases;--\u6062\u590d\u6210\u529f\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n7 rows in set (0.00 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nCREATE TABLE t1(n1 int);\nINSERT INTO t1 values(1);\n\nmysql> SELECT * FROM t1;\n+------+\n| n1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n\ncreate snapshot acc1_tab_snap1 for account acc1;--\u521b\u5efa\u5feb\u7167\ntruncate TABLE t1;--\u6e05\u7a7a t1\n\nmysql> SELECT * FROM t1;\nEmpty set (0.01 sec)\n\nrestore account acc1 database db1 TABLE t1 FROM snapshot acc1_tab_snap1;--\u6062\u590d\u5feb\u7167\n\nmysql> SELECT * FROM t1;--\u6062\u590d\u6210\u529f\n+------+\n| n1 |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ncreate database db1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate snapshot acc1_snap1 for account acc1;--\u4e3a acc1 \u521b\u5efa\u5feb\u7167\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ndrop database db1;--\u5220\u9664\u6570\u636e\u5e93 db1\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\nrestore account acc1 FROM snapshot acc1_snap1 TO account acc1;--\u5728\u7cfb\u7edf\u79df\u6237\u4e0b\u5bf9 acc1 \u8fdb\u884c\u5feb\u7167\u6062\u590d\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nmysql> show databases;--\u6062\u590d\u6210\u529f\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n
--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ncreate database db1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate snapshot acc1_snap1 for account acc1;--\u4e3a acc1 \u521b\u5efa\u5feb\u7167\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\ndrop database db1;--\u5220\u9664 db1\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n\n--\u5728\u7cfb\u7edf\u79df\u6237 sys \u4e0b\u6267\u884c\ncreate account acc2 ADMIN_NAME admin IDENTIFIED BY '111';--\u9700\u8981\u63d0\u524d\u521b\u5efa\u8981\u76ee\u6807\u65b0\u79df\u6237\nrestore account acc1 FROM snapshot acc1_snap1 TO account acc2;--\u5728\u7cfb\u7edf\u79df\u6237\u4e0b\u5bf9 acc1 \u8fdb\u884c\u5feb\u7167\u6062\u590d\uff0c\u6062\u590d\u81f3 acc2\n\n--\u5728\u79df\u6237 acc1 \u4e0b\u6267\u884c\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n5 rows in set (0.00 sec)\n\n--\u5728\u79df\u6237 acc2 \u4e0b\u6267\u884c\nmysql> show databases;--\u6062\u590d\u81f3 acc2\n+--------------------+\n| Database |\n+--------------------+\n| db1 |\n| information_schema |\n| mo_catalog |\n| mysql |\n| system |\n| system_metrics |\n+--------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/restore-account/#_4","title":"\u9650\u5236","text":"\u76ee\u524d\u53ea\u652f\u6301\u79df\u6237/\u6570\u636e\u5e93/\u8868\u7ea7\u522b\u7684\u6062\u590d\uff0c\u6682\u4e0d\u652f\u6301\u96c6\u7fa4\u7684\u3002
\u7cfb\u7edf\u79df\u6237\u6062\u590d\u666e\u901a\u79df\u6237\u5230\u65b0\u79df\u6237\u53ea\u5141\u8bb8\u79df\u6237\u7ea7\u522b\u7684\u6062\u590d\u3002
\u53ea\u6709\u7cfb\u7edf\u79df\u6237\u624d\u53ef\u4ee5\u6267\u884c\u6062\u590d\u6570\u636e\u5230\u65b0\u79df\u6237\uff0c\u4e14\u53ea\u5141\u8bb8\u79df\u6237\u7ea7\u522b\u7684\u6062\u590d\u3002\u65b0\u79df\u6237\u9700\u63d0\u524d\u521b\u5efa\uff0c\u4e3a\u4e86\u907f\u514d\u5bf9\u8c61\u51b2\u7a81\uff0c\u65b0\u79df\u6237\u6700\u597d\u4e3a\u65b0\u5efa\u79df\u6237\u3002
TRUNCATE TABLE
\u8bed\u53e5\u7528\u4e8e\u7528\u4e8e\u5220\u9664\u8868\u4e2d\u7684\u6240\u6709\u884c\uff0c\u800c\u4e0d\u8bb0\u5f55\u5355\u4e2a\u884c\u5220\u9664\u64cd\u4f5c\u3002TRUNCATE TABLE
\u4e0e\u6ca1\u6709 WHERE
\u5b50\u53e5\u7684 DELETE
\u8bed\u53e5\u7c7b\u4f3c\uff1b\u4f46\u662f\uff0cTRUNCATE TABLE
\u901f\u5ea6\u66f4\u5feb\uff0c\u4f7f\u7528\u7684\u7cfb\u7edf\u8d44\u6e90\u548c\u4e8b\u52a1\u65e5\u5fd7\u8d44\u6e90\u66f4\u5c11\u3002
TRUNCATE TABLE
\u6709\u4ee5\u4e0b\u7279\u70b9\uff1a
TRUNCATE TABLE
\u5220\u9664\u4e4b\u540e\uff0c\u4e0d\u53ef\u6062\u590d\u3002
\u5982\u679c\u8868\u5177\u6709 AUTO_INCREMENT
\u5217\uff0c\u5219 TRUNCATE TABLE
\u8bed\u53e5\u5c06\u81ea\u52a8\u9012\u589e\u503c\u91cd\u7f6e\u4e3a\u96f6\u3002
\u5982\u679c\u8868\u5177\u6709\u4efb\u4f55\u5916\u952e\u7ea6\u675f\uff08FOREIGN KEY
\uff09\uff0c\u5219 TRUNCATE TABLE
\u8bed\u53e5\u4f1a\u9010\u4e2a\u5220\u9664\u884c\u3002
\u5982\u679c\u8868\u6ca1\u6709\u4efb\u4f55\u5916\u952e\u7ea6\u675f\uff08FOREIGN KEY
\uff09\uff0c\u5219 TRUNCATE TABLE
\u8bed\u53e5\u5c06\u5220\u9664\u8be5\u8868\u5e76\u91cd\u65b0\u521b\u5efa\u4e00\u4e2a\u5177\u6709\u76f8\u540c\u7ed3\u6784\u7684\u65b0\u8868
DROP TABLE
\u3001TRUNCATE TABLE
\u548c DELETE TABLE
\u7684\u533a\u522b\uff1a
DROP TABLE
\uff1a\u5f53\u4f60\u4e0d\u518d\u9700\u8981\u8be5\u8868\u65f6\uff0c\u7528 DROP TABLE
\u3002TRUNCATE TABLE
\uff1a\u5f53\u4f60\u8981\u5220\u9664\u6240\u6709\u8bb0\u5f55\uff0c\u4f46\u4ecd\u8981\u4fdd\u7559\u8be5\u8868\u65f6\uff0c\u7528 TRUNCATE TABLE
\u3002DELETE TABLE
\uff1a\u5f53\u4f60\u8981\u5220\u9664\u90e8\u5206\u8bb0\u5f55\u65f6\uff0c\u7528 DELETE TABLE
\u3002> TRUNCATE [TABLE] table_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Definition-Language/truncate-table/#table","title":"TABLE","text":"TABLE \u5173\u952e\u5b57\u662f\u53ef\u9009\u7684\u3002\u4f7f\u7528\u5b83\u6765\u533a\u5206 TRUNCATE TABLE
\u8bed\u53e5\u548c TRUNCATE
\u51fd\u6570\u3002
create table index_table_05 (col1 bigint not null auto_increment,col2 varchar(25),col3 int,col4 varchar(50),primary key (col1),unique key col2(col2),key num_id(col4));\ninsert into index_table_05(col2,col3,col4) values ('apple',1,'10'),('store',2,'11'),('bread',3,'12');\nmysql> select * from index_table_05;\n+------+-------+------+------+\n| col1 | col2 | col3 | col4 |\n+------+-------+------+------+\n| 1 | apple | 1 | 10 |\n| 2 | store | 2 | 11 |\n| 3 | bread | 3 | 12 |\n+------+-------+------+------+\n3 rows in set (0.00 sec)\n\nmysql> truncate table index_table_05;\nQuery OK, 0 rows affected (0.12 sec)\n\nmysql> select * from index_table_05;\nEmpty set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/","title":"CASE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/case/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"CASE
\u8bed\u53e5\u7528\u4e8e\u5b58\u50a8\u8fc7\u7a0b\u7684\u590d\u5408\u8bed\u53e5\u4e2d\u3002
\u5982\u679c\u6ca1\u6709 when_value
\u6216 search_condition
\u5339\u914d\u7684\u503c\uff0c\u5e76\u4e14 CASE
\u8bed\u53e5\u4e0d\u5305\u542b ELSE
\u4ece\u53e5\uff0c\u90a3\u4e48 CASE
\u8bed\u53e5\u62a5\u9519\u3002
\u6bcf\u4e2a statement_list
\u53ef\u4ee5\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u8bed\u53e5\u7ec4\u6210\uff0c\u4f46\u4e0d\u5141\u8bb8\u4f7f\u7528\u7a7a\u3002
\u8fd8\u6709\u4e00\u4e2a CASE
\u64cd\u4f5c\u7b26\uff0c\u5b83\u4e0e\u672c\u7ae0 CASE
\u8bed\u53e5\u4e0d\u540c\u3002\u53c2\u89c1\u6d41\u63a7\u5236\u51fd\u6570\u3002CASE
\u8bed\u53e5\u4e0d\u80fd\u6709 ELSE NULL
\u4ece\u53e5\uff0c\u5e76\u4e14 CASE
\u8bed\u53e5\u5fc5\u987b\u4ee5 END CASE
\u7ed3\u5c3e\u3002
CASE case_value\n WHEN when_value THEN statement_list\n [WHEN when_value THEN statement_list] ...\n [ELSE statement_list]\nEND CASE\n
\u5728\u8fd9\u4e2a\u8bed\u6cd5\u7ed3\u6784\u4e2d\uff0ccase_value
\u662f\u4e00\u4e2a\u8868\u8fbe\u5f0f\u3002\u8fd9\u4e2a\u8868\u8fbe\u5f0f\u4f1a\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u67e5\u627e when_value
\uff0c\u76f4\u5230\u627e\u5230\u548c\u8868\u8fbe\u5f0f\u76f8\u7b49\u7684 when_value
\uff0c\u5e76\u8fd4\u56de\u5bf9\u5e94\u7684\u7ed3\u679c\uff0c\u75c5\u6267\u884c\u76f8\u5e94\u7684 THEN
\u4ece\u53e5 statement_list
\uff1b\u5982\u679c\u6ca1\u6709\u627e\u5230\u76f8\u7b49\u7684 when_value
\uff0c\u5219\u8fd4\u56de ELSE
\u8bed\u53e5\u540e\u7684 statement_list
\u7ed3\u679c\u3002
\u4f46\u662f\u8fd9\u4e2a\u8bed\u6cd5\u4e0d\u80fd\u7528\u4e8e\u6d4b\u8bd5\u662f\u5426\u4e0e NULL
\u76f8\u7b49\uff0c\u56e0\u4e3a NULL = NULL
\u4e3a false
\u3002
CASE\n WHEN search_condition THEN statement_list\n [WHEN search_condition THEN statement_list] ...\n [ELSE statement_list]\nEND CASE\n
\u5728\u8fd9\u4e2a\u8bed\u6cd5\u4e2d\uff0cCASE
\u8868\u8fbe\u5f0f\u4f1a\u4ece\u5de6\u5230\u53f3\u4f9d\u6b21\u8ba1\u7b97 search_condition
\uff0c\u76f4\u5230\u7b2c\u4e00\u4e2a\u4e3a true
\uff0c\u7136\u540e\u6267\u884c THEN
\u4ece\u53e5 statement_list
\u5e76\u8fd4\u56de\u5bf9\u5e94\u7ed3\u679c\u3002\u5982\u679c\u6ca1\u6709\u4e3a true
\u7684 search_condition
\uff0c\u5219\u6267\u884c ELSE
\u4ece\u53e5 statement_list
\u5e76\u8fd4\u56de\u7ed3\u679c\u3002
CREATE TABLE t1(c0 INTEGER, c1 INTEGER, c2 INTEGER);\nINSERT INTO t1 VALUES(1, 1, 1), (1, 1, 1);\n\nmysql> SELECT CASE AVG (c0) WHEN any_value(c1) * any_value(c2) THEN 1 END FROM t1;\n+------------------------------------------------------------+\n| case avg(c0) when any_value(c1) * any_value(c2) then 1 end |\n+------------------------------------------------------------+\n| 1 |\n+------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) * any_value(c2) WHEN SUM(c0) THEN 1 WHEN AVG(c0) THEN 2 END FROM t1;\n+--------------------------------------------------------------------------------+\n| case any_value(c1) * any_value(c2) when sum(c0) then 1 when avg(c0) then 2 end |\n+--------------------------------------------------------------------------------+\n| 2 |\n+--------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n\nmysql> SELECT CASE any_value(c1) WHEN any_value(c1) + 1 THEN 1 END, ABS(AVG(c0)) FROM t1;\n+------------------------------------------------------+--------------+\n| case any_value(c1) when any_value(c1) + 1 then 1 end | abs(avg(c0)) |\n+------------------------------------------------------+--------------+\n| NULL | 1 |\n+------------------------------------------------------+--------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/","title":"DELETE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/delete/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DELETE
\u7528\u4e8e\u5220\u9664\u5355\u8868\u6216\u591a\u8868\u4e2d\u7684\u8bb0\u5f55\u3002
DELETE FROM tbl_name [[AS] tbl_alias]\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
DELETE
\u8bed\u53e5\u4ece tbl_name
\u4e2d\u5220\u9664\u884c\uff0c\u5e76\u8fd4\u56de\u5df2\u5220\u9664\u7684\u884c\u6570\u3002
WHERE
\u4ece\u53e5\u7528\u4e8e\u6307\u5b9a\u7528\u4e8e\u6807\u8bc6\u8981\u5220\u9664\u54ea\u4e9b\u884c\u7684\u6761\u4ef6\u3002\u82e5\u65e0 WHERE
\u4ece\u53e5\uff0c\u5219\u5220\u9664\u6240\u6709\u884c\u3002
ORDER BY
\u4ece\u53e5\uff0c\u6307\u6309\u7167\u6307\u5b9a\u7684\u987a\u5e8f\u5220\u9664\u884c\u3002
LIMIT
\u4ece\u53e5\u7528\u4e8e\u9650\u5236\u53ef\u5220\u9664\u7684\u884c\u6570\u3002
CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\ndelete from t1 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 1 | 2 |\n+------+------+\n
\u540c\u65f6\u4e5f\u652f\u6301\u591a\u8868 JOIN \u8bed\u53e5\u3002
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (5);\ndelete t1 from t1 join t2 where t1.a = 2;\n\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n| 4 |\n+------+\n2 rows in set (0.00 sec)\n
drop database if exists db1;\ndrop database if exists db2;\ncreate database db1;\ncreate database db2;\nuse db2;\ndrop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values (1),(2),(4);\nuse db1;\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1),(2),(3);\ndelete from db1.t2, db2.t1 using db1.t2 join db2.t1 on db1.t2.b = db2.t1.a where 2 > 1;\n\nmysql> select * from db1.t2;\n+------+\n| b |\n+------+\n| 3 |\n+------+\nmysql> select * from db2.t1;\n+------+\n| a |\n+------+\n| 4 |\n+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/","title":"INSERT INTO SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"INSERT INTO SELECT
\u8bed\u53e5\u4ece\u4e00\u4e2a\u8868\u590d\u5236\u6570\u636e\uff0c\u7136\u540e\u628a\u6570\u636e\u63d2\u5165\u5230\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u8868\u4e2d\u3002\u4e14\u76ee\u6807\u8868\u4e2d\u4efb\u4f55\u5df2\u5b58\u5728\u7684\u884c\u90fd\u4e0d\u4f1a\u53d7\u5f71\u54cd\u3002
INSERT INTO table2 (column1, column2, column3, ...)\nSELECT column1, column2, column3, ...\nFROM table1\nWHERE condition;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert-into-select/#_3","title":"\u793a\u4f8b","text":"create table t1(id int, name varchar(10));\ninsert into t1 values(1, 'a');\ninsert into t1 values(2, 'b');\ninsert into t1 values(3, 'c');\ncreate table t2(id int, appname varchar(10), country varchar(10));\ninsert into t2 values(1, 'appone', 'CN');\ninsert into t2 values(2, 'apptwo', 'CN');\nINSERT INTO t1 (name) SELECT appname FROM t2;\n\nmysql> select * from t1;\n+------+--------+\n| id | name |\n+------+--------+\n| 1 | a |\n| 2 | b |\n| 3 | c |\n| NULL | appone |\n| NULL | apptwo |\n+------+--------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/","title":"INSERT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"INSERT
\u7528\u4e8e\u5728\u8868\u4e2d\u63d2\u5165\u65b0\u884c\u3002
> INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/insert/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(a int default (1+12), b int);\ninsert into t1(b) values(1), (1);\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 13 | 1 |\n| 13 | 1 |\n+------+------+\n2 rows in set (0.01 sec)\n\ndrop table if exists t1;\ncreate table t1 (a date);\ninsert into t1 values(DATE(\"2017-06-15 09:34:21\")),(DATE(\"2019-06-25 10:12:21\")),(DATE(\"2019-06-25 18:20:49\"));\n\nmysql> select * from t1;\n+------------+\n| a |\n+------------+\n| 2017-06-15 |\n| 2019-06-25 |\n| 2019-06-25 |\n+------------+\n3 rows in set (0.00 sec)\n\ndrop table if exists t;\nCREATE TABLE t (i1 INT, d1 DOUBLE, e2 DECIMAL(5,2));\nINSERT INTO t VALUES ( 6, 6.0, 10.0/3), ( null, 9.0, 10.0/3), ( 1, null, 10.0/3), ( 2, 2.0, null );\n\nmysql> select * from t;\n+------+------+------+\n| i1 | d1 | e2 |\n+------+------+------+\n| 6 | 6 | 3.33 |\n| NULL | 9 | 3.33 |\n| 1 | NULL | 3.33 |\n| 2 | 2 | NULL |\n+------+------+------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data-inline/","title":"LOAD DATA INLINE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data-inline/#_1","title":"\u6982\u8ff0","text":"LOAD DATA INLINE
\u8bed\u6cd5\u53ef\u4ee5\u5c06 csv \u683c\u5f0f\u7ec4\u7ec7\u7684\u5b57\u7b26\u4e32\u5bfc\u5165\u6570\u636e\u8868\u4e2d\uff0c\u5bfc\u5165\u901f\u5ea6\u8f83 INSERT INTO
\u64cd\u4f5c\u66f4\u5feb\u3002LOAD DATA INLINE
\u7684\u529f\u80fd\u9002\u5408\u65e0\u4e3b\u952e\u7684\u6d41\u5f0f\u5feb\u901f\u6570\u636e\u5199\u5165\uff0c\u5982 IoT \u7c7b\u7684\u573a\u666f\u3002
mysql> LOAD DATA INLINE FORMAT='csv' ,\nDATA=$XXX$\ncsv_string $XXX$\nINTO TABLE tbl_name;\n
\u53c2\u6570\u89e3\u91ca
FORMAT='csv'
\u8868\u793a\u540e\u9762 DATA
\u4e2d\u7684\u5b57\u7b26\u4e32\u6570\u636e\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u7684\u3002
DATA=$XXX$ csv_string $XXX$
\u4e2d\u7684 $XXX$
\u662f\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\u3002csv_string
\u662f\u4ee5 csv
\u4e3a\u683c\u5f0f\u7ec4\u7ec7\u5b57\u7b26\u4e32\u6570\u636e\uff0c\u4ee5 \\n
\u6216\u8005 \\r\\n
\u4f5c\u4e3a\u6362\u884c\u7b26\u3002
Note
$XXX$
\u4e3a\u6570\u636e\u5f00\u59cb\u548c\u7ed3\u675f\u7684\u6807\u8bc6\u7b26\uff0c\u6ce8\u610f\u6570\u636e\u7ed3\u675f\u5904\u7684 $XXX$
\u9700\u8981\u548c\u6700\u540e\u4e00\u884c\u6570\u636e\u653e\u5728\u540c\u4e00\u884c\uff0c\u6362\u884c\u53ef\u80fd\u5bfc\u81f4 ERROR 20101
LOAD DATA INLINE
\u5bfc\u5165\u6570\u636e","text":"\u542f\u52a8 MySQL \u5ba2\u6237\u7aef\uff0c\u8fde\u63a5 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n
Note
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
\u5728 MatrixOne \u4e2d\u6267\u884c LOAD DATA INLINE
\u4e4b\u524d\uff0c\u9700\u8981\u63d0\u524d\u5728 MatrixOne \u4e2d\u521b\u5efa\u5b8c\u6210\u6570\u636e\u8868 user
:
CREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n)\n
\u5728 MySQL \u5ba2\u6237\u7aef\u6267\u884c LOAD DATA INLINE
\u8fdb\u884c\u6570\u636e\u5bfc\u5165\uff0c\u4ee5 csv \u683c\u5f0f\u5bfc\u5165\u6570\u636e\uff1a
mysql> LOAD DATA INLINE FORMAT='csv',\nDATA=$XXX$\nLihua,23,Shanghai\nBob,25,Beijing $XXX$ INTO TABLE user;\n
LOAD DATA INFILE
\u8bed\u53e5\u53ef\u4ee5\u6781\u5feb\u5730\u5c06\u6587\u672c\u6587\u4ef6\u4e2d\u7684\u884c\u8bfb\u5165\u8868\u4e2d\u3002\u4f60\u53ef\u4ee5\u4ece\u670d\u52a1\u5668\u4e3b\u673a\u6216 S3 \u517c\u5bb9\u5bf9\u8c61\u5b58\u50a8\u8bfb\u53d6\u8be5\u6587\u4ef6\u3002LOAD DATA INFILE
\u662f SELECT ... INTO OUTFILE
\u76f8\u53cd\u7684\u64cd\u4f5c\u3002
LOAD DATA INFILE
\u3002SELECT ... INTO OUTFILE
\u3002FIELDS
\u548c LINES
\u5b50\u53e5\u7684\u8bed\u6cd5\u5bf9\u4e8e LOAD DATA INFILE
\u548c SELECT ... INTO OUTFILE
\u8fd9\u4e24\u4e2a\u8bed\u53e5\u7684\u4f7f\u7528\u65b9\u5f0f\u4e00\u81f4\uff0c\u4f7f\u7528 Fields \u548c Lines \u53c2\u6570\u6765\u6307\u5b9a\u5982\u4f55\u5904\u7406\u6570\u636e\u683c\u5f0f\u3002> LOAD DATA [LOCAL]\n INFILE 'file_name'\n INTO TABLE tbl_name\n [CHARACTER SET charset_name]\n [{FIELDS | COLUMNS}\n [TERMINATED BY 'string']\n [[OPTIONALLY] ENCLOSED BY 'char']\n [ENCASPED BY 'char']\n ]\n [LINES\n [STARTING BY 'string']\n [TERMINATED BY 'string']\n ]\n [IGNORE number {LINES | ROWS}]\n [SET column_name_1=nullif(column_name_1, expr1), column_name_2=nullif(column_name_2, expr2)...]\n [PARALLEL {'TRUE' | 'FALSE'}]\n [STRICT {'TRUE' | 'FALSE'}]\n
\u53c2\u6570\u89e3\u91ca
\u4e0a\u8ff0\u8bed\u6cd5\u7ed3\u6784\u4e2d\u7684\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#infile","title":"INFILE","text":"LOAD DATA INFILE 'file_name'
\uff1a\u547d\u4ee4\u884c\u4f7f\u7528\u573a\u666f\uff1a\u9700\u8981\u52a0\u8f7d\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u4e3b\u673a\u670d\u52a1\u5668\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u3002 file_name
\u53ef\u4ee5\u662f\u6587\u4ef6\u7684\u5b58\u653e\u4f4d\u7f6e\u7684\u76f8\u5bf9\u8def\u5f84\u540d\u79f0\uff0c\u4e5f\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84\u540d\u79f0\u3002
LOAD DATA LOCAL INFILE 'file_name'
\uff1a\u547d\u4ee4\u884c\u4f7f\u7528\u573a\u666f\uff1a\u9700\u8981\u52a0\u8f7d\u7684\u6570\u636e\u6587\u4ef6\u4e0e MatrixOne \u4e3b\u673a\u670d\u52a1\u5668\u4e0d\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\uff0c\u5373\uff0c\u6570\u636e\u6587\u4ef6\u5728\u5ba2\u6237\u673a\u4e0a\u3002 file_name
\u53ef\u4ee5\u662f\u6587\u4ef6\u7684\u5b58\u653e\u4f4d\u7f6e\u7684\u76f8\u5bf9\u8def\u5f84\u540d\u79f0\uff0c\u4e5f\u53ef\u4ee5\u662f\u7edd\u5bf9\u8def\u5f84\u540d\u79f0\u3002
\u5982\u679c\u6587\u4ef6\u5185\u5bb9\u4f7f\u7528\u4e0e\u9ed8\u8ba4\u503c\u4e0d\u540c\u7684\u5b57\u7b26\u96c6\uff0c\u53ef\u4f7f\u7528 CHARACTER SET
\u6307\u5b9a\u5b57\u7b26\u96c6\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 CHARACTER SET utf8
\u6307\u5b9a\u5bfc\u5165\u5185\u5bb9\u5b57\u7b26\u96c6\u4e3a utf8\uff1a
LOAD DATA INFILE 'yourfilepath' INTO TABLE xx CHARACTER SET utf8;\n
Note
\u9664\u4e86 utf8 \u5916\uff0cLOAD DATA
\u8fd8\u652f\u6301\u6307\u5b9a utf_8\u3001UTF_16\u3001UTF_xx\u3001gbk\u3001abcd \u7b49\u5b57\u7b26\u96c6\u3002\u6682\u4e0d\u652f\u6301\u6307\u5b9a\u5e26\u6709 -\uff08\u5982 utf-8,UTF-16) \u7684\u5b57\u7b26\u96c6\u3002
IGNORE number LINES
\u5b50\u53e5\u53ef\u7528\u4e8e\u5ffd\u7565\u6587\u4ef6\u5f00\u5934\u7684\u884c\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 IGNORE 1 LINES
\u8df3\u8fc7\u5305\u542b\u5217\u540d\u7684\u521d\u59cb\u6807\u9898\u884c\uff1a
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1 IGNORE 1 LINES;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#fields-lines","title":"FIELDS \u548c LINES \u53c2\u6570\u8bf4\u660e","text":"\u4f7f\u7528 FIELDS
\u548c LINES
\u53c2\u6570\u6765\u6307\u5b9a\u5982\u4f55\u5904\u7406\u6570\u636e\u683c\u5f0f\u3002
\u5bf9\u4e8e LOAD DATA
\u548c SELECT ... INTO OUTFILE
\u8bed\u53e5\uff0cFIELDS
\u548c LINES
\u5b50\u53e5\u7684\u8bed\u6cd5\u662f\u76f8\u540c\u7684\u3002\u8fd9\u4e24\u4e2a\u5b50\u53e5\u90fd\u662f\u53ef\u9009\u7684\uff0c\u4f46\u5982\u679c\u4e24\u8005\u90fd\u6307\u5b9a\uff0c\u5219 FIELDS
\u5fc5\u987b\u5728 LINES
\u4e4b\u524d\u3002
\u5982\u679c\u6307\u5b9a FIELDS
\u5b50\u53e5\uff0c\u90a3\u4e48 FIELDS
\u7684\u6bcf\u4e2a\u5b50\u53e5\uff08TERMINATED BY
\u3001[OPTIONALLY] ENCLOSED BY
\uff09\u4e5f\u662f\u53ef\u9009\u7684\uff0c\u9664\u975e\u4f60\u5fc5\u987b\u81f3\u5c11\u6307\u5b9a\u5176\u4e2d\u4e00\u4e2a\u3002
LOAD DATA
\u4e5f\u652f\u6301\u4f7f\u7528\u5341\u516d\u8fdb\u5236 ASCII
\u5b57\u7b26\u8868\u8fbe\u5f0f\u6216\u4e8c\u8fdb\u5236 ASCII
\u5b57\u7b26\u8868\u8fbe\u5f0f\u4f5c\u4e3a FIELDS ENCLOSED BY
\u548c FIELDS TERMINATED BY
\u7684\u53c2\u6570\u3002
\u5982\u679c\u4e0d\u6307\u5b9a\u5904\u7406\u6570\u636e\u7684\u53c2\u6570\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u503c\u5982\u4e0b\uff1a
FIELDS TERMINATED BY '\\t' ENCLOSED BY '\"' ESCAPED BY '\\\\' LINES TERMINATED BY '\\n'\n
Note
FIELDS TERMINATED BY '\\t'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \\t
\u4f5c\u4e3a\u5206\u9694\u7b26\u3002ENCLOSED BY '\"'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \"
\u4f5c\u4e3a\u5305\u62ec\u7b26\u3002ESCAPED BY '\\\\'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \\
\u4f5c\u4e3a\u8f6c\u4e49\u7b26\u3002LINES TERMINATED BY '\\n'
\uff1a\u4ee5\u4e14\u4ec5\u4ee5 \\n
\u6216 \\r\\n
\u4f5c\u4e3a\u884c\u95f4\u5206\u9694\u7b26\u3002FIELDS TERMINATED BY
FIELDS TERMINATED BY
\u8868\u793a\u5b57\u6bb5\u4e0e\u5b57\u6bb5\u4e4b\u95f4\u7684\u5206\u9694\u7b26\uff0c\u4f7f\u7528 FIELDS TERMINATED BY
\u5c31\u53ef\u4ee5\u6307\u5b9a\u6bcf\u4e2a\u6570\u636e\u7684\u5206\u9694\u7b26\u53f7\u3002
FIELDS TERMINATED BY
\u6307\u5b9a\u7684\u503c\u53ef\u4ee5\u8d85\u8fc7\u4e00\u4e2a\u5b57\u7b26\u3002
\u793a\u4f8b\uff1a
\u4f8b\u5982\uff0c\u8bfb\u53d6\u4f7f\u7528\u9017\u53f7\u5206\u9694\u7684\u6587\u4ef6\uff0c\u8bed\u6cd5\u662f\uff1a
LOAD DATA INFILE 'data.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',';\n
FIELDS ENCLOSED BY
FIELDS TERMINATED BY
\u6307\u5b9a\u7684\u503c\u5305\u542b\u8f93\u5165\u503c\u7684\u5b57\u7b26\u3002ENCLOSED BY
\u6307\u5b9a\u7684\u503c\u5fc5\u987b\u662f\u5355\u4e2a\u5b57\u7b26\uff1b\u5982\u679c\u8f93\u5165\u503c\u4e0d\u4e00\u5b9a\u5305\u542b\u5728\u5f15\u53f7\u4e2d\uff0c\u9700\u8981\u5728 ENCLOSED BY
\u9009\u9879\u4e4b\u524d\u4f7f\u7528 OPTIONALLY
\u3002
\u5982\u4e0b\u9762\u7684\u4f8b\u5b50\u6240\u793a\uff0c\u5373\u8868\u793a\u4e00\u90e8\u5206\u8f93\u5165\u503c\u7528\u53ef\u4ee5\u7528\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u53e6\u4e00\u4e9b\u53ef\u4ee5\u4e0d\u7528\u5f15\u53f7\u62ec\u8d77\u6765\uff1a
LOAD DATA INFILE 'data.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';\n
\u5982\u679c ENCLOSED BY
\u524d\u4e0d\u52a0 OPTIONALLY
\uff0c\u6bd4\u5982\u8bf4\uff0cENCLOSED BY '\"'
\u5c31\u8868\u793a\u4f7f\u7528\u53cc\u5f15\u53f7\u628a\u5404\u4e2a\u5b57\u6bb5\u90fd\u62ec\u8d77\u6765\u3002
FIELDS ESCAPED BY
FIELDS ESCAPED BY
\u5141\u8bb8\u4f60\u6307\u5b9a\u4e00\u4e2a\u8f6c\u4e49\u5b57\u7b26\uff0c\u9ed8\u8ba4\u503c \\\\
\uff0c\u4ee3\u8868 \\
\u662f\u4e2a\u8f6c\u4e49\u7b26\u53f7\uff0c\u5982\u679c FIELDS ESCAPED BY
\u5b57\u7b26\u4e0d\u4e3a\u7a7a\uff0c\u5219\u5220\u9664\u8be5\u5b57\u7b26\uff0c\u5e76\u4e14\u540e\u7eed\u5b57\u7b26\u5c06\u6309\u5b57\u9762\u610f\u601d\u4f5c\u4e3a\u5b57\u6bb5\u503c\u7684\u4e00\u90e8\u5206\u3002
\u4f46\u4e00\u4e9b\u53cc\u5b57\u7b26\u5e8f\u5217\u6709\u7740\u7279\u6b8a\u542b\u4e49\uff0c\u5982\u4e0b\u8868\uff1a
\u8f6c\u4e49\u5e8f\u5217 \u5e8f\u5217\u8868\u793a\u7684\u5b57\u7b26 \\0 \u7a7a\u683c\u7b26 \\b \u9000\u683c\u7b26 \\n \u6362\u884c\u7b26 \\r \u56de\u8f66\u7b26 \\t \u5236\u8868\u7b26 \\z \u7ed3\u675f\u7b26\uff08Ctl+Z\uff09\u793a\u4f8b
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\\\b\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t1\uff1a
create table t1(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t1;\n\nmysql> select * from t1;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | a\\b |\n+------+------+\n1 row in set (0.00 sec)\n
n2 \u7684\u7ed3\u679c\u4e3a a\\b
\uff0c\u56e0\u4e3a\u7b2c\u4e00\u4e2a \\
\u4e3a\u8f6c\u4e49\u7b26\uff0c\u88ab\u5220\u9664\u4e86\u3002
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\\\b\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t2\uff1a
create table t2(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t2 fields escaped by 'a';\n\nmysql> select * from t2;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | \\\\b |\n+------+------+\n1 row in set (0.00 sec)\n
n2 \u7684\u7ed3\u679c\u4e3a \\\\b
\uff0c\u56e0\u4e3a\u5728\u8fd9\u91cc\u6211\u4eec\u6307\u5b9a\u4e86\u8f6c\u4e49\u7b26\u4e3a a
\uff0c\u6240\u4ee5 a
\u88ab\u5220\u9664\u4e86\u3002
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\\\ b\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t1\uff1a
create table t3(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t3 fields escaped by '';\n\nmysql> SELECT * FROM t3;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | a\\\\b |\n+------+------+\n1 row in set (0.01 sec)\n
n2 \u7684\u7ed3\u679c\u4e3a a\\\\b
\uff0c\u5f53 ESCAPED BY \u4e3a\u7a7a\u65f6\uff0c\u539f\u6837\u8bfb\u53d6\u4e0d\u5bf9\u5b57\u7b26\u505a\u8f6c\u4e49\u5904\u7406\u3002
data.txt \u5185\u5bb9\u5982\u4e0b\uff1a
(base) admin@admindeMacBook-Pro case % cat data.txt \n1 a\\0b\n2 c\\bd\n3 a\\nb\n4 a\\rb\n5 a\\tb\n6 a\\Zb\n
\u8fde\u63a5 mo \u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\uff0c\u5c06 data.txt \u5185\u5bb9\u5bfc\u5165\u5230 t4\uff1a
create table t3(n1 int,n2 varchar(255));\nload data infile 'Users/admin/test/case/data.txt' into table t4;\n\nmysql> select * from t1;\n+------+------+\n| n1 | n2 |\n+------+------+\n| 1 | a b |\n| 2 | d |\n| 3 | a\nb |\nb | 4 | a\n| 5 | a b |\n| 6 | ab |\n+------+------+\n6 rows in set (0.01 sec)\n
n1=1 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a b
\uff0c\u56e0\u4e3a \\0
\u4e3a\u7a7a\u683c\u7b26\uff1b
n=2 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a d
\uff0c\u56e0\u4e3a \\b
\u4e3a\u9000\u683c\u7b26\uff0ca
\u88ab\u5220\u9664\uff1b
n=3 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a
\u52a0\u6362\u884c\u540e\u7684 b
\uff0c\u56e0\u4e3a \\n
\u4e3a\u6362\u884c\u7b26\uff1b
n=4 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a
\u52a0\u6362\u56de\u8f66\u540e\u7684 b
\uff0c\u56e0\u4e3a \\r
\u4e3a\u56de\u8f66\u7b26\uff1b
n=5 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a a b
\u7684 b\uff0c\u56e0\u4e3a \\t
\u4e3a\u5236\u8868\uff1b
n=6 \u65f6\uff0cn2 \u7684\u7ed3\u679c\u4e3a ab
\uff0c\u56e0\u4e3a \\z
\u4e3a\u7ed3\u675f\u7b26\u3002
LINES TERMINATED BY
LINES TERMINATED BY
\u7528\u4e8e\u6307\u5b9a\u4e00\u884c\u7684\u7ed3\u675f\u7b26\u3002LINES TERMINATED BY
\u503c\u53ef\u4ee5\u8d85\u8fc7\u4e00\u4e2a\u5b57\u7b26\u3002
\u4f8b\u5982\uff0ccsv \u6587\u4ef6\u4e2d\u7684\u884c\u4ee5\u56de\u8f66\u7b26/\u6362\u884c\u7b26\u5bf9\u7ed3\u675f\uff0c\u4f60\u5728\u52a0\u8f7d\u5b83\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 LINES TERMINATED BY '\\r\\n'
\u6216 LINES TERMINATED BY '\\n'
\uff1a
LOAD DATA INFILE 'data.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',' ENCLOSED BY '\"'\n LINES TERMINATED BY '\\r\\n';\n
LINE STARTING BY
\u5982\u679c\u6240\u6709\u8f93\u5165\u884c\u90fd\u6709\u4e00\u4e2a\u4f60\u60f3\u5ffd\u7565\u7684\u516c\u5171\u524d\u7f00\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 LINES STARTING BY
'prefix_string' \u6765\u5ffd\u7565\u524d\u7f00\u548c\u524d\u7f00\u4e4b\u524d\u7684\u4efb\u4f55\u5185\u5bb9\u3002
\u5982\u679c\u4e00\u884c\u4e0d\u5305\u542b\u524d\u7f00\uff0c\u5219\u8df3\u8fc7\u6574\u884c\u3002\u5982\u4e0b\u8bed\u53e5\u6240\u793a\uff1a
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE table1\n FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx';\n
\u5982\u679c\u6570\u636e\u6587\u4ef6\u662f\u5982\u4e0b\u6837\u5f0f\uff1a
xxx\"abc\",1\nsomething xxx\"def\",2\n\"ghi\",3\n
\u5219\u8f93\u51fa\u7684\u7ed3\u679c\u884c\u662f (\"abc\"\uff0c1) \u548c (\"def\"\uff0c2)\u3002\u6587\u4ef6\u4e2d\u7684\u7b2c\u4e09\u884c\u7531\u4e8e\u6ca1\u6709\u524d\u7f00\uff0c\u5219\u88ab\u5ffd\u7565\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#set","title":"SET","text":"MatrixOne \u5f53\u524d\u4ec5\u652f\u6301 SET column_name=nullif(column_name,expr)
\u3002\u5373\uff0c\u5f53 column_name = expr
\uff0c\u8fd4\u56de NULL
\uff1b\u5426\u5219\uff0c\u5219\u8fd4\u56de column_name
\u3002\u4f8b\u5982\uff0cSET a=nullif(a, 1)
\uff0c\u5f53 a=1 \u65f6\uff0c\u8fd4\u56de NULL
\uff1b\u5426\u5219\uff0c\u8fd4\u56de a \u5217\u539f\u59cb\u7684\u503c\u3002
\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u52a0\u8f7d\u6587\u4ef6\u65f6\uff0c\u8bbe\u7f6e\u53c2\u6570 SET column_name=nullif(column_name,\"null\")
\uff0c\u7528\u4e8e\u8fd4\u56de\u5217\u4e2d\u7684 NULL
\u503c\u3002
\u793a\u4f8b
\u672c\u5730\u6587\u4ef6 test.txt
\u8be6\u60c5\u5982\u4e0b\uff1a
id,user_name,sex\n1,\"weder\",\"man\"\n2,\"tom\",\"man\"\nnull,wederTom,\"man\"\n
\u5728 MatrixOne \u4e2d\u65b0\u5efa\u4e00\u4e2a\u8868 user
\uff1a
create database aaa;\nuse aaa;\nCREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\n
\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u5c06 test.txt
\u5bfc\u5165\u81f3\u8868 user
\uff1a
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE user SET id=nullif(id,\"null\");\n
\u5bfc\u5165\u540e\u7684\u8868\u5185\u5bb9\u5982\u4e0b\uff1a
select * from user;\n+------+-----------+------+\n| id | user_name | sex |\n+------+-----------+------+\n| 1 | weder | man |\n| 2 | tom | man |\n| null | wederTom | man |\n+------+-----------+------+\n
\u5bf9\u4e8e\u4e00\u4e2a\u683c\u5f0f\u826f\u597d\u7684\u5927\u6587\u4ef6\uff0c\u4f8b\u5982 JSONLines \u6587\u4ef6\uff0c\u6216\u8005\u4e00\u884c\u6570\u636e\u4e2d\u6ca1\u6709\u6362\u884c\u7b26\u7684 CSV \u6587\u4ef6\uff0c\u90fd\u53ef\u4ee5\u4f7f\u7528 PARALLEL
\u5bf9\u8be5\u6587\u4ef6\u8fdb\u884c\u5e76\u884c\u52a0\u8f7d\uff0c\u4ee5\u52a0\u5feb\u52a0\u8f7d\u901f\u5ea6\u3002
\u4f8b\u5982\uff0c\u5bf9\u4e8e 2 \u4e2a G \u7684\u5927\u6587\u4ef6\uff0c\u4f7f\u7528\u4e24\u4e2a\u7ebf\u7a0b\u53bb\u8fdb\u884c\u52a0\u8f7d\uff0c\u7b2c 2 \u4e2a\u7ebf\u7a0b\u5148\u62c6\u5206\u5b9a\u4f4d\u5230 1G \u7684\u4f4d\u7f6e\uff0c\u7136\u540e\u4e00\u76f4\u5f80\u540e\u8bfb\u53d6\u5e76\u8fdb\u884c\u52a0\u8f7d\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u505a\u5230\u4e24\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u53d6\u5927\u6587\u4ef6\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u8bfb\u53d6 1G \u7684\u6570\u636e\u3002
\u793a\u4f8b\uff1a
-- \u6253\u5f00\u5e76\u884c\u52a0\u8f7d\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'TRUE';\n\n-- \u5173\u95ed\u5e76\u884c\u52a0\u8f7d\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES PARALLEL 'FALSE';\n\n-- \u9ed8\u8ba4\u5173\u95ed\u5e76\u884c\u52a0\u8f7d\nload data infile 'file_name' into table tbl_name FIELDS TERMINATED BY '|' ENCLOSED BY '\\\"' LINES TERMINATED BY '\\n' IGNORE 1 LINES;\n
Note
[PARALLEL {'TRUE' | 'FALSE'}]
\u5185\u5b57\u6bb5\uff0c\u5f53\u524d\u4ec5\u652f\u6301 TRUE
\u6216 FALSE
\uff0c\u4e14\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002
Note: LOAD
\u8bed\u53e5\u4e2d\u5982\u679c\u4e0d\u52a0 PARALLEL
\u5b57\u6bb5\uff0c\u5bf9\u4e8e CSV \u6587\u4ef6\uff0c\u662f\u9ed8\u8ba4\u5173\u95ed\u5e76\u884c\u52a0\u8f7d\uff1b\u5bf9\u4e8e JSONLines \u6587\u4ef6\uff0c\u9ed8\u8ba4\u5f00\u542f\u5e76\u884c\u52a0\u8f7d\u3002\u5982\u679c CSV \u6587\u4ef6\u4e2d\u6709\u884c\u7ed3\u675f\u7b26\uff0c\u6bd4\u5982 '\\n'\uff0c\u90a3\u4e48\u6709\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6587\u4ef6\u52a0\u8f7d\u65f6\u6570\u636e\u51fa\u9519\u3002\u5982\u679c\u6587\u4ef6\u8fc7\u5927\uff0c\u5efa\u8bae\u4ece\u6362\u884c\u7b26\u4e3a\u8d77\u6b62\u70b9\u624b\u52a8\u62c6\u5206\u6587\u4ef6\u540e\u518d\u5f00\u542f\u5e76\u884c\u52a0\u8f7d\u3002
MO \u652f\u6301\u4f7f\u7528 STRICT
\u53c2\u6570\u6307\u5b9a\u6587\u4ef6\u5e76\u884c\u5207\u5272\u7684\u65b9\u5f0f\uff0c\u53ea\u6709\u5728 PARALLEL
\u4e3a TRUE
\u65f6\u6709\u6548\u3002STRICT
\u7684\u9ed8\u8ba4\u503c\u4e3a FALSE
\uff0c\u8868\u660e\u5728\u5207\u5206\u6587\u4ef6\u5e76\u884c\u5bfc\u5165\u65f6\u5229\u7528\u6362\u884c\u7b26\uff08\u9ed8\u8ba4\u4e3a\\n\uff09\u8fdb\u884c\u5207\u5272\uff0c\u5728\u6570\u636e\u6709\u6362\u884c\u7b26\u60c5\u51b5\u4e0b\uff0c\u5c31\u6709\u53ef\u80fd\u4f1a\u5207\u5206\u51fa\u9519\u3002\u800c\u5f53\u53c2\u6570\u4e3a TRUE
\u65f6\uff0c\u5219\u4f7f\u7528\u9884\u8bfb\u68c0\u6d4b\u7684\u65b9\u5f0f\u5207\u5272\uff0c\u5b83\u4e0d\u4ec5\u4f9d\u8d56\u4e8e\u6362\u884c\u7b26\u8fdb\u884c\u5206\u5272\uff0c\u8fd8\u4f1a\u8fdb\u884c\u9884\u8bfb\uff0c\u4ee5\u9a8c\u8bc1\u5176\u662f\u5426\u4e0e\u8868\u7684\u5217\u5b9a\u4e49\u76f8\u5339\u914d\uff0c\u53ea\u6709\u5f53\u6570\u636e\u7b26\u5408\u5217\u5b9a\u4e49\u65f6\uff0c\u624d\u4f1a\u5c06\u5176\u4f5c\u4e3a\u6709\u6548\u7684\u5206\u5272\u70b9\u8fdb\u884c\u5904\u7406\u3002
\u793a\u4f8b\uff1a
-- \u5f00\u542f\u9884\u8bfb\u6a21\u5f0f\nload data infile 'file_name' into table tbl_name PARALLEL 'TRUE' STRICT 'TRUE';\n\n-- \u5173\u95ed\u9884\u8bfb\u6a21\u5f0f\nload data infile 'file_name' into table tbl_name PARALLEL 'TRUE' STRICT 'FALSE';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_3","title":"\u652f\u6301\u7684\u6587\u4ef6\u683c\u5f0f","text":"\u5728 MatrixOne \u5f53\u524d\u7248\u672c\u4e2d\uff0cLOAD DATA
\u652f\u6301 CSV \u683c\u5f0f\u548c JSONLines \u683c\u5f0f\u6587\u4ef6\u3002
\u6709\u5173\u5bfc\u5165\u8fd9\u4e24\u79cd\u683c\u5f0f\u7684\u6587\u6863\uff0c\u53c2\u89c1\u5bfc\u5165. csv \u683c\u5f0f\u6570\u636e\u548c\u5bfc\u5165 JSONLines \u6570\u636e\u3002
Note
LOAD DATA
\u652f\u6301\u5bfc\u5165\u538b\u7f29\u6587\u4ef6\u7684\u7c7b\u578b\u6709 lz4
\uff0cgz
\uff0cbz2
\uff0czlib
\uff0cflate
\uff0c\u6682\u4e0d\u652f\u6301\u5bfc\u5165\u4ee5 .tar
\u6216\u8005 .tar.xx
\u7ed3\u5c3e\u7684\u538b\u7f29\u6587\u4ef6\u3002
MatrixOne \u52a0\u8f7d CSV \u683c\u5f0f\u7b26\u5408 RFC4180 \u6807\u51c6\uff0c\u89c4\u5b9a CSV \u683c\u5f0f\u5982\u4e0b\uff1a
\u6bcf\u6761\u8bb0\u5f55\u4f4d\u4e8e\u5355\u72ec\u7684\u4e00\u884c\uff0c\u7531\u6362\u884c\u7b26\uff08CRLF\uff09\u5206\u9694\uff1a
aaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | b bb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u6587\u4ef6\u4e2d\u6700\u540e\u4e00\u6761\u8bb0\u5f55\u53ef\u4ee5\u6709\u7ed3\u675f\u6362\u884c\u7b26\uff0c\u4e5f\u53ef\u4ee5\u65e0\u7ed3\u675f\u6362\u884c\u7b26\uff08CRLF\uff09\uff1a
aaa,bbb,ccc CRLF\nzzz,yyy,xxx\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | b bb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u53ef\u9009\u7684\u6807\u9898\u884c\u4f5c\u4e3a\u6587\u4ef6\u7684\u7b2c\u4e00\u884c\u51fa\u73b0\uff0c\u5176\u683c\u5f0f\u4e0e\u666e\u901a\u8bb0\u5f55\u884c\u76f8\u540c\u3002\u4f8b\u5982\uff1a
field_name,field_name,field_name CRLF\naaa,bbb,ccc CRLF\nzzz,yyy,xxx CRLF\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+------------+------------+------------+\n| field_name | field_name | field_name |\n+------------+------------+------------+\n| aaa | bbb | ccc |\n| zzz | yyy | xxx |\n+------------+------------+------------+\n
\u5728\u6807\u9898\u548c\u6bcf\u6761\u8bb0\u5f55\u4e2d\uff0c\u53ef\u80fd\u6709\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u6bb5\uff0c\u5b57\u6bb5\u4e4b\u95f4\u4ee5\u9017\u53f7\u5206\u9694\u3002\u5b57\u6bb5\u5185\u7684\u7a7a\u683c\u5c5e\u4e8e\u5b57\u6bb5\u7684\u4e00\u90e8\u5206\uff0c\u4e0d\u5e94\u5ffd\u7565\u3002\u6bcf\u6761\u8bb0\u5f55\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u5b57\u6bb5\u540e\u9762\u4e0d\u80fd\u8ddf\u9017\u53f7\u3002\u4f8b\u5982\uff1a
aaa,bbb,ccc\n
\u6216\uff1a
a aa, bbb,cc c\n
\u8fd9\u4e24\u4e2a\u4f8b\u5b50\u90fd\u662f\u5408\u6cd5\u7684\u3002
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | bbb | ccc |\n+---------+---------+---------+\n
\u6216\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| a aa | bbb | cc c |\n+---------+---------+---------+\n
\u6bcf\u4e2a\u5b57\u6bb5\u53ef\u4ee5\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u3002\u5982\u679c\u5b57\u6bb5\u6ca1\u6709\u7528\u53cc\u5f15\u53f7\u5f15\u8d77\u6765\uff0c\u90a3\u4e48\u53cc\u5f15\u53f7\u4e0d\u80fd\u51fa\u73b0\u5728\u5b57\u6bb5\u5185\u3002\u4f8b\u5982\uff1a
\"aaa\",\"bbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n
\u6216\uff1a
\"aaa\",\"bbb\",ccc CRLF\nzzz,yyy,xxx\n
\u8fd9\u4e24\u4e2a\u4f8b\u5b50\u90fd\u662f\u5408\u6cd5\u7684\u3002
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | bbb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u5305\u542b\u6362\u884c\u7b26\uff08CRLF\uff09\u3001\u53cc\u5f15\u53f7\u548c\u9017\u53f7\u7684\u5b57\u6bb5\u5e94\u8be5\u7528\u53cc\u5f15\u53f7\u5f15\u8d77\u6765\u3002\u4f8b\u5982\uff1a
\"aaa\",\"b CRLF\nbb\",\"ccc\" CRLF\nzzz,yyy,xxx\n
\u5bfc\u5165\u5230\u8868\u5185\u5982\u4e0b\u6240\u793a\uff1a
+---------+---------+---------+\n| col1 | col2 | col3 |\n+---------+---------+---------+\n| aaa | b bb | ccc |\n| zzz | yyy | xxx |\n+---------+---------+---------+\n
\u5982\u679c\u4f7f\u7528\u53cc\u5f15\u53f7\u5c06\u5b57\u6bb5\u62ec\u8d77\u6765\uff0c\u90a3\u4e48\u51fa\u73b0\u5728\u5b57\u6bb5\u5185\u7684\u591a\u4e2a\u53cc\u5f15\u53f7\u4e5f\u5fc5\u987b\u4f7f\u7528\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\uff0c\u5426\u5219\u5b57\u6bb5\u5185\u4e24\u4e2a\u53cc\u5f15\u53f7\u7684\u7b2c\u4e00\u4e2a\u5f15\u53f7\u5c06\u88ab\u89e3\u6790\u4e3a\u8f6c\u4e49\u5b57\u7b26\uff0c\u4ece\u800c\u53ea\u4fdd\u7559\u4e00\u4e2a\u53cc\u5f15\u53f7\u3002\u4f8b\u5982\uff1a
\"aaa\",\"b\"\"bb\",\"ccc\"\n
\u4e0a\u9762\u8fd9\u4e2a CSV \u4f1a\u628a \"b\"\"bb\"
\u89e3\u6790\u4e3a b\"bb
\uff0c\u5982\u679c\u6b63\u786e\u7684\u5b57\u6bb5\u4e3a b\"\"bb
\uff0c\u90a3\u4e48\u5e94\u8be5\u5199\u6210\uff1a
\"aaa\",\"b\"\"\"\"bb\",\"ccc\"\n
\u6216\uff1a
\"aaa\",b\"\"bb,\"ccc\"\n
\u4f60\u53ef\u4ee5\u5728 SSB \u6d4b\u8bd5\u4e2d\u4e86\u89e3 LOAD DATA
\u8bed\u53e5\u7684\u7528\u6cd5\uff0c\u53c2\u89c1\u5b8c\u6210 SSB \u6d4b\u8bd5\u3002
\u8bed\u6cd5\u793a\u4f8b\u5982\u4e0b\uff1a
> LOAD DATA INFILE '/ssb-dbgen-path/lineorder_flat.tbl ' INTO TABLE lineorder_flat;\n
\u4e0a\u9762\u8fd9\u884c\u8bed\u53e5\u8868\u793a\uff1a\u5c06 /ssb-dbgen-path/ \u8fd9\u4e2a\u76ee\u5f55\u8def\u5f84\u4e0b\u7684 lineorder_flat.tbl \u6570\u636e\u96c6\u52a0\u8f7d\u5230 MatrixOne \u7684\u6570\u636e\u8868 lineorder_flat \u4e2d\u3002
\u4f60\u4e5f\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u8bed\u6cd5\u793a\u4f8b\uff0c\u6765\u5feb\u901f\u4e86\u89e3 LOAD DATA
\uff1a
\u672c\u5730\u547d\u540d\u4e3a char_varchar.csv \u6587\u4ef6\u5185\u6570\u636e\u5982\u4e0b\uff1a
a|b|c|d\n\"a\"|\"b\"|\"c\"|\"d\"\n'a'|'b'|'c'|'d'\n\"'a'\"|\"'b'\"|\"'c'\"|\"'d'\"\n\"aa|aa\"|\"bb|bb\"|\"cc|cc\"|\"dd|dd\"\n\"aa|\"|\"bb|\"|\"cc|\"|\"dd|\"\n\"aa|||aa\"|\"bb|||bb\"|\"cc|||cc\"|\"dd|||dd\"\n\"aa'|'||aa\"|\"bb'|'||bb\"|\"cc'|'||cc\"|\"dd'|'||dd\"\naa\"aa|bb\"bb|cc\"cc|dd\"dd\n\"aa\"aa\"|\"bb\"bb\"|\"cc\"cc\"|\"dd\"dd\"\n\"aa\"\"aa\"|\"bb\"\"bb\"|\"cc\"\"cc\"|\"dd\"\"dd\"\n\"aa\"\"\"aa\"|\"bb\"\"\"bb\"|\"cc\"\"\"cc\"|\"dd\"\"\"dd\"\n\"aa\"\"\"\"aa\"|\"bb\"\"\"\"bb\"|\"cc\"\"\"\"cc\"|\"dd\"\"\"\"dd\"\n\"aa\"\"|aa\"|\"bb\"\"|bb\"|\"cc\"\"|cc\"|\"dd\"\"|dd\"\n\"aa\"\"\"\"|aa\"|\"bb\"\"\"\"|bb\"|\"cc\"\"\"\"|cc\"|\"dd\"\"\"\"|dd\"\n|||\n||||\n\"\"|\"\"|\"\"|\n\"\"\"\"|\"\"\"\"|\"\"\"\"|\"\"\"\"\n\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"|\"\"\"\"\"\"\n
\u5728 MatrixOne \u4e2d\u5efa\u8868\uff1a
mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(\n-> col1 char(225),\n-> col2 varchar(225),\n-> col3 text,\n-> col4 varchar(225)\n-> );\nQuery OK, 0 rows affected (0.02 sec)\n
\u5c06\u6570\u636e\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u8868 t1\uff1a
load data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|';\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+-----------+-----------+-----------+-----------+\n| col1 | col2 | col3 | col4 |\n+-----------+-----------+-----------+-----------+\n| a | b | c | d |\n| a | b | c | d |\n| 'a' | 'b' | 'c' | 'd' |\n| 'a' | 'b' | 'c' | 'd' |\n| aa|aa | bb|bb | cc|cc | dd|dd |\n| aa| | bb| | cc| | dd| |\n| aa|||aa | bb|||bb | cc|||cc | dd|||dd |\n| aa'|'||aa | bb'|'||bb | cc'|'||cc | dd'|'||dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"|aa | bb\"|bb | cc\"|cc | dd\"|dd |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n| | | | |\n| | | | |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+-----------+-----------+-----------+-----------+\n20 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_6","title":"\u589e\u52a0\u6761\u4ef6\u5bfc\u5165\u793a\u4f8b","text":"\u6cbf\u7528\u4e0a\u9762\u7684\u7b80\u5355\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539\u4e00\u4e0b LOAD DATA \u8bed\u53e5\uff0c\u5728\u672b\u5c3e\u589e\u52a0\u6761\u4ef6 LINES STARTING BY 'aa' ignore 10 lines;
\uff1a
delete from t1;\nload data infile '<your-local-file-path>/char_varchar.csv' into table t1 fields terminated by'|' LINES STARTING BY 'aa' ignore 10 lines;\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+---------+---------+---------+---------+\n| col1 | col2 | col3 | col4 |\n+---------+---------+---------+---------+\n| aa\"aa | bb\"bb | cc\"cc | dd\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"\"aa | bb\"\"bb | cc\"\"cc | dd\"\"dd |\n| aa\"|aa | bb\"|bb | cc\"|cc | dd\"|dd |\n| aa\"\"|aa | bb\"\"|bb | cc\"\"|cc | dd\"\"|dd |\n| | | | |\n| | | | |\n| | | | |\n| \" | \" | \" | \" |\n| \"\" | \"\" | \"\" | \"\" |\n+---------+---------+---------+---------+\n10 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u67e5\u8be2\u7ed3\u679c\u5ffd\u7565\u4e86\u524d 10 \u884c\uff0c\u5e76\u4e14\u5ffd\u7565\u4e86\u516c\u5171\u524d\u7f00 aa\u3002
\u6709\u5173\u5982\u4f55\u5bfc\u5165 CSV \u683c\u5f0f\u6587\u4ef6\u7684\u8be6\u7ec6\u6b65\u9aa4\uff0c\u53c2\u89c1\u5bfc\u5165. csv \u683c\u5f0f\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#2load-jsonlines","title":"\u793a\u4f8b 2\uff1aLOAD JSONLines","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_7","title":"\u7b80\u5355\u5bfc\u5165\u793a\u4f8b","text":"\u672c\u5730\u547d\u540d\u4e3a jsonline_array.jl \u6587\u4ef6\u5185\u6570\u636e\u5982\u4e0b\uff1a
[true,1,\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",121.11,[\"1\",2,null,false,true,{\"q\":1}],\"1qaz\",null,null]\n[\"true\",\"1\",\"var\",\"2020-09-07\",\"2020-09-07 00:00:00\",\"2020-09-07 00:00:00\",\"18\",\"121.11\",{\"c\":1,\"b\":[\"a\",\"b\",{\"q\":4}]},\"1aza\",null,null]\n
\u5728 MatrixOne \u4e2d\u5efa\u8868\uff1a
mysql> drop table if exists t1;\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> create table t1(col1 bool,col2 int,col3 varchar(100), col4 date,col5 datetime,col6 timestamp,col7 decimal,col8 float,col9 json,col10 text,col11 json,col12 bool);\nQuery OK, 0 rows affected (0.03 sec)\n
\u5c06\u6570\u636e\u6587\u4ef6\u5bfc\u5165\u5230 MatrixOne \u4e2d\u7684\u8868 t1\uff1a
load data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1;\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n| true | 1 | var | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 | 18 | 121.11 | [\"1\", 2, null, false, true, {\"q\": 1}] | 1qaz | NULL | NULL |\n| true | 1 | var | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 | 18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza | NULL | NULL |\n+------+------+------+------------+---------------------+---------------------+------+--------+---------------------------------------+-------+-------+-------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_8","title":"\u589e\u52a0\u6761\u4ef6\u5bfc\u5165\u793a\u4f8b","text":"\u6cbf\u7528\u4e0a\u9762\u7684\u7b80\u5355\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539\u4e00\u4e0b LOAD DATA \u8bed\u53e5\uff0c\u589e\u52a0 ignore 1 lines
\u5728\u8bed\u53e5\u7684\u672b\u5c3e\uff0c\u4f53\u9a8c\u4e00\u4e0b\u533a\u522b\uff1a
delete from t1;\nload data infile {'filepath'='<your-local-file-path>/jsonline_array.jl','format'='jsonline','jsondata'='array'} into table t1 ignore 1 lines;\n
\u67e5\u8be2\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from t1;\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8 | col9 | col10 | col11 | col12 |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n| true | 1 | var | 2020-09-07 | 2020-09-07 00:00:00 | 2020-09-07 00:00:00 | 18 | 121.11 | {\"b\": [\"a\", \"b\", {\"q\": 4}], \"c\": 1} | 1aza | NULL | NULL |\n+------+------+------+------------+---------------------+---------------------+------+--------+-------------------------------------+-------+-------+-------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u67e5\u8be2\u7ed3\u679c\u5ffd\u7565\u6389\u4e86\u7b2c\u4e00\u884c\u3002
\u6709\u5173\u5982\u4f55\u5bfc\u5165 JSONLines \u683c\u5f0f\u6587\u4ef6\u7684\u8be6\u7ec6\u6b65\u9aa4\uff0c\u53c2\u89c1\u5bfc\u5165 JSONLines \u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/load-data/#_9","title":"\u9650\u5236","text":"REPLACE
\u548c IGNORE
\u4fee\u9970\u7b26\u7528\u6765\u89e3\u51b3\u552f\u4e00\u7d22\u5f15\u7684\u51b2\u7a81\uff1aREPLACE
\u8868\u793a\u82e5\u8868\u4e2d\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u7528\u65b0\u7684\u6570\u636e\u66ff\u6362\u6389\u65e7\u7684\u6570\u636e\uff1bIGNORE
\u5219\u8868\u793a\u4fdd\u7559\u65e7\u7684\u6570\u636e\uff0c\u5ffd\u7565\u6389\u65b0\u6570\u636e\u3002\u8fd9\u4e24\u4e2a\u4fee\u9970\u7b26\u5728 MatrixOne \u4e2d\u5c1a\u4e0d\u652f\u6301\u3002SET
\uff0c\u4ec5\u652f\u6301 SET columns_name=nullif(col_name,expr2)
\u3002LOAD DATA LOCAL
\u8fdb\u884c\u672c\u5730\u52a0\u8f7d\uff0c\u5219\u9700\u8981\u4f7f\u7528\u547d\u4ee4\u884c\u8fde\u63a5 MatrixOne \u670d\u52a1\u4e3b\u673a\uff1amysql -h <mo-host -ip> -P 6001 -uroot -p111 --local-infile
\u3002UPDATE
\u7528\u4e8e\u4fee\u6539\u8868\u4e2d\u7684\u73b0\u6709\u8bb0\u5f55\u3002
UPDATE table_reference\n SET assignment_list\n [WHERE where_condition]\n [ORDER BY ...]\n [LIMIT row_count]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/update/#_4","title":"\u53c2\u6570\u91ca\u4e49","text":"UPDATE
\u5c06\u65b0\u503c\u66f4\u65b0\u5230\u6307\u5b9a\u8868\u4e2d\u73b0\u6709\u884c\u7684\u5217\u4e2d\u3002SET
\u4ece\u53e5\u6307\u51fa\u8981\u4fee\u6539\u54ea\u4e9b\u5217\u4ee5\u53ca\u5b83\u4eec\u5e94\u8be5\u88ab\u8d4b\u4e88\u7684\u503c\u3002\u6bcf\u4e2a\u503c\u53ef\u4ee5\u4f5c\u4e3a\u8868\u8fbe\u5f0f\u7ed9\u51fa\uff0c\u6216\u8005\u901a\u8fc7 DEFAULT
\u660e\u786e\u5c06\u5217\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u503c\u3002WHERE
\u4ece\u53e5\uff0c\u7528\u4e8e\u6307\u5b9a\u7528\u4e8e\u6807\u8bc6\u8981\u66f4\u65b0\u54ea\u4e9b\u884c\u7684\u6761\u4ef6\u3002\u82e5\u65e0 WHERE
\u4ece\u53e5\uff0c\u5219\u66f4\u65b0\u6240\u6709\u884c\u3002ORDER BY
\u4ece\u53e5\uff0c\u6307\u6309\u7167\u6307\u5b9a\u7684\u987a\u5e8f\u66f4\u65b0\u884c\u3002LIMIT
\u4ece\u53e5\u7528\u4e8e\u9650\u5236\u53ef\u66f4\u65b0\u7684\u884c\u6570\u3002CREATE TABLE t1 (a bigint(3), b bigint(5) primary key);\ninsert INTO t1 VALUES (1,1),(1,2);\nupdate t1 set a=2 where a=1 limit 1;\n\nmysql> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 1 |\n| 1 | 2 |\n+------+------+\n
drop table if exists t1;\ncreate table t1 (a int);\ninsert into t1 values(1), (2), (4);\ndrop table if exists t2;\ncreate table t2 (b int);\ninsert into t2 values(1), (2), (3);\nupdate t1, t2 set a = 1, b =2;\n\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n| 1 |\n| 1 |\n+------+\n\nupdate t1, t2 set a = null, b =null;\n\nmysql> select * from t2;\n+------+\n| b |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| NULL |\n| NULL |\n| NULL |\n+------+\n
\u652f\u6301\u591a\u8868 JOIN \u8bed\u53e5\u3002
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a int, b int, c int);\ninsert into t1 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\ncreate table t2 (a int, b int, c int);\ninsert into t2 values(1, 2, 3), (4, 5, 6), (7, 8, 9);\nupdate t1 join t2 on t1.a = t2.a set t1.b = 222, t1.c = 333, t2.b = 222, t2.c = 333;\n\nmysql> select * from t1;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 222 | 333 |\n| 4 | 222 | 333 |\n| 7 | 222 | 333 |\n+------+------+------+\n\nmysql> with t11 as (select * from (select * from t1) as t22) update t11 join t2 on t11.a = t2.a set t2.b = 666;\n\nmysql> select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 666 | 333 |\n| 4 | 666 | 333 |\n| 7 | 666 | 333 |\n+------+------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/","title":"LAST_INSERT_ID()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u82e5\u8868\u4e2d\u542b\u81ea\u589e\u5b57\u6bb5 AUTO_INCREMENT
\uff0c\u5219\u5411\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\u540e\uff0c\u53ef\u4ee5\u8c03\u7528 LAST_INSERT_ID()
\u6765\u83b7\u5f97\u6700\u8fd1\u63d2\u5165\u7684\u90a3\u884c\u8bb0\u5f55\u7684\u81ea\u589e\u5b57\u6bb5\u503c\u3002
\u5982\u679c\u6ca1\u6709\u63d2\u5165\u53c2\u6570\uff0cLAST_INSERT_ID() \u8fd4\u56de\u4e00\u4e2a BIGINT UNSIGNED\uff0864 \u4f4d\uff09\u503c\uff0c\u8be5\u503c\u8868\u793a\u4f5c\u4e3a\u6700\u8fd1\u6267\u884c\u7684 INSERT \u8bed\u53e5\u7684\u7ed3\u679c\u6210\u529f\u63d2\u5165\u5230 AUTO_INCREMENT
\u5217\u7684\u7b2c\u4e00\u4e2a\u81ea\u52a8\u751f\u6210\u7684\u503c\u3002\u8fd4\u56de\u503c\u53d6\u51b3\u4e8e\u4e4b\u524d AUTO_INCREMENT
\u5217\u7684\u503c\uff0c\u5982\u679c\u4f60\u4e4b\u524d\u6ca1\u6709\u63d2\u5165\u4e00\u4e2a\u5217\uff0c\u90a3\u4e48\u8fd4\u56de\u503c\u4ece 1 \u5f00\u59cb\uff0c\u5982\u679c\u4f60\u4e4b\u524d\u63d2\u5165\u4e86\u4e00\u4e2a\u5217\uff0c\u90a3\u4e48\u8fd4\u56de\u503c\u4e3a AUTO_INCREMENT
\u5217\u7684\u503c\u589e\u52a0 1\u3002
\u5982\u679c\u6ca1\u6709\u6210\u529f\u63d2\u5165\u53c2\u6570\uff0cLAST_INSERT_ID()
\u7684\u503c\u4fdd\u6301\u4e0d\u53d8\u3002
\u5728 MySQL \u4e2d\uff0c\u5982\u679c\u4f7f\u7528\u5355\u4e2a INSERT
\u8bed\u53e5\u63d2\u5165\u591a\u884c\uff0c\u5219 LAST_INSERT_ID()
\u4ec5\u8fd4\u56de\u4e3a\u7b2c\u4e00\u4e2a\u63d2\u5165\u884c\u751f\u6210\u7684\u503c\u3002\u4f8b\u5982\uff1a
mysql> CREATE TABLE t (id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, name VARCHAR(10) NOT NULL);\nmysql> INSERT INTO t VALUES (NULL, 'Bob');\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n| 1 | Bob |\n+----+------+\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 1 |\n+------------------+\nmysql> INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');\nmysql> SELECT * FROM t;\n+----+------+\n| id | name |\n+----+------+\n| 1 | Bob |\n| 2 | Mary |\n| 3 | Jane |\n| 4 | Lisa |\n+----+------+\nmysql> SELECT LAST_INSERT_ID();\n+------------------+\n| LAST_INSERT_ID() |\n+------------------+\n| 2 |\n+------------------+\n
\u4f46\u662f\u5728 MatrixOne \u4e2d\uff0c\u6211\u4eec\u6709\u4e0d\u540c\u7684\u884c\u4e3a\uff1b\u5982\u679c\u4f7f\u7528\u5355\u4e2a INSERT
\u8bed\u53e5\u63d2\u5165\u591a\u884c\uff0c\u5219 LAST_INSERT_ID()
\u8fd4\u56de\u4e3a\u6700\u540e\u63d2\u5165\u7684\u884c\u751f\u6210\u7684\u503c\u3002\u4e0e\u4e0a\u9762\u7684\u793a\u4f8b\u4e00\u6837\uff0c\u5f53\u60a8\u6267\u884c INSERT INTO t VALUES (NULL, 'Mary'), (NULL, 'Jane'), (NULL, 'Lisa');
\u65f6\uff0cLAST_INSERT_ID()
\u5c06\u8fd4\u56de 4\u3002
LAST_INSERT_ID(), LAST_INSERT_ID(expr)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-insert-id/#_3","title":"\u793a\u4f8b","text":"create table t1(a int auto_increment primary key);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(11);\ninsert into t1 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 12 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t1 values(null);\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 13 |\n+------------------+\n1 row in set (0.02 sec)\n\ncreate table t2(a int auto_increment primary key);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 1 |\n+------------------+\n1 row in set (0.02 sec)\n\ninsert into t2 values(100);\ninsert into t2 values();\nmysql> select last_insert_id();\n+------------------+\n| last_insert_id() |\n+------------------+\n| 101 |\n+------------------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/","title":"LAST_QUERY_ID()","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u5f53\u524d\u4f1a\u8bdd\u4e2d\u6307\u5b9a\u67e5\u8be2\u7684 ID\u3002\u5982\u679c\u672a\u6307\u5b9a\u67e5\u8be2\uff0c\u5219\u8fd4\u56de\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> LAST_QUERY_ID([ <num> ])\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/information-functions/last-query-id/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"num \u4e3a\u6b63\u6570\uff0c\u5373\u4ece\u4f1a\u8bdd\u4e2d\u6267\u884c\u7684\u7b2c\u4e00\u4e2a\u67e5\u8be2\u5f00\u59cb\u3002\u4f8b\u5982\uff1a
LAST_QUERY_ID(1)
\uff1a\u8fd4\u56de\u7b2c\u4e00\u4e2a\u67e5\u8be2\u3002
LAST_QUERY_ID(2)
\uff1a\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u3002
LAST_QUERY_ID(6)
\uff1a\u8fd4\u56de\u7b2c\u516d\u4e2a\u67e5\u8be2\u3002
num \u4e3a\u8d1f\u6570\uff0c\u5373\u4ece\u4f1a\u8bdd\u4e2d\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2\u5f00\u59cb\u3002\u4f8b\u5982\uff1a
LAST_QUERY_ID(-1)
\uff1a\u8fd4\u56de\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2\uff08\u76f8\u5f53\u4e8e LAST_QUERY_ID()\uff09\u3002
LAST_QUERY_ID(-2)
\uff1a\u8fd4\u56de\u6700\u8fd1\u6267\u884c\u7684\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u3002
mysql> SELECT LAST_QUERY_ID(-1);\n+--------------------------------------+\n| last_query_id(-1) |\n+--------------------------------------+\n| af974680-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> SELECT LAST_QUERY_ID();\n+--------------------------------------+\n| last_query_id() |\n+--------------------------------------+\n| 550e4d44-b1b5-11ed-8eb9-5ad2460dea4f |\n+--------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/","title":"INSERT IGNORE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"INSERT IGNORE
\u7528\u4e8e\u5728\u5411\u5177\u6709\u76f8\u540c\u552f\u4e00\u7d22\u5f15\u6216\u4e3b\u952e\u7684\u6570\u636e\u5e93\u8868\u4e2d\u63d2\u5165\u6570\u636e\u65f6\uff0c\u5982\u679c\u6570\u636e\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u5ffd\u7565\u8be5\u6570\u636e\uff0c\u800c\u4e0d\u662f\u8fd4\u56de\u62a5\u9519\uff0c\u5426\u5219\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002
\u4e0e MySQL \u4e0d\u540c\u7684\u662f\uff0c\u5728\u5bf9\u552f\u4e00\u7d22\u5f15\u6216\u4e3b\u952e\u63d2\u5165\u91cd\u590d\u503c\u65f6\uff0cMatrixOne \u4f1a\u5ffd\u7565\u62a5\u9519\uff0c\u800c MySQL \u4f1a\u6709\u544a\u8b66\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> INSERT IGNORE INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE user (\nid INT(11) NOT NULL PRIMARY KEY,\nname VARCHAR(50) NOT NULL,\nage INT(3) NOT NULL\n);\n-- \u63d2\u5165\u4e00\u6761\u65b0\u6570\u636e\uff0cid \u4e0d\u5b58\u5728\uff0c\u4e8e\u662f\u5f55\u5165\u65b0\u6570\u636e\nmysql> INSERT IGNORE INTO user VALUES (1, 'Tom', 18);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> SELECT * FROM USER;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 18 |\n+------+------+------+\n1 row in set (0.01 sec)\n\n-- \u518d\u63d2\u5165\u4e00\u6761\u65b0\u6570\u636e\uff0cid \u5b58\u5728\uff0c\u4e8e\u662f\u6570\u636e\u5ffd\u7565\nmysql> INSERT IGNORE INTO user VALUES (1, 'Jane', 16);\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> SELECT * FROM USER;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 18 |\n+------+------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-ignore/#_4","title":"\u9650\u5236","text":"INSERT IGNORE
\u4e0d\u652f\u6301\u5bf9 NOT NULL
\u5217\u5199\u5165 NULL
\u3002INSERT IGNORE
\u4e0d\u652f\u6301\u5bf9\u9519\u8bef\u7684\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u3002INSERT IGNORE
\u4e0d\u652f\u6301\u5904\u7406\u5206\u533a\u8868\u4e2d\u63d2\u5165\u6570\u636e\u5305\u542b\u4e0d\u5339\u914d\u5206\u533a\u503c\u7684\u64cd\u4f5c\u3002INSERT ... ON DUPLICATE KEY UPDATE
\u7528\u4e8e\u5728\u5411\u6570\u636e\u5e93\u8868\u4e2d\u63d2\u5165\u6570\u636e\u65f6\uff0c\u5982\u679c\u6570\u636e\u5df2\u7ecf\u5b58\u5728\uff0c\u5219\u66f4\u65b0\u8be5\u6570\u636e\uff0c\u5426\u5219\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002
INSERT INTO
\u8bed\u53e5\u662f\u7528\u4e8e\u5411\u6570\u636e\u5e93\u8868\u4e2d\u63d2\u5165\u6570\u636e\u7684\u6807\u51c6\u8bed\u53e5\uff1bON DUPLICATE KEY UPDATE
\u8bed\u53e5\u7528\u4e8e\u5728\u8868\u4e2d\u6709\u91cd\u590d\u8bb0\u5f55\u65f6\u8fdb\u884c\u66f4\u65b0\u64cd\u4f5c\u3002\u5982\u679c\u8868\u4e2d\u5b58\u5728\u5177\u6709\u76f8\u540c\u552f\u4e00\u7d22\u5f15\u6216\u4e3b\u952e\u7684\u8bb0\u5f55\uff0c\u5219\u4f7f\u7528 UPDATE
\u5b50\u53e5\u6765\u66f4\u65b0\u76f8\u5e94\u7684\u5217\u503c\uff0c\u5426\u5219\u4f7f\u7528 INSERT
\u5b50\u53e5\u63d2\u5165\u65b0\u8bb0\u5f55\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4f7f\u7528\u8be5\u8bed\u6cd5\u7684\u524d\u63d0\u662f\u9700\u8981\u5728\u8868\u4e2d\u5efa\u7acb\u4e3b\u952e\u7ea6\u675f\uff0c\u4ee5\u4fbf\u5224\u65ad\u662f\u5426\u6709\u91cd\u590d\u8bb0\u5f55\u3002\u540c\u65f6\uff0c\u66f4\u65b0\u64cd\u4f5c\u548c\u63d2\u5165\u64cd\u4f5c\u90fd\u9700\u8981\u8bbe\u7f6e\u5bf9\u5e94\u7684\u5217\u503c\uff0c\u5426\u5219\u4f1a\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-on-duplicate/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> INSERT INTO [db.]table [(c1, c2, c3)] VALUES (v11, v12, v13), (v21, v22, v23), ...\n [ON DUPLICATE KEY UPDATE column1 = value1, column2 = value2, column3 = value3, ...];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-on-duplicate/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE user (\nid INT(11) NOT NULL PRIMARY KEY,\nname VARCHAR(50) NOT NULL,\nage INT(3) NOT NULL\n);\n-- \u63d2\u5165\u4e00\u6761\u65b0\u6570\u636e\uff0cid \u4e0d\u5b58\u5728\uff0c\u4e8e\u662f\u5f55\u5165\u65b0\u6570\u636e\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE name='Tom', age=18;\n\nmysql> select * from user;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 18 |\n+------+------+------+\n1 row in set (0.01 sec)\n\n-- \u5c06\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684\u8bb0\u5f55\u7684 age \u5b57\u6bb5\u589e\u52a0 1\uff0c\u540c\u65f6 name \u5b57\u6bb5\u4fdd\u6301\u4e0d\u53d8\nINSERT INTO user (id, name, age) VALUES (1, 'Tom', 18)\nON DUPLICATE KEY UPDATE age=age+1;\n\nmysql> select * from user;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 19 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- \u63d2\u5165\u4e00\u6761\u65b0\u8bb0\u5f55\uff0c\u5c06 name \u548c age \u5b57\u6bb5\u66f4\u65b0\u4e3a\u6307\u5b9a\u503c\nINSERT INTO user (id, name, age) VALUES (2, 'Lucy', 20)\nON DUPLICATE KEY UPDATE name='Lucy', age=20;\n\nmysql> select * from user;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Tom | 19 |\n| 2 | Lucy | 20 |\n+------+------+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/insert-on-duplicate/#_4","title":"\u9650\u5236","text":"INSERT ... ON DUPLICATE KEY UPDATE
\u5f53\u524d\u8fd8\u4e0d\u652f\u6301\u552f\u4e00\u952e\uff08Unique key\uff09\uff0c\u7531\u4e8e\u552f\u4e00\u952e\u53ef\u4ee5\u4e3a NULL
\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u672a\u77e5\u9519\u8bef\u3002
REPLACE
\u4e0d\u4ec5\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u51fd\u6570\uff0c\u8fd8\u662f\u4e00\u4e2a\u66ff\u6362\u64cd\u4f5c\u7684\u6570\u636e\u64cd\u4f5c\u8bed\u53e5\u3002REPLACE
\u8bed\u53e5\u7684\u4f5c\u7528\u662f\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e\uff0c\u5982\u679c\u8868\u4e2d\u5df2\u7ecf\u5b58\u5728\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u5219\u4f1a\u5148\u5220\u9664\u8be5\u8bb0\u5f55\uff0c\u7136\u540e\u518d\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002\u5982\u679c\u8868\u4e2d\u4e0d\u5b58\u5728\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\uff0c\u5219\u76f4\u63a5\u63d2\u5165\u65b0\u7684\u6570\u636e\u3002
REPLACE
\u901a\u5e38\u5728\u5177\u6709\u552f\u4e00\u7ea6\u675f\u7684\u8868\u4e2d\u4f7f\u7528\u3002
REPLACE
\u8bed\u53e5\u8981\u6c42\u8868\u4e2d\u5fc5\u987b\u5b58\u5728\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\uff0c\u7528\u4e8e\u5224\u65ad\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u76f8\u540c\u7684\u8bb0\u5f55\u3002REPLACE
\u8bed\u53e5\u63d2\u5165\u65b0\u8bb0\u5f55\u65f6\uff0c\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u76f8\u540c\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\u7684\u8bb0\u5f55\uff0c\u65e7\u8bb0\u5f55\u5c06\u88ab\u5220\u9664\uff0c\u7136\u540e\u63d2\u5165\u65b0\u8bb0\u5f55\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4\u81ea\u589e\u5217\u7684\u503c\u53d1\u751f\u53d8\u5316\u3002REPLACE\n [INTO] tbl_name\n [(col_name [, col_name] ...)]\n { VALUES(value_list)\n |\n VALUES row_constructor_list\n }\n\nREPLACE\n [INTO] tbl_name\n SET assignment_list\n\nvalue:\n {expr | DEFAULT}\n\nvalue_list:\n value [, value] ...\n\nrow_constructor_list:\n ROW(value_list)\n\nassignment:\n col_name = value\n\nassignment_list:\n assignment [, assignment] ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/replace/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"REPLACE
\u8bed\u53e5\u7528\u4e8e\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636e\u6216\u66f4\u65b0\u5df2\u5b58\u5728\u7684\u6570\u636e\u3002\u5b83\u7684\u8bed\u6cd5\u6709\u4e24\u79cd\u5f62\u5f0f\uff1a\u4e00\u79cd\u662f\u57fa\u4e8e\u5217\u540d\u7684\u63d2\u5165\u5f62\u5f0f\uff0c\u53e6\u4e00\u79cd\u662f\u57fa\u4e8e SET \u5b50\u53e5\u7684\u66f4\u65b0\u5f62\u5f0f\u3002
\u4ee5\u4e0b\u662f\u5404\u4e2a\u53c2\u6570\u7684\u89e3\u91ca\uff1a
INTO
: \u53ef\u9009\u5173\u952e\u5b57\uff0c\u8868\u793a\u5411\u54ea\u5f20\u8868\u63d2\u5165\u6570\u636e\u6216\u66f4\u65b0\u6570\u636e\u3002
tbl_name
: \u8868\u793a\u8981\u63d2\u5165\u6216\u66f4\u65b0\u6570\u636e\u7684\u8868\u7684\u540d\u79f0\u3002
col_name
: \u53ef\u9009\u53c2\u6570\uff0c\u8868\u793a\u8981\u63d2\u5165\u6216\u66f4\u65b0\u7684\u5217\u540d\u3002\u5728\u63d2\u5165\u5f62\u5f0f\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u5217\u540d\u6307\u5b9a\u8981\u63d2\u5165\u7684\u5217\uff1b\u5728\u66f4\u65b0\u5f62\u5f0f\u4e2d\uff0c\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u3002
value
: \u8868\u793a\u8981\u63d2\u5165\u6216\u66f4\u65b0\u7684\u503c\u3002\u53ef\u4ee5\u662f\u5177\u4f53\u7684\u8868\u8fbe\u5f0f\uff08expr\uff09\u6216\u9ed8\u8ba4\u503c\uff08DEFAULT\uff09\u3002
value_list
: \u8868\u793a\u4e00\u7ec4\u8981\u63d2\u5165\u7684\u503c\u3002\u591a\u4e2a\u503c\u4e4b\u95f4\u7528\u9017\u53f7\u5206\u9694\u3002
\uff08\u6682\u4e0d\u652f\u6301\uff09row_constructor_list
: \u8868\u793a\u7528\u4e8e\u63d2\u5165\u7684\u4e00\u7ec4\u503c\u6784\u6210\u7684\u884c\u3002\u6bcf\u4e00\u884c\u7684\u503c\u4f7f\u7528\u62ec\u53f7\u62ec\u8d77\u6765\uff0c\u5e76\u7528\u9017\u53f7\u5206\u9694\u3002
assignment
: \u8868\u793a\u4e00\u4e2a\u5217\u540d\u548c\u5176\u5bf9\u5e94\u7684\u503c\u7684\u5173\u8054\uff0c\u7528\u4e8e\u66f4\u65b0\u5f62\u5f0f\u3002
assignment_list
: \u8868\u793a\u591a\u4e2a\u5217\u540d\u548c\u5bf9\u5e94\u503c\u7684\u5173\u8054\uff0c\u7528\u4e8e\u66f4\u65b0\u5f62\u5f0f\u3002\u591a\u4e2a\u5217\u540d\u548c\u503c\u4e4b\u95f4\u7528\u9017\u53f7\u5206\u9694\u3002
Note
VALUES
\u5173\u952e\u5b57\u540e\u8ddf value_list
\u6216 row_constructor_list
\u6765\u63d2\u5165\u6570\u636e\u3002VALUES
\u540e\u8ddf value_list
\u8868\u793a\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0cVALUES
\u540e\u8ddf row_constructor_list
\u8868\u793a\u63d2\u5165\u591a\u884c\u6570\u636e\u3002SET
\u5173\u952e\u5b57\u540e\u8ddf assignment_list
\u6765\u6307\u5b9a\u8981\u66f4\u65b0\u7684\u5217\u548c\u5bf9\u5e94\u7684\u503c\u3002create table names(id int PRIMARY KEY,name VARCHAR(255),age int);\n\n-- \u63d2\u5165\u4e00\u884c\u6570\u636e\uff0cid=1\uff0cname=\"Abby\"\uff0cage=24\nreplace into names(id, name, age) values(1,\"Abby\", 24);\nmysql> select name, age from names where id = 1;\n+------+------+\n| name | age |\n+------+------+\n| Abby | 24 |\n+------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+------+------+\n| id | name | age |\n+------+------+------+\n| 1 | Abby | 24 |\n+------+------+------+\n1 row in set (0.00 sec)\n\n-- \u4f7f\u7528 replace \u8bed\u53e5\u66f4\u65b0 id=1 \u7684\u8bb0\u5f55\u7684 name \u548c age \u5217\u7684\u503c\u4e3a\"Bob\"\u548c 25\nreplace into names(id, name, age) values(1,\"Bobby\", 25);\n\nmysql> select name, age from names where id = 1;\n+-------+------+\n| name | age |\n+-------+------+\n| Bobby | 25 |\n+-------+------+\n1 row in set (0.00 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Bobby | 25 |\n+------+-------+------+\n1 row in set (0.01 sec)\n\n-- \u4f7f\u7528 replace \u8bed\u53e5\u63d2\u5165\u4e00\u884c\u6570\u636e\uff0cid=2\uff0cname=\"Ciro\"\uff0cage \u4e3a NULL\nreplace into names set id = 2, name = \"Ciro\";\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age |\n+------+------+\n| Ciro | NULL |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Bobby | 25 |\n| 2 | Ciro | NULL |\n+------+-------+------+\n2 rows in set (0.00 sec)\n\n-- \u4f7f\u7528 replace \u8bed\u53e5\u66f4\u65b0 id=2 \u7684\u8bb0\u5f55\u7684 name \u5217\u7684\u503c\u4e3a \"Ciro\"\uff0cage \u5217\u7684\u503c\u4e3a 17\nreplace into names set id = 2, name = \"Ciro\", age = 17;\n\nmysql> select name, age from names where id = 2;\n+------+------+\n| name | age |\n+------+------+\n| Ciro | 17 |\n+------+------+\n1 row in set (0.01 sec)\n\nmysql> select * from names;\n+------+-------+------+\n| id | name | age |\n+------+-------+------+\n| 1 | Bobby | 25 |\n| 2 | Ciro | 17 |\n+------+-------+------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Manipulation-Language/upsert/replace/#_5","title":"\u9650\u5236","text":"MatrixOne \u5f53\u524d\u4e0d\u652f\u6301\u4f7f\u7528 VALUES row_constructor_list
\u53c2\u6570\u63d2\u5165\u7684\u4e00\u7ec4\u503c\u6784\u6210\u7684\u884c\u3002
UPSERT
\u662f\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u7ba1\u7406\u6570\u636e\u5e93\u7684\u57fa\u672c\u529f\u80fd\u4e4b\u4e00\uff0c\u662f UPDATE
\u548c INSERT
\u7684\u7ec4\u5408\uff0c\u5b83\u5141\u8bb8\u6570\u636e\u5e93\u64cd\u4f5c\u8bed\u8a00\u5728\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u65b0\u7684\u6570\u636e\u6216\u66f4\u65b0\u5df2\u6709\u7684\u6570\u636e\u3002\u5f53 UPSERT
\u64cd\u4f5c\u7684\u662f\u4e00\u6761\u65b0\u6570\u636e\u65f6\uff0c\u4f1a\u89e6\u53d1 INSERT
\u64cd\u4f5c\uff0c\u82e5\u8bb0\u5f55\u5df2\u7ecf\u5b58\u5728\u4e8e\u8868\u4e2d\uff0c\u5219 UPSERT
\u7c7b\u4f3c\u4e8e UPDATE
\u8bed\u53e5\u3002
\u4f8b\u5982\uff0c\u6211\u4eec\u6709\u4e00\u4e2a student
\u8868\uff0cid
\u5217\u4f5c\u4e3a\u4e3b\u952e\uff1a
> desc student;\n+-------+-------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+-------------+------+------+---------+-------+---------+\n| id | INT(32) | NO | PRI | NULL | | |\n| name | VARCHAR(50) | YES | | NULL | | |\n+-------+-------------+------+------+---------+-------+---------+\n
\u5728\u66f4\u6539\u6b64\u8868\u4e2d\u7684\u5b66\u751f\u4fe1\u606f\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 upsert
\u3002\u4ece\u903b\u8f91\u4e0a\u8bb2\u662f\u8fd9\u6837\u7684\uff1a
\u5982\u679c\u8868\u4e2d\u5b58\u5728\u5b66\u751f id\uff0c\u8bf7\u4f7f\u7528\u65b0\u4fe1\u606f\u66f4\u65b0\u8be5\u884c\u3002
\u5982\u679c\u8868\u4e2d\u4e0d\u5b58\u5728\u5b66\u751f\uff0c\u8bf7\u5c06\u5176\u6dfb\u52a0\u4e3a\u65b0\u884c\u3002
\u7136\u800c\uff0cUPSERT
\u547d\u4ee4\u5728 Matrixone \u4e2d\u4e0d\u5b58\u5728\uff0c\u4f46\u4ecd\u7136\u53ef\u4ee5\u5b9e\u73b0 UPSERT
\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cMatrixone \u63d0\u4f9b\u4e86\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0 Matrixone UPSERT \u64cd\u4f5c\uff1a
INSERT IGNORE
INSERT ON DUPLICATE KEY UPDATE
REPLACE
\u5f53\u6211\u4eec\u5411\u8868\u4e2d\u63d2\u5165\u975e\u6cd5\u884c\u65f6\uff0cINSERT IGNORE
\u8bed\u53e5\u4f1a\u5ffd\u7565\u6267\u884c\u65f6\u7684 error\u3002\u6bd4\u5982\uff0c\u4e3b\u952e\u5217\u4e0d\u5141\u8bb8\u6211\u4eec\u5b58\u50a8\u91cd\u590d\u503c\u3002\u5f53\u6211\u4eec\u4f7f\u7528 INSERT \u5411\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u6570\u636e\uff0c\u800c\u8fd9\u6761\u6570\u636e\u7684\u4e3b\u952e\u5df2\u7ecf\u5728\u8868\u4e2d\u5b58\u5728\u4e86\uff0c\u6b64\u65f6 Matrixone \u670d\u52a1\u5668\u751f\u6210 error\uff0c\u8bed\u53e5\u6267\u884c\u5931\u8d25\u3002\u7136\u800c\uff0c\u5f53\u6211\u4eec\u4f7f\u7528 INSERT IGNORE
\u6765\u6267\u884c\u6b64\u8bed\u53e5\u65f6\uff0cMatrixone \u670d\u52a1\u5668\u5c06\u4e0d\u4f1a\u751f\u6210 error\u3002
\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u66f4\u65b0\u5df2\u7ecf\u5b58\u5728\u7684\u6570\u636e\u3002\u6b64\u65f6\u53ef\u4ee5\u4f7f\u7528 REPLACE
\uff0c\u5f53\u6211\u4eec\u4f7f\u7528 REPLACE \u547d\u4ee4\u65f6\uff0c\u53ef\u80fd\u4f1a\u6709\u4e0b\u5217\u4e24\u79cd\u60c5\u51b5\u53d1\u751f\uff1a
\u5982\u679c\u6570\u636e\u5e93\u4e2d\u6ca1\u6709\u5bf9\u5e94\u7684\u8bb0\u5f55\uff0c\u5219\u6267\u884c\u6807\u51c6\u7684 INSERT
\u8bed\u53e5\u3002
\u5982\u679c\u6570\u636e\u5e93\u4e2d\u6709\u5bf9\u5e94\u7684\u8bb0\u5f55\uff0c\u5219 REPLACE
\u8bed\u53e5\u4f1a\u5148\u5220\u9664\u6570\u636e\u5e93\u4e2d\u7684\u5bf9\u5e94\u8bb0\u5f55\uff0c\u518d\u6267\u884c\u6807\u51c6\u7684 INSERT \u8bed\u53e5\uff08\u5f53\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\u91cd\u590d\u65f6\uff0c\u4f1a\u6267\u884c\u6b64\u66f4\u65b0\u64cd\u4f5c\uff09
\u5728 REPLACE
\u8bed\u53e5\u4e2d\uff0c\u66f4\u65b0\u6570\u636e\u5206\u4e3a\u4e24\u6b65\uff1a\u5148\u5220\u9664\u539f\u6709\u8bb0\u5f55\uff0c\u518d\u63d2\u5165\u8981\u66f4\u65b0\u7684\u8bb0\u5f55\u3002
\u76ee\u524d\u4e3a\u6b62\uff0c\u6211\u4eec\u5df2\u7ecf\u770b\u8fc7\u4e24\u79cd UPSERT
\u547d\u4ee4\u4e86\uff0c\u4f46\u5b83\u4eec\u90fd\u6709\u4e00\u4e9b\u9650\u5236\u3002INSERT ON DUPLICATE KEY IGNORE
\u53ea\u662f\u7b80\u5355\u5ffd\u7565\u4e86 duplicate error
\u3002REPLACE
\u4f1a\u68c0\u6d4b INSERT error
\uff0c\u4f46\u662f\u5b83\u5728\u6dfb\u52a0\u65b0\u6570\u636e\u524d\u4f1a\u5220\u9664\u539f\u6709\u6570\u636e\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u4ecd\u7136\u9700\u8981\u4e00\u79cd\u66f4\u597d\u7684\u89e3\u51b3\u65b9\u6848\u3002
INSERT ON DUPLICATE KEY UPDATE
\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u5b83\u4e0d\u4f1a\u5220\u9664\u91cd\u590d\u7684\u884c\uff0c\u5f53\u6211\u4eec\u5728 SQL \u8bed\u53e5\u4e2d\u4f7f\u7528 ON DUPLICATE KEY UPDATE\u5b50
\u53e5\u5e76\u4e14\u6709\u4e00\u884c\u6570\u636e\u5728\u4e3b\u952e\u6216\u552f\u4e00\u7d22\u5f15\u4e0a\u4ea7\u751f duplicate error
\u65f6\uff0c\u4f1a\u5728\u5df2\u6709\u7684\u6570\u636e\u4e0a\u505a\u66f4\u65b0\u3002
INTERSECT
\u8fd0\u7b97\u7b26\u662f\u4e00\u4e2a\u96c6\u5408\u8fd0\u7b97\u7b26\u4ec5\u8fd4\u56de\u4e24\u4e2a\u67e5\u8be2\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u4e0d\u540c\u884c\u3002
SELECT column_list FROM table_1\nINTERSECT\nSELECT column_list FROM table_2;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/intersect/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 intersect select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 2 | 3 |\n| 3 | 4 | 5 |\n+------+------+------+\n2 rows in set (0.01 sec)\n\nmysql> select a, b from t1 intersect select b, c from t2;\n+------+------+\n| a | b |\n+------+------+\n| 4 | 5 |\n+------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/","title":"MINUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"MINUS
\u6bd4\u8f83\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\uff0c\u5e76\u8fd4\u56de\u7b2c\u4e00\u4e2a\u67e5\u8be2\u4e2d\u4e0d\u662f\u7531\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u8f93\u51fa\u7684\u4e0d\u540c\u884c\u3002
SELECT column_list_1 FROM table_1\nMINUS\nSELECT columns_list_2 FROM table_2;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/minus/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 MINUS SELECT id FROM t2;\n+------+\n| id |\n+------+\n| 1 |\n+------+\n
drop table if exists t1;\ndrop table if exists t2;\ncreate table t1 (a smallint, b bigint, c int);\ninsert into t1 values (1,2,3);\ninsert into t1 values (1,2,3);\ninsert into t1 values (3,4,5);\ninsert into t1 values (4,5,6);\ninsert into t1 values (4,5,6);\ninsert into t1 values (1,1,2);\ncreate table t2 (a smallint, b bigint, c int);\ninsert into t2 values (1,2,3);\ninsert into t2 values (3,4,5);\ninsert into t2 values (1,2,1);\n\nmysql> select * from t1 minus select * from t2;\n+------+------+------+\n| a | b | c |\n+------+------+------+\n| 1 | 1 | 2 |\n| 4 | 5 | 6 |\n+------+------+------+\n\nmysql> select a, b from t1 minus select b, c from t2;\n+------+------+\n| a | b |\n+------+------+\n| 3 | 4 |\n| 1 | 1 |\n| 1 | 2 |\n+------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/","title":"SELECT","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"SELECT
\u8bed\u53e5\u7528\u4e8e\u4ece\u8868\u4e2d\u68c0\u7d22\u6570\u636e\u3002
SELECT\n[ALL | DISTINCT ]\nselect_expr [, select_expr] [[AS] alias] ...\n[INTO variable [, ...]]\n[FROM table_references\n[WHERE where_condition]\n[GROUP BY {col_name | expr | position}\n[ASC | DESC]]\n[HAVING where_condition]\n[ORDER BY {col_name | expr | position}\n[ASC | DESC]] [ NULLS { FIRST | LAST } ]\n[LIMIT {[offset,] row_count | row_count OFFSET offset}]\n[FOR {UPDATE}]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"SELECT
\u8bed\u53e5\u4e2d\u6700\u5e38\u7528\u7684\u5b50\u53e5\u6216\u6761\u4ef6\u91ca\u4e49\u5982\u4e0b\uff1a
all
& distinct
","text":"all
\u548c distinct
\u4fee\u9970\u7b26\u6307\u5b9a\u662f\u5426\u5e94\u8fd4\u56de\u91cd\u590d\u7684\u884c\u3002all
\uff08\u9ed8\u8ba4\u503c\uff09\u6307\u5b9a\u5e94\u8fd4\u56de\u6240\u6709\u5339\u914d\u7684\u884c\uff0c\u5305\u62ec\u91cd\u590d\u884c\u3002distinct
\u6307\u5b9a\u4ece\u7ed3\u679c\u96c6\u4e2d\u5220\u9664\u91cd\u590d\u7684\u884c\u3002
select_expr
","text":"\u6bcf\u4e2a select_expr
\u8868\u8fbe\u5f0f\u8868\u793a\u4f60\u9700\u8981\u67e5\u8be2\u7684\u5217\uff0c\u5e76\u4e14\u5fc5\u987b\u81f3\u5c11\u6709\u4e00\u4e2a select_expr
\u3002
select_expr
\u5217\u8868\u5305\u542b\u6307\u793a\u8981\u67e5\u8be2\u6240\u9009\u5217\u8868\u7684\u54ea\u4e9b\u5217\u3002select_expr
\u6307\u5b9a\u5217\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 * \u6307\u5b9a\u5168\u90e8\u67e5\u8be2\u5217\uff1a
SELECT * FROM t1\n
tbl_name.*
\u53ef\u7528\u4f5c\u4ee5\u4ece\u8868\u4e2d\u9009\u62e9\u6240\u6709\u5217\uff1aSELECT t1.*, t2.* FROM t1\n
select_expr
\u53ef\u4ee5\u4f7f\u7528 AS
\u4e3a\u8868\u6307\u5b9a\u522b\u540d\u3002table_references
","text":"\u4f60\u53ef\u4ee5\u5c06\u9ed8\u8ba4\u6570\u636e\u5e93\u4e2d\u7684\u8868\u79f0\u4e3a tbl_name
\u6216 db_name.tbl_name
\uff0c\u4e3b\u8981\u7528\u4e8e\u660e\u786e\u6307\u5b9a\u6570\u636e\u5e93\u3002\u60a8\u53ef\u4ee5\u5c06\u5217\u79f0\u4e3a col_name
\u3001tbl_name.col_name
\u6216 db_name.tbl_name.col_name
\u3002\u4f60\u4e0d\u9700\u8981\u4e3a\u5217\u6307\u5b9a tbl_name
\u6216 db_name.tbl_name
\uff0c\u5982\u679c\u9700\u8981\u660e\u786e\u6307\u5b9a\uff0c\u53ef\u4ee5\u6dfb\u52a0 tbl_name
\u6216 db_name.tbl_name
\u3002
\u53ef\u4ee5\u4f7f\u7528 tbl_name AS alias_name
\u6216 tbl_name alias_name
\u4e3a\u8868\u8d77\u522b\u540d\u3002
WHERE
","text":"WHERE
\u5b50\u53e5\uff08\u5982\u679c\u7ed9\u5b9a\uff09\u6307\u793a\u8981\u9009\u62e9\u884c\u5fc5\u987b\u6ee1\u8db3\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u6761\u4ef6\u3002where_condition
\u8868\u8fbe\u5f0f\uff0c\u5bf9\u4e8e\u8981\u9009\u62e9\u7684\u6bcf\u4e00\u884c\u8ba1\u7b97\u7ed3\u679c\u4e3a\u771f\u3002\u5982\u679c\u6ca1\u6709 WHERE
\u5b50\u53e5\uff0c\u8be5\u8bed\u53e5\u5c06\u9009\u62e9\u6240\u6709\u884c\u3002
GROUP BY
","text":"\u53ef\u4ee5\u4f7f\u7528\u5217\u540d\u3001\u5217\u522b\u540d\u6216\u5217\u4f4d\u7f6e\u5728 ORDER BY
\u548c GROUP BY
\u5b50\u53e5\u4e2d\u5f15\u7528\u9009\u62e9\u7684\u5217\u3002
Note
GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\uff0c\u4e0d\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u522b\u540d\u6765\u5b9a\u4e49\u53e6\u4e00\u4e2a\u522b\u540d\u3002GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\uff0c\u9996\u5148\u4f1a\u5c1d\u8bd5\u4f7f\u7528\u5217\u540d\u8fdb\u884c\u5206\u7ec4\u6216\u6761\u4ef6\u8fc7\u6ee4\u3002\u5982\u679c\u5728\u8fd9\u4e24\u4e2a\u5b50\u53e5\u4e2d\u627e\u4e0d\u5230\u76f8\u5e94\u7684\u5217\u540d\uff0c\u90a3\u4e48\u5b83\u4eec\u4f1a\u68c0\u67e5\u662f\u5426\u6709\u522b\u540d\u4e0e\u4e4b\u5339\u914d\uff0c\u7136\u540e\u518d\u4f7f\u7528\u8fd9\u4e2a\u522b\u540d\u3002GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\u4f7f\u7528\u522b\u540d\u65f6\u5e94\u5f53\u907f\u514d\u51fa\u73b0\u5217\u5f15\u7528\u6a21\u7cca\u4e0d\u6e05\u7684\u60c5\u51b5\uff0c\u56e0\u4e3a\u5f53\u5728 GROUP BY
\u6216 HAVING
\u5b50\u53e5\u4e2d\u4f7f\u7528\u522b\u540d\u65f6\uff0c\u5b83\u4f1a\u67e5\u627e\u4e0e\u522b\u540d\u5339\u914d\u7684\u5217\uff0c\u5982\u679c\u627e\u5230\u591a\u4e2a\u5339\u914d\u7684\u5217\uff0c\u5219\u4f1a\u4ea7\u751f\u62a5\u9519\u3002ORDER BY
\u5b50\u53e5\u9996\u5148\u4f1a\u5c1d\u8bd5\u4f7f\u7528\u522b\u540d\u6392\u5e8f\uff0c\u5982\u679c\u627e\u4e0d\u5230\u522b\u540d\uff0c\u5219\u518d\u5c1d\u8bd5\u4f7f\u7528\u5217\u540d\u8fdb\u884c\u6392\u5e8f\u3002HAVING
","text":"HAVING
\u5b50\u53e5\u4e0e WHERE
\u5b50\u53e5\u4e00\u6837\uff0c\u6307\u5b9a\u9009\u62e9\u6761\u4ef6\u3002
ORDER BY
","text":"ORDER BY
\u9ed8\u8ba4\u4e3a\u5347\u5e8f\uff1b\u53ef\u4ee5\u4f7f\u7528 ASC \u5173\u952e\u5b57\u660e\u786e\u6307\u5b9a\u3002\u8981\u4ee5\u76f8\u53cd\u7684\u987a\u5e8f\u6392\u5e8f\uff0c\u8bf7\u5c06\uff08\u964d\u5e8f\uff09\u5173\u952e\u5b57\u6dfb\u52a0\u5230\u4f60\u4f5c\u4e3a\u6392\u5e8f\u4f9d\u636e DESC \u7684\u5b50\u53e5\u4e2d\u7684\u5217\u7684\u540d\u79f0\u3002
LIMIT
","text":"LIMIT
\u5b50\u53e5\u53ef\u7528\u4e8e\u9650\u5236 SELECT
\u8bed\u53e5\u8fd4\u56de\u7684\u884c\u6570\u3002
FOR UPDATE
","text":"SELECT...FOR UPDATE
\u4e3b\u8981\u7528\u4e8e\u5728\u4e8b\u52a1\u5904\u7406\u4e2d\u9501\u5b9a\u4e00\u7ec4\u6570\u636e\u884c\uff0c\u4ee5\u9632\u6b62\u88ab\u5176\u4ed6\u5e76\u53d1\u7684\u4e8b\u52a1\u4fee\u6539\u3002\u8fd9\u4e2a\u8bed\u53e5\u6700\u5e38\u7528\u4e8e\u5904\u7406\u8bfb\u2014\u6539\u2014\u5199\u573a\u666f\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u5f53\u4f60\u9700\u8981\u8bfb\u53d6\u4e00\u7ec4\u6570\u636e\uff0c\u5bf9\u5176\u8fdb\u884c\u66f4\u6539\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u5199\u56de\u6570\u636e\u5e93\uff0c\u800c\u5728\u6b64\u8fc7\u7a0b\u4e2d\u4f60\u4e0d\u5e0c\u671b\u5176\u4ed6\u4e8b\u52a1\u4fee\u6539\u8fd9\u7ec4\u6570\u636e\u3002
\u5728\u4e00\u4e2a\u4e8b\u52a1\u4e2d\u4f7f\u7528 SELECT FOR UPDATE
\u53ef\u4ee5\u9501\u5b9a\u6240\u9009\u7684\u884c\uff0c\u76f4\u5230\u4e8b\u52a1\u7ed3\u675f\uff08\u901a\u8fc7\u63d0\u4ea4\u6216\u56de\u6eda\uff09\u624d\u91ca\u653e\u9501\u3002\u8fd9\u6837\uff0c\u5176\u4ed6\u5c1d\u8bd5\u4fee\u6539\u8fd9\u4e9b\u884c\u7684\u4e8b\u52a1\u5c06\u88ab\u963b\u585e\uff0c\u76f4\u5230\u7b2c\u4e00\u4e2a\u4e8b\u52a1\u5b8c\u6210\u3002
\u53c2\u89c1\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a
START TRANSACTION;\n\nSELECT * FROM Orders\nWHERE OrderID = 1\nFOR UPDATE;\n
\u5728\u4e0a\u9762\u7684\u4e8b\u52a1\u4e2d\uff0c\u4f7f\u7528 SELECT FOR UPDATE
\u8bed\u53e5\u9009\u53d6\u4e86 Orders
\u8868\u4e2d OrderID
\u4e3a 1 \u7684\u884c\uff0c\u5e76\u4e14\u9501\u5b9a\u4e86\u8fd9\u4e00\u884c\u3002\u5728\u4e8b\u52a1\u7ed3\u675f\u524d\uff0c\u5176\u4ed6\u4e8b\u52a1\u4e0d\u80fd\u4fee\u6539\u8fd9\u4e00\u884c\u3002\u5f53\u4f60\u5b8c\u6210\u5bf9\u8fd9\u4e00\u884c\u7684\u4fee\u6539\u540e\uff0c\u53ef\u4ee5\u63d0\u4ea4\u4e8b\u52a1\u6765\u91ca\u653e\u9501\uff1a
UPDATE Orders\nSET Quantity = Quantity - 1\nWHERE OrderID = 1;\n\nCOMMIT;\n
\u4e0a\u9762\u7684 UPDATE
\u8bed\u53e5\u66f4\u6539\u4e86\u9009\u53d6\u884c\u7684 Quantity
\u503c\uff0c\u7136\u540e COMMIT
\u8bed\u53e5\u63d0\u4ea4\u4e86\u4e8b\u52a1\u5e76\u91ca\u653e\u4e86\u9501\u3002\u6b64\u65f6\uff0c\u5176\u4ed6\u88ab\u963b\u585e\u7684\u4e8b\u52a1\u5c31\u53ef\u4ee5\u7ee7\u7eed\u6267\u884c\u4e86\u3002\u5982\u679c\u4f60\u51b3\u5b9a\u4e0d\u505a\u4efb\u4f55\u66f4\u6539\uff0c\u53ef\u4ee5\u4f7f\u7528 ROLLBACK
\u8bed\u53e5\u6765\u7ed3\u675f\u4e8b\u52a1\u5e76\u91ca\u653e\u9501\u3002
create table t1 (spID int,userID int,score smallint);\ninsert into t1 values (1,1,1);\ninsert into t1 values (2,2,2);\ninsert into t1 values (2,1,4);\ninsert into t1 values (3,3,3);\ninsert into t1 values (1,1,5);\ninsert into t1 values (4,6,10);\ninsert into t1 values (5,11,99);\ninsert into t1 values (null,0,99);\n\nmysql> SELECT spID FROM t1;\n+------+\n| spid |\n+------+\n| 1 |\n| 2 |\n| 2 |\n| 3 |\n| 1 |\n| 4 |\n| 5 |\n| NULL |\n+------+\n\nmysql> SELECT DISTINCT spID FROM t1;\n+------+\n| spid |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n| 5 |\n| NULL |\n+------+\n\nmysql> SELECT * FROM t1 WHERE spID>2 AND userID <2 || userID >=2 OR userID < 2 LIMIT 3;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| NULL | 0 | 99 |\n| 1 | 1 | 1 |\n| 2 | 2 | 2 |\n+------+--------+-------+\n\nmysql> SELECT userID,MAX(score) max_score FROM t1 WHERE userID <2 || userID > 3 GROUP BY userID ORDER BY max_score;\n+--------+-----------+\n| userid | max_score |\n+--------+-----------+\n| 1 | 5 |\n| 6 | 10 |\n| 0 | 99 |\n| 11 | 99 |\n+--------+-----------+\n\nmysql> select userID,count(score) from t1 group by userID having count(score)>1 order by userID;\n+--------+--------------+\n| userid | count(score) |\n+--------+--------------+\n| 1 | 3 |\n+--------+--------------+\n\nmysql> select userID,count(score) from t1 where userID>2 group by userID having count(score)>1 order by userID;\nEmpty set (0.01 sec)s\n\nmysql> select * from t1 order by spID asc nulls last;\n+------+--------+-------+\n| spid | userid | score |\n+------+--------+-------+\n| 1 | 1 | 1 |\n| 1 | 1 | 5 |\n| 2 | 2 | 2 |\n| 2 | 1 | 4 |\n| 3 | 3 | 3 |\n| 4 | 6 | 10 |\n| 5 | 11 | 99 |\n| NULL | 0 | 99 |\n+------+--------+-------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/select/#_5","title":"\u9650\u5236","text":"SELECT...FOR UPDATE
\u5f53\u524d\u4ec5\u652f\u6301\u5355\u8868\u67e5\u8be2\u3002INTO OUTFILE
\u3002\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u53ef\u4ee5\u4f7f\u7528 UNION
\uff0cINTERSECT
\u548c MINUS
\u8bed\u6cd5\u8fdb\u884c\u7ec4\u5408\u67e5\u8be2\u3002
\u793a\u4f8b\u8bed\u6cd5\u5982\u4e0b\uff1a
query1 UNION [ALL] query2\nquery1 INTERSECT [ALL] query2\nquery1 MINUS [ALL] query2\n
Tips: query1 \u548c query2 \u662f\u53ef\u4ee5\u4f7f\u7528\u5230\u76ee\u524d\u4e3a\u6b62\u8ba8\u8bba\u7684\u4efb\u4f55\u529f\u80fd\u7684\u67e5\u8be2\u3002
UNION
\u6709\u6548\u5730\u5c06 query2 \u7684\u7ed3\u679c\u5408\u5e76\u5230 query1 \u7684\u7ed3\u679c\u4e2d\uff08\u4f46\u4e0d\u80fd\u4fdd\u8bc1\u8fd9\u662f\u8fd4\u56de\u884c\u7684\u987a\u5e8f\uff09\u3002\u6b64\u5916\uff0c\u5b83\u4e0e DISTINCT
\u8bed\u6cd5\u76f8\u540c\uff0c\u5373\u4ece\u7ed3\u679c\u4e2d\u6d88\u9664\u91cd\u590d\u884c\uff1b\u4f7f\u7528\u4e86 UNION ALL
\uff0c\u5373\u4ece\u7ed3\u679c\u4e2d\u4e0d\u6d88\u9664\u91cd\u590d\u884c\u3002
INTERSECT
\u8fd4\u56de query1 \u548c query2 \u76f8\u4ea4\u7684\u7ed3\u679c\u4e2d\u7684\u6240\u6709\u884c\u3002\u4e0d\u4f7f\u7528 INTERSECT ALL
\uff0c\u5219\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\uff1b\u4f7f\u7528 INTERSECT ALL
\uff0c\u4e0d\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\u3002
MINUS
\u8fd4\u56de query1 \u7ed3\u679c\uff0c\u4f46\u4e0d\u5728 query2 \u4e2d\u7684\u6240\u6709\u884c\u3002\u5373 query1 \u548c query2 \u7684\u7ed3\u679c\u7684\u5dee\u96c6\u3002\u540c\u6837\uff0c\u4e0d\u4f7f\u7528 MINUS ALL
\uff0c\u5219\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\uff1b\u4f7f\u7528 MINUS ALL
\uff0c\u4e0d\u6d88\u9664\u7ed3\u679c\u4e2d\u7684\u91cd\u590d\u7684\u884c\u3002
\u8981\u8ba1\u7b97\u4e24\u4e2a\u67e5\u8be2\u7684\u5e76\u96c6\u3001\u4ea4\u96c6\u6216\u5dee\u96c6\uff0c\u8fd9\u4e24\u4e2a\u67e5\u8be2\u5fc5\u987b\u662f\u201c\u5e76\u96c6\u517c\u5bb9\u7684\u201d\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u8fd4\u56de\u76f8\u540c\u6570\u91cf\u7684\u5217\u5e76\u4e14\u5bf9\u5e94\u7684\u5217\u5177\u6709\u517c\u5bb9\u7684\u6570\u636e\u7c7b\u578b\u3002
UNION
\uff0cINTERSECT
\u548c MINUS
\u64cd\u4f5c\u53ef\u4ee5\u7ec4\u5408\uff0c\u4f8b\u5982\uff1a
query1 UNION query2 MINUS query3\n
\u5b83\u4e5f\u7b49\u4ef7\u4e8e\uff1a
(query1 UNION query2) MINUS query3\n
\u5982\u4e0a\u8ff0\u4ee3\u7801\u884c\u6240\u793a\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u62ec\u53f7\u6765\u63a7\u5236\u8ba1\u7b97\u987a\u5e8f\u3002\u5982\u679c\u6ca1\u6709\u62ec\u53f7\uff0cUNION
\u548c MINUS
\u4ece\u5de6\u5230\u53f3\u5173\u8054\u3002\u4f46 INTERSECT
\u6bd4\u8fd9\u4e24\u4e2a\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u66f4\u9ad8\uff0c\u56e0\u6b64\u53c2\u89c1\u4e0b\u9762\u7684\u4ee3\u7801\u884c\uff1a
query1 UNION query2 INTERSECT query3\n
\u8868\u793a\uff1a
query1 UNION (query2 INTERSECT query3)\n
\u4f60\u8fd8\u53ef\u4ee5\u7528\u62ec\u53f7\u5c06\u5355\u4e2a\u67e5\u8be2\u62ec\u8d77\u6765\u3002\u5982\u679c\u67e5\u8be2\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u793a\u4f8b\u4e2d\u7684\u5b50\u53e5\uff08\u4f8b\u5982 LIMIT
\u5b50\u53e5\uff09\uff0c\u5982\u679c\u6ca1\u6709\u62ec\u53f7\uff0c\u5c06\u4f1a\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef\uff0c\u8be5\u5b50\u53e5\u5728\u8ba1\u7b97\u8fc7\u7a0b\u4e2d\u5c06\u88ab\u7406\u89e3\u4e3a\u5e94\u7528\u4e8e\u7ec4\u5408\u64cd\u4f5c\u7684\u8f93\u51fa\u800c\u4e0d\u662f\u5176\u8f93\u5165\u4e4b\u4e00\u3002\u5982\u4e0b\u8ff0\u4f8b\u5b50\u6240\u793a\uff1a
SELECT a FROM b UNION SELECT x FROM y LIMIT 10\n
\u5b83\u53ef\u88ab\u63a5\u53d7\uff0c\u4f46\u662f\u5b83\u8868\u793a\u7684\u8ba1\u7b97\u987a\u5e8f\u5982\u4e0b\uff1a
(SELECT a FROM b UNION SELECT x FROM y) LIMIT 10\n
\u800c\u4e0d\u662f\u4e0b\u9762\u7684\u8ba1\u7b97\u987a\u5e8f\uff1a
SELECT a FROM b UNION (SELECT x FROM y LIMIT 10)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union-intersect-minus-overview/#_1","title":"\u53c2\u8003","text":"\u5173\u4e8e UNION
\uff0cINTERSECT
\u548c MINUS
\u5355\u4e2a\u8bed\u6cd5\u7684\u6587\u6863\uff0c\u53ef\u4ee5\u53c2\u89c1\u5982\u4e0b\uff1a
UNION
\u8fd0\u7b97\u7b26\u5141\u8bb8\u60a8\u5c06\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7ed3\u679c\u96c6\u5408\u5e76\u5230\u4e00\u4e2a\u7ed3\u679c\u96c6\u4e2d\u3002
SELECT column_list\nUNION [DISTINCT | ALL]\nSELECT column_list\nUNION [DISTINCT | ALL]\nSELECT column_list ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#union-union-all","title":"UNION
\u548c UNION ALL
","text":"\u4f7f\u7528 UNION
\u8fd0\u7b97\u7b26\u7ec4\u5408\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\uff0c\u9700\u8981\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a
SELECT
\u8bed\u53e5\u4e2d\u51fa\u73b0\u7684\u5217\u7684\u6570\u91cf\u548c\u987a\u5e8f\u5fc5\u987b\u76f8\u540c\u3002\u4f7f\u7528 UNION ALL
\uff0c\u5219\u91cd\u590d\u884c\uff08\u5982\u679c\u53ef\u7528\uff09\u5c06\u4fdd\u7559\u5728\u7ed3\u679c\u4e2d\u3002\u56e0\u4e3a UNION ALL
\u4e0d\u9700\u8981\u5904\u7406\u91cd\u590d\u9879\u3002
UNION
\u4e0e ORDER BY
\uff0cLIMIT
","text":"\u4f7f\u7528 ORDER BY
\u6216 LIMIT
\u5b50\u53e5\u5bf9\u5168\u90e8 UNION \u7ed3\u679c\u8fdb\u884c\u5206\u7c7b\u6216\u9650\u5236\u65f6\uff0c\u5e94\u5bf9\u5355\u4e2a\u7684 SELECT
\u8bed\u53e5\u52a0\u5706\u62ec\u53f7\uff0c\u5e76\u628a ORDER BY
\u6216 LIMIT
\u653e\u5230\u6700\u540e\u4e00\u4e2a\u7684\u540e\u9762\u3002
\u4f8b\u5982\uff1a
(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n
\u6216\uff1a
(SELECT a FROM t1 WHERE a=10 AND B=1)\nUNION\n(SELECT a FROM t2 WHERE a=11 AND B=2)\nORDER BY a LIMIT 10;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/union/#_4","title":"\u793a\u4f8b","text":"CREATE TABLE t1 (id INT PRIMARY KEY);\nCREATE TABLE t2 (id INT PRIMARY KEY);\nINSERT INTO t1 VALUES (1),(2),(3);\nINSERT INTO t2 VALUES (2),(3),(4);\n\nmysql> SELECT id FROM t1 UNION SELECT id FROM t2;\n+------+\n| id |\n+------+\n| 4 |\n| 1 |\n| 2 |\n| 3 |\n+------+\n\nmysql> SELECT id FROM t1 UNION ALL SELECT id FROM t2;\n+------+\n| id |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n
drop table t1;\nCREATE TABLE t1 (a INT, b INT);\nINSERT INTO t1 VALUES ROW(4,-2),ROW(5,9),ROW(10,1),ROW(11,2),ROW(13,5);\ndrop table t2;\nCREATE TABLE t2 (a INT, b INT);\nINSERT INTO t2 VALUES ROW(1,2),ROW(3,4),ROW(11,2),ROW(10,3),ROW(15,8);\n\nmysql> (SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10) UNION (SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);\n+------+\n| a |\n+------+\n| 10 |\n| 11 |\n+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/","title":"WITH (Common Table Expressions)","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u516c\u5171\u8868\u8fbe\u5f0f\uff08CTE\uff0ccommon table expression\uff09\uff0c\u5b83\u662f\u5728\u5355\u4e2a\u8bed\u53e5\u7684\u6267\u884c\u8303\u56f4\u5185\u5b9a\u4e49\u7684\u4e34\u65f6\u7ed3\u679c\u96c6\uff0c\u53ea\u5728\u67e5\u8be2\u671f\u95f4\u6709\u6548\u3002\u5b83\u53ef\u4ee5\u81ea\u5f15\u7528\uff0c\u4e5f\u53ef\u5728\u540c\u4e00\u67e5\u8be2\u4e2d\u591a\u6b21\u5f15\u7528\u3002\u4f5c\u7528\u662f\u7b80\u5316\u590d\u6742\u7684\u67e5\u8be2\uff0c\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u516c\u5171\u8868\u8fbe\u5f0f\u53ef\u4ee5\u88ab\u89c6\u4e3a\u4e00\u4e2a\u4e34\u65f6\u89c6\u56fe\uff0c\u53ea\u5728\u67e5\u8be2\u7684\u6267\u884c\u5468\u671f\u5185\u5b58\u5728\uff0c\u5bf9\u4e8e\u5916\u90e8\u67e5\u8be2\u662f\u4e0d\u53ef\u89c1\u7684\u3002
\u5b9a\u4e49 CTE
\u540e\uff0c\u53ef\u4ee5\u50cf SELECT
\uff0cINSERT
\uff0cUPDATE
\uff0cDELETE
\u6216 CREATE VIEW
\u8bed\u53e5\u4e00\u6837\u5f15\u7528\u5b83\u3002
\u4f7f\u7528 WITH
\u4ece\u53e5\u6307\u5b9a\u901a\u7528\u8868\u8868\u8fbe\u5f0f\uff0cWITH
\u4ece\u53e5\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u9017\u53f7\u5206\u9694\u3002\u6bcf\u4e2a\u4ece\u53e5\u63d0\u4f9b\u4e00\u4e2a\u5b50\u67e5\u8be2\uff0c\u8be5\u5b50\u67e5\u8be2\u751f\u6210\u4e00\u4e2a\u7ed3\u679c\u96c6\uff0c\u5e76\u5c06\u540d\u79f0\u4e0e\u5b50\u67e5\u8be2\u5173\u8054\u8d77\u6765\u3002
\u5e94\u7528\u573a\u666f\uff1a
\u901a\u7528\u8868\u8868\u8fbe\u5f0f\u5206\u4e3a\u975e\u9012\u5f52\u548c\u9012\u5f52\u4e24\u79cd\u7c7b\u578b\uff1a
\u975e\u9012\u5f52\u516c\u5171\u8868\u8fbe\u5f0f\uff1a\u662f\u6307 CTE \u4e2d\u4e0d\u5f15\u7528\u81ea\u8eab\u7684\u8868\u8fbe\u5f0f\uff0c\u5b83\u53ea\u7528\u4e8e\u6784\u5efa\u4e00\u6b21\u6027\u7684\u4e34\u65f6\u7ed3\u679c\u96c6\uff0c\u4e0d\u6d89\u53ca\u9012\u5f52\u64cd\u4f5c\u3002
\u9012\u5f52\u516c\u5171\u8868\u8fbe\u5f0f\uff1a\u662f\u6307 CTE \u4e2d\u5f15\u7528\u81ea\u8eab\u7684\u8868\u8fbe\u5f0f\uff0c\u7528\u4e8e\u5904\u7406\u5177\u6709\u9012\u5f52\u7ed3\u6784\u7684\u6570\u636e\uff0c\u4f8b\u5982\u6811\u5f62\u7ed3\u6784\u3001\u56fe\u5f62\u7b49\u3002\u9012\u5f52 CTE \u5728\u5b9a\u4e49\u4e2d\u5305\u542b\u4e00\u4e2a\u57fa\u672c\u67e5\u8be2\uff08\u8d77\u59cb\u6761\u4ef6\uff09\uff0c\u7136\u540e\u5728\u8be5\u57fa\u672c\u67e5\u8be2\u7684\u7ed3\u679c\u4e0a\u8fdb\u884c\u9012\u5f52\u64cd\u4f5c\uff0c\u76f4\u5230\u6ee1\u8db3\u505c\u6b62\u6761\u4ef6\u4e3a\u6b62\u3002
WITH <query_name> AS (\n <query_definition>\n)\nSELECT ... FROM <query_name>;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"<query_name>
\uff1a\u4e3a CTE \u7ed3\u679c\u96c6\u6307\u5b9a\u7684\u4e34\u65f6\u540d\u79f0\u3002\u5b83\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684\u6807\u8bc6\u7b26\uff0c\u7c7b\u4f3c\u4e8e\u8868\u540d\u6216\u5217\u540d\u3002
<query_definition>
\uff1a\u8fd9\u662f\u5b9a\u4e49 CTE \u7ed3\u679c\u96c6\u7684\u67e5\u8be2\u8bed\u53e5\u3002\u5b83\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684 SELECT
\u67e5\u8be2\uff0c\u7528\u4e8e\u521b\u5efa CTE \u7684\u7ed3\u679c\u96c6\u3002
SELECT ... FROM <query_name>
\uff1a\u8fd9\u662f\u5728 CTE \u4e0a\u6267\u884c\u7684\u67e5\u8be2\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u4f7f\u7528 CTE \u7684\u540d\u79f0\u3002
WITH RECURSIVE <query_name> AS (\n <query_definition>\n)\nSELECT ... FROM <query_name>;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_5","title":"\u53c2\u6570\u91ca\u4e49","text":"WITH RECURSIVE
\uff1a\u7528\u4e8e\u6307\u793a\u8fd9\u662f\u4e00\u4e2a\u9012\u5f52 CTE\u3002
<query_name>
\uff1a\u4e3a\u9012\u5f52 CTE \u7ed3\u679c\u96c6\u6307\u5b9a\u7684\u4e34\u65f6\u540d\u79f0\u3002\u5b83\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684\u6807\u8bc6\u7b26\uff0c\u7c7b\u4f3c\u4e8e\u8868\u540d\u6216\u5217\u540d\u3002
<query_definition>
\uff1a\u8fd9\u662f\u5b9a\u4e49\u9012\u5f52 CTE \u7ed3\u679c\u96c6\u7684\u67e5\u8be2\u8bed\u53e5\u3002\u5b83\u5305\u542b\u4e24\u90e8\u5206\uff1a
SELECT ... FROM <query_name>
\uff1a\u5728\u9012\u5f52 CTE \u4e0a\u4f7f\u7528\u9012\u5f52 CTE \u7684\u540d\u79f0\u8fdb\u884c\u67e5\u8be2\u3002
\u9012\u5f52 CTE \u5fc5\u987b\u5305\u542b\u81f3\u5c11\u4e24\u4e2a\u67e5\u8be2\u5b9a\u4e49\uff0c\u4e00\u4e2a\u662f\u951a\u5b9a\u6210\u5458\uff08anchor member\uff09\uff0c\u4e00\u4e2a\u662f\u9012\u5f52\u6210\u5458\uff08recursive member\uff09\u3002\u951a\u5b9a\u6210\u5458\u5fc5\u987b\u4f4d\u4e8e\u7b2c\u4e00\u4e2a\u9012\u5f52\u6210\u5458\u4e4b\u524d\uff0c\u53ef\u4ee5\u5b9a\u4e49\u591a\u4e2a\u951a\u5b9a\u548c\u9012\u5f52\u6210\u5458\u3002\u6240\u6709 CTE \u67e5\u8be2\u5b9a\u4e49\u90fd\u88ab\u89c6\u4e3a\u951a\u5b9a\u6210\u5458\uff0c\u9664\u975e\u5b83\u4eec\u5f15\u7528 CTE \u672c\u8eab\u3002
\u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a Employee
\u7684\u8868\uff0c\u5305\u542b\u5458\u5de5\u7684\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec EmployeeID
\u3001Name
\u548c ManagerID
\u5b57\u6bb5\uff0c\u8868\u793a\u5458\u5de5\u7684 ID\u3001\u59d3\u540d\u548c\u4e0a\u7ea7\u7ecf\u7406\u7684 ID\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u9012\u5f52 CTE \u6765\u67e5\u8be2\u5458\u5de5\u53ca\u5176\u4e0b\u5c5e\u7684\u5c42\u7ea7\u5173\u7cfb\u3002
\u5047\u8bbe\u8868\u4e2d\u7684\u6570\u636e\u5982\u4e0b\uff1a
EmployeeID Name ManagerID 1 Alice NULL 2 Bob 1 3 Charlie 1 4 David 2 5 Eve 2 6 Frank 3\u4ee5\u4e0b\u662f\u4f7f\u7528\u9012\u5f52 CTE \u6765\u67e5\u8be2\u5458\u5de5\u53ca\u5176\u4e0b\u5c5e\u7684\u5c42\u7ea7\u5173\u7cfb\u7684\u793a\u4f8b\uff1a
WITH RECURSIVE EmployeeHierarchy AS (\n-- \u951a\u5b9a\u6210\u5458\uff1a\u67e5\u627e\u9876\u5c42\u5458\u5de5\nSELECT EmployeeID, Name, ManagerID, 0 AS Level\nFROM Employee\nWHERE ManagerID IS NULL\n\nUNION ALL\n\n-- \u9012\u5f52\u6210\u5458\uff1a\u9012\u5f52\u67e5\u8be2\u4e0b\u5c5e\u5458\u5de5\nSELECT e.EmployeeID, e.Name, e.ManagerID, eh.Level + 1\nFROM Employee AS e\nJOIN EmployeeHierarchy AS eh ON e.ManagerID = eh.EmployeeID\n)\nSELECT Name, Level\nFROM EmployeeHierarchy;\n
\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff1a
ManagerID
\u4e3a NULL\uff09\u5e76\u5c06\u5176\u7ea7\u522b\uff08Level\uff09\u8bbe\u7f6e\u4e3a 0\u3002EmployeeHierarchy
\uff09\u67e5\u8be2\u4e0b\u5c5e\u5458\u5de5\uff0c\u5e76\u5c06\u7ea7\u522b\u9012\u589e\u3002SELECT
\u4ece\u9012\u5f52 CTE \u4e2d\u68c0\u7d22\u5458\u5de5\u59d3\u540d\u548c\u5c42\u7ea7\u3002\u6267\u884c\u6b64\u67e5\u8be2\u540e\uff0c\u5c06\u83b7\u5f97\u5458\u5de5\u53ca\u5176\u4e0b\u5c5e\u7684\u5c42\u7ea7\u5173\u7cfb\u4fe1\u606f\uff0c\u5176\u4e2d\u951a\u5b9a\u6210\u5458\u548c\u9012\u5f52\u6210\u5458\u5171\u540c\u6784\u6210\u4e86\u9012\u5f52\u67e5\u8be2\u7684\u7ed3\u6784\u3002\u975e\u9012\u5f52 CTE \u7528\u4e8e\u521b\u5efa\u4e34\u65f6\u7684\u67e5\u8be2\u7ed3\u679c\u96c6\uff0c\u4f60\u53ea\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a\u67e5\u8be2\u5b9a\u4e49\uff0c\u7136\u540e\u5728\u67e5\u8be2\u4e2d\u5f15\u7528\u8fd9\u4e2a CTE\uff0c\u800c\u65e0\u9700\u5173\u5fc3\u951a\u5b9a\u6210\u5458\u548c\u9012\u5f52\u6210\u5458\u7684\u95ee\u9898\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/with-cte/#_7","title":"\u8fd0\u7b97\u7b26\u4e0e\u8bed\u53e5\u8981\u6c42","text":"\u96c6\u5408\u8fd0\u7b97\u7b26\uff1a\u951a\u5b9a\u6210\u5458\u5fc5\u987b\u4f7f\u7528\u96c6\u5408\u8fd0\u7b97\u7b26\uff08\u5982 UNION ALL
\u3001UNION
\u3001INTERSECT
\u6216 EXCEPT
\uff09\u8fdb\u884c\u7ec4\u5408\u3002\u53ea\u6709\u5728\u6700\u540e\u4e00\u4e2a\u951a\u5b9a\u6210\u5458\u4e0e\u7b2c\u4e00\u4e2a\u9012\u5f52\u6210\u5458\u4e4b\u95f4\uff0c\u4ee5\u53ca\u5728\u7ec4\u5408\u591a\u4e2a\u9012\u5f52\u6210\u5458\u65f6\uff0c\u5141\u8bb8\u4f7f\u7528 UNION ALL\u3002
\u5217\u5339\u914d\uff1a\u951a\u5b9a\u6210\u5458\u548c\u9012\u5f52\u6210\u5458\u4e2d\u7684\u5217\u6570\u91cf\u5fc5\u987b\u76f8\u540c\u3002
\u6570\u636e\u7c7b\u578b\uff1a\u9012\u5f52\u6210\u5458\u4e2d\u7684\u5217\u7684\u6570\u636e\u7c7b\u578b\u5fc5\u987b\u4e0e\u951a\u5b9a\u6210\u5458\u4e2d\u76f8\u5e94\u5217\u7684\u6570\u636e\u7c7b\u578b\u76f8\u5339\u914d\u3002
FROM \u5b50\u53e5\uff1a\u9012\u5f52\u6210\u5458\u7684 FROM \u5b50\u53e5\u53ea\u80fd\u4e00\u6b21\u5f15\u7528 CTE expression_name\u3002
\u4e0d\u652f\u6301\u7684\u7279\u6027\uff1a\u5728\u9012\u5f52\u6210\u5458\u7684 CTE_query_definition \u4e2d\u4e0d\u5141\u8bb8\u4f7f\u7528\u67d0\u4e9b\u7279\u6027\uff0c\u5305\u62ec\uff1a
SELECT DISTINCT
\u5173\u952e\u5b57\u8fdb\u884c\u53bb\u91cd\u67e5\u8be2\u3002GROUP BY
\u5bf9\u7ed3\u679c\u8fdb\u884c\u5206\u7ec4\u3002HAVING
\u7b5b\u9009\u5206\u7ec4\u540e\u7684\u7ed3\u679c\u3002SUM
\u3001AVG
\u7b49\uff09\u5f97\u5230\u4e00\u4e2a\u5355\u4e00\u7684\u503c\u3002LEFT
\u3001RIGHT
\u3001OUTER JOIN
\u7b49\u5916\u8fde\u63a5\u64cd\u4f5c\uff08\u4f46\u662f INNER JOIN
\u662f\u5141\u8bb8\u7684\uff09\u3002CREATE TABLE employees (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nsalary INT\n);\n\nINSERT INTO employees (id, name, salary) VALUES\n(1, 'Alice', 50000),\n(2, 'Bob', 60000),\n(3, 'Charlie', 75000),\n(4, 'David', 55000),\n(5, 'Eve', 80000);\n\n-- \u67e5\u627e\u5de5\u8d44\u9ad8\u4e8e\u5e73\u5747\u5de5\u8d44\u7684\u5458\u5de5\nmysql> WITH avg_salary AS (\nSELECT AVG(salary) AS avg_salary FROM employees)\nSELECT name, salary\nFROM employees\nJOIN avg_salary ON salary > avg_salary.avg_salary;\n+---------+--------+\n| name | salary |\n+---------+--------+\n| Charlie | 75000 |\n| Eve | 80000 |\n+---------+--------+\n2 rows in set (0.00 sec)\n
CREATE TABLE employees_hierarchy (\nid INT PRIMARY KEY,\nname VARCHAR(50),\nmanager_id INT\n);\n\nINSERT INTO employees_hierarchy (id, name, manager_id) VALUES\n(1, 'Alice', NULL),\n(2, 'Bob', 1),\n(3, 'Charlie', 1),\n(4, 'David', 2),\n(5, 'Eve', 2),\n(6, 'Frank', 3);\n\n-- \u67e5\u627e\u67d0\u4e2a\u5458\u5de5\u53ca\u5176\u6240\u6709\u4e0b\u5c5e\u5458\u5de5\nmysql> WITH RECURSIVE employee_hierarchy_cte (id, name, manager_id, level) AS (\nSELECT id, name, manager_id, 0\nFROM employees_hierarchy\nWHERE name = 'Alice'\nUNION ALL\nSELECT e.id, e.name, e.manager_id, eh.level + 1\nFROM employees_hierarchy AS e\nJOIN employee_hierarchy_cte AS eh ON e.manager_id = eh.id\n)\nSELECT name, level\nFROM employee_hierarchy_cte;\n+---------+-------+\n| name | level |\n+---------+-------+\n| Alice | 0 |\n| Bob | 1 |\n| Charlie | 1 |\n| David | 2 |\n| Eve | 2 |\n| Frank | 2 |\n+---------+-------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/","title":"FULL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"FULL JOIN
\u5173\u952e\u5b57\u53ea\u8981\u5de6\u8868\uff08table1\uff09\u548c\u53f3\u8868\uff08table2\uff09\u5176\u4e2d\u4e00\u4e2a\u8868\u4e2d\u5b58\u5728\u5339\u914d\uff0c\u5219\u8fd4\u56de\u884c\u3002
FULL JOIN
\u5173\u952e\u5b57\u7ed3\u5408\u4e86 LEFT JOIN
\u548c RIGHT JOIN
\u7684\u7ed3\u679c\u3002
\u8bf4\u660e\uff1a\u5728\u4e00\u4e9b\u6570\u636e\u5e93\u4e2d\uff1aFULL JOIN
\u7b49\u540c\u4e8e FULL OUTER JOIN
\u3002
> SELECT column_name(s)\nFROM table1\nFULL OUTER JOIN table2\nON table1.column_name=table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/full-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 full join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/","title":"INNER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"INNER JOIN
\u9009\u53d6\u4e24\u4e2a\u8868\u4e2d\u5177\u6709\u5339\u914d\u503c\u7684\u6570\u636e\u8bb0\u5f55\u3002\uff08\u7b49\u540c\u4e8e JOIN
\uff09
> SELECT column_name(s)\nFROM table1\nINNER JOIN table2\nON table1.column_name = table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/inner-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/","title":"JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"JOIN
\u7528\u4e8e\u628a\u6765\u81ea\u4e24\u4e2a\u6216\u591a\u4e2a\u8868\u7684\u884c\u7ed3\u5408\u8d77\u6765\u3002
\u4e0b\u56fe\u5c55\u793a\u4e86 LEFT JOIN
\u3001RIGHT JOIN
\u3001INNER JOIN
\u3001\u548c OUTER JOIN
\u3002
LEFT JOIN
SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key\n
SELECT [select_list] FROM TableA A LEFT JOIN TableB B ON A.Key=B.Key WHERE B.Key IS NULL\n
\u56fe\u793a
RIGHT JOIN
SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key\n
SELECT [select_list] FROM TableA A RIGHT JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL\n
\u56fe\u793a
INNER JOIN
select_list] FROM TableA A INNER JOIN TableB B ON A.Key=B.Key\n
\u56fe\u793a
FULL JOIN
SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key\n
SELECT [select_list] FROM TableA A FULL OUTER JOIN TableB B ON A.Key=B.Key WHERE A.Key IS NULL OR B.Key IS NULL\n
\u56fe\u793a
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u8003\uff1a
LEFT JOIN
\u5173\u952e\u5b57\u4ece\u5de6\u8868\uff08table1\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\uff0c\u5373\u4f7f\u53f3\u8868\uff08table2\uff09\u4e2d\u6ca1\u6709\u5339\u914d\u3002\u5982\u679c\u53f3\u8868\u4e2d\u6ca1\u6709\u5339\u914d\uff0c\u5219\u7ed3\u679c\u4e3a NULL
\u3002
\u8bf4\u660e\uff1a\u5728\u4e00\u4e9b\u6570\u636e\u5e93\u4e2d\uff1aLEFT JOIN
\u7b49\u540c\u4e8e LEFT OUTER JOIN
\u3002
> SELECT column_name(s)\nFROM table1\nLEFT JOIN table2\nON table1.column_name=table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/left-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 left join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n| NULL | NULL | 0 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/","title":"NATURAL JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"NATURAL JOIN
\u76f8\u5f53\u4e8e INNER JOIN
\uff0c\u4f5c\u7528\u662f\u5c06\u4e24\u4e2a\u8868\u4e2d\u5177\u6709\u76f8\u540c\u540d\u79f0\u7684\u5217\u8fdb\u884c\u5339\u914d\u3002
> SELECT table_column1, table_column2...\nFROM table_name1\nNATURAL JOIN table_name2;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/natural-join/#_3","title":"\u793a\u4f8b","text":"create table t1(id int,desc1 varchar(50),desc2 varchar(50));\ncreate table t2(id int,desc3 varchar(50),desc4 varchar(50));\nINSERT INTO t1(id,desc1,desc2) VALUES(100,'desc11','desc12'),(101,'desc21','desc22'),(102,'desc31','desc32');\nINSERT INTO t2(id,desc3,desc4) VALUES(101,'desc41','desc42'),(103,'desc51','desc52'),(105,'desc61','desc62');\n\nmysql> SELECT t1.id,t2.id,desc1,desc2,desc3,desc4 FROM t1 NATURAL JOIN t2;\n+------+------+--------+--------+--------+--------+\n| id | id | desc1 | desc2 | desc3 | desc4 |\n+------+------+--------+--------+--------+--------+\n| 101 | 101 | desc21 | desc22 | desc41 | desc42 |\n+------+------+--------+--------+--------+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/","title":"OUTER JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/outer-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728 OUTER JOIN
\u4e2d\uff0c\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u6216\u4e24\u4e2a\u8868\u4e2d\u7684\u4e0d\u5339\u914d\u884c\u3002OUT JOIN
\u8bf7\u53c2\u8003\uff1a
LEFT JOIN
\u5173\u952e\u5b57\u4ece\u5de6\u8868\uff08table1\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\u3002\u53c2\u89c1 LEFT JOIN.RIGHT JOIN
\u5173\u952e\u5b57\u4ece\u53f3\u8868\uff08table2\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\u3002\u53c2\u89c1 RIGHT JOIN.FULL OUTER JOIN
\u5173\u952e\u5b57\u53ea\u8981\u5de6\u8868\uff08table1\uff09\u548c\u53f3\u8868\uff08table2\uff09\u5176\u4e2d\u4e00\u4e2a\u8868\u4e2d\u5b58\u5728\u5339\u914d\uff0c\u5219\u8fd4\u56de\u884c\u3002\u53c2\u89c1 FULL JOIN.create table t1 (a1 int, a2 char(3));\ninsert into t1 values(10,'aaa'), (10,null), (10,'bbb'), (20,'zzz');\ncreate table t2(a1 char(3), a2 int, a3 real);\ninsert into t2 values('AAA', 10, 0.5);\ninsert into t2 values('BBB', 20, 1.0);\n\nmysql> select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10;\n+------+------+------+------+\n| a1 | a2 | a1 | a2 |\n+------+------+------+------+\n| 10 | aaa | AAA | 10 |\n| 10 | aaa | BBB | 20 |\n| 10 | NULL | AAA | 10 |\n| 10 | NULL | BBB | 20 |\n| 10 | bbb | AAA | 10 |\n| 10 | bbb | BBB | 20 |\n| 20 | zzz | NULL | NULL |\n+------+------+------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/","title":"RIGHT JOIN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"RIGHT JOIN
\u5173\u952e\u5b57\u4ece\u53f3\u8868\uff08table2\uff09\u8fd4\u56de\u6240\u6709\u7684\u884c\uff0c\u5373\u4f7f\u5de6\u8868\uff08table1\uff09\u4e2d\u6ca1\u6709\u5339\u914d\u3002\u5982\u679c\u5de6\u8868\u4e2d\u6ca1\u6709\u5339\u914d\uff0c\u5219\u7ed3\u679c\u4e3a NULL
\u3002
\u8bf4\u660e\uff1a\u5728\u4e00\u4e9b\u6570\u636e\u5e93\u4e2d\uff1aRIGHT JOIN
\u7b49\u540c\u4e8e RIGHT OUTER JOIN
\u3002
> SELECT column_name(s)\nFROM table1\nRIGHT JOIN table2\nON table1.column_name=table2.column_name;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/join/right-join/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1,t2,t3;\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values ('000','NewYorkPublicLibra',1);\ninsert into t3 values ('001','NewYorkPublicLibra',2);\ninsert into t3 values ('002','NewYorkPublicLibra',3);\ninsert into t3 values ('003','NewYorkPublicLibra',4);\ninsert into t3 values ('004','NewYorkPublicLibra',5);\ninsert into t3 values ('005','NewYorkPublicLibra',6);\ninsert into t3 values ('006','SanFransiscoPublic',5);\ninsert into t3 values ('007','BerkeleyPublic1',3);\ninsert into t3 values ('007','BerkeleyPublic2',3);\ninsert into t3 values ('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select city,libname1,count(libname1) as a from t3 right join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/","title":"\u5b50\u67e5\u8be2\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u7684\u4f7f\u7528","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#_2","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5b50\u67e5\u8be2\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u6700\u5e38\u89c1\u7684\u7528\u6cd5\u5982\u4e0b\uff1a
non_subquery_operand comparison_operator (subquery)\n
\u5176\u4e2d\uff0ccomparison_operator
\u6307\u4ee5\u4e0b\u64cd\u4f5c\u7b26\uff1a
= > < >= <= <> != <=>\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#_3","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SELECT column_name(s) FROM table_name WHERE 'a' = (SELECT column1 FROM t1)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/comparisons-using-subqueries/#_4","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where a = (select b from t2);\nERROR 1105 (HY000): scalar subquery returns more than 1 row\nmysql> select * from t3 where a = (select distinct b from t2);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 rows in set (0.01 sec)\n\nmysql> select a,b from t4 where a > ( select a ,b from t2 where a>1);\nERROR 1105 (HY000): Internal error: Unknow type TUPLE\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/","title":"Derived Tables","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5f53 SELECT
\u8bed\u53e5\u7684 FROM
\u4ece\u53e5\u4e2d\u4f7f\u7528\u72ec\u7acb\u5b50\u67e5\u8be2\u65f6\uff0c\u6211\u4eec\u4e5f\u7ecf\u5e38\u5c06\u5176\u79f0\u4e3a\u6d3e\u751f\u8868\uff0c\u56e0\u4e3a\u5b9e\u9645\u4e0a\u5916\u90e8\u67e5\u8be2\u5c06\u5b50\u67e5\u8be2\u7684\u7ed3\u679c\u5f53\u4f5c\u4e86\u4e00\u4e2a\u6570\u636e\u6e90\u3002
\u6bcf\u4e2a FROM \u5b50\u67e5\u8be2\u7684\u8868\u90fd\u5fc5\u987b\u8981\u6709\u4e00\u4e2a\u540d\u5b57\uff0c\u56e0\u6b64 [AS] \u64cd\u4f5c\u7b26\u662f\u5fc5\u987b\u7684\u3002\u5b50\u67e5\u8be2\u7684 SELECT \u5217\u8868\u4e2d\u6bcf\u4e2a\u5217\u4e5f\u5fc5\u987b\u8981\u6709\u4e00\u4e2a\u552f\u4e00\u7684\u540d\u5b57\u3002
> SELECT ... FROM (subquery) [AS] name ...\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/derived-tables/#_3","title":"\u793a\u4f8b","text":"> CREATE TABLE tb1 (c1 INT, c2 CHAR(5), c3 FLOAT);\n> INSERT INTO tb1 VALUES (1, '1', 1.0);\n> INSERT INTO tb1 VALUES (2, '2', 2.0);\n> INSERT INTO tb1 VALUES (3, '3', 3.0);\n> select * from tb1;\n+------+------+--------+\n| c1 | c2 | c3 |\n+------+------+--------+\n| 1 | 1 | 1.0000 |\n| 2 | 2 | 2.0000 |\n| 3 | 3 | 3.0000 |\n+------+------+--------+\n3 rows in set (0.03 sec)\n\n> SELECT sc1, sc2, sc3 FROM (SELECT c1 AS sc1, c2 AS sc2, c3*3 AS sc3 FROM tb1) AS sb WHERE sc1 > 1;\n+------+------+--------+\n| sc1 | sc2 | sc3 |\n+------+------+--------+\n| 2 | 2 | 6.0000 |\n| 3 | 3 | 9.0000 |\n+------+------+--------+\n2 rows in set (0.02 sec)\n``````sql\nCREATE TABLE tb1 (c1 INT, c2 CHAR(5), c3 FLOAT);\nINSERT INTO tb1 VALUES (1, '1', 1.0);\nINSERT INTO tb1 VALUES (2, '2', 2.0);\nINSERT INTO tb1 VALUES (3, '3', 3.0);\n\nmysql> select * from tb1;\n+------+------+--------+\n| c1 | c2 | c3 |\n+------+------+--------+\n| 1 | 1 | 1.0000 |\n| 2 | 2 | 2.0000 |\n| 3 | 3 | 3.0000 |\n+------+------+--------+\n3 rows in set (0.03 sec)\n\nmysql> SELECT sc1, sc2, sc3 FROM (SELECT c1 AS sc1, c2 AS sc2, c3*3 AS sc3 FROM tb1) AS sb WHERE sc1 > 1;\n+------+------+--------+\n| sc1 | sc2 | sc3 |\n+------+------+--------+\n| 2 | 2 | 6.0000 |\n| 3 | 3 | 9.0000 |\n+------+------+--------+\n2 rows in set (0.02 sec)\n
> create table t1 (libname1 varchar(21) not null primary key, city varchar(20));\n> create table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\n> create table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\n> insert into t2 values ('001','Daffy','Aducklife');\n> insert into t2 values ('002','Bugs','Arabbitlife');\n> insert into t2 values ('003','Cowboy','Lifeontherange');\n> insert into t2 values ('000','Anonymous','Wannabuythisbook?');\n> insert into t2 values ('004','BestSeller','OneHeckuvabook');\n> insert into t2 values ('005','EveryoneBuys','Thisverybook');\n> insert into t2 values ('006','SanFran','Itisasanfranlifestyle');\n> insert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\n> insert into t3 values('000','NewYorkPublicLibra',1);\n> insert into t3 values('001','NewYorkPublicLibra',2);\n> insert into t3 values('002','NewYorkPublicLibra',3);\n> insert into t3 values('003','NewYorkPublicLibra',4);\n> insert into t3 values('004','NewYorkPublicLibra',5);\n> insert into t3 values('005','NewYorkPublicLibra',6);\n> insert into t3 values('006','SanFransiscoPublic',5);\n> insert into t3 values('007','BerkeleyPublic1',3);\n> insert into t3 values('007','BerkeleyPublic2',3);\n> insert into t3 values('001','NYC Lib',8);\n> insert into t1 values ('NewYorkPublicLibra','NewYork');\n> insert into t1 values ('SanFransiscoPublic','SanFran');\n> insert into t1 values ('BerkeleyPublic1','Berkeley');\n> insert into t1 values ('BerkeleyPublic2','Berkeley');\n> insert into t1 values ('NYCLib','NewYork');\n> select * from (select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1) sub ;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n4 rows in set (0.00 sec)\n``````sql\ncreate table t1 (libname1 varchar(21) not null primary key, city varchar(20));\ncreate table t2 (isbn2 varchar(21) not null primary key, author varchar(20), title varchar(60));\ncreate table t3 (isbn3 varchar(21) not null, libname3 varchar(21) not null, quantity int);\ninsert into t2 values ('001','Daffy','Aducklife');\ninsert into t2 values ('002','Bugs','Arabbitlife');\ninsert into t2 values ('003','Cowboy','Lifeontherange');\ninsert into t2 values ('000','Anonymous','Wannabuythisbook?');\ninsert into t2 values ('004','BestSeller','OneHeckuvabook');\ninsert into t2 values ('005','EveryoneBuys','Thisverybook');\ninsert into t2 values ('006','SanFran','Itisasanfranlifestyle');\ninsert into t2 values ('007','BerkAuthor','Cool.Berkley.the.book');\ninsert into t3 values('000','NewYorkPublicLibra',1);\ninsert into t3 values('001','NewYorkPublicLibra',2);\ninsert into t3 values('002','NewYorkPublicLibra',3);\ninsert into t3 values('003','NewYorkPublicLibra',4);\ninsert into t3 values('004','NewYorkPublicLibra',5);\ninsert into t3 values('005','NewYorkPublicLibra',6);\ninsert into t3 values('006','SanFransiscoPublic',5);\ninsert into t3 values('007','BerkeleyPublic1',3);\ninsert into t3 values('007','BerkeleyPublic2',3);\ninsert into t3 values('001','NYC Lib',8);\ninsert into t1 values ('NewYorkPublicLibra','NewYork');\ninsert into t1 values ('SanFransiscoPublic','SanFran');\ninsert into t1 values ('BerkeleyPublic1','Berkeley');\ninsert into t1 values ('BerkeleyPublic2','Berkeley');\ninsert into t1 values ('NYCLib','NewYork');\n\nmysql> select * from (select city,libname1,count(libname1) as a from t3 join t1 on libname1=libname3 join t2 on isbn3=isbn2 group by city,libname1) sub ;\n+----------+--------------------+------+\n| city | libname1 | a |\n+----------+--------------------+------+\n| NewYork | NewYorkPublicLibra | 6 |\n| SanFran | SanFransiscoPublic | 1 |\n| Berkeley | BerkeleyPublic1 | 1 |\n| Berkeley | BerkeleyPublic2 | 1 |\n+----------+--------------------+------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/","title":"Subqueries with ALL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5173\u952e\u8bcd ALL
\u5fc5\u987b\u8ddf\u5728\u6bd4\u8f83\u64cd\u4f5c\u7b26\u540e\u9762\uff0c\u6307\u5982\u679c\u5b50\u67e5\u8be2\u8fd4\u56de\u7684\u5217\u4e2d\u503c\u7684 ALL
\u7684\u6bd4\u8f83\u662f TRUE
\uff0c\u5219\u8fd4\u56de TRUE
\u3002
operand comparison_operator ALL (subquery)\n
\u793a\u4f8b\u5982\u4e0b\uff1a
SELECT s1 FROM t1 WHERE s1 > ALL (SELECT s1 FROM t2);\n
\u5982\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5047\u8bbe\u8868 t1 \u4e2d\u6709\u4e00\u884c\u5305\u542b (10)\uff0c\u8868 t2 \u5305\u542b (-5,0\uff0c+5)\uff0c\u5219\u8868\u8fbe\u5f0f\u4e3a TRUE
\uff0c\u56e0\u4e3a 10 \u5927\u4e8e t2 \u4e2d\u7684\u6240\u6709\u4e09\u4e2a\u503c\u3002\u5982\u679c\u8868 t2 \u5305\u542b (12,6,NULL\uff0c-100)\uff0c\u5219\u8868\u8fbe\u5f0f\u4e3a FALSE
\uff0c\u56e0\u4e3a\u5728\u8868 t2 \u4e2d\u6709\u4e00\u4e2a\u5927\u4e8e 10 \u7684\u503c 12\u3002\u5982\u679c\u8868 t2 \u5305\u542b (0,NULL,1)\uff0c\u5219\u8868\u8fbe\u5f0f\u4e3a NULL
\u3002
TRUE
\u3002\u4f8b\u5982\uff0c\u5f53\u4e0b\u8868 t2 \u4e3a\u7a7a\u65f6\uff0c\u8868\u8fbe\u5f0f\u662f TRUE
\uff1aSELECT * FROM t1 WHERE 1 > ALL (SELECT s1 FROM t2);\n
NULL
\uff1aSELECT * FROM t1 WHERE 1 > (SELECT s1 FROM t2);\n
\u6216\uff1a
SELECT * FROM t1 WHERE 1 > ALL (SELECT MAX(s1) FROM t2);\n
\u8bf4\u660e\uff1a\u5728\u4e66\u5199\u5b50\u67e5\u8be2\u8bed\u6cd5\u65f6\uff0c\u8981\u6ce8\u610f\u8003\u8651\u5230\u542b\u6709 NULL
\u503c\u7684\u8868\u548c\u7a7a\u8868\u7684\u60c5\u51b5\u3002
> SELECT column_name(s) FROM table_name {WHERE | HAVING} [not] expression comparison_operator ALL (subquery)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-all/#_3","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> all (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t4 where 5 > all (select a from t5);\n+------+------+\n| a | b |\n+------+------+\n| 4 | 8 |\n| 3 | 8 |\n| 5 | 9 |\n+------+------+\n3 rows in set (0.01 sec)\n\nmysql> select * from t3 where 10 > all (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 7 |\n| 3 |\n+------+\n3 rows in set (0.00 sec)\n\nmysql> select a,b from t6 where a > all ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/","title":"Subqueries with ANY or SOME","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u7531\u4e8e\u5217\u5b50\u67e5\u8be2\u8fd4\u56de\u7684\u7ed3\u679c\u96c6\u662f\u591a\u884c\u4e00\u5217\uff0c\u56e0\u6b64\u4e0d\u80fd\u76f4\u63a5\u4f7f\u7528\uff08=\uff0c>\uff0c<\uff0c>=\uff0c<=\uff0c<>\uff09\u8fd9\u4e9b\u6bd4\u8f83\u64cd\u4f5c\u7b26\u3002\u5728\u5217\u5b50\u67e5\u8be2\u4e2d\u53ef\u4ee5\u4f7f\u7528 ANY
\u3001SOME
\u64cd\u4f5c\u7b26\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u8054\u5408\u4f7f\u7528\uff1a
ANY
\uff1a\u4e0e\u6bd4\u8f83\u64cd\u4f5c\u7b26\u8054\u5408\u4f7f\u7528\uff0c\u8868\u793a\u4e0e\u5b50\u67e5\u8be2\u8fd4\u56de\u7684\u4efb\u4f55\u503c\u6bd4\u8f83\u4e3a TRUE
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a true
\u3002SOME
\uff1aANY
\u7684\u522b\u540d\uff0c\u4e0e ANY
\u610f\u4e49\u76f8\u540c\uff0c\u4f46\u8f83\u5c11\u4f7f\u7528\u3002> SELECT column_name(s) FROM table_name WHERE column_name ANY (subquery);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-any-some/#_3","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select * from t3 where a <> any (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a <> some (select b from t2);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n\nmysql> select * from t3 where a = some (select b from t2);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select * from t3 where a = any (select b from t2);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select a,b from t6 where a > any ( select a ,b from t4 where a>3);\nERROR 1105 (HY000): subquery should return 1 column\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/","title":"Subqueries with EXISTS or NOT EXISTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"EXISTS
\u7528\u4e8e\u68c0\u67e5\u5b50\u67e5\u8be2\u662f\u5426\u81f3\u5c11\u4f1a\u8fd4\u56de\u4e00\u884c\u6570\u636e\u3002\u5373\u5c06\u4e3b\u67e5\u8be2\u7684\u6570\u636e\uff0c\u653e\u5230\u5b50\u67e5\u8be2\u4e2d\u505a\u6761\u4ef6\u9a8c\u8bc1\uff0c\u6839\u636e\u9a8c\u8bc1\u7ed3\u679c\uff08TRUE \u6216 FALSE\uff09\u6765\u51b3\u5b9a\u4e3b\u67e5\u8be2\u7684\u6570\u636e\u7ed3\u679c\u662f\u5426\u5f97\u4ee5\u4fdd\u7559\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u8fd4\u56de\u4efb\u4f55\u884c\uff0cEXISTS
\u5b50\u67e5\u8be2\u6761\u4ef6\u4e3a TRUE
\uff0cNOT EXISTS
\u5b50\u67e5\u8be2\u6761\u4ef6\u4e3a FALSE
\u3002
> SELECT column_name(s)\nFROM table_name\nWHERE EXISTS\n(SELECT column_name FROM table_name WHERE condition);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-exists/#_3","title":"\u793a\u4f8b","text":"create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t3 values (6),(7),(3);\n\nmysql> select * from t3 where exists (select * from t2 where t2.b=t3.a);\n+------+\n| a |\n+------+\n| 7 |\n+------+\n1 row in set (0.00 sec)\nmysql> select * from t3 where not exists (select * from t2 where t2.b=t3.a);\n+------+\n| a |\n+------+\n| 6 |\n| 3 |\n+------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/","title":"Subqueries with IN","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#_1","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u5b50\u67e5\u8be2\u53ef\u4ee5\u4e0e IN
\u64cd\u4f5c\u7b26\u4e00\u8d77\u4f7f\u7528\uff0c\u4f5c\u4e3a\u201c\u8868\u8fbe\u5f0f IN (\u5b50\u67e5\u8be2)\u201d\uff0c\u67e5\u8be2\u67d0\u4e2a\u8303\u56f4\u5185\u7684\u6570\u636e\u3002\u5b50\u67e5\u8be2\u5e94\u8be5\u8fd4\u56de\u5e26\u6709\u4e00\u884c\u6216\u591a\u884c\u7684\u5355\u4e2a\u5217\uff0c\u4ee5\u5f62\u6210 IN
\u64cd\u4f5c\u4f7f\u7528\u7684\u503c\u5217\u8868\u3002
\u5bf9\u591a\u8bb0\u5f55\u3001\u5355\u5217\u5b50\u67e5\u8be2\u4f7f\u7528 IN
\u5b50\u53e5\u3002\u5b50\u67e5\u8be2\u8fd4\u56de IN
\u6216 NOT IN
\u5f15\u5165\u7684\u7ed3\u679c\u540e\uff0c\u5916\u90e8\u67e5\u8be2\u4f7f\u7528\u5b83\u4eec\u8fd4\u56de\u6700\u7ec8\u7ed3\u679c\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e2d\u6709\u5339\u914d\u7684\u884c\uff0c\u5219\u7ed3\u679c\u4e3a TRUE
\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e2d\u6ca1\u6709\u5339\u914d\u7684\u884c\uff0c\u7ed3\u679c\u4e5f\u662f FALSE
\u3002
\u5982\u679c\u5b50\u67e5\u8be2\u7ed3\u679c\u4e2d\u6240\u6709\u7684\u503c\u90fd\u4e3a NULL
\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u4e3a false
\u3002
> SELECT ... FROM table_name WHERE column_name IN (subquery)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery-with-in/#_3","title":"\u793a\u4f8b","text":"create table t1(val varchar(10));\ninsert into t1 values ('aaa'), ('bbb'),('eee'),('mmm'),('ppp');\n\nmysql> select count(*) from t1 as w1 where w1.val in (select w2.val from t1 as w2 where w2.val like 'm%') and w1.val in (select w3.val from t1 as w3 where w3.val like 'e%');\n+----------+\n| count(*) |\n+----------+\n| 0 |\n+----------+\n1 row in set (0.01 sec)\n
create table t1 (id int not null, text varchar(20) not null default '', primary key (id));\ninsert into t1 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text11'), (12, 'text12');\n\nmysql> select * from t1 where id not in (select id from t1 where id < 8);\n+------+--------+\n| id | text |\n+------+--------+\n| 8 | text8 |\n| 9 | text9 |\n| 10 | text10 |\n| 11 | text11 |\n| 12 | text12 |\n+------+--------+\n5 rows in set (0.00 sec)\n
CREATE TABLE t1 (a int);\nCREATE TABLE t2 (a int, b int);\nCREATE TABLE t3 (b int NOT NULL);\nINSERT INTO t1 VALUES (1), (2), (3), (4);\nINSERT INTO t2 VALUES (1,10), (3,30);\n\nmysql> select * from t1 where t1.a in (SELECT t1.a FROM t1 LEFT JOIN t2 ON t2.a=t1.a);\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n4 rows in set (0.01 sec)\n\nmysql> SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10;\nEmpty set (0.01 sec)\nmysql> SELECT * FROM t1 WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t3.b IS NOT NULL OR t2.a > 10);\n+------+\n| a |\n+------+\n| 1 |\n| 2 |\n| 3 |\n| 4 |\n+------+\n4 rows in set (0.00 sec)\n
create table t1 (a int);\ncreate table t2 (a int, b int);\ncreate table t3 (a int);\ncreate table t4 (a int not null, b int not null);\ncreate table t5 (a int);\ncreate table t6 (a int, b int);\ninsert into t1 values (2);\ninsert into t2 values (1,7),(2,7);\ninsert into t4 values (4,8),(3,8),(5,9);\ninsert into t5 values (null);\ninsert into t3 values (6),(7),(3);\ninsert into t6 values (10,7),(null,7);\n\nmysql> select a,b from t6 where (a,b) in ( select a,b from t4 where a>3);\nEmpty set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Data-Query-Language/subqueries/subquery/","title":"\u5b50\u67e5\u8be2","text":"\u5b50\u67e5\u8be2\uff0c\u4e5f\u79f0\u4e3a\u5d4c\u5957\u67e5\u8be2\u6216\u5b50\u9009\u62e9\uff0c\u662f SELECT
\u5b50\u67e5\u8be2\u8bed\u53e5\u5d4c\u5165\u5728\u53e6\u4e00\u4e2a SQL
\u67e5\u8be2\u7684\u67e5\u8be2\u65b9\u5f0f\u3002
\u53c2\u89c1\u4e0b\u9762\u7684\u5b50\u67e5\u8be2\u793a\u4f8b\uff1a
SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);\n
\u5728\u793a\u4f8b\u4e2d\uff0cSELECT * FROM t1 WHERE column1
\u662f\u5916\u90e8\u67e5\u8be2\uff08\u6216\u5916\u90e8\u8bed\u53e5\uff09\uff0c(SELECT column1 FROM t2)
\u662f\u5b50\u67e5\u8be2\u3002\u5b50\u67e5\u8be2\u8bed\u53e5\u5fc5\u987b\u5199\u5728\u62ec\u53f7\u5185\uff0c\u7136\u540e\u5d4c\u5957\u5728\u5916\u90e8\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u4e5f\u53ef\u4ee5\u5d4c\u5957\u5728\u5176\u4ed6\u5b50\u67e5\u8be2\u8bed\u53e5\u4e2d\uff0c\u5f62\u6210\u591a\u5c42\u5d4c\u5957\u3002
\u5b50\u67e5\u8be2\u7684\u4e3b\u8981\u4f18\u70b9\uff1a
\u5b50\u67e5\u8be2\u53ef\u4ee5\u5212\u5206\u8bed\u53e5\uff0c\u63d0\u4f9b\u7ed3\u6784\u5316\u67e5\u8be2\u3002
\u5b50\u67e5\u8be2\u53ef\u66ff\u4ee3\u590d\u6742\u7684 JOIN
\u548c UNIONS
\u8bed\u53e5\u3002
\u5b50\u67e5\u8be2\u6bd4\u590d\u6742\u7684 JOIN
\u548c UNIONS
\u53ef\u8bfb\u6027\u5f3a\u3002
\u4e00\u4e2a\u5b50\u67e5\u8be2\u6709\u4ee5\u4e0b\u51e0\u7c7b\uff1a
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1\uff1a
MatrixOne \u6682\u4e0d\u652f\u6301\u9009\u62e9\u591a\u5217\u8fdb\u884c\u5b50\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/","title":"KILL","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"KILL
\u8bed\u53e5\u7528\u4e8e\u7ec8\u6b62\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u6216\u8fdb\u7a0b\u3002
Info
\u7ec8\u6b62\u8fdb\u7a0b\u6216\u67e5\u8be2\u53ef\u80fd\u4f1a\u5bfc\u81f4\u672a\u4fdd\u5b58\u7684\u6570\u636e\u4e22\u5931\uff1b\u7ec8\u6b62\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u53ef\u80fd\u4f1a\u5360\u7528\u7cfb\u7edf\u8d44\u6e90\uff0c\u5e76\u4e14\u53ef\u80fd\u4f1a\u5f71\u54cd\u5176\u4ed6\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> KILL [CONNECTION | QUERY] process_id;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/kill/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"process_id
\u662f\u6307\u8981\u7ec8\u6b62\u7684\u8fdb\u7a0b\u6216\u67e5\u8be2\u7684\u6807\u8bc6\u7b26\u3002\u5982\u679c\u4f7f\u7528 CONNECTION
\u5173\u952e\u5b57\uff0c\u5219 process_id
\u662f\u8fde\u63a5\u6807\u8bc6\u7b26\uff0c\u800c\u5982\u679c\u4f7f\u7528 QUERY
\u5173\u952e\u5b57\uff0c\u5219 process_id
\u662f\u67e5\u8be2\u6807\u8bc6\u7b26\u3002
select connection_id();\n+-----------------+\n| connection_id() |\n+-----------------+\n| 1008 |\n+-----------------+\n1 row in set (0.00 sec)\n\n-- \u7ec8\u6b62\u67e5\u8be2\u8fdb\u7a0b\nmysql> kill query 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- \u7ec8\u6b62\u8fde\u63a5\u8fdb\u7a0b\nmysql> kill connection 1008;\nQuery OK, 0 rows affected (0.00 sec)\n\n-- \u6d4b\u8bd5\u662f\u5426\u65ad\u5f00\u4e86\u8fde\u63a5\nmysql> show databases;\nERROR 2013 (HY000): Lost connection to MySQL server during query\nNo connection. Trying to reconnect...\nConnection id: 1180\n-- \u5df2\u7ecf\u65ad\u5f00\u4e86\u8fde\u63a5\uff0c\u670d\u52a1\u53c8\u5f00\u59cb\u91cd\u65b0\u8fde\u63a5\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/","title":"USE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"USE
\u8bed\u53e5\u7528\u4e8e\u9009\u62e9\u5f53\u524d\u6570\u636e\u5e93\uff0c\u5728\u6b64\u6570\u636e\u5e93\u8fdb\u884c\u540e\u7eed\u64cd\u4f5c\u3002
> USE db_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/use-database/#_3","title":"\u793a\u4f8b","text":"> USE db1;\n> SELECT COUNT(*) FROM mytable; \n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-analyze/","title":"\u901a\u8fc7 EXPLAIN ANALYZE
\u83b7\u53d6\u4fe1\u606f","text":"EXPLAIN ANALYZE
\u662f\u4e00\u4e2a\u7528\u4e8e\u67e5\u8be2\u7684\u5206\u6790\u5de5\u5177\uff0c\u5b83\u5c06\u5411\u4f60\u663e\u793a SQL \u5728\u67e5\u8be2\u4e0a\u82b1\u8d39\u7684\u65f6\u95f4\u4ee5\u53ca\u539f\u56e0\u3002\u5b83\u5c06\u8ba1\u5212\u67e5\u8be2\u3001\u68c0\u6d4b\u5b83\u5e76\u6267\u884c\u5b83\uff0c\u540c\u65f6\u8ba1\u7b97\u884c\u6570\u5e76\u6d4b\u91cf\u5728\u6267\u884c\u8ba1\u5212\u7684\u5404\u4e2a\u70b9\u82b1\u8d39\u7684\u65f6\u95f4\u3002\u6267\u884c\u5b8c\u6210\u540e\uff0cEXPLAIN ANALYZE
\u5c06\u6253\u5370\u8ba1\u5212\u548c\u6d4b\u91cf\u7ed3\u679c\uff0c\u800c\u4e0d\u662f\u67e5\u8be2\u7ed3\u679c\u3002
EXPLAIN ANALYZE
\uff0c\u5b83\u8fd0\u884c SQL \u8bed\u53e5\u4ea7\u751f EXPLAIN
\u8f93\u51fa\uff0c\u6b64\u5916\uff0c\u8fd8\u4ea7\u751f\u5176\u4ed6\u4fe1\u606f\uff0c\u4f8b\u5982\u65f6\u95f4\u548c\u57fa\u4e8e\u8fed\u4ee3\u5668\u7684\u9644\u52a0\u4fe1\u606f\uff0c\u4ee5\u53ca\u5173\u4e8e\u4f18\u5316\u5668\u7684\u9884\u671f\u4e0e\u5b9e\u9645\u6267\u884c\u7684\u5339\u914d\u60c5\u51b5\u3002
\u5bf9\u4e8e\u6bcf\u4e2a\u8fed\u4ee3\u5668\uff0c\u63d0\u4f9b\u4ee5\u4e0b\u4fe1\u606f\uff1a
\u6210\u672c\u6a21\u578b\u6ca1\u6709\u8003\u8651\u4e00\u4e9b\u8fed\u4ee3\u5668\uff0c\u56e0\u6b64\u4e0d\u5305\u62ec\u5728\u4f30\u7b97\u4e2d\u3002
\u4f30\u8ba1\u7684\u8fd4\u56de\u7684\u884c\u6570
\u8fd4\u56de\u7b2c\u4e00\u884c\u7684\u65f6\u95f4
\u6267\u884c\u6b64\u8fed\u4ee3\u5668\uff08\u4ec5\u5305\u62ec\u5b50\u8fed\u4ee3\u5668\uff0c\u4f46\u4e0d\u5305\u62ec\u7236\u8fed\u4ee3\u5668\uff09\u6240\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d\u3002
\u8fed\u4ee3\u5668\u8fd4\u56de\u7684\u884c\u6570
\u5faa\u73af\u6570
\u67e5\u8be2\u6267\u884c\u4fe1\u606f\u4f7f\u7528 TREE
\u8f93\u51fa\u683c\u5f0f\u663e\u793a\uff0c\u5176\u4e2d\u8282\u70b9\u4ee3\u8868\u8fed\u4ee3\u5668\u3002EXPLAIN ANALYZE
\u59cb\u7ec8\u4f7f\u7528 TREE
\u8f93\u51fa\u683c\u5f0f\u3002
EXPLAIN ANALYZE
\u53ef\u4ee5\u4e0e SELECT
\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u4e0e\u591a\u8868 UPDATE
\u548c DELETE
\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528 KILL QUERY
\u6216 CTRL-C
\u7ec8\u6b62\u6b64\u8bed\u53e5\u3002
EXPLAIN ANALYZE
\u4e0d\u80fd\u4e0e FOR CONNECTION
\u4e00\u8d77\u4f7f\u7528\u3002
\u5efa\u8868
CREATE TABLE t1 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t2 (\nc1 INTEGER DEFAULT NULL,\nc2 INTEGER DEFAULT NULL\n);\n\nCREATE TABLE t3 (\npk INTEGER NOT NULL PRIMARY KEY,\ni INTEGER DEFAULT NULL\n);\n
\u8868\u8f93\u51fa\u7ed3\u679c\uff1a
> mysql> EXPLAIN ANALYZE SELECT * FROM t1 JOIN t2 ON (t1.c1 = t2.c2)\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN: -> Join\n*************************** 4. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=16441bytes\n*************************** 5. row ***************************\nQUERY PLAN: Join Type: INNER\n*************************** 6. row ***************************\nQUERY PLAN: Join Cond: (t1.c1 = t2.c2)\n*************************** 7. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t1\n*************************** 8. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 9. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t2\n*************************** 10. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n10 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE i > 8\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t3\n*************************** 4. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN: Filter Cond: (t3.i > 8)\n5 rows in set (0.00 sec)\n\n> EXPLAIN ANALYZE SELECT * FROM t3 WHERE pk > 17\\G\n*************************** 1. row ***************************\nQUERY PLAN: Project\n*************************** 2. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 3. row ***************************\nQUERY PLAN: -> Table Scan on tpch.t3\n*************************** 4. row ***************************\nQUERY PLAN: Analyze: timeConsumed=0ms waitTime=0ms inputRows=0 outputRows=0 InputSize=0bytes OutputSize=0bytes MemorySize=0bytes\n*************************** 5. row ***************************\nQUERY PLAN: Filter Cond: (t3.pk > 17)\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-prepared/","title":"EXPLAIN PREPARED","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-prepared/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u5728 MatrixOne \u4e2d\uff0cEXPLAIN \u662f\u4e00\u4e2a\u7528\u4e8e\u83b7\u53d6 SQL \u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u7684\u547d\u4ee4\uff0c\u800c PREPARE \u662f\u4e00\u4e2a\u7528\u6765\u521b\u5efa\u4e00\u4e2a\u51c6\u5907\u597d\u7684\u8bed\u53e5\uff08prepared statement\uff09\u7684\u547d\u4ee4\u3002\u5c06\u8fd9\u4e24\u4e2a\u547d\u4ee4\u4e00\u8d77\u4f7f\u7528\uff0c\u53ef\u4ee5\u5e26\u6765\u4ee5\u4e0b\u4f18\u52bf\uff1a
\u6027\u80fd\u8c03\u4f18\uff1a\u901a\u8fc7\u67e5\u770b\u6267\u884c\u8ba1\u5212\uff0c\u4f60\u53ef\u4ee5\u4e86\u89e3\u67e5\u8be2\u7684\u6548\u7387\uff0c\u8bc6\u522b\u6f5c\u5728\u7684\u6027\u80fd\u74f6\u9888\u3002
\u5b89\u5168\uff1a\u56e0\u4e3a PREPARE \u5206\u79bb\u4e86 SQL \u8bed\u53e5\u7684\u7ed3\u6784\u548c\u6570\u636e\uff0c\u5b83\u6709\u52a9\u4e8e\u9632\u6b62 SQL \u6ce8\u5165\u653b\u51fb\u3002
\u91cd\u7528\uff1a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u53ef\u4ee5\u88ab\u91cd\u590d\u4f7f\u7528\uff0c\u8fd9\u5728\u9700\u8981\u591a\u6b21\u6267\u884c\u76f8\u540c\u67e5\u8be2\u4f46\u4f7f\u7528\u4e0d\u540c\u53c2\u6570\u7684\u60c5\u51b5\u4e0b\u975e\u5e38\u6709\u7528\u3002
PREPARE stmt_name FROM preparable_stmt\n
EXPLAIN\n\nwhere option can be one of:\n ANALYZE [ boolean ]\n VERBOSE [ boolean ]\n (FORMAT=TEXT)\n\nFORCE EXECUTE stmt_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-prepared/#_3","title":"\u793a\u4f8b","text":"\u793a\u4f8b 1
create table t1(n1 int);\ninsert into t1 values(1);\nprepare st_t1 from 'select * from t1';\n\nmysql> explain force execute st_t1;\n+----------------------------+\n| QUERY PLAN |\n+----------------------------+\n| Project |\n| -> Table Scan on db1.t1 |\n+----------------------------+\n2 rows in set (0.01 sec)\n
\u793a\u4f8b 2
create table t2 (col1 int, col2 decimal);\ninsert into t2 values (1,2);\nprepare st from 'select * from t2 where col1 = ?';\nset @A = 1;\n\nmysql> explain force execute st using @A;\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Table Scan on db1.t2 |\n| Filter Cond: (t2.col1 = cast('1' AS INT)) |\n+---------------------------------------------------+\n3 rows in set (0.00 sec)\n\nmysql> explain verbose force execute st using @A;\n+----------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+----------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| -> Table Scan on db1.t2 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| Table: 't2' (0:'col1', 1:'col2') |\n| Filter Cond: (t2.col1 = cast('1' AS INT)) |\n+----------------------------------------------------------------------------------------+\n6 rows in set (0.00 sec)\n\nmysql> explain analyze force execute st using @A;\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| Project |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=0bytes |\n| -> Table Scan on db1.t2 |\n| Analyze: timeConsumed=0ms waitTime=0ms inputBlocks=1 inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=21bytes |\n| Filter Cond: (t2.col1 = 1) |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n5 rows in set (0.00 sec)\n\nmysql> explain analyze verbose force execute st using @A;\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n| Project (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| Analyze: timeConsumed=0ms waitTime=0ms inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=0bytes |\n| -> Table Scan on db1.t2 (cost=1000.00 outcnt=1000.00 selectivity=1.0000 blockNum=1) |\n| Output: t2.col1, t2.col2 |\n| Table: 't2' (0:'col1', 1:'col2') |\n| Analyze: timeConsumed=0ms waitTime=0ms inputBlocks=1 inputRows=1 outputRows=1 InputSize=20bytes OutputSize=20bytes MemorySize=21bytes |\n| Filter Cond: (t2.col1 = 1) |\n+-----------------------------------------------------------------------------------------------------------------------------------------------+\n8 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/","title":"EXPLAIN \u8f93\u51fa\u683c\u5f0f","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#_1","title":"\u8f93\u51fa\u7ed3\u6784","text":"\u8bed\u6cd5\u7ed3\u6784\u6267\u884c\u7ed3\u679c\u662f\u4e3a statement
\u9009\u62e9\u7684\u8ba1\u5212\u7684\u6587\u672c\u63cf\u8ff0\uff0c\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u6267\u884c\u7edf\u8ba1\u4fe1\u606f\u8fdb\u884c\u6ce8\u91ca\u3002
\u4ee5\u4e0b\u4ee5 TPCH \u4e2d\u6570\u636e\u96c6\u7684\u67e5\u8be2\u5206\u6790\u4e3a\u4f8b\uff0c\u6f14\u793a\u8f93\u51fa\u7ed3\u6784\uff1a
explain SELECT * FROM customer WHERE c_nationkey = (SELECT n_nationkey FROM nation\nWHERE customer.c_nationkey = nation.n_nationkey AND nation.n_nationkey > 5);\n
mysql> explain SELECT * FROM customer WHERE c_nationkey = (SELECT n_nationkey FROM nation\n -> WHERE customer.c_nationkey = nation.n_nationkey AND nation.n_nationkey > 5);\n+----------------------------------------------------------------------+\n| QUERY PLAN |\n+----------------------------------------------------------------------+\n| Project |\n| -> Filter |\n| Filter Cond: (customer.c_nationkey = nation.n_nationkey) |\n| -> Join |\n| Join Type: SINGLE hashOnPK |\n| Join Cond: (customer.c_nationkey = nation.n_nationkey) |\n| -> Table Scan on tpch.customer |\n| -> Table Scan on tpch.nation |\n| Filter Cond: (nation.n_nationkey > 5) |\n| Block Filter Cond: (nation.n_nationkey > 5) |\n+----------------------------------------------------------------------+\n10 rows in set (0.01 sec)\n
EXPLAIN \u8f93\u51fa\u4e00\u4e2a\u540d\u79f0\u4e3a QUERY PLAN
\u6811\u5f62\u7ed3\u6784\uff0c\u6bcf\u4e2a\u53f6\u5b50\u8282\u70b9\u90fd\u5305\u542b\u8282\u70b9\u7c7b\u578b\u3001\u53d7\u5f71\u54cd\u7684\u5bf9\u8c61\u3002\u6211\u4eec\u73b0\u5728\u53ea\u4f7f\u7528\u8282\u70b9\u7c7b\u578b\u4fe1\u606f\u6765\u7b80\u5316\u5c55\u793a\u4e0a\u9762\u7684\u793a\u4f8b\u3002QUERY PLAN
\u6811\u5f62\u7ed3\u6784\u53ef\u4ee5\u53ef\u89c6\u5316 SQL \u67e5\u8be2\u7684\u6574\u4e2a\u8fc7\u7a0b\uff0c\u663e\u793a\u5b83\u6240\u7ecf\u8fc7\u7684\u64cd\u4f5c\u8282\u70b9\u3002
Project\n\u2514\u2500\u2500 Filter\n \u2514\u2500\u2500 Join\n \u2514\u2500\u2500 Table Scan\n \u2514\u2500\u2500 Table Scan\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#_2","title":"\u8282\u70b9\u7c7b\u578b","text":"MatrixOne \u652f\u6301\u4ee5\u4e0b\u8282\u70b9\u7c7b\u578b\u3002
\u8282\u70b9\u540d\u79f0 \u542b\u4e49 Values Scan \u5904\u7406\u503c\u7684\u626b\u63cf Table Scan \u4ece\u8868\u4e2d\u626b\u63cf\u6570\u636e External Scan \u5904\u7406\u5916\u90e8\u7684\u6570\u636e\u626b\u63cf Source Scan \u5904\u7406 source \u8868\u7684\u6570\u636e\u626b\u63cf Project \u5bf9\u6570\u636e\u8fdb\u884c\u6295\u5f71\u8fd0\u7b97 Sink \u5206\u53d1\u540c\u4e00\u4efd\u6570\u636e\u7ed9\u4e00\u4e2a / \u591a\u4e2a\u5bf9\u8c61 Sink Scan \u8bfb\u53d6\u5176\u4ed6\u5bf9\u8c61\u5206\u53d1\u8fc7\u6765\u7684\u6570\u636e Recursive Scan \u5faa\u73af CTE \u8bed\u6cd5\u4e2d\uff0c\u5904\u7406\u6bcf\u6b21\u5faa\u73af\u7ed3\u675f\u65f6\u7684\u6570\u636e\uff0c\u5224\u65ad\u662f\u5426\u5f00\u542f\u4e0b\u4e00\u8f6e\u5faa\u73af CTE Scan \u5faa\u73af CTE \u8bed\u6cd5\u4e2d\uff0c\u8bfb\u6bcf\u6b21\u5faa\u73af\u5f00\u59cb\u65f6\u7684\u6570\u636e Aggregate \u5bf9\u6570\u636e\u8fdb\u884c\u805a\u5408 Filter \u5bf9\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4 Join \u5bf9\u6570\u636e\u8fdb\u884c\u8fde\u63a5\u8fd0\u7b97 Sample SAMPLE \u91c7\u6837\u51fd\u6570\uff0c\u5bf9\u6570\u636e\u8fdb\u884c\u62bd\u6837 Sort \u5bf9\u6570\u636e\u8fdb\u884c\u6392\u5e8f Partition \u8303\u56f4\u7a97\u53e3\u4e2d\u5bf9\u6570\u636e\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u6309\u503c\u5207\u5206 Union \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u7ec4\u5408 Union All \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u7ec4\u5408\uff0c\u5305\u62ec\u91cd\u590d\u884c Window \u5bf9\u6570\u636e\u8fdb\u884c\u8303\u56f4\u7a97\u53e3\u8ba1\u7b97 Time Window \u5bf9\u6570\u636e\u8fdb\u884c\u65f6\u95f4\u7a97\u53e3\u8ba1\u7b97 Fill \u5904\u7406\u65f6\u95f4\u7a97\u53e3\u4e2d\u7684 NULL \u503c Insert \u5bf9\u6570\u636e\u8fdb\u884c\u63d2\u5165 Delete \u5bf9\u6570\u636e\u8fdb\u884c\u5220\u9664 Intersect \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u90fd\u5b58\u5728\u7684\u884c\u7ec4\u5408 Intersect All \u5bf9\u4e24\u4e2a\u6216\u591a\u4e2a\u67e5\u8be2\u7684\u90fd\u5b58\u5728\u7684\u884c\u7ec4\u5408\uff0c\u5305\u62ec\u91cd\u590d\u884c Minus \u6bd4\u8f83\u4e24\u4e2a\u67e5\u8be2\u7684\u7ed3\u679c\uff0c\u8fd4\u56de\u5b58\u5728\u4e8e\u7b2c\u4e00\u4e2a\u67e5\u8be2\u800c\u5728\u7b2c\u4e8c\u4e2a\u67e5\u8be2\u4e2d\u4e0d\u5b58\u5728\u7684\u884c Table Function \u901a\u8fc7\u8868\u51fd\u6570\u8bfb\u53d6\u6570\u636e PreInsert \u6574\u7406\u8981\u5199\u5165\u7684\u6570\u636e PreInsert UniqueKey \u6574\u7406\u8981\u5199\u5165\u5230\u552f\u4e00\u952e\u9690\u85cf\u8868\u7684\u6570\u636e PreInsert SecondaryKey \u6574\u7406\u8981\u5199\u5165\u5230\u6b21\u7ea7\u7d22\u5f15\u9690\u85cf\u8868\u7684\u6570\u636e PreDelete \u6574\u7406\u5206\u533a\u8868\u6240\u9700\u8981\u5220\u9664\u7684\u6570\u636e\u3002 On Duplicate Key \u5bf9\u91cd\u590d\u7684\u6570\u636e\u8fdb\u884c\u66f4\u65b0 Fuzzy Filter for duplicate key \u5bf9\u5199\u5165/\u66f4\u65b0\u7684\u6570\u636e\u8fdb\u884c\u53bb\u91cd Lock \u5bf9\u64cd\u4f5c\u7684\u6570\u636e\u4e0a\u9501"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#_3","title":"\u793a\u4f8b","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#values-scan-project","title":"VALUES Scan & Project","text":"mysql> explain select abs(-1);\n+-------------------------------+\n| QUERY PLAN |\n+-------------------------------+\n| Project |\n| -> Values Scan \"*VALUES*\" |\n+-------------------------------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#table-scan","title":"Table Scan","text":"mysql> explain select * from customer;\n+-----------------------------------+\n| QUERY PLAN |\n+-----------------------------------+\n| Project |\n| -> Table Scan on tpch.customer |\n+-----------------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#external-scan","title":"External Scan","text":"mysql> create external table extable(n1 int)infile{\"filepath\"='yourpath/xx.csv'} ;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> explain select * from extable;\n+------------------------------------+\n| QUERY PLAN |\n+------------------------------------+\n| Project |\n| -> External Scan on db1.extable |\n+------------------------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sink-lock-delete-insert-preinsert-sink-scan","title":"Sink & Lock & Delete & Insert & PreInsert & Sink Scan","text":"mysql> create table t3(n1 int);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t3 values(1);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> explain update t3 set n1=2;\n+-----------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> Lock |\n| -> Project |\n| -> Project |\n| -> Table Scan on tpch.t3 |\n| Plan 1: |\n| Delete on tpch.t3 |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n| Plan 2: |\n| Insert on tpch.t3 |\n| -> Project |\n| -> PreInsert on tpch.t3 |\n| -> Project |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n+-----------------------------------------------+\n17 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#recursive-scan-cte-scan-filter","title":"Recursive Scan & CTE Scan & Filter","text":"mysql> create table t4(n1 int,n2 int);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> insert into t4 values(1,1),(2,2),(3,3);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> explain WITH RECURSIVE t4_1(n1_1) AS (\n-> SELECT n1 FROM t4 -> UNION all\n-> SELECT n1_1 FROM t4_1 WHERE n1_1=1\n-> )\n-> SELECT * FROM t4_1;\n+---------------------------------------------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> Project |\n| -> Table Scan on tpch.t4 |\n| Plan 1: |\n| Sink |\n| -> Project |\n| -> Filter |\n| Filter Cond: (t4_1.n1_1 = 1), mo_check_level((t4_1.__mo_recursive_level_col < 100)) |\n| -> Recursive Scan |\n| DataSource: Plan 2 |\n| Plan 2: |\n| Sink |\n| -> CTE Scan |\n| DataSource: Plan 0, Plan 1 |\n| Plan 3: |\n| Project |\n| -> Sink Scan |\n| DataSource: Plan 2 |\n+---------------------------------------------------------------------------------------------------+\n19 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#aggregate","title":"Aggregate","text":"mysql> explain SELECT count(*) FROM NATION group by N_NAME;\n+-------------------------------------------+\n| QUERY PLAN |\n+-------------------------------------------+\n| Project |\n| -> Aggregate |\n| Group Key: nation.n_name |\n| Aggregate Functions: starcount(1) |\n| -> Table Scan on tpch.nation |\n+-------------------------------------------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#join","title":"Join","text":"mysql> create table t5(n1 int);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> insert into t5 values(1),(2),(3);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> create table t6(n1 int);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> insert into t5 values(3),(4),(5);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> explain SELECT * FROM t5 LEFT JOIN t6 ON t5.n1 = t6.n1;\n+------------------------------------+\n| QUERY PLAN |\n+------------------------------------+\n| Project |\n| -> Join |\n| Join Type: LEFT |\n| Join Cond: (t5.n1 = t6.n1) |\n| -> Table Scan on tpch.t5 |\n| -> Table Scan on tpch.t6 |\n+------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sample","title":"Sample","text":"mysql> explain SELECT SAMPLE(c_address, 90 percent) FROM customer;\n+-----------------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------------+\n| Project |\n| -> Sample |\n| Sample 90.00 Percent by: customer.c_address |\n| -> Table Scan on tpch.customer |\n+-----------------------------------------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#sort","title":"SORT","text":"mysql> explain select * from customer order by c_custkey;\n+-----------------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------------+\n| Project |\n| -> Sort |\n| Sort Key: customer.c_custkey INTERNAL |\n| -> Table Scan on tpch.customer |\n+-----------------------------------------------+\n4 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#partition-window","title":"Partition & Window","text":"mysql>CREATE TABLE t7(n1 int,n2 int);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> INSERT INTO t7 values(1,3),(2,2),(3,1);\nQuery OK, 3 rows affected (0.01 sec)\n\nmysql> explain SELECT SUM(n1) OVER(PARTITION BY n2) AS sn1 FROM t7;\n+----------------------------------------------------------+\n| QUERY PLAN |\n+----------------------------------------------------------+\n| Project |\n| -> Window |\n| Window Function: sum(t7.n1); Partition By: t7.n2 |\n| -> Partition |\n| Sort Key: t7.n2 INTERNAL |\n| -> Table Scan on tpch.t7 |\n+----------------------------------------------------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#time-window-fill","title":"Time window & Fill","text":"mysql> CREATE TABLE sensor_data (ts timestamp(3) primary key, temperature FLOAT);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> INSERT INTO sensor_data VALUES('2023-08-01 00:00:00', 25.0);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> INSERT INTO sensor_data VALUES('2023-08-01 00:05:00', 26.0);\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> explain select _wstart, _wend from sensor_data interval(ts, 10, minute) fill(prev);\n+---------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------+\n| Project |\n| -> Fill |\n| Fill Columns: |\n| Fill Mode: Prev |\n| -> Time window |\n| Sort Key: sensor_data.ts |\n| Aggregate Functions: _wstart, _wend |\n| -> Table Scan on db2.sensor_data |\n+---------------------------------------------------+\n8 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#intersect","title":"Intersect","text":"mysql> explain select * from t5 intersect select * from t6;\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Intersect |\n| -> Project |\n| -> Table Scan on tpch.t5 |\n| -> Project |\n| -> Table Scan on tpch.t6 |\n+-----------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#intersect-all","title":"Intersect All","text":"mysql> explain select * from t5 intersect all select * from t6;\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Intersect All |\n| -> Project |\n| -> Table Scan on tpch.t5 |\n| -> Project |\n| -> Table Scan on tpch.t6 |\n+-----------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#minus","title":"Minus","text":"mysql> explain select * from t5 minus select * from t6;\n+-----------------------------------------+\n| QUERY PLAN |\n+-----------------------------------------+\n| Project |\n| -> Minus |\n| -> Project |\n| -> Table Scan on tpch.t5 |\n| -> Project |\n| -> Table Scan on tpch.t6 |\n+-----------------------------------------+\n6 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#table-function","title":"Table Function","text":"mysql> explain select * from unnest('{\"a\":1}') u;\n+-------------------------------------+\n| QUERY PLAN |\n+-------------------------------------+\n| Project |\n| -> Table Function on unnest |\n| -> Values Scan \"*VALUES*\" |\n+-------------------------------------+\n3 rows in set (0.10 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#preinsert-uniquekey-fuzzy-filter-for-duplicate-key","title":"PreInsert UniqueKey & Fuzzy Filter for duplicate key","text":"mysql> CREATE TABLE t8(n1 int,n2 int UNIQUE key);\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> explain INSERT INTO t8(n2) values(1);\n+---------------------------------------------------------------------------------+\n| QUERY PLAN |\n+---------------------------------------------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> PreInsert on tpch.t8 |\n| -> Project |\n| -> Project |\n| -> Values Scan \"*VALUES*\" |\n| Plan 1: |\n| Sink |\n| -> Lock |\n| -> PreInsert UniqueKey |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n| Plan 2: |\n| Insert on tpch.__mo_index_unique_018e2d16-6629-719d-82b5-036222e9658a |\n| -> Sink Scan |\n| DataSource: Plan 1 |\n| Plan 3: |\n| Fuzzy Filter for duplicate key |\n| -> Table Scan on tpch.__mo_index_unique_018e2d16-6629-719d-82b5-036222e9658a |\n| Filter Cond: (__mo_index_idx_col = 1) |\n| Block Filter Cond: (__mo_index_idx_col = 1) |\n| -> Sink Scan |\n| DataSource: Plan 1 |\n| Plan 4: |\n| Insert on tpch.t8 |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n+---------------------------------------------------------------------------------+\n27 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain-workflow/#preinsert-secondarykey","title":"PreInsert SecondaryKey","text":"mysql> CREATE TABLE t9 ( n1 int , n2 int, KEY key2 (n2) USING BTREE);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> explain INSERT INTO t9(n2) values(2);\n+--------------------------------------------------------------------------+\n| QUERY PLAN |\n+--------------------------------------------------------------------------+\n| Plan 0: |\n| Sink |\n| -> PreInsert on tpch.t9 |\n| -> Project |\n| -> Project |\n| -> Values Scan \"*VALUES*\" |\n| Plan 1: |\n| Insert on tpch.__mo_index_secondary_018e2d14-6f20-7db0-babb-c1fd505fd3c5 |\n| -> Lock |\n| -> PreInsert SecondaryKey |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n| Plan 2: |\n| Insert on tpch.t9 |\n| -> Sink Scan |\n| DataSource: Plan 0 |\n+--------------------------------------------------------------------------+\n16 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/","title":"EXPLAIN","text":"EXPLAIN \u2014 \u5c55\u793a\u4e00\u4e2a\u8bed\u53e5\u7684\u6267\u884c\u8ba1\u5212\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#_1","title":"\u8bed\u6cd5\u7ed3\u6784","text":"EXPLAIN [ ( option [, ...] ) ] statement\n\nwhere option can be one of:\n ANALYZE [ boolean ]\n VERBOSE [ boolean ]\n (FORMAT=TEXT)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Explain/explain/#_2","title":"\u8bed\u6cd5\u63cf\u8ff0","text":"\u6b64\u547d\u4ee4\u4e3b\u8981\u4f5c\u7528\u662f\u663e\u793a\u51fa MatrixOne \u8ba1\u5212\u7a0b\u5e8f\u4e3a\u63d0\u4f9b\u7684\u8bed\u53e5\u751f\u6210\u7684\u6267\u884c\u8ba1\u5212\u3002\u6267\u884c\u8ba1\u5212\u663e\u793a\u4e86\u5982\u4f55\u901a\u8fc7\u666e\u901a\u987a\u5e8f\u626b\u63cf\u3001\u7d22\u5f15\u626b\u63cf\u7b49\u65b9\u5f0f\u626b\u63cf\u8bed\u53e5\u5f15\u7528\u7684\u8868\uff0c\u5982\u679c\u5f15\u7528\u4e86\u591a\u4e2a\u8868\uff0c\u5c06\u4f7f\u7528\u4ec0\u4e48\u8fde\u63a5\u7b97\u6cd5\u5c06\u6bcf\u4e2a\u8f93\u5165\u8868\u4e2d\u6240\u9700\u7684\u884c\u805a\u96c6\u5728\u4e00\u8d77\u3002
\u663e\u793a\u7684\u6700\u5173\u952e\u90e8\u5206\u662f\u4f30\u8ba1\u8bed\u53e5\u6267\u884c\u6210\u672c\uff0c\u5373\u8ba1\u5212\u7a0b\u5e8f\u5c06\u4f30\u8ba1\u8fd0\u884c\u8bed\u53e5\u6240\u9700\u65f6\u95f4 (\u4ee5\u4efb\u610f\u4e00\u79cd\u6210\u672c\u5355\u4f4d\u8861\u91cf\uff0c\u4f46\u901a\u5e38\u662f\u901a\u8fc7\u78c1\u76d8\u9875\u83b7\u53d6)\u3002\u5b9e\u9645\u4e0a\u8fd9\u91cc\u663e\u793a\u4e86\u4e24\u4e2a\u6570\u5b57\uff1a\u8fd4\u56de\u7b2c\u4e00\u884c\u4e4b\u524d\u7684\u542f\u52a8\u6210\u672c\uff0c\u4ee5\u53ca\u8fd4\u56de\u6240\u6709\u884c\u7684\u603b\u6210\u672c\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u67e5\u8be2\u6765\u8bf4\uff0c\u603b\u6210\u672c\u662f\u6700\u91cd\u8981\u7684\uff0c\u4f46\u5728 EXISTS
\u4e2d\u7684\u5b50\u67e5\u8be2\u4e2d\uff0c\u8ba1\u5212\u7a0b\u5e8f\u4f1a\u9009\u62e9\u6700\u5c0f\u7684\u542f\u52a8\u6210\u672c\uff0c\u800c\u4e0d\u662f\u6700\u5c0f\u7684\u603b\u6210\u672c (\u56e0\u4e3a\u6267\u884c\u8005\u5728\u83b7\u5f97\u4e00\u884c\u4e4b\u540e\u5c31\u4f1a\u505c\u6b62)\u3002\u6b64\u5916\uff0c\u5982\u679c\u60a8\u4f7f\u7528 LIMIT
\u4ece\u53e5\u9650\u5236\u8fd4\u56de\u7684\u884c\u6570\uff0c\u8ba1\u5212\u7a0b\u5e8f\u5c06\u5728\u7aef\u70b9\u6210\u672c\u4e4b\u95f4\u8fdb\u884c\u9002\u5f53\u7684\u63d2\u503c\uff0c\u4ee5\u4fbf\u4f30\u8ba1\u54ea\u4e2a\u8ba1\u5212\u771f\u6b63\u662f\u6700\u4fbf\u5b9c\u7684\u3002
ANALYZE
\u5b50\u53e5\u8bed\u6cd5\u9009\u9879\u4e3a\u8bed\u53e5\u5b9e\u9645\u6267\u884c\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u8ba1\u5212\u6267\u884c\uff0c\u7136\u540e\u5c06\u5b9e\u9645\u8fd0\u884c\u65f6\u7edf\u8ba1\u4fe1\u606f\u6dfb\u52a0\u5230\u663e\u793a\u4e2d\uff0c\u5305\u62ec\u6bcf\u4e2a\u8ba1\u5212\u8282\u70b9\u4e2d\u82b1\u8d39\u7684\u603b\u8fd0\u884c\u65f6\u95f4 (\u4ee5\u6beb\u79d2\u4e3a\u5355\u4f4d) \u548c\u5b9e\u9645\u8fd4\u56de\u7684\u884c\u603b\u6570\u3002\u8fd9\u6709\u52a9\u4e8e\u4e86\u89e3\u89c4\u5212\u8005\u7684\u671f\u671b\u662f\u5426\u63a5\u8fd1\u5b9e\u9645\u3002
\u6267\u884c\u8be5\u547d\u4ee4\u5e76\u663e\u793a\u5b9e\u9645\u8fd0\u884c\u65f6\u548c\u5176\u4ed6\u7edf\u8ba1\u6570\u636e\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a FALSE
\u3002
VERBOSE
\u7528\u4f5c\u663e\u793a\u6709\u5173\u8ba1\u5212\u7684\u5176\u4ed6\u4fe1\u606f\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5305\u62ec\u8ba1\u5212\u6811\u4e2d\u6bcf\u4e2a\u8282\u70b9\u7684\u8f93\u51fa\u5217\u5217\u8868\u3001\u6a21\u5f0f\u9650\u5b9a\u8868\u548c\u51fd\u6570\u540d\u79f0\uff0c\u59cb\u7ec8\u4f7f\u7528\u8303\u56f4\u8868\u522b\u540d\u6807\u8bb0\u8868\u8fbe\u5f0f\u4e2d\u7684\u53d8\u91cf\uff0c\u5e76\u4e14\u59cb\u7ec8\u6253\u5370\u663e\u793a\u7edf\u8ba1\u4fe1\u606f\u7684\u6bcf\u4e2a\u89e6\u53d1\u5668\u7684\u540d\u79f0\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a FALSE
\u3002
FORMAT
\u7528\u4f5c\u6307\u5b9a\u8f93\u51fa\u683c\u5f0f\uff0c\u8bed\u6cd5\u4e3a explain ( format xx )
\uff0c\u6682\u53ea\u652f\u6301 TEXT
\u683c\u5f0f\u3002\u975e\u6587\u672c\u8f93\u51fa\u5305\u542b\u4e0e\u6587\u672c\u8f93\u51fa\u683c\u5f0f\u76f8\u540c\u7684\u4fe1\u606f\uff0c\u4e14\u5bb9\u6613\u88ab\u7a0b\u5e8f\u89e3\u6790\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a TEXT
\u3002
BOOLEAN
\u6307\u5b9a\u6240\u9009\u9009\u9879\u662f\u6253\u5f00\u8fd8\u662f\u5173\u95ed\u3002\u4f60\u53ef\u4ee5\u5199 TRUE
\u6765\u542f\u7528\u8be5\u9009\u9879\uff0c\u6216\u8005\u5199 FALSE
\u6765\u7981\u7528\u5b83\u3002\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a TRUE
\u3002
MatrixOne \u652f\u6301\u4efb\u4f55 SELECT
\uff0cINSERT
\uff0cUPDATE
\uff0cDELETE
\u8bed\u53e5\u6267\u884c\u8ba1\u5212\u3002
\u76ee\u524d MatrixOne \u7684 DDL \u8bed\u53e5\u652f\u6301\u7684 6 \u79cd\u5206\u533a\u7c7b\u578b\uff0c\u4e0e MySQL \u5b98\u7f51\u57fa\u672c\u4e00\u81f4\uff0c\u5177\u4f53\u5982\u4e0b\uff1a
\u5206\u533a\u952e\uff08Partition Keys\uff09\u3001\u4e3b\u952e\uff08Primary Keys\uff09\u548c\u552f\u4e00\u952e\uff08Unique Keys\uff09\u7684\u5173\u7cfb\u89c4\u5219\u53ef\u4ee5\u6982\u62ec\u4e3a\uff1a
\u5206\u533a\u8868\u7684\u5206\u533a\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528\u7684\u6240\u6709\u5217\u5fc5\u987b\u662f\u8be5\u8868\u53ef\u80fd\u5177\u6709\u7684\u6bcf\u4e2a\u552f\u4e00\u952e\u7684\u4e00\u90e8\u5206\u3002
Note
\u552f\u4e00\u952e\u5305\u62ec PrimaryKey \u548c Unique KEY\u3002
\u200b \u4e5f\u5c31\u662f\u8bf4\uff0c\u8868\u4e0a\u7684\u6bcf\u4e2a\u552f\u4e00\u952e\u5fc5\u987b\u4f7f\u7528\u8868\u7684\u5206\u533a\u8868\u8fbe\u5f0f\u4e2d\u7684\u6bcf\u4e00\u5217\u3002\u552f\u4e00\u952e\u4e5f\u5305\u62ec\u8868\u7684\u4e3b\u952e\uff0c\u56e0\u4e3a\u6839\u636e\u5b9a\u4e49\uff0c\u8868\u7684\u4e3b\u952e\u4e5f\u662f\u552f\u4e00\u952e\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#_1","title":"\u793a\u4f8b\u8bf4\u660e","text":"\u4f8b\u5982\uff0c\u4ee5\u4e0b\u6bcf\u4e2a\u8868\u521b\u5efa\u8bed\u53e5\u90fd\u65e0\u6548\uff1a
> CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY HASH(col3)\nPARTITIONS 4;\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n
> CREATE TABLE t2 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1),\nUNIQUE KEY (col3)\n)\nPARTITION BY HASH(col1 + col3)\nPARTITIONS 4;\n\nERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#key-null","title":"\u5173\u4e8e KEY \u5206\u533a\u952e\u4e3a NULL","text":"KEY \u53ea\u63a5\u53d7\u96f6\u4e2a\u6216\u591a\u4e2a\u5217\u540d\u7684\u5217\u8868\u3002\u5728\u8868\u6709\u4e3b\u952e\u7684\u60c5\u51b5\u4e0b\uff0c\u7528\u4f5c\u5206\u533a\u952e\u7684\u4efb\u4f55\u5217\u5fc5\u987b\u5305\u542b\u8868\u4e3b\u952e\u7684\u4e00\u90e8\u5206\u6216\u5168\u90e8\u3002
\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u5217\u540d\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u5219\u4f7f\u7528\u8868\u7684\u4e3b\u952e\uff08\u5982\u679c\u6709\uff09\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b CREATE TABLE
\u8bed\u53e5\u5728 MySQL \u4e2d\u6709\u6548\u3002
\u5982\u679c\u6ca1\u6709\u4e3b\u952e\uff0c\u4f46\u6709 UNIQUE KEY\uff0c\u90a3\u4e48 UNIQUE KEY \u7528\u4e8e\u5206\u533a\u952e\u3002
\u200b \u4f8b\u5982\uff0c\u4ee5\u4e0b\u5efa\u8868\u8bed\u53e5\u4e2d\uff0cKEY \u5206\u533a\u5206\u533a\u952e\u4e3a NULL\uff0c\u6ca1\u6709\u5b9a\u4e49\u4e3b\u952e\uff0c\u4f46\u662f\u542b\u6709\u552f\u4e00\u952e\uff0c\u6784\u5efa\u5206\u533a\u8868\u8fbe\u5f0f\u65f6\u5219\u4f7f\u7528\u552f\u4e00\u952e\u4f5c\u4e3a\u5206\u533a\u952e\uff1a
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nUNIQUE KEY (col1, col2)\n)\nPARTITION BY KEY()\nPARTITIONS 4;\n
Note
\u5176\u4ed6\u5206\u533a\u89c4\u5219\u4e0e MySQL \u57fa\u672c\u4fdd\u6301\u4e00\u81f4\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#3-matrixone","title":"3. \u5173\u4e8e MatrixOne \u5206\u533a\u8868\u8fbe\u5f0f\u7684\u8bf4\u660e","text":"\u200b \u5728 DDL \u8bed\u53e5\u6784\u5efa\u5206\u533a\u8868\u65f6\uff0c\u4f1a\u9488\u5bf9\u6bcf\u4e00\u79cd\u5206\u533a\u5b9a\u4e49\u751f\u6210\u4e00\u4e2a\u5206\u533a\u8868\u8fbe\u5f0f\uff0c\u8be5\u5206\u533a\u8868\u8fbe\u5f0f\u53ef\u7528\u4e8e\u8ba1\u7b97\u6570\u636e\u7684\u6240\u5c5e\u7684\u5206\u533a\u3002
\u5728\u8ba1\u5212\u6784\u5efa\u9636\u6bb5\u5bf9 DDL \u8bed\u53e5\u4e2d\u7684\u5206\u533a\u4fe1\u606f\u6570\u636e\u7ed3\u6784\u4e3a plan.PartitionInfo\uff1a
type PartitionInfo struct {\nType PartitionType\nExpr *Expr\nPartitionExpression *Expr\nColumns []*Expr\nPartitionColumns []string\nPartitionNum uint64\nPartitions []*PartitionItem\nAlgorithm int64\nIsSubPartition bool\nPartitionMsg string\n}\n
\u5176\u4e2d PartitionExpression
\u5373\u4e3a\u5206\u533a\u8868\u8fbe\u5f0f\u3002\u5206\u533a\u8868\u8fbe\u5f0f\u4e3a MatrixOne \u628a\u5206\u533a\u5b50\u53e5\u8f6c\u6362\u4e3a\u4e00\u4e2a\u8868\u8fbe\u5f0f\u8fdb\u884c\u5904\u7406\u7684\u65b9\u5f0f\uff0c\u5bf9\u6bcf\u4e00\u79cd\u5206\u533a\u8868\u8fbe\u5f0f\u7684\u6784\u5efa\u65b9\u5f0f\u5982\u4e0b\uff1a
KEY \u5206\u533a\u4f1a\u6839\u636e\u5206\u533a\u952e\u548c\u5206\u533a\u6570\u91cf\uff0c\u6784\u5efa\u4e00\u4e2a\u5206\u533a\u8868\u8fbe\u5f0f\uff0c\u5206\u533a\u8868\u8fbe\u5f0f\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a\u4e00\u4e2a\u5927\u4e8e\u7b49\u4e8e 0 \u7684\u6574\u6570\uff0c\u4ee3\u8868\u5206\u533a\u5e8f\u53f7\uff0c\u4ece\u96f6\u5f00\u59cb\u4f9d\u6b21\u9012\u589e\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE t1 (\ncol1 INT NOT NULL,\ncol2 DATE NOT NULL,\ncol3 INT NOT NULL,\ncol4 INT NOT NULL,\nPRIMARY KEY (col1, col2)\n)\nPARTITION BY KEY(col1)\nPARTITIONS 4;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#hash-partitioning","title":"HASH Partitioning","text":"\u200b \u4e0e KEY \u5206\u533a\u7c7b\u4f3c\uff0cHASH \u5206\u533a\u4f1a\u6839\u636e\u5206\u533a\u51fd\u6570\u548c\u5206\u533a\u6570\u91cf\uff0c\u6784\u5efa\u4e00\u4e2a\u5206\u533a\u8868\u8fbe\u5f0f\uff0c\u5206\u533a\u8868\u8fbe\u5f0f\u7684\u8ba1\u7b97\u7ed3\u679c\u4e3a\u4e00\u4e2a\u5927\u4e8e\u7b49\u4e8e 0 \u7684\u6574\u6570\uff0c\u4ee3\u8868\u5206\u533a\u5e8f\u53f7\uff0c\u4ece\u96f6\u5f00\u59cb\u4f9d\u6b21\u9012\u589e\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE t1 (\ncol1 INT,\ncol2 CHAR(5),\ncol3 DATE\n)\nPARTITION BY LINEAR HASH( YEAR(col3))\nPARTITIONS 6;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#range-partitioning","title":"RANGE Partitioning","text":"\u200bRANGE \u5206\u533a\u662f\u57fa\u4e8e\u5217\u503c\u7684\u8303\u56f4\u5c06\u8868\u7684\u6570\u636e\u5212\u5206\u5230\u4e0d\u540c\u7684\u5206\u533a\u4e2d\u7684\u4e00\u79cd\u65b9\u6cd5\u3002\u8fd9\u79cd\u5206\u533a\u7c7b\u578b\u975e\u5e38\u9002\u5408\u4e8e\u90a3\u4e9b\u53ef\u4ee5\u6839\u636e\u7279\u5b9a\u5217\u7684\u503c\u8303\u56f4\u8fdb\u884c\u5206\u6bb5\u7684\u6570\u636e\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE employees (\nid INT NOT NULL,\nfname VARCHAR(30),\nlname VARCHAR(30),\nhired DATE NOT NULL DEFAULT '1970-01-01',\nseparated DATE NOT NULL DEFAULT '9999-12-31',\njob_code INT NOT NULL,\nstore_id INT NOT NULL\n)\nPARTITION BY RANGE (store_id) (\nPARTITION p0 VALUES LESS THAN (6),\nPARTITION p1 VALUES LESS THAN (11),\nPARTITION p2 VALUES LESS THAN (16),\nPARTITION p3 VALUES LESS THAN MAXVALUE\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#range-columns-partitioning","title":"RANGE COLUMNS partitioning","text":"\u200bRANGE COLUMNS \u5206\u533a\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u7684\u7ec4\u5408\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u6bcf\u4e2a\u5206\u533a\u5b9a\u4e49\u4e86\u4e00\u4e2a\u503c\u8303\u56f4\uff0c\u5bf9\u5e94\u4e8e\u5206\u533a\u952e\u5217\u7684\u7ec4\u5408\u503c\uff0c\u5f53\u63d2\u5165\u6570\u636e\u65f6\uff0c\u6839\u636e\u8fd9\u4e9b\u5217\u7684\u503c\u786e\u5b9a\u884c\u6240\u5c5e\u7684\u5206\u533a\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE rc (\na INT NOT NULL,\nb INT NOT NULL\n)\nPARTITION BY RANGE COLUMNS(a,b) (\nPARTITION p0 VALUES LESS THAN (10,5) COMMENT = 'Data for LESS THAN (10,5)',\nPARTITION p1 VALUES LESS THAN (20,10) COMMENT = 'Data for LESS THAN (20,10)',\nPARTITION p2 VALUES LESS THAN (50,MAXVALUE) COMMENT = 'Data for LESS THAN (50,MAXVALUE)',\nPARTITION p3 VALUES LESS THAN (65,MAXVALUE) COMMENT = 'Data for LESS THAN (65,MAXVALUE)',\nPARTITION p4 VALUES LESS THAN (MAXVALUE,MAXVALUE) COMMENT = 'Data for LESS THAN (MAXVALUE,MAXVALUE)'\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#list-partitioning","title":"LIST Partitioning","text":"\u200bLIST \u5206\u533a\u662f\u57fa\u4e8e\u5355\u4e2a\u5217\u7684\u79bb\u6563\u503c\u6765\u5212\u5206\u6570\u636e\uff0c\u6bcf\u4e2a\u5206\u533a\u5305\u542b\u4e86\u5217\u503c\u7684\u4e00\u4e2a\u7279\u5b9a\u5217\u8868\uff0c\u5f53\u63d2\u5165\u6570\u636e\u65f6\uff0c\u884c\u6839\u636e\u8be5\u5217\u7684\u503c\u88ab\u5206\u914d\u5230\u76f8\u5e94\u7684\u5206\u533a\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE client_firms (\nid INT,\nname VARCHAR(35)\n)\nPARTITION BY LIST (id) (\nPARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21),\nPARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22),\nPARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23),\nPARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24)\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Partition/mo-partition-support/#list-columns-partitioning","title":"LIST COLUMNS partitioning","text":"\u200bLIST COLUMNS \u5206\u533a\u7c7b\u4f3c\u4e8e LIST \u5206\u533a\uff0c\u4f46\u5141\u8bb8\u4f7f\u7528\u4e00\u4e2a\u6216\u591a\u4e2a\u5217\u7684\u7ec4\u5408\u4f5c\u4e3a\u5206\u533a\u952e\uff0c\u5206\u533a\u662f\u57fa\u4e8e\u5217\u503c\u7ec4\u5408\u7684\u7279\u5b9a\u5217\u8868\uff0c\u63d2\u5165\u884c\u65f6\uff0c\u6839\u636e\u8fd9\u4e9b\u5217\u7684\u7ec4\u5408\u503c\u6765\u786e\u5b9a\u5176\u5206\u533a\u3002
SQL \u793a\u4f8b\u5982\u4e0b\uff1a
CREATE TABLE lc (\na INT NULL,\nb INT NULL\n)\nPARTITION BY LIST COLUMNS(a,b) (\nPARTITION p0 VALUES IN( (0,0), (NULL,NULL) ),\nPARTITION p1 VALUES IN( (0,1), (0,2) ),\nPARTITION p2 VALUES IN( (1,0), (2,0) )\n);\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/","title":"DEALLOCATE PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"DEALLOCATE PREPARE
\u8bed\u53e5\u7684\u4f5c\u7528\u662f\u91ca\u653e\u4f7f\u7528 PREPARE
\u751f\u6210\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u3002\u5728\u91ca\u653e\u9884\u7f16\u8bd1\u8bed\u53e5\u540e\uff0c\u518d\u6b21\u6267\u884c\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002\u82e5\u521b\u5efa\u4e86\u8fc7\u591a\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u5e76\u4e14\u6ca1\u6709\u4f7f\u7528 DEALLOCATE PREPARE
\u8bed\u53e5\u8fdb\u884c\u91ca\u653e\uff0c\u90a3\u4e48\u7cfb\u7edf\u53d8\u91cf\u4f1a\u5f3a\u5236\u6267\u884c\u9884\u7f16\u8bd1\u8bed\u53e5\u4e0a\u9650 max_prepared_stmt_count
\u63d0\u793a\u3002
{DEALLOCATE | DROP} PREPARE stmt_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/deallocate/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk | ui | si |\n+------+------+----------------------+\n| 0 | 0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk | ui | si |\n+------+----------------------+---------------------+\n| 1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/","title":"EXECUTE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"EXECUTE
\u8bed\u53e5\u7684\u4f5c\u7528\u662f\uff1a\u4f7f\u7528 PREPARE
\u51c6\u5907\u597d\u4e00\u6761\u8bed\u53e5\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 EXECUTE
\u8bed\u53e5\u5f15\u7528\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u540d\u79f0\u5e76\u6267\u884c\u3002\u5982\u679c\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u5305\u542b\u4efb\u4f55\u53c2\u6570\u6807\u8bb0\uff0c\u5219\u5fc5\u987b\u63d0\u4f9b\u4e00\u4e2a USING
\u5b50\u53e5\uff0c\u8be5\u5b50\u53e5\u5217\u51fa\u5305\u542b\u8981\u7ed1\u5b9a\u5230\u53c2\u6570\u7684\u503c\u7684\u7528\u6237\u53d8\u91cf\u3002\u53c2\u6570\u503c\u53ea\u80fd\u7531\u7528\u6237\u53d8\u91cf\u63d0\u4f9b\uff0c\u5e76\u4e14 USING
\u5b50\u53e5\u5fc5\u987b\u547d\u540d\u4e0e\u8bed\u53e5\u4e2d\u53c2\u6570\u6807\u8bb0\u7684\u6570\u91cf\u4e00\u6837\u591a\u7684\u53d8\u91cf\u3002
\u4f60\u53ef\u4ee5\u591a\u6b21\u6267\u884c\u7ed9\u5b9a\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u5c06\u4e0d\u540c\u7684\u53d8\u91cf\u4f20\u9012\u7ed9\u5b83\uff0c\u6216\u8005\u5728\u6bcf\u6b21\u6267\u884c\u4e4b\u524d\u5c06\u53d8\u91cf\u8bbe\u7f6e\u4e3a\u4e0d\u540c\u7684\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"EXECUTE stmt_name\n [USING @var_name [, @var_name] ...]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/execute/#_4","title":"\u793a\u4f8b","text":"> CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\n> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\n> SET @si_min = -9223372036854775808;\n> SET @si_max = 9223372036854775807;\n> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.00 sec)\n\n> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk | ui | si |\n+------+------+----------------------+\n| 0 | 0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.01 sec)\n\n> EXECUTE s2 USING @si_max;\n+------+----------------------+---------------------+\n| pk | ui | si |\n+------+----------------------+---------------------+\n| 1 | 18446744073709551615 | 9223372036854775807 |\n+------+----------------------+---------------------+\n1 row in set (0.01 sec)\n\n> DEALLOCATE PREPARE s2;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/","title":"PREPARE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"PREPARE
\u8bed\u53e5\u51c6\u5907\u4e00\u6761 SQL \u8bed\u53e5\u5e76\u7ed9\u5b83\u5206\u914d\u4e00\u4e2a\u540d\u79f0\u3002
\u51c6\u5907\u597d\u7684\u8bed\u53e5\u7528 EXECUTE
\u6267\u884c\uff0c\u7528 DEALLOCATE PREPARE
\u91ca\u653e\u3002
SQL \u8bed\u53e5\u7684\u547d\u540d\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"PREPARE stmt_name FROM preparable_stmt\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_3","title":"\u53c2\u6570\u91ca\u4e49","text":"\u53c2\u6570 \u8bf4\u660e stmt_name \u9884\u7f16\u8bd1\u7684 SQL \u8bed\u53e5\u7684\u540d\u79f0 preparable_stmt \u5305\u542b SQL \u8bed\u53e5\u6587\u672c\u7684\u5b57\u7b26\u4e32\u6587\u5b57\u6216\u7528\u6237\u53d8\u91cf\u3002\u6587\u672c\u5fc5\u987b\u4ee3\u8868\u5355\u4e2a\u8bed\u53e5\uff0c\u800c\u4e0d\u662f\u591a\u4e2a\u8bed\u53e5\u3002\u5728\u58f0\u660e\u4e2d\uff0c? \u5b57\u7b26\u53ef\u7528\u4f5c\u53c2\u6570\u6807\u8bb0\uff0c\u4ee5\u6307\u793a\u7a0d\u540e\u5728\u6267\u884c\u67e5\u8be2\u65f6\u5c06\u6570\u636e\u503c\u7ed1\u5b9a\u5230\u67e5\u8be2\u7684\u4f4d\u7f6e\u3002? \u5b57\u7b26\u4e0d\u5305\u542b\u5728\u5f15\u53f7\u5185\uff0c\u5373\u4f7f\u4f60\u6253\u7b97\u5c06\u5b83\u4eec\u7ed1\u5b9a\u5230\u5b57\u7b26\u4e32\u503c\u3002\u53c2\u6570\u6807\u8bb0\u53ea\u80fd\u7528\u4e8e\u5e94\u51fa\u73b0\u6570\u636e\u503c\u7684\u5730\u65b9\uff0c\u4e0d\u80fd\u7528\u4e8e SQL \u5173\u952e\u5b57\u3001\u6807\u8bc6\u7b26\u7b49\u3002 \u5982\u679c\u5df2\u5b58\u5728\u5177\u6709\u7ed9\u5b9a\u540d\u79f0\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u5219\u5728\u51c6\u5907\u65b0\u7684\u8bed\u53e5\u4e4b\u524d\u9700\u8981\u5c06\u5176\u9690\u5f0f\u91ca\u653e\u3002
\u9884\u7f16\u8bd1\u8bed\u53e5\u521b\u5efa\u65f6\u9700\u8981\u4e86\u89e3\u4ee5\u4e0b\u51e0\u70b9\uff1a
\u5728\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u521b\u5efa\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u4e0d\u53ef\u7528\u4e8e\u5176\u4ed6\u4f1a\u8bdd\u3002
\u5728\u4e00\u4e2a\u4f1a\u8bdd\u4e2d\u521b\u5efa\u7684\u51c6\u5907\u597d\u7684\u8bed\u53e5\u4e0d\u9002\u7528\u4e8e\u5176\u4ed6\u4f1a\u8bdd\u3002
\u5f53\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u65e0\u8bba\u662f\u6b63\u5e38\u8fd8\u662f\u5f02\u5e38\uff0c\u5176\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u90fd\u4e0d\u518d\u5b58\u5728\u3002\u5982\u679c\u542f\u7528\u4e86\u81ea\u52a8\u91cd\u65b0\u8fde\u63a5\uff0c\u4e5f\u4e0d\u4f1a\u901a\u77e5\u5ba2\u6237\u7aef\u8fde\u63a5\u4e22\u5931\u3002\u56e0\u6b64\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\u7981\u7528\u81ea\u52a8\u91cd\u65b0\u8fde\u63a5\u3002
\u5728\u9884\u7f16\u8bd1\u7684\u8bed\u53e5\u4e2d\u4f7f\u7528\u7684\u53c2\u6570\u9700\u8981\u518d\u9996\u6b21\u51c6\u5907\u8bed\u53e5\u65f6\u786e\u5b9a\u5176\u7c7b\u578b\uff0c\u5e76\u4e14\u5728\u4f7f\u7528 EXECUTE
\u8fd0\u884c\u9884\u7f16\u8bd1\u8bed\u53e5\u65f6\u4fdd\u7559\u53c2\u6570\u7c7b\u578b\u3002\u4ee5\u4e0b\u5185\u5bb9\u5217\u51fa\u4e86\u786e\u5b9a\u53c2\u6570\u7c7b\u578b\u7684\u89c4\u5219\uff1a
\u4e8c\u5143\u7b97\u672f\u8fd0\u7b97\u7b26\u7684\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u53c2\u6570\u6570\u636e\u7c7b\u578b\u9700\u4e00\u81f4\u3002
\u5982\u679c\u4e8c\u5143\u7b97\u672f\u8fd0\u7b97\u7b26\u7684\u4e24\u4e2a\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u7531\u8fd0\u7b97\u7b26\u7684\u4e0a\u4e0b\u6587\u51b3\u5b9a\u3002
\u5982\u679c\u4e00\u5143\u7b97\u672f\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u7531\u8fd0\u7b97\u7b26\u7684\u4e0a\u4e0b\u6587\u51b3\u5b9a\u3002
\u5982\u679c\u7b97\u672f\u8fd0\u7b97\u7b26\u6ca1\u6709\u4e0a\u4e0b\u6587\u6765\u786e\u5b9a\u64cd\u4f5c\u6570\u53c2\u6570\u7c7b\u578b\uff0c\u5219\u76f8\u5173\u53c2\u6570\u7684\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f DOUBLE PRECISION
\u3002\u4f8b\u5982\uff0c\u5f53\u53c2\u6570\u662f SELECT
\u5217\u8868\u4e2d\u7684\u9876\u7ea7\u8282\u70b9\uff0c\u6216\u8005\u5f53\u5b83\u662f\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u4e00\u90e8\u5206\u65f6\uff0c\u90a3\u4e48\u5b83\u76f8\u5173\u53c2\u6570\u7684\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f DOUBLE PRECISION
\u3002
\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\u5177\u6709\u4e0e\u5176\u4ed6\u64cd\u4f5c\u6570\u7684\u805a\u5408\u7c7b\u578b\u76f8\u540c\u7684\u6d3e\u751f\u7c7b\u578b\u3002\u5982\u679c\u8fd0\u7b97\u7b26\u7684\u6240\u6709\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u5219\u6d3e\u751f\u7c7b\u578b\u4e3a VARCHAR
\uff0c\u5176\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u51b3\u5b9a\u3002
\u53c2\u6570\u4e3a\u65f6\u95f4\u64cd\u4f5c\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\uff0c\u5982\u679c\u64cd\u4f5c\u7b26\u8fd4\u56de DATETIME
\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u4e3a DATETIME
\uff1b\u5982\u679c\u64cd\u4f5c\u7b26\u8fd4\u56de TIME
\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u4e3a TIME
\uff1b\u5982\u679c\u64cd\u4f5c\u7b26\u8fd4\u56de DATE
\uff0c\u5219\u53c2\u6570\u7c7b\u578b\u4e3a DATE
\u3002
\u4e8c\u5143\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u4e24\u4e2a\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e00\u81f4\u3002
\u53c2\u6570\u4e3a\u4e09\u5143\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\uff0c\u4f8b\u5982 BETWEEN
\u8fd0\u7b97\u4e2d\u7684\u53c2\u6570\uff0c\u5b83\u4eec\u7684\u6d3e\u751f\u7c7b\u578b\u4e0e\u5176\u4ed6\u64cd\u4f5c\u6570\u7684\u805a\u5408\u7c7b\u578b\u76f8\u540c\u3002
\u5982\u679c\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7684\u6240\u6709\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u90a3\u4e48\u6bcf\u4e2a\u64cd\u4f5c\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f VARCHAR
\uff0c\u4ed6\u4eec\u7684\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u786e\u5b9a\u3002
CASE
\u3001COALESCE
\u3001IF
\u3001IFNULL
\u6216 NULLIF
\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u8f93\u51fa\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\uff0c\u5176\u6d3e\u751f\u7c7b\u578b\u4e0e\u64cd\u4f5c\u7b26\u7684\u5176\u4ed6\u8f93\u51fa\u64cd\u4f5c\u6570\u7684\u805a\u5408\u7c7b\u578b\u76f8\u540c\u3002
\u5982\u679c CASE
\u3001COALESCE
\u3001IF
\u3001IFNULL
\u6216 NULLIF
\u7684\u6240\u6709\u8f93\u51fa\u64cd\u4f5c\u6570\u90fd\u662f\u5f62\u5f0f\u53c2\u6570\uff0c\u6216\u8005\u5b83\u4eec\u90fd\u662f NULL
\uff0c\u5219\u53c2\u6570\u7684\u7c7b\u578b\u7531\u64cd\u4f5c\u7b26\u7684\u4e0a\u4e0b\u6587\u51b3\u5b9a\u3002
\u2014 \u5982\u679c\u53c2\u6570\u662f CASE
\u3001COALESCE()
\u3001IF
\u6216 IFNULL
\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u64cd\u4f5c\u6570\uff0c\u5e76\u4e14\u64cd\u4f5c\u7b26\u4e0a\u4e0b\u6587\u4e0d\u80fd\u786e\u5b9a\u5176\u53c2\u6570\u7c7b\u578b\uff0c\u5219\u6bcf\u4e2a\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u90fd\u662f VARCHAR
\uff0c\u5176\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u51b3\u5b9a\u3002
\u2014 CAST()
\u64cd\u4f5c\u6570\u7684\u5f62\u5f0f\u53c2\u6570\u4e0e CAST()
\u6307\u5b9a\u7684\u7c7b\u578b\u76f8\u540c\u3002
\u2014 \u5982\u679c\u4e00\u4e2a\u5f62\u5f0f\u53c2\u6570\u662f SELECT
\u5217\u8868\u7684\u76f4\u63a5\u6210\u5458\uff0c\u800c\u4e0d\u662f INSERT
\u8bed\u53e5\u7684\u4e00\u90e8\u5206\uff0c\u5219\u5f62\u5f0f\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a VARCHAR
\uff0c\u5176\u6392\u5e8f\u89c4\u5219\u7531 collation_connection
\u7684\u503c\u51b3\u5b9a\u3002
\u2014 \u5982\u679c\u5f62\u5f0f\u53c2\u6570\u662f INSERT
\u8bed\u53e5\u7684\u4e00\u90e8\u5206 SELECT
\u5217\u8868\u7684\u76f4\u63a5\u6210\u5458\uff0c\u5219\u5f62\u5f0f\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a\u63d2\u5165\u5f62\u5f0f\u53c2\u6570\u7684\u5bf9\u5e94\u5217\u7684\u7c7b\u578b\u3002
\u5982\u679c\u4e00\u4e2a\u5f62\u5f0f\u53c2\u6570\u88ab\u7528\u4f5c UPDATE
\u8bed\u53e5\u7684 SET
\u5b50\u53e5\u6216 INSERT
\u8bed\u53e5\u7684 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u4e2d\u7684\u8d4b\u503c\u6e90\uff0c\u5f62\u5f0f\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u662f\u7531 SET
\u6216 ON DUPLICATE KEY UPDATE
\u5b50\u53e5\u66f4\u65b0\u7684\u5bf9\u5e94\u5217\u7684\u7c7b\u578b\u3002
\u5982\u679c\u5f62\u5f0f\u53c2\u6570\u662f\u51fd\u6570\u7684\u5b9e\u9645\u53c2\u6570\uff0c\u5219\u5176\u6d3e\u751f\u7c7b\u578b\u53d6\u51b3\u4e8e\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u3002
\u5bf9\u4e8e\u5b9e\u9645\u7c7b\u578b\u548c\u6d3e\u751f\u7c7b\u578b\u7684\u67d0\u4e9b\u7ec4\u5408\uff0c\u4f1a\u89e6\u53d1\u81ea\u52a8\u91cd\u65b0\u51c6\u5907\u9884\u7f16\u8bd1\u8bed\u53e5\u3002\u4ee5\u4e0b\u60c5\u51b5\uff0c\u65e0\u9700\u91cd\u65b0\u51c6\u5907\u9884\u7f16\u8bd1\u8bed\u53e5\uff1a
NULL
\u4e3a\u5b9e\u9645\u53c2\u6570\u3002
\u5f62\u5f0f\u53c2\u6570\u662f CAST()
\u7684\u64cd\u4f5c\u6570\u3002(CAST()
\u4f1a\u5c1d\u8bd5\u5c06\u53c2\u6570\u8f6c\u6362\u5230\u6d3e\u751f\u7c7b\u578b\uff0c\u5982\u679c\u8f6c\u6362\u5931\u8d25\u5219\u4f1a\u5f15\u53d1\u5f02\u5e38\u3002)
\u53c2\u6570\u7c7b\u578b\u4e3a\u5b57\u7b26\u4e32\u3002(\u5728\u672c\u4f8b\u4e2d\uff0c\u9690\u5f0f\u6267\u884c CAST(? AS derived_type)
)\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u548c\u5b9e\u9645\u7c7b\u578b\u5747\u4e3a INTEGER
\uff0c\u4e14\u5177\u6709\u76f8\u540c\u7684\u7b26\u53f7\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a DECIMAL
\uff0c\u5b9e\u9645\u7c7b\u578b\u4e3a DECIMAL
\u6216 INTEGER
\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u4e3a DOUBLE
\uff0c\u5b9e\u9645\u7c7b\u578b\u4e3a\u4efb\u610f\u6570\u5b57\u7c7b\u578b\u3002
\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u548c\u5b9e\u9645\u7c7b\u578b\u90fd\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\u3002
\u53c2\u6570\u6d3e\u751f\u7c7b\u578b\u662f\u65f6\u6001\u7c7b\u578b\uff0c\u5b9e\u9645\u7c7b\u578b\u662f\u65f6\u6001\u7c7b\u578b\u3002\u5f02\u5e38\u60c5\u51b5\uff1a\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u662f TIME
\uff0c\u800c\u5b9e\u9645\u7c7b\u578b\u4e0d\u662f TIME
\uff1b\u53c2\u6570\u7684\u6d3e\u751f\u7c7b\u578b\u662f DATE
\uff0c\u800c\u5b9e\u9645\u7c7b\u578b\u4e0d\u662f DATE
\u3002
\u6d3e\u751f\u7c7b\u578b\u662f\u65f6\u95f4\u7c7b\u578b\uff0c\u5b9e\u9645\u7c7b\u578b\u662f\u6570\u5b57\u7c7b\u578b\u3002
\u9664\u4e0a\u8ff0\u60c5\u51b5\u4ee5\u5916\uff0c\u9700\u8981\u91cd\u65b0\u51c6\u5907\u9884\u7f16\u8bd1\u8bed\u53e5\u5e76\u4f7f\u7528\u5b9e\u9645\u53c2\u6570\u7c7b\u578b\uff0c\u4e0d\u80fd\u4f7f\u7528\u6d3e\u751f\u53c2\u6570\u7c7b\u578b\u3002
\u8fd9\u4e9b\u89c4\u5219\u4e5f\u9002\u7528\u4e8e\u5728\u9884\u7f16\u8bd1\u8bed\u53e5\u4e2d\u5f15\u7528\u7684\u7528\u6237\u53d8\u91cf\u3002
\u5728\u9884\u7f16\u8bd1\u8bed\u53e5\u4e2d\u4e3a\u7ed9\u5b9a\u53c2\u6570\u6216\u7528\u6237\u53d8\u91cf\u65f6\uff0c\u5982\u679c\u5728\u7b2c\u4e00\u6b21\u6267\u884c\u65f6\u4f7f\u7528\u4e0d\u540c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5219\u4f1a\u5bfc\u81f4\u91cd\u65b0\u51c6\u5907\u8be5\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u4e0d\u4f46\u8fd0\u884c\u6548\u7387\u4f4e\uff0c\u800c\u4e14\u8fd8\u53ef\u80fd\u5bfc\u81f4\u53c2\u6570\uff08\u6216\u53d8\u91cf\uff09\u7684\u5b9e\u9645\u7c7b\u578b\u53d1\u751f\u53d8\u5316\uff0c\u5b9e\u9645\u6267\u884c\u7ed3\u679c\u4e0e\u8bed\u53e5\u7684\u9884\u671f\u7ed3\u679c\u4e0d\u4e00\u81f4\u3002\u5efa\u8bae\u5728\u9884\u7f16\u8bd1\u8bed\u53e5\u4e2d\u5bf9\u7ed9\u5b9a\u53c2\u6570\u4f7f\u7528\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Prepared-Statements/prepare/#_4","title":"\u793a\u4f8b","text":"> create table t13 (a int primary key);\n> insert into t13 values (1);\n> select * from t13 where 3 in (select (1+1) union select 1);\nEmpty set (0.01 sec)\n\n> select * from t13 where 3 in (select (1+2) union select 1);\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n\n> prepare st_18492 from 'select * from t13 where 3 in (select (1+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18492;\nEmpty set (0.01 sec)\n\n> prepare st_18493 from 'select * from t13 where 3 in (select (2+1) union select 1)';\nQuery OK, 0 rows affected (0.00 sec)\n\n> execute st_18493;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n\n> deallocate prepare st_18492;\nQuery OK, 0 rows affected (0.00 sec)\n\n> deallocate prepare st_18493;\nQuery OK, 0 rows affected (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/","title":"SHOW ACCOUNTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5217\u51fa\u4e3a\u4f60\u7684\u8d26\u6237\u4e0b\u521b\u5efa\u7684\u79df\u6237\u7528\u6237\u7684\u5143\u4fe1\u606f\u548c\u7edf\u8ba1\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_2","title":"\u51fd\u6570\u8bed\u6cd5","text":"> SHOW ACCOUNTS;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_3","title":"\u79df\u6237\u7528\u6237\u4fe1\u606f\u8be6\u60c5","text":"\u5217\u540d \u4fe1\u606f \u7c7b\u578b \u6570\u636e\u6e90\u5934 ACCOUNT_NAME \u79df\u6237\u540d\u79f0 varchar mo_account ADMIN_NAME \u521b\u5efa\u65f6\u9ed8\u8ba4\u8d85\u7ea7\u7ba1\u7406\u5458\u540d\u79f0 varchar \u6bcf\u4e2a\u79df\u6237\u4e0b\u7684 mo_user \u8868\u4e2d CREATED \u521b\u5efa\u65f6\u95f4 timestamp mo_account STATUS \u5f53\u524d\u72b6\u6001\uff0cOPEN \u6216 SUSPENDED varchar mo_account SUSPENDED_TIME \u505c\u7528\u65f6\u95f4 timestamp mo_account DB_COUNT \u6570\u636e\u5e93\u6570\u91cf bigint unsigned mo_tables TABLE_COUNT \u8868\u6570\u91cf bigint unsigned mo_tables ROW_COUNT \u603b\u884c\u6570 bigint unsigned sum(mo_table_rows()) SIZE \u4f7f\u7528\u7a7a\u95f4\u603b\u91cf\uff08MB\uff09 decimal(29,3) sum(mo_table_size(mt.reldatabase,mt.relname) COMMENT \u521b\u5efa\u65f6\u7684 COMMENT \u4fe1\u606f varchar mo_account"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-account/#_4","title":"\u793a\u4f8b","text":"mysql> show accounts;\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| account_name | admin_name | created | status | suspended_time | db_count | table_count | row_count | size | comment |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n| sys | root | 2023-02-14 06:58:15 | open | NULL | 8 | 57 | 2681 | 0.351 | system account |\n+--------------+------------+---------------------+--------+----------------+----------+-------------+-----------+-------+----------------+\n1 row in set (0.14 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/","title":"SHOW COLLATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u663e\u793a MatrixOne \u652f\u6301\u5b57\u7b26\u96c6\u7684\u6392\u5e8f\u89c4\u5219\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cSHOW COLLATION
\u7684\u8f93\u51fa\u5305\u62ec\u6240\u6709\u53ef\u7528\u7684\u6392\u5e8f\u89c4\u5219\u3002LIKE
\u5b50\u53e5\uff08\u5982\u679c\u5b58\u5728\uff09\u6307\u793a\u8981\u5339\u914d\u7684\u6392\u5e8f\u89c4\u5219\u540d\u79f0\u3002WHERE
\u5b50\u53e5\u53ef\u4ee5\u4f7f\u7528\u66f4\u4e00\u822c\u7684\u6761\u4ef6\u6765\u9009\u62e9\u884c\u3002
> SHOW COLLATION\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-collation/#_3","title":"\u793a\u4f8b","text":"mysql> show collation;\n+-------------+---------+------+----------+---------+\n| Collation | Charset | Id | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 | 46 | Yes | 1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation like '%';\n+-------------+---------+------+----------+---------+\n| Collation | Charset | Id | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 | 46 | Yes | 1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n\nmysql> show collation where 'Charset'='utf8mb4';\n+-------------+---------+------+----------+---------+\n| Collation | Charset | Id | Compiled | Sortlen |\n+-------------+---------+------+----------+---------+\n| utf8mb4_bin | utf8mb4 | 46 | Yes | 1 |\n+-------------+---------+------+----------+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/","title":"SHOW COLUMNS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW COLUMNS
\u7528\u4e8e\u663e\u793a\u6307\u5b9a\u8868\u4e2d\u6709\u5173\u5217\u7684\u4fe1\u606f\u3002
> SHOW [FULL] {COLUMNS}\n {FROM | IN} tbl_name\n [{FROM | IN} db_name]\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-columns/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show columns from t1;\n+-------+----------------+------+------+---------+-------+-------------------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+----------------+------+------+---------+-------+-------------------+\n| col1 | INT | YES | | NULL | | First column |\n| col2 | FLOAT | YES | | NULL | | \"%$^&*()_+@! |\n| col3 | VARCHAR(65535) | YES | | NULL | | ZD5lTndyuEzw49gxR |\n| col4 | BOOL | YES | | NULL | | |\n+-------+----------------+------+------+---------+-------+-------------------+\n4 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/","title":"SHOW CREATE PUBLICATION","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de PUBLICATION \u521b\u5efa\u65f6\u7684 SQL \u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SHOW CREATE PUBLICATION pubname;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-publication/#_3","title":"\u793a\u4f8b","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\nmysql> alter publication pub3 account add accx;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> show create publication pub3;\n+-------------+-----------------------------------------------------------------------+\n| Publication | Create Publication |\n+-------------+-----------------------------------------------------------------------+\n| pub3 | CREATE PUBLICATION `pub3` DATABASE `t` ACCOUNT `acc0`, `acc1`, `accx` |\n+-------------+-----------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/","title":"SHOW CREATE TABLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u67d0\u4e2a\u8868\u7684\u8868\u7ed3\u6784\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW CREATE TABLE tbl_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-table/#_3","title":"\u793a\u4f8b","text":"drop table if exists t1;\ncreate table t1(\ncol1 int comment 'First column',\ncol2 float comment '\"%$^&*()_+@!',\ncol3 varchar comment 'ZD5lTndyuEzw49gxR',\ncol4 bool comment ''\n);\nmysql> show create table t1;\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`col1` INT DEFAULT NULL COMMENT 'First column',\n`col2` FLOAT DEFAULT NULL COMMENT '\"%$^&*()_+@!',\n`col3` VARCHAR(65535) DEFAULT NULL COMMENT 'ZD5lTndyuEzw49gxR',\n`col4` BOOL DEFAULT NULL\n) |\n+-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/","title":"SHOW CREATE VIEW","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd9\u4e2a\u8bed\u53e5\u663e\u793a\u4e86\u521b\u5efa\u547d\u540d\u89c6\u56fe\u7684 CREATE VIEW
\u8bed\u53e5\u3002
> SHOW CREATE VIEW view_name\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-create-view/#_3","title":"\u793a\u4f8b","text":"create table test_table(col1 int, col2 float, col3 bool, col4 Date, col5 varchar(255), col6 text);\ncreate view test_view as select * from test_table;\nmysql> show create view test_view;\n+-----------+---------------------------------------------------+\n| View | Create View |\n+-----------+---------------------------------------------------+\n| test_view | create view test_view as select * from test_table |\n+-----------+---------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/","title":"SHOW DATABASES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"SHOW DATABASES
\u5217\u51fa MatrixOne \u4e0a\u7684\u6570\u636e\u5e93\u3002SHOW SCHEMAS
\u662f SHOW DATABASES
\u7684\u540c\u4e49\u8bcd\u3002
\u5982\u679c\u5b58\u5728 LIKE
\u5b50\u53e5\uff0c\u8868\u793a\u9700\u8981\u5339\u914d\u54ea\u4e9b\u6570\u636e\u5e93\u540d\u3002WHERE
\u5b50\u53e5\u53ef\u4ee5\u4f7f\u7528\u901a\u7528\u7684\u6761\u4ef6\u6765\u9009\u62e9\u884c\u3002
MatrixOne \u5c06\u6570\u636e\u5e93\u5c55\u793a\u5728\u6570\u636e\u76ee\u5f55\u4e2d\u3002
\u6570\u636e\u5e93\u4fe1\u606f\u4e5f\u53ef\u4ee5\u4ece INFORMATION_SCHEMA
SCHEMATA \u8868\u4e2d\u83b7\u5f97\u3002
> SHOW {DATABASES | SCHEMAS}\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-databases/#_3","title":"\u793a\u4f8b","text":"create database demo_1;\n\nmysql> show databases;\n+--------------------+\n| Database |\n+--------------------+\n| mo_task |\n| information_schema |\n| mysql |\n| system_metrics |\n| system |\n| demo_1 |\n| mo_catalog |\n+--------------------+\n7 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/","title":"SHOW FUNCTION STATUS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW FUNCTION STATUS
\u662f\u7528\u6765\u663e\u793a\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u51fd\u6570\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u51fd\u6570\u540d\u3001\u6570\u636e\u5e93\u540d\u3001\u521b\u5efa\u65f6\u95f4\u7b49\u7b49\u3002
SHOW FUNCTION STATUS
\u547d\u4ee4\u53ea\u663e\u793a\u7528\u6237\u5b9a\u4e49\u7684\u51fd\u6570\uff0c\u4e0d\u5305\u62ec\u7cfb\u7edf\u51fd\u6570\u3002MatrixOne \u652f\u6301 SQL UDF \u548c Python UDF\u3002
> SHOW FUNCTION STATUS\n [LIKE 'pattern' | WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"LIKE 'pattern'
\u662f\u53ef\u9009\u53c2\u6570\uff0c\u7528\u4e8e\u7b5b\u9009\u8981\u663e\u793a\u7684\u51fd\u6570\u3002pattern
\u662f\u4e00\u4e2a\u6a21\u5f0f\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 %
\u548c _
\u901a\u914d\u7b26\u3002\u4f8b\u5982\uff0c\u8981\u663e\u793a\u6240\u6709\u4ee5 my_function
\u5f00\u5934\u7684\u51fd\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a
SHOW FUNCTION STATUS LIKE 'my_function%';\n
\u8f93\u51fa\u7ed3\u679c\u5c06\u5305\u62ec\u51fd\u6570\u540d\u3001\u6570\u636e\u5e93\u540d\u3001\u7c7b\u578b\u3001\u521b\u5efa\u65f6\u95f4\u548c\u4fee\u6539\u65f6\u95f4\u7b49\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-function-status/#_4","title":"\u793a\u4f8b","text":"create or replace function py_add(a int, b int) returns int language python as $$\ndef add(a, b):\nreturn a + b\n$$\nhandler 'add';\ncreate function twosum (x float, y float) returns float language sql as 'select $1 + $2' ;\ncreate function helloworld () returns int language sql as 'select id from tbl1 limit 1';\n\nmysql> show function status;\n+------+-------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+-------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| db1 | py_add | FUNCTION | root | 2024-01-16 08:00:21 | 2024-01-16 08:00:21 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n| db1 | twosum | FUNCTION | root | 2024-01-16 08:00:39 | 2024-01-16 08:00:39 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n| db1 | helloworld | FUNCTION | root | 2024-01-16 08:00:53 | 2024-01-16 08:00:53 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n+------+-------------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n3 rows in set (0.01 sec)\n\nmysql> show function status like 'two%';\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| Db | Name | Type | Definer | Modified | Created | Security_type | Comment | character_set_client | collation_connection | Database Collation |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n| db1 | twosum | FUNCTION | root | 2024-01-16 08:00:39 | 2024-01-16 08:00:39 | DEFINER | | utf8mb4 | utf8mb4_0900_ai_ci | utf8mb4_0900_ai_ci |\n+------+--------+----------+---------+---------------------+---------------------+---------------+---------+----------------------+----------------------+--------------------+\n1 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/","title":"SHOW GRANTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4f7f\u7528 SHOW GRANTS
\u8bed\u53e5\u663e\u793a\u7528\u6237\u7684\u6240\u6709\u6388\u6743\u4fe1\u606f\u3002SHOW GRANTS
\u8bed\u53e5\u663e\u793a\u4f7f\u7528 GRANT
\u547d\u4ee4\u5206\u914d\u7ed9\u7528\u6237\u7684\u6743\u9650\u3002
\u4f7f\u7528 SHOW GRANTS
\u8bed\u53e5\u9700\u8981\u62e5\u6709\u67e5\u8be2 mo_catalog \u5e93\u4e0b\u6240\u6709\u8868\u7684 SELECT
\u6743\u9650\uff0c\u4f46\u663e\u793a\u5f53\u524d\u7528\u6237\u7684\u6743\u9650\u548c\u89d2\u8272\u9664\u5916\u3002
\u8981\u4e3a SHOW GRANTS
\u547d\u540d\u5e10\u6237\u6216\u89d2\u8272\uff0c\u5373\u4f7f\u7528\u4e0e GRANT
\u8bed\u53e5\u76f8\u540c\u7684\u683c\u5f0f\uff0c\u4f8b\u5982\uff1a
show grants for 'root'@'localhost';\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW GRANTS FOR {username[@hostname] | rolename};\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-grants/#_3","title":"\u793a\u4f8b","text":"create role role1;\ngrant all on table *.* to role1;\ngrant create table, drop table on database *.* to role1;\ncreate user user1 identified by 'pass1';\ngrant role1 to user1;\n> show grants for 'user1'@'localhost';\n+--------------------------------------------------------+\n| Grants for user1@localhost |\n+--------------------------------------------------------+\n| GRANT connect ON account `user1`@`localhost` |\n| GRANT table all ON table *.* `user1`@`localhost` |\n| GRANT create table ON database *.* `user1`@`localhost` |\n| GRANT drop table ON database *.* `user1`@`localhost` |\n+--------------------------------------------------------+\n4 rows in set (0.00 sec)\n\nmysql> show grants for ROLE role1;\n+--------------------------------------------+\n| Grants for role1 |\n+--------------------------------------------+\n| GRANT table all ON table *.* `role1` |\n| GRANT create table ON database *.* `role1` |\n| GRANT drop table ON database *.* `role1` |\n+--------------------------------------------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/","title":"SHOW INDEX","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW INDEX
\u8fd4\u56de\u8868\u7684\u7d22\u5f15\u4fe1\u606f\u3002
SHOW INDEX
\u8fd4\u56de\u4ee5\u4e0b\u5b57\u6bb5\uff1a
> SHOW {INDEX | INDEXES}\n {FROM | IN} tbl_name\n [{FROM | IN} db_name]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-index/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"tbl_name FROM db_name
\u8bed\u6cd5\u7684\u66ff\u4ee3\u65b9\u6cd5\u662f db_name.tbl_name
\u3002
CREATE TABLE show_01(sname varchar(30),id int);\nmysql> show INDEX FROM show_01;\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Visible | Expression |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n| show_01 | 0 | id | 1 | id | A | 0 | NULL | NULL | YES | | | YES | NULL |\n| show_01 | 0 | sname | 1 | sname | A | 0 | NULL | NULL | YES | | | YES | NULL |\n| show_01 | 0 | __mo_rowid | 1 | __mo_rowid | A | 0 | NULL | NULL | NO | | Physical address | NO | NULL |\n+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+------------------+---------+------------+\n3 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/","title":"SHOW PROCESSLIST","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW PROCESSLIST
\u7528\u4e8e\u67e5\u770b\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u5217\u8868\uff08\u4e5f\u79f0\u4e3a\u8fdb\u7a0b\u5217\u8868\uff09\uff0c\u63d0\u4f9b\u4e86\u5173\u4e8e MatrixOne \u670d\u52a1\u5668\u4e0a\u6240\u6709\u6d3b\u52a8\u8fde\u63a5\u548c\u6267\u884c\u4e2d\u67e5\u8be2\u7684\u4fe1\u606f\u3002
SHOW PROCESSLIST
\u7528\u4e8e\u76d1\u63a7\u548c\u7ba1\u7406\u6570\u636e\u5e93\u4e2d\u7684\u6d3b\u52a8\uff0c\u53d1\u73b0\u6f5c\u5728\u95ee\u9898\uff0c\u5e2e\u52a9\u67e5\u8be2\u6027\u80fd\u95ee\u9898\uff0c\u5e76\u5e2e\u52a9\u51b3\u7b56\u4f18\u5316\u6570\u636e\u5e93\u7684\u8fd0\u884c\uff1a
\u76d1\u63a7\u6570\u636e\u5e93\u6d3b\u52a8\uff1a\u901a\u8fc7\u6267\u884c SHOW PROCESSLIST
\uff0c\u53ef\u4ee5\u5b9e\u65f6\u67e5\u770b\u6570\u636e\u5e93\u4e2d\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u67e5\u8be2\u548c\u64cd\u4f5c\u3002\u8fd9\u5bf9\u4e8e\u76d1\u63a7\u6570\u636e\u5e93\u6d3b\u52a8\u5e76\u53ca\u65f6\u53d1\u73b0\u53ef\u80fd\u7684\u6027\u80fd\u95ee\u9898\u975e\u5e38\u6709\u7528\u3002\u4f60\u53ef\u4ee5\u4e86\u89e3\u54ea\u4e9b\u67e5\u8be2\u6b63\u5728\u8fd0\u884c\uff0c\u5b83\u4eec\u7684\u72b6\u6001\u5982\u4f55\uff0c\u4ee5\u53ca\u662f\u5426\u6709\u957f\u65f6\u95f4\u8fd0\u884c\u6216\u963b\u585e\u7684\u67e5\u8be2\u3001\u6216\u8005\u9501\u5b9a\u3001\u6b7b\u9501\u6216\u8d44\u6e90\u4e89\u7528\u7b49\u3002
\u7ec8\u6b62\u67e5\u8be2\uff1a\u901a\u8fc7\u67e5\u770b\u8fdb\u7a0b\u5217\u8868\uff0c\u53ef\u4ee5\u786e\u5b9a\u8981\u7ec8\u6b62\u7684\u67e5\u8be2 ID\uff0c\u5e76\u4f7f\u7528 KILL
\u547d\u4ee4\u7ec8\u6b62\u5177\u4f53\u7684\u67e5\u8be2\u3002\u8fd9\u5bf9\u4e8e\u505c\u6b62\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u67e5\u8be2\u6216\u89e3\u51b3\u6b7b\u9501\u95ee\u9898\u975e\u5e38\u6709\u7528\u3002
> SHOW PROCESSLIST;\n
\u67e5\u8be2\u51fa\u7684\u8868\u7ed3\u6784\u5b57\u6bb5\u89e3\u91ca\u5982\u4e0b\uff1a
\u5217\u540d \u7c7b\u578b \u7ea6\u675f \u5907\u6ce8 node_id varchar not null \u8282\u70b9 ID\uff0c\u7528\u4e8e\u5728\u6570\u636e\u5e93\u96c6\u7fa4\u4e2d\u552f\u4e00\u6807\u8bc6\u4e0d\u540c\u7684\u8282\u70b9\u3002\u5728 MatrixOne \u4e2d\uff0c\u4e00\u4e2a\u8282\u70b9\u5373\u4e3a\u4e00\u4e2a CN\uff08Compute Node\uff09\u3002 Note: - \u5728\u5355\u673a\u7248\u672c\u7684 MatrixOne \u4e2d\uff0c\u901a\u5e38\u53ea\u6709\u4e00\u4e2a\u8282\u70b9\uff0c\u6240\u6709\u8fdb\u7a0b\u90fd\u8fd0\u884c\u5728\u8fd9\u4e2a\u8282\u70b9\u4e0a\uff0c\u56e0\u6b64\u6240\u6709\u8fdb\u7a0b\u7684 node_id \u90fd\u76f8\u540c\u3002 - \u5728\u5206\u5e03\u5f0f\u7248\u672c\u7684 MatrixOne \u4e2d\uff0c\u6bcf\u4e2a\u8282\u70b9\u90fd\u6709\u4e00\u4e2a\u552f\u4e00\u7684 node_id\u3002\u7cfb\u7edf\u79df\u6237\u53ef\u4ee5\u67e5\u770b\u6240\u6709\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u6240\u5728\u8282\u70b9\u5bf9\u5e94\u7684 node_id\uff0c\u800c\u975e\u7cfb\u7edf\u79df\u6237\u53ea\u80fd\u770b\u5230\u5c5e\u4e8e\u5176\u79df\u6237\u4e0b\u6b63\u5728\u6267\u884c\u7684\u7ebf\u7a0b\u7684\u8282\u70b9\u5bf9\u5e94\u7684 node_id\u3002 conn_id uint32 not null \u8fde\u63a5 ID\uff0c\u7528\u4e8e\u6807\u8bc6\u4e0d\u540c\u7684\u6570\u636e\u5e93\u8fde\u63a5\u3002\u5982\u679c\u9700\u8981\u7ec8\u6b62\u67d0\u4e2a\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u53ef\u4ee5\u4f7f\u7528KILL CONNECTION conn_id;
\u547d\u4ee4\u6765\u7ec8\u6b62\u8be5\u8fde\u63a5\u3002\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u6bcf\u4e2a\u8fde\u63a5\u90fd\u4f1a\u88ab\u5206\u914d\u4e00\u4e2a\u552f\u4e00\u7684 conn_id\uff0c\u7528\u4e8e\u6807\u8bc6\u8be5\u8fde\u63a5\u3002 Note: \u7cfb\u7edf\u79df\u6237\u53ef\u4ee5\u67e5\u770b\u6240\u6709 conn_id\uff0c\u975e\u7cfb\u7edf\u79df\u6237\u53ea\u80fd\u770b\u5230\u79df\u6237\u4e0b\u7684 conn_id\u3002ID session_id varchar not null \u4f1a\u8bdd ID account varchar not null \u79df\u6237 Note: \u7cfb\u7edf\u79df\u6237\u4e0b\u53ef\u4ee5\u770b\u5230\u6240\u6709\u79df\u6237\u7684\u4f1a\u8bdd\u4e0e\u79df\u6237\u540d\u79f0\uff0c\u975e\u7cfb\u7edf\u79df\u6237\u53ea\u80fd\u770b\u5230\u81ea\u5df1\u79df\u6237\u7684\u4f1a\u8bdd\u4e0e\u79df\u6237\u540d\u79f0\u3002 user varchar not null \u7528\u6237 host varchar not null \u5ba2\u6237\u673a\u7aef\u7684\u4e3b\u673a\u540d db varchar \u6570\u636e\u5e93\u540d session_start varchar \u4f1a\u8bdd\u5f00\u59cb\u65f6\u95f4 command varchar not null \u547d\u4ee4\u7c7b\u578b\uff0c\u5982 COM_QUERY info varchar \u5f53\u524d\u6216\u4e0a\u4e00\u6761 SQL \u8bed\u53e5 txn_id varchar not null \u5f53\u524d\u6216\u4e0a\u4e00\u6761\u4e8b\u52a1 ID statement_id varchar \u5f53\u524d\u6216\u4e0a\u4e00\u6761\u8bed\u53e5 ID statement_type varchar \u5f53\u524d\u6216\u4e0a\u4e00\u6761\u8bed\u53e5\u7c7b\u578b query_type varchar \u67e5\u8be2\u7c7b\u578b\uff0c\u5982 DDL\uff0cDML \u7b49 sql_source_type varchar SQL \u6e90\u7c7b\u578b\uff0c\u5982 external_sql, internal_sql \u7b49 query_start varchar \u67e5\u8be2\u5f00\u59cb\u65f6\u95f4"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-processlist/#_3","title":"\u793a\u4f8b","text":"mysql> SHOW PROCESSLIST;\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| node_id | conn_id | session_id | account | user | host | db | session_start | command | info | txn_id | statement_id | statement_type | query_type | sql_source_type | query_start |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 1 | 97f85f80-2a5c-11ee-ae41-5ad2460dea4f | sys | mo_logger | 127.0.0.1:6001 | | 2023-07-24 19:59:27.005755 | COM_QUERY | COMMIT | | | | | internal_sql | |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 8 | a056b7c6-2a5c-11ee-ae42-5ad2460dea4f | sys | root | 127.0.0.1:6001 | aab | 2023-07-24 19:59:41.045851 | COM_QUERY | SHOW PROCESSLIST | c207acc30a19432f8d3cbac387c6e520 | 421aadaa-2a68-11ee-ae5b-5ad2460dea4f | Show Processlist | Other | external_sql | 2023-07-24 21:22:56.907266 |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 24 | 0915f91a-2a63-11ee-ae4d-5ad2460dea4f | sys | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 20:45:33.762679 | COM_QUERY | select\ntask_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ntask_parent_id,\ntask_status,\ntask_runner,\ntask_epoch,\nlast_heartbeat,\nresult_code,\nerror_msg,\ncreate_at,\nend_at\nfrom mo_task.sys_async_task where task_id>17 AND task_runner='dd1dccb4-4d3c-41f8-b482-5251dc7a41bf' AND task_status=1 order by task_id limit 3 | | | | | internal_sql | |\n| dd1dccb4-4d3c-41f8-b482-5251dc7a41bf | 36 | d8aa4060-2a67-11ee-ae59-5ad2460dea4f | sys | 3bf028e0-aa43-4917-b82f-ed533c0f401e | 127.0.0.1:6001 | mo_task | 2023-07-24 21:20:00.009746 | COM_QUERY | select\ncron_task_id,\ntask_metadata_id,\ntask_metadata_executor,\ntask_metadata_context,\ntask_metadata_option,\ncron_expr,\nnext_time,\ntrigger_times,\ncreate_at,\nupdate_at\nfrom mo_task.sys_cron_task | | | | | internal_sql | |\n+--------------------------------------+---------+--------------------------------------+---------+--------------------------------------+----------------+---------+----------------------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------+------------------+------------+-----------------+----------------------------+\n4 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/","title":"SHOW PUBLICATIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u6240\u6709\u53d1\u5e03\u540d\u3001\u53d1\u5e03\u7684\u6570\u636e\u5e93\u540d\u3001\u53d1\u5e03\u521b\u5efa\u65f6\u95f4\u3001\u53d1\u5e03\u6700\u65b0\u4fee\u6539\u65f6\u95f4\u3001\u53d1\u5e03\u6307\u5b9a\u7684\u79df\u6237\u540d\u5217\u8868\uff08\u5982\u679c\u662f\u6240\u6709\u5219\u5c55\u793a \"*\"\uff09\u548c\u5907\u6ce8\u3002
\u5982\u9700\u67e5\u770b\u66f4\u591a\u4fe1\u606f\uff0c\u9700\u8981\u62e5\u6709\u79df\u6237\u7ba1\u7406\u5458\u6743\u9650\uff0c\u67e5\u770b\u7cfb\u7edf\u8868 mo_pubs \u67e5\u770b\u66f4\u591a\u53c2\u6570\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SHOW PUBLICATIONS;\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-publications/#_3","title":"\u793a\u4f8b","text":"create account acc0 admin_name 'root' identified by '111';\ncreate account acc1 admin_name 'root' identified by '111';\ncreate account acc2 admin_name 'root' identified by '111';\ncreate database t;\ncreate publication pub3 database t account acc0,acc1;\n\nmysql> show publications;\n+-------------+----------+---------------------+-------------+-------------+----------+\n| publication | database | create_time | update_time | sub_account | comments |\n+-------------+----------+---------------------+-------------+-------------+----------+\n| pub3 | t | 2024-04-23 10:10:59 | NULL | acc0,acc1 | |\n+-------------+----------+---------------------+-------------+-------------+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/","title":"SHOW ROLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#_1","title":"\u51fd\u6570\u8bf4\u660e","text":"\u5217\u51fa\u4e3a\u4f60\u7684\u8d26\u6237\u4e0b\u521b\u5efa\u7684\u89d2\u8272\u7684\u5143\u4fe1\u606f\uff0c\u5305\u62ec\u89d2\u8272\u540d\u79f0\u3001\u521b\u5efa\u8005\u3001\u521b\u5efa\u65f6\u95f4\u4ee5\u53ca\u6ce8\u91ca\u5185\u5bb9\u3002
Note: \u5982\u679c\u9700\u8981\u67e5\u8be2\u4f60\u5f53\u524d\u6240\u4f7f\u7528\u7684\u89d2\u8272\uff0c\u4f7f\u7528 select current_role()
\u8bed\u53e5\u3002
> SHOW ROLES [LIKE 'pattern'];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-roles/#_3","title":"\u793a\u4f8b","text":"-- \u5c55\u793a\u5f53\u524d\u4f60\u8d26\u6237\u4e0b\u7684\u89d2\u8272\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME | COMMENTS |\n+-----------+---------+---------------------+----------+\n| moadmin | 0 | 2023-04-19 06:37:58 | |\n| public | 0 | 2023-04-19 06:37:58 | |\n+-----------+---------+---------------------+----------+\n2 rows in set (0.01 sec)\n\n-- \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u89d2\u8272 rolex\nmysql> create role rolex;\nQuery OK, 0 rows affected (0.02 sec)\n\n-- \u518d\u6b21\u67e5\u770b\u5f53\u524d\u4f60\u8d26\u6237\u4e0b\u7684\u89d2\u8272\nmysql> show roles;\n+-----------+---------+---------------------+----------+\n| ROLE_NAME | CREATOR | CREATED_TIME | COMMENTS |\n+-----------+---------+---------------------+----------+\n| rolex | 1 | 2023-04-19 06:43:29 | |\n| moadmin | 0 | 2023-04-19 06:37:58 | |\n| public | 0 | 2023-04-19 06:37:58 | |\n+-----------+---------+---------------------+----------+\n3 rows in set (0.01 sec)\n\n-- \u67e5\u8be2\u5f53\u524d\u4f60\u6240\u4f7f\u7528\u7684\u89d2\u8272\nmysql> select current_role();\n+----------------+\n| current_role() |\n+----------------+\n| moadmin |\n+----------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/","title":"SHOW SEQUENCES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW SEQUENCES
\u7528\u4e8e\u67e5\u770b\u5f53\u524d\u5e8f\u5217\u5217\u8868\u7684\u540d\u79f0\u4e0e\u5217\u8868\u7c7b\u578b\u3002
> SHOW SQUENCES\n [WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-sequences/#_3","title":"\u793a\u4f8b","text":"CREATE SEQUENCE s1 START 101;\nCREATE SEQUENCE s3 as smallint INCREMENT 10 MINVALUE -100 MAXVALUE 100 START 0 CYCLE;\nCREATE SEQUENCE seq_id INCREMENT BY 1 MAXVALUE 1000 START with 1;\nmysql> show sequences;\n+--------+-----------+\n| Names | Data Type |\n+--------+-----------+\n| s3 | SMALLINT |\n| s1 | BIGINT |\n| seq_id | BIGINT |\n+--------+-----------+\n3 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-snapshots/","title":"SHOW SNAPSHOTS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-snapshots/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"SHOW SNAPSHOTS
\u8fd4\u56de\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u7684\u5feb\u7167\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u5feb\u7167\u540d\u3001\u521b\u5efa\u65f6\u95f4\u6233\uff08UTC \u65f6\u95f4\uff09\u3001\u5feb\u7167\u7ea7\u522b\u3001\u79df\u6237\u540d\u79f0\u3001\u6570\u636e\u5e93\u540d\u3001\u8868\u540d\u3002
> SHOW SNAPSHOTS [WHERE expr]\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-snapshots/#_3","title":"\u793a\u4f8b","text":"create account acc1 admin_name admin identified by '111';\ncreate snapshot sp1 for account acc1;\ncreate snapshot sp2 for account sys;\n\nmysql> show snapshots;\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| SNAPSHOT_NAME | TIMESTAMP | SNAPSHOT_LEVEL | ACCOUNT_NAME | DATABASE_NAME | TABLE_NAME |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp2 | 2024-05-10 09:58:55.602263 | account | sys | | |\n| sp1 | 2024-05-10 09:58:55.212365 | account | acc1 | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n2 rows in set (0.01 sec)\n\nmysql> show snapshots where account_name=\"acc1\";\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| snapshot_name | timestamp | snapshot_level | account_name | database_name | table_name |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n| sp1 | 2024-05-10 09:58:55.212365 | account | acc1 | | |\n+---------------+----------------------------+----------------+--------------+---------------+------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/","title":"SHOW STAGES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u6570\u636e\u9636\u6bb5\u3002
MatrixOne \u7528\u6237\u4f7f\u7528 SHOW STAGES
\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u6240\u6709\u7684\u6570\u636e\u9636\u6bb5\uff0c\u53ef\u4ee5\u9009\u62e9\u5c06\u6570\u636e\u5bfc\u51fa\u5230\u7684\u6709\u6548\u8def\u5f84\u3002
> SHOW STAGES [LIKE 'pattern']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-stage/#_3","title":"\u793a\u4f8b","text":"CREATE TABLE `user` (`id` int(11) ,`user_name` varchar(255) ,`sex` varchar(255));\nINSERT INTO user(id,user_name,sex) values('1', 'weder', 'man'), ('2', 'tom', 'man'), ('3', 'wederTom', 'man');\n\n-- \u521b\u5efa\u5185\u90e8\u6570\u636e\u9636\u6bb5\nmysql> CREATE STAGE stage1 URL='/tmp' ENABLE = TRUE;\n\n-- \u5c06\u6570\u636e\u4ece\u8868\u5bfc\u51fa\u5230\u6570\u636e\u9636\u6bb5\nmysql> SELECT * FROM user INTO OUTFILE 'stage1:/user.csv';\n-- \u4f60\u53ef\u4ee5\u5728\u4f60\u672c\u5730\u76ee\u5f55\u4e0b\u770b\u5230\u4f60\u5bfc\u51fa\u7684\u8868\n\n-- \u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u6570\u636e\u9636\u6bb5\u3002\nmysql> SHOW STAGES;\n+------------+-----------------------------+---------+---------+\n| STAGE_NAME | URL | STATUS | COMMENT |\n+------------+-----------------------------+---------+---------+\n| stage1 | /tmp | ENABLED | |\n+------------+-----------------------------+---------+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/","title":"SHOW SUBSCRIPTIONS","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8fd4\u56de\u6240\u6709\u53d1\u5e03\u540d\u3001\u53d1\u5e03\u79df\u6237\u540d\u3001\u53d1\u5e03\u7684\u6570\u636e\u5e93\u540d\u3001\u53d1\u5e03\u7ed9\u8be5\u79df\u6237\u7684\u65f6\u95f4\u3001\u8ba2\u9605\u540d\u548c\u521b\u5efa\u8be5\u8ba2\u9605\u7684\u65f6\u95f4\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"SHOW SUBSCRIPTIONS [ALL];\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-subscriptions/#_3","title":"\u8bed\u6cd5\u89e3\u91ca","text":"mysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+----------+\n| pub3 | sys | t | 2024-04-23 11:11:06 | NULL | NULL |\n+----------+-------------+--------------+---------------------+----------+----------+\n1 row in set (0.01 sec)\n\nmysql> show subscriptions;\nEmpty set (0.00 sec)\n\nmysql> create database sub3 from sys publication pub3;\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> show subscriptions all;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub3 | sys | t | 2024-04-23 11:11:06 | sub3 | 2024-04-23 11:12:11 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.00 sec)\n\nmysql> show subscriptions;\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub_name | pub_account | pub_database | pub_time | sub_name | sub_time |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n| pub3 | sys | t | 2024-04-23 11:11:06 | sub3 | 2024-04-23 11:12:11 |\n+----------+-------------+--------------+---------------------+----------+---------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/","title":"SHOW TABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u521b\u5efa\u7684\u6240\u6709\u8868\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW TABLES [LIKE 'pattern' | WHERE expr | FROM 'pattern' | IN 'pattern']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-tables/#_3","title":"\u793a\u4f8b","text":"> SHOW TABLES;\n+---------------+\n| name |\n+---------------+\n| clusters |\n| contributors |\n| databases |\n| functions |\n| numbers |\n| numbers_local |\n| numbers_mt |\n| one |\n| processes |\n| settings |\n| tables |\n| tracing |\n+---------------+\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/","title":"SHOW VARIABLES","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u4ee5\u5217\u8868\u7684\u5f62\u5f0f\u5c55\u73b0\u5f53\u524d\u6570\u636e\u5e93\u7cfb\u7edf\u53d8\u91cf\u7684\u503c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SHOW VARIABLES\n [LIKE 'pattern']\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/SHOW-Statements/show-variables/#_3","title":"\u8bed\u6cd5\u91ca\u4e49","text":"LIKE
\u5b50\u53e5\u4ec5\u663e\u793a\u540d\u79f0\u4e0e\u6a21\u5f0f\u5339\u914d\u7684\u90a3\u4e9b\u53d8\u91cf\u7684\u884c\u3002\u8981\u83b7\u53d6\u540d\u79f0\u4e0e\u6a21\u5f0f\u5339\u914d\u7684\u53d8\u91cf\u5217\u8868\uff0c\u8bf7\u5728\u5b50\u53e5\u4e2d\u4f7f\u7528 % \u901a\u914d\u7b26\u3002mysql> SHOW VARIABLES;\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| Variable_name | Value |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n| auto_increment_increment | 1 |\n| auto_increment_offset | 1 |\n| autocommit | 1 |\n| character_set_client | utf8mb4 |\n| character_set_connection | utf8mb4 |\n| character_set_database | utf8mb4 |\n| character_set_results | utf8mb4 |\n| character_set_server | utf8mb4 |\n| collation_connection | default |\n| collation_server | utf8mb4_bin |\n| completion_type | NO_CHAIN |\n| host | 0.0.0.0 |\n| init_connect | |\n| interactive_timeout | 28800 |\n| license | APACHE |\n| lower_case_table_names | 0 |\n| max_allowed_packet | 16777216 |\n| net_write_timeout | 60 |\n| performance_schema | 0 |\n| port | 6001 |\n| profiling | 0 |\n| query_result_maxsize | 100 |\n| query_result_timeout | 24 |\n| save_query_result | 0 |\n| sql_mode | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |\n| sql_safe_updates | 0 |\n| sql_select_limit | 18446744073709551615 |\n| system_time_zone | |\n| testbotchvar_nodyn | 0 |\n| testbothvar_dyn | 0 |\n| testglobalvar_dyn | 0 |\n| testglobalvar_nodyn | 0 |\n| testsessionvar_dyn | 0 |\n| testsessionvar_nodyn | 0 |\n| time_zone | SYSTEM |\n| transaction_isolation | REPEATABLE-READ |\n| transaction_read_only | 0 |\n| tx_isolation | REPEATABLE-READ |\n| tx_read_only | 0 |\n| version_comment | MatrixOne |\n| wait_timeout | 28800 |\n+--------------------------+-----------------------------------------------------------------------------------------------------------------------+\n41 rows in set (0.01 sec)\n\nmysql> show variables like 'auto%';\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1 |\n| auto_increment_offset | 1 |\n| autocommit | 1 |\n+--------------------------+-------+\n3 rows in set (0.00 sec)\n\nmysql> show variables like 'auto_increment_increment';\n+--------------------------+-------+\n| Variable_name | Value |\n+--------------------------+-------+\n| auto_increment_increment | 1 |\n+--------------------------+-------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/","title":"SET ROLE","text":""},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_1","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u8bbe\u7f6e\u4f1a\u8bdd\u7684\u6d3b\u52a8/\u5f53\u524d\u4e3b\u8981\u89d2\u8272\u3002\u4e3a\u5f53\u524d\u6d3b\u52a8\u7684\u4e3b\u89d2\u8272\u8bbe\u7f6e\u4e0a\u4e0b\u6587\uff0c\u4ee5\u786e\u5b9a\u5f53\u524d\u7528\u6237\u662f\u5426\u62e5\u6709\u6267\u884c CREATE <object>
\u8bed\u53e5\u6216\u6267\u884c\u4efb\u4f55\u5176\u4ed6 SQL \u64cd\u4f5c\u6240\u9700\u7684\u6743\u9650\u3002
\u9664\u4e86\u521b\u5efa\u5bf9\u8c61\u4e4b\u5916\uff0c\u4efb\u4f55 SQL \u64cd\u4f5c\u7684\u6388\u6743\u90fd\u53ef\u4ee5\u7531\u6b21\u7ea7\u89d2\u8272\u6267\u884c\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_2","title":"\u8bed\u6cd5\u7ed3\u6784","text":"> SET SECONDARY ROLE {\n NONE\n | ALL \n}\nSET ROLE role\n
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_3","title":"\u8bed\u6cd5\u8bf4\u660e","text":"\u89d2\u8272\u662f\u6743\u9650\u7684\u96c6\u5408\uff0c\u4e00\u4e2a\u7528\u6237\u53ef\u4ee5\u5bf9\u5e94\u591a\u4e2a\u89d2\u8272\u3002
\u4f8b\u5982\uff0cuser1 \u62e5\u6709\u4e3b\u8981\u89d2\u8272 role1\uff0c\u6b21\u8981\u89d2\u8272 role2 \u548c role3, role1 \u88ab\u6388\u4e88 pri1 \u548c pri2 \u6743\u9650\uff1brole2 \u88ab\u8d4b\u4e88\u6743\u9650 pri3\uff1brole3 \u88ab\u8d4b\u4e88\u6743\u9650 pri4\uff0c\u6388\u6743\u793a\u4f8b\u8868\u5982\u4e0b\uff1a
\u7528\u6237\u540d \u89d2\u8272\u540d \u6743\u9650\u540d user1 role1 pri1,pri2 role2 pri3 role3 pri4\u4e3a\u4e86\u66f4\u5bb9\u6613\u7406\u89e3\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u793a\u4f8b\uff1a
\u7528\u6237 \u89d2\u8272 \u6743\u9650\u540d Tom \u5e94\u7528\u5f00\u53d1\u8005\uff08Application Developer\uff09 \u8bfb\u6570\u636e\uff08Read Data\uff09\uff0c\u5199\u6570\u636e\uff08Write Data\uff09 \u8fd0\u7ef4\u4e13\u5bb6\uff08O&M expert\uff09 \u8bfb\u6570\u636e\uff08Read data\uff09 \u6570\u636e\u5e93\u7ba1\u7406\u5458\uff08Database Administrator\uff09 \u7ba1\u7406\u5458\u6743\u9650\uff08Administrator Privileges\uff09\u6b64\u65f6 Tom \u7684\u4e3b\u8981\u89d2\u8272\u662f\u5e94\u7528\u5f00\u53d1\u8005\uff0cTom \u9700\u8981\u8c03\u7528\u7ba1\u7406\u5458\u6743\u9650\uff0c\u90a3\u4e48 Tom \u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u65b9\u6cd5\uff1a
\u2014\u4f7f\u7528 SET role role
\u8bed\u53e5\u5c06\u5176\u89d2\u8272\u5207\u6362\u4e3a\u201c\u6570\u636e\u5e93\u7ba1\u7406\u5458\u201d\u3002
\u2014\u5982\u679c\u9700\u8981\u4f7f\u7528\u4e3b\u3001\u4ece\u89d2\u8272\u7684\u6240\u6709\u6743\u9650\uff0c\u53ef\u4ee5\u4f7f\u7528 SET secondary ROLE all
\u3002
\u8fd9\u4e24\u79cd\u8bed\u53e5\u89e3\u91ca\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-all","title":"SET SECONDARY ROLE ALL","text":"\u5c06\u8be5\u7528\u6237\u6240\u6709\u7684 ROLE \u53d6\u5e76\u96c6\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-secondary-role-none","title":"SET SECONDARY ROLE NONE","text":"\u5c06\u9664 PRIMARY ROLE \u4e4b\u5916\u7684\u6240\u6709\u89d2\u8272\u4ece\u5f53\u524d\u4f1a\u8bdd\u4e2d\u53bb\u9664\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#set-role-role","title":"SET ROLE role","text":"\u5c06\u5f53\u524d\u89d2\u8272\u5207\u6362\u4e3a\u65b0\u89d2\u8272\u3002
"},{"location":"MatrixOne/Reference/SQL-Reference/Other/Set/set-role/#_4","title":"\u793a\u4f8b","text":"> drop role if exists use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> drop user if exists use_user_1,use_user_2;\n> drop database if exists use_db_1;\n> create role use_role_1,use_role_2,use_role_3,use_role_4,use_role_5;\n> create database use_db_1;\n> create user use_user_1 identified by '123456' default role use_role_1;\n-- \u628a\u6240\u6709\u8868\u7684 select\uff0cinsert \u548c update \u6743\u9650\u6388\u6743\u7ed9 use_role_1\n> grant select ,insert ,update on table *.* to use_role_1;\n-- \u628a\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\u6388\u6743\u7ed9 use_role_2\n> grant all on database * to use_role_2;\n-- \u628a\u89d2\u8272 use_role_2 \u5206\u914d\u7ed9\u7528\u6237 use_user_1\n> grant use_role_2 to use_user_1;\n-- \u521b\u5efa\u8868 use_table_1\n> create table use_db_1.use_table_1(a int,b varchar(20),c double );\n-- \u8bbe\u7f6e\u7528\u6237 use_user_1 \u4e3b\u8981\u89d2\u8272\u548c\u6b21\u8981\u89d2\u8272\u5168\u90e8\u53ef\u7528\n> set secondary role all;\n-- \u67e5\u770b\u7528\u6237 use_user_1 \u73b0\u5728\u62e5\u6709\u7684\u6743\u9650\n> show grants for 'use_user_1'@'localhost';\n+-----------------------------------------------------------+\n| Grants for use_user_1@localhost |\n+-----------------------------------------------------------+\n| GRANT select ON table *.* `use_user_1`@`localhost` |\n| GRANT insert ON table *.* `use_user_1`@`localhost` |\n| GRANT update ON table *.* `use_user_1`@`localhost` |\n| GRANT connect ON account `use_user_1`@`localhost` |\n| GRANT database all ON database * `use_user_1`@`localhost` |\n+-----------------------------------------------------------+\n5 rows in set (0.01 sec)\n-- \u53ef\u4ee5\u770b\u5230\uff0c\u7528\u6237 use_user_1 \u62e5\u6709\u9ed8\u8ba4\u7684\u8fde\u63a5 MatrixOne \u7684\u6743\u9650 connect\uff1b\u4e5f\u62e5\u6709\u5bf9\u6240\u6709\u8868\u7684 select\uff0cinsert \u548c update \u6743\u9650\uff0c\u540c\u65f6\u4e5f\u62e5\u6709\u5bf9\u6570\u636e\u5e93\u7684\u5168\u90e8\u6743\u9650\n
"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/","title":"\u5206\u5e03\u5f0f\u7248\u901a\u7528\u53c2\u6570\u914d\u7f6e","text":"\u5728 matrixone/etc/launch-with-proxy/ \u76ee\u5f55\u4e0b\uff0c\u6709\u56db\u4e2a\u914d\u7f6e\u6587\u4ef6\uff1acn.toml\u3001tn.toml\u3001proxy.toml \u548c log.toml\u3002\u8fd9\u4e9b\u914d\u7f6e\u6587\u4ef6\u4e2d\u5305\u542b\u7684\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_2","title":"\u9ed8\u8ba4\u53c2\u6570","text":"cn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [cn] cn \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 / port-base \"cn\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 18000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"127.0.0.1\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 port MatrixOne \u76d1\u542c\u53ca\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u7aef\u53e3 port = 6001 host \u76d1\u542c IP \u5730\u5740 host = \"0.0.0.0\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_3","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 cn.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 unix-socket \u76d1\u542c Unix \u57df\u63a5\u53e3 unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted \u63a7\u5236\u53f0\u8f93\u51fa\u67e5\u8be2\u957f\u5ea6 lengthOfQueryPrinted = 200000 enableTls \u662f\u5426\u542f\u7528 TLS enableTls = false tlsCaFile \u5ba2\u6237\u7aef SSL CA \u5217\u8868\u6587\u4ef6\u8def\u5f84 tlsCaFile = '' tlsCertFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsCertFile = '' tlsKeyFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsKeyFile = '' saveQueryResult \u662f\u5426\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c saveQueryResult = false queryResultTimeout \u67e5\u8be2\u7ed3\u679c\u8d85\u65f6\u65f6\u95f4 queryResultTimeout = 24 queryResultMaxsize \u67e5\u8be2\u7ed3\u679c\u6700\u5927\u89c4\u6a21 queryResultMaxsize = 100 lowerCaseTableNames \u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u654f\u611f\uff0c\u9ed8\u8ba4\u53c2\u6570\u503c\u4e3a 1\uff0c\u8868\u793a\u5927\u5c0f\u5199\u4e0d\u654f\u611f lowerCaseTableNames = 1 [cn.Txn] \u4e8b\u52a1\u914d\u7f6e\u8282 isolation \u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u3002\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u5b9a\u4e49\u4e86\u4e8b\u52a1\u5728\u5904\u7406\u5e76\u53d1\u64cd\u4f5c\u65f6\u7684\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u672a\u8bbe\u7f6e\u9694\u79bb\u7ea7\u522b\uff08Isolation\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\uff08Mode\uff09\u8bbe\u7f6e\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u5e8f\u5217\u5316\u9694\u79bb\uff08SI\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\u8bbe\u7f6e\u4e3a\u60b2\u89c2\uff08pessimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u53ef\u91cd\u590d\u8bfb\u9694\u79bb\uff08RC\uff09\u3002\u9ed8\u8ba4\uff1aRC isolation = \"RC\" mode \u4e8b\u52a1\u6a21\u5f0f\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u6a21\u5f0f\u3002\u4e8b\u52a1\u6a21\u5f0f\u5b9a\u4e49\u4e86\u5982\u4f55\u5904\u7406\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\u548c\u5e76\u53d1\u6027\u3002\u53ef\u9009\u7684\u503c\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u548c\u60b2\u89c2\uff08pessimistic\uff09\uff0c\u9ed8\u8ba4\u503c\u662f\u60b2\u89c2\uff08pessimistic\uff09\u3002 mode = \"pessimistic\" [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_4","title":"\u9ed8\u8ba4\u53c2\u6570","text":"tn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [dn] TN \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 uuid TN \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base \"TN\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 19000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"0.0.0.0\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_5","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 tn.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [dn.LogtailServer] Logtail \u670d\u52a1\u5668\u914d\u7f6e\u8282 rpc-enable-checksum \u662f\u5426\u5f00\u542f RPC \u6821\u9a8c\u548c rpc-enable-checksum = false [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_6","title":"\u9ed8\u8ba4\u53c2\u6570","text":"log.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [logservice] Logservice \u914d\u7f6e\u8282 uuid Logservice \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir \u9ed8\u8ba4\u6570\u636e\u76ee\u5f55 data-dir = \"./mo-data/logservice\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_7","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 log.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [logservice.BootstrapConfig] num-of-log-shards num-of-log-shards = 0 num-of-tn-shards num-of-tn-shards = 0 num-of-log-shard-replicas num-of-log-shard-replicas = 0 [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_8","title":"\u9ed8\u8ba4\u53c2\u6570","text":"proxy.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 listen-address \u76d1\u542c\u5730\u5740\uff0c\u9ed8\u8ba4\u4e3a0.0.0.0:6009
listen-address = \"0.0.0.0:6009\" [fileservice.s3] S3 \u6587\u4ef6\u670d\u52a1\u914d\u7f6e\u8282 bucket S3 \u6876\u540d\u79f0 bucket = \"my-bucket\" key-prefix S3 \u952e\u524d\u7f00 key-prefix = \"prefix/\""},{"location":"MatrixOne/Reference/System-Parameters/distributed-configuration-settings/#_9","title":"\u6269\u5c55\u53c2\u6570","text":"\u4f60\u8fd8\u53ef\u4ee5\u5728 proxy.toml \u6587\u4ef6\u4e2d\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 rebalance-interval \u91cd\u65b0\u5e73\u8861\u95f4\u9694\u3002\u8fd9\u662f\u4e24\u6b21\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u662f\u4e3a\u4e86\u5747\u8861\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8d1f\u8f7d\uff0c\u786e\u4fdd\u6bcf\u4e2a\u670d\u52a1\u5668\u90fd\u5177\u6709\u76f8\u4f3c\u7684\u5de5\u4f5c\u91cf\u3002 rebalance-interval = 30 rebalance-disabled \u91cd\u65b0\u5e73\u8861\u7981\u7528\u6807\u5fd7\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u88ab\u7981\u7528\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u81ea\u52a8\u6267\u884c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002 rebalance-disabled = false rebalance-tolerance \u91cd\u65b0\u5e73\u8861\u5bb9\u5fcd\u5ea6\u3002\u8fd9\u4e2a\u53c2\u6570\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u7684\u5bb9\u5fcd\u7a0b\u5ea6\u3002\u5f53\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u503c avg * (1 + tolerance) \u65f6\uff0c\u8fde\u63a5\u5c06\u88ab\u8fc1\u79fb\u5230\u5176\u4ed6 CN\uff08\u8ba1\u7b97\u8282\u70b9\uff09\u670d\u52a1\u5668\u4e0a\u3002\u5bb9\u5fcd\u5ea6\u7684\u503c\u5e94\u5c0f\u4e8e 1\uff0c\u5b83\u5b9a\u4e49\u4e86\u5728\u4f55\u79cd\u7a0b\u5ea6\u4e0a\u8fde\u63a5\u6570\u53ef\u4ee5\u8d85\u8fc7\u5e73\u5747\u503c\u800c\u4e0d\u89e6\u53d1\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5bb9\u5fcd\u5ea6\u8bbe\u7f6e\u4e3a 0.3\uff0c\u5f53\u67d0\u4e2a\u670d\u52a1\u5668\u7684\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u8fde\u63a5\u6570\u7684 30% \u65f6\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4f1a\u5f00\u59cb\u5c06\u8fde\u63a5\u8fc1\u79fb\u5230\u5176\u4ed6\u670d\u52a1\u5668\u4e0a\uff0c\u4ee5\u5e73\u8861\u8d1f\u8f7d\u3002 rebalance-tolerance = 0.3 [fileservice.s3] endpoint S3 \u7aef\u70b9\u5730\u5740 endpoint = \"s3.amazonaws.com\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" disk-path \u78c1\u76d8\u7f13\u5b58\u8def\u5f84 disk-path = \"/var/matrixone/cache\" disk-capacity \u78c1\u76d8\u7f13\u5b58\u5bb9\u91cf disk-capacity = \"8GB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/","title":"\u5355\u673a\u7248\u901a\u7528\u53c2\u6570\u914d\u7f6e","text":"\u5728 matrixone/etc/launch/ \u76ee\u5f55\u4e0b\u6709\u56db\u4e2a\u914d\u7f6e\u6587\u4ef6\uff1acn.toml\u3001tn.toml\u3001proxy.toml \u548c log.toml\uff0c\u7528\u4e8e\u914d\u7f6e\u901a\u7528\u53c2\u6570\u3002
"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#cntoml","title":"cn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_2","title":"\u9ed8\u8ba4\u53c2\u6570","text":"cn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [cn] cn \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 / port-base \"cn\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 18000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"127.0.0.1\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 port MatrixOne \u76d1\u542c\u53ca\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u7aef\u53e3 port = 6001 host \u76d1\u542c IP \u5730\u5740 host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_3","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 cn.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"mo.log\" [cn.frontend] \u524d\u7aef\u914d\u7f6e\u8282 unix-socket \u76d1\u542c Unix \u57df\u63a5\u53e3 unix-socket = \"/tmp/mysql.sock\" lengthOfQueryPrinted \u63a7\u5236\u53f0\u8f93\u51fa\u67e5\u8be2\u957f\u5ea6 lengthOfQueryPrinted = 200000 enableTls \u662f\u5426\u542f\u7528 TLS enableTls = false tlsCaFile \u5ba2\u6237\u7aef SSL CA \u5217\u8868\u6587\u4ef6\u8def\u5f84 tlsCaFile = '' tlsCertFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsCertFile = '' tlsKeyFile \u5ba2\u6237\u7aef X509 PEM \u683c\u5f0f\u5bc6\u94a5\u6587\u4ef6\u8def\u5f84 tlsKeyFile = '' saveQueryResult \u662f\u5426\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c saveQueryResult = false queryResultTimeout \u67e5\u8be2\u7ed3\u679c\u8d85\u65f6\u65f6\u95f4 queryResultTimeout = 24 queryResultMaxsize \u67e5\u8be2\u7ed3\u679c\u6700\u5927\u89c4\u6a21 queryResultMaxsize = 100 lowerCaseTableNames \u6807\u8bc6\u7b26\u5927\u5c0f\u5199\u654f\u611f\uff0c\u9ed8\u8ba4\u53c2\u6570\u503c\u4e3a 1\uff0c\u8868\u793a\u5927\u5c0f\u5199\u4e0d\u654f\u611f lowerCaseTableNames = 1 [cn.Txn] \u4e8b\u52a1\u914d\u7f6e\u8282 isolation \u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u3002\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u5b9a\u4e49\u4e86\u4e8b\u52a1\u5728\u5904\u7406\u5e76\u53d1\u64cd\u4f5c\u65f6\u7684\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u672a\u8bbe\u7f6e\u9694\u79bb\u7ea7\u522b\uff08Isolation\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\uff08Mode\uff09\u8bbe\u7f6e\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u5e8f\u5217\u5316\u9694\u79bb\uff08SI\uff09\uff0c\u5f53\u4e8b\u52a1\u6a21\u5f0f\u8bbe\u7f6e\u4e3a\u60b2\u89c2\uff08pessimistic\uff09\u65f6\uff0c\u9694\u79bb\u7ea7\u522b\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u53ef\u91cd\u590d\u8bfb\u9694\u79bb\uff08RC\uff09\u3002\u9ed8\u8ba4\uff1aRC isolation = \"RC\" mode \u4e8b\u52a1\u6a21\u5f0f\uff0c\u6b64\u53c2\u6570\u7528\u4e8e\u914d\u7f6e\u8282\u70b9\uff08cn\uff09\u4e0a\u7684\u4e8b\u52a1\u6a21\u5f0f\u3002\u4e8b\u52a1\u6a21\u5f0f\u5b9a\u4e49\u4e86\u5982\u4f55\u5904\u7406\u4e8b\u52a1\u4e2d\u7684\u64cd\u4f5c\u548c\u5e76\u53d1\u6027\u3002\u53ef\u9009\u7684\u503c\u4e3a\u4e50\u89c2\uff08optimistic\uff09\u548c\u60b2\u89c2\uff08pessimistic\uff09\uff0c\u9ed8\u8ba4\u503c\u662f\u4e50\u89c2\uff08optimistic\uff09\u3002 mode = \"optimistic\" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#tntoml","title":"tn.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_4","title":"\u9ed8\u8ba4\u53c2\u6570","text":"tn.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [dn] TN \u8282\u70b9\uff0c\u4e0d\u53ef\u4fee\u6539 uuid TN \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd4dccb4-4d3c-41f8-b482-5251dc7a41bf\" port-base \"TN\" \u4f7f\u7528\u7684\u8d77\u59cb\u7aef\u53e3\u53f7\uff0c\u4ece\u7aef\u53e3\u53f7\u5f80\u540e\uff0c\u8fde\u7eed 20 \u4e2a\u7aef\u53e3\u627e\u5230\u53ef\u7528\u7aef\u53e3\u7528\u4e8e\u5185\u90e8\u670d\u52a1 port-base = 19000 service-host \u670d\u52a1\u8fde\u63a5\u5730\u5740\uff0c\u7528\u4e8e\u6ce8\u518c\u5230 HAKeeper \u4e2d service-host = \"0.0.0.0\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_5","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 tn.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"tn.log\" [dn.LogtailServer] Logtail \u670d\u52a1\u5668\u914d\u7f6e\u8282 rpc-enable-checksum \u662f\u5426\u5f00\u542f RPC \u6821\u9a8c\u548c rpc-enable-checksum = false [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#logtoml","title":"log.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_6","title":"\u9ed8\u8ba4\u53c2\u6570","text":"log.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [logservice] Logservice \u914d\u7f6e\u8282 uuid Logservice \u7684\u552f\u4e00\u6807\u8bc6\u7b26\uff0c\u4e0d\u53ef\u4fee\u6539 uuid = \"dd1dccb4-4d3c-41f8-b482-5251dc7a41bf\" data-dir \u9ed8\u8ba4\u6570\u636e\u76ee\u5f55 data-dir = \"./mo-data\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_7","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 log.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"log1.log\" [logservice] Logservice \u914d\u7f6e\u8282 logservice-address Logservice \u5730\u5740 logservice-address = \"0.0.0.0:32000\" raft-address Raft \u5730\u5740 raft-address = \"0.0.0.0:32001\" gossip-address Gossip \u5730\u5740 gossip-address = \"0.0.0.0:32002\" gossip-seed-addresses Gossip \u79cd\u5b50\u8282\u70b9\u5730\u5740 gossip-seed-addresses = \" \" [LogtailServer.BootstrapConfig] LogtailServer \u542f\u52a8\u914d\u7f6e\u8282 init-hakeeper-members \u521d\u59cb HAKeeper \u6210\u5458 init-hakeeper-members = \" \" [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#proxytoml","title":"proxy.toml","text":""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_8","title":"\u9ed8\u8ba4\u53c2\u6570","text":"proxy.toml \u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5305\u542b\u4ee5\u4e0b\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 level \u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4\u503c\u4e3a info\uff0c\u53ef\u4fee\u6539\u4e3a\u4e0d\u540c\u7ea7\u522b level = \"info\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 listen-address \u76d1\u542c\u5730\u5740\uff0c\u9ed8\u8ba4\u4e3a0.0.0.0:6009
listen-address = \"0.0.0.0:6009\""},{"location":"MatrixOne/Reference/System-Parameters/standalone-configuration-settings/#_9","title":"\u6269\u5c55\u53c2\u6570","text":"\u5728 proxy.toml \u6587\u4ef6\u4e2d\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u53c2\u6570\uff1a
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca \u4e66\u5199\u683c\u5f0f\u793a\u4f8b [log] \u65e5\u5fd7\u914d\u7f6e\u8282 format \u65e5\u5fd7\u4fdd\u5b58\u683c\u5f0f\u4e3a JSON \u6216\u5176\u4ed6 format = \"console\" filename \u65e5\u5fd7\u6587\u4ef6\u540d filename = \"proxy.log\" [proxy] \u4ee3\u7406\u914d\u7f6e\u8282 rebalance-interval \u91cd\u65b0\u5e73\u8861\u95f4\u9694\u3002\u8fd9\u662f\u4e24\u6b21\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4e4b\u95f4\u7684\u65f6\u95f4\u95f4\u9694\u3002\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u662f\u4e3a\u4e86\u5747\u8861\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u8d1f\u8f7d\uff0c\u786e\u4fdd\u6bcf\u4e2a\u670d\u52a1\u5668\u90fd\u5177\u6709\u76f8\u4f3c\u7684\u5de5\u4f5c\u91cf\u3002 rebalance-interval = 30 rebalance-disabled \u91cd\u65b0\u5e73\u8861\u7981\u7528\u6807\u5fd7\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u88ab\u7981\u7528\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u81ea\u52a8\u6267\u884c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002 rebalance-disabled = false rebalance-tolerance \u91cd\u65b0\u5e73\u8861\u5bb9\u5fcd\u5ea6\u3002\u8fd9\u4e2a\u53c2\u6570\u8868\u793a\u91cd\u65b0\u5e73\u8861\u5668\u7684\u5bb9\u5fcd\u7a0b\u5ea6\u3002\u5f53\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u503c avg * (1 + tolerance) \u65f6\uff0c\u8fde\u63a5\u5c06\u88ab\u8fc1\u79fb\u5230\u5176\u4ed6 CN\uff08\u8ba1\u7b97\u8282\u70b9\uff09\u670d\u52a1\u5668\u4e0a\u3002\u5bb9\u5fcd\u5ea6\u7684\u503c\u5e94\u5c0f\u4e8e 1\uff0c\u5b83\u5b9a\u4e49\u4e86\u5728\u4f55\u79cd\u7a0b\u5ea6\u4e0a\u8fde\u63a5\u6570\u53ef\u4ee5\u8d85\u8fc7\u5e73\u5747\u503c\u800c\u4e0d\u89e6\u53d1\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5bb9\u5fcd\u5ea6\u8bbe\u7f6e\u4e3a 0.3\uff0c\u5f53\u67d0\u4e2a\u670d\u52a1\u5668\u7684\u8fde\u63a5\u6570\u8d85\u8fc7\u5e73\u5747\u8fde\u63a5\u6570\u7684 30% \u65f6\uff0c\u91cd\u65b0\u5e73\u8861\u64cd\u4f5c\u4f1a\u5f00\u59cb\u5c06\u8fde\u63a5\u8fc1\u79fb\u5230\u5176\u4ed6\u670d\u52a1\u5668\u4e0a\uff0c\u4ee5\u5e73\u8861\u8d1f\u8f7d\u3002 rebalance-tolerance = 0.3 [fileservice.cache] \u6587\u4ef6\u670d\u52a1\u7f13\u5b58\u914d\u7f6e\u8282 memory-capacity cache \u5185\u5b58\u5927\u5c0f memory-capacity = \"512MB\" [observability] \u53ef\u89c2\u6d4b\u6027\u53c2\u6570 host \u66b4\u9732\u5ea6\u91cf\u670d\u52a1\u76d1\u542c IP\u3002\u8be5\u53c2\u6570\u6307\u5b9a\u4e86\u5ea6\u91cf\u670d\u52a1\uff08metrics service\uff09\u76d1\u542c\u7684 IP \u5730\u5740\u3002 host = \"0.0.0.0\" statusPort prometheus \u76d1\u63a7\u7aef\u53e3\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u5ea6\u91cf\u670d\u52a1\u76d1\u542c\u7684\u7aef\u53e3\u53f7\u3002\u5ea6\u91cf\u670d\u52a1\u901a\u5e38\u901a\u8fc7 HTTP \u63d0\u4f9b\u5ea6\u91cf\u6570\u636e\uff0c\u8be5\u53c2\u6570\u7ed3\u5408 host \u53c2\u6570\u6784\u6210\u5ea6\u91cf\u670d\u52a1\u7684\u8bbf\u95ee\u5730\u5740\u3002 statusPort = 7001 enableMetricToProm \u542f\u7528\u5ea6\u91cf\u670d\u52a1\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u8868\u793a\u542f\u7528\u5ea6\u91cf\u670d\u52a1 enableMetricToProm = false disableMetric \u7981\u7528\u5ea6\u91cf\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u4e0d\u4f1a\u6536\u96c6\u4efb\u4f55\u5ea6\u91cf\u6570\u636e\uff0c\u540c\u65f6\u4e5f\u4e0d\u4f1a\u76d1\u542c\u5ea6\u91cf\u670d\u52a1\u7aef\u53e3 disableMetric = false disableTrace \u7981\u7528\u8ddf\u8e2a\u6536\u96c6\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a true\uff0c\u7cfb\u7edf\u5c06\u505c\u6b62\u6536\u96c6\u4efb\u4f55\u8ddf\u8e2a\uff08trace\uff09\u3001\u5ea6\u91cf\uff08metric\uff09\u548c\u65e5\u5fd7\uff08log\uff09\u6570\u636e\uff0c disableTrace = false longQueryTime \u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u7684\u67e5\u8be2\u3002\u8be5\u53c2\u6570\u5b9a\u4e49\u4e86\u4e00\u4e2a\u9608\u503c\uff0c\u4ee5\u79d2\u4e3a\u5355\u4f4d\uff0c\u7528\u4e8e\u7b5b\u9009\u51fa\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8be5\u9608\u503c\u7684\u67e5\u8be2\u8bed\u53e5\uff0c\u7136\u540e\u8bb0\u5f55\u8fd9\u4e9b\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff08ExecPlan\uff09\u3002\u5982\u679c\u67e5\u8be2\u7684\u6267\u884c\u65f6\u95f4\u8d85\u8fc7\u8fd9\u4e2a\u9608\u503c\uff0c\u7cfb\u7edf\u4f1a\u8bb0\u5f55\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0.0\uff0c\u8868\u793a\u8bb0\u5f55\u6240\u6709\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\u3002 longQueryTime = 1.0"},{"location":"MatrixOne/Reference/System-Parameters/system-parameter/","title":"\u7cfb\u7edf\u53c2\u6570\u6982\u8ff0","text":"\u5728 MatrixOne \u4e2d\uff0c\u6d89\u53ca\u591a\u79cd\u6570\u636e\u5e93\u7cfb\u7edf\u53c2\u6570\uff0c\u5176\u4e2d\u4e00\u90e8\u5206\u4ee5\u914d\u7f6e\u6587\u4ef6\u7684\u65b9\u5f0f\u8fdb\u884c\u8bbe\u7f6e\uff0c\u4ec5\u5728\u542f\u52a8\u65f6\u751f\u6548\uff0c\u8fd9\u7c7b\u53c2\u6570\u88ab\u79f0\u4e3a\u9759\u6001\u53c2\u6570\u3002
\u53e6\u4e00\u79cd\u7c7b\u578b\u662f\u53ef\u4ee5\u5728\u5ba2\u6237\u7aef\u8fdb\u884c\u52a8\u6001\u914d\u7f6e\u4e14\u7acb\u5373\u751f\u6548\u7684\u53c2\u6570\uff0c\u88ab\u79f0\u4e3a\u52a8\u6001\u53c2\u6570\u3002\u8fd9\u4e24\u79cd\u53c2\u6570\u7c7b\u578b\u7528\u4e8e\u914d\u7f6e\u548c\u63a7\u5236 MatrixOne \u670d\u52a1\u5668\u7684\u884c\u4e3a\u3002
\u52a8\u6001\u53c2\u6570\u7684\u4fee\u6539\u65b9\u5f0f\u53ef\u4ee5\u5206\u4e3a\u4f1a\u8bdd\u7ea7\u522b\u548c\u5168\u5c40\u7ea7\u522b\u7684\u53c2\u6570\u914d\u7f6e\u3002
\u5168\u5c40\u7ea7\u522b\u53c2\u6570\u914d\u7f6e\uff1a\u9488\u5bf9 MatrixOne \u5f53\u524d\u79df\u6237\u7684\u53c2\u6570\u914d\u7f6e\u3002\u8fd9\u4e9b\u53c2\u6570\u5f71\u54cd\u6240\u6709\u65b0\u8fde\u63a5\u5230\u8be5\u79df\u6237\u7684\u4f1a\u8bdd\u3002\u5168\u5c40\u53c2\u6570\u5728 MatrixOne \u670d\u52a1\u5668\u542f\u52a8\u65f6\u4f1a\u6301\u4e45\u5316\u4fdd\u5b58\u5728\u5143\u6570\u636e\u8868 mo_catalog.mo_mysql_compatbility_mode \u4e2d\uff0c\u5bf9\u5168\u5c40\u53c2\u6570\u7684\u4fee\u6539\u4f1a\u5728\u4e0b\u6b21\u767b\u5f55\u65f6\u751f\u6548\u3002
\u4f1a\u8bdd\u7ea7\u522b\u53c2\u6570\u914d\u7f6e\uff1a\u9488\u5bf9\u5355\u4e2a MatrixOne \u8fde\u63a5\u7684\u53c2\u6570\u914d\u7f6e\u3002\u8fd9\u4e9b\u53c2\u6570\u4ec5\u5f71\u54cd\u8be5\u8fde\u63a5\u7684\u884c\u4e3a\u3002\u4f1a\u8bdd\u53c2\u6570\u4f1a\u5728\u8fde\u63a5\u5efa\u7acb\u65f6\u4ece mo_catalog.mo_mysql_compatbility_mode \u4e2d\u8bfb\u53d6\uff0c\u53ef\u4ee5\u901a\u8fc7\u5ba2\u6237\u7aef\u547d\u4ee4\u6765\u914d\u7f6e\u5f53\u524d\u8fde\u63a5\u3002\u5f53\u8fde\u63a5\u5173\u95ed\u65f6\uff0c\u4f1a\u8bdd\u53c2\u6570\u7684\u914d\u7f6e\u5c06\u4f1a\u88ab\u91cd\u7f6e\u4e3a\u9ed8\u8ba4\u503c\u3002
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cMatrixOne \u662f\u4e00\u4e2a\u591a\u79df\u6237\u6570\u636e\u5e93\uff0cset global
\u53ea\u4f1a\u5f71\u54cd\u5f53\u524d\u79df\u6237\u3002
\u9759\u6001\u53c2\u6570\u7684\u76f8\u5173\u6587\u6863\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\uff1a
\u52a8\u6001\u53c2\u6570\u7684\u76f8\u5173\u6587\u6863\uff0c\u4f60\u53ef\u4ee5\u53c2\u8003\uff1a
\u5728 MatrixOne \u4e2d\uff0c\u81ea\u5b9a\u4e49\u53d8\u91cf\u662f\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u548c\u64cd\u4f5c\u503c\u7684\u673a\u5236\u3002\u81ea\u5b9a\u4e49\u53d8\u91cf\u53ef\u4ee5\u901a\u8fc7 SET
\u8bed\u53e5\u8bbe\u7f6e\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u6574\u4e2a\u4f1a\u8bdd\u671f\u95f4\u4fdd\u6301\u503c\u4e0d\u53d8\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7 SET
\u547d\u4ee4\u8fdb\u884c\u53d8\u91cf\u7684\u81ea\u5b9a\u4e49\uff0c\u5e76\u4e14\u5728 SQL \u4e2d\u4f7f\u7528\u3002\u5177\u4f53\u8bed\u6cd5\u5982\u4e0b\uff1a
SET @variable_name = value;\n
@variable_name
\u662f\u81ea\u5b9a\u4e49\u53d8\u91cf\u7684\u540d\u79f0\uff0cvalue
\u662f\u8981\u5206\u914d\u7ed9\u8be5\u53d8\u91cf\u7684\u503c\u3002\u4e00\u65e6\u5b9a\u4e49\u4e86\u53d8\u91cf\uff0c\u53ef\u4ee5\u5728 SQL \u8bed\u53e5\u4e2d\u4f7f\u7528\u5b83\u6765\u4ee3\u66ff\u5b9e\u9645\u7684\u503c\u3002
\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8bed\u53e5\u5c06\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a @max_salary
\u7684\u53d8\u91cf\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a 100000\uff1a
SET @max_salary = 100000;\n-- \u67e5\u770b @max_salary \u53d8\u91cf\u8bbe\u7f6e\u7684\u503c\nmysql> select @max_salary;\n+-------------+\n| @max_salary |\n+-------------+\n| 100000 |\n+-------------+\n1 row in set (0.01 sec)\n
\u5728\u4f7f\u7528\u81ea\u5b9a\u4e49\u53d8\u91cf\u65f6\uff0c\u53ef\u4ee5\u5c06\u5176\u5305\u542b\u5728 SQL \u8bed\u53e5\u4e2d\uff0c\u4f7f\u7528 @variable_name
\u7684\u5f62\u5f0f\u5f15\u7528\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8bed\u53e5\u5c06\u8fd4\u56de\u6240\u6709\u85aa\u6c34\u5c0f\u4e8e @max_salary
\u7684\u5458\u5de5\u8bb0\u5f55\uff1a
SELECT * FROM employees WHERE salary < @max_salary;\n
\u53ef\u4ee5\u901a\u8fc7\u66f4\u6539\u81ea\u5b9a\u4e49\u53d8\u91cf\u7684\u503c\u6765\u5f71\u54cd SQL \u67e5\u8be2\u7684\u7ed3\u679c\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u8bed\u53e5\u5c06\u66f4\u6539 @max_salary
\u7684\u503c\uff0c\u5e76\u8fd4\u56de\u65b0\u7684\u67e5\u8be2\u7ed3\u679c\uff1a
SET @max_salary = 80000;\nSELECT * FROM employees WHERE salary < @max_salary;\n
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u81ea\u5b9a\u4e49\u53d8\u91cf\u53ea\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u4fdd\u6301\u6709\u6548\uff0c\u5f53\u4f1a\u8bdd\u7ed3\u675f\u65f6\uff0c\u53d8\u91cf\u5c06\u88ab\u5220\u9664\u5e76\u91ca\u653e\u3002\u6b64\u5916\uff0c\u53d8\u91cf\u540d\u5fc5\u987b\u4ee5 @
\u7b26\u53f7\u5f00\u5934\uff0c\u5e76\u4e14\u5927\u5c0f\u5199\u654f\u611f\u3002
\u73b0\u5728\u4ee5\u5b9a\u4e49\u4e24\u4e2a\u53d8\u91cf a \u548c b \u4e3a\u4f8b\uff1a
> SET @a=2, @b=3;\nQuery OK, 0 rows affected (0.00 sec)\n\n> select @a;\n+------+\n| @a |\n+------+\n| 2 |\n+------+\n1 row in set (0.00 sec)\n\n> select @b;\n+------+\n| @b |\n+------+\n| 3 |\n+------+\n1 row in set (0.00 sec)\n
\u5728 SQL \u4e2d\u4f7f\u7528\u81ea\u5b9a\u4e49\u53d8\u91cf\uff1a
> create table t1(a int,b varchar(1));\nQuery OK, 0 rows affected (0.02 sec)\n\n> insert into t1 values(@a,@b);\nQuery OK, 1 row affected (0.02 sec)\n\n> select * from t1;\n+------+------+\n| a | b |\n+------+------+\n| 2 | 3 |\n+------+------+\n1 row in set (0.01 sec)\n
Note
\u53d8\u91cf a \u548c b \u5728\u6b64\u5904\u90fd\u662f int \u6570\u636e\u7c7b\u578b\uff0c\u5982\u679c\u60f3\u8981\u4e00\u4e2a\u5b57\u7b26\u4e32\u7684 2 \u6216 3\uff0c\u5efa\u8bae\u4f7f\u7528 SET @a='2', @b='3';
\u3002
MatrixOne \u652f\u6301\u4f1a\u8bdd\u7ea7\u522b\uff0c\u4e0e MySQL \u652f\u6301\u60c5\u51b5\u76f8\u540c\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/","title":"\u5916\u952e\u7ea6\u675f\u68c0\u67e5","text":"\u5728 MatrixOne \u4e2d\uff0cforeign_key_checks
\u662f\u4e00\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff0c\u7528\u4e8e\u63a7\u5236\u5916\u952e\u7ea6\u675f\u7684\u68c0\u67e5\u3002\u8fd9\u4e2a\u53d8\u91cf\u53ef\u4ee5\u662f\u5168\u5c40\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u4f1a\u8bdd\u7ea7\u522b\u7684\u3002\u5f53\u8bbe\u7f6e\u4e3a 1\uff08\u9ed8\u8ba4\u503c\uff09\u65f6\uff0cMatrixOne \u4f1a\u68c0\u67e5\u5916\u952e\u7ea6\u675f\u7684\u5b8c\u6574\u6027\uff0c\u786e\u4fdd\u6570\u636e\u7684\u53c2\u7167\u5b8c\u6574\u6027\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a 0\uff0c\u5219\u8df3\u8fc7\u8fd9\u4e9b\u68c0\u67e5\u3002
Note
\u4e0e MySQL \u884c\u4e3a\u4e0d\u4e00\u81f4\u7684\u662f\uff0c\u5f53\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u5220\u9664\u7236\u8868\uff0cMySQL \u4e0d\u4f1a\u5220\u9664\u5b50\u8868\u5f15\u7528\u7236\u8868\u7684\u5916\u952e\u5173\u7cfb\uff0c\u4f46 MatrixOne \u4f1a\u5220\u9664\u5b50\u8868\u5f15\u7528\u7236\u8868\u7684\u5916\u952e\u5173\u7cfb\uff0c\u91cd\u5efa\u7236\u8868\u540e\u4f1a\u91cd\u65b0\u5efa\u7acb\u5916\u952e\u5173\u7cfb\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/#foreign_key_checks","title":"\u67e5\u770b foreign_key_checks","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b foreign_key_checks\uff1a
--\u5168\u5c40\u6a21\u5f0f\nSELECT @@global.foreign_key_checks;\nSHOW global VARIABLES LIKE 'foreign_key_checks';\n\n--\u4f1a\u8bdd\u6a21\u5f0f\nSELECT @@session.foreign_key_checks;\nSHOW session VARIABLES LIKE 'foreign_key_checks';\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/#foreign_key_checks_1","title":"\u8bbe\u7f6e foreign_key_checks","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e foreign_key_checks\uff1a
--\u5168\u5c40\u6a21\u5f0f\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\nset global foreign_key_checks = 'xxx' --\u4f1a\u8bdd\u6a21\u5f0f\nset session foreign_key_checks = 'xxx'\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/foreign_key_checks/#_2","title":"\u793a\u4f8b","text":"mysql> SELECT @@session.foreign_key_checks;\n+----------------------+\n| @@foreign_key_checks |\n+----------------------+\n| 1 |\n+----------------------+\n1 row in set (0.00 sec)\n\ncreate table t2(a int primary key,b int);\ncreate table t1( b int, constraint `c1` foreign key `fk1` (b) references t2(a));\n\ninsert into t2 values(1,2);\nmysql> insert into t1 values(3);--\u5f00\u542f\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u4e0d\u80fd\u63d2\u5165\u8fdd\u53cd\u7ea6\u675f\u7684\u503c\nERROR 20101 (HY000): internal error: Cannot add or update a child row: a foreign key constraint fails\n\nmysql> drop table t2;--\u5f00\u542f\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u4e0d\u80fd\u5220\u9664\u7236\u8868\nERROR 20101 (HY000): internal error: can not drop table 't2' referenced by some foreign key constraint\n\nset session foreign_key_checks =0;--\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\nmysql> SELECT @@session.foreign_key_checks;\n+----------------------+\n| @@foreign_key_checks |\n+----------------------+\n| 0 |\n+----------------------+\n1 row in set (0.00 sec)\n\nmysql> insert into t1 values(3);--\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u53ef\u4ee5\u63d2\u5165\u8fdd\u53cd\u7ea6\u675f\u7684\u503c\nQuery OK, 1 row affected (0.01 sec)\n\nmysql> drop table t2;--\u5173\u95ed\u5916\u952e\u7ea6\u675f\u68c0\u67e5\u65f6\uff0c\u53ef\u4ee5\u5220\u9664\u7236\u8868\uff0c\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> show create table t1;--\u5220\u9664\u7236\u8868\uff0c\u5916\u952e\u7ea6\u675f\u4e5f\u88ab\u5220\u9664\n+-------+--------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`b` INT DEFAULT NULL\n) |\n+-------+--------------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> create table t2(n1 int);--\u91cd\u5efa\u88ab\u5220\u9664\u7684\u7236\u8868 t2\uff0c\u9700\u5305\u542b\u5b50\u8868\u539f\u5916\u952e\u5f15\u7528\u5217\nERROR 20101 (HY000): internal error: column 'a' no exists in table ''\n\nmysql> create table t2(n1 int,a int primary key);--\u5305\u542b\u88ab\u5f15\u7528\u7684\u4e3b\u952e\u5217 a\uff0c\u91cd\u5efa\u6210\u529f\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> show create table t1;--\u91cd\u5efa t2 \u540e\uff0c\u5916\u952e\u5173\u7cfb\u4f1a\u81ea\u52a8\u91cd\u65b0\u5efa\u7acb\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`b` INT DEFAULT NULL,\nCONSTRAINT `c1` FOREIGN KEY (`b`) REFERENCES `t2` (`a`) ON DELETE RESTRICT ON UPDATE RESTRICT\n) |\n+-------+-------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/keep_user_target_list_in_result/","title":"keep_user_target_list_in_result \u4fdd\u6301\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u5927\u5c0f\u5199\u4e00\u81f4","text":"\u5728 MatrixOne \u67e5\u8be2\u4e2d\uff0c\u4fdd\u6301\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u4e00\u81f4\uff0c\u9664\u4e86\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u522b\u540d\uff08alias\uff09\u6765\u5b9e\u73b0\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u53c2\u6570\u6765\u5b9e\u73b0\u3002
keep_user_target_list_in_result
\u662f MatrixOne \u8bbe\u7f6e\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u5199\u662f\u5426\u4e00\u81f4\u7684\u4e00\u4e2a\u5168\u5c40\u53c2\u6570\u3002
\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b keep_user_target_list_in_result
\uff1a
--\u9ed8\u8ba4\u4e3a 1\nshow variables like \"keep_user_target_list_in_result\";\nselect @@keep_user_target_list_in_result;\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/keep_user_target_list_in_result/#keep_user_target_list_in_result_2","title":"\u8bbe\u7f6e keep_user_target_list_in_result","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e keep_user_target_list_in_result
\uff1a
--\u9ed8\u8ba4\u4e3a 1\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\nset global keep_user_target_list_in_result = 0;\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/keep_user_target_list_in_result/#_1","title":"\u793a\u4f8b","text":"create table t1(aa int, bb int, cc int, AbC varchar(25), A_BC_d double);\ninsert into t1 values (1,2,3,'A',10.9);\n\nmysql> select * from t1; +------+------+------+------+--------+\n| aa | bb | cc | abc | a_bc_d |\n+------+------+------+------+--------+\n| 1 | 2 | 3 | A | 10.9 |\n+------+------+------+------+--------+\n1 row in set (0.00 sec)\n\nmysql> select @@keep_user_target_list_in_result; --\u67e5\u8be2\u53c2\u6570\u503c\uff0c\u9ed8\u8ba4\u5f00\u542f\n+-----------------------------------+\n| @@keep_user_target_list_in_result |\n+-----------------------------------+\n| 1 |\n+-----------------------------------+\n1 row in set (0.01 sec)\n\nmysql> select aA, bB, CC, abc, a_Bc_D from t1;--\u5728\u5f00\u542f\u60c5\u51b5\u4e0b\uff0c\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u5199\u4e00\u81f4\n+------+------+------+------+--------+\n| aA | bB | CC | abc | a_Bc_D |\n+------+------+------+------+--------+\n| 1 | 2 | 3 | A | 10.9 |\n+------+------+------+------+--------+\n1 row in set (0.00 sec)\n\nmysql> set global keep_user_target_list_in_result =0;--\u5173\u95ed\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u4e00\u81f4\u8bbe\u7f6e\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> exit;--\u9000\u51fa\u6570\u636e\u5e93\u91cd\u65b0\u8fde\u63a5\u540e\u53c2\u6570\u751f\u6548\n\nmysql> show variables like \"keep_user_target_list_in_result\";\n+---------------------------------+-------+\n| Variable_name | Value |\n+---------------------------------+-------+\n| keep_user_target_list_in_result | 0 |\n+---------------------------------+-------+\n1 row in set (0.00 sec)\n\nmysql> select aA, bB, CC, abc, a_Bc_D from t1;--\u5728\u8bbe\u7f6e\u5173\u95ed\u60c5\u51b5\u4e0b\uff0c\u67e5\u8be2\u7ed3\u679c\u96c6\u5217\u540d\u4e0e\u7528\u6237\u6307\u5b9a\u7684\u540d\u79f0\u5927\u5c0f\u5199\u4e0d\u4e00\u81f4\n+------+------+------+------+--------+\n| aa | bb | cc | abc | a_bc_d |\n+------+------+------+------+--------+\n| 1 | 2 | 3 | A | 10.9 |\n+------+------+------+------+--------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/","title":"lower_case_table_names \u5927\u5c0f\u5199\u654f\u611f\u652f\u6301","text":"lower_case_table_names
\u662f MatrixOne \u8bbe\u7f6e\u5927\u5c0f\u5199\u662f\u5426\u654f\u611f\u7684\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\u3002
Note
\u4e0e mysql \u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u6682\u65f6\u53ea\u652f\u6301 0 \u548c 1 \u4e24\u79cd\u6a21\u5f0f\uff0c\u4e14\u5728 linux \u548c mac \u7cfb\u7edf\u4e0b\u9ed8\u8ba4\u503c\u90fd\u4e3a 1\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#lower_case_table_names_1","title":"\u67e5\u770b lower_case_table_names","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b lower_case_table_names
\uff1a
show variables like \"lower_case_table_names\";--\u9ed8\u8ba4\u4e3a 1\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#lower_case_table_names_2","title":"\u8bbe\u7f6e lower_case_table_names","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e lower_case_table_names
\uff1a
set global lower_case_table_names = 0;--\u9ed8\u8ba4\u4e3a 1\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#_1","title":"\u53c2\u6570\u89e3\u91ca","text":""},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#0","title":"\u53c2\u6570\u8bbe\u7f6e\u4e3a 0","text":"\u5c06 lower_case_table_names
\u8bbe\u7f6e\u4e3a 0\u3002\u6807\u8bc6\u7b26\u5b58\u50a8\u4e3a\u539f\u59cb\u5b57\u7b26\u4e32\uff0c\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u654f\u611f\u3002
\u793a\u4f8b
mysql> show variables like \"lower_case_table_names\";--\u67e5\u770b\u9ed8\u8ba4\u53c2\u6570\uff0c\u9ed8\u8ba4\u503c\u4e3a 1\n+------------------------+-------+\n| Variable_name | Value |\n+------------------------+-------+\n| lower_case_table_names | 1 |\n+------------------------+-------+\n1 row in set (0.00 sec)\n\nset global lower_case_table_names = 0;--\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\n\nmysql> show variables like \"lower_case_table_names\";--\u91cd\u8fde\u6570\u636e\u5e93\u67e5\u770b\u53c2\u6570\uff0c\u4fee\u6539\u6210\u529f\n+------------------------+-------+\n| Variable_name | Value |\n+------------------------+-------+\n| lower_case_table_names | 0 |\n+------------------------+-------+\n1 row in set (0.00 sec)\n\ncreate table Tt (Aa int);\ninsert into Tt values (1), (2), (3);\n\nmysql> select Aa from Tt;--\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u654f\u611f\n+------+\n| Aa |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.03 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/lower_case_tables_name/#1","title":"\u53c2\u6570\u8bbe\u7f6e\u4e3a 1","text":"\u5c06 lower_case_table_names
\u8bbe\u7f6e\u4e3a 1\u3002\u6807\u8bc6\u7b26\u5b58\u50a8\u4e3a\u5c0f\u5199\uff0c\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002
\u793a\u4f8b
set global lower_case_table_names = 1;--\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\n\nmysql> show variables like \"lower_case_table_names\";--\u91cd\u8fde\u6570\u636e\u5e93\u67e5\u770b\u53c2\u6570\uff0c\u4fee\u6539\u6210\u529f\n+------------------------+-------+\n| Variable_name | Value |\n+------------------------+-------+\n| lower_case_table_names | 1 |\n+------------------------+-------+\n1 row in set (0.00 sec)\n\ncreate table Tt (Aa int,Bb int);\ninsert into Tt values (1,2), (2,3), (3,4);\n\nmysql> select Aa from Tt;--\u540d\u79f0\u6bd4\u8f83\u5927\u5c0f\u5199\u4e0d\u654f\u611f\n+------+\n| aa |\n+------+\n| 1 |\n| 2 |\n| 3 |\n+------+\n3 rows in set (0.03 sec)\n\n-- \u5217\u7684\u522b\u540d\u5728\u8fd4\u56de\u7ed3\u679c\u96c6\u65f6\u4f1a\u663e\u793a\u539f\u59cb\u5b57\u7b26\u4e32\uff0c\u4f46\u540d\u79f0\u6bd4\u8f83\u65f6\u5927\u5c0f\u5199\u4e0d\u654f\u611f\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a\nmysql> select Aa as AA,Bb from Tt;\n+------+------+\n| AA | bb |\n+------+------+\n| 1 | 2 |\n| 2 | 3 |\n| 3 | 4 |\n+------+------+\n3 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/","title":"save_query_result \u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u652f\u6301","text":"\u5f00\u542f save_query_result
\u540e\uff0cMatrixOne \u4f1a\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u3002
\u5bf9\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u6709\u5f71\u54cd\u7684\u53c2\u6570\u6709\u4e09\u4e2a\uff1a
save_query_result
\uff1a\u5f00\u542f/\u5173\u95ed\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u3002
query_result_timeout
\uff1a\u8bbe\u7f6e\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u7684\u65f6\u95f4\u3002
query_result_maxsize
\uff1a\u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u6700\u5927\u503c\u3002
SELECT
, SHOW
, DESC
, EXECUTE
\u8bed\u53e5SELECT
\u8bed\u53e5\uff0c\u53ea\u4fdd\u5b58\u4ee5 /* cloud_user */
\u548c /* save_result */
\u56fa\u5b9a\u5f00\u5934\u7684 SELECT
\u8bed\u53e5\u7684\u7ed3\u679c\u3002-- \u9ed8\u8ba4\u4e3a off\nset save_query_result = on
-- \u9ed8\u8ba4\u4e3a off\nset global save_query_result = on
\u5168\u5c40\u5f00\u542f\u4e5f\u53ef\u5728\u542f\u52a8 MatrixOne \u4e4b\u524d\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 cn.toml
\uff0c\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1a
[cn.frontend]\nsaveQueryResult = \"on\" // \u9ed8\u8ba4\u4e3a off\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_3","title":"\u8bbe\u7f6e\u4fdd\u5b58\u65f6\u95f4","text":"\u8bbe\u7f6e\u4fdd\u5b58\u65f6\u95f4\u5355\u4f4d\u4e3a\u5c0f\u65f6\u3002
-- \u9ed8\u8ba4\u4e3a 24\nset query_result_timeout = 48\n
-- \u9ed8\u8ba4\u4e3a 24\nset global query_result_timeout = 48\n
\u5168\u5c40\u5f00\u542f\u4e5f\u53ef\u5728\u542f\u52a8 MatrixOne \u4e4b\u524d\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 cn.toml
\uff0c\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1a
[cn.frontend]\nqueryResultTimeout = 48 // \u9ed8\u8ba4\u4e3a 24\n
Note: \u4fdd\u5b58\u65f6\u95f4\u5982\u679c\u8bbe\u7f6e\u7684\u503c\u6bd4\u4e0a\u4e00\u6b21\u8bbe\u7f6e\u7684\u77ed\uff0c\u4e0d\u5f71\u54cd\u4e4b\u524d\u7684\u4fdd\u5b58\u7ed3\u679c\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_4","title":"\u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u7684\u6700\u5927\u503c","text":"\u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u7684\u6700\u5927\u503c\u5355\u4f4d\u4e3a MB\u3002
-- \u9ed8\u8ba4\u4e3a 100\nset query_result_maxsize = 200\n
-- \u9ed8\u8ba4\u4e3a 100\nset global query_result_maxsize = 200\n
\u5168\u5c40\u5f00\u542f\u4e5f\u53ef\u5728\u542f\u52a8 MatrixOne \u4e4b\u524d\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 cn.toml
\uff0c\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\u5e76\u4fdd\u5b58\uff1a
[cn.frontend]\nqueryResultMaxsize = 200 // \u9ed8\u8ba4\u4e3a 100\n
Note: \u5355\u4e2a\u67e5\u8be2\u7ed3\u679c\u7684\u6700\u5927\u503c\u5982\u679c\u8bbe\u7f6e\u7684\u503c\u6bd4\u4e0a\u4e00\u6b21\u8bbe\u7f6e\u7684\u5c0f\uff0c\u4e0d\u5f71\u54cd\u4e4b\u524d\u7684\u4fdd\u5b58\u7ed3\u679c\u5927\u5c0f\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_5","title":"\u67e5\u8be2\u5143\u6570\u636e\u4fe1\u606f","text":"\u67e5\u8be2\u5143\u6570\u636e\u4fe1\u606f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684 SQL \u8bed\u53e5\uff1a
select * from meta_scan(query_id) as u;\n\u5f53\u524d account_id\nselect query_id from meta_scan(query_id) as u;\n
\u5143\u6570\u636e\u4fe1\u606f\u5982\u4e0b\uff1a
\u5217\u540d \u7c7b\u578b \u5907\u6ce8 query_id uuid \u67e5\u8be2\u7ed3\u679c ID statement text \u6267\u884c\u7684 SQL \u8bed\u53e5 account_id uint32 \u8d26\u6237 ID role_id uint32 \u89d2\u8272 ID result_path text \u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c\u7684\u8def\u5f84\uff0c\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\u4e3a matrixone \u6587\u4ef6\u5939 mo-data/s3\uff0c\u5982\u9700\u4fee\u6539\u9ed8\u8ba4\u4fdd\u5b58\u7684\u8def\u5f84\uff0c\u9700\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684data-dir = \"mo-data/s3\"
\u3002\u5982\u9700\u67e5\u9605\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e\uff0c\u53c2\u89c1\u901a\u7528\u53c2\u6570\u914d\u7f6e created_time timestamp \u521b\u5efa\u65f6\u95f4 result_size float \u7ed3\u679c\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3a MB\u3002 tables text SQL \u6240\u7528\u5230\u7684\u8868 user_id uint32 \u7528\u6237 ID expired_time timestamp \u67e5\u8be2\u7ed3\u679c\u7684\u8d85\u65f6\u65f6\u95f4 column_map text \u67e5\u8be2\u5982\u679c\u6709\u540c\u540d\u7684\u5217\u7ed3\u679c\u540d\uff0cresult scan \u4f1a\u5bf9\u5217\u540d\u505a\u91cd\u6620\u5c04"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_6","title":"\u4fdd\u5b58\u67e5\u8be2\u7ed3\u679c","text":"\u4f60\u53ef\u4ee5\u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5728\u4f60\u7684\u672c\u5730\u78c1\u76d8\u6216 S3 \u4e2d\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/save_query_result/#_7","title":"\u8bed\u6cd5\u7ed3\u6784","text":"MODUMP QUERY_RESULT query_id INTO s3_path\n[FIELDS TERMINATED BY 'char']\n[ENCLOSED BY 'char']\n[LINES TERMINATED BY 'string']\n[header 'bool']\n[MAX_FILE_SIZE unsigned_number]\n
query_id\uff1a\u662f UUID \u7684\u5b57\u7b26\u4e32\u3002
s3_path\uff1a\u662f\u67e5\u8be2\u7ed3\u679c\u6587\u4ef6\u4fdd\u5b58\u7684\u8def\u5f84\u3002\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\u4e3a matrixone \u6587\u4ef6\u5939 mo-data/s3\uff0c\u5982\u9700\u4fee\u6539\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\uff0c\u9700\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684 data-dir = \"mo-data/s3\"
\u3002\u5982\u9700\u67e5\u9605\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e\uff0c\u53c2\u89c1\u901a\u7528\u53c2\u6570\u914d\u7f6e
root@rootMacBook-Pro 02matrixone % cd matrixone/mo-data\nroot@rootMacBook-Pro mo-data % ls\ntn-data etl local logservice-data s3\n
Note: \u5982\u679c\u4f60\u9700\u8981\u5bfc\u51fa csv
\u6587\u4ef6\u3002\u8def\u5f84\u9700\u8981\u4ee5 etl:
\u5f00\u5934\u3002
[FIELDS TERMINATED BY 'char']\uff1a\u53ef\u9009\u53c2\u6570\u3002\u5b57\u6bb5\u5206\u5272\u7b26\u53f7\uff0c\u9ed8\u8ba4\u4e3a\u5355\u5f15\u53f7 '
\u3002
[ENCLOSED BY 'char']\uff1a\u53ef\u9009\u53c2\u6570\u3002\u5b57\u6bb5\u5305\u62ec\u7b26\u53f7\uff0c\u9ed8\u8ba4\u4e3a\u5f15\u53cc\u53f7 \u201c
\u3002
[LINES TERMINATED BY 'string']\uff1a\u53ef\u9009\u53c2\u6570\u3002\u884c\u7ed3\u675f\u7b26\u53f7\uff0c\u9ed8\u8ba4\u4e3a\u6362\u884c\u7b26\u53f7 \\n
\u3002
[header 'bool']\uff1a\u53ef\u9009\u53c2\u6570\u3002bool \u7c7b\u578b\u53ef\u4ee5\u9009\u62e9 true
\u6216 false
\u3002csv
\u6587\u4ef6\u7b2c\u4e00\u884c\u4e3a\u5404\u4e2a\u5217\u540d\u7684\u6807\u9898\u884c\u3002
[MAX_FILE_SIZE unsigned_number]\uff1a\u53ef\u9009\u53c2\u6570\u3002\u6587\u4ef6\u6700\u5927\u6587\u4ef6\u5927\u5c0f\uff0c\u5355\u4f4d\u4e3a KB\u3002\u9ed8\u8ba4\u4e3a 0\u3002
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> /* cloud_user */select a from t1;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.16 sec)\n-- \u67e5\u8be2\u5f53\u524d\u4f1a\u8bdd\u4e2d\u6700\u8fd1\u6267\u884c\u7684\u67e5\u8be2 ID\nmysql> select last_query_id();\n+--------------------------------------+\n| last_query_id() |\n+--------------------------------------+\n| f005ebc6-a3dc-11ee-bb76-26dd28356ef3 |\n+--------------------------------------+\n1 row in set (0.12 sec)\n-- \u83b7\u53d6\u8fd9\u4e2a\u67e5\u8be2 ID \u7684\u67e5\u8be2\u7ed3\u679c\nmysql> select * from result_scan('f005ebc6-a3dc-11ee-bb76-26dd28356ef3') as t;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n-- \u67e5\u770b\u8fd9\u4e2a\u67e5\u8be2 ID \u7684\u5143\u6570\u636e\nmysql> select * from meta_scan('f005ebc6-a3dc-11ee-bb76-26dd28356ef3') as t;\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| f005ebc6-a3dc-11ee-bb76-26dd28356ef3 | select a from t1 | 0 | 0 | SHARED:/query_result/sys_f005ebc6-a3dc-11ee-bb76-26dd28356ef3_1.blk | 2023-12-26 18:53:01 | 0.000003814697265625 | t1 | 0 | 2023-12-27 18:53:01 | a -> a |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n1 row in set (0.01 sec)\n\n-- \u5c06\u67e5\u8be2\u7ed3\u679c\u4fdd\u5b58\u5230\u672c\u5730\nMODUMP QUERY_RESULT 'f005ebc6-a3dc-11ee-bb76-26dd28356ef3' INTO 'etl:your_local_path';\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> /* save_result */select a from t1;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.02 sec)\n\nmysql> select last_query_id();\n+--------------------------------------+\n| last_query_id() |\n+--------------------------------------+\n| afc82394-a45e-11ee-bb9a-26dd28356ef3 |\n+--------------------------------------+\n1 row in set (0.00 sec)\n\nmysql> select * from result_scan('afc82394-a45e-11ee-bb9a-26dd28356ef3') as t;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.01 sec)\n\nmysql> select * from meta_scan('afc82394-a45e-11ee-bb9a-26dd28356ef3') as t;\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n| afc82394-a45e-11ee-bb9a-26dd28356ef3 | select a from t1 | 0 | 0 | SHARED:/query_result/sys_afc82394-a45e-11ee-bb9a-26dd28356ef3_1.blk | 2023-12-27 10:21:47 | 0.000003814697265625 | t1 | 0 | 2023-12-28 10:21:47 | a -> a |\n+--------------------------------------+------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+-----------+\n1 row in set (0.00 sec)\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> show create table t1;\n+-------+--------------------------------------------+\n| Table | Create Table |\n+-------+--------------------------------------------+\n| t1 | CREATE TABLE `t1` (\n`a` INT DEFAULT NULL\n) |\n+-------+--------------------------------------------+\n1 row in set (0.02 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\n+--------------------------------------+----------------------+------------+---------+---------------------------------------------------------------------+---------------------+-----------------------+--------+---------+---------------------+----------------------------------------------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+----------------------+------------+---------+---------------------------------------------------------------------+---------------------+-----------------------+--------+---------+---------------------+----------------------------------------------+\n| 617647f4-a45c-11ee-bb97-26dd28356ef3 | show create table t1 | 0 | 0 | SHARED:/query_result/sys_617647f4-a45c-11ee-bb97-26dd28356ef3_1.blk | 2023-12-27 10:05:17 | 0.0000858306884765625 | | 0 | 2023-12-28 10:05:17 | Table -> Table, Create Table -> Create Table |\n+--------------------------------------+----------------------+------------+---------+---------------------------------------------------------------------+---------------------+-----------------------+--------+---------+---------------------+----------------------------------------------+\n1 row in set (0.00 sec)\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> desc t1;\n+-------+---------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-------+---------+------+------+---------+-------+---------+\n| a | INT(32) | YES | | NULL | | |\n+-------+---------+------+------+---------+-------+---------+\n1 row in set (0.03 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\n+--------------------------------------+-----------+------------+---------+---------------------------------------------------------------------+---------------------+---------------------+------------+---------+---------------------+----------------------------------------------------------------------------------------------------------------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+-----------+------------+---------+---------------------------------------------------------------------+---------------------+---------------------+------------+---------+---------------------+----------------------------------------------------------------------------------------------------------------+\n| 143a54b6-a45d-11ee-bb97-26dd28356ef3 | desc t1 | 0 | 0 | SHARED:/query_result/sys_143a54b6-a45d-11ee-bb97-26dd28356ef3_1.blk | 2023-12-27 10:10:17 | 0.00016021728515625 | mo_columns | 0 | 2023-12-28 10:10:17 | Field -> Field, Type -> Type, Null -> Null, Key -> Key, Default -> Default, Extra -> Extra, Comment -> Comment |\n+--------------------------------------+-----------+------------+---------+---------------------------------------------------------------------+---------------------+---------------------+------------+---------+---------------------+----------------------------------------------------------------------------------------------------------------+\n1 row in set (0.00 sec)\n
mysql> CREATE TABLE numbers(pk INTEGER PRIMARY KEY, ui BIGINT UNSIGNED, si BIGINT);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> INSERT INTO numbers VALUES (0, 0, -9223372036854775808), (1, 18446744073709551615, 9223372036854775807);\nQuery OK, 2 rows affected (0.01 sec)\n\nmysql> SET @si_min = -9223372036854775808;\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> PREPARE s2 FROM 'SELECT * FROM numbers WHERE si=?';\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql> EXECUTE s2 USING @si_min;\n+------+------+----------------------+\n| pk | ui | si |\n+------+------+----------------------+\n| 0 | 0 | -9223372036854775808 |\n+------+------+----------------------+\n1 row in set (0.02 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\n+--------------------------------------+---------------------------------------------------------------------------------------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+------------------------------+\n| query_id | statement | account_id | role_id | result_path | create_time | result_size | tables | user_id | expired_time | ColumnMap |\n+--------------------------------------+---------------------------------------------------------------------------------------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+------------------------------+\n| e83b8df2-a45d-11ee-bb98-26dd28356ef3 | EXECUTE s2 USING @si_min // SELECT * FROM numbers WHERE si=? ; SET @si_min = -9223372036854775808 | 0 | 0 | SHARED:/query_result/sys_e83b8df2-a45d-11ee-bb98-26dd28356ef3_1.blk | 2023-12-27 10:16:13 | 0.000019073486328125 | | 0 | 2023-12-28 10:16:13 | pk -> pk, ui -> ui, si -> si |\n+--------------------------------------+---------------------------------------------------------------------------------------------------+------------+---------+---------------------------------------------------------------------+---------------------+----------------------+--------+---------+---------------------+------------------------------+\n1 row in set (0.00 sec)\n
mysql> set global save_query_result = on;\nmysql> set global query_result_timeout = 24;\nmysql> set global query_result_maxsize = 200;\nmysql> create table t1 (a int);\nmysql> insert into t1 values(1);\nmysql> select * from t1;\n+------+\n| a |\n+------+\n| 1 |\n+------+\n1 row in set (0.00 sec)\n\nmysql> select * from meta_scan(last_query_id()) as t;\nERROR 20405 (HY000): file query_result_meta/sys_c16859e4-a462-11ee-bba0-26dd28356ef3.blk is not found\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/","title":"SQL \u6a21\u5f0f","text":"sql_mode \u662f MatrixOne \u4e2d\u7684\u4e00\u4e2a\u7cfb\u7edf\u53c2\u6570\uff0c\u7528\u4e8e\u6307\u5b9a MatrixOne \u6267\u884c\u67e5\u8be2\u548c\u64cd\u4f5c\u7684\u6a21\u5f0f\u3002sql_mode \u53ef\u4ee5\u5f71\u54cd MatrixOne \u7684\u8bed\u6cd5\u548c\u8bed\u4e49\u89c4\u5219\uff0c\u4ece\u800c\u6539\u53d8 MatrixOne \u67e5\u8be2 SQL \u7684\u884c\u4e3a\u3002\u5728\u672c\u7bc7\u6587\u7ae0\u4e2d\uff0c\u5c06\u4e3a\u4f60\u4ecb\u7ecd sql_mode \u7684\u6a21\u5f0f\u3001\u4f5c\u7528\u4ee5\u53ca\u5982\u4f55\u8bbe\u7f6e SQL \u6a21\u5f0f\u3002
Note
MatrixOne \u76ee\u524d\u53ea\u652f\u6301 ONLY_FULL_GROUP_BY
\u8fd9\u4e00\u6a21\u5f0f\uff0c\u5176\u5b83\u6a21\u5f0f\u4ec5\u4f5c\u8bed\u6cd5\u652f\u6301\u3002ONLY_FULL_GROUP_BY
\u88ab\u7528\u4e8e\u63a7\u5236 GROUP BY \u8bed\u53e5\u7684\u884c\u4e3a\u3002\u5f53\u542f\u7528 ONLY_FULL_GROUP_BY
\u6a21\u5f0f\u65f6\uff0cMatrixOne \u8981\u6c42\u5728 SELECT \u8bed\u53e5\u4e2d\u7684 GROUP BY \u5b50\u53e5\u4e2d\u7684\u5217\u5fc5\u987b\u662f\u805a\u5408\u51fd\u6570 (\u5982 SUM\u3001COUNT \u7b49) \u6216\u5728 GROUP BY \u5b50\u53e5\u4e2d\u51fa\u73b0\u7684\u5217\u3002\u5982\u679c SELECT \u8bed\u53e5\u4e2d\u5b58\u5728\u4e0d\u7b26\u5408\u8fd9\u4e2a\u8981\u6c42\u7684\u5217\uff0c\u5c06\u4f1a\u629b\u51fa\u9519\u8bef\uff0c\u5982\u679c\u4f60\u7684\u8868\u7ed3\u6784\u590d\u6742\uff0c\u4e3a\u4e86\u4fbf\u4e8e\u67e5\u8be2\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u5c06 ONLY_FULL_GROUP_BY
\u6a21\u5f0f\u5173\u95ed\u3002
\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b sql_mode\uff1a
SELECT @@global.sql_mode;--\u5168\u5c40\u6a21\u5f0f\nSELECT @@session.sql_mode;--\u4f1a\u8bdd\u6a21\u5f0f\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#sql_mode_1","title":"\u8bbe\u7f6e sql_mode","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e sql_mode\uff1a
set global sql_mode = 'xxx' --\u5168\u5c40\u6a21\u5f0f\uff0c\u91cd\u65b0\u8fde\u63a5\u6570\u636e\u5e93\u751f\u6548\nset session sql_mode = 'xxx'--\u4f1a\u8bdd\u6a21\u5f0f\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/sql-mode/#_1","title":"\u793a\u4f8b","text":"CREATE TABLE student(\nid int,\nname char(20),\nage int,\nnation char(20)\n);\n\nINSERT INTO student values(1,'tom',18,'\u4e0a\u6d77'),(2,'jan',19,'\u4e0a\u6d77'),(3,'jen',20,'\u5317\u4eac'),(4,'bob',20,'\u5317\u4eac'),(5,'tim',20,'\u5e7f\u5dde');\n\nmysql> select * from student group by nation;--\u5728`ONLY_FULL_GROUP_BY`\u6a21\u5f0f\u4e0b\u4e0d\u652f\u6301\u8fdb\u884c\u6b64\u64cd\u4f5c\nERROR 1149 (HY000): SQL syntax error: column \"student.id\" must appear in the GROUP BY clause or be used in an aggregate function\n\nmysql> SET session sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_TRANS_TAB\nLES';--\u5173\u95ed\u5f53\u524d\u4f1a\u8bdd\u7684 ONLY_FULL_GROUP_BY \u6a21\u5f0f\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> select * from student group by nation;--\u5728\u5f53\u524d\u4f1a\u8bdd\u5173\u95ed`ONLY_FULL_GROUP_BY`\u6a21\u5f0f\u7acb\u5373\u751f\u6548\n+------+------+------+--------+\n| id | name | age | nation |\n+------+------+------+--------+\n| 1 | tom | 18 | \u4e0a\u6d77 |\n| 3 | jen | 20 | \u5317\u4eac |\n| 5 | tim | 20 | \u5e7f\u5dde |\n+------+------+------+--------+\n3 rows in set (0.00 sec)\n\nmysql> SET global sql_mode='ONLY_FULL_GROUP_BY';--\u8bbe\u7f6e\u5168\u5c40\u5f00\u542f ONLY_FULL_GROUP_BY \u6a21\u5f0f\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> select * from student group by nation;--ONLY_FULL_GROUP_BY \u6a21\u5f0f\u672a\u751f\u6548\uff0c\u56e0\u4e3a\u5168\u5c40\u6a21\u5f0f\u5f00\u542f\u540e\u9700\u8981\u91cd\u8fde\u6570\u636e\u5e93\u65b9\u53ef\u751f\u6548\n+------+------+------+--------+\n| id | name | age | nation |\n+------+------+------+--------+\n| 1 | tom | 18 | \u4e0a\u6d77 |\n| 3 | jen | 20 | \u5317\u4eac |\n| 5 | tim | 20 | \u5e7f\u5dde |\n+------+------+------+--------+\n3 rows in set (0.00 sec)\n\nmysql> exit --\u9000\u51fa\u5f53\u524d\u4f1a\u8bdd\n\nmysql> select * from student group by nation;--\u91cd\u8fde\u6570\u636e\u5e93\u540e\u6267\u884c\u67e5\u8be2\u64cd\u4f5c\uff0cONLY_FULL_GROUP_BY \u6a21\u5f0f\u6210\u529f\u5f00\u542f\nERROR 1149 (HY000): SQL syntax error: column \"student.id\" must appear in the GROUP BY clause or be used in an aggregate function\n
"},{"location":"MatrixOne/Reference/Variable/system-variables/system-variables-overview/","title":"\u670d\u52a1\u5668\u7cfb\u7edf\u53d8\u91cf","text":"MatrixOne \u670d\u52a1\u5668\u7cfb\u7edf\u53d8\u91cf\uff08System Variable\uff09\u662f\u6307\u5728 MatrixOne Server \u4e2d\uff0c\u7528\u4e8e\u63a7\u5236\u6216\u914d\u7f6e\u6570\u636e\u5e93\u5f15\u64ce\u6216\u5176\u4ed6\u7ec4\u4ef6\u884c\u4e3a\u7684\u4e00\u7ec4\u53d8\u91cf\u3002\u8fd9\u4e9b\u53d8\u91cf\u7684\u503c\u53ef\u4ee5\u901a\u8fc7 SET
\u8bed\u53e5\u8fdb\u884c\u8bbe\u7f6e\u548c\u66f4\u6539\u3002
\u7cfb\u7edf\u53d8\u91cf\u53ef\u5206\u4e3a\u4e24\u7c7b\uff1a\u5168\u5c40\u53d8\u91cf\u548c\u4f1a\u8bdd\u53d8\u91cf\u3002
\u5168\u5c40\u53d8\u91cf\uff1a\u662f\u6307\u5bf9\u6240\u6709\u8fde\u63a5\u7684 MatrixOne \u4f1a\u8bdd\u90fd\u9002\u7528\u7684\u53d8\u91cf\u3002\u5b83\u4eec\u7684\u503c\u5728 MatrixOne Server \u542f\u52a8\u65f6\u8bbe\u7f6e\uff0c\u5e76\u5728 MatrixOne Server \u5173\u95ed\u4e4b\u524d\u4fdd\u6301\u4e0d\u53d8\u3002\u5168\u5c40\u53d8\u91cf\u901a\u5e38\u7528\u4e8e\u63a7\u5236 MatrixOne Server \u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u6307\u5b9a\u9ed8\u8ba4\u5907\u4efd\u548c\u6062\u590d\u4f4d\u7f6e\uff0c\u6307\u5b9a\u9ed8\u8ba4\u8bed\u8a00\u73af\u5883\u7b49\u3002
\u4f1a\u8bdd\u53d8\u91cf\uff1a\u662f\u6307\u53ea\u5bf9\u5f53\u524d\u7528\u6237\u8fde\u63a5\u7684 MatrixOne \u4f1a\u8bdd\u9002\u7528\u7684\u53d8\u91cf\u3002\u5b83\u4eec\u7684\u503c\u53ef\u4ee5\u5728\u7528\u6237\u8fde\u63a5\u7684\u4efb\u4f55\u65f6\u95f4\u66f4\u6539\uff0c\u5e76\u5728\u7528\u6237\u65ad\u5f00\u8fde\u63a5\u65f6\u81ea\u52a8\u6e05\u9664\u3002\u4f1a\u8bdd\u53d8\u91cf\u901a\u5e38\u7528\u4e8e\u63a7\u5236\u4f1a\u8bdd\u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u63a7\u5236\u6253\u5370\u4fe1\u606f\u7684\u65b9\u5f0f\uff0c\u6307\u5b9a\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u7b49\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8be2\uff1a
SHOW VARIABLES;\n
\u8fd9\u4f1a\u5217\u51fa\u6240\u6709\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u67e5\u770b\u4e0e\u7279\u5b9a\u4e3b\u9898\u76f8\u5173\u7684\u7cfb\u7edf\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
SHOW VARIABLES LIKE '%theme%';\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002
Note: LIKE
\u8fd0\u7b97\u7b26\u662f\u7528\u6765\u6a21\u7cca\u5339\u914d\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\uff0c% \u8868\u793a\u96f6\u4e2a\u6216\u591a\u4e2a\u4efb\u610f\u5b57\u7b26\u3002\u6240\u4ee5\uff0c\u4e0a\u8ff0\u547d\u4ee4\u5c06\u5339\u914d\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4efb\u4f55\u7cfb\u7edf\u53d8\u91cf\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8be2\uff1a
SHOW GLOBAL VARIABLES;\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u5168\u5c40\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u67e5\u770b\u4e0e\u7279\u5b9a\u4e3b\u9898\u76f8\u5173\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
SHOW GLOBAL VARIABLES LIKE '%theme%';\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u5168\u5c40\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002
Note: LIKE
\u8fd0\u7b97\u7b26\u662f\u7528\u6765\u6a21\u7cca\u5339\u914d\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\uff0c% \u8868\u793a\u96f6\u4e2a\u6216\u591a\u4e2a\u4efb\u610f\u5b57\u7b26\u3002\u6240\u4ee5\uff0c\u4e0a\u8ff0\u547d\u4ee4\u5c06\u5339\u914d\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4efb\u4f55\u5168\u5c40\u7cfb\u7edf\u53d8\u91cf\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8be2\uff1a
SHOW SESSION VARIABLES;\n
\u8fd9\u5c06\u5217\u51fa\u5f53\u524d\u4f1a\u8bdd\u4e2d\u6240\u6709\u7684\u7cfb\u7edf\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002\u5982\u679c\u4f60\u53ea\u60f3\u67e5\u770b\u4e0e\u7279\u5b9a\u4e3b\u9898\u76f8\u5173\u7684\u4f1a\u8bdd\u53d8\u91cf\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a
SHOW SESSION VARIABLES LIKE '%theme%';\n
\u8fd9\u5c06\u5217\u51fa\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4f1a\u8bdd\u53d8\u91cf\u53ca\u5176\u5f53\u524d\u503c\u3002
Note: LIKE
\u8fd0\u7b97\u7b26\u662f\u7528\u6765\u6a21\u7cca\u5339\u914d\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\uff0c% \u8868\u793a\u96f6\u4e2a\u6216\u591a\u4e2a\u4efb\u610f\u5b57\u7b26\u3002\u6240\u4ee5\uff0c\u4e0a\u8ff0\u547d\u4ee4\u5c06\u5339\u914d\u540d\u79f0\u4e2d\u5305\u542b theme
\u7684\u4efb\u4f55\u4f1a\u8bdd\u7cfb\u7edf\u53d8\u91cf\u3002
MatrixOne \u4e3a\u517c\u5bb9 MySQL\uff0cSQL \u6a21\u5f0f\u53ea\u652f\u6301 ONLY_FULL_GROUP_BY
\u6a21\u5f0f\uff1b\u5176\u4ed6 SQL \u6a21\u5f0f\u4ec5\u8bed\u6cd5\u652f\u6301\uff0c\u5b9e\u9645\u4e0d\u8d77\u4f5c\u7528\u3002
MatrixOne \u4f7f\u7528\u7684\u65f6\u533a\u53d6\u51b3\u4e8e\u4e09\u4e2a\u7cfb\u7edf\u53d8\u91cf\uff1aglobal.time_zone
\uff0csession.time_zone
\u548c global.system_time_zone
\u3002
global.system_time_zone
\u8868\u793a\u670d\u52a1\u5668\u7cfb\u7edf\u65f6\u533a\u3002\u5f53\u670d\u52a1\u5668\u542f\u52a8\u65f6\uff0c\u5b83\u4f1a\u5c1d\u8bd5\u786e\u5b9a\u4e3b\u673a\u7684\u65f6\u533a\uff0c\u5e76\u4f7f\u7528\u5b83\u6765\u8bbe\u7f6e\u7cfb\u7edf\u65f6\u533a\uff08system_time_zone
\uff09\u3002
global.time_zone
\u8868\u793a\u670d\u52a1\u5668\u5f53\u524d\u65f6\u533a\u3002\u521d\u59cb time_zone
\u503c\u4e3a SYSTEM
\uff0c\u8868\u793a\u670d\u52a1\u5668\u65f6\u533a\u4e0e\u7cfb\u7edf\u65f6\u533a\u76f8\u540c\u3002
\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\u5728\u8fd0\u884c\u65f6\u8bbe\u7f6e\u5168\u5c40\u670d\u52a1\u5668\u65f6\u533a\uff0c\u8bbe\u7f6e\u5b8c\u6210\u540e\u65e0\u6cd5\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u751f\u6548\uff0c\u4f60\u9700\u8981\u5148\u9000\u51fa\u5f53\u524d\u4f1a\u8bdd\uff0c\u518d\u6b21\u91cd\u65b0\u8fde\u63a5 MatrixOne \u65f6\u624d\u4f1a\u751f\u6548\u3002
> SET GLOBAL time_zone = timezone;\n
time_zone
\u53d8\u91cf\u51b3\u5b9a\u3002\u6700\u521d\uff0c\u4f1a\u8bdd\u65f6\u533a\u7684\u53d8\u91cf\u503c\u4ece\u5168\u5c40 time_zone
\u53d8\u91cf\u4e2d\u83b7\u5f97\uff0c\u4f46\u4f1a\u8bdd\u5ba2\u6237\u7aef\u53ef\u4ee5\u66f4\u6539\u81ea\u5df1\u7684\u65f6\u533a\u3002\u4f46\u662f\u8fd9\u4e2a\u8fd9\u4e2a\u8bbe\u7f6e\u53ea\u4f1a\u5728\u5f53\u524d\u4f1a\u8bdd\u671f\u95f4\u6709\u6548\u3002SET time_zone = timezone;\n
\u4f7f\u7528\u4ee5\u4e0b SQL \u8bed\u53e5\u67e5\u770b\u5f53\u524d\u5168\u5c40\u65f6\u533a\u3001\u5ba2\u6237\u7aef\u65f6\u533a\u548c\u7cfb\u7edf\u65f6\u533a\u7684\u503c\uff1a
> SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| timezone | +08:00 | CST |\n+-------------+-------------+--------------------+\n1 row in set (0.01 sec)\n
\u8bbe\u7f6e time_zone \u7684\u503c\u7684\u683c\u5f0f\uff1a
\u503c SYSTEM
\u8868\u793a\u65f6\u533a\u5e94\u4e0e\u670d\u52a1\u5668\u7cfb\u7edf\u65f6\u533a\u76f8\u540c\u3002
\u503c UTC
\u8868\u793a\u65f6\u533a\u8bbe\u7f6e\u4e3a UTC\uff08Coordinated Universal Time\uff0c\u534f\u8c03\u4e16\u754c\u65f6\uff09\u3002\u4ec5\u652f\u6301\u201cUTC\u201d\u7f29\u5199\u4f5c\u4e3a\u65f6\u533a\u4f7f\u7528\u3002
\u8be5\u503c\u53ef\u4ee5\u4f5c\u4e3a\u5b57\u7b26\u4e32\u7ed9\u51fa\uff0c\u8868\u793a UTC \u65f6\u95f4\u7684\u504f\u79fb\uff0c\u683c\u5f0f\u4e3a\u201cHH:MM\u201d\uff0c\u5e26\u6709 + \u6216 -\uff0c\u4f8b\u5982 +10:00
\u6216\u8005 -6:00
\u3002\u5141\u8bb8\u7684\u8303\u56f4\u662f\u201c-13:59\u201d\u5230\u201c+14:00\u201d\u3002
\u5f53\u524d\u4f1a\u8bdd\u65f6\u533a\u8bbe\u7f6e\u4f1a\u5f71\u54cd\u65f6\u533a\u654f\u611f\u65f6\u95f4\u503c\u7684\u663e\u793a\u548c\u5b58\u50a8\u3002\u5373\u4f1a\u5f71\u54cd\u6267\u884c NOW()
\u7b49\u51fd\u6570\u67e5\u8be2\u5230\u7684\u503c\u4ee5\u53ca\u5b58\u50a8\u5728 TIMESTAMP
\u5217\u4e2d\u548c\u4ece TIMESTAMP
\u5217\u4e2d\u67e5\u8be2\u5230\u7684\u503c\u3002
\u4f1a\u8bdd\u65f6\u533a\u8bbe\u7f6e\u4e0d\u5f71\u54cd UTC_TIMESTAMP()
\u7b49\u51fd\u6570\u663e\u793a\u7684\u503c\u6216 DATE
\u3001TIME
\u6216 DATETIME
\u5217\u4e2d\u7684\u503c\u3002
Note
\u53ea\u6709 Timestamp \u6570\u636e\u7c7b\u578b\u7684\u503c\u662f\u53d7\u65f6\u533a\u5f71\u54cd\u7684\u3002\u53ef\u4ee5\u7406\u89e3\u4e3a\uff0cTimestamp \u6570\u636e\u7c7b\u578b\u7684\u5b9e\u9645\u8868\u793a\u4f7f\u7528\u7684\u662f\uff08\u5b57\u9762\u503c + \u65f6\u533a\u4fe1\u606f\uff09\u3002\u5176\u5b83\u65f6\u95f4\u548c\u65e5\u671f\u7c7b\u578b\uff0c\u6bd4\u5982 Datetime/Date/Time \u662f\u4e0d\u5305\u542b\u65f6\u533a\u4fe1\u606f\u7684\uff0c\u6240\u4ee5\u4e5f\u4e0d\u53d7\u5230\u65f6\u533a\u53d8\u5316\u7684\u5f71\u54cd\u3002
> SELECT @@global.time_zone, @@session.time_zone, @@global.system_time_zone;\n+-------------+-------------+--------------------+\n| @@time_zone | @@time_zone | @@system_time_zone |\n+-------------+-------------+--------------------+\n| SYSTEM | SYSTEM | CST |\n+-------------+-------------+--------------------+\n1 row in set (0.00 sec)\n\n> create table t (ts timestamp, dt datetime);\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql> set @@time_zone = 'UTC';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> insert into t values ('2017-09-30 11:11:11', '2017-09-30 11:11:11');\nQuery OK, 1 row affected (0.02 sec)\n\nmysql> set @@time_zone = '+08:00';\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql> select * from t;\n+---------------------+---------------------+\n| ts | dt |\n+---------------------+---------------------+\n| 2017-09-30 19:11:11 | 2017-09-30 11:11:11 |\n+---------------------+---------------------+\n1 row in set (0.00 sec)\n
\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u65e0\u8bba\u600e\u4e48\u8c03\u6574\u65f6\u533a\u7684\u503c\uff0cDatetime \u7c7b\u578b\u5b57\u6bb5\u7684\u503c\u662f\u4e0d\u53d7\u5f71\u54cd\u7684\uff0c\u800c Timestamp \u5219\u968f\u7740\u65f6\u533a\u6539\u53d8\uff0c\u663e\u793a\u7684\u503c\u4f1a\u53d1\u751f\u53d8\u5316\u3002\u5176\u5b9e Timestamp \u6301\u4e45\u5316\u5230\u5b58\u50a8\u7684\u503c\u59cb\u7ec8\u6ca1\u6709\u53d8\u5316\u8fc7\uff0c\u53ea\u662f\u6839\u636e\u65f6\u533a\u7684\u4e0d\u540c\u663e\u793a\u503c\u4e0d\u540c\u3002
Note
Timestamp \u7c7b\u578b\u548c Datetime \u7b49\u7c7b\u578b\u7684\u503c\uff0c\u4e24\u8005\u76f8\u4e92\u8f6c\u6362\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u6d89\u53ca\u5230\u65f6\u533a\u3002\u8fd9\u79cd\u60c5\u51b5\u4e00\u5f8b\u57fa\u4e8e\u5f53\u524d time_zone \u65f6\u533a\u5904\u7406\u3002
"},{"location":"MatrixOne/Reference/Variable/system-variables/timezone/#matrixone","title":"\u4fee\u6539 MatrixOne \u65f6\u533a","text":"> select now();\n+----------------------------+\n| now() |\n+----------------------------+\n| 2022-10-14 18:38:27.876181 |\n+----------------------------+\n1 row in set (0.00 sec)\n\n> show variables like \"%time_zone%\";\n+------------------+--------+\n| Variable_name | Value |\n+------------------+--------+\n| system_time_zone | CST |\n| time_zone | SYSTEM |\n+------------------+--------+\n2 rows in set (0.00 sec)\n
time_zone
\uff1a\u4f7f\u7528 system \u7684\u65f6\u533a\u3002
system_time_zone
\u8bf4\u660e system \u4f7f\u7528\u670d\u52a1\u5668\u7cfb\u7edf\u65f6\u533a\u3002
\u4fee\u6539\u5f53\u524d\u65f6\u533a\uff1a
set global time_zone = '+08:00';\nset time_zone = '+08:00';\n
set global time_zone = '+08:00';
\uff1a\u4fee\u6539 MatrixOne \u5168\u5c40\u65f6\u533a\u4e3a\u5317\u4eac\u65f6\u95f4\uff0c\u5373\u6211\u4eec\u6240\u5728\u7684\u4e1c 8 \u533a\u3002set time_zone = '+08:00';
\uff1a\u4fee\u6539\u5f53\u524d\u4f1a\u8bdd\u65f6\u533a\u3002MatrixOne \u4ec5\u652f\u6301 (+/-)HH:MM
\u683c\u5f0f\u548c UTC
\u6765\u8bbe\u7f6e time_zone
\u7684\u503c\u3002
mo_ctl
\u662f\u4e00\u6b3e\u5e2e\u52a9\u4f60\u5bf9\u5355\u673a\u7248 MatrixOne \u8fdb\u884c\u90e8\u7f72\u5b89\u88c5\u3001\u542f\u505c\u63a7\u5236\u4ee5\u53ca\u6570\u636e\u5e93\u8fde\u63a5\u7b49\u64cd\u4f5c\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002
mo_ctl
\u76ee\u524d\u5df2\u9002\u914d\u8fc7\u7684\u64cd\u4f5c\u7cfb\u7edf\u5982\u4e0b\u8868\u6240\u793a\uff1a
mo_ctl
\u76ee\u524d\u7684\u529f\u80fd\u5217\u8868\u5982\u4e0b\u8868\u6240\u793a\u3002
mo_ctl help
\u67e5\u770bmo_ctl
\u5de5\u5177\u672c\u8eab\u7684\u8bed\u53e5\u548c\u529f\u80fd\u5217\u8868 mo_ctl precheck
\u68c0\u67e5 MatrixOne \u6e90\u7801\u5b89\u88c5\u6240\u9700\u8981\u7684\u4f9d\u8d56\u9879\uff0c\u5206\u522b\u4e3a golang, gcc, git,MySQL Client mo_ctl deploy
\u4e0b\u8f7d\u5e76\u5b89\u88c5\u53ca\u7f16\u8bd1 MatrixOne \u76f8\u5e94\u7248\u672c\uff0c\u9ed8\u8ba4\u4e3a\u5b89\u88c5\u6700\u65b0\u7a33\u5b9a\u7248\u672c mo_ctl start
\u542f\u52a8 MatrixOne \u670d\u52a1 mo_ctl status
\u68c0\u67e5 MatrixOne \u670d\u52a1\u662f\u5426\u6b63\u5728\u8fd0\u884c\u4e2d mo_ctl stop
\u505c\u6b62\u6240\u6709 MatrixOne \u670d\u52a1\u8fdb\u7a0b mo_ctl restart
\u91cd\u542f MatrixOne \u670d\u52a1 mo_ctl connect
\u8c03\u7528 MySQL Client \u8fde\u63a5 MatrixOne \u670d\u52a1 mo_ctl upgrade
\u5c06 MatrixOne \u4ece\u5f53\u524d\u7248\u672c\u5347\u7ea7/\u964d\u7ea7\u5230\u67d0\u4e2a\u53d1\u5e03\u7248\u672c\u6216\u8005 commit id \u7248\u672c mo_ctl set_conf
\u8bbe\u7f6e\u5404\u7c7b\u4f7f\u7528\u53c2\u6570 mo_ctl get_conf
\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u53c2\u6570 mo_ctl uninstall
\u4ece MO_PATH \u8def\u5f84\u4e0b\u5378\u8f7d MatrixOne mo_ctl watchdog
\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u4efb\u52a1\u4fdd\u8bc1 MatrixOne \u670d\u52a1\u53ef\u7528\u6027\uff0c\u6bcf\u5206\u949f\u68c0\u67e5 MatrixOne \u7684\u72b6\u6001\uff0c\u5982\u679c\u53d1\u73b0\u670d\u52a1\u4e2d\u6b62\u5219\u81ea\u52a8\u62c9\u8d77\u670d\u52a1 mo_ctl sql
\u76f4\u63a5\u901a\u8fc7\u547d\u4ee4\u6267\u884c SQL \u6216\u8005 SQL \u6784\u6210\u7684\u6587\u672c\u6587\u4ef6 mo_ctl ddl_convert
\u5c06 MySQL \u7684 DDL \u8bed\u53e5\u8f6c\u6362\u6210 MatrixOne \u8bed\u53e5\u7684\u5de5\u5177 mo_ctl get_cid
\u67e5\u770b\u5f53\u524d\u4f7f\u7528 MatrixOne \u4e0b\u8f7d\u4ed3\u5e93\u7684\u6e90\u7801\u7248\u672c mo_ctl get_branch
\u67e5\u770b\u5f53\u524d\u4f7f\u7528 MatrixOne \u4e0b\u8f7d\u4ed3\u5e93\u7684\u5206\u652f\u7248\u672c mo_ctl pprof
\u7528\u4e8e\u6536\u96c6 MatrixOne \u7684\u6027\u80fd\u5206\u6790\u6570\u636e"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#mo_ctl_1","title":"\u5b89\u88c5 mo_ctl","text":"\u6839\u636e\u60a8\u662f\u5426\u6709\u4e92\u8054\u7f51\u8bbf\u95ee\u6743\u9650\uff0c\u53ef\u4ee5\u9009\u62e9\u5728\u7ebf\u6216\u79bb\u7ebf\u5b89\u88c5 mo_ctl
\u5de5\u5177\uff0c\u4f60\u9700\u8981\u6ce8\u610f\u59cb\u7ec8\u4ee5 root \u6216\u5177\u6709 sudo \u6743\u9650\u6267\u884c\u547d\u4ee4\uff08\u5e76\u5728\u6bcf\u4e2a\u547d\u4ee4\u524d\u6dfb\u52a0 sudo\uff09\u3002\u540c\u65f6\uff0cinstall.sh
\u5c06\u4f7f\u7528 unzip
\u547d\u4ee4\u6765\u89e3\u538b mo_ctl
\u8f6f\u4ef6\u5305\uff0c\u8bf7\u786e\u4fdd\u5df2\u5b89\u88c5 unzip
\u547d\u4ee4\u3002
wget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh && sudo bash +x ./install.sh\n\n# \u5907\u7528\u5730\u5740\nwget https://ghproxy.com/https://github.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh && sudo bash +x install.sh\n
\u5bf9\u4e8e\u5728 macOS \u73af\u5883\u4e2d\u8fd0\u884c\u6b64\u547d\u4ee4\u7684\u7528\u6237\uff0c\u5982\u679c\u60a8\u662f\u975e root \u7528\u6237\uff0c\u8bf7\u4ee5\u4ee5\u4e0b\u8bed\u53e5\u8fd0\u884c install.sh
:
sudo -u $(whoami) bash +x ./install.sh\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#_3","title":"\u79bb\u7ebf\u5b89\u88c5","text":"# 1. \u5148\u5c06\u5b89\u88c5\u811a\u672c\u4e0b\u8f7d\u5230\u672c\u5730\u8ba1\u7b97\u673a\uff0c\u518d\u4e0a\u4f20\u5230\u5b89\u88c5\u673a\u5668\u4e0a\nwget https://raw.githubusercontent.com/matrixorigin/mo_ctl_standalone/main/install.sh\nwget https://github.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# \u5982 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\uff0c\u60a8\u53ef\u5c1d\u8bd5\u4ece\u4ee5\u4e0b\u955c\u50cf\u5730\u5740\u4e0b\u8f7d\uff1a\nwget https://githubfast.com/matrixorigin/mo_ctl_standalone/blob/main/install.sh\nwget https://githubfast.com/matrixorigin/mo_ctl_standalone/archive/refs/heads/main.zip -O mo_ctl.zip\n\n# 2. \u4ece\u79bb\u7ebf\u5305\u5b89\u88c5\nbash +x ./install.sh mo_ctl.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#_4","title":"\u5feb\u901f\u4e0a\u624b","text":"\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5feb\u901f\u5b89\u88c5\u90e8\u7f72\u5355\u673a\u7248 MatrixOne\uff0c\u8be6\u7ec6\u6307\u5357\u53ef\u4ee5\u67e5\u770b\u5355\u673a\u90e8\u7f72 MatrixOne.
\u4f7f\u7528\u547d\u4ee4 mo_ctl help
\u67e5\u770b\u5de5\u5177\u6307\u5357\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl precheck
\u67e5\u770b\u524d\u7f6e\u4f9d\u8d56\u6761\u4ef6\u662f\u5426\u6ee1\u8db3\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl get_conf
\u8bbe\u7f6e\u76f8\u5173\u53c2\u6570\uff0c\u53ef\u80fd\u7528\u5230\u7684\u53c2\u6570\u914d\u7f6e\u5982\u4e0b\u6240\u793a\uff1a
mo_ctl set_conf MO_PATH=\"/data/mo/matrixone\" #\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u7684 MatrixOne \u4e0b\u8f7d\u8def\u5f84\nmo_ctl set_conf MO_GIT_URL=\"https://githubfast.com/matrixorigin/matrixone.git\" #\u9488\u5bf9 github \u539f\u5730\u5740\u4e0b\u8f7d\u8fc7\u6162\u95ee\u9898\uff0c\u8bbe\u7f6e\u955c\u50cf\u4e0b\u8f7d\u5730\u5740\n
\u4f7f\u7528\u547d\u4ee4 mo_ctl deploy
\u5b89\u88c5\u90e8\u7f72 MatrixOne \u6700\u65b0\u7a33\u5b9a\u7248\u672c\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl start
\u542f\u52a8 MatrixOne \u670d\u52a1\u3002
\u4f7f\u7528\u547d\u4ee4 mo_ctl connect
\u8fde\u63a5 MatrixOne \u670d\u52a1\u3002
mo_ctl help\nUsage : mo_ctl [option_1] [option_2]\n\n [option_1] : available: connect | ddl_connect | deploy | get_branch | get_cid | get_conf | help | pprof | precheck | query | restart | set_conf | sql | start | status | stop | uninstall | upgrade | watchdog\n 1) connect : connect to mo via mysql client using connection info configured\n 2) ddl_convert : convert ddl file to mo format from other types of database\n 3) deploy : deploy mo onto the path configured\n 4) get_branch : upgrade or downgrade mo from current version to a target commit id or stable version\n 5) get_cid : print mo git commit id from the path configured\n 6) get_conf : get configurations\n 7) help : print help information\n 8) pprof : collect pprof information\n 9) precheck : check pre-requisites for mo_ctl\n 10) restart : a combination operation of stop and start\n 11) set_conf : set configurations\n 12) sql : execute sql from string, or a file or a path containg multiple files\n 13) start : start mo-service from the path configured\n 14) status : check if there's any mo process running on this machine\n 15) stop : stop all mo-service processes found on this machine\n 16) uninstall : uninstall mo from path MO_PATH=/data/mo/20230712_1228//matrixone\n 17) upgrade : upgrade or downgrade mo from current version to a target commit id or stable version\n 18) watchdog : setup a watchdog crontab task for mo-service to keep it alive\n e.g. : mo_ctl status\n\n [option_2] : Use \" mo_ctl [option_1] help \" to get more info\n e.g. : mo_ctl deploy help\n
\u4f7f\u7528 mo_ctl [option_1] help
\u6765\u83b7\u53d6\u4e0b\u4e00\u7ea7 mo_ctl [option_1]
\u529f\u80fd\u7684\u4f7f\u7528\u6307\u5357\u3002
\u6e90\u7801\u5b89\u88c5 MatrixOne \u524d\u4f7f\u7528 mo_ctl precheck
\u68c0\u67e5\u524d\u7f6e\u4f9d\u8d56\u6761\u4ef6\uff0c\u76ee\u524d\u524d\u7f6e\u4f9d\u8d56\u4e8e go
/gcc
/git
/mysql(client)
\u3002
mo_ctl precheck help\nUsage : mo_ctl precheck # check pre-requisites for mo_ctl\n Check list : go gcc git mysql\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#deploy-matrixone","title":"deploy - \u5b89\u88c5 MatrixOne","text":"\u4f7f\u7528 mo_ctl deploy [mo_version] [force]
\u5b89\u88c5\u90e8\u7f72\u7a33\u5b9a\u7248\u672c MatrixOne, \u6216\u67d0\u4e2a\u6307\u5b9a\u7248\u672c\uff0c\u901a\u8fc7 force
\u9009\u9879\u53ef\u4ee5\u5c06\u540c\u4e00\u76ee\u5f55\u4e0b\u5df2\u7ecf\u5b58\u5728\u7684 MatrixOne \u7248\u672c\u5220\u9664\uff0c\u5f3a\u5236\u91cd\u65b0\u5b89\u88c5\u65b0\u7248\u672c\u3002
mo_ctl deploy help\nUsage : mo_ctl deploy [mo_version] [force] # deploy mo onto the path configured\n [mo_version]: optional, specify an mo version to deploy\n [force] : optional, if specified will delete all content under MO_PATH and deploy from beginning\n e.g. : mo_ctl deploy # default, same as mo_ctl deploy 1.2.1\n : mo_ctl deploy main # deploy development latest version\n : mo_ctl deploy d29764a # deploy development version d29764a\n : mo_ctl deploy 1.2.1 # deploy stable verson 1.2.1\n : mo_ctl deploy force # delete all under MO_PATH and deploy verson 1.2.1\n : mo_ctl deploy 1.2.1 force # delete all under MO_PATH and deploy stable verson 1.2.1 from beginning\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#start-matrixone","title":"start - \u542f\u52a8 MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl start
\u542f\u52a8 MatrixOne \u670d\u52a1\uff0c\u542f\u52a8\u6587\u4ef6\u8def\u5f84\u4f4d\u4e8e MO_PATH
\u4e0b\u3002
mo_ctl start help\nUsage : mo_ctl start # start mo-service from the path configured\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#stop-matrixone","title":"stop - \u505c\u6b62 MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl stop [force]
\u505c\u6b62\u672c\u673a\u5668\u4e0a\u6240\u6709 MatrixOne \u670d\u52a1\uff0c\u5982\u679c\u6709\u591a\u4e2a MatrixOne \u670d\u52a1\u5728\u8fd0\u884c\uff0c\u4e5f\u4f1a\u5168\u90e8\u505c\u6b62\u3002
mo_ctl stop help\nUsage : mo_ctl stop [force] # stop all mo-service processes found on this machine\n [force] : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n e.g. : mo_ctl stop # default, stop all mo-service processes found on this machine\n : mo_ctl stop force # stop all mo-services with kill -9 command\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#restart-matrixone","title":"restart - \u91cd\u542f MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl restart [force]
\u505c\u6b62\u6240\u6709\u672c\u673a\u5668\u4e0a MatrixOne \u670d\u52a1\uff0c\u5e76\u91cd\u542f\u4f4d\u4e8e MO_PATH
\u8def\u5f84\u4e0b\u7684 MatrixOne \u670d\u52a1\u3002
mo_ctl restart help\nUsage : mo_ctl restart [force] # a combination operation of stop and start\n [force] : optional, if specified, will try to kill mo-services with -9 option, so be very carefully\n e.g. : mo_ctl restart # default, stop all mo-service processes found on this machine and start mo-serivce under path of conf MO_PATH\n : mo_ctl restart force # stop all mo-services with kill -9 command and start mo-serivce under path of conf MO_PATH\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#connect-mysql-client-matrixone","title":"connect - \u901a\u8fc7 mysql-client \u8fde\u63a5 MatrixOne \u670d\u52a1","text":"\u4f7f\u7528 mo_ctl connect
\u8fde\u63a5\u5230 MatrixOne \u670d\u52a1\uff0c\u8fde\u63a5\u53c2\u6570\u5747\u7531 mo_ctl
\u5de5\u5177\u4e2d\u8bbe\u7f6e\u3002
mo_ctl connect help\nUsage : mo_ctl connect # connect to mo via mysql client using connection info configured\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#status-matrixone","title":"status - \u68c0\u67e5 MatrixOne \u7684\u72b6\u6001","text":"\u4f7f\u7528 mo_ctl status
\u6765\u68c0\u67e5 MatrixOne \u7684\u8fd0\u884c\u72b6\u6001\uff0c\u662f\u5426\u5728\u8fd0\u884c\u4e2d\u3002
mo_ctl status help\nUsage : mo_ctl status # check if there's any mo process running on this machine\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#get_cid-matrixone-id","title":"get_cid - \u6253\u5370 MatrixOne \u4ee3\u7801\u63d0\u4ea4 id","text":"\u4f7f\u7528 mo_ctl get_cid
\u6253\u5370\u5f53\u524d MO_PATH
\u8def\u5f84\u4e0b\u7684 MatrixOne \u4ee3\u7801\u5e93\u63d0\u4ea4 id\u3002
mo_ctl get_cid help\nUsage : mo_ctl get_cid # print mo commit id from the path configured\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#get_branch-matrixone-id","title":"get_branch - \u6253\u5370 MatrixOne \u4ee3\u7801\u63d0\u4ea4 id","text":"\u4f7f\u7528 mo_ctl get_branch
\u6253\u5370\u5f53\u524d MO_PATH
\u8def\u5f84\u4e0b\u7684 MatrixOne \u4ee3\u7801\u5e93\u5206\u652f\u3002
mo_ctl get_branch help\nUsage : mo_ctl get_branch # print which git branch mo is currently on\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#pprof-","title":"pprof - \u6536\u96c6\u6027\u80fd\u4fe1\u606f","text":"\u4f7f\u7528 mo_ctl pprof [item] [duration]
\u6536\u96c6 MatrixOne \u7684\u76f8\u5173\u6027\u80fd\u4fe1\u606f\uff0c\u4e3b\u8981\u4e3a\u5f00\u53d1\u4eba\u5458\u8fdb\u884c\u8c03\u8bd5\u4f7f\u7528\u3002
mo_ctl pprof help\nUsage : mo_ctl pprof [item] [duration] # collect pprof information\n [item] : optional, specify what pprof to collect, available: profile | heap | allocs\n 1) profile : default, collect profile pprof for 30 seconds\n 2) heap : collect heap pprof at current moment\n 3) allocs : collect allocs pprof at current moment\n [duration] : optional, only valid when [item]=profile, specifiy duration to collect profile\n e.g. : mo_ctl pprof\n : mo_ctl pprof profile # collect duration will use conf value PPROF_PROFILE_DURATION from conf file or 30 if it's not set\n : mo_ctl pprof profile 30\n : mo_ctl pprof heap\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#set_conf-","title":"set_conf - \u914d\u7f6e\u53c2\u6570","text":"\u4f7f\u7528 mo_ctl set_conf [conf_list]
\u914d\u7f6e 1 \u4e2a\u6216\u591a\u4e2a\u4f7f\u7528\u53c2\u6570\u3002
mo_ctl set_conf help\nUsage : mo_ctl setconf [conf_list] # set configurations\n [conf_list] : configuration list in key=value format, seperated by comma\n e.g. : mo_ctl setconf MO_PATH=/data/mo/matrixone,MO_PW=M@trix0riginR0cks,MO_PORT=6101 # set multiple configurations\n : mo_ctl setconf MO_PATH=/data/mo/matrixone # set single configuration\n
Note
\u5f53 set_conf \u7684\u8bbe\u7f6e\u7684\u8def\u5f84\u4e2d\u5305\u542b\u53d8\u91cf\u5982 ${MO_PATH}
\u65f6\uff0c\u9700\u8981\u5728 $
\u524d\u52a0\u4e0a \\
\uff0c\u4f8b\u5982\uff1a
mo_ctl set_conf MO_CONF_FILE=\"\\${MO_PATH}/matrixone/etc/launch/launch.toml\"\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#get_conf-","title":"get_conf - \u83b7\u53d6\u53c2\u6570\u5217\u8868","text":"\u4f7f\u7528 mo_ctl get_conf [conf_list]
\u83b7\u53d6\u4e00\u4e2a\u6216\u591a\u4e2a\u5f53\u524d\u914d\u7f6e\u9879\u3002
mo_ctl get_conf help\nUsage : mo_ctl getconf [conf_list] # get configurations\n [conf_list] : optional, configuration list in key, seperated by comma.\n : use 'all' or leave it as blank to print all configurations\n e.g. : mo_ctl getconf MO_PATH,MO_PW,MO_PORT # get multiple configurations\n : mo_ctl getconf MO_PATH # get single configuration\n : mo_ctl getconf all # get all configurations\n : mo_ctl getconf # get all configurations\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#mo_ctl-get_conf-","title":"mo_ctl get_conf - \u8be6\u7ec6\u53c2\u6570\u5217\u8868","text":"\u4f7f\u7528 mo_ctl get_conf
\u5c06\u6253\u5370\u5f53\u524d\u5de5\u5177\u4f7f\u7528\u7684\u6240\u6709\u53c2\u6570\u5217\u8868\uff0c\u5b83\u4eec\u7684\u91ca\u4e49\u4e0e\u53d6\u503c\u8303\u56f4\u5982\u4e0b\u8868\u6240\u793a\u3002
\u4f7f\u7528 mo_ctl ddl_convert [options] [src_file] [tgt_file]
\u5c06\u4e00\u4e2a DDL \u6587\u4ef6\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u8bed\u6cd5\u683c\u5f0f\u8f6c\u6362\u6210 MatrixOne \u7684 DDL \u683c\u5f0f\uff0c\u76ee\u524d\u4ec5\u6709 mysql_to_mo
\u6a21\u5f0f\u652f\u6301\u3002
mo_ctl ddl_convert help\nUsage : mo_ctl ddl_convert [options] [src_file] [tgt_file] # convert a ddl file to mo format from other types of database\n [options] : available: mysql_to_mo\n [src_file] : source file to be converted, will use env DDL_SRC_FILE from conf file by default\n [tgt_file] : target file of converted output, will use env DDL_TGT_FILE from conf file by default\n e.g. : mo_ctl ddl_convert mysql_to_mo /tmp/mysql.sql /tmp/mo.sql\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#sql-sql","title":"sql - \u6267\u884c SQL","text":"\u4f7f\u7528 mo_ctl sql [sql]
\u6765\u6267\u884c SQL \u6587\u672c\u6216\u8005 SQL \u6587\u4ef6\u3002
mo_ctl sql help\nUsage : mo_ctl sql [sql] # execute sql from string, or a file or a path containg multiple files\n [sql] : a string quote by \"\", or a file, or a path\n e.g. : mo_ctl sql \"use test;select 1;\" # execute sql \"use test;select 1\"\n : mo_ctl sql /data/q1.sql # execute sql in file /data/q1.sql\n : mo_ctl sql /data/ # execute all sql files with .sql postfix in /data/\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#uninstall-matrixone","title":"uninstall - \u5378\u8f7d MatrixOne","text":"\u4f7f\u7528 mo_ctl uninstall
\u6765\u4ece MO_PATH \u4e0a\u5378\u8f7d MatrixOne\u3002
mo_ctl uninstall help\nUsage : mo_ctl uninstall # uninstall mo from path MO_PATH=/data/mo//matrixone\n # note: you will need to input 'Yes/No' to confirm before uninstalling\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#upgrade-matrixone","title":"upgrade - \u5347\u7ea7/\u964d\u7ea7 MatrixOne \u7248\u672c","text":"MatrixOne 0.8 \u53ca\u66f4\u9ad8\u7248\u672c\u53ef\u4f7f\u7528 mo_ctl upgrade version
\u6216\u8005 mo_ctl upgrade commitid
\u6765\u5c06 MatrixOne \u4ece\u5f53\u524d\u7248\u672c\u5347\u7ea7\u6216\u964d\u7ea7\u5230\u67d0\u4e2a\u7a33\u5b9a\u7248\u672c\u6216\u8005\u67d0\u4e2a commit id \u7248\u672c\u3002
mo_ctl upgrade help\nUsage : mo_ctl upgrade [version_commitid] # upgrade or downgrade mo from current version to a target commit id or stable version\n [commitid] : a commit id such as '38888f7', or a stable version such as '1.2.1'\n : use 'latest' to upgrade to latest commit on main branch if you don't know the id\n e.g. : mo_ctl upgrade 38888f7 # upgrade/downgrade to commit id 38888f7 on main branch\n : mo_ctl upgrade latest # upgrade/downgrade to latest commit on main branch\n : mo_ctl upgrade 1.2.1 # upgrade/downgrade to stable version 1.2.1\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ctl/#watchdog-matrixone","title":"watchdog - \u4fdd\u6d3b MatrixOne","text":"\u4f7f\u7528 mo_ctl watchdog [options]
\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u4efb\u52a1\u4fdd\u8bc1 MatrixOne \u670d\u52a1\u53ef\u7528\u6027\uff0c\u6bcf\u5206\u949f\u68c0\u67e5 MatrixOne \u7684\u72b6\u6001\uff0c\u5982\u679c\u53d1\u73b0\u670d\u52a1\u4e2d\u6b62\u5219\u81ea\u52a8\u62c9\u8d77\u670d\u52a1\u3002
mo_ctl watchdog help\nUsage : mo_ctl watchdog [options] # setup a watchdog crontab task for mo-service to keep it alive\n [options] : available: enable | disable | status\n e.g. : mo_ctl watchdog enable # enable watchdog service for mo, by default it will check if mo-servie is alive and pull it up if it's dead every one minute\n : mo_ctl watchdog disable # disable watchdog\n : mo_ctl watchdog status # check if watchdog is enabled or disabled\n : mo_ctl watchdog # same as mo_ctl watchdog status\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/","title":"mo_datax_writer \u5de5\u5177\u6307\u5357","text":"mo_datax_writer
\u662f\u4e00\u6b3e\u5e2e\u52a9\u4f60\u5b9e\u73b0\u5c06\u6570\u636e\u4ece mysql \u5230 matrixone \u8fc1\u79fb\u7684\u5de5\u5177\u3002
Note
mo_datax_writer
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_datax_writer/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip cd mo_datax_writer-1.0.1/ #\u5c06mo_datax_writer\u89e3\u538b\u5230datax/plugin/writer/\u76ee\u5f55\u4e0b\nunzip matrixonewriter.zip -d ../datax/plugin/writer/\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#matrixone","title":"\u521d\u59cb\u5316 MatrixOne \u6570\u636e\u8868","text":""},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_2","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"create database test;\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_3","title":"\u521b\u5efa\u8868","text":"use test;\n\nCREATE TABLE `user` (\n`name` VARCHAR(255) DEFAULT null,\n`age` INT DEFAULT null,\n`city` VARCHAR(255) DEFAULT null\n);\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#mysql","title":"\u521d\u59cb\u5316 MySQL \u6570\u636e\u8868","text":""},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_4","title":"\u521b\u5efa\u6570\u636e\u5e93","text":"create database test;\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_5","title":"\u521b\u5efa\u8868","text":"use test;\n\nCREATE TABLE `user` (\n`name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,\n`age` int DEFAULT NULL,\n`city` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_6","title":"\u5bfc\u5165\u6570\u636e","text":"insert into user values('zhangsan',26,'Shanghai'),('lisi',24,'Chengdu'),('wangwu',28,'Xian'),('zhaoliu',22,'Beijing'),('tianqi',26,'Shenzhen');\n\nmysql> select * from user;\n+----------+------+----------+\n| name | age | city |\n+----------+------+----------+\n| zhangsan | 26 | Shanghai |\n| lisi | 24 | Chengdu |\n| wangwu | 28 | Xian |\n| zhaoliu | 22 | Beijing |\n| tianqi | 26 | Shenzhen |\n+----------+------+----------+\n5 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#datax","title":"\u4f7f\u7528 DataX \u5bfc\u5165\u6570\u636e","text":""},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_7","title":"\u7f16\u5199\u914d\u7f6e\u6587\u4ef6","text":"\u5728 datax/job \u76ee\u5f55\u4e0b\u6dfb\u52a0 datax \u914d\u7f6e\u6587\u4ef6 mysql2mo.json\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a
{\n\"job\": {\n\"setting\": {\n\"speed\": {\n\"channel\": 1\n},\n\"errorLimit\": {\n\"record\": 0,\n\"percentage\": 0\n}\n},\n\"content\": [\n{\n\"reader\": {\n\"name\": \"mysqlreader\",\n\"parameter\": {\n// MySQL \u6570\u636e\u5e93\u7528\u6237\u540d\n\"username\": \"root\",\n// MySQL \u6570\u636e\u5e93\u5bc6\u7801\n\"password\": \"111\",\n// MySQL \u6570\u636e\u8868\u8bfb\u53d6\u7684\u5217\u540d\n\"column\": [\"name\",\"age\",\"city\"],\n\"splitPk\": \"\",\n\"connection\": [\n{\n// MySQL \u6570\u636e\u8868\n\"table\": [\"user\"],\n// MySQL \u8fde\u63a5\u4fe1\u606f\n\"jdbcUrl\": [\n\"jdbc:mysql://127.0.0.1:3306/test?useSSL=false\"\n]\n}\n]\n}\n},\n\"writer\": {\n\"name\": \"matrixonewriter\",\n\"parameter\": {\n// \u6570\u636e\u5e93\u7528\u6237\u540d\n\"username\": \"root\",\n// \u6570\u636e\u5e93\u5bc6\u7801\n\"password\": \"111\",\n// \u9700\u8981\u5bfc\u5165\u7684\u8868\u5217\u540d\n\"column\": [\"name\",\"age\",\"city\"],\n// \u5bfc\u5165\u4efb\u52a1\u5f00\u59cb\u524d\u9700\u8981\u6267\u884c\u7684 SQL \u8bed\u53e5\n\"preSql\": [],\n// \u5bfc\u5165\u4efb\u52a1\u5b8c\u6210\u4e4b\u540e\u8981\u6267\u884c\u7684 SQL \u8bed\u53e5\n\"postSql\": [],\n// \u6279\u91cf\u5199\u5165\u6761\u6570\uff0c\u5373\u8bfb\u53d6\u591a\u5c11\u6761\u6570\u636e\u540e\u6267\u884c load data inline \u5bfc\u5165\u4efb\u52a1\n\"maxBatchRows\": 60000,\n// \u6279\u91cf\u5199\u5165\u5927\u5c0f\uff0c\u5373\u8bfb\u53d6\u591a\u5927\u7684\u6570\u636e\u540e\u6267\u884c load data inline \u5bfc\u5165\u4efb\u52a1\n\"maxBatchSize\": 5242880,\n// \u5bfc\u5165\u4efb\u52a1\u6267\u884c\u65f6\u95f4\u95f4\u9694\uff0c\u5373\u7ecf\u8fc7\u591a\u957f\u65f6\u95f4\u540e\u6267\u884c load data inline \u5bfc\u5165\u4efb\u52a1\n\"flushInterval\": 300000,\n\"connection\": [\n{\n// \u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f\n\"jdbcUrl\": \"jdbc:mysql://127.0.0.1:6001/test?useUnicode=true&useSSL=false\",\n// \u6570\u636e\u5e93\u540d\n\"database\": \"test\",\n// \u6570\u636e\u5e93\u8868\n\"table\": [\"user\"]\n}\n]\n}\n}\n}\n]\n}\n}\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#datax_1","title":"\u6267\u884c DataX \u4efb\u52a1","text":"\u8fdb\u5165 datax \u5b89\u88c5\u76ee\u5f55\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4
python bin/datax.py job/mysql2mo.json\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
2024-06-06 06:26:52.145 [job-0] INFO StandAloneJobContainerCommunicator - Total 5 records, 75 bytes | Speed 7B/s, 0 records/s | Error 0 records, 0 bytes | All Task WaitWriterTime 0.000s | All Task WaitReaderTime 0.012s | Percentage 100.00%\n2024-06-06 06:26:52.147 [job-0] INFO JobContainer - \n\u4efb\u52a1\u542f\u52a8\u65f6\u523b : 2024-06-06 14:26:41\n\u4efb\u52a1\u7ed3\u675f\u65f6\u523b : 2024-06-06 14:26:52\n\u4efb\u52a1\u603b\u8ba1\u8017\u65f6 : 10s\n\u4efb\u52a1\u5e73\u5747\u6d41\u91cf : 7B/s\n\u8bb0\u5f55\u5199\u5165\u901f\u5ea6 : 0rec/s\n\u8bfb\u51fa\u8bb0\u5f55\u603b\u6570 : 5\n\u8bfb\u5199\u5931\u8d25\u603b\u6570 : 0\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_datax_writer/#_8","title":"\u67e5\u770b\u7ed3\u679c","text":"\u5728 MatrixOne \u6570\u636e\u5e93\u4e2d\u67e5\u770b\u7ed3\u679c\uff0c\u53ef\u4ee5\u770b\u5230\u6570\u636e\u5df2\u7ecf\u4ece MySQL \u540c\u6b65\u5230 MatrixOne \u4e2d
mysql> select * from user;\n+----------+------+-----------+\n| name | age | city |\n+----------+------+-----------+\n| zhangsan | 26 | Shanghai |\n| lisi | 24 | Chengdu |\n| wangwu | 28 | Xian |\n| zhaoliu | 22 | Beijing |\n| tianqi | 26 | Shenzhen |\n+----------+------+-----------+\n5 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/","title":"mo_ssb_open \u5de5\u5177\u6307\u5357","text":"mo_ssb_open
\u662f\u4e00\u6b3e\u9488\u5bf9 MatrixOne \u5b9e\u73b0 SSB \u6d4b\u8bd5\u7684\u5de5\u5177\u3002
Note
mo_ssb_open
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_ssb_open/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#_2","title":"\u751f\u6210\u6570\u636e\u96c6","text":"cd mo_ssb_open-1.0.1 \n./bin/gen-ssb-data.sh -s 1 -c 5\n
-s\uff1a\u8868\u793a\u4ea7\u751f\u5927\u7ea6 1GB \u7684\u6570\u636e\u96c6\uff0c\u4e0d\u6307\u5b9a\u53c2\u6570\uff0c\u9ed8\u8ba4\u751f\u6210 100G \u6570\u636e\uff0c
-c\uff1a\u8868\u793a\u751f\u6210 lineorder \u8868\u6570\u636e\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 10 \u7ebf\u7a0b\u3002
\u751f\u6210\u5b8c\u6574\u6570\u636e\u96c6\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u3002\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 mo_ssb_open-1.0.1/bin/ssb-data/ \u76ee\u5f55\u4e0b\u770b\u5230\u7ed3\u679c\u6587\u4ef6\u3002
root@host-10-222-4-8:~/soft/ssb/mo_ssb_open-1.0.1/bin/ssb-data# ls -l\ntotal 604976\n-rwS--S--T 1 root root 2837046 Jun 7 03:31 customer.tbl\n-rw-r--r-- 1 root root 229965 Jun 7 03:31 date.tbl\n-rw-r--r-- 1 root root 118904702 Jun 7 03:31 lineorder.tbl.1\n-rw-r--r-- 1 root root 119996341 Jun 7 03:31 lineorder.tbl.2\n-rw-r--r-- 1 root root 120146777 Jun 7 03:31 lineorder.tbl.3\n-rw-r--r-- 1 root root 120000311 Jun 7 03:31 lineorder.tbl.4\n-rw-r--r-- 1 root root 120057972 Jun 7 03:31 lineorder.tbl.5\n-rw-r--r-- 1 root root 17139259 Jun 7 03:31 part.tbl\n-rw-r--r-- 1 root root 166676 Jun 7 03:31 supplier.tbl\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#matrixone","title":"\u5728 MatrixOne \u4e2d\u5efa\u8868","text":"\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 conf/matrxione.conf\uff0c\u6307\u5b9a MatrixOne \u7684\u5730\u5740\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\uff0c\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b\u5982\u4e0b
# MatrixOne host\nexport HOST='127.0.0.1'\n# MatrixOne port\nexport PORT=6001\n# MatrixOne username\nexport USER='root'\n# MatrixOne password\nexport PASSWORD='111'\n# The database where SSB tables located\nexport DB='ssb'\n
\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u8fdb\u884c\u5efa\u8868\u64cd\u4f5c\u3002
./bin/create-ssb-tables.sh\n
\u8fde\u63a5 MatrixOne \u67e5\u770b\uff0c\u5efa\u8868\u6210\u529f\u3002
mysql> show tables;\n+----------------+\n| Tables_in_ssb |\n+----------------+\n| customer |\n| dates |\n| lineorder |\n| lineorder_flat |\n| part |\n| supplier |\n+----------------+\n6 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#_3","title":"\u5bfc\u5165\u6570\u636e","text":"\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u5bfc\u5165 ssb \u6d4b\u8bd5\u6240\u9700\u6570\u636e\uff1a
./bin/load-ssb-data.sh -c 10\n
\u53c2\u6570\u91ca\u4e49
-c: \u53ef\u4ee5\u6307\u5b9a\u6267\u884c\u5bfc\u5165\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 5 \u4e2a\u7ebf\u7a0b\u3002
\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u521b\u5efa\u7684\u8868\u67e5\u8be2 MatrixOne \u4e2d\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_ssb_open/#_4","title":"\u8fd0\u884c\u67e5\u8be2\u547d\u4ee4","text":"\u67e5\u8be2\u7ed3\u679c\u7b2c\u4e00\u5217\u4e3a\u67e5\u8be2\u7f16\u7801\uff0c
root@host-10-222-4-8:~/soft/ssb/mo_ssb_open-1.0.1# ./bin/run-ssb-queries.sh\nmysqlslap Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nmysql Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nHOST: 127.0.0.1\nPORT: 6001\nUSER: root\nDB: ssb\nq1.1: 0.22 0.16 0.13 fast:0.13\nq1.2: 0.17 0.17 0.17 fast:0.17\nq1.3: 0.15 0.19 0.18 fast:0.15\nq2.1: 0.22 0.21 0.23 fast:0.21\nq2.2: 0.18 0.17 0.16 fast:0.16\nq2.3: 0.15 0.16 0.17 fast:0.15\nq3.1: 0.24 0.23 0.23 fast:0.23\nq3.2: 0.16 0.16 0.20 fast:0.16\nq3.3: 0.16 0.14 0.13 fast:0.13\nq3.4: 0.12 0.11 0.11 fast:0.11\nq4.1: 0.24 0.22 0.30 fast:0.22\nq4.2: 0.22 0.21 0.22 fast:0.21\nq4.3: 0.20 0.21 0.20 fast:0.20\ntotal time: 2.23 seconds\nFinish ssb queries.\n
root@host-10-222-4-8:~/soft/ssb/mo_ssb_open-1.0.1# ./bin/run-ssb-flat-queries.sh\nmysqlslap Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nmysql Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nbc 1.07.1\nCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc.\nHOST: 127.0.0.1\nPORT: 6001\nUSER: root\nDB: ssb\nq1.1: 0.21 0.13 0.14 fast:0.13\nq1.2: 0.15 0.13 0.15 fast:0.13\nq1.3: 0.16 0.21 0.22 fast:0.16\nq2.1: 0.36 0.34 0.38 fast:0.34\nq2.2: 0.36 0.34 0.32 fast:0.32\nq2.3: 0.25 0.26 0.22 fast:0.22\nq3.1: 0.39 0.39 0.30 fast:0.30\nq3.2: 0.32 0.33 0.29 fast:0.29\nq3.3: 0.22 0.23 0.29 fast:0.22\nq3.4: 0.32 0.28 0.31 fast:0.28\nq4.1: 0.42 0.38 0.38 fast:0.38\nq4.2: 0.42 0.48 0.45 fast:0.42\nq4.3: 0.35 0.34 0.29 fast:0.29\ntotal time: 3.48 seconds\nFinish ssb-flat queries.\n
\u67e5\u8be2\u7ed3\u679c\u5206\u522b\u5bf9\u5e94\uff1a\u67e5\u8be2\u8bed\u53e5\u3001\u7b2c\u4e00\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e8c\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e09\u6b21\u67e5\u8be2\u7ed3\u679c\u548c\u6700\u5feb\u7ed3\u679c\uff0c\u5355\u4f4d\u4e3a s\u3002
Note
\u60a8\u53ef\u4ee5\u5728 mo_ssb_open-1.0.1/ssb-queries \u76ee\u5f55\u4e0b\u67e5\u770b\u5177\u4f53\u7684\u67e5\u8be2\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/","title":"mo_tpch_open \u5de5\u5177\u6307\u5357","text":"mo_tpch_open
\u662f\u4e00\u6b3e\u9488\u5bf9 MatrixOne \u5b9e\u73b0 TPCH \u6d4b\u8bd5\u7684\u5de5\u5177\u3002
Note
mo_tpch_open
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_tpch_open/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#_2","title":"\u751f\u6210\u6570\u636e\u96c6","text":"\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u6570\u636e\u96c6\uff1a
cd mo_tpch_open-1.0.1\n./bin/gen-tpch-data.sh -s 1 -c 5\n
\u53c2\u6570\u91ca\u4e49
-s\uff1a\u8868\u793a\u4ea7\u751f\u5927\u7ea6 1GB \u7684\u6570\u636e\u96c6\uff0c\u4e0d\u6307\u5b9a\u53c2\u6570\uff0c\u9ed8\u8ba4\u751f\u6210 100G \u6570\u636e\uff0c
-c\uff1a\u8868\u793a\u751f\u6210\u8868\u6570\u636e\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 10 \u7ebf\u7a0b\u3002
\u751f\u6210\u5b8c\u6574\u6570\u636e\u96c6\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u3002\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 mo_tpch_open-1.0.1/bin/tpch-data \u76ee\u5f55\u4e0b\u770b\u5230\u7ed3\u679c\u6587\u4ef6\u3002
root@host-10-222-4-8:~/soft/tpch/tpch-tools/bin/tpch-data# ls -l\nroot@host-10-222-4-8:~/soft/tpch/mo_tpch_open-1.0.1/bin/tpch-data# ls -l\ntotal 1074936\n-rw-r--r-- 1 root root 24346144 Jun 7 03:16 customer.tbl\n-rw-r--r-- 1 root root 151051198 Jun 7 03:16 lineitem.tbl.1\n-rw-r--r-- 1 root root 152129724 Jun 7 03:16 lineitem.tbl.2\n-rw-r--r-- 1 root root 152344710 Jun 7 03:16 lineitem.tbl.3\n-rw-r--r-- 1 root root 152123661 Jun 7 03:16 lineitem.tbl.4\n-rw-r--r-- 1 root root 152213994 Jun 7 03:16 lineitem.tbl.5\n-rw-r--r-- 1 root root 2224 Jun 7 03:16 nation.tbl\n-rw-r--r-- 1 root root 34175478 Jun 7 03:16 orders.tbl.1\n-rw-r--r-- 1 root root 34463858 Jun 7 03:16 orders.tbl.2\n-rw-r--r-- 1 root root 34437453 Jun 7 03:16 orders.tbl.3\n-rw-r--r-- 1 root root 34445732 Jun 7 03:16 orders.tbl.4\n-rw-r--r-- 1 root root 34429640 Jun 7 03:16 orders.tbl.5\n-rw-r--r-- 1 root root 24135125 Jun 7 03:16 part.tbl\n-rw-r--r-- 1 root root 23677134 Jun 7 03:16 partsupp.tbl.1\n-rw-r--r-- 1 root root 23721079 Jun 7 03:16 partsupp.tbl.2\n-rw-r--r-- 1 root root 23808550 Jun 7 03:16 partsupp.tbl.3\n-rw-r--r-- 1 root root 23894802 Jun 7 03:16 partsupp.tbl.4\n-rw-r--r-- 1 root root 23883051 Jun 7 03:16 partsupp.tbl.5\n-rw-r--r-- 1 root root 389 Jun 7 03:16 region.tbl\n-rw-r--r-- 1 root root 1409184 Jun 7 03:16 supplier.tbl\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#matrixone","title":"\u5728 MatrixOne \u4e2d\u5efa\u8868","text":"\u4fee\u6539\u914d\u7f6e\u6587\u4ef6 conf/matrxione.conf\uff0c\u6307\u5b9a MatrixOne \u7684\u5730\u5740\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\uff0c\u914d\u7f6e\u6587\u4ef6\u793a\u4f8b\u5982\u4e0b
# MatrixOne host\nexport HOST='127.0.0.1'\n# MatrixOne port\nexport PORT=6001\n# MatrixOne username\nexport USER='root'\n# MatrixOne password\nexport PASSWORD='111'\n# The database where TPC-H tables located\nexport DB='tpch'\n
\u7136\u540e\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u8fdb\u884c\u5efa\u8868\u64cd\u4f5c\u3002
./bin/create-tpch-tables.sh\n
\u8fde\u63a5 MatrixOne \u67e5\u770b\uff0c\u5efa\u8868\u6210\u529f\u3002
mysql> show tables;\n+----------------+\n| Tables_in_tpch |\n+----------------+\n| customer |\n| lineitem |\n| nation |\n| orders |\n| part |\n| partsupp |\n| region |\n| revenue0 |\n| supplier |\n+----------------+\n9 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#_3","title":"\u5bfc\u5165\u6570\u636e","text":"\u6267\u884c\u4ee5\u4e0b\u811a\u672c\u5bfc\u5165 TPC-H \u6d4b\u8bd5\u6240\u9700\u6570\u636e\uff1a
./bin/load-tpch-data.sh -c 10\n
\u53c2\u6570\u91ca\u4e49
-c: \u53ef\u4ee5\u6307\u5b9a\u6267\u884c\u5bfc\u5165\u7684\u7ebf\u7a0b\u6570\uff0c\u9ed8\u8ba4\u4e3a 5 \u4e2a\u7ebf\u7a0b\u3002
\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u521b\u5efa\u7684\u8868\u67e5\u8be2 MatrixOne \u4e2d\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_tpch_open/#_4","title":"\u8fd0\u884c\u67e5\u8be2\u547d\u4ee4","text":"\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u67e5\u8be2\uff1a
root@host-10-222-4-8:~/soft/tpch/mo_tpch_open-1.0.1# ./bin/run-tpch-queries.sh\nmysql Ver 8.0.37 for Linux on x86_64 (MySQL Community Server - GPL)\nHOST: 127.0.0.1\nPORT: 6001\nUSER: root\nDB: tpch\nTime Unit: ms\nq1 836 715 691 691\nq2 111 80 88 80\nq3 325 235 212 212\nq4 221 181 177 177\nq5 240 236 295 236\nq6 215 292 350 292\nq7 373 327 299 299\nq8 236 238 243 238\nq9 443 406 413 406\nq10 375 390 422 390\nq11 201 237 231 231\nq12 461 460 400 400\nq13 321 294 301 294\nq14 289 261 282 261\nq15 391 285 294 285\nq16 222 288 255 255\nq17 333 247 243 243\nq18 275 262 317 262\nq19 513 479 511 479\nq20 240 244 198 198\nq21 1503 1746 1786 1746\nq22 138 122 126 122\nTotal cold run time: 8262 ms\nTotal hot run time: 7797 ms\nFinish tpch queries.\n
\u67e5\u8be2\u7ed3\u679c\u5206\u522b\u5bf9\u5e94\uff1a\u67e5\u8be2\u8bed\u53e5\u3001\u7b2c\u4e00\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e8c\u6b21\u67e5\u8be2\u7ed3\u679c\u3001\u7b2c\u4e09\u6b21\u67e5\u8be2\u7ed3\u679c\u548c\u6700\u5feb\u7ed3\u679c\uff0c\u5355\u4f4d\u4e3a ms\u3002
Note
\u60a8\u53ef\u4ee5\u5728 mo_tpch_open-1.0.1/queries \u76ee\u5f55\u4e0b\u67e5\u770b\u5177\u4f53\u7684\u67e5\u8be2\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/","title":"mo_ts_perf_test \u5de5\u5177\u6307\u5357","text":"mo_ts_perf_test
\u662f\u4e00\u6b3e\u9488\u5bf9 MatrixOne \u8fdb\u884c\u65f6\u5e8f\u5199\u5165\u548c\u67e5\u8be2\u6d4b\u8bd5\u5de5\u5177\u3002
Note
mo_ts_perf_test
\u5de5\u5177\u76ee\u524d\u53ea\u652f\u6301\u5728 Linux \u7cfb\u7edf x86 \u67b6\u6784\u90e8\u7f72\u3002
wget https://github.com/matrixorigin/mo_ts_perf_test/archive/refs/tags/v1.0.1.zip\nunzip v1.0.1.zip\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/#_2","title":"\u914d\u7f6e","text":"\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u4fee\u6539 matrixone/conf \u76ee\u5f55\u4e0b\u7684 db.conf \u914d\u7f6e\u6587\u4ef6
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.0/matrixone/conf# cat db.conf [dbInfo]\nhost = 127.0.0.1\nport = 6001\nuser = root\npassword = 111\ntablePrefix = d\npoint_query_ts_condition = '2017-07-14 10:40:06.379'\nloadFilePath = /root/soft/perf/\n
\u914d\u7f6e\u8bf4\u660e\uff1a
mo-write \u4e3a MO \u5199\u5165\u6d4b\u8bd5\u5de5\u5177\uff0c\u547d\u4ee4\u4e3a\uff1a
mo-write -T -r -n -retry -mode -txc -tType -wType -wType\n
Note
\u6240\u6709\u5199\u5165\u90fd\u662f\u5411 test \u6570\u636e\u5e93\u4e0b\u7684\u8868\u5199\uff0c\u5355\u8868\u5199\u5165\u662f\u5411 d0 \u8868\u5199\uff0c\u591a\u8868\u5199\u5165\u662f\u5411 d0\u3001d1\u3001d2 \u7b49\u7b49\uff08\u6570\u91cf\u7531\u5ba2\u6237\u7aef\u6570\u636e\u51b3\u5b9a\uff09\u3002
\u53c2\u6570\u8bf4\u660e
\u4f7f\u7528\u9ed8\u8ba4\u914d\u7f6e\u5199\u6570\u636e\uff0c\u5373\uff1a7 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 load data inline \u7684\u65b9\u5f0f\uff0c\u5206\u522b\u5411\u65e0\u4e3b\u952e\u7684\u65f6\u5e8f\u8868\uff08d0\u3001d1\u2026\u2026 d6\uff09\u591a\u8868\u5199\u5165 500000 \u6761\u6570\u636e\uff08\u603b\u5171\u5199\u5165\u6570\u636e\u91cf\uff1a500000*7\uff09\uff0c\u6bcf\u6b21\u5199\u5165 10000 \u884c\u6570\u636e\uff0c\u6d4b\u8bd5\u4e00\u7ec4\u6570\u636e\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.0/matrixone/mo-write# ./mo-write r=10000, T=7, n=500000, mode=multi, retry=1, txc=0, tType=ts, wType=loadLine \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:7\ndb connection[1] created.\ndb connection[2] created.\ndb connection[3] created.\ndb connection[4] created.\ndb connection[5] created.\ndb connection[6] created.\ndb connection[7] created.\nmo-data of all clinet(7 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:7.255468 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=0 \n\nstart test 1 \u2026\u2026.\nspend time:7.405524 s\n1 test: 3500000/7.405524 = 472620.159086 records/second\n======== avg test: 472620.159086/1 = 472620.159086 records/second txc=0 ===========\n
2 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 insert into \u7684\u65b9\u5f0f\uff0c\u5206\u522b\u5411\u6709\u4e3b\u952e\u7684\u65f6\u5e8f\u8868\uff08d0\uff09\u5355\u8868\u5199 100000 \u6761\u6570\u636e\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-write# ./mo-write -T 2 -n 100000 -mode single -tType tsPK -wType insert\nr=10000, T=2, n=100000, mode=single, retry=1, txc=0, tType=tsPK, wType=insert \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:2\ndb connection[1] created.\ndb connection[2] created.\nmo-data of all clinet(2 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:0.819425 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=0 \n\nstart test 1 \u2026\u2026.\nspend time:11.388648 s\n1 test: 200000/11.388648 = 17561.347089 records/second\n======== avg test: 17561.347089/1 = 17561.347089 records/second txc=0 ===========\n
1 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 load data inline \u7684\u65b9\u5f0f\uff0c\u5411\u4e3b\u952e\u4e3a int \u7c7b\u578b\u7684\u666e\u901a\u8868\uff08d0\uff09\u5199 500000 \u6761\u6570\u636e\uff0c\u6d4b\u8bd5\u4e00\u7ec4\u6570\u636e\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-write# ./mo-write -T 1 -tType=intPK -retry 1\nr=10000, T=1, n=500000, mode=multi, retry=1, txc=0, tType=intPK, wType=loadLine \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:1\ndb connection[1] created.\nmo-data of all clinet(1 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:1.583363 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=0 \n\nstart test 1 \u2026\u2026.\nspend time:5.062582 s\n1 test: 500000/5.062582 = 98763.826906 records/second\n======== avg test: 98763.826906/1 = 98763.826906 records/second txc=0 ===========\n
8 \u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528 load data inline \u7684\u65b9\u5f0f\uff0c\u901a\u8fc7\u4e8b\u52a1\u63d0\u4ea4\uff08\u6bcf\u6b21\u63d0\u4ea4 10 \u6b21\u5199\u5165\uff09\u5411\u65e0\u4e3b\u952e\u7684\u65f6\u5e8f\u8868\uff08d0\u2026\u2026d7\uff09\u591a\u8868\u5199 500000 \u6761\u6570\u636e\uff0c\u81ea\u52a8\u6d4b\u8bd5 3 \u7ec4\u6c42\u5e73\u5747\u503c\uff1a
root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-write# ./mo-write -T 8 -txc 10 -retry 3\nr=10000, T=8, n=500000, mode=multi, retry=3, txc=10, tType=ts, wType=loadLine \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:8\ndb connection[1] created.\ndb connection[2] created.\ndb connection[3] created.\ndb connection[4] created.\ndb connection[5] created.\ndb connection[6] created.\ndb connection[7] created.\ndb connection[8] created.\nmo-data of all clinet(8 thread) has ready!\nInitialize database and table completed.\nstart preparing test data.\nspend time of prepare testing data:7.854798 s\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c1\u6b21\u6d4b\u8bd5, txc=10 \n\nstart test 1 \u2026\u2026.\n\u5f00\u59cb\u4e8b\u52a1\u63d0\u4ea4\u5199\u5165, \u4e00\u6b21\u4e8b\u52a1\u63d0\u4ea4\u7684\u5199\u5165: 10\nspend time:9.482012 s\n1 test: 4000000/9.482012 = 421851.388088 records/second\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c2\u6b21\u6d4b\u8bd5, txc=10 \n\nstart test 2 \u2026\u2026.\ntables has truncated and start insert data \u2026\u2026\n\u5f00\u59cb\u4e8b\u52a1\u63d0\u4ea4\u5199\u5165, \u4e00\u6b21\u4e8b\u52a1\u63d0\u4ea4\u7684\u5199\u5165: 10\nspend time:10.227261 s\n2 test: 4000000/10.227261 = 391111.576833 records/second\n\u6309 Y \u6216\u8005 \u56de\u8f66\u952e,\u5c06\u5f00\u59cb\u63d2\u5165\u6570\u636e,\u6309 N \u5c06\u9000\u51fa, \u5f00\u7684\u7b2c3\u6b21\u6d4b\u8bd5, txc=10 \n\nstart test 3 \u2026\u2026.\ntables has truncated and start insert data \u2026\u2026\n\u5f00\u59cb\u4e8b\u52a1\u63d0\u4ea4\u5199\u5165, \u4e00\u6b21\u4e8b\u52a1\u63d0\u4ea4\u7684\u5199\u5165: 10\nspend time:8.994586 s\n3 test: 4000000/8.994586 = 444711.979564 records/second\n======== avg test: 1257674.944485/3 = 419224.981495 records/second txc=10 ===========\n
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/#mo-query","title":"\u4f7f\u7528 mo-query \u6267\u884c\u67e5\u8be2\u6d4b\u8bd5","text":"mo-query \u4e3a\u67e5\u8be2\u6d4b\u8bd5\u5de5\u5177\uff0c\u6d4b\u8bd5 select *\u3001\u70b9\u67e5\u8be2\u3001\u5e38\u7528\u805a\u5408\u67e5\u8be2\u3001\u65f6\u95f4\u7a97\u53e3\u7b49\u67e5\u8be2\u7684\u65f6\u95f4\uff0c\u6240\u6709\u67e5\u8be2\u90fd\u53ea\u67e5\u8be2 test \u5e93\u91cc d0 \u8fd9\u4e00\u5f20\u8868\u3002\u547d\u4ee4\u4e3a\uff1a
mo-query -T\n
\u53c2\u6570\u8bf4\u660e
-T: \u8868\u793a\u5e76\u53d1\u6267\u884c select * \u67e5\u8be2\u7684\u5ba2\u6237\u7aef\u6570\u91cf\uff0c\u9ed8\u8ba4\u4e3a 1\u3002
"},{"location":"MatrixOne/Reference/mo-tools/mo_ts_perf_test/#_4","title":"\u793a\u4f8b","text":"root@host-10-222-4-8:~/soft/perf/mo_ts_perf_test-1.0.1/matrixone/mo-query# ./mo-query -T 5\nT=5 \ndbConfig:{127.0.0.1 6001 root 111 d '2017-07-14 10:40:06.379' /root/soft/perf/}\nstart create db conn, count:5\ndb connection[1] created.\ndb connection[2] created.\ndb connection[3] created.\ndb connection[4] created.\ndb connection[5] created.\nmo all clinet(5 thread) has ready!\n\n count value is:200000\n'count(*)' query spend time:0.062345 s\n\n'select *' (5 client concurrent query) spend time:0.850350 s\nquery speed: 1000000/0.850350 = 1175985.806764 records/second\n\n point query sql: select * from test.d0 where ts='2017-07-14 10:40:06.379'\n'point query' spend time:0.001589 s\n\n avg value is: 0.07560730761790913\n'avg(current)' query spend time:0.026116 s\n\n sum value is: 15121.461523581824\n'sum(current)' query spend time:0.023109 s\n\n max value is: 3.9999022\n'max(current)' query spend time:0.054021 s\n\n min value is: -3.9999993\n'min(current)' query spend time:0.035809 s\n\nTimeWindow query sql:select _wstart, _wend, max(current), min(current) from d0 interval(ts, 60, minute) sliding(60, minute)\n2017-07-14 02:00:00 +0000 UTC 2017-07-14 03:00:00 +0000 UTC 3.9999022 -3.9999993\nTimeWindow query spend time:0.180333 s\n
"},{"location":"MatrixOne/Release-Notes/release-timeline/","title":"MatrixOne \u7248\u672c\u53d1\u5e03\u5386\u53f2\u8bb0\u5f55","text":"\u672c\u6587\u5217\u51fa\u4e86\u6240\u6709\u5df2\u53d1\u5e03\u7684 MatrixOne \u7248\u672c\uff0c\u6309\u53d1\u5e03\u65f6\u95f4\u5012\u5e8f\u6392\u5217\u5448\u73b0\u3002
\u7248\u672c \u53d1\u5e03\u65e5\u671f v1.2.1 2024/06/27 v1.2.0 2024/05/20 v1.1.3 2024/04/16 v1.1.2 2024/04/02 v1.1.1 2024/02/04 v1.1.0 2023/12/29 v1.0.2 2023/12/23 v1.0.1 2023/12/16 v1.0.0 2023/11/13 v1.0.0-rc2 2023/10/24 v1.0.0-rc1 2023/8/24 v0.8.0 2023/6/30 v0.7.0 2023/2/23 v0.6.0 2022/11/29 v0.5.1 2022/8/19 v0.5.0 2022/7/18 v0.4.0 2022/5/5 v0.3.0 2022/3/10 v0.2.0 2022/1/6 v0.1.0 2021/10/24"},{"location":"MatrixOne/Release-Notes/v0.1.0/","title":"MatrixOne v0.1.0 Release Notes","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.1.0 \u7248\u672c\u4e8e 2021 \u5e74 10 \u6708 24 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
"},{"location":"MatrixOne/Release-Notes/v0.1.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne 0.1.0 \u7248\u672c\u3002
"},{"location":"MatrixOne/Release-Notes/v0.1.0/#_1","title":"\u6838\u5fc3\u7279\u6027","text":""},{"location":"MatrixOne/Release-Notes/v0.1.0/#sql","title":"SQL","text":"\u672c\u6b21\u53d1\u5e03\u7684\u7248\u672c\u652f\u6301\u4e00\u4e0b SQL \u8bed\u53e5\uff1a
"},{"location":"MatrixOne/Release-Notes/v0.1.0/#ddl","title":"DDL","text":"\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 16 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 453 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002\u6b64\u5916\uff0c\u6211\u4eec\u683c\u5916\u611f\u8c22\u9996\u6b21\u4e3a MatrixOne \u4f5c\u51fa\u8d21\u732e\u7684\u5f00\u53d1\u8005\uff01
Yan Wenze (@nnsgmsone) Chen Mingsong (@m-schen) Jin Hai (@JinHai-CN) Jiang xinmeng (@jiangxinmeng1) Li Yang (@lignay) Lin Junhong (@iamlinjunhong) lni (@lni) Long Ran (@aunjgr) Peng Zhen (@daviszhen) Qin Shuqi (@sukki37) Shen JiangWei (@LeftHandCold) Wei Ziran (@w-zr) Xiong Jingjuan (@anitajjx) Xu Peng (@XuPeng-SH) Yan Wenze (@nnsgmsone) Zilong Zhou (@zzl200012) Zhang Yingfeng (@yingfeng)
"},{"location":"MatrixOne/Release-Notes/v0.2.0/","title":"MatrixOne v0.2.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.2.0 \u7248\u672c\u4e8e 2022 \u5e74 1 \u6708 6 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u4ee5\u4e0b\u6211\u4eec\u5c06\u5bf9\u7248\u672c\u6700\u65b0\u7684\u66f4\u65b0\u5185\u5bb9\u8fdb\u884c\u9648\u5217\u3002
"},{"location":"MatrixOne/Release-Notes/v0.2.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne0.2.0 \u7248\u672c\u3002
"},{"location":"MatrixOne/Release-Notes/v0.2.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"group by
\u6216\u805a\u5408\u8bed\u53e5\u4e2d\u4f7f\u7528 equi joinpre-allocate-group-num
\u53c2\u6570\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u66f4\u5927\u7684\u503c\u3002\u5426\u5219\uff0c\u8fc7\u7a0b\u4e2d\u4f1a\u62a5\u9519 \"no available raft group\"\u3002 \u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 21 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 243 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.3.0 \u7248\u672c\u4e8e 2022 \u5e74 3 \u6708 10 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u4ee5\u4e0b\u6211\u4eec\u5c06\u5bf9\u7248\u672c\u6700\u65b0\u7684\u66f4\u65b0\u5185\u5bb9\u8fdb\u884c\u9648\u5217\u3002
"},{"location":"MatrixOne/Release-Notes/v0.3.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne0.3.0 \u7248\u672c\u3002
"},{"location":"MatrixOne/Release-Notes/v0.3.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"IN
\u8fd0\u7b97\u7b26\uff0c\u5728 WHERE
\u5b50\u53e5\u4e2d\u6307\u5b9a\u591a\u4e2a\u503cGROUP BY
\u8bed\u53e5\u4e2d\u652f\u6301 NULLABLE
\u5217Chaos
\u6d4b\u8bd5\u6846\u67b6pre-allocate-group-num
\u53c2\u6570\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u66f4\u5927\u7684\u503c\u3002\u5426\u5219\uff0c\u8fc7\u7a0b\u4e2d\u4f1a\u62a5\u9519 \"no available raft group\"\u3002 \u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 21 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 157 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
\u6211\u4eec\u671f\u5f85\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.3.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.2.0...v0.3.0
"},{"location":"MatrixOne/Release-Notes/v0.4.0/","title":"MatrixOne v0.4.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.4.0 \u7248\u672c\u4e8e 2022 \u5e74 5 \u6708 5 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u4ee5\u4e0b\u6211\u4eec\u5bf9\u7248\u672c\u6700\u65b0\u7684\u66f4\u65b0\u5185\u5bb9\u8fdb\u884c\u7b80\u8981\u8bf4\u660e\u3002
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne0.4.0 \u7248\u672c\u3002
docker pull matrixorigin/matrixone:0.4.0\n
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"pre-allocate-group-num
\u53c2\u6570\u5e94\u8be5\u8bbe\u7f6e\u4e3a\u66f4\u5927\u7684\u503c\u3002\u5426\u5219\uff0c\u5efa\u8868\u8fc7\u7a0b\u4e2d\u4f1a\u62a5\u9519 \"no available raft group\"\u3002 \u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 50 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 253 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.4.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.2.0...v0.3.0
"},{"location":"MatrixOne/Release-Notes/v0.5.0/","title":"MatrixOne v0.5.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.5.0 \u7248\u672c\u4e8e 2022 \u5e74 7 \u6708 18 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u62e5\u6709\u4e00\u4e2a\u72ec\u7acb\u7684\u5217\u5f0f\u5b58\u50a8\u5f15\u64ce\uff0c\u53ef\u4ee5\u652f\u6301 HTAP \u5de5\u4f5c\u8d1f\u8f7d\u3002\u5e72\u676f\uff01
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#docker","title":"Docker","text":"\u53ef\u4ee5\u4f7f\u7528 docker \u62c9\u53d6 MatrixOne 0.5.0 \u7248\u672c\u3002
docker pull matrixorigin/matrixone:0.5.0\n
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"UPDATE
\uff0cDELETE
\u548c INSERT INTO ... SELECT ...
\u8bed\u6cd5\u3002 \u2014 \u652f\u6301 BOOL
\u548c Timestamp
\u6570\u636e\u7c7b\u578b\u3002LEFT/RIGHT/OUTER/NATURAL JOIN
Having
\u8868\u8fbe\u3002CASE ... WHEN
\u8868\u8fbe\u5f0f\u3002Interva
\u8868\u8fbe\u5f0f\u3002Explain
\u8ba1\u5212\u6811\u3002Any_value
\u3002\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 73 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 811 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.5.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.0
"},{"location":"MatrixOne/Release-Notes/v0.5.1/","title":"MatrixOne v0.5.1 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.5.1 \u7248\u672c\u4e8e 2022 \u5e74 8 \u6708 19 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u89e3\u51b3\u4e86\u4e00\u4e9b\u65e5\u5fd7\u56de\u653e\u548c\u5b58\u50a8\u5783\u573e\u6536\u96c6\uff08GC\uff0cGarbage Collection\uff09\u95ee\u9898\u3002
"},{"location":"MatrixOne/Release-Notes/v0.5.1/#_1","title":"\u529f\u80fd\u4f18\u5316","text":"\u4fee\u590d\u8fd9\u4e9b\u9519\u8bef\u540e\uff0cMatrixOne \u5b9e\u4f8b\u7a33\u5b9a\u6027\u5f97\u4ee5\u63d0\u5347\u3002
"},{"location":"MatrixOne/Release-Notes/v0.5.1/#_2","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.4.0...v0.5.1
"},{"location":"MatrixOne/Release-Notes/v0.6.0/","title":"MatrixOne v0.6.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.6.0 \u7248\u672c\u4e8e 2022 \u5e74 11 \u6708 29 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u5df2\u5347\u7ea7\u4e3a\u5b58\u7b97\u5206\u79bb\u3001\u8bfb\u5199\u5206\u79bb\u3001\u51b7\u70ed\u5206\u79bb\u3001\u4e8b\u52a1\u548c\u5206\u6790\u80fd\u529b\u5206\u79bb\u3001\u5e76\u62e5\u6709\u6781\u81f4\u6269\u5c55\u80fd\u529b\u548c\u5b8c\u6574\u529f\u80fd\u7684\u4e91\u539f\u751f HTAP \u6570\u636e\u5e93\u3002\u5e72\u676f\uff01
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#docker","title":"Docker","text":"docker pull matrixorigin/matrixone:0.6.0\n
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"TEXT
\u3001BLOB
\u3001TIME
\u3001JSON
\u6570\u636e\u7c7b\u578b\u3002CREATE/GRANT/SET ROLE/REVOKE
\u7b49\u64cd\u4f5c\u3002VIEW
\u3002CSV
\u548c JSON
\u6570\u636e\u3002mo-dump
\u3002system_metrics
\u6570\u636e\u5e93\u4ee5\u76d1\u63a7\u5b9e\u4f8b\u72b6\u6001\u3002system
\u6570\u636e\u5e93\uff0c\u7528\u4e8e\u8bb0\u5f55\u7528\u6237\u8bed\u53e5\u548c\u7cfb\u7edf\u65e5\u5fd7\u3002timezone
\u7684\u652f\u6301\u3002PREPARE
\u3001EXECUTE
\u3001DEALLOCATE
\u3002Explain Analyze
\u8be6\u7ec6\u67e5\u8be2\u8ba1\u5212\u5206\u6790\u3002UNION
\u3001UNION ALL
\u3001INTERSECT
\u3001MINUS
\u8fd0\u7b97\u7b26\u3002CREATE TEMPORARY TABLE
\u4e34\u65f6\u8868\u3002CREATE EXTERNAL TABLE
\u5916\u90e8\u8868\u3002Partition by
\u80fd\u529b\u3002JSON
\u4ee5\u53ca\u5927\u91cf Datetime
\u7c7b\u578b\u51fd\u6570\u3002UUID
\u51fd\u6570\u3002&, |, ^, ~, <<, >>
\u3002DDL
\u4e2d\u5e26 comment
\u529f\u80fd\u3002SET
\u81ea\u5b9a\u4e49\u53d8\u91cf\u529f\u80fd\u3002BLOB
\u4e2d\u4f1a\u51fa\u73b0\u5931\u8d25\u3002#6302\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 97 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 1520 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.6.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.5.1...v0.6.0
"},{"location":"MatrixOne/Release-Notes/v0.7.0/","title":"MatrixOne v0.7.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.7.0 \u7248\u672c\u4e8e 2023 \u5e74 2 \u6708 23 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01\u5728\u8fd9\u4e2a\u7248\u672c\u4e2d\uff0cMatrixOne \u5728\u4e91\u539f\u751f\u67b6\u6784\u548c\u5b8c\u6574\u6570\u636e\u5e93\u529f\u80fd\u5f62\u6001\u4e0b\uff0c\u7248\u672c 0.7.0 \u8fdb\u884c\u4e86\u7a33\u5b9a\u6027\u548c\u6027\u80fd\u7684\u4e13\u9879\u4f18\u5316\uff1a
Cluster by
\u5b57\u6bb5\uff0c\u53ef\u4ee5\u9884\u5148\u5c06\u6570\u636e\u505a\u597d\u6392\u5e03\uff0c\u4ee5\u65b9\u4fbf\u66f4\u5feb\u7684\u83b7\u53d6\u3002\u53e6\u5916\u4e5f\u4f18\u5316\u4e86 IN
\u64cd\u4f5c\u7b26\u3001\u7c7b\u578b\u8f6c\u6362\u3001\u8c13\u8bcd\u8fc7\u6ee4\u7b49\u4f17\u591a\u6027\u80fd\u5361\u70b9\u3002\u5728\u5199\u7684\u65b9\u9762\uff0c\u8fd9\u4e2a\u8fed\u4ee3\u5b9e\u73b0\u4e86\u76f4\u63a5\u901a\u8fc7 CN
\u8282\u70b9\u5927\u6279\u91cf\u5e76\u884c\u5199\u5165\u5171\u4eab\u5b58\u50a8\uff0c\u4ece\u800c\u83b7\u5f97\u4e86\u52a0\u8f7d\u6027\u80fd\u7684\u5927\u5e45\u63d0\u5347\u3002docker pull matrixorigin/matrixone:0.7.0\n
"},{"location":"MatrixOne/Release-Notes/v0.7.0/#_1","title":"\u6700\u65b0\u7279\u6027","text":"Foreign Key
\u3002Cluster by
\u5b57\u6bb5\u3002MYSQL_COMPATBILITY_MODE
\u53c2\u6570\u7ba1\u7406\u90e8\u5206 MySQL \u4e13\u5c5e\u517c\u5bb9\u884c\u4e3a\u3002REPEATABLE_READ
\u5b9e\u73b0\u66f4\u4f18\u7684 MySQL \u517c\u5bb9\u3002Unique Index
\u5b9e\u73b0\u5b8c\u6574\u552f\u4e00\u7ea6\u675f\u3002Alter View
\u3002group_concat
\u3002format
, replace
, curdate
, field
, substring_index
\u7b49\u7cfb\u7edf\u51fd\u6570\u3002\u622a\u6b62\u672c\u6b21\u53d1\u5e03\uff0c\u5171\u6709 43 \u4f4d\u8d21\u732e\u8005\u4e3a MatrixOne \u7684\u5f00\u53d1\u4f5c\u51fa\u8d21\u732e\uff0c\u5171\u4ea7\u751f\u4e86 656 \u6b21\u63d0\u4ea4\u8bb0\u5f55\u3002
"},{"location":"MatrixOne/Release-Notes/v0.7.0/#_4","title":"\u6b22\u8fce\u65b0\u52a0\u5165\u7684\u8d21\u732e\u8005","text":"\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.7.0/#_5","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.6.0...v0.7.0
"},{"location":"MatrixOne/Release-Notes/v0.8.0/","title":"MatrixOne v0.8.0 \u53d1\u5e03\u62a5\u544a","text":"\u70ed\u70c8\u795d\u8d3a MatrixOne \u7684 v0.8.0 \u7248\u672c\u4e8e 2023 \u5e74 6 \u6708 30 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
\u5728\u5386\u7ecf\u56db\u4e2a\u6708\u7684\u6df1\u5ea6\u7814\u53d1\u4e4b\u540e\uff0cMatrixOne \u5728\u6027\u80fd\u3001\u6269\u5c55\u6027\u548c\u53ef\u7528\u6027\u65b9\u9762\u5b9e\u73b0\u4e86\u663e\u8457\u63d0\u5347\u3002\u6b64\u6b21\u66f4\u65b0\u7684\u4eae\u70b9\u5728\u4e8e Proxy \u6a21\u5757\u7684\u5f15\u5165\uff0c\u5b83\u4f7f\u5f97 MatrixOne \u80fd\u591f\u51c6\u786e\u5730\u5c06\u5404\u7c7b SQL \u8bf7\u6c42\u548c\u8d1f\u8f7d\u7c7b\u578b\u4e0e\u76f8\u5e94\u7684 CN \u7ec4\u8fdb\u884c\u5173\u8054\uff0c\u4ece\u800c\u5728\u79df\u6237\u9694\u79bb\u3001\u8bfb\u5199\u5206\u79bb\u3001\u4e8b\u52a1\u5904\u7406\uff08TP\uff09/\u5206\u6790\u5904\u7406\uff08AP\uff09\u8d1f\u8f7d\u5206\u79bb\u7b49\u5173\u952e\u529f\u80fd\u4e0a\u53d6\u5f97\u4e86\u663e\u8457\u63d0\u5347\u3002\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u8fd9\u6b21\u53d1\u5e03\u7684 0.8.0 \u7248\u672c\u662f MatrixOne \u5728\u5168\u9762\u516c\u5f00\u53d1\u5e03\u524d\u7684\u6700\u540e\u4e00\u4e2a\u7248\u672c\uff0c\u540c\u65f6\u4e5f\u4f5c\u4e3a MatrixOne \u4ea7\u54c1\u7684\u516c\u6d4b Beta \u7248\uff0c\u6211\u4eec\u8bda\u631a\u9080\u8bf7\u5404\u4f4d\u7528\u6237\u548c\u5f00\u53d1\u8005\u4e0b\u8f7d\u8bd5\u7528\uff0c\u671f\u5f85\u4f60\u4eec\u7684\u53cd\u9988\u548c\u5efa\u8bae\u3002\u4e3a\u4e86\u8fd9\u4e00\u91cc\u7a0b\u7891\u5f0f\u7684\u8fdb\u6b65\uff0c\u8ba9\u6211\u4eec\u5171\u540c\u4e3e\u676f\u5e86\u795d\uff01
"},{"location":"MatrixOne/Release-Notes/v0.8.0/#docker","title":"Docker","text":"docker pull matrixorigin/matrixone:0.8.0\n
docker pull registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:0.8.0\n
"},{"location":"MatrixOne/Release-Notes/v0.8.0/#_1","title":"\u91cd\u70b9\u5173\u6ce8","text":""},{"location":"MatrixOne/Release-Notes/v0.8.0/#_2","title":"\u6027\u80fd\u63d0\u5347","text":"mo_ctl
\uff0c\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u68c0\u67e5\u57fa\u7840\u786c\u4ef6\u73af\u5883\uff0c\u521d\u59cb\u5316\u914d\u7f6e\u53ca\u4e00\u952e\u5b89\u88c5\u90e8\u7f72\u3002\u4e0d\u8bba\u662f\u5355\u673a\u7248\u672c\u8fd8\u662f\u5206\u5e03\u5f0f\u7248\u672c\u7528\u6237\u90fd\u4e0d\u518d\u9700\u8981\u901a\u8fc7\u590d\u6742\u7684 Linux \u53ca K8s \u539f\u751f\u547d\u4ee4\u6765\u8fdb\u884c\u90e8\u7f72\u53ca\u8fd0\u7ef4\u3002information_schema
\u5e93\u7684\u8868\u7ed3\u6784\uff0c\u5927\u5927\u964d\u4f4e\u4e86\u4ece MySQL \u8fdb\u884c\u8fc1\u79fb\u7684\u9002\u914d\u5de5\u4f5c\u91cf\u3002Select for update
\u547d\u4ee4\u7684\u652f\u6301\u3002RANK()
\uff0cROW_NUMBER()
\u548c DENSE_RANK()
\u3002BINARY
\u7c7b\u578b\u548c\u76f8\u5173\u51fd\u6570\u3002PUBLISH
/SUBSCRIBE
\u51fd\u6570\u3002INSERT...ON DUPLICATE KEY UPDATE
\u8bed\u53e5\u3002Sequence
\u3002ALTER TABLE
\u3002RAND()
\u51fd\u6570\u3002Partition By
\u5206\u533a\u8868\u529f\u80fd\u3002\u6211\u4eec\u611f\u8c22\u60a8\u7684\u8d21\u732e\uff0c\u6b22\u8fce\u6765\u5230 MatrixOne \u793e\u533a\uff01
"},{"location":"MatrixOne/Release-Notes/v0.8.0/#_8","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v0.7.0...v0.8.0
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/","title":"MatrixOne v1.0.0-RC1 \u53d1\u5e03\u62a5\u544a","text":"\u6211\u4eec\u975e\u5e38\u9ad8\u5174\u5730\u5ba3\u5e03 MatrixOne \u5185\u6838 v1.0.0-RC1 \u7248\u672c\u4e8e 2023 \u5e74 8 \u6708 24 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
\u8fd9\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u91cc\u7a0b\u7891\uff0c\u6807\u5fd7\u7740 MatrixOne \u5df2\u7ecf\u57fa\u672c\u5b9e\u73b0\u4e00\u4e2a\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\u7684\u4e3b\u8981\u529f\u80fd\u3002MatrixOne \u5185\u6838 1.0 GA \u53ca MatrixOne Cloud \u6b63\u5f0f\u7248\u4e5f\u5c06\u5728\u8fd1\u671f\u53d1\u5e03\uff0c\u656c\u8bf7\u5173\u6ce8\uff01
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#matrixone-100-rc1","title":"MatrixOne 1.0.0-RC1 \u529f\u80fd\u6982\u89c8","text":"MatrixOne \u7684\u8bbe\u8ba1\u548c\u5f00\u53d1\u59cb\u7ec8\u805a\u7126\u5728\u8d44\u6e90\u5229\u7528\u6700\u5927\u5316\u548c\u8d85\u9ad8\u6027\u4ef7\u6bd4\u3001\u7b80\u5316\u6570\u636e\u5904\u7406\u67b6\u6784\u3001\u964d\u4f4e\u7528\u6237\u6570\u636e\u5904\u7406\u96be\u5ea6\u7b49\u51e0\u4e2a\u65b9\u9762\u3002MatrixOne 1.0.0-RC1 \u7684\u529f\u80fd\u4e0e\u6027\u80fd\u5df2\u7ecf\u57fa\u672c\u4e0a\u8fbe\u6210\u4e86\u67b6\u6784\u8bbe\u8ba1\u76ee\u6807\uff0c\u5b8c\u6574\u7684\u5b9e\u73b0\u4e86\u4e91\u539f\u751f\u53ca\u5b58\u7b97\u5206\u79bb\u3001\u51b7\u70ed\u5206\u79bb\u548c\u7ec6\u6570\u636e\u9897\u7c92\u5ea6\u7684\u8bfb\u5199\u5206\u79bb\u67b6\u6784\uff0c\u5177\u5907\u4e86\u4e00\u6b3e SQL \u6570\u636e\u5e93\u4ea7\u54c1\u7684\u4e3b\u8981\u529f\u80fd\uff0c\u4e14\u5728 OLTP\uff0cOLAP\uff0c\u65f6\u5e8f\u51e0\u4e2a\u4e0d\u540c\u8d1f\u8f7d\u4e0b\u7684\u6027\u80fd\u5747\u8868\u73b0\u826f\u597d\uff0c\u4e5f\u5df2\u7ecf\u63d0\u4f9b\u4e86\u6700\u57fa\u7840\u6d41\u8ba1\u7b97\u80fd\u529b\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#sql","title":"SQL \u80fd\u529b","text":"MatrixOne \u4ea7\u54c1\u9002\u7528\u4e8e\u4ee5\u4e0b\u51e0\u4e2a\u5e94\u7528\u573a\u666f\u3002\u6211\u4eec\u975e\u5e38\u6b22\u8fce\u6709\u4ee5\u4e0b\u4e1a\u52a1\u75db\u70b9\u53ca\u9700\u6c42\u7684\u7528\u6237\u4e0e\u6211\u4eec\u8054\u7cfb\u8fdb\u884c\u8bd5\u7528\u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#htap","title":"\u8f7b\u91cf\u7ea7 HTAP \u573a\u666f","text":"\u4f01\u4e1a\u5e38\u7528\u7684\u4e1a\u52a1\u7cfb\u7edf\uff0c\u5982 OA\uff0cERP\uff0cCRM \u7b49\u7cfb\u7edf\u968f\u7740\u4e1a\u52a1\u7684\u53d1\u5c55\u6570\u636e\u91cf\u589e\u5927\uff0c\u4f20\u7edf\u7684\u5355\u673a\u6570\u636e\u5e93\u65e0\u6cd5\u6ee1\u8db3\u5176\u6027\u80fd\u9700\u6c42\uff0c\u5c24\u5176\u5728\u7279\u6b8a\u65f6\u95f4\u70b9\u7684\u4e1a\u52a1\u5206\u6790\u9700\u6c42\uff0c\u5f88\u591a\u4f01\u4e1a\u4f1a\u4e13\u95e8\u914d\u5907\u4e00\u5957\u5206\u6790\u6570\u636e\u5e93\u7cfb\u7edf\u6765\u6ee1\u8db3\u6708\u672b\uff0c\u5b63\u672b\u7b49\u91cd\u8981\u8282\u70b9\u7684\u7edf\u8ba1\u62a5\u8868\u9700\u6c42\uff0c\u6216\u8005\u91c7\u7528\u5206\u5e93\u5206\u8868\u7b49\u5f62\u5f0f\u6765\u964d\u4f4e\u67e5\u8be2\u8d1f\u8f7d\u3002\u8fd9\u79cd\u573a\u666f\u91c7\u7528 MatrixOne \u6570\u636e\u5e93\u53ef\u4ee5\u7528\u4e00\u5957\u6570\u636e\u5e93\u540c\u65f6\u6ee1\u8db3\u4e1a\u52a1\u7cfb\u7edf\u548c\u5206\u6790\u7cfb\u7edf\u7684\u9700\u6c42\uff0c\u540c\u65f6\u5177\u5907\u5f3a\u5927\u7684\u6269\u5c55\u6027\uff0c\u968f\u7740\u4e1a\u52a1\u589e\u957f\u53ef\u4ee5\u65e0\u7f1d\u6269\u5bb9\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_7","title":"\u5b9e\u65f6\u5206\u6790\u573a\u666f","text":"\u9488\u5bf9\u4f01\u4e1a\u5178\u578b\u7684 OLAP \u7c7b\u578b\u5e94\u7528\uff0c\u5982\u770b\u677f\u3001BI \u62a5\u8868\u7b49\u5206\u6790\u7cfb\u7edf\uff0c\u5f80\u5f80\u9700\u8981\u8fdb\u884c\u6d77\u91cf\u6570\u636e\u7684\u5206\u6790\uff0c\u6570\u636e\u91cf\u4e00\u65e6\u8f83\u4e3a\u5e9e\u5927\u5219\u4f1a\u9762\u4e34\u6027\u80fd\u74f6\u9888\uff0c\u5bfc\u81f4\u65f6\u6548\u6027\u8f83\u5dee\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u5206\u6790\u6027\u80fd\u548c\u53ef\u6269\u5c55\u80fd\u529b\uff0c\u53ef\u4ee5\u9488\u5bf9\u5404\u7c7b\u590d\u6742\u548c\u6570\u636e\u91cf\u5e9e\u5927\u7684 SQL \u67e5\u8be2\u8fdb\u884c\u52a0\u901f\uff0c\u83b7\u5f97\u79d2\u7ea7\u4f53\u9a8c\u7684\u6548\u679c\uff0c\u63d0\u9ad8\u4f01\u4e1a\u51b3\u7b56\u5206\u6790\u7684\u654f\u6377\u5ea6\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_8","title":"\u65f6\u5e8f\u6570\u636e\u573a\u666f","text":"\u968f\u7740\u4f20\u611f\u5668\u548c\u7f51\u7edc\u6280\u672f\u7684\u5927\u91cf\u5e94\u7528\uff0c\u6d77\u91cf\u7684\u5404\u7c7b IoT \u8bbe\u5907\u751f\u4ea7\u4e86\u5927\u91cf\u7684\u6570\u636e\uff0c\u6bd4\u5982\u5236\u9020\u4e1a\u5de5\u5382\u4ea7\u7ebf\uff0c\u65b0\u80fd\u6e90\u6c7d\u8f66\uff0c\u57ce\u5e02\u5b89\u9632\u76d1\u63a7\u6444\u50cf\u5934\u7b49\u7b49\uff0c\u5176\u89c4\u6a21\u53ef\u80fd\u8f7b\u6613\u80fd\u8fbe\u5230\u6570\u767e TB \u751a\u81f3 PB \u7ea7\u522b\uff0c\u800c\u5bf9\u6570\u5b57\u5316\u7684\u9700\u6c42\u4e5f\u8d8a\u6765\u8d8a\u591a\u7684\u8981\u6c42\u4f01\u4e1a\u5b58\u50a8\u548c\u5229\u7528\u8fd9\u4e9b\u6570\u636e\u3002\u4f46\u662f\u4f20\u7edf\u7684\u6570\u636e\u5e93\u65b9\u6848\u65e0\u6cd5\u6ee1\u8db3\u5982\u6b64\u6d77\u91cf\u4e14\u5927\u89c4\u6a21\u7684\u5b9e\u65f6\u6570\u636e\u5199\u5165\uff0c\u4ee5\u53ca\u52a0\u5de5\u5e94\u7528\u7684\u573a\u666f\u3002MatrixOne \u5177\u5907\u5f3a\u5927\u7684\u6d41\u5f0f\u6570\u636e\u5199\u5165\u548c\u52a0\u5de5\u7684\u80fd\u529b\uff0c\u540c\u65f6\u5f3a\u5927\u7684\u53ef\u6269\u5c55\u6027\u53ef\u4ee5\u9002\u5e94\u4efb\u610f\u89c4\u6a21\u7684\u8d1f\u8f7d\u548c\u6570\u636e\u91cf\uff0c\u53ef\u4ee5\u5b8c\u5168\u6ee1\u8db3\u8be5\u573a\u666f\u7684\u9700\u6c42\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_9","title":"\u8d1f\u8f7d\u6ce2\u52a8\u8f83\u591a\u7684\u521b\u65b0\u4e1a\u52a1\u573a\u666f","text":"\u5bf9\u4e8e\u6e38\u620f\uff0c\u7535\u5546\uff0c\u6587\u5a31\uff0c\u793e\u4ea4\uff0c\u65b0\u95fb\u7b49\u4e92\u8054\u7c7b\u5e94\u7528\u6765\u8bf4\uff0c\u7528\u6237\u6570\u91cf\u5e9e\u5927\u4e14\u4e1a\u52a1\u6ce2\u52a8\u5267\u70c8\u800c\u9891\u7e41\uff0c\u5728\u70ed\u95e8\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u5019\uff0c\u5f80\u5f80\u9700\u8981\u5927\u91cf\u7684\u8ba1\u7b97\u8d44\u6e90\u6765\u652f\u6491\u4e1a\u52a1\u9700\u6c42\u3002MatrixOne \u5b8c\u5168\u4e91\u539f\u751f\u5316\u7684\u67b6\u6784\u5177\u5907\u8d85\u5f3a\u7684\u6269\u5c55\u6027\uff0c\u53ef\u4ee5\u8ddf\u968f\u4e1a\u52a1\u7684\u53d8\u5316\u81ea\u52a8\u7684\u5feb\u901f\u6269\u7f29\u5bb9\uff0c\u6781\u5927\u7684\u964d\u4f4e\u7528\u6237\u7684\u8fd0\u7ef4\u96be\u5ea6\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#saas","title":"\u4f01\u4e1a\u7ea7 SaaS \u573a\u666f","text":"\u4f01\u4e1a\u7ea7 SaaS \u5e94\u7528\u5728\u8fd1\u51e0\u5e74\u6210\u7206\u53d1\u5f0f\u7684\u589e\u957f\u8d8b\u52bf\uff0cSaaS \u7684\u5e94\u7528\u5f00\u53d1\u4e2d\u90fd\u9700\u8981\u8003\u8651\u81ea\u5df1\u7684\u591a\u79df\u6237\u6a21\u578b\uff0c\u4f20\u7edf\u7684\u65b9\u6848\u4e2d\u4f1a\u6709\u591a\u79df\u6237\u5171\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u548c\u5355\u79df\u6237\u72ec\u4eab\u6570\u636e\u5e93\u5b9e\u4f8b\u4e24\u79cd\u6a21\u5f0f\uff0c\u4f46\u662f\u4f1a\u9762\u4e34\u7ba1\u7406\u6210\u672c\u548c\u9694\u79bb\u6027\u7684\u4e24\u96be\u9009\u62e9\u3002MatrixOne \u81ea\u5e26\u591a\u79df\u6237\u80fd\u529b\uff0c\u79df\u6237\u4e4b\u95f4\u5929\u7136\u8d1f\u8f7d\u9694\u79bb\u4e14\u53ef\u4ee5\u72ec\u7acb\u6269\u5c55\uff0c\u540c\u65f6\u53c8\u63d0\u4f9b\u4e86\u7edf\u4e00\u7ba1\u7406\u80fd\u529b\uff0c\u53ef\u4ee5\u517c\u987e\u4f01\u4e1a\u5bf9\u6210\u672c\uff0c\u7ba1\u7406\u7b80\u6613\u5ea6\u548c\u9694\u79bb\u6027\u7684\u9700\u6c42\uff0c\u662f SaaS \u5e94\u7528\u7684\u6700\u4f73\u9009\u62e9\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_10","title":"\u5feb\u901f\u8bd5\u7528","text":"\u793e\u533a\u7528\u6237\u53ca\u4f01\u4e1a\u5f00\u53d1\u8005\u90fd\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u4e00\u952e\u90e8\u7f72 MatrixOne \u8fdb\u884c\u8bd5\u7528\u3002
docker pull matrixorigin/matrixone:1.0.0-rc1\n
\u672c\u6587\u6863\u7f51\u7ad9\u4e5f\u63d0\u4f9b\u8be6\u7ec6\u7684\u67b6\u6784\u8bf4\u660e\u3001\u5b89\u88c5\u6307\u5357\u548c\u5f00\u53d1\u6559\u7a0b\uff0c\u5e2e\u52a9\u60a8\u63a2\u7d22 MatrixOne \u7684\u80fd\u529b\u3002
\u6b64\u5916\uff0c\u6211\u4eec\u7684 GitHub \u7f51\u7ad9\u548c\u793e\u533a\u5fae\u4fe1\u7fa4\u6b22\u8fce\u60a8\u63d0\u95ee\u3001\u8ba8\u8bba\u6216\u53cd\u9988\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#080-100","title":"0.8.0 \u5230 1.0.0 \u7684\u8fed\u4ee3\u66f4\u65b0","text":"\u5728\u8fd9\u4e24\u4e2a\u6708\u7684\u7248\u672c\u8fed\u4ee3\u4e2d\uff0c\u6211\u4eec\u4e5f\u7740\u91cd\u4f18\u5316\u4e86\u6211\u4eec\u9762\u5411\u751f\u4ea7\u73af\u5883\u7684\u4e00\u4e9b\u529f\u80fd\u53ca\u53ef\u7528\u6027\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_11","title":"\u91cd\u70b9\u65b0\u529f\u80fd","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_12","title":"\u7269\u7406\u5907\u4efd\uff08\u4f01\u4e1a\u7248\uff09","text":"\u8fd9\u4e2a\u7248\u672c\u6211\u4eec\u5f15\u5165\u4e86\u7269\u7406\u5907\u4efd\u529f\u80fd\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u65b9\u4fbf\u5730\u5907\u4efd\u548c\u8fd8\u539f\u6570\u636e\u5e93\u3002\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u521b\u5efa\u6570\u636e\u5e93\u7684\u5feb\u7167\uff0c\u5e76\u5728\u9700\u8981\u65f6\u6062\u590d\u5230\u5148\u524d\u7684\u72b6\u6001\uff0c\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u53ef\u9760\u6027\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_13","title":"\u6d41\u8ba1\u7b97","text":"\u4f5c\u4e3a HSTAP \u67b6\u6784\u7684\u6700\u540e\u4e00\u5757\u62fc\u56fe\uff0c\u6211\u4eec\u5b8c\u6210\u4e86\u6d41\u8ba1\u7b97\u7684\u6846\u67b6\u8bbe\u8ba1\uff0c\u5e76\u5728\u8fd9\u4e2a\u8fed\u4ee3\u589e\u52a0\u4e86\u521b\u5efa\u6d41\u5f0f\u8868\u7684\u76f8\u5173\u80fd\u529b\uff0c\u540c\u65f6\u5b9e\u73b0\u4e86\u4e00\u4e2a Kafka \u7684\u8fde\u63a5\u5668\uff0c\u7528\u4e8e\u6ee1\u8db3\u5927\u91cf\u65f6\u5e8f\u573a\u666f\u7684\u6d41\u5f0f\u6570\u636e\u63a5\u5165\u9700\u6c42\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#cte","title":"\u9012\u5f52 CTE","text":"\u9012\u5f52 CTE \u662f\u4e00\u4e2a\u91cd\u590d\u6267\u884c\u521d\u59cb CTE \u4ee5\u8fd4\u56de\u6570\u636e\u5b50\u96c6\u76f4\u5230\u83b7\u53d6\u5b8c\u6574\u7ed3\u679c\u96c6\u7684\u516c\u7528\u8868\u8868\u8fbe\u5f0f\u3002\u672c\u8fed\u4ee3\u7684\u5b9e\u73b0\u5c06\u4f7f\u5f97\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u5904\u7406\u5177\u6709\u5c42\u6b21\u7ed3\u6784\u7684\u6570\u636e\uff0c\u80fd\u591f\u4f7f\u7528\u9012\u5f52\u67e5\u8be2\u6784\u5efa\u66f4\u590d\u6742\u548c\u7075\u6d3b\u7684\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_14","title":"\u53ef\u7528\u6027\u63d0\u5347","text":""},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mysql","title":"MySQL \u5efa\u8868\u8bed\u53e5\u517c\u5bb9","text":"\u6211\u4eec\u8fdb\u4e00\u6b65\u6539\u8fdb\u4e86 MatrixOne \u5bf9 MySQL \u7684\u517c\u5bb9\u6027\uff0c\u4f7f\u5176\u80fd\u591f\u66f4\u597d\u5730\u652f\u6301 MySQL \u5efa\u8868\u8bed\u53e5\u3002\u73b0\u5728\u7528\u6237\u53ef\u4ee5\u65e0\u7f1d\u8fc1\u79fb\u73b0\u6709\u7684 MySQL \u5e94\u7528\u7a0b\u5e8f\u5230 MatrixOne \u4e2d\uff0c\u800c\u65e0\u9700\u4fee\u6539\u73b0\u6709\u7684\u5efa\u8868\u8bed\u53e5\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_15","title":"\u6269\u7f29\u5bb9\u4f1a\u8bdd\u8fc1\u79fb","text":"\u6211\u4eec\u589e\u52a0\u4e86\u6269\u7f29\u5bb9\u4f1a\u8bdd\u8fc1\u79fb\u7684\u80fd\u529b\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u5728\u5206\u5e03\u5f0f\u5b9e\u4f8b\u6269\u5bb9\u6216\u7f29\u5bb9\u65f6\u65e0\u7f1d\u8fc1\u79fb\u4f1a\u8bdd\u3002\u7528\u6237\u53ef\u4ee5\u5728\u4e0d\u5f71\u54cd\u73b0\u6709\u4f1a\u8bdd\u548c\u4e1a\u52a1\u7684\u60c5\u51b5\u4e0b\uff0c\u8f7b\u677e\u5730\u8c03\u6574 MatrixOne \u7684\u5bb9\u91cf\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_16","title":"\u7cfb\u7edf\u914d\u7f6e\u7b80\u5316","text":"\u6211\u4eec\u5927\u5e45\u7b80\u5316\u4e86\u5355\u673a\u4e0e\u5206\u5e03\u5f0f\u7248\u672c\u7684\u542f\u52a8\u914d\u7f6e\u9879\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u66f4\u5feb\u901f\u5730\u4e0a\u624b\u542f\u52a8\u6570\u636e\u5e93\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#mo_ctl","title":"mo_ctl \u5de5\u5177\u4f18\u5316","text":"\u6211\u4eec\u9488\u5bf9\u5355\u673a\u4e0e\u5206\u5e03\u5f0f\u7684 mo_ctl \u8fd0\u7ef4\u5de5\u5177\u8fdb\u884c\u4e86\u529f\u80fd\u4f18\u5316\uff0c\u63d0\u4f9b\u4e86\u66f4\u5f3a\u5927\u548c\u6613\u7528\u7684\u8fd0\u7ef4\u529f\u80fd\u3002\u73b0\u5728\u60a8\u53ef\u4ee5\u901a\u8fc7\u5206\u5e03\u5f0f mo_ctl \u5de5\u5177\uff08\u4f01\u4e1a\u7248\uff09\u8f7b\u677e\u5b9e\u73b0\u90e8\u7f72\uff0c\u5347\u7ea7\uff0c\u6269\u7f29\u5bb9\u7b49\u8fd0\u7ef4\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc1/#_17","title":"\u5176\u4ed6\u65b0\u529f\u80fd","text":"Replace
\u8bed\u53e5Alter Table
\u5b8c\u5584\u4e86\u4fee\u6539\u5217\u5c5e\u6027\u76f8\u5173\u80fd\u529bCreate Stage
\u8bed\u53e5\uff0c\u7b80\u5316\u5bfc\u5165\u5bfc\u51fa\u7684\u6d41\u7a0bShow Processlist
\u8bed\u53e5\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u72b6\u6001enum
\u7c7b\u578bYear
\u7c7b\u578bTo_Days
/To_Seconds
\u7cfb\u7edf\u51fd\u6570Group by
\u884c\u4e3a\uff0c\u53ef\u4ee5\u652f\u6301\u522b\u540dhttps://github.com/matrixorigin/matrixone/compare/v0.8.0...v1.0.0-rc1
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc2/","title":"MatrixOne v1.0.0-RC2 \u53d1\u5e03\u62a5\u544a","text":"\u4e0e\u4e4b\u524d\u7684 v1.0.0-RC1 \u76f8\u6bd4\uff0cv1.0.0-RC2 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0-rc2/#_1","title":"\u6027\u80fd\u63d0\u5347","text":"delete
\u64cd\u4f5c\u7684\u6027\u80fd\u548c\u7a33\u5b9a\u6027\uff1a#11541, #11542, #11882, #11969\u3002on duplicate key
\u7684\u529f\u80fd\uff1a#11632, #11760\u3002mo_ctl
\u7684\u80fd\u529b\uff1a#11680, #12247\u3002partition
\u76f8\u5173\u7684\u529f\u80fd\uff1a#11762\u3002runtime filter
#11868\u3002count/min/max
\u64cd\u4f5c\u8fdb\u884c\u4e86\u6027\u80fd\u4f18\u5316\uff1a#11959\u3002checkpoint
\u76f8\u5173\u7684\u9519\u8bef\uff1a#12014\uff0c#12124\uff0c#12172\u3002alter table/db
\u76f8\u5173\u7684\u9519\u8bef\uff1a#11429\uff0c#11484\uff0c#12162\u3002taskservice
\u76f8\u5173\u7684\u9519\u8bef\uff1a#11544\u3002show backend servers
\u663e\u793a\u9519\u8bef\u7ed3\u679c\u7684\u95ee\u9898 #11414\u3002insert
\u76f8\u5173\u7684 bug\uff1a#11495\u3002https://github.com/matrixorigin/matrixone/compare/v1.0.0-rc1...v1.0.0-rc2
"},{"location":"MatrixOne/Release-Notes/v1.0.0/","title":"MatrixOne v1.0.0 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2023 \u5e74 11 \u6708 13 \u65e5
MatrixOne \u7248\u672c\uff1av1.0.0
\u4e0e\u4e4b\u524d\u7684 v1.0.0-RC2 \u76f8\u6bd4\uff0cv1.0.0 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.0/#_1","title":"\u6539\u8fdb","text":"https://github.com/matrixorigin/matrixone/compare/v1.0.0-rc2...v1.0.0
"},{"location":"MatrixOne/Release-Notes/v1.0.1/","title":"MatrixOne v1.0.1 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2023 \u5e74 12 \u6708 16 \u65e5
MatrixOne \u7248\u672c\uff1av1.0.1
\u4e0e\u4e4b\u524d\u7684 v1.0.0 \u76f8\u6bd4\uff0cv1.0.1 \u4ec5\u5f15\u5165\u4e86\u5c11\u91cf\u7cfb\u7edf\u51fd\u6570\u529f\u80fd\uff0c\u5176\u4ed6\u5747\u4e3a\u7cfb\u7edf\u4f18\u5316\u548c Bug \u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.1/#_1","title":"\u6539\u8fdb","text":"Show processlist
\u7684 bug: #12834https://github.com/matrixorigin/matrixone/compare/v1.0.0...v1.0.1
"},{"location":"MatrixOne/Release-Notes/v1.0.2/","title":"MatrixOne v1.0.2 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2023 \u5e74 12 \u6708 23 \u65e5
MatrixOne \u7248\u672c\uff1av1.0.2
\u4e0e\u4e4b\u524d\u7684 v1.0.1 \u76f8\u6bd4\uff0cv1.0.2 \u4ec5\u5f15\u5165\u4e86\u5c11\u91cf\u7684\u7cfb\u7edf\u51fd\u6570\u548c\u6539\u8fdb\uff0c\u800c\u66f4\u4e13\u6ce8\u4e8e\u5bf9\u9519\u8bef\u7684\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.0.2/#_1","title":"\u6539\u8fdb","text":"https://github.com/matrixorigin/matrixone/compare/v1.0.1...v1.0.2
"},{"location":"MatrixOne/Release-Notes/v1.1.0/","title":"MatrixOne v1.1.0 \u53d1\u5e03\u62a5\u544a","text":"\u6211\u4eec\u975e\u5e38\u9ad8\u5174\u5730\u5ba3\u5e03 MatrixOne \u5185\u6838 v1.1.0 \u7248\u672c\u4e8e 2023 \u5e74 12 \u6708 29 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#matrixone","title":"MatrixOne \u662f\u4ec0\u4e48\uff1f","text":"MatrixOne \u662f\u4e00\u6b3e\u5206\u5e03\u5f0f\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0cMatrixOne \u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u4e91\u539f\u751f\u3001\u9ad8\u6027\u80fd\u3001\u9ad8\u5f39\u6027\u3001\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684 HSTAP \u6570\u636e\u5e93\uff0c\u8ba9\u7528\u6237\u9762\u5bf9\u4e8b\u52a1\u3001\u5206\u6790\u3001\u65f6\u5e8f\u3001\u6d41\u8ba1\u7b97\u7b49\u6df7\u5408\u8d1f\u8f7d\u65f6\uff0c\u901a\u8fc7 MatrixOne \u4e00\u7ad9\u5f0f\u7684\u5b8c\u6210\u6574\u4e2a\u6570\u636e\u5904\u7406\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_1","title":"\u91cd\u70b9\u5173\u6ce8","text":"MatrixOne \u5728\u672c\u8fed\u4ee3\u589e\u52a0\u4e86\u591a\u4e2a\u91cd\u8981\u529f\u80fd\uff0c\u5728\u6574\u4f53 HTAP \u7684\u57fa\u7840\u4e0a\u589e\u5f3a\u4e86\u5411\u91cf\uff0c\u6d41\u548c\u65f6\u5e8f\u65b9\u9762\u7684\u80fd\u529b\uff0c\u8fdb\u4e00\u6b65\u4e30\u5bcc\u4e86\u80fd\u529b\u8c61\u9650\u548c\u9002\u7528\u8303\u56f4\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_2","title":"\u5411\u91cf\u6570\u636e\u7c7b\u578b","text":"\u4f5c\u4e3a 2023 \u5e74 AI \u4e0e\u5927\u6a21\u578b\u70ed\u6f6e\u7684\u6570\u636e\u57fa\u5ea7\u80fd\u529b\uff0c\u5411\u91cf\u7c7b\u578b\u5df2\u7ecf\u6210\u4e3a\u901a\u7528\u6570\u636e\u5e93\u7684\u6807\u914d\u3002\u672c\u8fed\u4ee3 MatrixOne \u652f\u6301\u4e86 vecf32 \u53ca vecf64 \u7684\u5411\u91cf\u7c7b\u578b\uff0c\u5206\u522b\u5bf9\u5e94 float32 \u548c float64 \u6570\u636e\u7c7b\u578b\uff0c\u540c\u65f6\u652f\u6301\u4e86\u57fa\u672c\u7684\u7b97\u5b50\u548c\u64cd\u4f5c\u7b26\uff0c\u4ee5\u53ca\u5411\u91cf\u5e38\u89c1\u7684\u6c42\u548c\uff0cL1 \u8303\u6570\uff0cL2 \u8303\u6570\uff0c\u5185\u79ef\uff0c\u4f59\u5f26\u76f8\u4f3c\u5ea6\u7b49\u8ba1\u7b97\u51fd\u6570\u3002\u7528\u6237\u4f7f\u7528\u7684\u65f6\u5019\u914d\u5408 AI \u7b97\u6cd5\u6a21\u578b\u53ef\u4ee5\u5feb\u901f\u642d\u5efa\u4e00\u4e2a AI \u5e94\u7528\u3002\u6bd4\u5982\u57fa\u4e8e\u5927\u8bed\u8a00\u6a21\u578b LLM \u7684 RAG \u5e94\u7528\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u7528\u6237\u4ec5\u9700\u5c06\u81ea\u5df1\u7684\u77e5\u8bc6\u5e93\u8c03\u7528 OpenAI \u7684 Embedding \u63a5\u53e3\u751f\u6210\u5411\u91cf\u6570\u636e\u5b58\u5165 MatrixOne \u4e2d\uff0c\u518d\u901a\u8fc7\u4f59\u5f26\u76f8\u4f3c\u5ea6\u51fd\u6570\u8ba1\u7b97\u641c\u7d22\u6700\u76f8\u4f3c\u7b54\u6848\uff0c\u518d\u5c06\u7b54\u6848\u901a\u8fc7 OpenAI \u7684 Prompt \u63a5\u53e3\u4ea4\u7ed9 LLM \u4f18\u5316\u56de\u7b54\u5373\u53ef\u3002
\u4e0e\u4e13\u7528\u7684\u5411\u91cf\u6570\u636e\u5e93\u4e0d\u540c\u7684\u662f\uff0cMatrixOne \u662f\u4e00\u4e2a\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684\u901a\u7528\u6570\u636e\u5e93\uff0c\u7528\u6237\u51e0\u4e4e\u4e0d\u9700\u8981\u989d\u5916\u7684\u5b66\u4e60\u95e8\u69db\u5373\u53ef\u5feb\u901f\u4e0a\u624b\uff0c\u540c\u65f6\u5728\u6784\u5efa AI \u5e94\u7528\u7684\u65f6\u5019\u4e5f\u53ef\u4ee5\u5c06\u7ed3\u6784\u5316\u6570\u636e\u4e0e\u5411\u91cf\u6570\u636e\u7684\u5904\u7406\u5408\u4e8c\u4e3a\u4e00\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_3","title":"\u65f6\u5e8f\u80fd\u529b","text":"\u4e3a\u4e86\u66f4\u597d\u7684\u5904\u7406\u6570\u636e\u5feb\u901f\u6d41\u5165\u7684\u5404\u7c7b IoT \u573a\u666f\uff0c\u672c\u8fed\u4ee3 MatrixOne \u5728\u65f6\u5e8f\u65b9\u6848\u7684\u80fd\u529b\u4e5f\u5927\u5e45\u52a0\u5f3a\uff0c\u5177\u4f53\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u70b9\uff1a
\u672c\u8fed\u4ee3\u5728\u57fa\u7840\u6d41\u8ba1\u7b97\u7684\u6846\u67b6\u57fa\u7840\u4e0a\u5b9e\u73b0\u4e86 Kafka connector\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 CREATE DYNAMIC TABLE \u521b\u5efa\u6d41\u5f0f\u52a8\u6001\u8868\uff0c\u6b64\u7c7b\u578b\u7684\u8868\u662f Append Only \u7684\u8868\uff0c\u540c\u65f6\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 CREATE SOURCE \u7684\u65b9\u5f0f\u914d\u7f6e\u5916\u90e8\u6570\u636e\u6e90\uff0c\u672c\u8fed\u4ee3\u5df2\u9002\u914d Kafka \u4f5c\u4e3a\u6570\u636e\u6e90\uff0c\u53ef\u4ee5\u63a5\u5165 Kafka \u7684 Topic\uff08JSON \u7c7b\u578b\u6216\u8005 protobuf \u534f\u8bae\u7c7b\u578b\uff09\uff0c\u63a5\u5165\u540e MatrixOne \u4f1a\u81ea\u52a8\u5c06 Kafka \u7684 Message \u5199\u5165\u5230\u52a8\u6001\u8868\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u5bf9\u6d41\u5f0f\u8868\u8fdb\u884c\u7a97\u53e3\u67e5\u8be2\uff0c\u6216\u8005\u4e0e\u5176\u4ed6\u8868\u4e00\u8d77\u8fdb\u884c\u5173\u8054\u67e5\u8be2\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#udfbeta","title":"\u81ea\u5b9a\u4e49\u51fd\u6570 UDF\uff08beta\uff09","text":"\u672c\u8fed\u4ee3 MatrixOne \u5f00\u59cb\u652f\u6301\u7528\u6237\u7f16\u5199\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u76ee\u524d\u7b2c\u4e00\u4e2a\u7248\u672c\u4ec5\u652f\u6301 Python \u8bed\u8a00\u3002\u5728\u5f88\u591a\u573a\u666f\u4e2d\u6570\u636e\u5e93\u7cfb\u7edf\u63d0\u4f9b\u7684\u7cfb\u7edf\u51fd\u6570\u5e76\u65e0\u6cd5\u6ee1\u8db3\u7528\u6237\u7684\u4e1a\u52a1\u9700\u6c42\uff0c\u901a\u8fc7 UDF \u7684\u65b9\u5f0f\u7528\u6237\u53ef\u4ee5\u5c06\u4e1a\u52a1\u7684\u903b\u8f91\u5305\u88c5\u5728 Python \u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06\u5176\u5c01\u88c5\u6210 SQL \u7684\u51fd\u6570\uff0c\u5b9e\u73b0\u5728 SQL \u4e2d\u76f4\u63a5\u8c03\u7528\u3002\u57fa\u4e8e Python \u7684 UDF\uff0c\u7528\u6237\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u7684\u4f7f\u7528 numpy \u548c scikit-learn \u7b49 Python \u7684\u6d41\u884c\u5e93\uff0c\u5927\u5e45\u5ea6\u7684\u63d0\u9ad8 MatrixOne \u5728\u6570\u636e\u79d1\u5b66\uff0c\u673a\u5668\u5b66\u4e60\u53ca AI \u7b49\u9886\u57df\u7684\u9002\u7528\u6027\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.0/#_4","title":"\u5176\u4ed6\u65b0\u529f\u80fd","text":""},{"location":"MatrixOne/Release-Notes/v1.1.0/#ddl","title":"DDL \u8bed\u53e5","text":"https://github.com/matrixorigin/matrixone/compare/v1.0.0...v1.1.0
"},{"location":"MatrixOne/Release-Notes/v1.1.1/","title":"MatrixOne v1.1.1 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 02 \u6708 04 \u65e5
MatrixOne \u7248\u672c\uff1av1.1.1
\u4e0e\u4e4b\u524d\u7684 v1.1.0 \u76f8\u6bd4\uff0cv1.1.1 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.1/#_1","title":"\u6539\u8fdb","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.0...v1.1.1
"},{"location":"MatrixOne/Release-Notes/v1.1.2/","title":"MatrixOne v1.1.2 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 04 \u6708 02 \u65e5
MatrixOne \u7248\u672c\uff1av1.1.2
\u4e0e\u4e4b\u524d\u7684 v1.1.1 \u76f8\u6bd4\uff0cv1.1.2 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u6539\u8fdb\u548c\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.2/#_1","title":"\u6539\u8fdb","text":"\u6709\u5173\u5176\u4ed6\u9519\u8bef\u4fee\u590d\uff0c\u8bf7\u70b9\u51fb MatrixOne-v1.1.2 \u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.2/#_3","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.1...v1.1.2
"},{"location":"MatrixOne/Release-Notes/v1.1.3/","title":"MatrixOne v1.1.3 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 04 \u6708 16 \u65e5
MatrixOne \u7248\u672c\uff1av1.1.3
\u4e0e\u4e4b\u524d\u7684 v1.1.2 \u76f8\u6bd4\uff0cv1.1.3 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u9519\u8bef\u4fee\u590d\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.3/#_1","title":"\u9519\u8bef\u4fee\u590d","text":"\u6709\u5173\u5176\u4ed6\u9519\u8bef\u4fee\u590d\uff0c\u8bf7\u70b9\u51fb MatrixOne-v1.1.3 \u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Release-Notes/v1.1.3/#_2","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.2...v1.1.3
"},{"location":"MatrixOne/Release-Notes/v1.2.0/","title":"MatrixOne v1.2.0 \u53d1\u5e03\u62a5\u544a","text":"\u6211\u4eec\u975e\u5e38\u9ad8\u5174\u5730\u5ba3\u5e03 MatrixOne \u5185\u6838 v1.2.0 \u7248\u672c\u4e8e 2024 \u5e74 05 \u6708 20 \u65e5\u6b63\u5f0f\u53d1\u5e03\uff01
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#matrixone","title":"MatrixOne \u662f\u4ec0\u4e48\uff1f","text":"MatrixOne \u662f\u4e00\u6b3e\u5206\u5e03\u5f0f\u8d85\u878d\u5408\u5f02\u6784\u4e91\u539f\u751f\u6570\u636e\u5e93\uff0cMatrixOne \u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u4e91\u539f\u751f\u3001\u9ad8\u6027\u80fd\u3001\u9ad8\u5f39\u6027\u3001\u9ad8\u5ea6\u517c\u5bb9 MySQL \u7684 HSTAP \u6570\u636e\u5e93\uff0c\u8ba9\u7528\u6237\u9762\u5bf9\u4e8b\u52a1\u3001\u5206\u6790\u3001\u65f6\u5e8f\u3001\u6d41\u8ba1\u7b97\u7b49\u6df7\u5408\u8d1f\u8f7d\u65f6\uff0c\u901a\u8fc7 MatrixOne \u4e00\u7ad9\u5f0f\u7684\u5b8c\u6210\u6574\u4e2a\u6570\u636e\u5904\u7406\u8fc7\u7a0b\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_1","title":"\u91cd\u70b9\u5173\u6ce8","text":"MatrixOne \u5728\u672c\u6b21\u7684\u8fed\u4ee3\u4e2d\u8fdb\u884c\u4e86\u663e\u8457\u7684\u529f\u80fd\u6269\u5c55\uff0c\u91cd\u70b9\u529f\u80fd\u6709\uff1a\u5feb\u7167\u5907\u4efd\u3001\u589e\u91cf\u7269\u7406\u5907\u4efd\u3001CTAS\u3001BITMAP \u548c\u5411\u91cf\u7d22\u5f15\u3002\u968f\u7740\u8fd9\u4e9b\u65b0\u529f\u80fd\u7684\u5f15\u5165\uff0cMatrixOne \u6b63\u9010\u6b65\u6210\u4e3a\u4f01\u4e1a\u7ea7\u6570\u636e\u7ba1\u7406\u548c\u5206\u6790\u7684\u7406\u60f3\u9009\u62e9\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#beta","title":"\u5feb\u7167\u5907\u4efd\u6062\u590d (Beta)","text":"\u6570\u636e\u5e93\u5feb\u7167\u5907\u4efd\u6280\u672f\u901a\u8fc7\u521b\u5efa\u7279\u5b9a\u65f6\u95f4\u70b9\u7684\u53ea\u8bfb\u526f\u672c\uff0c\u5728\u4e0d\u5f71\u54cd\u6570\u636e\u5e93\u8fd0\u884c\u7684\u60c5\u51b5\u4e0b\u4e3a\u6570\u636e\u63d0\u4f9b\u4e86\u4e00\u79cd\u9ad8\u6548\u7684\u4fdd\u62a4\u65b9\u5f0f\u3002\u5728\u672c\u6b21\u8fed\u4ee3\u4e2d\uff0cMatrixone \u5f00\u59cb\u652f\u6301\u79df\u6237\u7ea7\u522b\u7684\u5feb\u7167\u5907\u4efd\u6062\u590d\uff0c\u5728\u6570\u636e\u4e22\u5931\u6216\u635f\u574f\u7684\u60c5\u51b5\u4e0b\uff0c\u5feb\u7167\u5907\u4efd\u53ef\u4ee5\u5feb\u901f\u6062\u590d\u5230\u5907\u4efd\u65f6\u7684\u72b6\u6001\uff0c\u51cf\u5c11\u4e86\u6062\u590d\u65f6\u95f4\u76ee\u6807\uff08RTO\uff09\u3002\u5feb\u7167\u5907\u4efd\u4e0d\u9700\u8981\u505c\u6b62\u6570\u636e\u5e93\u670d\u52a1\uff0c\u56e0\u6b64\u53ef\u4ee5\u7b80\u5316\u5907\u4efd\u6d41\u7a0b\u5e76\u4fdd\u8bc1\u4e86\u4e1a\u52a1\u7684\u8fde\u7eed\u6027\u3002\u5728\u707e\u96be\u6062\u590d\u8ba1\u5212\u4e2d\uff0c\u5feb\u7167\u5907\u4efd\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\uff0c\u786e\u4fdd\u5728\u7d27\u6025\u60c5\u51b5\u4e0b\u80fd\u591f\u8fc5\u901f\u6062\u590d\u5173\u952e\u6570\u636e\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_2","title":"\u589e\u91cf\u7269\u7406\u5907\u4efd\uff08\u4f01\u4e1a\u7248\uff09","text":"\u5728 mo_backup \u5de5\u5177\u652f\u6301\u5168\u91cf\u7269\u7406\u5907\u4efd\u7684\u57fa\u7840\u4e0a\uff0c\u589e\u52a0\u4e86\u589e\u91cf\u7269\u7406\u5907\u4efd\u80fd\u529b\u3002\u5728\u6570\u636e\u91cf\u8f83\u5927\u7684\u73af\u5883\u4e0b\uff0c\u8fc7\u53bb\u6bcf\u6b21\u5907\u4efd\u90fd\u662f\u5168\u91cf\u5907\u4efd\uff0c\u5bfc\u81f4\u5907\u4efd\u65f6\u95f4\u8f83\u957f\uff0c\u4e14\u5360\u7528\u5927\u91cf\u5b58\u50a8\u7a7a\u95f4\u3002\u589e\u91cf\u5907\u4efd\u529f\u80fd\u4f1a\u81ea\u52a8\u8ba1\u7b97\u8fc7\u53bb\u5df2\u7ecf\u5907\u4efd\u8fc7\u7684\u65f6\u95f4\u70b9\u4ee5\u53ca\u5df2\u5907\u4efd\u8fc7\u7684 object \u5217\u8868\uff0c\u4ec5\u9700\u8981\u5bf9\u65b0\u7684 object \u5217\u8868\u8fdb\u884c\u5907\u4efd\u5373\u53ef\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#ctas","title":"CTAS","text":"\u5728\u672c\u8fed\u4ee3\u4e2d\uff0cMatrixOne \u652f\u6301\u4e86 CTAS\u3002CTAS \u662f\u4e00\u79cd SQL \u8bed\u53e5\uff0c\u7528\u4e8e\u57fa\u4e8e\u73b0\u6709\u6570\u636e\u5feb\u901f\u521b\u5efa\u4e00\u4e2a\u65b0\u8868\u3002\u5b83\u7ed3\u5408\u4e86\u521b\u5efa\u8868\u548c\u9009\u62e9\u67e5\u8be2\u7684\u529f\u80fd\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u9ad8\u6548\u7684\u65b9\u5f0f\u6765\u521b\u5efa\u8868\u7684\u5feb\u7167\u3001\u8fdb\u884c\u6570\u636e\u8f6c\u6362\u3001\u6216\u8005\u521b\u5efa\u7528\u4e8e\u62a5\u544a\u548c\u5206\u6790\u7684\u6570\u636e\u6a21\u578b\u3002\u7279\u70b9\u5982\u4e0b\uff1a
\u9ad8\u6548\u6027\uff1aCTAS \u901a\u5e38\u4f5c\u4e3a\u4e00\u4e2a\u539f\u5b50\u64cd\u4f5c\u6267\u884c\uff0c\u51cf\u5c11\u4e86\u521b\u5efa\u8868\u548c\u63d2\u5165\u6570\u636e\u7684\u6b65\u9aa4\uff0c\u63d0\u9ad8\u4e86\u6027\u80fd\u3002
\u7b80\u6d01\u6027\uff1a\u901a\u8fc7\u4e00\u6b21\u6027\u64cd\u4f5c\u521b\u5efa\u65b0\u8868\u548c\u586b\u5145\u6570\u636e\uff0c\u7b80\u5316\u4e86\u6570\u636e\u5efa\u6a21\u548c ETL \u8fc7\u7a0b\u3002
\u7075\u6d3b\u6027\uff1a\u53ef\u4ee5\u5229\u7528 SELECT \u8bed\u53e5\u4e2d\u7684\u5927\u90e8\u5206\u529f\u80fd\uff0c\u5982 WHERE\u3001JOIN\u3001GROUP BY \u7b49\uff0c\u8fdb\u884c\u590d\u6742\u7684\u6570\u636e\u8f6c\u6362\u3002
\u5728\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u652f\u6301\u7684\u8fc7\u7a0b\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9\u5927\u91cf\u6570\u636e\u8fdb\u884c\u53bb\u91cd\u8ba1\u6570\uff0c\u4ee5\u83b7\u5f97\u4e0d\u540c\u503c\u7684\u51c6\u786e\u6570\u91cf\u3002\u4f20\u7edf\u7684 count(distinct values) \u8bed\u53e5\u867d\u7136\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u76ee\u7684\uff0c\u4f46\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u96c6\u65f6\uff0c\u5176\u6027\u80fd\u5f80\u5f80\u4e0d\u5c3d\u4eba\u610f\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0cMatrixOne \u5728\u672c\u8fed\u4ee3\u4e2d\u5f15\u5165\u4e86 BITMAP\uff08\u4f4d\u56fe\uff09\u51fd\u6570\u3002\u8fd9\u4e9b\u5185\u7f6e\u51fd\u6570\u4f7f\u5f97 BITMAP \u5728\u8fdb\u884c\u6570\u636e\u53bb\u91cd\u3001\u8ba1\u6570\u3001\u67e5\u8be2\u7edf\u8ba1\u3001\u6392\u5e8f\u7b49\u64cd\u4f5c\u65f6\uff0c\u80fd\u591f\u63d0\u4f9b\u6bd4\u4f20\u7edf\u65b9\u6cd5\u66f4\u5feb\u7684\u5904\u7406\u901f\u5ea6\u548c\u66f4\u4f4e\u7684\u8d44\u6e90\u6d88\u8017\u3002\u5728\u5546\u4e1a\u667a\u80fd\u3001\u7528\u6237\u884c\u4e3a\u5206\u6790\u3001\u5b9e\u65f6\u63a8\u8350\u7cfb\u7edf\u7b49\u5e94\u7528\u573a\u666f\u4e2d\uff0cBITMAP \u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u6570\u636e\u5904\u7406\u7684\u901f\u5ea6\u548c\u51c6\u786e\u6027\uff0c\u5e2e\u52a9\u4f01\u4e1a\u548c\u7ec4\u7ec7\u66f4\u597d\u5730\u8fdb\u884c\u6570\u636e\u5206\u6790\u548c\u51b3\u7b56\u5236\u5b9a\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_3","title":"\u5411\u91cf\u7d22\u5f15","text":"\u5728\u4e0a\u4e2a\u8fed\u4ee3\u4e2d\uff0cMatrixone \u652f\u6301\u4e86\u5411\u91cf\u7c7b\u578b\u4ee5\u53ca\u5e38\u89c1\u7684\u5411\u91cf\u76f8\u4f3c\u5ea6\u51fd\u6570\uff0c\u5728\u672c\u6b21\u8fed\u4ee3\u4e2d\uff0cMatrixone \u8fdb\u4e00\u6b65\u5f15\u5165\u4e86\u5411\u91cf\u7d22\u5f15\u6280\u672f\uff0c\u8fd9\u4e00\u8fdb\u5c55\u663e\u8457\u63d0\u5347\u4e86\u7cfb\u7edf\u5728\u5904\u7406\u5411\u91cf\u6570\u636e\u65f6\u7684\u6027\u80fd\u3002\u5411\u91cf\u7d22\u5f15\u5141\u8bb8\u7cfb\u7edf\u5feb\u901f\u68c0\u7d22\u4e0e\u67e5\u8be2\u5411\u91cf\u6700\u76f8\u4f3c\u6216\u6700\u63a5\u8fd1\u7684\u6570\u636e\u70b9\u3002\u8fd9\u79cd\u9ad8\u6548\u7684\u68c0\u7d22\u80fd\u529b\uff0c\u5bf9\u4e8e\u9700\u8981\u5728\u6d77\u91cf\u6570\u636e\u4e2d\u8fdb\u884c\u5feb\u901f\u641c\u7d22\u548c\u5339\u914d\u7684\u5e94\u7528\u573a\u666f\u81f3\u5173\u91cd\u8981\u3002\u5728\u673a\u5668\u5b66\u4e60\u548c\u4eba\u5de5\u667a\u80fd\u9886\u57df\uff0c\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u548c\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08RAG\uff09\u7b49\u6280\u672f\u7684\u5e94\u7528\u65e5\u76ca\u589e\u591a\uff0c\u8fd9\u4e9b\u6280\u672f\u901a\u5e38\u9700\u8981\u5904\u7406\u5927\u91cf\u7684\u9ad8\u7ef4\u6570\u636e\uff0c\u5e76\u5bf9\u6570\u636e\u8fdb\u884c\u590d\u6742\u7684\u76f8\u4f3c\u6027\u6bd4\u8f83\u548c\u6a21\u5f0f\u5339\u914d\u3002\u5411\u91cf\u7d22\u5f15\u7684\u5f15\u5165\uff0c\u4e3a\u8fd9\u4e9b\u6280\u672f\u7684\u5e94\u7528\u63d0\u4f9b\u4e86\u575a\u5b9e\u7684\u57fa\u7840\u3002\u5b83\u4e0d\u4ec5\u80fd\u591f\u51cf\u5c11\u8ba1\u7b97\u8d44\u6e90\u7684\u6d88\u8017\uff0c\u8fd8\u80fd\u663e\u8457\u63d0\u9ad8\u67e5\u8be2\u54cd\u5e94\u65f6\u95f4\uff0c\u4ece\u800c\u4f18\u5316\u6574\u4f53\u7684\u7cfb\u7edf\u6027\u80fd\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.0/#_4","title":"\u5176\u4ed6\u65b0\u529f\u80fd","text":""},{"location":"MatrixOne/Release-Notes/v1.2.0/#sql","title":"SQL \u8bed\u53e5","text":"https://github.com/matrixorigin/matrixone/compare/v1.1.0...v1.2.0
"},{"location":"MatrixOne/Release-Notes/v1.2.1/","title":"MatrixOne v1.2.1 \u53d1\u5e03\u62a5\u544a","text":"\u53d1\u5e03\u65e5\u671f\uff1a2024 \u5e74 06 \u6708 30 \u65e5
MatrixOne \u7248\u672c\uff1av1.2.1
\u4e0e\u4e4b\u524d\u7684 v1.2.0 \u76f8\u6bd4\uff0cv1.2.1 \u6ca1\u6709\u5f15\u5165\u4efb\u4f55\u65b0\u529f\u80fd\uff0c\u800c\u662f\u4e13\u6ce8\u4e8e\u4e00\u4e9b\u9519\u8bef\u4fee\u590d\u548c\u4f18\u5316\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.1/#_1","title":"\u6539\u8fdb","text":"show accounts
\u7684\u6027\u80fd\u3002 fileservice
\u7684\u53ef\u89c2\u5bdf\u6027\u5ea6\u91cf\u3002 TCP
\u6570\u636e\u5305\u7684\u4f30\u7b97\u3002 mologing
\u3002 zonemap
\u7684\u624b\u52a8\u5408\u5e76\u3002 \u4fee\u590d\u4e86\u4e0e\u5feb\u7167\u8bfb\u53d6\u3001MySQL \u517c\u5bb9\u6027\u3001\u9501\u670d\u52a1\u3001\u8fd0\u884c\u65f6\u7b5b\u9009\u5668\u548c\u7cfb\u7edf\u8868\u5347\u7ea7\u76f8\u5173\u7684\u9519\u8bef\u3002\u6709\u5173\u5176\u4ed6\u9519\u8bef\u4fee\u590d\uff0c\u8bf7\u70b9\u51fb MatrixOne-v1.2.1 \u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Release-Notes/v1.2.1/#_3","title":"\u66f4\u8be6\u7ec6\u7684\u66f4\u65b0\u65e5\u5fd7","text":"https://github.com/matrixorigin/matrixone/compare/v1.2.0...v1.2.1
"},{"location":"MatrixOne/Security/Authentication/","title":"\u8eab\u4efd\u9274\u522b\u4e0e\u8ba4\u8bc1","text":"\u7528\u6237\u5728\u8bbf\u95ee MatrixOne \u6570\u636e\u5e93\u65f6\u9700\u8981\u8fdb\u884c\u8eab\u4efd\u9274\u522b\u4e0e\u8ba4\u8bc1\uff0c\u76ee\u524d MatrixOne \u4ec5\u652f\u6301\u7528\u6237\u540d\u5bc6\u7801\u9a8c\u8bc1\u65b9\u5f0f\u767b\u5f55\u3002\u6570\u636e\u5e93\u4f1a\u5bf9\u8bbf\u95ee\u6570\u636e\u7684\u7528\u6237\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\uff0c\u786e\u8ba4\u8be5\u7528\u6237\u662f\u5426\u80fd\u591f\u4e0e\u67d0\u4e00\u4e2a\u6570\u636e\u5e93\u7528\u6237\u8fdb\u884c\u5173\u8054\uff0c\u5e76\u68c0\u67e5\u5176\u63d0\u4f9b\u7684\u5bc6\u7801\u662f\u5426\u6709\u6548\u3002
"},{"location":"MatrixOne/Security/Authentication/#_2","title":"\u767b\u5f55\u8bed\u6cd5","text":"\u5728 MatrixOne \u4e2d\uff0c\u7528\u6237\u7684\u767b\u5f55\u8eab\u4efd\u9274\u522b\u7531 acccount_name
\uff0cuser_name
\uff0chost
\uff0cpassword
\u5171\u540c\u7ec4\u6210\u3002\u5b8c\u6574\u7684\u767b\u5f55\u8bed\u6cd5\u5982\u4e0b\uff1a
mysql -h host -p password -u accountname:username -P port\n
\u5176\u4e2d -h
\u3001-p
\u3001-P
\u53c2\u6570\u4e0e MySQL \u76f8\u540c\u3002\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\uff1a
-u
\u4ee3\u8868\u7528\u6237\uff0c\u5728 MatrixOne \u7684\u7528\u6237\u4f53\u7cfb\u4e2d\uff0c\u7528\u6237\u662f\u4f4d\u4e8e\u79df\u6237 account
\u4ee5\u4e0b\u4e00\u5c42\u7684\u6982\u5ff5\uff0c\u56e0\u6b64\u767b\u5f55\u65f6\u9700\u8981\u5148\u6307\u5b9a\u79df\u6237 account_name
\uff0c\u518d\u6307\u5b9a\u79df\u6237\u4e2d\u7684\u7528\u6237 username
\u624d\u80fd\u5b8c\u6210\u767b\u5f55\u3002\u5982\u679c\u4e0d\u6307\u5b9a account_name
\uff0c\u5219\u9ed8\u8ba4\u4e3a\u7cfb\u7edf\u79df\u6237 sys
\u3002\u793a\u4f8b\uff1a
> mysql -h 127.0.0.1 -P6001 -utenant1:u1 -p111\n
Note
\u5bf9\u4e8e\u5355\u673a\u7248 MatrixOne\uff0c\u53ef\u4ee5\u901a\u8fc7\u53c2\u6570\u914d\u7f6e\u5c06\u8fde\u63a5\u5b57\u7b26\u4e32\u7b80\u5316\u5230 mo_ctl \u5de5\u5177\u4e2d\uff0c\u4ee5\u7b80\u5316\u767b\u5f55\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Security/Authentication/#_3","title":"\u67e5\u8be2\u5f53\u524d\u7528\u6237","text":"\u767b\u5f55\u540e\u8981\u83b7\u53d6\u6709\u5173\u5f53\u524d\u7528\u6237\u7684\u4fe1\u606f\uff0c\u53ef\u4ee5\u4f7f\u7528 user()
\u6216 current_user()
\u51fd\u6570\u3002
mysql> select user();\n+--------------------+\n| user() |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\nmysql> select current_user();\n+--------------------+\n| current_user() |\n+--------------------+\n| tenant1:u1@0.0.0.0 |\n+--------------------+\n1 row in set (0.00 sec)\n
Note
\u76ee\u524d MatrixOne \u4e0d\u652f\u6301 IP \u767d\u540d\u5355\uff0c\u56e0\u6b64\u65e0\u8bba\u4ece\u4efb\u4f55\u4f4d\u7f6e\u767b\u5f55\u67e5\u770b\u7684\u7528\u6237\u90fd\u4e3a 0.0.0.0\u3002
"},{"location":"MatrixOne/Security/Authentication/#_4","title":"\u67e5\u8be2\u6240\u6709\u7528\u6237","text":"\u6bcf\u4e2a\u7528\u6237\u8eab\u4efd\u5177\u6709\u552f\u4e00\u6027\uff0c\u6bcf\u4e2a\u5177\u6709 accountadmin
\u89d2\u8272\u7684\u7528\u6237\u53ef\u4ee5\u67e5\u770b\u8be5\u79df\u6237\u4e0b\u7684\u6240\u6709\u7528\u6237\u3002
mysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| 10001 | localhost | u1 | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-10 06:43:44 | NULL | PASSWORD | 0 | 0 | 1 |\n| 0 | localhost | root | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL | PASSWORD | 0 | 0 | 0 |\n| 1 | localhost | root | *832EB84CB764129D05D498ED9CA7E5CE9B8F83EB | unlock | 2023-07-08 03:17:27 | NULL | PASSWORD | 0 | 0 | 0 |\n+---------+-----------+-----------+-------------------------------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n3 rows in set (0.01 sec)\n
Note
MatrixOne \u4e2d\u7528\u6237\u8868\u7684\u8bb0\u5f55\u4f4d\u7f6e\u548c\u8868\u7ed3\u6784\u4e0e MySQL \u4e0d\u540c\u3002MatrixOne \u4e2d\u7684\u7528\u6237\u5143\u6570\u636e\u4fe1\u606f\u4e0d\u5b58\u50a8\u5728 mysql.user
\u8868\u4e2d\uff0c\u800c\u662f\u5b58\u50a8\u5728 mo_catalog.mo_user
\u4e2d\u3002
sys
\u79df\u6237\u7684 root
\u7528\u6237\uff09\u521d\u59cb\u5bc6\u7801\u4e3a 111\u3002\u7528\u6237\u4fee\u6539\u5bc6\u7801\u540e\u9700\u8981\u81ea\u884c\u8bb0\u4f4f\u65b0\u5bc6\u7801\uff0c\u4e00\u65e6\u5fd8\u8bb0\u5bc6\u7801\uff0cMatrixOne \u76ee\u524d\u6ca1\u6709\u63d0\u4f9b\u627e\u56de\u6216\u7ed5\u8fc7\u5b89\u5168\u9a8c\u8bc1\u8fdb\u884c\u5bc6\u7801\u91cd\u7f6e\u7684\u65b9\u6cd5\uff0c\u5fc5\u987b\u91cd\u65b0\u5b89\u88c5 MatrixOne\u3002\u6570\u636e\u5e93\u5b89\u5168\u548c\u6743\u9650\u662f\u786e\u4fdd\u6570\u636e\u5e93\u7cfb\u7edf\u53ca\u5176\u4e2d\u5b58\u50a8\u7684\u6570\u636e\u53d7\u5230\u4fdd\u62a4\u548c\u7ba1\u7406\u7684\u5173\u952e\u65b9\u9762\u3002\u5b83\u6d89\u53ca\u4e00\u7cfb\u5217\u7b56\u7565\u3001\u63aa\u65bd\u548c\u6743\u9650\u63a7\u5236\uff0c\u4ee5\u786e\u4fdd\u53ea\u6709\u7ecf\u8fc7\u6388\u6743\u7684\u7528\u6237\u80fd\u591f\u8bbf\u95ee\u3001\u4fee\u6539\u548c\u64cd\u4f5c\u6570\u636e\u5e93\u3002\u672c\u7ae0\u8282\u5c06\u4e3a\u60a8\u4ecb\u7ecd MatrixOne \u6570\u636e\u5e93\u7684\u5b89\u5168\u4e0e\u6743\u9650\u7ba1\u7406\u4f53\u7cfb\u3002
"},{"location":"MatrixOne/Security/Security-Permission-Overview/#_2","title":"\u6570\u636e\u5e93\u5b89\u5168\u7ba1\u7406","text":"MatrixOne \u6570\u636e\u5e93\u5b89\u5168\u7684\u76ee\u6807\u662f\u4fdd\u62a4\u6570\u636e\u5e93\u514d\u53d7\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u3001\u6570\u636e\u6cc4\u9732\u3001\u6570\u636e\u7be1\u6539\u548c\u5176\u4ed6\u5b89\u5168\u5a01\u80c1\u3002MatrixOne \u63d0\u4f9b\u4ee5\u4e0b\u80fd\u529b\u6765\u786e\u4fdd\u6570\u636e\u5e93\u5b89\u5168\uff1a
MatrixOne \u6570\u636e\u5e93\u6743\u9650\u7ba1\u7406\u662f\u7ba1\u7406\u7528\u6237\u5bf9\u6570\u636e\u5e93\u7684\u8bbf\u95ee\u6743\u9650\u548c\u64cd\u4f5c\u6743\u9650\u7684\u8fc7\u7a0b\u3002\u901a\u8fc7\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u63a7\u5236\uff0c\u53ef\u4ee5\u786e\u4fdd\u6bcf\u4e2a\u7528\u6237\u53ea\u80fd\u6267\u884c\u5176\u6240\u9700\u7684\u64cd\u4f5c\uff0c\u5e76\u9650\u5236\u5bf9\u654f\u611f\u6570\u636e\u7684\u8bbf\u95ee\u3002MatrixOne \u7684\u6570\u636e\u5e93\u6743\u9650\u7ba1\u7406\u5305\u62ec\u4ee5\u4e0b\u65b9\u9762\uff1a
\u672c\u7bc7\u6587\u6863\u5c06\u4ecb\u7ecd MatrixOne \u5bf9\u6570\u636e\u4f20\u8f93\u52a0\u5bc6\u7684\u652f\u6301\u60c5\u51b5\u4ee5\u53ca\u5982\u4f55\u5f00\u59cb\u52a0\u5bc6\u4f20\u8f93\u3002
"},{"location":"MatrixOne/Security/TLS-introduction/#_2","title":"\u6982\u8ff0","text":"MatrixOne \u9ed8\u8ba4\u91c7\u7528\u975e\u52a0\u5bc6\u4f20\u8f93\uff0c\u4e5f\u652f\u6301\u542f\u7528\u57fa\u4e8e TLS \u534f\u8bae\u7684\u52a0\u5bc6\u4f20\u8f93\u3002\u4f7f\u7528\u52a0\u5bc6\u4f20\u8f93\u53ef\u4ee5\u51cf\u5c11\u6570\u636e\u5e93\u4e2d\u654f\u611f\u4fe1\u606f\u7684\u6cc4\u9732\u98ce\u9669\u3002\u52a0\u5bc6\u4f20\u8f93\u662f\u91c7\u7528\u5bc6\u94a5\u5bf9\u4fe1\u606f\u8fdb\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u4fdd\u62a4\u6570\u636e\u7684\u5b89\u5168\u3002
\u4f20\u8f93\u5c42\u5b89\u5168\u6027 (Transport Layer Security, TLS) \u662f\u4e00\u79cd\u5e7f\u6cdb\u91c7\u7528\u7684\u5b89\u5168\u6027\u534f\u8bae\uff0cMatrixOne \u652f\u6301\u7684\u534f\u8bae\u7248\u672c\u6709 TLS 1.0, TLS 1.1, TLS 1.2\u3002
TLS \u5b89\u5168\u8fde\u63a5\u914d\u7f6e\u4e3b\u8981\u6b65\u9aa4\u6982\u8ff0\uff1a
\u9996\u5148\u5728 MatrixOne \u4e2d\u5f00\u542f TLS\u3002
\u7136\u540e\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u5b89\u5168\u8fde\u63a5\u53c2\u6570\u3002
\u5b8c\u6210\u8fd9\u4e24\u4e2a\u4e3b\u8981\u6b65\u9aa4\u7684\u914d\u7f6e\u540e\uff0c\u5373\u53ef\u5efa\u7acb TLS \u5b89\u5168\u8fde\u63a5\u3002
"},{"location":"MatrixOne/Security/TLS-introduction/#matrixone-tls","title":"\u6b65\u9aa4\u4e00\uff1a\u5f00\u542f MatrixOne \u7684 TLS \u652f\u6301","text":"\u751f\u6210\u8bc1\u4e66\u53ca\u5bc6\u94a5\uff1aMatrixOne \u5c1a\u4e0d\u652f\u6301\u52a0\u8f7d\u6709\u5bc6\u7801\u4fdd\u62a4\u7684\u79c1\u94a5\uff0c\u56e0\u6b64\u5fc5\u987b\u63d0\u4f9b\u4e00\u4e2a\u6ca1\u6709\u5bc6\u7801\u7684\u79c1\u94a5\u6587\u4ef6\u3002\u8bc1\u4e66\u548c\u5bc6\u94a5\u53ef\u4ee5\u4f7f\u7528 OpenSSL \u7b7e\u53d1\u548c\u751f\u6210\uff0c\u63a8\u8350\u4f7f\u7528 MySQL \u81ea\u5e26\u7684\u5de5\u5177 mysql_ssl_rsa_setup
\u5feb\u6377\u751f\u6210\uff1a
#\u68c0\u67e5\u4f60\u672c\u5730 MySQL \u5ba2\u6237\u7aef\u7684\u5b89\u88c5\u76ee\u5f55\nps -ef|grep mysql\n#\u8fdb\u5165\u5230\u4f60\u672c\u5730 MySQL \u5ba2\u6237\u7aef\u7684\u5b89\u88c5\u76ee\u5f55\ncd /usr/local/mysql/bin\n#\u751f\u6210\u8bc1\u4e66\u548c\u5bc6\u94a5\n./mysql_ssl_rsa_setup --datadir=<yourpath>\n#\u68c0\u67e5\u4f60\u751f\u6210\u7684 pem \u6587\u4ef6\nls <yourpath>\n\u251c\u2500\u2500 ca-key.pem\n\u251c\u2500\u2500 ca.pem\n\u251c\u2500\u2500 client-cert.pem\n\u251c\u2500\u2500 client-key.pem\n\u251c\u2500\u2500 private_key.pem\n\u251c\u2500\u2500 public_key.pem\n\u251c\u2500\u2500 server-cert.pem\n\u2514\u2500\u2500 server-key.pem\n
Note: \u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684 <yourpath>
\u662f\u4f60\u9700\u8981\u5b58\u653e\u751f\u6210\u7684\u8bc1\u4e66\u53ca\u5bc6\u94a5\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u8def\u5f84\u3002
\u8fdb\u5165\u5230\u4f60\u672c\u5730\u7684 MatrixOne \u6587\u4ef6\u76ee\u5f55\u8def\u5f84 matrixone/etc/launch-tae-CN-tae-TN/ \u4e2d\u7684 cn.toml \u914d\u7f6e\u6587\u4ef6\uff1a
\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528 vim \u547d\u4ee4\u76f4\u63a5\u5728\u7ec8\u7aef\u4e2d\u6253\u5f00 cn.toml \u6587\u4ef6
vim $matrixone/etc/launch-tae-CN-tae-TN/cn.toml\n
\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u6bb5\u590d\u5236\u7c98\u8d34\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d\uff1a
[cn.frontend]\n#default is false. With true. Server will support tls\nenableTls = true\n\n#default is ''. Path of file that contains X509 certificate in PEM format for client\ntlsCertFile = \"<yourpath>/server-cert.pem\"\n\n#default is ''. Path of file that contains X509 key in PEM format for client\ntlsKeyFile = \"<yourpath>/server-key.pem\"\n\n#default is ''. Path of file that contains list of trusted SSL CAs for client\ntlsCaFile = \"<yourpath>/ca.pem\"\n
Note: \u4e0a\u8ff0\u4ee3\u7801\u4e2d\u7684 <yourpath>
\u662f\u4f60\u9700\u8981\u5b58\u653e\u751f\u6210\u7684\u8bc1\u4e66\u53ca\u5bc6\u94a5\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u8def\u5f84
\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u914d\u7f6e\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
\u53c2\u6570 \u63cf\u8ff0 enableTls \u5e03\u5c14\u7c7b\u578b\uff0c\u662f\u5426\u5728 MatrixOne \u670d\u52a1\u7aef\u6253\u5f00 TLS \u7684\u652f\u6301\u3002 tlsCertFile \u6307\u5b9a SSL \u8bc1\u4e66\u6587\u4ef6\u8def\u5f84 tlsKeyFile \u6307\u5b9a\u8bc1\u4e66\u6587\u4ef6\u5bf9\u5e94\u7684\u79c1\u94a5 tlsCaFile \u53ef\u9009\uff0c\u6307\u5b9a\u53d7\u4fe1\u4efb\u7684 CA \u8bc1\u4e66\u6587\u4ef6\u8def\u5f84Note: \u5982\u679c\u4f60\u662f\u4f7f\u7528 Docker \u5b89\u88c5\u90e8\u7f72\u7684 MatrixOne\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u5148\u6302\u8f7d\u914d\u7f6e\u6587\u4ef6\u518d\u8fdb\u884c\u4fee\u6539\uff0c\u64cd\u4f5c\u5177\u4f53\u53c2\u89c1\u6302\u8f7d\u76ee\u5f55\u5230 Docker \u5bb9\u5668\u3002
\u9a8c\u8bc1 MatrixOne \u7684 SSL \u662f\u5426\u542f\u7528\u3002
\u2460 \u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne\uff0c\u6b64\u5904\u4ee5\u521d\u59cb\u8d26\u53f7\u548c\u5bc6\u7801\u4e3a\u4f8b\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n
\u2461 \u4f7f\u7528 Status
\u547d\u4ee4\u67e5\u770b SSL \u662f\u5426\u542f\u7528\u3002
\u6210\u529f\u542f\u7528\uff0c\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff0c\u53ef\u4ee5\u770b\u5230 SSL \u72b6\u6001\u4e3a Cipher in use is TLS_AES_128_GCM_SHA256
\uff1a
mysql> status\nmysql Ver 8.0.28 for macos11 on arm64 (MySQL Community Server - GPL)\n\nConnection id: 1001\nCurrent database:\nCurrent user: root@0.0.0.0\nSSL: Cipher in use is TLS_AES_128_GCM_SHA256\nCurrent pager: stdout\nUsing outfile: ''\nUsing delimiter: ;\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne\nProtocol version: 10\nConnection: 127.0.0.1 via TCP/IP\nServer characterset: utf8mb4\nDB characterset: utf8mb4\nClient characterset: utf8mb4\nConn. characterset: utf8mb4\nTCP port: 6001\nBinary data as: Hexadecimal\n--------------\n
\u672a\u542f\u7528\u6210\u529f\uff0c\u5219\u8fd4\u56de\u7ed3\u679c\u5982\u4e0b\uff0c\u53ef\u4ee5\u770b\u5230 SSL \u72b6\u6001\u4e3a Not in use
\uff0c\u4f60\u9700\u8981\u91cd\u65b0\u68c0\u67e5\u4e00\u4e0b\u4e0a\u8ff0\u6b65\u9aa4\u4e2d\u4f60\u6240\u914d\u7f6e\u8bc1\u4e66\u53ca\u5bc6\u94a5\u6587\u4ef6\u7684\u672c\u5730\u76ee\u5f55\u8def\u5f84\uff08\u5373 \uff09\u662f\u5426\u6b63\u786e\uff1a
mysql> status;\n/usr/local/mysql/bin/mysql Ver 8.0.30 for macos12 on arm64 (MySQL Community Server - GPL)\n\nConnection id: 1009\nCurrent database: test\nCurrent user: root@0.0.0.0\nSSL: Not in use\nCurrent pager: stdout\nUsing outfile: ''\nUsing delimiter: ;\nServer version: 8.0.30-MatrixOne-v1.2.1 MatrixOne \nProtocol version: 10\nConnection: 127.0.0.1 via TCP/IP\nServer characterset: utf8mb4\nDb characterset: utf8mb4\nClient characterset: utf8mb4\nConn. characterset: utf8mb4\nTCP port: 6001\nBinary data as: Hexadecimal\n--------------\n
\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u5373\u5f00\u542f\u4e86 MatrixOne \u7684 TLS\u3002
"},{"location":"MatrixOne/Security/TLS-introduction/#mysql","title":"\u6b65\u9aa4\u4e8c\uff1a\u914d\u7f6e MySQL \u5ba2\u6237\u7aef\u53c2\u6570","text":"MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne Server \u65f6\uff0c\u9700\u8981\u901a\u8fc7 --ssl-mode
\u53c2\u6570\u6307\u5b9a\u52a0\u5bc6\u8fde\u63a5\u884c\u4e3a\uff0c\u5982\uff1a
mysql -h 127.0.0.1 -P 6001 -uroot -p111 --ssl-mode=PREFERRED\n
Info
\u4e0a\u8ff0\u4ee3\u7801\u6bb5\u4e2d\u7684\u767b\u5f55\u8d26\u53f7\u4e3a\u521d\u59cb\u8d26\u53f7\uff0c\u8bf7\u5728\u767b\u5f55 MatrixOne \u540e\u53ca\u65f6\u4fee\u6539\u521d\u59cb\u5bc6\u7801\uff0c\u53c2\u89c1\u5bc6\u7801\u7ba1\u7406\u3002
ssl mode \u53d6\u503c\u7c7b\u578b\u5982\u4e0b\uff1a
ssl-mode \u53d6\u503c \u542b\u4e49 DISABLED \u4e0d\u4f7f\u7528 SSL/TLS \u5efa\u7acb\u52a0\u5bc6\u8fde\u63a5\uff0c\u4e0e skip-ssl \u540c\u4e49\u3002 PREFERRED \u9ed8\u8ba4\u884c\u4e3a\uff0c\u4f18\u5148\u5c1d\u8bd5\u4f7f\u7528 SSL/TLS \u5efa\u7acb\u52a0\u5bc6\u8fde\u63a5\uff0c\u5982\u679c\u65e0\u6cd5\u5efa\u5219\u5c1d\u8bd5\u5efa\u7acb\u975e SSL/TLS \u8fde\u63a5\u3002 REQUIRED \u53ea\u4f1a\u5c1d\u8bd5\u4f7f\u7528 SSL/TLS \u5efa\u7acb\u52a0\u5bc6\u8fde\u63a5\uff0c\u5982\u679c\u65e0\u6cd5\u5efa\u7acb\u8fde\u63a5\uff0c\u5219\u4f1a\u8fde\u63a5\u5931\u8d25\u3002 VERIFY_CA \u4e0e REQUIRED \u884c\u4e3a\u4e00\u6837\uff0c\u5e76\u4e14\u8fd8\u4f1a\u9a8c\u8bc1 Server \u7aef\u7684 CA \u8bc1\u4e66\u662f\u5426\u6709\u6548\u3002 VERIFY_IDENTITY \u4e0e VERIFY_CA \u884c\u4e3a\u4e00\u6837\uff0c\u5e76\u4e14\u8fd8\u9a8c\u8bc1 Server \u7aef CA \u8bc1\u4e66\u4e2d\u7684 host \u662f\u5426\u4e0e\u5b9e\u9645\u8fde\u63a5\u7684 hostname \u662f\u5426\u4e00\u81f4\u3002Note
\u5ba2\u6237\u7aef\u5728\u6307\u5b9a\u4e86 --ssl-mode=VERIFY_CA
\u65f6\uff0c\u9700\u8981\u4f7f\u7528 --ssl-ca
\u6765\u6307\u5b9a CA \u8bc1\u4e66\u3002 \u5ba2\u6237\u7aef\u5728\u6307\u5b9a\u4e86 --ssl-mode=VERIFY_IDENTITY
\u65f6\uff0c\u9700\u8981\u6307\u5b9a CA \u8bc1\u4e66\uff0c\u4e14\u9700\u8981\u4f7f\u7528 --ssl-key
\u6307\u5b9a\u5ba2\u6237\u7aef\u7684\u79c1\u94a5\u548c\u4f7f\u7528 --ssl-cert
\u6307\u5b9a\u5ba2\u6237\u7aef\u7684\u8bc1\u4e66\u3002
\u672c\u6587\u6863\u5bf9 MatrixOne \u5b89\u5168\u5ba1\u8ba1\u57fa\u672c\u529f\u80fd\u8fdb\u884c\u9610\u8ff0\uff0c\u5e76\u6307\u5f15\u5982\u4f55\u5f00\u542f\u548c\u4f7f\u7528\u3002
"},{"location":"MatrixOne/Security/audit/#_2","title":"\u6982\u8ff0","text":"\u5ba1\u8ba1\u662f\u7528\u6765\u8bb0\u5f55\u6570\u636e\u5e93\u7528\u6237\u884c\u4e3a\u4ee5\u53ca\u6570\u636e\u5e93\u5185\u90e8\u91cd\u8981\u4e8b\u4ef6\u7684\u529f\u80fd\uff0c\u5b83\u8bb0\u5f55\u4e86\u6240\u6709\u7528\u6237\u5728\u767b\u5f55\u6570\u636e\u5e93\u540e\u505a\u51fa\u7684\u6240\u6709\u6570\u636e\u5e93\u64cd\u4f5c\u4ee5\u53ca\u6570\u636e\u5185\u90e8\u7684\u91cd\u5927\u4e8b\u4ef6\u3002\u4e5f\u662f\u5f88\u591a\u4f01\u4e1a\u7ea7\u6570\u636e\u5e93\u5fc5\u5907\u7684\u529f\u80fd\u4e4b\u4e00\u3002
\u5728\u65e5\u5e38\u7684\u6570\u636e\u5e93\u8fd0\u7ef4\u4e2d\uff0c\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u5e93\u7528\u6237\u7684\u6240\u6709\u884c\u4e3a\u5408\u89c4\u5408\u6cd5\uff0c\u5ba1\u8ba1\u662f\u975e\u5e38\u6709\u6548\u7684\u624b\u6bb5\u3002\u5728\u6570\u636e\u5e93\u53d1\u751f\u91cd\u8981\u4e8b\u4ef6\u65f6\uff0c\u4f8b\u5982\u542f\u505c\u3001\u8282\u70b9\u5b95\u673a\u7b49\uff0c\u5ba1\u8ba1\u5185\u5bb9\u53ef\u4ee5\u975e\u5e38\u65b9\u4fbf\u5730\u8ffd\u8e2a\u5230\u524d\u540e\u65f6\u6bb5\u7684\u6570\u636e\u5e93\u884c\u4e3a\u3002
\u5bf9\u4e8e\u91cd\u8981\u7684\u4e1a\u52a1\u4fe1\u606f\u8868\u6216\u7cfb\u7edf\u914d\u7f6e\u8868\u9700\u8981\u8fdb\u884c\u6709\u6548\u5b8c\u6574\u7684\u884c\u4e3a\u76d1\u63a7\u65f6\uff0c\u6570\u636e\u5e93\u5ba1\u8ba1\u7684\u5f00\u542f\u5341\u5206\u6709\u5fc5\u8981\u3002\u4f8b\u5982\u76d1\u63a7\u5bf9\u7528\u6237 A \u5728\u6570\u636e\u5e93\u4e2d\u6240\u6709\u884c\u4e3a\uff0c\u4ee5\u4fbf\u4e8e\u53ca\u65f6\u53d1\u73b0\u8fdd\u89c4\u7684\u6570\u636e\u4fee\u6539\u6216\u5220\u9664\u6765\u6e90\u3002\u5bf9\u4e8e\u6570\u636e\u5e93\u5185\u90e8\u91cd\u5927\u4e8b\u4ef6\u7684\u76d1\u63a7\uff0c\u53ef\u4ee5\u7b2c\u4e00\u65f6\u95f4\u6392\u67e5\u6545\u969c\uff0c\u5e76\u4e14\u8ffd\u6eaf\u4e8b\u6545\u4ea7\u751f\u7684\u6839\u672c\u539f\u56e0\u3002
MatrixOne \u652f\u6301\u5bf9\u7528\u6237\u884c\u4e3a\uff0c\u64cd\u4f5c\u65e5\u5fd7\uff0cSQL \u8bed\u53e5\u7684\u5ba1\u8ba1\u3002MatrixOne \u7684\u5ba1\u8ba1\u6570\u636e\u4fdd\u5b58\u5728\u6570\u636e\u5e93\u8868\u4e2d\uff0c\u76f4\u63a5\u901a\u8fc7 SQL \u4ea4\u4e92\u53ef\u4ee5\u67e5\u8be2\u5ba1\u8ba1\u6570\u636e\u3002
"},{"location":"MatrixOne/Security/audit/#_3","title":"\u5f00\u542f\u5ba1\u8ba1","text":"\u6267\u884c\u5982\u4e0b\u5185\u5bb9\u811a\u672c\uff0c\u5f00\u542f\u5ba1\u8ba1\u529f\u80fd\uff1a
drop database if exists mo_audits;\ncreate database mo_audits;\nuse mo_audits;\ncreate view mo_user_action as select request_at,user,host,statement,status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like '______internal_%' order by request_at desc;\ncreate view mo_events as select timestamp,level,message from system.log_info where level in ('error','panic','fatal') order by timestamp desc;\n
"},{"location":"MatrixOne/Security/audit/#_4","title":"\u5ba1\u8ba1\u67e5\u8be2","text":"\u5bf9\u7528\u6237\u884c\u4e3a\u8fdb\u884c\u5ba1\u8ba1\u65f6\uff0c\u6267\u884c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u8fdb\u884c\u67e5\u770b\uff1a
mysql> select * from mo_audits.mo_user_action;\n
\u67e5\u8be2\u793a\u4f8b\u7ed3\u679c\u5982\u4e0b\uff1a
+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| request_at | user | host | statement | status |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n| 2023-02-10 19:54:28.831970 | root | 0.0.0.0 | create view mo_user_action as select request_at, user, host, statement, status from system.statement_info where user in (select distinct user_name from mo_catalog.mo_user) and statement not like \"______internal_%\" order by request_at desc | Success |\n| 2023-02-10 19:54:14.079939 | root | 0.0.0.0 | show tables | Success |\n| 2023-02-10 19:54:14.076260 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:54:14.071728 | root | 0.0.0.0 | use mo_audits | Success |\n| 2023-02-10 19:54:14.071108 | root | 0.0.0.0 | select database() | Success |\n| 2023-02-10 19:54:01.007241 | root | 0.0.0.0 | create database mo_audits | Success |\n| 2023-02-10 19:53:48.924819 | root | 0.0.0.0 | drop database if exists mo_audits | Success |\n| 2023-02-10 19:30:59.668646 | root | 0.0.0.0 | show triggers | Success |\n| 2023-02-10 19:30:53.438212 | root | 0.0.0.0 | show locks | Success |\n| 2023-02-10 19:30:44.258894 | root | 0.0.0.0 | show index from t | Success |\n| 2023-02-10 19:30:43.662063 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a)) | Success |\n| 2023-02-10 19:30:23.104830 | root | 0.0.0.0 | show triggers | Success |\n| 2023-02-10 19:30:20.062010 | root | 0.0.0.0 | show tables | Success |\n| 2023-02-10 19:30:20.060324 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:30:20.055515 | root | 0.0.0.0 | use aab | Success |\n| 2023-02-10 19:30:20.055186 | root | 0.0.0.0 | select database() | Success |\n| 2023-02-10 19:30:17.152087 | root | 0.0.0.0 | create database aab | Success |\n| 2023-02-10 19:30:10.621294 | root | 0.0.0.0 | create aab | Failed |\n| 2023-02-10 19:29:59.983433 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:29:45.370956 | root | 0.0.0.0 | show index from t | Failed |\n| 2023-02-10 19:29:44.875580 | root | 0.0.0.0 | create table t (a int, b int, c int, primary key (a)) | Failed |\n| 2023-02-10 19:29:44.859588 | root | 0.0.0.0 | drop table if exists t | Success |\n| 2023-02-10 19:29:19.974775 | root | 0.0.0.0 | show index | Failed |\n| 2023-02-10 19:29:11.188286 | root | 0.0.0.0 | show locks | Success |\n| 2023-02-10 19:29:06.618778 | root | 0.0.0.0 | show node list | Success |\n| 2023-02-10 19:19:11.319058 | root | 0.0.0.0 | show triggers | Failed |\n| 2023-02-10 19:19:06.809302 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 19:18:52.840282 | root | 0.0.0.0 | show triggers | Failed |\n| 2023-02-10 10:54:09.892254 | root | 0.0.0.0 | show databases | Success |\n| 2023-02-10 10:54:04.468721 | root | 0.0.0.0 | select @@version_comment limit 1 | Success |\n+----------------------------+------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+\n30 rows in set (0.81 sec)\n
\u67e5\u8be2\u6570\u636e\u5e93\u5185\u90e8\u72b6\u6001\u53d8\u66f4\u67e5\u8be2\uff0c\u6267\u884c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\u8fdb\u884c\u67e5\u770b\uff1a
mysql> select * from mo_events;\n
\u67e5\u8be2\u793a\u4f8b\u7ed3\u679c\u5982\u4e0b\uff1a
|\n| 2022-10-18 15:26:20.293735 | error | error: timeout, converted to code 20429 |\n| 2022-10-18 15:26:20.293725 | error | failed to propose initial cluster info |\n| 2022-10-18 15:26:20.288695 | error | failed to set initial cluster info |\n| 2022-10-18 15:26:20.288559 | error | failed to propose initial cluster info |\n| 2022-10-18 15:26:20.285384 | error | failed to set initial cluster info |\n| 2022-10-18 15:26:20.285235 | error | failed to propose initial cluster info |\n| 2022-10-18 15:26:18.473472 | error | failed to join the gossip group, 1 error occurred:\n * Failed to join 127.0.0.1:32022: dial tcp 127.0.0.1:32022: connect: connection refused |\n| 2022-10-18 15:26:18.469029 | error | failed to join the gossip group, 1 error occurred:\n * Failed to join 127.0.0.1:32012: dial tcp 127.0.0.1:32012: connect: connection refused \n
"},{"location":"MatrixOne/Security/audit/#_5","title":"\u5173\u95ed\u5ba1\u8ba1","text":"\u6267\u884c\u4e0b\u9762\u7684 SQL \u8bed\u53e5\uff0c\u5173\u95ed\u5ba1\u8ba1\uff1a
> drop database if exists mo_audits;\n
"},{"location":"MatrixOne/Security/password-mgmt/","title":"\u5bc6\u7801\u7ba1\u7406","text":"\u4e3a\u4e86\u4fdd\u62a4\u7528\u6237\u5bc6\u7801\u7684\u5b89\u5168\uff0cMatrixOne \u652f\u6301\u5bc6\u7801\u7ba1\u7406\u80fd\u529b\uff1a
MatrixOne \u5efa\u8bae\u7528\u6237\u8bbe\u7f6e\u590d\u6742\u7684\u5bc6\u7801\uff0c\u4fdd\u8bc1\u8d26\u53f7\u5b89\u5168\u3002
\u6709\u5173\u6743\u9650\u7ea7\u522b\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53ef\u53c2\u8003 MatrixOne \u6743\u9650\u5206\u7c7b\u3002
"},{"location":"MatrixOne/Security/password-mgmt/#_4","title":"\u4fee\u6539\u5bc6\u7801\u6559\u7a0b","text":""},{"location":"MatrixOne/Security/password-mgmt/#root","title":"root \u7528\u6237\u4fee\u6539\u5bc6\u7801","text":""},{"location":"MatrixOne/Security/password-mgmt/#root_1","title":"root \u7528\u6237\u4fee\u6539\u81ea\u5df1\u7684\u5bc6\u7801","text":"\u542f\u52a8\u7684 MatrixOne \u5e76\u4f7f\u7528 root \u8d26\u53f7\u767b\u5f55\u6210\u529f\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u4fee\u6539\u5bc6\u7801\uff1a
mysql> alter user root identified by '${your password}'\n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u9000\u51fa\u5f53\u524d\u4f1a\u8bdd\uff0c\u518d\u6b21\u767b\u5f55 MatrixOne \u65b0\u5bc6\u7801\u751f\u6548\u3002
Note
\u7531\u4e8e root \u8d26\u53f7\u9ed8\u8ba4\u662f\u5177\u6709\u6700\u9ad8\u6743\u9650\u7684\u7528\u6237\uff0c\u8bf7\u4f7f\u7528\u521d\u59cb\u8d26\u53f7\u5bc6\u7801\u767b\u5f55\u540e\u53ca\u65f6\u4fee\u6539\u5bc6\u7801\u3002
"},{"location":"MatrixOne/Security/password-mgmt/#root_2","title":"root \u7528\u6237\u4fee\u6539\u79df\u6237\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER ACCOUNT
"},{"location":"MatrixOne/Security/password-mgmt/#_5","title":"\u5176\u4ed6\u7528\u6237\u4fee\u6539\u5bc6\u7801","text":""},{"location":"MatrixOne/Security/password-mgmt/#_6","title":"\u79df\u6237\u4fee\u6539\u81ea\u5df1\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER ACCOUNT
"},{"location":"MatrixOne/Security/password-mgmt/#_7","title":"\u79df\u6237\u4fee\u6539\u81ea\u5df1\u521b\u5efa\u7684\u5176\u4ed6\u7528\u6237\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER USER
"},{"location":"MatrixOne/Security/password-mgmt/#_8","title":"\u666e\u901a\u7528\u6237\u4fee\u6539\u81ea\u5df1\u7684\u5bc6\u7801","text":"\u53c2\u8003 ALTER USER
"},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/","title":"\u521b\u5efa\u79df\u6237\uff0c\u9a8c\u8bc1\u8d44\u6e90\u9694\u79bb","text":"\u521d\u59cb\u5316\u63a5\u5165 MatrixOne \u96c6\u7fa4\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u9ed8\u8ba4\u8d26\u53f7\uff0c\u5373\u96c6\u7fa4\u7ba1\u7406\u5458\u3002\u96c6\u7fa4\u7ba1\u7406\u5458\u88ab\u81ea\u52a8\u9ed8\u8ba4\u8d4b\u4e88\u7ba1\u7406\u79df\u6237\u8d26\u53f7\u7684\u6743\u9650\uff0c\u4f46\u4e0d\u80fd\u7ba1\u7406\u79df\u6237\u4e0b\u7684\u8d44\u6e90\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u8d26\u53f7\u521b\u5efa\u4e24\u4e2a\u65b0\u7684\u79df\u6237\uff0c\u5e76\u8d4b\u4e88\u79df\u6237\u7ba1\u7406\u5458\u7684\u6743\u9650\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u5b9e\u73b0\u4e86\u79df\u6237\u4e4b\u95f4\u7684\u8d44\u6e90\u9694\u79bb\u3002
"},{"location":"MatrixOne/Security/how-tos/quick-start-create-account/#_2","title":"\u524d\u63d0\u6761\u4ef6","text":"\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u7528\u6237\u540d\uff08\u9ed8\u8ba4 root\uff09\u548c\u5bc6\u7801\u767b\u5f55 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -u root -p\n
\u521b\u5efa\u65b0\u7684\u79df\u6237\uff1a
create account a1 ADMIN_NAME 'admin1' IDENTIFIED BY 'test123';\ncreate account a2 ADMIN_NAME 'admin2' IDENTIFIED BY 'test456';\n
\u4f7f\u7528 admin1 \u767b\u5f55\u79df\u6237 a1\uff0c\u5e76\u521b\u5efa\u6570\u636e\u8868 db1.t1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:admin1 -p\ncreate database db1;\ncreate table db1.t1(c1 int,c2 varchar);\ninsert into db1.t1 values (1,'shanghai'),(2,'beijing');\n
\u9a8c\u8bc1\u79df\u6237 a1 \u662f\u5426\u6210\u529f\u521b\u5efa\u8868\uff1a
mysql> select * from db1.t1;\n+------+----------+\n| c1 | c2 |\n+------+----------+\n| 1 | shanghai |\n| 2 | beijing |\n+------+----------+\n2 rows in set (0.01 sec)\n
\u4f7f\u7528 admin2 \u767b\u5f55\u79df\u6237 a2\uff1a
mysql -h 127.0.0.1 -P 6001 -u a2:admin2 -p\n
\u67e5\u770b\u79df\u6237 a1 \u4e2d\u7684 db1.t1 \u6570\u636e\uff1a
mysql> select * from db1.t1;\nERROR 1064 (HY000): SQL parser error: table \"t1\" does not exist\n
\u4e0a\u8ff0\u547d\u4ee4\u8fd0\u884c\u62a5\u9519\uff0c\u8bc1\u660e\u5728\u79df\u6237 a2 \u4e2d\uff0c\u5e76\u4e0d\u80fd\u770b\u5230\u79df\u6237 a1 \u4e2d\u7684\u6570\u636e\u5e93 db1\uff1a
\u5728\u79df\u6237 a2 \u4e2d\u4e5f\u53ef\u4ee5\u521b\u5efa\u5e93 db1 \u548c\u8868 db1.t1\uff1a
mysql> create database db1;\nQuery OK, 0 rows affected (0.03 sec)\n\nmysql> create table db1.t1(c1 int,c2 varchar);\nQuery OK, 0 rows affected (0.05 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n
\u5728\u79df\u6237 a2 \u7684 db1.t1 \u8fd9\u5f20\u8868\u5185\u63d2\u5165\u4e0e\u79df\u6237 a1 \u4e2d\u8868 db1.t1 \u4e0d\u540c\u7684\u6570\u636e\u5e76\u67e5\u770b\uff1a
mysql> insert into db1.t1 values (3,'guangzhou');\nQuery OK, 1 row affected (0.05 sec)\n\nmysql> select * from db1.t1;\n+------+-----------+\n| c1 | c2 |\n+------+-----------+\n| 3 | guangzhou |\n+------+-----------+\n1 row in set (0.01 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u5373\u4f7f\u4e0e\u79df\u6237 a1 \u4e2d\u7684\u6570\u636e\u5e93\u4e0e\u8868\u91cd\u540d\uff0c\u4f46\u662f\u8fd9\u4e24\u4e2a\u6570\u636e\u5e93\u4e0e\u8868\u4e92\u4e0d\u5e72\u6270\uff0c\u5b8c\u5168\u9694\u79bb\u3002
\u521d\u59cb\u5316\u63a5\u5165 MatrixOne \u96c6\u7fa4\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2a\u9ed8\u8ba4\u8d26\u53f7\uff0c\u5373\u96c6\u7fa4\u7ba1\u7406\u5458\u3002\u96c6\u7fa4\u7ba1\u7406\u5458\u9ed8\u8ba4\u7528\u6237\u540d\u4e3a root\uff0croot \u65e2\u662f\u96c6\u7fa4\u7ba1\u7406\u5458\uff0c\u540c\u65f6\u4e5f\u662f\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\uff0croot \u53ef\u4ee5\u521b\u5efa\u548c\u7ba1\u7406\u5176\u4ed6\u666e\u901a\u79df\u6237\uff08\u975e\u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458\uff09\u3002
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u79df\u6237\uff0c\u5e76\u5207\u6362\u81f3\u65b0\u79df\u6237\u767b\u5f55\uff0c\u7528\u65b0\u79df\u6237\u8d26\u53f7\u521b\u5efa\u7528\u6237\u3001\u521b\u5efa\u89d2\u8272\u3001\u521b\u5efa\u6743\u9650\uff0c\u5e76\u8d4b\u4e88\u7528\u6237\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/how-tos/quick-start-create-user/#_2","title":"\u524d\u63d0\u6761\u4ef6","text":"\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u7528\u6237\u540d\uff08\u9ed8\u8ba4 root\uff09\u548c\u5bc6\u7801\u767b\u5f55 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -u root -p\n
\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u79df\u6237 a1\uff0c\u7528\u6237\u540d\u548c\u5bc6\u7801\u5206\u522b\u4e3a\uff1aadmin\uff0ctest123\uff1a
create account a1 ADMIN_NAME 'admin' IDENTIFIED BY 'test123';\n
\u67e5\u770b\u96c6\u7fa4\u4e2d\u7684\u6240\u6709\u79df\u6237\u4fe1\u606f\uff08\u4ec5 root \u53ef\u67e5\u770b\uff09\uff1a
mysql> select * from mo_catalog.mo_account;\n+------------+--------------+--------+---------------------+----------------+----------------+\n| account_id | account_name | status | created_time | comments | suspended_time |\n+------------+--------------+--------+---------------------+----------------+----------------+\n| 1 | a1 | open | 2022-12-19 14:47:19 | | NULL |\n| 0 | sys | open | 2022-12-07 11:00:58 | system account | NULL |\n+------------+--------------+--------+---------------------+----------------+----------------+\n
\u4f60\u53ef\u4ee5\u91cd\u65b0\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\uff0c\u4f7f\u7528 admin \u767b\u5f55\u79df\u6237 a1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:admin -p\n
\u73b0\u5728\u4f60\u53ef\u4ee5\u4f5c\u4e3a\u79df\u6237 a1 \u67e5\u770b\u79df\u6237\u4e0b\u7684\u9ed8\u8ba4\u7528\u6237\u548c\u89d2\u8272\uff1a
mysql> select * from mo_catalog.mo_role;\n+---------+--------------+---------+-------+---------------------+----------+\n| role_id | role_name | creator | owner | created_time | comments |\n+---------+--------------+---------+-------+---------------------+----------+\n| 2 | accountadmin | 0 | 0 | 2022-12-19 14:47:20 | |\n| 1 | public | 0 | 0 | 2022-12-19 14:47:20 | |\n+---------+--------------+---------+-------+---------------------+----------+\n2 rows in set (0.01 sec)\n\nmysql> select * from mo_catalog.mo_user;\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| user_id | user_host | user_name | authentication_string | status | created_time | expired_time | login_type | creator | owner | default_role |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n| 2 | localhost | admin | test123 | unlock | 2022-12-19 14:47:20 | NULL | PASSWORD | 0 | 0 | 2 |\n+---------+-----------+-----------+-----------------------+--------+---------------------+--------------+------------+---------+-------+--------------+\n1 row in set (0.00 sec)\n
\u79df\u6237 a1 \u88ab\u521b\u5efa\u6210\u529f\u540e\u4fbf\u9ed8\u8ba4\u62e5\u6709\u4e86\u79df\u6237\u7ba1\u7406\u5458\u6743\u9650\uff0c\u6240\u4ee5\u53ef\u4ee5\u67e5\u770b\u79df\u6237 a1 \u4e0b\u7684\u7cfb\u7edf\u8868\u4fe1\u606f\u3002\u5728 mo_user \u8868\u4e2d\u53ef\u4ee5\u89c2\u5bdf\u5230\u5f53\u524d\u6709\u4e00\u4e2a\u7528\u6237\u540d\u4e3a admin \u7684\u7528\u6237\u8d26\u53f7\uff0c\u5373\u521b\u5efa\u79df\u6237\u65f6\u6307\u5b9a\u7684\uff1b\u6b64\u5916\uff0c\u8fd8\u6709 accountadmin \u548c public \u4e24\u4e2a\u9ed8\u8ba4\u89d2\u8272\uff1a
connect
\uff0c\u5373\u8fde\u63a5 MatrixOne\u3002\u6b64\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u5728\u7cfb\u7edf\u8868\u4e2d\u67e5\u770b\u5230\u8fd9\u4e9b\u9ed8\u8ba4\u89d2\u8272\u7684\u6743\u9650\u96c6\u5408\uff1a
mysql> select * from mo_catalog.mo_role_privs;\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n| role_id | role_name | obj_type | obj_id | privilege_id | privilege_name | privilege_level | operation_user_id | granted_time | with_grant_option |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n| 2 | accountadmin | account | 0 | 3 | create user | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 4 | drop user | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 5 | alter user | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 6 | create role | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 7 | drop role | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 9 | create database | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 10 | drop database | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 11 | show databases | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 12 | connect | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 13 | manage grants | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | account | 0 | 14 | account all | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 18 | show tables | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 20 | create table | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 23 | drop table | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 26 | alter table | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 21 | create view | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 24 | drop view | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 27 | alter view | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 28 | database all | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | database | 0 | 29 | database ownership | * | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 30 | select | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 31 | insert | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 32 | update | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 33 | truncate | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 34 | delete | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 35 | reference | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 36 | index | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 37 | table all | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 38 | table ownership | *.* | 0 | 2022-12-19 14:47:20 | true |\n| 2 | accountadmin | table | 0 | 41 | values | t | 0 | 2022-12-19 14:47:20 | true |\n| 1 | public | account | 0 | 12 | connect | * | 0 | 2022-12-19 14:47:20 | true |\n+---------+--------------+----------+--------+--------------+--------------------+-----------------+-------------------+---------------------+-------------------+\n
\u5728\u79df\u6237 a1 \u4e2d\uff0c\u521b\u5efa\u65b0\u7684\u7528\u6237\u548c\u89d2\u8272\uff1a
create user u1 identified by 'user123';\ncreate user u2 identified by 'user456';\ncreate role r1;\ncreate role r2;\n
\u521b\u5efa\u6570\u636e\u5e93 db1\uff0c\u5e76\u5728 db1 \u4e2d\u521b\u5efa\u8868 t1\uff1a
create database db1;\ncreate table db1.t1(c1 int,c2 varchar);\n
\u5c06 db1.t1 \u7684 select
\u6743\u9650\u6388\u4e88\u7ed9 r1\uff0cinsert
\u6743\u9650\u6388\u4e88\u7ed9 r2\uff1a
grant select on table db1.t1 to r1;\ngrant insert on table db1.t1 to r2;\n
\u5c06\u89d2\u8272 r1 \u6388\u4e88\u7ed9\u7528\u6237 u1\uff1b\u5c06\u89d2\u8272 r2 \u6388\u4e88\u7ed9\u7528\u6237 u2\uff1a
grant r1 to u1;\ngrant r2 to u2;\n
\u6b64\u65f6\uff0c\u65b0\u5efa\u7684\u7528\u6237\u3001\u89d2\u8272\u3001\u5bf9\u8c61\u6743\u9650\u5173\u7cfb\u5982\u4e0b\u56fe\u6240\u793a\uff1a
\u5206\u522b\u4f7f\u7528\u7528\u6237 u1 \u548c u2 \u767b\u5f55\u79df\u6237 a1\uff0c\u9a8c\u8bc1\u6743\u9650\u662f\u5426\u751f\u6548\u3002
\u7531\u4e8e u2 \u88ab\u6388\u4e88\u4e86 r2 \u89d2\u8272\uff0c\u4e14 r2 \u88ab\u6388\u4e88\u4e86 db1.t1 \u7684 insert
\u6743\u9650\uff0c\u6240\u4ee5 u2 \u5177\u5907 db1.t1 \u7684 insert
\u6743\u9650\uff0c\u5373\u53ef\u4ee5\u5411 db1.t1 \u63d2\u5165\u6570\u636e\uff0c
\u4f7f\u7528 u1 \u767b\u5f55 a1 \u8fdb\u884c\u9a8c\u8bc1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:u2:r2 -p\n\nmysql> insert into db1.t1 values (1,'shanghai'),(2,'beijing');\nQuery OK, 2 rows affected (0.04 sec)\n\nmysql> select * from db1.t1;\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n
u2 \u53ef\u4ee5\u6210\u529f\u5411\u8868 db1.t1 \u63d2\u5165\u6570\u636e\uff0c\u4f46\u65e0\u6cd5\u67e5\u770b db1.t1 \u8868\u91cc\u7684\u6570\u636e\u3002
\u540c\u6837\u7684\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 u1 \u767b\u5f55 a1 \u8fdb\u884c\u6743\u9650\u9a8c\u8bc1\uff1a
mysql -h 127.0.0.1 -P 6001 -u a1:u1:r1 -p\n\nmysql> select * from db1.t1;\n+------+----------+\n| c1 | c2 |\n+------+----------+\n| 1 | shanghai |\n| 2 | beijing |\n+------+----------+\n2 rows in set (0.01 sec)\n\nmysql> insert into db1.t1 values (3,'guangzhou');\nERROR 20101 (HY000): internal error: do not have privilege to execute the statement\n
\u5982\u4e0a\u8ff0\u4ee3\u7801\u6240\u793a\uff0cu1 \u53ef\u4ee5\u6210\u529f\u7684\u67e5\u8be2\u8868 db1.t1 \u7684\u6570\u636e\uff0c\u4f46\u4e0d\u80fd\u5411\u5176\u63d2\u5165\u6570\u636e\u3002
Note
\u4e0a\u8ff0\u64cd\u4f5c\u6b65\u9aa4\u4e2d\uff0c\u66f4\u591a\u6709\u5173\u67e5\u770b\u7684\u7cfb\u7edf\u8868\u4fe1\u606f\uff0c\u53c2\u89c1 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868
"},{"location":"MatrixOne/Security/how-tos/user-guide/","title":"\u6743\u9650\u7ba1\u7406\u64cd\u4f5c\u6982\u8ff0","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_2","title":"\u7ba1\u7406\u79df\u6237","text":"\u6709\u5173 root \u8d26\u53f7\u5bf9\u5e94\u7684\u89d2\u8272\u548c\u6743\u9650\u5982\u4e0b\u8868\u6240\u793a\uff1a
\u7528\u6237\u540d \u89e3\u91ca \u6240\u62e5\u6709\u7684\u89d2\u8272 \u6240\u62e5\u6709\u7684\u6743\u9650 \u63cf\u8ff0 root \u96c6\u7fa4\u7ba1\u7406\u5458 MOADMIN \u521b\u5efa\u3001\u7f16\u8f91\u3001\u5220\u9664\u79df\u6237 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 root \u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458 MOADMIN \u7ba1\u7406\u7cfb\u7edf\u79df\u6237\u4e0b\u7684\u6240\u6709\u8d44\u6e90\uff0c\u5305\u542b\u7528\u6237\u3001\u89d2\u8272\u3001\u6570\u636e\u5e93/\u8868/\u89c6\u56fe\uff0c\u6388\u6743\u7ba1\u7406 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88"},{"location":"MatrixOne/Security/how-tos/user-guide/#_3","title":"\u521b\u5efa\u79df\u6237","text":"SQL \u8bed\u6cd5
create account <account_name> admin_name='<user_name>' identified by '<password>';\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca account_name \u65b0\u5efa\u79df\u6237\u7684\u540d\u79f0 user_name \u65b0\u5efa\u79df\u6237\u7684\u7ba1\u7406\u5458\u7528\u6237\u540d\uff0c\u5176\u4f1a\u88ab\u81ea\u52a8\u6388\u4e88\u79df\u6237\u7684\u6700\u9ad8\u6743\u9650\u89d2\u8272\uff0c\u5373ACCOUNTADMIN
password \u65b0\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u5bc6\u7801 \u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE ACCOUNT\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_4","title":"\u67e5\u770b\u79df\u6237","text":"SQL \u8bed\u6cd5
select * from mo_catalog.mo_account;\n
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_5","title":"\u5220\u9664\u79df\u6237","text":"SQL \u8bed\u6cd5
drop account if exists account_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca account_name \u9700\u8981\u5220\u9664\u7684\u79df\u6237\u540d\u79f0Note
\u5220\u9664\u79df\u6237\u540e\u5219\u65e0\u6cd5\u6062\u590d\uff0c\u5305\u62ec\u79df\u6237\u8d26\u53f7\u4e0b\u7684\u6240\u6709\u6570\u636e\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 DROP ACCOUNT\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_6","title":"\u7ba1\u7406\u7528\u6237","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_7","title":"\u521b\u5efa\u7528\u6237","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 CREATE USER
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5728\u5f53\u524d\u79df\u6237\u4e2d\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002
SQL \u8bed\u6cd5
create user <user_name> identified by '<password>';\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca user_name \u65b0\u5efa\u7528\u6237\u7684\u540d\u79f0 password \u65b0\u5efa\u7684\u7528\u6237\u5bc6\u7801\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE USER\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_8","title":"\u67e5\u770b\u7528\u6237","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709\u67e5\u770b\u7528\u6237\u7684\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u67e5\u770b\u5f53\u524d\u79df\u6237\u4e0b\u6240\u6709\u7684\u7528\u6237\u3002
SQL \u8bed\u6cd5
select * from mo_catalog.mo_user;\n
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_9","title":"\u5220\u9664\u7528\u6237","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 DROP USER
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5220\u9664\u5f53\u524d\u79df\u6237\u4e0b\u7684\u6307\u5b9a\u7684\u7528\u6237\u3002
SQL \u8bed\u6cd5
drop user if exist <user_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca user_name \u65b0\u5efa\u7528\u6237\u7684\u540d\u79f0Note
\u5220\u9664\u7528\u6237\u65f6\uff0c\u9700\u8981\u5148\u505c\u6b62\u7528\u6237\u5f53\u524d\u5b58\u5728\u7684\u4f1a\u8bdd\uff0c\u5426\u5219\u5220\u9664\u5931\u8d25\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 DROP USER\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_10","title":"\u7ba1\u7406\u89d2\u8272","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_11","title":"\u521b\u5efa\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 CREATE ROLE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5728\u5f53\u524d\u79df\u6237\u4e0b\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u89d2\u8272\u3002
SQL \u8bed\u6cd5
create role <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u65b0\u5efa\u89d2\u8272\u7684\u540d\u79f0\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 CREATE ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_12","title":"\u67e5\u770b\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709\u67e5\u770b\u89d2\u8272\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u67e5\u770b\u5f53\u524d\u79df\u6237\u4e0b\u6240\u6709\u7684\u89d2\u8272\u3002
SQL \u8bed\u6cd5
select * from mo_catalog.mo_role;\n
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_13","title":"\u5207\u6362\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 SET ROLE
\u6743\u9650\u3002\u9ed8\u8ba4\u6240\u6709\u7528\u6237\u90fd\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5728\u79df\u6237\u4e2d\u5207\u6362\u7528\u6237\u7684\u89d2\u8272\uff0c\u83b7\u53d6\u5176\u4ed6\u89d2\u8272\u7684\u6743\u9650\uff0c\u4ee5\u4fbf\u6267\u884c\u76f8\u5e94\u7684 SQL\u3002
SQL \u8bed\u6cd5
set role <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u89d2\u8272\u7684\u540d\u79f0\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 SET ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_14","title":"\u5220\u9664\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 DROP ROLE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5220\u9664\u5f53\u524d\u79df\u6237\u4e0b\u7684\u7279\u5b9a\u89d2\u8272\u3002
SQL \u8bed\u6cd5
drop role if exists <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u9700\u8981\u5220\u9664\u7684\u89d2\u8272\u7684\u540d\u79f0Note
\u5220\u9664\u67d0\u4e2a\u6307\u5b9a\u89d2\u8272\u65f6\uff0c\u4f1a\u540c\u65f6\u56de\u6536\u5df2\u7ecf\u88ab\u6388\u6743\u7684\u7528\u6237\u7684\u89d2\u8272\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 DROP ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_15","title":"\u7ba1\u7406\u6743\u9650","text":""},{"location":"MatrixOne/Security/how-tos/user-guide/#_16","title":"\u5411\u89d2\u8272\u6388\u4e88\u67d0\u4e2a\u5bf9\u8c61\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5411\u67d0\u4e2a\u89d2\u8272\u6388\u4e88\u67d0\u4e2a\u5bf9\u8c61\u7684\u67d0\u4e2a\u6743\u9650\u3002
SQL \u8bed\u6cd5
grant <privilege> on <object_type> <object_name> to <role_name>\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca privilege \u6743\u9650 object_type \u5bf9\u8c61\u7c7b\u578b object_name \u5bf9\u8c61\u540d\u79f0 role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT PRIVILEGES\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_17","title":"\u5411\u89d2\u8272\u6388\u4e88\u67d0\u7c7b\u5bf9\u8c61\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5411\u89d2\u8272\u6388\u4e88\u6240\u6709\u6570\u636e\u5e93/\u6570\u636e\u8868\u7684\u67d0\u4e2a\u6743\u9650\u3002
SQL \u8bed\u6cd5
grant <privilege> on database * to <role_name>;\ngrant <privilege> on table *.* to <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca privilege \u6743\u9650\u540d\u79f0 role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272\u540d\u79f0Note
\u8be5\u64cd\u4f5c\u867d\u7136\u5728\u6388\u6743\u591a\u4e2a\u76f8\u540c\u7c7b\u522b\u5bf9\u8c61\u65f6\u6bd4\u8f83\u7b80\u4fbf\uff0c\u4f46\u4e5f\u5f88\u5bb9\u6613\u53d1\u751f\u6743\u9650\u6cc4\u6f0f\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT PRIVILEGES\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_18","title":"\u5411\u7528\u6237\u6388\u4e88\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5411\u67d0\u4e2a\u7528\u6237\u6388\u4e88\u67d0\u4e2a\u89d2\u8272\u3002
SQL \u8bed\u6cd5
grant <role_name> to <user_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272 user_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u7528\u6237\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_19","title":"\u8ba9\u4e00\u4e2a\u89d2\u8272\u7ee7\u627f\u53e6\u4e00\u4e2a\u89d2\u8272\u7684\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 MANAGE GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u8ba9 role_b \u7ee7\u627f role_a \u7684\u6240\u6709\u6743\u9650\u3002
SQL \u8bed\u6cd5
grant <role_a> to <role_b>;\n
Note
\u8be5\u6743\u9650\u7ee7\u627f\u4e3a\u52a8\u6001\u7ee7\u627f\uff0c\u82e5 role_a \u7684\u6743\u9650\u53d1\u751f\u6539\u53d8\uff0c\u5219 role_b \u6240\u7ee7\u627f\u7684\u6743\u9650\u4e5f\u4f1a\u52a8\u6001\u66f4\u6539\u3002MatrixOne \u4e0d\u5141\u8bb8\u89d2\u8272\u73af\u7ee7\u627f\uff0c\u5373 role1 \u7ee7\u627f role2\uff0crole2 \u7ee7\u627f role3\uff0c\u4f46\u662f role3 \u7ee7\u627f\u4e0d\u80fd\u7ee7\u627f role1\u3002
\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 GRANT ROLE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_20","title":"\u67e5\u770b\u67d0\u4e00\u7528\u6237\u6240\u62e5\u6709\u7684\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 SHOW GRANTS
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u67e5\u770b\u6240\u6307\u5b9a\u7528\u6237\u5f53\u524d\u6240\u62e5\u6709\u7684\u5168\u90e8\u6743\u9650\u3002
SQL \u8bed\u6cd5
show grants for <user_name>@<localhost>\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca user_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u7528\u6237\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 SHOW GRANTS\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_21","title":"\u56de\u6536\u6388\u6743\u7528\u6237\u7684\u67d0\u4e2a\u89d2\u8272","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 REVOKE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u5c06\u67d0\u4e00\u7528\u6237\u7684\u67d0\u4e00\u89d2\u8272\u79fb\u9664\u3002
SQL \u8bed\u6cd5
revoke <role_name> from <user_name>\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272 user_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u7528\u6237\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 REVOKE\u3002
"},{"location":"MatrixOne/Security/how-tos/user-guide/#_22","title":"\u56de\u6536\u89d2\u8272\u4e2d\u7684\u67d0\u4e2a\u5bf9\u8c61\u6743\u9650","text":"\u524d\u63d0\u6761\u4ef6\uff1a\u62e5\u6709 REVOKE
\u6743\u9650\u3002
\u00b7 \u9ed8\u8ba4\u62e5\u6709\u8fd9\u4e2a\u6743\u9650\u7684\u89d2\u8272\u4e3a MOADMIN \u6216 ACCOUNTADMIN\uff1a\u96c6\u7fa4\u7ba1\u7406\u5458\uff08\u9ed8\u8ba4\u8d26\u6237\u4e3a root\uff09\u548c\u7531\u96c6\u7fa4\u7ba1\u7406\u5458\u521b\u5efa\u7684\u79df\u6237\u7ba1\u7406\u5458\u9ed8\u8ba4\u62e5\u6709\u6743\u9650\u3002
\u64cd\u4f5c\u8bf4\u660e\uff1a\u56de\u6536\u89d2\u8272\u4e2d\u7684\u67d0\u4e2a\u5bf9\u8c61\u6743\u9650\u3002
SQL \u8bed\u6cd5
revoke <privilege> on <object_type> <object_name> to <role_name>;\n
\u53c2\u6570\u89e3\u91ca
\u53c2\u6570 \u53c2\u6570\u89e3\u91ca privilege \u6743\u9650\u540d\u79f0 object_type \u5bf9\u8c61\u7c7b\u578b object_name \u5bf9\u8c61\u540d\u79f0 role_name \u88ab\u8d4b\u4e88\u6743\u9650\u7684\u89d2\u8272\u66f4\u591a\u4fe1\u606f\uff0c\u53c2\u89c1 REVOKE\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/","title":"\u6743\u9650\u7ba1\u7406\u6982\u8ff0","text":""},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#matrixone","title":"MatrixOne \u6743\u9650\u7ba1\u7406\u6982\u8ff0","text":"MatrixOne \u6743\u9650\u7ba1\u7406\u5e2e\u52a9\u4f60\u7ba1\u7406\u79df\u6237\u3001\u7528\u6237\u5e10\u53f7\u751f\u547d\u5468\u671f\uff0c\u5206\u914d\u7ed9\u7528\u6237\u76f8\u5e94\u7684\u89d2\u8272\uff0c\u63a7\u5236 MatrixOne \u4e2d\u8d44\u6e90\u7684\u8bbf\u95ee\u6743\u9650\u3002\u5f53\u6570\u636e\u5e93\u6216\u96c6\u7fa4\u5355\u4f4d\u4e2d\u5b58\u5728\u591a\u4e2a\u7528\u6237\u65f6\uff0c\u6743\u9650\u7ba1\u7406\u786e\u4fdd\u7528\u6237\u53ea\u8bbf\u95ee\u5df2\u88ab\u6388\u6743\u7684\u8d44\u6e90\uff0c\u8d4b\u4e88\u7528\u6237\u6700\u5c11\u6743\u9650\u539f\u5219\u53ef\u964d\u4f4e\u4f01\u4e1a\u4fe1\u606f\u5b89\u5168\u98ce\u9669\u3002 MatrixOne \u4e5f\u53ef\u4ee5\u901a\u8fc7\u6743\u9650\u7ba1\u7406\u5b9e\u73b0\u591a\u79df\u6237\u65b9\u6848\u3002\u5728 MatrixOne \u4e2d\uff0c\u6bcf\u4e2a\u79df\u6237\u5728\u96c6\u7fa4\u4e2d\u6240\u62e5\u6709\u7684\u6570\u636e\u6216\u8d44\u6e90\u88ab\u5b89\u5168\u7684\u9694\u79bb\uff0c\u8de8\u96c6\u7fa4\u5355\u4f4d\u7684\u7528\u6237\u4e0d\u53ef\u8bbf\u95ee\u5176\u4ed6\u96c6\u7fa4\u5355\u4f4d\u7684\u8d44\u6e90\uff0c\u5728\u8be5\u96c6\u7fa4\u4e2d\u88ab\u8d4b\u6743\u8bbf\u95ee\u8d44\u6e90\u7684\u7528\u6237\u624d\u6709\u6743\u8bbf\u95ee\u672c\u96c6\u7fa4\u5355\u4f4d\u5185\u7684\u8d44\u6e90\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#matrixone_1","title":"MatrixOne \u6743\u9650\u7ba1\u7406\u7279\u6027","text":"MatrixOne \u7684\u6743\u9650\u7ba1\u7406\u662f\u7ed3\u5408\u4e86\u57fa\u4e8e\u89d2\u8272\u7684\u8bbf\u95ee\u63a7\u5236 (RBAC\uff0cRole-based access control) \u548c\u81ea\u4e3b\u8bbf\u95ee\u63a7\u5236 (DAC\uff0cDiscretionary access control) \u4e24\u79cd\u5b89\u5168\u6a21\u578b\u8bbe\u8ba1\u548c\u5b9e\u73b0\u7684\uff0c\u8fd9\u4e24\u79cd\u5b89\u5168\u6a21\u578b\u662f\u4e2d\u7acb\u7684\u8bbf\u95ee\u63a7\u5236\u673a\u5236\uff0c\u4e3b\u8981\u56f4\u7ed5\u89d2\u8272\u548c\u6743\u9650\u6388\u6743\u7b56\u7565\u3002\u5b83\u65e2\u4fdd\u8bc1\u4e86\u6570\u636e\u8bbf\u95ee\u7684\u5b89\u5168\u6027\uff0c\u53c8\u7ed9\u6570\u636e\u5e93\u8fd0\u7ef4\u4eba\u5458\u63d0\u4f9b\u4e86\u7075\u6d3b\u4e14\u4fbf\u6377\u7684\u7ba1\u7406\u65b9\u6cd5\u3002
\u5728 MatrixOne \u4e2d\uff0c\u4e3a\u4e86\u65b9\u4fbf\u7ba1\u7406\u591a\u79cd\u64cd\u4f5c\u6743\u9650\uff0c\u4e8e\u662f\u4fbf\u628a\u6743\u9650\u5c01\u88c5\u5728\u4e00\u4e2a\u5b9e\u4f53\u5185\uff0c\u8fd9\u4e2a\u5b9e\u4f53\u5c31\u662f\u5bf9\u8c61\u3002
\u4f8b\u5982\uff0cSelect
\uff0cInsert
\uff0cUpdate
\u7b49\u64cd\u4f5c\u6743\u9650\uff0c\u4fbf\u5c01\u88c5\u5728\u4e86 Table \u5bf9\u8c61\u5185\u3002\u66f4\u591a\u5173\u4e8e\u5bf9\u8c61\u6743\u9650\u7684\u4fe1\u606f\u8bf7\u53c2\u8003 MatrixOne \u6743\u9650\u5206\u7c7b\u3002
\u5982\u4e0b\u56fe\u4e2d\u6240\u793a\uff0c\u4ece\u4e0a\u4e4b\u4e0b\uff0c\u9ad8\u5c42\u7ea7\u5bf9\u8c61\u53ef\u4ee5\u521b\u5efa\uff08\u6216\u5220\u9664\uff09\u4f4e\u5c42\u7ea7\u5bf9\u8c61\u3002
\u4e0a\u56fe\u4e2d\u7684\u5c42\u7ea7\u5173\u7cfb\u5747\u4e3a 1\uff1an \u7684\u5173\u7cfb\uff0c\u5373\uff0c\u4e00\u4e2a\u96c6\u7fa4\u4e2d\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u79df\u6237\uff08Account\uff09\uff0c\u4e00\u4e2a\u79df\u6237\u4e0b\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u7528\u6237\u548c\u89d2\u8272\uff0c\u4e00\u4e2a\u6570\u636e\u5e93\u4e2d\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u8868\u548c\u89c6\u56fe\u3002
\u5728 MatrixOne \u4e2d\uff0c\u5c3d\u7ba1\u6bcf\u4e2a\u5bf9\u8c61\u4e2d\u7684\u64cd\u4f5c\u6743\u9650\u662f\u76f8\u4e92\u72ec\u7acb\u7684\uff08\u4f8b\u5982 Database \u5bf9\u8c61\u4e2d\u7684 SHOW TABLES
\u6743\u9650\u548c Table \u5bf9\u8c61\u4e2d\u7684 SELECT
\u6743\u9650\u5e76\u6ca1\u6709\u76f4\u63a5\u5173\u7cfb\uff09\uff0c\u4f46\u5bf9\u8c61\u4e4b\u95f4\u7684\u521b\u5efa\u4ecd\u5177\u6709\u4e00\u5b9a\u5173\u8054\uff0c\u4f8b\u5982 Database \u5bf9\u8c61\u4e2d\u7684 CREAT TABLE
\u6743\u9650\u53ef\u4ee5\u521b\u5efa Table \u5bf9\u8c61\uff0c\u8fd9\u4fbf\u5f62\u6210\u4e86\u5bf9\u8c61\u4e4b\u95f4\u7684\u5c42\u7ea7\u5173\u7cfb\uff0c
\u90a3\u4e48\uff0c\u7531\u4e8e\u9ad8\u5c42\u7ea7\u5bf9\u8c61\u53ef\u4ee5\u521b\u5efa\u4f4e\u5c42\u7ea7\u5bf9\u8c61\uff0c\u90a3\u4e48\u8f83\u9ad8\u5c42\u7ea7\u7684\u5bf9\u8c61\u5c31\u662f\u5bf9\u8c61\u7684\u521b\u5efa\u8005 (Owner)\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#owner","title":"\u5bf9\u8c61\u7684\u521b\u5efa\u8005\uff08Owner\uff09","text":"\u5f53\u4e00\u4e2a\u5bf9\u8c61\u88ab\u521b\u5efa\u540e\uff0c\u521b\u5efa\u8005\u4fbf\u662f\u8fd9\u4e2a\u5bf9\u8c61\u7684 Owner\uff0c\u5b83\u5177\u6709\u7ba1\u7406\u8fd9\u4e2a\u5bf9\u8c61\u7684\u6700\u9ad8\u6743\u9650\uff08\u5373 Ownership \u6743\u9650\uff0c\u5b83\u662f\u5bf9\u8c61\u5185\u6240\u5c01\u88c5\u7684\u6240\u6709\u6743\u9650\uff09\uff0c\u90a3\u4e48 Owner \u7684\u64cd\u4f5c\u6743\u9650\u96c6\u5408\u4e86\u8be5\u5bf9\u8c61\u7684\u6240\u6709\u64cd\u4f5c\u6743\u9650\u3002
\u4f8b\u5982 Table \u5bf9\u8c61\u6709 Select
\uff0cInsert
\uff0cUpdate
\uff0cDelete
\uff0cTruncate
\uff0cOwnership
\u6743\u9650\uff0c\u5982\u679c\u4e00\u4e2a\u89d2\u8272\u62e5\u6709\u4e86\u67d0\u4e2a Table \u7684 Ownership \u6743\u9650\uff0c\u90a3\u4e48\u8be5\u89d2\u8272\u7b49\u540c\u4e8e\u62e5\u6709\u4e86 Select
\uff0cInsert
\uff0cUpdate
\uff0cDelete
\uff0cTruncate
\u6743\u9650\u3002
\u7531\u4e8e\u6743\u9650\u3001\u89d2\u8272\u548c\u7528\u6237\u4e4b\u95f4\u7684\u4f20\u9012\u6027\uff0c\u4f60\u53ef\u4ee5\u628a\u5bf9\u8c61\u7684\u521b\u5efa\u8005\uff08\u4ee5\u4e0b\u79f0\u4e3a\u5bf9\u8c61 Owner\uff09\u7406\u89e3\u4e3a\u4e00\u4e2a\u89d2\u8272\u3002
\u5982\u4f55\u7406\u89e3\u5bf9\u8c61\u7684\u521b\u5efa\u8005\u662f\u4e00\u4e2a\u89d2\u8272\u5462\uff1f
\u4e00\u4e2a\u7528\u6237\u53ef\u4ee5\u540c\u65f6\u62e5\u6709\u591a\u4e2a\u89d2\u8272\uff0c\u6bd4\u5982 User A \u62e5\u6709 Role 1 \u548c Role 2\uff0c\u8fd8\u6709 Role 3 \u8fd9\u4e09\u4e2a\u89d2\u8272\uff0c\u6bcf\u4e2a\u89d2\u8272\u62e5\u6709\u7684\u6743\u9650\u4e0d\u540c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0c\u5e2e\u52a9\u4f60\u5feb\u901f\u7406\u89e3\u8fd9\u4e00\u884c\u4e3a\uff1a
\u5047\u5982 User A \u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u89d2\u8272\u4e3a Role 1\uff0cUser A \u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7528\u6237 New user B\uff0c\u53ef\u662f\u5f53\u524d Role 1 \u8fd9\u4e2a\u89d2\u8272\u6ca1\u6709\u521b\u5efa\u65b0\u7528\u6237\u7684\u6743\u9650\uff0cRole 2 \u62e5\u6709\u521b\u5efa\u65b0\u7528\u6237\u7684\u6743\u9650\uff0c\u90a3\u4e48 User A \u9700\u8981\u5207\u6362\u5230 Role 2 \u8fd9\u4e2a\u89d2\u8272\uff0c\u7136\u540e\u518d\u521b\u5efa\u65b0\u7684\u7528\u6237\u3002\u90a3\u4e48\uff0cNew user B \u7684 Owner \u662f Role 2\uff0c\u5176\u4ed6\u89d2\u8272 Role 1 \u548c Role 3 \u5e76\u4e0d\u80fd\u62e5\u6709 New user B \u7684\u6240\u6709\u6743\u3002
\u5bf9\u8c61\u7684 Owner \u8981\u70b9
\u5bf9\u8c61\u7684 Owner \u662f\u4e00\u4e2a\u89d2\u8272\uff0c\u5bf9\u8c61\u6700\u521d\u7684 Owner \u662f\u521b\u5efa\u5b83\u7684\u89d2\u8272\u3002
\u4e00\u4e2a\u5bf9\u8c61\u7684 Owner \u5728\u4efb\u610f\u65f6\u523b\u6709\u4e14\u53ea\u6709\u4e00\u4e2a\u3002
\u4e00\u4e2a\u89d2\u8272\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u5bf9\u8c61\uff0c\u56e0\u6b64\u4e00\u4e2a\u89d2\u8272\u53ef\u4ee5\u662f\u591a\u4e2a\u5bf9\u8c61\u7684 Owner\u3002
\u89d2\u8272\u672c\u8eab\u4e5f\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u56e0\u6b64\u89d2\u8272\u4e5f\u6709 Owner\u3002
\u5f53\u5bf9\u8c61\u7684 Owner \u88ab\u5220\u9664\u65f6\uff0c\u8be5\u5bf9\u8c61\u7684 Owner \u4f1a\u81ea\u52a8\u53d8\u66f4\u4e3a\u88ab\u5220\u9664\u89d2\u8272\u7684 Owner\u3002
Owner \u53ef\u4ee5\u8f6c\u79fb\u7ed9\u53e6\u4e00\u4e2a\u89d2\u8272\u3002
Note: ACCOUNTADMIN (\u79df\u6237\u7ba1\u7406\u5458\u89d2\u8272\uff0c\u79df\u6237\u88ab\u521b\u5efa\u540e\u5373\u81ea\u52a8\u751f\u6210) \u867d\u7136\u4e0d\u662f\u79df\u6237\u5185\u6240\u7528\u5bf9\u8c61\u7684 Owner\uff0c\u4f46\u5b83\u62e5\u6709\u6240\u6709\u5bf9\u8c61\u7684 Ownership \u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_5","title":"\u96c6\u7fa4","text":"\u96c6\u7fa4\u662f MatrixOne \u6743\u9650\u7ba1\u7406\u4e2d\u6700\u9ad8\u5c42\u7ea7\u7684\u5bf9\u8c61\uff0c\u5f53\u90e8\u7f72\u5b8c MatrixOne \u540e\u4fbf\u521b\u5efa\u4e86\u96c6\u7fa4\u8fd9\u4e2a\u5bf9\u8c61\u3002
Tip: \u5bf9\u96c6\u7fa4\u5bf9\u8c61\u7684\u64cd\u4f5c\u6743\u9650\u7684\u96c6\u5408\u88ab\u79f0\u4e3a\u7cfb\u7edf\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_6","title":"\u79df\u6237","text":"MatrixOne \u96c6\u7fa4\u5185\u53ef\u4ee5\u521b\u5efa\u548c\u7ba1\u7406\u591a\u4e2a\u6570\u636e\u548c\u7528\u6237\u6743\u9650\u4f53\u7cfb\u5b8c\u5168\u9694\u79bb\u7684\u79df\u6237\uff0c\u5e76\u5bf9\u8fd9\u4e9b\u8d44\u6e90\u9694\u79bb\u7684\u79df\u6237\u8fdb\u884c\u7ba1\u7406\uff0c\u8fd9\u79cd\u591a\u79df\u6237\u529f\u80fd\u65e2\u8282\u7701\u4e86\u90e8\u7f72\u548c\u8fd0\u7ef4\u591a\u5957\u6570\u636e\u4e1a\u52a1\u7cfb\u7edf\u7684\u6210\u672c\uff0c\u53c8\u80fd\u5229\u7528\u79df\u6237\u95f4\u7684\u786c\u4ef6\u8d44\u6e90\u5171\u4eab\u6700\u5927\u9650\u5ea6\u7684\u8282\u7ea6\u673a\u5668\u6210\u672c\u3002
\u5728 MatrixOne \u4e2d\u5c06\u79df\u6237\u79f0\u4e3a Account\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_7","title":"\u7cfb\u7edf\u79df\u6237","text":"\u4e3a\u4e86\u517c\u5bb9\u4f20\u7edf\u975e\u591a\u79df\u6237\u6570\u636e\u5e93\u7684\u4f7f\u7528\u4e60\u60ef\uff0cMatrixOne \u5728\u96c6\u7fa4\u521b\u5efa\u5b8c\u6210\u540e\u4f1a\u81ea\u52a8\u65b0\u5efa\u4e00\u4e2a\u7cfb\u7edf\u9ed8\u8ba4\u79df\u6237\uff0c\u4e5f\u5c31\u662f\u7cfb\u7edf\u79df\u6237\uff0c\u5373 Sys Account\uff0c\u5982\u679c\u4f60\u73b0\u5728\u53ea\u6709\u4e00\u5957\u6570\u636e\u4e1a\u52a1\u7cfb\u7edf\u9700\u8981 MatrixOne \u7ba1\u7406\uff0c\u4fbf\u4e0d\u9700\u8981\u521b\u5efa\u66f4\u591a\u7684\u79df\u6237\uff0c\u76f4\u63a5\u767b\u5f55\u5e76\u8bbf\u95ee\u7cfb\u7edf\u79df\u6237 (Sys Account) \u5373\u53ef\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_8","title":"\u89d2\u8272","text":"\u89d2\u8272\u4e5f\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5b83\u662f MatrixOne \u4e2d\u7528\u6765\u7ba1\u7406\u548c\u5206\u914d\u6743\u9650\u7684\u5bf9\u8c61\u3002
\u5728\u79df\u6237\u4e2d\uff0c\u7528\u6237\u5982\u679c\u6ca1\u6709\u88ab\u8d4b\u4e88\u89d2\u8272\uff0c\u90a3\u4e48\u7528\u6237\u5c31\u4e0d\u80fd\u505a\u4efb\u4f55\u64cd\u4f5c\u3002\u9996\u5148\uff0c\u9700\u8981\u5148\u6709\u4e00\u4e2a\u9ad8\u6743\u9650\u7684\u8d26\u53f7\u5148\u505a\u4e00\u4e9b\u521d\u671f\u7684\u8d44\u6e90\u5206\u914d\uff0c\u6bd4\u5982\u8bf4\uff0c\u7531\u7cfb\u7edf\u79df\u6237\u6216\u8005\u79df\u6237\u521b\u5efa\u4e00\u4e9b\u89d2\u8272\u548c\u7528\u6237\uff0c\u5c06\u5bf9\u8c61\u6743\u9650\u6388\u4e88\u7ed9\u89d2\u8272\uff0c\u518d\u5c06\u89d2\u8272\u8d4b\u4e88\u7ed9\u7528\u6237\uff0c\u8fd9\u4e2a\u65f6\u5019\uff0c\u7528\u6237\u5c31\u53ef\u4ee5\u5bf9\u5bf9\u8c61\u8fdb\u884c\u64cd\u4f5c\u4e86\u3002
\u8bbe\u7acb\u89d2\u8272\uff0c\u662f\u4e3a\u4e86\u8282\u7701\u76f8\u540c\u6743\u9650\u6388\u4e88\u7684\u64cd\u4f5c\u6210\u672c\u3002p1\uff0cp2\uff0cp3 \u8fd9\u4e09\u4e2a\u6743\u9650\u90fd\u9700\u8981\u88ab\u6388\u4e88\u7ed9\u7528\u6237 u1\uff0cu2\uff0cu3\uff0c\u4f60\u53ea\u9700\u8981\u5148\u5c06 p1\uff0cp2\uff0cp3 \u6388\u4e88\u89d2\u8272 r1\uff0c\u518d\u5c06\u89d2\u8272 r1 \u4e00\u6b21\u6027\u6388\u4e88\u7528\u6237 u1\uff0cu2\uff0cu3\uff0c\u76f8\u6bd4\u628a\u6bcf\u4e2a\u6743\u9650\u90fd\u5206\u522b\u6388\u4e88\u6bcf\u4e2a\u7528\u6237\u6765\u8bf4\uff0c\u64cd\u4f5c\u4e0a\u66f4\u4e3a\u7b80\u5355\uff0c\u5e76\u4e14\u968f\u7740\u7528\u6237\u548c\u6743\u9650\u6570\u76ee\u7684\u589e\u52a0\uff0c\u8fd9\u4e00\u4f18\u52bf\u4f1a\u8d8a\u53d1\u660e\u663e\u3002\u540c\u65f6\uff0c\u89d2\u8272\u7684\u51fa\u73b0\u8fdb\u4e00\u6b65\u62bd\u8c61\u4e86\u6743\u9650\u96c6\u5408\u53ca\u5176\u5173\u7cfb\uff0c\u5bf9\u4e8e\u540e\u671f\u7684\u6743\u9650\u7ef4\u62a4\u4e5f\u5341\u5206\u65b9\u4fbf\u3002
MatrixOne \u5728\u96c6\u7fa4\u548c\u79df\u6237 (Account) \u521b\u5efa\u540e\uff0c\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e9b\u9ed8\u8ba4\u89d2\u8272\u548c\u7528\u6237\uff08\u8be6\u89c1\u4e0b\u9762\u7684\u521d\u59cb\u5316\u8bbf\u95ee\u7ae0\u8282\uff09\uff0c\u8fd9\u4e9b\u89d2\u8272\u5177\u6709\u6700\u9ad8\u7ba1\u7406\u6743\u9650\uff0c\u7528\u4e8e\u5728\u6700\u5f00\u59cb\u7ba1\u7406\u96c6\u7fa4\u548c\u79df\u6237 (Account)\uff0c\u6211\u4eec\u4e0d\u5efa\u8bae\u60a8\u5c06\u8fd9\u4e9b\u89d2\u8272\u6388\u4e88\u65e5\u5e38\u6267\u884c SQL \u7684\u7528\u6237\uff0c\u6743\u9650\u8fc7\u9ad8\u4f1a\u5f15\u5165\u66f4\u591a\u7684\u5b89\u5168\u95ee\u9898\uff0c\u56e0\u6b64\uff0cMatrixOne \u652f\u6301\u521b\u5efa\u81ea\u5b9a\u4e49\u89d2\u8272\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u7528\u6237\u7684\u4e1a\u52a1\u9700\u8981\u81ea\u5b9a\u4e49\u89d2\u8272\uff0c\u518d\u5c06\u9002\u5408\u7684\u6743\u9650\u8d4b\u4e88\u8fd9\u4e9b\u89d2\u8272\u3002
\u89d2\u8272\u8981\u70b9
\u5728 MatrixOne \u4e2d\uff0c\u89d2\u8272\u7684\u884c\u4e3a\u7ec6\u8282\u5982\u4e0b\uff1a
\u4e00\u4e2a\u89d2\u8272\u53ef\u4ee5\u5c06\u5176\u6743\u9650\u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u89d2\u8272\u3002
\u5c06\u67d0\u4e00\u89d2\u8272\u7684\u5168\u90e8\u6743\u9650\u7ed9\u53e6\u4e00\u4e2a\u89d2\u8272\u4f7f\u7528\uff0c\u4f8b\u5982\u5c06 role1 \u7684\u6240\u6709\u6743\u9650\u4f20\u9012\u7ed9 role2 \u4f7f\u7528\uff0c\u90a3\u4e48 role2 \u7ee7\u627f\u4e86 role1 \u7684\u6743\u9650\u3002
\u89d2\u8272\u548c\u7528\u6237\u4ec5\u5728\u5404\u81ea\u7684\u79df\u6237 (Account) \u5185\u751f\u6548\uff0c\u5305\u62ec\u7cfb\u7edf\u79df\u6237 (Sys Account)\u3002
Note
\u4e00\u4e2a\u7528\u6237\u88ab\u6388\u4e88\u591a\u4e2a\u89d2\u8272\uff0c\u7528\u4e8e\u6267\u884c\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u4e1a\u52a1\u3002
\u4e3b\u8981\u89d2\u8272\uff1a\u7528\u6237\u5728\u67d0\u4e00\u65f6\u523b\u53ea\u80fd\u4f7f\u7528\u5176\u4e2d\u4e00\u4e2a\u89d2\u8272\uff0c\u6211\u4eec\u79f0\u5f53\u524d\u6240\u4f7f\u7528\u7684\u8fd9\u4e2a\u89d2\u8272\u4e3a\u4e3b\u8981\u89d2\u8272\u3002 \u6b21\u8981\u89d2\u8272\uff1a\u9664\u4e86\u4e3b\u8981\u89d2\u8272\u4e4b\u5916\u8be5\u7528\u6237\u6240\u62e5\u6709\u7684\u5176\u4ed6\u89d2\u8272\u96c6\u5408\u79f0\u4e3a\u6b21\u8981\u89d2\u8272\u3002
\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u7528\u6237\u60f3\u53bb\u6267\u884c\u53e6\u4e00\u4e2a\u89d2\u8272\u6743\u9650\u7684 SQL \u65f6\uff0c\u9700\u8981\u5148\u5207\u6362\u89d2\u8272\uff08\u5373 set role <role>
\uff09\u3002\u6b64\u5916\uff0c\u4e3a\u4e86\u517c\u5bb9\u7ecf\u5178\u6570\u636e\u5e93\u7684\u6743\u9650\u884c\u4e3a\uff0cMatrixOne \u8fd8\u652f\u6301\u5f00\u542f\u4f7f\u7528\u6b21\u8981\u89d2\u8272\u7684\u529f\u80fd\uff1a\u4f7f\u7528 set secondary role all
\uff0c\u6267\u884c\u8fd9\u6761 SQL \u540e\uff0c\u8be5\u7528\u6237\u4fbf\u53ef\u540c\u65f6\u62e5\u6709\u4ed6\u6240\u6709\u89d2\u8272\u7684\u6743\u9650\u4e86\uff0c\u6267\u884c set secondary role none
\u5373\u53ef\u5173\u95ed\u6b64\u529f\u80fd\u3002
A \u516c\u53f8\u8d2d\u4e70\u4e86 MatrixOne \u96c6\u7fa4\uff0c\u5e76\u4e14\u5b8c\u6210\u4e86\u90e8\u7f72\u3002\u7531\u4e8e A \u516c\u53f8\u89c4\u6a21\u6bd4\u8f83\u5927\uff0c\u4e1a\u52a1\u7ebf\u591a\u4e14\u590d\u6742\uff0c\u6570\u636e\u91cf\u4e5f\u975e\u5e38\u5e9e\u5927\uff0c\u60f3\u8981\u9488\u5bf9\u67d0\u4e2a\u4e1a\u52a1\u7ebf\u5f00\u53d1\u4e00\u6b3e\u5e94\u7528\u7a0b\u5e8f\uff0c\u5047\u8bbe\u547d\u540d\u4e3a BusinessApp\uff0c\u4f46\u662f\u9700\u8981\u8ddf\u5176\u4ed6\u4e1a\u52a1\u7ebf\u7684\u6570\u636e\u8fdb\u884c\u9694\u79bb\uff0c\u90a3\u4e48 MatrxiOne \u600e\u4e48\u9694\u79bb\u51fa\u8fd9\u4e9b\u6570\u636e\u8d44\u6e90\u3001\u6743\u9650\u8d44\u6e90\u5462\uff1f
\u5b8c\u6210\u90e8\u7f72 MatrixOne \u96c6\u7fa4\uff0c\u7814\u53d1\u90e8\u95e8\u7684 Tom \u83b7\u53d6\u5230\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u516c\u53f8\u6307\u6d3e\u4ed6\u6765\u5b8c\u6210\u8d44\u6e90\u9694\u79bb\u8fd9\u4e00\u4efb\u52a1\u3002Tom \u9700\u8981\u8fd9\u4e48\u505a\uff1a
Tom \u9700\u8981\u5148\u521b\u5efa\u4e24\u4e2a\u79df\u6237\uff0c\u79df\u6237\u8d26\u53f7\u4e00\u4e2a\u662f BusinessAccount\uff0c\u4e00\u4e2a\u662f ElseAccount\u3002
\u5173\u4e8e\u8d44\u6e90\u9694\u79bb\u7684\u5177\u4f53\u5b9e\u64cd\uff0c\u53ef\u4ee5\u53c2\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u9a8c\u8bc1\u8d44\u6e90\u9694\u79bb\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_12","title":"\u7528\u6237\u521b\u5efa\u548c\u6388\u6743\u573a\u666f\u4ecb\u7ecd","text":"\u8fd8\u662f\u6cbf\u7528\u4e0a\u9762\u7684\u573a\u666f\u793a\u4f8b\uff0cTom \u628a BusinessAccount \u8fd9\u4e2a\u79df\u6237\u8d26\u53f7\u7ed9\u4e86\u516c\u53f8\u7684\u6570\u636e\u7ba1\u7406\u5458 Robert\uff0c\u8ba9 Robert \u53bb\u5206\u914d\u65b0\u7684\u7528\u6237\u8d26\u53f7\u548c\u6743\u9650\u7ed9\u5176\u4ed6\u7814\u53d1\u540c\u4e8b\u3002
\u7814\u53d1\u540c\u4e8b Joe \u662f\u8fd9\u4e2a A \u516c\u53f8\u9879\u76ee BusinessApp \u7684\u5e94\u7528\u5f00\u53d1\u8005\uff0cJoe \u6709\u4e00\u4e2a\u5f00\u53d1\u4efb\u52a1\uff0cJoe \u9700\u8981\u4f7f\u7528\u6570\u636e\u5e93\u5185\u6240\u6709\u7684\u6570\u636e\u3002\u90a3\u4e48 Robert \u5c31\u8981\u5e2e Joe \u5f00\u901a\u8d26\u53f7\uff0c\u7ed9 Joe \u6388\u6743\uff1a
\u5173\u4e8e\u7528\u6237\u521b\u5efa\u548c\u6388\u6743\u7684\u5177\u4f53\u5b9e\u64cd\uff0c\u53ef\u4ee5\u53c2\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u521b\u5efa\u65b0\u79df\u6237\uff0c\u5e76\u7531\u65b0\u79df\u6237\u521b\u5efa\u7528\u6237\u3001\u521b\u5efa\u89d2\u8272\u548c\u6388\u6743\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_13","title":"\u521d\u59cb\u5316\u8bbf\u95ee","text":"\u521d\u59cb\u5316\u96c6\u7fa4\u6216\u8d26\u6237\u540e\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e9b\u9ed8\u8ba4\u7528\u6237\u548c\u9ed8\u8ba4\u89d2\u8272\uff1a
\u7528\u6237\u540d \u89e3\u91ca \u6240\u62e5\u6709\u7684\u89d2\u8272 \u6240\u62e5\u6709\u7684\u6743\u9650 \u63cf\u8ff0 root \u96c6\u7fa4\u7ba1\u7406\u5458 MOADMIN \u521b\u5efa\u3001\u7f16\u8f91\u3001\u5220\u9664\u79df\u6237 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 root \u7cfb\u7edf\u79df\u6237\u7ba1\u7406\u5458 MOADMIN \u7ba1\u7406\u7cfb\u7edf\u79df\u6237\u4e0b\u7684\u6240\u6709\u8d44\u6e90\uff0c\u5305\u542b\u7528\u6237\u3001\u89d2\u8272\u3001\u6570\u636e\u5e93/\u8868/\u89c6\u56fe\uff0c\u6388\u6743\u7ba1\u7406 \u96c6\u7fa4\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 <\u81ea\u5b9a\u4e49> \u79df\u6237\u7ba1\u7406\u5458 ACCOUNTADMIN \u7ba1\u7406\u666e\u901a\u79df\u6237\u4e0b\u7684\u6240\u6709\u8d44\u6e90\uff0c\u5305\u542b\u7528\u6237\u3001\u89d2\u8272\u3001\u6570\u636e\u5e93/\u8868/\u89c6\u56fe\uff0c\u6388\u6743\u7ba1\u7406 \u79df\u6237\u88ab\u521b\u5efa\u540e\u81ea\u52a8\u751f\u6210\u5e76\u6388\u4e88 \u6240\u6709\u7528\u6237 \u666e\u901a\u7528\u6237 PUBLIC \u8fde\u63a5 MatrixOne \u6240\u6709\u7528\u6237\u88ab\u521b\u5efa\u540e\uff0c\u81ea\u52a8\u88ab\u6388\u4e88 PUBLIC \u89d2\u8272"},{"location":"MatrixOne/Security/role-priviledge-management/about-privilege-management/#_14","title":"\u9a6c\u4e0a\u5f00\u59cb","text":"\u5982\u679c\u4f60\u6240\u5728\u7684\u4f01\u4e1a\u90e8\u7f72\u4e86 MatrixOne \u96c6\u7fa4\uff0c\u90a3\u4e48\u90e8\u7f72\u5b8c\u6210\u540e\uff0c\u96c6\u7fa4\u521d\u59cb\u5316\u65f6\u5373\u81ea\u52a8\u5b58\u5728\u4e00\u4e2a\u96c6\u7fa4\u7ba1\u7406\u5458\u8d26\u6237\uff0c\u4f60\u53ef\u4ee5\u8054\u7cfb MatrxiOne \u7684\u9879\u76ee\u7ecf\u7406\u6216\u9500\u552e\u4ee3\u8868\u83b7\u53d6\u8d26\u53f7\u4fe1\u606f\u548c\u521d\u59cb\u5bc6\u7801\u3002\u4f7f\u7528\u96c6\u7fa4\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u4f60\u53ef\u4ee5\u65b0\u5efa\u79df\u6237\uff0c\u7ba1\u7406\u79df\u6237\u751f\u547d\u5468\u671f\uff0c\u5e76\u5c06\u79df\u6237\u8d26\u53f7\u5bc6\u7801\u5206\u914d\u7ed9\u4f60\u6240\u5728\u4f01\u4e1a\u5bf9\u5e94\u7684\u8d1f\u8d23\u4eba\u3002\u7ba1\u7406\u79df\u6237\u7684\u64cd\u4f5c\u8bf4\u660e\uff0c\u8be6\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u521b\u5efa\u79df\u6237\uff0c\u9a8c\u8bc1\u8d44\u6e90\u9694\u79bb\u6216\u6743\u9650\u7ba1\u7406\u64cd\u4f5c\u6307\u5357\u3002
\u5982\u679c\u4f60\u6240\u5728\u7684\u4f01\u4e1a\u4ec5\u9700\u4f7f\u7528 MatrixOne \u96c6\u7fa4\u79df\u6237\u8d44\u6e90\uff0c\u5b8c\u6210\u90e8\u7f72\u540e\uff0cMatrixOne \u96c6\u7fa4\u7ba1\u7406\u5458\u4f1a\u5e2e\u4f60\u5f00\u901a\u79df\u6237\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u4f60\u53ef\u4ee5\u8054\u7cfb MatrxiOne \u7684\u9879\u76ee\u7ecf\u7406\u6216\u9500\u552e\u4ee3\u8868\u83b7\u53d6\u8d26\u53f7\u4fe1\u606f\u548c\u521d\u59cb\u5bc6\u7801\u3002\u4f7f\u7528\u79df\u6237\u7ba1\u7406\u5458\u7684\u8d26\u53f7\uff0c\u4f60\u53ef\u4ee5\u65b0\u5efa\u7528\u6237\uff0c\u7ba1\u7406\u7528\u6237\u751f\u547d\u5468\u671f\u3001\u79df\u6237\u5185\u7684\u8d44\u6e90\uff08\u7528\u6237\u3001\u89d2\u8272\u548c\u6743\u9650\uff09\uff0c\u5e76\u5c06\u7528\u6237\u8d26\u53f7\u5bc6\u7801\u5206\u914d\u7ed9\u4f60\u6240\u5728\u4f01\u4e1a\u5bf9\u5e94\u7684\u8d1f\u8d23\u4eba\u3002\u7ba1\u7406\u7528\u6237\u7684\u64cd\u4f5c\u8bf4\u660e\uff0c\u8be6\u89c1\u5feb\u901f\u5f00\u59cb\uff1a\u521b\u5efa\u7528\u6237\u3001\u521b\u5efa\u89d2\u8272\u548c\u6388\u6743\u6216\u6743\u9650\u7ba1\u7406\u64cd\u4f5c\u6307\u5357\u3002
\u5728\u5b9e\u9645\u5e94\u7528\u573a\u666f\u4e2d\uff0c\u9700\u8981\u8bbe\u7acb\u4e00\u4e2a\u6570\u636e\u7ba1\u7406\u5458\u7684\u5c97\u4f4d\uff0c\u4ed6\u8d1f\u8d23\u7ba1\u7406\u6574\u4e2a\u6570\u636e\u5e93\u4e2d\u8d44\u6e90\u5206\u914d\u7684\u60c5\u51b5\uff0c\u6bd4\u5982\u8bf4\uff0c\u516c\u53f8\u5176\u4ed6\u6210\u5458\u9700\u8981\u88ab\u5206\u914d\u4e00\u4e2a\u7528\u6237\u8d26\u53f7\u548c\u5bc6\u7801\uff0c\u88ab\u5206\u914d\u89d2\u8272\uff0c\u5e76\u88ab\u6388\u4e88\u6700\u4f4e\u7684\u4f7f\u7528\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#_5","title":"\u524d\u63d0\u6761\u4ef6","text":"\u4f60\u9996\u5148\u9700\u8981\u62e5\u6709\u79df\u6237\u7ba1\u7406\u5458\u7684\u8d26\u53f7
\u5df2\u7ecf\u8fde\u63a5\u4e0a MatrixOne \u96c6\u7fa4
\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u7ba1\u7406\u5458\u7684\u89d2\u8272\uff0c\u6388\u4e88\u4ed6\u79df\u6237\u5185\u7684\u5168\u5c40\u7ba1\u7406\u7684\u6743\u9650\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u505a\u5230\u5982\u4e0b\u51e0\u70b9\uff1a
\u4f7f\u7528\u4f60\u6240\u62e5\u6709\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7\u767b\u5f55\u79df\u6237\uff1a
Note: \u6b64\u5904\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7 account1 \u4e3a\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u5728\u521b\u5efa\u79df\u6237\u7ba1\u7406\u5458\u65f6\u8fdb\u884c\u81ea\u5b9a\u4e49\u3002
mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u8d26\u53f7\uff0c\u547d\u540d\u4e3a dbauser\uff0c\u5bc6\u7801\u4e3a 123456\uff1a
create user dbauser identified by \"123456\";\n
\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u7ba1\u7406\u5458\u7684\u89d2\u8272\uff0c\u547d\u540d\u4e3a dba\uff1a
create role dba;\n
\u6388\u6743\u6743\u9650\u7ed9\u89d2\u8272\u5982\u4e0b\u6743\u9650\uff1a
grant all on account * to dba with grant option;\ngrant all on database * to dba with grant option;\ngrant all on table *.* to dba with grant option;\n
\u6388\u6743\u89d2\u8272 dba \u7ed9\u7528\u6237 dbauser\uff1a
grant dba to dbauser;\n
\u67e5\u770b\u6743\u9650\u6388\u4e88\u60c5\u51b5\uff1a
show grants for dbauser@localhost;\n
\u4f7f\u7528\u6570\u636e\u7ba1\u7406\u5458\u8d26\u53f7 dbauser \u767b\u5f55 MatrixOne\uff1a
mysql -h 127.0.0.1 -P 6001 -u account1:dbauser:dba -p\n
\u67e5\u770b dbauser \u6240\u62e5\u6709\u7684\u6743\u9650\uff1a
show grants for dbauser@localhost;\n
\u67e5\u770b dbauser \u7684\u89d2\u8272\uff1a
SET SECONDARY ROLE ALL;\nuse mo_catalog;\nselect mu.user_name,mr.role_name from mo_role mr,mo_user mu,mo_user_grant mug where mu.user_id=mug.user_id and mr.role_id=mug.role_id and mu.user_name='dbauser';\n
\u5b9e\u9645\u64cd\u4f5c\u4e00\u4e2a\u6570\u636e\u5e93\u8fdb\u884c\u9a8c\u8bc1\uff1a
drop database if exists test;\ncreate database test;\nuse test;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\n
\u4e0a\u9762\u4ee3\u7801\u8868\u793a\u9a8c\u8bc1\u6210\u529f\u3002
\u5e94\u7528\u7cfb\u7edf\u4e0a\u7ebf\u65f6\uff0c\u4f1a\u6839\u636e\u5e94\u7528\u7cfb\u7edf\u7684\u4f7f\u7528\u9700\u6c42\uff0c\u521b\u5efa\u65b0\u7684\u6570\u636e\u5e93\u4e0e\u5bf9\u5e94\u6570\u636e\u5e93\u7528\u6237\uff0c\u5e76\u4e14\u6388\u4e88\u8fd9\u4e2a\u7528\u6237\u62e5\u6709\u76ee\u6807\u6570\u636e\u5e93\u7684\u6240\u6709\u6743\u9650\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/app-scenarios/#_12","title":"\u524d\u63d0\u6761\u4ef6","text":"\u9700\u6c42 1\uff1a\u5e94\u7528\u7cfb\u7edf\u9700\u8981\u4e00\u5957\u65b0\u7684\u6570\u636e\u5e93\u4e13\u95e8\u5e94\u7528\u4e8e\u5e94\u7528\u7684\u5f00\u53d1\u3002
\u9700\u6c42 2\uff1a\u8be5\u5e94\u7528\u7cfb\u7edf\u9700\u8981\u4e13\u95e8\u7684\u89d2\u8272\u3002
\u9700\u6c42 3\uff1a\u8be5\u5e94\u7528\u7cfb\u7edf\u9700\u8981\u4e13\u95e8\u7684\u8d1f\u8d23\u4eba\u7ba1\u7406\u8fd9\u4e2a\u6570\u636e\u5e93\u3002
\u4f7f\u7528\u4f60\u6240\u62e5\u6709\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7\u767b\u5f55\u79df\u6237\uff1a
Note: \u6b64\u5904\u7684\u79df\u6237\u7ba1\u7406\u5458\u8d26\u53f7 account1 \u4e3a\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u5728\u521b\u5efa\u79df\u6237\u7ba1\u7406\u5458\u65f6\u8fdb\u884c\u81ea\u5b9a\u4e49\u3002
mysql -h 127.0.0.1 -P 6001 -u account1:admin:admin -p\n
\u521b\u5efa\u5e94\u7528\u6240\u9700\u8981\u7684\u6570\u636e\u5e93\uff0c\u7ed9\u6570\u636e\u5e93\u547d\u540d\u4e3a appdb\uff1a
create database appdb;\n
\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a approle \u7684\u89d2\u8272\uff0c\u5e76\u6388\u6743\u7ed9\u8fd9\u4e2a\u89d2\u8272\u5bf9\u4e8e\u6570\u636e\u5e93 appdb \u7684\u5168\u90e8\u64cd\u4f5c\u6743\u9650\uff1a
create role approle;\ngrant all on database appdb to approle;\ngrant all on table appdb.* to approle;\n
\u521b\u5efa\u6570\u636e\u5e93\u7528\u6237 appuser\uff0c\u5bc6\u7801\u4e3a 123456\uff0c\u5e76\u5c06\u89d2\u8272 approle \u5206\u914d\u7ed9 appuser\uff1a
create user appuser identified by \"123456\" default role approle;\n
\u4f7f\u7528\u6570\u636e\u5e93\u7528\u6237\u8d26\u53f7 appuser \u767b\u5f55 MatrixOne\uff1a
mysql -h127.0.0.1 -utest:appuser -P6001 -p123456\n
\u9a8c\u8bc1\u6570\u636e\u7528\u6237\u8d26\u53f7 appuser \u7684\u6743\u9650\uff1a
set secondary role all;\nuse appdb;\ncreate table t1(a int);\ninsert into t1 values(1),(2),(3);\nselect * from t1;\ndrop table t1;\n
\u4e0a\u9762\u4ee3\u7801\u8868\u793a\u9a8c\u8bc1\u6210\u529f\u3002
\u4ee5\u4e0b\u662f MatrixOne \u4e2d\u7684\u5178\u578b\u89d2\u8272\u4ee5\u53ca\u5efa\u8bae\u7684\u6700\u4f4e\u6743\u9650\uff0c\u4f9b\u4f60\u8fdb\u884c\u53c2\u8003\u3002
"},{"location":"MatrixOne/Security/role-priviledge-management/best-practice/#_2","title":"\u8d1f\u8d23\u6570\u636e\u5e93\u8d44\u6e90\uff08\u7528\u6237\u3001\u89d2\u8272\u3001\u6743\u9650\uff09\u7ba1\u7406\u7684\u5de5\u7a0b\u5e08","text":"\u6570\u636e\u5e93\u7ba1\u7406\u5458
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u7ba1\u7406\u79df\u6237\u5185\u7684\u6240\u6709\u914d\u7f6e\u4fe1\u606f\u3001\u7528\u6237\u6743\u9650\u3001\u5907\u4efd\u6062\u590d\u3001\u6027\u80fd\u8c03\u4f18\u3001\u6545\u969c\u6392\u67e5
\u6570\u636e\u8fd0\u7ef4\u5de5\u7a0b\u5e08
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u7ba1\u7406\u79df\u6237\u5185\u7684\u6240\u6709\u6570\u636e\u4e0e\u5143\u6570\u636e\u4fe1\u606f\uff0c\u4ee5\u53ca\u6570\u636e\u7684\u6743\u9650\u6388\u6743
\u53c2\u8003\u6388\u4e88\u6743\u9650\uff1a\u79df\u6237\u7ea7\u522b\u7684\u6570\u636e\u7ba1\u7406\uff08ALL ON ACCOUNT\uff09
\u5e94\u7528\u5f00\u53d1\u8005
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u5bf9\u5f00\u53d1\u73af\u5883\u79df\u6237\u4e0b\u7279\u5b9a\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c\uff0c\u5e76\u62e5\u6709\u7cfb\u7edf\u79df\u6237\u7684\u53ea\u8bfb\u6743\u9650
\u53c2\u8003\u6388\u4e88\u6743\u9650\uff1a\u6570\u636e\u5e93\u7ea7\u522b\u7684\u6570\u636e\u7ba1\u7406\uff08ALL ON DATABASE\uff09\u3001\u7cfb\u7edf\u6570\u636e\u5e93\u53ea\u8bfb\uff08SELECT ON DATABASE\uff09
\u5e94\u7528\u7cfb\u7edf\u7ba1\u7406\u5de5\u7a0b\u5e08
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u5bf9\u751f\u4ea7\u73af\u5883\u79df\u6237\u4e0b\u7279\u5b9a\u6570\u636e\u5e93\u8fdb\u884c\u64cd\u4f5c
\u53c2\u8003\u6388\u4e88\u6743\u9650\uff1a\u6570\u636e\u5e93\u7ea7\u522b\u7684\u6570\u636e\u7ba1\u7406\uff08ALL ON DATABASE\uff09
\u7cfb\u7edf\u76d1\u63a7\u5de5\u7a0b\u5e08
\u4e3b\u8981\u5de5\u4f5c\u804c\u80fd\uff1a\u76d1\u63a7\u79df\u6237\u4e0b\u6240\u6709\u7684\u7cfb\u7edf\u7edf\u8ba1\u4fe1\u606f\u4e0e\u9519\u8bef\u4fe1\u606f
SSB \u661f\u578b\u6a21\u5f0f\u57fa\u51c6\u6d4b\u8bd5\u662f OLAP \u6570\u636e\u5e93\u6027\u80fd\u6d4b\u8bd5\u7684\u5e38\u7528\u573a\u666f\uff0c\u901a\u8fc7\u672c\u7bc7\u6559\u7a0b\uff0c\u60a8\u53ef\u4ee5\u4e86\u89e3\u5230\u5982\u4f55\u5728 MatrixOne \u4e2d\u5b9e\u73b0 SSB \u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_1","title":"\u51c6\u5907\u5de5\u4f5c","text":"\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#1-dbgen","title":"1. \u7f16\u8bd1 dbgen","text":"git clone https://github.com/vadimtk/ssb-dbgen.git\n\u6216\u8005\ngit clone https://githubfast.com/vadimtk/ssb-dbgen.git\ncd ssb-dbgen\nmake\n
Note
\u5982\u679c\u4f60\u7684\u786c\u4ef6\u914d\u7f6e\u4e3a M1 \u82af\u7247\uff0c\u7f16\u8bd1 dbgen \u4ecd\u9700\u8fdb\u884c\u5176\u4ed6\u914d\u7f6e\uff0c\u53c2\u89c1\u90e8\u7f72\u5e38\u89c1\u95ee\u9898\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#2","title":"2. \u751f\u6210\u6570\u636e","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_2","title":"\u9009\u9879\u4e00\uff1a\u751f\u6210\u5355\u8868\u6570\u636e\u96c6","text":"\u5f53\u4f7f\u7528 -s 1
\u65f6 dbgen
\u547d\u4ee4\u4f1a\u751f\u4ea7\u8fd1 600 \u4e07\u884c\u6570\u636e (670MB)\uff0c\u5f53\u4f7f\u7528 -s 10
\u65f6\u4f1a\u751f\u4ea7\u8fd1 6000 \u4e07\u884c\u6570\u636e\uff0c\u4f1a\u8017\u8d39\u5927\u91cf\u65f6\u95f4\u3002
./dbgen -s 1 -T c\n./dbgen -s 1 -T l\n./dbgen -s 1 -T p\n./dbgen -s 1 -T s\n./dbgen -s 1 -T d\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_3","title":"\u9009\u9879\u4e8c\uff1a\u4e0b\u8f7d\u5927\u5bbd\u8868\u6570\u636e\u96c6","text":"\u6211\u4eec\u51c6\u5907\u4e86 1GB \u7684\u5927\u5bbd\u8868\u6570\u636e\u96c6\u4f9b\u4f60\u4e0b\u8f7d\u3002
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/lineorder_flat.tar.bz2\n
create database if not exists ssb;\nuse ssb;\ndrop table if exists lineorder;\ndrop table if exists part;\ndrop table if exists supplier;\ndrop table if exists customer;\ndrop table if exists date;\ndrop table if exists lineorder_flat;\n\ncreate table lineorder (\n lo_orderkey bigint,\n lo_linenumber int,\n lo_custkey int,\n lo_partkey int,\n lo_suppkey int,\n lo_orderdate date,\n lo_orderpriority char (15),\n lo_shippriority tinyint,\n lo_quantity double,\n lo_extendedprice double,\n lo_ordtotalprice double,\n lo_discount double,\n lo_revenue double,\n lo_supplycost double,\n lo_tax double,\n lo_commitdate date,\n lo_shipmode char (10)\n) ;\n\ncreate table part (\n p_partkey int,\n p_name varchar (22),\n p_mfgr char (6),\n p_category char (7),\n p_brand char (9),\n p_color varchar (11),\n p_type varchar (25),\n p_size int,\n p_container char (10)\n) ;\n\ncreate table supplier (\n s_suppkey int,\n s_name char (25),\n s_address varchar (25),\n s_city char (10),\n s_nation char (15),\n s_region char (12),\n s_phone char (15)\n) ;\n\ncreate table customer (\n c_custkey int,\n c_name varchar (25),\n c_address varchar (25),\n c_city char (10),\n c_nation char (15),\n c_region char (12),\n c_phone char (15),\n c_mktsegment char (10)\n) ;\n\ncreate table date (\n d_datekey date,\n d_date char (18),\n d_dayofweek char (9),\n d_month char (9),\n d_year int,\n d_yearmonthnum int,\n d_yearmonth char (7),\n d_daynuminweek varchar(12),\n d_daynuminmonth int,\n d_daynuminyear int,\n d_monthnuminyear int,\n d_weeknuminyear int,\n d_sellingseason varchar (12),\n d_lastdayinweekfl varchar (1),\n d_lastdayinmonthfl varchar (1),\n d_holidayfl varchar (1),\n d_weekdayfl varchar (1)\n) ;\n\nCREATE TABLE lineorder_flat(\n LO_ORDERKEY bigint key,\n LO_LINENUMBER int,\n LO_CUSTKEY int,\n LO_PARTKEY int,\n LO_SUPPKEY int,\n LO_ORDERDATE date,\n LO_ORDERPRIORITY char(15),\n LO_SHIPPRIORITY tinyint,\n LO_QUANTITY double,\n LO_EXTENDEDPRICE double,\n LO_ORDTOTALPRICE double,\n LO_DISCOUNT double,\n LO_REVENUE int unsigned,\n LO_SUPPLYCOST int unsigned,\n LO_TAX double,\n LO_COMMITDATE date,\n LO_SHIPMODE char(10),\n C_NAME varchar(25),\n C_ADDRESS varchar(25),\n C_CITY char(10),\n C_NATION char(15),\n C_REGION char(12),\n C_PHONE char(15),\n C_MKTSEGMENT char(10),\n S_NAME char(25),\n S_ADDRESS varchar(25),\n S_CITY char(10),\n S_NATION char(15),\n S_REGION char(12),\n S_PHONE char(15),\n P_NAME varchar(22),\n P_MFGR char(6),\n P_CATEGORY char(7),\n P_BRAND char(9),\n P_COLOR varchar(11),\n P_TYPE varchar(25),\n P_SIZE int,\n P_CONTAINER char(10)\n);\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#4","title":"4. \u5bfc\u5165\u6570\u636e","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_4","title":"\u9009\u9879\u4e00\uff1a\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5bfc\u5165\u5355\u8868\u6570\u636e\u96c6","text":"load data infile '/ssb-dbgen-path/supplier.tbl' into table supplier FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/customer.tbl' into table customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/date.tbl' into table date FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/part.tbl' into table part FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/ssb-dbgen-path/lineorder.tbl' into table lineorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u63a5\u7740\u4f60\u53ef\u4ee5\u5728 MatrixOne \u4e2d\u8fdb\u884c\u67e5\u8be2\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_5","title":"\u9009\u9879\u4e8c\uff1a\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5bfc\u5165\u5927\u5bbd\u8868\u6570\u636e\u96c6","text":"\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6570\u636e\u5bfc\u5165 lineorder_flat
\uff1a
load data infile '/ssb-dbgen-path/lineorder_flat.tbl' into table lineorder_flat FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#5-ssb","title":"5. \u8fd0\u884c SSB \u6d4b\u8bd5\u547d\u4ee4","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_6","title":"\u5355\u8868\u67e5\u8be2","text":"--Q1.1\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25;\n\n--Q1.2\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n--Q1.3\nSELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE year(LO_ORDERDATE)=1994 AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35;\n\n--Q2.1\nSELECT sum(LO_REVENUE),year(LO_ORDERDATE) AS year,P_BRAND FROM lineorder_flat WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' GROUP BY year, P_BRAND ORDER BY year,P_BRAND;\n\n--Q2.2\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND BETWEEN 'MFGR#2221' AND 'MFGR#2228' AND S_REGION = 'ASIA' GROUP BY year, P_BRAND ORDER BY year, P_BRAND;\n\n--Q2.3\nSELECT sum(LO_REVENUE), year(LO_ORDERDATE) AS year, P_BRAND FROM lineorder_flat WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' GROUP BY year, P_BRAND ORDER BY year, P_BRAND;\n\n--Q3.1\nSELECT C_NATION, S_NATION, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_REGION = 'ASIA' AND S_REGION = 'ASIA' AND year(LO_ORDERDATE) between 1992 AND 1997 GROUP BY C_NATION, S_NATION, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q3.2\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE C_NATION = 'CHINA' AND S_NATION = 'CHINA' AND year(LO_ORDERDATE) between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q3.3\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'UNITED KI0' OR S_CITY = 'UNITED KI7') AND year(LO_ORDERDATE) between 1992 AND 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q3.4\nSELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS year, sum(LO_REVENUE) AS revenue FROM lineorder_flat WHERE (C_CITY = 'UNITED KI0' OR C_CITY = 'UNITED KI7') AND (S_CITY = 'MOZAMBIQU1' OR S_CITY = 'KENYA 4') AND year(LO_ORDERDATE)= 1997 GROUP BY C_CITY, S_CITY, year(LO_ORDERDATE) ORDER BY year asc, revenue desc;\n\n--Q4.1\nSELECT year(LO_ORDERDATE) AS year, C_NATION, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY year(LO_ORDERDATE), C_NATION ORDER BY year, C_NATION;\n\n--Q4.2\nSELECT year(LO_ORDERDATE) AS year, S_NATION, P_CATEGORY, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE C_REGION = 'AMERICA' AND S_REGION = 'AMERICA' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND (P_MFGR = 'MFGR#1' OR P_MFGR = 'MFGR#2') GROUP BY year(LO_ORDERDATE), S_NATION, P_CATEGORY ORDER BY year, S_NATION, P_CATEGORY;\n\n--Q4.3\nSELECT year(LO_ORDERDATE) AS year, S_CITY, P_BRAND, sum(LO_REVENUE - LO_SUPPLYCOST) AS profit FROM lineorder_flat WHERE S_NATION = 'UNITED STATES' AND (year(LO_ORDERDATE) = 1997 OR year(LO_ORDERDATE) = 1998) AND P_CATEGORY = 'MFGR#14' GROUP BY year(LO_ORDERDATE), S_CITY, P_BRAND ORDER BY year, S_CITY, P_BRAND;\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_7","title":"\u591a\u8868\u67e5\u8be2","text":"--Q1.1\nselect sum(lo_revenue) as revenue\nfrom lineorder join date on lo_orderdate = d_datekey\nwhere year(d_datekey) = 1993 and lo_discount between 1 and 3 and lo_quantity < 25;\n\n--Q1.2\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_yearmonthnum = 199401\nand lo_discount between 4 and 6\nand lo_quantity between 26 and 35;\n\n--Q1.3\nselect sum(lo_revenue) as revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\nwhere d_weeknuminyear = 6 and year(d_datekey) = 1994\nand lo_discount between 5 and 7\nand lo_quantity between 26 and 35;\n\n--Q2.1\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_category = 'MFGR#12' and s_region = 'AMERICA'\ngroup by year, p_brand\norder by year, p_brand;\n\n--Q2.2\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand between 'MFGR#2221' and 'MFGR#2228' and s_region = 'ASIA'\ngroup by year, p_brand\norder by year, p_brand;\n\n--Q2.3\nselect sum(lo_revenue) as lo_revenue, year(d_datekey) as year, p_brand\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin part on lo_partkey = p_partkey\njoin supplier on lo_suppkey = s_suppkey\nwhere p_brand = 'MFGR#2239' and s_region = 'EUROPE'\ngroup by year, p_brand\norder by year, p_brand;\n\n--Q3.1\nselect c_nation, s_nation, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_region = 'ASIA' and s_region = 'ASIA' and year(d_datekey) between 1992 and 1997\ngroup by c_nation, s_nation, year\norder by year asc, lo_revenue desc;\n\n--Q3.2\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere c_nation = 'UNITED STATES' and s_nation = 'UNITED STATES'\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year\norder by year asc, lo_revenue desc;\n\n--Q3.3\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5')\nand (s_city='UNITED KI1' or s_city='UNITED KI5')\nand year(d_datekey) between 1992 and 1997\ngroup by c_city, s_city, year\norder by year asc, lo_revenue desc;\n\n--Q3.4\nselect c_city, s_city, year(d_datekey) as year, sum(lo_revenue) as lo_revenue\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\nwhere (c_city='UNITED KI1' or c_city='UNITED KI5') and (s_city='UNITED KI1' or s_city='UNITED KI5') and d_yearmonth = 'Dec1997'\ngroup by c_city, s_city, year\norder by year asc, lo_revenue desc;\n\n--Q4.1\nselect year(d_datekey) as year, c_nation, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA' and s_region = 'AMERICA' and (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year, c_nation\norder by year, c_nation;\n\n--Q4.2\nselect year(d_datekey) as year, s_nation, p_category, sum(lo_revenue) - sum(lo_supplycost) as profit\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere c_region = 'AMERICA'and s_region = 'AMERICA'\nand (year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand (p_mfgr = 'MFGR#1' or p_mfgr = 'MFGR#2')\ngroup by year, s_nation, p_category\norder by year, s_nation, p_category;\n\n--Q4.3\nselect year(d_datekey) as year, s_city, p_brand, sum(lo_revenue) - sum(lo_supplycost) as profit,c_region , s_nation, p_category\nfrom lineorder\njoin date on lo_orderdate = d_datekey\njoin customer on lo_custkey = c_custkey\njoin supplier on lo_suppkey = s_suppkey\njoin part on lo_partkey = p_partkey\nwhere\n(year(d_datekey) = 1997 or year(d_datekey) = 1998)\nand s_nation='ALGERIA'\ngroup by year, s_city, p_brand\norder by year, s_city, p_brand;\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#6","title":"6. \u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":""},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_8","title":"\u5355\u8868\u67e5\u8be2\u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":"-- Q1.1\n+--------------+\n| revenue |\n+--------------+\n| 702223464659 |\n+--------------+\n\n-- Q1.2\n+---------------+\n| revenue |\n+---------------+\n| 1842875090496 |\n+---------------+\n\n-- Q1.3\n+---------------+\n| revenue |\n+---------------+\n| 2208738861324 |\n+---------------+\n\n-- Q2.1\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand |\n+-----------------+------+-----------+\n| 283684289 | 1992 | MFGR#121 |\n| 1344702529 | 1992 | MFGR#1210 |\n| 757158682 | 1992 | MFGR#1211 |\n| 1156022815 | 1992 | MFGR#1212 |\n| 676164367 | 1992 | MFGR#1213 |\n| 522779256 | 1992 | MFGR#1214 |\n| 233507213 | 1992 | MFGR#1215 |\n| 726755819 | 1992 | MFGR#1216 |\n| 1865504710 | 1992 | MFGR#1217 |\n| 685600451 | 1992 | MFGR#1218 |\n| 814671470 | 1992 | MFGR#1219 |\n| 655405800 | 1992 | MFGR#122 |\n| 962120553 | 1992 | MFGR#1220 |\n| 961393626 | 1992 | MFGR#1221 |\n| 922110830 | 1992 | MFGR#1222 |\n| 814842712 | 1992 | MFGR#1223 |\n| 1402773165 | 1992 | MFGR#1224 |\n| 977517439 | 1992 | MFGR#1225 |\n| 1392114944 | 1992 | MFGR#1226 |\n| 658922951 | 1992 | MFGR#1227 |\n| 892495927 | 1992 | MFGR#1228 |\n| 806609100 | 1992 | MFGR#1229 |\n| 578875657 | 1992 | MFGR#123 |\n| 691236902 | 1992 | MFGR#1230 |\n| 482715249 | 1992 | MFGR#1231 |\n| 618556590 | 1992 | MFGR#1232 |\n| 981657009 | 1992 | MFGR#1233 |\n| 1050794669 | 1992 | MFGR#1234 |\n| 1335217991 | 1992 | MFGR#1235 |\n| 686009527 | 1992 | MFGR#1236 |\n| 605242584 | 1992 | MFGR#1237 |\n| 430455641 | 1992 | MFGR#1238 |\n| 359654993 | 1992 | MFGR#1239 |\n| 818818457 | 1992 | MFGR#124 |\n| 1388502581 | 1992 | MFGR#1240 |\n| 711566198 | 1992 | MFGR#125 |\n| 893045647 | 1992 | MFGR#126 |\n| 1240534333 | 1992 | MFGR#127 |\n| 871966127 | 1992 | MFGR#128 |\n| 719176622 | 1992 | MFGR#129 |\n| 245880758 | 1993 | MFGR#121 |\n| 1480662753 | 1993 | MFGR#1210 |\n| 982292725 | 1993 | MFGR#1211 |\n| 1001136766 | 1993 | MFGR#1212 |\n| 227144072 | 1993 | MFGR#1213 |\n| 291611370 | 1993 | MFGR#1214 |\n| 454576668 | 1993 | MFGR#1215 |\n| 772027256 | 1993 | MFGR#1216 |\n| 1155751851 | 1993 | MFGR#1217 |\n| 897883050 | 1993 | MFGR#1218 |\n| 1209508962 | 1993 | MFGR#1219 |\n| 530577973 | 1993 | MFGR#122 |\n| 901650471 | 1993 | MFGR#1220 |\n| 739540494 | 1993 | MFGR#1221 |\n| 698751459 | 1993 | MFGR#1222 |\n| 1327979157 | 1993 | MFGR#1223 |\n| 1476697469 | 1993 | MFGR#1224 |\n| 792103134 | 1993 | MFGR#1225 |\n| 1420277376 | 1993 | MFGR#1226 |\n| 1446032835 | 1993 | MFGR#1227 |\n| 884375309 | 1993 | MFGR#1228 |\n| 522705868 | 1993 | MFGR#1229 |\n| 601685233 | 1993 | MFGR#123 |\n| 806727248 | 1993 | MFGR#1230 |\n| 399477390 | 1993 | MFGR#1231 |\n| 894047578 | 1993 | MFGR#1232 |\n| 496067089 | 1993 | MFGR#1233 |\n| 1050223756 | 1993 | MFGR#1234 |\n| 891681399 | 1993 | MFGR#1235 |\n| 1402903631 | 1993 | MFGR#1236 |\n| 347380448 | 1993 | MFGR#1237 |\n| 514853194 | 1993 | MFGR#1238 |\n| 410543863 | 1993 | MFGR#1239 |\n| 673483594 | 1993 | MFGR#124 |\n| 713343630 | 1993 | MFGR#1240 |\n| 512610707 | 1993 | MFGR#125 |\n| 1228110634 | 1993 | MFGR#126 |\n| 936958961 | 1993 | MFGR#127 |\n| 579067515 | 1993 | MFGR#128 |\n| 636174833 | 1993 | MFGR#129 |\n| 370347074 | 1994 | MFGR#121 |\n| 483900410 | 1994 | MFGR#1210 |\n| 1240306281 | 1994 | MFGR#1211 |\n| 1003345253 | 1994 | MFGR#1212 |\n| 557310864 | 1994 | MFGR#1213 |\n| 314972328 | 1994 | MFGR#1214 |\n| 1130260810 | 1994 | MFGR#1215 |\n| 401618319 | 1994 | MFGR#1216 |\n| 652173601 | 1994 | MFGR#1217 |\n| 923612074 | 1994 | MFGR#1218 |\n| 469711377 | 1994 | MFGR#1219 |\n| 580152115 | 1994 | MFGR#122 |\n| 433134653 | 1994 | MFGR#1220 |\n| 730569849 | 1994 | MFGR#1221 |\n| 607609104 | 1994 | MFGR#1222 |\n| 949877669 | 1994 | MFGR#1223 |\n| 1644687916 | 1994 | MFGR#1224 |\n| 492974194 | 1994 | MFGR#1225 |\n| 921499688 | 1994 | MFGR#1226 |\n| 719059761 | 1994 | MFGR#1227 |\n| 1000497056 | 1994 | MFGR#1228 |\n| 486968927 | 1994 | MFGR#1229 |\n| 734124906 | 1994 | MFGR#123 |\n| 645016873 | 1994 | MFGR#1230 |\n| 526638240 | 1994 | MFGR#1231 |\n| 1358112405 | 1994 | MFGR#1232 |\n| 1167074905 | 1994 | MFGR#1233 |\n| 1102915239 | 1994 | MFGR#1234 |\n| 693058125 | 1994 | MFGR#1235 |\n| 1673392892 | 1994 | MFGR#1236 |\n| 849630029 | 1994 | MFGR#1237 |\n| 721392705 | 1994 | MFGR#1238 |\n| 1237195774 | 1994 | MFGR#1239 |\n| 1107832795 | 1994 | MFGR#124 |\n| 827906290 | 1994 | MFGR#1240 |\n| 682827304 | 1994 | MFGR#125 |\n| 1198768141 | 1994 | MFGR#126 |\n| 1274148181 | 1994 | MFGR#127 |\n| 738849138 | 1994 | MFGR#128 |\n| 751136619 | 1994 | MFGR#129 |\n| 318978803 | 1995 | MFGR#121 |\n| 383199448 | 1995 | MFGR#1210 |\n| 1300165814 | 1995 | MFGR#1211 |\n| 1550400731 | 1995 | MFGR#1212 |\n| 451958158 | 1995 | MFGR#1213 |\n| 431434279 | 1995 | MFGR#1214 |\n| 713735582 | 1995 | MFGR#1215 |\n| 919323722 | 1995 | MFGR#1216 |\n| 1542358864 | 1995 | MFGR#1217 |\n| 500930092 | 1995 | MFGR#1218 |\n| 1208162086 | 1995 | MFGR#1219 |\n| 785707989 | 1995 | MFGR#122 |\n| 993828211 | 1995 | MFGR#1220 |\n| 667253893 | 1995 | MFGR#1221 |\n| 1654114297 | 1995 | MFGR#1222 |\n| 986528377 | 1995 | MFGR#1223 |\n| 755014642 | 1995 | MFGR#1224 |\n| 1090300100 | 1995 | MFGR#1225 |\n| 1063626454 | 1995 | MFGR#1226 |\n| 1382528859 | 1995 | MFGR#1227 |\n| 919953351 | 1995 | MFGR#1228 |\n| 457795295 | 1995 | MFGR#1229 |\n| 953851827 | 1995 | MFGR#123 |\n| 807209283 | 1995 | MFGR#1230 |\n| 236304454 | 1995 | MFGR#1231 |\n| 668449537 | 1995 | MFGR#1232 |\n| 240657083 | 1995 | MFGR#1233 |\n| 920389826 | 1995 | MFGR#1234 |\n| 684096065 | 1995 | MFGR#1235 |\n| 1005844219 | 1995 | MFGR#1236 |\n| 626170996 | 1995 | MFGR#1237 |\n| 984581826 | 1995 | MFGR#1238 |\n| 602850634 | 1995 | MFGR#1239 |\n| 1172025628 | 1995 | MFGR#124 |\n| 489788581 | 1995 | MFGR#1240 |\n| 643100327 | 1995 | MFGR#125 |\n| 894596661 | 1995 | MFGR#126 |\n| 706917239 | 1995 | MFGR#127 |\n| 428671983 | 1995 | MFGR#128 |\n| 971611472 | 1995 | MFGR#129 |\n| 306497573 | 1996 | MFGR#121 |\n| 890719726 | 1996 | MFGR#1210 |\n| 1761977172 | 1996 | MFGR#1211 |\n| 633845765 | 1996 | MFGR#1212 |\n| 475801202 | 1996 | MFGR#1213 |\n| 271930385 | 1996 | MFGR#1214 |\n| 366399844 | 1996 | MFGR#1215 |\n| 877472476 | 1996 | MFGR#1216 |\n| 970366290 | 1996 | MFGR#1217 |\n| 537175690 | 1996 | MFGR#1218 |\n| 956970528 | 1996 | MFGR#1219 |\n| 711962074 | 1996 | MFGR#122 |\n| 1062161683 | 1996 | MFGR#1220 |\n| 406293744 | 1996 | MFGR#1221 |\n| 785404335 | 1996 | MFGR#1222 |\n| 579267044 | 1996 | MFGR#1223 |\n| 1220640256 | 1996 | MFGR#1224 |\n| 490130196 | 1996 | MFGR#1225 |\n| 1603805636 | 1996 | MFGR#1226 |\n| 1530646510 | 1996 | MFGR#1227 |\n| 1093328922 | 1996 | MFGR#1228 |\n| 596520140 | 1996 | MFGR#1229 |\n| 450815571 | 1996 | MFGR#123 |\n| 315053350 | 1996 | MFGR#1230 |\n| 198951017 | 1996 | MFGR#1231 |\n| 579778438 | 1996 | MFGR#1232 |\n| 480905486 | 1996 | MFGR#1233 |\n| 1433336215 | 1996 | MFGR#1234 |\n| 560925251 | 1996 | MFGR#1235 |\n| 1038766181 | 1996 | MFGR#1236 |\n| 783697960 | 1996 | MFGR#1237 |\n| 972656445 | 1996 | MFGR#1238 |\n| 614528801 | 1996 | MFGR#1239 |\n| 1418931894 | 1996 | MFGR#124 |\n| 995139591 | 1996 | MFGR#1240 |\n| 824028471 | 1996 | MFGR#125 |\n| 669475113 | 1996 | MFGR#126 |\n| 831704651 | 1996 | MFGR#127 |\n| 920514555 | 1996 | MFGR#128 |\n| 436162421 | 1996 | MFGR#129 |\n| 553684594 | 1997 | MFGR#121 |\n| 1317368046 | 1997 | MFGR#1210 |\n| 1617056983 | 1997 | MFGR#1211 |\n| 1196031005 | 1997 | MFGR#1212 |\n| 1056458336 | 1997 | MFGR#1213 |\n| 352179650 | 1997 | MFGR#1214 |\n| 511058114 | 1997 | MFGR#1215 |\n| 658259312 | 1997 | MFGR#1216 |\n| 1238450697 | 1997 | MFGR#1217 |\n| 376245955 | 1997 | MFGR#1218 |\n| 913437812 | 1997 | MFGR#1219 |\n| 1114996000 | 1997 | MFGR#122 |\n| 814059433 | 1997 | MFGR#1220 |\n| 817328516 | 1997 | MFGR#1221 |\n| 541428597 | 1997 | MFGR#1222 |\n| 1260539052 | 1997 | MFGR#1223 |\n| 1766426582 | 1997 | MFGR#1224 |\n| 1221271245 | 1997 | MFGR#1225 |\n| 1499152922 | 1997 | MFGR#1226 |\n| 491586909 | 1997 | MFGR#1227 |\n| 911517084 | 1997 | MFGR#1228 |\n| 728186585 | 1997 | MFGR#1229 |\n| 904363416 | 1997 | MFGR#123 |\n| 605369014 | 1997 | MFGR#1230 |\n| 290370455 | 1997 | MFGR#1231 |\n| 602414397 | 1997 | MFGR#1232 |\n| 765339065 | 1997 | MFGR#1233 |\n| 1170973957 | 1997 | MFGR#1234 |\n| 860319765 | 1997 | MFGR#1235 |\n| 1031080311 | 1997 | MFGR#1236 |\n| 736404810 | 1997 | MFGR#1237 |\n| 1012330790 | 1997 | MFGR#1238 |\n| 681055343 | 1997 | MFGR#1239 |\n| 601626600 | 1997 | MFGR#124 |\n| 920404157 | 1997 | MFGR#1240 |\n| 1007678757 | 1997 | MFGR#125 |\n| 622347203 | 1997 | MFGR#126 |\n| 1215295592 | 1997 | MFGR#127 |\n| 822274972 | 1997 | MFGR#128 |\n| 643903475 | 1997 | MFGR#129 |\n| 470008435 | 1998 | MFGR#121 |\n| 568508492 | 1998 | MFGR#1210 |\n| 323759101 | 1998 | MFGR#1211 |\n| 572013331 | 1998 | MFGR#1212 |\n| 448137748 | 1998 | MFGR#1213 |\n| 137422458 | 1998 | MFGR#1214 |\n| 346491756 | 1998 | MFGR#1215 |\n| 454542243 | 1998 | MFGR#1216 |\n| 759205210 | 1998 | MFGR#1217 |\n| 674544462 | 1998 | MFGR#1218 |\n| 735952270 | 1998 | MFGR#1219 |\n| 490186568 | 1998 | MFGR#122 |\n| 769456686 | 1998 | MFGR#1220 |\n| 654540341 | 1998 | MFGR#1221 |\n| 800329859 | 1998 | MFGR#1222 |\n| 263849231 | 1998 | MFGR#1223 |\n| 445461642 | 1998 | MFGR#1224 |\n| 387808862 | 1998 | MFGR#1225 |\n| 675424382 | 1998 | MFGR#1226 |\n| 265906673 | 1998 | MFGR#1227 |\n| 585938371 | 1998 | MFGR#1228 |\n| 683188537 | 1998 | MFGR#1229 |\n| 304403717 | 1998 | MFGR#123 |\n| 533781674 | 1998 | MFGR#1230 |\n| 304060011 | 1998 | MFGR#1231 |\n| 635275907 | 1998 | MFGR#1232 |\n| 658295080 | 1998 | MFGR#1233 |\n| 524133341 | 1998 | MFGR#1234 |\n| 363911877 | 1998 | MFGR#1235 |\n| 300885635 | 1998 | MFGR#1236 |\n| 532608453 | 1998 | MFGR#1237 |\n| 484291410 | 1998 | MFGR#1238 |\n| 445336624 | 1998 | MFGR#1239 |\n| 719027801 | 1998 | MFGR#124 |\n| 518860961 | 1998 | MFGR#1240 |\n| 491235383 | 1998 | MFGR#125 |\n| 520917638 | 1998 | MFGR#126 |\n| 1158787745 | 1998 | MFGR#127 |\n| 401190922 | 1998 | MFGR#128 |\n| 406656337 | 1998 | MFGR#129 |\n+-----------------+------+-----------+\n\n-- Q2.2\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand |\n+-----------------+------+-----------+\n| 1259802358 | 1992 | MFGR#2221 |\n| 1728549344 | 1992 | MFGR#2222 |\n| 1375260024 | 1992 | MFGR#2223 |\n| 1299982475 | 1992 | MFGR#2224 |\n| 1541960331 | 1992 | MFGR#2225 |\n| 1151853513 | 1992 | MFGR#2226 |\n| 1271175264 | 1992 | MFGR#2227 |\n| 1726441695 | 1992 | MFGR#2228 |\n| 1251460032 | 1993 | MFGR#2221 |\n| 1331062515 | 1993 | MFGR#2222 |\n| 902809293 | 1993 | MFGR#2223 |\n| 980512417 | 1993 | MFGR#2224 |\n| 1253088003 | 1993 | MFGR#2225 |\n| 959195148 | 1993 | MFGR#2226 |\n| 555593932 | 1993 | MFGR#2227 |\n| 2186479174 | 1993 | MFGR#2228 |\n| 1094092222 | 1994 | MFGR#2221 |\n| 1491699323 | 1994 | MFGR#2222 |\n| 1501160826 | 1994 | MFGR#2223 |\n| 1387107418 | 1994 | MFGR#2224 |\n| 1641588884 | 1994 | MFGR#2225 |\n| 1387296390 | 1994 | MFGR#2226 |\n| 1038341470 | 1994 | MFGR#2227 |\n| 1565763138 | 1994 | MFGR#2228 |\n| 1412945650 | 1995 | MFGR#2221 |\n| 1546178356 | 1995 | MFGR#2222 |\n| 1218352073 | 1995 | MFGR#2223 |\n| 1052197762 | 1995 | MFGR#2224 |\n| 1822921900 | 1995 | MFGR#2225 |\n| 728142181 | 1995 | MFGR#2226 |\n| 966131607 | 1995 | MFGR#2227 |\n| 1379320517 | 1995 | MFGR#2228 |\n| 1042767284 | 1996 | MFGR#2221 |\n| 994733835 | 1996 | MFGR#2222 |\n| 1615788545 | 1996 | MFGR#2223 |\n| 1113980216 | 1996 | MFGR#2224 |\n| 1622570253 | 1996 | MFGR#2225 |\n| 1540226758 | 1996 | MFGR#2226 |\n| 1115687883 | 1996 | MFGR#2227 |\n| 1716355343 | 1996 | MFGR#2228 |\n| 867705636 | 1997 | MFGR#2221 |\n| 1529877498 | 1997 | MFGR#2222 |\n| 1594444450 | 1997 | MFGR#2223 |\n| 587421043 | 1997 | MFGR#2224 |\n| 1112274470 | 1997 | MFGR#2225 |\n| 1327884722 | 1997 | MFGR#2226 |\n| 884180880 | 1997 | MFGR#2227 |\n| 1664207656 | 1997 | MFGR#2228 |\n| 827743515 | 1998 | MFGR#2221 |\n| 662242310 | 1998 | MFGR#2222 |\n| 861445539 | 1998 | MFGR#2223 |\n| 694538672 | 1998 | MFGR#2224 |\n| 675179021 | 1998 | MFGR#2225 |\n| 480728720 | 1998 | MFGR#2226 |\n| 643763072 | 1998 | MFGR#2227 |\n| 994499201 | 1998 | MFGR#2228 |\n+-----------------+------+-----------+\n\n-- Q2.3\n+-----------------+------+-----------+\n| sum(lo_revenue) | year | p_brand |\n+-----------------+------+-----------+\n| 1428843284 | 1992 | MFGR#2239 |\n| 1865666054 | 1993 | MFGR#2239 |\n| 2242753254 | 1994 | MFGR#2239 |\n| 1446677305 | 1995 | MFGR#2239 |\n| 921681503 | 1996 | MFGR#2239 |\n| 1549990572 | 1997 | MFGR#2239 |\n| 926327433 | 1998 | MFGR#2239 |\n+-----------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation | s_nation | year | revenue |\n+-----------+-----------+------+-------------+\n| VIETNAM | CHINA | 1992 | 17194479086 |\n| JAPAN | CHINA | 1992 | 15572594510 |\n| JAPAN | JAPAN | 1992 | 13861682954 |\n| INDONESIA | CHINA | 1992 | 13499663933 |\n| VIETNAM | INDONESIA | 1992 | 13163103649 |\n| JAPAN | INDONESIA | 1992 | 13035158590 |\n| INDIA | CHINA | 1992 | 12987688902 |\n| INDONESIA | JAPAN | 1992 | 12939737918 |\n| VIETNAM | JAPAN | 1992 | 12174715858 |\n| JAPAN | VIETNAM | 1992 | 11669093753 |\n| INDIA | INDONESIA | 1992 | 11452602145 |\n| INDONESIA | INDONESIA | 1992 | 10394407561 |\n| INDIA | JAPAN | 1992 | 10313084900 |\n| JAPAN | INDIA | 1992 | 10035511089 |\n| CHINA | CHINA | 1992 | 9828744666 |\n| VIETNAM | VIETNAM | 1992 | 9701522505 |\n| INDONESIA | INDIA | 1992 | 9271105764 |\n| INDIA | INDIA | 1992 | 8879645522 |\n| CHINA | INDONESIA | 1992 | 8373693838 |\n| CHINA | JAPAN | 1992 | 8051248951 |\n| VIETNAM | INDIA | 1992 | 7804539029 |\n| INDONESIA | VIETNAM | 1992 | 7615465790 |\n| CHINA | INDIA | 1992 | 7344868842 |\n| INDIA | VIETNAM | 1992 | 6830508508 |\n| CHINA | VIETNAM | 1992 | 6529888238 |\n| JAPAN | CHINA | 1993 | 18839180326 |\n| VIETNAM | CHINA | 1993 | 14761890330 |\n| JAPAN | INDONESIA | 1993 | 13648082171 |\n| INDONESIA | CHINA | 1993 | 13518181805 |\n| INDIA | CHINA | 1993 | 13249555999 |\n| JAPAN | JAPAN | 1993 | 12667833152 |\n| JAPAN | VIETNAM | 1993 | 11529854580 |\n| CHINA | CHINA | 1993 | 11216468573 |\n| INDONESIA | INDONESIA | 1993 | 10953284722 |\n| VIETNAM | INDONESIA | 1993 | 10582912267 |\n| INDIA | JAPAN | 1993 | 10482950584 |\n| VIETNAM | JAPAN | 1993 | 10370811002 |\n| INDIA | INDONESIA | 1993 | 10145286112 |\n| INDONESIA | JAPAN | 1993 | 9850020303 |\n| VIETNAM | VIETNAM | 1993 | 9591468153 |\n| CHINA | INDONESIA | 1993 | 9015864524 |\n| CHINA | JAPAN | 1993 | 8972996729 |\n| INDONESIA | INDIA | 1993 | 8903638786 |\n| JAPAN | INDIA | 1993 | 8848048514 |\n| INDONESIA | VIETNAM | 1993 | 8024464882 |\n| VIETNAM | INDIA | 1993 | 7806575746 |\n| INDIA | VIETNAM | 1993 | 7537331106 |\n| INDIA | INDIA | 1993 | 7211053846 |\n| CHINA | VIETNAM | 1993 | 6700022269 |\n| CHINA | INDIA | 1993 | 6327331541 |\n| JAPAN | CHINA | 1994 | 15661051644 |\n| VIETNAM | CHINA | 1994 | 13958591931 |\n| JAPAN | JAPAN | 1994 | 13566252348 |\n| CHINA | CHINA | 1994 | 12870010072 |\n| VIETNAM | JAPAN | 1994 | 12728320716 |\n| INDONESIA | CHINA | 1994 | 12295790872 |\n| INDIA | CHINA | 1994 | 12166419121 |\n| JAPAN | INDONESIA | 1994 | 11358955025 |\n| INDIA | INDONESIA | 1994 | 11111248365 |\n| JAPAN | INDIA | 1994 | 10078806371 |\n| VIETNAM | INDONESIA | 1994 | 9923852578 |\n| INDIA | JAPAN | 1994 | 9839136767 |\n| CHINA | JAPAN | 1994 | 9836586308 |\n| INDONESIA | JAPAN | 1994 | 9786694572 |\n| INDIA | VIETNAM | 1994 | 9551081406 |\n| JAPAN | VIETNAM | 1994 | 9035431932 |\n| VIETNAM | INDIA | 1994 | 9032319402 |\n| INDONESIA | INDONESIA | 1994 | 8876012426 |\n| CHINA | INDONESIA | 1994 | 8375581981 |\n| VIETNAM | VIETNAM | 1994 | 8095638136 |\n| INDONESIA | INDIA | 1994 | 7943993512 |\n| INDONESIA | VIETNAM | 1994 | 7927236697 |\n| INDIA | INDIA | 1994 | 7534915457 |\n| CHINA | VIETNAM | 1994 | 6062387221 |\n| CHINA | INDIA | 1994 | 5816794324 |\n| VIETNAM | CHINA | 1995 | 15128423080 |\n| INDONESIA | CHINA | 1995 | 14794647970 |\n| INDIA | CHINA | 1995 | 14724240804 |\n| JAPAN | CHINA | 1995 | 14579848516 |\n| CHINA | CHINA | 1995 | 14296657586 |\n| INDIA | JAPAN | 1995 | 13511381754 |\n| JAPAN | JAPAN | 1995 | 12015968288 |\n| VIETNAM | INDONESIA | 1995 | 11290647784 |\n| JAPAN | INDONESIA | 1995 | 10968840402 |\n| INDIA | INDONESIA | 1995 | 10879296370 |\n| CHINA | INDONESIA | 1995 | 10611767914 |\n| VIETNAM | JAPAN | 1995 | 10493043807 |\n| INDONESIA | INDONESIA | 1995 | 10350165199 |\n| VIETNAM | INDIA | 1995 | 10147175135 |\n| CHINA | JAPAN | 1995 | 9967113498 |\n| JAPAN | VIETNAM | 1995 | 9871240910 |\n| INDONESIA | JAPAN | 1995 | 9554798320 |\n| JAPAN | INDIA | 1995 | 9224478715 |\n| INDIA | INDIA | 1995 | 8880501531 |\n| VIETNAM | VIETNAM | 1995 | 8530802028 |\n| INDIA | VIETNAM | 1995 | 8470249830 |\n| CHINA | INDIA | 1995 | 8460557790 |\n| INDONESIA | VIETNAM | 1995 | 8393411088 |\n| CHINA | VIETNAM | 1995 | 7838238263 |\n| INDONESIA | INDIA | 1995 | 7001659338 |\n| JAPAN | CHINA | 1996 | 14974943391 |\n| INDIA | CHINA | 1996 | 14236197987 |\n| VIETNAM | CHINA | 1996 | 13723231674 |\n| JAPAN | INDONESIA | 1996 | 13304501801 |\n| INDONESIA | CHINA | 1996 | 12444022202 |\n| CHINA | CHINA | 1996 | 12120893189 |\n| INDIA | JAPAN | 1996 | 11649117519 |\n| INDONESIA | JAPAN | 1996 | 11345350775 |\n| VIETNAM | JAPAN | 1996 | 11294284203 |\n| INDONESIA | INDONESIA | 1996 | 11111201530 |\n| JAPAN | INDIA | 1996 | 10871364136 |\n| JAPAN | JAPAN | 1996 | 10836947449 |\n| INDIA | INDONESIA | 1996 | 10568008435 |\n| JAPAN | VIETNAM | 1996 | 10503890555 |\n| VIETNAM | INDONESIA | 1996 | 10494783196 |\n| INDONESIA | VIETNAM | 1996 | 9940440124 |\n| INDONESIA | INDIA | 1996 | 9864980677 |\n| VIETNAM | VIETNAM | 1996 | 9560258720 |\n| INDIA | VIETNAM | 1996 | 9324764214 |\n| INDIA | INDIA | 1996 | 9023346020 |\n| VIETNAM | INDIA | 1996 | 8968179949 |\n| CHINA | INDONESIA | 1996 | 8877441837 |\n| CHINA | JAPAN | 1996 | 8749420872 |\n| CHINA | VIETNAM | 1996 | 6973983457 |\n| CHINA | INDIA | 1996 | 6515658476 |\n| JAPAN | CHINA | 1997 | 15365039212 |\n| INDONESIA | CHINA | 1997 | 14159930904 |\n| VIETNAM | CHINA | 1997 | 13678288757 |\n| INDIA | CHINA | 1997 | 13599028484 |\n| JAPAN | JAPAN | 1997 | 12921870544 |\n| CHINA | CHINA | 1997 | 12720975220 |\n| VIETNAM | JAPAN | 1997 | 11929000810 |\n| VIETNAM | INDONESIA | 1997 | 11325447090 |\n| JAPAN | INDONESIA | 1997 | 10764312416 |\n| INDONESIA | JAPAN | 1997 | 10555558162 |\n| INDONESIA | INDONESIA | 1997 | 10416928126 |\n| CHINA | INDONESIA | 1997 | 10317902565 |\n| INDIA | JAPAN | 1997 | 10272590051 |\n| JAPAN | VIETNAM | 1997 | 9940032294 |\n| CHINA | JAPAN | 1997 | 9519485461 |\n| JAPAN | INDIA | 1997 | 9465935835 |\n| INDIA | INDONESIA | 1997 | 9405085270 |\n| INDONESIA | INDIA | 1997 | 8930955270 |\n| INDIA | INDIA | 1997 | 8295504178 |\n| VIETNAM | VIETNAM | 1997 | 8293412532 |\n| INDONESIA | VIETNAM | 1997 | 8116443059 |\n| INDIA | VIETNAM | 1997 | 7960292262 |\n| VIETNAM | INDIA | 1997 | 7529455873 |\n| CHINA | VIETNAM | 1997 | 7038413355 |\n| CHINA | INDIA | 1997 | 6530770558 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n\n+------------+------------+------+-----------+\n| c_city | s_city | year | revenue |\n+------------+------------+------+-----------+\n| CHINA 3 | CHINA 0 | 1992 | 539864249 |\n| CHINA 0 | CHINA 6 | 1992 | 471363128 |\n| CHINA 8 | CHINA 1 | 1992 | 421384110 |\n| CHINA 6 | CHINA 1 | 1992 | 382204882 |\n| CHINA 6 | CHINA 7 | 1992 | 355755835 |\n| CHINA 8 | CHINA 9 | 1992 | 349006417 |\n| CHINA 7 | CHINA 7 | 1992 | 320232842 |\n| CHINA 8 | CHINA 3 | 1992 | 296105733 |\n| CHINA 5 | CHINA 3 | 1992 | 277283951 |\n| CHINA 6 | CHINA 6 | 1992 | 265527771 |\n| CHINA 4 | CHINA 1 | 1992 | 237402078 |\n| CHINA 8 | CHINA 6 | 1992 | 234720401 |\n| CHINA 4 | CHINA 6 | 1992 | 230169075 |\n| CHINA 9 | CHINA 1 | 1992 | 223815249 |\n| CHINA 1 | CHINA 1 | 1992 | 223467947 |\n| CHINA 2 | CHINA 1 | 1992 | 219559691 |\n| CHINA 9 | CHINA 6 | 1992 | 205915890 |\n| CHINA 7 | CHINA 9 | 1992 | 201288909 |\n| CHINA 1 | CHINA 6 | 1992 | 195622902 |\n| CHINA 9 | CHINA 7 | 1992 | 190345063 |\n| CHINA 8 | CHINA 4 | 1992 | 174478626 |\n| CHINA 1 | CHINA 7 | 1992 | 173803257 |\n| CHINA 9 | CHINA 9 | 1992 | 162458028 |\n| CHINA 6 | CHINA 0 | 1992 | 154260702 |\n| CHINA 8 | CHINA 0 | 1992 | 149794069 |\n| CHINA 5 | CHINA 9 | 1992 | 149369922 |\n| CHINA 8 | CHINA 8 | 1992 | 147607252 |\n| CHINA 6 | CHINA 4 | 1992 | 147137516 |\n| CHINA 7 | CHINA 8 | 1992 | 139974858 |\n| CHINA 5 | CHINA 6 | 1992 | 138467127 |\n| CHINA 3 | CHINA 6 | 1992 | 119521008 |\n| CHINA 8 | CHINA 7 | 1992 | 109887269 |\n| CHINA 6 | CHINA 3 | 1992 | 107201214 |\n| CHINA 9 | CHINA 4 | 1992 | 101504450 |\n| CHINA 1 | CHINA 3 | 1992 | 101388208 |\n| CHINA 7 | CHINA 0 | 1992 | 98475237 |\n| CHINA 5 | CHINA 8 | 1992 | 98370738 |\n| CHINA 2 | CHINA 6 | 1992 | 93254616 |\n| CHINA 2 | CHINA 4 | 1992 | 86394644 |\n| CHINA 3 | CHINA 7 | 1992 | 81027008 |\n| CHINA 5 | CHINA 4 | 1992 | 78587418 |\n| CHINA 3 | CHINA 9 | 1992 | 78114762 |\n| CHINA 2 | CHINA 0 | 1992 | 77786892 |\n| CHINA 2 | CHINA 8 | 1992 | 75605732 |\n| CHINA 4 | CHINA 3 | 1992 | 75101512 |\n| CHINA 7 | CHINA 4 | 1992 | 74119240 |\n| CHINA 2 | CHINA 9 | 1992 | 73413108 |\n| CHINA 5 | CHINA 7 | 1992 | 73199718 |\n| CHINA 4 | CHINA 4 | 1992 | 72839118 |\n| CHINA 1 | CHINA 9 | 1992 | 68538220 |\n| CHINA 0 | CHINA 8 | 1992 | 65856888 |\n| CHINA 0 | CHINA 9 | 1992 | 65590624 |\n| CHINA 3 | CHINA 8 | 1992 | 64556586 |\n| CHINA 2 | CHINA 7 | 1992 | 63336330 |\n| CHINA 4 | CHINA 9 | 1992 | 57645963 |\n| CHINA 0 | CHINA 7 | 1992 | 55251918 |\n| CHINA 0 | CHINA 1 | 1992 | 51774462 |\n| CHINA 6 | CHINA 8 | 1992 | 45676858 |\n| CHINA 3 | CHINA 3 | 1992 | 41147560 |\n| CHINA 3 | CHINA 4 | 1992 | 36838082 |\n| CHINA 5 | CHINA 0 | 1992 | 36554488 |\n| CHINA 3 | CHINA 1 | 1992 | 32036313 |\n| CHINA 4 | CHINA 8 | 1992 | 31517575 |\n| CHINA 0 | CHINA 3 | 1992 | 25524054 |\n| CHINA 1 | CHINA 4 | 1992 | 12681846 |\n| CHINA 7 | CHINA 3 | 1992 | 11395152 |\n| CHINA 6 | CHINA 9 | 1992 | 8642375 |\n| CHINA 8 | CHINA 6 | 1993 | 638396852 |\n| CHINA 7 | CHINA 6 | 1993 | 576731239 |\n| CHINA 2 | CHINA 6 | 1993 | 528008729 |\n| CHINA 8 | CHINA 9 | 1993 | 522412584 |\n| CHINA 8 | CHINA 7 | 1993 | 475478848 |\n| CHINA 8 | CHINA 1 | 1993 | 452064153 |\n| CHINA 0 | CHINA 1 | 1993 | 425902649 |\n| CHINA 9 | CHINA 1 | 1993 | 405252987 |\n| CHINA 6 | CHINA 9 | 1993 | 385005953 |\n| CHINA 8 | CHINA 8 | 1993 | 382884778 |\n| CHINA 0 | CHINA 6 | 1993 | 344911487 |\n| CHINA 6 | CHINA 7 | 1993 | 341436211 |\n| CHINA 3 | CHINA 6 | 1993 | 291652051 |\n| CHINA 7 | CHINA 1 | 1993 | 257769861 |\n| CHINA 8 | CHINA 0 | 1993 | 231981252 |\n| CHINA 4 | CHINA 6 | 1993 | 215180968 |\n| CHINA 3 | CHINA 0 | 1993 | 213320777 |\n| CHINA 9 | CHINA 6 | 1993 | 207281000 |\n| CHINA 5 | CHINA 9 | 1993 | 206555882 |\n| CHINA 6 | CHINA 1 | 1993 | 205665388 |\n| CHINA 5 | CHINA 1 | 1993 | 193491875 |\n| CHINA 2 | CHINA 9 | 1993 | 193324425 |\n| CHINA 5 | CHINA 8 | 1993 | 190521023 |\n| CHINA 7 | CHINA 0 | 1993 | 183487919 |\n| CHINA 0 | CHINA 9 | 1993 | 170223958 |\n| CHINA 6 | CHINA 8 | 1993 | 166821272 |\n| CHINA 3 | CHINA 8 | 1993 | 163053528 |\n| CHINA 2 | CHINA 0 | 1993 | 158276154 |\n| CHINA 3 | CHINA 1 | 1993 | 153652018 |\n| CHINA 5 | CHINA 6 | 1993 | 151359347 |\n| CHINA 6 | CHINA 0 | 1993 | 140494698 |\n| CHINA 8 | CHINA 4 | 1993 | 139857147 |\n| CHINA 2 | CHINA 7 | 1993 | 136009418 |\n| CHINA 5 | CHINA 7 | 1993 | 133892119 |\n| CHINA 9 | CHINA 9 | 1993 | 118965507 |\n| CHINA 1 | CHINA 1 | 1993 | 108898379 |\n| CHINA 6 | CHINA 6 | 1993 | 100311475 |\n| CHINA 0 | CHINA 4 | 1993 | 93483068 |\n| CHINA 1 | CHINA 4 | 1993 | 87714152 |\n| CHINA 4 | CHINA 1 | 1993 | 87690658 |\n| CHINA 4 | CHINA 7 | 1993 | 83701574 |\n| CHINA 1 | CHINA 0 | 1993 | 82670983 |\n| CHINA 7 | CHINA 4 | 1993 | 77396461 |\n| CHINA 5 | CHINA 4 | 1993 | 73556161 |\n| CHINA 4 | CHINA 8 | 1993 | 72203335 |\n| CHINA 0 | CHINA 7 | 1993 | 70395334 |\n| CHINA 3 | CHINA 4 | 1993 | 64771003 |\n| CHINA 7 | CHINA 8 | 1993 | 64514099 |\n| CHINA 3 | CHINA 7 | 1993 | 62868516 |\n| CHINA 8 | CHINA 3 | 1993 | 56504804 |\n| CHINA 2 | CHINA 4 | 1993 | 56031779 |\n| CHINA 1 | CHINA 7 | 1993 | 48951262 |\n| CHINA 7 | CHINA 3 | 1993 | 45962220 |\n| CHINA 4 | CHINA 9 | 1993 | 43158138 |\n| CHINA 7 | CHINA 9 | 1993 | 42611979 |\n| CHINA 2 | CHINA 8 | 1993 | 38092546 |\n| CHINA 1 | CHINA 9 | 1993 | 29665374 |\n| CHINA 1 | CHINA 3 | 1993 | 23991216 |\n| CHINA 6 | CHINA 6 | 1994 | 596294890 |\n| CHINA 8 | CHINA 6 | 1994 | 542104721 |\n| CHINA 6 | CHINA 1 | 1994 | 504359553 |\n| CHINA 3 | CHINA 7 | 1994 | 476727294 |\n| CHINA 3 | CHINA 6 | 1994 | 476349724 |\n| CHINA 8 | CHINA 9 | 1994 | 427241348 |\n| CHINA 6 | CHINA 9 | 1994 | 358191581 |\n| CHINA 9 | CHINA 6 | 1994 | 352344057 |\n| CHINA 3 | CHINA 0 | 1994 | 351708546 |\n| CHINA 8 | CHINA 0 | 1994 | 351131413 |\n| CHINA 3 | CHINA 3 | 1994 | 339279574 |\n| CHINA 0 | CHINA 1 | 1994 | 298307857 |\n| CHINA 0 | CHINA 7 | 1994 | 289536010 |\n| CHINA 0 | CHINA 6 | 1994 | 285639032 |\n| CHINA 7 | CHINA 6 | 1994 | 263170455 |\n| CHINA 2 | CHINA 8 | 1994 | 250332990 |\n| CHINA 6 | CHINA 4 | 1994 | 235897763 |\n| CHINA 5 | CHINA 1 | 1994 | 234681515 |\n| CHINA 8 | CHINA 7 | 1994 | 234390101 |\n| CHINA 1 | CHINA 6 | 1994 | 232792764 |\n| CHINA 8 | CHINA 1 | 1994 | 223808842 |\n| CHINA 4 | CHINA 6 | 1994 | 209522926 |\n| CHINA 8 | CHINA 4 | 1994 | 208632636 |\n| CHINA 7 | CHINA 3 | 1994 | 202424117 |\n| CHINA 4 | CHINA 7 | 1994 | 185487544 |\n| CHINA 2 | CHINA 7 | 1994 | 183551771 |\n| CHINA 7 | CHINA 1 | 1994 | 178421732 |\n| CHINA 4 | CHINA 1 | 1994 | 176262868 |\n| CHINA 5 | CHINA 6 | 1994 | 173651872 |\n| CHINA 0 | CHINA 4 | 1994 | 173584501 |\n| CHINA 8 | CHINA 8 | 1994 | 172179808 |\n| CHINA 9 | CHINA 1 | 1994 | 169617585 |\n| CHINA 0 | CHINA 9 | 1994 | 167569085 |\n| CHINA 5 | CHINA 8 | 1994 | 162066559 |\n| CHINA 7 | CHINA 9 | 1994 | 161041255 |\n| CHINA 5 | CHINA 4 | 1994 | 154820955 |\n| CHINA 7 | CHINA 0 | 1994 | 152844960 |\n| CHINA 2 | CHINA 6 | 1994 | 149839190 |\n| CHINA 7 | CHINA 8 | 1994 | 149536114 |\n| CHINA 1 | CHINA 4 | 1994 | 142403628 |\n| CHINA 9 | CHINA 9 | 1994 | 131064832 |\n| CHINA 2 | CHINA 1 | 1994 | 124489283 |\n| CHINA 2 | CHINA 0 | 1994 | 114263273 |\n| CHINA 5 | CHINA 7 | 1994 | 113311766 |\n| CHINA 8 | CHINA 3 | 1994 | 112573609 |\n| CHINA 3 | CHINA 4 | 1994 | 104903651 |\n| CHINA 4 | CHINA 0 | 1994 | 101914439 |\n| CHINA 3 | CHINA 1 | 1994 | 98253251 |\n| CHINA 1 | CHINA 7 | 1994 | 94582288 |\n| CHINA 4 | CHINA 4 | 1994 | 92818317 |\n| CHINA 1 | CHINA 9 | 1994 | 85220541 |\n| CHINA 6 | CHINA 3 | 1994 | 84604801 |\n| CHINA 0 | CHINA 3 | 1994 | 77574978 |\n| CHINA 1 | CHINA 3 | 1994 | 74435316 |\n| CHINA 4 | CHINA 9 | 1994 | 72622300 |\n| CHINA 3 | CHINA 8 | 1994 | 72559366 |\n| CHINA 9 | CHINA 0 | 1994 | 69298222 |\n| CHINA 3 | CHINA 9 | 1994 | 67472592 |\n| CHINA 6 | CHINA 8 | 1994 | 66271372 |\n| CHINA 7 | CHINA 4 | 1994 | 59634606 |\n| CHINA 2 | CHINA 9 | 1994 | 56882136 |\n| CHINA 1 | CHINA 1 | 1994 | 56592337 |\n| CHINA 5 | CHINA 9 | 1994 | 52879724 |\n| CHINA 9 | CHINA 4 | 1994 | 49324497 |\n| CHINA 2 | CHINA 3 | 1994 | 45042384 |\n| CHINA 7 | CHINA 7 | 1994 | 44458451 |\n| CHINA 5 | CHINA 0 | 1994 | 39091925 |\n| CHINA 9 | CHINA 3 | 1994 | 39082405 |\n| CHINA 0 | CHINA 8 | 1994 | 28203459 |\n| CHINA 6 | CHINA 7 | 1994 | 27243775 |\n| CHINA 0 | CHINA 0 | 1994 | 15591040 |\n| CHINA 2 | CHINA 6 | 1995 | 832176707 |\n| CHINA 8 | CHINA 6 | 1995 | 793322102 |\n| CHINA 3 | CHINA 7 | 1995 | 505446788 |\n| CHINA 7 | CHINA 9 | 1995 | 483519933 |\n| CHINA 4 | CHINA 6 | 1995 | 440320366 |\n| CHINA 8 | CHINA 1 | 1995 | 394522570 |\n| CHINA 7 | CHINA 1 | 1995 | 393861389 |\n| CHINA 5 | CHINA 1 | 1995 | 343166828 |\n| CHINA 1 | CHINA 7 | 1995 | 341736584 |\n| CHINA 8 | CHINA 7 | 1995 | 323623203 |\n| CHINA 6 | CHINA 6 | 1995 | 312876143 |\n| CHINA 3 | CHINA 6 | 1995 | 306516324 |\n| CHINA 7 | CHINA 6 | 1995 | 294840537 |\n| CHINA 3 | CHINA 3 | 1995 | 290066240 |\n| CHINA 8 | CHINA 3 | 1995 | 289182495 |\n| CHINA 3 | CHINA 1 | 1995 | 288853766 |\n| CHINA 0 | CHINA 1 | 1995 | 279082523 |\n| CHINA 0 | CHINA 8 | 1995 | 265291443 |\n| CHINA 1 | CHINA 6 | 1995 | 262283412 |\n| CHINA 4 | CHINA 1 | 1995 | 246559891 |\n| CHINA 2 | CHINA 8 | 1995 | 246465167 |\n| CHINA 6 | CHINA 7 | 1995 | 246385862 |\n| CHINA 9 | CHINA 6 | 1995 | 231314393 |\n| CHINA 2 | CHINA 7 | 1995 | 224354491 |\n| CHINA 4 | CHINA 7 | 1995 | 222368398 |\n| CHINA 0 | CHINA 7 | 1995 | 221334917 |\n| CHINA 6 | CHINA 3 | 1995 | 217756587 |\n| CHINA 6 | CHINA 9 | 1995 | 215736018 |\n| CHINA 4 | CHINA 9 | 1995 | 210496516 |\n| CHINA 0 | CHINA 6 | 1995 | 197891458 |\n| CHINA 8 | CHINA 9 | 1995 | 192018213 |\n| CHINA 7 | CHINA 0 | 1995 | 188804482 |\n| CHINA 5 | CHINA 6 | 1995 | 186378531 |\n| CHINA 6 | CHINA 1 | 1995 | 165831073 |\n| CHINA 1 | CHINA 3 | 1995 | 165118263 |\n| CHINA 6 | CHINA 8 | 1995 | 157640218 |\n| CHINA 1 | CHINA 1 | 1995 | 150838433 |\n| CHINA 1 | CHINA 4 | 1995 | 147632879 |\n| CHINA 6 | CHINA 0 | 1995 | 147314401 |\n| CHINA 5 | CHINA 4 | 1995 | 142820978 |\n| CHINA 5 | CHINA 9 | 1995 | 141416829 |\n| CHINA 2 | CHINA 0 | 1995 | 135608473 |\n| CHINA 5 | CHINA 7 | 1995 | 131596218 |\n| CHINA 0 | CHINA 4 | 1995 | 129159370 |\n| CHINA 3 | CHINA 9 | 1995 | 126837748 |\n| CHINA 8 | CHINA 0 | 1995 | 126564932 |\n| CHINA 0 | CHINA 3 | 1995 | 121337041 |\n| CHINA 7 | CHINA 7 | 1995 | 118697587 |\n| CHINA 5 | CHINA 8 | 1995 | 116538842 |\n| CHINA 8 | CHINA 8 | 1995 | 110161904 |\n| CHINA 9 | CHINA 0 | 1995 | 109582187 |\n| CHINA 9 | CHINA 1 | 1995 | 103455098 |\n| CHINA 2 | CHINA 1 | 1995 | 100264691 |\n| CHINA 7 | CHINA 3 | 1995 | 99011859 |\n| CHINA 3 | CHINA 0 | 1995 | 90383390 |\n| CHINA 4 | CHINA 3 | 1995 | 89908903 |\n| CHINA 7 | CHINA 8 | 1995 | 81425699 |\n| CHINA 3 | CHINA 4 | 1995 | 77577579 |\n| CHINA 4 | CHINA 8 | 1995 | 74805746 |\n| CHINA 9 | CHINA 7 | 1995 | 74597020 |\n| CHINA 9 | CHINA 9 | 1995 | 73514511 |\n| CHINA 5 | CHINA 0 | 1995 | 73274726 |\n| CHINA 8 | CHINA 4 | 1995 | 61708487 |\n| CHINA 1 | CHINA 0 | 1995 | 58753734 |\n| CHINA 3 | CHINA 8 | 1995 | 57133566 |\n| CHINA 9 | CHINA 4 | 1995 | 53259334 |\n| CHINA 1 | CHINA 9 | 1995 | 46177797 |\n| CHINA 2 | CHINA 4 | 1995 | 45147325 |\n| CHINA 0 | CHINA 0 | 1995 | 43963173 |\n| CHINA 0 | CHINA 9 | 1995 | 40184107 |\n| CHINA 1 | CHINA 8 | 1995 | 18859188 |\n| CHINA 8 | CHINA 7 | 1996 | 621957444 |\n| CHINA 3 | CHINA 9 | 1996 | 530082848 |\n| CHINA 8 | CHINA 6 | 1996 | 525755549 |\n| CHINA 8 | CHINA 1 | 1996 | 399229343 |\n| CHINA 6 | CHINA 7 | 1996 | 365540749 |\n| CHINA 8 | CHINA 8 | 1996 | 351864283 |\n| CHINA 1 | CHINA 6 | 1996 | 329186504 |\n| CHINA 9 | CHINA 6 | 1996 | 321113085 |\n| CHINA 3 | CHINA 6 | 1996 | 318264871 |\n| CHINA 2 | CHINA 6 | 1996 | 315233397 |\n| CHINA 2 | CHINA 9 | 1996 | 285852841 |\n| CHINA 9 | CHINA 9 | 1996 | 264510548 |\n| CHINA 5 | CHINA 6 | 1996 | 261385523 |\n| CHINA 8 | CHINA 9 | 1996 | 259497265 |\n| CHINA 6 | CHINA 6 | 1996 | 258200131 |\n| CHINA 4 | CHINA 9 | 1996 | 257345949 |\n| CHINA 6 | CHINA 9 | 1996 | 247667288 |\n| CHINA 2 | CHINA 7 | 1996 | 234569026 |\n| CHINA 2 | CHINA 1 | 1996 | 218568966 |\n| CHINA 4 | CHINA 1 | 1996 | 207383476 |\n| CHINA 0 | CHINA 1 | 1996 | 204596428 |\n| CHINA 3 | CHINA 0 | 1996 | 204375870 |\n| CHINA 4 | CHINA 0 | 1996 | 202299286 |\n| CHINA 4 | CHINA 4 | 1996 | 191983261 |\n| CHINA 4 | CHINA 8 | 1996 | 183961012 |\n| CHINA 4 | CHINA 6 | 1996 | 183872085 |\n| CHINA 6 | CHINA 8 | 1996 | 182132356 |\n| CHINA 7 | CHINA 9 | 1996 | 170941341 |\n| CHINA 0 | CHINA 6 | 1996 | 168082672 |\n| CHINA 1 | CHINA 7 | 1996 | 165942066 |\n| CHINA 1 | CHINA 9 | 1996 | 165878775 |\n| CHINA 9 | CHINA 8 | 1996 | 156009357 |\n| CHINA 7 | CHINA 7 | 1996 | 155842944 |\n| CHINA 2 | CHINA 0 | 1996 | 147709906 |\n| CHINA 5 | CHINA 7 | 1996 | 147257366 |\n| CHINA 1 | CHINA 8 | 1996 | 141840928 |\n| CHINA 2 | CHINA 4 | 1996 | 136244052 |\n| CHINA 9 | CHINA 0 | 1996 | 130997019 |\n| CHINA 1 | CHINA 0 | 1996 | 124362038 |\n| CHINA 0 | CHINA 9 | 1996 | 114011231 |\n| CHINA 7 | CHINA 3 | 1996 | 112398764 |\n| CHINA 4 | CHINA 7 | 1996 | 110567337 |\n| CHINA 3 | CHINA 4 | 1996 | 109269982 |\n| CHINA 5 | CHINA 1 | 1996 | 107482704 |\n| CHINA 6 | CHINA 4 | 1996 | 105485170 |\n| CHINA 1 | CHINA 4 | 1996 | 105320270 |\n| CHINA 0 | CHINA 7 | 1996 | 102545071 |\n| CHINA 2 | CHINA 3 | 1996 | 100407151 |\n| CHINA 0 | CHINA 4 | 1996 | 95913303 |\n| CHINA 7 | CHINA 0 | 1996 | 94706269 |\n| CHINA 6 | CHINA 1 | 1996 | 86949951 |\n| CHINA 8 | CHINA 3 | 1996 | 84157344 |\n| CHINA 2 | CHINA 8 | 1996 | 83176903 |\n| CHINA 5 | CHINA 9 | 1996 | 83104330 |\n| CHINA 7 | CHINA 8 | 1996 | 81490639 |\n| CHINA 9 | CHINA 3 | 1996 | 79655829 |\n| CHINA 5 | CHINA 0 | 1996 | 77489995 |\n| CHINA 8 | CHINA 0 | 1996 | 76989056 |\n| CHINA 9 | CHINA 1 | 1996 | 72011031 |\n| CHINA 7 | CHINA 4 | 1996 | 64764322 |\n| CHINA 5 | CHINA 4 | 1996 | 62827767 |\n| CHINA 5 | CHINA 8 | 1996 | 62673237 |\n| CHINA 7 | CHINA 6 | 1996 | 61880459 |\n| CHINA 3 | CHINA 7 | 1996 | 56642844 |\n| CHINA 3 | CHINA 1 | 1996 | 50799366 |\n| CHINA 3 | CHINA 3 | 1996 | 42601269 |\n| CHINA 4 | CHINA 3 | 1996 | 38290290 |\n| CHINA 3 | CHINA 8 | 1996 | 21263056 |\n| CHINA 7 | CHINA 1 | 1996 | 14836937 |\n| CHINA 5 | CHINA 3 | 1996 | 13611339 |\n| CHINA 1 | CHINA 3 | 1996 | 8430793 |\n| CHINA 1 | CHINA 1 | 1996 | 1601332 |\n| CHINA 1 | CHINA 7 | 1997 | 664436721 |\n| CHINA 8 | CHINA 9 | 1997 | 585552148 |\n| CHINA 8 | CHINA 6 | 1997 | 543571889 |\n| CHINA 8 | CHINA 7 | 1997 | 516131917 |\n| CHINA 6 | CHINA 7 | 1997 | 467477883 |\n| CHINA 3 | CHINA 9 | 1997 | 444914344 |\n| CHINA 5 | CHINA 6 | 1997 | 353316321 |\n| CHINA 6 | CHINA 4 | 1997 | 338136205 |\n| CHINA 0 | CHINA 7 | 1997 | 329137493 |\n| CHINA 5 | CHINA 1 | 1997 | 328142466 |\n| CHINA 8 | CHINA 4 | 1997 | 308276385 |\n| CHINA 6 | CHINA 9 | 1997 | 306814317 |\n| CHINA 5 | CHINA 9 | 1997 | 301145803 |\n| CHINA 7 | CHINA 1 | 1997 | 299575802 |\n| CHINA 8 | CHINA 8 | 1997 | 282083295 |\n| CHINA 4 | CHINA 9 | 1997 | 280242025 |\n| CHINA 9 | CHINA 1 | 1997 | 253155313 |\n| CHINA 4 | CHINA 6 | 1997 | 234247182 |\n| CHINA 5 | CHINA 0 | 1997 | 217246162 |\n| CHINA 9 | CHINA 4 | 1997 | 215424663 |\n| CHINA 0 | CHINA 6 | 1997 | 211152240 |\n| CHINA 3 | CHINA 6 | 1997 | 205982217 |\n| CHINA 7 | CHINA 6 | 1997 | 196440117 |\n| CHINA 1 | CHINA 6 | 1997 | 195757737 |\n| CHINA 2 | CHINA 3 | 1997 | 189836909 |\n| CHINA 7 | CHINA 8 | 1997 | 189291379 |\n| CHINA 9 | CHINA 6 | 1997 | 189236146 |\n| CHINA 3 | CHINA 1 | 1997 | 188537684 |\n| CHINA 9 | CHINA 7 | 1997 | 182516267 |\n| CHINA 0 | CHINA 0 | 1997 | 182459980 |\n| CHINA 5 | CHINA 8 | 1997 | 177077882 |\n| CHINA 2 | CHINA 6 | 1997 | 176030529 |\n| CHINA 2 | CHINA 1 | 1997 | 168770050 |\n| CHINA 8 | CHINA 0 | 1997 | 167294093 |\n| CHINA 4 | CHINA 3 | 1997 | 161980658 |\n| CHINA 3 | CHINA 4 | 1997 | 154433882 |\n| CHINA 6 | CHINA 6 | 1997 | 153336736 |\n| CHINA 6 | CHINA 3 | 1997 | 151596497 |\n| CHINA 8 | CHINA 1 | 1997 | 145432603 |\n| CHINA 1 | CHINA 4 | 1997 | 126773981 |\n| CHINA 1 | CHINA 0 | 1997 | 120594770 |\n| CHINA 7 | CHINA 3 | 1997 | 119618460 |\n| CHINA 6 | CHINA 1 | 1997 | 119529805 |\n| CHINA 2 | CHINA 9 | 1997 | 114591288 |\n| CHINA 7 | CHINA 7 | 1997 | 111335941 |\n| CHINA 5 | CHINA 3 | 1997 | 111044153 |\n| CHINA 6 | CHINA 0 | 1997 | 104404276 |\n| CHINA 1 | CHINA 1 | 1997 | 98869501 |\n| CHINA 7 | CHINA 0 | 1997 | 97198605 |\n| CHINA 7 | CHINA 9 | 1997 | 92872632 |\n| CHINA 0 | CHINA 9 | 1997 | 91097832 |\n| CHINA 9 | CHINA 9 | 1997 | 86479272 |\n| CHINA 2 | CHINA 7 | 1997 | 79380820 |\n| CHINA 9 | CHINA 0 | 1997 | 78499693 |\n| CHINA 1 | CHINA 9 | 1997 | 73589328 |\n| CHINA 2 | CHINA 8 | 1997 | 71633835 |\n| CHINA 8 | CHINA 3 | 1997 | 70505885 |\n| CHINA 3 | CHINA 0 | 1997 | 61039282 |\n| CHINA 0 | CHINA 3 | 1997 | 58325113 |\n| CHINA 5 | CHINA 7 | 1997 | 55476389 |\n| CHINA 4 | CHINA 7 | 1997 | 46480159 |\n| CHINA 0 | CHINA 1 | 1997 | 38223038 |\n| CHINA 4 | CHINA 1 | 1997 | 21636342 |\n| CHINA 9 | CHINA 3 | 1997 | 13092788 |\n| CHINA 6 | CHINA 8 | 1997 | 2490092 |\n+------------+------------+------+-----------+\n\n-- Q3.3\n+------------+------------+------+-----------+\n| c_city | s_city | year | revenue |\n+------------+------------+------+-----------+\n| UNITED KI0 | UNITED KI7 | 1992 | 251282102 |\n| UNITED KI0 | UNITED KI0 | 1992 | 170005406 |\n| UNITED KI7 | UNITED KI7 | 1992 | 36835396 |\n| UNITED KI0 | UNITED KI7 | 1993 | 560335810 |\n| UNITED KI0 | UNITED KI0 | 1993 | 294257692 |\n| UNITED KI7 | UNITED KI0 | 1993 | 159005896 |\n| UNITED KI7 | UNITED KI7 | 1993 | 139029264 |\n| UNITED KI0 | UNITED KI7 | 1994 | 739847089 |\n| UNITED KI0 | UNITED KI0 | 1994 | 302339390 |\n| UNITED KI7 | UNITED KI7 | 1994 | 275609814 |\n| UNITED KI7 | UNITED KI0 | 1994 | 117654093 |\n| UNITED KI0 | UNITED KI7 | 1995 | 540994655 |\n| UNITED KI0 | UNITED KI0 | 1995 | 230825439 |\n| UNITED KI7 | UNITED KI0 | 1995 | 197347696 |\n| UNITED KI7 | UNITED KI7 | 1995 | 136620517 |\n| UNITED KI0 | UNITED KI7 | 1996 | 448412094 |\n| UNITED KI0 | UNITED KI0 | 1996 | 203511607 |\n| UNITED KI7 | UNITED KI7 | 1996 | 94528075 |\n| UNITED KI7 | UNITED KI0 | 1996 | 35448536 |\n| UNITED KI7 | UNITED KI0 | 1997 | 289323850 |\n| UNITED KI7 | UNITED KI7 | 1997 | 214791175 |\n| UNITED KI0 | UNITED KI7 | 1997 | 196510174 |\n| UNITED KI0 | UNITED KI0 | 1997 | 125066127 |\n+------------+------------+------+-----------+\n\n-- Q3.4\n+------------+------------+------+-----------+\n| c_city | s_city | year | revenue |\n+------------+------------+------+-----------+\n| UNITED KI7 | KENYA 4 | 1997 | 170083300 |\n| UNITED KI0 | MOZAMBIQU1 | 1997 | 155234463 |\n| UNITED KI0 | KENYA 4 | 1997 | 87283610 |\n+------------+------------+------+-----------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation | profit |\n+------+---------------+-------------+\n| 1992 | ARGENTINA | 13746243380 |\n| 1992 | BRAZIL | 15762831144 |\n| 1992 | CANADA | 17477043721 |\n| 1992 | PERU | 14698567030 |\n| 1992 | UNITED STATES | 14043501956 |\n| 1993 | ARGENTINA | 13992888207 |\n| 1993 | BRAZIL | 15146262693 |\n| 1993 | CANADA | 12463985574 |\n| 1993 | PERU | 11385007831 |\n| 1993 | UNITED STATES | 10651361815 |\n| 1994 | ARGENTINA | 13128610315 |\n| 1994 | BRAZIL | 13764866493 |\n| 1994 | CANADA | 13723188154 |\n| 1994 | PERU | 12784683808 |\n| 1994 | UNITED STATES | 12554422837 |\n| 1995 | ARGENTINA | 14337205612 |\n| 1995 | BRAZIL | 15068918320 |\n| 1995 | CANADA | 14529005783 |\n| 1995 | PERU | 13086675480 |\n| 1995 | UNITED STATES | 11330297649 |\n| 1996 | ARGENTINA | 13659108915 |\n| 1996 | BRAZIL | 12660837584 |\n| 1996 | CANADA | 14558903190 |\n| 1996 | PERU | 14162285166 |\n| 1996 | UNITED STATES | 11117076866 |\n| 1997 | ARGENTINA | 12556399750 |\n| 1997 | BRAZIL | 13961587144 |\n| 1997 | CANADA | 15567856947 |\n| 1997 | PERU | 13595325340 |\n| 1997 | UNITED STATES | 10779073839 |\n| 1998 | ARGENTINA | 7843424759 |\n| 1998 | BRAZIL | 8853904827 |\n| 1998 | CANADA | 8286104334 |\n| 1998 | PERU | 5822590950 |\n| 1998 | UNITED STATES | 8526236814 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation | p_category | profit |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA | MFGR#11 | 1636950553 |\n| 1997 | ARGENTINA | MFGR#12 | 1265547847 |\n| 1997 | ARGENTINA | MFGR#13 | 1505131346 |\n| 1997 | ARGENTINA | MFGR#14 | 1405447137 |\n| 1997 | ARGENTINA | MFGR#15 | 1564085340 |\n| 1997 | ARGENTINA | MFGR#21 | 1335009490 |\n| 1997 | ARGENTINA | MFGR#22 | 1309054179 |\n| 1997 | ARGENTINA | MFGR#23 | 1305213794 |\n| 1997 | ARGENTINA | MFGR#24 | 1089725126 |\n| 1997 | ARGENTINA | MFGR#25 | 1291995512 |\n| 1997 | BRAZIL | MFGR#11 | 721240147 |\n| 1997 | BRAZIL | MFGR#12 | 928318830 |\n| 1997 | BRAZIL | MFGR#13 | 1164674879 |\n| 1997 | BRAZIL | MFGR#14 | 1215622587 |\n| 1997 | BRAZIL | MFGR#15 | 940971658 |\n| 1997 | BRAZIL | MFGR#21 | 1158909618 |\n| 1997 | BRAZIL | MFGR#22 | 1251221641 |\n| 1997 | BRAZIL | MFGR#23 | 1552552455 |\n| 1997 | BRAZIL | MFGR#24 | 929057361 |\n| 1997 | BRAZIL | MFGR#25 | 574645288 |\n| 1997 | CANADA | MFGR#11 | 1170341370 |\n| 1997 | CANADA | MFGR#12 | 1220238121 |\n| 1997 | CANADA | MFGR#13 | 1245774025 |\n| 1997 | CANADA | MFGR#14 | 1032046642 |\n| 1997 | CANADA | MFGR#15 | 738650612 |\n| 1997 | CANADA | MFGR#21 | 1476055209 |\n| 1997 | CANADA | MFGR#22 | 1239005798 |\n| 1997 | CANADA | MFGR#23 | 869393804 |\n| 1997 | CANADA | MFGR#24 | 1466964051 |\n| 1997 | CANADA | MFGR#25 | 1358922727 |\n| 1997 | PERU | MFGR#11 | 1031023174 |\n| 1997 | PERU | MFGR#12 | 731821491 |\n| 1997 | PERU | MFGR#13 | 1044642877 |\n| 1997 | PERU | MFGR#14 | 654877417 |\n| 1997 | PERU | MFGR#15 | 1201769474 |\n| 1997 | PERU | MFGR#21 | 1275496672 |\n| 1997 | PERU | MFGR#22 | 599324545 |\n| 1997 | PERU | MFGR#23 | 1200754744 |\n| 1997 | PERU | MFGR#24 | 942152801 |\n| 1997 | PERU | MFGR#25 | 1064322995 |\n| 1997 | UNITED STATES | MFGR#11 | 2365218925 |\n| 1997 | UNITED STATES | MFGR#12 | 1132346574 |\n| 1997 | UNITED STATES | MFGR#13 | 2460882362 |\n| 1997 | UNITED STATES | MFGR#14 | 2190816877 |\n| 1997 | UNITED STATES | MFGR#15 | 1687829921 |\n| 1997 | UNITED STATES | MFGR#21 | 2125880770 |\n| 1997 | UNITED STATES | MFGR#22 | 2013348097 |\n| 1997 | UNITED STATES | MFGR#23 | 2570581084 |\n| 1997 | UNITED STATES | MFGR#24 | 2724372315 |\n| 1997 | UNITED STATES | MFGR#25 | 1480012758 |\n| 1998 | ARGENTINA | MFGR#11 | 783662770 |\n| 1998 | ARGENTINA | MFGR#12 | 472818450 |\n| 1998 | ARGENTINA | MFGR#13 | 585091533 |\n| 1998 | ARGENTINA | MFGR#14 | 507297527 |\n| 1998 | ARGENTINA | MFGR#15 | 549185408 |\n| 1998 | ARGENTINA | MFGR#21 | 972928972 |\n| 1998 | ARGENTINA | MFGR#22 | 1508294213 |\n| 1998 | ARGENTINA | MFGR#23 | 517896738 |\n| 1998 | ARGENTINA | MFGR#24 | 240754731 |\n| 1998 | ARGENTINA | MFGR#25 | 757030162 |\n| 1998 | BRAZIL | MFGR#11 | 826283793 |\n| 1998 | BRAZIL | MFGR#12 | 482293349 |\n| 1998 | BRAZIL | MFGR#13 | 1037202334 |\n| 1998 | BRAZIL | MFGR#14 | 743598666 |\n| 1998 | BRAZIL | MFGR#15 | 584176304 |\n| 1998 | BRAZIL | MFGR#21 | 557259779 |\n| 1998 | BRAZIL | MFGR#22 | 535654445 |\n| 1998 | BRAZIL | MFGR#23 | 403656721 |\n| 1998 | BRAZIL | MFGR#24 | 1305217551 |\n| 1998 | BRAZIL | MFGR#25 | 1109801463 |\n| 1998 | CANADA | MFGR#11 | 936169617 |\n| 1998 | CANADA | MFGR#12 | 1017751308 |\n| 1998 | CANADA | MFGR#13 | 850046376 |\n| 1998 | CANADA | MFGR#14 | 808138010 |\n| 1998 | CANADA | MFGR#15 | 701990010 |\n| 1998 | CANADA | MFGR#21 | 402611051 |\n| 1998 | CANADA | MFGR#22 | 382705122 |\n| 1998 | CANADA | MFGR#23 | 509674722 |\n| 1998 | CANADA | MFGR#24 | 1003021250 |\n| 1998 | CANADA | MFGR#25 | 574602788 |\n| 1998 | PERU | MFGR#11 | 552608732 |\n| 1998 | PERU | MFGR#12 | 500581456 |\n| 1998 | PERU | MFGR#13 | 894607711 |\n| 1998 | PERU | MFGR#14 | 386487826 |\n| 1998 | PERU | MFGR#15 | 1044780577 |\n| 1998 | PERU | MFGR#21 | 184346232 |\n| 1998 | PERU | MFGR#22 | 674942976 |\n| 1998 | PERU | MFGR#23 | 665523956 |\n| 1998 | PERU | MFGR#24 | 631374203 |\n| 1998 | PERU | MFGR#25 | 602609608 |\n| 1998 | UNITED STATES | MFGR#11 | 1230069867 |\n| 1998 | UNITED STATES | MFGR#12 | 1557720319 |\n| 1998 | UNITED STATES | MFGR#13 | 999206739 |\n| 1998 | UNITED STATES | MFGR#14 | 605040268 |\n| 1998 | UNITED STATES | MFGR#15 | 850219215 |\n| 1998 | UNITED STATES | MFGR#21 | 1032550760 |\n| 1998 | UNITED STATES | MFGR#22 | 1370141401 |\n| 1998 | UNITED STATES | MFGR#23 | 1226632297 |\n| 1998 | UNITED STATES | MFGR#24 | 1528135100 |\n| 1998 | UNITED STATES | MFGR#25 | 1127867278 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+-----------+\n| year | s_city | p_brand | profit |\n+------+------------+-----------+-----------+\n| 1997 | UNITED ST0 | MFGR#1410 | 58481513 |\n| 1997 | UNITED ST0 | MFGR#1412 | 33582225 |\n| 1997 | UNITED ST0 | MFGR#1413 | 135625490 |\n| 1997 | UNITED ST0 | MFGR#1414 | 18581969 |\n| 1997 | UNITED ST0 | MFGR#142 | 164080005 |\n| 1997 | UNITED ST0 | MFGR#1420 | 30831591 |\n| 1997 | UNITED ST0 | MFGR#1424 | 4085253 |\n| 1997 | UNITED ST0 | MFGR#1425 | 163183170 |\n| 1997 | UNITED ST0 | MFGR#1427 | 87578288 |\n| 1997 | UNITED ST0 | MFGR#1428 | 109488143 |\n| 1997 | UNITED ST0 | MFGR#143 | 198055627 |\n| 1997 | UNITED ST0 | MFGR#1430 | 52544552 |\n| 1997 | UNITED ST0 | MFGR#1432 | 158742311 |\n| 1997 | UNITED ST0 | MFGR#144 | 43479982 |\n| 1997 | UNITED ST0 | MFGR#1440 | 40412893 |\n| 1997 | UNITED ST0 | MFGR#145 | 175568435 |\n| 1997 | UNITED ST1 | MFGR#141 | 11932912 |\n| 1997 | UNITED ST1 | MFGR#1411 | 40637463 |\n| 1997 | UNITED ST1 | MFGR#1415 | 27562355 |\n| 1997 | UNITED ST1 | MFGR#1421 | 100271780 |\n| 1997 | UNITED ST1 | MFGR#1422 | 103286764 |\n| 1997 | UNITED ST1 | MFGR#1423 | 106114459 |\n| 1997 | UNITED ST1 | MFGR#1427 | 157715681 |\n| 1997 | UNITED ST1 | MFGR#1428 | 91550168 |\n| 1997 | UNITED ST1 | MFGR#1430 | 56560173 |\n| 1997 | UNITED ST1 | MFGR#1431 | 248448914 |\n| 1997 | UNITED ST1 | MFGR#1435 | 994228 |\n| 1997 | UNITED ST1 | MFGR#144 | 55729825 |\n| 1997 | UNITED ST1 | MFGR#145 | 118034196 |\n| 1997 | UNITED ST1 | MFGR#146 | 99170724 |\n| 1997 | UNITED ST1 | MFGR#147 | 5123001 |\n| 1997 | UNITED ST2 | MFGR#141 | 111908637 |\n| 1997 | UNITED ST2 | MFGR#1414 | 96864725 |\n| 1997 | UNITED ST2 | MFGR#1415 | 123601050 |\n| 1997 | UNITED ST2 | MFGR#1421 | 21014618 |\n| 1997 | UNITED ST2 | MFGR#1427 | 46524767 |\n| 1997 | UNITED ST2 | MFGR#1429 | 18800062 |\n| 1997 | UNITED ST2 | MFGR#1431 | 79199532 |\n| 1997 | UNITED ST2 | MFGR#1432 | 53841788 |\n| 1997 | UNITED ST2 | MFGR#1433 | 133842836 |\n| 1997 | UNITED ST2 | MFGR#1434 | 96443006 |\n| 1997 | UNITED ST2 | MFGR#1435 | 50858424 |\n| 1997 | UNITED ST2 | MFGR#1438 | 64571457 |\n| 1997 | UNITED ST2 | MFGR#144 | 61319000 |\n| 1997 | UNITED ST2 | MFGR#146 | 69558050 |\n| 1997 | UNITED ST2 | MFGR#147 | 41160961 |\n| 1997 | UNITED ST2 | MFGR#149 | 31735872 |\n| 1997 | UNITED ST3 | MFGR#1410 | 306449140 |\n| 1997 | UNITED ST3 | MFGR#1411 | 114677189 |\n| 1997 | UNITED ST3 | MFGR#1412 | 49229127 |\n| 1997 | UNITED ST3 | MFGR#1413 | 174911640 |\n| 1997 | UNITED ST3 | MFGR#1415 | 134932298 |\n| 1997 | UNITED ST3 | MFGR#1416 | 97111854 |\n| 1997 | UNITED ST3 | MFGR#1417 | 176279103 |\n| 1997 | UNITED ST3 | MFGR#1418 | 70684147 |\n| 1997 | UNITED ST3 | MFGR#1420 | 27591782 |\n| 1997 | UNITED ST3 | MFGR#1422 | 39411253 |\n| 1997 | UNITED ST3 | MFGR#1424 | 226736650 |\n| 1997 | UNITED ST3 | MFGR#1426 | 63997112 |\n| 1997 | UNITED ST3 | MFGR#1429 | 556053 |\n| 1997 | UNITED ST3 | MFGR#143 | 73550925 |\n| 1997 | UNITED ST3 | MFGR#1430 | 218807697 |\n| 1997 | UNITED ST3 | MFGR#1431 | 39936281 |\n| 1997 | UNITED ST3 | MFGR#1432 | 44356689 |\n| 1997 | UNITED ST3 | MFGR#1435 | 49225455 |\n| 1997 | UNITED ST3 | MFGR#1436 | 90326644 |\n| 1997 | UNITED ST3 | MFGR#1439 | 84615817 |\n| 1997 | UNITED ST3 | MFGR#144 | 59081596 |\n| 1997 | UNITED ST3 | MFGR#1440 | 59601014 |\n| 1997 | UNITED ST3 | MFGR#145 | 100692258 |\n| 1997 | UNITED ST3 | MFGR#147 | 142417874 |\n| 1997 | UNITED ST3 | MFGR#148 | 38233221 |\n| 1997 | UNITED ST5 | MFGR#1416 | 62387773 |\n| 1997 | UNITED ST5 | MFGR#1417 | 54974702 |\n| 1997 | UNITED ST5 | MFGR#1418 | 87301086 |\n| 1997 | UNITED ST5 | MFGR#1421 | 9869673 |\n| 1997 | UNITED ST5 | MFGR#1422 | 58912225 |\n| 1997 | UNITED ST5 | MFGR#1424 | 80038584 |\n| 1997 | UNITED ST5 | MFGR#1428 | 44422717 |\n| 1997 | UNITED ST5 | MFGR#1430 | 67186074 |\n| 1997 | UNITED ST5 | MFGR#1433 | 105646942 |\n| 1997 | UNITED ST5 | MFGR#1434 | 13923867 |\n| 1997 | UNITED ST5 | MFGR#145 | 104286534 |\n| 1997 | UNITED ST5 | MFGR#146 | 20965182 |\n| 1997 | UNITED ST5 | MFGR#148 | 170596496 |\n| 1997 | UNITED ST5 | MFGR#149 | 42639213 |\n| 1997 | UNITED ST6 | MFGR#1411 | 48199726 |\n| 1997 | UNITED ST6 | MFGR#1413 | 28825982 |\n| 1997 | UNITED ST6 | MFGR#1414 | 107783723 |\n| 1997 | UNITED ST6 | MFGR#1415 | 92119787 |\n| 1997 | UNITED ST6 | MFGR#1416 | 35390328 |\n| 1997 | UNITED ST6 | MFGR#1417 | 92594053 |\n| 1997 | UNITED ST6 | MFGR#1418 | 67638716 |\n| 1997 | UNITED ST6 | MFGR#1421 | 98608466 |\n| 1997 | UNITED ST6 | MFGR#143 | 23938737 |\n| 1997 | UNITED ST6 | MFGR#1432 | 104846191 |\n| 1997 | UNITED ST6 | MFGR#1435 | 185809031 |\n| 1997 | UNITED ST6 | MFGR#1436 | 82920407 |\n| 1997 | UNITED ST6 | MFGR#1438 | 137524730 |\n| 1997 | UNITED ST6 | MFGR#146 | 28124052 |\n| 1997 | UNITED ST7 | MFGR#141 | 65266383 |\n| 1997 | UNITED ST7 | MFGR#1411 | 78295166 |\n| 1997 | UNITED ST7 | MFGR#1413 | 37554700 |\n| 1997 | UNITED ST7 | MFGR#1414 | 20428356 |\n| 1997 | UNITED ST7 | MFGR#1416 | 92381468 |\n| 1997 | UNITED ST7 | MFGR#1418 | 105276410 |\n| 1997 | UNITED ST7 | MFGR#1419 | 116086880 |\n| 1997 | UNITED ST7 | MFGR#1420 | 62010492 |\n| 1997 | UNITED ST7 | MFGR#1428 | 50904528 |\n| 1997 | UNITED ST7 | MFGR#1430 | 103558679 |\n| 1997 | UNITED ST7 | MFGR#1431 | 38342548 |\n| 1997 | UNITED ST7 | MFGR#1436 | 59859992 |\n| 1997 | UNITED ST7 | MFGR#1437 | 90701341 |\n| 1997 | UNITED ST7 | MFGR#147 | 133840269 |\n| 1997 | UNITED ST7 | MFGR#148 | 175852097 |\n| 1997 | UNITED ST9 | MFGR#1411 | 62786695 |\n| 1997 | UNITED ST9 | MFGR#1416 | 25354497 |\n| 1997 | UNITED ST9 | MFGR#1417 | 47367797 |\n| 1997 | UNITED ST9 | MFGR#1418 | 27220077 |\n| 1997 | UNITED ST9 | MFGR#142 | 41015203 |\n| 1997 | UNITED ST9 | MFGR#1423 | 41473506 |\n| 1997 | UNITED ST9 | MFGR#1424 | 10735092 |\n| 1997 | UNITED ST9 | MFGR#1425 | 27926087 |\n| 1997 | UNITED ST9 | MFGR#1426 | 136645966 |\n| 1997 | UNITED ST9 | MFGR#1430 | 41283531 |\n| 1997 | UNITED ST9 | MFGR#1433 | 497505 |\n| 1997 | UNITED ST9 | MFGR#1434 | 101147110 |\n| 1997 | UNITED ST9 | MFGR#1436 | 30923170 |\n| 1997 | UNITED ST9 | MFGR#145 | 18049495 |\n| 1997 | UNITED ST9 | MFGR#146 | 43726737 |\n| 1998 | UNITED ST0 | MFGR#1413 | 131487843 |\n| 1998 | UNITED ST0 | MFGR#1426 | 52942692 |\n| 1998 | UNITED ST0 | MFGR#146 | 13567224 |\n| 1998 | UNITED ST1 | MFGR#1410 | 65992198 |\n| 1998 | UNITED ST1 | MFGR#1416 | 115552383 |\n| 1998 | UNITED ST1 | MFGR#1418 | 15646035 |\n| 1998 | UNITED ST1 | MFGR#1419 | 129708776 |\n| 1998 | UNITED ST1 | MFGR#1428 | 18176281 |\n| 1998 | UNITED ST1 | MFGR#1431 | 17985830 |\n| 1998 | UNITED ST1 | MFGR#1436 | 16714417 |\n| 1998 | UNITED ST1 | MFGR#145 | 48297153 |\n| 1998 | UNITED ST2 | MFGR#1418 | 9240384 |\n| 1998 | UNITED ST2 | MFGR#1419 | 40909344 |\n| 1998 | UNITED ST2 | MFGR#1420 | 78625306 |\n| 1998 | UNITED ST2 | MFGR#1426 | 67161050 |\n| 1998 | UNITED ST2 | MFGR#1430 | 19028508 |\n| 1998 | UNITED ST2 | MFGR#1434 | 127804385 |\n| 1998 | UNITED ST2 | MFGR#1435 | 75092689 |\n| 1998 | UNITED ST2 | MFGR#1436 | 54579894 |\n| 1998 | UNITED ST2 | MFGR#1440 | 29067722 |\n| 1998 | UNITED ST2 | MFGR#148 | 78886426 |\n| 1998 | UNITED ST3 | MFGR#141 | 4311846 |\n| 1998 | UNITED ST3 | MFGR#1412 | 98979253 |\n| 1998 | UNITED ST3 | MFGR#1415 | 102275672 |\n| 1998 | UNITED ST3 | MFGR#1416 | 50781431 |\n| 1998 | UNITED ST3 | MFGR#1419 | 37451476 |\n| 1998 | UNITED ST3 | MFGR#1420 | 24660608 |\n| 1998 | UNITED ST3 | MFGR#1422 | 98548762 |\n| 1998 | UNITED ST3 | MFGR#1424 | 96601854 |\n| 1998 | UNITED ST3 | MFGR#1425 | 74508450 |\n| 1998 | UNITED ST3 | MFGR#1426 | 330583054 |\n| 1998 | UNITED ST3 | MFGR#1427 | 41352585 |\n| 1998 | UNITED ST3 | MFGR#1428 | 61979722 |\n| 1998 | UNITED ST3 | MFGR#1429 | 869295 |\n| 1998 | UNITED ST3 | MFGR#1432 | 66991135 |\n| 1998 | UNITED ST3 | MFGR#146 | 35929398 |\n| 1998 | UNITED ST3 | MFGR#147 | 8484972 |\n| 1998 | UNITED ST3 | MFGR#149 | 11793257 |\n| 1998 | UNITED ST5 | MFGR#1410 | 55951811 |\n| 1998 | UNITED ST5 | MFGR#1413 | 13403140 |\n| 1998 | UNITED ST5 | MFGR#142 | 24156762 |\n| 1998 | UNITED ST5 | MFGR#1422 | 105826683 |\n| 1998 | UNITED ST5 | MFGR#1430 | 67851607 |\n| 1998 | UNITED ST5 | MFGR#1431 | 84833774 |\n| 1998 | UNITED ST5 | MFGR#1434 | 45541810 |\n| 1998 | UNITED ST5 | MFGR#1437 | 33353745 |\n| 1998 | UNITED ST5 | MFGR#146 | 19891496 |\n| 1998 | UNITED ST6 | MFGR#1413 | 135522572 |\n| 1998 | UNITED ST6 | MFGR#1416 | 185707286 |\n| 1998 | UNITED ST6 | MFGR#1417 | 80511133 |\n| 1998 | UNITED ST6 | MFGR#1419 | 127132766 |\n| 1998 | UNITED ST6 | MFGR#142 | 72629474 |\n| 1998 | UNITED ST6 | MFGR#1435 | 158543190 |\n| 1998 | UNITED ST7 | MFGR#1412 | 56750777 |\n| 1998 | UNITED ST7 | MFGR#1424 | 89508621 |\n| 1998 | UNITED ST7 | MFGR#1425 | 160377031 |\n| 1998 | UNITED ST7 | MFGR#1434 | 20882477 |\n| 1998 | UNITED ST7 | MFGR#146 | 100783548 |\n| 1998 | UNITED ST7 | MFGR#147 | 61595522 |\n| 1998 | UNITED ST9 | MFGR#1412 | 5049765 |\n| 1998 | UNITED ST9 | MFGR#142 | 69919113 |\n| 1998 | UNITED ST9 | MFGR#1425 | 11003199 |\n| 1998 | UNITED ST9 | MFGR#1426 | 103616972 |\n| 1998 | UNITED ST9 | MFGR#1435 | 18879758 |\n| 1998 | UNITED ST9 | MFGR#1438 | 101903219 |\n+------+------------+-----------+-----------+\n
"},{"location":"MatrixOne/Test/performance-testing/SSB-test-with-matrixone/#_9","title":"\u591a\u8868\u67e5\u8be2\u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":"-- Q1.1\n+--------------+\n| revenue |\n+--------------+\n| 218453880421 |\n+--------------+\n\n-- Q1.2\n+---------+\n| revenue |\n+---------+\n| NULL |\n+---------+\n\n-- Q1.3\n+-------------+\n| revenue |\n+-------------+\n| 17527575453 |\n+-------------+\n\n-- Q2.1\n+------------+------+-----------+\n| lo_revenue | year | p_brand |\n+------------+------+-----------+\n| 1135676414 | 1992 | MFGR#121 |\n| 1221327580 | 1992 | MFGR#1210 |\n| 1101539324 | 1992 | MFGR#1211 |\n| 1298411712 | 1992 | MFGR#1212 |\n| 1248062482 | 1992 | MFGR#1213 |\n| 1340976936 | 1992 | MFGR#1214 |\n| 1266304940 | 1992 | MFGR#1215 |\n| 1349693562 | 1992 | MFGR#1216 |\n| 1350186870 | 1992 | MFGR#1217 |\n| 1200404140 | 1992 | MFGR#1218 |\n| 1076087188 | 1992 | MFGR#1219 |\n| 1310653344 | 1992 | MFGR#122 |\n| 1080525764 | 1992 | MFGR#1220 |\n| 1112241266 | 1992 | MFGR#1221 |\n| 1181525554 | 1992 | MFGR#1222 |\n| 1070897302 | 1992 | MFGR#1223 |\n| 1407505222 | 1992 | MFGR#1224 |\n| 1141665736 | 1992 | MFGR#1225 |\n| 1228123186 | 1992 | MFGR#1226 |\n| 1163518776 | 1992 | MFGR#1227 |\n| 1289285184 | 1992 | MFGR#1228 |\n| 1281716860 | 1992 | MFGR#1229 |\n| 1579511670 | 1992 | MFGR#123 |\n| 937070174 | 1992 | MFGR#1230 |\n| 1184873312 | 1992 | MFGR#1231 |\n| 1328550304 | 1992 | MFGR#1232 |\n| 1227770200 | 1992 | MFGR#1233 |\n| 1334798562 | 1992 | MFGR#1234 |\n| 1280580140 | 1992 | MFGR#1235 |\n| 1003785122 | 1992 | MFGR#1236 |\n| 1182963006 | 1992 | MFGR#1237 |\n| 954847540 | 1992 | MFGR#1238 |\n| 1276518748 | 1992 | MFGR#1239 |\n| 1144708392 | 1992 | MFGR#124 |\n| 1480958496 | 1992 | MFGR#1240 |\n| 957554190 | 1992 | MFGR#125 |\n| 1184349232 | 1992 | MFGR#126 |\n| 1412303264 | 1992 | MFGR#127 |\n| 1084613292 | 1992 | MFGR#128 |\n| 1163974704 | 1992 | MFGR#129 |\n| 1646175404 | 1993 | MFGR#121 |\n| 1296321412 | 1993 | MFGR#1210 |\n| 1269487796 | 1993 | MFGR#1211 |\n| 1571278566 | 1993 | MFGR#1212 |\n| 1276510058 | 1993 | MFGR#1213 |\n| 1233674474 | 1993 | MFGR#1214 |\n| 1269375950 | 1993 | MFGR#1215 |\n| 1276707800 | 1993 | MFGR#1216 |\n| 1326745902 | 1993 | MFGR#1217 |\n| 1367971710 | 1993 | MFGR#1218 |\n| 1293900066 | 1993 | MFGR#1219 |\n| 1245065968 | 1993 | MFGR#122 |\n| 1061660254 | 1993 | MFGR#1220 |\n| 1086692674 | 1993 | MFGR#1221 |\n| 1513842406 | 1993 | MFGR#1222 |\n| 1067088700 | 1993 | MFGR#1223 |\n| 1831832170 | 1993 | MFGR#1224 |\n| 946014762 | 1993 | MFGR#1225 |\n| 1478072248 | 1993 | MFGR#1226 |\n| 1184357774 | 1993 | MFGR#1227 |\n| 1167014116 | 1993 | MFGR#1228 |\n| 1234906982 | 1993 | MFGR#1229 |\n| 1275727736 | 1993 | MFGR#123 |\n| 1251068620 | 1993 | MFGR#1230 |\n| 1160655270 | 1993 | MFGR#1231 |\n| 1394746196 | 1993 | MFGR#1232 |\n| 1031142832 | 1993 | MFGR#1233 |\n| 1303871516 | 1993 | MFGR#1234 |\n| 1151558960 | 1993 | MFGR#1235 |\n| 1183757334 | 1993 | MFGR#1236 |\n| 1219237152 | 1993 | MFGR#1237 |\n| 889228020 | 1993 | MFGR#1238 |\n| 1190512654 | 1993 | MFGR#1239 |\n| 1321172474 | 1993 | MFGR#124 |\n| 1577460118 | 1993 | MFGR#1240 |\n| 1232449078 | 1993 | MFGR#125 |\n| 1234253508 | 1993 | MFGR#126 |\n| 1308876648 | 1993 | MFGR#127 |\n| 1463314002 | 1993 | MFGR#128 |\n| 1096096790 | 1993 | MFGR#129 |\n| 1128811296 | 1994 | MFGR#121 |\n| 1290809698 | 1994 | MFGR#1210 |\n| 1263241270 | 1994 | MFGR#1211 |\n| 1136664696 | 1994 | MFGR#1212 |\n| 1357571714 | 1994 | MFGR#1213 |\n| 1068004660 | 1994 | MFGR#1214 |\n| 1308800484 | 1994 | MFGR#1215 |\n| 1117292682 | 1994 | MFGR#1216 |\n| 1375691282 | 1994 | MFGR#1217 |\n| 1093348694 | 1994 | MFGR#1218 |\n| 1134545884 | 1994 | MFGR#1219 |\n| 1319768124 | 1994 | MFGR#122 |\n| 1125164344 | 1994 | MFGR#1220 |\n| 1197237994 | 1994 | MFGR#1221 |\n| 1202032882 | 1994 | MFGR#1222 |\n| 1110268808 | 1994 | MFGR#1223 |\n| 1474844604 | 1994 | MFGR#1224 |\n| 1141491910 | 1994 | MFGR#1225 |\n| 1492604490 | 1994 | MFGR#1226 |\n| 1303414962 | 1994 | MFGR#1227 |\n| 1147387094 | 1994 | MFGR#1228 |\n| 1295836746 | 1994 | MFGR#1229 |\n| 1160899184 | 1994 | MFGR#123 |\n| 986540824 | 1994 | MFGR#1230 |\n| 1207092296 | 1994 | MFGR#1231 |\n| 1439730662 | 1994 | MFGR#1232 |\n| 1277964476 | 1994 | MFGR#1233 |\n| 1486495354 | 1994 | MFGR#1234 |\n| 1197361918 | 1994 | MFGR#1235 |\n| 1231452194 | 1994 | MFGR#1236 |\n| 1085139630 | 1994 | MFGR#1237 |\n| 1147021562 | 1994 | MFGR#1238 |\n| 1159711706 | 1994 | MFGR#1239 |\n| 1369146644 | 1994 | MFGR#124 |\n| 1747471474 | 1994 | MFGR#1240 |\n| 1120976608 | 1994 | MFGR#125 |\n| 1314073028 | 1994 | MFGR#126 |\n| 1245142366 | 1994 | MFGR#127 |\n| 1173691328 | 1994 | MFGR#128 |\n| 1069083050 | 1994 | MFGR#129 |\n| 1412939022 | 1995 | MFGR#121 |\n| 1205785606 | 1995 | MFGR#1210 |\n| 1290332184 | 1995 | MFGR#1211 |\n| 1226578566 | 1995 | MFGR#1212 |\n| 1199172958 | 1995 | MFGR#1213 |\n| 1125141608 | 1995 | MFGR#1214 |\n| 1345057510 | 1995 | MFGR#1215 |\n| 1338001944 | 1995 | MFGR#1216 |\n| 1450724898 | 1995 | MFGR#1217 |\n| 1314053270 | 1995 | MFGR#1218 |\n| 1039318006 | 1995 | MFGR#1219 |\n| 1449455482 | 1995 | MFGR#122 |\n| 1035912262 | 1995 | MFGR#1220 |\n| 1271482702 | 1995 | MFGR#1221 |\n| 1128736820 | 1995 | MFGR#1222 |\n| 1201330298 | 1995 | MFGR#1223 |\n| 1525400702 | 1995 | MFGR#1224 |\n| 1343339172 | 1995 | MFGR#1225 |\n| 1145137496 | 1995 | MFGR#1226 |\n| 1060722600 | 1995 | MFGR#1227 |\n| 1266714170 | 1995 | MFGR#1228 |\n| 1095920488 | 1995 | MFGR#1229 |\n| 1321422154 | 1995 | MFGR#123 |\n| 1205471716 | 1995 | MFGR#1230 |\n| 999704292 | 1995 | MFGR#1231 |\n| 1430601506 | 1995 | MFGR#1232 |\n| 1114299142 | 1995 | MFGR#1233 |\n| 1420046118 | 1995 | MFGR#1234 |\n| 1244850478 | 1995 | MFGR#1235 |\n| 1269131002 | 1995 | MFGR#1236 |\n| 1145694540 | 1995 | MFGR#1237 |\n| 1098637824 | 1995 | MFGR#1238 |\n| 1187703424 | 1995 | MFGR#1239 |\n| 1170843630 | 1995 | MFGR#124 |\n| 1414415776 | 1995 | MFGR#1240 |\n| 1076493744 | 1995 | MFGR#125 |\n| 1211598042 | 1995 | MFGR#126 |\n| 1331956224 | 1995 | MFGR#127 |\n| 1293921912 | 1995 | MFGR#128 |\n| 1017498802 | 1995 | MFGR#129 |\n| 1047758290 | 1996 | MFGR#121 |\n| 1287290106 | 1996 | MFGR#1210 |\n| 1190130678 | 1996 | MFGR#1211 |\n| 1349252880 | 1996 | MFGR#1212 |\n| 992594174 | 1996 | MFGR#1213 |\n| 1166499010 | 1996 | MFGR#1214 |\n| 1404369714 | 1996 | MFGR#1215 |\n| 1203618668 | 1996 | MFGR#1216 |\n| 1409796774 | 1996 | MFGR#1217 |\n| 1057686172 | 1996 | MFGR#1218 |\n| 1172492660 | 1996 | MFGR#1219 |\n| 1424220984 | 1996 | MFGR#122 |\n| 1036888430 | 1996 | MFGR#1220 |\n| 998638828 | 1996 | MFGR#1221 |\n| 1358938712 | 1996 | MFGR#1222 |\n| 1257525508 | 1996 | MFGR#1223 |\n| 1449689712 | 1996 | MFGR#1224 |\n| 1321241174 | 1996 | MFGR#1225 |\n| 1335349458 | 1996 | MFGR#1226 |\n| 967676170 | 1996 | MFGR#1227 |\n| 1219710782 | 1996 | MFGR#1228 |\n| 1317919114 | 1996 | MFGR#1229 |\n| 1132435704 | 1996 | MFGR#123 |\n| 1057759996 | 1996 | MFGR#1230 |\n| 1178962388 | 1996 | MFGR#1231 |\n| 1405611792 | 1996 | MFGR#1232 |\n| 1327359894 | 1996 | MFGR#1233 |\n| 1142298900 | 1996 | MFGR#1234 |\n| 957296148 | 1996 | MFGR#1235 |\n| 1136498730 | 1996 | MFGR#1236 |\n| 1185232334 | 1996 | MFGR#1237 |\n| 933352296 | 1996 | MFGR#1238 |\n| 1341387438 | 1996 | MFGR#1239 |\n| 1121335438 | 1996 | MFGR#124 |\n| 1642335900 | 1996 | MFGR#1240 |\n| 953728666 | 1996 | MFGR#125 |\n| 1116061768 | 1996 | MFGR#126 |\n| 1271747782 | 1996 | MFGR#127 |\n| 1102021236 | 1996 | MFGR#128 |\n| 1121141260 | 1996 | MFGR#129 |\n| 1174026414 | 1997 | MFGR#121 |\n| 1232575784 | 1997 | MFGR#1210 |\n| 1097177522 | 1997 | MFGR#1211 |\n| 1179187784 | 1997 | MFGR#1212 |\n| 848613340 | 1997 | MFGR#1213 |\n| 1023943820 | 1997 | MFGR#1214 |\n| 1263544492 | 1997 | MFGR#1215 |\n| 1384270280 | 1997 | MFGR#1216 |\n| 1555989914 | 1997 | MFGR#1217 |\n| 1414107440 | 1997 | MFGR#1218 |\n| 1122339054 | 1997 | MFGR#1219 |\n| 1329832490 | 1997 | MFGR#122 |\n| 1188932314 | 1997 | MFGR#1220 |\n| 1177696342 | 1997 | MFGR#1221 |\n| 1057977920 | 1997 | MFGR#1222 |\n| 1074196422 | 1997 | MFGR#1223 |\n| 1349526332 | 1997 | MFGR#1224 |\n| 900804584 | 1997 | MFGR#1225 |\n| 1402721444 | 1997 | MFGR#1226 |\n| 1012023140 | 1997 | MFGR#1227 |\n| 1171157474 | 1997 | MFGR#1228 |\n| 1245488032 | 1997 | MFGR#1229 |\n| 1293006336 | 1997 | MFGR#123 |\n| 1143601882 | 1997 | MFGR#1230 |\n| 1005203580 | 1997 | MFGR#1231 |\n| 1355849312 | 1997 | MFGR#1232 |\n| 1068911952 | 1997 | MFGR#1233 |\n| 1429869430 | 1997 | MFGR#1234 |\n| 1534302840 | 1997 | MFGR#1235 |\n| 1237754358 | 1997 | MFGR#1236 |\n| 1279276114 | 1997 | MFGR#1237 |\n| 803906838 | 1997 | MFGR#1238 |\n| 1221513428 | 1997 | MFGR#1239 |\n| 1086496174 | 1997 | MFGR#124 |\n| 1350265384 | 1997 | MFGR#1240 |\n| 958198730 | 1997 | MFGR#125 |\n| 1141393136 | 1997 | MFGR#126 |\n| 1166149184 | 1997 | MFGR#127 |\n| 1390266208 | 1997 | MFGR#128 |\n| 1311277552 | 1997 | MFGR#129 |\n| 689151850 | 1998 | MFGR#121 |\n| 834304832 | 1998 | MFGR#1210 |\n| 634136336 | 1998 | MFGR#1211 |\n| 748683032 | 1998 | MFGR#1212 |\n| 665481806 | 1998 | MFGR#1213 |\n| 609746004 | 1998 | MFGR#1214 |\n| 732202264 | 1998 | MFGR#1215 |\n| 758267796 | 1998 | MFGR#1216 |\n| 719016994 | 1998 | MFGR#1217 |\n| 641246668 | 1998 | MFGR#1218 |\n| 692365724 | 1998 | MFGR#1219 |\n| 624880054 | 1998 | MFGR#122 |\n| 696247922 | 1998 | MFGR#1220 |\n| 679690796 | 1998 | MFGR#1221 |\n| 710832322 | 1998 | MFGR#1222 |\n| 689779644 | 1998 | MFGR#1223 |\n| 793813382 | 1998 | MFGR#1224 |\n| 580417756 | 1998 | MFGR#1225 |\n| 838831414 | 1998 | MFGR#1226 |\n| 716932680 | 1998 | MFGR#1227 |\n| 503099910 | 1998 | MFGR#1228 |\n| 766277720 | 1998 | MFGR#1229 |\n| 592661122 | 1998 | MFGR#123 |\n| 874362486 | 1998 | MFGR#1230 |\n| 797888984 | 1998 | MFGR#1231 |\n| 848124910 | 1998 | MFGR#1232 |\n| 813934376 | 1998 | MFGR#1233 |\n| 857734480 | 1998 | MFGR#1234 |\n| 704555562 | 1998 | MFGR#1235 |\n| 723654172 | 1998 | MFGR#1236 |\n| 683237138 | 1998 | MFGR#1237 |\n| 489478462 | 1998 | MFGR#1238 |\n| 828303606 | 1998 | MFGR#1239 |\n| 660164742 | 1998 | MFGR#124 |\n| 830624906 | 1998 | MFGR#1240 |\n| 720579248 | 1998 | MFGR#125 |\n| 683315160 | 1998 | MFGR#126 |\n| 755014122 | 1998 | MFGR#127 |\n| 722832994 | 1998 | MFGR#128 |\n| 637539146 | 1998 | MFGR#129 |\n+------------+------+-----------+\n\n-- Q2.2\n+------------+------+-----------+\n| lo_revenue | year | p_brand |\n+------------+------+-----------+\n| 1419049858 | 1992 | MFGR#2221 |\n| 1567692788 | 1992 | MFGR#2222 |\n| 1530104004 | 1992 | MFGR#2223 |\n| 1302977924 | 1992 | MFGR#2224 |\n| 1293057178 | 1992 | MFGR#2225 |\n| 1419301096 | 1992 | MFGR#2226 |\n| 1491112632 | 1992 | MFGR#2227 |\n| 1513803750 | 1992 | MFGR#2228 |\n| 1533042206 | 1993 | MFGR#2221 |\n| 1382951194 | 1993 | MFGR#2222 |\n| 1516441504 | 1993 | MFGR#2223 |\n| 1339325414 | 1993 | MFGR#2224 |\n| 1547708456 | 1993 | MFGR#2225 |\n| 1474175036 | 1993 | MFGR#2226 |\n| 1563935532 | 1993 | MFGR#2227 |\n| 1361760432 | 1993 | MFGR#2228 |\n| 1371555036 | 1994 | MFGR#2221 |\n| 1333049614 | 1994 | MFGR#2222 |\n| 1467987180 | 1994 | MFGR#2223 |\n| 1415738080 | 1994 | MFGR#2224 |\n| 1442503934 | 1994 | MFGR#2225 |\n| 1644991838 | 1994 | MFGR#2226 |\n| 1441674256 | 1994 | MFGR#2227 |\n| 1652450700 | 1994 | MFGR#2228 |\n| 1550874148 | 1995 | MFGR#2221 |\n| 1522709584 | 1995 | MFGR#2222 |\n| 1275665150 | 1995 | MFGR#2223 |\n| 1179531414 | 1995 | MFGR#2224 |\n| 1416580078 | 1995 | MFGR#2225 |\n| 1494712766 | 1995 | MFGR#2226 |\n| 1605005080 | 1995 | MFGR#2227 |\n| 1791873572 | 1995 | MFGR#2228 |\n| 1400020016 | 1996 | MFGR#2221 |\n| 1554620170 | 1996 | MFGR#2222 |\n| 1312190628 | 1996 | MFGR#2223 |\n| 1313719834 | 1996 | MFGR#2224 |\n| 1531641792 | 1996 | MFGR#2225 |\n| 1616355468 | 1996 | MFGR#2226 |\n| 1459126606 | 1996 | MFGR#2227 |\n| 1639331748 | 1996 | MFGR#2228 |\n| 1454684764 | 1997 | MFGR#2221 |\n| 1329067558 | 1997 | MFGR#2222 |\n| 1496576784 | 1997 | MFGR#2223 |\n| 1260844162 | 1997 | MFGR#2224 |\n| 1514782406 | 1997 | MFGR#2225 |\n| 1495778514 | 1997 | MFGR#2226 |\n| 1457715798 | 1997 | MFGR#2227 |\n| 1550625970 | 1997 | MFGR#2228 |\n| 670609008 | 1998 | MFGR#2221 |\n| 818694274 | 1998 | MFGR#2222 |\n| 918219154 | 1998 | MFGR#2223 |\n| 826636144 | 1998 | MFGR#2224 |\n| 820804190 | 1998 | MFGR#2225 |\n| 907030088 | 1998 | MFGR#2226 |\n| 781012810 | 1998 | MFGR#2227 |\n| 795878206 | 1998 | MFGR#2228 |\n+------------+------+-----------+\n\n-- Q2.3\n+------------+------+-----------+\n| lo_revenue | year | p_brand |\n+------------+------+-----------+\n| 1452854972 | 1992 | MFGR#2239 |\n| 1410477918 | 1993 | MFGR#2239 |\n| 1328290268 | 1994 | MFGR#2239 |\n| 1427678672 | 1995 | MFGR#2239 |\n| 1456985730 | 1996 | MFGR#2239 |\n| 1467793064 | 1997 | MFGR#2239 |\n| 760511462 | 1998 | MFGR#2239 |\n+------------+------+-----------+\n\n-- Q3.1\n+-----------+-----------+------+-------------+\n| c_nation | s_nation | year | lo_revenue |\n+-----------+-----------+------+-------------+\n| INDONESIA | INDONESIA | 1992 | 13811397976 |\n| CHINA | INDONESIA | 1992 | 13232157738 |\n| CHINA | CHINA | 1992 | 12912862954 |\n| VIETNAM | INDONESIA | 1992 | 12680363414 |\n| VIETNAM | CHINA | 1992 | 12665688780 |\n| INDONESIA | CHINA | 1992 | 12621419066 |\n| INDIA | INDONESIA | 1992 | 12477614708 |\n| JAPAN | INDONESIA | 1992 | 12445131276 |\n| CHINA | INDIA | 1992 | 12379662702 |\n| CHINA | JAPAN | 1992 | 12315357786 |\n| JAPAN | CHINA | 1992 | 12134201310 |\n| INDIA | CHINA | 1992 | 12132923622 |\n| VIETNAM | JAPAN | 1992 | 11727572698 |\n| JAPAN | INDIA | 1992 | 11605499970 |\n| INDONESIA | INDIA | 1992 | 11540406436 |\n| VIETNAM | INDIA | 1992 | 11397022802 |\n| INDONESIA | JAPAN | 1992 | 11327531220 |\n| JAPAN | JAPAN | 1992 | 11296069422 |\n| INDIA | JAPAN | 1992 | 10843918562 |\n| CHINA | VIETNAM | 1992 | 10824644052 |\n| JAPAN | VIETNAM | 1992 | 10803385110 |\n| INDIA | INDIA | 1992 | 10722487510 |\n| INDONESIA | VIETNAM | 1992 | 10605276744 |\n| INDIA | VIETNAM | 1992 | 10490661242 |\n| VIETNAM | VIETNAM | 1992 | 10223463556 |\n| INDONESIA | INDONESIA | 1993 | 13862726524 |\n| INDONESIA | CHINA | 1993 | 13225782498 |\n| CHINA | INDONESIA | 1993 | 13163026732 |\n| VIETNAM | INDONESIA | 1993 | 13023278704 |\n| CHINA | CHINA | 1993 | 12889027574 |\n| CHINA | INDIA | 1993 | 12843388242 |\n| VIETNAM | CHINA | 1993 | 12827159998 |\n| INDIA | INDONESIA | 1993 | 12662117188 |\n| JAPAN | CHINA | 1993 | 12584587990 |\n| INDIA | CHINA | 1993 | 12418707584 |\n| CHINA | JAPAN | 1993 | 12390933768 |\n| VIETNAM | INDIA | 1993 | 12322348954 |\n| INDONESIA | INDIA | 1993 | 12303328612 |\n| INDONESIA | JAPAN | 1993 | 12295210498 |\n| JAPAN | INDONESIA | 1993 | 12107892626 |\n| INDIA | JAPAN | 1993 | 11990417970 |\n| CHINA | VIETNAM | 1993 | 11770046456 |\n| VIETNAM | JAPAN | 1993 | 11748533734 |\n| INDONESIA | VIETNAM | 1993 | 11680575444 |\n| JAPAN | INDIA | 1993 | 11646686314 |\n| INDIA | INDIA | 1993 | 11143151598 |\n| VIETNAM | VIETNAM | 1993 | 11108322366 |\n| JAPAN | JAPAN | 1993 | 10860637166 |\n| JAPAN | VIETNAM | 1993 | 10813139306 |\n| INDIA | VIETNAM | 1993 | 10467742974 |\n| VIETNAM | CHINA | 1994 | 13419766884 |\n| CHINA | CHINA | 1994 | 13297885930 |\n| INDONESIA | CHINA | 1994 | 12967201820 |\n| CHINA | JAPAN | 1994 | 12698074042 |\n| VIETNAM | INDONESIA | 1994 | 12694883862 |\n| JAPAN | CHINA | 1994 | 12640018436 |\n| INDONESIA | INDONESIA | 1994 | 12630662172 |\n| CHINA | INDIA | 1994 | 12595165622 |\n| CHINA | INDONESIA | 1994 | 12469575792 |\n| VIETNAM | JAPAN | 1994 | 12463946094 |\n| INDONESIA | INDIA | 1994 | 12396824490 |\n| INDIA | INDONESIA | 1994 | 12336379718 |\n| INDONESIA | JAPAN | 1994 | 12282391938 |\n| JAPAN | INDONESIA | 1994 | 12026069236 |\n| CHINA | VIETNAM | 1994 | 11770637466 |\n| INDIA | CHINA | 1994 | 11630045428 |\n| VIETNAM | INDIA | 1994 | 11578797382 |\n| JAPAN | JAPAN | 1994 | 11507642964 |\n| JAPAN | INDIA | 1994 | 11291637744 |\n| INDONESIA | VIETNAM | 1994 | 11248692736 |\n| INDIA | INDIA | 1994 | 11169873030 |\n| VIETNAM | VIETNAM | 1994 | 10836996318 |\n| INDIA | JAPAN | 1994 | 10788269948 |\n| JAPAN | VIETNAM | 1994 | 10551643274 |\n| INDIA | VIETNAM | 1994 | 10502079630 |\n| CHINA | INDONESIA | 1995 | 14149078888 |\n| INDONESIA | CHINA | 1995 | 13857241240 |\n| CHINA | CHINA | 1995 | 13249333224 |\n| JAPAN | CHINA | 1995 | 13039778770 |\n| VIETNAM | CHINA | 1995 | 12665462536 |\n| INDONESIA | INDONESIA | 1995 | 12537062642 |\n| VIETNAM | JAPAN | 1995 | 12527914040 |\n| CHINA | INDIA | 1995 | 12493312748 |\n| VIETNAM | INDIA | 1995 | 12396883914 |\n| INDONESIA | INDIA | 1995 | 12347610366 |\n| VIETNAM | INDONESIA | 1995 | 12115640296 |\n| CHINA | JAPAN | 1995 | 12043708260 |\n| INDONESIA | JAPAN | 1995 | 12038187742 |\n| INDIA | CHINA | 1995 | 12021065586 |\n| INDIA | INDONESIA | 1995 | 11951037194 |\n| JAPAN | JAPAN | 1995 | 11904558258 |\n| JAPAN | INDONESIA | 1995 | 11894001470 |\n| VIETNAM | VIETNAM | 1995 | 11509455214 |\n| JAPAN | INDIA | 1995 | 11461486252 |\n| INDONESIA | VIETNAM | 1995 | 11149948132 |\n| INDIA | INDIA | 1995 | 11131991100 |\n| JAPAN | VIETNAM | 1995 | 11002627550 |\n| CHINA | VIETNAM | 1995 | 10979872126 |\n| INDIA | JAPAN | 1995 | 10938406854 |\n| INDIA | VIETNAM | 1995 | 10414126568 |\n| INDONESIA | INDONESIA | 1996 | 13500112566 |\n| CHINA | INDONESIA | 1996 | 13314250150 |\n| INDONESIA | CHINA | 1996 | 13226878224 |\n| CHINA | CHINA | 1996 | 13183395830 |\n| VIETNAM | CHINA | 1996 | 12857307780 |\n| VIETNAM | INDONESIA | 1996 | 12591253464 |\n| JAPAN | INDONESIA | 1996 | 12454895712 |\n| INDIA | CHINA | 1996 | 12397135638 |\n| INDIA | INDONESIA | 1996 | 12378484116 |\n| CHINA | INDIA | 1996 | 12307574730 |\n| INDONESIA | INDIA | 1996 | 12277621726 |\n| CHINA | JAPAN | 1996 | 12211132648 |\n| JAPAN | CHINA | 1996 | 12177971128 |\n| INDONESIA | JAPAN | 1996 | 12111276444 |\n| VIETNAM | JAPAN | 1996 | 11839994300 |\n| VIETNAM | VIETNAM | 1996 | 11721684604 |\n| INDIA | JAPAN | 1996 | 11683329610 |\n| VIETNAM | INDIA | 1996 | 11614973966 |\n| JAPAN | INDIA | 1996 | 11289159232 |\n| JAPAN | JAPAN | 1996 | 11132409590 |\n| INDIA | INDIA | 1996 | 11064146206 |\n| INDONESIA | VIETNAM | 1996 | 10877028774 |\n| CHINA | VIETNAM | 1996 | 10869545636 |\n| JAPAN | VIETNAM | 1996 | 10668555098 |\n| INDIA | VIETNAM | 1996 | 10587783062 |\n| CHINA | INDONESIA | 1997 | 13306469392 |\n| INDONESIA | CHINA | 1997 | 13154792628 |\n| CHINA | CHINA | 1997 | 12927589590 |\n| JAPAN | INDONESIA | 1997 | 12858540252 |\n| INDONESIA | INDONESIA | 1997 | 12796855642 |\n| VIETNAM | INDONESIA | 1997 | 12727166240 |\n| CHINA | JAPAN | 1997 | 12569467036 |\n| VIETNAM | CHINA | 1997 | 12328437446 |\n| INDIA | CHINA | 1997 | 12306564428 |\n| CHINA | INDIA | 1997 | 12168567966 |\n| INDONESIA | JAPAN | 1997 | 12002855912 |\n| INDIA | INDONESIA | 1997 | 11966878600 |\n| JAPAN | CHINA | 1997 | 11947699374 |\n| CHINA | VIETNAM | 1997 | 11816508352 |\n| JAPAN | INDIA | 1997 | 11593843984 |\n| JAPAN | JAPAN | 1997 | 11580900078 |\n| INDONESIA | INDIA | 1997 | 11578734210 |\n| VIETNAM | INDIA | 1997 | 11460243216 |\n| INDIA | INDIA | 1997 | 11386057814 |\n| VIETNAM | JAPAN | 1997 | 11378690460 |\n| INDONESIA | VIETNAM | 1997 | 11331356264 |\n| VIETNAM | VIETNAM | 1997 | 11240502648 |\n| INDIA | JAPAN | 1997 | 11175655826 |\n| JAPAN | VIETNAM | 1997 | 10499749228 |\n| INDIA | VIETNAM | 1997 | 10007249674 |\n+-----------+-----------+------+-------------+\n\n-- Q3.2\n+------------+------------+------+------------+\n| c_city | s_city | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED ST4 | UNITED ST1 | 1992 | 204054910 |\n| UNITED ST1 | UNITED ST0 | 1992 | 193978982 |\n| UNITED ST7 | UNITED ST0 | 1992 | 192156020 |\n| UNITED ST9 | UNITED ST0 | 1992 | 189626588 |\n| UNITED ST4 | UNITED ST0 | 1992 | 189288484 |\n| UNITED ST2 | UNITED ST4 | 1992 | 182361000 |\n| UNITED ST5 | UNITED ST0 | 1992 | 180864600 |\n| UNITED ST6 | UNITED ST7 | 1992 | 175316534 |\n| UNITED ST3 | UNITED ST9 | 1992 | 172284096 |\n| UNITED ST6 | UNITED ST5 | 1992 | 171765932 |\n| UNITED ST7 | UNITED ST3 | 1992 | 167531332 |\n| UNITED ST2 | UNITED ST9 | 1992 | 167411236 |\n| UNITED ST4 | UNITED ST6 | 1992 | 163772748 |\n| UNITED ST2 | UNITED ST1 | 1992 | 163678330 |\n| UNITED ST9 | UNITED ST1 | 1992 | 161590604 |\n| UNITED ST6 | UNITED ST3 | 1992 | 157556436 |\n| UNITED ST6 | UNITED ST0 | 1992 | 157393912 |\n| UNITED ST0 | UNITED ST1 | 1992 | 154534792 |\n| UNITED ST0 | UNITED ST0 | 1992 | 151244244 |\n| UNITED ST1 | UNITED ST9 | 1992 | 150734118 |\n| UNITED ST3 | UNITED ST1 | 1992 | 147274980 |\n| UNITED ST2 | UNITED ST0 | 1992 | 144420436 |\n| UNITED ST1 | UNITED ST7 | 1992 | 142945946 |\n| UNITED ST6 | UNITED ST4 | 1992 | 142173888 |\n| UNITED ST4 | UNITED ST4 | 1992 | 140222670 |\n| UNITED ST6 | UNITED ST1 | 1992 | 138817376 |\n| UNITED ST4 | UNITED ST3 | 1992 | 138003574 |\n| UNITED ST5 | UNITED ST7 | 1992 | 136667302 |\n| UNITED ST4 | UNITED ST9 | 1992 | 135675940 |\n| UNITED ST7 | UNITED ST6 | 1992 | 131026410 |\n| UNITED ST4 | UNITED ST5 | 1992 | 130115744 |\n| UNITED ST7 | UNITED ST4 | 1992 | 129801776 |\n| UNITED ST1 | UNITED ST1 | 1992 | 129338140 |\n| UNITED ST3 | UNITED ST5 | 1992 | 128478096 |\n| UNITED ST0 | UNITED ST9 | 1992 | 127959992 |\n| UNITED ST3 | UNITED ST4 | 1992 | 126289544 |\n| UNITED ST5 | UNITED ST6 | 1992 | 125256186 |\n| UNITED ST4 | UNITED ST7 | 1992 | 125058752 |\n| UNITED ST3 | UNITED ST0 | 1992 | 124883312 |\n| UNITED ST9 | UNITED ST4 | 1992 | 122979026 |\n| UNITED ST8 | UNITED ST6 | 1992 | 121080880 |\n| UNITED ST7 | UNITED ST9 | 1992 | 120652084 |\n| UNITED ST7 | UNITED ST7 | 1992 | 120242772 |\n| UNITED ST5 | UNITED ST1 | 1992 | 119890574 |\n| UNITED ST5 | UNITED ST4 | 1992 | 115251254 |\n| UNITED ST7 | UNITED ST5 | 1992 | 115133604 |\n| UNITED ST2 | UNITED ST5 | 1992 | 114042730 |\n| UNITED ST9 | UNITED ST7 | 1992 | 113766718 |\n| UNITED ST0 | UNITED ST3 | 1992 | 112718634 |\n| UNITED ST1 | UNITED ST3 | 1992 | 111454948 |\n| UNITED ST5 | UNITED ST3 | 1992 | 107927106 |\n| UNITED ST0 | UNITED ST7 | 1992 | 101166818 |\n| UNITED ST5 | UNITED ST9 | 1992 | 100382182 |\n| UNITED ST7 | UNITED ST1 | 1992 | 100334416 |\n| UNITED ST0 | UNITED ST8 | 1992 | 99465280 |\n| UNITED ST0 | UNITED ST4 | 1992 | 99353614 |\n| UNITED ST9 | UNITED ST3 | 1992 | 95362330 |\n| UNITED ST8 | UNITED ST4 | 1992 | 93514038 |\n| UNITED ST3 | UNITED ST3 | 1992 | 90174432 |\n| UNITED ST8 | UNITED ST0 | 1992 | 88737678 |\n| UNITED ST0 | UNITED ST6 | 1992 | 84943612 |\n| UNITED ST6 | UNITED ST8 | 1992 | 84927380 |\n| UNITED ST8 | UNITED ST7 | 1992 | 83795802 |\n| UNITED ST3 | UNITED ST8 | 1992 | 82551528 |\n| UNITED ST6 | UNITED ST9 | 1992 | 81183442 |\n| UNITED ST0 | UNITED ST5 | 1992 | 80241772 |\n| UNITED ST1 | UNITED ST4 | 1992 | 78652692 |\n| UNITED ST3 | UNITED ST7 | 1992 | 78057158 |\n| UNITED ST3 | UNITED ST6 | 1992 | 77597430 |\n| UNITED ST9 | UNITED ST9 | 1992 | 72096686 |\n| UNITED ST2 | UNITED ST8 | 1992 | 72092898 |\n| UNITED ST2 | UNITED ST3 | 1992 | 71963926 |\n| UNITED ST8 | UNITED ST1 | 1992 | 71361504 |\n| UNITED ST1 | UNITED ST6 | 1992 | 70809980 |\n| UNITED ST8 | UNITED ST5 | 1992 | 70375220 |\n| UNITED ST1 | UNITED ST5 | 1992 | 67942502 |\n| UNITED ST5 | UNITED ST8 | 1992 | 67756106 |\n| UNITED ST2 | UNITED ST7 | 1992 | 67405558 |\n| UNITED ST8 | UNITED ST3 | 1992 | 61898648 |\n| UNITED ST8 | UNITED ST8 | 1992 | 58618216 |\n| UNITED ST5 | UNITED ST5 | 1992 | 58559136 |\n| UNITED ST1 | UNITED ST8 | 1992 | 57131158 |\n| UNITED ST9 | UNITED ST5 | 1992 | 56150008 |\n| UNITED ST2 | UNITED ST6 | 1992 | 55627478 |\n| UNITED ST0 | UNITED ST2 | 1992 | 55437466 |\n| UNITED ST2 | UNITED ST2 | 1992 | 51487308 |\n| UNITED ST8 | UNITED ST9 | 1992 | 45368942 |\n| UNITED ST4 | UNITED ST8 | 1992 | 43856884 |\n| UNITED ST9 | UNITED ST8 | 1992 | 42772200 |\n| UNITED ST5 | UNITED ST2 | 1992 | 40991634 |\n| UNITED ST6 | UNITED ST6 | 1992 | 36274210 |\n| UNITED ST9 | UNITED ST6 | 1992 | 31759136 |\n| UNITED ST4 | UNITED ST2 | 1992 | 24123690 |\n| UNITED ST7 | UNITED ST8 | 1992 | 23791404 |\n| UNITED ST6 | UNITED ST2 | 1992 | 23641396 |\n| UNITED ST9 | UNITED ST2 | 1992 | 23246354 |\n| UNITED ST8 | UNITED ST2 | 1992 | 21943122 |\n| UNITED ST1 | UNITED ST2 | 1992 | 15413456 |\n| UNITED ST7 | UNITED ST2 | 1992 | 9886408 |\n| UNITED ST3 | UNITED ST2 | 1992 | 2194416 |\n| UNITED ST0 | UNITED ST9 | 1993 | 219668080 |\n| UNITED ST7 | UNITED ST0 | 1993 | 219576048 |\n| UNITED ST5 | UNITED ST0 | 1993 | 213645194 |\n| UNITED ST0 | UNITED ST0 | 1993 | 213485096 |\n| UNITED ST1 | UNITED ST0 | 1993 | 198611904 |\n| UNITED ST4 | UNITED ST4 | 1993 | 196300930 |\n| UNITED ST3 | UNITED ST4 | 1993 | 184987840 |\n| UNITED ST0 | UNITED ST1 | 1993 | 182393186 |\n| UNITED ST4 | UNITED ST1 | 1993 | 177042846 |\n| UNITED ST8 | UNITED ST0 | 1993 | 176712742 |\n| UNITED ST4 | UNITED ST7 | 1993 | 176344396 |\n| UNITED ST4 | UNITED ST0 | 1993 | 173836916 |\n| UNITED ST6 | UNITED ST3 | 1993 | 166834322 |\n| UNITED ST6 | UNITED ST1 | 1993 | 166691878 |\n| UNITED ST7 | UNITED ST9 | 1993 | 160621402 |\n| UNITED ST3 | UNITED ST1 | 1993 | 156460556 |\n| UNITED ST6 | UNITED ST7 | 1993 | 156394588 |\n| UNITED ST5 | UNITED ST9 | 1993 | 152573078 |\n| UNITED ST0 | UNITED ST3 | 1993 | 152342566 |\n| UNITED ST5 | UNITED ST8 | 1993 | 148718558 |\n| UNITED ST9 | UNITED ST1 | 1993 | 148118838 |\n| UNITED ST4 | UNITED ST9 | 1993 | 146593918 |\n| UNITED ST5 | UNITED ST1 | 1993 | 142909246 |\n| UNITED ST6 | UNITED ST4 | 1993 | 139293826 |\n| UNITED ST2 | UNITED ST1 | 1993 | 139263402 |\n| UNITED ST6 | UNITED ST0 | 1993 | 136495078 |\n| UNITED ST7 | UNITED ST7 | 1993 | 136219640 |\n| UNITED ST2 | UNITED ST3 | 1993 | 133944876 |\n| UNITED ST3 | UNITED ST0 | 1993 | 133253852 |\n| UNITED ST9 | UNITED ST7 | 1993 | 133250966 |\n| UNITED ST1 | UNITED ST8 | 1993 | 132292396 |\n| UNITED ST2 | UNITED ST7 | 1993 | 128370028 |\n| UNITED ST5 | UNITED ST4 | 1993 | 126831278 |\n| UNITED ST9 | UNITED ST9 | 1993 | 126521526 |\n| UNITED ST1 | UNITED ST4 | 1993 | 125768694 |\n| UNITED ST7 | UNITED ST4 | 1993 | 123313226 |\n| UNITED ST3 | UNITED ST6 | 1993 | 117169616 |\n| UNITED ST2 | UNITED ST4 | 1993 | 113300782 |\n| UNITED ST3 | UNITED ST5 | 1993 | 111814610 |\n| UNITED ST6 | UNITED ST9 | 1993 | 109801884 |\n| UNITED ST1 | UNITED ST7 | 1993 | 109702366 |\n| UNITED ST3 | UNITED ST9 | 1993 | 109525192 |\n| UNITED ST8 | UNITED ST6 | 1993 | 109266124 |\n| UNITED ST8 | UNITED ST3 | 1993 | 108099748 |\n| UNITED ST5 | UNITED ST7 | 1993 | 105491076 |\n| UNITED ST0 | UNITED ST5 | 1993 | 105402104 |\n| UNITED ST1 | UNITED ST9 | 1993 | 105029804 |\n| UNITED ST8 | UNITED ST5 | 1993 | 104475674 |\n| UNITED ST1 | UNITED ST3 | 1993 | 104195892 |\n| UNITED ST8 | UNITED ST4 | 1993 | 102838712 |\n| UNITED ST0 | UNITED ST6 | 1993 | 100864564 |\n| UNITED ST5 | UNITED ST5 | 1993 | 100714378 |\n| UNITED ST3 | UNITED ST7 | 1993 | 100270896 |\n| UNITED ST0 | UNITED ST4 | 1993 | 98520134 |\n| UNITED ST0 | UNITED ST7 | 1993 | 97592720 |\n| UNITED ST2 | UNITED ST9 | 1993 | 96377014 |\n| UNITED ST1 | UNITED ST1 | 1993 | 95077220 |\n| UNITED ST9 | UNITED ST3 | 1993 | 93887294 |\n| UNITED ST7 | UNITED ST5 | 1993 | 89527384 |\n| UNITED ST1 | UNITED ST6 | 1993 | 89457080 |\n| UNITED ST8 | UNITED ST1 | 1993 | 88830868 |\n| UNITED ST7 | UNITED ST8 | 1993 | 87805256 |\n| UNITED ST9 | UNITED ST6 | 1993 | 87734320 |\n| UNITED ST2 | UNITED ST0 | 1993 | 85690970 |\n| UNITED ST3 | UNITED ST8 | 1993 | 84503696 |\n| UNITED ST0 | UNITED ST8 | 1993 | 84005364 |\n| UNITED ST4 | UNITED ST8 | 1993 | 83315164 |\n| UNITED ST1 | UNITED ST5 | 1993 | 81387026 |\n| UNITED ST9 | UNITED ST5 | 1993 | 79370538 |\n| UNITED ST7 | UNITED ST3 | 1993 | 79047722 |\n| UNITED ST8 | UNITED ST8 | 1993 | 77580470 |\n| UNITED ST8 | UNITED ST9 | 1993 | 77032722 |\n| UNITED ST2 | UNITED ST5 | 1993 | 74813690 |\n| UNITED ST9 | UNITED ST8 | 1993 | 74369392 |\n| UNITED ST8 | UNITED ST7 | 1993 | 73804436 |\n| UNITED ST6 | UNITED ST8 | 1993 | 72913482 |\n| UNITED ST7 | UNITED ST1 | 1993 | 68782318 |\n| UNITED ST6 | UNITED ST5 | 1993 | 68458164 |\n| UNITED ST5 | UNITED ST3 | 1993 | 68063622 |\n| UNITED ST2 | UNITED ST8 | 1993 | 66890892 |\n| UNITED ST4 | UNITED ST3 | 1993 | 66258824 |\n| UNITED ST6 | UNITED ST6 | 1993 | 66101326 |\n| UNITED ST9 | UNITED ST0 | 1993 | 65306610 |\n| UNITED ST4 | UNITED ST6 | 1993 | 61398510 |\n| UNITED ST9 | UNITED ST4 | 1993 | 61289374 |\n| UNITED ST4 | UNITED ST5 | 1993 | 58239188 |\n| UNITED ST7 | UNITED ST6 | 1993 | 54201004 |\n| UNITED ST4 | UNITED ST2 | 1993 | 54025356 |\n| UNITED ST2 | UNITED ST6 | 1993 | 52964452 |\n| UNITED ST5 | UNITED ST6 | 1993 | 50715358 |\n| UNITED ST3 | UNITED ST3 | 1993 | 43554288 |\n| UNITED ST3 | UNITED ST2 | 1993 | 43118146 |\n| UNITED ST5 | UNITED ST2 | 1993 | 41220484 |\n| UNITED ST7 | UNITED ST2 | 1993 | 40438608 |\n| UNITED ST6 | UNITED ST2 | 1993 | 37628734 |\n| UNITED ST9 | UNITED ST2 | 1993 | 35436780 |\n| UNITED ST1 | UNITED ST2 | 1993 | 33689076 |\n| UNITED ST0 | UNITED ST2 | 1993 | 30084290 |\n| UNITED ST2 | UNITED ST2 | 1993 | 29043990 |\n| UNITED ST8 | UNITED ST2 | 1993 | 19968732 |\n| UNITED ST8 | UNITED ST0 | 1994 | 198441578 |\n| UNITED ST3 | UNITED ST9 | 1994 | 194952370 |\n| UNITED ST6 | UNITED ST1 | 1994 | 193874294 |\n| UNITED ST6 | UNITED ST9 | 1994 | 189366618 |\n| UNITED ST9 | UNITED ST1 | 1994 | 180881896 |\n| UNITED ST0 | UNITED ST9 | 1994 | 179730404 |\n| UNITED ST5 | UNITED ST7 | 1994 | 178179922 |\n| UNITED ST9 | UNITED ST0 | 1994 | 175341146 |\n| UNITED ST3 | UNITED ST1 | 1994 | 171047306 |\n| UNITED ST4 | UNITED ST9 | 1994 | 167644786 |\n| UNITED ST0 | UNITED ST0 | 1994 | 167053754 |\n| UNITED ST7 | UNITED ST0 | 1994 | 164531072 |\n| UNITED ST2 | UNITED ST1 | 1994 | 162600178 |\n| UNITED ST5 | UNITED ST0 | 1994 | 157296114 |\n| UNITED ST4 | UNITED ST7 | 1994 | 153908280 |\n| UNITED ST4 | UNITED ST4 | 1994 | 153674762 |\n| UNITED ST0 | UNITED ST1 | 1994 | 153226758 |\n| UNITED ST1 | UNITED ST3 | 1994 | 151984918 |\n| UNITED ST7 | UNITED ST1 | 1994 | 150641598 |\n| UNITED ST4 | UNITED ST0 | 1994 | 147438680 |\n| UNITED ST5 | UNITED ST1 | 1994 | 147016836 |\n| UNITED ST4 | UNITED ST1 | 1994 | 144439114 |\n| UNITED ST2 | UNITED ST9 | 1994 | 139342108 |\n| UNITED ST6 | UNITED ST5 | 1994 | 132923068 |\n| UNITED ST2 | UNITED ST3 | 1994 | 131241520 |\n| UNITED ST3 | UNITED ST0 | 1994 | 131045454 |\n| UNITED ST5 | UNITED ST3 | 1994 | 130669822 |\n| UNITED ST7 | UNITED ST4 | 1994 | 129557430 |\n| UNITED ST3 | UNITED ST4 | 1994 | 126824730 |\n| UNITED ST8 | UNITED ST4 | 1994 | 124283362 |\n| UNITED ST0 | UNITED ST4 | 1994 | 123039488 |\n| UNITED ST0 | UNITED ST7 | 1994 | 122961640 |\n| UNITED ST0 | UNITED ST6 | 1994 | 122577556 |\n| UNITED ST2 | UNITED ST0 | 1994 | 120364306 |\n| UNITED ST6 | UNITED ST4 | 1994 | 119659978 |\n| UNITED ST4 | UNITED ST5 | 1994 | 118794056 |\n| UNITED ST8 | UNITED ST9 | 1994 | 117333812 |\n| UNITED ST4 | UNITED ST6 | 1994 | 117266964 |\n| UNITED ST5 | UNITED ST5 | 1994 | 112470426 |\n| UNITED ST6 | UNITED ST3 | 1994 | 112246476 |\n| UNITED ST2 | UNITED ST4 | 1994 | 111358754 |\n| UNITED ST8 | UNITED ST3 | 1994 | 110407682 |\n| UNITED ST1 | UNITED ST1 | 1994 | 108766348 |\n| UNITED ST1 | UNITED ST7 | 1994 | 107706212 |\n| UNITED ST6 | UNITED ST0 | 1994 | 107457706 |\n| UNITED ST5 | UNITED ST9 | 1994 | 106734662 |\n| UNITED ST9 | UNITED ST9 | 1994 | 103961698 |\n| UNITED ST5 | UNITED ST4 | 1994 | 103599186 |\n| UNITED ST7 | UNITED ST9 | 1994 | 100288170 |\n| UNITED ST7 | UNITED ST7 | 1994 | 92892884 |\n| UNITED ST6 | UNITED ST6 | 1994 | 92399444 |\n| UNITED ST7 | UNITED ST5 | 1994 | 91790728 |\n| UNITED ST3 | UNITED ST3 | 1994 | 91254306 |\n| UNITED ST8 | UNITED ST5 | 1994 | 89106112 |\n| UNITED ST9 | UNITED ST4 | 1994 | 87821522 |\n| UNITED ST1 | UNITED ST0 | 1994 | 86450402 |\n| UNITED ST1 | UNITED ST9 | 1994 | 86000074 |\n| UNITED ST7 | UNITED ST8 | 1994 | 85552934 |\n| UNITED ST0 | UNITED ST5 | 1994 | 83616602 |\n| UNITED ST2 | UNITED ST6 | 1994 | 83052210 |\n| UNITED ST1 | UNITED ST4 | 1994 | 82763116 |\n| UNITED ST3 | UNITED ST7 | 1994 | 81870262 |\n| UNITED ST8 | UNITED ST1 | 1994 | 80304192 |\n| UNITED ST9 | UNITED ST8 | 1994 | 78557616 |\n| UNITED ST5 | UNITED ST6 | 1994 | 77316902 |\n| UNITED ST2 | UNITED ST5 | 1994 | 75280634 |\n| UNITED ST8 | UNITED ST7 | 1994 | 75201374 |\n| UNITED ST9 | UNITED ST5 | 1994 | 74293452 |\n| UNITED ST6 | UNITED ST7 | 1994 | 74115616 |\n| UNITED ST8 | UNITED ST6 | 1994 | 73553138 |\n| UNITED ST3 | UNITED ST6 | 1994 | 72580514 |\n| UNITED ST9 | UNITED ST3 | 1994 | 71693000 |\n| UNITED ST2 | UNITED ST8 | 1994 | 67535548 |\n| UNITED ST0 | UNITED ST8 | 1994 | 63690866 |\n| UNITED ST4 | UNITED ST3 | 1994 | 63198866 |\n| UNITED ST9 | UNITED ST7 | 1994 | 63172346 |\n| UNITED ST1 | UNITED ST6 | 1994 | 62574652 |\n| UNITED ST1 | UNITED ST8 | 1994 | 60490306 |\n| UNITED ST7 | UNITED ST3 | 1994 | 58849680 |\n| UNITED ST9 | UNITED ST6 | 1994 | 58425854 |\n| UNITED ST0 | UNITED ST3 | 1994 | 54655658 |\n| UNITED ST6 | UNITED ST8 | 1994 | 53185992 |\n| UNITED ST3 | UNITED ST5 | 1994 | 52395750 |\n| UNITED ST6 | UNITED ST2 | 1994 | 51618000 |\n| UNITED ST1 | UNITED ST5 | 1994 | 49878276 |\n| UNITED ST7 | UNITED ST6 | 1994 | 49263874 |\n| UNITED ST1 | UNITED ST2 | 1994 | 47113172 |\n| UNITED ST4 | UNITED ST2 | 1994 | 46071784 |\n| UNITED ST2 | UNITED ST7 | 1994 | 44365516 |\n| UNITED ST0 | UNITED ST2 | 1994 | 44035908 |\n| UNITED ST4 | UNITED ST8 | 1994 | 41370704 |\n| UNITED ST7 | UNITED ST2 | 1994 | 39310162 |\n| UNITED ST5 | UNITED ST8 | 1994 | 37863782 |\n| UNITED ST2 | UNITED ST2 | 1994 | 36137314 |\n| UNITED ST3 | UNITED ST8 | 1994 | 31872102 |\n| UNITED ST8 | UNITED ST8 | 1994 | 20046824 |\n| UNITED ST3 | UNITED ST2 | 1994 | 19990468 |\n| UNITED ST9 | UNITED ST2 | 1994 | 19401978 |\n| UNITED ST5 | UNITED ST2 | 1994 | 14325592 |\n| UNITED ST8 | UNITED ST2 | 1994 | 7579252 |\n| UNITED ST5 | UNITED ST1 | 1995 | 239587338 |\n| UNITED ST4 | UNITED ST9 | 1995 | 198980136 |\n| UNITED ST7 | UNITED ST0 | 1995 | 196062590 |\n| UNITED ST6 | UNITED ST0 | 1995 | 183436942 |\n| UNITED ST4 | UNITED ST1 | 1995 | 181757306 |\n| UNITED ST0 | UNITED ST1 | 1995 | 181527198 |\n| UNITED ST8 | UNITED ST9 | 1995 | 177710178 |\n| UNITED ST7 | UNITED ST7 | 1995 | 173143248 |\n| UNITED ST3 | UNITED ST0 | 1995 | 168925466 |\n| UNITED ST9 | UNITED ST1 | 1995 | 165877934 |\n| UNITED ST2 | UNITED ST4 | 1995 | 164864610 |\n| UNITED ST1 | UNITED ST0 | 1995 | 163353246 |\n| UNITED ST5 | UNITED ST4 | 1995 | 162033522 |\n| UNITED ST7 | UNITED ST1 | 1995 | 159928724 |\n| UNITED ST5 | UNITED ST3 | 1995 | 156198260 |\n| UNITED ST5 | UNITED ST0 | 1995 | 155231492 |\n| UNITED ST9 | UNITED ST9 | 1995 | 153031916 |\n| UNITED ST7 | UNITED ST9 | 1995 | 150635418 |\n| UNITED ST4 | UNITED ST4 | 1995 | 149174142 |\n| UNITED ST9 | UNITED ST4 | 1995 | 145051372 |\n| UNITED ST1 | UNITED ST9 | 1995 | 144941740 |\n| UNITED ST4 | UNITED ST7 | 1995 | 138528814 |\n| UNITED ST6 | UNITED ST3 | 1995 | 135026124 |\n| UNITED ST2 | UNITED ST3 | 1995 | 130436258 |\n| UNITED ST2 | UNITED ST9 | 1995 | 130110356 |\n| UNITED ST7 | UNITED ST6 | 1995 | 130041342 |\n| UNITED ST3 | UNITED ST1 | 1995 | 129525630 |\n| UNITED ST1 | UNITED ST1 | 1995 | 128398664 |\n| UNITED ST6 | UNITED ST9 | 1995 | 126914210 |\n| UNITED ST0 | UNITED ST9 | 1995 | 126506998 |\n| UNITED ST5 | UNITED ST9 | 1995 | 124729794 |\n| UNITED ST4 | UNITED ST5 | 1995 | 124163010 |\n| UNITED ST1 | UNITED ST7 | 1995 | 123031482 |\n| UNITED ST2 | UNITED ST7 | 1995 | 120000416 |\n| UNITED ST8 | UNITED ST6 | 1995 | 117980808 |\n| UNITED ST1 | UNITED ST4 | 1995 | 115071198 |\n| UNITED ST0 | UNITED ST3 | 1995 | 112721416 |\n| UNITED ST8 | UNITED ST0 | 1995 | 110463328 |\n| UNITED ST5 | UNITED ST7 | 1995 | 107481518 |\n| UNITED ST2 | UNITED ST0 | 1995 | 105121676 |\n| UNITED ST3 | UNITED ST7 | 1995 | 103159096 |\n| UNITED ST9 | UNITED ST0 | 1995 | 103097242 |\n| UNITED ST6 | UNITED ST6 | 1995 | 101909354 |\n| UNITED ST5 | UNITED ST5 | 1995 | 100788014 |\n| UNITED ST7 | UNITED ST4 | 1995 | 99799090 |\n| UNITED ST3 | UNITED ST3 | 1995 | 96316178 |\n| UNITED ST6 | UNITED ST4 | 1995 | 95394482 |\n| UNITED ST9 | UNITED ST7 | 1995 | 92929178 |\n| UNITED ST4 | UNITED ST0 | 1995 | 92285798 |\n| UNITED ST1 | UNITED ST3 | 1995 | 91646112 |\n| UNITED ST2 | UNITED ST1 | 1995 | 90874680 |\n| UNITED ST6 | UNITED ST5 | 1995 | 90856304 |\n| UNITED ST8 | UNITED ST5 | 1995 | 89989726 |\n| UNITED ST7 | UNITED ST3 | 1995 | 87399468 |\n| UNITED ST9 | UNITED ST6 | 1995 | 86964988 |\n| UNITED ST2 | UNITED ST5 | 1995 | 86764834 |\n| UNITED ST6 | UNITED ST8 | 1995 | 83947840 |\n| UNITED ST0 | UNITED ST6 | 1995 | 81437884 |\n| UNITED ST3 | UNITED ST5 | 1995 | 80115630 |\n| UNITED ST7 | UNITED ST5 | 1995 | 78030586 |\n| UNITED ST0 | UNITED ST0 | 1995 | 77969004 |\n| UNITED ST6 | UNITED ST1 | 1995 | 76656704 |\n| UNITED ST4 | UNITED ST6 | 1995 | 76219048 |\n| UNITED ST3 | UNITED ST9 | 1995 | 74729246 |\n| UNITED ST4 | UNITED ST3 | 1995 | 74712792 |\n| UNITED ST2 | UNITED ST6 | 1995 | 74292576 |\n| UNITED ST9 | UNITED ST5 | 1995 | 72019848 |\n| UNITED ST1 | UNITED ST8 | 1995 | 69837586 |\n| UNITED ST8 | UNITED ST1 | 1995 | 68435560 |\n| UNITED ST0 | UNITED ST7 | 1995 | 66790626 |\n| UNITED ST1 | UNITED ST5 | 1995 | 63714904 |\n| UNITED ST8 | UNITED ST7 | 1995 | 61836404 |\n| UNITED ST2 | UNITED ST8 | 1995 | 61008378 |\n| UNITED ST3 | UNITED ST4 | 1995 | 60844692 |\n| UNITED ST5 | UNITED ST6 | 1995 | 60409474 |\n| UNITED ST8 | UNITED ST3 | 1995 | 58699876 |\n| UNITED ST0 | UNITED ST4 | 1995 | 58340076 |\n| UNITED ST1 | UNITED ST6 | 1995 | 54278806 |\n| UNITED ST7 | UNITED ST8 | 1995 | 52888980 |\n| UNITED ST6 | UNITED ST7 | 1995 | 47667954 |\n| UNITED ST4 | UNITED ST8 | 1995 | 46106472 |\n| UNITED ST4 | UNITED ST2 | 1995 | 45574006 |\n| UNITED ST3 | UNITED ST8 | 1995 | 45010478 |\n| UNITED ST9 | UNITED ST8 | 1995 | 42585054 |\n| UNITED ST8 | UNITED ST4 | 1995 | 38574622 |\n| UNITED ST8 | UNITED ST2 | 1995 | 36565980 |\n| UNITED ST9 | UNITED ST3 | 1995 | 35078204 |\n| UNITED ST3 | UNITED ST6 | 1995 | 33477060 |\n| UNITED ST0 | UNITED ST8 | 1995 | 32786498 |\n| UNITED ST5 | UNITED ST2 | 1995 | 29902046 |\n| UNITED ST2 | UNITED ST2 | 1995 | 26910062 |\n| UNITED ST5 | UNITED ST8 | 1995 | 26693864 |\n| UNITED ST3 | UNITED ST2 | 1995 | 25773658 |\n| UNITED ST9 | UNITED ST2 | 1995 | 25306724 |\n| UNITED ST0 | UNITED ST5 | 1995 | 22907418 |\n| UNITED ST6 | UNITED ST2 | 1995 | 22727102 |\n| UNITED ST8 | UNITED ST8 | 1995 | 22571734 |\n| UNITED ST1 | UNITED ST2 | 1995 | 15983352 |\n| UNITED ST0 | UNITED ST2 | 1995 | 9552920 |\n| UNITED ST7 | UNITED ST2 | 1995 | 7947130 |\n| UNITED ST6 | UNITED ST0 | 1996 | 264573526 |\n| UNITED ST4 | UNITED ST0 | 1996 | 213795126 |\n| UNITED ST5 | UNITED ST0 | 1996 | 209003958 |\n| UNITED ST0 | UNITED ST4 | 1996 | 206457498 |\n| UNITED ST9 | UNITED ST1 | 1996 | 203967654 |\n| UNITED ST1 | UNITED ST0 | 1996 | 189723108 |\n| UNITED ST0 | UNITED ST1 | 1996 | 183897554 |\n| UNITED ST6 | UNITED ST1 | 1996 | 179411740 |\n| UNITED ST2 | UNITED ST1 | 1996 | 176512310 |\n| UNITED ST1 | UNITED ST1 | 1996 | 174531696 |\n| UNITED ST4 | UNITED ST7 | 1996 | 167355628 |\n| UNITED ST6 | UNITED ST3 | 1996 | 164336458 |\n| UNITED ST2 | UNITED ST7 | 1996 | 160936954 |\n| UNITED ST8 | UNITED ST1 | 1996 | 157943512 |\n| UNITED ST7 | UNITED ST4 | 1996 | 155882022 |\n| UNITED ST1 | UNITED ST3 | 1996 | 155221810 |\n| UNITED ST9 | UNITED ST9 | 1996 | 154603480 |\n| UNITED ST0 | UNITED ST9 | 1996 | 151870418 |\n| UNITED ST7 | UNITED ST0 | 1996 | 151204890 |\n| UNITED ST3 | UNITED ST1 | 1996 | 149493398 |\n| UNITED ST7 | UNITED ST7 | 1996 | 148081288 |\n| UNITED ST4 | UNITED ST1 | 1996 | 145639734 |\n| UNITED ST5 | UNITED ST9 | 1996 | 145228228 |\n| UNITED ST1 | UNITED ST9 | 1996 | 139647538 |\n| UNITED ST9 | UNITED ST4 | 1996 | 139233228 |\n| UNITED ST6 | UNITED ST4 | 1996 | 138592010 |\n| UNITED ST2 | UNITED ST0 | 1996 | 134190244 |\n| UNITED ST5 | UNITED ST1 | 1996 | 130692778 |\n| UNITED ST6 | UNITED ST9 | 1996 | 126512364 |\n| UNITED ST4 | UNITED ST6 | 1996 | 124378656 |\n| UNITED ST0 | UNITED ST0 | 1996 | 123057710 |\n| UNITED ST8 | UNITED ST9 | 1996 | 120933382 |\n| UNITED ST3 | UNITED ST0 | 1996 | 120453680 |\n| UNITED ST8 | UNITED ST6 | 1996 | 119493310 |\n| UNITED ST2 | UNITED ST3 | 1996 | 119297196 |\n| UNITED ST0 | UNITED ST5 | 1996 | 115525790 |\n| UNITED ST8 | UNITED ST7 | 1996 | 115047850 |\n| UNITED ST2 | UNITED ST4 | 1996 | 114974114 |\n| UNITED ST6 | UNITED ST7 | 1996 | 114181238 |\n| UNITED ST3 | UNITED ST4 | 1996 | 109676518 |\n| UNITED ST4 | UNITED ST9 | 1996 | 108269680 |\n| UNITED ST1 | UNITED ST6 | 1996 | 108112732 |\n| UNITED ST3 | UNITED ST7 | 1996 | 107974436 |\n| UNITED ST2 | UNITED ST9 | 1996 | 106982830 |\n| UNITED ST4 | UNITED ST8 | 1996 | 106071324 |\n| UNITED ST9 | UNITED ST5 | 1996 | 105651844 |\n| UNITED ST7 | UNITED ST3 | 1996 | 104713772 |\n| UNITED ST6 | UNITED ST8 | 1996 | 104273568 |\n| UNITED ST1 | UNITED ST5 | 1996 | 102379298 |\n| UNITED ST8 | UNITED ST4 | 1996 | 102066108 |\n| UNITED ST1 | UNITED ST4 | 1996 | 100271094 |\n| UNITED ST3 | UNITED ST9 | 1996 | 99224608 |\n| UNITED ST9 | UNITED ST0 | 1996 | 99181402 |\n| UNITED ST3 | UNITED ST3 | 1996 | 98527592 |\n| UNITED ST9 | UNITED ST7 | 1996 | 97597518 |\n| UNITED ST7 | UNITED ST1 | 1996 | 97568350 |\n| UNITED ST9 | UNITED ST6 | 1996 | 97370126 |\n| UNITED ST2 | UNITED ST5 | 1996 | 94057952 |\n| UNITED ST9 | UNITED ST3 | 1996 | 94042036 |\n| UNITED ST2 | UNITED ST8 | 1996 | 93730226 |\n| UNITED ST4 | UNITED ST3 | 1996 | 92921880 |\n| UNITED ST6 | UNITED ST5 | 1996 | 92060208 |\n| UNITED ST2 | UNITED ST6 | 1996 | 90833298 |\n| UNITED ST8 | UNITED ST5 | 1996 | 86960946 |\n| UNITED ST5 | UNITED ST5 | 1996 | 86041444 |\n| UNITED ST6 | UNITED ST6 | 1996 | 85846064 |\n| UNITED ST4 | UNITED ST5 | 1996 | 85616824 |\n| UNITED ST3 | UNITED ST6 | 1996 | 83763256 |\n| UNITED ST1 | UNITED ST7 | 1996 | 83443012 |\n| UNITED ST5 | UNITED ST7 | 1996 | 81892660 |\n| UNITED ST8 | UNITED ST0 | 1996 | 79690854 |\n| UNITED ST8 | UNITED ST3 | 1996 | 79071880 |\n| UNITED ST1 | UNITED ST8 | 1996 | 78861764 |\n| UNITED ST5 | UNITED ST6 | 1996 | 76664088 |\n| UNITED ST0 | UNITED ST6 | 1996 | 74464124 |\n| UNITED ST7 | UNITED ST6 | 1996 | 73071256 |\n| UNITED ST9 | UNITED ST8 | 1996 | 72224602 |\n| UNITED ST3 | UNITED ST8 | 1996 | 67849464 |\n| UNITED ST3 | UNITED ST5 | 1996 | 67434878 |\n| UNITED ST5 | UNITED ST4 | 1996 | 66849718 |\n| UNITED ST5 | UNITED ST3 | 1996 | 65839852 |\n| UNITED ST4 | UNITED ST4 | 1996 | 65575990 |\n| UNITED ST7 | UNITED ST5 | 1996 | 65568448 |\n| UNITED ST5 | UNITED ST8 | 1996 | 64831364 |\n| UNITED ST0 | UNITED ST7 | 1996 | 62782362 |\n| UNITED ST0 | UNITED ST3 | 1996 | 59591330 |\n| UNITED ST7 | UNITED ST9 | 1996 | 50056182 |\n| UNITED ST7 | UNITED ST8 | 1996 | 48697702 |\n| UNITED ST6 | UNITED ST2 | 1996 | 40895694 |\n| UNITED ST8 | UNITED ST8 | 1996 | 32681206 |\n| UNITED ST0 | UNITED ST8 | 1996 | 30336524 |\n| UNITED ST4 | UNITED ST2 | 1996 | 24903734 |\n| UNITED ST1 | UNITED ST2 | 1996 | 20165072 |\n| UNITED ST5 | UNITED ST2 | 1996 | 17088466 |\n| UNITED ST7 | UNITED ST2 | 1996 | 16780940 |\n| UNITED ST9 | UNITED ST2 | 1996 | 16216070 |\n| UNITED ST8 | UNITED ST2 | 1996 | 14056668 |\n| UNITED ST0 | UNITED ST2 | 1996 | 13814398 |\n| UNITED ST3 | UNITED ST2 | 1996 | 8623600 |\n| UNITED ST5 | UNITED ST0 | 1997 | 242915532 |\n| UNITED ST0 | UNITED ST9 | 1997 | 239712536 |\n| UNITED ST5 | UNITED ST1 | 1997 | 213800322 |\n| UNITED ST9 | UNITED ST9 | 1997 | 212445590 |\n| UNITED ST5 | UNITED ST4 | 1997 | 206865854 |\n| UNITED ST7 | UNITED ST1 | 1997 | 202653880 |\n| UNITED ST5 | UNITED ST9 | 1997 | 194785280 |\n| UNITED ST8 | UNITED ST0 | 1997 | 178869690 |\n| UNITED ST1 | UNITED ST3 | 1997 | 170351276 |\n| UNITED ST4 | UNITED ST1 | 1997 | 169222376 |\n| UNITED ST4 | UNITED ST7 | 1997 | 169213992 |\n| UNITED ST1 | UNITED ST4 | 1997 | 166185138 |\n| UNITED ST0 | UNITED ST1 | 1997 | 160334278 |\n| UNITED ST4 | UNITED ST9 | 1997 | 159395854 |\n| UNITED ST1 | UNITED ST0 | 1997 | 155335732 |\n| UNITED ST2 | UNITED ST0 | 1997 | 155182940 |\n| UNITED ST1 | UNITED ST7 | 1997 | 154091444 |\n| UNITED ST2 | UNITED ST7 | 1997 | 152967604 |\n| UNITED ST1 | UNITED ST1 | 1997 | 152680888 |\n| UNITED ST0 | UNITED ST7 | 1997 | 145154980 |\n| UNITED ST4 | UNITED ST0 | 1997 | 139751608 |\n| UNITED ST6 | UNITED ST3 | 1997 | 139451012 |\n| UNITED ST2 | UNITED ST9 | 1997 | 139087968 |\n| UNITED ST7 | UNITED ST0 | 1997 | 138708624 |\n| UNITED ST9 | UNITED ST7 | 1997 | 138105260 |\n| UNITED ST8 | UNITED ST3 | 1997 | 133836788 |\n| UNITED ST0 | UNITED ST0 | 1997 | 132617032 |\n| UNITED ST9 | UNITED ST0 | 1997 | 132133582 |\n| UNITED ST2 | UNITED ST3 | 1997 | 130858906 |\n| UNITED ST2 | UNITED ST1 | 1997 | 130792270 |\n| UNITED ST4 | UNITED ST4 | 1997 | 125064692 |\n| UNITED ST9 | UNITED ST1 | 1997 | 124836812 |\n| UNITED ST3 | UNITED ST7 | 1997 | 122190600 |\n| UNITED ST7 | UNITED ST4 | 1997 | 120246988 |\n| UNITED ST4 | UNITED ST3 | 1997 | 119268306 |\n| UNITED ST3 | UNITED ST4 | 1997 | 116712282 |\n| UNITED ST6 | UNITED ST9 | 1997 | 116462526 |\n| UNITED ST6 | UNITED ST4 | 1997 | 114430044 |\n| UNITED ST2 | UNITED ST4 | 1997 | 114025222 |\n| UNITED ST5 | UNITED ST3 | 1997 | 113579864 |\n| UNITED ST9 | UNITED ST5 | 1997 | 112183840 |\n| UNITED ST6 | UNITED ST0 | 1997 | 111649838 |\n| UNITED ST6 | UNITED ST1 | 1997 | 110235418 |\n| UNITED ST7 | UNITED ST9 | 1997 | 110079940 |\n| UNITED ST5 | UNITED ST7 | 1997 | 109068630 |\n| UNITED ST3 | UNITED ST1 | 1997 | 108301366 |\n| UNITED ST3 | UNITED ST0 | 1997 | 108100344 |\n| UNITED ST3 | UNITED ST9 | 1997 | 102740616 |\n| UNITED ST1 | UNITED ST5 | 1997 | 102104220 |\n| UNITED ST6 | UNITED ST7 | 1997 | 99591698 |\n| UNITED ST5 | UNITED ST6 | 1997 | 98060032 |\n| UNITED ST1 | UNITED ST9 | 1997 | 97888222 |\n| UNITED ST3 | UNITED ST3 | 1997 | 96770466 |\n| UNITED ST0 | UNITED ST5 | 1997 | 95976836 |\n| UNITED ST2 | UNITED ST8 | 1997 | 92783818 |\n| UNITED ST4 | UNITED ST6 | 1997 | 92473698 |\n| UNITED ST9 | UNITED ST3 | 1997 | 92243448 |\n| UNITED ST8 | UNITED ST9 | 1997 | 91705592 |\n| UNITED ST7 | UNITED ST8 | 1997 | 90952532 |\n| UNITED ST8 | UNITED ST1 | 1997 | 86568278 |\n| UNITED ST7 | UNITED ST7 | 1997 | 85133206 |\n| UNITED ST0 | UNITED ST4 | 1997 | 82387606 |\n| UNITED ST8 | UNITED ST7 | 1997 | 81756858 |\n| UNITED ST8 | UNITED ST8 | 1997 | 81498800 |\n| UNITED ST2 | UNITED ST5 | 1997 | 81325772 |\n| UNITED ST0 | UNITED ST3 | 1997 | 80157016 |\n| UNITED ST6 | UNITED ST8 | 1997 | 75976890 |\n| UNITED ST9 | UNITED ST6 | 1997 | 75193764 |\n| UNITED ST6 | UNITED ST5 | 1997 | 75143576 |\n| UNITED ST2 | UNITED ST2 | 1997 | 74068666 |\n| UNITED ST7 | UNITED ST5 | 1997 | 73779472 |\n| UNITED ST8 | UNITED ST4 | 1997 | 73201168 |\n| UNITED ST3 | UNITED ST6 | 1997 | 72151688 |\n| UNITED ST7 | UNITED ST3 | 1997 | 70337844 |\n| UNITED ST2 | UNITED ST6 | 1997 | 68548934 |\n| UNITED ST5 | UNITED ST8 | 1997 | 65821892 |\n| UNITED ST3 | UNITED ST5 | 1997 | 65623926 |\n| UNITED ST4 | UNITED ST8 | 1997 | 65199472 |\n| UNITED ST5 | UNITED ST5 | 1997 | 65137776 |\n| UNITED ST4 | UNITED ST5 | 1997 | 63991736 |\n| UNITED ST9 | UNITED ST4 | 1997 | 63530956 |\n| UNITED ST7 | UNITED ST2 | 1997 | 62819180 |\n| UNITED ST9 | UNITED ST8 | 1997 | 62544770 |\n| UNITED ST0 | UNITED ST8 | 1997 | 60482740 |\n| UNITED ST3 | UNITED ST8 | 1997 | 58204440 |\n| UNITED ST7 | UNITED ST6 | 1997 | 55079862 |\n| UNITED ST8 | UNITED ST5 | 1997 | 53347486 |\n| UNITED ST6 | UNITED ST6 | 1997 | 49966582 |\n| UNITED ST0 | UNITED ST2 | 1997 | 47168458 |\n| UNITED ST0 | UNITED ST6 | 1997 | 45848092 |\n| UNITED ST1 | UNITED ST2 | 1997 | 41198260 |\n| UNITED ST8 | UNITED ST6 | 1997 | 40146000 |\n| UNITED ST1 | UNITED ST6 | 1997 | 36410652 |\n| UNITED ST1 | UNITED ST8 | 1997 | 30750516 |\n| UNITED ST6 | UNITED ST2 | 1997 | 29493360 |\n| UNITED ST5 | UNITED ST2 | 1997 | 27726876 |\n| UNITED ST8 | UNITED ST2 | 1997 | 24107412 |\n| UNITED ST3 | UNITED ST2 | 1997 | 15783756 |\n| UNITED ST4 | UNITED ST2 | 1997 | 5696314 |\n| UNITED ST9 | UNITED ST2 | 1997 | 5323304 |\n+------------+------------+------+------------+\n\n-- Q3.3\n+------------+------------+------+------------+\n| c_city | s_city | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI1 | UNITED KI1 | 1992 | 93471990 |\n| UNITED KI5 | UNITED KI1 | 1992 | 72554110 |\n| UNITED KI5 | UNITED KI5 | 1992 | 50710534 |\n| UNITED KI1 | UNITED KI5 | 1992 | 43835692 |\n| UNITED KI5 | UNITED KI1 | 1993 | 122035214 |\n| UNITED KI1 | UNITED KI1 | 1993 | 91339070 |\n| UNITED KI5 | UNITED KI5 | 1993 | 68198784 |\n| UNITED KI1 | UNITED KI5 | 1993 | 42888412 |\n| UNITED KI5 | UNITED KI1 | 1994 | 72564326 |\n| UNITED KI1 | UNITED KI1 | 1994 | 69736882 |\n| UNITED KI5 | UNITED KI5 | 1994 | 69014568 |\n| UNITED KI1 | UNITED KI5 | 1994 | 42443560 |\n| UNITED KI5 | UNITED KI1 | 1995 | 165911792 |\n| UNITED KI1 | UNITED KI1 | 1995 | 71762372 |\n| UNITED KI5 | UNITED KI5 | 1995 | 41079610 |\n| UNITED KI1 | UNITED KI5 | 1995 | 34353020 |\n| UNITED KI5 | UNITED KI1 | 1996 | 131534098 |\n| UNITED KI1 | UNITED KI1 | 1996 | 119846074 |\n| UNITED KI5 | UNITED KI5 | 1996 | 92154684 |\n| UNITED KI1 | UNITED KI5 | 1996 | 27400508 |\n| UNITED KI1 | UNITED KI1 | 1997 | 140686266 |\n| UNITED KI5 | UNITED KI1 | 1997 | 129956718 |\n| UNITED KI5 | UNITED KI5 | 1997 | 54664054 |\n| UNITED KI1 | UNITED KI5 | 1997 | 32821336 |\n+------------+------------+------+------------+\n\n-- Q3.4\n+------------+------------+------+------------+\n| c_city | s_city | year | lo_revenue |\n+------------+------------+------+------------+\n| UNITED KI5 | UNITED KI1 | 1997 | 18235692 |\n| UNITED KI5 | UNITED KI5 | 1997 | 12407602 |\n| UNITED KI1 | UNITED KI5 | 1997 | 3740140 |\n+------------+------------+------+------------+\n\n-- Q4.1\n+------+---------------+-------------+\n| year | c_nation | profit |\n+------+---------------+-------------+\n| 1992 | ARGENTINA | 19317928938 |\n| 1992 | BRAZIL | 18453966110 |\n| 1992 | CANADA | 19286353574 |\n| 1992 | PERU | 18821353194 |\n| 1992 | UNITED STATES | 19698855306 |\n| 1993 | ARGENTINA | 19952665706 |\n| 1993 | BRAZIL | 18937598458 |\n| 1993 | CANADA | 19794604840 |\n| 1993 | PERU | 18618891672 |\n| 1993 | UNITED STATES | 20007970172 |\n| 1994 | ARGENTINA | 19880610430 |\n| 1994 | BRAZIL | 18697303354 |\n| 1994 | CANADA | 19165295192 |\n| 1994 | PERU | 18590530026 |\n| 1994 | UNITED STATES | 19039760850 |\n| 1995 | ARGENTINA | 20287682760 |\n| 1995 | BRAZIL | 18312154700 |\n| 1995 | CANADA | 19125224320 |\n| 1995 | PERU | 19556174422 |\n| 1995 | UNITED STATES | 18621130488 |\n| 1996 | ARGENTINA | 20003855790 |\n| 1996 | BRAZIL | 18336970302 |\n| 1996 | CANADA | 20123208406 |\n| 1996 | PERU | 18710271348 |\n| 1996 | UNITED STATES | 19539424348 |\n| 1997 | ARGENTINA | 19709120522 |\n| 1997 | BRAZIL | 18243142094 |\n| 1997 | CANADA | 20194743556 |\n| 1997 | PERU | 18631051834 |\n| 1997 | UNITED STATES | 21013447758 |\n| 1998 | ARGENTINA | 11668480814 |\n| 1998 | BRAZIL | 10712796190 |\n| 1998 | CANADA | 10846422392 |\n| 1998 | PERU | 11452371940 |\n| 1998 | UNITED STATES | 12018924038 |\n+------+---------------+-------------+\n\n-- Q4.2\n+------+---------------+------------+------------+\n| year | s_nation | p_category | profit |\n+------+---------------+------------+------------+\n| 1997 | ARGENTINA | MFGR#11 | 1814143132 |\n| 1997 | ARGENTINA | MFGR#12 | 1848231124 |\n| 1997 | ARGENTINA | MFGR#13 | 1945723642 |\n| 1997 | ARGENTINA | MFGR#14 | 1950820690 |\n| 1997 | ARGENTINA | MFGR#15 | 1877734750 |\n| 1997 | ARGENTINA | MFGR#21 | 2029565148 |\n| 1997 | ARGENTINA | MFGR#22 | 1746033566 |\n| 1997 | ARGENTINA | MFGR#23 | 2060714604 |\n| 1997 | ARGENTINA | MFGR#24 | 1786921158 |\n| 1997 | ARGENTINA | MFGR#25 | 2012622806 |\n| 1997 | BRAZIL | MFGR#11 | 2146438656 |\n| 1997 | BRAZIL | MFGR#12 | 1979717666 |\n| 1997 | BRAZIL | MFGR#13 | 2256960758 |\n| 1997 | BRAZIL | MFGR#14 | 2388513444 |\n| 1997 | BRAZIL | MFGR#15 | 2188838248 |\n| 1997 | BRAZIL | MFGR#21 | 1820053664 |\n| 1997 | BRAZIL | MFGR#22 | 1986284096 |\n| 1997 | BRAZIL | MFGR#23 | 2215345748 |\n| 1997 | BRAZIL | MFGR#24 | 2116027298 |\n| 1997 | BRAZIL | MFGR#25 | 1989467528 |\n| 1997 | CANADA | MFGR#11 | 1709450040 |\n| 1997 | CANADA | MFGR#12 | 1877436328 |\n| 1997 | CANADA | MFGR#13 | 1918531780 |\n| 1997 | CANADA | MFGR#14 | 2005624900 |\n| 1997 | CANADA | MFGR#15 | 1696366026 |\n| 1997 | CANADA | MFGR#21 | 1999610544 |\n| 1997 | CANADA | MFGR#22 | 1556839526 |\n| 1997 | CANADA | MFGR#23 | 1856719290 |\n| 1997 | CANADA | MFGR#24 | 1699790256 |\n| 1997 | CANADA | MFGR#25 | 1809175930 |\n| 1997 | PERU | MFGR#11 | 2200485754 |\n| 1997 | PERU | MFGR#12 | 1988730700 |\n| 1997 | PERU | MFGR#13 | 1694972210 |\n| 1997 | PERU | MFGR#14 | 1895539366 |\n| 1997 | PERU | MFGR#15 | 1998791356 |\n| 1997 | PERU | MFGR#21 | 1735846788 |\n| 1997 | PERU | MFGR#22 | 1977494918 |\n| 1997 | PERU | MFGR#23 | 2133290172 |\n| 1997 | PERU | MFGR#24 | 1871331450 |\n| 1997 | PERU | MFGR#25 | 1962908258 |\n| 1997 | UNITED STATES | MFGR#11 | 2093412096 |\n| 1997 | UNITED STATES | MFGR#12 | 1818427418 |\n| 1997 | UNITED STATES | MFGR#13 | 2192557812 |\n| 1997 | UNITED STATES | MFGR#14 | 1868564222 |\n| 1997 | UNITED STATES | MFGR#15 | 1925521686 |\n| 1997 | UNITED STATES | MFGR#21 | 2001352948 |\n| 1997 | UNITED STATES | MFGR#22 | 2153895230 |\n| 1997 | UNITED STATES | MFGR#23 | 1874576204 |\n| 1997 | UNITED STATES | MFGR#24 | 2006772726 |\n| 1997 | UNITED STATES | MFGR#25 | 2107332104 |\n| 1998 | ARGENTINA | MFGR#11 | 1135224454 |\n| 1998 | ARGENTINA | MFGR#12 | 1054050084 |\n| 1998 | ARGENTINA | MFGR#13 | 1165583584 |\n| 1998 | ARGENTINA | MFGR#14 | 1047452736 |\n| 1998 | ARGENTINA | MFGR#15 | 1044156534 |\n| 1998 | ARGENTINA | MFGR#21 | 1009425370 |\n| 1998 | ARGENTINA | MFGR#22 | 1012123472 |\n| 1998 | ARGENTINA | MFGR#23 | 1120959602 |\n| 1998 | ARGENTINA | MFGR#24 | 1049158236 |\n| 1998 | ARGENTINA | MFGR#25 | 1095680422 |\n| 1998 | BRAZIL | MFGR#11 | 1277156976 |\n| 1998 | BRAZIL | MFGR#12 | 1292625362 |\n| 1998 | BRAZIL | MFGR#13 | 1310323544 |\n| 1998 | BRAZIL | MFGR#14 | 1105352340 |\n| 1998 | BRAZIL | MFGR#15 | 1327625418 |\n| 1998 | BRAZIL | MFGR#21 | 1337644896 |\n| 1998 | BRAZIL | MFGR#22 | 1183583836 |\n| 1998 | BRAZIL | MFGR#23 | 1381297754 |\n| 1998 | BRAZIL | MFGR#24 | 1124724440 |\n| 1998 | BRAZIL | MFGR#25 | 1408364752 |\n| 1998 | CANADA | MFGR#11 | 1018172250 |\n| 1998 | CANADA | MFGR#12 | 976179544 |\n| 1998 | CANADA | MFGR#13 | 973066594 |\n| 1998 | CANADA | MFGR#14 | 1055674454 |\n| 1998 | CANADA | MFGR#15 | 1071738598 |\n| 1998 | CANADA | MFGR#21 | 911737302 |\n| 1998 | CANADA | MFGR#22 | 1188554616 |\n| 1998 | CANADA | MFGR#23 | 1148250140 |\n| 1998 | CANADA | MFGR#24 | 1017060848 |\n| 1998 | CANADA | MFGR#25 | 1095515984 |\n| 1998 | PERU | MFGR#11 | 1135677094 |\n| 1998 | PERU | MFGR#12 | 1081089514 |\n| 1998 | PERU | MFGR#13 | 1182663766 |\n| 1998 | PERU | MFGR#14 | 962670128 |\n| 1998 | PERU | MFGR#15 | 1140492276 |\n| 1998 | PERU | MFGR#21 | 1067466660 |\n| 1998 | PERU | MFGR#22 | 1055581312 |\n| 1998 | PERU | MFGR#23 | 1272786442 |\n| 1998 | PERU | MFGR#24 | 1178150524 |\n| 1998 | PERU | MFGR#25 | 1086502230 |\n| 1998 | UNITED STATES | MFGR#11 | 1112552464 |\n| 1998 | UNITED STATES | MFGR#12 | 1224771964 |\n| 1998 | UNITED STATES | MFGR#13 | 1244827854 |\n| 1998 | UNITED STATES | MFGR#14 | 1110013774 |\n| 1998 | UNITED STATES | MFGR#15 | 1050239138 |\n| 1998 | UNITED STATES | MFGR#21 | 1126813672 |\n| 1998 | UNITED STATES | MFGR#22 | 1160957470 |\n| 1998 | UNITED STATES | MFGR#23 | 1312160930 |\n| 1998 | UNITED STATES | MFGR#24 | 1076890116 |\n| 1998 | UNITED STATES | MFGR#25 | 1178223904 |\n+------+---------------+------------+------------+\n\n-- Q4.3\n+------+------------+-----------+---------------+\n| year | s_city | p_brand | profit |\n+------+------------+-----------+---------------+\n| 1997 | UNITED ST1 | MFGR#1414 | 10001830.0000 |\n| 1997 | UNITED ST1 | MFGR#147 | 13643806.0000 |\n| 1997 | UNITED ST9 | MFGR#144 | 4953914.0000 |\n| 1998 | UNITED ST0 | MFGR#1424 | 14202690.0000 |\n| 1998 | UNITED ST5 | MFGR#1430 | 7742358.0000 |\n+------+------------+-----------+---------------+\n5 rows in set (0.25 sec)\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/","title":"\u5b8c\u6210 TPC-C \u6d4b\u8bd5","text":"\u901a\u8fc7\u9605\u8bfb\u672c\u6559\u7a0b\uff0c\u4f60\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528 MatrixOne \u5b8c\u6210 TPC-C \u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#tpc-c_1","title":"TPC-C \u6982\u8ff0","text":"TPC-C \u662f\u4e00\u79cd\u8861\u91cf\u5728\u7ebf\u4e8b\u52a1\u5904\u7406\uff08OLTP\uff09\u7cfb\u7edf\u6027\u80fd\u548c\u53ef\u4f38\u7f29\u6027\u7684\u57fa\u51c6\u6d4b\u8bd5\u89c4\u8303\u3002TPC-C \u6a21\u62df\u4e86\u4e00\u4e2a\u6bd4\u8f83\u6709\u4ee3\u8868\u610f\u4e49\u7684 OLTP \u5e94\u7528\u73af\u5883\uff1a\u5728\u7ebf\u8ba2\u5355\u5904\u7406\u7cfb\u7edf\u3002TPC-C \u57fa\u51c6\u6d4b\u8bd5\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u5e93\u7531 Warehouse\u3001Customer\u3001Order\u3001Item \u7b49\u4e5d\u4e2a\u8868\u7ec4\u6210\uff08\u53c2\u89c1\u4e0b\u56fe\uff09\u3002\u9664 Item \u8868\u5916\uff0c\u6bcf\u6761\u8bb0\u5f55\u90fd\u4ee5\u6bcf\u4e2a Warehouse \u4e3a\u57fa\u7840\u8fdb\u884c\u586b\u5145\uff0c\u5e76\u4e14\u4ed3\u5e93\u7684\u6570\u91cf\u6309\u6bd4\u4f8b\u914d\u7f6e\u3002
TPC-C \u9700\u8981\u5904\u7406\u7684\u4ea4\u6613\u4e8b\u52a1\u6709\u4e94\u79cd\uff1aNewOrder\u3001Payment\u3001OrderStatus\u3001Delivery \u548c StockLevel\u3002TPC-C \u5b9a\u4e49\u4e86\u6bcf\u79cd\u4e8b\u52a1\u7684\u8bf7\u6c42\u7387\uff0c\u5176\u4e2d\u51e0\u4e4e 90% \u8bf7\u6c42\u7387\u7684\u4e8b\u52a1\u4e3a\u5199\u5bc6\u96c6\u578b\u7684 NewOrder \u548c Payment\u3002TPC-C \u4e8b\u52a1\u4e3b\u8981\u8bbf\u95ee\u5355\u4e2a\uff08\u672c\u5730\uff09\u4ed3\u5e93\uff0c\u4f46\u5927\u7ea6 10% \u7684\u4e8b\u52a1\u4e0e\u53e6\u4e00\u4e2a\uff08\u8fdc\u7a0b\uff09\u4ed3\u5e93\u4ea4\u4e92\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#matrixone","title":"\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne","text":"\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#mo-tpcc","title":"\u514b\u9686 mo-tpcc \u4ed3\u5e93\u5230\u672c\u5730","text":"git clone https://github.com/matrixorigin/mo-tpcc.git\n\u6216\u8005\ngit clone https://githubfast.com/matrixorigin/mo-tpcc.git\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#_2","title":"\u6b65\u9aa4","text":""},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#_3","title":"\u6b65\u9aa4\u7b80\u4ecb","text":"\u672c\u8282\u5c06\u4ecb\u7ecd\u5982\u4f55\u751f\u6210 TPCC \u6570\u636e\u3001\u521b\u5efa TPCC \u8868\uff0c\u5e76\u5c06\u6570\u636e\u52a0\u8f7d\u5230 MatrixOne \u4ee5\u53ca\u8fd0\u884c TPCC \u6d4b\u8bd5\u3002
\u73b0\u5728\u4f60\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u63cf\u8ff0\u9010\u6b65\u6267\u884c\u547d\u4ee4\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#1-propsmo","title":"1. \u914d\u7f6e props.mo \u6587\u4ef6","text":"\u514b\u9686 mo-tpch \u4ed3\u5e93\u5230\u672c\u5730\u540e\uff0c\u5728\u672c\u5730\u6253\u5f00 mo-tpch \u6587\u4ef6\u5939\uff0c\u6309\u7167\u4e0b\u9762\u7684\u914d\u7f6e\u9879\uff0c\u4fee\u6539\u6587\u4ef6\u5939\u4e2d\u7684 props.mo \u6587\u4ef6\u3002\u6570\u636e\u4ed3\u5e93\u7684\u6570\u91cf\u53ef\u4ee5\u901a\u8fc7\u8be5\u6587\u4ef6\u4e2d\u7684 warehouse=XX
\u884c\u8fdb\u884c\u914d\u7f6e\u3002
db=mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=111\n\n//the number of warehouse\nwarehouses=10\nloadWorkers=4\n\n//the num of terminals that will simultaneously run\n//must be less than warehouses*10\nterminals=1\n//To run specified transactions per terminal- runMins must equal zero\nrunTxnsPerTerminal=0\n//To run for specified minutes- runTxnsPerTerminal must equal zero\nrunMins=1\n//Number of total transactions per minute\nlimitTxnsPerMin=0\n
\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58 props.mo \u6587\u4ef6\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#2-tpcc","title":"2. \u521b\u5efa TPCC \u6570\u636e\u5e93\u548c\u8868","text":"\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff1a
cd mo-tpcc\n./runSQL.sh props.mo tableCreates\n
Note: \u5982\u679c\u5728\u8fd0\u884c ./runSQL.sh props.mo tableCreates
\u65f6\u4ea7\u751f java:command not found
\u62a5\u9519\uff0c\u90a3\u4e48\u4f60\u9700\u8981\u5728\u4f60\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u6216\u91cd\u65b0\u5b89\u88c5 Java \u548c JDK\u3002
\u4e0a\u9762\u7684\u4ee3\u7801\u8868\u793a\uff0c\u8fdb\u5165\u5230 mo-tpch \u6587\u4ef6\u5939\u76ee\u5f55\uff0c\u6267\u884c\u4ee3\u7801\u521b\u5efa\u5b8c\u6210 TPCC \u6570\u636e\u5e93\u548c\u8868\u3002
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
# ------------------------------------------------------------\n# Loading SQL file ./sql/tableCreates.sql\n# ------------------------------------------------------------\ndrop database if exists tpcc;\ncreate database if not exists tpcc;\nuse tpcc;\ncreate table bmsql_config (\ncfg_name varchar(30) primary key,\ncfg_value varchar(50)\n);\ncreate table bmsql_warehouse (\nw_id integer not null,\nw_ytd decimal(12,2),\nw_tax decimal(4,4),\nw_name varchar(10),\nw_street_1 varchar(20),\nw_street_2 varchar(20),\nw_city varchar(20),\nw_state char(2),\nw_zip char(9),\nprimary key (w_id)\n) PARTITION BY KEY(w_id);\ncreate table bmsql_district (\nd_w_id integer not null,\nd_id integer not null,\nd_ytd decimal(12,2),\nd_tax decimal(4,4),\nd_next_o_id integer,\nd_name varchar(10),\nd_street_1 varchar(20),\nd_street_2 varchar(20),\nd_city varchar(20),\nd_state char(2),\nd_zip char(9),\nprimary key (d_w_id, d_id)\n) PARTITION BY KEY(d_w_id);\ncreate table bmsql_customer (\nc_w_id integer not null,\nc_d_id integer not null,\nc_id integer not null,\nc_discount decimal(4,4),\nc_credit char(2),\nc_last varchar(16),\nc_first varchar(16),\nc_credit_lim decimal(12,2),\nc_balance decimal(12,2),\nc_ytd_payment decimal(12,2),\nc_payment_cnt integer,\nc_delivery_cnt integer,\nc_street_1 varchar(20),\nc_street_2 varchar(20),\nc_city varchar(20),\nc_state char(2),\nc_zip char(9),\nc_phone char(16),\nc_since timestamp,\nc_middle char(2),\nc_data varchar(500),\nprimary key (c_w_id, c_d_id, c_id)\n) PARTITION BY KEY(c_w_id);\ncreate table bmsql_history (\nhist_id integer auto_increment,\nh_c_id integer,\nh_c_d_id integer,\nh_c_w_id integer,\nh_d_id integer,\nh_w_id integer,\nh_date timestamp,\nh_amount decimal(6,2),\nh_data varchar(24),\nprimary key (hist_id)\n);\ncreate table bmsql_new_order (\nno_w_id integer not null,\nno_d_id integer not null,\nno_o_id integer not null,\nprimary key (no_w_id, no_d_id, no_o_id)\n) PARTITION BY KEY(no_w_id);\ncreate table bmsql_oorder (\no_w_id integer not null,\no_d_id integer not null,\no_id integer not null,\no_c_id integer,\no_carrier_id integer,\no_ol_cnt integer,\no_all_local integer,\no_entry_d timestamp,\nprimary key (o_w_id, o_d_id, o_id)\n) PARTITION BY KEY(o_w_id);\ncreate table bmsql_order_line (\nol_w_id integer not null,\nol_d_id integer not null,\nol_o_id integer not null,\nol_number integer not null,\nol_i_id integer not null,\nol_delivery_d timestamp,\nol_amount decimal(6,2),\nol_supply_w_id integer,\nol_quantity integer,\nol_dist_info char(24),\nprimary key (ol_w_id, ol_d_id, ol_o_id, ol_number)\n) PARTITION BY KEY(ol_w_id);\ncreate table bmsql_item (\ni_id integer not null,\ni_name varchar(24),\ni_price decimal(5,2),\ni_data varchar(50),\ni_im_id integer,\nprimary key (i_id)\n) PARTITION BY KEY(i_id);\ncreate table bmsql_stock (\ns_w_id integer not null,\ns_i_id integer not null,\ns_quantity integer,\ns_ytd integer,\ns_order_cnt integer,\ns_remote_cnt integer,\ns_data varchar(50),\ns_dist_01 char(24),\ns_dist_02 char(24),\ns_dist_03 char(24),\ns_dist_04 char(24),\ns_dist_05 char(24),\ns_dist_06 char(24),\ns_dist_07 char(24),\ns_dist_08 char(24),\ns_dist_09 char(24),\ns_dist_10 char(24),\nprimary key (s_w_id, s_i_id)\n) PARTITION BY KEY(s_w_id);\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#3-tpcc","title":"3. \u751f\u6210 TPCC \u6570\u636e\u96c6","text":"\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u751f\u6210 TPCC \u6570\u636e\u96c6\uff1a
./runLoader.sh props.mo filelocation /yourpath/\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
Starting BenchmarkSQL LoadData\n\nprops.mo\ndriver=com.mysql.cj.jdbc.Driver\nconn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\nuser=root\npassword=***********\nwarehouses=10\nloadWorkers=4\nfileLocation (not defined)\ncsvNullValue (not defined - using default '')\n\nWorker 000: Loading ITEM\nWorker 001: Loading Warehouse 1\nWorker 002: Loading Warehouse 2\nWorker 003: Loading Warehouse 3\nWorker 000: Loading ITEM done\nWorker 000: Loading Warehouse 4\nWorker 003: Loading Warehouse 3 done\nWorker 003: Loading Warehouse 5\nWorker 001: Loading Warehouse 1 done\nWorker 001: Loading Warehouse 6\nWorker 002: Loading Warehouse 2 done\nWorker 002: Loading Warehouse 7\nWorker 000: Loading Warehouse 4 done\nWorker 000: Loading Warehouse 8\nWorker 003: Loading Warehouse 5 done\nWorker 003: Loading Warehouse 9\nWorker 000: Loading Warehouse 8 done\nWorker 000: Loading Warehouse 10\nWorker 002: Loading Warehouse 7 done\nWorker 001: Loading Warehouse 6 done\nWorker 000: Loading Warehouse 10 done\nWorker 003: Loading Warehouse 9 done\n
\u4f60\u4f1a\u5728\u4f60\u6240\u6307\u5b9a\u8def\u5f84\u4e2d\u627e\u5230 10 \u4e2a csv \u6587\u4ef6\uff0c\u6bcf\u4e2a csv \u6587\u4ef6\u90fd\u4f1a\u6620\u5c04\u5230\u7b2c 2 \u6b65\u4e2d\u521b\u5efa\u7684\u8868\u4e2d\u3002
config.csv\ncust-hist.csv\ncustomer.csv\ndistrict.csv\nitem.csv\nnew-order.csv\norder-line.csv\norder.csv\nstock.csv\nwarehouse.csv\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#4-tpcc-matrixone","title":"4. \u5c06 TPCC \u6570\u636e\u52a0\u8f7d\u5230 MatrixOne","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u5e76\u6267\u884c\u4ee5\u4e0b\u8bed\u53e5\u5c06 csv \u6587\u4ef6\u52a0\u8f7d\u5230 MatrixOne \u4e2d\u3002
mysql> load data infile '/yourpath/config.csv' INTO TABLE bmsql_config FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/cust-hist.csv' INTO TABLE bmsql_history FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/customer.csv' INTO TABLE bmsql_customer FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/district.csv' INTO TABLE bmsql_district FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/data/warehouse.csv' INTO TABLE bmsql_warehouse FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/item.csv' INTO TABLE bmsql_item FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/new-order.csv' INTO TABLE bmsql_new_order FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order-line.csv' INTO TABLE bmsql_order_line FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/stock.csv' INTO TABLE bmsql_stock FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\nload data infile '/yourpath/order.csv' INTO TABLE bmsql_oorder FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY \"\\r\\n\";\n
"},{"location":"MatrixOne/Test/performance-testing/TPCC-test-with-matrixone/#5-tpcc","title":"5. \u8fd0\u884c TPCC \u6d4b\u8bd5","text":"\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u8fd0\u884c TPCC \u6d4b\u8bd5\uff1a
./runBenchmark.sh props.mo\n
\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
.:./lib/*\n2022-12-22 21:15:35 INFO jTPCC:78 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:79 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO jTPCC:80 - Term-00, BenchmarkSQL v5.0\n2022-12-22 21:15:35 INFO jTPCC:81 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO jTPCC:82 - Term-00, (c) 2003, Raul Barbosa\n2022-12-22 21:15:35 INFO jTPCC:83 - Term-00, (c) 2004-2016, Denis Lussier\n2022-12-22 21:15:35 INFO jTPCC:84 - Term-00, (c) 2016, Jan Wieck\n2022-12-22 21:15:35 INFO jTPCC:85 - Term-00, +-------------------------------------------------------------+\n2022-12-22 21:15:35 INFO jTPCC:86 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, db=mo\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, driver=com.mysql.cj.jdbc.Driver\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, conn=jdbc:mysql://127.0.0.1:6001/tpcc?characterSetResults=utf8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&enabledTLSProtocols=TLSv1.2&useSSL=false\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, user=root\n2022-12-22 21:15:35 INFO jTPCC:93 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, warehouses=10\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, terminals=1\n2022-12-22 21:15:35 INFO jTPCC:100 - Term-00, runMins=1\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, limitTxnsPerMin=0\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, terminalWarehouseFixed=false\n2022-12-22 21:15:35 INFO jTPCC:108 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, newOrderWeight=45\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, paymentWeight=43\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, orderStatusWeight=4\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, deliveryWeight=4\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, stockLevelWeight=4\n2022-12-22 21:15:35 INFO jTPCC:115 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, resultDirectory=my_result_%tY-%tm-%td_%tH%tM%tS\n2022-12-22 21:15:35 INFO jTPCC:63 - Term-00, osCollectorScript=null\n2022-12-22 21:15:35 INFO jTPCC:119 - Term-00,\n2022-12-22 21:15:35 INFO jTPCC:710 - Term-00, Loading database driver: 'com.mysql.cj.jdbc.Driver'...\n2022-12-22 21:15:35 INFO jTPCC:219 - Term-00, copied props.mo to my_result_2022-12-22_211535/run.properties\n2022-12-22 21:15:35 INFO jTPCC:239 - Term-00, created my_result_2022-12-22_211535/data/runInfo.csv for runID 1\n2022-12-22 21:15:35 INFO jTPCC:255 - Term-00, writing per transaction results to my_result_2022-12-22_211535/data/result.csv\n2022-12-22 21:15:35 INFO jTPCC:268 - Term-00,\n2022-12-22 21:15:36 INFO jTPCC:324 - Term-00, C value for C_LAST during load: 28\n2022-12-22 21:15:36 INFO jTPCC:325 - Term-00, C value for C_LAST this run: 132\n2022-12-22 21:15:36 INFO jTPCC:326 - Term-00,\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Session started! Memory Usage: 17MB / 245MB \n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Creating 1 terminal(s) with -1 transaction(s) per terminal...\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Terminal Warehouse is NOT fixed\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Transaction Weights: 45% New-Order, 43% Payment, 4% Order-Status, 4% Delivery, 4% Stock-Level\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Number of Terminals 1\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Creating database connection for Term-01...\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Term-01 7\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Transaction Weight\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % New-Order 45\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Payment 43\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Order-Status 4\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Delivery 4\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, % Stock-Level 4\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Transaction Number Terminal Type Execution Time (ms) Comment\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Created 1 terminal(s) successfully!\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, Starting all terminals...\n2022-12-22 21:15:36 INFO jTPCC:710 - Term-00, All terminals started executing 2022-12-22 21:15:36\nTerm-00, Running Average tpmTOTAL: 60000.00 Current tpmTOTAL: 12 Memory Usage: 19MB / 245MB 2022-12-22 21:15:36 INFO jTPCCTerminal:350 - Term-01, Executing for a limited time...\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, The time limit has been reached.: 21MB / 245MB \n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, Signalling all terminals to stop...\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Terminal received stop signal!\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Finishing current transaction before exit...\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, Waiting for all active transactions to end...\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, OTAL: 24 Memory Usage: 22MB / 245MB \n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Closing statement and connection...\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01,\n2022-12-22 21:16:42 INFO jTPCCTerminal:350 - Term-01, Terminal 'Term-01' finished after 0 transaction(s).\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, All terminals finished executing 2022-12-22 21:16:42\n\n2022-12-22 21:16:42 INFO jTPCC:694 - Term-00,\n2022-12-22 21:16:42 INFO jTPCC:695 - Term-00,\n2022-12-22 21:16:42 INFO jTPCC:696 - Term-00, Measured tpmC (NewOrders) = 2.74\n2022-12-22 21:16:42 INFO jTPCC:697 - Term-00, Measured tpmTOTAL = 3.66\n2022-12-22 21:16:42 INFO jTPCC:698 - Term-00, Measured tpmE (ErrorCount) = 0.0\n2022-12-22 21:16:42 INFO jTPCC:699 - Term-00, Session Start = 2022-12-22 21:15:36\n2022-12-22 21:16:42 INFO jTPCC:700 - Term-00, Session End = 2022-12-22 21:16:42\n2022-12-22 21:16:42 INFO jTPCC:701 - Term-00, Transaction Count = 3\n2022-12-22 21:16:42 INFO jTPCC:702 - Term-00, Transaction Error = 0\n2022-12-22 21:16:42 INFO jTPCC:703 - Term-00, Transaction NewOrders = 3\n2022-12-22 21:16:42 INFO jTPCC:710 - Term-00, Session finished!\n
\u7531\u4e0a\u9762\u7684\u7ed3\u679c\u53ef\u4ee5\u5f97\u5230 tpmC\uff08\u6bcf\u5206\u949f\u4e8b\u52a1\u6570\uff09\u7684\u503c\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/","title":"\u5b8c\u6210 TPCH \u6d4b\u8bd5","text":"TPC Benchmark\u2122H\uff08TPC-H\uff09\u662f\u51b3\u7b56\u652f\u6301\u57fa\u51c6\u3002\u5b83\u7531\u4e00\u5957\u9762\u5411\u4e1a\u52a1\u7684\u5373\u65f6\u67e5\u8be2\uff08ad-hoc\uff09\u548c\u5e76\u53d1\u6570\u636e\u4fee\u6539\u7ec4\u6210\u3002\u9009\u62e9\u67e5\u8be2\u548c\u586b\u5145\u6570\u636e\u5e93\u7684\u6570\u636e\u5177\u6709\u5e7f\u6cdb\u7684\u884c\u4e1a\u76f8\u5173\u6027\u3002\u8be5\u57fa\u51c6\u6d4b\u8bd5\u89e3\u91ca\u8bf4\u660e\u4e86\u51b3\u7b56\u652f\u6301\u7cfb\u7edf\uff0c\u8be5\u7cfb\u7edf\u53ef\u68c0\u67e5\u5927\u91cf\u6570\u636e\uff0c\u6267\u884c\u9ad8\u5ea6\u590d\u6742\u7684\u67e5\u8be2\u5e76\u4e3a\u5173\u952e\u4e1a\u52a1\u95ee\u9898\u63d0\u4f9b\u7b54\u6848\u3002TPC-H \u662f OLAP \u6570\u636e\u5e93\u5e7f\u6cdb\u4f7f\u7528\u7684\u57fa\u51c6\u6d4b\u8bd5\u3002
\u901a\u8fc7\u9605\u8bfb\u672c\u6559\u7a0b\uff0c\u60a8\u5c06\u5b66\u4e60\u5982\u4f55\u4f7f\u7528 MatrixOne \u5b8c\u6210 TPC-H \u6d4b\u8bd5\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#1-dbgen","title":"1. \u7f16\u8bd1 dbgen","text":"\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cTPCH dbgen \u5b9e\u7528\u7a0b\u5e8f\u662f\u7528\u6765\u751f\u6210\u6d4b\u8bd5\u6570\u636e\u96c6\u8868\u683c\u7684\u5de5\u5177\uff0c\u5b83\u6839\u636e\u6bd4\u4f8b\u56e0\u5b50 Scale Factor\uff08SF) \u7684\u5927\u5c0f\u786e\u5b9a\u6570\u636e\u96c6\u7684\u5927\u5c0f\uff0c\u5e76\u751f\u6210\u4e00\u7ec4\u5e73\u9762\u6587\u4ef6\uff08Flat File)\uff0c\u8fd9\u4e9b\u6587\u4ef6\u9002\u5408\u52a0\u8f7d\u5230 tpch \u6a21\u5f0f\u4e2d\u3002
\u5f53\u4f7f\u7528 -s 1
\u65f6 dbgen
\u547d\u4ee4\u4f1a\u4ea7\u751f 1GB \u7684\u5b8c\u6574\u6570\u636e\u96c6\uff0c\u5f53\u4f7f\u7528 -s 10
\u65f6\u4f1a\u4ea7\u751f\u5927\u7ea6 10GB \u7684\u6570\u636e\u96c6\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002
git clone https://github.com/electrum/tpch-dbgen.git\n\u6216\u8005\ngit clone https://githubfast.com/electrum/tpch-dbgen.git\ncd tpch-dbgen\nmake\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#2","title":"2. \u751f\u6210\u6570\u636e","text":"\u8fd0\u884c dbgen
\uff0c\u83b7\u5f97\u9002\u5f53\u7684\u6570\u636e\u5e93\u5927\u5c0f\u56e0\u5b50 (\u5728\u793a\u4f8b\u4e2d\u4e3a 1GB)\u3002
./dbgen -s 1\n
\u751f\u6210\u5b8c\u6574\u6570\u636e\u96c6\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u3002\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u770b\u5230\u7ed3\u679c\u6587\u4ef6\u3002
total 2150000\n-rw-r--r-- 1 deister staff 24346144 13 may 12:05 customer.tbl\n-rw-r--r-- 1 deister staff 759863287 13 may 12:05 lineitem.tbl\n-rw-r--r-- 1 deister staff 2224 13 may 12:05 nation.tbl\n-rw-r--r-- 1 deister staff 171952161 13 may 12:05 orders.tbl\n-rw-r--r-- 1 deister staff 24135125 13 may 12:05 part.tbl\n-rw-r--r-- 1 deister staff 118984616 13 may 12:05 partsupp.tbl\n-rw-r--r-- 1 deister staff 389 13 may 12:05 region.tbl\n-rw-r--r-- 1 deister staff 1409184 13 may 12:05 supplier.tbl\n
\u6211\u4eec\u540c\u65f6\u4e5f\u51c6\u5907\u4e86 1GB \u7684\u6570\u636e\u96c6\u4f9b\u60a8\u4e0b\u8f7d\u3002\u60a8\u53ef\u4ee5\u5728\u4ee5\u4e0b\u94fe\u63a5\u4e2d\u76f4\u63a5\u83b7\u53d6\u6570\u636e\u6587\u4ef6\uff1a
https://community-shared-data-1308875761.cos.ap-beijing.myqcloud.com/tpch/tpch-1g.zip\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#3-matrixone","title":"3. \u5728 MatrixOne \u4e2d\u5efa\u8868","text":"MatrixOne \u6682\u4e0d\u652f\u6301\u5206\u533a\u52a0\u901f\uff0cLINEITEM
\u8868\u7684\u521b\u5efa\u4ee3\u7801\u6709\u4ee5\u4e0b\u4fee\u6539\uff1a
LINEITEM
\u8868\u7684 PARTITION BY KEY()
\u3002drop database if exists TPCH;\ncreate database if not exists TPCH;\nuse tpch;\nCREATE TABLE NATION(\nN_NATIONKEY INTEGER NOT NULL,\nN_NAME CHAR(25) NOT NULL,\nN_REGIONKEY INTEGER NOT NULL,\nN_COMMENT VARCHAR(152),\nPRIMARY KEY (N_NATIONKEY)\n);\n\nCREATE TABLE REGION(\nR_REGIONKEY INTEGER NOT NULL,\nR_NAME CHAR(25) NOT NULL,\nR_COMMENT VARCHAR(152),\nPRIMARY KEY (R_REGIONKEY)\n);\n\nCREATE TABLE PART(\nP_PARTKEY INTEGER NOT NULL,\nP_NAME VARCHAR(55) NOT NULL,\nP_MFGR CHAR(25) NOT NULL,\nP_BRAND CHAR(10) NOT NULL,\nP_TYPE VARCHAR(25) NOT NULL,\nP_SIZE INTEGER NOT NULL,\nP_CONTAINER CHAR(10) NOT NULL,\nP_RETAILPRICE DECIMAL(15,2) NOT NULL,\nP_COMMENT VARCHAR(23) NOT NULL,\nPRIMARY KEY (P_PARTKEY)\n);\n\nCREATE TABLE SUPPLIER(\nS_SUPPKEY INTEGER NOT NULL,\nS_NAME CHAR(25) NOT NULL,\nS_ADDRESS VARCHAR(40) NOT NULL,\nS_NATIONKEY INTEGER NOT NULL,\nS_PHONE CHAR(15) NOT NULL,\nS_ACCTBAL DECIMAL(15,2) NOT NULL,\nS_COMMENT VARCHAR(101) NOT NULL,\nPRIMARY KEY (S_SUPPKEY)\n);\n\nCREATE TABLE PARTSUPP (\nPS_PARTKEY INTEGER NOT NULL,\nPS_SUPPKEY INTEGER NOT NULL,\nPS_AVAILQTY INTEGER NOT NULL,\nPS_SUPPLYCOST DECIMAL(15,2) NOT NULL,\nPS_COMMENT VARCHAR(199) NOT NULL,\nPRIMARY KEY (PS_PARTKEY, PS_SUPPKEY)\n);\n\nCREATE TABLE CUSTOMER(\nC_CUSTKEY INTEGER NOT NULL,\nC_NAME VARCHAR(25) NOT NULL,\nC_ADDRESS VARCHAR(40) NOT NULL,\nC_NATIONKEY INTEGER NOT NULL,\nC_PHONE CHAR(15) NOT NULL,\nC_ACCTBAL DECIMAL(15,2) NOT NULL,\nC_MKTSEGMENT CHAR(10) NOT NULL,\nC_COMMENT VARCHAR(117) NOT NULL,\nPRIMARY KEY (C_CUSTKEY)\n);\n\nCREATE TABLE ORDERS(\nO_ORDERKEY BIGINT NOT NULL,\nO_CUSTKEY INTEGER NOT NULL,\nO_ORDERSTATUS CHAR(1) NOT NULL,\nO_TOTALPRICE DECIMAL(15,2) NOT NULL,\nO_ORDERDATE DATE NOT NULL,\nO_ORDERPRIORITY CHAR(15) NOT NULL,\nO_CLERK CHAR(15) NOT NULL,\nO_SHIPPRIORITY INTEGER NOT NULL,\nO_COMMENT VARCHAR(79) NOT NULL,\nPRIMARY KEY (O_ORDERKEY)\n);\n\nCREATE TABLE LINEITEM (\nL_ORDERKEY BIGINT NOT NULL,\nL_PARTKEY INTEGER NOT NULL,\nL_SUPPKEY INTEGER NOT NULL,\nL_LINENUMBER INTEGER NOT NULL,\nL_QUANTITY DECIMAL(15,2) NOT NULL,\nL_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,\nL_DISCOUNT DECIMAL(15,2) NOT NULL,\nL_TAX DECIMAL(15,2) NOT NULL,\nL_RETURNFLAG CHAR(1) NOT NULL,\nL_LINESTATUS CHAR(1) NOT NULL,\nL_SHIPDATE DATE NOT NULL,\nL_COMMITDATE DATE NOT NULL,\nL_RECEIPTDATE DATE NOT NULL,\nL_SHIPINSTRUCT CHAR(25) NOT NULL,\nL_SHIPMODE CHAR(10) NOT NULL,\nL_COMMENT VARCHAR(44) NOT NULL,\nPRIMARY KEY (L_ORDERKEY, L_LINENUMBER)\n);\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#4","title":"4. \u5bfc\u5165\u6570\u636e","text":"\u5728 MatrixOne \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6570\u636e\u52a0\u8f7d\u5230\u76f8\u5173\u7684\u8868\u4e2d\u3002
load data infile '/YOUR_TPCH_DATA_PATH/nation.tbl' into table NATION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/region.tbl' into table REGION FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/part.tbl' into table PART FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/supplier.tbl' into table SUPPLIER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/partsupp.tbl' into table PARTSUPP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/orders.tbl' into table ORDERS FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/customer.tbl' into table CUSTOMER FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n\nload data infile '/YOUR_TPCH_DATA_PATH/lineitem.tbl' into table LINEITEM FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n';\n
\u52a0\u8f7d\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u521b\u5efa\u7684\u8868\u67e5\u8be2 MatrixOne \u4e2d\u7684\u6570\u636e\u3002
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#5-tpch","title":"5. \u8fd0\u884c TPCH \u6d4b\u8bd5\u547d\u4ee4","text":"-- Q1\nselect\nl_returnflag,\nl_linestatus,\nsum(l_quantity) as sum_qty,\nsum(l_extendedprice) as sum_base_price,\nsum(l_extendedprice * (1 - l_discount)) as sum_disc_price,\nsum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,\navg(l_quantity) as avg_qty,\navg(l_extendedprice) as avg_price,\navg(l_discount) as avg_disc,\ncount(*) as count_order\nfrom\nlineitem\nwhere\nl_shipdate <= date '1998-12-01' - interval '112' day\ngroup by\nl_returnflag,\nl_linestatus\norder by\nl_returnflag,\nl_linestatus\n;\n\n-- Q2\nselect\ns_acctbal,\ns_name,\nn_name,\np_partkey,\np_mfgr,\ns_address,\ns_phone,\ns_comment\nfrom\npart,\nsupplier,\npartsupp,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand p_size = 48\nand p_type like '%TIN'\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\nand ps_supplycost = (\nselect\nmin(ps_supplycost)\nfrom\npartsupp,\nsupplier,\nnation,\nregion\nwhere\np_partkey = ps_partkey\nand s_suppkey = ps_suppkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'MIDDLE EAST'\n)\norder by\ns_acctbal desc,\nn_name,\ns_name,\np_partkey\nlimit 100\n;\n\n\n-- Q3\nselect\nl_orderkey,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\no_orderdate,\no_shippriority\nfrom\ncustomer,\norders,\nlineitem\nwhere\nc_mktsegment = 'HOUSEHOLD'\nand c_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate < date '1995-03-29'\nand l_shipdate > date '1995-03-29'\ngroup by\nl_orderkey,\no_orderdate,\no_shippriority\norder by\nrevenue desc,\no_orderdate\nlimit 10\n;\n\n-- Q4\nselect\no_orderpriority,\ncount(*) as order_count\nfrom\norders\nwhere\no_orderdate >= date '1997-07-01'\nand o_orderdate < date '1997-07-01' + interval '3' month\nand exists (\nselect\n*\nfrom\nlineitem\nwhere\nl_orderkey = o_orderkey\nand l_commitdate < l_receiptdate\n)\ngroup by\no_orderpriority\norder by\no_orderpriority\n;\n\n\n-- Q5\nselect\nn_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue\nfrom\ncustomer,\norders,\nlineitem,\nsupplier,\nnation,\nregion\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand l_suppkey = s_suppkey\nand c_nationkey = s_nationkey\nand s_nationkey = n_nationkey\nand n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand o_orderdate >= date '1994-01-01'\nand o_orderdate < date '1994-01-01' + interval '1' year\ngroup by\nn_name\norder by\nrevenue desc\n;\n\n\n-- Q6\nselect\nsum(l_extendedprice * l_discount) as revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1994-01-01'\nand l_shipdate < date '1994-01-01' + interval '1' year\nand l_discount between 0.03 - 0.01 and 0.03 + 0.01\nand l_quantity < 24;\n\n-- Q7\nselect\nsupp_nation,\ncust_nation,\nl_year,\nsum(volume) as revenue\nfrom\n(\nselect\nn1.n_name as supp_nation,\nn2.n_name as cust_nation,\nextract(year from l_shipdate) as l_year,\nl_extendedprice * (1 - l_discount) as volume\nfrom\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2\nwhere\ns_suppkey = l_suppkey\nand o_orderkey = l_orderkey\nand c_custkey = o_custkey\nand s_nationkey = n1.n_nationkey\nand c_nationkey = n2.n_nationkey\nand (\n(n1.n_name = 'FRANCE' and n2.n_name = 'ARGENTINA')\nor (n1.n_name = 'ARGENTINA' and n2.n_name = 'FRANCE')\n)\nand l_shipdate between date '1995-01-01' and date '1996-12-31'\n) as shipping\ngroup by\nsupp_nation,\ncust_nation,\nl_year\norder by\nsupp_nation,\ncust_nation,\nl_year\n;\n\n-- Q8\nselect\no_year,\n(sum(case\nwhen nation = 'ARGENTINA' then volume\nelse 0\nend) / sum(volume)) as mkt_share\nfrom\n(\nselect\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) as volume,\nn2.n_name as nation\nfrom\npart,\nsupplier,\nlineitem,\norders,\ncustomer,\nnation n1,\nnation n2,\nregion\nwhere\np_partkey = l_partkey\nand s_suppkey = l_suppkey\nand l_orderkey = o_orderkey\nand o_custkey = c_custkey\nand c_nationkey = n1.n_nationkey\nand n1.n_regionkey = r_regionkey\nand r_name = 'AMERICA'\nand s_nationkey = n2.n_nationkey\nand o_orderdate between date '1995-01-01' and date '1996-12-31'\nand p_type = 'ECONOMY BURNISHED TIN'\n) as all_nations\ngroup by\no_year\norder by\no_year\n;\n\n-- Q9\nselect\nnation,\no_year,\nsum(amount) as sum_profit\nfrom\n(\nselect\nn_name as nation,\nextract(year from o_orderdate) as o_year,\nl_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount\nfrom\npart,\nsupplier,\nlineitem,\npartsupp,\norders,\nnation\nwhere\ns_suppkey = l_suppkey\nand ps_suppkey = l_suppkey\nand ps_partkey = l_partkey\nand p_partkey = l_partkey\nand o_orderkey = l_orderkey\nand s_nationkey = n_nationkey\nand p_name like '%pink%'\n) as profit\ngroup by\nnation,\no_year\norder by\nnation,\no_year desc\n;\n\n\n-- Q10\nselect\nc_custkey,\nc_name,\nsum(l_extendedprice * (1 - l_discount)) as revenue,\nc_acctbal,\nn_name,\nc_address,\nc_phone,\nc_comment\nfrom\ncustomer,\norders,\nlineitem,\nnation\nwhere\nc_custkey = o_custkey\nand l_orderkey = o_orderkey\nand o_orderdate >= date '1993-03-01'\nand o_orderdate < date '1993-03-01' + interval '3' month\nand l_returnflag = 'R'\nand c_nationkey = n_nationkey\ngroup by\nc_custkey,\nc_name,\nc_acctbal,\nc_phone,\nn_name,\nc_address,\nc_comment\norder by\nrevenue desc\nlimit 20\n;\n\n\n-- Q11\nselect\nps_partkey,\nsum(ps_supplycost * ps_availqty) as value\nfrom\npartsupp,\nsupplier,\nnation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\ngroup by\nps_partkey having\nsum(ps_supplycost * ps_availqty) > (\nselect\nsum(ps_supplycost * ps_availqty) * 0.0001000000\nfrom\npartsupp,\nsupplier,nation\nwhere\nps_suppkey = s_suppkey\nand s_nationkey = n_nationkey\nand n_name = 'JAPAN'\n)\norder by\nvalue desc\n;\n\n-- Q12\nselect\nl_shipmode,\nsum(case\nwhen o_orderpriority = '1-URGENT'\nor o_orderpriority = '2-HIGH'\nthen 1\nelse 0\nend) as high_line_count,\nsum(case\nwhen o_orderpriority <> '1-URGENT'\nand o_orderpriority <> '2-HIGH'\nthen 1\nelse 0\nend) as low_line_count\nfrom\norders,\nlineitem\nwhere\no_orderkey = l_orderkey\nand l_shipmode in ('FOB', 'TRUCK')\nand l_commitdate < l_receiptdate\nand l_shipdate < l_commitdate\nand l_receiptdate >= date '1996-01-01'\nand l_receiptdate < date '1996-01-01' + interval '1' year\ngroup by\nl_shipmode\norder by\nl_shipmode\n;\n\n-- Q13\nselect\nc_count,\ncount(*) as custdist\nfrom\n(\nselect\nc_custkey,\ncount(o_orderkey)\nfrom\ncustomer left outer join orders on\nc_custkey = o_custkey\nand o_comment not like '%pending%accounts%'\ngroup by\nc_custkey\n) as c_orders (c_custkey, c_count)\ngroup by\nc_count\norder by\ncustdist desc,\nc_count desc\n;\n\n-- Q14\nselect\n100.00 * sum(case\nwhen p_type like 'PROMO%'\nthen l_extendedprice * (1 - l_discount)\nelse 0\nend) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue\nfrom\nlineitem,\npart\nwhere\nl_partkey = p_partkey\nand l_shipdate >= date '1996-04-01'\nand l_shipdate < date '1996-04-01' + interval '1' month;\n\n-- Q15\nwith q15_revenue0 as (\nselect\nl_suppkey as supplier_no,\nsum(l_extendedprice * (1 - l_discount)) as total_revenue\nfrom\nlineitem\nwhere\nl_shipdate >= date '1995-12-01'\nand l_shipdate < date '1995-12-01' + interval '3' month\ngroup by\nl_suppkey\n)\nselect\ns_suppkey,\ns_name,\ns_address,\ns_phone,\ntotal_revenue\nfrom\nsupplier,\nq15_revenue0\nwhere\ns_suppkey = supplier_no\nand total_revenue = (\nselect\nmax(total_revenue)\nfrom\nq15_revenue0\n)\norder by\ns_suppkey\n;\n\n-- Q16\nselect\np_brand,\np_type,\np_size,\ncount(distinct ps_suppkey) as supplier_cnt\nfrom\npartsupp,\npart\nwhere\np_partkey = ps_partkey\nand p_brand <> 'Brand#35'\nand p_type not like 'ECONOMY BURNISHED%'\nand p_size in (14, 7, 21, 24, 35, 33, 2, 20)\nand ps_suppkey not in (\nselect\ns_suppkey\nfrom\nsupplier\nwhere\ns_comment like '%Customer%Complaints%'\n)\ngroup by\np_brand,\np_type,\np_size\norder by\nsupplier_cnt desc,\np_brand,\np_type,\np_size\n;\n\n-- Q17\nselect\nsum(l_extendedprice) / 7.0 as avg_yearly\nfrom\nlineitem,\npart\nwhere\np_partkey = l_partkey\nand p_brand = 'Brand#54'\nand p_container = 'LG BAG'\nand l_quantity < (\nselect\n0.2 * avg(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = p_partkey\n);\n\n-- Q18\nselect\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice,\nsum(l_quantity)\nfrom\ncustomer,\norders,\nlineitem\nwhere\no_orderkey in (\nselect\nl_orderkey\nfrom\nlineitem\ngroup by\nl_orderkey having\nsum(l_quantity) > 314\n)\nand c_custkey = o_custkey\nand o_orderkey = l_orderkey\ngroup by\nc_name,\nc_custkey,\no_orderkey,\no_orderdate,\no_totalprice\norder by\no_totalprice desc,\no_orderdate\nlimit 100\n;\n\n-- Q19\nselect\nsum(l_extendedprice* (1 - l_discount)) as revenue\nfrom\nlineitem,\npart\nwhere\n(\np_partkey = l_partkey\nand p_brand = 'Brand#23'\nand p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')\nand l_quantity >= 5 and l_quantity <= 5 + 10\nand p_size between 1 and 5\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#15'\nand p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')\nand l_quantity >= 14 and l_quantity <= 14 + 10\nand p_size between 1 and 10\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n)\nor\n(\np_partkey = l_partkey\nand p_brand = 'Brand#44'\nand p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')\nand l_quantity >= 28 and l_quantity <= 28 + 10\nand p_size between 1 and 15\nand l_shipmode in ('AIR', 'AIR REG')\nand l_shipinstruct = 'DELIVER IN PERSON'\n);\n\n-- Q20\nselect\ns_name,\ns_address\nfrom\nsupplier,\nnation\nwhere\ns_suppkey in (\nselect\nps_suppkey\nfrom\npartsupp\nwhere\nps_partkey in (\nselect\np_partkey\nfrom\npart\nwhere\np_name like 'lime%'\n)\nand ps_availqty > (\nselect\n0.5 * sum(l_quantity)\nfrom\nlineitem\nwhere\nl_partkey = ps_partkey\nand l_suppkey = ps_suppkey\nand l_shipdate >= date '1993-01-01'\nand l_shipdate < date '1993-01-01' + interval '1' year\n)\n)\nand s_nationkey = n_nationkey\nand n_name = 'VIETNAM'\norder by s_name\n;\n\n-- Q21\nselect\ns_name,\ncount(*) as numwait\nfrom\nsupplier,\nlineitem l1,\norders,\nnation\nwhere\ns_suppkey = l1.l_suppkey\nand o_orderkey = l1.l_orderkey\nand o_orderstatus = 'F'\nand l1.l_receiptdate > l1.l_commitdate\nand exists (\nselect\n*\nfrom\nlineitem l2\nwhere\nl2.l_orderkey = l1.l_orderkey\nand l2.l_suppkey <> l1.l_suppkey\n)\nand not exists (\nselect\n*\nfrom\nlineitem l3\nwhere\nl3.l_orderkey = l1.l_orderkey\nand l3.l_suppkey <> l1.l_suppkey\nand l3.l_receiptdate > l3.l_commitdate\n)\nand s_nationkey = n_nationkey\nand n_name = 'BRAZIL'\ngroup by\ns_name\norder by\nnumwait desc,\ns_name\nlimit 100\n;\n\n-- Q22\nselect\ncntrycode,\ncount(*) as numcust,\nsum(c_acctbal) as totacctbal\nfrom\n(\nselect\nsubstring(c_phone from 1 for 2) as cntrycode,\nc_acctbal\nfrom\ncustomer\nwhere\nsubstring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\nand c_acctbal > (\nselect\navg(c_acctbal)\nfrom\ncustomer\nwhere\nc_acctbal > 0.00\nand substring(c_phone from 1 for 2) in\n('10', '11', '26', '22', '19', '20', '27')\n)\nand not exists (\nselect\n*\nfrom\norders\nwhere\no_custkey = c_custkey\n)\n) as custsale\ngroup by\ncntrycode\norder by\ncntrycode\n;\n
"},{"location":"MatrixOne/Test/performance-testing/TPCH-test-with-matrixone/#6","title":"6. \u8fd0\u884c\u9884\u671f\u7ed3\u679c","text":"\u4ee5\u4e0b\u4e3a 22 \u4e2a TPCH \u67e5\u8be2\u7684\u9884\u671f\u7ed3\u679c\u3002
\u8bf4\u660e\uff1a\u7531\u4e8e Q16 \u7684\u7ed3\u679c\u6bb5\u843d\u8fc7\u957f\uff0c\u65e0\u6cd5\u5728\u4e0b\u6587\u5c55\u793a\uff0c\u8bf7\u53c2\u9605\u6b64\u8fde\u7ed3\u7684\u5b8c\u6574\u7ed3\u679c\uff1aQ16 \u8fd0\u884c\u9884\u671f\u7ed3\u679c
Q1\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+-------------+----------------+------------+-------------+\n| l_returnflag | l_linestatus | sum_qty | sum_base_price | sum_disc_price | sum_charge | avg_qty | avg_price | avg_disc | count_order |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+-------------+----------------+------------+-------------+\n| A | F | 37734107.00 | 56586554400.73 | 53758257134.8700 | 55909065222.827692 | 25.52200585 | 38273.12973462 | 0.04998530 | 1478493 |\n| N | F | 991417.00 | 1487504710.38 | 1413082168.0541 | 1469649223.194375 | 25.51647192 | 38284.46776085 | 0.05009343 | 38854 |\n| N | O | 73295769.00 | 109931611187.71 | 104436646745.0693 | 108617847377.142872 | 25.50176452 | 38248.45691074 | 0.04999662 | 2874145 |\n| R | F | 37719753.00 | 56568041380.90 | 53741292684.6040 | 55889619119.831932 | 25.50579361 | 38250.85462610 | 0.05000941 | 1478870 |\n+--------------+--------------+-------------+-----------------+-------------------+---------------------+-------------+----------------+------------+-------------+\n4 rows in set (0.56 sec)\n\nQ2\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n| s_acctbal | s_name | n_name | p_partkey | p_mfgr | s_address | s_phone | s_comment |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n| 9973.93 | Supplier#000004194 | JORDAN | 14193 | Manufacturer#1 | A8AoX9AK,qhf,CpEF | 23-944-413-2681 | t fluffily. regular requests about the regular, unusual somas play of the furiously busy |\n| 9956.34 | Supplier#000005108 | IRAN | 140079 | Manufacturer#5 | d3PLCdpPP3uE4GzbbAh4bWmU 7ecOifL9e1mNnzG | 20-842-882-7047 | ronic accounts. carefully bold accounts sleep beyond |\n| 9836.43 | Supplier#000000489 | IRAN | 190488 | Manufacturer#2 | y9NMoYGxDUPfrB1GwjYhLtCeV7pOt | 20-375-500-2226 | quickly carefully pending accounts. fina |\n| 9825.95 | Supplier#000007554 | IRAQ | 40041 | Manufacturer#5 | Huq0k qKET hByp3RcMcr | 21-787-637-9651 | ending, final requests thrash pending, |\n| 9806.52 | Supplier#000005276 | IRAQ | 132762 | Manufacturer#2 | inh0KOhRfLM7WRhdRNvJJDQx | 21-834-496-7360 | the slyly unusual theodolites; carefully even accounts use slyly. sl |\n| 9796.31 | Supplier#000005847 | IRAQ | 188292 | Manufacturer#1 | obol3bfh0zWi | 21-530-950-2847 | equests. blithely regular deposits should have to impress. final platelets integrate fluffily |\n| 9775.37 | Supplier#000007245 | IRAQ | 169696 | Manufacturer#5 | 5VOUnvxlJeOJ | 21-663-724-2985 | ic deposits about the slyly bold requests |\n| 9755.43 | Supplier#000002439 | EGYPT | 172438 | Manufacturer#5 | rXxojWV0VefSK7A0dhF | 14-410-168-5354 | p quickly packages. carefully pending pinto beans after the |\n| 9714.60 | Supplier#000007317 | EGYPT | 29810 | Manufacturer#4 | nJGsPl2ruoq4Ydtv0fwWG385eOFV6 VUokbCZ | 14-666-351-2592 | ons integrate furiously? slyly ironic requests sl |\n| 9557.33 | Supplier#000007367 | EGYPT | 197366 | Manufacturer#3 | bTP8DLvaRAB0n | 14-234-934-5255 | ep slyly regular accounts-- regular, regular excuses dazzle furiously about the reg |\n| 9538.15 | Supplier#000000979 | IRAN | 55968 | Manufacturer#1 | cdvHjrKZR7iDlmSWU2a | 20-151-688-1408 | ckages cajole quietly carefully regular in |\n| 9513.31 | Supplier#000004163 | SAUDI ARABIA | 109142 | Manufacturer#4 | 2VnQypC7pJPJRu6HzYRg7nAvhzckcYAQFbI | 30-544-852-3772 | he regular requests. blithely final |\n| 9450.15 | Supplier#000002067 | EGYPT | 9566 | Manufacturer#3 | 9dO68x0XLMCUDuFk1J6k9hpvLoKx 4qasok4lIb | 14-252-246-5791 | rding to the regular dolphins. quickly ir |\n| 9359.59 | Supplier#000005087 | JORDAN | 55086 | Manufacturer#4 | q0c6r9wYVQx31IeGBZKfe | 23-335-392-5204 | osits. quickly regular packages haggle among the quickly silent ins |\n| 9343.35 | Supplier#000006337 | IRAN | 173819 | Manufacturer#1 | ilQgNOdCAysclt3SgODb6LeJ7d4RzYD | 20-950-345-8173 | quickly ironic packages affix aft |\n| 9318.47 | Supplier#000003834 | SAUDI ARABIA | 11332 | Manufacturer#5 | cxGQnW3nShks59xA5bPoaC bIvcBWUt | 30-823-353-6520 | regular instructions. express packages run slyly pending |\n| 9318.47 | Supplier#000003834 | SAUDI ARABIA | 108813 | Manufacturer#2 | cxGQnW3nShks59xA5bPoaC bIvcBWUt | 30-823-353-6520 | regular instructions. express packages run slyly pending |\n| 9315.33 | Supplier#000003009 | IRAN | 40504 | Manufacturer#2 | oTbwfQ,Yfdcf3ysgc60NKtTpSIc | 20-306-556-2450 | the carefully special requests. express instructions wake |\n| 9296.31 | Supplier#000008213 | JORDAN | 163180 | Manufacturer#2 | YhdN9ESxYvhJp9ngr12Bbeo4t3zLPD, | 23-197-507-9431 | g to the blithely regular accounts! deposit |\n| 9284.57 | Supplier#000009781 | EGYPT | 4780 | Manufacturer#4 | 49NAd1iDiY4, | 14-410-636-4312 | its. ironic pinto beans are blithely. express depths use caref |\n| 9261.13 | Supplier#000000664 | EGYPT | 125639 | Manufacturer#5 | ln6wISAnC8Bpj q4V | 14-244-772-4913 | ly special foxes cajole slyly ironic reque |\n| 9260.78 | Supplier#000001949 | IRAN | 86932 | Manufacturer#2 | W79M2lpYiSY76Ujo6fSRUQiu | 20-531-767-2819 | thinly ironic excuses haggle slyly. f |\n| 9227.16 | Supplier#000009461 | EGYPT | 126948 | Manufacturer#2 | Eweba 0sfaF,l4sAxXGTgEjzsJsNWWIGjYhFkRWV | 14-983-137-4957 | lly bold packages. carefully express deposits integrate about the unusual accounts. regular, |\n| 9185.89 | Supplier#000007888 | EGYPT | 27887 | Manufacturer#1 | nq06Y48amPfS8YBuduy1RYu | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas |\n| 9185.89 | Supplier#000007888 | EGYPT | 190330 | Manufacturer#4 | nq06Y48amPfS8YBuduy1RYu | 14-462-704-3828 | ole slyly-- blithely careful foxes wake against the furiously ironic accounts. pending ideas |\n| 9132.92 | Supplier#000007878 | IRAN | 92859 | Manufacturer#3 | aq6T3tUVq1, | 20-861-274-6282 | waters cajole ironic, ironic requests. furi |\n| 9058.94 | Supplier#000002789 | IRAN | 142788 | Manufacturer#4 | 7EkIldjP7M6psSWcJ11tf65GT7ZC7UaiCh | 20-842-716-4307 | s. platelets use carefully. busily regular accounts cajole fluffily above the slowly final pinto be |\n| 9026.80 | Supplier#000005436 | SAUDI ARABIA | 92926 | Manufacturer#3 | 3HiusYZGYmHItExgX5VfNCdJwkW8W7R | 30-453-280-6340 | . blithely unusual requests |\n| 9007.16 | Supplier#000001747 | EGYPT | 121746 | Manufacturer#3 | UyDlFjVxanP,ifej7L5jtNaubC | 14-141-360-9722 | maintain bravely across the busily express pinto beans. sometimes |\n| 8846.35 | Supplier#000005446 | EGYPT | 57930 | Manufacturer#2 | Nusoq0ckv9SwnJZV8Rw2dUqE,V0ylm Bon | 14-468-853-6477 | deposits. ironic, bold ideas wake. fluffily ironic deposits must have to sleep furiously pending |\n| 8837.21 | Supplier#000007210 | JORDAN | 144695 | Manufacturer#3 | G7MYkWkkJDVu,rr23aXjQCwNqZ2Vk6 | 23-560-295-1805 | en, express foxes use across the blithely bold |\n| 8800.91 | Supplier#000008182 | EGYPT | 143153 | Manufacturer#5 | KGMyipBiAF00tSB99DwH | 14-658-338-3635 | thely even excuses integrate blithel |\n| 8788.46 | Supplier#000003437 | IRAN | 118414 | Manufacturer#4 | JfgZDO9fsP4ljfzsi,s7431Ld3A7zXtHfrF74 | 20-547-871-1712 | ickly unusual dependencies. carefully regular dolphins ha |\n| 8750.12 | Supplier#000001064 | IRAQ | 31063 | Manufacturer#5 | QgmUIaEs5KpuW ,oREZV2b4wr3HEC1z4F | 21-440-809-7599 | sly even deposits? furiously regular pack |\n| 8594.80 | Supplier#000007553 | IRAN | 5052 | Manufacturer#4 | wAU2Lui w9 | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final |\n| 8594.80 | Supplier#000007553 | IRAN | 195033 | Manufacturer#1 | wAU2Lui w9 | 20-663-409-7956 | old, stealthy accounts are blithely. fluffily final |\n| 8588.63 | Supplier#000008094 | SAUDI ARABIA | 148093 | Manufacturer#1 | SNS6FCscBNZBFecA | 30-465-665-6735 | ake quickly blithely ironic theodolites. quickly ironic ideas boost. furiously iro |\n| 8522.70 | Supplier#000004208 | IRAQ | 166659 | Manufacturer#5 | x3jZYF7ZYN 8a4LY1c1kEsh | 21-468-998-1571 | furiously regular accounts! |\n| 8514.86 | Supplier#000006347 | JORDAN | 181310 | Manufacturer#5 | wwR5j4kdIAwLe33uBwo | 23-340-942-3641 | uests breach blithely ironic deposi |\n| 8473.01 | Supplier#000003912 | IRAQ | 33911 | Manufacturer#3 | Op7,1zt3MAxs34Qo4O W | 21-474-809-6508 | es. regular, brave instructions wa |\n| 8405.28 | Supplier#000007886 | IRAQ | 192847 | Manufacturer#4 | sFTj5nzc5EIVmzjXwenFTXD U | 21-735-778-5786 | ven dependencies boost blithely ironic de |\n| 8375.58 | Supplier#000001259 | IRAQ | 38755 | Manufacturer#2 | 32cJBGFFpGEkEjx1sF8JZAy0A72uXL5qU | 21-427-422-4993 | ironic accounts haggle slyly alongside of the carefully ironic deposit |\n| 8351.75 | Supplier#000007495 | IRAQ | 114983 | Manufacturer#4 | 3jQQGvfs,5Aryhn0Z | 21-953-463-7239 | requests. carefully final accounts after the qui |\n| 8230.12 | Supplier#000001058 | SAUDI ARABIA | 68551 | Manufacturer#2 | fJ8egP,xkLygXGv8bmtc9T1FJ | 30-496-504-3341 | requests haggle? regular, regular pinto beans integrate fluffily. dependenc |\n| 8195.44 | Supplier#000009805 | IRAQ | 4804 | Manufacturer#4 | dTTmLRYJNat,JbhlQlxwWp HjMR | 21-838-243-3925 | lets. quickly even theodolites dazzle slyly even a |\n| 8175.17 | Supplier#000003172 | IRAN | 55656 | Manufacturer#5 | 8ngbGS7BQoTDmJyMa5WV9XbaM31u5FAayd2vT3 | 20-834-374-7746 | ss deposits use furiously after the quickly final sentiments. fluffily ruthless ideas believe regu |\n| 8159.13 | Supplier#000007486 | EGYPT | 17485 | Manufacturer#1 | AjfdzbrrJE1 | 14-970-643-1521 | ld accounts. enticingly furious requests cajole. final packages s |\n| 8111.40 | Supplier#000007567 | IRAN | 197566 | Manufacturer#1 | 7W4k2qEVoBkRehprGliXRSYVOQEh | 20-377-181-7435 | gular foxes. silent attainments boost furiousl |\n| 8046.55 | Supplier#000001625 | IRAQ | 14121 | Manufacturer#2 | yKlKMbENR6bfmIu7aCFmbs | 21-769-404-7617 | deposits. ideas boost blithely. slyly even Tiresias according to the platelets are q |\n| 8040.16 | Supplier#000001925 | SAUDI ARABIA | 4424 | Manufacturer#4 | Cu5Ub AAdXT | 30-969-417-1108 | pending packages across the regular req |\n| 8031.68 | Supplier#000002370 | SAUDI ARABIA | 147341 | Manufacturer#5 | xGQB9xSPqRtCuMZaJavOrFuTY7km | 30-373-388-2352 | dependencies. carefully express deposits use slyly among the slyly unusual pearls. dogge |\n| 8031.42 | Supplier#000008216 | IRAN | 83199 | Manufacturer#2 | jsqlyr1ViAo | 20-224-305-7298 | to the carefully even excuses haggle blithely against the pending pinto be |\n| 8007.83 | Supplier#000006266 | JORDAN | 81249 | Manufacturer#1 | XWBf5Jd2V5SOurbn11Tt1 | 23-363-445-7184 | as cajole carefully against the quickly special ac |\n| 7995.78 | Supplier#000006957 | IRAN | 161924 | Manufacturer#1 | 8lvRhU5xtXv | 20-312-173-2216 | ly ironic accounts. stealthily regular foxes about the blithely ironic requests play blithely abo |\n| 7913.40 | Supplier#000003148 | JORDAN | 58137 | Manufacturer#1 | CpCJWI4PHeiwYuq0 | 23-767-770-9172 | ove the quickly final packages boost fluffily among the furiously final platelets. carefully s |\n| 7910.16 | Supplier#000002102 | IRAQ | 99592 | Manufacturer#2 | 1kuyUn5q6czLOGB60fAVgpv68M2suwchpmp2nK | 21-367-198-9930 | accounts after the blithely |\n| 7893.58 | Supplier#000000918 | SAUDI ARABIA | 13414 | Manufacturer#1 | e0sB7xAU3,cWF7pzXrpIbATUNydCUZup | 30-303-831-1662 | ependencies wake carefull |\n| 7885.17 | Supplier#000004001 | JORDAN | 38994 | Manufacturer#2 | 3M39sZY1XeQXPDRO | 23-109-632-6806 | efully express packages integrate across the regular pearls. blithely unusual packages mainta |\n| 7880.20 | Supplier#000005352 | JORDAN | 351 | Manufacturer#3 | PP9gHTn946hXqUF5E7idIPLkhnN | 23-557-756-7951 | egular frays. final instructions sleep a |\n| 7844.31 | Supplier#000006987 | IRAQ | 44482 | Manufacturer#5 | UH1zBxTNjTminnmHRe h YUT1eR | 21-963-444-7397 | nag quickly carefully regular requests. ironic theo |\n| 7812.27 | Supplier#000006967 | SAUDI ARABIA | 151936 | Manufacturer#4 | S4i1HfrSM4m3di3R9Cxxp59M1 | 30-193-457-6365 | ely. dependencies cajole quickly. final warhorses across the furiously ironic foxes integr |\n| 7767.63 | Supplier#000004306 | IRAN | 31802 | Manufacturer#2 | SkZkJZflW5mDg9wL fJ | 20-911-180-1895 | uickly regular ideas. blithely express accounts along the carefully sile |\n| 7741.42 | Supplier#000000899 | IRAQ | 53383 | Manufacturer#5 | oLlkiVghtro IwzcwFuzwMCG94rRpux | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi |\n| 7741.42 | Supplier#000000899 | IRAQ | 105878 | Manufacturer#3 | oLlkiVghtro IwzcwFuzwMCG94rRpux | 21-980-994-3905 | equests wake quickly special, express accounts. courts promi |\n| 7741.10 | Supplier#000001059 | IRAN | 103528 | Manufacturer#4 | 4tBenOMokWbWVRB8i8HwENeO cQjM9 | 20-620-710-8984 | to the carefully special courts. |\n| 7599.20 | Supplier#000006596 | SAUDI ARABIA | 184077 | Manufacturer#2 | k8qeFxfXKIGYdQ82RXAfCwddSrc | 30-804-947-3851 | ously unusual deposits boost carefully after the enticing |\n| 7598.31 | Supplier#000008857 | IRAQ | 63844 | Manufacturer#4 | dP2th8vneyOLIUFwNBwqixkFD6 | 21-691-170-4769 | s. quickly ironic frays detect carefully |\n| 7591.79 | Supplier#000009723 | JORDAN | 104702 | Manufacturer#2 | Q1CkkpDdlLOpCJiV,zIf,Mv86otWhxj7slGc | 23-710-907-3873 | e fluffily even instructions. packages impress enticingly. |\n| 7575.12 | Supplier#000007557 | IRAQ | 77556 | Manufacturer#1 | udLvpjNvIx9qeRNdjL1ZAO0OZNOBo6h | 21-629-935-9941 | ally special accounts nod; f |\n| 7496.91 | Supplier#000005828 | IRAN | 103317 | Manufacturer#1 | Xt0EqDCNU6X00sNsIO7nd0ws3H | 20-435-850-8703 | furiously about the fluffily careful idea |\n| 7472.88 | Supplier#000004204 | EGYPT | 14203 | Manufacturer#1 | 0rGZJ6VZXdH | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care |\n| 7472.88 | Supplier#000004204 | EGYPT | 161687 | Manufacturer#3 | 0rGZJ6VZXdH | 14-520-667-4690 | y pending pinto beans. even, final requests sleep care |\n| 7467.63 | Supplier#000003270 | IRAN | 45757 | Manufacturer#2 | 7j4n5FnNEHVJxFhiyz | 20-450-599-9591 | regular, even instructions boost deposits |\n| 7465.41 | Supplier#000008686 | EGYPT | 188685 | Manufacturer#4 | 4Onf4yxuNwHCRIC0y | 14-454-946-4151 | ly final ideas. bravely unusual deposits doze carefully. expr |\n| 7460.80 | Supplier#000008701 | IRAQ | 83684 | Manufacturer#3 | PLR2QehcW08 | 21-747-984-4244 | ideas use carefully pending, final deposits. ironic, pe |\n| 7447.86 | Supplier#000005877 | JORDAN | 120852 | Manufacturer#2 | EyqOHClZZMJkq grnOX9 4alZx6P7B2fq | 23-419-288-6451 | lar pinto beans breach carefully final pinto |\n| 7445.03 | Supplier#000009802 | IRAQ | 164769 | Manufacturer#5 | y6wLN KiZuTf5HT9Hbm0BELn1GUTD6yl | 21-116-708-2013 | nic requests. pinto beans across the carefully regular grouches snooze among the final pin |\n| 7401.46 | Supplier#000008677 | IRAN | 123652 | Manufacturer#5 | WNa780JZzivxuGBEsDszqoT1Pj | 20-899-256-5288 | onic instructions along the furiously ironic accounts haggle fluffily silently un |\n| 7393.50 | Supplier#000007056 | IRAQ | 54550 | Manufacturer#1 | M5cAJQvW9D5zwC7o2qkoe | 21-175-383-4727 | slyly even requests. forges haggle boldly express requests. furio |\n| 7376.11 | Supplier#000003982 | IRAQ | 118959 | Manufacturer#1 | jx9EloF33Ez | 21-890-236-4160 | s the furiously special warhorses affix after the car |\n| 7264.42 | Supplier#000001565 | IRAQ | 14061 | Manufacturer#4 | bOwKHdBteMkZoZcxdigk4Tnu07w1gDztmV7hvCw | 21-791-273-8592 | to beans. express accounts nag around the |\n| 7256.46 | Supplier#000009116 | IRAQ | 4115 | Manufacturer#3 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci |\n| 7256.46 | Supplier#000009116 | IRAQ | 99115 | Manufacturer#1 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci |\n| 7256.46 | Supplier#000009116 | IRAQ | 131576 | Manufacturer#4 | ULjaQwNbcB XUG9dvbZDHvJVwLo08utswt | 21-241-469-8343 | ending deposits. slyly ironic dependencies breach. blithely speci |\n| 7254.81 | Supplier#000005664 | EGYPT | 35663 | Manufacturer#2 | b8VWuTXRt66wF9bfrgTmNGuxf1PU0x3O9e | 14-214-171-8987 | ts across the quickly pending pin |\n| 7186.63 | Supplier#000006958 | IRAN | 71943 | Manufacturer#4 | 0n9BD,gRzUc3B,PsFcxDBGp4BFf4P | 20-185-413-5590 | against the instructions. requests are. speci |\n| 7166.36 | Supplier#000003541 | EGYPT | 116007 | Manufacturer#1 | DbwyOxoaMEdhEtIB3y045QrKCi2fQpGRu, | 14-508-763-1850 | ages. carefully unusual requests across the pending instructions aff |\n| 7128.81 | Supplier#000000677 | JORDAN | 50676 | Manufacturer#4 | 8mhrffG7D2WJBSQbOGstQ | 23-290-639-3315 | nder blithely. slyly unusual theod |\n| 7051.73 | Supplier#000003349 | IRAQ | 125812 | Manufacturer#3 | wtTK9df9kY7mQ5QUM0Xe5bHLMRLgwE | 21-614-525-7451 | ar theodolites cajole fluffily across the pending requests. slyly final requests a |\n| 7023.47 | Supplier#000009543 | SAUDI ARABIA | 47038 | Manufacturer#1 | VYKinyOBNXRr Hdqn8kOxfTw | 30-785-782-6088 | sts. furiously pending packages sleep slyly even requests. final excuses print deposits. final pac |\n| 6985.93 | Supplier#000006409 | IRAQ | 131382 | Manufacturer#1 | eO8JDNM19HrlQMR | 21-627-356-3992 | sts. slyly final deposits around the regular accounts are along the furiously final pac |\n| 6964.75 | Supplier#000009931 | EGYPT | 57425 | Manufacturer#1 | peQYiRFk G0xZKfJ | 14-989-166-5782 | deposits according to the sometimes silent requests wake along the packages-- blithely f |\n| 6964.04 | Supplier#000007399 | IRAQ | 77398 | Manufacturer#2 | zdxjENOGR4QiCFP | 21-859-733-1999 | e blithely after the even requests. carefully ironic packages use slyly a |\n| 6913.81 | Supplier#000002625 | IRAQ | 22624 | Manufacturer#3 | a4V0rWemgbsT ZMj w7DB8rUbZ4F4lqqW5VKljQF | 21-136-564-3910 | . asymptotes among the express requests cajole furiously after the ca |\n| 6880.18 | Supplier#000006704 | IRAN | 26703 | Manufacturer#4 | 97rxJlAImbO1 sUlChUWoOJ0ZzvQ2NI3KI6VDOwk | 20-588-916-1286 | old accounts wake quickly. ca |\n| 6878.62 | Supplier#000001697 | IRAQ | 146668 | Manufacturer#5 | 37nm ODTeHy0xWTWegplgdWQqelh | 21-377-544-4864 | ironic theodolites. furiously regular d |\n| 6790.39 | Supplier#000008703 | IRAN | 123678 | Manufacturer#4 | wMslK1A8SEUTIIdApQ | 20-782-266-2552 | eep blithely regular, pending w |\n| 6763.46 | Supplier#000007882 | EGYPT | 137881 | Manufacturer#5 | JDv8BZiYG0UlZ | 14-111-252-9120 | the silent accounts wake foxes. furious |\n| 6751.81 | Supplier#000003156 | EGYPT | 165607 | Manufacturer#2 | alRWaW4FTFERMM4vf2rHKIKE | 14-843-946-7775 | are furiously. final theodolites affix slyly bold deposits. even packages haggle idly slyly specia |\n| 6702.07 | Supplier#000006276 | EGYPT | 31269 | Manufacturer#2 | ,dE1anEjKQGZfgquYfkx2fkGcXH | 14-896-626-7847 | ze about the carefully regular pint |\n+-----------+--------------------+--------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------+\n100 rows in set (0.11 sec)\n\nQ3\n+------------+-------------+-------------+----------------+\n| l_orderkey | revenue | o_orderdate | o_shippriority |\n+------------+-------------+-------------+----------------+\n| 2152675 | 431309.8065 | 1995-03-28 | 0 |\n| 4994400 | 423834.7976 | 1995-03-09 | 0 |\n| 2160291 | 401149.7805 | 1995-03-18 | 0 |\n| 2845094 | 401094.1393 | 1995-03-06 | 0 |\n| 1902471 | 400497.3847 | 1995-03-01 | 0 |\n| 5624358 | 395710.6806 | 1995-03-20 | 0 |\n| 2346242 | 392580.0394 | 1995-03-17 | 0 |\n| 2529826 | 387365.1560 | 1995-02-17 | 0 |\n| 5168933 | 385433.6198 | 1995-03-20 | 0 |\n| 2839239 | 380503.7310 | 1995-03-22 | 0 |\n+------------+-------------+-------------+----------------+\n10 rows in set\n\nQ4\n+-----------------+-------------+\n| o_orderpriority | order_count |\n+-----------------+-------------+\n| 1-URGENT | 10623 |\n| 2-HIGH | 10465 |\n| 3-MEDIUM | 10309 |\n| 4-NOT SPECIFIED | 10618 |\n| 5-LOW | 10541 |\n+-----------------+-------------+\n5 rows in set\n\nQ5\n+---------------+---------------+\n| n_name | revenue |\n+---------------+---------------+\n| PERU | 56206762.5035 |\n| CANADA | 56052846.0161 |\n| ARGENTINA | 54595012.8076 |\n| BRAZIL | 53601776.5201 |\n| UNITED STATES | 50890580.8962 |\n+---------------+---------------+\n5 rows in set\n\nQ6\n+---------------+\n| revenue |\n+---------------+\n| 61660051.7967 |\n+---------------+\n\nQ7\n+-------------+-------------+--------+---------------+\n| supp_nation | cust_nation | l_year | revenue |\n+-------------+-------------+--------+---------------+\n| ARGENTINA | FRANCE | 1995 | 57928886.8015 |\n| ARGENTINA | FRANCE | 1996 | 55535134.8474 |\n| FRANCE | ARGENTINA | 1995 | 52916227.7375 |\n| FRANCE | ARGENTINA | 1996 | 51077995.8841 |\n+-------------+-------------+--------+---------------+\n4 rows in set\n\nQ8\n+--------+----------------------+\n| o_year | mkt_share |\n+--------+----------------------+\n| 1995 | 0.035094304475112484 |\n| 1996 | 0.03724375099464825 |\n+--------+----------------------+\n2 rows in set\n\nQ9\n+----------------+--------+---------------+\n| nation | o_year | sum_profit |\n+----------------+--------+---------------+\n| ALGERIA | 1998 | 29931671.4862 |\n| ALGERIA | 1997 | 49521023.1139 |\n| ALGERIA | 1996 | 51283603.7356 |\n| ALGERIA | 1995 | 50206939.3447 |\n| ALGERIA | 1994 | 48738988.5891 |\n| ALGERIA | 1993 | 48084070.1204 |\n| ALGERIA | 1992 | 49725592.1793 |\n| ARGENTINA | 1998 | 26407044.9262 |\n| ARGENTINA | 1997 | 46224601.0785 |\n| ARGENTINA | 1996 | 44579611.0571 |\n| ARGENTINA | 1995 | 45081953.2540 |\n| ARGENTINA | 1994 | 48291282.8512 |\n| ARGENTINA | 1993 | 48063838.9130 |\n| ARGENTINA | 1992 | 45277890.2991 |\n| BRAZIL | 1998 | 28577022.6384 |\n| BRAZIL | 1997 | 46808660.3688 |\n| BRAZIL | 1996 | 47119265.0765 |\n| BRAZIL | 1995 | 47706399.9100 |\n| BRAZIL | 1994 | 48377469.9386 |\n| BRAZIL | 1993 | 46933565.7471 |\n| BRAZIL | 1992 | 47272215.5408 |\n| CANADA | 1998 | 30500303.6521 |\n| CANADA | 1997 | 50046257.5687 |\n| CANADA | 1996 | 52638586.9029 |\n| CANADA | 1995 | 50433911.3289 |\n| CANADA | 1994 | 51605251.7124 |\n| CANADA | 1993 | 50117218.8464 |\n| CANADA | 1992 | 50347111.2789 |\n| CHINA | 1998 | 26956001.9487 |\n| CHINA | 1997 | 48311246.7866 |\n| CHINA | 1996 | 51133929.1033 |\n| CHINA | 1995 | 48024289.1049 |\n| CHINA | 1994 | 50027433.6557 |\n| CHINA | 1993 | 48240226.3801 |\n| CHINA | 1992 | 47769117.6007 |\n| EGYPT | 1998 | 26972573.1604 |\n| EGYPT | 1997 | 46708654.7666 |\n| EGYPT | 1996 | 46095050.4457 |\n| EGYPT | 1995 | 44901908.2949 |\n| EGYPT | 1994 | 48522762.8892 |\n| EGYPT | 1993 | 49055807.7642 |\n| EGYPT | 1992 | 46909796.1083 |\n| ETHIOPIA | 1998 | 26364411.6457 |\n| ETHIOPIA | 1997 | 44889623.0645 |\n| ETHIOPIA | 1996 | 47554295.2892 |\n| ETHIOPIA | 1995 | 44747639.5440 |\n| ETHIOPIA | 1994 | 46497570.0631 |\n| ETHIOPIA | 1993 | 43853718.5460 |\n| ETHIOPIA | 1992 | 44005773.0397 |\n| FRANCE | 1998 | 27033406.6353 |\n| FRANCE | 1997 | 45763555.5515 |\n| FRANCE | 1996 | 47178544.9301 |\n| FRANCE | 1995 | 48821282.1929 |\n| FRANCE | 1994 | 46444640.9397 |\n| FRANCE | 1993 | 46602311.0590 |\n| FRANCE | 1992 | 47769356.5113 |\n| GERMANY | 1998 | 26165681.8305 |\n| GERMANY | 1997 | 46600844.4431 |\n| GERMANY | 1996 | 44873520.1979 |\n| GERMANY | 1995 | 47761215.6058 |\n| GERMANY | 1994 | 42283120.0209 |\n| GERMANY | 1993 | 46954873.9820 |\n| GERMANY | 1992 | 46263626.6361 |\n| INDIA | 1998 | 27651103.0250 |\n| INDIA | 1997 | 46000888.8340 |\n| INDIA | 1996 | 43993476.7354 |\n| INDIA | 1995 | 44015709.1914 |\n| INDIA | 1994 | 44281439.6282 |\n| INDIA | 1993 | 45367255.7857 |\n| INDIA | 1992 | 45350810.5330 |\n| INDONESIA | 1998 | 27120545.3120 |\n| INDONESIA | 1997 | 45745362.3667 |\n| INDONESIA | 1996 | 45347554.8232 |\n| INDONESIA | 1995 | 45685709.4978 |\n| INDONESIA | 1994 | 44738603.1901 |\n| INDONESIA | 1993 | 45172063.2033 |\n| INDONESIA | 1992 | 44623924.3942 |\n| IRAN | 1998 | 27876287.0949 |\n| IRAN | 1997 | 47184621.5647 |\n| IRAN | 1996 | 47397859.7878 |\n| IRAN | 1995 | 49579120.6991 |\n| IRAN | 1994 | 48032316.8744 |\n| IRAN | 1993 | 48295593.2066 |\n| IRAN | 1992 | 50531453.3934 |\n| IRAQ | 1998 | 29997323.2927 |\n| IRAQ | 1997 | 52851471.1377 |\n| IRAQ | 1996 | 53671825.6297 |\n| IRAQ | 1995 | 53251012.1025 |\n| IRAQ | 1994 | 50934553.4361 |\n| IRAQ | 1993 | 51961214.1186 |\n| IRAQ | 1992 | 50840364.3833 |\n| JAPAN | 1998 | 26054615.4955 |\n| JAPAN | 1997 | 43557394.2595 |\n| JAPAN | 1996 | 46531743.0980 |\n| JAPAN | 1995 | 41688293.4741 |\n| JAPAN | 1994 | 45526719.0728 |\n| JAPAN | 1993 | 45619475.4478 |\n| JAPAN | 1992 | 44545639.3069 |\n| JORDAN | 1998 | 24793092.4101 |\n| JORDAN | 1997 | 42050730.7748 |\n| JORDAN | 1996 | 42562783.8663 |\n| JORDAN | 1995 | 42253019.5330 |\n| JORDAN | 1994 | 45027034.7721 |\n| JORDAN | 1993 | 44797510.9808 |\n| JORDAN | 1992 | 41313405.2890 |\n| KENYA | 1998 | 24550926.4693 |\n| KENYA | 1997 | 42767120.5848 |\n| KENYA | 1996 | 45000095.1105 |\n| KENYA | 1995 | 43250458.0109 |\n| KENYA | 1994 | 42891596.7158 |\n| KENYA | 1993 | 43599201.5126 |\n| KENYA | 1992 | 45286145.8141 |\n| MOROCCO | 1998 | 23482053.5970 |\n| MOROCCO | 1997 | 41503033.0020 |\n| MOROCCO | 1996 | 45645555.9409 |\n| MOROCCO | 1995 | 44462858.7689 |\n| MOROCCO | 1994 | 44768368.8310 |\n| MOROCCO | 1993 | 44611871.2477 |\n| MOROCCO | 1992 | 43057959.1352 |\n| MOZAMBIQUE | 1998 | 28824737.9244 |\n| MOZAMBIQUE | 1997 | 48682746.5995 |\n| MOZAMBIQUE | 1996 | 50816940.9909 |\n| MOZAMBIQUE | 1995 | 50010039.0178 |\n| MOZAMBIQUE | 1994 | 48794892.1253 |\n| MOZAMBIQUE | 1993 | 48451128.3332 |\n| MOZAMBIQUE | 1992 | 50113858.5449 |\n| PERU | 1998 | 30575758.1899 |\n| PERU | 1997 | 49323405.6808 |\n| PERU | 1996 | 50063490.6085 |\n| PERU | 1995 | 51272843.6555 |\n| PERU | 1994 | 50690589.2334 |\n| PERU | 1993 | 49086129.3668 |\n| PERU | 1992 | 50067216.3450 |\n| ROMANIA | 1998 | 27367992.9903 |\n| ROMANIA | 1997 | 45668932.7094 |\n| ROMANIA | 1996 | 46594220.7498 |\n| ROMANIA | 1995 | 44576835.1623 |\n| ROMANIA | 1994 | 45640971.0684 |\n| ROMANIA | 1993 | 46374545.0712 |\n| ROMANIA | 1992 | 47130533.3076 |\n| RUSSIA | 1998 | 27486839.8755 |\n| RUSSIA | 1997 | 44050712.6907 |\n| RUSSIA | 1996 | 45604597.4983 |\n| RUSSIA | 1995 | 48972490.6009 |\n| RUSSIA | 1994 | 45652045.5872 |\n| RUSSIA | 1993 | 47139548.1597 |\n| RUSSIA | 1992 | 47159990.1221 |\n| SAUDI ARABIA | 1998 | 29766229.7961 |\n| SAUDI ARABIA | 1997 | 51473031.6922 |\n| SAUDI ARABIA | 1996 | 52859666.6646 |\n| SAUDI ARABIA | 1995 | 50946175.0229 |\n| SAUDI ARABIA | 1994 | 53085288.9954 |\n| SAUDI ARABIA | 1993 | 50907571.2046 |\n| SAUDI ARABIA | 1992 | 50334063.0381 |\n| UNITED KINGDOM | 1998 | 27904712.8220 |\n| UNITED KINGDOM | 1997 | 48170994.4362 |\n| UNITED KINGDOM | 1996 | 46498116.9611 |\n| UNITED KINGDOM | 1995 | 43210619.0456 |\n| UNITED KINGDOM | 1994 | 47339709.9122 |\n| UNITED KINGDOM | 1993 | 44308436.3275 |\n| UNITED KINGDOM | 1992 | 45870809.6693 |\n| UNITED STATES | 1998 | 25856187.3719 |\n| UNITED STATES | 1997 | 44934753.2208 |\n| UNITED STATES | 1996 | 44826974.2915 |\n| UNITED STATES | 1995 | 44160425.4086 |\n| UNITED STATES | 1994 | 43193241.6843 |\n| UNITED STATES | 1993 | 45126307.2619 |\n| UNITED STATES | 1992 | 44205926.3317 |\n| VIETNAM | 1998 | 28289193.6726 |\n| VIETNAM | 1997 | 48284585.4019 |\n| VIETNAM | 1996 | 48360225.9084 |\n| VIETNAM | 1995 | 48742082.6165 |\n| VIETNAM | 1994 | 49035537.3894 |\n| VIETNAM | 1993 | 47222674.6352 |\n| VIETNAM | 1992 | 48628336.9011 |\n+----------------+--------+---------------+\n175 rows in set\n\nQ10\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n| c_custkey | c_name | revenue | c_acctbal | n_name | c_address | c_phone | c_comment |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n| 95962 | Customer#000095962 | 704336.0774 | -9.33 | MOZAMBIQUE | 83wOMt9iAb9OJ0HbkQ1PaX3odXVBNEIMXaE | 26-127-693-7436 | nusual theodolites maintain furiously fluffily iro |\n| 87064 | Customer#000087064 | 684037.4349 | 5244.68 | BRAZIL | 0xej6ldT8zi7MwLdDJ1II3YWwprkvwB1 I0kwsf | 12-930-206-2571 | de of the ironic, silent warthogs. bold, r |\n| 56416 | Customer#000056416 | 661218.0492 | 4303.82 | INDIA | CEuBN,xZVmP | 18-212-984-8331 | al waters cajole along the slyly unusual dugouts. carefully regular deposits use slyly? packages h |\n| 46450 | Customer#000046450 | 646205.6835 | 2400.59 | UNITED STATES | rzWQxB9iFpd8i4KUCAPdv | 34-765-320-4326 | ss, final deposits cajole sly |\n| 128713 | Customer#000128713 | 643240.1183 | 7200.30 | ARGENTINA | mm0kxtHFCchaZX4eYSCCyQHno7vq,SRmv4 | 11-174-994-6880 | ording to the express accounts cajole carefully across the bravely special packages. carefully regular account |\n| 102187 | Customer#000102187 | 637493.0787 | -896.03 | ETHIOPIA | EAi6vcGnWHUMb6rJwn,PtUgSH74tR Aixa | 15-877-462-6534 | gular packages. carefully regular deposits cajole carefully of the regular requests. carefully special accou |\n| 42541 | Customer#000042541 | 634546.9756 | 8082.14 | IRAN | IccOGHgp8g | 20-442-159-1337 | cross the final asymptotes. final packages wake furiously ironic dec |\n| 51595 | Customer#000051595 | 611926.8265 | 7236.80 | UNITED STATES | wQFWZk 7JCpeg50O0KCzSmUFnNNwX1aEQ7V3Q | 34-844-269-9070 | sts. always express accounts use carefully along the quickly speci |\n| 66391 | Customer#000066391 | 608385.5852 | 9404.57 | UNITED STATES | V0XvU1Nh9NU4zsyOkm,RBa | 34-149-224-8119 | ages cajole carefully carefully bold deposits: fluffily unusual deposits promise slyly carefully ironic co |\n| 48358 | Customer#000048358 | 603621.4823 | -611.15 | ETHIOPIA | ycg3uMG7iDdwQvJ1irr | 15-687-936-5181 | the slyly unusual foxes-- carefully regular |\n| 99175 | Customer#000099175 | 602125.3304 | 2218.76 | INDONESIA | 9wbW52xx9T84E0dZ Rvz1ozQ1 | 19-125-912-6494 | ide of the slyly ironic foxes boost silently ironic, even instructions. blithe |\n| 122509 | Customer#000122509 | 601580.1203 | 2613.83 | KENYA | ZN1sc0eJrkD8t6X5Q1d3 | 24-421-308-3881 | brave deposits haggle across the even deposits. instr |\n| 148055 | Customer#000148055 | 601003.6812 | 455.31 | PERU | Y,RCZ3Bislx64nTsPaRL,5gjx7xgC6y, yKYnCw | 27-473-476-4382 | uickly final accounts wake carefully sl |\n| 117451 | Customer#000117451 | 599792.7063 | 1090.48 | UNITED STATES | bSwr7mNPiaf1f lNK9 uTJxWCL2sn1Lak5NIB | 34-354-586-6011 | ding to the furiously express accounts boost carefully af |\n| 104110 | Customer#000104110 | 588194.3118 | 2762.52 | JORDAN | mm7 ZuDX5Z5nAQbKObB 80XBCy,1nyW | 23-639-800-5768 | urts sleep furiously alongside of the packages! slyly ironic packages sleep |\n| 13666 | Customer#000013666 | 579926.1679 | 7453.98 | EGYPT | DLRUWGcprmWqdROJvmZwpE | 14-316-135-4381 | ross the silent requests. special theodolit |\n| 96202 | Customer#000096202 | 571017.3398 | 4703.04 | CANADA | 4Vcxcx3w4zMjVYNQaqrweweQY6TJO AP9rdvQaLl | 13-194-779-9597 | en packages use. fluffily regular dependencies boost. never pending requ |\n| 70279 | Customer#000070279 | 561369.3650 | 9109.34 | CHINA | ltie8o3ihwffMrqMrkvN957KZVWmH5 | 28-842-825-1717 | theodolites sleep: blithely final requests are fur |\n| 16972 | Customer#000016972 | 560435.8065 | 6408.66 | ROMANIA | X6T8vRKy6kSO0f2wJJt | 29-483-958-3347 | sts. pending deposits are across the regular, express instructions. carefully daring foxes cajol |\n| 113443 | Customer#000113443 | 557272.6706 | -72.67 | UNITED KINGDOM | SUHbS85cYxgVkKbfh9sUpEa6ezVSlQuCKe3CV | 33-819-742-6112 | ic foxes cajole thinly furiously stealthy instructions. pinto beans are. quickly regular accounts integrate car |\n+-----------+--------------------+-------------+-----------+----------------+------------------------------------------+-----------------+-----------------------------------------------------------------------------------------------------------------+\n20 rows in set\n\nQ11\n+------------+-------------+\n| ps_partkey | value |\n+------------+-------------+\n| 131630 | 17882680.37 |\n| 104150 | 17613017.18 |\n| 128284 | 16502418.74 |\n| 8978 | 16470438.59 |\n| 147193 | 16462742.12 |\n| 78788 | 16010246.37 |\n| 76331 | 15776882.05 |\n| 137287 | 15770471.15 |\n| 51302 | 15730620.22 |\n| 141553 | 15333540.19 |\n| 137196 | 15035435.60 |\n| 186531 | 14818272.68 |\n| 103818 | 14690943.63 |\n| 80080 | 14626441.35 |\n| 1312 | 14330729.50 |\n| 6531 | 14267308.08 |\n| 96162 | 14154396.04 |\n| 69605 | 14018927.25 |\n| 30118 | 13854726.38 |\n| 17006 | 13731495.60 |\n| 95347 | 13716648.60 |\n| 18722 | 13707978.71 |\n| 122875 | 13640341.00 |\n| 105499 | 13532912.80 |\n| 165560 | 13509536.95 |\n| 1531 | 13337454.55 |\n| 34732 | 13304041.48 |\n| 173221 | 13038078.41 |\n| 180975 | 13038039.17 |\n| 24703 | 12957050.80 |\n| 72036 | 12939426.90 |\n| 124814 | 12849842.04 |\n| 174453 | 12814999.00 |\n| 14209 | 12814858.56 |\n| 185186 | 12657201.05 |\n| 187868 | 12647101.80 |\n| 125085 | 12639931.63 |\n| 80331 | 12625007.00 |\n| 118685 | 12515185.68 |\n| 163988 | 12484272.80 |\n| 124685 | 12432747.32 |\n| 92838 | 12410071.57 |\n| 140928 | 12396673.84 |\n| 1218 | 12362877.75 |\n| 39201 | 12328085.10 |\n| 33237 | 12180622.98 |\n| 183791 | 12150040.50 |\n| 3243 | 12136315.74 |\n| 62740 | 12131313.60 |\n| 154171 | 12105470.89 |\n| 49034 | 11982382.52 |\n| 88673 | 11925499.04 |\n| 52527 | 11923653.16 |\n| 83974 | 11871084.73 |\n| 88254 | 11870393.22 |\n| 411 | 11806670.95 |\n| 14320 | 11800136.02 |\n| 164979 | 11794760.03 |\n| 166149 | 11778499.72 |\n| 74105 | 11750224.34 |\n| 169104 | 11708532.18 |\n| 15542 | 11687293.42 |\n| 161538 | 11661769.80 |\n| 63337 | 11592505.40 |\n| 117197 | 11508165.60 |\n| 102989 | 11497056.75 |\n| 10836 | 11465875.43 |\n| 199561 | 11431793.36 |\n| 134683 | 11384564.54 |\n| 136318 | 11351893.30 |\n| 166270 | 11336004.81 |\n| 32200 | 11324838.00 |\n| 57033 | 11281026.52 |\n| 18098 | 11245398.24 |\n| 135174 | 11189782.12 |\n| 181616 | 11183947.65 |\n| 85064 | 11175761.43 |\n| 120719 | 11164342.08 |\n| 99670 | 11140257.47 |\n| 46096 | 11034143.76 |\n| 195124 | 11030197.30 |\n| 78838 | 11012446.40 |\n| 151656 | 11010376.90 |\n| 156956 | 10996384.80 |\n| 34028 | 10942671.24 |\n| 15778 | 10937778.75 |\n| 199707 | 10924333.33 |\n| 118776 | 10920609.31 |\n| 27640 | 10919693.42 |\n| 15237 | 10918145.54 |\n| 148243 | 10916765.29 |\n| 111498 | 10867707.51 |\n| 132024 | 10834280.47 |\n| 35124 | 10806898.50 |\n| 196818 | 10787371.25 |\n| 197669 | 10779504.60 |\n| 110042 | 10778828.37 |\n| 197422 | 10770092.44 |\n| 75160 | 10746976.60 |\n| 191567 | 10642430.39 |\n| 34225 | 10574664.41 |\n| 102588 | 10567012.05 |\n| 44148 | 10505249.34 |\n| 126607 | 10484944.29 |\n| 172625 | 10444857.62 |\n| 157054 | 10406203.24 |\n| 19322 | 10378704.98 |\n| 136541 | 10371536.77 |\n| 167526 | 10320346.58 |\n| 136011 | 10302146.84 |\n| 107431 | 10273992.76 |\n| 16485 | 10257703.67 |\n| 52580 | 10250264.05 |\n| 839 | 10238243.36 |\n| 31704 | 10196678.94 |\n| 122558 | 10137326.18 |\n| 180386 | 10123318.07 |\n| 97705 | 10089163.37 |\n| 96327 | 10087851.88 |\n| 136143 | 10082137.97 |\n| 15174 | 10057277.55 |\n| 193324 | 10039922.93 |\n| 33593 | 10019952.10 |\n| 126288 | 10014855.05 |\n| 64123 | 9985650.90 |\n| 183712 | 9973256.18 |\n| 138831 | 9963069.10 |\n| 123694 | 9959096.38 |\n| 51734 | 9952439.73 |\n| 11861 | 9949647.12 |\n| 119127 | 9942105.69 |\n| 173308 | 9932264.52 |\n| 40986 | 9921554.40 |\n| 176970 | 9919708.65 |\n| 54316 | 9913595.16 |\n| 62644 | 9903936.27 |\n| 185354 | 9895956.52 |\n| 81468 | 9885132.60 |\n| 104687 | 9883888.05 |\n| 198959 | 9875351.28 |\n| 179767 | 9872309.86 |\n| 102835 | 9870743.52 |\n| 163221 | 9856173.04 |\n| 32633 | 9852565.04 |\n| 19605 | 9850164.48 |\n| 47378 | 9826135.11 |\n| 44026 | 9822433.44 |\n| 126629 | 9816227.30 |\n| 199665 | 9812400.23 |\n| 30989 | 9812295.52 |\n| 102177 | 9810372.32 |\n| 25765 | 9806344.88 |\n| 110721 | 9804895.23 |\n| 159532 | 9803738.34 |\n| 101640 | 9801375.65 |\n| 151569 | 9792489.20 |\n| 180629 | 9782164.34 |\n| 165528 | 9769074.10 |\n| 23772 | 9766084.22 |\n| 149727 | 9765190.96 |\n| 189605 | 9761887.80 |\n| 74703 | 9758757.28 |\n| 83382 | 9758144.21 |\n| 93775 | 9726901.71 |\n| 56192 | 9725508.16 |\n| 50060 | 9712714.65 |\n| 15409 | 9706898.91 |\n| 139104 | 9701070.72 |\n| 177435 | 9686566.09 |\n| 31351 | 9675197.98 |\n| 20495 | 9672566.31 |\n| 24537 | 9654516.03 |\n| 160528 | 9650804.70 |\n| 34706 | 9647241.90 |\n| 149039 | 9643498.32 |\n| 147139 | 9642356.34 |\n| 118629 | 9624960.80 |\n| 35359 | 9621549.92 |\n| 33854 | 9616857.73 |\n| 33707 | 9609988.84 |\n| 149055 | 9599364.32 |\n| 127429 | 9580670.49 |\n| 67575 | 9579613.26 |\n| 80727 | 9576545.81 |\n| 181650 | 9574445.40 |\n| 50176 | 9573389.08 |\n| 171093 | 9571625.20 |\n| 151342 | 9569230.21 |\n| 123052 | 9561903.68 |\n| 132633 | 9545052.14 |\n| 130419 | 9524936.49 |\n| 89241 | 9512992.32 |\n| 138255 | 9503515.93 |\n| 31680 | 9502841.07 |\n| 151986 | 9500862.59 |\n| 146390 | 9490242.96 |\n| 62275 | 9475584.10 |\n| 33518 | 9475074.40 |\n| 5286 | 9473739.88 |\n| 39020 | 9467701.22 |\n| 113281 | 9466510.94 |\n| 138789 | 9464407.24 |\n| 165040 | 9462153.75 |\n| 150766 | 9461855.88 |\n| 54341 | 9459425.45 |\n| 33464 | 9459377.37 |\n| 15251 | 9455980.84 |\n| 145308 | 9454189.29 |\n| 192621 | 9449324.14 |\n| 175218 | 9448987.35 |\n| 58992 | 9446144.40 |\n| 24548 | 9442739.03 |\n| 177563 | 9440891.04 |\n| 184482 | 9431486.10 |\n| 78961 | 9430401.05 |\n| 174167 | 9428622.96 |\n| 88265 | 9423143.28 |\n| 6057 | 9405359.37 |\n| 85387 | 9402175.55 |\n| 47053 | 9399707.66 |\n| 128973 | 9399265.92 |\n| 65668 | 9395584.45 |\n| 50222 | 9394502.96 |\n| 116534 | 9388011.08 |\n| 140959 | 9386284.56 |\n| 46897 | 9385056.21 |\n| 141872 | 9383820.48 |\n| 177181 | 9383551.92 |\n| 168265 | 9376664.16 |\n| 48974 | 9374769.12 |\n| 46218 | 9364135.50 |\n| 104039 | 9363227.03 |\n| 61538 | 9360159.08 |\n| 94688 | 9359604.98 |\n| 122393 | 9357937.19 |\n| 7323 | 9356712.30 |\n| 197892 | 9356573.44 |\n| 194056 | 9352381.73 |\n| 61285 | 9348480.54 |\n| 180336 | 9347874.15 |\n| 121930 | 9347784.74 |\n| 80652 | 9347143.50 |\n| 18549 | 9346038.72 |\n| 23992 | 9339908.16 |\n| 136583 | 9337299.56 |\n| 156151 | 9337138.10 |\n| 160572 | 9336553.40 |\n| 113391 | 9335558.10 |\n| 48068 | 9334317.92 |\n| 20409 | 9331093.65 |\n| 39712 | 9324685.28 |\n| 59364 | 9322249.86 |\n| 1344 | 9308304.39 |\n| 60549 | 9308293.20 |\n| 83854 | 9307387.25 |\n| 92092 | 9307165.64 |\n| 193306 | 9306177.31 |\n| 118265 | 9300250.20 |\n| 107568 | 9296254.34 |\n| 109127 | 9293552.10 |\n| 184688 | 9291647.92 |\n| 8718 | 9287337.37 |\n| 80433 | 9286295.52 |\n| 26670 | 9284963.44 |\n| 139548 | 9283605.21 |\n| 14736 | 9280119.20 |\n| 97886 | 9273852.42 |\n| 181442 | 9273130.50 |\n| 172360 | 9272824.92 |\n| 192714 | 9268366.36 |\n| 106726 | 9264879.90 |\n| 72157 | 9263498.40 |\n| 70445 | 9257553.92 |\n| 75148 | 9257420.83 |\n| 26170 | 9256074.12 |\n| 116531 | 9249721.71 |\n| 133665 | 9245464.80 |\n| 129041 | 9244629.48 |\n| 136486 | 9240748.92 |\n| 198924 | 9239976.06 |\n| 115254 | 9233580.37 |\n| 168135 | 9232693.98 |\n| 22480 | 9232190.78 |\n| 192018 | 9230386.58 |\n| 111889 | 9228204.96 |\n| 151661 | 9227926.90 |\n| 96482 | 9226960.85 |\n| 49198 | 9226436.40 |\n| 41219 | 9222883.52 |\n| 113502 | 9222208.59 |\n| 84009 | 9218703.22 |\n| 192788 | 9213468.00 |\n| 160251 | 9206353.32 |\n| 188162 | 9200537.88 |\n| 167589 | 9195835.03 |\n| 132673 | 9194021.22 |\n| 191105 | 9192417.12 |\n| 128748 | 9189941.55 |\n| 130423 | 9184710.96 |\n| 22639 | 9182963.16 |\n| 199034 | 9180909.86 |\n| 187644 | 9180350.20 |\n| 970 | 9175757.70 |\n| 59070 | 9170000.64 |\n| 66568 | 9166070.04 |\n| 52715 | 9161221.80 |\n| 130276 | 9161201.57 |\n| 24189 | 9160740.15 |\n| 132402 | 9144498.48 |\n| 37799 | 9142271.24 |\n| 173337 | 9140566.68 |\n| 176552 | 9135054.51 |\n| 195714 | 9133679.77 |\n| 119363 | 9123261.90 |\n| 161160 | 9122259.60 |\n| 196968 | 9111592.20 |\n| 61943 | 9111527.33 |\n| 79766 | 9109534.89 |\n| 178082 | 9105694.92 |\n| 38800 | 9105468.72 |\n| 83608 | 9099493.68 |\n| 146346 | 9098628.00 |\n| 116690 | 9098099.93 |\n| 64690 | 9095441.10 |\n| 82061 | 9095381.18 |\n| 89015 | 9092660.48 |\n| 188457 | 9091400.40 |\n| 125177 | 9090455.55 |\n| 114776 | 9088177.68 |\n| 4486 | 9087487.20 |\n| 176940 | 9086842.84 |\n| 93157 | 9084361.81 |\n| 148624 | 9083370.78 |\n| 4441 | 9079520.58 |\n| 63590 | 9079125.44 |\n| 174189 | 9078023.39 |\n| 63054 | 9075441.98 |\n| 14950 | 9073156.19 |\n| 175646 | 9072322.47 |\n| 63712 | 9067710.48 |\n| 157197 | 9067452.77 |\n| 147196 | 9064699.80 |\n| 50551 | 9062434.72 |\n| 43035 | 9061782.03 |\n| 187679 | 9056529.40 |\n| 96673 | 9056525.94 |\n| 130148 | 9054217.06 |\n| 159007 | 9053155.29 |\n| 41544 | 9052820.94 |\n| 109476 | 9048012.09 |\n| 60092 | 9045562.44 |\n| 197490 | 9044579.88 |\n| 47311 | 9037223.52 |\n| 87230 | 9033227.61 |\n| 3860 | 9030622.02 |\n| 5466 | 9029841.66 |\n| 171537 | 9024699.30 |\n| 39707 | 9022833.12 |\n| 167048 | 9022709.18 |\n| 109006 | 9022258.40 |\n| 17910 | 9019688.45 |\n| 132826 | 9017286.74 |\n| 157502 | 9016444.08 |\n| 142309 | 9016270.60 |\n| 78891 | 9005693.25 |\n| 88301 | 9002414.82 |\n| 11496 | 9000803.97 |\n| 163633 | 8996162.06 |\n| 151809 | 8993104.95 |\n| 131555 | 8988340.68 |\n| 72812 | 8985370.68 |\n| 77047 | 8981489.79 |\n| 1553 | 8977226.10 |\n| 162531 | 8973689.92 |\n| 154026 | 8973320.24 |\n| 125499 | 8969667.84 |\n| 34547 | 8966116.43 |\n| 41301 | 8965350.42 |\n| 12853 | 8959403.59 |\n| 27736 | 8957933.23 |\n| 162817 | 8956868.20 |\n| 155389 | 8955349.85 |\n| 130360 | 8952928.25 |\n| 120878 | 8952393.10 |\n| 150671 | 8952112.72 |\n| 190365 | 8951671.57 |\n| 72364 | 8950587.82 |\n| 71615 | 8949277.07 |\n| 95277 | 8947796.58 |\n| 78180 | 8946814.80 |\n| 97062 | 8945057.46 |\n| 170013 | 8944660.40 |\n| 113426 | 8943016.29 |\n| 173751 | 8942914.28 |\n| 1478 | 8941906.24 |\n| 26061 | 8941022.48 |\n| 152527 | 8939654.10 |\n| 148360 | 8939589.40 |\n| 44057 | 8939101.36 |\n| 13595 | 8936720.10 |\n| 33337 | 8935366.48 |\n| 169698 | 8931507.20 |\n| 26155 | 8927283.11 |\n| 17185 | 8927218.40 |\n| 51996 | 8926661.08 |\n| 101869 | 8919281.70 |\n| 14561 | 8910653.92 |\n| 190047 | 8909427.90 |\n| 104143 | 8909328.40 |\n| 133330 | 8907195.90 |\n| 169144 | 8904989.34 |\n| 87067 | 8900079.44 |\n| 176075 | 8898845.64 |\n| 25076 | 8895274.12 |\n| 80838 | 8895205.30 |\n| 40387 | 8890891.55 |\n| 88004 | 8888748.80 |\n| 105527 | 8888672.72 |\n| 40741 | 8886674.24 |\n| 76690 | 8880622.61 |\n| 86485 | 8880488.57 |\n| 75736 | 8877666.06 |\n| 48704 | 8876626.52 |\n| 56450 | 8872277.59 |\n| 61683 | 8870173.93 |\n| 24067 | 8867814.12 |\n| 108012 | 8863632.38 |\n| 180971 | 8862007.20 |\n| 132986 | 8861335.20 |\n| 35839 | 8859344.64 |\n| 191553 | 8857411.14 |\n| 163492 | 8855825.91 |\n| 112101 | 8851904.10 |\n| 27050 | 8847924.19 |\n| 57481 | 8845309.59 |\n| 163252 | 8842276.65 |\n| 87958 | 8840221.67 |\n| 60162 | 8838927.08 |\n| 131928 | 8838900.48 |\n| 123514 | 8833601.14 |\n| 42891 | 8830401.37 |\n| 71547 | 8829540.72 |\n| 13975 | 8826582.48 |\n| 31577 | 8825371.40 |\n| 86165 | 8816308.38 |\n| 164646 | 8815470.18 |\n| 150176 | 8814992.11 |\n| 152464 | 8814533.82 |\n| 183434 | 8813941.24 |\n| 58839 | 8808010.20 |\n| 59952 | 8801497.32 |\n| 151038 | 8800215.80 |\n| 139523 | 8800032.57 |\n| 8828 | 8798704.66 |\n| 14080 | 8797032.12 |\n| 194080 | 8792825.27 |\n| 87199 | 8788933.64 |\n| 91747 | 8785811.64 |\n| 194429 | 8776185.03 |\n| 118998 | 8776071.00 |\n| 179467 | 8771474.74 |\n| 68715 | 8771302.80 |\n| 180572 | 8771095.68 |\n| 19821 | 8770770.82 |\n| 41702 | 8770565.71 |\n| 27916 | 8769001.47 |\n| 121302 | 8763598.50 |\n| 107013 | 8762893.37 |\n| 37287 | 8761196.43 |\n| 117050 | 8758230.00 |\n| 58547 | 8757757.40 |\n| 197088 | 8749026.12 |\n| 55839 | 8747234.02 |\n| 71829 | 8744546.91 |\n| 30961 | 8743416.92 |\n| 134548 | 8741635.28 |\n| 179833 | 8738680.00 |\n| 79721 | 8737857.70 |\n| 144577 | 8736427.08 |\n| 29051 | 8729063.28 |\n| 131481 | 8728799.64 |\n| 73271 | 8727985.25 |\n| 89553 | 8725727.19 |\n| 31306 | 8724451.12 |\n| 82181 | 8724017.16 |\n| 95549 | 8723460.30 |\n| 31507 | 8722094.40 |\n| 21302 | 8722054.95 |\n| 137953 | 8721611.83 |\n| 195768 | 8721020.99 |\n| 180105 | 8718021.20 |\n| 98241 | 8717935.36 |\n| 59431 | 8715482.28 |\n| 143694 | 8713267.63 |\n| 109020 | 8713043.36 |\n| 46732 | 8711642.04 |\n| 144172 | 8711013.10 |\n| 139056 | 8710786.50 |\n| 107543 | 8706135.75 |\n| 89127 | 8705410.56 |\n| 146544 | 8704812.86 |\n| 195524 | 8699333.14 |\n| 133563 | 8698060.14 |\n| 112707 | 8694322.84 |\n| 98951 | 8690376.70 |\n| 132635 | 8689305.24 |\n| 69056 | 8688980.25 |\n| 134143 | 8688695.26 |\n| 148150 | 8687553.16 |\n| 89122 | 8686767.31 |\n| 15085 | 8685772.26 |\n| 196686 | 8682783.57 |\n| 3076 | 8672940.78 |\n| 137428 | 8672547.80 |\n| 27263 | 8671719.36 |\n| 101561 | 8667962.72 |\n| 12597 | 8662223.52 |\n| 143329 | 8661688.72 |\n| 130813 | 8659409.04 |\n| 183679 | 8658698.30 |\n| 47449 | 8658493.58 |\n| 164677 | 8658220.00 |\n| 51437 | 8654713.02 |\n| 116162 | 8649713.36 |\n| 71889 | 8645159.67 |\n| 6486 | 8639891.76 |\n| 192102 | 8638102.72 |\n| 101660 | 8634451.80 |\n| 124703 | 8633146.86 |\n| 150469 | 8631948.60 |\n| 197467 | 8630739.78 |\n| 97621 | 8630453.32 |\n| 150354 | 8630288.15 |\n| 179544 | 8630121.63 |\n| 38972 | 8626072.00 |\n| 110732 | 8625761.16 |\n| 170791 | 8625203.06 |\n| 149414 | 8617070.17 |\n| 59527 | 8616079.20 |\n| 157580 | 8615676.04 |\n| 16268 | 8615087.46 |\n| 76464 | 8610219.38 |\n| 44474 | 8607934.92 |\n| 125527 | 8607708.08 |\n| 118076 | 8602251.65 |\n| 180362 | 8601367.05 |\n| 5808 | 8599851.04 |\n| 28703 | 8599486.36 |\n| 113373 | 8597996.36 |\n| 118918 | 8597063.80 |\n| 44868 | 8596304.52 |\n| 43419 | 8596265.35 |\n| 89763 | 8595248.64 |\n| 119232 | 8594224.56 |\n| 108649 | 8590683.68 |\n| 10396 | 8588398.05 |\n| 79536 | 8587117.83 |\n| 149800 | 8587058.86 |\n| 165839 | 8582991.20 |\n| 115397 | 8581524.77 |\n| 104394 | 8581384.42 |\n| 142569 | 8581127.40 |\n| 63676 | 8580930.08 |\n| 29029 | 8580613.53 |\n| 156604 | 8580477.00 |\n| 7310 | 8579949.50 |\n| 105381 | 8576164.24 |\n| 84306 | 8573960.40 |\n| 61217 | 8570393.04 |\n| 164438 | 8569616.36 |\n| 28073 | 8565639.60 |\n| 125743 | 8563258.90 |\n| 190032 | 8561620.55 |\n| 147122 | 8561245.68 |\n| 5384 | 8558830.08 |\n| 70172 | 8558319.64 |\n| 161966 | 8556193.38 |\n| 69530 | 8554377.60 |\n| 111243 | 8553627.55 |\n| 72590 | 8551077.51 |\n| 134423 | 8550604.77 |\n| 44509 | 8547134.31 |\n| 160707 | 8546000.68 |\n| 54123 | 8545976.26 |\n| 36547 | 8540333.04 |\n| 48715 | 8537983.35 |\n| 103078 | 8537142.60 |\n| 137613 | 8536278.96 |\n| 44995 | 8532416.72 |\n| 191159 | 8532173.37 |\n| 119345 | 8532070.56 |\n| 109941 | 8531904.79 |\n| 5449 | 8528034.35 |\n| 134116 | 8526854.95 |\n| 199268 | 8523599.58 |\n| 168520 | 8523360.67 |\n| 154189 | 8521620.13 |\n| 108771 | 8513853.87 |\n| 198651 | 8511238.80 |\n| 93681 | 8510935.14 |\n| 170680 | 8509087.68 |\n| 106409 | 8506859.19 |\n| 27110 | 8499811.75 |\n| 43224 | 8499539.52 |\n| 153225 | 8499434.28 |\n| 16681 | 8498021.66 |\n| 117983 | 8496934.32 |\n| 192158 | 8492372.03 |\n| 33900 | 8491139.64 |\n| 37006 | 8489126.28 |\n| 176554 | 8488633.92 |\n| 69234 | 8484937.26 |\n| 176652 | 8484496.02 |\n| 41660 | 8480585.65 |\n| 129104 | 8480411.17 |\n| 66960 | 8478978.86 |\n| 36296 | 8472438.75 |\n| 98665 | 8471241.57 |\n| 134173 | 8467888.57 |\n| 60496 | 8467019.22 |\n| 197520 | 8466553.20 |\n| 116746 | 8465792.60 |\n| 187394 | 8458248.24 |\n| 140377 | 8455546.68 |\n| 97326 | 8450501.67 |\n| 26770 | 8449625.64 |\n| 104884 | 8446152.26 |\n| 143109 | 8443547.19 |\n| 127361 | 8441094.08 |\n| 104754 | 8436883.50 |\n| 183676 | 8436165.76 |\n| 906 | 8434608.12 |\n| 55768 | 8433763.69 |\n| 118654 | 8433465.57 |\n| 39310 | 8433214.55 |\n| 173261 | 8432992.53 |\n| 93976 | 8432605.20 |\n| 63318 | 8432149.26 |\n| 128243 | 8424182.94 |\n| 156063 | 8422743.54 |\n| 195087 | 8421279.30 |\n| 67668 | 8417594.98 |\n| 49882 | 8417237.80 |\n| 105631 | 8412628.07 |\n| 40987 | 8406033.41 |\n| 185735 | 8404112.83 |\n| 173986 | 8403050.34 |\n| 87372 | 8402838.40 |\n| 24509 | 8398807.24 |\n| 180522 | 8394989.75 |\n| 76215 | 8394433.35 |\n| 193872 | 8390435.23 |\n| 141234 | 8390180.92 |\n| 91138 | 8386645.20 |\n| 28097 | 8385577.38 |\n| 4053 | 8384952.75 |\n| 17050 | 8380304.40 |\n| 64050 | 8377921.56 |\n| 80836 | 8375803.16 |\n| 86084 | 8373551.95 |\n| 168499 | 8373348.72 |\n| 178642 | 8372218.52 |\n| 8498 | 8370557.16 |\n| 156312 | 8366249.30 |\n| 136803 | 8361949.92 |\n| 92109 | 8359503.23 |\n| 138625 | 8358135.21 |\n| 137540 | 8358031.08 |\n| 176531 | 8355437.00 |\n| 53783 | 8352395.63 |\n| 106977 | 8352334.98 |\n| 21385 | 8351786.37 |\n| 114885 | 8351582.40 |\n| 113643 | 8350530.65 |\n| 89061 | 8349422.08 |\n| 77752 | 8348730.24 |\n| 28623 | 8348321.44 |\n| 74478 | 8348064.27 |\n| 41383 | 8347223.45 |\n| 147632 | 8346967.80 |\n| 40948 | 8346743.30 |\n| 154324 | 8346521.91 |\n| 89724 | 8346034.80 |\n| 119083 | 8338084.92 |\n| 124143 | 8335841.76 |\n| 80512 | 8335705.69 |\n| 105047 | 8332249.86 |\n| 38243 | 8329017.19 |\n| 42583 | 8328613.91 |\n| 44240 | 8327684.64 |\n| 57611 | 8321693.94 |\n| 9730 | 8319725.70 |\n| 91655 | 8318837.40 |\n| 13140 | 8316216.96 |\n| 112257 | 8315169.85 |\n| 27182 | 8314740.99 |\n| 166654 | 8314332.64 |\n| 40572 | 8312654.55 |\n| 26680 | 8311626.68 |\n| 138947 | 8311347.29 |\n| 184982 | 8310393.08 |\n| 35540 | 8308058.43 |\n| 181446 | 8304851.76 |\n| 65160 | 8299581.90 |\n| 9533 | 8299139.42 |\n| 67836 | 8294228.46 |\n| 159414 | 8293114.90 |\n| 115025 | 8291746.65 |\n| 30780 | 8291580.00 |\n| 164680 | 8290263.02 |\n| 4599 | 8288816.03 |\n| 73366 | 8286818.96 |\n| 135625 | 8284930.92 |\n| 46497 | 8284638.88 |\n| 63781 | 8284447.60 |\n| 84332 | 8283372.14 |\n| 196269 | 8276407.36 |\n| 166651 | 8275663.35 |\n| 142 | 8273960.31 |\n| 56904 | 8272891.44 |\n| 46821 | 8272603.71 |\n| 76051 | 8272300.75 |\n| 19666 | 8270192.64 |\n| 92723 | 8267074.20 |\n| 125843 | 8266816.38 |\n| 158722 | 8266634.88 |\n| 28941 | 8266245.12 |\n| 39968 | 8265605.53 |\n| 41429 | 8265317.84 |\n| 61601 | 8264074.31 |\n| 179159 | 8260137.47 |\n| 15969 | 8259835.96 |\n| 121125 | 8253912.49 |\n| 66486 | 8253743.66 |\n| 181031 | 8253570.14 |\n| 43712 | 8250825.78 |\n| 13842 | 8245765.00 |\n| 76203 | 8245412.16 |\n| 68992 | 8243081.46 |\n| 119704 | 8241363.06 |\n| 86109 | 8240377.92 |\n| 29534 | 8239914.00 |\n| 68596 | 8239825.29 |\n| 168291 | 8237626.32 |\n| 183308 | 8235947.21 |\n| 78657 | 8233481.64 |\n| 193545 | 8233037.49 |\n| 23658 | 8232306.18 |\n| 179945 | 8231365.25 |\n| 53391 | 8231252.10 |\n| 71380 | 8231125.68 |\n| 53666 | 8226715.00 |\n| 118592 | 8226181.00 |\n| 67203 | 8225355.99 |\n| 1178 | 8224625.05 |\n| 147876 | 8224189.62 |\n| 80042 | 8220826.70 |\n| 48950 | 8218611.22 |\n| 43331 | 8218448.04 |\n| 177706 | 8215723.50 |\n| 145442 | 8215706.16 |\n| 197042 | 8215536.00 |\n| 169952 | 8214698.43 |\n| 57907 | 8211740.04 |\n| 145741 | 8210316.57 |\n| 91144 | 8209855.02 |\n| 160266 | 8209468.80 |\n| 31602 | 8209366.90 |\n| 98672 | 8208412.85 |\n| 199012 | 8207897.50 |\n| 151148 | 8207645.16 |\n| 116545 | 8207573.24 |\n| 122176 | 8207508.04 |\n| 11021 | 8206766.10 |\n| 47752 | 8203436.82 |\n| 124 | 8203209.30 |\n| 148126 | 8202846.66 |\n| 15753 | 8202695.55 |\n| 50833 | 8200880.16 |\n| 11523 | 8196478.02 |\n| 71478 | 8195930.68 |\n| 129262 | 8190520.80 |\n| 43023 | 8186451.85 |\n| 119193 | 8184853.14 |\n| 85067 | 8182638.86 |\n| 164534 | 8181563.04 |\n| 82556 | 8180455.14 |\n| 31813 | 8179417.14 |\n| 81345 | 8173128.69 |\n| 38413 | 8172464.04 |\n| 106014 | 8171418.35 |\n| 191180 | 8170663.97 |\n| 43274 | 8169669.72 |\n| 5837 | 8166123.50 |\n| 63332 | 8161839.60 |\n| 47668 | 8161790.04 |\n| 112468 | 8160728.40 |\n| 132541 | 8160680.00 |\n| 59457 | 8160393.33 |\n| 71751 | 8159865.19 |\n| 118395 | 8156795.00 |\n| 132390 | 8154867.54 |\n| 44792 | 8153384.22 |\n| 128838 | 8153018.30 |\n| 87197 | 8152281.72 |\n| 187978 | 8150832.56 |\n| 147419 | 8150063.60 |\n| 149166 | 8149406.78 |\n| 196012 | 8147307.42 |\n| 190519 | 8145402.96 |\n| 151511 | 8144276.58 |\n| 88891 | 8140166.24 |\n| 168056 | 8139101.96 |\n| 189186 | 8136933.25 |\n| 117326 | 8136047.82 |\n| 60575 | 8133316.80 |\n| 75452 | 8130427.37 |\n| 194126 | 8129751.80 |\n| 130199 | 8129270.88 |\n| 41680 | 8128823.40 |\n| 107624 | 8125799.20 |\n| 135069 | 8123999.10 |\n| 119032 | 8123770.24 |\n| 27635 | 8123076.65 |\n| 14317 | 8121553.23 |\n| 148018 | 8119898.16 |\n| 51152 | 8118370.26 |\n| 112643 | 8117331.37 |\n| 119526 | 8116075.80 |\n| 192084 | 8114896.38 |\n| 151385 | 8114711.28 |\n| 160836 | 8112053.68 |\n| 91468 | 8111785.50 |\n| 58877 | 8108256.25 |\n| 41885 | 8107026.81 |\n| 155542 | 8106757.18 |\n| 149968 | 8104953.78 |\n| 168380 | 8103576.00 |\n| 134641 | 8101092.32 |\n| 92470 | 8100877.70 |\n| 113610 | 8098591.93 |\n| 198538 | 8097343.20 |\n| 122506 | 8096090.76 |\n| 29082 | 8093543.55 |\n| 161345 | 8093157.93 |\n| 105743 | 8093045.53 |\n| 103572 | 8091573.66 |\n| 59514 | 8089470.48 |\n| 8801 | 8088454.15 |\n| 129062 | 8088206.58 |\n| 155464 | 8086115.79 |\n| 86363 | 8082561.00 |\n| 180836 | 8082087.30 |\n| 92558 | 8081407.80 |\n| 85120 | 8073164.00 |\n| 149026 | 8072285.40 |\n| 51138 | 8072074.48 |\n| 36306 | 8071648.86 |\n| 102380 | 8070503.00 |\n| 147597 | 8069397.60 |\n| 41382 | 8059995.35 |\n| 121856 | 8059809.11 |\n| 86644 | 8058667.76 |\n| 108481 | 8058214.81 |\n| 41685 | 8057355.39 |\n| 175712 | 8054878.30 |\n| 72815 | 8052294.24 |\n| 58794 | 8047848.00 |\n| 118769 | 8047465.14 |\n| 157192 | 8046501.96 |\n| 195708 | 8045001.94 |\n| 163683 | 8044727.02 |\n| 189018 | 8043927.54 |\n| 62904 | 8043011.65 |\n| 80095 | 8042575.59 |\n| 90500 | 8042502.65 |\n| 73281 | 8040167.52 |\n| 150710 | 8035910.80 |\n| 139282 | 8034489.36 |\n| 172904 | 8033791.68 |\n| 38881 | 8032557.38 |\n| 53055 | 8030796.15 |\n| 105816 | 8025318.24 |\n| 88304 | 8024637.06 |\n| 115565 | 8023928.25 |\n| 55376 | 8021432.16 |\n| 56334 | 8019313.12 |\n| 58875 | 8016065.00 |\n| 4688 | 8012303.00 |\n| 49117 | 8009207.80 |\n| 57173 | 8008116.27 |\n| 48176 | 8006765.85 |\n| 112191 | 8003883.39 |\n| 33265 | 8002391.76 |\n| 181788 | 8002030.50 |\n| 172799 | 8001050.55 |\n| 2084 | 7999172.30 |\n| 174747 | 7997167.48 |\n| 171184 | 7996930.11 |\n| 113271 | 7992683.04 |\n| 68662 | 7991426.30 |\n| 179375 | 7991170.88 |\n| 188383 | 7990226.27 |\n| 50208 | 7989363.27 |\n| 23653 | 7988890.87 |\n| 159419 | 7988841.36 |\n| 74581 | 7987356.50 |\n| 133590 | 7986046.81 |\n| 195820 | 7985473.14 |\n| 87903 | 7983482.88 |\n| 69032 | 7981908.18 |\n| 113975 | 7980561.00 |\n| 178678 | 7975116.93 |\n| 52316 | 7973618.16 |\n| 135546 | 7972669.80 |\n| 89425 | 7970077.44 |\n| 115937 | 7966015.20 |\n| 151483 | 7964850.88 |\n| 73974 | 7964186.23 |\n| 39976 | 7964104.24 |\n| 130168 | 7961690.88 |\n| 58973 | 7957416.76 |\n| 16354 | 7956051.07 |\n| 23988 | 7955837.92 |\n| 138467 | 7955481.05 |\n| 26096 | 7955212.32 |\n| 192216 | 7953429.18 |\n| 112833 | 7952279.26 |\n| 60599 | 7951261.80 |\n| 129116 | 7948811.85 |\n| 79529 | 7947581.91 |\n| 71616 | 7944476.54 |\n| 136821 | 7942188.24 |\n| 116204 | 7941096.90 |\n| 165298 | 7939933.31 |\n| 44009 | 7939859.65 |\n| 194487 | 7938247.20 |\n| 11299 | 7938135.81 |\n| 76488 | 7935926.86 |\n| 58998 | 7934414.04 |\n| 25175 | 7931035.11 |\n| 136144 | 7929283.23 |\n| 132829 | 7926841.62 |\n| 84176 | 7925781.05 |\n| 68592 | 7922872.98 |\n| 139280 | 7922119.48 |\n| 160669 | 7921588.43 |\n| 42938 | 7917524.56 |\n| 183183 | 7915624.86 |\n| 95449 | 7914292.08 |\n| 115390 | 7912655.54 |\n| 173723 | 7911329.40 |\n| 48992 | 7911153.12 |\n| 173464 | 7910458.65 |\n| 26098 | 7910217.75 |\n| 141115 | 7909496.38 |\n| 195218 | 7906315.56 |\n| 116608 | 7906302.60 |\n| 163793 | 7905477.33 |\n| 10419 | 7904598.30 |\n| 106312 | 7901466.72 |\n| 48674 | 7901010.24 |\n| 35198 | 7899974.88 |\n| 88954 | 7899573.52 |\n| 41505 | 7897709.99 |\n| 115586 | 7897301.88 |\n| 167431 | 7895826.00 |\n| 158787 | 7894948.50 |\n| 161712 | 7893410.70 |\n| 46930 | 7892707.77 |\n| 58633 | 7892088.15 |\n| 10599 | 7892067.69 |\n| 99523 | 7891485.16 |\n| 70126 | 7890247.41 |\n| 32476 | 7890149.34 |\n| 152617 | 7890136.50 |\n| 162639 | 7889822.70 |\n| 82056 | 7889345.05 |\n| 186450 | 7887873.56 |\n| 39082 | 7886019.89 |\n| 183217 | 7885948.48 |\n| 192551 | 7884432.48 |\n| 164801 | 7882870.10 |\n| 112804 | 7882772.00 |\n| 5956 | 7878805.04 |\n| 73054 | 7878479.63 |\n| 62593 | 7878401.44 |\n| 137687 | 7873755.91 |\n| 80526 | 7871839.50 |\n| 195354 | 7869617.75 |\n| 4122 | 7867967.09 |\n| 4057 | 7865176.80 |\n| 63195 | 7864322.16 |\n| 143370 | 7863444.54 |\n| 41473 | 7862926.89 |\n| 155060 | 7860900.96 |\n| 76875 | 7858529.64 |\n| 135778 | 7857660.51 |\n| 30534 | 7855226.08 |\n| 99405 | 7853410.95 |\n| 161551 | 7852244.40 |\n| 185034 | 7850752.00 |\n| 17264 | 7850704.88 |\n| 23652 | 7848909.16 |\n| 123681 | 7848265.36 |\n| 186170 | 7845527.50 |\n| 81496 | 7840427.40 |\n| 25407 | 7840234.72 |\n| 96662 | 7839907.41 |\n| 156407 | 7839647.75 |\n| 165843 | 7839562.80 |\n| 153361 | 7838813.07 |\n| 149362 | 7838282.52 |\n| 46057 | 7835709.81 |\n| 114341 | 7835492.25 |\n| 154823 | 7834898.61 |\n| 139538 | 7834690.64 |\n| 42853 | 7833252.60 |\n| 177659 | 7831803.58 |\n| 29158 | 7829880.80 |\n| 85583 | 7825996.64 |\n| 165714 | 7825006.46 |\n| 58662 | 7821977.76 |\n| 185839 | 7821640.74 |\n| 93559 | 7821137.52 |\n| 58481 | 7818648.16 |\n| 162217 | 7817923.47 |\n| 130014 | 7815929.34 |\n| 125640 | 7815262.90 |\n| 83723 | 7815021.48 |\n| 54314 | 7813732.94 |\n| 146652 | 7809817.39 |\n| 189256 | 7808972.00 |\n| 87994 | 7808660.48 |\n| 157067 | 7806217.25 |\n| 56859 | 7805947.60 |\n| 118132 | 7804423.69 |\n| 189457 | 7802777.91 |\n| 1509 | 7802315.42 |\n| 129101 | 7801994.70 |\n| 162285 | 7801859.52 |\n| 182358 | 7801430.46 |\n| 6288 | 7800363.30 |\n| 68972 | 7799224.95 |\n| 51684 | 7795455.46 |\n| 148645 | 7794585.92 |\n| 94359 | 7794358.92 |\n| 40451 | 7791437.70 |\n| 44019 | 7790053.76 |\n| 81470 | 7788716.85 |\n| 12731 | 7786998.38 |\n| 114393 | 7784963.34 |\n| 69323 | 7783583.08 |\n| 169794 | 7780968.30 |\n| 25378 | 7778569.60 |\n| 104509 | 7777137.62 |\n| 81874 | 7775216.80 |\n| 70859 | 7771185.07 |\n| 135768 | 7769704.84 |\n| 181960 | 7768847.90 |\n| 28481 | 7768516.61 |\n| 191604 | 7765367.68 |\n| 754 | 7762507.02 |\n| 127702 | 7761776.05 |\n| 36488 | 7761744.00 |\n| 183906 | 7759864.80 |\n| 90365 | 7759602.50 |\n| 60725 | 7759495.78 |\n| 69436 | 7759033.52 |\n| 12963 | 7756623.52 |\n| 64571 | 7755731.04 |\n| 160111 | 7753787.70 |\n| 107970 | 7753735.88 |\n| 132036 | 7753401.36 |\n| 79965 | 7748656.15 |\n| 149862 | 7747239.10 |\n| 73218 | 7745499.42 |\n| 161036 | 7742807.45 |\n| 152467 | 7742471.40 |\n| 163358 | 7742034.00 |\n| 197951 | 7741768.84 |\n| 15820 | 7740003.00 |\n| 31444 | 7739519.60 |\n| 151208 | 7738273.85 |\n| 20410 | 7737192.99 |\n| 45462 | 7736792.55 |\n| 128966 | 7736467.65 |\n| 118945 | 7735275.00 |\n| 106458 | 7734069.72 |\n| 162706 | 7730189.88 |\n| 70528 | 7730088.25 |\n| 107998 | 7728273.45 |\n| 163110 | 7728042.40 |\n| 74591 | 7727297.76 |\n| 121454 | 7726200.56 |\n| 181252 | 7724464.38 |\n| 29154 | 7724129.66 |\n| 63854 | 7720353.88 |\n| 34157 | 7719803.30 |\n| 30684 | 7718307.84 |\n| 3985 | 7715042.96 |\n| 29387 | 7714858.80 |\n| 184703 | 7712545.12 |\n| 124679 | 7712528.72 |\n| 15606 | 7710658.46 |\n| 123814 | 7709872.95 |\n| 83760 | 7709633.92 |\n| 22084 | 7707219.79 |\n| 123210 | 7706030.42 |\n| 75066 | 7704727.51 |\n| 16337 | 7704517.80 |\n| 47109 | 7704111.51 |\n| 8232 | 7702887.50 |\n| 11222 | 7702535.62 |\n| 84961 | 7701923.72 |\n| 157118 | 7700132.88 |\n| 118362 | 7699210.20 |\n| 193755 | 7698545.20 |\n| 1520 | 7697759.37 |\n| 114599 | 7697377.50 |\n| 168842 | 7696152.00 |\n| 172245 | 7694286.06 |\n| 4584 | 7693352.79 |\n| 113651 | 7689659.67 |\n| 183207 | 7687955.66 |\n| 175802 | 7686604.70 |\n| 59066 | 7685120.43 |\n| 130726 | 7684159.25 |\n| 89672 | 7684049.50 |\n| 7224 | 7683446.40 |\n| 97533 | 7680694.62 |\n| 59941 | 7680100.80 |\n| 29298 | 7676823.42 |\n| 163962 | 7675924.96 |\n| 41086 | 7674518.14 |\n| 185483 | 7673376.60 |\n| 165010 | 7672469.70 |\n| 3708 | 7671744.18 |\n| 192994 | 7671712.00 |\n| 79968 | 7668060.48 |\n| 118494 | 7666659.00 |\n| 59236 | 7666625.98 |\n| 149509 | 7665930.67 |\n| 3793 | 7664981.28 |\n| 28979 | 7664632.93 |\n| 178389 | 7662544.96 |\n| 65315 | 7661085.88 |\n| 59710 | 7657442.00 |\n| 170276 | 7656813.89 |\n| 182707 | 7656387.06 |\n| 129170 | 7655820.48 |\n| 59765 | 7655009.92 |\n| 23337 | 7654271.94 |\n| 90396 | 7653568.35 |\n| 68842 | 7652742.72 |\n| 16315 | 7652630.70 |\n| 956 | 7652174.81 |\n| 10639 | 7651375.80 |\n| 112886 | 7649534.08 |\n| 9561 | 7648502.73 |\n| 65484 | 7647789.30 |\n| 68677 | 7646879.14 |\n| 196529 | 7645482.24 |\n| 6556 | 7642116.06 |\n| 9113 | 7640163.68 |\n| 128139 | 7638760.00 |\n| 143264 | 7635499.56 |\n| 21569 | 7634785.86 |\n| 193402 | 7633576.06 |\n| 35545 | 7632210.69 |\n| 65068 | 7632188.76 |\n| 25515 | 7630952.93 |\n| 180189 | 7630887.10 |\n| 131680 | 7629593.64 |\n| 80162 | 7629440.93 |\n| 139054 | 7629417.37 |\n| 8028 | 7629134.04 |\n| 76804 | 7626731.00 |\n| 74179 | 7624974.03 |\n| 122507 | 7623903.87 |\n| 141889 | 7623552.30 |\n| 184279 | 7623048.17 |\n| 8076 | 7620897.81 |\n| 192681 | 7619802.09 |\n| 21398 | 7617942.52 |\n| 14825 | 7617843.60 |\n| 17969 | 7617524.64 |\n| 170764 | 7616119.96 |\n| 115303 | 7615914.17 |\n| 67708 | 7615306.08 |\n| 33317 | 7613417.24 |\n| 190782 | 7613203.42 |\n| 113818 | 7612852.48 |\n| 178091 | 7611457.30 |\n| 87603 | 7611343.68 |\n| 108317 | 7610509.71 |\n| 106552 | 7609868.84 |\n| 28679 | 7609292.20 |\n| 192350 | 7609140.81 |\n| 154801 | 7607944.38 |\n| 5768 | 7607785.68 |\n| 127689 | 7606313.94 |\n| 62847 | 7605651.45 |\n| 111212 | 7605052.00 |\n| 156065 | 7603327.60 |\n| 115140 | 7601161.68 |\n| 19597 | 7601153.46 |\n| 55233 | 7600940.23 |\n| 89353 | 7600929.84 |\n| 75701 | 7600492.60 |\n| 64974 | 7599754.80 |\n| 116156 | 7597452.48 |\n| 59491 | 7596352.84 |\n| 6138 | 7594861.54 |\n| 62317 | 7594854.10 |\n| 106575 | 7594520.08 |\n| 161092 | 7594454.40 |\n| 9872 | 7593734.34 |\n| 77711 | 7593431.60 |\n| 61206 | 7593153.00 |\n| 123776 | 7592736.80 |\n| 185141 | 7592617.12 |\n| 5542 | 7592513.04 |\n| 185296 | 7591439.31 |\n| 72597 | 7591142.40 |\n+------------+-------------+\n1225 rows in set\n\nQ12\n+------------+-----------------+----------------+\n| l_shipmode | high_line_count | low_line_count |\n+------------+-----------------+----------------+\n| FOB | 6273 | 9429 |\n| TRUCK | 6336 | 9300 |\n+------------+-----------------+----------------+\n\nQ13\n+---------+----------+\n| c_count | custdist |\n+---------+----------+\n| 0 | 50005 |\n| 10 | 6574 |\n| 9 | 6554 |\n| 11 | 6072 |\n| 8 | 5934 |\n| 12 | 5598 |\n| 13 | 5032 |\n| 19 | 4685 |\n| 7 | 4663 |\n| 20 | 4607 |\n| 17 | 4550 |\n| 18 | 4515 |\n| 14 | 4480 |\n| 15 | 4476 |\n| 16 | 4341 |\n| 21 | 4176 |\n| 22 | 3710 |\n| 6 | 3303 |\n| 23 | 3172 |\n| 24 | 2670 |\n| 25 | 2111 |\n| 5 | 1954 |\n| 26 | 1605 |\n| 27 | 1195 |\n| 4 | 1030 |\n| 28 | 898 |\n| 29 | 620 |\n| 3 | 408 |\n| 30 | 353 |\n| 31 | 225 |\n| 32 | 135 |\n| 2 | 128 |\n| 33 | 82 |\n| 34 | 54 |\n| 35 | 33 |\n| 1 | 18 |\n| 36 | 17 |\n| 37 | 7 |\n| 41 | 3 |\n| 40 | 3 |\n| 38 | 3 |\n| 39 | 1 |\n+---------+----------+\n42 rows in set\n\n\nQ14\n+-------------------+\n| promo_revenue |\n+-------------------+\n| 16.65118731292792 |\n+-------------------+\n\nQ15\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n| s_suppkey | s_name | s_address | s_phone | total_revenue |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n| 7895 | Supplier#000007895 | NYl,i8UhxTykLxGJ2voIRn20Ugk1KTzz | 14-559-808-3306 | 1678635.2636 |\n+-----------+--------------------+----------------------------------+-----------------+---------------+\n\n\nQ16\n+----------+---------------------------+--------+--------------+\n| p_brand | p_type | p_size | supplier_cnt |\n+----------+---------------------------+--------+--------------+\n| Brand#55 | LARGE BURNISHED TIN | 21 | 36 |\n| Brand#25 | PROMO BRUSHED STEEL | 24 | 28 |\n| Brand#54 | STANDARD BRUSHED COPPER | 14 | 27 |\n| Brand#12 | MEDIUM PLATED BRASS | 21 | 24 |\n| Brand#14 | ECONOMY PLATED TIN | 33 | 24 |\n| Brand#24 | ECONOMY PLATED TIN | 33 | 24 |\n| Brand#25 | MEDIUM PLATED STEEL | 35 | 24 |\n| Brand#32 | MEDIUM POLISHED COPPER | 20 | 24 |\n| Brand#32 | SMALL ANODIZED BRASS | 7 | 24 |\n| Brand#33 | ECONOMY PLATED STEEL | 7 | 24 |\n| Brand#33 | MEDIUM PLATED COPPER | 20 | 24 |\n| Brand#33 | PROMO POLISHED STEEL | 14 | 24 |\n...\n| Brand#31 | PROMO ANODIZED COPPER | 20 | 3 |\n| Brand#41 | LARGE BURNISHED STEEL | 20 | 3 |\n| Brand#43 | SMALL BRUSHED COPPER | 7 | 3 |\n| Brand#52 | MEDIUM POLISHED BRASS | 21 | 3 |\n| Brand#52 | SMALL POLISHED TIN | 2 | 3 |\n+----------+---------------------------+--------+--------------+\n18341 rows in set\n\nQ17\n+-------------------+\n| avg_yearly |\n+-------------------+\n| 348406.0542857143 |\n+-------------------+\n\nQ18\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| c_name | c_custkey | o_orderkey | o_orderdate | o_totalprice | sum(l_quantity) |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n| Customer#000128120 | 128120 | 4722021 | 1994-04-07 | 544089.09 | 323.00 |\n| Customer#000144617 | 144617 | 3043270 | 1997-02-12 | 530604.44 | 317.00 |\n| Customer#000066790 | 66790 | 2199712 | 1996-09-30 | 515531.82 | 327.00 |\n| Customer#000015619 | 15619 | 3767271 | 1996-08-07 | 480083.96 | 318.00 |\n| Customer#000147197 | 147197 | 1263015 | 1997-02-02 | 467149.67 | 320.00 |\n| Customer#000117919 | 117919 | 2869152 | 1996-06-20 | 456815.92 | 317.00 |\n| Customer#000126865 | 126865 | 4702759 | 1994-11-07 | 447606.65 | 320.00 |\n| Customer#000036619 | 36619 | 4806726 | 1995-01-17 | 446704.09 | 328.00 |\n| Customer#000119989 | 119989 | 1544643 | 1997-09-20 | 434568.25 | 320.00 |\n+--------------------+-----------+------------+-------------+--------------+-----------------+\n9 rows in set\n\nQ19\n+--------------+\n| revenue |\n+--------------+\n| 3083843.0578 |\n+--------------+\n\nQ20\n+--------------------+------------------------------------------+\n| s_name | s_address |\n+--------------------+------------------------------------------+\n| Supplier#000000035 | QymmGXxjVVQ5OuABCXVVsu,4eF gU0Qc6 |\n| Supplier#000000068 | Ue6N50wH2CwE4PPgTGLmat,ibGYYlDoOb3xQwtgb |\n| Supplier#000000080 | cJ2MHSEJ13rIL2Wj3D5i6hRo30,ZiNUXhqn |\n| Supplier#000000100 | rIlN li8zvW22l2slbcx ECP4fL |\n| Supplier#000000274 | usxbl9KSW41DTE6FAglxHU |\n| Supplier#000000406 | zMhU58CDF4aHTeodxg9IgRZgq |\n| Supplier#000000444 | mHr2VcUpRkvyQ9rjKMaPkeWbVZmEIhxhb8F |\n| Supplier#000000453 | bpt98PxU5HSQt61bVB695JPjBmJKUv hNzQeHvC |\n| Supplier#000000458 | IFNkUK1H53HwUHabiONkMFAUDb |\n| Supplier#000000622 | gCQimU1jYHoQiglDmW1FkQM9wzi YC1P15pMy1 |\n| Supplier#000000713 | DBMIf1HiYY8OyRFcbtHpKIz |\n| Supplier#000000767 | bHEuqKKdmCMEKOV |\n| Supplier#000000776 | nklfFoSkCwf,ooSuF |\n| Supplier#000000823 | gC0DrEG5U,v893fp3nj mmXa6rYhJ0tjpJ |\n| Supplier#000000828 | 0B2aPqJ6KTEr2fqxuC7z |\n| Supplier#000000941 | gqG2XEnVlzUhjjfQGYGlwk,jcaNsplI8Rleg |\n| Supplier#000000973 | 5 nhBZ 03rG6EcOEDkZXvt |\n| Supplier#000000984 | 6H6qqye iYbYzCmwWhj |\n| Supplier#000001149 | Nuno37wiZOjNGHF |\n| Supplier#000001201 | Seh4D7pi9UdK,XQkF46A0O2N |\n| Supplier#000001309 | 72RNUzKzbniUnnsSs24ZzGDvmcv2Pd |\n| Supplier#000001344 | 6iF,zVDNTykohVKcb7FKvn82s74ez |\n| Supplier#000001351 | zXdoBMmmRx1wOD7GKoHHBtemXGuYKLDb,U2KP |\n| Supplier#000001391 | hkWoAM561QlLjBNk,SdFdIgFx |\n| Supplier#000001481 | ARqVvJHMxBNKl2LrfPsR Wq9ZUXh,14 |\n| Supplier#000001584 | gJbTkijteJxSMLmdzBSzeMAH |\n| Supplier#000001651 | 6rJNoWL9YL |\n| Supplier#000001710 | J,sdOOJwUhwPv2mrEiNEA0UZlmu5IRmgz |\n| Supplier#000001755 | QstBVfnY,93NsbWXCqO |\n| Supplier#000001869 | nogoCdaFQii,ri9rs3P8f5rPt1wVOMw9I7TmypxK |\n| Supplier#000001895 | lywAGDbk37fYPDS |\n| Supplier#000001910 | vih,zrhclXX1O9x |\n| Supplier#000001930 | 2jCSw3KOLHol7y5omVO13 |\n| Supplier#000001979 | UNW7nA,IC 5igvVsgUHA7OaLL,jOzUcT |\n| Supplier#000002046 | BiTDgHknmvQGT6FpZXfRX,xlnR |\n| Supplier#000002071 | zLH3QAtZuuOq8AoVNM |\n| Supplier#000002270 | HIscbvhw8N94djn,3UbPaY4R |\n| Supplier#000002350 | TWsO2iJGOl7v3vSwiscXp6X |\n| Supplier#000002409 | oy39SaSQ,FIP pzLqblhxj |\n| Supplier#000002520 | 5y55UzYQKByZP3 |\n| Supplier#000002618 | 3UtbE1kKm29kKyx09hSEBMhRLM |\n| Supplier#000002643 | eDN6YjGtp2dcj0IF,BKEEYjElO,sUjjcNI |\n| Supplier#000002649 | agDQi9iCt1cUaS |\n| Supplier#000002655 | i6v8dkQBuK0NSCeqQCE8 |\n| Supplier#000002812 | Q9sO3wZkBU5QBe0VITRWShv |\n| Supplier#000002888 | 3AtRoxBFh6HIBa9kdBX,6,Ml2SZGUA |\n| Supplier#000002910 | nlH1gjApxHkQe5SU4iVZwi2xWk88wwhTWRkSvOBB |\n| Supplier#000002914 | fUC4IkGB8pt1S |\n| Supplier#000003000 | JtDvRf4iWHJkj54PYxl |\n| Supplier#000003011 | vfL mV0MTdyozfRIPZkJbM1Z7Lcm2NCPIj6qSgBz |\n| Supplier#000003038 | F5Tz7P juuCbABDuW8JGomRFxqVHBWyQrsLwg4i |\n| Supplier#000003150 | XwSjsmzEnANK,wAQUp4Xf5xJDqR |\n| Supplier#000003305 | GLZJimfuzKoQcqcv4 |\n| Supplier#000003394 | R6D7n3WrQjWNGSQTb7eN ,X0oCMkhyuTHBOSPw |\n| Supplier#000003452 | 7tMycIKhE,pe4OL3Du |\n| Supplier#000003666 | ENS fE9iSrSzw,iTwA,zGorkflw |\n| Supplier#000003698 | lnSEu64ca4B53BfznJPg |\n| Supplier#000003773 | UWjSotAjkAD |\n| Supplier#000003837 | SYXpXaKop3 |\n| Supplier#000003846 | wl076KfcEpYLRegb1LfIf93b3n5HBabFK2R,mEM |\n| Supplier#000003862 | 0XXFhF1IDBh |\n| Supplier#000003868 | 5aP4VBn0t666NbGYB |\n| Supplier#000003880 | DZo80mSznrhCpb8 |\n| Supplier#000003955 | piECPB8qbn7s3XP |\n| Supplier#000004007 | cvlSgCCKGOwpaB iFIPx4vU2qA5b6K hz9Z91 |\n| Supplier#000004066 | TNBnJFDScUmsjBy6pSWTS sfMg9jpfKx |\n| Supplier#000004127 | EduKm3NcCc75Cd |\n| Supplier#000004174 | Bk97olQYwXmjYdQjwyt N |\n| Supplier#000004328 | euddbWZRcVMD3W |\n| Supplier#000004341 | ea8KZYvO7amq8A |\n| Supplier#000004360 | w 7kM5J,fqjiqBu4SU0UPEDqspaUEm |\n| Supplier#000004375 | Cmr952zcJJuW0xAYc0W0MA7N6vMcCjy |\n| Supplier#000004391 | pcsiJBhSEHuFHNAxR3K c |\n| Supplier#000004398 | khZZ0CmLip49Zncec |\n| Supplier#000004402 | acagGfDWzwmS,,WVBsszubFs3LOA8rDRS0I |\n| Supplier#000004714 | IKRla2xArMmR4p3Mbn8JV8g0 |\n| Supplier#000004717 | H,Suh5pN230Ol,ggx0QEh3rrvzyQsq050Lat |\n| Supplier#000004740 | yM0TXkhfjpObafbQhuWU |\n| Supplier#000004763 | W 7kS9LLh4ZgLpk2 |\n| Supplier#000004837 | tYHMZS4XlJjzvj34mH2PCoj |\n| Supplier#000004882 | e,V Bo1KZEt |\n| Supplier#000004913 | em,yC41xEl Fst9LwEik |\n| Supplier#000005005 | K6 GI4WzmbsGEOh |\n| Supplier#000005238 | jmtI76 8RNG8Z2BZu |\n| Supplier#000005289 | 62XeOur9SnXgbdjGwb9E1aJIEBr5PA9 |\n| Supplier#000005317 | lPOPHufNjwZaUJGVNHCC2DE FYQcKZBzHltL5 |\n| Supplier#000005401 | eEOlCEAaIfVexStlrgTuzwQx7vjPF6ZT dm |\n| Supplier#000005449 | fhc8lUuZdqWUujcVaWogowEq1WVL9Y8m1efwCl3G |\n| Supplier#000005472 | LlyLSmvY9GFvMN4QhHzMokW0k5d |\n| Supplier#000005572 | o0VYozeSbEyqck |\n| Supplier#000005579 | ACVEMP4IwRf |\n| Supplier#000005661 | pq5wuxmkIW0DyWU |\n| Supplier#000005676 | HInJHZisl5svSU1oKsr |\n| Supplier#000005815 | S6cu6cspYxHlTz2 |\n| Supplier#000005835 | rYoXzV3EZ77Z |\n| Supplier#000006103 | l32l8iaPdbHgRXoq,kdjFAj3hZk2d |\n| Supplier#000006173 | hBdratcVfL4LpWxsEpCRP g0AksN0CDhBZ |\n| Supplier#000006226 | CKuDyeGAxPHeRHwC4a |\n| Supplier#000006254 | g7OY1vWNUb1vxIRgEl |\n| Supplier#000006348 | f2KDn2rLnadX8I DZR |\n| Supplier#000006359 | QyUuVHYBp8sTd7Y9WveNfsz |\n| Supplier#000006430 | F2RrkeaNcs6po8x2PyYvcPa1rtKd,fT2AMxP |\n| Supplier#000006516 | 89XwFOC,hLRxGq5rL0txv0EM9F |\n| Supplier#000006700 | BWjerJH5kbEPu 8h9 |\n| Supplier#000006785 | lyo6PpwulTeN9ZfIkvWag5NucL,XMC 89Kn7U |\n| Supplier#000006998 | r2i3HfkSQh9dvho, NpoabdMsPBG |\n| Supplier#000007019 | 2GQsALzRiTt2BQum6bocdeGawkOrsjNIZ |\n| Supplier#000007114 | s9s4YLeLWo7fLRO3rdQKFfUnZhrZUPjOC |\n| Supplier#000007170 | 9vABqu hZaciXSCQrbTj |\n| Supplier#000007171 | DXerxFIhNRpqF9dWNRw hDOlLX gEJFxh0 |\n| Supplier#000007213 | 2Nrby3JJHDJyWwVNiqPtm2U JGWlZpU |\n| Supplier#000007219 | p5Ui3IGPcmotYu |\n| Supplier#000007229 | iwNoWdaURFzLAsQHxK,BeOPpI5TOTo |\n| Supplier#000007263 | malQPdYc8xiup2MiFuKHa |\n| Supplier#000007270 | TksERECGdYZRPUjkUdDRZv5pW26cOTaA1 |\n| Supplier#000007276 | Vi9,aBg2ychZf |\n| Supplier#000007334 | NPXYWdJ8L9EDr20tw9CZQsEMqXlgXzI2JC Y |\n| Supplier#000007400 | 7r9zZj8J,,hN2GRfWtDxzuGa |\n| Supplier#000007442 | DzycM1,T6kh2EutfPeFpv0Ro |\n| Supplier#000007456 | ITYEeccPVJi0HvnAwVs2Z |\n| Supplier#000007559 | Wmzx1vskciC |\n| Supplier#000007677 | OoTYQdxQyd7NukSaSRv |\n| Supplier#000007712 | DyTQD 3ajuOtHQTpI4LsWSF kSd2SE6U4COgYHQ |\n| Supplier#000007715 | gZHd7Yzbtv7yb7DYCCAQPJH8FRHTqi6T4w |\n| Supplier#000007816 | 1ejcJ545bwLWLuY6Qq4qyEExZIsp0SG |\n| Supplier#000007845 | agwGVTzLyRKOsZxLVi,mPWZ08Qxb |\n| Supplier#000007875 | E0CkoBYngcIoH |\n| Supplier#000007908 | ghhHapj7GK |\n| Supplier#000007972 | WW0GuiWP2N3kUo4f |\n| Supplier#000008162 | XASpbn08mRV0kgHRmUSKx |\n| Supplier#000008235 | TjVWq6bTdGJB |\n| Supplier#000008249 | PwUjvlMk y72zaMRtZQ8trbCmu4j |\n| Supplier#000008309 | 6P,FQbW6sJouqunvttVO6vEeY |\n| Supplier#000008339 | uWw8 P6u,S |\n| Supplier#000008343 | BbHngAVqj0J8 |\n| Supplier#000008349 | 8Hkx1IDd0mZCTX |\n| Supplier#000008377 | ,Yk0mflw2LqQCTxMYR sU2juj5DorUAG4w6i |\n| Supplier#000008468 | 5R4jsweitleustYlE3w,u5otW |\n| Supplier#000008523 | C4ocdfNu5I2nnnVG2xSd3016J6KNLIg |\n| Supplier#000008580 | t5ri71bM6Sox3riP4JUZsMMNC |\n| Supplier#000008638 | yxj50B 8aMql |\n| Supplier#000008642 | qnN9N9du9Dg2arf6kjD xW0DjMT9cM |\n| Supplier#000008651 | pfw32RGA7BPXrUiavYqE |\n| Supplier#000008679 | JWFVoSsCwn9p8o |\n| Supplier#000008704 | a6DjHp0B6mifKBtqUk,C |\n| Supplier#000008737 | MsdGxF9Xoq9 8s |\n| Supplier#000008820 | uAsBvPBNsEsO |\n| Supplier#000008829 | lNcY7xNLDonCw TuRYL |\n| Supplier#000008947 | 1Ij3T0egGHnVbLich98HzY,UeCdVbxzYa ZpKDVc |\n| Supplier#000008964 | U2YJW,Y1xCbUWbjuovtzsLfsl |\n| Supplier#000008974 | 4JCXOJ3MyPfa51mIf,MQu |\n| Supplier#000008997 | KY MmMEcyQ6FEDCooFj xa uCwF2GbaeA8 |\n| Supplier#000009065 | ZELuiqWrWbJV9zAuco1OnXKTJClhR |\n| Supplier#000009114 | nkn6bcPvlP5w,lUpO0nZTBSj |\n| Supplier#000009125 | IQbCXbN1mmght |\n| Supplier#000009131 | gDBXgWtg4rTxu0WUJhhV |\n| Supplier#000009149 | yKX,bKryD6YtvF,cVLIKC0Z6rN |\n| Supplier#000009182 | z56kNgeqaWQ1kHFBp |\n| Supplier#000009220 | N4y,vP kdArpcmdypBh,fJVVB |\n| Supplier#000009226 | yzT10vNTFJ |\n| Supplier#000009288 | 251AA4ziZ3d7TTWXLGnXjb4BnXv |\n| Supplier#000009360 | 1NVjjX8zMjyBX2UapDTP0Sz |\n| Supplier#000009381 | rhCTm7QehIznqd8 Np7VT,H5J5zSGr |\n| Supplier#000009403 | 70841REghyWBrHyyg762Jh4sjCG7CKaIc |\n| Supplier#000009504 | Rqt07,ANI92kj1oU |\n| Supplier#000009598 | PnTAz7rNRLVDFO3zoo2QRTlh4o |\n| Supplier#000009609 | LV2rJUGfr0k3dPNRqufG1IoYHzV |\n| Supplier#000009619 | K0RwcJ9S75Xil jqKukFoDNkD |\n| Supplier#000009626 | Nm1FnIh4asUR3EnXv2Pvy3gXqI9es |\n| Supplier#000009738 | 15RRSVTuOzwdMP LmfCtIguMGXK |\n| Supplier#000009770 | Ag, SZfowit580QPDdbP8kmFHdpZ9ASI |\n| Supplier#000009865 | extcOh9ZrdDCMsHhhsFTkTUAh,HM2UQ2qa8sRo |\n| Supplier#000009866 | Auh6aZnOnQG1pPYKZ5o9ATramJBA |\n| Supplier#000009890 | izJXemCM Ikpgxk |\n| Supplier#000009937 | edZ9HQJ0KJAU6EWknTiDghKfRLHq6vtFqdey,0l |\n| Supplier#000009954 | VzElx9ihlXFJLIQw2Hn4bC2 |\n| Supplier#000009958 | ggiiSA4CSyvhwQUYjdJhWlKEY9PAfs |\n+--------------------+------------------------------------------+\n177 rows in set\n\n\nQ21\n+--------------------+---------+\n| s_name | numwait |\n+--------------------+---------+\n| Supplier#000009302 | 21 |\n| Supplier#000000342 | 20 |\n| Supplier#000000632 | 19 |\n| Supplier#000002196 | 19 |\n| Supplier#000003325 | 18 |\n| Supplier#000003915 | 18 |\n| Supplier#000005045 | 18 |\n| Supplier#000006442 | 18 |\n| Supplier#000003093 | 17 |\n| Supplier#000004498 | 17 |\n| Supplier#000000906 | 16 |\n| Supplier#000001183 | 16 |\n| Supplier#000001477 | 16 |\n| Supplier#000006043 | 16 |\n| Supplier#000000689 | 15 |\n| Supplier#000001955 | 15 |\n| Supplier#000002066 | 15 |\n| Supplier#000002146 | 15 |\n| Supplier#000003253 | 15 |\n| Supplier#000003527 | 15 |\n| Supplier#000003947 | 15 |\n| Supplier#000004915 | 15 |\n| Supplier#000005248 | 15 |\n| Supplier#000006718 | 15 |\n| Supplier#000007773 | 15 |\n| Supplier#000008121 | 15 |\n| Supplier#000008169 | 15 |\n| Supplier#000008645 | 15 |\n| Supplier#000008684 | 15 |\n| Supplier#000009079 | 15 |\n| Supplier#000009956 | 15 |\n| Supplier#000000737 | 14 |\n| Supplier#000000775 | 14 |\n| Supplier#000001474 | 14 |\n| Supplier#000001502 | 14 |\n| Supplier#000003196 | 14 |\n| Supplier#000004415 | 14 |\n| Supplier#000004940 | 14 |\n| Supplier#000005253 | 14 |\n| Supplier#000005703 | 14 |\n| Supplier#000006308 | 14 |\n| Supplier#000006789 | 14 |\n| Supplier#000007161 | 14 |\n| Supplier#000007952 | 14 |\n| Supplier#000008062 | 14 |\n| Supplier#000008414 | 14 |\n| Supplier#000008442 | 14 |\n| Supplier#000008508 | 14 |\n| Supplier#000000300 | 13 |\n| Supplier#000000727 | 13 |\n| Supplier#000000921 | 13 |\n| Supplier#000000992 | 13 |\n| Supplier#000001282 | 13 |\n| Supplier#000001582 | 13 |\n| Supplier#000001662 | 13 |\n| Supplier#000001683 | 13 |\n| Supplier#000002933 | 13 |\n| Supplier#000003177 | 13 |\n| Supplier#000003428 | 13 |\n| Supplier#000003640 | 13 |\n| Supplier#000004842 | 13 |\n| Supplier#000004951 | 13 |\n| Supplier#000005795 | 13 |\n| Supplier#000005981 | 13 |\n| Supplier#000006118 | 13 |\n| Supplier#000006433 | 13 |\n| Supplier#000006484 | 13 |\n| Supplier#000007268 | 13 |\n| Supplier#000008599 | 13 |\n| Supplier#000008675 | 13 |\n| Supplier#000009474 | 13 |\n| Supplier#000009521 | 13 |\n| Supplier#000009853 | 13 |\n| Supplier#000000021 | 12 |\n| Supplier#000000211 | 12 |\n| Supplier#000000743 | 12 |\n| Supplier#000000951 | 12 |\n| Supplier#000001654 | 12 |\n| Supplier#000001868 | 12 |\n| Supplier#000002089 | 12 |\n| Supplier#000002879 | 12 |\n| Supplier#000003060 | 12 |\n| Supplier#000003215 | 12 |\n| Supplier#000003365 | 12 |\n| Supplier#000003873 | 12 |\n| Supplier#000003985 | 12 |\n| Supplier#000004452 | 12 |\n| Supplier#000004639 | 12 |\n| Supplier#000005122 | 12 |\n| Supplier#000005633 | 12 |\n| Supplier#000005671 | 12 |\n| Supplier#000005782 | 12 |\n| Supplier#000006088 | 12 |\n| Supplier#000006477 | 12 |\n| Supplier#000006508 | 12 |\n| Supplier#000006750 | 12 |\n| Supplier#000006802 | 12 |\n| Supplier#000008236 | 12 |\n| Supplier#000009294 | 12 |\n| Supplier#000009329 | 12 |\n+--------------------+---------+\n100 rows in set\n\nQ22\n+-----------+---------+------------+\n| cntrycode | numcust | totacctbal |\n+-----------+---------+------------+\n| 10 | 882 | 6606081.31 |\n| 11 | 899 | 6702253.34 |\n| 19 | 963 | 7230776.82 |\n| 20 | 916 | 6824676.02 |\n| 22 | 894 | 6636740.03 |\n| 26 | 861 | 6404695.86 |\n| 27 | 877 | 6565078.99 |\n+-----------+---------+------------+\n7 rows in set\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/","title":"MO-Tester \u89c4\u8303\u8981\u6c42","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#-case","title":"\u7f16\u5199\u6d4b\u8bd5\u7528\u4f8b\u89c4\u8303 - case","text":"\u89c4\u8303 \u8be6\u60c5 \u6587\u4ef6\u547d\u540d 1. \u4ee5 .sql \u6216 .test \u4f5c\u4e3a\u540e\u7f00\u30022. \u6587\u4ef6\u540d\u79f0\u6709\u5b9e\u9645\u542b\u4e49\u3002\u4f8b\u5982\uff0c\u9700\u8981\u7f16\u5199\u6d4b\u8bd5\u7d22\u5f15\u7528\u4f8b\uff0c\u53ef\u4ee5\u5c06\u6d4b\u8bd5\u7d22\u5f15\u7528\u4f8b\u547d\u540d\u4e3a index.sql \u6216\u8005index_xxxx.sql\u3002 \u6d4b\u8bd5\u7528\u4f8b 1. \u6d4b\u8bd5\u7528\u4f8b\uff0c\u5373 case \u5185\u7684\u5177\u4f53\u793a\u4f8b\u5185\u5bb9\uff0c\u6240\u6709\u7684\u7a7a\u884c\u5728\u6d4b\u8bd5\u65f6\u90fd\u81ea\u52a8\u5ffd\u7565\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u7a7a\u884c\u6765\u4f7f\u6574\u4e2a\u6587\u4ef6\u5185\u5bb9\u66f4\u6613\u8bfb\u30022. \u6bcf\u6761 SQL \u8bed\u53e5\u53ea\u5199\u4e00\u884c\uff0c\u5982\u679c\u5fc5\u987b\u8981\u591a\u884c\u4e66\u5199\uff0c\u90a3\u4e48\u6bcf\u884c\u5fc5\u987b\u9876\u683c\u4e66\u5199\uff0c\u4e14 SQL \u7ed3\u5c3e\u4e0d\u80fd\u6709\u7a7a\u683c\uff0c\u5426\u5219\u5c06\u9020\u6210 case \u6587\u4ef6 \u548c result \u6587\u4ef6\u4e2d SQL \u4e0d\u80fd\u5b8c\u5168\u5339\u914d\u30023. \u6dfb\u52a0\u6ce8\u91ca\uff0c\u6ce8\u660e\u5f53\u524d\u6240\u5199\u6d4b\u8bd5\u7528\u4f8b\u7684\u76ee\u7684\u30024. \u4e3a\u9700\u8981\u589e\u52a0 Tag \u6807\u7b7e\u6d4b\u8bd5\u7528\u4f8b\u6dfb\u52a0 Tag\u3002"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#-tag","title":"\u6d4b\u8bd5\u7528\u4f8b\u6ce8\u89e3\u8bf4\u660e - Tag","text":"\u6ce8\u89e3 \u8d77\u59cb \u7ed3\u675f \u8bf4\u660e -- @bvt:issue -- @bvt:issue#{issueNO.}] -- @bvt:issue \u5e26\u6709\u6b64\u6ce8\u89e3\u6807\u8bb0\u7684 SQL \u5c06\u4e0d\u4f1a\u88ab\u6267\u884c -- @sessio -- @session:id=X{ -- @session} \u5e26\u6709\u6b64\u4e3b\u952e\u6807\u8bb0\u7684\u6240\u6709 SQL \u5c06\u5728 id=X \u7684\u65b0\u4f1a\u8bdd\u4e2d\u6267\u884c -- @separator / / \u6307\u5b9a SQL \u8bed\u53e5\u5728\u89e3\u6790\u5176 result \u4ee5\u53ca\u751f\u6210 result \u6587\u4ef6\u7684\u65f6\u5019\uff0c\u4f7f\u7528\u7684\u5217\u5206\u9694\u7b26\uff0c\u6709\u4e24\u4e2a\u53d6\u503c -- @separator:table / / \u8868\u793a\u7ed3\u679c\u4e2d\u5217\u5206\u9694\u7b26\u4e3a\u5236\u8868\u7b26 \\t -- @separator:space / / \u8868\u793a\u7ed3\u679c\u4e2d\u5217\u5206\u9694\u7b26\u4e3a 4 \u4e2a\u7a7a\u683c -- @sortkey -- @sortkey:1,2,3 / \u8868\u793a\u8be5 SQL \u8bed\u53e5\u7684\u7ed3\u679c\u662f\u6709\u5e8f\u7684\uff0c\u6392\u5e8f\u952e\u4e3a\u7b2c 1\uff0c2\uff0c3 \u5217\uff08\u4ece 0 \u5f00\u59cb\uff09\uff1b\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u88ab\u6d4b\u8bd5\u7cfb\u7edf\u8fd4\u56de\u7684\u7ed3\u679c\u987a\u5e8f\u662f\u4e0d\u56fa\u5b9a\u7684\uff0c\u6240\u4ee5\u5de5\u5177\u5728\u6bd4\u5bf9\u7684\u65f6\u5019\uff0c\u4f1a\u628a\u5b9e\u9645\u7ed3\u679c\u548c\u9884\u671f\u7ed3\u679c\u90fd\u8fdb\u884c\u6392\u5e8f\u540e\u6bd4\u5bf9\uff0c\u4f46\u662f\u5bf9\u4e8e\u67d0\u4e9b SQL\uff0c\u5176\u9884\u671f\u7684\u7ed3\u679c\u5c31\u5e94\u8be5\u662f\u6709\u5e8f\u7684\uff0c\u6bd4\u5982\u5b58\u5728 order by
\u7684 SQL \u8bed\u53e5\uff0c\u90a3\u4e48\u9700\u8981\u628a\u7c7b\u4f3c\u8fd9\u79cd SQL \u6dfb\u52a0\u4e0a\u8fd9\u6837\u7684 Tag\uff0c\u5de5\u5177\u5728\u6bd4\u5bf9\u7684\u65f6\u5019\uff0c\u4e0d\u4f1a\u5bf9 sortkey \u4e2d\u7684\u8fd9\u4e9b\u5217\u8fdb\u884c\u91cd\u65b0\u6392\u5e8f"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#-result","title":"\u7f16\u5199\u6d4b\u8bd5\u7ed3\u679c\u89c4\u8303 - result","text":"\u89c4\u8303 \u8be6\u60c5 \u666e\u901a\u6d4b\u8bd5\u7528\u4f8b\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c 1. \u5982\u679c\u65b0\u589e\u4e86\u6d4b\u8bd5 case \u6587\u4ef6\uff0c\u9996\u5148\u786e\u4fdd\u6240\u6709 SQL \u90fd\u8c03\u8bd5\u901a\u8fc7\uff0c\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u30022. \u5982\u679c\u662f\u5728\u5df2\u6709\u7684 case \u5185\u65b0\u589e\u4e00\u4e9b SQL\uff0c\u9996\u5148\u786e\u4fdd\u6240\u6709 SQL \u90fd\u8c03\u8bd5\u901a\u8fc7\uff0c\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u3002 \u542b\u6709 Tag \u7684\u6d4b\u8bd5\u7528\u4f8b\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c 1. \u5982\u679c\u65b0\u589e\u6d4b\u8bd5 case \u6587\u4ef6\uff0c\u4e14 case \u6587\u4ef6\u5185\u542b\u6709\u5e26 --bvt:issue
\u6807\u7b7e SQL\uff0c\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\uff0c\u5e26 --bvt:issue
\u6807\u7b7e SQL \u5728\u6240\u751f\u6210\u7684 result \u6587\u4ef6\u4e2d\u7ed3\u679c\u4e3a unknown result because it is related to issue#XXX\"
\u30022. \u5982\u679c\u662f\u5df2\u6709\u6d4b\u8bd5 case \u6587\u4ef6\uff0c\u5df2\u901a\u8fc7 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\uff0c\u518d\u6b21\u4f7f\u7528 MO-Tester \u5de5\u5177\u81ea\u52a8\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u65f6\uff0c\u5e26 --bvt:issue
\u6807\u7b7e SQL \u5728\u6240\u751f\u6210\u7684 result \u6587\u4ef6\u4e2d\u7ed3\u679c\u5c06\u4fdd\u7559\u539f\u6709\u503c\uff0c\u4e0d\u518d\u66f4\u65b0\u3002 \u624b\u52a8\u7f16\u5199\u6d4b\u8bd5\u7ed3\u679c 1. \u5982\u679c\u662f\u624b\u52a8\u7f16\u5199 result\uff0c\u4e0d\u53ef\u6709\u7a7a\u884c\uff0c\u5426\u5219\u7ed3\u679c\u5c06\u4ea7\u751f\u89e3\u6790\u9519\u8bef\u30022. \u5982\u679c\u9884\u671f\u67d0\u6761 SQL \u7684\u6267\u884c\u7ed3\u679c\u4e2d\uff0c\u5b58\u5728\u5236\u8868\u7b26\u6216\u8005\u8d85\u8fc7\u8fde\u7eed\u7684 4 \u4e2a\u7a7a\u683c\uff0c\u5219\u5728\u6d4b\u8bd5 case \u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684 SQL \u8bed\u53e5\uff0c\u5fc5\u987b\u589e\u52a0 Tag \u6807\u7b7e -- @separator:
\uff0c\u5426\u5219\u5c06\u89e3\u6790\u5931\u8d25\u3002\u4f8b\u5982\uff0c\u82e5 case \u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684 SQL \u8bed\u53e5\u542b\u8fde\u7eed 4 \u4e2a\u7a7a\u683c\uff0c\u5219\u9700\u8981\u6307\u5b9a Tag \u6807\u7b7e -- @separator:space
\uff1b\u82e5\u542b\u542b\u6709\u5236\u8868\u7b26\uff0c\u5219\u6307\u5b9a Tag \u6807\u7b7e -- @separator:table
\u3002"},{"location":"MatrixOne/Test/testing-tool/mo-tester-reference/#_1","title":"\u5728\u6d4b\u8bd5\u7528\u4f8b\u811a\u672c\u4e2d\u8bbe\u7f6e\u6807\u8bb0","text":"\u6709\u65f6\uff0c\u4e3a\u4e86\u8fbe\u5230\u7279\u5b9a\u7684\u76ee\u7684\uff0c\u5982\u6682\u505c\u6216\u521b\u5efa\u65b0\u8fde\u63a5\uff0c\u60a8\u53ef\u4ee5\u5411\u811a\u672c\u6587\u4ef6\u6dfb\u52a0\u7279\u6b8a\u7684\u6807\u8bb0\u3002Mo tester \u63d0\u4f9b\u4ee5\u4e0b\u6807\u7b7e\u4f9b\u4f7f\u7528\uff1a
\u6807\u7b7e \u8bf4\u660e -- @skip:issue#{IssueNo.} \u8bbe\u7f6e\u540e\uff0c\u6574\u4e2a\u811a\u672c\u6587\u4ef6\u5c06\u88ab\u8df3\u8fc7\uff0c\u5e76\u4e14\u4e0d\u518d\u6267\u884c issue{IssueNo.} -- @bvt:issue#{IssueNo.}-- @bvt:issue \u4e0d\u6267\u884c issue{IssueNo.} \u8fd9\u4e24\u4e2a\u6807\u8bb0\u4e4b\u95f4\u7684 sql \u8bed\u53e5\u3002 -- @sleep:{time} mo-tester \u5c06\u7b49\u5f85\u65f6\u957f{time} -- @session:id=2&user=root&password=111 -- @session mo tester \u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\u6765\u6267\u884c\u8fd9\u4e24\u4e2a\u6807\u8bb0\u4e4b\u95f4\u7684 sql \u8bed\u53e5\u3002 id \u9ed8\u8ba4\u503c\u4e3a 1\uff0c\u6700\u5927\u503c\u4e3a 10\u3002\u5728 mo.yml \u4e2d\u914d\u7f6e\u4e86\u7528\u6237\u548c\u5bc6\u7801\u7684\u9ed8\u8ba4\u503c\u3002 -- @sortkey: \u8bbe\u7f6e\u6b64\u6807\u8bb0\uff0c\u8868\u793a\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f\u3002\u4f8b\u5982:\u2014\u2014@sortkey:0,1:\u8868\u793a\u6392\u5e8f\u952e\u662f\u7b2c\u4e00\u5217\u548c\u7b2c\u4e8c\u5217\u3002"},{"location":"MatrixOne/Test/testing-tool/mo-tester/","title":"MO-Tester \u7b80\u4ecb","text":"\u4ece 0.5.0 \u7248\u672c\u5f00\u59cb\uff0cMatrixOne \u5f15\u5165\u4e86\u4e00\u4e2a\u81ea\u52a8\u6d4b\u8bd5\u6846\u67b6 MO-Tester\u3002
MO-Tester \u6d4b\u8bd5\u6846\u67b6\uff0c\u4e5f\u53ef\u4ee5\u79f0\u4f5c\u4e3a\u6d4b\u8bd5\u5668\uff0c\u662f\u901a\u8fc7 SQL \u6d4b\u8bd5 MatrixOne \u6216\u5176\u4ed6\u6570\u636e\u5e93\u529f\u80fd\u7684\u3002
MO-Tester \u662f\u57fa\u4e8e Java \u8bed\u8a00\u8fdb\u884c\u5f00\u53d1\uff0c\u7528\u4e8e MatrixOne \u7684\u6d4b\u8bd5\u5957\u4ef6\u3002MO-Tester \u6784\u5efa\u4e86\u4e00\u6574\u5957\u5b8c\u6574\u7684\u5de5\u5177\u94fe\u6765\u8fdb\u884c SQL \u81ea\u52a8\u6d4b\u8bd5\u3002\u5b83\u5305\u542b\u6d4b\u8bd5\u7528\u4f8b\u548c\u8fd0\u884c\u7ed3\u679c\u3002MO-Tester \u542f\u52a8\u540e\uff0cMO-Tester \u5c06\u4f7f\u7528 MatrixOne \u8fd0\u884c\u6240\u6709 SQL \u6d4b\u8bd5\u7528\u4f8b\uff0c\u5e76\u5c06\u6240\u6709\u8f93\u51fa SQL \u6d4b\u8bd5\u7ed3\u679c\u4e0e\u9884\u671f\u7ed3\u679c\u8fdb\u884c\u6bd4\u8f83\u3002\u6240\u6709\u6848\u4f8b\u7684\u7ed3\u679c\u65e0\u8bba\u6210\u529f\u6216\u8005\u5931\u8d25\uff0c\u90fd\u5c06\u8bb0\u5f55\u5728\u62a5\u544a\u4e2d\u3002
MO-Tester \u76f8\u5173\u7528\u4f8b\u3001\u7ed3\u679c\u548c\u62a5\u544a\u7684\u653e\u5728 MatrixOne \u4ed3\u5e93\u5185\uff0c\u94fe\u63a5\u5982\u4e0b\uff1a
Cases: https://github.com/matrixorigin/matrixone/tree/main/test/distributed/cases
Result: \u751f\u6210\u5728 /cases \u7684\u5177\u4f53\u6d4b\u8bd5\u7528\u4f8b\u4e0b\uff0c\u4f8b\u5982 /cases/auto_increment \u76ee\u5f55\u7684\u5177\u4f53\u6d4b\u8bd5\u7528\u4f8b\u540c\u7ea7\u76ee\u5f55\u4e0b\u751f\u6210\u5bf9\u5e94\u7684. result \u6587\u4ef6\u3002
Report: \u8fd0\u884c\u7ed3\u675f\u540e\uff0c\u672c\u5730\u76ee\u5f55\u81ea\u52a8\u751f\u6210 mo-tester/report
\u3002
\u6d4b\u8bd5\u7528\u4f8b\u548c\u6d4b\u8bd5\u7ed3\u679c\u4e00\u4e00\u5bf9\u5e94\u3002\u5982\u9700\u6dfb\u52a0\u65b0\u7684\u6d4b\u8bd5\u7528\u4f8b\u548c\u6d4b\u8bd5\u7ed3\u679c\u8bf7\u8fdb\u5165\u53f3\u4fa7\u6240\u793a MatrixOne \u4ed3\u5e93\u8def\u5f84\u4e2d\u8fdb\u884c\u6dfb\u52a0\uff1ahttps://github.com/matrixorigin/matrixone/tree/main/test
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#mo-tester_1","title":"\u4f7f\u7528 MO-Tester","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#1","title":"1. \u51c6\u5907\u6d4b\u8bd5\u73af\u5883","text":"\u8bf7\u5148\u786e\u8ba4\u5df2\u5b89\u88c5 jdk8\u3002
\u542f\u52a8 MatrixOne \u6216\u5176\u4ed6\u6570\u636e\u5e93\u7528\u4f8b\u3002\u53c2\u89c1\u66f4\u591a\u4fe1\u606f >>\u5b89\u88c5\u5355\u673a\u7248 MatrixOne.
\u514b\u9686 mo-tester \u4ed3\u5e93\u3002
git clone https://github.com/matrixorigin/mo-tester.git\n\u6216\u8005 \ngit clone https://githubfast.com/matrixorigin/mo-tester.git\n
git clone https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit clone https://githubfast.com/matrixorigin/matrixone.git\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#2-mo-tester","title":"2. \u914d\u7f6e MO-Tester","text":"MO-tester \u57fa\u4e8e Java \u8bed\u8a00\u8fdb\u884c\u5f00\u53d1\uff0c\u56e0\u6b64 Mo-tester \u6240\u4f9d\u8d56\u7684 Java \u6570\u636e\u5e93\u8fde\u63a5\uff08JDBC\uff0cJava Database Connectivity\uff09\u9a71\u52a8\u7a0b\u5e8f\u9700\u8981\u914d\u7f6e mo.yml \u6587\u4ef6\u91cc\u7684\u53c2\u6570\u4fe1\u606f\uff1a\u8fdb\u5165\u5230 mo-tester \u672c\u5730\u4ed3\u5e93\uff0c\u6253\u5f00 mo.yml \u6587\u4ef6\uff0c\u914d\u7f6e\u670d\u52a1\u5668\u5730\u5740\u3001\u9ed8\u8ba4\u7684\u6570\u636e\u5e93\u540d\u79f0\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u7b49\u3002
\u4ee5\u4e0b\u662f\u672c\u5730\u72ec\u7acb\u7248\u672c MatrixOne \u7684\u9ed8\u8ba4\u793a\u4f8b\u3002
#jdbc\njdbc:\n driver: \"com.mysql.cj.jdbc.Driver\"\n server:\n - addr: \"127.0.0.1:6001\"\n database:\n default: \"test\"\n paremeter:\n characterSetResults: \"utf8\"\n continueBatchOnError: \"false\"\n useServerPrepStmts: \"true\"\n alwaysSendSetIsolation: \"false\"\n useLocalSessionState: \"true\"\n zeroDateTimeBehavior: \"CONVERT_TO_NULL\"\n failoverReadOnly: \"false\"\n serverTimezone: \"Asia/Shanghai\"\n socketTimeout: 30000\n#users\nuser:\n name: \"root\"\n passwrod: \"111\"\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#3-mo-tester","title":"3. \u8fd0\u884c MO-Tester","text":"\u8fd0\u884c\u4ee5\u4e0b\u6240\u793a\u547d\u4ee4\u884c\uff0cSQL \u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\u5c06\u81ea\u52a8\u8fd0\u884c\uff0c\u5e76\u5c06\u62a5\u544a\u548c\u9519\u8bef\u6d88\u606f\u751f\u6210\u81f3 report/report.txt \u548c report/error.txt \u6587\u4ef6\u4e2d\u3002
> ./run.sh -p {path_name}/matrixone/test/cases\n
\u5982\u679c\u4f60\u60f3\u8c03\u6574\u6d4b\u8bd5\u8303\u56f4\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539 run.yml
\u6587\u4ef6\u4e2d\u7684 path
\u53c2\u6570\u3002\u6216\u8005\uff0c\u5728\u6267\u884c ./run.sh
\u547d\u4ee4\u65f6\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e9b\u53c2\u6570\uff0c\u53c2\u6570\u89e3\u91ca\u5982\u4e0b\uff1a
path
\u7684\u914d\u7f6e\u53c2\u6570 -m \u8bbe\u7f6e MO-tester \u6d4b\u8bd5\u7684\u65b9\u6cd5\uff0c\u5373\u76f4\u63a5\u8fd0\u884c\u6216\u8005\u751f\u6210\u65b0\u7684\u6d4b\u8bd5\u7ed3\u679c\u3002\u9ed8\u8ba4\u503c\u53ef\u4ee5\u53c2\u89c1 run.yaml \u6587\u4ef6\u4e2d method
\u7684\u914d\u7f6e\u53c2\u6570 -t \u8bbe\u7f6e MO-tester \u6267\u884c SQL \u547d\u4ee4\u7684\u683c\u5f0f\u7c7b\u578b\u3002\u9ed8\u8ba4\u503c\u53ef\u4ee5\u53c2\u89c1 run.yml \u6587\u4ef6\u4e2d type
\u7684\u914d\u7f6e\u53c2\u6570\u3002 -r \u8bbe\u7f6e\u6d4b\u8bd5\u7528\u4f8b\u5e94\u8be5\u8fbe\u5230\u7684\u6210\u529f\u7387\u3002\u9ed8\u8ba4\u503c\u53ef\u4ee5\u53c2\u89c1 run.yml \u6587\u4ef6\u4e2d rate
\u7684\u914d\u7f6e\u53c2\u6570\u3002 -i \u8bbe\u7f6e\u5305\u542b\u5217\u8868\uff0c\u53ea\u6709\u8def\u5f84\u4e2d\u540d\u79f0\u5305\u542b\u5176\u4e2d\u4e00\u4e2a\u5217\u8868\u7684\u811a\u672c\u6587\u4ef6\u5c06\u88ab\u6267\u884c\uff0c\u5982\u679c\u6709\u591a\u4e2a\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a\uff0c\u7528'\uff0c'\u5206\u9694\uff0c\u6307\u7684\u662f\u5305\u542b\u7684\u6240\u6709\u60c5\u51b5 set the including list, and only script files in the path whose name contains one of the lists will be executed, if more than one, separated by ,
, if not specified, refers to all cases included -e \u8bbe\u7f6e\u6392\u9664\u5217\u8868\uff0c\u5982\u679c\u8def\u5f84\u4e0b\u7684\u811a\u672c\u6587\u4ef6\u7684\u540d\u79f0\u5305\u542b\u4e00\u4e2a\u6392\u9664\u5217\u8868\uff0c\u5219\u4e0d\u4f1a\u88ab\u6267\u884c\uff0c\u5982\u679c\u6709\u591a\u4e2a\uff0c\u7528','\u5206\u9694\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9a\uff0c\u8868\u793a\u4e0d\u6392\u9664\u4efb\u4f55\u60c5\u51b5 set the excluding list, and script files in the path whose name contains one of the lists will not be executed, if more than one, separated by ,
, if not specified, refers to none of the cases excluded -g \u8868\u793a\u5e26\u6709[-- @bvt:issue#{issueNO.}]\u6807\u5fd7\u7684 SQL \u547d\u4ee4\u5c06\u4e0d\u4f1a\u88ab\u6267\u884c\uff0c\u8be5\u6807\u5fd7\u4ee5 [-- @bvt:issue#{issueNO.}]\u5f00\u59cb\uff0c\u4ee5 [-- @bvt:issue]\u7ed3\u675f\u3002\u4f8b\u5982\uff0c-- @bvt:issue#3236select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-10000:1\" HOUR_MINUTE);select date_add(\"1997-12-31 23:59:59\",INTERVAL \"-100 1\" YEAR_MONTH);-- @bvt:issue\u8fd9\u4e24\u4e2a SQL \u547d\u4ee4\u4e0e\u95ee\u9898 #3236 \u76f8\u5173\u8054\uff0c\u5b83\u4eec\u5c06\u4e0d\u4f1a\u5728 MO-tester \u6d4b\u8bd5\u4e2d\u6267\u884c\uff0c\u76f4\u5230\u95ee\u9898 #3236 \u4fee\u590d\u540e\u6807\u7b7e\u79fb\u9664\u624d\u53ef\u4ee5\u5728\u6d4b\u8bd5\u4e2d\u6267\u884c\u3002 -n \u8868\u793a\u5728\u6bd4\u8f83\u7ed3\u679c\u65f6\u5c06\u5ffd\u7565\u7ed3\u679c\u96c6\u7684\u5143\u6570\u636e -c \u53ea\u9700\u8981\u68c0\u67e5 case \u6587\u4ef6\u4e0e result \u6587\u4ef6\u662f\u5426\u5339\u914d \u793a\u4f8b\uff1a
./run.sh -p {path_name}/matrixone/test/cases -m run -t script -r 100 -i select,subquery -e substring -g\n
\u5982\u679c\u4f60\u60f3\u6d4b\u8bd5\u65b0\u7684 SQL \u7528\u4f8b\u5e76\u81ea\u52a8\u751f\u6210 SQL \u7ed3\u679c\uff0c\u8fd0\u884c\u547d\u4ee4\u4e2d\u53ef\u4ee5\u5c06 -m run
\u66f4\u6539\u4e3a -m genrs
\uff0c\u6216\u8005\u5c06 run.yml \u6587\u4ef6\u91cc\u7684 method
\u53c2\u6570\u4fee\u6539\u4e3a genrs
\uff0c\u4e14. result \u6587\u4ef6\u5c06\u751f\u6210\u5728\u4e0e\u8fd9\u4e2a\u65b0\u7684 SQL \u7528\u4f8b\u540c\u7ea7\u76ee\u5f55\u5185\uff0c\u76f8\u5173\u793a\u4f8b\u53c2\u89c1
\u793a\u4f8b 4
Note
\u6bcf\u6b21\u8fd0\u884c ./run.sh
\u90fd\u4f1a\u8986\u76d6 mo-tester \u4ed3\u5e93\u5185 report/ \u8def\u5f84\u4e0b error.txt\u3001report.txt \u548c success.txt \u62a5\u544a\u6587\u4ef6\u3002
\u6d4b\u8bd5\u5b8c\u6210\u540e\uff0cmo-tester \u4ed3\u5e93\u5185\u5c06\u751f\u6210 error.txt\u3001report.txt \u548c success.txt \u62a5\u544a\u6587\u4ef6\u3002
[SUMMARY] COST : 98s, TOTAL :12702, SUCCESS : 11851, FAILED :13, IGNORED :838, ABNORAML :0, SUCCESS RATE : 99%\n[{path_name}/matrixone/test/cases/auto_increment/auto_increment_columns.sql] COST : 2.159s, TOTAL :185, SUCCESS :163, FAILED :0, IGNORED :22, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/01_DDL/01_create_table.sql] COST : 0.226s, TOTAL :11, SUCCESS :11, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/benchmark/tpch/02_LOAD/02_insert_customer.sql] COST : 0.357s, TOTAL :16, SUCCESS :16, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
\u62a5\u544a\u5173\u952e\u8bcd \u89e3\u91ca TOTAL \u6267\u884c\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570 SUCCESS \u6267\u884c\u6210\u529f\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570 FAILED \u6267\u884c\u5931\u8d25\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570 IGNORED \u5ffd\u7565\u6267\u884c\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570\uff0c\u7279\u6307\u5177\u6709 --bvt:issue
\u6807\u7b7e\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09 ABNORAML \u6267\u884c\u5f02\u5e38\u7684\u6d4b\u8bd5\u7528\u4f8b\uff08SQL \u8bed\u53e5\uff09\u603b\u6570\uff0c\u6bd4\u5982\u6267\u884c\u8fc7\u7a0b\u4e2d\u88ab\u7cfb\u7edf\u5f02\u5e38\u5bfc\u81f4 MO \u65e0\u6cd5\u5224\u65ad\u5b9e\u9645\u7ed3\u679c\uff0c\u6216\u8005 .result \u6587\u4ef6\u89e3\u6790\u5931\u8d25\u7b49 SUCCESS RATE \u6210\u529f\u7387\uff0c\u5373 SUCCESS/(TOTAL - IGNORED) [ERROR]\n[SCRIPT FILE]: cases/transaction/atomicity.sql\n[ROW NUMBER]: 14\n[SQL STATEMENT]: select * from test_11 ;\n[EXPECT RESULT]:\nc d\n1 1\n2 2\n[ACTUAL RESULT]:\nc d\n1 1\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#5","title":"5. \u6d4b\u8bd5\u793a\u4f8b","text":""},{"location":"MatrixOne/Test/testing-tool/mo-tester/#1_1","title":"\u793a\u4f8b 1","text":"\u793a\u4f8b\u63cf\u8ff0\uff1a\u8fd0\u884c matrixone \u4ed3\u5e93\u5185\u7684 test/cases \u8def\u5f84\u4e0b\u7684\u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\u3002
\u6b65\u9aa4\uff1a
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases\n
\u793a\u4f8b\u63cf\u8ff0\uff1a\u8fd0\u884c matrixone \u4ed3\u5e93\u5185 /cases/transaction/ \u8def\u5f84\u4e0b\u7684\u6d4b\u8bd5\u7528\u4f8b\u3002
\u6b65\u9aa4\uff1a
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/\n
[SUMMARY] COST : 5s, TOTAL :1362, SUCCESS : 1354, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.575s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit.test] COST : 0.175s, TOTAL :50, SUCCESS :50, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_1.sql] COST : 1.141s, TOTAL :296, SUCCESS :288, FAILED :0, IGNORED :8, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_atomicity.sql] COST : 0.52s, TOTAL :75, SUCCESS :75, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation.sql] COST : 1.607s, TOTAL :215, SUCCESS :215, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/autocommit_isolation_1.sql] COST : 1.438s, TOTAL :241, SUCCESS :241, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation.sql] COST : 1.632s, TOTAL :202, SUCCESS :202, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/isolation_1.sql] COST : 1.512s, TOTAL :217, SUCCESS :217, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#3","title":"\u793a\u4f8b 3","text":"\u793a\u4f8b\u63cf\u8ff0\uff1a\u8fd0\u884c matrixone \u4ed3\u5e93\u5185 cases/transaction/atomicity.sql \u5355\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u3002
\u6b65\u9aa4\uff1a
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/transaction/atomicity.sql\n
[SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#4_1","title":"\u793a\u4f8b 4","text":"\u793a\u4f8b\u63cf\u8ff0\uff1a
\u6b65\u9aa4
cd matrixone\ngit pull https://github.com/matrixorigin/matrixone.git\n\u6216\u8005\ngit pull https://githubfast.com/matrixorigin/matrixone.git\n
\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\uff1a
cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql -m genrs -g\n
run
\u4fee\u6539\u4e3a genrs
\uff0c\u7136\u540e\u8fd0\u884c\u5982\u4e0b\u547d\u4ee4\uff0c\u751f\u6210\u6d4b\u8bd5\u7ed3\u679c\u3002cd mo-tester\n./run.sh -p {path_name}/matrixone/test/cases/local_test/new_test.sql\n
\u5728 matrixone \u4ed3\u5e93\u5185 test/cases/local_test/ \u8def\u5f84\u4e0b\u67e5\u770b new_test.result \u7ed3\u679c\u3002
\u5728 mo-tester \u4ed3\u5e93\u5185 report/ \u8def\u5f84\u4e0b\u7684 error.txt\u3001report.txt \u548c success.txt \u62a5\u544a\u6587\u4ef6\u4e2d\u67e5\u770b\u8fd0\u884c\u7ed3\u679c\u3002\u4f8b\u5982\uff0creport.txt \u4e2d\u7ed3\u679c\u5982\u4e0b\u6240\u793a\uff1a
[SUMMARY] COST : 0s, TOTAL :66, SUCCESS : 66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n[{path_name}/matrixone/test/cases/transaction/atomicity.sql] COST : 0.56s, TOTAL :66, SUCCESS :66, FAILED :0, IGNORED :0, ABNORAML :0, SUCCESS RATE : 100%\n
"},{"location":"MatrixOne/Test/testing-tool/mo-tester/#_1","title":"\u53c2\u8003\u6587\u6863","text":"\u66f4\u591a\u5173\u4e8e MO-Tester \u6d4b\u8bd5\u5de5\u5177\u7684\u6ce8\u89e3\u4ee5\u53ca\u6d4b\u8bd5\u7528\u4f8b\u7f16\u5199\u89c4\u8303\uff0c\u53c2\u89c1 MO-Tester \u89c4\u8303\u8981\u6c42\u3002
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/","title":"\u5e38\u7528\u7edf\u8ba1\u6570\u636e\u67e5\u8be2","text":"\u7edf\u8ba1\u6570\u636e\u662f\u6570\u636e\u5e93\u5728\u8fd0\u7ef4\u4f7f\u7528\u7684\u8fc7\u7a0b\u4e2d\u5468\u671f\u6027\u8fdb\u884c\u7684\u5e38\u7528\u67e5\u8be2\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6570\u636e\u5e93\u7528\u6237\u8f83\u4e3a\u76f4\u89c2\u51c6\u786e\u5730\u638c\u63e1\u5f53\u524d\u6570\u636e\u5e93\u7684\u72b6\u6001\u4ee5\u53ca\u5065\u5eb7\u7a0b\u5ea6\u3002
\u5728 MatrixOne \u4e2d\uff0c\u7edf\u8ba1\u6570\u636e\u5305\u542b\u4e86\u5982\u4e0b\u51e0\u65b9\u9762\u7684\u5185\u5bb9\uff1a
> select md.datname as database_name,md.created_time as created_time,mu.user_name as creator, mr.role_name as owner_role, count(mt.reldatabase) as total_tables\nfrom mo_catalog.mo_database md,mo_catalog.mo_role mr, mo_catalog.mo_user mu, mo_catalog.mo_tables mt\nwhere md.creator=mu.user_id and md.owner=mr.role_id and mt.reldatabase_id=md.dat_id\ngroup by mt.reldatabase,md.datname,md.created_time,mu.user_name,mr.role_name\norder by md.created_time asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_3","title":"\u67e5\u770b\u6240\u6709\u7684\u81ea\u589e\u5217\u76f8\u5173\u4fe1\u606f","text":"> select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_is_auto_increment=1\norder by att_database, att_relname asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_4","title":"\u67e5\u770b\u6240\u6709\u89c6\u56fe","text":"> select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='v' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_5","title":"\u67e5\u770b\u6240\u6709\u5916\u90e8\u8868","text":"> select mt.relname as view_name, mt.reldatabase as database_name,mu.user_name as created_user,mr.role_name as owner_role,mt.created_time\nfrom mo_catalog.mo_tables mt, mo_catalog.mo_user mu, mo_catalog.mo_role mr\nwhere mt.relkind='e' and mt.creator=mu.user_id and mt.owner=mr.role_id\norder by 1,2 asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_6","title":"\u67e5\u770b\u6240\u6709\u8868\u7684\u4e3b\u952e","text":"> select att_database as database_name,att_relname as table_name,attname as column_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p' and att_relname not like '%!%'\norder by att_database, att_relname asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_7","title":"\u67e5\u770b\u6240\u6709\u6ca1\u6709\u4e3b\u952e\u7684\u8868","text":"> select distinct att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nminus\nselect att_database as database_name,att_relname as table_name\nfrom mo_catalog.mo_columns\nwhere att_constraint_type='p'\norder by database_name,table_name asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#24-sql-sys","title":"\u67e5\u770b\u8fc7\u53bb 24 \u5c0f\u65f6\u5185\u7684 sql \u7edf\u8ba1\uff08\u975e sys \u79df\u6237\u6682\u4e0d\u652f\u6301\uff09","text":"> select user,host,status,count(status) as count, date_sub(now(), interval 24 hour) as start_time, now() as end_time\nfrom system.statement_info\nwhere status in ('Success','Failed') and user <> 'internal'\nand request_at between date_sub(now(), interval 24 hour) and now()\ngroup by status,user,host\norder by user,status asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_8","title":"\u67e5\u770b\u6240\u6709\u89d2\u8272\u6388\u4e88\u7528\u6237\u4fe1\u606f","text":"> select mu.user_name as user_name,mr.role_name as role_name,mug.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr, mo_catalog.mo_user_grant mug\nwhere mu.user_id=mug.user_id and mr.role_id=mug.role_id\norder by mu.user_name,mr.role_name asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_9","title":"\u67e5\u770b\u6240\u6709\u89d2\u8272\u6743\u9650\u4fe1\u606f","text":"> select mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,md.datname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_database md\nwhere mrp.obj_id=md.dat_id and mrp.obj_type='database'\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,'*',with_grant_option\nfrom mo_catalog.mo_role_privs mrp\nwhere obj_id=0\nunion\nselect mrp.role_name,mrp.privilege_name,mrp.obj_type,mrp.privilege_level,mt.relname as object_name,with_grant_option\nfrom mo_catalog.mo_role_privs mrp, mo_catalog.mo_tables mt\nwhere mrp.obj_id=mt.rel_id and mrp.obj_type='table'\norder by 1,2 asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_10","title":"\u67e5\u770b\u6240\u6709\u89d2\u8272\u7ee7\u627f\u4fe1\u606f","text":"> select mr1.role_name as inheritor_role,mr2.role_name as inheritee_role,mu.user_name as operator_user,mrg.granted_time,mrg.with_grant_option\nfrom mo_catalog.mo_user mu, mo_catalog.mo_role mr1, mo_catalog.mo_role mr2,mo_catalog.mo_role_grant mrg\nwhere mu.user_id=mrg.operation_user_id and mr1.role_id=mrg.grantee_id and mr2.role_id=mrg.granted_id\norder by mr1.role_name,mr2.role_name asc;\n
"},{"location":"MatrixOne/Troubleshooting/common-statistics-query/#_11","title":"\u53c2\u8003\u6587\u6863","text":"\u672c\u7bc7\u6587\u7ae0\u4e2d\u6240\u67e5\u8be2\u7684 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u662f MatrixOne \u5b58\u50a8\u7cfb\u7edf\u4fe1\u606f\u7684\u5730\u65b9\u3002\u5982\u679c\u4f60\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u89c1 MatrixOne \u7cfb\u7edf\u6570\u636e\u5e93\u548c\u8868\u3002
"},{"location":"MatrixOne/Troubleshooting/error-code/","title":"\u9519\u8bef\u7801","text":"\u5728 MatrixOne \u4e2d\uff0c\u9519\u8bef\u4fe1\u606f\u662f\u6839\u636e\u9519\u8bef\u7f16\u7801\u8fdb\u884c\u5206\u7c7b\uff0c\u67d0\u4e00\u7c7b\u7684\u9519\u8bef\u7f16\u7801\u4f1a\u7edf\u4e00\u81f3\u4e00\u4e2a\u786e\u5b9a\u7684\u9519\u8bef\u7f16\u7801\u4e2d\uff0c\u4ee5\u4fbf\u4e8e\u7528\u6237\u8fdb\u884c\u6392\u67e5\u3002MatrixOne \u6570\u636e\u5e93\u670d\u52a1\u6240\u53d1\u51fa\u7684\u6240\u6709\u6d88\u606f\u90fd\u5206\u914d\u6709\u4e94\u4e2a\u5b57\u7b26\u7684\u9519\u8bef\u4ee3\u7801\uff0c\u65e2\u5305\u542b\u4e86\u9519\u8bef\u7f16\u7801\u7684\u79cd\u7c7b\uff0c\u53c8\u5305\u542b\u4e86\u9519\u8bef\u7f16\u7801\u7684\u5177\u4f53\u7c7b\u522b\u3002
\u5b9e\u9645\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f18\u5148\u67e5\u770b\u9519\u8bef\u7f16\u7801\uff0c\u642d\u914d\u9519\u8bef\u7f16\u7801\u9644\u5e26\u7684\u6587\u672c\u9519\u8bef\u6d88\u606f\uff0c\u6765\u786e\u5b9a\u53d1\u751f\u4e86\u54ea\u79cd\u9519\u8bef\u60c5\u51b5\u3002\u9519\u8bef\u7f16\u7801\u4e0d\u4f1a\u53d1\u751f\u8de8\u7248\u672c\u66f4\u6539\uff0c\u5e76\u4e14\u4e5f\u4e0d\u4f1a\u56e0\u9519\u8bef\u6d88\u606f\u7684\u672c\u5730\u5316\u800c\u53d1\u751f\u66f4\u6539\u3002
Note
MatrixOne \u751f\u6210\u7684\u4e00\u90e8\u5206\u9519\u8bef\u7f16\u7801\u662f\u7531 SQL \u6807\u51c6\u5b9a\u4e49\u7684\uff1b\u4e00\u4e9b\u672a\u88ab\u6807\u51c6\u5b9a\u4e49\u7684\u6761\u4ef6\u7684\u989d\u5916\u9519\u8bef\u7f16\u7801\u662f\u4ece\u5176\u4ed6\u6570\u636e\u5e93\u4e2d\u53d1\u660e\u6216\u501f\u7528\u7684\u3002
\u9519\u8bef\u7f16\u7801\u5f00\u5934 \u7c7b\u578b 201 \u5185\u90e8\u9519\u8bef 202 \u6570\u5b57\u4e0e\u51fd\u6570\u9519\u8bef 203 \u65e0\u6548\u64cd\u4f5c 204 \u672a\u77e5\u9519\u8bef\u6216 IO \u9519\u8bef 205 RPC \u8d85\u65f6 206 \u4e8b\u52a1\u9519\u8bef\u6216\u5b58\u50a8\u5f15\u64ce\u9519\u8bef\u8be6\u7ec6\u9519\u8bef\u7801\u5bf9\u5e94\u7684\u9519\u8bef\u4fe1\u606f\u53ca\u9519\u8bef\u8be6\u60c5\u8bf7\u53c2\u89c1\u4e0b\u8868\uff1a
\u9519\u8bef\u7801 \u9519\u8bef\u4fe1\u606f \u9519\u8bef\u8be6\u60c5 \u9519\u8bef\u5206\u7c7b 20100 ErrStart internal error code start \u5185\u90e8\u9519\u8bef 20101 ErrInternal Internal error \u5185\u90e8\u9519\u8bef 20103 ErrNYI not yet implemented \u5185\u90e8\u9519\u8bef 20104 ErrOOM out of memory \u5185\u90e8\u9519\u8bef 20105 ErrQueryInterrupted query interrupted \u5185\u90e8\u9519\u8bef 20106 ErrNotSupported not supported \u5185\u90e8\u9519\u8bef 20200 ErrDivByZero division by zero \u6570\u5b57\u4e0e\u51fd\u6570 20201 ErrOutOfRange data out of range \u6570\u5b57\u4e0e\u51fd\u6570 20202 ErrDataTruncated data truncated \u6570\u5b57\u4e0e\u51fd\u6570 20203 ErrInvalidArg invalid argument \u6570\u5b57\u4e0e\u51fd\u6570 20204 ErrTruncatedWrongValueForField truncated wrong value for column \u6570\u5b57\u4e0e\u51fd\u6570 20300 ErrBadConfig invalid configuration \u65e0\u6548\u64cd\u4f5c 20301 ErrInvalidInput invalid input \u65e0\u6548\u64cd\u4f5c 20302 ErrSyntaxError SQL syntax error \u65e0\u6548\u64cd\u4f5c 20303 ErrParseError SQL parser error \u65e0\u6548\u64cd\u4f5c 20304 ErrConstraintViolation constraint violation \u65e0\u6548\u64cd\u4f5c 20305 ErrDuplicate tae data duplicated \u65e0\u6548\u64cd\u4f5c 20306 ErrRoleGrantedToSelf cannot grant role \u65e0\u6548\u64cd\u4f5c 20307 ErrDuplicateEntry duplicate entry for key \u65e0\u6548\u64cd\u4f5c 20400 ErrInvalidState invalid state \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20401 ErrLogServiceNotReady log service not ready \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20402 ErrBadDB invalid database \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20403 ErrNoSuchTable no such table \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20404 ErrEmptyVector empty vector \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20405 ErrFileNotFound file is not found \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20406 ErrFileAlreadyExists file alread exists \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20407 ErrUnexpectedEOF unexpteded end of file \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20408 ErrEmptyRange empty range of file \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20409 ErrSizeNotMatch file size does not match \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20410 ErrNoProgress file has no io progress \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20411 ErrInvalidPath invalid file path \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20412 ErrShortWrite file io short write \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20413 ErrInvalidWrite file io invalid write \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20414 ErrShortBuffer file io short buffer \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20415 ErrNoDB not connect to a database \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20416 ErrNoWorkingStore no working store \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20417 ErrNoHAKeeper cannot locate ha keeper \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20418 ErrInvalidTruncateLsn invalid truncate lsn, shard already truncated \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20419 ErrNotLeaseHolder not lease holder, current lease holder ID xxx \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20420 ErrDBAlreadyExists database already exists \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20421 ErrTableAlreadyExists table already exists \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20422 ErrNoService service not found \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20423 ErrDupServiceName duplicate service name \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20424 ErrWrongService wrong service, expecting A, got B \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20425 ErrBadS3Config bad s3 config \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20426 ErrBadView invalid view \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20427 ErrInvalidTask invalid task \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20428 ErrInvalidServiceIndex invalid service idx \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20429 ErrDragonboatTimeout Dragonboat timeout \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20430 ErrDragonboatTimeoutTooSmall Dragonboat timeout too small \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20431 ErrDragonboatInvalidDeadline Dragonboat invalid deadline \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20432 ErrDragonboatRejected Dragonboat rejected \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20433 ErrDragonboatInvalidPayloadSize invalid payload size \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20434 ErrDragonboatShardNotReady shard not ready \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20435 ErrDragonboatSystemClosed Dragonboat system closed \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20436 ErrDragonboatInvalidRange Dragonboat invalid range \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20437 ErrDragonboatShardNotFound shard not found \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20438 ErrDragonboatOtherSystemError other system error \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20439 ErrDropNonExistsDB Can't drop database ; database doesn't exist \u672a\u77e5\u72b6\u6001\u6216 I/O \u9519\u8bef 20500 ErrRPCTimeout rpc timeout RPC \u8d85\u65f6 20501 ErrClientClosed client closed RPC \u8d85\u65f6 20502 ErrBackendClosed backend closed RPC \u8d85\u65f6 20503 ErrStreamClosed stream closed RPC \u8d85\u65f6 20504 ErrNoAvailableBackend no available backend RPC \u8d85\u65f6 20600 ErrTxnClosed the transaction has been committed or aborted \u4e8b\u52a1 20601 ErrTxnWriteConflict transaction write conflict \u4e8b\u52a1 20602 ErrMissingTxn missing transaction \u4e8b\u52a1 20603 ErrUnresolvedConflict unresolved conflict \u4e8b\u52a1 20604 ErrTxnError transaction error \u4e8b\u52a1 20605 ErrDNShardNotFound TN shard not found \u4e8b\u52a1 20606 ErrShardNotReported TN shard not reported \u4e8b\u52a1 20607 ErrTAEError tae error TAE \u9519\u8bef 20608 ErrTAERead tae read error TAE \u9519\u8bef 20609 ErrRpcError rpc error TAE \u9519\u8bef 20610 ErrWaitTxn transaction wait error TAE \u9519\u8bef 20611 ErrTxnNotFound transaction not found TAE \u9519\u8bef 20612 ErrTxnNotActive transaction not active TAE \u9519\u8bef 20613 ErrTAEWrite tae write error TAE \u9519\u8bef 20614 ErrTAECommit tae commit error TAE \u9519\u8bef 20615 ErrTAERollback tae rollback error TAE \u9519\u8bef 20616 ErrTAEPrepare tae prepare error TAE \u9519\u8bef 20617 ErrTAEPossibleDuplicate tae possible duplicate TAE \u9519\u8bef 20618 ErrTxnRWConflict r-w conflict TAE \u9519\u8bef 20619 ErrTxnWWConflict w-w conflict TAE \u9519\u8bef 20620 ErrNotFound transaction not found TAE \u9519\u8bef 20621 ErrTxnInternal transaction internal error TAE \u9519\u8bef 20622 ErrTxnReadConflict transaction read conflict TAE \u9519\u8bef 20623 ErrPrimaryKeyDuplicated duplicated primary key TAE \u9519\u8bef 20624 ErrAppendableSegmentNotFound appendable segment not found TAE \u9519\u8bef 20625 ErrAppendableBlockNotFound appendable block not found TAE \u9519\u8bef 20626 ErrTAEDebug TAE debug TAE \u9519\u8bef"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/","title":"MatrixOne \u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f","text":"MatrixOne \u6570\u636e\u5e93\u7edf\u8ba1\u4fe1\u606f\u662f\u6307\u6570\u636e\u5e93\u901a\u8fc7\u91c7\u6837\u3001\u7edf\u8ba1\u51fa\u6765\u7684\u8868\u3001\u5217\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u4f8b\u5982\uff0c\u8868\u7684\u4e2a\u6570\u3001\u8868\u7684\u5217\u6570\u3001\u8868\u6240\u5360\u7684\u5b58\u50a8\u7a7a\u95f4\u7b49\u3002MatrixOne \u6570\u636e\u5e93\u5728\u751f\u6210\u6267\u884c\u8ba1\u5212\u65f6\uff0c\u9700\u8981\u6839\u636e\u7edf\u8ba1\u4fe1\u606f\u8fdb\u884c\u4f30\u7b97\uff0c\u8ba1\u7b97\u51fa\u6700\u4f18\u7684\u6267\u884c\u8ba1\u5212\u3002
MatrixOne \u6570\u636e\u5e93\u7684\u7edf\u8ba1\u4fe1\u606f\u7ef4\u5ea6\u5982\u4e0b\uff1a
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_1","title":"\u67e5\u770b\u6570\u636e\u5e93\u4e0b\u8868\u7684\u4e2a\u6570","text":"\u901a\u8fc7\u8be5\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u6307\u5b9a\u6570\u636e\u5e93\u4e0b\u8868\u7684\u603b\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
SHOW TABLE_NUMBER FROM {DATABASE_NAME}\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_2","title":"\u793a\u4f8b","text":"mysql> show table_number from mo_catalog;\n+--------------------------------+\n| Number of tables in mo_catalog |\n+--------------------------------+\n| 11 |\n+--------------------------------+\n\n-- \u9a8c\u8bc1\u4e00\u4e0b\u662f\u54ea\u4e9b\u8868\nmysql> use mo_catalog;\nmysql> show tables;\n+----------------------------+\n| Tables_in_mo_catalog |\n+----------------------------+\n| mo_user |\n| mo_account |\n| mo_role |\n| mo_user_grant |\n| mo_role_grant |\n| mo_role_privs |\n| mo_user_defined_function |\n| mo_columns |\n| mo_mysql_compatbility_mode |\n| mo_tables |\n| mo_database |\n+----------------------------+\n11 rows in set (0.01 sec)\n
create database demo_1;\nuse demo_1;\n-- \u521b\u5efa\u4e09\u4e2a\u65b0\u7684\u8868\nCREATE TABLE t1(a bigint, b varchar(10), c varchar(10));\nCREATE TABLE t2(a bigint, b int);\nCREATE TABLE t3(a int, b varchar(10), c varchar(10));\n\n-- \u67e5\u8be2\u51fa\u6570\u636e\u5e93 demo_1 \u4e2d\u6709\u4e09\u4e2a\u8868\nmysql> show table_number from demo_1;\n+----------------------------+\n| Number of tables in demo_1 |\n+----------------------------+\n| 3 |\n+----------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_3","title":"\u67e5\u770b\u8868\u62e5\u6709\u7684\u5217\u6570","text":"\u901a\u8fc7\u8be5\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u6307\u5b9a\u8868\u7684\u603b\u5217\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
SHOW COLUMN_NUMBER FROM {[DATABASE_NAME.]TABLE_NAME}\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_4","title":"\u793a\u4f8b","text":"use mo_catalog;\nuse mo_user;\nmysql> show column_number from mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n| 11 |\n+------------------------------+\n\n-- \u6216\u8005\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\nmysql> show column_number from mo_catalog.mo_user;\n+------------------------------+\n| Number of columns in mo_user |\n+------------------------------+\n| 11 |\n+------------------------------+\n\n-- \u67e5\u770b\u9a8c\u8bc1\u6709\u54ea\u4e9b\u5217\nmysql> desc mo_catalog.mo_user;\n+-----------------------+--------------+------+------+---------+-------+---------+\n| Field | Type | Null | Key | Default | Extra | Comment |\n+-----------------------+--------------+------+------+---------+-------+---------+\n| user_id | INT | YES | | NULL | | |\n| user_host | VARCHAR(100) | YES | | NULL | | |\n| user_name | VARCHAR(300) | YES | | NULL | | |\n| authentication_string | VARCHAR(100) | YES | | NULL | | |\n| status | VARCHAR(8) | YES | | NULL | | |\n| created_time | TIMESTAMP | YES | | NULL | | |\n| expired_time | TIMESTAMP | YES | | NULL | | |\n| login_type | VARCHAR(16) | YES | | NULL | | |\n| creator | INT | YES | | NULL | | |\n| owner | INT | YES | | NULL | | |\n| default_role | INT | YES | | NULL | | |\n+-----------------------+--------------+------+------+---------+-------+---------+\n11 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_5","title":"\u67e5\u770b\u8868\u4e2d\u6240\u6709\u5217\u5305\u542b\u7684\u6700\u5927\u4e0e\u6700\u5c0f\u503c","text":"\u901a\u8fc7\u8be5\u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u6307\u5b9a\u8868\u4e2d\u7684\u6bcf\u4e00\u5217\u7684\u6700\u5927\u503c\u4e0e\u6700\u5c0f\u503c\u3002
Note: \u5982\u679c\u6307\u5b9a\u8868\u4e2d\u5404\u5217\u503c\u7684\u6570\u636e\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0c\u5219\u6392\u5e8f\u89c4\u5219\u4e3a\uff1a\u6309\u7167\u6570\u5b57\u7684\u5927\u5c0f\u6392\u5e8f\uff1b\u65e5\u671f\u6309\u7167\u65f6\u95f4\u5148\u540e\u6392\u5e8f\uff1b\u5b57\u7b26\u7c7b\u6309\u7167 ASCII \u7801\u6392\u5e8f\uff1b\u5f53\u51e0\u79cd\u6570\u636e\u7c7b\u578b\u6df7\u5408\u6392\u5e8f\u65f6\uff0c\u975e\u5b57\u7b26\u7c7b\u578b\u7684\u5219\u5148\u8f6c\u6362\u4e3a\u5b57\u7b26\u7c7b\u578b\uff0c\u7136\u540e\u6309 ASCII \u7801\u6392\u5e8f\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
SHOW TABLE_VALUES FROM {[DATABASE_NAME.]TABLE_NAME}\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_6","title":"\u793a\u4f8b","text":"create table t1(\ncol1 int,\ncol2 float,\ncol3 varchar\n);\ninsert into t1 values(1,1.11,'1.111'),(2,2.22,'1.222'),(3,0,'abc');\n\nmysql> show table_values from t1;\n+-----------+-----------+-----------+-----------+-----------+-----------+\n| max(col1) | min(col1) | max(col2) | min(col2) | max(col3) | min(col3) |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n| 3 | 1 | 2.22 | 0 | abc | 1.111 |\n+-----------+-----------+-----------+-----------+-----------+-----------+\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_7","title":"\u67e5\u770b\u8868\u4e2d\u7684\u6570\u636e\u603b\u884c\u6570","text":"\u901a\u8fc7\u8c03\u7528\u8be5\u51fd\u6570\uff0c\u5373\u53ef\u83b7\u5f97\u6570\u636e\u5e93\u4e2d\u67d0\u5f20\u8868\u7684\u6570\u636e\u603b\u884c\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
MO_TABLE_ROWS({DATABASE_NAME},{TABLE_NAME})\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_8","title":"\u793a\u4f8b","text":"-- \u67e5\u8be2\u6570\u636e\u5e93 mo_catalog \u4e0b\u8868 mo_tables \u7684\u603b\u884c\u6570\nmysql> select mo_table_rows('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_rows(mo_catalog, mo_tables) |\n+--------------------------------------+\n| 64 |\n+--------------------------------------+\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_9","title":"\u67e5\u770b\u8868\u5728\u5b58\u50a8\u4e2d\u5360\u7528\u7684\u7a7a\u95f4","text":"\u901a\u8fc7\u8c03\u7528\u8be5\u51fd\u6570\uff0c\u5373\u53ef\u83b7\u5f97\u6570\u636e\u5e93\u4e2d\u67d0\u5f20\u8868\u5360\u7528\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5355\u4f4d\u662f\u5b57\u8282\u6570\u3002
\u8bed\u6cd5\u7ed3\u6784\uff1a
MO_TABLE_SIZE({DATABASE_NAME},{TABLE_NAME})\n
"},{"location":"MatrixOne/Troubleshooting/query-table-statistics/#_10","title":"\u793a\u4f8b","text":"-- \u67e5\u8be2\u6570\u636e\u5e93 mo_catalog \u4e0b\u8868 mo_tables \u5360\u7528\u7684\u5b58\u50a8\u7a7a\u95f4\nmysql> select mo_table_size('mo_catalog','mo_tables');\n+--------------------------------------+\n| mo_table_size(mo_catalog, mo_tables) |\n+--------------------------------------+\n| 16128 |\n+--------------------------------------+\n
"},{"location":"MatrixOne/Troubleshooting/slow-queries/","title":"\u6162\u67e5\u8be2","text":"\u6162\u67e5\u8be2\uff0c\u5373\u5728\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u8fd0\u884c\u6bd4\u8f83\u6162\u7684 SQL \u8bed\u53e5\u3002\u6162\u67e5\u8be2\u8bb0\u5f55\u5728\u6162\u67e5\u8be2\u65e5\u5fd7\u4e2d\uff0c\u901a\u8fc7\u6162\u67e5\u8be2\u65e5\u5fd7\uff0c\u53ef\u4ee5\u67e5\u627e\u51fa\u54ea\u4e9b\u67e5\u8be2\u8bed\u53e5\u7684\u6267\u884c\u6548\u7387\u4f4e\uff0c\u4ee5\u4fbf\u8fdb\u884c\u4f18\u5316\u3002
\u5f53\u524d MatrixOne \u7684\u6162\u67e5\u8be2\u662f\u8d85\u8fc7 1000 \u6beb\u79d2\u7684\u67e5\u8be2\uff0c\u6682\u4e0d\u652f\u6301\u5b9a\u5411\u8f93\u51fa\u5230\u5bf9\u5e94\u7684\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u901a\u8fc7\u521b\u5efa\u89c6\u56fe\u7684\u65b9\u5f0f\u8fdb\u884c\u8fc7\u6ee4\u83b7\u53d6\u3002
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#_2","title":"\u5f00\u542f\u6162\u67e5\u8be2","text":"\u6162\u67e5\u8be2\u65e5\u5fd7\u9ed8\u8ba4\u5173\u95ed\uff0c\u8981\u4f7f\u7528\u6162\u67e5\u8be2\u65e5\u5fd7\u529f\u80fd\uff0c\u9996\u5148\u8981\u5f00\u542f\u6162\u67e5\u8be2\u65e5\u5fd7\u529f\u80fd\u3002
MatrixOne \u7684\u6162\u67e5\u8be2\u529f\u80fd\u63d0\u4f9b\u4e86\u5982\u4e0b\u51e0\u4e2a\u57fa\u7840\u4fe1\u606f\uff1a
statement
\uff1a\u5373 SQL \u6587\u672c\uff0c\u7528\u4e8e\u63d0\u4f9b\u5b8c\u6574\u7684 SQL \u8bed\u53e5\u3002request_at
\uff1aSQL \u8bed\u53e5\u7684\u7684\u8d77\u59cb\u65f6\u95f4\u3002duration_second
\uff1aSQL \u8bed\u53e5\u7684\u5b9e\u9645\u6267\u884c\u65f6\u95f4\u3002exec_plan
\uff1aSQL \u8bed\u53e5\u7684\u8be6\u7ec6\u6267\u884c\u8ba1\u5212\u3002\u6267\u884c\u5982\u4e0b\u5185\u5bb9\u7684\u811a\u672c\uff0c\u5f00\u542f\u6162\u67e5\u8be2\uff1a
drop database if exists mo_ts;\ncreate database mo_ts;\nuse mo_ts;\ncreate view slow_query as select statement,request_at,duration/1000000000 as duration_second from system.statement_info where statement like 'select%' and duration/1000000000>1 order by request_at desc;\ncreate view slow_query_with_plan as select statement,request_at,duration/1000000000 as duration_second,exec_plan from system.statement_info where statement like 'select%' and duration/1000000000>1 order by request_at desc;\n
\u5bf9\u4e8e\u6240\u6709\u8d85\u8fc7 1 \u79d2\u7684\u67e5\u8be2\uff0c\u53ef\u4ee5\u6267\u884c\u5982\u4e0b\u8bed\u53e5\uff1a
mysql> select * from mo_ts.slow_query;\nmysql> select * from mo_ts.slow_query_with_plan;\n
\u8bed\u53e5\u89e3\u91ca
select * from mo_ts.slow_query;
\uff1a\u4e0d\u5e26\u6267\u884c\u8ba1\u5212\u3002
select * from mo_ts.slow_query_with_plan;
\uff1a\u5e26\u6267\u884c\u8ba1\u5212\u3002
\u5728\u5f00\u542f\u4e86\u6162\u67e5\u8be2\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u5f00\u542f\u9519\u8bef\u65e5\u5fd7\uff0c\u68c0\u67e5\u65e5\u5fd7\uff0c\u5b9a\u4f4d\u9519\u8bef\u4fe1\u606f\u3002
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#_4","title":"\u5f00\u542f\u9519\u8bef\u65e5\u5fd7","text":"\u6267\u884c\u5982\u4e0b\u5185\u5bb9\u811a\u672c\uff1a
create database mo_ts if not exists mo_ts;\nuse mo_ts;\ncreate view error_message as select timestamp,message from system.log_info where level in ('error','panic','faltal');\ncreate view error_sql as select si.request_at time_stamp,si.statement,si.error as SQL from system.statement_info si where si.user<>'internal' and si.status='Failed' ;\n
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#_5","title":"\u67e5\u8be2\u6570\u636e\u5e93\u670d\u52a1\u9519\u8bef","text":"\u67e5\u8be2\u6570\u636e\u5e93\u670d\u52a1\u9519\u8bef\uff0c\u6267\u884c\u5982\u4e0b SQL\uff1a
mysql> select * from mo_ts.error_message;\n
\u67e5\u8be2\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
+----------------------------+-------------------------------------------------------------------------+\n| timestamp | message |\n+----------------------------+-------------------------------------------------------------------------+\n| 2022-11-28 14:47:31.324762 | error: SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 14:47:31.324837 | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 14:47:31.324872 | query trace status |\n| 2022-11-28 14:40:06.579795 | read loop stopped |\n| 2022-11-28 14:40:06.585220 | gc inactive backends task stopped |\n| 2022-11-28 14:40:06.591082 | error: cannot locate ha keeper |\n| 2022-11-28 14:40:08.442515 | failed to propose initial cluster info |\n| 2022-11-28 14:40:08.442667 | failed to set initial cluster info |\n| 2022-11-28 14:40:09.411286 | error: timeout, converted to code 20429 |\n| 2022-11-28 14:40:09.411508 | read loop stopped |\n| 2022-11-28 14:40:09.416557 | gc inactive backends task stopped |\n| 2022-11-28 14:40:10.052585 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:10.052630 | failed to create init tasks |\n| 2022-11-28 14:40:11.053926 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:11.054059 | failed to create init tasks |\n| 2022-11-28 14:40:12.054578 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:12.054630 | failed to create init tasks |\n| 2022-11-28 14:40:13.055828 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:13.055896 | failed to create init tasks |\n| 2022-11-28 14:40:14.057102 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:14.057208 | failed to create init tasks |\n| 2022-11-28 14:40:15.058425 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:15.058563 | failed to create init tasks |\n| 2022-11-28 14:40:16.059867 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:16.060031 | failed to create init tasks |\n| 2022-11-28 14:40:16.443234 | read loop stopped |\n| 2022-11-28 14:40:16.443162 | read from backend failed |\n| 2022-11-28 14:40:16.448858 | gc inactive backends task stopped |\n| 2022-11-28 14:40:16.457276 | error: file tnservice/dd4dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 14:40:17.061260 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:17.061323 | failed to create init tasks |\n| 2022-11-28 14:40:18.062165 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:18.062249 | failed to create init tasks |\n| 2022-11-28 14:40:18.642097 | error: TN shard uuid , id 2 not reported |\n| 2022-11-28 14:40:19.062775 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:19.062937 | failed to create init tasks |\n| 2022-11-28 14:40:20.063237 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:20.063252 | failed to create init tasks |\n| 2022-11-28 14:40:21.064529 | failed to create init tasks |\n| 2022-11-28 14:40:21.064457 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:21.463193 | read loop stopped |\n| 2022-11-28 14:40:21.468423 | gc inactive backends task stopped |\n| 2022-11-28 14:40:21.474688 | error: file cnservice/dd1dccb4-4d3c-41f8-b482-5251dc7a41bf is not found |\n| 2022-11-28 15:24:56.210577 | error: SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:24:56.210773 | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:24:56.210898 | query trace status |\n| 2022-11-28 14:40:22.065723 | error: internal error: failed to get task service |\n| 2022-11-28 14:40:22.065838 | failed to create init tasks |\n| 2022-11-28 14:40:22.478229 | error: invalid state no cn in the cluster |\n| 2022-11-28 14:40:22.478846 | failed to refresh task storage |\n| 2022-11-28 14:40:23.090160 | error: invalid database mo_task |\n| 2022-11-28 14:40:23.090274 | invalid database mo_task |\n| 2022-11-28 14:40:23.090604 | query trace status |\n| 2022-11-28 15:32:30.354364 | error: SQL parser error: table \"slow_query\" does not exist |\n| 2022-11-28 15:32:30.354485 | SQL parser error: table \"slow_query\" does not exist |\n| 2022-11-28 15:32:30.354605 | query trace status |\n| 2022-11-28 15:26:59.639892 | error: SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:26:59.640039 | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:26:59.640208 | query trace status |\n| 2022-11-28 15:37:29.289457 | error: table slow_query already exists |\n| 2022-11-28 15:37:29.289486 | table slow_query already exists |\n| 2022-11-28 15:37:29.289518 | query trace status |\n| 2022-11-28 15:37:45.773829 | error: table slow_query_with_plan already exists |\n| 2022-11-28 15:37:45.773856 | table slow_query_with_plan already exists |\n| 2022-11-28 15:37:45.773888 | query trace status |\n| 2022-11-28 14:45:48.821324 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:45:48.823261 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:45:48.823426 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:45:48.823525 | error: not supported: function or operator 'interval' |\n| 2022-11-28 14:47:14.513831 | error: SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:14.513929 | SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:14.513962 | query trace status |\n+----------------------------+-------------------------------------------------------------------------+\n72 rows in set (0.13 sec)\n
"},{"location":"MatrixOne/Troubleshooting/slow-queries/#sql","title":"\u67e5\u8be2 SQL \u9519\u8bef","text":"\u67e5\u8be2 SQL \u9519\u8bef\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a
mysql> select * from mo_ts.error_sql;\n
\u67e5\u8be2\u7ed3\u679c\u793a\u4f8b\u5982\u4e0b\uff1a
+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| time_stamp | statement | sql |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n| 2022-11-28 14:40:23.073188 | use mo_task | invalid database mo_task |\n| 2022-11-28 15:26:59.637130 | select * from mo_ts.error_sql | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:37:29.283683 | create view slow_query as select statement, request_at, duration / 1000000000 as duration_second from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc | table slow_query already exists |\n| 2022-11-28 15:37:45.765394 | create view slow_query_with_plan as select statement, request_at, duration / 1000000000 as duration_second, exec_plan from system.statement_info where statement like \"select%\" and duration / 1000000000 > 1 order by request_at desc | table slow_query_with_plan already exists |\n| 2022-11-28 15:32:30.351695 | select * from mo_ts.slow_query | SQL parser error: table \"slow_query\" does not exist |\n| 2022-11-28 14:47:14.510060 | create view error_sql as select si.request_at as time_stamp, si.statement as sql, el.err_code from statement_info as si cross join error_info as el where si.statement_id = el.statement_id and user != \"internal\" | SQL parser error: table \"statement_info\" does not exist |\n| 2022-11-28 14:47:31.323884 | select * from mo_ts.error_sql | SQL parser error: table \"error_sql\" does not exist |\n| 2022-11-28 15:24:56.208171 | select * from mo_ts.error_sql | SQL parser error: table \"error_sql\" does not exist |\n+----------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------+\n8 rows in set (0.14 sec)\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/","title":"C# \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 C# \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u5df2\u5b8c\u6210\u5b89\u88c5\u5e76\u542f\u52a8 MatrixOne
\u5df2\u5b89\u88c5. NET Core SDK
\u5df2\u5b89\u88c5 MySQL Client
\u4f7f\u7528 dotnet \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a myapp \u7684\u65b0\u5e94\u7528\uff1a
dotnet new console -o myapp\n
\u968f\u540e\u5207\u6362\u5230 myapp \u76ee\u5f55\u4e0b
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#mysql-connectornet-nuget","title":"\u6b65\u9aa4\u4e8c\uff1a\u6dfb\u52a0 MySQL Connector/NET NuGet \u5305","text":"\u4f7f\u7528 NuGet \u5305\u7ba1\u7406\u5668\u5b89\u88c5 MySql.Data \u5305\uff1a
dotnet add package MySql.Data\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#matrixone","title":"\u6b65\u9aa4\u4e09\uff1a\u8fde\u63a5 Matrixone \u8fdb\u884c\u64cd\u4f5c","text":"\u7f16\u5199\u4ee3\u7801\u8fde\u63a5 Matrixone\uff0c\u5efa\u7acb\u4e00\u4e2a\u5b66\u751f\u8868\u5e76\u8fdb\u884c\u589e\u5220\u6539\u67e5\u64cd\u4f5c\u3002\u5728 Program.cs \u6587\u4ef6\u4e2d\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a
using System;\nusing MySql.Data.MySqlClient;\n\nclass Program\n{\n\n static void ExecuteSQL(MySqlConnection connection, string query)\n {\n using (MySqlCommand command = new MySqlCommand(query, connection))\n {\n command.ExecuteNonQuery();\n }\n }\n static void Main(string[] args)\n {\n Program n =new Program();\n string connectionString = \"server=127.0.0.1;user=root;database=test;port=6001;password=111\";\n using (MySqlConnection connection = new MySqlConnection(connectionString))\n {\n try{\n connection.Open();\n Console.WriteLine(\"\u5df2\u7ecf\u5efa\u7acb\u8fde\u63a5\");\n // \u5efa\u8868\n ExecuteSQL(connection,\"CREATE TABLE IF NOT EXISTS Student (id INT auto_increment PRIMARY KEY, name VARCHAR(255),age int,remark VARCHAR(255) )\");\n Console.WriteLine(\"\u5efa\u8868\u6210\u529f\uff01\");\n //\u63d2\u5165\u6570\u636e\n ExecuteSQL(connection,\"INSERT INTO Student(name,age) VALUES ('\u5f20\u4e09',22),('\u674e\u56db',25),('\u8d75\u4e94',30)\");\n Console.WriteLine(\"\u6210\u529f\u63d2\u5165\u6570\u636e\uff01\");\n //\u66f4\u65b0\u6570\u636e\n ExecuteSQL(connection,\"UPDATE Student SET remark = 'Updated' WHERE id = 1\");\n Console.WriteLine(\"\u6210\u529f\u66f4\u65b0\u6570\u636e\uff01\");\n //\u5220\u9664\u6570\u636e\n ExecuteSQL(connection,\"DELETE FROM Student WHERE id = 2\");\n Console.WriteLine(\"\u6210\u529f\u5220\u9664\u6570\u636e\uff01\");\n //\u67e5\u8be2\u6570\u636e\n MySqlCommand command = new MySqlCommand(\"SELECT * FROM Student\", connection);\n using (MySqlDataReader reader = command.ExecuteReader())\n {\n while (reader.Read())\n {\n Console.WriteLine($\"\u59d3\u540d: {reader[\"name\"]}, \u5e74\u9f84: {reader[\"age\"]},\u5907\u6ce8: {reader[\"remark\"]}\");\n }\n }\n Console.WriteLine(\"\u6570\u636e\u67e5\u8be2\u6210\u529f\uff01\");\n }\n catch (MySqlException ex)\n {\n Console.WriteLine(ex.Message);\n\n }\n finally\n {\n Console.WriteLine(\"\u51c6\u5907\u65ad\u5f00\u8fde\u63a5\");\n connection.Close();\n Console.WriteLine(\"\u65ad\u5f00\u8fde\u63a5\u6210\u529f\uff01\");\n }\n\n //connection.Close();\n }\n }\n}\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#_3","title":"\u6b65\u9aa4\u56db\uff1a\u8fd0\u884c\u7a0b\u5e8f","text":"\u5728\u7ec8\u7aef\u6267\u884c\u547d\u4ee4 dotnet run
\uff1a
(base) admin@admindeMacBook-Pro myapp % dotnet run \n\u5df2\u7ecf\u5efa\u7acb\u8fde\u63a5\n\u5efa\u8868\u6210\u529f\uff01\n\u6210\u529f\u63d2\u5165\u6570\u636e\uff01\n\u6210\u529f\u66f4\u65b0\u6570\u636e\uff01\n\u6210\u529f\u5220\u9664\u6570\u636e\uff01\n\u59d3\u540d: \u8d75\u4e94, \u5e74\u9f84: 30,\u5907\u6ce8: \n\u59d3\u540d: \u5f20\u4e09, \u5e74\u9f84: 22,\u5907\u6ce8: Updated\n\u6570\u636e\u67e5\u8be2\u6210\u529f\uff01\n\u51c6\u5907\u65ad\u5f00\u8fde\u63a5\n\u65ad\u5f00\u8fde\u63a5\u6210\u529f\uff01\n
"},{"location":"MatrixOne/Tutorial/c-net-crud-demo/#_4","title":"\u6b65\u9aa4\u4e94\uff1a\u68c0\u67e5\u6570\u636e","text":"\u4f7f\u7528 Mysql \u5ba2\u6237\u7aef\u8fde\u63a5 Matrixone \u5bf9 Student \u8868\u8fdb\u884c\u67e5\u8be2\uff1a
mysql> select * from student;\n+------+--------+------+---------+\n| id | name | age | remark |\n+------+--------+------+---------+\n| 3 | \u8d75\u4e94 | 30 | NULL |\n| 1 | \u5f20\u4e09 | 22 | Updated |\n+------+--------+------+---------+\n2 rows in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6570\u636e\u8fd4\u56de\u6b63\u786e\u3002
"},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/","title":"Golang \u57fa\u7840\u793a\u4f8b","text":""},{"location":"MatrixOne/Tutorial/develop-golang-crud-demo/#_1","title":"\u914d\u7f6e\u73af\u5883","text":"\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Golang 1.18 \u7248\u672c\u53ca\u4ee5\u4e0a\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u884c\u786e\u8ba4\u4f60\u7684 Golang \u7248\u672c\uff1a
#To check with Golang installation and its version\ngo version\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
Go-MySQL-Driver
\u5de5\u5177\u3002\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a test \u7684\u65b0\u6570\u636e\u5e93\u3002
mysql> create database test;\n
\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a golang_crud_matrixone.go
\u7684\u7eaf\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u62f7\u8d1d\u81f3\u6587\u4ef6\u5185\uff1a
package main\n\nimport (\n \"database/sql\"\n \"fmt\"\n \"log\"\n _ \"github.com/go-sql-driver/mysql\"\n)\n\nfunc main() {\n //Open a new connection to MatrixOne\n db, err := sql.Open(\"mysql\", \"root:111@tcp(127.0.0.1:6001)/test\")\n checkErr(err)\n\n //Create a table\n _, err2 := db.Exec(\"CREATE TABLE `userinfo` (`uid` INT(10) NOT NULL AUTO_INCREMENT,`username` VARCHAR(64) NULL DEFAULT NULL,`department` VARCHAR(64) NULL DEFAULT NULL,`created` DATETIME NULL DEFAULT NULL, PRIMARY KEY (`uid`));\")\n if err2 != nil {\n log.Fatal(err2)\n }\n fmt.Print(\"Successfully Created\\n\")\n\n // Insert a record\n stmt, err := db.Prepare(\"INSERT userinfo SET username=?,department=?,created=?\")\n checkErr(err)\n\n res, err := stmt.Exec(\"Alex\", \"r&d\", \"2023-01-01 12:00:00\")\n checkErr(err)\n\n id, err := res.LastInsertId()\n checkErr(err)\n\n fmt.Println(id)\n //Update a record\n stmt, err = db.Prepare(\"update userinfo set username=? where uid=?\")\n checkErr(err)\n\n res, err = stmt.Exec(\"Mark\", id)\n checkErr(err)\n\n affect, err := res.RowsAffected()\n checkErr(err)\n\n fmt.Println(affect)\n\n // Query all records\n rows, err := db.Query(\"SELECT * FROM userinfo\")\n checkErr(err)\n\n for rows.Next() {\n var uid int\n var username string\n var department string\n var created string\n err = rows.Scan(&uid, &username, &department, &created)\n checkErr(err)\n fmt.Println(uid)\n fmt.Println(username)\n fmt.Println(department)\n fmt.Println(created)\n }\n\n // Delete a record\n stmt, err = db.Prepare(\"delete from userinfo where uid=?\")\n checkErr(err)\n\n res, err = stmt.Exec(id)\n checkErr(err)\n\n affect, err = res.RowsAffected()\n checkErr(err)\n\n fmt.Println(affect)\n\n db.Close()\n\n}\n\nfunc checkErr(err error) {\n if err != nil {\n panic(err)\n }\n}\n
\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u884c\uff0c\u6267\u884c\u6b64 Golang \u6587\u4ef6\u3002
> go run golang_crud_matrixone.go\nSuccessfully Created\n1\n1\n1\nMark\nr&d\n2023-01-01\n1\n
Note
\u672c\u7bc7\u6587\u6863\u6240\u4ecb\u7ecd\u7684\u6f14\u793a\u7a0b\u5e8f\u7684\u6e90\u4ee3\u7801\u4e0b\u8f7d\u5730\u5740\u4e3a\uff1aJava CRUD \u793a\u4f8b\u3002
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#_1","title":"\u914d\u7f6e\u73af\u5883","text":"\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u4ee5\u4e0b\u8f6f\u4ef6\u3002
mysql> create database test;\n
Note
\u6211\u4eec\u4f7f\u7528 IDEA \u4f5c\u4e3a\u4e00\u4e2a IDE \u793a\u4f8b\u6765\u6f14\u793a\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u4f60\u53ef\u4ee5\u81ea\u7531\u5730\u9009\u62e9 Eclipse \u6216\u5176\u4ed6 IDE \u5de5\u5177\u5b9e\u8df5\u3002
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#java_1","title":"\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u7684 Java \u9879\u76ee","text":"\u542f\u52a8 IDEA\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Java \u9879\u76ee\uff0c\u5982\u4e0b\u6240\u793a\uff1a
\u8fdb\u5165\u83dc\u5355 Project Setting > Libraries\uff0c\u5bfc\u5165 mysql-connector-java-8.0.30.jar \u6587\u4ef6\u3002
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#java-matrixone","title":"\u7f16\u5199 Java \u4ee3\u7801\u8fde\u63a5 MatrixOne","text":"\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a JDBCUtils \u7684 Java \u7c7b\u4f5c\u4e3a\u8fde\u63a5\u5b9e\u7528\u7a0b\u5e8f\u3002\u8fd9\u4e2a\u7c7b\u5c06\u4f5c\u4e3a\u8fde\u63a5 MatrixOne \u548c\u6267\u884c SQL \u67e5\u8be2\u7684\u5de5\u5177\u3002
\u5728 src \u76ee\u5f55\u4e0b\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a JDBCUtils.java
\u7684\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u7f16\u8f91\u8be5\u6587\u4ef6\uff1a
import java.sql.Connection;\nimport java.sql.DriverManager;\nimport java.sql.SQLException;\n\npublic class JDBCUtils {\n private static String jdbcURL = \"jdbc:mysql://127.0.0.1:6001/test\";\n private static String jdbcUsername = \"root\";\n private static String jdbcPassword = \"111\";\n\n public static Connection getConnection() {\n Connection connection = null;\n try {\n connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);\n } catch (SQLException e) {\n // TODO Auto-generated catch block\n e.printStackTrace();\n }\n return connection;\n }\n\n public static void printSQLException(SQLException ex) {\n for (Throwable e : ex) {\n if (e instanceof SQLException) {\n e.printStackTrace(System.err);\n System.err.println(\"SQLState: \" + ((SQLException) e).getSQLState());\n System.err.println(\"Error Code: \" + ((SQLException) e).getErrorCode());\n System.err.println(\"Message: \" + e.getMessage());\n Throwable t = ex.getCause();\n while (t != null) {\n System.out.println(\"Cause: \" + t);\n t = t.getCause();\n }\n }\n }\n }\n}\n
\u5176\u6b21\uff0c\u6211\u4eec\u7528 MatrixOne \u7f16\u5199\u521b\u5efa\u3001\u63d2\u5165\u3001\u66f4\u65b0\u548c\u5220\u9664\u64cd\u4f5c\u7684\u793a\u4f8b\u4ee3\u7801\u3002
\u6211\u4eec\u9700\u8981\u5728 src \u76ee\u5f55\u4e0b\u521b\u5efa\u76f8\u5e94\u7684 java \u6e90\u4ee3\u7801\u6587\u4ef6\uff1aCreate.java
\u3001Insert.java
\u3001Update.java
\u3001Select.java
\uff0c\u5e76\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u5bf9\u5e94\u653e\u5728\u8fd9\u4e9b\u6587\u4ef6\u4e2d\u3002
Create.java
)","text":"import java.sql.Connection;\nimport java.sql.SQLException;\nimport java.sql.Statement;\n\npublic class Create {\n private static final String createTableSQL = \"create table student (\\r\\n\" + \" id int primary key,\\r\\n\" +\n \" name varchar(20),\\r\\n\" + \" email varchar(20),\\r\\n\" + \" country varchar(20),\\r\\n\" +\n \" age int\\r\\n\" + \" );\";\n\n public static void main(String[] argv) throws SQLException {\n Create createTable = new Create();\n createTable.createTable();\n }\n\n public void createTable() throws SQLException {\n\n System.out.println(createTableSQL);\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n // Step 2:Create a statement using connection object\n Statement statement = connection.createStatement();) {\n\n // Step 3: Execute the query or update query\n statement.execute(createTableSQL);\n } catch (SQLException e) {\n\n // print SQL exception information\n JDBCUtils.printSQLException(e);\n }\n\n // Step 4: try-with-resource statement will auto close the connection.\n }\n}\n
\u6267\u884c\u4e0a\u8ff0\u4ee3\u7801\u4f1a\u5728 test
\u6570\u636e\u5e93\u4e2d\u521b\u5efa\u4e00\u4e2a\u8868\uff0c\u7136\u540e\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u4f7f\u7528\u5982\u4e0b\u4ee3\u7801\u9a8c\u8bc1\u662f\u5426\u521b\u5efa\u4e86\u8868\u3002
mysql> show create table student;\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| student | CREATE TABLE `student` (\n`id` INT DEFAULT NULL,\n`name` VARCHAR(20) DEFAULT NULL,\n`email` VARCHAR(20) DEFAULT NULL,\n`country` VARCHAR(20) DEFAULT NULL,\n`age` INT DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#insertjava","title":"\u63d2\u5165\uff08Insert.java
\uff09","text":"import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Insert {\n private static final String INSERT_STUDENT_SQL = \"INSERT INTO student\" +\n \" (id, name, email, country, age) VALUES \" +\n \" (?, ?, ?, ?, ?);\";\n\n public static void main(String[] argv) throws SQLException {\n Insert insertTable = new Insert();\n insertTable.insertRecord();\n }\n\n public void insertRecord() throws SQLException {\n System.out.println(INSERT_STUDENT_SQL);\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n // Step 2:Create a statement using connection object\n PreparedStatement preparedStatement = connection.prepareStatement(INSERT_STUDENT_SQL)) {\n preparedStatement.setInt(1, 1);\n preparedStatement.setString(2, \"Tony\");\n preparedStatement.setString(3, \"tony@gmail.com\");\n preparedStatement.setString(4, \"US\");\n preparedStatement.setString(5, \"20\");\n\n System.out.println(preparedStatement);\n // Step 3: Execute the query or update query\n preparedStatement.executeUpdate();\n } catch (SQLException e) {\n\n // print SQL exception information\n JDBCUtils.printSQLException(e);\n }\n\n // Step 4: try-with-resource statement will auto close the connection.\n }\n\n}\n
\u6267\u884c\u7ed3\u679c\uff1a
mysql> select * from student;\n+------+------+----------------+---------+------+\n| id | name | email | country | age |\n+------+------+----------------+---------+------+\n| 1 | Tony | tony@gmail.com | US | 20 |\n+------+------+----------------+---------+------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#updatejava","title":"\u66f4\u65b0\uff08Update.java
\uff09","text":"import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.SQLException;\n\npublic class Update {\n private static final String UPDATE_STUDENT_SQL = \"update student set name = ? where id = ?;\";\n\n public static void main(String[] argv) throws SQLException {\n Update updateTable = new Update();\n updateTable.updateRecord();\n }\n\n public void updateRecord() throws SQLException {\n System.out.println(UPDATE_STUDENT_SQL);\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n // Step 2:Create a statement using connection object\n PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_STUDENT_SQL)) {\n preparedStatement.setString(1, \"Ram\");\n preparedStatement.setInt(2, 1);\n\n // Step 3: Execute the query or update query\n preparedStatement.executeUpdate();\n } catch (SQLException e) {\n\n // print SQL exception information\n JDBCUtils.printSQLException(e);\n }\n\n // Step 4: try-with-resource statement will auto close the connection.\n }\n}\n
\u8fd0\u884c\u7ed3\u679c\uff1a
mysql> select * from student;\n+------+------+----------------+---------+------+\n| id | name | email | country | age |\n+------+------+----------------+---------+------+\n| 1 | Ram | tony@gmail.com | US | 20 |\n+------+------+----------------+---------+------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-java-crud-demo/#selectjava","title":"\u67e5\u8be2\uff08Select.java
\uff09","text":"import java.sql.Connection;\nimport java.sql.PreparedStatement;\nimport java.sql.ResultSet;\nimport java.sql.SQLException;\n\npublic class Select {\n private static final String QUERY = \"select id,name,email,country,age from student where id =?\";\n\n public static void main(String[] args) {\n\n // using try-with-resources to avoid closing resources (boiler plate code)\n\n // Step 1: Establishing a Connection\n try (Connection connection = JDBCUtils.getConnection();\n\n // Step 2:Create a statement using connection object\n PreparedStatement preparedStatement = connection.prepareStatement(QUERY);) {\n preparedStatement.setInt(1, 1);\n System.out.println(preparedStatement);\n // Step 3: Execute the query or update query\n ResultSet rs = preparedStatement.executeQuery();\n\n // Step 4: Process the ResultSet object.\n while (rs.next()) {\n int id = rs.getInt(\"id\");\n String name = rs.getString(\"name\");\n String email = rs.getString(\"email\");\n String country = rs.getString(\"country\");\n String password = rs.getString(\"age\");\n System.out.println(id + \",\" + name + \",\" + email + \",\" + country + \",\" + password);\n }\n } catch (SQLException e) {\n JDBCUtils.printSQLException(e);\n }\n // Step 4: try-with-resource statement will auto close the connection.\n }\n}\n
\u8fd0\u884c\u7ed3\u679c\uff1a
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/","title":"Python \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 Python \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_2","title":"\u73af\u5883\u914d\u7f6e","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus)\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
```\n#To check with Python installation and its version\npython3 -V\n```\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u548c cryptography
\u5de5\u5177\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u548c cryptography
\u5de5\u5177\uff1a
```\npip3 install pymysql\npip3 install cryptography\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\n```\n
\u4f60\u53ef\u4ee5\u53c2\u8003 Python \u8fde\u63a5 MatrixOne \u670d\u52a1\u4e86\u89e3\u5982\u4f55\u901a\u8fc7 pymysql
\u8fde\u63a5\u5230 MatrixOne\uff0c\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664)\u3002
\u65b0\u5efa\u4e00\u4e2a create.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"CREATE TABLE cars (id INT NOT NULL AUTO_INCREMENT, car_model VARCHAR(45) NULL,car_brand VARCHAR(45) NULL,PRIMARY KEY (`id`))\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n print(\"Table created\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u3002\u8fd9\u5c06\u5728 MatrixOne \u4e2d\u7684\u6570 \u200b\u200b \u636e\u5e93 test \u5185\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a cars \u8868\u3002
> python3 create.py\nTable created\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u521b\u5efa\u6210\u529f\uff1a
mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| cars |\n+----------------+\n1 row in set (0.03 sec)\nmysql> show create table cars;\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n| cars | CREATE TABLE `cars` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`car_model` VARCHAR(45) DEFAULT NULL,\n`car_brand` VARCHAR(45) DEFAULT NULL,\nPRIMARY KEY (`id`)\n) |\n+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_4","title":"\u63d2\u5165\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a insert.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"INSERT INTO cars(car_model, car_brand) VALUES ('accord', 'honda')\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(\"Record Added\")\n else:\n print(sql_exec)\n print(\"Not Added\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\u4f1a\u5728 cars \u8868\u4e2d\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a
> python3 insert.py\n1\nRecord Added\n
\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u9a8c\u8bc1\u8fd9\u6761\u8bb0\u5f55\u662f\u5426\u63d2\u5165\u6210\u529f\uff1a
mysql> select * from cars;\n+------+-----------+-----------+\n| id | car_model | car_brand |\n+------+-----------+-----------+\n| 1 | accord | honda |\n+------+-----------+-----------+\n1 row in set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_5","title":"\u67e5\u8be2\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a read.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"SELECT * FROM cars\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(cursor.fetchall())\n else:\n print(sql_exec)\n print(\"No Record\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u7684\u4ee3\u7801\u67e5\u8be2\u5e76\u8fd4\u56de cars \u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff1a
> python3 read.py\n1\n[{'id': 1, 'car_model': 'accord', 'car_brand': 'honda'}]\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_6","title":"\u66f4\u65b0\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a update.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"UPDATE cars SET car_model = 'explorer', car_brand = 'ford' WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(\"Record Updated\")\n else:\n print(sql_exec)\n print(\"Not Updated\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u4ee3\u7801\u66f4\u65b0 id \u4e3a\u201c1\u201d\u7684\u8bb0\u5f55\uff1a
> python3 update.py\n1\nRecord Updated\n
\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u9a8c\u8bc1\u8fd9\u6761\u8bb0\u5f55\u662f\u5426\u66f4\u65b0\u6210\u529f\uff1a
mysql> select * from cars;\n+------+-----------+-----------+\n| id | car_model | car_brand |\n+------+-----------+-----------+\n| 1 | explorer | ford |\n+------+-----------+-----------+\n1 row in set (0.02 sec)\n
"},{"location":"MatrixOne/Tutorial/develop-python-crud-demo/#_7","title":"\u5220\u9664\u6570\u636e","text":"\u65b0\u5efa\u4e00\u4e2a delete.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
#!/usr/bin/python3\n\nimport pymysql.cursors\n\nSQL_CONNECTION = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='test',\n cursorclass=pymysql.cursors.DictCursor,\n autocommit=True\n )\n\nSQL = \"DELETE FROM cars WHERE id = '1'\"\n\nwith SQL_CONNECTION.cursor() as cursor:\n try:\n sql_exec = cursor.execute(SQL)\n if sql_exec:\n print(sql_exec)\n print(\"Record Deleted\")\n else:\n print(sql_exec)\n print(\"Not Deleted\")\n except (pymysql.Error, pymysql.Warning) as e:\n print(f'error! {e}')\n\n finally:\n SQL_CONNECTION.close()\n
\u6267\u884c\u4e0b\u9762\u4ee3\u7801\u5220\u9664 id \u4e3a\u201c1\u201d\u7684\u8bb0\u5f55\uff1a
> python3 delete.py\n1\nRecord Deleted\n
\u4f60\u53ef\u4ee5\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\u9a8c\u8bc1\u8fd9\u6761\u8bb0\u5f55\u662f\u5426\u5220\u9664\u6210\u529f\uff1a
mysql> select * from cars;\nEmpty set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/","title":"Django \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 Django \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
Django \u662f\u4e00\u4e2a\u7531 Python \u7f16\u5199\u7684\u4e00\u4e2a\u5f00\u653e\u6e90\u4ee3\u7801\u7684 Web \u5e94\u7528\u6846\u67b6\u3002
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u76f8\u5173\u8f6f\u4ef6\u7684\u7b80\u5355\u4ecb\u7ecd\uff1a
\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -V\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Django\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Django \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -m django --version\n
pymysql
\u5de5\u5177\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\uff1apip3 install pymysql\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_3","title":"\u73af\u5883\u914d\u7f6e","text":"\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne\u3002\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a test \u7684\u65b0\u6570\u636e\u5e93\u3002
mysql> create database test;\n
\u521b\u5efa\u9879\u76ee django_crud_matrixone
\u3002
django-admin startproject django_crud_matrixone\n
\u521b\u5efa\u5b8c\u6210\u540e\u6211\u4eec\u53ef\u4ee5\u67e5\u770b\u4e0b\u9879\u76ee\u7684\u76ee\u5f55\u7ed3\u6784\uff1a
cd django_crud_matrixone/\n\ndjango_crud_matrixone/\n\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 asgi.py\n\u2514\u2500\u2500 settings.py\n\u2514\u2500\u2500 urls.py\n\u2514\u2500\u2500 wsgi.py\nmanage.py\n
\u63a5\u4e0b\u6765\u6211\u4eec\u8fdb\u5165 django_crud_matrixone \u76ee\u5f55\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8\u670d\u52a1\u5668\uff1a
python3 manage.py runserver 0.0.0.0:8000\n
0.0.0.0 \u8ba9\u5176\u5b83\u7535\u8111\u53ef\u8fde\u63a5\u5230\u5f00\u53d1\u670d\u52a1\u5668\uff0c8000 \u4e3a\u7aef\u53e3\u53f7\u3002\u5982\u679c\u4e0d\u8bf4\u660e\uff0c\u90a3\u4e48\u7aef\u53e3\u53f7\u9ed8\u8ba4\u4e3a 8000\u3002
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
\u6211\u4eec\u5728\u9879\u76ee\u7684 settings.py \u6587\u4ef6\u4e2d\u627e\u5230 DATABASES \u914d\u7f6e\u9879\uff0c\u5c06\u5176\u4fe1\u606f\u4fee\u6539\u4e3a\uff1a
DATABASES = { \n 'default': \n { \n 'ENGINE': 'django.db.backends.mysql', # \u6570\u636e\u5e93\u5f15\u64ce\n 'NAME': 'test', # \u6570\u636e\u5e93\u540d\u79f0\n 'HOST': '127.0.0.1', # \u6570\u636e\u5e93\u5730\u5740\uff0c\u672c\u673a ip \u5730\u5740 127.0.0.1 \n 'PORT': 6001, # \u7aef\u53e3 \n 'USER': 'root', # \u6570\u636e\u5e93\u7528\u6237\u540d\n 'PASSWORD': '111', # \u6570\u636e\u5e93\u5bc6\u7801\n } \n}\n
\u63a5\u4e0b\u6765\uff0c\u544a\u8bc9 Django \u4f7f\u7528 pymysql \u6a21\u5757\u8fde\u63a5 mysql \u6570\u636e\u5e93\uff0c\u5728\u4e0e settings.py \u540c\u7ea7\u76ee\u5f55\u4e0b\u7684 init. py \u4e2d\u5f15\u5165\u6a21\u5757\u548c\u8fdb\u884c\u914d\u7f6e\uff1a
import pymysql\npymysql.install_as_MySQLdb()\n
\u521b\u5efa app\uff0cDjango \u89c4\u5b9a\uff0c\u5982\u679c\u8981\u4f7f\u7528\u6a21\u578b\uff0c\u5fc5\u987b\u8981\u521b\u5efa\u4e00\u4e2a app\u3002\u6211\u4eec\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a TestModel \u7684 app:
django-admin startapp TestModel\n
\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b\uff1a
django_crud_matrixone/\n\u251c\u2500\u2500 __init__.py\n\u2514\u2500\u2500 asgi.py\n...\nTestModel\n\u2514\u2500\u2500 migrations\n\u2514\u2500\u2500 __init__.py\n\u2514\u2500\u2500 admin.py\n\u2514\u2500\u2500 apps.py\n\u2514\u2500\u2500 models.py\n\u2514\u2500\u2500 tests.py\n\u2514\u2500\u2500 views.py\n
\u63a5\u4e0b\u6765\u5728 settings.py \u4e2d\u627e\u5230 INSTALLED_APPS \u8fd9\u4e00\u9879\uff0c\u5982\u4e0b\uff1a
INSTALLED_APPS = [\n\"django.contrib.admin\",\n\"django.contrib.auth\",\n\"django.contrib.contenttypes\",\n\"django.contrib.sessions\",\n\"django.contrib.messages\",\n\"django.contrib.staticfiles\",\n\"TestModel\", #\u6dfb\u52a0\u6b64\u9879 \n]\n
from django.db import models\nclass Book(models.Model): \nid = models.AutoField(primary_key=True) # id \u4f1a\u81ea\u52a8\u521b\u5efa\uff0c\u53ef\u4ee5\u624b\u52a8\u5199\u5165\ntitle = models.CharField(max_length=32) # \u4e66\u7c4d\u540d\u79f0\nprice = models.DecimalField(max_digits=5, decimal_places=2) # \u4e66\u7c4d\u4ef7\u683c \npublish = models.CharField(max_length=32) # \u51fa\u7248\u793e\u540d\u79f0 \npub_date = models.DateField() # \u51fa\u7248\u65f6\u95f4\n
Django \u6a21\u578b\u4f7f\u7528\u81ea\u5e26\u7684 ORM\u3002\u4ee5\u4e0a\u7684\u7c7b\u540d\u4ee3\u8868\u4e86\u6570\u636e\u5e93\u8868\u540d\uff08testmodel_book)\uff0c\u4e14\u7ee7\u627f\u4e86 models.Model\uff0c\u7c7b\u91cc\u9762\u7684\u5b57\u6bb5\u4ee3\u8868\u6570\u636e\u8868\u4e2d\u7684\u5b57\u6bb5\uff0c\u6570\u636e\u7c7b\u578b\uff1aAutoField\uff08\u76f8\u5f53\u4e8e int\uff09\u3001CharField\uff08\u76f8\u5f53\u4e8e varchar\uff09\u3001DecimalField (\u76f8\u5f53\u4e8e decimal)\u3001DateField\uff08\u76f8\u5f53\u4e8e date\uff09\uff0cmax_length \u53c2\u6570\u9650\u5b9a\u957f\u5ea6\u3002
ORM \u5bf9\u5e94\u5173\u7cfb\u8868\uff1a
\u6709\u5173\u66f4\u591a\u6a21\u578b\u5b57\u6bb5\u7c7b\u578b\u8bf7\u53c2\u8003\uff1ahttps://docs.djangoproject.com/en/5.0/ref/models/fields/\u3002
python3 manage.py makemigrations TestModel # \u751f\u6210\u914d\u7f6e\u6587\u4ef6\u5e76\u653e\u5230app\u4e0b\u9762\u7684migrations\u76ee\u5f55\npython3 manage.py migrate TestModel # \u6839\u636e\u914d\u7f6e\u6587\u4ef6\u81ea\u52a8\u751f\u6210\u76f8\u5e94\u7684SQL\u8bed\u53e5\n
\u8fdb\u5165\u5230 test \u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230 testmodel_book \u8868\u5df2\u751f\u6210\u3002\u5176\u4e2d django_migrations \u8868\u4e2d\u751f\u6210\u6267\u884c\u8fc7\u7684\u64cd\u4f5c\u7684\u8bb0\u5f55\u3002
mysql> show tables;\n+-------------------+\n| Tables_in_test |\n+-------------------+\n| django_migrations |\n| testmodel_book |\n+-------------------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_5","title":"\u63d2\u5165\u6570\u636e","text":"from django.shortcuts import render,HttpResponse\nfrom TestModel import models \ndef add_book(request):\n books = models.Book.objects.create(title=\"\u767d\u591c\u884c\",price=39.50,publish=\"\u5357\u6d77\u51fa\u7248\u516c\u53f8\",pub_date=\"2010-10-10\") \n return HttpResponse(\"<p>\u6570\u636e\u6dfb\u52a0\u6210\u529f\uff01</p>\")\n
from django.contrib import admin\nfrom django.urls import path\nfrom . import views\n\nurlpatterns = [\n path('', views.add_book),\n ]\n
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from testmodel_book;\n+------+-----------+-------+--------------------+------------+\n| id | title | price | publish | pub_date |\n+------+-----------+-------+--------------------+------------+\n| 1 | \u767d\u591c\u884c | 39.50 | \u5357\u6d77\u51fa\u7248\u516c\u53f8 | 2010-10-10 |\n+------+-----------+-------+--------------------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_6","title":"\u67e5\u8be2\u6570\u636e","text":"def src_book(request):\n books = models.Book.objects.all()#\u4f7f\u7528 all() \u65b9\u6cd5\u6765\u67e5\u8be2\u6240\u6709\u5185\u5bb9\n for i in books:\n print(i.id,i.title,i.price,i.publish,i.pub_date)\n return HttpResponse(\"<p>\u67e5\u627e\u6210\u529f\uff01</p>\") \n
\u6709\u5173\u67e5\u8be2\u76f8\u5173\u7684\u66f4\u591a\u65b9\u6cd5\uff0c\u8bf7\u53c2\u8003\uff1ahttps://docs.djangoproject.com/en/5.0/ref/models/querysets/
\u4fee\u6539 urls.py \u6587\u4ef6\uff1a
urlpatterns = [\npath('', views.src_book),\n]\n
\u63a5\u4e0b\u6765\u6211\u4eec\u8fdb\u5165 django_crud_matrixone \u76ee\u5f55\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u542f\u52a8\u670d\u52a1\u5668\uff1a
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
\u547d\u4ee4\u884c\u7ed3\u679c\u4e3a\uff1a
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_7","title":"\u66f4\u65b0\u6570\u636e","text":".update()
\uff0c\u4ee5\u4e0b\u4f8b\u5b50\u4e3a id \u503c\u4e3a 1 \u7684\u8bb0\u5f55\u7684 price \u503c\u66f4\u65b0\u4e3a 50\u3002\u4fee\u6539 django_crud_matrixone \u76ee\u5f55\u4e0b\u7684 views.py \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee3\u7801\uff1adef upd_book(request):\n books = models.Book.objects.filter(pk=1).update(price=50)\n return HttpResponse(\"<p>\u66f4\u65b0\u6210\u529f\uff01</p>\")\n
pk=1 \u7684\u610f\u601d\u662f\u4e3b\u952e primary key=1\uff0c\u76f8\u5f53\u4e8e id=1\u3002
urlpatterns = [\npath('', views.upd_book),\n]\n
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
mysql> select * from testmodel_book;\n+------+-----------+-------+--------------------+------------+\n| id | title | price | publish | pub_date |\n+------+-----------+-------+--------------------+------------+\n| 1 | \u767d\u591c\u884c | 50.00 | \u5357\u6d77\u51fa\u7248\u516c\u53f8 | 2010-10-10 |\n+------+-----------+-------+--------------------+------------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/django-python-crud-demo/#_8","title":"\u5220\u9664\u6570\u636e","text":".delete()
\uff0c\u4ee5\u4e0b\u4f8b\u5b50\u4e3a\u5220\u9664 price \u4e3a 50 \u7684\u8bb0\u5f55\u3002\u4fee\u6539 django_crud_matrixone \u76ee\u5f55\u4e0b\u7684 views.py \u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee3\u7801\uff1adef del_book(request):\n books=models.Book.objects.filter(price=50).delete()\n return HttpResponse(\"<p>\u5220\u9664\u6210\u529f\uff01</p>\")\n
urlpatterns = [\npath('', views.del_book),\n]\n
python3 manage.py runserver 0.0.0.0:8000\n
\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u4f60\u670d\u52a1\u5668\u7684 ip\uff08\u8fd9\u91cc\u6211\u4eec\u8f93\u5165\u672c\u673a IP \u5730\u5740\uff1a127.0.0.1:8000\uff09\u53ca\u7aef\u53e3\u53f7\uff0c\u5982\u679c\u6b63\u5e38\u542f\u52a8\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a
sql mysql> select * from testmodel_book; Empty set (0.00 sec)
\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 golang \u548c gorm \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
Gorm \u662f Golang \u8bed\u8a00\u4e2d\u6700\u6d41\u884c\u7684 ORM \u5de5\u5177\u4e4b\u4e00\u3002
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u76f8\u5173\u8f6f\u4ef6\u7684\u7b80\u5355\u4ecb\u7ecd\uff1a
gorm.io/gorm
\u548c gorm.io/driver/mysql
\u8fd9\u4e24\u4e2a\u5e93\u6765\u8ba9 Go \u8fde\u63a5\u5230 MatrixOne \u6570\u636e\u5e93\u5e76\u5b8c\u6210 CRUD \u64cd\u4f5c\u3002\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
mysql> create database test;\n
#To check with Golang installation and its version\ngo version\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u786e\u8ba4\u4f60\u5df2\u7ecf\u5b89\u88c5 gorm.io/gorm
\u4ee5\u53ca gorm.io/driver/mysql
\uff0c\u4f7f\u7528 go get
\u547d\u4ee4\u5b89\u88c5\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a
go get -u gorm.io/gorm\ngo get -u gorm.io/driver/mysql\n
\u4f60\u53ef\u4ee5\u53c2\u8003 Golang \u8fde\u63a5 MatrixOne \u670d\u52a1\u4e86\u89e3\u5982\u4f55\u901a\u8fc7 Gorm
\u8fde\u63a5\u5230 MatrixOne\uff0c\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u3002
\u4f5c\u4e3a\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668\uff08ORM\uff09\u5de5\u5177\uff0cGorm
\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u521b\u5efa GO \u7c7b\u6765\u6620\u5c04\u5173\u7cfb\u6570\u636e\u5e93\u4e2d\u7684\u8868\u3002 \u5728\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\uff0c\u5c06\u521b\u5efa\u4e00\u4e2a USER
\u7c7b\uff0c\u8fd9\u91cc\u7684\u7c7b\u540d\u548c\u5c5e\u6027\u540d\u79f0\u5fc5\u987b\u4f7f\u7528\u5927\u5199\u82f1\u6587\u5f00\u5934\u4ee5\u4fdd\u8bc1 public
\u8bbf\u95ee\uff0c\u5426\u5219\u4e0d\u80fd\u521b\u5efa\u3002USER
\u7c7b\u5728 GORM
\u7684\u4f5c\u7528\u4e0b\u5c06\u8f6c\u5316\u4e3a\u4e00\u6761 SQL
\u8bed\u53e5\uff0c\u521b\u5efa\u8868\u540d\u4e3a users
\u7684\u8868\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_create.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{\n// Logger: logger.Default.LogMode(logger.Info), //print SQL\n})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n}\n
\u4f60\u53ef\u4ee5\u53d6\u6d88\u6ce8\u91ca Logger: logger.Default.LogMode(logger.Info)
\u4ee5\u628a\u8f6c\u5316\u540e\u7684 SQL
\u8f93\u51fa\u51fa\u6765\u3002 \u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_create.go\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u521b\u5efa\u6210\u529f\uff1a
mysql> show tables;\n+----------------+\n| Tables_in_test |\n+----------------+\n| users |\n+----------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_4","title":"\u63d2\u5165\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5728\u521a\u521a\u521b\u5efa\u7684 users
\u8868\u4e2d\u63d2\u5165\u4e24\u6761\u6570\u636e\u8bb0\u5f55\uff0c\u8fd9\u91cc\u7684 ID
\u9ed8\u8ba4\u662f\u81ea\u589e\u7684\uff0c\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4e3a\u56fa\u5b9a\u7684\u503c\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_insert.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Insert users**\nusers := []USER{\n{\n// ID: 1, //autoincrement\nCNAME: \"lili\",\nCADDRESS: \"Shanghai\"},\n{\nID: 111,\nCNAME: \"zhang\",\nCADDRESS: \"Biejing\",\n},\n}\n\ndb.Create(users)\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_insert.go\n
\u540c\u6837\u7684\uff0c\u7ec8\u7aef\u4e5f\u4f1a\u8f93\u51fa SQL \u8bed\u53e5\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u6210\u529f\u63d2\u5165\u6570\u636e\uff1a
mysql> select * from users;\n+------+-------+----------+\n| id | cname | caddress |\n+------+-------+----------+\n| 1 | lili | Shanghai |\n| 111 | zhang | Biejing |\n+------+-------+----------+\n2 rows in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_5","title":"\u67e5\u8be2\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u7528\u6761\u4ef6\u67e5\u8be2\u90e8\u5206\u6570\u636e\uff0c\u67e5\u8be2 CNAME=zhang
\u7684\u6570\u636e\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_query.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Query\u2014\u2014 String condition** \nres := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&res)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nfmt.Println(res)\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_query.go\n
\u7ec8\u7aef\u7684\u8f93\u51fa\u7ed3\u679c\u4e2d\u5c06\u5305\u542b\u4ee5\u4e0b\u6570\u636e\uff1a
{111 zhang Biejing}\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_6","title":"\u66f4\u65b0\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u66f4\u65b0\u6570\u636e\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_update.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Update** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres:=db.Model(&aUser).Update(\"CADDRESS\", \"HongKong\")\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_update.go\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u66f4\u65b0\u6210\u529f\uff1a
mysql> select * from users;\n+------+-------+----------+\n| id | cname | caddress |\n+------+-------+----------+\n| 111 | zhang | HongKong |\n| 1 | lili | Shanghai |\n+------+-------+----------+\n2 rows in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/gorm-golang-crud-demo/#_7","title":"\u5220\u9664\u6570\u636e","text":"\u4e0b\u9762\u7684\u6f14\u793a\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u8fdb\u884c\u5355\u6761\u6570\u636e\u7684\u5220\u9664\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728\u5220\u9664\u5355\u6761\u8bb0\u5f55\u65f6\uff0c\u9700\u8981\u6307\u5b9a\u4e3b\u952e\uff0c\u5426\u5219\u53ef\u80fd\u4f1a\u89e6\u53d1\u6279\u91cf\u5220\u9664\u3002 \u65b0\u5efa\u4e00\u4e2a gorm_delete.go
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
package main\nimport (\n\"fmt\"\n\n\"gorm.io/driver/mysql\"\n\"gorm.io/gorm\"\n\"gorm.io/gorm/logger\"\n)\n// user model\ntype USER struct {\nID uint `gorm:\"primaryKey\"`\nCNAME string\nCADDRESS string\n}\n\nfunc getDBConn() *gorm.DB {\ndsn := \"root:111@tcp(127.0.0.1:6001)/test?charset=utf8mb4&parseTime=True&loc=Local\" //MO\ndb, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})\n// get connection\nif err != nil {\nfmt.Println(\"Database Connection Failed\") //Connection failed\n} else {\nfmt.Println(\"Database Connection Succeed\") //Connection succeed\n}\nreturn db\n}\n\nfunc main() {\n//get *gorm.DB\ndb := getDBConn()\n\n// auto create table\ndb.AutoMigrate(&USER{})\n\n// **Delete** \naUser := USER{}\ntx := db.Where(\"CNAME = ? \", \"zhang\").Find(&USER{}).Scan(&aUser)\nif tx.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\nres := db.Delete(&aUser)\nif res.Error != nil {\nfmt.Println(tx.Error)\nreturn\n}\n\n}\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 go \u6587\u4ef6\uff1a
go run gorm_delete.go\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u5220\u9664\u6210\u529f\uff1a
mysql> select * from users;\n+------+-------+----------+\n| id | cname | caddress |\n+------+-------+----------+\n| 1 | lili | Shanghai |\n+------+-------+----------+\n1 row in set (0.00 sec)\n
\u4ee5\u4e0a\u4ec5\u662f GORM \u4e2d CRUD \u64cd\u4f5c\u7684\u90e8\u5206\u6f14\u793a\uff0c\u66f4\u591a\u7684\u7528\u6cd5\u548c\u6848\u4f8b\u53ef\u4ee5\u53c2\u8003 GORM \u5b98\u65b9\u6307\u5357
"},{"location":"MatrixOne/Tutorial/rag-demo/","title":"RAG \u5e94\u7528\u57fa\u7840\u793a\u4f8b","text":""},{"location":"MatrixOne/Tutorial/rag-demo/#rag_1","title":"\u4ec0\u4e48\u662f RAG?","text":"RAG\uff0c\u5168\u79f0\u4e3a Retrieval-Augmented Generation\uff08\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff09\uff0c\u662f\u4e00\u79cd\u7ed3\u5408\u4e86\u4fe1\u606f\u68c0\u7d22\u548c\u6587\u672c\u751f\u6210\u7684\u6280\u672f\uff0c\u7528\u4e8e\u63d0\u9ad8\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\u751f\u6210\u6587\u672c\u7684\u51c6\u786e\u6027\u548c\u76f8\u5173\u6027\u3002LLM \u7531\u4e8e\u5176\u8bad\u7ec3\u6570\u636e\u7684\u5c40\u9650\u6027\uff0c\u53ef\u80fd\u65e0\u6cd5\u83b7\u53d6\u6700\u65b0\u7684\u4fe1\u606f\u3002
\u4f8b\u5982\u6211\u5411 GPT \u8be2\u95ee MatrixOne \u7684\u6700\u65b0\u7248\u672c\u65f6\uff0c\u5b83\u5e76\u4e0d\u80fd\u7ed9\u51fa\u7b54\u6848\u3002
\u6b64\u5916\uff0c\u8fd9\u4e9b\u6a21\u578b\u6709\u65f6\u4e5f\u53ef\u80fd\u4ea7\u751f\u8bef\u5bfc\u6027\u7684\u4fe1\u606f\uff0c\u751f\u6210\u4e0e\u4e8b\u5b9e\u4e0d\u7b26\u7684\u5185\u5bb9\u3002\u4f8b\u5982\u5f53\u6211\u8be2\u95ee\u9c81\u8fc5\u548c\u5468\u6811\u4eba\u7684\u5173\u7cfb\u65f6\uff0cGPT \u5f00\u59cb\u4e86\u4e00\u672c\u6b63\u7ecf\u5730\u80e1\u8bf4\u516b\u9053\u3002
\u8981\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u628a LLM \u6a21\u578b\u91cd\u65b0\u518d\u8bad\u7ec3\u4e00\u904d\uff0c\u4f46\u6210\u672c\u662f\u9ad8\u6602\u7684\u3002\u800c RAG \u7684\u4e3b\u8981\u4f18\u52bf\u5728\u4e8e\u53ef\u4ee5\u907f\u514d\u9488\u5bf9\u7279\u5b9a\u4efb\u52a1\u518d\u6b21\u8fdb\u884c\u8bad\u7ec3\uff0c\u5176\u9ad8\u53ef\u7528\u6027\u548c\u4f4e\u95e8\u69db\u4f7f\u4e4b\u6210\u4e3a LLM \u7cfb\u7edf\u4e2d\u6700\u53d7\u6b22\u8fce\u7684\u65b9\u6848\u4e4b\u4e00\uff0c\u8bb8\u591a LLM \u5e94\u7528\u90fd\u4f1a\u57fa\u4e8e RAG \u6784\u5efa\u3002RAG \u7684\u6838\u5fc3\u601d\u60f3\u662f\u8ba9\u6a21\u578b\u5728\u751f\u6210\u56de\u7b54\u65f6\uff0c\u4e0d\u4ec5\u4f9d\u8d56\u4e8e\u5176\u5728\u8bad\u7ec3\u9636\u6bb5\u5b66\u5230\u7684\u77e5\u8bc6\uff0c\u8fd8\u80fd\u5229\u7528\u5916\u90e8\u7684\u3001\u6700\u65b0\u7684\u3001\u4e13\u6709\u7684\u4fe1\u606f\u6e90\uff0c\u56e0\u6b64\u7528\u6237\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u989d\u5916\u9644\u52a0\u5916\u90e8\u77e5\u8bc6\u5e93\uff0c\u4e30\u5bcc\u8f93\u5165\uff0c\u4ece\u800c\u4f18\u5316\u6a21\u578b\u7684\u8f93\u51fa\u6548\u679c\u3002
RAG \u7684\u5de5\u4f5c\u6d41\u7a0b\u901a\u5e38\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a
\u4ee5\u4e0b\u4e3a Native RAG \u7684\u6d41\u7a0b\u56fe\uff1a
\u53ef\u4ee5\u770b\u5230\uff0c\u68c0\u7d22\u73af\u8282\u5728 RAG \u67b6\u6784\u4e2d\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\uff0cMatrixOne \u5177\u6709\u5411\u91cf\u68c0\u7d22\u7684\u80fd\u529b\uff0c\u8fd9\u4e3a\u6784\u5efa RAG \u5e94\u7528\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u68c0\u7d22\u652f\u6301\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#matrixone-rag","title":"Matrixone \u5728 RAG \u4e2d\u7684\u4f5c\u7528","text":"Matrxione \u4f5c\u4e3a\u8d85\u878d\u5408\u6570\u636e\u5e93\uff0c\u81ea\u5e26\u5411\u91cf\u80fd\u529b\uff0c\u8fd9\u5728 RAG \u5e94\u7528\u4e2d\u8d77\u7740\u91cd\u8981\u7684\u4f5c\u7528\uff0c\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a
\u9ad8\u6548\u7684\u4fe1\u606f\u68c0\u7d22\uff1aMatrxione \u62e5\u6709\u5411\u91cf\u6570\u636e\u7c7b\u578b\uff0c\u4e13\u95e8\u7528\u4e8e\u5904\u7406\u548c\u5b58\u50a8\u9ad8\u7ef4\u5411\u91cf\u6570\u636e\uff0c\u5b83\u901a\u8fc7\u7279\u6b8a\u7684\u6570\u636e\u7ed3\u6784\u548c\u7d22\u5f15\u7b56\u7565\uff0c\u5982 KNN \u67e5\u8be2\uff0c\u6765\u5feb\u901f\u627e\u5230\u4e0e\u67e5\u8be2\u5411\u91cf\u6700\u76f8\u4f3c\u7684\u6570\u636e\u9879\u3002
\u652f\u6301\u5927\u89c4\u6a21\u6570\u636e\u5904\u7406\uff1aMatrxione \u80fd\u591f\u6709\u6548\u7ba1\u7406\u548c\u5904\u7406\u5927\u89c4\u6a21\u7684\u5411\u91cf\u6570\u636e\uff0c\u8fd9\u5bf9\u4e8e RAG \u7cfb\u7edf\u7684\u68c0\u7d22\u7ec4\u4ef6\u6765\u8bf4\u662f\u6838\u5fc3\u529f\u80fd\uff0c\u5b83\u4f7f\u5f97 RAG \u7cfb\u7edf\u80fd\u591f\u5feb\u901f\u4ece\u6d77\u91cf\u6570\u636e\u4e2d\u68c0\u7d22\u51fa\u4e0e\u7528\u6237\u67e5\u8be2\u6700\u76f8\u5173\u7684\u4fe1\u606f\u3002
\u63d0\u9ad8\u751f\u6210\u8d28\u91cf\uff1a\u901a\u8fc7 Matrxione \u5411\u91cf\u80fd\u529b\u7684\u68c0\u7d22\u529f\u80fd\uff0cRAG \u6280\u672f\u80fd\u591f\u5f15\u5165\u5916\u90e8\u77e5\u8bc6\u5e93\u4e2d\u7684\u4fe1\u606f\uff0c\u751f\u6210\u66f4\u52a0\u51c6\u786e\u3001\u4e30\u5bcc\u548c\u5177\u6709\u4e0a\u4e0b\u6587\u7684\u6587\u672c\uff0c\u4ece\u800c\u63d0\u5347\u751f\u6210\u6587\u672c\u7684\u8d28\u91cf\u3002
\u5b89\u5168\u6027\u548c\u9690\u79c1\u4fdd\u62a4\uff1aMatrxione \u8fd8\u53ef\u4ee5\u901a\u8fc7\u52a0\u5bc6\u5b58\u50a8\u548c\u8bbf\u95ee\u63a7\u5236\u7b49\u6570\u636e\u5b89\u5168\u63aa\u65bd\u6765\u4fdd\u62a4\u6570\u636e\uff0c\u8fd9\u5bf9\u4e8e\u5904\u7406\u654f\u611f\u6570\u636e\u7684 RAG \u5e94\u7528\u5c24\u5176\u91cd\u8981\u3002
\u7b80\u5316\u5f00\u53d1\u6d41\u7a0b\uff1a\u4f7f\u7528 Matrxione \u53ef\u4ee5\u7b80\u5316 RAG \u5e94\u7528\u7684\u5f00\u53d1\u6d41\u7a0b\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u5b58\u50a8\u548c\u68c0\u7d22\u5411\u91cf\u5316\u6570\u636e\u7684\u9ad8\u6548\u673a\u5236\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u5f00\u53d1\u8005\u5728\u6570\u636e\u7ba1\u7406\u65b9\u9762\u7684\u5de5\u4f5c\u8d1f\u62c5\u3002
\u672c\u6587\u57fa\u4e8e Ollama\uff0c\u7ed3\u5408 Llama2 \u548c Mxbai-embed-large\uff0c\u5229\u7528 Matrixone \u7684\u5411\u91cf\u80fd\u529b\u5feb\u901f\u6784\u5efa\u4e00\u4e2a Native RAG \u5e94\u7528\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Tutorial/rag-demo/#_2","title":"\u76f8\u5173\u77e5\u8bc6","text":"Ollama: Ollama \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5927\u578b\u8bed\u8a00\u6a21\u578b\u670d\u52a1\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u5728\u81ea\u5df1\u7684\u786c\u4ef6\u73af\u5883\u4e2d\u8f7b\u677e\u90e8\u7f72\u548c\u4f7f\u7528\u5927\u89c4\u6a21\u9884\u8bad\u7ec3\u6a21\u578b\u3002Ollama \u7684\u4e3b\u8981\u529f\u80fd\u662f\u5728 Docker \u5bb9\u5668\u5185\u90e8\u7f72\u548c\u7ba1\u7406\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08LLM\uff09\uff0c\u4f7f\u7528\u6237\u80fd\u591f\u5feb\u901f\u5730\u5728\u672c\u5730\u8fd0\u884c\u8fd9\u4e9b\u6a21\u578b\u3002Ollama \u7b80\u5316\u4e86\u90e8\u7f72\u8fc7\u7a0b\uff0c\u901a\u8fc7\u7b80\u5355\u7684\u5b89\u88c5\u6307\u4ee4\uff0c\u7528\u6237\u53ef\u4ee5\u6267\u884c\u4e00\u6761\u547d\u4ee4\u5c31\u5728\u672c\u5730\u8fd0\u884c\u5f00\u6e90\u5927\u578b\u8bed\u8a00\u6a21\u578b\u3002
Llama2\uff1allama2 \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u8bed\u8a00\u5927\u6a21\u578b\uff0c\u53ef\u4ee5\u7406\u89e3\u548c\u751f\u6210\u957f\u6587\u672c\uff0c\u8be5\u6a21\u578b\u53ef\u7528\u4e8e\u7814\u7a76\u548c\u5546\u4e1a\u7528\u9014\u3002
Mxbai-embed-large\uff1amxbai-embed-large \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5d4c\u5165\u6a21\u578b\uff0c\u4e13\u4e3a\u6587\u672c\u5d4c\u5165\u548c\u68c0\u7d22\u4efb\u52a1\u8bbe\u8ba1\uff0c\u6a21\u578b\u751f\u6210\u7684\u5d4c\u5165\u5411\u91cf\u5927\u5c0f\u4e3a 1024\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#_3","title":"\u8f6f\u4ef6\u5b89\u88c5","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -V\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\uff1a
pip3 install pymysql\n
ollama -v \n
llama2
\u548c embedding \u6a21\u578b mxbai-embed-large
\uff1aollama pull llama2\nollama pull mxbai-embed-large\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#_4","title":"\u6784\u5efa\u5e94\u7528","text":""},{"location":"MatrixOne/Tutorial/rag-demo/#_5","title":"\u5efa\u8868","text":"\u8fde\u63a5 MatrixOne\uff0c\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3a rag_tab
\u7684\u8868\u6765\u5b58\u50a8\u6587\u672c\u4fe1\u606f\u548c\u5bf9\u5e94\u7684\u5411\u91cf\u4fe1\u606f\u3002
create table rag_tab(content text,embedding vecf32(1024));\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#matrixone","title":"\u6587\u672c\u5411\u91cf\u5316\u5b58\u50a8\u5230 MatrixOne","text":"\u521b\u5efa python \u6587\u4ef6 rag_example.py\uff0c\u5229\u7528 mxbai-embed-large \u5d4c\u5165\u6a21\u578b\u5c06\u6587\u672c\u4fe1\u606f\u5207\u5206\u548c\u5411\u91cf\u5316\uff0c\u7136\u540e\u5b58\u5230 MatrixOne \u7684 rag_tab
\u8868\u4e2d\u3002
import ollama\nimport pymysql.cursors\n\nconn = pymysql.connect(\n host='127.0.0.1',\n port=6001,\n user='root',\n password = \"111\",\n db='db1',\n autocommit=True\n )\ncursor = conn.cursor()\n\n#\u751f\u6210 embeddings\ndocuments = [\n\"MatrixOne is a hyper-converged cloud & edge native distributed database with a structure that separates storage, computation, and transactions to form a consolidated HSTAP data engine. This engine enables a single database system to accommodate diverse business loads such as OLTP, OLAP, and stream computing. It also supports deployment and utilization across public, private, and edge clouds, ensuring compatibility with diverse infrastructures.\",\n\"MatrixOne touts significant features, including real-time HTAP, multi-tenancy, stream computation, extreme scalability, cost-effectiveness, enterprise-grade availability, and extensive MySQL compatibility. MatrixOne unifies tasks traditionally performed by multiple databases into one system by offering a comprehensive ultra-hybrid data solution. This consolidation simplifies development and operations, minimizes data fragmentation, and boosts development agility.\",\n\"MatrixOne is optimally suited for scenarios requiring real-time data input, large data scales, frequent load fluctuations, and a mix of procedural and analytical business operations. It caters to use cases such as mobile internet apps, IoT data applications, real-time data warehouses, SaaS platforms, and more.\",\n\"Matrix is a collection of complex or real numbers arranged in a rectangular array.\",\n\"The lastest version of MatrixOne is 1.2.1, releases on 30th June, 2024.\",\n\"We are excited to announce MatrixOne 0.8.0 release on 2023/6/30.\"\n]\n\nfor i,d in enumerate(documents):\n response = ollama.embeddings(model=\"mxbai-embed-large\", prompt=d)\n embedding = response[\"embedding\"]\n insert_sql = \"insert into rag_tab(content,embedding) values (%s, %s)\"\n data_to_insert = (d, str(embedding))\n cursor.execute(insert_sql, data_to_insert)\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#rag_tab","title":"\u67e5\u770b rag_tab
\u8868\u4e2d\u6570\u91cf","text":"mysql> select count(*) from rag_tab;\n+----------+\n| count(*) |\n+----------+\n| 6 |\n+----------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6570\u636e\u6210\u529f\u5b58\u50a8\u5230\u6570\u636e\u5e93\u4e2d\u3002
\u5728\u5927\u89c4\u6a21\u9ad8\u7ef4\u6570\u636e\u68c0\u7d22\u65f6\uff0c\u5982\u679c\u91c7\u7528\u5168\u91cf\u641c\u7d22\uff0c\u9700\u8981\u5bf9\u6bcf\u4e2a\u67e5\u8be2\u90fd\u6267\u884c\u4e0e\u6574\u4e2a\u6570\u636e\u96c6\u4e2d\u6bcf\u4e2a\u5411\u91cf\u7684\u76f8\u4f3c\u5ea6\u8ba1\u7b97\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u5de8\u5927\u7684\u6027\u80fd\u5f00\u9500\u548c\u5ef6\u8fdf\u3002\u800c\u4f7f\u7528\u5411\u91cf\u7d22\u5f15\u53ef\u4ee5\u6709\u6548\u5730\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\uff0c\u901a\u8fc7\u5efa\u7acb\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u6765\u4f18\u5316\u641c\u7d22\u8fc7\u7a0b\uff0c\u63d0\u9ad8\u68c0\u7d22\u6027\u80fd\uff0c\u964d\u4f4e\u8ba1\u7b97\u548c\u5b58\u50a8\u6210\u672c\uff0c\u540c\u65f6\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u4e3a\u5411\u91cf\u5b57\u6bb5\u5efa\u7acb IVF-FLAT \u5411\u91cf\u7d22\u5f15
SET GLOBAL experimental_ivf_index = 1;--\u5f00\u542f\u5411\u91cf\u7d22\u5f15\ncreate index idx_rag using ivfflat on rag_tab(embedding) lists=1 op_type \"vector_l2_ops\";\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#_6","title":"\u5411\u91cf\u68c0\u7d22","text":"\u6570\u636e\u51c6\u5907\u597d\u4ee5\u540e\u5c31\u53ef\u4ee5\u6839\u636e\u6211\u4eec\u63d0\u51fa\u7684\u95ee\u9898\u5728\u6570\u636e\u5e93\u641c\u7d22\u6700\u76f8\u4f3c\u7684\u5185\u5bb9\uff0c\u8fd9\u4e00\u6b65\u4e3b\u8981\u4f9d\u8d56 MatrixOne \u7684\u5411\u91cf\u68c0\u7d22\u80fd\u529b\uff0cMatrixOne \u652f\u6301\u591a\u79cd\u76f8\u4f3c\u5ea6\u641c\u7d22\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528 l2_distance
\u6765\u68c0\u7d22\uff0c\u5e76\u8bbe\u7f6e\u8fd4\u56de\u7ed3\u679c\u6570\u91cf\u4e3a 3\u3002
prompt = \"What is the latest version of MatrixOne?\"\n\nresponse = ollama.embeddings(\n prompt=prompt,\n model=\"mxbai-embed-large\"\n)\nquery_embedding= response[\"embedding\"]\nquery_sql = \"select content from rag_tab order by l2_distance(embedding,%s) asc limit 3\"\ndata_to_query = str(query_embedding)\ncursor.execute(query_sql, data_to_query)\ndata = cursor.fetchall()\n
"},{"location":"MatrixOne/Tutorial/rag-demo/#_7","title":"\u589e\u5f3a\u751f\u6210","text":"\u6211\u4eec\u5c06\u4e0a\u4e00\u6b65\u68c0\u7d22\u5230\u7684\u5185\u5bb9\u4e0e LLM \u7ed3\u5408\uff0c\u751f\u6210\u7b54\u6848\u3002
#\u589e\u5f3a\u751f\u6210\noutput = ollama.generate(\n model=\"llama2\",\n prompt=f\"Using this data: {data}. Respond to this prompt: {prompt}\"\n)\n\nprint(output['response'])\n
\u63a7\u5236\u53f0\u8f93\u51fa\u76f8\u5173\u56de\u7b54\uff1a
Based on the provided data, the latest version of MatrixOne is 1.2.1, which was released on June 30th, 2024.\n
\u5728\u589e\u5f3a\u540e\uff0c\u6a21\u578b\u751f\u6210\u4e86\u6b63\u786e\u7b54\u6848\u3002
"},{"location":"MatrixOne/Tutorial/rag-demo/#_8","title":"\u53c2\u8003\u6587\u6863","text":"\u5f53\u4e0b\uff0c\u4ee5\u56fe\u641c\u56fe\u548c\u4ee5\u6587\u641c\u56fe\u7684\u76f8\u5173\u5e94\u7528\u6db5\u76d6\u4e86\u5e7f\u6cdb\u7684\u9886\u57df\uff0c\u5728\u7535\u5b50\u5546\u52a1\u4e2d\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u4e0a\u4f20\u56fe\u7247\u6216\u6587\u672c\u63cf\u8ff0\u6765\u641c\u7d22\u5546\u54c1\uff1b\u5728\u793e\u4ea4\u5a92\u4f53\u5e73\u53f0\uff0c\u901a\u8fc7\u56fe\u50cf\u6216\u6587\u672c\u5feb\u901f\u627e\u5230\u76f8\u5173\u5185\u5bb9\uff0c\u589e\u5f3a\u7528\u6237\u7684\u4f53\u9a8c\uff1b\u800c\u5728\u7248\u6743\u68c0\u6d4b\u65b9\u9762\uff0c\u5219\u53ef\u4ee5\u5e2e\u52a9\u8bc6\u522b\u548c\u4fdd\u62a4\u56fe\u50cf\u7248\u6743\uff1b\u6b64\u5916\uff0c\u4ee5\u6587\u641c\u56fe\u8fd8\u5e7f\u6cdb\u5e94\u7528\u4e8e\u641c\u7d22\u5f15\u64ce\uff0c\u5e2e\u52a9\u7528\u6237\u901a\u8fc7\u5173\u952e\u8bcd\u627e\u5230\u7279\u5b9a\u56fe\u50cf\uff0c\u800c\u4ee5\u56fe\u641c\u56fe\u5219\u5728\u673a\u5668\u5b66\u4e60\u548c\u4eba\u5de5\u667a\u80fd\u9886\u57df\u4e2d\u7528\u4e8e\u56fe\u50cf\u8bc6\u522b\u548c\u5206\u7c7b\u4efb\u52a1\u3002
\u4ee5\u4e0b\u4e3a\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u7684\u6d41\u7a0b\u56fe\uff1a
\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\u4e2d\uff0c\u6d89\u53ca\u5230\u5bf9\u56fe\u7247\u7684\u5411\u91cf\u5316\u5b58\u50a8\u548c\u68c0\u7d22\uff0c\u800c MatrixOne \u5177\u5907\u5411\u91cf\u80fd\u529b\uff0c\u4e14\u63d0\u4f9b\u591a\u79cd\u68c0\u7d22\u65b9\u5f0f\uff0c\u8fd9\u4e3a\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u5e94\u7528\u63d0\u4f9b\u4e86\u5173\u952e\u7684\u6280\u672f\u652f\u6301\u3002
\u5728\u672c\u7ae0\u8282\uff0c\u6211\u4eec\u5c06\u57fa\u4e8e MatrixOne \u7684\u5411\u91cf\u80fd\u529b\u6765\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u7684\u5e94\u7528\u3002
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_2","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":""},{"location":"MatrixOne/Tutorial/search-picture-demo/#_3","title":"\u76f8\u5173\u77e5\u8bc6","text":"Transformers\uff1aTransformers \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff0c\u63d0\u4f9b\u4e86\u5e7f\u6cdb\u7684\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u901a\u8fc7 Transformers \u5e93\uff0c\u7814\u7a76\u4eba\u5458\u548c\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5730\u4f7f\u7528\u548c\u96c6\u6210 CLIP \u6a21\u578b\u5230\u4ed6\u4eec\u7684\u9879\u76ee\u4e2d\u3002
CLIP: CLIP \u6a21\u578b\u662f\u7531 OpenAI \u53d1\u5e03\u7684\u4e00\u79cd\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff0c\u6838\u5fc3\u662f\u901a\u8fc7\u5bf9\u6bd4\u5b66\u4e60\u7684\u65b9\u6cd5\u6765\u7edf\u4e00\u5904\u7406\u6587\u672c\u548c\u56fe\u50cf\uff0c\u4ece\u800c\u80fd\u591f\u901a\u8fc7\u6587\u672c - \u56fe\u50cf\u76f8\u4f3c\u5ea6\u6765\u5b8c\u6210\u56fe\u50cf\u5206\u7c7b\u7b49\u4efb\u52a1\uff0c\u800c\u65e0\u9700\u76f4\u63a5\u4f18\u5316\u4efb\u52a1\u3002\u5b83\u53ef\u4ee5\u7ed3\u5408\u5411\u91cf\u6570\u636e\u5e93\uff0c\u6765\u6784\u5efa\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe\u7684\u5de5\u5177\u3002\u901a\u8fc7 CLIP \u6a21\u578b\u63d0\u53d6\u56fe\u50cf\u7684\u9ad8\u7ef4\u5411\u91cf\u8868\u793a\uff0c\u4ee5\u6355\u83b7\u5176\u8bed\u4e49\u548c\u611f\u77e5\u7279\u5f81\uff0c\u7136\u540e\u5c06\u8fd9\u4e9b\u56fe\u50cf\u7f16\u7801\u5230\u5d4c\u5165\u7a7a\u95f4\u4e2d\u3002\u5728\u67e5\u8be2\u65f6\uff0c\u6837\u672c\u56fe\u50cf\u901a\u8fc7\u76f8\u540c\u7684 CLIP \u7f16\u7801\u5668\u6765\u83b7\u53d6\u5176\u5d4c\u5165\uff0c\u6267\u884c\u5411\u91cf\u76f8\u4f3c\u6027\u641c\u7d22\u4ee5\u6709\u6548\u5730\u627e\u5230\u524d k \u4e2a\u6700\u63a5\u8fd1\u7684\u6570\u636e\u5e93\u56fe\u50cf\u5411\u91cf\u3002
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_4","title":"\u8f6f\u4ef6\u5b89\u88c5","text":"\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
python3 -V\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 pymysql
\u5de5\u5177\uff1a
pip install pymysql\n
transformers
\u5e93\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 transformers
\u5e93\uff1apip install transformers\n
Pillow
\u5e93\u3002\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 Pillow
\u5e93\uff1apip install pillow \n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_5","title":"\u6784\u5efa\u5e94\u7528","text":""},{"location":"MatrixOne/Tutorial/search-picture-demo/#_6","title":"\u5efa\u8868","text":"\u8fde\u63a5 MatrixOne\uff0c\u5efa\u7acb\u4e00\u4e2a\u540d\u4e3a pic_tab
\u7684\u8868\u6765\u5b58\u50a8\u56fe\u7247\u8def\u5f84\u4fe1\u606f\u548c\u5bf9\u5e94\u7684\u5411\u91cf\u4fe1\u606f\u3002
create table pic_tab(pic_path varchar(200), embedding vecf64(512));\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_7","title":"\u52a0\u8f7d\u6a21\u578b","text":"from transformers import CLIPProcessor, CLIPModel\n\n# \u4ece HuggingFace \u52a0\u8f7d\u6a21\u578b\nmodel = CLIPModel.from_pretrained(\"openai/clip-vit-base-patch32\")\nprocessor = CLIPProcessor.from_pretrained(\"openai/clip-vit-base-patch32\")\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_8","title":"\u904d\u5386\u56fe\u7247\u8def\u5f84","text":"\u5b9a\u4e49\u65b9\u6cd5 find_img_files
\u904d\u5386\u672c\u5730\u56fe\u7247\u6587\u4ef6\u5939\uff0c\u8fd9\u91cc\u6211\u9884\u5148\u5728\u672c\u5730\u5b58\u4e86\u82f9\u679c\u3001\u9999\u8549\u3001\u84dd\u8393\u3001\u6a31\u6843\u3001\u674f\u5b50\u4e94\u79cd\u7c7b\u522b\u7684\u6c34\u679c\u56fe\u7247\uff0c\u6bcf\u79cd\u7c7b\u522b\u82e5\u5e72\u5f20\uff0c\u683c\u5f0f\u90fd\u4e3a .jpg
\u3002
def find_img_files(directory):\n img_files = [] # \u7528\u4e8e\u5b58\u50a8\u627e\u5230\u7684.jpg \u6587\u4ef6\u8def\u5f84\n for root, dirs, files in os.walk(directory):\n for file in files:\n if file.lower().endswith('.jpg'):\n full_path = os.path.join(root, file)\n img_files.append(full_path) # \u6784\u5efa\u5b8c\u6574\u7684\u6587\u4ef6\u8def\u5f84\n return img_files\n
\u5b9a\u4e49\u65b9\u6cd5 storage_img
\u5c06\u56fe\u7247\u6620\u5c04\u6210\u5411\u91cf\uff0c\u8fdb\u884c\u5f52\u4e00\u5316\uff08\u975e\u5fc5\u9700\uff09\u5e76\u5b58\u50a8\u5230 MatrixOne \u91cc\u3002MatrixOne \u652f\u6301\u4f7f\u7528 NORMALIZE_L2()
\u51fd\u6570\u5bf9\u5411\u91cf\u6267\u884c L2 \u5f52\u4e00\u5316\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6570\u636e\u7684\u7279\u5f81\u53ef\u80fd\u5206\u5e03\u5728\u4e0d\u540c\u7684\u5c3a\u5ea6\u4e0a\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u67d0\u4e9b\u7279\u5f81\u5bf9\u8ddd\u79bb\u8ba1\u7b97\u6709\u4e0d\u6210\u6bd4\u4f8b\u7684\u5f71\u54cd\u3002\u901a\u8fc7\u5f52\u4e00\u5316\uff0c\u53ef\u4ee5\u51cf\u5c11\u8fd9\u79cd\u5f71\u54cd\uff0c\u4f7f\u4e0d\u540c\u7279\u5f81\u5bf9\u6700\u7ec8\u7ed3\u679c\u7684\u8d21\u732e\u66f4\u52a0\u5747\u8861\u3002\u800c\u5728\u4f7f\u7528 L2 distance \u5ea6\u91cf\u65f6\uff0cL2 \u5f52\u4e00\u5316\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u957f\u5ea6\u7684\u5411\u91cf\u5f71\u54cd\u8ddd\u79bb\u8ba1\u7b97\u3002
import pymysql\nfrom PIL import Image\n\nconn = pymysql.connect(\n host = '127.0.0.1',\n port = 6001,\n user = 'root',\n password = \"111\",\n db = 'db1',\n autocommit = True\n )\n\ncursor = conn.cursor()\n\n# \u628a\u56fe\u50cf\u6620\u5c04\u6210\u5411\u91cf\uff0c\u5b58\u50a8\u5728 MatrixOne \u4e2d\ndef storage_img():\n for file_path in jpg_files:\n image = Image.open(file_path)\n if image.mode != 'RGBA':\n image = image.convert('RGBA')\n inputs = processor(images=image, return_tensors=\"pt\", padding=True)\n img_features = model.get_image_features(inputs[\"pixel_values\"]) # \u4f7f\u7528\u6a21\u578b\u83b7\u53d6\u56fe\u50cf\u7279\u5f81\n img_features = img_features .detach().tolist() # \u5206\u79bb\u5f20\u91cf\uff0c\u8f6c\u6362\u4e3a\u5217\u8868\n embeddings = img_features [0]\n insert_sql = \"insert into pic_tab(pic_path,embedding) values (%s, normalize_l2(%s))\"\n data_to_insert = (file_path, str(embeddings))\n cursor.execute(insert_sql, data_to_insert)\n image.close()\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#pic_tab","title":"\u67e5\u770b pic_tab
\u8868\u4e2d\u6570\u91cf","text":"mysql> select count(*) from pic_tab;\n+----------+\n| count(*) |\n+----------+\n| 4801 |\n+----------+\n1 row in set (0.00 sec)\n
\u53ef\u4ee5\u770b\u5230\uff0c\u6570\u636e\u6210\u529f\u5b58\u50a8\u5230\u6570\u636e\u5e93\u4e2d\u3002
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_9","title":"\u5efa\u7acb\u5411\u91cf\u7d22\u5f15","text":"MatrixOne \u652f\u6301\u5728 IVF-FLAT \u5411\u91cf\u7d22\u5f15\uff0c\u5728\u6ca1\u6709\u7d22\u5f15\u7684\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6b21\u641c\u7d22\u90fd\u9700\u8981\u91cd\u65b0\u8ba1\u7b97\u67e5\u8be2\u56fe\u50cf\u4e0e\u6570\u636e\u5e93\u4e2d\u6bcf\u5f20\u56fe\u50cf\u4e4b\u95f4\u7684\u76f8\u4f3c\u5ea6\u3002\u800c\u7d22\u5f15\u53ef\u4ee5\u51cf\u5c11\u5fc5\u8981\u7684\u8ba1\u7b97\u91cf\uff0c\u53ea\u5bf9\u7d22\u5f15\u4e2d\u6807\u8bb0\u4e3a\u201c\u76f8\u5173\u201d\u7684\u56fe\u50cf\u8fdb\u884c\u76f8\u4f3c\u5ea6\u8ba1\u7b97\u3002
def create_idx(n):\n cursor.execute('SET GLOBAL experimental_ivf_index = 1')\n create_sql = 'create index idx_pic using ivfflat on pic_tab(embedding) lists=%s op_type \"vector_l2_ops\"'\n cursor.execute(create_sql, n)\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_10","title":"\u4ee5\u56fe\uff08\u6587\uff09\u641c\u56fe","text":"\u63a5\u7740\uff0c\u6211\u4eec\u5b9a\u4e49\u65b9\u6cd5 img_search_img
\u548c text_search_img
\u5b9e\u73b0\u4ee5\u56fe\u641c\u56fe\u548c\u4ee5\u6587\u641c\u56fe\uff0cMatrixOne \u5177\u6709\u5411\u91cf\u68c0\u7d22\u80fd\u529b\uff0c\u652f\u6301\u591a\u79cd\u76f8\u4f3c\u5ea6\u641c\u7d22\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528 l2_distance
\u6765\u68c0\u7d22\u3002
# \u4ee5\u56fe\u641c\u56fe\ndef img_search_img(img_path, k):\n image = Image.open(img_path)\n inputs = processor(images=image, return_tensors=\"pt\")\n img_features = model.get_image_features(**inputs)\n img_features = img_features.detach().tolist()\n img_features = img_features[0]\n query_sql = \"select pic_path from pic_tab order by l2_distance(embedding,normalize_l2(%s)) asc limit %s\"\n data_to_query = (str(img_features), k)\n cursor.execute(query_sql, data_to_query)\n global data\n data = cursor.fetchall()\n\n# \u4ee5\u6587\u641c\u56fe\ndef text_search_img(text,k):\n inputs = processor(text=text, return_tensors=\"pt\", padding=True)\n text_features = model.get_text_features(inputs[\"input_ids\"], inputs[\"attention_mask\"])\n embeddings = text_features.detach().tolist()\n embeddings = embeddings[0]\n query_sql = \"select pic_path from pic_tab order by l2_distance(embedding,normalize_l2(%s)) asc limit %s\"\n data_to_query = (str(embeddings),k)\n cursor.execute(query_sql, data_to_query)\n global data\n data = cursor.fetchall()\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_11","title":"\u641c\u7d22\u7ed3\u679c\u5c55\u793a","text":"\u5728\u6839\u636e\u56fe\u7247\u6216\u6587\u5b57\u68c0\u7d22\u5230\u76f8\u5173\u56fe\u7247\u65f6\uff0c\u6211\u4eec\u9700\u8981\u628a\u7ed3\u679c\u6253\u5370\u51fa\u6765\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528 Matplotlib \u6765\u5c55\u793a\u641c\u7d22\u7ed3\u679c\u3002
import matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\n\ndef show_img(img_path,rows,cols):\n if img_path:\n result_path = [img_path] + [path for path_tuple in data for path in path_tuple]\n else:\n result_path = [path for path_tuple in data for path in path_tuple]\n # \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u548c\u5750\u6807\u8f74\n fig, axes = plt.subplots(nrows=rows, ncols=cols, figsize=(10, 10))\n # \u5faa\u73af\u904d\u5386\u56fe\u7247\u8def\u5f84\u548c\u5750\u6807\u8f74\n for i, (result_path, ax) in enumerate(zip(result_path, axes.ravel())):\n image = mpimg.imread(result_path) # \u8bfb\u53d6\u56fe\u7247\n ax.imshow(image) # \u663e\u793a\u56fe\u7247\n ax.axis('off') # \u79fb\u9664\u5750\u6807\u8f74\n ax.set_title(f'image{i + 1}') # \u8bbe\u7f6e\u5b50\u56fe\u6807\u9898\n plt.tight_layout() # \u8c03\u6574\u5b50\u56fe\u95f4\u8ddd\n plt.show() # \u663e\u793a\u6574\u4e2a\u56fe\u5f62\n
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_12","title":"\u67e5\u770b\u7ed3\u679c","text":"\u5728\u4e3b\u7a0b\u5e8f\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff0c\u8fd0\u884c\u7a0b\u5e8f\uff1a
if __name__ == \"__main__\":\n directory_path = '/Users/admin/Downloads/fruit01' # \u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u76ee\u5f55\u8def\u5f84\n jpg_files = find_img_files(directory_path)\n storage_img()\n create_idx(4)\n img_path = '/Users/admin/Downloads/fruit01/blueberry/f_01_04_0450.jpg'\n img_search_img(img_path, 3) # \u4ee5\u56fe\u641c\u56fe\n show_img(img_path,1,4)\n text = [\"Banana\"]\n text_search_img(text,3) # \u4ee5\u6587\u641c\u56fe\n show_img(None,1,3)\n
\u4ee5\u56fe\u641c\u56fe\u7ed3\u679c\uff0c\u5de6\u8fb9\u7b2c\u4e00\u5f20\u56fe\u4e3a\u6bd4\u5bf9\u56fe\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u641c\u7d22\u51fa\u6765\u7684\u56fe\u7247\u4e0e\u88ab\u6bd4\u5bf9\u56fe\u975e\u5e38\u76f8\u4f3c\uff1a
\u4ee5\u6587\u641c\u56fe\u7ed3\u679c\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u641c\u51fa\u6765\u7684\u56fe\u7247\u4e0e\u8f93\u5165\u6587\u672c\u4e00\u81f4\uff1a
"},{"location":"MatrixOne/Tutorial/search-picture-demo/#_13","title":"\u53c2\u8003\u6587\u6863","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 SpringBoot\u3001Spring Data JPA \u548c Intellij IDEA \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#_1","title":"\u5f00\u59cb\u4e4b\u524d","text":"\u672c\u7bc7\u6559\u7a0b\u6d89\u53ca\u5230\u7684\u8f6f\u4ef6\u4ecb\u7ecd\u5982\u4e0b\uff1a
Spring Data JPA\uff1aJPA\uff08Java Persistence API\uff0cJava \u6301\u4e45\u5c42 API\uff09\u662f\u4e00\u79cd\u89c4\u8303\uff0c\u662f JDK 5.0 \u6ce8\u89e3\u6216 XML \u63cf\u8ff0\u5bf9\u8c61\u4e0e\u5173\u7cfb\u8868\u7684\u6620\u5c04\u5173\u7cfb\uff0c\u5e76\u5c06\u8fd0\u884c\u671f\u7684\u5b9e\u4f53\u5bf9\u8c61\u6301\u4e45\u5316\u5230\u6570\u636e\u5e93\u4e2d\u3002Spring Data JPA \u662f\u4e00\u4e2a Java \u5bf9\u8c61\u6620\u5c04\u5173\u7cfb\u7684\u89e3\u51b3\u65b9\u6848\u7684 ORM\uff08Object-Relational Mapping\uff09\u6846\u67b6\uff0c\u662f\u4e00\u4e2a\u5c06\u9762\u5411\u5bf9\u8c61\u7684\u57df\u6a21\u578b\u6620\u5c04\u5230\u5173\u7cfb\u6570\u636e\u5e93\u7684\u5f00\u6e90\u6846\u67b6\u3002
Intellij IDEA\uff1aIntelliJ IDEA \u662f\u4e00\u79cd\u5546\u4e1a\u5316\u9500\u552e\u7684 Java \u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08Integrated Development Environment\uff0cIDE\uff09\u5de5\u5177\u8f6f\u4ef6\u3002\u5b83\u6240\u62e5\u6709\u8bf8\u591a\u63d2\u4ef6\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6211\u4eec\u7684\u5de5\u4f5c\u6548\u7387\u3002
Maven\uff1aMaven \u662f Java \u4e2d\u529f\u80fd\u5f3a\u5927\u7684\u9879\u76ee\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u6839\u636e pom.xml \u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u81ea\u52a8\u4e0b\u8f7d\u548c\u5bfc\u5165 Jar \u6587\u4ef6\u3002\u8fd9\u4e2a\u7279\u6027\u51cf\u5c11\u4e86\u4e0d\u540c\u7248\u672c Jar \u6587\u4ef6\u4e4b\u95f4\u7684\u51b2\u7a81\u3002
Spring\uff1aSpring \u662f Java \u4e2d\u6700\u6d41\u884c\u7684\u6846\u67b6\u4e4b\u4e00\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u4f01\u4e1a\u4f7f\u7528 Spring \u6846\u67b6\u6765\u6784\u5efa\u4ed6\u4eec\u7684\u9879\u76ee\u3002Spring Boot \u6784\u5efa\u5728\u4f20\u7edf\u7684 Spring \u6846\u67b6\u4e4b\u4e0a\u3002\u56e0\u6b64\uff0c\u5b83\u63d0\u4f9b\u4e86 Spring \u7684\u6240\u6709\u7279\u6027\uff0c\u800c\u4e14\u6bd4 Spring \u66f4\u6613\u7528\u3002
Postman: Postman \u662f\u4e00\u4e2a\u7528\u4e8e API \u6d4b\u8bd5\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u662f\u4e00\u4e2a HTTP \u5ba2\u6237\u7aef\uff0c\u5229\u7528\u56fe\u5f62\u7528\u6237\u754c\u9762\u6d4b\u8bd5 HTTP \u8bf7\u6c42\uff0c\u4ee5\u83b7\u5f97\u9700\u8981\u8fdb\u884c\u9a8c\u8bc1\u7684\u4e0d\u540c\u7c7b\u578b\u7684\u54cd\u5e94\u3002
\u6309\u7167\u6b65\u9aa4\u4ecb\u7ecd\u5b8c\u6210\u5b89\u88c5\u5355\u673a\u7248 MatrixOne\uff0c\u5728 MySQL \u5ba2\u6237\u7aef\u65b0\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a test
\u6570\u636e\u5e93\u3002
mysql> create database test;\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-intellij-idea-spring-boot","title":"2. \u4f7f\u7528 IntelliJ IDEA \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Spring Boot \u9879\u76ee","text":"\u9009\u62e9 Spring Initializer\uff0c\u6309\u9700\u547d\u540d\u9879\u76ee\u540d\u79f0\u3002
\u9009\u62e9\u5982\u4e0b\u4f9d\u8d56\u9879\uff1a
\u70b9\u51fb Create \u521b\u5efa\u9879\u76ee\u3002\u4f9d\u8d56\u9879\u5217\u5728 pom.xml \u6587\u4ef6\u4e2d\u3002\u901a\u5e38\u4f60\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u4e1c\u897f\u3002
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n <groupId>com.example</groupId>\n <artifactId>jpademo</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <name>jpademo</name>\n <description>jpademo</description>\n\n <properties>\n <java.version>1.8</java.version>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n </properties>\n\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-data-jpa</artifactId>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-jdbc</artifactId>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-web</artifactId>\n </dependency>\n\n <dependency>\n <groupId>mysql</groupId>\n <artifactId>mysql-connector-java</artifactId>\n <scope>runtime</scope>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-test</artifactId>\n <scope>test</scope>\n <exclusions>\n <exclusion>\n <groupId>org.junit.vintage</groupId>\n <artifactId>junit-vintage-engine</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n </dependencies>\n\n <dependencyManagement>\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-dependencies</artifactId>\n <version>${spring-boot.version}</version>\n <type>pom</type>\n <scope>import</scope>\n </dependency>\n </dependencies>\n </dependencyManagement>\n\n <build>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-compiler-plugin</artifactId>\n <version>3.8.1</version>\n <configuration>\n <source>1.8</source>\n <target>1.8</target>\n <encoding>UTF-8</encoding>\n </configuration>\n </plugin>\n <plugin>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-maven-plugin</artifactId>\n <version>2.3.7.RELEASE</version>\n <configuration>\n <mainClass>com.example.jpademo.JpademoApplication</mainClass>\n </configuration>\n <executions>\n <execution>\n <id>repackage</id>\n <goals>\n <goal>repackage</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n\n</project>\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-applicationproperties","title":"3. \u4fee\u6539 application.properties \u6587\u4ef6","text":"\u8fdb\u5165\u5230 resources \u6587\u4ef6\u76ee\u5f55\u4e0b\uff0c\u914d\u7f6e application.properties \u6587\u4ef6\uff0c\u5b8c\u6210 MatrixOne \u8fde\u63a5\u3002
# Application Name\nspring.application.name=jpademo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with parameters\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n# Web application port\nserver.port=8080\n\n# Hibernate configurations\nspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect\nspring.jpa.properties.hibernate.id.new_generator_mappings = false\nspring.jpa.properties.hibernate.format_sql = true\nspring.jpa.hibernate.ddl-auto = validate\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-matrixone","title":"4. \u5728 MatrixOne \u4e2d\u65b0\u5efa\u8868\u5e76\u63d2\u5165\u6570\u636e","text":"\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5\u5230 MatrixOne \u5e76\u6267\u884c\u4ee5\u4e0b SQL \u8bed\u53e5\u3002\u4f60\u53ef\u4ee5\u5c06\u8fd9\u4e9b SQL \u8bed\u53e5\u4fdd\u5b58\u5728 /resource/database/ \u76ee\u5f55\u4e0b\u7684 book.sql \u4e2d\u3002
mysql> USE test;\nmysql> CREATE TABLE IF NOT EXISTS `book` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `author` varchar(255) DEFAULT NULL,\n `category` varchar(255) DEFAULT NULL,\n `name` varchar(255) DEFAULT NULL,\n `pages` int(11) DEFAULT NULL,\n `price` int(11) DEFAULT NULL,\n `publication` varchar(255) DEFAULT NULL,\n PRIMARY KEY (`id`)\n );\nmysql> INSERT INTO `book` (`id`, `author`, `category`, `name`, `pages`, `price`, `publication`) VALUES\n(1, 'Antoine de Saint-Exupery', 'Fantancy', 'The Little Prince', 100, 50, 'Amazon'),\n(2, 'J. K. Rowling', 'Fantancy', 'Harry Potter and the Sorcerer''s Stone', 1000, 200, 'Amazon'),\n(3, 'Lewis Carroll', 'Fantancy', 'Alice''s Adventures in Wonderland', 1500, 240, 'Amazon');\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#_3","title":"\u7f16\u5199\u4ee3\u7801","text":"\u5b8c\u6210\u73af\u5883\u914d\u7f6e\u540e\uff0c\u6211\u4eec\u7f16\u5199\u4ee3\u7801\u6765\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u5e94\u7528\u7a0b\u5e8f\u3002
\u5728\u5b8c\u6210\u7f16\u5199\u4ee3\u7801\u540e\uff0c\u4f60\u5c06\u62e5\u6709\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684\u9879\u76ee\u7ed3\u6784\u3002\u4f60\u53ef\u4ee5\u9884\u5148\u521b\u5efa\u8fd9\u4e9b\u5305\u548c java \u7c7b\u3002
\u6211\u4eec\u5c06\u4e3a\u8fd9\u4e2a\u6f14\u793a\u5e94\u7528\u7a0b\u5e8f\u7f16\u5199\u521b\u5efa\u3001\u66f4\u65b0\u3001\u63d2\u5165\u3001\u5220\u9664\u548c\u9009\u62e9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-bookstorecontrollerjava","title":"1. BookStoreController.java","text":"package com.example.jpademo.controller;\n\nimport com.example.jpademo.entity.Book;\nimport com.example.jpademo.services.IBookStoreService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.stereotype.Controller;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\n\n@Controller\n@RequestMapping(\"bookservice\")\npublic class BookStoreController {\n\n @Autowired\n private IBookStoreService service;\n\n @GetMapping(\"books\")\n public ResponseEntity<List<Book>> getBooks(){\n\n List<Book> books = service.getBooks();\n return new ResponseEntity<List<Book>>(books, HttpStatus.OK);\n\n }\n\n @GetMapping(\"books/{id}\")\n public ResponseEntity<Book> getBook(@PathVariable(\"id\") Integer id){\n Book book = service.getBook(id);\n return new ResponseEntity<Book>(book, HttpStatus.OK);\n }\n\n @PostMapping(\"books\")\n public ResponseEntity<Book> createBook(@RequestBody Book book){\n Book b = service.createBook(book);\n return new ResponseEntity<Book>(b, HttpStatus.OK);\n\n }\n\n @PutMapping(\"books/{id}\")\n public ResponseEntity<Book> updateBook(@PathVariable(\"id\") int id, @RequestBody Book book){\n\n Book b = service.updateBook(id, book);\n return new ResponseEntity<Book>(b, HttpStatus.OK);\n }\n\n @DeleteMapping(\"books/{id}\")\n public ResponseEntity<String> deleteBook(@PathVariable(\"id\") int id){\n boolean isDeleted = service.deleteBook(id);\n if(isDeleted){\n String responseContent = \"Book has been deleted successfully\";\n return new ResponseEntity<String>(responseContent,HttpStatus.OK);\n }\n String error = \"Error while deleting book from database\";\n return new ResponseEntity<String>(error,HttpStatus.INTERNAL_SERVER_ERROR);\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-boostoredaojava","title":"2. BooStoreDAO.java","text":"package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\nimport org.springframework.stereotype.Repository;\nimport org.springframework.transaction.annotation.Transactional;\n\nimport javax.persistence.EntityManager;\nimport javax.persistence.PersistenceContext;\nimport javax.persistence.Query;\nimport java.util.List;\n\n@Transactional\n@Repository\npublic class BookStoreDAO implements IBookStoreDAO {\n\n @PersistenceContext\n private EntityManager entityManager;\n\n /**\n * This method is responsible to get all books available in database and return it as List<Book>\n */\n @SuppressWarnings(\"unchecked\")\n @Override\n public List<Book> getBooks() {\n\n String hql = \"FROM Book as atcl ORDER BY atcl.id\";\n return (List<Book>) entityManager.createQuery(hql).getResultList();\n }\n\n /**\n * This method is responsible to get a particular Book detail by given book id\n */\n @Override\n public Book getBook(int bookId) {\n\n return entityManager.find(Book.class, bookId);\n }\n\n /**\n * This method is responsible to create new book in database\n */\n @Override\n public Book createBook(Book book) {\n entityManager.persist(book);\n Book b = getLastInsertedBook();\n return b;\n }\n\n /**\n * This method is responsible to update book detail in database\n */\n @Override\n public Book updateBook(int bookId, Book book) {\n\n //First We are taking Book detail from database by given book id and\n // then updating detail with provided book object\n Book bookFromDB = getBook(bookId);\n bookFromDB.setName(book.getName());\n bookFromDB.setAuthor(book.getAuthor());\n bookFromDB.setCategory(book.getCategory());\n bookFromDB.setPublication(book.getPublication());\n bookFromDB.setPages(book.getPages());\n bookFromDB.setPrice(book.getPrice());\n\n entityManager.flush();\n\n //again i am taking updated result of book and returning the book object\n Book updatedBook = getBook(bookId);\n\n return updatedBook;\n }\n\n /**\n * This method is responsible for deleting a particular(which id will be passed that record)\n * record from the database\n */\n @Override\n public boolean deleteBook(int bookId) {\n Book book = getBook(bookId);\n entityManager.remove(book);\n\n //we are checking here that whether entityManager contains earlier deleted book or not\n // if contains then book is not deleted from DB that's why returning false;\n boolean status = entityManager.contains(book);\n if(status){\n return false;\n }\n return true;\n }\n\n /**\n * This method will get the latest inserted record from the database and return the object of Book class\n * @return book\n */\n private Book getLastInsertedBook(){\n String hql = \"from Book order by id DESC\";\n Query query = entityManager.createQuery(hql);\n query.setMaxResults(1);\n Book book = (Book)query.getSingleResult();\n return book;\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-ibookstoredaojava","title":"3. IBookStoreDAO.java","text":"package com.example.jpademo.dao;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreDAO {\n\n List<Book> getBooks();\n Book getBook(int bookId);\n Book createBook(Book book);\n Book updateBook(int bookId,Book book);\n boolean deleteBook(int bookId);\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-bookjava","title":"4. Book.java","text":"package com.example.jpademo.entity;\n\nimport javax.persistence.*;\nimport java.io.Serializable;\n\n@Entity\n@Table(name=\"book\")\npublic class Book implements Serializable {\n\n private static final long serialVersionUID = 1L;\n @Id\n @GeneratedValue(strategy= GenerationType.AUTO)\n @Column(name=\"id\")\n private int id;\n\n @Column(name=\"name\")\n private String name;\n\n @Column(name=\"author\")\n private String author;\n\n @Column(name=\"publication\")\n private String publication;\n\n @Column(name=\"category\")\n private String category;\n\n @Column(name=\"pages\")\n private int pages;\n\n @Column(name=\"price\")\n private int price;\n\n public int getId() {\n return id;\n }\n\n public void setId(int id) {\n this.id = id;\n }\n\n public String getName() {\n return name;\n }\n\n public void setName(String name) {\n this.name = name;\n }\n\n public String getAuthor() {\n return author;\n }\n\n public void setAuthor(String author) {\n this.author = author;\n }\n\n public String getPublication() {\n return publication;\n }\n\n public void setPublication(String publication) {\n this.publication = publication;\n }\n\n public String getCategory() {\n return category;\n }\n\n public void setCategory(String category) {\n this.category = category;\n }\n\n public int getPages() {\n return pages;\n }\n\n public void setPages(int pages) {\n this.pages = pages;\n }\n\n public int getPrice() {\n return price;\n }\n\n public void setPrice(int price) {\n this.price = price;\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-bookstoreservicejava","title":"5. BookStoreService.java","text":"package com.example.jpademo.services;\n\nimport com.example.jpademo.dao.IBookStoreDAO;\nimport com.example.jpademo.entity.Book;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\nimport java.util.List;\n\n@Service\npublic class BookStoreService implements IBookStoreService {\n\n @Autowired\n private IBookStoreDAO dao;\n\n @Override\n public List<Book> getBooks() {\n return dao.getBooks();\n }\n\n @Override\n public Book createBook(Book book) {\n return dao.createBook(book);\n }\n\n @Override\n public Book updateBook(int bookId, Book book) {\n return dao.updateBook(bookId, book);\n }\n\n @Override\n public Book getBook(int bookId) {\n return dao.getBook(bookId);\n }\n\n @Override\n public boolean deleteBook(int bookId) {\n return dao.deleteBook(bookId);\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#6-ibookstoreservicejava","title":"6. IBookStoreService.java","text":"package com.example.jpademo.services;\n\nimport com.example.jpademo.entity.Book;\n\nimport java.util.List;\n\npublic interface IBookStoreService {\n\n List<Book> getBooks();\n Book createBook(Book book);\n Book updateBook(int bookId, Book book);\n Book getBook(int bookId);\n boolean deleteBook(int bookId);\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#7-jpademoapplication","title":"7. JpademoApplication","text":"package com.example.jpademo;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication\npublic class JpademoApplication {\n\n public static void main(String[] args) {\n SpringApplication.run(JpademoApplication.class, args);\n }\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#_4","title":"\u6d4b\u8bd5","text":"\u6784\u5efa\u5e76\u542f\u52a8\u8fd9\u4e2a\u9879\u76ee\u3002
\u5f53\u51fa\u73b0\u4e0b\u9762\u7684\u6d88\u606f\u793a\u4f8b\u65f6\uff0c\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u6b63\u5e38\u542f\u52a8\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 Postman \u8c03\u7528 REST \u7aef\u53e3\u3002
2022-10-27 11:16:16.793 INFO 93488 --- [ main] com.example.jpademo.JpademoApplication : Starting JpademoApplication on username-macbookpro.local with PID 93488 (/Users/username/IdeaProjects/jpademo/target/classes started by username in /Users/username/IdeaProjects/jpademo)\n2022-10-27 11:16:16.796 INFO 93488 --- [ main] com.example.jpademo.JpademoApplication : No active profile set, falling back to default profiles: default\n2022-10-27 11:16:18.022 INFO 93488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.\n2022-10-27 11:16:18.093 INFO 93488 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 50ms. Found 0 JPA repository interfaces.\n2022-10-27 11:16:18.806 INFO 93488 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)\n2022-10-27 11:16:18.814 INFO 93488 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]\n2022-10-27 11:16:18.814 INFO 93488 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-27 11:16:18.886 INFO 93488 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext\n2022-10-27 11:16:18.886 INFO 93488 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2005 ms\n2022-10-27 11:16:19.068 INFO 93488 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]\n2022-10-27 11:16:19.119 INFO 93488 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final\n2022-10-27 11:16:19.202 INFO 93488 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}\n2022-10-27 11:16:19.282 INFO 93488 --- [ main] com.zaxxer.hikari.HikariDataSource : defaultDataSource - Starting...\n2022-10-27 11:16:20.025 INFO 93488 --- [ main] com.zaxxer.hikari.HikariDataSource : defaultDataSource - Start completed.\n2022-10-27 11:16:20.035 INFO 93488 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect\n2022-10-27 11:16:21.929 INFO 93488 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]\n2022-10-27 11:16:21.937 INFO 93488 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'\n2022-10-27 11:16:22.073 WARN 93488 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning\n2022-10-27 11:16:22.221 INFO 93488 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-27 11:16:22.415 INFO 93488 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-27 11:16:22.430 INFO 93488 --- [ main] com.example.jpademo.JpademoApplication : Started JpademoApplication in 6.079 seconds (JVM running for 8.765)\n2022-10-27 11:16:40.180 INFO 93488 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'\n2022-10-27 11:16:40.183 INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'\n2022-10-27 11:16:40.249 INFO 93488 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 66 ms\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#1-book-get","title":"1. \u83b7\u53d6 Book \u5217\u8868\uff0c\u4f7f\u7528 GET \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":"http://localhost:8080/bookservice/books\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#2-book-post","title":"2. \u521b\u5efa\u4e00\u4e2a\u65b0 Book\uff0c\u4f7f\u7528 POST \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":"http://localhost:8080/bookservice/books\n
\u5c06 Header \u4e2d\u7684\u5185\u5bb9\u7c7b\u578b\u8bbe\u7f6e\u4e3a application/json
\uff0c\u5c06 Request Body \u8bbe\u7f6e\u4e3a\u539f\u59cb JSON \u6709\u6548\u8d1f\u8f7d\u3002
{\n \"name\": \"The Lion, the Witch and the Wardrobe\",\n \"author\": \"C. S. Lewis\",\n \"publication\": \"Amazon\",\n \"category\": \"Fantancy\",\n \"pages\": 123,\n \"price\": 10\n }\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#3-book-get","title":"3. \u5982\u9700\u83b7\u53d6\u7279\u5b9a Book\uff0c\u4f7f\u7528 GET \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":" http://localhost:8080/bookservice/books/<id>\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#4-book-put","title":"4. \u5728\u6570\u636e\u5e93\u4e2d\u5347\u7ea7 Book\uff0c\u4f7f\u7528 PUT \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":" http://localhost:8080/bookservice/books/<id>\n
\u5c06 Header \u4e2d\u7684\u5185\u5bb9\u7c7b\u578b\u8bbe\u7f6e\u4e3a application/json
\u3002
\u5c06 Request Body \u8bbe\u7f6e\u4e3a\u539f\u59cb JSON \u6709\u6548\u8d1f\u8f7d
{\n \"name\": \"Black Beauty\",\n \"author\": \"Anna Sewell\",\n \"publication\": \"Amazon\",\n \"category\": \"Fantancy\",\n \"pages\": 134,\n \"price\": 12\n }\n
"},{"location":"MatrixOne/Tutorial/springboot-hibernate-crud-demo/#5-book-delete","title":"5. \u5982\u9700\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664\u7279\u5b9a\u7684 Book\uff0c\u4f7f\u7528 DELETE \u8bf7\u6c42\u8c03\u7528\u4ee5\u4e0b\u63a5\u53e3","text":" http://localhost:8080/bookservice/books/<id>\n
mysql> select * from book;\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n| id | author | category | name | pages | price | publication |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n| 1 | Antoine de Saint-Exupery | Fantancy | The Little Prince | 100 | 50 | Amazon |\n| 2 | Anna Sewell | Fantancy | Black Beauty | 134 | 12 | Amazon |\n| 3 | Lewis Carroll | Fantancy | Alice's Adventures in Wonderland | 1500 | 240 | Amazon |\n+----+--------------------------+----------+----------------------------------+-------+-------+-------------+\n3 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/","title":"SpringBoot \u548c MyBatis \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 SpringBoot\u3001Mybatis \u548c Intellij IDEA \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#_1","title":"\u5f00\u59cb\u4e4b\u524d","text":"\u672c\u7bc7\u6559\u7a0b\u6d89\u53ca\u5230\u7684\u8f6f\u4ef6\u4ecb\u7ecd\u5982\u4e0b\uff1a
MyBatis\uff1aMyBatis \u662f\u4e00\u6b3e\u4f18\u79c0\u7684\u6301\u4e45\u5c42\u6846\u67b6\uff0c\u5b83\u652f\u6301\u81ea\u5b9a\u4e49 SQL\u3001\u5b58\u50a8\u8fc7\u7a0b\u4ee5\u53ca\u9ad8\u7ea7\u6620\u5c04\u3002\u6211\u4eec\u53ea\u9700\u8981\u5173\u6ce8\u9879\u76ee\u4e2d\u7684 SQL \u672c\u8eab\u3002
Intellij IDEA\uff1aIntelliJ IDEA \u662f\u4e00\u79cd\u5546\u4e1a\u5316\u9500\u552e\u7684 Java \u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08Integrated Development Environment\uff0cIDE\uff09\u5de5\u5177\u8f6f\u4ef6\u3002\u5b83\u6240\u62e5\u6709\u7684\u8bf8\u591a\u63d2\u4ef6\uff0c\u53ef\u4ee5\u63d0\u9ad8\u6211\u4eec\u7684\u5de5\u4f5c\u6548\u7387\u3002
Maven\uff1aMaven \u662f Java \u4e2d\u529f\u80fd\u5f3a\u5927\u7684\u9879\u76ee\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u6839\u636e pom.xml \u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u81ea\u52a8\u4e0b\u8f7d\u548c\u5bfc\u5165 Jar \u6587\u4ef6\u3002\u8fd9\u4e2a\u7279\u6027\u51cf\u5c11\u4e86\u4e0d\u540c\u7248\u672c Jar \u6587\u4ef6\u4e4b\u95f4\u7684\u51b2\u7a81\u3002
Spring\uff1aSpring \u662f Java \u4e2d\u6700\u6d41\u884c\u7684\u6846\u67b6\u4e4b\u4e00\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u4f01\u4e1a\u4f7f\u7528 Spring \u6846\u67b6\u6765\u6784\u5efa\u4ed6\u4eec\u7684\u9879\u76ee\u3002Spring Boot \u6784\u5efa\u5728\u4f20\u7edf\u7684 Spring \u6846\u67b6\u4e4b\u4e0a\u3002\u56e0\u6b64\uff0c\u5b83\u63d0\u4f9b\u4e86 Spring \u7684\u6240\u6709\u7279\u6027\uff0c\u800c\u4e14\u6bd4 Spring \u66f4\u6613\u7528\u3002
\u6309\u7167\u6b65\u9aa4\u4ecb\u7ecd\u5b8c\u6210\u5b89\u88c5\u5355\u673a\u7248 MatrixOne\uff0c\u5728 MySQL \u5ba2\u6237\u7aef\u65b0\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a test
\u6570\u636e\u5e93\u3002
mysql> create database test;\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-intellij-idea-spring-boot","title":"2. \u4f7f\u7528 IntelliJ IDEA \u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Spring Boot \u9879\u76ee","text":"\u9009\u62e9 Spring Initializer\uff0c\u6309\u9700\u547d\u540d\u9879\u76ee\u540d\u79f0\u3002
\u9009\u62e9\u5982\u4e0b\u4f9d\u8d56\u9879\uff1a
\u70b9\u51fb Create \u521b\u5efa\u9879\u76ee\u3002\u4f9d\u8d56\u9879\u5217\u5728 pom.xml \u6587\u4ef6\u4e2d\u3002\u901a\u5e38\u4f60\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u4e1c\u897f\u3002
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\">\n <modelVersion>4.0.0</modelVersion>\n <groupId>com.example</groupId>\n <artifactId>mybatis-demo</artifactId>\n <version>0.0.1-SNAPSHOT</version>\n <name>mybatis-demo</name>\n <description>mybatis-demo</description>\n\n <properties>\n <java.version>1.8</java.version>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\n <spring-boot.version>2.3.7.RELEASE</spring-boot.version>\n </properties>\n\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-jdbc</artifactId>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-web</artifactId>\n </dependency>\n <dependency>\n <groupId>org.mybatis.spring.boot</groupId>\n <artifactId>mybatis-spring-boot-starter</artifactId>\n <version>2.1.4</version>\n </dependency>\n\n <dependency>\n <groupId>mysql</groupId>\n <artifactId>mysql-connector-java</artifactId>\n <scope>runtime</scope>\n </dependency>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-starter-test</artifactId>\n <scope>test</scope>\n <exclusions>\n <exclusion>\n <groupId>org.junit.vintage</groupId>\n <artifactId>junit-vintage-engine</artifactId>\n </exclusion>\n </exclusions>\n </dependency>\n </dependencies>\n\n <dependencyManagement>\n <dependencies>\n <dependency>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-dependencies</artifactId>\n <version>${spring-boot.version}</version>\n <type>pom</type>\n <scope>import</scope>\n </dependency>\n </dependencies>\n </dependencyManagement>\n\n <build>\n <plugins>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-compiler-plugin</artifactId>\n <version>3.8.1</version>\n <configuration>\n <source>1.8</source>\n <target>1.8</target>\n <encoding>UTF-8</encoding>\n </configuration>\n </plugin>\n <plugin>\n <groupId>org.springframework.boot</groupId>\n <artifactId>spring-boot-maven-plugin</artifactId>\n <version>2.3.7.RELEASE</version>\n <configuration>\n <mainClass>com.example.mybatisdemo.MybatisDemoApplication</mainClass>\n </configuration>\n <executions>\n <execution>\n <id>repackage</id>\n <goals>\n <goal>repackage</goal>\n </goals>\n </execution>\n </executions>\n </plugin>\n </plugins>\n </build>\n\n</project>\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-applicationproperties","title":"3. \u4fee\u6539 application.properties \u6587\u4ef6","text":"\u8fdb\u5165\u5230 resources \u6587\u4ef6\u76ee\u5f55\u4e0b\uff0c\u914d\u7f6e application.properties \u6587\u4ef6\uff0c\u5b8c\u6210 MatrixOne \u8fde\u63a5\u3002
# Application Name\nspring.application.name=MyBatisDemo\n# Database driver\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n# Data Source name\nspring.datasource.name=defaultDataSource\n\n# Database connection url, modify to MatrixOne address and port, with paratemers\nspring.datasource.url=jdbc:mysql://127.0.0.1:6001/test?characterSetResults=UTF-8&continueBatchOnError=false&useServerPrepStmts=true&alwaysSendSetIsolation=false&useLocalSessionState=true&zeroDateTimeBehavior=CONVERT_TO_NULL&failoverReadOnly=false&serverTimezone=Asia/Shanghai&socketTimeout=30000\n# Database username and password\nspring.datasource.username=root\nspring.datasource.password=111\n\n# Mybatis mapper location\nmybatis.mapper-locations=classpath:mapping/*xml\n# Mybatis entity package\nmybatis.type-aliases-package=com.example.mybatisdemo.entity\n# Web application port\nserver.port=8080\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#_3","title":"\u7f16\u5199\u4ee3\u7801","text":"\u5b8c\u6210\u73af\u5883\u914d\u7f6e\u540e\uff0c\u6211\u4eec\u7f16\u5199\u4ee3\u7801\u6765\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684 CRUD \u5e94\u7528\u7a0b\u5e8f\u3002
\u5728\u5b8c\u6210\u7f16\u5199\u4ee3\u7801\u540e\uff0c\u4f60\u5c06\u62e5\u6709\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684\u9879\u76ee\u7ed3\u6784\u3002\u4f60\u53ef\u4ee5\u9884\u5148\u521b\u5efa\u8fd9\u4e9b\u5305\u548c java \u7c7b\u3002
\u6211\u4eec\u5c06\u4e3a\u8fd9\u4e2a\u6f14\u793a\u5e94\u7528\u7a0b\u5e8f\u7f16\u5199\u521b\u5efa\u3001\u66f4\u65b0\u3001\u63d2\u5165\u3001\u5220\u9664\u548c\u9009\u62e9\u64cd\u4f5c\u3002
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1-usercontrollerjava","title":"1. UserController.java","text":"package com.example.mybatisdemo.controller;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.service.UserService;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\nimport org.springframework.web.bind.annotation.ResponseBody;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\n@RequestMapping(\"/test\")\npublic class UserController {\n\n String tableName = \"user\";\n @Autowired\n private UserService userService;\n\n @RequestMapping(value = \"/create\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n @ResponseBody\n public String createTable(){\n return userService.createTable(tableName);\n }\n\n @RequestMapping(value = \"/selectUserByid\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n @ResponseBody\n public String GetUser(User user){\n return userService.Sel(user).toString();\n }\n\n @RequestMapping(value = \"/add\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n public String Add(User user){\n return userService.Add(user);\n }\n\n @RequestMapping(value = \"/update\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n public String Update(User user){\n return userService.Update(user);\n }\n\n @RequestMapping(value = \"/delete\", produces = \"application/json;charset=UTF-8\", method = RequestMethod.GET)\n public String Delete(User user){\n return userService.Delete(user);\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2-userjava","title":"2. User.java","text":"package com.example.mybatisdemo.entity;\n\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RequestMethod;\n\npublic class User {\n private Integer id;\n private String username;\n private String password;\n private String address;\n\n public User(Integer id, String username, String password, String address) {\n this.id = id;\n this.username = username;\n this.password = password;\n this.address = address;\n }\n\n public Integer getId() {\n return id;\n }\n\n public String getUsername() {\n return username;\n }\n\n public String getPassword() {\n return password;\n }\n\n public String getAddress() {\n return address;\n }\n\n public void setId(Integer id) {\n this.id = id;\n }\n\n public void setUsername(String username) {\n this.username = username;\n }\n\n public void setPassword(String password) {\n this.password = password;\n }\n\n public void setAddress(String address) {\n this.address = address;\n }\n\n @Override\n public String toString() {\n return \"User{\" +\n \"id=\" + id +\n \", username='\" + username + '\\'' +\n \", password='\" + password + '\\'' +\n \", address='\" + address + '\\'' +\n '}';\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3-usermapperjava","title":"3. UserMapper.java","text":"package com.example.mybatisdemo.mapper;\n\nimport com.example.mybatisdemo.entity.User;\nimport org.apache.ibatis.annotations.Param;\nimport org.springframework.stereotype.Repository;\n\n@Repository\npublic interface UserMapper {\n\n int createTable(@Param(\"tableName\") String tableName);\n\n User Sel(@Param(\"user\")User user);\n\n int Add(@Param(\"user\")User user);\n\n int Update(@Param(\"user\")User user);\n\n int Delete(@Param(\"user\")User user);\n\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4-userservicejava","title":"4. UserService.java","text":"package com.example.mybatisdemo.service;\n\nimport com.example.mybatisdemo.entity.User;\nimport com.example.mybatisdemo.mapper.UserMapper;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Service;\n\n@Service\npublic class UserService {\n @Autowired\n UserMapper userMapper;\n\n public String createTable(String table){\n int a = userMapper.createTable(table);\n if (a == 1) {\n return \"Create table failed\";\n } else {\n return \"Create table successfully\";\n }\n }\n\n public User Sel(User user) {\n return userMapper.Sel(user);\n }\n\n public String Add(User user) {\n int a = userMapper.Add(user);\n if (a == 1) {\n return \"Add user successfully\";\n } else {\n return \"Add user failed\";\n }\n }\n\n public String Update(User user) {\n int a = userMapper.Update(user);\n if (a == 1) {\n return \"Update user successfully\";\n } else {\n return \"Update user failed\";\n }\n }\n\n public String Delete(User user) {\n int a = userMapper.Delete(user);\n if (a == 1) {\n return \"Delete user successfully\";\n } else {\n return \"Delete user failed\";\n }\n }\n\n};\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5-mybatisdemoapplicationjava","title":"5. MyBatisDemoApplication.java","text":"package com.example.mybatisdemo;\n\nimport org.mybatis.spring.annotation.MapperScan;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@MapperScan(\"com.example.mybatisdemo.mapper\")\n@SpringBootApplication\npublic class MyBatisDemoApplication {\n public static void main(String[] args) {\n SpringApplication.run(MyBatisDemoApplication.class, args);\n }\n}\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#6-usermapperxml","title":"6. UserMapper.xml","text":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE mapper PUBLIC \"-//mybatis.org//DTD Mapper 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">\n\n<mapper namespace=\"com.example.mybatisdemo.mapper.UserMapper\">\n\n <resultMap id=\"BaseResultMap\" type=\"com.example.mybatisdemo.entity.User\">\n <result column=\"id\" jdbcType=\"INTEGER\" property=\"id\"/>\n <result column=\"userName\" jdbcType=\"VARCHAR\" property=\"username\"/>\n <result column=\"passWord\" jdbcType=\"VARCHAR\" property=\"password\"/>\n <result column=\"realName\" jdbcType=\"VARCHAR\" property=\"address\"/>\n </resultMap>\n\n <update id=\"createTable\" parameterType=\"string\">\n CREATE TABLE ${tableName} (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `username` varchar(255) DEFAULT NULL,\n `password` varchar(255) DEFAULT NULL,\n `address` varchar(255) DEFAULT NULL,\n PRIMARY KEY (`id`)\n );\n </update>\n\n <select id=\"Sel\" resultType=\"com.example.mybatisdemo.entity.User\">\n select * from user where 1=1\n <if test=\"user.id != null\">\n AND id = #{user.id}\n </if>\n </select>\n\n <insert id=\"Add\" parameterType=\"com.example.mybatisdemo.entity.User\">\n INSERT INTO user\n <trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">\n <if test=\"user.username != null\">\n username,\n </if>\n <if test=\"user.password != null\">\n password,\n </if>\n <if test=\"user.address != null\">\n address,\n </if>\n </trim>\n <trim prefix=\"VALUES (\" suffix=\")\" suffixOverrides=\",\">\n <if test=\"user.username != null\">\n #{user.username,jdbcType=VARCHAR},\n </if>\n <if test=\"user.password != null\">\n #{user.password,jdbcType=VARCHAR},\n </if>\n <if test=\"user.address != null\">\n #{user.address,jdbcType=VARCHAR},\n </if>\n </trim>\n </insert>\n\n <update id=\"Update\" parameterType=\"com.example.mybatisdemo.entity.User\">\n UPDATE user\n <set>\n <if test=\"user.username != null\">\n username = #{user.username},\n </if>\n <if test=\"user.password != null\">\n password = #{user.password},\n </if>\n <if test=\"user.address != null\">\n address = #{user.address},\n </if>\n </set>\n WHERE\n id=#{user.id}\n </update>\n\n <delete id=\"Delete\" parameterType=\"com.example.mybatisdemo.entity.User\">\n DELETE FROM user WHERE id = #{user.id}\n </delete>\n\n</mapper>\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#_4","title":"\u6d4b\u8bd5","text":"\u6784\u5efa\u5e76\u542f\u52a8\u8fd9\u4e2a\u9879\u76ee\u3002
\u5f53\u51fa\u73b0\u4e0b\u9762\u7684\u6d88\u606f\u793a\u4f8b\u65f6\uff0c\u8868\u793a\u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u6b63\u5e38\u542f\u52a8\uff0c\u4f60\u53ef\u4ee5\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u53d1\u9001 HTTP \u8bf7\u6c42\u3002
2022-10-26 16:13:24.030 INFO 60253 --- [ main] c.e.mybatisdemo.MyBatisDemoApplication : Starting MyBatisDemoApplication on username-macbookpro.local with PID 60253 (/Users/username/IdeaProjects/MyBatisDemo/target/classes started by username in /Users/username/IdeaProjects/MyBatisDemo)\n2022-10-26 16:13:24.035 INFO 60253 --- [ main] c.e.mybatisdemo.MyBatisDemoApplication : No active profile set, falling back to default profiles: default\n2022-10-26 16:13:25.415 INFO 60253 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)\n2022-10-26 16:13:25.421 INFO 60253 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]\n2022-10-26 16:13:25.421 INFO 60253 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]\n2022-10-26 16:13:25.476 INFO 60253 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext\n2022-10-26 16:13:25.477 INFO 60253 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1390 ms\n2022-10-26 16:13:26.020 INFO 60253 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'\n2022-10-26 16:13:26.248 INFO 60253 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''\n2022-10-26 16:13:26.272 INFO 60253 --- [ main] c.e.mybatisdemo.MyBatisDemoApplication : Started MyBatisDemoApplication in 2.669 seconds (JVM running for 3.544)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#1","title":"1. \u6d4b\u8bd5\u65b0\u5efa\u8868","text":"\u6253\u5f00\u4f60\u7684\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/create
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u9a8c\u8bc1\u8868\u662f\u5426\u5df2\u6210\u529f\u521b\u5efa\u3002
mysql> use test;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| user |\n+----------------+\n1 row in set (0.00 sec)\n\nmysql> show create table user;\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| Table | Create Table |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n| user | CREATE TABLE `user` (\n`id` INT NOT NULL AUTO_INCREMENT,\n`username` VARCHAR(255) DEFAULT null,\n`password` VARCHAR(255) DEFAULT null,\n`address` VARCHAR(255) DEFAULT null,\nPRIMARY KEY (`id`)\n) |\n+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+\n1 row in set (0.01 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#2","title":"2. \u6d4b\u8bd5\u589e\u52a0\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/add?username=tom&password=123456&address=shanghai
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u6dfb\u52a0\u8bb0\u5f55\uff1a
mysql> select * from user;\n+------+----------+----------+----------+\n| id | username | password | address |\n+------+----------+----------+----------+\n| 1 | tom | 123456 | shanghai |\n+------+----------+----------+----------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#3","title":"3. \u6d4b\u8bd5\u67e5\u8be2\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/selectUserByid?id=1
\u4f60\u53ef\u4ee5\u76f4\u63a5\u4ece\u6d4f\u89c8\u5668\u4e2d\u83b7\u53d6\u67e5\u8be2\u7ed3\u679c\u3002
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#4","title":"4. \u6d4b\u8bd5\u66f4\u65b0\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/update?id=1&username=tom&password=654321&address=beijing
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u66f4\u65b0\u8bb0\u5f55\uff1a
mysql> select * from user;\n+------+----------+----------+---------+\n| id | username | password | address |\n+------+----------+----------+---------+\n| 1 | tom | 654321 | beijing |\n+------+----------+----------+---------+\n1 row in set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/springboot-mybatis-crud-demo/#5","title":"5. \u6d4b\u8bd5\u5220\u9664\u7528\u6237","text":"\u6253\u5f00\u4f60\u7684\u6d4f\u89c8\u5668\u5e76\u8f93\u5165\u7f51\u5740\uff1ahttp://localhost:8080/test/delete?id=1
\u5728 MySQL \u5ba2\u6237\u7aef\u4e2d\uff0c\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u9a8c\u8bc1\u662f\u5426\u6210\u529f\u5220\u9664\u8bb0\u5f55\uff1a
mysql> select * from user;\nEmpty set (0.00 sec)\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/","title":"SQLAlchemy \u57fa\u7840\u793a\u4f8b","text":"\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u4f7f\u7528 Python \u548c SQLAlchemy \u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664\uff09\u529f\u80fd\u3002
SQLAlchemy \u662f Python \u8bed\u8a00\u4e2d\u6700\u6d41\u884c\u7684 ORM \u5de5\u5177\u4e4b\u4e00\u3002
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_1","title":"\u5f00\u59cb\u524d\u51c6\u5907","text":"\u76f8\u5173\u8f6f\u4ef6\u7684\u7b80\u5355\u4ecb\u7ecd\uff1a
SQLAlchemy\uff1aSQLAlchemy \u662f\u4e00\u4e2a Python \u5e93\uff0c\u53ef\u4ee5\u4fc3\u8fdb Python \u7a0b\u5e8f\u548c\u6570\u636e\u5e93\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5927\u591a\u6570\u65f6\u5019\uff0c\u8fd9\u4e2a\u5e93\u7528\u4f5c\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668 (ORM) \u5de5\u5177\uff0c\u5c06 Python \u7c7b\u8f6c\u6362\u4e3a\u5173\u7cfb\u6570\u636e\u5e93\u4e0a\u7684\u8868\uff0c\u5e76\u81ea\u52a8\u5c06\u51fd\u6570\u8c03\u7528\u8f6c\u6362\u4e3a SQL \u8bed\u53e5\u3002
Faker\uff1aFaker \u662f\u4e00\u4e2a\u751f\u6210\u5047\u6570\u636e\u7684 Python \u5e93\u3002\u865a\u5047\u6570\u636e\u901a\u5e38\u7528\u4e8e\u6d4b\u8bd5\u6216\u7528\u4e00\u4e9b\u865a\u62df\u6570\u636e\u586b\u5145\u6570\u636e\u5e93\u3002
\u5728\u4f60\u5f00\u59cb\u4e4b\u524d\uff0c\u786e\u8ba4\u4f60\u5df2\u7ecf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e86\u5982\u4e0b\u8f6f\u4ef6\uff1a
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5355\u673a\u90e8\u7f72 MatrixOne\u3002\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u8fde\u63a5 MatrixOne \u5e76\u521b\u5efa\u4e00\u4e2a\u547d\u540d\u4e3a test \u7684\u6570\u636e\u5e93\uff1a
mysql> create database test;\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 Python 3.8(or plus) version\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u68c0\u67e5 Python \u7248\u672c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\uff1a
```\n#To check with Python installation and its version\npython3 -V\n```\n
\u786e\u8ba4\u4f60\u5df2\u5b8c\u6210\u5b89\u88c5 MySQL \u5ba2\u6237\u7aef\u3002
\u4e0b\u8f7d\u5b89\u88c5 sqlalchemy
\u3001pymysql
\u3001cryptography
\u548c faker
\u5de5\u5177\u3002
\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u4e0b\u8f7d\u5b89\u88c5 sqlalchemy
\u3001pymysql
\u3001cryptography
\u548c faker
\u5de5\u5177\uff1a
```\npip3 install sqlalchemy\npip3 install pymysql\npip3 install cryptography\npip3 install faker\n\n#If you are in China mainland and have a low downloading speed, you can speed up the download by following commands.\npip3 install sqlalchemy -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install cryptography -i https://pypi.tuna.tsinghua.edu.cn/simple\npip3 install faker -i https://pypi.tuna.tsinghua.edu.cn/simple\n```\n
\u4f60\u53ef\u4ee5\u53c2\u8003 Python \u8fde\u63a5 MatrixOne \u670d\u52a1\u4e86\u89e3\u5982\u4f55\u901a\u8fc7 SQLAlchemy
\u8fde\u63a5\u5230 MatrixOne\uff0c\u672c\u7bc7\u6587\u6863\u5c06\u6307\u5bfc\u4f60\u5982\u4f55\u5b9e\u73b0 CRUD\uff08\u521b\u5efa\u3001\u8bfb\u53d6\u3001\u66f4\u65b0\u3001\u5220\u9664)\u3002
\u4f5c\u4e3a\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04\u5668\uff08ORM\uff09\u5de5\u5177\uff0cSQLAlchemy \u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u521b\u5efa Python \u7c7b\u6765\u6620\u5c04\u5173\u7cfb\u6570\u636e\u5e93\u4e2d\u7684\u8868\u3002
\u5728\u4e0b\u9762\u7684\u4ee3\u7801\u793a\u4f8b\u4e2d\uff0c\u5c06\u521b\u5efa\u4e00\u4e2a Customer
\u7c7b\uff0c\u5b83\u5b9a\u4e49\u7684 Customer
\u7684\u4ee3\u7801\u76f8\u5f53\u4e8e\u4e00\u6761 SQL \u8bed\u53e5\uff0c\u5b83\u8868\u793a MatrixOne \u4e2d\u7684\u547d\u540d\u4e3a Customer
\u7684\u8868\uff1a
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_create.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from faker import Factory\nfrom sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nfaker = Factory.create()\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# Generate 10 Customer records\nCustomers = [Customer(name= faker.name(),address = faker.address()) for i in range(10)]\n\n# Create the table\nBase.metadata.create_all(engine)\n\n# Insert all customer records to Customer table\nsession.add_all(Customers)\n\nsession.commit()\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\uff1a
> python3 sqlalchemy_create.py\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u521b\u5efa\u6210\u529f\uff1a
mysql> show tables;\n+----------------+\n| tables_in_test |\n+----------------+\n| Customer |\n+----------------+\n1 row in set (0.04 sec)\nmysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id | cname | caddress |\n+------+------------------+-----------------------------------------------------+\n| 1 | Wendy Luna | 002 Brian Plaza\nAndrewhaven, SC 88456 |\n| 2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249 |\n| 3 | Angela Ramos | 029 Todd Curve Apt. 352\nMooreville, FM 15950 |\n| 4 | Lisa Bruce | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853 |\n| 5 | Julie Moore | Unit 1117 Box 1029\nDPO AP 87468 |\n| 6 | David Massey | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549 |\n| 7 | David Mccann | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n| 8 | Morgan Price | 57463 Lisa Drive\nThompsonshire, NM 88077 |\n| 9 | Samuel Griffin | 186 Patel Crossing\nNorth Stefaniechester, WV 08221 |\n| 10 | Tristan Pierce | 593 Blankenship Rapids\nNew Jameshaven, SD 89585 |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.03 sec)\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_4","title":"\u8bfb\u53d6\u6570\u636e","text":"\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5c06\u901a\u8fc7\u4e24\u79cd\u65b9\u5f0f\u4ece Customer
\u8868\u4e2d\u8bfb\u53d6\u6570\u636e\u3002
\u7b2c\u4e00\u79cd\u65b9\u5f0f\u662f\u5168\u8868\u626b\u63cf\uff1a
select * from `Customer`\n
\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u662f\u70b9\u67e5\u8be2\uff1a
select * from `Customer` where `cname` = 'David Mccann';\n
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_read.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n print(customer.__str__() +\"\\n--------------------------\\n\")\n\n# query with a filter condition\nMccann = session.query(Customer).filter_by(cname='David Mccann').first()\nprint(Mccann)\nprint(\"\\n------------------------\\n\")\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u5e76\u67e5\u770b\u7ed3\u679c\uff1a
> python3 sqlalchemy_read.py\ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n--------------------------\n\ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n\n------------------------\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_5","title":"\u66f4\u65b0\u6570\u636e","text":"\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u66f4\u65b0 Customer \u8868\u7684\u7b2c\u4e00\u4e2a cname \u5217\u4e3a\u53e6\u4e00\u4e2a\u503c\u3002
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_update.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\ncustomer = session.query(Customer).first()\nprint(customer)\nprint(\"\\n---------------------\\n\")\n\n# Rename customer\ncustomer.cname = \"Coby White\"\n\n\nsession.commit()\n\n# See the updated result\ncustomer = session.query(Customer).first()\nprint(customer)\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u5e76\u67e5\u770b\u7ed3\u679c\uff1a
> python3 sqlalchemy_update.py \ncname:Wendy Luna caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n\n---------------------\n\ncname:Coby White caddress:002 Brian Plaza\nAndrewhaven, SC 88456\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u662f\u5426\u66f4\u65b0\u6210\u529f\uff1a
mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id | cname | caddress |\n+------+------------------+-----------------------------------------------------+\n| 1 | Coby White | 002 Brian Plaza\nAndrewhaven, SC 88456 |\n| 2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249 |\n| 3 | Angela Ramos | 029 Todd Curve Apt. 352\nMooreville, FM 15950 |\n| 4 | Lisa Bruce | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853 |\n| 5 | Julie Moore | Unit 1117 Box 1029\nDPO AP 87468 |\n| 6 | David Massey | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549 |\n| 7 | David Mccann | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n| 8 | Morgan Price | 57463 Lisa Drive\nThompsonshire, NM 88077 |\n| 9 | Samuel Griffin | 186 Patel Crossing\nNorth Stefaniechester, WV 08221 |\n| 10 | Tristan Pierce | 593 Blankenship Rapids\nNew Jameshaven, SD 89585 |\n+------+------------------+-----------------------------------------------------+\n10 rows in set (0.02 sec)\n
"},{"location":"MatrixOne/Tutorial/sqlalchemy-python-crud-demo/#_6","title":"\u5220\u9664\u6570\u636e","text":"\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5c06\u6307\u5bfc\u4f60\u5220\u9664 Customer \u8868\u7684\u7b2c\u4e00\u6761\u6570\u636e\u3002
\u65b0\u5efa\u4e00\u4e2a sqlalchemy_detele.py
\u7684\u6587\u672c\u6587\u4ef6\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u62f7\u8d1d\u7c98\u8d34\u5230\u6587\u4ef6\u5185\uff1a
from sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker\n\nengine = create_engine('mysql+pymysql://root:111@127.0.0.1:6001/test')\n\nSession = sessionmaker(bind=engine)\nsession = Session()\n\nBase = declarative_base()\n\nclass Customer(Base):\n __tablename__ = \"Customer\"\n id = Column(Integer, primary_key=True,autoincrement=True)\n cname = Column(String(64))\n caddress = Column(String(512))\n\n def __init__(self,name,address):\n self.cname = name\n self.caddress = address\n\n def __str__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n def __repr__(self):\n return \"cname:\"+self.cname +\" caddress:\"+self.caddress\n\n\n# delete the first record\ncustomer = session.query(Customer).first()\n\nsession.delete(customer)\nsession.commit()\n\n# query all data\ncustomers = session.query(Customer).all()\n\nfor customer in customers:\n print(customer.__str__() +\"\\n--------------------------\\n\")\n
\u6253\u5f00\u7ec8\u7aef\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u8fd0\u884c\u6b64 python \u6587\u4ef6\u5e76\u67e5\u770b\u7ed3\u679c\uff1a
> python3 sqlalchemy_delete.py \ncname:Meagan Rodriguez caddress:USCGC Olson\nFPO AP 21249\n--------------------------\n\ncname:Angela Ramos caddress:029 Todd Curve Apt. 352\nMooreville, FM 15950\n--------------------------\n\ncname:Lisa Bruce caddress:68103 Mackenzie Mountain\nNorth Andrew, UT 29853\n--------------------------\n\ncname:Julie Moore caddress:Unit 1117 Box 1029\nDPO AP 87468\n--------------------------\n\ncname:David Massey caddress:207 Wayne Groves Apt. 733\nVanessashire, NE 34549\n--------------------------\n\ncname:David Mccann caddress:97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558\n--------------------------\n\ncname:Morgan Price caddress:57463 Lisa Drive\nThompsonshire, NM 88077\n--------------------------\n\ncname:Samuel Griffin caddress:186 Patel Crossing\nNorth Stefaniechester, WV 08221\n--------------------------\n\ncname:Tristan Pierce caddress:593 Blankenship Rapids\nNew Jameshaven, SD 89585\n--------------------------\n
\u4f60\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\u9a8c\u8bc1\u8868\u4e2d\u7684\u8bb0\u5f55\u662f\u5426\u5220\u9664\u6210\u529f\uff1a
mysql> select * from `Customer`;\n+------+------------------+-----------------------------------------------------+\n| id | cname | caddress |\n+------+------------------+-----------------------------------------------------+\n| 2 | Meagan Rodriguez | USCGC Olson\nFPO AP 21249 |\n| 3 | Angela Ramos | 029 Todd Curve Apt. 352\nMooreville, FM 15950 |\n| 4 | Lisa Bruce | 68103 Mackenzie Mountain\nNorth Andrew, UT 29853 |\n| 5 | Julie Moore | Unit 1117 Box 1029\nDPO AP 87468 |\n| 6 | David Massey | 207 Wayne Groves Apt. 733\nVanessashire, NE 34549 |\n| 7 | David Mccann | 97274 Sanders Tunnel Apt. 480\nAnthonyberg, DC 06558 |\n| 8 | Morgan Price | 57463 Lisa Drive\nThompsonshire, NM 88077 |\n| 9 | Samuel Griffin | 186 Patel Crossing\nNorth Stefaniechester, WV 08221 |\n| 10 | Tristan Pierce | 593 Blankenship Rapids\nNew Jameshaven, SD 89585 |\n+------+------------------+-----------------------------------------------------+\n9 rows in set (0.04 sec)\n
"}]}
\ No newline at end of file
diff --git a/1.2.1/sitemap.xml.gz b/1.2.1/sitemap.xml.gz
index e2ead42776..c15f4b43ef 100644
Binary files a/1.2.1/sitemap.xml.gz and b/1.2.1/sitemap.xml.gz differ