Knowledge (XXG)

Hierarchical and recursive queries in SQL

Source đź“ť

173: 2081: 2091: 2101: 35: 761:
7902 2 | BLAKE | 7698 | 7839 3 | ALLEN | 7499 | 7698 3 | WARD | 7521 | 7698 3 | MARTIN | 7654 | 7698 3 | TURNER | 7844 | 7698 3 | JAMES | 7900 | 7698 2 | CLARK | 7782 | 7839 3 | MILLER | 7934 | 7782 (14 rows)
539:
construct; it was introduced by Oracle in the 1980s. Prior to Oracle 10g, the construct was only useful for traversing acyclic graphs because it returned an error on detecting any cycles; in version 10g Oracle introduced the NOCYCLE feature (and keyword), making the traversal work in the presence of
760:
level | employee | empno | manager -------+-------------+-------+--------- 1 | KING | 7839 | 2 | JONES | 7566 | 7839 3 | SCOTT | 7788 | 7566 4 | ADAMS | 7876 | 7788 3 | FORD | 7902 | 7566 4 | SMITH | 7369 |
121:, recursive CTEs were designed with fixpoint semantics from the beginning. Recursive CTEs from the standard were relatively close to the existing implementation in IBM DB2 version 2. Recursive CTEs are also supported by 796:
The following example returns the last name of each employee in department 10, each manager above that employee in the hierarchy, the number of levels between manager and employee, and the path between the two:
1691: 302: 53: 359:
Recursive CTEs can be used to traverse relations (as graphs or trees) although the syntax is much more involved because there are no automatic pseudo-columns created (like
1120: 387:, one can populate a table with data generated from a recursive query; random data generation is possible using this technique without using any procedural statements. 1674: 1686: 1222: 1157: 1407: 160:
Without common table expressions or connected-by clauses it is possible to achieve hierarchical queries with user-defined recursive functions.
1583: 1563: 1544: 1517: 1485: 1389: 1362: 1315: 1288: 1261: 1206: 1029: 157:
describing how CTEs can be used. TIBCO Spotfire does not support CTEs, while Oracle 11g Release 2's implementation lacks fixpoint semantics.
1236: 2125: 2084: 390:
Some Databases, like PostgreSQL, support a shorter CREATE RECURSIVE VIEW format which is internally translated into WITH RECURSIVE coding.
1757: 1646: 1436: 1169: 2104: 71: 1461: 376:
In SQL:1999 a recursive (CTE) query may appear anywhere a query is allowed. It's possible, for example, to name the result using
366:); if these are desired, they have to be created in the code. See MSDN documentation or IBM documentation for tutorial examples. 1599: 1810: 1124: 2061: 1708: 1604: 2000: 2026: 1745: 1949: 1939: 1715: 250: 126: 2036: 1769: 1423: 1158:
https://firebirdsql.org/file/documentation/reference_manuals/reference_material/Firebird-2.5-LangRef-Update.pdf
1619: 1995: 1985: 1639: 1698: 207:) is a temporary named result set, derived from a simple query and defined within the execution scope of a 2066: 2021: 1609: 1614: 2041: 1795: 1090: 154: 1404: 2094: 2031: 1913: 1883: 1752: 1703: 254: 122: 1145: 2051: 1944: 1929: 1856: 1681: 1170:
https://stackoverflow.com/questions/42579298/why-does-a-with-clause-give-a-syntax-error-on-informix
2135: 2046: 1990: 1959: 1908: 1740: 1632: 1181: 990: 980: 975: 966: 101: 93: 1800: 1530:. Note that these cover only the SQL:1999 standard (and Datalog), but not the Oracle extension. 1331: 1070: 1866: 1720: 1579: 1559: 1540: 1513: 1481: 1385: 1379: 1358: 1311: 1305: 1284: 1278: 1257: 1202: 1196: 1025: 1019: 290: 1600:
https://stackoverflow.com/questions/1731889/cycle-detection-with-recursive-subquery-factoring
1251: 2056: 1903: 1893: 1861: 1475: 1350: 1345:
Benedikt, M.; Senellart, P. (2011). "Databases". In Blum, Edward K.; Aho, Alfred V. (eds.).
1440: 1964: 1934: 1888: 1669: 1411: 555: 258: 231: 1605:
http://explainextended.com/2009/11/18/sql-server-are-the-recursive-ctes-really-set-based/
1049: 2016: 1954: 1898: 1871: 1764: 1725: 995: 970: 547: 1146:
Paragon corporation: Using PostgreSQL User-Defined Functions to solve the Tree Problem
172: 2119: 1835: 1820: 2130: 985: 563: 551: 282: 138: 89: 570:
although only if it is enabled as a compatibility mode. The syntax is as follows:
1354: 1825: 1805: 1195:
Karen Morton; Robyn Sands; Jared Still; Riyaj Shamsudeen; Kerry Osborne (2010).
1969: 1878: 1840: 1815: 1624: 1505: 1121:"MySQL 8.0 Labs: [Recursive] Common Table Expressions in MySQL (CTEs)" 262: 130: 394: 298: 373:
keyword is not usually needed after WITH in systems other than PostgreSQL.
1620:
http://www.blacktdn.com.br/2015/06/blacktdn-mssql-usando-consulta-cte.html
17: 1830: 1785: 1655: 286: 246: 238: 227: 108: 97: 308:
The syntax for a CTE (which may or may not be recursive) is as follows:
1610:
https://web.archive.org/web/20131114094211/http://gennick.com/with.html
1105: 960: 567: 294: 266: 242: 146: 1615:
http://www.cs.duke.edu/courses/fall04/cps116/lectures/11-recursion.pdf
1735: 559: 278: 274: 142: 134: 1730: 270: 150: 1790: 1574:
Hector Garcia-Molina; Jeffrey D. Ullman; Jennifer Widom (2009).
1628: 204: 167: 28: 226:
CTEs can be thought of as alternatives to derived tables (
1578:(2nd ed.). Pearson Prentice Hall. pp. 437–445. 1510:
SQL and Relational Theory: How to Write Accurate SQL Code
111:
hierarchical queries are implemented by way of recursive
1535:
Abraham Silberschatz; Henry Korth; S. Sudarshan (2010).
1347:
Computer Science. The Hardware, Software and Heart of It
184: 96:
data. They are special cases of more general recursive
49: 1280:
SQL:1999: Understanding Relational Language Components
1021:
SQL:1999: Understanding Relational Language Components
2009: 1978: 1922: 1849: 1778: 1662: 44:
may be too technical for most readers to understand
1512:(2nd ed.). O'Reilly Media. pp. 159–163. 1050:"Recursive Queries Using Common Table Expressions" 757:The output from the above query would look like: 1480:(3rd ed.). O'Reilly Media, Inc. p. 8. 1148:, February 15, 2004, accessed September 19, 2015 1539:(6th ed.). McGraw-Hill. pp. 187–192. 393:An example of a recursive query computing the 1640: 8: 1554:Raghu Ramakrishnan; Johannes Gehrke (2003). 1013: 1011: 113: 1043: 1041: 305:. Oracle calls CTEs "subquery factoring". 1647: 1633: 1625: 1307:A Complete Guide to DB2 Universal Database 969:are a specific kind of recursive query in 535:An alternative syntax is the non-standard 237:Common table expressions are supported by 397:of numbers from 0 to 9 is the following: 72:Learn how and when to remove this message 56:, without removing the technical details. 1168:possible before 14.10 with temp tables 1007: 203:A common table expression, or CTE, (in 261:(with recursion since 11g release 2), 1378:Sanjay Mishra; Alan Beaulieu (2004). 1310:. Morgan Kaufmann. pp. 253–254. 234:, and inline user-defined functions. 54:make it understandable to non-experts 7: 1384:. O'Reilly Media, Inc. p. 227. 2100: 1576:Database systems: the complete book 363: 1277:Jim Melton; Alan R. Simon (2002). 1018:Jim Melton; Alan R. Simon (2002). 25: 2099: 2089: 2080: 2079: 1283:. Morgan Kaufmann. p. 352. 963:also implements fixpoint queries 171: 117:(CTEs). Unlike Oracle's earlier 33: 2090: 118: 1256:. O'Reilly Media. p. 94. 257:(starting with version 2005), 249:(starting with version 14.1), 1: 1558:(3rd ed.). McGraw-Hill. 253:(starting with version 2.1), 1355:10.1007/978-1-4614-1168-0_10 1250:Regina Obe; Leo Hsu (2012). 1071:"Firebird 2.1 Release Notes" 241:(starting with version 14), 125:(since SQL Server 2008 R2), 2126:Database management systems 1656:Database management systems 1556:Database management systems 1437:"CUBRID Hierarchical Query" 1069:Helen Borrie (2008-07-15). 293:(starting with version 9), 2152: 2062:Object–relational database 1253:PostgreSQL: Up and Running 2075: 2037:Federated database system 1770:Blockchain-based database 1474:Jonathan Gennick (2010). 155:Tableau has documentation 1537:Database System Concepts 799: 644: 572: 399: 383:. Using a CTE inside an 333: 310: 114:common table expressions 1304:Don Chamberlin (1998). 1201:. Apress. p. 283. 164:Common table expression 100:queries, which compute 2067:Transaction processing 2022:Database normalization 1965:Query rewriting system 285:(since 14.10), Google 2042:Referential integrity 507:-- Recursive Subquery 2032:Distributed database 1424:Hierarchical Queries 1405:Hierarchical Queries 1381:Mastering Oracle SQL 967:Regular path queries 916:"Employee" 808:"Employee" 695:"employee" 301:(experimental), and 255:Microsoft SQL Server 123:Microsoft SQL Server 2052:Relational calculus 1930:Concurrency control 1462:Hierarchical Clause 1443:on 14 February 2013 1334:. 10 February 2022. 1136:mysqlserverteam.com 1093:. 10 February 2022. 1024:. Morgan Kaufmann. 976:Deductive databases 949:SYS_CONNECT_BY_PATH 928:"Pathlen" 922:"Manager" 841:SYS_CONNECT_BY_PATH 835:"Pathlen" 820:"Manager" 710:"manager" 444:-- Initial Subquery 102:transitive closures 2047:Relational algebra 1991:Query optimization 1796:Armstrong's axioms 1528:Academic textbooks 1410:2008-06-21 at the 991:Transitive closure 981:Hierarchical model 781:CONNECT_BY_ISCYCLE 183:. You can help by 94:hierarchical model 86:hierarchical query 2113: 2112: 1721:Wide-column store 1716:Document-oriented 1585:978-0-13-187325-4 1565:978-0-07-246563-1 1546:978-0-07-352332-3 1519:978-1-4493-1640-2 1487:978-1-4493-9409-7 1391:978-0-596-00632-7 1364:978-1-4614-1167-3 1317:978-1-55860-482-7 1290:978-1-55860-456-8 1263:978-1-4493-2633-3 1208:978-1-4302-3228-5 1031:978-1-55860-456-8 776:CONNECT_BY_ISLEAF 201: 200: 119:connect-by clause 82: 81: 74: 16:(Redirected from 2143: 2103: 2102: 2093: 2092: 2083: 2082: 2057:Relational model 2027:Database storage 1904:Stored procedure 1649: 1642: 1635: 1626: 1589: 1569: 1550: 1523: 1492: 1491: 1477:SQL Pocket Guide 1471: 1465: 1459: 1453: 1452: 1450: 1448: 1439:. Archived from 1433: 1427: 1421: 1415: 1402: 1396: 1395: 1375: 1369: 1368: 1342: 1336: 1335: 1328: 1322: 1321: 1301: 1295: 1294: 1274: 1268: 1267: 1247: 1241: 1240: 1233: 1227: 1226: 1219: 1213: 1212: 1192: 1186: 1185: 1178: 1172: 1166: 1160: 1155: 1149: 1143: 1137: 1135: 1133: 1132: 1123:. Archived from 1117: 1111: 1109: 1102: 1096: 1094: 1087: 1081: 1080: 1078: 1077: 1066: 1060: 1059: 1057: 1056: 1045: 1036: 1035: 1015: 950: 938: 935: 934:"Path" 932: 929: 926: 923: 920: 917: 914: 911: 908: 905: 902: 899: 896: 893: 890: 887: 884: 881: 878: 875: 872: 869: 866: 863: 860: 859:"Path" 857: 854: 851: 848: 845: 842: 839: 836: 833: 830: 827: 824: 821: 818: 815: 812: 809: 806: 803: 787: 782: 777: 772: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 636: 633: 630: 627: 624: 621: 618: 615: 612: 609: 606: 603: 600: 597: 594: 591: 588: 585: 584:table_expression 582: 579: 576: 546:is supported by 545: 540:cycles as well. 538: 526: 523: 520: 517: 514: 511: 508: 505: 502: 499: 496: 493: 490: 487: 484: 481: 478: 475: 472: 469: 466: 463: 460: 457: 454: 451: 448: 445: 442: 439: 436: 433: 430: 427: 424: 421: 418: 415: 412: 409: 406: 403: 386: 382: 379: 372: 362: 355: 352: 349: 346: 343: 340: 337: 330: 323: 320: 317: 314: 222: 218: 214: 210: 196: 193: 175: 168: 141:version 11.50+, 77: 70: 66: 63: 57: 37: 36: 29: 21: 2151: 2150: 2146: 2145: 2144: 2142: 2141: 2140: 2116: 2115: 2114: 2109: 2071: 2017:Database models 2005: 1974: 1960:Query optimizer 1935:Data dictionary 1918: 1889:Transaction log 1845: 1801:Codd's 12 rules 1774: 1704:Column-oriented 1670:Object-oriented 1658: 1653: 1596: 1586: 1573: 1566: 1553: 1547: 1534: 1520: 1504: 1501: 1499:Further reading 1496: 1495: 1488: 1473: 1472: 1468: 1460: 1456: 1446: 1444: 1435: 1434: 1430: 1422: 1418: 1412:Wayback Machine 1403: 1399: 1392: 1377: 1376: 1372: 1365: 1349:. p. 189. 1344: 1343: 1339: 1330: 1329: 1325: 1318: 1303: 1302: 1298: 1291: 1276: 1275: 1271: 1264: 1249: 1248: 1244: 1235: 1234: 1230: 1221: 1220: 1216: 1209: 1194: 1193: 1189: 1180: 1179: 1175: 1167: 1163: 1156: 1152: 1144: 1140: 1130: 1128: 1119: 1118: 1114: 1104: 1103: 1099: 1089: 1088: 1084: 1075: 1073: 1068: 1067: 1063: 1054: 1052: 1047: 1046: 1039: 1032: 1017: 1016: 1009: 1004: 971:graph databases 957: 948: 945: 940: 939: 936: 933: 930: 927: 924: 921: 918: 915: 912: 909: 906: 903: 900: 897: 894: 891: 888: 885: 882: 879: 876: 873: 870: 867: 864: 861: 858: 855: 852: 849: 846: 843: 840: 837: 834: 831: 828: 825: 822: 819: 816: 814:CONNECT_BY_ROOT 813: 810: 807: 804: 801: 794: 792:Unary operators 786:CONNECT_BY_ROOT 785: 780: 775: 770: 767: 762: 755: 754: 751: 748: 745: 742: 739: 736: 733: 730: 727: 724: 721: 718: 715: 712: 709: 706: 703: 700: 697: 694: 691: 688: 685: 682: 679: 676: 673: 670: 667: 664: 661: 658: 655: 652: 649: 646: 638: 637: 634: 631: 628: 625: 622: 619: 616: 613: 610: 607: 604: 601: 598: 595: 592: 589: 586: 583: 580: 577: 574: 556:Oracle database 543: 536: 533: 528: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 404: 401: 384: 380: 377: 370: 360: 357: 356: 353: 350: 347: 344: 341: 338: 335: 328: 325: 324: 321: 318: 315: 312: 277:(since 3.8.3), 220: 216: 212: 208: 197: 191: 188: 181:needs expansion 166: 131:PostgreSQL 8.4+ 78: 67: 61: 58: 50:help improve it 47: 38: 34: 23: 22: 15: 12: 11: 5: 2149: 2147: 2139: 2138: 2133: 2128: 2118: 2117: 2111: 2110: 2108: 2107: 2097: 2087: 2076: 2073: 2072: 2070: 2069: 2064: 2059: 2054: 2049: 2044: 2039: 2034: 2029: 2024: 2019: 2013: 2011: 2010:Related topics 2007: 2006: 2004: 2003: 1998: 1993: 1988: 1986:Administration 1982: 1980: 1976: 1975: 1973: 1972: 1967: 1962: 1957: 1955:Query language 1952: 1947: 1942: 1937: 1932: 1926: 1924: 1920: 1919: 1917: 1916: 1911: 1906: 1901: 1896: 1891: 1886: 1881: 1876: 1875: 1874: 1869: 1864: 1853: 1851: 1847: 1846: 1844: 1843: 1838: 1833: 1828: 1823: 1818: 1813: 1808: 1803: 1798: 1793: 1788: 1782: 1780: 1776: 1775: 1773: 1772: 1767: 1762: 1761: 1760: 1750: 1749: 1748: 1738: 1733: 1728: 1723: 1718: 1713: 1712: 1711: 1701: 1696: 1695: 1694: 1689: 1679: 1678: 1677: 1666: 1664: 1660: 1659: 1654: 1652: 1651: 1644: 1637: 1629: 1623: 1622: 1617: 1612: 1607: 1602: 1595: 1594:External links 1592: 1591: 1590: 1584: 1571: 1564: 1551: 1545: 1525: 1524: 1518: 1500: 1497: 1494: 1493: 1486: 1466: 1464:, IBM Informix 1454: 1428: 1416: 1414:, EnterpriseDB 1397: 1390: 1370: 1363: 1337: 1323: 1316: 1296: 1289: 1269: 1262: 1242: 1228: 1214: 1207: 1198:Pro Oracle SQL 1187: 1173: 1161: 1150: 1138: 1112: 1097: 1091:"WITH Queries" 1082: 1061: 1037: 1030: 1006: 1005: 1003: 1000: 999: 998: 996:Tree structure 993: 988: 983: 978: 973: 964: 956: 953: 952: 951: 944: 941: 800: 793: 790: 789: 788: 783: 778: 773: 766: 765:Pseudo-columns 763: 759: 645: 643: 642: 573: 532: 529: 400: 334: 331:'s syntax is: 311: 269:(since 10.2), 199: 198: 178: 176: 165: 162: 80: 79: 41: 39: 32: 24: 14: 13: 10: 9: 6: 4: 3: 2: 2148: 2137: 2134: 2132: 2129: 2127: 2124: 2123: 2121: 2106: 2098: 2096: 2088: 2086: 2078: 2077: 2074: 2068: 2065: 2063: 2060: 2058: 2055: 2053: 2050: 2048: 2045: 2043: 2040: 2038: 2035: 2033: 2030: 2028: 2025: 2023: 2020: 2018: 2015: 2014: 2012: 2008: 2002: 1999: 1997: 1994: 1992: 1989: 1987: 1984: 1983: 1981: 1977: 1971: 1968: 1966: 1963: 1961: 1958: 1956: 1953: 1951: 1948: 1946: 1943: 1941: 1938: 1936: 1933: 1931: 1928: 1927: 1925: 1921: 1915: 1912: 1910: 1907: 1905: 1902: 1900: 1897: 1895: 1892: 1890: 1887: 1885: 1882: 1880: 1877: 1873: 1870: 1868: 1865: 1863: 1860: 1859: 1858: 1855: 1854: 1852: 1848: 1842: 1839: 1837: 1836:Surrogate key 1834: 1832: 1829: 1827: 1824: 1822: 1821:Candidate key 1819: 1817: 1814: 1812: 1809: 1807: 1804: 1802: 1799: 1797: 1794: 1792: 1789: 1787: 1784: 1783: 1781: 1777: 1771: 1768: 1766: 1763: 1759: 1756: 1755: 1754: 1751: 1747: 1744: 1743: 1742: 1739: 1737: 1734: 1732: 1729: 1727: 1724: 1722: 1719: 1717: 1714: 1710: 1707: 1706: 1705: 1702: 1700: 1697: 1693: 1690: 1688: 1685: 1684: 1683: 1680: 1676: 1673: 1672: 1671: 1668: 1667: 1665: 1661: 1657: 1650: 1645: 1643: 1638: 1636: 1631: 1630: 1627: 1621: 1618: 1616: 1613: 1611: 1608: 1606: 1603: 1601: 1598: 1597: 1593: 1587: 1581: 1577: 1572: 1567: 1561: 1557: 1552: 1548: 1542: 1538: 1533: 1532: 1531: 1529: 1521: 1515: 1511: 1507: 1503: 1502: 1498: 1489: 1483: 1479: 1478: 1470: 1467: 1463: 1458: 1455: 1442: 1438: 1432: 1429: 1425: 1420: 1417: 1413: 1409: 1406: 1401: 1398: 1393: 1387: 1383: 1382: 1374: 1371: 1366: 1360: 1356: 1352: 1348: 1341: 1338: 1333: 1332:"Create View" 1327: 1324: 1319: 1313: 1309: 1308: 1300: 1297: 1292: 1286: 1282: 1281: 1273: 1270: 1265: 1259: 1255: 1254: 1246: 1243: 1238: 1232: 1229: 1224: 1218: 1215: 1210: 1204: 1200: 1199: 1191: 1188: 1183: 1177: 1174: 1171: 1165: 1162: 1159: 1154: 1151: 1147: 1142: 1139: 1127:on 2019-08-16 1126: 1122: 1116: 1113: 1107: 1106:"WITH Clause" 1101: 1098: 1092: 1086: 1083: 1072: 1065: 1062: 1051: 1044: 1042: 1038: 1033: 1027: 1023: 1022: 1014: 1012: 1008: 1001: 997: 994: 992: 989: 987: 984: 982: 979: 977: 974: 972: 968: 965: 962: 959: 958: 954: 947: 946: 942: 798: 791: 784: 779: 774: 769: 768: 764: 758: 640: 639: 571: 569: 565: 561: 557: 553: 549: 541: 530: 398: 396: 391: 388: 374: 367: 365: 332: 309: 306: 304: 300: 296: 292: 288: 284: 280: 276: 273:(since 8.0), 272: 268: 265:(since 8.4), 264: 260: 256: 252: 248: 244: 240: 235: 233: 229: 224: 206: 195: 192:November 2012 186: 182: 179:This section 177: 174: 170: 169: 163: 161: 158: 156: 152: 148: 147:MariaDB 10.2+ 144: 140: 136: 135:SQLite 3.8.3+ 132: 128: 124: 120: 116: 115: 110: 105: 103: 99: 95: 92:that handles 91: 88:is a type of 87: 76: 73: 65: 55: 51: 45: 42:This article 40: 31: 30: 27: 19: 1575: 1555: 1536: 1527: 1526: 1509: 1476: 1469: 1457: 1445:. Retrieved 1441:the original 1431: 1419: 1400: 1380: 1373: 1346: 1340: 1326: 1306: 1299: 1279: 1272: 1252: 1245: 1231: 1217: 1197: 1190: 1176: 1164: 1153: 1141: 1129:. Retrieved 1125:the original 1115: 1100: 1085: 1074:. Retrieved 1064: 1053:. Retrieved 1020: 986:Reachability 795: 756: 641:For example, 564:IBM Informix 552:EnterpriseDB 542: 534: 392: 389: 375: 368: 358: 326: 307: 236: 225: 202: 189: 185:adding to it 180: 159: 151:MySQL 8.0.1+ 139:IBM Informix 127:Firebird 2.1 112: 107:In standard 106: 85: 83: 68: 59: 43: 26: 2105:WikiProject 1996:Replication 1884:Transaction 1826:Foreign key 1806:CAP theorem 1753:Multi-model 1570:Chapter 24. 1447:11 February 1048:Microsoft. 853:'/' 662:' ' 611:parent_expr 605:parent_expr 578:select_list 385:INSERT INTO 303:many others 223:statement. 2120:Categories 1970:Query plan 1923:Components 1841:Unique key 1758:comparison 1692:comparison 1682:Relational 1675:comparison 1506:C. J. Date 1237:"IBM Docs" 1223:"IBM Docs" 1182:"Advanced" 1131:2017-12-20 1095:PostgreSQL 1076:2015-11-24 1055:2009-12-23 1002:References 620:child_expr 599:child_expr 544:CONNECT BY 537:CONNECT BY 531:CONNECT BY 336:query_name 329:with_query 316:with_query 263:PostgreSQL 62:April 2018 18:CONNECT BY 2136:Recursion 1979:Functions 1914:Partition 1741:In-memory 1699:Key–value 943:Functions 548:Snowflake 405:recursive 395:factorial 371:RECURSIVE 90:SQL query 2085:Category 2001:Sharding 1857:Relation 1831:Superkey 1786:Database 1779:Concepts 1508:(2011). 1426:, Oracle 1408:Archived 955:See also 287:BigQuery 283:Informix 279:HyperSQL 251:Firebird 247:Informix 239:Teradata 228:subquery 109:SQL:1999 98:fixpoint 2095:Outline 1894:Trigger 1850:Objects 961:Datalog 892:CONNECT 734:CONNECT 587:CONNECT 568:IBM Db2 295:Vertica 267:MariaDB 243:IBM Db2 48:Please 1909:Cursor 1867:column 1736:NewSQL 1582:  1562:  1543:  1516:  1484:  1388:  1361:  1314:  1287:  1260:  1205:  1110:SQLite 1028:  883:deptno 802:SELECT 647:SELECT 575:SELECT 560:CUBRID 513:SELECT 453:SELECT 432:SELECT 378:CREATE 351:SELECT 327:where 319:SELECT 291:Sybase 275:SQLite 259:Oracle 221:DELETE 217:UPDATE 213:INSERT 209:SELECT 143:CUBRID 1899:Index 1862:table 1765:Cloud 1731:NoSQL 1726:Graph 1663:Types 910:ORDER 901:empno 898:PRIOR 871:LEVEL 868:WHERE 847:ename 826:LEVEL 817:ename 805:ename 771:LEVEL 743:empno 740:PRIOR 719:START 701:empno 692:ename 677:LEVEL 650:LEVEL 617:PRIOR 596:PRIOR 495:WHERE 447:UNION 364:below 361:LEVEL 271:MySQL 232:views 219:, or 1950:ODBC 1940:JDBC 1879:View 1816:Null 1811:CRUD 1791:ACID 1746:list 1709:list 1687:list 1580:ISBN 1560:ISBN 1541:ISBN 1514:ISBN 1482:ISBN 1449:2013 1386:ISBN 1359:ISBN 1312:ISBN 1285:ISBN 1258:ISBN 1203:ISBN 1026:ISBN 874:> 862:FROM 731:NULL 722:WITH 713:FROM 656:LPAD 581:FROM 566:and 522:temp 519:FROM 501:< 492:temp 489:FROM 486:fact 420:fact 408:temp 402:WITH 381:VIEW 369:The 354:...) 313:WITH 149:and 2131:SQL 1945:XQJ 1872:row 1351:doi 907:mgr 880:AND 865:emp 749:mgr 725:mgr 716:emp 707:mgr 635:... 629:... 450:ALL 322:... 230:), 205:SQL 187:. 52:to 2122:: 1357:. 1040:^ 1010:^ 913:BY 895:BY 889:10 737:BY 728:IS 689:|| 686:)) 590:BY 562:, 558:, 554:, 550:, 426:AS 345:AS 299:H2 297:, 289:, 281:, 245:, 215:, 211:, 153:. 145:, 137:, 133:, 129:, 104:. 84:A 1648:e 1641:t 1634:v 1588:. 1568:. 1549:. 1522:. 1490:. 1451:. 1394:. 1367:. 1353:: 1320:. 1293:. 1266:. 1239:. 1225:. 1211:. 1184:. 1134:. 1108:. 1079:. 1058:. 1034:. 937:; 931:, 925:, 919:, 904:= 886:= 877:1 856:) 850:, 844:( 838:, 832:1 829:- 823:, 811:, 752:; 746:= 704:, 698:, 683:1 680:- 674:( 671:* 668:2 665:, 659:( 653:, 632:] 626:] 623:} 614:= 608:| 602:= 593:{ 525:; 516:* 510:) 504:9 498:n 483:* 480:) 477:1 474:+ 471:n 468:( 465:, 462:1 459:+ 456:n 441:1 438:, 435:0 429:( 423:) 417:, 414:n 411:( 348:( 342:] 339:) 194:) 190:( 75:) 69:( 64:) 60:( 46:. 20:)

Index

CONNECT BY
help improve it
make it understandable to non-experts
Learn how and when to remove this message
SQL query
hierarchical model
fixpoint
transitive closures
SQL:1999
common table expressions
connect-by clause
Microsoft SQL Server
Firebird 2.1
PostgreSQL 8.4+
SQLite 3.8.3+
IBM Informix
CUBRID
MariaDB 10.2+
MySQL 8.0.1+
Tableau has documentation

adding to it
SQL
subquery
views
Teradata
IBM Db2
Informix
Firebird
Microsoft SQL Server

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑