Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 196DF4758F1 for ; Fri, 24 Jan 2003 03:58:53 -0500 (EST) Received: from post.webmailer.de (natsmtp00.webmailer.de [192.67.198.74]) by postgresql.org (Postfix) with ESMTP id E1114477324 for ; Fri, 24 Jan 2003 03:27:10 -0500 (EST) Received: from ianb.local (pD951718D.dip.t-dialin.net [217.81.113.141]) by post.webmailer.de (8.9.3/8.8.7) with ESMTP id JAA24594; Fri, 24 Jan 2003 09:26:48 +0100 (MET) Content-Type: text/plain; charset="utf-8" From: Ian Barwick To: Andre Schubert , pgsql-admin@postgresql.org Subject: Re: Length of Varchar Date: Fri, 24 Jan 2003 09:26:45 +0100 X-Mailer: KMail [version 1.4] References: <20030124073709.7f2b1524.andre@km3.de> In-Reply-To: <20030124073709.7f2b1524.andre@km3.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200301240926.45780.barwick@gmx.net> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/265 X-Sequence-Number: 7107 On Friday 24 January 2003 07:37, Andre Schubert wrote: > i have a little question on changing the length of a varchar field. > Is there another way than dump and reload if i want to change the length > of a varchar field ? in 7.3: BEGIN; ALTER TABLE foo RENAME your_field TO your_field_old; ALTER TABLE foo ADD COLUMN your_field VARCHAR([new length]); UPDATE foo SET your_field=3Dyour_field_old; ALTER TABLE foo DROP COLUMN your_field_old; COMMIT; In 7.3, if the new column is shorter you may need to truncate the values being inserted. In versions < 7.3 you will not be able to drop the old column; there you may want to recreate the table, there's a techdoc article here: http://techdocs.postgresql.org/techdocs/updatingcolumns.php > I have search the idocs and found some docs about the system-table > pg_attribute, where the length of a varchar-field is stored in atttypmod. > Is it possible to change the value of atttypmod and is it safe to change > this value? Possible but probably not safe. No doubt someone will be along shortly with a more accurate opinion ;-). Ian Barwick barwick@gmx.net