Postgresql tree data structure

家住魔仙堡 提交于 2021-02-18 20:49:25

问题


I have installed Postgresql 9.2 and would like to use LTREE data type. When I try to create table as in the documentation.

CREATE TABLE test (path ltree);

I have error: type ltree does not exist
I use pgAdmin III for this query. What am I doing wrong? Should I install this module separately. If yes, how?
P.S. OS Windows.


回答1:


You need to install the ltree extension by running:

CREATE EXTENSION ltree;

as a superuser.

See the manual for details: http://www.postgresql.org/docs/current/static/sql-createextension.html

You might also want to read up on recursive queries which let query this kind of data structure in a "regular table" using a parent_id



来源:https://stackoverflow.com/questions/17065625/postgresql-tree-data-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!