Re: Trailing spaces in char or varchar fields

From: "Anthony E (dot) Greene" <agreene(at)pobox(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Cc: Huy Do <huy(at)travel(dot)com(dot)au>
Subject: Re: Trailing spaces in char or varchar fields
Date: 2001-01-05 06:05:11
Message-ID: 20010105010511.S8784@cp5340
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, 04 Jan 2001 20:26:11 Tom Lane wrote:
>"Huy Do" <huy(at)travel(dot)com(dot)au> writes:
>> Is there a way to get postgres to keep the trailing spaces
>> in a field. I have an existing database which I am porting
>> to postgresql. This database allows fields to have trailing
>> spaces and many key fields have trailing spaces to distinguish
>> uniqueness (i know this is bad but it's legacy stuff).
>> When I dump my database and try to copy it into postgresql, it
>> complains about duplicate keys because postgres is trimming the
>> spaces.
>
>Postgres does not trim trailing spaces. I suspect that that behavior
>is coming from whatever tool you used to transfer the data.
>
> regards, tom lane

I have found in testing with pgsql that trailing spaces are ignored in
fixed-length char fields. In varchar fields, trailing spaces are
significant.

--
Anthony E. Greene <agreene(at)pobox(dot)com> <http://www.pobox.com/~agreene/>
PGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D
Chat: AOL/Yahoo: TonyG05 ICQ: 91183266
Linux. The choice of a GNU Generation. <http://www.linux.org/>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andrew McMillan 2001-01-05 09:48:33 Re: Question on setting up trigger.
Previous Message Eric Nielsen 2001-01-05 04:13:58 I think I know what I'm doing wrong, but....