Mario Splivalo <mario.splivalo@megafon.hr> writes:
> I have two tables, tableA and tableB:
> CREATE TABLE tableA (idA integer primary key, email character varying
> unique);
> CREATE TABLE tableB (idB integer primary key, email character varying
> unique);
> Now, I want to create check constraint in both tables that would
> disallow records to either table where email is 'mentioned' in other table.
Have you considered refactoring so there's only one table?
Cross-table constraints are a really bad idea unless you can express
them as foreign keys. There's a lot of "secret sauce" in the FK
mechanism that isn't available to user-written constraints.
regards, tom lane