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.

LVL 1
diteps06Asked:
Who is Participating?
 
awking00Commented:
slightwv, I agree with what you are saying as well, the key being once the columns are mapped. Then a simple intersect would return matching rows or a simple minus would return non-matching rows. The attached procedure will ascertain that for columns that are known to map.
procedure.txt
0
 
awking00Commented:
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.
0
 
slightwv (䄆 Netminder) Commented:
I agree with everything said above.  There is really no way to 'map' columns based on the data contained in them without some possibility of error.

>>columns in Oracle table are equal
>>I'll work on the procedure to manage the first case

Why write code?  Once the columns are mapped, wouldn't a simple INTERSECT query return matching rows?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
awking00Commented:
diteps06,
Can you post a describe of the two tables?
0
 
awking00Commented:
The attached procedure will find columns whose names are different, but whose datatypes are the same and the data in each table is the same. The problem with this is that, if they don't match, you won't know whether it's due to the data or it's a different column altogether.
procedure2.txt
0
 
diteps06Author Commented:
THANKS THE SOLUTIONS WERE VERY SEFUL
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.