varchar with length
postgres=# postgres=# CREATE TABLE test2 (b varchar(5)); CREATE TABLE postgres=# postgres=# INSERT INTO test2 VALUES ('ok'); INSERT 0 1 postgres=# INSERT INTO test2 VALUES ('good '); INSERT 0 1 postgres=# INSERT INTO test2 VALUES ('too long'); ERROR: value too long for type character varying(5) postgres=# postgres=# INSERT INTO test2 VALUES ('too long'::varchar(5)); -- explicit truncation INSERT 0 1 postgres=# SELECT b, char_length(b) FROM test2; b | char_length -------+------------- ok | 2 good | 5 too l | 5 (3 rows) postgres=# postgres=# drop table test2; DROP TABLE postgres=# postgres=#