From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | vod vos <vodvos(at)zoho(dot)com>, Charles Clavadetscher <clavadetscher(at)swisspug(dot)org> |
Cc: | 'Pavel Stehule' <pavel(dot)stehule(at)gmail(dot)com>, 'pgsql-general' <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to define the limit length for numeric type? |
Date: | 2017-03-12 15:11:44 |
Message-ID: | ab0855fa-538c-bf07-f2c2-3c1a8c7955dd@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-03-12 16:39:01 | Re: How to define the limit length for numeric type? |
Previous Message | Francisco Olarte | 2017-03-12 10:13:07 | Re: Index using in jsonb query |