Skip to content
Advertisement

Oracle SQL find columns with different values

I have two tables A and B both with some millions rows and around one hundred columns.

I want to find which columns have different observations without the need of listing the names of all the columns.

For example, suppose column ID is the primary key in both tables. And that table A is

while table B is

The result of my query would be something about col2. I’m indifferent if a table based on observations form tabla A or B or whatever. What I would like in the query is to avoid to list all the columns since they are a lot. I am not interested in knowing the rows whose columns have different values, only the columns.

EDIT:

Consider these assumptions:

  • First, assume that the columns in the two tables have the same name. I would prefer something that works without this assumption but I’m more than ok with it.

  • Second, the columns of the tables are only numeric. Again, this is assumed to simplify.

Thanks!

Advertisement

Answer

I got the answer from a colleague and I think it’s worth posting it for future users. He used PL/SQL and a loop on the two tables TABLE_A and TABLE_B

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement