Ja. Und es ist sogar noch viel schlimmer:
Siehst Du auch das, was ich sehen? Der PK ist nicht vererbt!!1elf.Code:test=# create table tiere (rasse varchar(30) primary key); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "tiere_pkey" for table "tiere" CREATE TABLE test=*# create table milchvieh (milchmenge real) inherits (tiere); CREATE TABLE test=*# \d tiere Table "public.tiere" Column | Type | Modifiers --------+-----------------------+----------- rasse | character varying(30) | not null Indexes: "tiere_pkey" PRIMARY KEY, btree (rasse) test=*# \d milchvieh Table "public.milchvieh" Column | Type | Modifiers ------------+-----------------------+----------- rasse | character varying(30) | not null milchmenge | real | Inherits: tiere test=*#
Die gute Nachricht: dies ist so auch dokumentiert:
Aus: PostgreSQL: Documentation: Manuals: PostgreSQL 8.4: InheritanceCode:All check constraints and not-null constraints on a parent table are automatically inherited by its children. Other types of constraints (unique, primary key, and foreign key constraints) are not inherited.
Hättest Du nachträglich NOT NULL für die Spalte definiert, so wäre dies 'durchgeschlagen':
[code]
test=# \h alter table
test=# create table tiere (rasse varchar(30));
CREATE TABLE
test=*# create table milchvieh (milchmenge real) inherits (tiere);
CREATE TABLE
test=*# alter table tiere alter column rasse set not null;
ALTER TABLE
test=*# \d tiere
Table "public.tiere"
Column | Type | Modifiers
--------+-----------------------+-----------
rasse | character varying(30) | not null
test=*# \d milchvieh
Table "public.milchvieh"
Column | Type | Modifiers
------------+-----------------------+-----------
rasse | character varying(30) | not null
milchmenge | real |
Inherits: tiere
[/quote]
Du wirst Dich fragen, warum dies so ist: ein PK z.B. erfordert einen zusätzlichen Index, der angelegt werden müßte. Ein NOT NULL nicht. Ich vermute mal, daß daher ein PK nicht vererbt wird. Das ist auch etwas, bei bei table-partitioning zu beachten ist.
Andreas



LinkBack URL
About LinkBacks
Zitieren

Lesezeichen