pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jkakar@expressus.com
To: pgsql-sql@postgresql.org
Subject: Need to do an ALTER TABLE.
Date: Wed, 4 Apr 2001 10:57:38 -0700
Message-ID: <20010404105738.A536@expressus.com> (raw)

Hi,

I've got a live database running PSQL 7.0.3.  I need to do a couple of
changes to some of the table schema's but need to preserve the data
that currently exists in the tables.  I've used pg_dump to make
backups and have verified that I can indeed restore into an empty
database from those backups; I'm glad I did this as I found out I have
to use 'pg_dump -d' to get a useful backup. =)

I need to perform three slightly different ALTER TABLE type jobs:

1. I need to change a column from numeric(8,2) to text.
2. I need to add a column or two to a couple of tables.
3. I need to drop a column or two from a couple of tables.

Initially my thought was to create a new temporary table, SELECT INTO
it from my original table, drop the original table, re-create it as I
need it and do a SELECT INTO from the temporary table back to the new
table.  The thing I'm unsure of is what will happen to referential
integrity?  The tables I need to modify are referenced by other
tables- will those other tables realise that they should re-establish
foreign key references?  If not automatically, will VACUUM ANALYZE do
this for me?

I'm going to experiment in my test database but figured this might be
an interesting topic to discuss anyway.  Also, if any good
advice/answers exist perhaps they should go in the FAQ?

Any suggestions would be appreciated.

Cheers,
Jamu.

-- 
Jamu Kakar (Developer)			Expressus Design Studio, Inc.
jkakar@expressus.com			708-1641 Lonsdale Avenue
V: (604) 903-6994			North Vancouver, BC, V7M 2J5



view thread (3+ messages)  latest in thread

Message-ID: <20010404105738.A536@expressus.com>
Permalink:  ../20010404105738.A536@expressus.com/
Also on:    postgresql.org/message-id/20010404105738.A536@expressus.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jkakar@expressus.com
  Subject: Re: Need to do an ALTER TABLE.
  In-Reply-To: <20010404105738.A536@expressus.com>
  References: <20010404105738.A536@expressus.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