From: | Oliver Elphick <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | julesa(at)arbodienst-limburg(dot)nl |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: inheritance and audit columns |
Date: | 2002-01-15 10:18:42 |
Message-ID: | 1011089933.9010.28.camel@linda |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Mon, 2002-01-14 at 14:20, Jules Alberts wrote:
...
> what may cause a problem though is that i want to do multiple
> inheritance, something like:
>
> /** start of code **/
> create table dummy (
> dummy_id serial primary_key,
> dummy_name varchar(100)
> ) inherits (foo, bar);
> /** end of code **/
>
> i have two questions about this statement:
>
> 1. the manual says that multiple inheritance is possible, but doesn't
> give an example. is the syntax "inherits (foo, bar)" correct?
>
> 2. both foo and bar have (inherited) columns called mut_user and
> mut_timestamp. can i expect a conflict when creating dummy?
>
> i couldn't find the answers neither in the online help nor in Bruces
> book, also online (maybe i didn't search good enough), so TIA for any
> pointers!
Well, the simple method is to try it! (Which would show you that
"primary_key" is wrong; it should be "primary key".):
junk=# create table dummy (
junk(# dummy_id serial primary key,
junk(# dummy_name varchar(100)
junk(# ) inherits (foo, bar);
NOTICE: CREATE TABLE will create implicit sequence 'dummy_dummy_id_seq'
for SERIAL column 'dummy.dummy_id'
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index
'dummy_pkey' for table 'dummy'
NOTICE: CREATE TABLE: merging multiple inherited definitions of
attribute "mut_user"
NOTICE: CREATE TABLE: merging multiple inherited definitions of
attribute "mut_timestamp"
CREATE
Duplicate multiply inherited columns will be merged if they are of the
same type. It is an error to have them of the same name but different
types:
junk=# create table try (mut_user char(10));
CREATE
junk=# create table foobar (junk serial primary key) inherits
(audit_cols, try);
NOTICE: CREATE TABLE will create implicit sequence 'foobar_junk_seq'
for SERIAL column 'foobar.junk'
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index
'foobar_pkey' for table 'foobar'
NOTICE: CREATE TABLE: merging multiple inherited definitions of
attribute "mut_user"
ERROR: CREATE TABLE: inherited attribute "mut_user" type conflict
(varchar and bpchar)
There are problems with inheritance with regard to inheritance of primry
keys and use of parent tables in foreign key references; see in the todo
details directory.
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
"For I know that my redeemer liveth, and that he shall
stand at the latter day upon the earth"
Job 19:25
From | Date | Subject | |
---|---|---|---|
Next Message | Jules Alberts | 2002-01-15 12:19:46 | Re: inheritance and audit columns |
Previous Message | Andreas Fitzner | 2002-01-15 09:42:55 | Re: length(columnname), solved |