Re: Using indexes and keys - Mailing list pgsql-novice

From John Taylor
Subject Re: Using indexes and keys
Date
Msg-id 02021110231000.01463@splash.hq.jtresponse.co.uk
Whole thread Raw
In response to Re: Using indexes and keys  ("Josh Berkus" <josh@agliodbs.com>)
Responses Re: Using indexes and keys  ("Josh Berkus" <josh@agliodbs.com>)
List 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




pgsql-novice by date:

Previous
From: Phil Mitchell
Date:
Subject: how to INSERT foreign keys?
Next
From: Rob
Date:
Subject: Triggers