Re: Question about Indexes...

From: Aarni Ruuhimäki <aarni(dot)ruuhimaki(at)kymi(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Question about Indexes...
Date: 2004-01-03 10:42:39
Message-ID: 200401031242.39566.aarni.ruuhimaki@kymi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,

You can also use a SEQUENCE which is unique and will add a PK constraint to
your field.

Not sure about the date thing because with sequence you would already have a
PK for that row ? A bit confused too ...

e.g.:

CREATE SEQUENCE main_cats_main_cat_id_seq
START 1
INCREMENT 1
MAXVALUE 9223372036854775807
MINVALUE 1
CACHE 1;

CREATE TABLE main_cats (
main_cat_id integer DEFAULT nextval('"main_cats_main_cat_id_seq"'::text)
NOT NULL,
lang_id integer NOT NULL,
main_cat_name text NOT NULL,
mc_order_nro smallint,
main_cat_show boolean NOT NULL,
sub_cats boolean NOT NULL,
last_mod timestamp without time zone
);

BR,

Aarni

On Saturday 03 January 2004 10:27, you wrote:
> If I create a table and assign the column type for what will be the primary
> key the value of "Serial", do I need to explicitly create an index in
> addition?
>
> I was thinking that a Serial, would automatically be a Unique Index
> wouldn't it? I also set that field to the primary key... does that ensure
> an index is created?
>
> Just a little confused...
>
> Also, while I am on the topic, does it do any good to create indexes on a
> timestamp field?
>
> Thanks in advance,
> Alan
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

--
-------------------------------------------------
Aarni Ruuhimäki | Megative Tmi | KYMI.com
-------------------------------------------------
This is a bugfree broadcast to you from a linux system.
-------------------------------------------------

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message G. Walsh 2004-01-03 12:14:59 Creating initial data bases
Previous Message Sukellusseura Vesikot r.y. 2004-01-03 10:38:57 Re: Question about Indexes...