[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-sql
Subject:    Re: [SQL] How to compare two tables in PostgreSQL
From:       Kamal Kumar TRR <kamalkumar.trr () gmail ! com>
Date:       2014-09-15 10:43:51
Message-ID: 1410777831983-5819036.post () n5 ! nabble ! com
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic