Re: Primary Key Problems

Поиск
Список
Период
Сортировка
От reina@nsi.edu (Tony Reina)
Тема Re: Primary Key Problems
Дата
Msg-id f40d3195.0112281441.223a73ce@posting.google.com
обсуждение исходный текст
Ответ на Primary Key Problems  (Phill Kenoyer <pgsql@c0de.net>)
Список 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 по дате отправления:

Предыдущее
От: jmp@safe.ca (Jean-Marc Pigeon)
Дата:
Сообщение: Re: Looking for management software
Следующее
От: Oleg Lebedev
Дата:
Сообщение: Postgres RPMS for RedHat 7.2