Search Postgresql Archives

Re: Help with exclusion constraint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Moshe Jacobson <moshe@xxxxxxxxxxxx> writes:

> Take the following table:
>
> CREATE TABLE exclusion_example AS
> (
>      pk_col  integer primary key,
>      fk_col integer not null references other_table,
>      bool_col boolean not null
> );
>
> I want to ensure that for any given value of fk_col that there is a maximum
> of one row with bool_col = true.

This should be what you want:

ALTER TABLE exclusion_example
ADD CONSTRAINT ex
EXCLUDE (fk_col WITH =) WHERE (bool_col);



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux