Thread: trailing spaces

trailing spaces

From
Alejandro Fernandez
Date:
Hi,

I have a table with a field created as char(400). For some reason, when
I insert information into this, trailing spaces are automatically added
so that select char_length(fieldname) always gives 400.

How can I amend this table column so that I don't have to use "select
trim(trailing from fieldname);" to get a well formatted result?

Thanks

Ale
--
Alejandro Fernandez Bscp 5 Caledonian University
0790 541 8809 - ale@nin.cx

Re: trailing spaces

From
Justin Clift
Date:
Hi Alenjandro,

You'll probably want to use the type "varchar(400)" instead of
"char(400)".

It doesn't pad it's contents with spaces.

:-)

Regards and best wishes,

Justin Clift

Alejandro Fernandez wrote:
>
> Hi,
>
> I have a table with a field created as char(400). For some reason, when
> I insert information into this, trailing spaces are automatically added
> so that select char_length(fieldname) always gives 400.
>
> How can I amend this table column so that I don't have to use "select
> trim(trailing from fieldname);" to get a well formatted result?
>
> Thanks
>
> Ale
> --
> Alejandro Fernandez Bscp 5 Caledonian University
> 0790 541 8809 - ale@nin.cx
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: trailing spaces

From
Diana Cionoiu
Date:
>Hi,

Hy,

>I have a table with a field created as char(400). For some reason, when
>I insert information into this, trailing spaces are automatically added
>so that select char_length(fieldname) always gives 400.
>
>How can I amend this table column so that I don't have to use "select
>trim(trailing from fieldname);" to get a well formatted result?

Don't use char(400) use varchar(400).

>Thanks
>
>Ale

Diana