Обсуждение: Override defaults in inherited fields and tables

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

Override defaults in inherited fields and tables

От
Uwe Feldtmann
Дата:
Hi all,

Is it possible to override the defaults in inherited fields when
defining tables?

e.g.

table1
    field1
    field2

table2 inherits table1
    field1 default 'A'
    field3
    field4

table3 inherits table1
    field1 default 'B'
    field5
    field6




Re: Override defaults in inherited fields and tables

От
Tom Lane
Дата:
Uwe Feldtmann <uwe@microshare.com.au> writes:
> Is it possible to override the defaults in inherited fields when
> defining tables?

Sure.  This has worked for a release or two, IIRC:

regression=# create table parent (f1 int default 42);
CREATE TABLE
regression=# create table child (f1 int default 43) inherits (parent);
NOTICE:  CREATE TABLE: merging attribute "f1" with inherited definition
CREATE TABLE
regression=# insert into child default values;
INSERT 153946 1
regression=# select * from child;
 f1
----
 43
(1 row)


            regards, tom lane