Re: varchar or text

From: Pascal Cohen <pcohen(at)wimba(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: varchar or text
Date: 2008-04-29 07:36:31
Message-ID: 4816CFFF.3020908@wimba.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Guillaume Lelarge wrote:
> Pascal Cohen a écrit :
>> I had a look in previous posts in the forum but could not find the
>> answer I was looking for.
>> My question is should I switch from varchar to text.
>> We have "discovered" although it seems to be SQL that adding
>> something like 'text ' to a varchar(50) just silently
>> cut the text while a text with check(length) - or also a varchar with
>> a check raised an error.
>
> Nope. If you try to add some text with more than 50 characters on a
> varchar(50) column, you will get an error. For example :
>
> test=# create table t (c varchar(5));
> CREATE TABLE
> test=# insert into t (c) values ('12345');
> INSERT 0 1
> test=# insert into t (c) values ('123456');
> ERREUR: valeur trop longue pour le type character varying(5)
>
> (the english error message is:
> ERROR: value too long for type character varying(5)
> ).
>
> Which release do you use ?
I am with 8.3.1 release but I mentioned that this appears with spaces at
then end not with standard chars. Of course your examples are working
fine but insert something like 'abc ' (with several spaces and it
will work but just ignore the spaces above the 5th char.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message wstrzalka 2008-04-29 08:20:13 Re: PITR problem
Previous Message paul rivers 2008-04-29 06:59:14 Re: close database, nomount state