Postgresql 在postgres的ltree type列中插入Uuid
我有一张下表Postgresql 在postgres的ltree type列中插入Uuid,postgresql,Postgresql,我有一张下表 CREATE TABLE ProductCode_Timeline ( "Uuid" uuid, "Descriptions" text, "Hierarchy" ltree, ) 在上表的“层次结构”列中,我想添加uuid作为路径引用。 像这样的东西 INSERT INTO ProductCode_Timeline (Uuid, Descriptions, Hierarchy) VALUES ( '3a037b24-a7d8-11e6-894d-a4d
CREATE TABLE ProductCode_Timeline
(
"Uuid" uuid,
"Descriptions" text,
"Hierarchy" ltree,
)
在上表的“层次结构”列中,我想添加uuid
作为路径引用。
像这样的东西
INSERT INTO ProductCode_Timeline (Uuid, Descriptions, Hierarchy) VALUES ( '3a037b24-a7d8-11e6-894d-a4db30217df5', "Test", '');
INSERT INTO ProductCode_Timeline (Uuid, Descriptions, Hierarchy) VALUES ( '4a037b24-a7d8-11e6-894d-a4db30217df5', "Test1", '3a037b24-a7d8-11e6-894d-a4db30217df5');
INSERT INTO ProductCode_Timeline (Uuid, Descriptions, Hierarchy) VALUES ( '5a037b24-a7d8-11e6-894d-a4db30217df5', "Test2", '3a037b24-a7d8-11e6-894d-a4db30217df5.4a037b24-a7d8-11e6-894d-a4db30217df5');
尝试在层次结构路径中添加uuid
时,我遇到了错误的语法错误(如上面的示例所示)
如何在层次结构路径中添加Uuid?在研究生中如何处理这种情况
提前感谢。标签是一系列字母数字字符和下划线(例如,在C语言环境中,允许使用字符A-Za-z0-9)。标签长度必须小于256字节。谢谢你,波兹。我已将uuid中的-替换为u,它正在正确插入。但现在我尝试使用where子句获取它,它类似于where层次结构,我认为您可能会在
“Research”
模式下安装ltree
模块,并且在查询时,该模式不在搜索路径中。使用f.ex将其放入搜索路径
<代码>将搜索路径设置为“MyOtherSchema”、“Research”
或使用显式模式语法:层次结构运算符(“Research”)。附带说明:为什么不为层次结构使用父id
?PostgreSQL支持。感谢pozs的评论。它确实帮助我解决了问题。标签是字母数字字符和下划线的序列(例如,在C语言环境中,允许使用字符A-Za-z0-9).标签的长度必须小于256字节。感谢pozs。我已将uuid中的-替换为uu,它正在正确插入。但现在我尝试使用where子句获取它,它类似于where层次结构,我认为您可能会在的“研究”下安装ltree
模块
schema,在查询时,该schema不在search\u路径中
。使用f.ex将其放入search\u路径中。将search\u路径设置为“MyOtherSchema”、“Research”;
或使用显式架构语法:层次运算符(“Research”)。另请注意:为什么不在层次结构中使用parent\u id
?PostgreSQL支持。感谢pozs的评论。它确实帮助我解决了问题。