Re: Composite primary keys

From: Joshua Tolley <eggyknap(at)gmail(dot)com>
To: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Composite primary keys
Date: 2009-06-23 18:44:12
Message-ID: 20090623184412.GG27474@eddie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Jun 23, 2009 at 05:14:36PM +0200, Harald Fuchs wrote:
> test=# CREATE TABLE t2 (
> test(# id int NOT NULL REFERENCES t1,
> test(# language char(3) NULL,
> test(# txt text NOT NULL,
> test(# PRIMARY KEY (id, language)
> test(# );
> CREATE TABLE

<snip>

> test=# INSERT INTO t2 (id, language, txt) VALUES (2, NULL, 'text 1 no language');
> ERROR: null value in column "language" violates not-null constraint

Primary keys are NOT NULL and UNIQUE. You can't have null values in a primary
key.

- Josh / eggyknap

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2009-06-23 19:15:17 Re: Composite primary keys
Previous Message Oliveiros Cristina 2009-06-23 15:32:01 Re: Composite primary keys