pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guyren Howe <guyren@gmail.com>
To: PegoraroF10 <marcos@f10.com.br>
Cc: pgsql-general@postgresql.org
Subject: Re: single sql, multiple schemas, one result set
Date: Tue, 3 Apr 2018 11:05:55 -0700
Message-ID: <D01ABCC8-4DD4-401F-9D38-5B9ECE2AC1AD@gmail.com> (raw)
In-Reply-To: <1522777660304-0.post@n3.nabble.com>
References: <1522777660304-0.post@n3.nabble.com>

Make a view that joins all the things, with a column providing the name of the schema that they came from.

> On Apr 3, 2018, at 10:47 , PegoraroF10 <marcos@f10.com.br> wrote:
> 
> Suppose a DB with dozens of schemas with same structure.
> DB
>  Schema1
>    Table1
>    Table2
>  Schema2
>    Table1
>    Table2
>  Schema3
>    Table1
>    Table2
> Then we want to execute a SQL on specific schemas and the result of it could
> be a UNION ALL. So, how could be a function that runs that SQL on each
> schema and results just on result set ?
> 
> Then I would use something like ...
> select * from SQLFromMultipleShema(Array['Schema1,Schema3'],'select count(*)
> from Table2');
> 
> 
> 
> 
> --
> Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
> 

view thread (3+ messages)  latest in thread

Message-ID: <D01ABCC8-4DD4-401F-9D38-5B9ECE2AC1AD@gmail.com>
Permalink:  ../D01ABCC8-4DD4-401F-9D38-5B9ECE2AC1AD@gmail.com/
Also on:    postgresql.org/message-id/D01ABCC8-4DD4-401F-9D38-5B9ECE2AC1AD@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guyren@gmail.com, marcos@f10.com.br
  Subject: Re: single sql, multiple schemas, one result set
  In-Reply-To: <D01ABCC8-4DD4-401F-9D38-5B9ECE2AC1AD@gmail.com>
  References: <1522777660304-0.post@n3.nabble.com> <D01ABCC8-4DD4-401F-9D38-5B9ECE2AC1AD@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox