Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XVKdp-000384-1J for pgsql-sql@arkaria.postgresql.org; Sat, 20 Sep 2014 13:23:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XVKdo-0002tm-GG for pgsql-sql@arkaria.postgresql.org; Sat, 20 Sep 2014 13:23:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XTTlL-0004Ly-7y for pgsql-sql@postgresql.org; Mon, 15 Sep 2014 10:44:03 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XTTlD-00078e-CU for pgsql-sql@postgresql.org; Mon, 15 Sep 2014 10:44:02 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1XTTl9-0005gw-Vy for pgsql-sql@postgresql.org; Mon, 15 Sep 2014 03:43:51 -0700 Date: Mon, 15 Sep 2014 03:43:51 -0700 (PDT) From: Kamal Kumar TRR To: pgsql-sql@postgresql.org Message-ID: <1410777831983-5819036.post@n5.nabble.com> In-Reply-To: References: Subject: Re: How to compare two tables in PostgreSQL MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org NOTE: SIMILAR TABLES -- Ignore if it doesn't meet your requirement. If you like to compare the structure of the similar tables, then prefer below example which will help you in locating the missing/additional column. Consider we have these two tables on different schema. Table: 1 : billing_name columns: no, name, invid, amount Table 2: billing_name columns: no,name,invid *select * from (select column_name from information_schema.columns where table_schema = 'TEST' and table_name like 'billing_name') WHERE column_name NOT IN (select column_name from information_schema.columns where table_schema = 'public' and table_name like 'billing_name');* *Result Set: amount* Then, you can use any function/SP to dynamically pick the datatype and alter column on run time. Thank you for your time. Kamal -- View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-compare-two-tables-in-PostgreSQL-tp5731597p5819036.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql