Re: why do i get 2 as answer for select length('aa '::char(6));

Поиск
Список
Период
Сортировка
От john snow
Тема Re: why do i get 2 as answer for select length('aa '::char(6));
Дата
Msg-id CAE67tvVt=oO=SeDKTNztov-bgVUrStp4MCwKhGUnoDmWBPMJMg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: why do i get 2 as answer for select length('aa '::char(6));  (Andrej <andrej.groups@gmail.com>)
Список 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.groups@gmail.com> wrote:
On 17 January 2018 at 14:59, john snow <ofbizfanster@gmail.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

В списке pgsql-novice по дате отправления:

Предыдущее
От: Andrej
Дата:
Сообщение: Re: why do i get 2 as answer for select length('aa '::char(6));
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: why do i get 2 as answer for select length('aa '::char(6));