alter table workaround

From: wsheldah(at)lexmark(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: alter table workaround
Date: 2001-10-31 15:16:32
Message-ID: 200110311516.KAA03579@interlock2.lexmark.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marat Khairullin 2001-10-31 15:17:28 Error in date_trunc function?
Previous Message samsom, debra 2001-10-31 15:09:28 Postgresql Copy