I
I
ivanovSP2017-10-19 15:54:39
PostgreSQL
ivanovSP, 2017-10-19 15:54:39

How to work with Ltree?

I want to fasten Ltree, I have little experience, tree search is very easy, judging by the help.
But does anyone have examples of how to migrate branches and delete a branch?
Example: There is a department with employees that belongs to a subdivision and I need to transfer this department to another subdivision.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2017-10-19
@melkij

This is the implementation of the materialized path. A branch is deleted if it has no items. Move - move each element. subpath function to help for example

update tablename set tree = concat('newbranch.', subpath(tree, 1))::ltree where tree <@ 'origbranch';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question