Re: A few questions about foreign tables

2023-10-20 Thread Marcin Borkowski
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.

Re: A few questions about foreign tables

2023-10-20 Thread Marcin Borkowski
On 2023-10-18, at 17:56, Laurenz Albe wrote: > On Wed, 2023-10-18 at 10:24 +0200, Marcin Borkowski wrote: >> How to revert the effect of "import foreign schema"? Is just dropping >> the imported tables enough? > > Running DROP FOREIGN TABLE ... for all imported tables is enough. > >> Also, how

Re: A few questions about foreign tables

2023-10-18 Thread Ron
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::reg

Re: A few questions about foreign tables

2023-10-18 Thread Laurenz Albe
On Wed, 2023-10-18 at 10:24 +0200, Marcin Borkowski wrote: > How to revert the effect of "import foreign schema"?  Is just dropping > the imported tables enough? Running DROP FOREIGN TABLE ... for all imported tables is enough. > Also, how can I check the definitions (i.e., what tables on the ser

A few questions about foreign tables

2023-10-18 Thread Marcin Borkowski
Hello, I want to set up a few foreign tables (to access tables from one PostgreSQL database in another one). However, I want to do it "properly", using a database migration tool, so I need to have a "down" migration to revert to the previous state. How to revert the effect of "import foreign sch