Re: extra spaces

Поиск
Список
Период
Сортировка
От Mark Cowlishaw
Тема Re: extra spaces
Дата
Msg-id 015301c06a14$4e939980$5250460a@meta2k
обсуждение исходный текст
Ответ на Re: extra spaces  (Alvaro Herrera <alvherre@protecne.cl>)
Ответы Re: Re: extra spaces  ("Denis A. Doroshenko" <d.doroshenko@omnitel.net>)
Список pgsql-general
> >     Soma> All values called from the database are still padded with
> >     Soma> extra spaces from the column size in the database. Is this
> >     Soma> normal - I don't remember this happening when I was using
> >     Soma> MySQL. I thought usually the database stripped the extra
> >     Soma> spaces when it retrieved the values.

>
> According to "Postgres: Introduction and Concepts", varchar is slower
> than char. So if you (like me) want to use char and get rid of the
> padding spaces, you may use a regex replacement, as in
>
>         while (@row=$result->fetchrow)
>             {
>                 $row[0] =~ s/[\s]+$//;
>             }
>
> in perl, or
>
> $array["name"]=preg_replace("'[\s]+$'", "", $array["name"], -1);
>
> in PHP.
>

I'm new to the list so I'm not sure if this has already been said, but Perl
DBI has an option to trim trailing spaces in the connect statement. eg:


my $dbh = DBI->connect("dbi:Pg:dbname=mydb",
    'myuser','mypass',
    {RaiseError => 1, AutoCommit => 0, ChopBlanks => 1})
    or die $DBI::errstr;

Cheers


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

Предыдущее
От: "Edmar Wiggers"
Дата:
Сообщение: RE: Trigger with superuser privileges
Следующее
От: "Oliver Elphick"
Дата:
Сообщение: Re: Character encoding problem using Tcl