X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id A957E11F6AFB for ; Thu, 27 Apr 2006 13:09:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 62137-03 for ; Thu, 27 Apr 2006 13:09:22 -0300 (ADT) X-Greylist: delayed 00:27:33.394267 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 9D9DB11F6926 for ; Thu, 27 Apr 2006 13:09:22 -0300 (ADT) Received: from bedrock.cromagnon.com (170-215-19-8.dsl1.mnd.mn.frontiernet.net [170.215.19.8]) by svr4.postgresql.org (Postfix) with ESMTP id 2C32F5B0E9F for ; Thu, 27 Apr 2006 15:41:45 +0000 (GMT) Received: from [192.168.200.100] ([192.168.200.100]) (authenticated bits=0) by bedrock.cromagnon.com (8.12.8/8.12.8) with ESMTP id k3RFfhdd001107 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 27 Apr 2006 10:41:43 -0500 From: Craig Servin Organization: Cro-Magnon To: pgsql-admin@postgresql.org Subject: Alter table alter column using question Date: Thu, 27 Apr 2006 10:40:29 -0500 User-Agent: KMail/1.9.1 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200604271040.29326.cservin@cromagnon.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/309 X-Sequence-Number: 21478 I have a table called type: type ------- type_id integer tvalue smallint ... .. .. tvalue was a second key on this table which now turns out to be unnecessary. Before I can remove it I need to change the columns which reference it. I wanted to do this with alter table alter column using But the using clause I am using does not work. I think I may just be misunderstanding how this is done, but I could only find a few examples. Here is an example of what I have tried: alter table service.service alter column environment_tvalue type integer using select type.type.type_id where tvalue = environment_tvalue and typeset_id = 1; Does the expression in the using clause have to be a function? Any advice would be appreciated. Thanks, Craig