Re: char column with a single space as the default not working - Mailing list pgsql-admin

From Tom Lane
Subject Re: char column with a single space as the default not working
Date
Msg-id 526193.1701383665@sss.pgh.pa.us
Whole thread Raw
In response to Re: char column with a single space as the default not working  (Ron Johnson <ronljohnsonjr@gmail.com>)
Responses Re: char column with a single space as the default not working
List pgsql-admin
Ron Johnson <ronljohnsonjr@gmail.com> writes:
> On Thu, Nov 30, 2023 at 2:56 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Yeah, the space is stored.  What is probably surprising the OP
>> is that applying the || operator involves a coercion from "char"
>> to "text", which strips the defined-to-be-insignificant trailing
>> space(s) of the "char" value.

> How do you get a trailing space when trailing spaces are significant?

Use varchar or text.  If you want trailing spaces to be significant,
char is simply the wrong data type.

            regards, tom lane



pgsql-admin by date:

Previous
From: Ron Johnson
Date:
Subject: Re: char column with a single space as the default not working
Next
From: M Sarwar
Date:
Subject: Re: char column with a single space as the default not working