From: Gregory Brauer <greg@wildbrain.com>
To: pgsql-sql@postgresql.org
Subject: Altering live databases
Date: Wed, 07 Aug 2002 14:45:49 -0700
Message-ID: <3D51950D.7090004@wildbrain.com> (raw)
I am starting to do a test run of maintaining a live database,
and I'm trying to figure out how to add a relation to an existing
table. Lets say I do:
CREATE TABLE something
(
id serial ,
);
And later I decide I *really* wish I had done:
CREATE TABLE something
(
id serial ,
foo_id int4 not null,
foreign key(foo_id) references foo(id) on update CASCADE,
);
How can I update a live database to add the missing relation?
So far I know that I need to:
ALTER TABLE issue_transaction ADD COLUMN foo_id int4 not null;
But how do I declare the foreign key and how do I declare the
ON UPDATE? Is this something that is better done from a
backup? I've noticed the trigger syntax in a backup isn't
exactly friendly, and the TOC Entry IDs are numbered, but I
woudn't know what number to use to create a new one.
Advice?
Greg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: greg@wildbrain.com
Subject: Re: Altering live databases
In-Reply-To: <3D51950D.7090004@wildbrain.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox