AI engineering glossary · SQL databases
What is Recursive CTE?
Recursive CTE: A common table expression that refers to itself: an anchor query gives starting rows, and a recursive part repeatedly adds rows built from the previous step until nothing new appears. It walks hierarchies such as org charts.
Recursive CTE: an example
Starting from the CEO row, each step adds employees whose manager_id matches the previous level, producing the whole reporting tree.
Related terms
More SQL databases terms
- Referential integrity
- Relational algebra
- Relational database
- Replication
- Row
- ROW_NUMBER
- Schema
- Second normal form
Where you learn it
Recursive CTE is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.