From: Peter Koczan <pjkoczan@gmail.com>
To: Kostis Mentzelos <mentzelos@gmx.net>
Cc: pgsql-admin@postgresql.org
Subject: Re: convert char to varchar
Date: Thu, 18 Oct 2007 10:37:10 -0500
Message-ID: <4544e0330710180837ya0a7082v2db9fbbe0119bb9f@mail.gmail.com> (raw)
In-Reply-To: <4544e0330710180835h70aae76cm149bb671fed086ae@mail.gmail.com>
References: <4716EDD7.7010104@gmx.net>
<4544e0330710180835h70aae76cm149bb671fed086ae@mail.gmail.com>
On 10/18/07, Peter Koczan <pjkoczan@gmail.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: pjkoczan@gmail.com, mentzelos@gmx.net
Subject: Re: convert char to varchar
In-Reply-To: <4544e0330710180837ya0a7082v2db9fbbe0119bb9f@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox