Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3QJz-0005Ys-SU for pgsql-general@arkaria.postgresql.org; Tue, 03 Apr 2018 18:06:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f3QJy-0001HQ-Lt for pgsql-general@arkaria.postgresql.org; Tue, 03 Apr 2018 18:06:14 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f3QJy-0001HE-8Q for pgsql-general@lists.postgresql.org; Tue, 03 Apr 2018 18:06:14 +0000 Received: from mail-pl0-x236.google.com ([2607:f8b0:400e:c01::236]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f3QJu-00061r-Ab for pgsql-general@postgresql.org; Tue, 03 Apr 2018 18:06:12 +0000 Received: by mail-pl0-x236.google.com with SMTP id s24-v6so9933185plq.6 for ; Tue, 03 Apr 2018 11:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:mime-version:from:in-reply-to:date:cc:message-id:references :to; bh=qtFUuTtZh1aatqoM5wN5h66/e6YMxrv5i1Q7HN+5tOc=; b=MWh6wA//fO7PqfiU1R1pyrRD+0Hke6CrR8/CG+aZDl0ssNx3JNJABMGnx6LR5AIFuz 71OtdHBlPlfwBDugHM2muh1S+U68ZEVtpgmueObQOgjftBqNBTq6UyHpuExoAjiVaATT /NN/9K+j9URsnrtyuTN98pSCnPFerkRHyjYov/BHqwpDUc5Z2E9RvO14Ee2aA/wsXtA1 zzxO6sRTK+vlOGc7+63PmNNuisaA6AWC8hWWoTcOayZts+zNOP6rk2juNqIOzcJbRz0B TRXACdS/iLo78BI6MedJcxp3cXpt+b/JEQDJaEev2N51h7dplV4shTcwQxlecZrfZcYO cWNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :message-id:references:to; bh=qtFUuTtZh1aatqoM5wN5h66/e6YMxrv5i1Q7HN+5tOc=; b=PAETMo2TxHcOt/YtHWJWyh4dztpR0i9QxW4DBaNLiD8vtjcbR1f4BfEv6eCV3C/JGZ fIR3sHMhQZOIxOvrl7PtYHuwlBJwgvIft+JVyZNkxwhzPafRkra54PrZVRZqNzWAWoJ+ NkqvmYm0XMaLLjGehJSBhF8nUauf10vi0mPCBtigozx7Ni0V5GXJO+z0+t+X+Tvb/YuD RT1PV81PHNvXiqik01o0euA5u+T3BmtU68VBdy+M+x70mObVWEQLy+2XGSVjvp2/7Rcs sCkhATGeTeZDzOYBanF/B5FVY4vGYWT/NjMKWe6Yc5S0PPEiXmEnRSCNO/FO9cIh/AUn XX5A== X-Gm-Message-State: AElRT7EN2DL44x19zulYUvnh0nOvx+iWbj1baLsJGCtCv+l6gmrpgb31 9vV6HG4shpDmMYwBgwQwtv4= X-Google-Smtp-Source: AIpwx4/hknctlXeklP+6CCNj5Md6bNlSRO66Lb3/huZ6U44IsRNx2xU2/a1YUSJo0oSj4KJa6azqcA== X-Received: by 10.101.89.65 with SMTP id g1mr9821811pgu.185.1522778768737; Tue, 03 Apr 2018 11:06:08 -0700 (PDT) Received: from ?IPv6:2600:8801:8800:1a::d? ([2600:8801:8800:1a::d]) by smtp.gmail.com with ESMTPSA id e62sm6605425pfl.117.2018.04.03.11.06.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Apr 2018 11:06:08 -0700 (PDT) Subject: Re: single sql, multiple schemas, one result set Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_D95E8797-9A22-41E2-AB2E-FA7E579627E8" From: Guyren Howe X-Mailbutler-Tracking-Uuid: 04D06157-14EB-4F77-805B-6E91C4FEFF5A X-Mailbutler-Link-Tracking-Uuid: In-Reply-To: <1522777660304-0.post@n3.nabble.com> Date: Tue, 3 Apr 2018 11:05:55 -0700 Cc: pgsql-general@postgresql.org Message-Id: References: <1522777660304-0.post@n3.nabble.com> To: PegoraroF10 X-Mailer: Apple Mail (2.3445.5.20) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_D95E8797-9A22-41E2-AB2E-FA7E579627E8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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 wrote: >=20 > 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 ? >=20 > Then I would use something like ... > select * from SQLFromMultipleShema(Array['Schema1,Schema3'],'select = count(*) > from Table2'); >=20 >=20 >=20 >=20 > -- > Sent from: = http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html >=20 --Apple-Mail=_D95E8797-9A22-41E2-AB2E-FA7E579627E8 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii 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.h= tml


3D""= --Apple-Mail=_D95E8797-9A22-41E2-AB2E-FA7E579627E8--