changing records in inherited tables

From: Adrian Holovaty <postgres(at)holovaty(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: changing records in inherited tables
Date: 2003-08-18 15:37:15
Message-ID: 200308181037.15244.postgres@holovaty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi everybody,

I just started using Postgres a few days ago and love it so far. I've been
trying to wrap my head around its OO features, and I have a question about
table inheritance:

Is it possible to change a record in a parent table in such a way that it is
retroactively inserted into a child table? Here's an example:

CREATE TABLE people (
id SERIAL,
first_name VARCHAR(20),
last_name VARCHAR(30)
);

CREATE TABLE athletes (
sport VARCHAR(10),
uniform_no MEDIUMINT
) INHERITS people;

INSERT INTO people (first_name, last_name) VALUES ('John', 'Smith');

What if John Smith later becomes an athlete? Is that best handled by deleting
him from people and reinserting him into athletes while somehow maintaining
the record ID, or is there a better way to do it?

Thanks in advance,
Adrian

Browse pgsql-novice by date

  From Date Subject
Next Message Adam Witney 2003-08-18 16:05:14 Re: Array Data Type
Previous Message jun queano 2003-08-18 15:29:24 Fw: Array Data Type