Search Postgresql Archives

Re: How to define the limit length for numeric type?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx


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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux