In PostgreSQL, the EXCEPT operator is used to retrieve distinct rows from the result set of the first query that are not present in the result set of the second query. It effectively performs a set difference operation between the two queries. The queries on either side of EXCEPT must have the same number of columns in their result sets, and the columns must be of compatible data types.
Source code viewer
-- Comparing specific columns. SELECT comparing_columns FROM my_table_1 EXCEPT SELECT comparing_columns FROM my_table_2 -- Comparing all columns when tables/schemas are identical. SELECT * FROM my_table_1 EXCEPT SELECT * FROM my_table_2Programming Language: PostgreSQL