X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2021FD1D1BB for ; Mon, 26 Jan 2004 17:58:50 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 58351-09 for ; Mon, 26 Jan 2004 13:58:19 -0400 (AST) Received: from faraday.gene.com (unknown [192.12.78.250]) by svr1.postgresql.org (Postfix) with ESMTP id 3791BD1CC8B for ; Mon, 26 Jan 2004 13:58:17 -0400 (AST) Received: from tallac.gene.com (tallac.gene.com [128.137.187.213]) by faraday.gene.com (Switch-3.1.0/Switch-3.1.0) with ESMTP id i0QHvlfr009577; Mon, 26 Jan 2004 09:57:48 -0800 (PST) Received: by tallac.gene.com (Postfix, from userid 13922) id E7F8E4BA4A; Mon, 26 Jan 2004 09:57:46 -0800 (PST) Subject: Re: "mirroring" a table - PostgreSQL 7.3.2 From: Reece Hart To: "C. Bensend" Cc: pgsql-admin In-Reply-To: <53768.63.227.74.41.1075004080.squirrel@webmail.stinkweasel.net> References: <53076.63.227.74.41.1074972926.squirrel@webmail.stinkweasel.net> <5233.1074978599@sss.pgh.pa.us> <56251.63.227.74.41.1074979320.squirrel@webmail.stinkweasel.net> <1074984488.5591.29.camel@whoville> <53768.63.227.74.41.1075004080.squirrel@webmail.stinkweasel.net> Content-Type: multipart/alternative; boundary="=-xYUjtgyn8IKsOejTh0OZ" Message-Id: <1075139866.4062.43.camel@tallac> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Mon, 26 Jan 2004 09:57:46 -0800 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/240 X-Sequence-Number: 12103 --=-xYUjtgyn8IKsOejTh0OZ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Sat, 2004-01-24 at 20:14, C. Bensend wrote: > I am loath to ask for a hand-hold here, but could you explain a little > more about how to do such a thing? It's probably easier than you think. Briefly, it goes like this: 1) read http://www.postgresql.org/docs/current/static/tutorial-inheritance.html 2) try those examples 3) In your case: create table bob_def (surname text); create table bob () inherits (bob_def); create table bob_test () inherits (bob_def); insert into bob (surname) values ('smith'); insert into bob_test (surname) values ('gazpacho'); \d bob \d bob_test alter table bob_def add column age integer; \d bob \d bob_test update bob set age=104 where surname='smith'; select * from bob; Note: You'll need to index the subtables separately if that's important to you. -Reece -- Reece Hart, http://www.in-machina.com/~reece/, GPG:0x25EC91A0 0xD178AAF9 --=-xYUjtgyn8IKsOejTh0OZ Content-Type: text/html; charset=utf-8 On Sat, 2004-01-24 at 20:14, C. Bensend wrote:
I am loath to ask for a hand-hold here, but could you explain a little
more about how to do such a thing?

It's probably easier than you think. Briefly, it goes like this:
1) read http://www.postgresql.org/docs/current/static/tutorial-inheritance.html
2) try those examples
3) In your case:
create table bob_def (surname text);
create table bob () inherits (bob_def);
create table bob_test () inherits (bob_def);

insert into bob (surname) values ('smith');
insert into bob_test (surname) values ('gazpacho');

\d bob
\d bob_test
alter table bob_def add column age integer;
\d bob
\d bob_test

update bob set age=104 where surname='smith';

select * from bob;

Note:
You'll need to index the subtables separately if that's important to you.


-Reece

-- 
Reece Hart, http://www.in-machina.com/~reece/, GPG:0x25EC91A0 0xD178AAF9
--=-xYUjtgyn8IKsOejTh0OZ--