Re: Primary Key Problems - Mailing list pgsql-admin

From reina@nsi.edu (Tony Reina)
Subject Re: Primary Key Problems
Date
Msg-id f40d3195.0112281441.223a73ce@posting.google.com
Whole thread Raw
In response to Primary Key Problems  (Phill Kenoyer <pgsql@c0de.net>)
List pgsql-admin
pgsql@c0de.net (Phill Kenoyer) wrote in message news:<20011208014433.GA2913@c0de.net>...
> Here is a good one.  I have three fields set for my primary key.  Now I
> thought that a primary key was unique, and dups can not be inserted.
>

I don't think primary keys per se are unique, but rather can be made
unique by specifying that option. IIRC primary keys just allow you to
index searches within the database. So to make a unique primary key
from your db schema:


CREATE TABLE "inventory" (
        "stock" character varying(50) NOT NULL,
        "inventory_type" character varying(20) DEFAULT 'unknown' NOT
NULL,
        "client_id" integer NOT NULL,
[...]
    UNIQUE ("stock", "inventory_type", "client_id")
        Constraint "inventory_pkey"
                Primary Key ("stock", "inventory_type", "client_id")
);

HTH,
-Tony


BTW, I'm using Google newsgroups to view the Postgres messages, but
haven't seen posted messages in several days on the Hackers list. Does
anyone know if this is a Google glitch or is the hackers list just not
very active during the holiday?

pgsql-admin by date:

Previous
From: jmp@safe.ca (Jean-Marc Pigeon)
Date:
Subject: Re: Looking for management software
Next
From: Oleg Lebedev
Date:
Subject: Postgres RPMS for RedHat 7.2