X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D78D49FB201 for ; Wed, 12 Jul 2006 09:18:32 -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 19918-09 for ; Wed, 12 Jul 2006 09:18:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from grzm.com (grzm.com [200.46.204.98]) by postgresql.org (Postfix) with ESMTP id 869B69FB1F5 for ; Wed, 12 Jul 2006 09:18:32 -0300 (ADT) Received: from localhost (unknown [200.46.208.251]) by grzm.com (Postfix) with ESMTP id BA47A127C516 for ; Wed, 12 Jul 2006 13:18:26 +0100 (BST) Received: from grzm.com ([200.46.204.98]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 18133-10; Wed, 12 Jul 2006 09:18:28 -0300 (ADT) Received: from [192.168.0.106] (12-226-29-139.client.mchsi.com [12.226.29.139]) by grzm.com (Postfix) with ESMTP id 5DA5D127C4EC; Wed, 12 Jul 2006 13:18:23 +0100 (BST) In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <793EC6C5-19C6-490F-812A-AD9FD0070107@seespotcode.net> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: Unexpected SQL error for UPDATE Date: Wed, 12 Jul 2006 08:18:30 -0400 To: aurora X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.393 tagged_above=0 required=5 tests=BAYES_00, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL X-Spam-Level: * X-Archive-Number: 200607/189 X-Sequence-Number: 25763 On Jul 11, 2006, at 20:47 , aurora wrote: > There is no simple SQL to alter the type. So I use a series of SQLs to > create a new column, copy the data over and then replace the old > column with the > new. What version of PostgreSQL are you running? In 8.0 and later you can use ALTER TABLE ALTER TYPE. http://www.postgresql.org/docs/current/interactive/sql-altertable.html Something like this (untested) should work in your case: ALTER TABLE users ALTER email_addresses TYPE text; > ALTER TABLE users ADD email_address_text text UNIQUE; > UPDATE users set email_address_text=email_address; > ALTER TABLE users DROP email_address; > ALTER TABLE users RENAME email_address_text TO email_address; > ALTER TABLE users ALTER email_address SET not null; This looks like it should work, so perhaps someone else has an idea as to why you're receiving the error. Is the error reproducible? If you can put together a reproducible test case, it may help someone else be able to figure out what's going on. Michael Glaesemann grzm seespotcode net