From: Adrian Klaver <adrian.klaver@aklaver.com>
To: ramsiddu007 <ramsiddu007@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Newly Created Source DB Table Not Reflecting into Destination Foreign Tables
Date: Tue, 11 Dec 2018 07:46:51 -0800
Message-ID: <5e55ab04-2f31-e147-8ca4-93ce7d51afe8@aklaver.com> (raw)
In-Reply-To: <CA+zEy784QW0P_PsRic9b3F-P9Or8DWDzOZeTEuSxbBqhqh9_ig@mail.gmail.com>
References: <CA+zEy78vXrRt9As57m5XP+DrDw-i4GRK_Htsp34JFHwKcjO+FA@mail.gmail.com>
<6c11cbc0-1d3c-87fe-c611-765cfe93e410@aklaver.com>
<CA+zEy784QW0P_PsRic9b3F-P9Or8DWDzOZeTEuSxbBqhqh9_ig@mail.gmail.com>
On 12/11/18 7:28 AM, ramsiddu007 wrote:
Please reply to list also.
Ccing list.
> Thanks for giving reply.
> 1. Postgres Version: 11
>
> 2. Below Databases are in Single Server:
> Source Database (TestDB1):
> ---------------------------------------
> create table dept(deptno smallint, dname character varying(50), location
> character varying(50));
> insert into dept values (10, 'Product - Development',
> 'Hyderabad'), (20, 'Product - Sales', 'Pune'), (30, 'Product -
> Marketing', 'Bangalore');
>
> Destination Database (TestDB2):
> ---------------------------------------------
> create extension postgres_fdw;
>
> CREATE SERVER fdw_hr
> FOREIGN DATA WRAPPER postgres_fdw
> OPTIONS (dbname 'TestDB1', host '192.168.52.25', port '5432');
>
> CREATE USER MAPPING for postgres
> SERVER fdw_hr
> OPTIONS (user 'postgres', password 'Qazwsx@12');
>
> IMPORT FOREIGN SCHEMA "public" FROM SERVER fdw_hr INTO public;
>
> Now dept table in foreign tables tree view in destination database.
>
> I have ran below query in destination database
> select * from dept;
>
> Good. Above query getting data.
>
> After that i have created emp table in Destination Database like below
>
> CREATE TABLE employee (empid int, eame character varying(20), deptno
> smallint);
>
> insert into employee values (101, 'Einstein', 10), (102, 'Saleem Ali',
> 20), (103, 'Adison', 30);
>
> after that emp table not came in foreign table tree view in destination
> database.
https://www.postgresql.org/docs/11/sql-importforeignschema.html
"By default, all tables and views existing in a particular schema on the
foreign server are imported"
The emp table did not exist when you did the initial IMPORT FOREIGN
SCHEMA. You will need to import it using either CREATE FOREIGN TABLE or
IMPORT FOREIGN SCHEMA. NOTE: For IMPORT FOREIGN SCHEMA you can exclude
the existing table using:
EXCEPT ( table_name [, ...] )
>
> I have done those things only, no configurations done.
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, ramsiddu007@gmail.com
Subject: Re: Newly Created Source DB Table Not Reflecting into Destination Foreign Tables
In-Reply-To: <5e55ab04-2f31-e147-8ca4-93ce7d51afe8@aklaver.com>
References: <CA+zEy78vXrRt9As57m5XP+DrDw-i4GRK_Htsp34JFHwKcjO+FA@mail.gmail.com> <6c11cbc0-1d3c-87fe-c611-765cfe93e410@aklaver.com> <CA+zEy784QW0P_PsRic9b3F-P9Or8DWDzOZeTEuSxbBqhqh9_ig@mail.gmail.com> <5e55ab04-2f31-e147-8ca4-93ce7d51afe8@aklaver.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