Re: Primary Key Problems

From: reina(at)nsi(dot)edu (Tony Reina)
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Primary Key Problems
Date: 2001-12-28 22:41:34
Message-ID: f40d3195.0112281441.223a73ce@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

pgsql(at)c0de(dot)net (Phill Kenoyer) wrote in message news:<20011208014433(dot)GA2913(at)c0de(dot)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?

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Oleg Lebedev 2001-12-28 23:55:01 Postgres RPMS for RedHat 7.2
Previous Message Andrew McMillan 2001-12-28 21:50:55 Re: [ADMIN] compression -Fx "problem"