Non è necessario specificare le colonne in WITH
parte. Se lo si omette, i nomi delle colonne saranno determinati dalla prima query in UNION
:
WITH RECURSIVE recursetree AS (
SELECT * FROM tree WHERE parent_id = 0
UNION
SELECT t.*
FROM tree t
JOIN recursetree rt ON rt.id = t.parent_id
)
SELECT *
FROM recursetree;