Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWkFW-0007dJ-Mc for pgsql-general@arkaria.postgresql.org; Tue, 11 Dec 2018 15:47:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gWkFV-0005W9-7g for pgsql-general@arkaria.postgresql.org; Tue, 11 Dec 2018 15:47:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWkFT-0005W1-F2 for pgsql-general@lists.postgresql.org; Tue, 11 Dec 2018 15:47:05 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gWkFK-0004TV-Qx for pgsql-general@postgresql.org; Tue, 11 Dec 2018 15:47:02 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E1A8722167; Tue, 11 Dec 2018 10:46:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 11 Dec 2018 10:46:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= from:subject:to:references:cc:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=W dE7wLw/EM8R1GsA7ljApg/BbKTGZquUYqB0TPHeZFg=; b=mAQHBE3btf8JM1qt2 vzioslqXWEWtd/h8Q8tI/SbPB8HAw2BZXHDCMa1v9DUODSwGetJwijL+2G5Z482l RCD+UOmdLS1+eqtn0onszyFcq0G4URrUwQzUbPgJwOHY0H1GVXDROrrx+sxXEk43 0IcmX5/WTK2RTvVu5jabxDKuumwMr7tyCV1xlbjqQ+G0obvolTlzK8z+VKVKyQ0k ZRUo/OxkleWYj61VCl31bax4K6cB9KDlbyuPFcg3WZiTbL8Dmu91UY20dn9YwrjW XwfXse2PmvRMnULGlTFHxGTk3jveQ5lyBctMbLT4/xIJnGWqyc/yumvctjNQK2aZ HGccg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=WdE7wLw/EM8R1GsA7ljApg/BbKTGZquUYqB0TPHeZ Fg=; b=Iz8/9JtDJG8vHsNDguEZcW/pNQXliDIrrZ8Ht7s7zNOdMvha9Qy4jhAnB t611vY/+jWzvBKura2KyqUxMCOOJ5u5hYXPRog1TEe6jU53fISY8dnkaxtK16Wo7 vRrhJQdjWGR2rTFMZ/tG9ZfnPlZPNimlxrRR3232Z43Sy4NmK6Y59tsSMkTj2tEJ DNDap/qzBklD5Q2/a9A90h/NmiD0qvgDtHQFrMkUTNR5coBYBwMZSDbzwEVYvNIf jw/8/9dMnXLiG8iV+W1K4vC3tg/ENFKDdTXCuSk36r4nRTamem/q2P+OTpvX24+M 6Nfdo+aTUNOIkEo10oFtqAAUlAWuA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegjedgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecunecujfgurhephffuvfhfkffffgggjggtgfesthekredttdefjeenucfhrhhomh eptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghv vghrrdgtohhmqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppe ejuddrvdduvddrudefgedrfeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 41A17103B3; Tue, 11 Dec 2018 10:46:52 -0500 (EST) From: Adrian Klaver Subject: Re: Newly Created Source DB Table Not Reflecting into Destination Foreign Tables To: ramsiddu007 References: <6c11cbc0-1d3c-87fe-c611-765cfe93e410@aklaver.com> Cc: pgsql-general Message-ID: <5e55ab04-2f31-e147-8ca4-93ce7d51afe8@aklaver.com> Date: Tue, 11 Dec 2018 07:46:51 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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