Re: How to set up a table where 2 columns together must be unique?

From: "Dann Corbit" <DCorbit(at)connx(dot)com>
To: <scott_list(at)mischko(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to set up a table where 2 columns together must be unique?
Date: 2003-11-01 06:19:01
Message-ID: D90A5A6C612A39408103E6ECDD77B8294CE2EB@voyager.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: Scott Chapman [mailto:scott_list(at)mischko(dot)com]
> Sent: Friday, October 31, 2003 10:04 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] How to set up a table where 2 columns
> together must be unique?
>
>
> Hi all!
>
> I want to create a table:
>
> user_id: bigserial
> user_name: text
> user_company: text
> password: text
>
> How do I build this table so that user_name+user_company must
> be unique? This way there can be only one of a given username
> for a given company name
> but there can be more than one of a given username if they
> are with different
> companies.

Put a unique index on user_name, user_company.

Browse pgsql-general by date

  From Date Subject
Next Message Paul Thomas 2003-11-01 12:13:37 Re: regular backups - super user
Previous Message Scott Chapman 2003-11-01 06:03:43 How to set up a table where 2 columns together must be unique?