Unix Technical Forum

how to make table inherits another ?

This is a discussion on how to make table inherits another ? within the pgsql Hackers forums, part of the PostgreSQL category; --> Hi there, is't possible to make table to be inherited from another table in case both tables already exist. ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 02:44 AM
Oleg Bartunov
 
Posts: n/a
Default how to make table inherits another ?

Hi there,

is't possible to make table to be inherited from another table in case
both tables already exist. I tried to insert record to pg_inherits,
but it doesn't helped.

openfts=# select * from pg_inherits;
inhrelid | inhparent | inhseqno
----------+-----------+----------
2617283 | 2417279 | 1

did I miss something ?

Regards,
Oleg
__________________________________________________ ___________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 02:44 AM
elein
 
Posts: n/a
Default Re: how to make table inherits another ?

You specify the inheritance on the creation of the child table.
See CREATE TABLE

--elein

On Wed, Feb 16, 2005 at 11:48:54PM +0300, Oleg Bartunov wrote:
> Hi there,
>
> is't possible to make table to be inherited from another table in case
> both tables already exist. I tried to insert record to pg_inherits,
> but it doesn't helped.
>
> openfts=# select * from pg_inherits;
> inhrelid | inhparent | inhseqno
> ----------+-----------+----------
> 2617283 | 2417279 | 1
>
> did I miss something ?
>
> Regards,
> Oleg
> __________________________________________________ ___________
> Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
> Sternberg Astronomical Institute, Moscow University (Russia)
> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
> phone: +007(095)939-16-83, +007(095)939-23-83
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-11-2008, 02:44 AM
Oleg Bartunov
 
Posts: n/a
Default Re: how to make table inherits another ?

On Wed, 16 Feb 2005, elein wrote:

> You specify the inheritance on the creation of the child table.
> See CREATE TABLE


I know this. I need to create inheritance for already created tables.
There is no way to do this using alter table, so I tried to
define it by hand

>
> --elein
>
> On Wed, Feb 16, 2005 at 11:48:54PM +0300, Oleg Bartunov wrote:
>> Hi there,
>>
>> is't possible to make table to be inherited from another table in case
>> both tables already exist. I tried to insert record to pg_inherits,
>> but it doesn't helped.
>>
>> openfts=# select * from pg_inherits;
>> inhrelid | inhparent | inhseqno
>> ----------+-----------+----------
>> 2617283 | 2417279 | 1
>>
>> did I miss something ?
>>
>> Regards,
>> Oleg
>> __________________________________________________ ___________
>> Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
>> Sternberg Astronomical Institute, Moscow University (Russia)
>> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
>> phone: +007(095)939-16-83, +007(095)939-23-83
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 3: if posting/reading through Usenet, please send an appropriate
>> subscribe-nomail command to majordomo@postgresql.org so that your
>> message can get through to the mailing list cleanly
>>

>


Regards,
Oleg
__________________________________________________ ___________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-11-2008, 02:44 AM
Tom Lane
 
Posts: n/a
Default Re: how to make table inherits another ?

Oleg Bartunov <oleg@sai.msu.su> writes:
> I know this. I need to create inheritance for already created tables.
> There is no way to do this using alter table, so I tried to
> define it by hand


Did you remember to set relhassubclass for the parent table?
AFAIR, all that you really need are that and the pg_inherits row.

It'd be a good idea to install a pg_depend entry, and to modify the
child's pg_attribute rows to show the columns as inherited (attislocal
and attinhcount) but I believe the latter would only bite you if you
tried to do ALTER commands on the tables later.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-11-2008, 02:44 AM
Oleg Bartunov
 
Posts: n/a
Default Re: how to make table inherits another ?

On Wed, 16 Feb 2005, Tom Lane wrote:

> Oleg Bartunov <oleg@sai.msu.su> writes:
>> I know this. I need to create inheritance for already created tables.
>> There is no way to do this using alter table, so I tried to
>> define it by hand

>
> Did you remember to set relhassubclass for the parent table?
> AFAIR, all that you really need are that and the pg_inherits row.


Aha, that works. Thanks, Tom.

>
> It'd be a good idea to install a pg_depend entry, and to modify the
> child's pg_attribute rows to show the columns as inherited (attislocal
> and attinhcount) but I believe the latter would only bite you if you
> tried to do ALTER commands on the tables later.
>


I'll save this info.

> regards, tom lane
>


Regards,
Oleg
__________________________________________________ ___________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:19 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com