Re: Primary Key on Inherited Table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wenjin Zheng <wenjin(dot)zheng(at)lsbc(dot)com>
Cc: "Pgsql-Hackers (E-mail)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Primary Key on Inherited Table
Date: 2000-05-09 21:10:28
Message-ID: 15146.957906628@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Wenjin Zheng <wenjin(dot)zheng(at)lsbc(dot)com> writes:
> Is there a way to specify primary key in the child table using columns
> from parent table? I am using 6.5.0.

It sounds like the PRIMARY KEY spec is getting processed before the
parent table reference is expanded. That's probably a bug, but it's
not going to get fixed in 6.5 ;-). What I'd suggest is not relying
on the PRIMARY KEY syntax, but just writing out the equivalent CREATE
UNIQUE INDEX command separately after you create the child table.

(Strictly speaking, PRIMARY KEY also implies NOT NULL on each column,
which might be hard to duplicate if you don't want the same columns
to be NOT NULL in the parent, but as long as you can set them that
way in the parent you don't need PRIMARY KEY.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 2000-05-09 21:13:29 Re: misc questions
Previous Message Henry B. Hotz 2000-05-09 21:02:17 Re: You're on SecurityFocus.com for the cleartext passwords.