From: | Mike Christensen <mike(at)kitchenpc(dot)com> |
---|---|
To: | Christophe Pettus <xof(at)thebuild(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org mailing list" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Best data type to use for sales tax percent |
Date: | 2009-10-09 19:14:34 |
Message-ID: | 7aa638e00910091214h6039fabdpb69378d7c3334fbf@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thanks for the info! I was thinking this would be a short thread but
I definitely appreciate all the information.
I will definitely create a domain for this (and probably for some
other types in my app since I now know about this). However, is the
CHECK really necessary? A numeric(5,5) already has a maximum value of
10^0, so it would already create an overflow error if you set it
higher. Is there an advantage of using the CHECK constraint? Perhaps
this is faster or doesn't lock the row on update or something?
Just to point out, NUMERIC and DECIMAL are one and the same yes?
Mike
On Fri, Oct 9, 2009 at 11:46 AM, Christophe Pettus <xof(at)thebuild(dot)com> wrote:
>
> On Oct 9, 2009, at 11:36 AM, Mike Christensen wrote:
>
>> Can you explain what you mean by "put it in a domain" - I'd love extra
>> style points, but this sounds like a feature I haven't learned about
>> yet.
>
>
> http://www.postgresql.org/docs/8.4/interactive/sql-createdomain.html
>
> Domains are basically type aliases with an optional CHECK clause, so you
> could do something like:
>
> CREATE DOMAN sales_tax_rate AS DECIMAL(5,5) CHECK (VALUE >= 0);
>
> Then, you can use the type "sales_tax_rate" in your tables, etc. just as a
> normal first-class type. (The only limitation, right now, is that you can't
> create an array of them.)
>
> In response to the other email, DECIMAL is definitely the better solution
> for what you are looking for.
>
> --
> -- Christophe Pettus
> xof(at)thebuild(dot)com
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2009-10-09 19:18:17 | Re: Best data type to use for sales tax percent |
Previous Message | Oleg Bartunov | 2009-10-09 19:04:11 | Re: [GENERAL] contrib/plantuner - enable PostgreSQL planner hints |