pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Need to do an ALTER TABLE.
3+ messages / 3 participants
[nested] [flat]

* Need to do an ALTER TABLE.
@ 2001-04-04 17:57 jkakar@expressus.com
  2001-04-04 18:55 ` Re: Need to do an ALTER TABLE. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: jkakar@expressus.com @ 2001-04-04 17:57 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Need to do an ALTER TABLE.
  2001-04-04 17:57 Need to do an ALTER TABLE. jkakar@expressus.com
@ 2001-04-04 18:55 ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-04-04 23:07   ` Re: Need to do an ALTER TABLE. Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2001-04-04 18:55 UTC (permalink / raw)
  To: jkakar@expressus.com; +Cc: pgsql-sql

jkakar@expressus.com writes:
> I'm glad I did this as I found out I have
> to use 'pg_dump -d' to get a useful backup. =)

Why?

> 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?

No, and no :-(.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Need to do an ALTER TABLE.
  2001-04-04 17:57 Need to do an ALTER TABLE. jkakar@expressus.com
  2001-04-04 18:55 ` Re: Need to do an ALTER TABLE. Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-04-04 23:07   ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Josh Berkus @ 2001-04-04 23:07 UTC (permalink / raw)
  To: pgsql-sql

Tom,

	That does bring up a related question:  when are we gonna get DROP
COLUMN capability?  Currently my tables are littered with unused columns
because I can't remove them without blowing my referential integrity and
views to heck.

					-Josh Berkus

______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-04-04 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-04 17:57 Need to do an ALTER TABLE. jkakar@expressus.com
2001-04-04 18:55 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-04-04 23:07   ` Josh Berkus <josh@agliodbs.com>

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