{"id":2001,"date":"2020-11-17T09:55:19","date_gmt":"2020-11-17T01:55:19","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=2001"},"modified":"2020-11-17T09:55:19","modified_gmt":"2020-11-17T01:55:19","slug":"gbase-8a%e9%80%92%e5%bd%92%e6%9f%a5%e8%af%a2start-with-connect-by-%e6%8a%a5%e9%94%99-restrict-connect-by-clause-must-be-used-with-table-not-deleted","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/2001","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u9012\u5f52\u67e5\u8be2Start with connect by \u62a5\u9519 Restrict: Connect by clause must be used with table not deleted"},"content":{"rendered":"<p>GBase 8a\u652f\u6301\u9012\u5f52\u67e5\u8be2\uff0c\u8981\u6c42\u590d\u5236\u8868\u7684\u6570\u636e\u4e0d\u80fd\u6709\u5220\u9664\u7684\uff0c\u5426\u5219\u62a5DETAIL: (GBA-01EX-700) Gbase general error: Restrict: Connect by clause must be used with table not deleted<\/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-6a2a9405af590\" 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-6a2a9405af590\"  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\/2001\/#%E6%8A%A5%E9%94%99%E6%A0%B7%E4%BE%8B\" >\u62a5\u9519\u6837\u4f8b<\/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\/2001\/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\" >Solution<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%8A%A5%E9%94%99%E6%A0%B7%E4%BE%8B\"><\/span>\u62a5\u9519\u6837\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> select * from t2;\n+------+-----------+------+\n| id   | name      | pid  |\n+------+-----------+------+\n|    1 | First     |    0 |\n|    2 | Fist_1    |    1 |\n|    3 | First_2   |    1 |\n|    4 | First_1_1 |    2 |\n+------+-----------+------+\n4 rows in set (Elapsed: 00:00:00.01)\n\ngbase> create table t3 replicated as select * from t2;\nQuery OK, 4 rows affected (Elapsed: 00:00:00.14)\n\ngbase> select * from t3 connect by pid=prior id start with pid=0;\n+------+-----------+------+\n| id   | name      | pid  |\n+------+-----------+------+\n|    1 | First     |    0 |\n|    2 | Fist_1    |    1 |\n|    4 | First_1_1 |    2 |\n|    3 | First_2   |    1 |\n+------+-----------+------+\n4 rows in set (Elapsed: 00:00:00.02)\n\ngbase> delete t3 where id=3;\nQuery OK, 1 row affected (Elapsed: 00:00:00.04)\n\ngbase> select * from t3 connect by pid=prior id start with pid=0;\nERROR 1708 (HY000): &#91;gbase_rh7_001:5050](GBA-02AD-0005)Failed to query in gnode:\nDETAIL: (GBA-01EX-700) Gbase general error: Restrict: Connect by clause must be used with table not deleted\nSQL: SELECT \/*gbase_rh7_001_12_16_2020-11-16_17:37:32*\/ \/*+ TID('589860') *\/ `vcname000001.testdb.t3`.`id` AS `id`, `vcname000001.testdb.t3`.`name` AS `name`, `vcname000001.testdb.t3`.`pid` AS `pid` FROM `testdb`.`t3` `vcname000001.testdb.t3` START WITH (`vcname000001.testdb.t3`.`pid` = 0) CONNECT BY (`vcname000001.testdb.t3`.`pid` = PRIOR\ngbase>\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\"><\/span>Solution<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>1\u3001\u65b0\u5efa\u4e00\u4e2a\u8868\uff0c\u4e0d\u8981\u5220\u9664\u6570\u636e\uff0c\u6216\u8005\u7528\u5b50\u67e5\u8be2\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> select * from (select * from t3) a connect by pid=prior id start with pid=0;\n+------+-----------+------+\n| id   | name      | pid  |\n+------+-----------+------+\n|    1 | First     |    0 |\n|    2 | Fist_1    |    1 |\n|    4 | First_1_1 |    2 |\n+------+-----------+------+\n3 rows in set (Elapsed: 00:00:00.03)\n<\/code><\/pre>\n\n\n\n<p>2\u3001\u6253\u5f00\u53c2\u6570 _gbase_connect_by_support_table_with_deleted_records<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> show variables like '%deleted%';\n+------------------------------------------------------+-------+\n| Variable_name                                        | Value |\n+------------------------------------------------------+-------+\n| _gbase_connect_by_support_table_with_deleted_records | OFF   |\n+------------------------------------------------------+-------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase> set _gbase_connect_by_support_table_with_deleted_records=1;\nERROR 1229 (HY000): Variable '_gbase_connect_by_support_table_with_deleted_records' is a GLOBAL variable and should be set with SET GLOBAL\ngbase> set global _gbase_connect_by_support_table_with_deleted_records=1;\nQuery OK, 0 rows affected (Elapsed: 00:00:00.00)\n\ngbase> select * from t3 connect by pid=prior id start with pid=0;\n+------+-----------+------+\n| id   | name      | pid  |\n+------+-----------+------+\n|    1 | First     |    0 |\n|    2 | Fist_1    |    1 |\n|    4 | First_1_1 |    2 |\n+------+-----------+------+\n3 rows in set (Elapsed: 00:00:00.01)\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u652f\u6301\u9012\u5f52\u67e5\u8be2\uff0c\u8981\u6c42\u590d\u5236\u8868\u7684\u6570\u636e\u4e0d\u80fd\u6709\u5220\u9664\u7684\uff0c\u5426\u5219\u62a5DETAIL: (GBA-01EX-700) Gbase general error: Restrict: Connect by clause must be used with table not deleted<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,54],"tags":[],"class_list":["post-2001","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2001","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=2001"}],"version-history":[{"count":1,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2001\/revisions"}],"predecessor-version":[{"id":2002,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2001\/revisions\/2002"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=2001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=2001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=2001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}