SQL tree duplication

Поиск
Список
Период
Сортировка
От Philippe Lang
Тема SQL tree duplication
Дата
Msg-id 6C0CF58A187DA5479245E0830AF84F4218D00A@poweredge.attiksystem.ch
обсуждение исходный текст
Ответы Re: SQL tree duplication  (tv@fuzzy.cz)
Список pgsql-sql
Hi,

I have the following kind of sql structure, in 3 levels:

-----------------------
create table documents ( id serial, name varchar(50), primary key (id)
);

create table lines ( id serial, name varchar(50), document_id integer, primary key (id), foreign key (document_id)
referencesdocuments (id) 
);

create table line_details ( id serial, name varchar(50), line_id integer, primary key (id), foreign key (line_id)
referenceslines (id) 
);
-----------------------

I'd like to be able to "duplicate" a document, with all of its lines and
line details.

Is there any easy way to do that with Postgresql? The only solution I
can think of at the moment is to loop through all lines and line
details, and replace foreign keys properly with values fetch with
"currval". It should work just fine, but I was wondering if some
advanced features of Postgresql could help in this situation.

Regards,

Philippe Lang


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

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: date format
Следующее
От: tv@fuzzy.cz
Дата:
Сообщение: Re: SQL tree duplication