Re: Question: unique on multiple columns - Mailing list pgsql-general

From will trillich
Subject Re: Question: unique on multiple columns
Date
Msg-id 20030206163351.GA17263@mail.serensoft.com
Whole thread Raw
In response to Re: Question: unique on multiple columns  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: Question: unique on multiple columns  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
On Wed, Feb 05, 2003 at 10:53:09AM -0600, Bruno Wolff III wrote:
> On Wed, Feb 05, 2003 at 08:09:13 -0600,
>   will trillich <will@serensoft.com> wrote:
> >     create table something (
> >         a int4,
> >         b varchar(20),
> >         c timestamp
> >     );
> >     create unique index on something ( a, c );
> >     create unique index on something ( b, c, a );
>
> While that will work, I think the following format is a little better.
>      create table something (
>          a int4,
>          b varchar(20),
>          c timestamp,
>                 unique(a,c),
>                 unique(b,c,a)
>      );

i like it. see what happens when you have to read the manual for
configuring apache and exim in the same week? it shoves out
previously-gained knowledge. :)

i also like specifying "primary key" at the bottom of the table
def. keeps commas after all the field defs, making it easier to
move whole lines around.

of course, my example is rather bogus -- as others pointed out,
unique(a,c) means that there'll only be 1 b for any a/c pair, so
the unique(b...) index is not-too-useful. it's just an
illustration, and a bad one at that. ah, well...

--
There are 10 kinds of people:
ones that get binary, and ones that don't.

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Looking for a firewall? Do you think smoothwall sucks? You're
probably right... Try the folks at http://clarkconnect.org/ !

pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: Re: Pg_dumpall problem
Next
From: Arjen van der Meijden
Date:
Subject: Re: password() function?