【发布时间】:2012-04-05 08:29:43
【问题描述】:
我有一个树形结构的表,列是id,category,parent_id
现在我需要将一个节点及其子节点复制到另一个节点,复制时,类别必须相同,但具有新的 id 和 parent_id..
我的输入将是node to copy & destination node to copy
我已经解释了图像文件中的树结构..
我需要一个函数来做到这一点..,
PostgreSQL 版本 9.1.2
Column | Type | Modifiers
-----------+---------+-------------------------------------------------
id | integer | not null default nextval('t1_id_seq'::regclass)
category | text |
parent_id | integer |
Indexes:
"t1_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"fk_t1_1" FOREIGN KEY (parent_id) REFERENCES t1(id)
Referenced by:
TABLE "t1" CONSTRAINT "fk_t1_1" FOREIGN KEY (parent_id) REFERENCES t1(id)
【问题讨论】:
-
帮助我获得 2 个输入并完成工作...
-
所以基本上你想克隆一个子树?难的。我正在考虑。
-
是的,它很难..我已经尝试了很多功能..没用..
-
我认为可以做到,但您至少需要表格中的一位“状态”。你有备用柱子吗? (也可以在单独的表格中完成)
-
谁能帮我this
标签: sql function postgresql tree