X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CDF36D1B9AF for ; Wed, 10 Mar 2004 17:58:55 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 85851-06 for ; Wed, 10 Mar 2004 13:58:52 -0400 (AST) Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) by svr1.postgresql.org (Postfix) with ESMTP id 90EA1D1B80C for ; Wed, 10 Mar 2004 13:58:51 -0400 (AST) Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i2AHvQSn023215; Wed, 10 Mar 2004 10:57:26 -0700 (MST) Date: Wed, 10 Mar 2004 10:55:47 -0700 (MST) From: "scott.marlowe" To: David Cc: Subject: Re: Alter table In-Reply-To: <006801c406c0$da8fef50$42660c81@ad.kent.ac.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IHS-MailScanner: Found to be clean X-IHS-MailScanner-SpamCheck: X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/114 X-Sequence-Number: 17213 On Wed, 10 Mar 2004, David wrote: > Ok another very newbie question. How can i change the data type a column can > accept? at the moment it will only take character(7) i want to change it to > varchar(30), but i cant figure how, ideas? While there are ways to tinker with the system catalogs to change between different text types / lengths, none of these are "officially supported" and may well screw up your database if you do something wrong. I believe the archives likely have this question over and over in them. The proper way to do this is to make a new column, put the old column in it, and then drop the old column: create table test (a char(7)); insert a few thousand lines to test...; begin; alter table test add column b varchar(30); update test set b=a; alter table test drop column a; commit; (or rollback; should things go horribly wrong...) vacuum full test;