Altering live databases
| От | Gregory Brauer |
|---|---|
| Тема | Altering live databases |
| Дата | |
| Msg-id | 3D51950D.7090004@wildbrain.com обсуждение исходный текст |
| Ответы |
Re: Altering live databases
|
| Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: