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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: why do i get 2 as answer for select length('aa '::char(6));
Дата
Msg-id 13472.1516158556@sss.pgh.pa.us
обсуждение исходный текст
Ответ на why do i get 2 as answer for select length('aa '::char(6));  (john snow <ofbizfanster@gmail.com>)
Ответы Re: why do i get 2 as answer for select length('aa '::char(6));
Список pgsql-novice
john snow <ofbizfanster@gmail.com> writes:
> 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?

It *is* padded, as you can verify with other functions such as
octet_length or pg_column_size.  But length() disregards trailing
spaces in char-type values, on the theory that they're semantically
insignificant.

            regards, tom lane


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

Предыдущее
От: john snow
Дата:
Сообщение: 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));