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

2017-03-12 Thread rob stone
Hello, On Sat, 2017-03-11 at 22:14 -0800, vod vos wrote: > Hi everyone, > > How to define the exact limit length of numeric type? For example,  > > CREATE TABLE test  (id serial, goose numeric(4,1)); > > 300.2 and 30.2 can be inserted into COLUMN goose, but I want 30.2 or > 3.2 can not be

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

2017-03-12 Thread Tom Lane
"David G. Johnston" writes: > On Sun, Mar 12, 2017 at 12:00 AM, vod vos wrote: >> The INSERT action still can be done. What I want is just how to limit the >> length of the insert value, you can just type format like 59.22, only four >> digits length.

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

2017-03-12 Thread Adrian Klaver
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"

Re: [GENERAL] Index using in jsonb query

2017-03-12 Thread Francisco Olarte
On Sun, Mar 12, 2017 at 9:50 AM, SuperCiccio wrote: > But even if I create a specific index > CREATE INDEX on datatable (((jsonfield#>>'{path1,path2}')::numeric)); > it isn't used in such a query; it is used in this query: > select field1,field2 from datatable where >

Re: [GENERAL] Index using in jsonb query

2017-03-12 Thread SuperCiccio
This is a kind of document, there are many other kinds, with different json structure. So, a general index would be better. But even if I create a specific index CREATE INDEX on datatable (((jsonfield#>>'{path1,path2}')::numeric)); it isn't used in such a query; it is used in this query:

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

2017-03-12 Thread vod vos
So there is no other simpler method for checking that? like varchar(4), only 4 char can be input? would using regexp cost more CPU or memory resources? On 星期六, 11 三月 2017 23:21:16 -0800 Charles Clavadetscher wrote > Hello > > > -Original