Re: Howto change column length

From: wsheldah(at)lexmark(dot)com
To: "DC" <danc(at)bspmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Howto change column length
Date: 2001-11-06 18:59:08
Message-ID: 200111061859.NAA20551@interlock2.lexmark.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The short answer is to copy the info to a temp table, drop the table, recreate
the table with the correct attributes, and copy the data back from the temp
table. HOWEVER, if you have foreign keys or triggers that reference the table,
they will become invalid through the above procedure. So you need to make a
backup of the database with pg_dump, edit the CREATE TABLE statement in the
backup file so the column has the correct length, drop the database, and
recreate the database using the backup file. There's an article at
http://techdocs.postgresql.org that describes the process in greater detail.

I understand that 7.3 might have support for ALTER TABLE DROP COLUMN.

"DC" <danc%bspmail(dot)com(at)interlock(dot)lexmark(dot)com> on 11/05/2001 12:21:12 PM

Please respond to "DC" <danc%bspmail(dot)com(at)interlock(dot)lexmark(dot)com>

To: pgsql-general%postgresql(dot)org(at)interlock(dot)lexmark(dot)com
cc: (bcc: Wesley Sheldahl/Lex/Lexmark)
Subject: [GENERAL] Howto change column length

I have a column (ie name varchar(10))
and I want to alter it to varchar(20)
I've looked throught the docementation and web for examples (no luck),
can anyone help?

thx

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-11-06 19:27:51 Re: Null value representation in the array data structure
Previous Message Jason Earl 2001-11-06 18:55:30 Re: data integrity