Categories
Database PostgreSQL

Oracle Calls It MINUS, PostgreSQL Calls It EXCEPT

Just in case I run into this again, you can use EXCEPT in PostgreSQL as a replacement for using MINUS in Oracle. This was extremely handy this morning when I ran a query on Oracle and wanted to see if I could do the same thing on exported data in PostgreSQL. Doing a cut-n-paste returned a syntax error because the query used MINUS. A couple of minutes with Google and the PostgreSQL documentation and I discovered that EXCEPT does the same thing that Oracle’s MINUS does. After changing that one word in the query it ran perfectly.

Honestly, I tried to resist the urge, but I just couldn’t. According to the MySQL future feature list MINUS, INTERSECT, and FULL OUTER JOIN will be implemented in the “mid-term future” (after 5.1).

3 replies on “Oracle Calls It MINUS, PostgreSQL Calls It EXCEPT”

Thanks for the info. I tried this but the results were the same as if I had used NOT IN and encountered a NULL – i.e, it acted as though the ‘expression’ was false

In some cases (large result sets) EXCEPT can be much more slower then ‘NOT IN’ or ‘LEFT JOIN’. But as a quick replacement it is same.

Leave a Reply

Your email address will not be published. Required fields are marked *