{"id":1078,"date":"2020-09-09T10:23:32","date_gmt":"2020-09-09T02:23:32","guid":{"rendered":"http:\/\/www.gbase8.cn\/?p=1078"},"modified":"2022-06-10T17:05:25","modified_gmt":"2022-06-10T09:05:25","slug":"gbase-8a-%e6%94%af%e6%8c%81cte-%e5%8a%9f%e8%83%bdwith-as-%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/1078","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a \u652f\u6301CTE \u529f\u80fdwith as \u4ecb\u7ecd"},"content":{"rendered":"<p>GBase 8a\u6570\u636e\u5e93\u96c6\u7fa4\u5728\u65b0\u7248\u672c\u91cc\u652f\u6301\u4e86CTE(Common Table Expression)\u529f\u80fd\uff0c\u652f\u6301\u7684\u7248\u672c\u53ef\u4ee5\u67e5\u770b\u5230_t_gcluster_support_cte&nbsp;\u8fd9\u4e2a\u53c2\u6570\u3002\u901a\u8fc7with as \u7684CTE\u529f\u80fd\uff0c\u53ef\u4ee5\u6781\u5927\u7b80\u5316\u5d4c\u5957SQL\u7684\u590d\u6742\u6027\uff0c\u63d0\u5347SQL\u7684\u53ef\u8bfb\u6027\u3002\u5982\u679c\u6ca1\u6709\u6253\u5f00\u4f1a\u62a5This version of GBase doesn't yet support 'CTE' \u62a5\u9519\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b164fcadde\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2b164fcadde\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/1078\/#%E5%8F%82%E6%95%B0\" >\u53c2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/1078\/#%E8%AF%B4%E6%98%8E\" >\u8bf4\u660e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/1078\/#%E6%A0%B7%E4%BE%8B\" >\u6837\u4f8b<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0\"><\/span>\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>_t_gcluster_support_cte&nbsp;<br>\u9ed8\u8ba4\u503c\u4e3a0<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AF%B4%E6%98%8E\"><\/span>\u8bf4\u660e<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5982\u679c\u7528\u6237\u4f7f\u7528\u8fd9\u4e2a\u529f\u80fd\uff0c\u9700\u8981\u6253\u5f00\u8fd9\u4e2a\u53c2\u6570\uff0c\u652f\u6301session\u548cglobal\u65b9\u5f0f\u3002 \u5177\u4f53\u53c2\u6570\u8bbe\u7f6e\u7ec6\u8282\u4ecb\u7ecd\uff0c\u8bf7\u53c2\u8003 <a href=\"http:\/\/www.gbase8.cn\/en\/?p=865\">GBase 8a\u6570\u636e\u5e93\u8bbe\u7f6e\u53c2\u6570\u7684\u65b9\u6cd5<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A0%B7%E4%BE%8B\"><\/span>\u6837\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5982\u4e0b\u6f14\u793asession\u7ea7\u7684\u8bbe\u7f6e\u548c\u4f7f\u7528\u6837\u4f8b\u3002\u53ef\u4ee5\u770b\u5230\u5982\u679c\u6ca1\u6709\u6253\u5f00\u53c2\u6570\uff0c\u4f7f\u7528with as \u4f1a\u62a5\u9519 \u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ERROR 1235 (42000): This version of GBase doesn't yet support 'CTE'\ngbase&gt; show variables like '%CTE%';\n+--------------------------+--------------------------------------------------+\n| Variable_name            | Value                                            |\n+--------------------------+--------------------------------------------------+\n| _t_gcluster_support_cte  | 0                                                |\n| character_set_client     | utf8                                             |\n| character_set_connection | utf8                                             |\n| character_set_database   | utf8                                             |\n| character_set_filesystem | binary                                           |\n| character_set_results    | utf8                                             |\n| character_set_server     | utf8                                             |\n| character_set_sort       | binary                                           |\n| character_set_system     | utf8mb4                                          |\n| character_sets_dir       | \/opt\/gbase\/gcluster\/server\/share\/gbase\/charsets\/ |\n+--------------------------+--------------------------------------------------+\n10 rows in set (Elapsed: 00:00:00.00)\n\ngbase&gt; set _t_gcluster_support_cte=1;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\n\ngbase&gt; with a as (select * from t_autoinc) select * from a where id&lt;10;\n+----+--------+\n| id | name   |\n+----+--------+\n|  1 | First  |\n|  4 | Second |\n|  7 | Third  |\n|  8 | BBBB   |\n|  9 | CCCC   |\n+----+--------+\n5 rows in set (Elapsed: 00:00:00.06)\n<\/code><\/pre>\n\n\n\n<p>cte\u8868\u53ef\u4ee5\u88ab\u540e\u9762\u7684cte\u8868\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>with a as (select * from t1),b as (select * from a) select * from b;<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u653e\u5728\u524d\u9762\uff0c\u8bed\u6cd5\u89e3\u6790\u65f6\u4f1a\u62a5\u8868\u4e0d\u5b58\u5728<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> with c as (select * from b),a as (select * from t1),b as (select * from a) select * from b;\r\nERROR 1146 (42S02): Table 'testdb.b' doesn't exist\r\n<\/code><\/pre>\n\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u6570\u636e\u5e93\u652f\u6301\u4e86CTE\u529f\u80fd\uff0c\u540c\u901a\u8fc7_t_gcluster_support_cte \u53c2\u6570\u63a7\u5236\u3002\u5982\u679c\u6ca1\u6709\u6253\u5f00\u4f1a\u62a5This version of GBase doesn't yet support 'CTE' \u62a5\u9519\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1078","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/1078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=1078"}],"version-history":[{"count":8,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/1078\/revisions"}],"predecessor-version":[{"id":9641,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/1078\/revisions\/9641"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=1078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=1078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=1078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}