Thread: primary key and indexing

primary key and indexing

From
"Sharmad Naik"
Date:
I m sorry If anyone has already asked this Q earlier
    I wanted to know
 
Q1. Whether I can have another key on which the table is indexed even though i have a primary key..Then how would the data be accessed according to primary key or the indexed key of my choice or i can index as per my choice ( primary / index key)?
 
Q2. If possible can anybody tell me how to get the script given in the e-book of Postresql be interpreted in Perl i.e
perl <name of file>
gives an error that Pg is not connected to Dbase

Re: primary key and indexing

From
"Richard Huxton"
Date:
Sorry for lack of proper quoting, you might find it useful to

From: "Sharmad Naik" <sharmad@im.eth.net>


I m sorry If anyone has already asked this Q earlier   I wanted to know

Q1. Whether I can have another key on which the table is indexed even though
i have a primary key..Then how would the data be accessed according to
primary key or the indexed key of my choice or i can index as per my choice
( primary / index key)?

You can create as many indices as you like. Type "\h create index" in psql
for details, but basically:

CREATE INDEX indexname ON table (columnlist)

PostgreSQL will use whichever index it thinks is the most useful. Remember
to vacuum analyze to update table statistics.

Q2. If possible can anybody tell me how to get the script given in the
e-book of Postresql be interpreted in Perl i.e
perl <name of file>
gives an error that Pg is not connected to Dbase

Don't know the script you're talking about. Check the settings in the
connect command. Try "perldoc Pg" for information on how the Pg module
works.

- Richard Huxton