Re: copy recursive data

Поиск
Список
Период
Сортировка
От Petronenko D.S.
Тема Re: copy recursive data
Дата
Msg-id 44AAB4F9.2040406@gmail.com
обсуждение исходный текст
Ответы Re: copy recursive data  (Christoph Della Valle <christoph.dellavalle@goetheanum.ch>)
Список pgsql-novice
Hello,

I have two tables. They are linked with foreign key. How can i copy row
with all subrows into the same tables?

For example, i have

table1(id,title):
1,"title1".

table2(id,table1_id,name):
1,1,"name1",
2,1,"name2",
3,1,"name3".

I want to copy first row in table 1 and get following result:
table1(id,title):
1,"title1",
2,"title1".

table2(id,table1_id,name):
1,1,"name1",
2,1,"name2",
3,1,"name3",
4,2,"name1",
5,2,"name2",
6,2,"name3".

How can i do this using sql queries from database side (not from
application side)? And in general case table2 either can contain subrows
from (for example) table3.
Is it possible? and is solution is graceful?

Thanks,
Denis.

В списке pgsql-novice по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: WAL Internals question
Следующее
От: Christoph Della Valle
Дата:
Сообщение: Re: copy recursive data