Re: Using indexes and keys

From: John Taylor <postgres(at)jtresponse(dot)co(dot)uk>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>, John Taylor <postgres(at)jtresponse(dot)co(dot)uk>, <pgsql-novice(at)postgresql(dot)org>
Cc: josh(at)agliodbs(dot)com
Subject: Re: Using indexes and keys
Date: 2002-02-11 10:23:10
Message-ID: 02021110231000.01463@splash.hq.jtresponse.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Josh,

I've taken your advise and ordered a book, but until that arrives,
one further question, if you don't mind:

On Friday 08 February 2002 17:49, Josh Berkus wrote:

>
> > 2a) If so - If I define two or more columns as the primary key, will
> > they
> > be indexed seperately, or do I need to index the 2nd and 3rd
> > columns
> > seperately
>
> They will be indexed together. So, if you need to do lookups on the
> 3rd column seperate from the 1st, you will need to build a seperate
> index for that column alone.
>

If I need to lookup on a combined key, how do I do that ?
The CREATE TABLE syntax doesn't seem to allow me to combine the columns into a single key name.

Additionally, if I combine two VARCHAR columns are the following keys unique ?

...
a VARCHAR(10),
b VARCHAR(10),
PRIMARY KEY (a,b),
...

a="abc", b="def"

a="ab", b="cdef"

If not, would I need to make a CHAR(10) rather than VARCHAR(10), or is there some other trick ?

Thanks
JohnT

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bill Triplett 2002-02-11 15:34:36 C Function Question
Previous Message Phil Mitchell 2002-02-10 22:33:05 how to INSERT foreign keys?