On 03/12/2017 12:33 AM, vod vos wrote:
> So there is no other simpler method for checking that? like varchar(4), only 4 char can be input?
That is not how that works:
test=# create table varchar_test(fld_1 varchar(4));
CREATE TABLE
test=# \d varchar_test
Table "public.varchar_test"
Column | Type | Modifiers
--------+----------------------+-----------
fld_1 | character varying(4) |
INSERT INTO varchar_test VALUES ('test'), ('tes'), ('te'), ('t');
INSERT 0 4
test=# select * from varchar_test ;
fld_1
-------
test
tes
te
t
(4 rows)
test=# INSERT INTO varchar_test VALUES ('tests');
ERROR: value too long for type character varying(4)
It just sets the upper limit of what can be entered.
>
> would using regexp cost more CPU or memory resources?
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com