Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj1PO-0001uW-L5 for pgsql-sql@arkaria.postgresql.org; Thu, 13 Oct 2022 16:50:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oj1PN-00042i-Ck for pgsql-sql@arkaria.postgresql.org; Thu, 13 Oct 2022 16:50:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj1PN-00042Y-24 for pgsql-sql@lists.postgresql.org; Thu, 13 Oct 2022 16:50:09 +0000 Received: from mail.familiegard.de ([2a01:4f8:192:1144::88]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj1PK-0007hB-Kq for pgsql-sql@lists.postgresql.org; Thu, 13 Oct 2022 16:50:07 +0000 Received: from [IPV6:2a02:6d40:2143:b901:92f6:52ff:fe00:a664] (unknown [IPv6:2a02:6d40:2143:b901:92f6:52ff:fe00:a664]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: frank@familie-gard.de) by mail.familiegard.de (Postfix) with ESMTPSA id 1B6B22A0033A for ; Thu, 13 Oct 2022 18:50:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=familie-gard.de; s=202201; t=1665679803; bh=nqUgP7yupBqBQxl1G0MrUbm8gTfT+nVamwCEUjKklvA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=L+x7L5XVP7gdXaoIkTQY/Qlbwk/lc7sD+Ct7a+VJga9yGg94daw2kTnYKq24eMw+w bSOmkFlP0DMqrq6ls+RxE3MlWrKVWCJ1Og5u+gvSiGjOG0jR8xhYeJBWU9wZqBS0kl VEPmisLIke4K80B6pClq88cu9W9rpifahWx3txKE= Content-Type: multipart/alternative; boundary="------------Psp5lb9GIxC4Qg0aJUnwtUdV" Message-ID: Date: Thu, 13 Oct 2022 18:50:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: Can we generate a series of tables in a loop and then use another loop to union all? Content-Language: de-DE To: pgsql-sql@lists.postgresql.org References: From: Frank Gard In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------Psp5lb9GIxC4Qg0aJUnwtUdV Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, you can use PL/pgSQL's "EXECUTE" to do such things. Cheers, Frank. Am 13.10.22 um 17:44 schrieb Shaozhong SHI: > Can we do the following? > > for j in 1..max loop > create table j as select ............. > end loop; > > Then,  We do > > > Alternatively, can we generate an empty table and append each newly generated table to it so that we end up with a whole table? > > Regards, > > David --------------Psp5lb9GIxC4Qg0aJUnwtUdV Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi,

you can use PL/pgSQL's "EXECUTE" to do such things.

Cheers,
Frank.

Am 13.10.22 um 17:44 schrieb Shaozhong SHI:
Can we do the following?

for j in 1..max loop
create table j as select .............
end loop;

Then,  We do 


Alternatively, can we generate an empty table and append each newly generated table to it so that we end up with a whole table?

Regards,

David
--------------Psp5lb9GIxC4Qg0aJUnwtUdV--