Tr: UNIQUE

Started by Stéphane FILLONalmost 27 years ago2 messagesgeneral
Jump to latest
#1Stéphane FILLON
fillons@offratel.nc

-----Message d'origine-----
De : St�phane FILLON <fillons@offratel.nc>
� : pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>;
pgsql-novice@postgresql.org <pgsql-novice@postgresql.org>
Date : dimanche 1 ao�t 1999 09:12
Objet : Tr: UNIQUE

Show quoted text

Hi !

I have a table with a primary key id to have a unique tuple and

I want to check that (fk_acount + code) is unique.

I don't know how to create this CHECK CONSTRAINT

create table amount(
id int4 constraint pk_amount primary key,
fk_acount int4 not null,
code char(3) not null
);

Thanks in advance.

Stephane

#2José Soares
jose@sferacarta.com
In reply to: Stéphane FILLON (#1)
Re: [GENERAL] Tr: UNIQUE

Try this:

create table amount(
id int4 constraint pk_amount primary key,
fk_acount int4 not null,
code char(3) not null,
constraint unico unique (fk_acount, code)
);

Jos�

St�phane FILLON ha scritto:

Show quoted text

-----Message d'origine-----
De : St�phane FILLON <fillons@offratel.nc>
� : pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>;
pgsql-novice@postgresql.org <pgsql-novice@postgresql.org>
Date : dimanche 1 ao�t 1999 09:12
Objet : Tr: UNIQUE

Hi !

I have a table with a primary key id to have a unique tuple and

I want to check that (fk_acount + code) is unique.

I don't know how to create this CHECK CONSTRAINT

create table amount(
id int4 constraint pk_amount primary key,
fk_acount int4 not null,
code char(3) not null
);

Thanks in advance.

Stephane