Обсуждение: Inheritance of primary key

Поиск
Список
Период
Сортировка

Inheritance of primary key

От
Don Yury
Дата:
Hi All.

I asked a question in group "novice" but haven't got an answer,
therefore decided to ask here.
How to inherit primary key?
For example, i have created tables
create table t1(
id int4  .... primary key
)

create table t2(
name text
)
inherits (t1)

and i would like to have id as a primary key in t2. But when i look at
the list of indexes in pg_index, i see there are t1_pkey - index for
primary key in t1, but don't see the same for t2, so id is not a primary
key in t2.

I tried

create table t2(
name text
primary key (id)
)
inherits (t1)

but got an error.

How i can make field id as a primary key in t2?
Thank you in advance.

Sincerely yours, Yury.
don.web-page.net, ICQ 11831432