DZone Database Zone
Manipulating Trees Using SQL and the Postgres LTREE Extension
Previously, I used the LTREE extension to save a tree data structure in a Postgres table. After saving the tree, I used the @>, or ancestor operator, to count the number of descendant nodes on a given branch.
But that's not all LTREE can do. Today, I'll show you how to delete, move, and copy branches from one place to another in your tree using @> in combination with other LTREE functions. After that, in my last post in this series, I'll look at how LTREE works under the hood and explore the computer science that makes all of this possible.
No comments:
Post a Comment