Link to home
Start Free TrialLog in
Avatar of diteps06
diteps06Flag for United States of America

asked on

Detect columns in Oracle table are equal comparing data

I would like to detailed compare two tables t1 and t2.
Table t1 have 73 columns whereas t2 have 101.
I would like to have a query which returns columns common to both.
There also columns that have been renamed that at times is difficlut to know they are equivalent.
For example CD_AB may have been rename CD_BD but they are suppose to be the same.
The contents of the columns can confirmed it.
Both tables have 3 columns that make up the primary. Two of the columns are common.
How can I make a query to know some columns are common from their contents.

Avatar of awking00
awking00
Flag of United States of America image

Comparing the data is not difficult, but not knowing which column names to apply is another story. I would start with comparing the columns that you know to be the same (i.e. they have the same name and datatypes). As for the remaining columns, do you expect the values, from your example, of CD_AB in t1 to be the same as the values of CD_BD in t2? If so, you might be able to select the column names from t1 that are not in t2 and dynamically compare them to the columns in t2 that are not in t1 and look for matching data. I'll work on the procedure to manage the first case and, depending on your response to the question, continue with a possible means of determining the second case.
SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
diteps06,
Can you post a describe of the two tables?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of diteps06

ASKER

THANKS THE SOLUTIONS WERE VERY SEFUL