Thread: inheritence behavior question ....
I did the following which sounds illogical to me : <snip> test=> create table father (col1 integer not null unique); NOTICE: CREATE TABLE/UNIQUE will create implicit index 'father_col1_key' for table 'father' CREATE test=> create table son (col2 integer) inherits (father); CREATE test=> insert into father (1); ERROR: parser: parse error at or near "1" test=> insert into father values (1); INSERT 19423 1 test=> insert into father values (2); INSERT 19424 1 test=> insert into father values (3); INSERT 19425 1 test=> insert into son values (1, 3); INSERT 19426 1 test=> select * from father; col1 ------ 1 2 3 1 (4 rows) </snip> Could some one explain why the last insert did not fail ? I understand why it could work ! But I would still expect it to fail as the user requested to have the tabl containing unique values and it obviously doesn't contain only uniques .. Much tx, thomas, -- Thomas SMETS rue J. Wytsmanstraat 62 1050 Bruxelles yahoo-id : smetsthomas
Hi Thomas > Could some one explain why the last insert did not fail ? Because you inserted into the table son;-) So why should it fail? Greetings Conni
On Mon, 25 Mar 2002 tsmets@brutele.be wrote: > > I did the following which sounds illogical to me : > <snip> > test=> create table father (col1 integer not null unique); > NOTICE: CREATE TABLE/UNIQUE will create implicit index 'father_col1_key' > for table 'father' > CREATE > test=> create table son (col2 integer) inherits (father); > CREATE Currently primary keys, unique constraints and foreign keys do not inherit to child tables. There's also no current notion of unique across the inheritance tree build in (you can probably kind of fake it with an additional table and a bunch of rules, but...) k
Nope what really bothers me is that I see the son's values while querying the father ! That w/o specifying the father* <snip> test=> select * from father; col1 ------ 1 2 3 1 (4 rows) </snip> I have absolutely no problem with the inserts in the son ! Dropping the constraints at Son's level sound weird to me but I can agree with that w/o toomuch problem ! It's the query result that bothers me ! thomas, -- Thomas SMETS rue J. Wytsmanstraat 62 1050 Bruxelles yahoo-id : smetsthomas ----- Original Message ----- From: "Cornelia Boenigk" <poppcorn@cornelia-boenigk.de> To: "pgsql-general" <pgsql-general@postgresql.org>; <tsmets@brutele.be> Sent: 25 March, 2002 4:12 AM Subject: Re: [GENERAL] inheritence behavior question .... Hi Thomas > Could some one explain why the last insert did not fail ? Because you inserted into the table son;-) So why should it fail? Greetings Conni
On Mon, 2002-03-25 at 10:09, tsmets@brutele.be wrote: > > Nope what really bothers me is that I see the son's values while querying > the father ! ... If you select on a parent table, you see all of its descendents as well. To see just the parent say "SELECT * FROM ONLY father". -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C "Why are you downcast, O my soul? Why so disturbed within me? Put your hope in God, for I will yet praise Him, my Saviour and my God." Psalm 42:11