Sunday, December 17, 2017

Manipulating Trees Using SQL and the Postgres LTREE Extension

DZone Database Zone
Manipulating Trees Using SQL and the Postgres LTREE Extension
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:

Fun With SQL: Functions in Postgres

DZone Database Zone Fun With SQL: Functions in Postgres In our previous  Fun with SQL  post on the  Citus Data  blog, we covered w...