How to compare 2 VIEWS in Oracle

I would like to know the differences in columns between 2 Views.
To give a simplify example View A_Old can have 3 while View A can have 5 columns.
There are 3 columns common to both views. How can I create a query to return the columns which arent present in both
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

if you know VIEW_A has more columns than VIEW_A_OLD try this...
select column_name,data_type from dba_tab_columns where owner = 'NEW_OWNER' and table_name = 'VIEW_A'
select  column_name,data_type from dba_tab_columns where owner = 'OLD_OWNER' and ttable_name = 'VIEW_A_OLD'

Open in new window

if you have no idea what the difference between views A and B might be,  then try this...
  SELECT   owner, table_name view_name, column_name, data_type
    FROM   dba_tab_columns dtc
       AND table_name IN ('VIEW_A', 'VIEW_B')
                     FROM   (SELECT   *
                               FROM   (SELECT   column_name, data_type
                                         FROM   dba_tab_columns
                                        WHERE   owner = 'VIEW_A_OWNER' AND table_name = 'VIEW_A'
                                       SELECT   column_name, data_type
                                         FROM   dba_tab_columns
                                        WHERE   owner = 'VIEW_B_OWNER' AND table_name = 'VIEW_B')
                             SELECT   *
                               FROM   (SELECT   column_name, data_type
                                         FROM   dba_tab_columns
                                        WHERE   owner = 'VIEW_A_OWNER' AND table_name = 'VIEW_A'
                                       SELECT   column_name, data_type
                                         FROM   dba_tab_columns
                                        WHERE   owner = 'VIEW_B_OWNER' AND table_name = 'VIEW_B')) x
                    WHERE   x.column_name = dtc.column_name AND x.data_type = dtc.data_type)
ORDER BY   owner, view_name, column_name

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I like this one much more, as you have to edit things on one place only:

select    a.column_name,a.data_type, b.column_name, b.data_type
from dba_tab_columns a full join dba_tab_columns b
  on a.column_name = b.column_name and a.data_type = b.data_type
 and a.owner = 'OWNER_NEW' and a.table_name = 'VIEW_NEW'
 and b.owner = 'OWNER_OLD' and b.table_name = 'VIEW_OLD'
where a.column_name is null or b.column_name is null
   or a.data_type != b.data_type

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

diteps06Author Commented:
The question is about View which a join of one or more tables.
It doesn't regard Tables.
I expected functions like DBA_VIEWS OR VIEW_NAME
did you try the queries?

dba_tab_columns has columns for both tables and views
diteps06Author Commented:
I had the error 'table or view doesn't exist' refering to dba_tab_columns.
Can it be a priviliege problem
Maybe, try all_tab_columns instead
diteps06Author Commented:
Thanks alot.
I used the query when you have no idea about the differences between the Views.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.