Search Postgresql Archives

Re: varchar or text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux