From: | will trillich <will(at)serensoft(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Question: unique on multiple columns |
Date: | 2003-02-06 16:33:51 |
Message-ID: | 20030206163351.GA17263@mail.serensoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)serensoft(dot)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(at)serensoft(dot)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/ !
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-02-06 16:35:26 | Re: Deleting orphan records |
Previous Message | Dennis Gearon | 2003-02-06 16:33:12 | Re: how to determine OID of the row I just inserted??? |