• <legend id='stLwJ'><style id='stLwJ'><dir id='stLwJ'><q id='stLwJ'></q></dir></style></legend>
      <bdo id='stLwJ'></bdo><ul id='stLwJ'></ul>
  • <small id='stLwJ'></small><noframes id='stLwJ'>

    1. <tfoot id='stLwJ'></tfoot>

        <i id='stLwJ'><tr id='stLwJ'><dt id='stLwJ'><q id='stLwJ'><span id='stLwJ'><b id='stLwJ'><form id='stLwJ'><ins id='stLwJ'></ins><ul id='stLwJ'></ul><sub id='stLwJ'></sub></form><legend id='stLwJ'></legend><bdo id='stLwJ'><pre id='stLwJ'><center id='stLwJ'></center></pre></bdo></b><th id='stLwJ'></th></span></q></dt></tr></i><div id='stLwJ'><tfoot id='stLwJ'></tfoot><dl id='stLwJ'><fieldset id='stLwJ'></fieldset></dl></div>

        Oracle 中的递归

        时间:2023-09-19

            <tbody id='iOEm2'></tbody>

            <legend id='iOEm2'><style id='iOEm2'><dir id='iOEm2'><q id='iOEm2'></q></dir></style></legend>
            <i id='iOEm2'><tr id='iOEm2'><dt id='iOEm2'><q id='iOEm2'><span id='iOEm2'><b id='iOEm2'><form id='iOEm2'><ins id='iOEm2'></ins><ul id='iOEm2'></ul><sub id='iOEm2'></sub></form><legend id='iOEm2'></legend><bdo id='iOEm2'><pre id='iOEm2'><center id='iOEm2'></center></pre></bdo></b><th id='iOEm2'></th></span></q></dt></tr></i><div id='iOEm2'><tfoot id='iOEm2'></tfoot><dl id='iOEm2'><fieldset id='iOEm2'></fieldset></dl></div>

                <small id='iOEm2'></small><noframes id='iOEm2'>

              • <tfoot id='iOEm2'></tfoot>
                • <bdo id='iOEm2'></bdo><ul id='iOEm2'></ul>
                • 本文介绍了Oracle 中的递归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 oracle 中有下表:

                  I have the following table in an oracle:

                  Parent(arg1, arg2)
                  

                  并且我想要关系父级的传递闭包.也就是说,我想要下表

                  and I want the transitive closure of the relation parent. That is, I want the following table

                  Ancestor(arg1, arg2)
                  

                  这在 Oracle 中怎么可能?

                  How is this possible in Oracle?

                  我正在做以下事情:

                  WITH Ancestor(arg1, arg2)  AS (
                  
                    SELECT p.arg1, p.arg2 from parent p
                    UNION
                    SELECT p.arg1 , a.arg2 from parent p,  Ancestor a 
                    WHERE p.arg2 = a.arg1
                  
                  )
                  
                  SELECT DISTINCT * FROM Ancestor;
                  

                  我收到错误

                  *Cause:    column aliasing in WITH clause is not supported yet
                  *Action:   specify aliasing in defintion subquery and retry
                  Error at Line: 1 Column: 20
                  

                  如何在没有列别名的情况下解决此问题?

                  How can I solve this without column aliasing?

                  推荐答案

                  WITH    Ancestor(arg1, arg2) AS
                          (
                          SELECT  p.arg1, p.arg2
                          FROM    parent p
                          WHERE   arg2 NOT IN
                          (
                              SELECT  arg1
                              FROM    parent
                          )
                  
                          UNION ALL
                  
                          SELECT  p.arg1, a.arg2
                          FROM    Ancestor a 
                          JOIN    parent p
                          ON      p.arg2 = a.arg1
                          )
                  SELECT  *
                  FROM    Ancestor
                  

                  Oracle11g Release 2 起仅支持递归 CTE.

                  Oracle only supports recursive CTE since 11g Release 2.

                  在早期版本中,使用CONNECT BY 子句:

                  In earlier versions, use CONNECT BY clause:

                  SELECT  arg1, CONNECT_BY_ROOT arg2
                  FROM    parent
                  START WITH
                          arg2 NOT IN
                          (
                          SELECT  arg1
                          FROM    parent
                          )
                  CONNECT BY
                          arg2 = PRIOR arg1
                  

                  这篇关于Oracle 中的递归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Oracle 在所有表的所有列中搜索字符串 下一篇:动态 Oracle Pivot_In_Clause

                  相关文章

                • <legend id='N7XEZ'><style id='N7XEZ'><dir id='N7XEZ'><q id='N7XEZ'></q></dir></style></legend><tfoot id='N7XEZ'></tfoot>

                    <i id='N7XEZ'><tr id='N7XEZ'><dt id='N7XEZ'><q id='N7XEZ'><span id='N7XEZ'><b id='N7XEZ'><form id='N7XEZ'><ins id='N7XEZ'></ins><ul id='N7XEZ'></ul><sub id='N7XEZ'></sub></form><legend id='N7XEZ'></legend><bdo id='N7XEZ'><pre id='N7XEZ'><center id='N7XEZ'></center></pre></bdo></b><th id='N7XEZ'></th></span></q></dt></tr></i><div id='N7XEZ'><tfoot id='N7XEZ'></tfoot><dl id='N7XEZ'><fieldset id='N7XEZ'></fieldset></dl></div>
                  1. <small id='N7XEZ'></small><noframes id='N7XEZ'>

                      <bdo id='N7XEZ'></bdo><ul id='N7XEZ'></ul>