Re: character varying == text?

From: Alex Turner <armtuk(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: CSN <cool_screen_name90001(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: character varying == text?
Date: 2005-09-19 17:54:48
Message-ID: 33c6269f05091910541b93241b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I thought a char field was supposed to return a padded string, and varchar
was supposed to return a non-padded string?

I just checked though:

create table test (
stuff char(10)
);

insert into test values ('foo');

select stuff || 'lemon' from test;

This returns 'foolemon', not 'foo lemon' as I would have expected.

Alex Turner
NetEconomist

On 9/15/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> CSN <cool_screen_name90001(at)yahoo(dot)com> writes:
> > Just something I was curious about - is there any
> > difference at all between "character varying" (in the
> > SQL spec) without a length specified and "text" (not
> > in the SQL spec)?
>
> The SQL standard doesn't allow "character varying" without a length spec.
>
> But yeah, in Postgres they're essentially the same thing.
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alex Turner 2005-09-19 17:56:19 Re: Arrrr... date formatting.
Previous Message hubert depesz lubaczewski 2005-09-19 17:51:35 Re: Help trying to write my first plpgsql function...