Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtqpR-00EDfC-Bz for pgsql-general@arkaria.postgresql.org; Fri, 20 Oct 2023 14:50:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qtqaw-002ozZ-2V for pgsql-general@arkaria.postgresql.org; Fri, 20 Oct 2023 14:35:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtkqb-00F8B4-2b for pgsql-general@lists.postgresql.org; Fri, 20 Oct 2023 08:27:09 +0000 Received: from mail.mojserwer.eu ([195.110.48.8]) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qtkqZ-001OF4-1o for pgsql-general@lists.postgresql.org; Fri, 20 Oct 2023 08:27:08 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 25698976D4B; Fri, 20 Oct 2023 10:27:05 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tOqR74I-9BWS; Fri, 20 Oct 2023 10:27:02 +0200 (CEST) Received: from localhost (91-227-196-3.net4me.pl [91.227.196.3]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 03AE122715A4; Fri, 20 Oct 2023 10:27:00 +0200 (CEST) References: <87bkcws5i3.fsf@mbork.pl> <4e7b5deef8b8e5e603bcb9dc32fc20e84bb95419.camel@cybertec.at> <66971fc2-d49c-4c50-a8bb-a185fd543fa1@gmail.com> User-agent: mu4e 1.1.0; emacs 30.0.50 From: Marcin Borkowski To: Ron Cc: pgsql-general@lists.postgresql.org Subject: Re: A few questions about foreign tables In-reply-to: <66971fc2-d49c-4c50-a8bb-a185fd543fa1@gmail.com> Date: Fri, 20 Oct 2023 10:27:00 +0200 Message-ID: <871qdp3dij.fsf@mbork.pl> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-10-18, at 18:14, Ron wrote: > And SELECT relnamespace::regnamespace::text, relname FROM pg_class > WHERE relkind='f'; tells you all of the foreign tables. > > Thus, this (untested) query generate all of the DROP FOREIGN TABLE statements: > SELECT format('DROP FOREIGN TABLE IF EXISTS %I.%I RESTRICT;' > , relnamespace::regnamespace::text, relname) > FROM pg_class WHERE relkind='f' > ORDER BY relkind; Thanks, though happily I only have about a dozen of them, so I could create these by hand (well, actually by some automation features of my text editor). Best, -- Marcin Borkowski http://mbork.pl