Re: [GENERAL] How to define the limit length for numeric type?
От | David G. Johnston |
---|---|
Тема | Re: [GENERAL] How to define the limit length for numeric type? |
Дата | |
Msg-id | CAKFQuwZO17LkR2t3WHhVPPqr8rznpjiubGCZZRS0SErnXesiRA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [GENERAL] How to define the limit length for numeric type? (vod vos <vodvos@zoho.com>) |
Ответы |
Re: [GENERAL] How to define the limit length for numeric type?
|
Список | pgsql-general |
Please don't top-post on these lists.
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 of the insert value, you can just type format like 59.22, only four digits length.
length(trunc(goose, 0)::text) + scale(goose)
I suspect you might encounter some issues, namely around 123.456789::numeric(6,1) casting behavior and maybe 00059.12000::numeric(6,1) treatment of unimportant zeros. I haven't tested any of that. The above will get you a single length value for a given input.
David J.
В списке pgsql-general по дате отправления: