Re: simulate multiple primary keys

From: "Hartman, Matthew" <Matthew(dot)Hartman(at)krcc(dot)on(dot)ca>
To: "Brandon Metcalf" <brandon(at)geronimoalloys(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: simulate multiple primary keys
Date: 2009-07-02 17:29:10
Message-ID: 366642367C5B354197A1E0D27BC175BD0225981A@KGHMAIL.KGH.ON.CA
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Just create a unique constraint on all of the columns.

Matthew Hartman
Programmer/Analyst
Information Management, ICP
Kingston General Hospital
(613) 549-6666 x4294

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] On Behalf Of Brandon Metcalf
> Sent: Thursday, July 02, 2009 1:28 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] simulate multiple primary keys
>
> I have the following table:
>
> gms=> \d jobclock
> Table "public.jobclock"
> Column | Type |
> Modifiers
>
-------------+--------------------------------+-------------------------
> ---------------------------------------
> jobclock_id | integer | not null default
> nextval('jobclock_jobclock_id_seq'::regclass)
> employee_id | integer | not null
> machine_id | character varying(4) | not null
> workorder | character varying(8) | not null
> operation | integer | not null
> bartype | character varying(10) | not null
> clockin | timestamp(0) without time zone | not null
> clockout | timestamp(0) without time zone | default
NULL::timestamp
> without time zone
> comments | character varying(255) | default
NULL::character
> varying
> Indexes:
> "jobclock_pkey" PRIMARY KEY, btree (jobclock_id)
> ...
>
> I need to keep jobclock_id unique and not null, but I also need to
> ensure that no row is duplicated. Is my best bet to drop the current
> primary key and make a primary key out of the columns that I want to
> ensure remain unique from row to row?
>
> Thanks.
>
>
> --
> Brandon
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
.now.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pedro Doria Meunier 2009-07-02 17:30:09 Re: pgAdmin - no_spool
Previous Message Brandon Metcalf 2009-07-02 17:27:48 simulate multiple primary keys