Re: R: aggregate over tables in different schema
От | Ivan Sergio Borgonovo |
---|---|
Тема | Re: R: aggregate over tables in different schema |
Дата | |
Msg-id | 20100111123556.53c2e8e3@dawn.webthatworks.it обсуждение исходный текст |
Ответ на | R: aggregate over tables in different schema (Vincenzo Romano <vincenzo.romano@notorand.it>) |
Список | pgsql-general |
On Sun, 10 Jan 2010 10:49:48 +0100 Vincenzo Romano <vincenzo.romano@notorand.it> wrote: > Try using inheritance. One of the things I didn't mention is: I've to join these tables with other tables that may or may not (public) belong to the same schema. select sum(i.qty) from s1.list_items li join public.item i on i.itemid=li.itemid; Now I'd like to pick up the sum over all list_items tables across all the schemas. If I define the summary table as the child of all the sub-tables I'm going to write dynamic SQL anyway. So I guess I should define a common ancestor for all the tables (list_items) in different schema. create public.list_items ( itemid int primary key, // trouble name varchar(32) ); create table s1.list_items ( ) inherits (public.list_items); create table s2.list_items ( ) inherits (public.list_items); But I can't see how am I going to write the query. Furthermore the children should have their own pk and not share them. thanks -- Ivan Sergio Borgonovo http://www.webthatworks.it
В списке pgsql-general по дате отправления: