Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id C79BE9FBCC2 for ; Thu, 18 Oct 2007 12:37:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 91428-02 for ; Thu, 18 Oct 2007 12:37:12 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.228]) by postgresql.org (Postfix) with ESMTP id 060299FBBA1 for ; Thu, 18 Oct 2007 12:37:12 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id 68so178314wri for ; Thu, 18 Oct 2007 08:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=fEia99S0E62XKHX6IN7KQ/VspeqVJmgRU/HS0hkFaJw=; b=Y/HzVC2L0D3So9nGbWkoQ0TOPsibhuUrj7gw0Cxl9xv0FjU3wgo8BzhG++W26RA4A+6Ipai4zl9vW3uxtIOlrTd09t0I6unQnIcoD1rjmKcdA8QiWjsXuRt8ne1Gb/aNnw3dlkX22SZs9mbBzz1Krk7U1eIT/PzwuHo8KyO2XxU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ciiXv6hGDZW1rVBtxV6zuICwebz+pBEZqR/hBkb8ctXvWfHm49TWolxbln6Cb1J7R+SFwZsjvhVGMGELSpwS92J3UThZQ23Gs0z1e4TuvfGbWPMInvmcRIXZZ3eLdkmUJije2vgzT7Lol5/N4YgpQ0sqPjgM0Uc1/8yO4lJGXQ0= Received: by 10.114.14.1 with SMTP id 1mr591272wan.1192721830703; Thu, 18 Oct 2007 08:37:10 -0700 (PDT) Received: by 10.114.197.19 with HTTP; Thu, 18 Oct 2007 08:37:10 -0700 (PDT) Message-ID: <4544e0330710180837ya0a7082v2db9fbbe0119bb9f@mail.gmail.com> Date: Thu, 18 Oct 2007 10:37:10 -0500 From: "Peter Koczan" To: "Kostis Mentzelos" Subject: Re: convert char to varchar Cc: pgsql-admin@postgresql.org In-Reply-To: <4544e0330710180835h70aae76cm149bb671fed086ae@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4716EDD7.7010104@gmx.net> <4544e0330710180835h70aae76cm149bb671fed086ae@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/172 X-Sequence-Number: 27086 On 10/18/07, Peter Koczan wrote: > > Is there any other way to clear trailing spaces when I restore the table? > > If you're running 8.x, you can do this in place: > > ALTER TABLE c1 ALTER COLUMN name varchar(20) USING rtrim(name), ALTER > COLUMN date varchar(20) USING rtrim(date); > > This could take a long time if the table is large or has a lot of indexes on it. Oops. The command should be: ALTER TABLE c1 ALTER COLUMN name TYPE varchar(20) USING rtrim(name), ALTER COLUMN date TYPE varchar(20) USING rtrim(date); I forgot the TYPE keyword...it's important. Peter