Re: How to compare two tables in PostgreSQL

From: Kamal Kumar TRR <kamalkumar(dot)trr(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to compare two tables in PostgreSQL
Date: 2014-09-15 10:43:51
Message-ID: 1410777831983-5819036.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Dev Kumkar 2014-09-17 12:16:05 pg_multixact issues
Previous Message Craig Ringer 2014-09-12 15:55:37 Re: VF0072 - Operating System Compatibility for Application PostgreSQL 8.3