From: | john snow <ofbizfanster(at)gmail(dot)com> |
---|---|
To: | Andrej <andrej(dot)groups(at)gmail(dot)com> |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: why do i get 2 as answer for select length('aa '::char(6)); |
Date: | 2018-01-17 02:40:50 |
Message-ID: | CAE67tvVt=oO=SeDKTNztov-bgVUrStp4MCwKhGUnoDmWBPMJMg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
select length('aa '::varchar(6)); //answers 6
select char_length('aa '::varchar(6)); //answers 6
select char_length('aa '::char(6)); //answers 2 even though the input
string has 6 characters as was the case with the varchar input string
select length('aa '::char(6)); //answers 2 even though the input
string has 6 characters as was the case with the varchar input string
are the results as expected? the last two strike me as unexpected
On Wed, Jan 17, 2018 at 10:14 AM, Andrej <andrej(dot)groups(at)gmail(dot)com> wrote:
> On 17 January 2018 at 14:59, john snow <ofbizfanster(at)gmail(dot)com> wrote:
> > as well as select length('aa'::char(6));
> >
> > i thought if the string to be stored is shorter than specified length ,
> it
> > will be padded with spaces?
>
> What made you think that?
>
>
>
>
> --
> Please don't top post, and don't use HTML e-Mail :} Make your quotes
> concise.
>
> http://www.georgedillon.com/web/html_email_is_evil.shtml
> http://www.catb.org/jargon/html/email-style.html
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2018-01-17 02:52:23 | Re: why do i get 2 as answer for select length('aa '::char(6)); |
Previous Message | Andrej | 2018-01-17 02:14:48 | Re: why do i get 2 as answer for select length('aa '::char(6)); |