user2994978
user2994978

Reputation: 11

Comparing Two tables without knowing columns information

If I have two tables A and B. I want to know if this table are same or not ? i.e check does columns match ? and does data match ?

Upvotes: 1

Views: 42

Answers (2)

pratim_b
pratim_b

Reputation: 1210

Query USER_TAB_COLUMNS for each table

SELECT table_name, column_name, 
    FROM USER_TAB_COLUMNS
    WHERE table_name = 'MYTABLE'

And you can compare it for matching columns .

(hawk's answer will do it in one step.)

Upvotes: 0

Hawk
Hawk

Reputation: 5170

SELECT *
FROM 
(
  (SELECT * FROM Table1
   MINUS 
   SELECT * FROM Table2)
UNION ALL
  (SELECT * FROM Table2
   MINUS
   SELECT * FROM Table1)
 )

Upvotes: 1

Related Questions