CREATETABLE test1 (a character(4));INSERTINTO test1 VALUES('ok');SELECT a, char_length(a)FROM test1;-- (1)
a | char_length
------+-------------
ok |2CREATETABLE test2 (b varchar(5));INSERTINTO test2 VALUES('ok');INSERTINTO test2 VALUES('good ');INSERTINTO test2 VALUES('too long');
ERROR: value too long fortypecharactervarying(5)INSERTINTO test2 VALUES('too long'::varchar(5));-- explicit truncationSELECT b, char_length(b)FROM test2;
b | char_length
-------+-------------
ok |2
good |5
too l |5