Sri
Sri

Reputation: 613

MINUS operation in SQL using query

I have a question regarding the MINUS operation in Database Systems. If I want to perform a MINUS operation, is it mandatory that both the tables should have same type of Primary/Composite keys?

I am performing the MINUS operation using normal query and not the operator directly. So in order to do that, is it enough to just compare the Primary key in both tables and do the MINUS operation? Or do I need to do compare all the values in the rows?

Upvotes: 0

Views: 496

Answers (1)

D Stanley
D Stanley

Reputation: 152624

So in order to do that, is it enough to just compare the Primary key in both tables and do the MINUS operation? Or do I need to do compare all the values in the rows?

The MINUS operation in Oracle will return "All distinct rows selected by the first query but not the second" So it has nothing to do with primary keys - it will look at values in all columns.

If you just want to compare primary keys then a NOT IN or NOT EXISTS operator with a subquery might be more practical.

Upvotes: 1

Related Questions