Postgresql 树状数据结构 [英] Postgresql tree data structure

查看:72
本文介绍了Postgresql 树状数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 Postgresql 9.2 并且想使用 LTREE 数据类型.当我尝试按照文档中的说明创建表格时.

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);

我有错误:type ltree 不存在
我使用 pgAdmin III 进行此查询.我究竟做错了什么?我应该单独安装这个模块吗?如果是,如何?
附言操作系统 Windows.

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.

推荐答案

您需要通过运行以下命令安装 ltree 扩展:

You need to install the ltree extension by running:

CREATE EXTENSION ltree;

作为超级用户.

详见手册:http://www.postgresql.org/docs/current/static/sql-createextension.html

您可能还想阅读递归查询,它允许查询此类使用 parent_id

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

这篇关于Postgresql 树状数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆