pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: reina@nsi.edu
To: pgsql-admin@postgresql.org
Subject: Re: Primary Key Problems
Date: 28 Dec 2001 14:41:34 -0800
Message-ID: <f40d3195.0112281441.223a73ce@posting.google.com> (raw)
References: <20011208014433.GA2913@c0de.net>

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?



view thread (8+ messages)  latest in thread

Message-ID: <f40d3195.0112281441.223a73ce@posting.google.com>
Permalink:  ../f40d3195.0112281441.223a73ce@posting.google.com/
Also on:    postgresql.org/message-id/f40d3195.0112281441.223a73ce@posting.google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: reina@nsi.edu
  Subject: Re: Primary Key Problems
  In-Reply-To: <f40d3195.0112281441.223a73ce@posting.google.com>
  References: <20011208014433.GA2913@c0de.net> <f40d3195.0112281441.223a73ce@posting.google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox