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.kla...@aklaver.com


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to