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

2017-03-13 Thread David G. Johnston
On Mon, Mar 13, 2017 at 7:51 AM, vod vos wrote: > Sorry for taking varchar(4) as an example, What I want urgently is how to > make a constraint of fixed length of a numeric data, > that you can only input data like 23.45, and if you input the data like > 2.45, 23.4356, 233.45,

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

2017-03-13 Thread Charles Clavadetscher
Hello > -Original Message- > From: pgsql-general-ow...@postgresql.org > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of vod vos > Sent: Montag, 13. März 2017 15:52 > To: rob stone > Cc: pgsql-general > Subject: Re: [GENERAL]

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

2017-03-13 Thread vod vos
Sorry for taking varchar(4) as an example, What I want urgently is how to make a constraint of fixed length of a numeric data, that you can only input data like 23.45, and if you input the data like 2.45, 23.4356, 233.45, you will get a warning message from postgresql. I think expr will do

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] 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

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

2017-03-11 Thread David G. Johnston
Please don't top-post on these lists. On Sun, Mar 12, 2017 at 12:00 AM, vod vos wrote: > Maybe CHECK (goose >= 100 AND goose <= -100) works better, But if : > > INSERT INTO test VALUES (1, 59.2); > INSERT INTO test VALUES (1, 59.24); > INSERT INTO test VALUES (1, 59.26); >

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

2017-03-11 Thread Charles Clavadetscher
Hello > -Original Message- > From: pgsql-general-ow...@postgresql.org > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of vod vos > Sent: Sonntag, 12. März 2017 08:01 > To: Pavel Stehule > Cc: pgsql-general > Subject: Re:

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

2017-03-11 Thread vod vos
Maybe CHECK (goose >= 100 AND goose <= -100) works better, But if : INSERT INTO test VALUES (1, 59.2); INSERT INTO test VALUES (1, 59.24); INSERT INTO test VALUES (1, 59.26); INSERT INTO test VALUES (1, 59.2678); The INSERT action still can be done. What I want is just how to limit the length

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

2017-03-11 Thread David G. Johnston
On Sat, Mar 11, 2017 at 11:14 PM, 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)); > > ​[...] > 30.2 can be inserted into COLUMN goose, but I want 30.2 > ​[...] > can

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

2017-03-11 Thread Pavel Stehule
2017-03-12 7:25 GMT+01:00 Pavel Stehule : > > > 2017-03-12 7:14 GMT+01:00 vod vos : > >> >> 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

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

2017-03-11 Thread Pavel Stehule
2017-03-12 7:14 GMT+01:00 vod vos : > > 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 inserted,

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

2017-03-11 Thread Christoph Moench-Tegeder
## vod vos (vod...@zoho.com): > 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 inserted, how to do this? testing=# CREATE TABLE

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

2017-03-11 Thread Charles Clavadetscher
Hello > -Original Message- > From: pgsql-general-ow...@postgresql.org > [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of vod vos > Sent: Sonntag, 12. März 2017 07:15 > To: pgsql-general > Subject: [GENERAL] How to define the limit length for numeric

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

2017-03-11 Thread vod vos
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 inserted, how to do this? Thank you. -- Sent via pgsql-general mailing