alter table workaround - Mailing list pgsql-general

From wsheldah@lexmark.com
Subject alter table workaround
Date
Msg-id 200110311516.KAA03579@interlock2.lexmark.com
Whole thread Raw
Responses Re: alter table workaround  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: alter table workaround  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

I just had to expand a column from varchar(10) to varchar(75). The affected
table had a sequence and almost a dozen referential integrity triggers, so a
straight 'drop table; create table' solution wouldn't be enough.  Joel Burton's
techdoc on the subject
(http://techdocs.postgresql.org/techdocs/updatingcolumns.php) suggests usging
pg_dump to dump the entire database, then change the create table statement for
the table, then drop and restore the entire database.

What I'm wondering is whether it would be safe to just dump the affected table
with `pg_dump -t mytable mydb >mytable.sql`, and then in psql do:
drop table mytable;
drop sequence mysequence;
\i mytable.sql

...after editing mytable.sql of course.  My goal here is to only drop and
restore what I really need to.  Will this restore all affected triggers, etc.
that are affected by the drop table command?  Any other caveats?

Thanks,

Wes Sheldahl



pgsql-general by date:

Previous
From: Meenatchi Anbuchelvan
Date:
Subject: Re: DOes PostgreSQL support UInt64?
Next
From: Randall Perry
Date:
Subject: serial sequence problem with existing keys