On Tue, 2009-06-30 at 10:22 +1000, Robert Edwards wrote:
> Would this be in addition to a unique constraint on (a, b, c) (for the
> cases where c is not null)?
That depends on your app's needs. Do you need to enforce uniqueness of
(a,b,c) ? Or of (a,b) where c is _not_ null? If so, then yes, that
Thanks for all these great ideas!
Craig Ringer wrote:
On Mon, 2009-06-29 at 15:42 +1000, Robert Edwards wrote:
Can anyone suggest a way that I can impose uniqueness on a and b when
c is NULL?
One way is to add an additional partial index on (a,b):
CREATE INDEX bobtest_ab_unique ON bobtest(
Craig Ringer writes:
> On Mon, 2009-06-29 at 15:42 +1000, Robert Edwards wrote:
>> Can anyone suggest a way that I can impose uniqueness on a and b when
>> c is NULL?
> One way is to add an additional partial index on (a,b):
> CREATE INDEX bobtest_ab_unique ON bobtest(a,b) WHERE (c IS NULL);
Tha
On Mon, 2009-06-29 at 15:42 +1000, Robert Edwards wrote:
> Can anyone suggest a way that I can impose uniqueness on a and b when
> c is NULL?
One way is to add an additional partial index on (a,b):
CREATE INDEX bobtest_ab_unique ON bobtest(a,b) WHERE (c IS NULL);
... however, if you want to do
In response to Leo Mannhart :
> On Mon, 2009-06-29 at 17:08 +1000, Robert Edwards wrote:
> > A. Kretschmer wrote:
> > > In response to Robert Edwards :
> > >> Can anyone suggest a way that I can impose uniqueness on a and b when
> > >> c is NULL?
> > >
> > > Sure, use a functional index:
> > >
>
In response to Robert Edwards :
> A. Kretschmer wrote:
> >In response to Robert Edwards :
> >>Can anyone suggest a way that I can impose uniqueness on a and b when
> >>c is NULL?
> >
> >Sure, use a functional index:
> >
> >test=# create table bobtest (a int, b int, c int);
> >CREATE TABLE
> >test=*
On Mon, 2009-06-29 at 17:08 +1000, Robert Edwards wrote:
> A. Kretschmer wrote:
> > In response to Robert Edwards :
> >> Can anyone suggest a way that I can impose uniqueness on a and b when
> >> c is NULL?
> >
> > Sure, use a functional index:
> >
> > test=# create table bobtest (a int, b int, c
A. Kretschmer wrote:
In response to Robert Edwards :
Can anyone suggest a way that I can impose uniqueness on a and b when
c is NULL?
Sure, use a functional index:
test=# create table bobtest (a int, b int, c int);
CREATE TABLE
test=*# create unique index idx_bobtest on
bobtest(a,b,coalesce(c
In response to Robert Edwards :
> Can anyone suggest a way that I can impose uniqueness on a and b when
> c is NULL?
Sure, use a functional index:
test=# create table bobtest (a int, b int, c int);
CREATE TABLE
test=*# create unique index idx_bobtest on
bobtest(a,b,coalesce(c::text,'NULL'));
CREA
I have a table with a uniqueness constraint on three columns:
# \d bobtest
Table "public.bobtest"
Column | Type | Modifiers
+-+--
id | integer | not null default nextval('bob
10 matches
Mail list logo