Skip site navigation (1) Skip section navigation (2)

Re: numeric data type

From: "Phillip Smith" <phillips(at)weatherbeeta(dot)com(dot)au>
To: "'Corey'" <corey(at)bitworthy(dot)net>,<pgsql-novice(at)postgresql(dot)org>
Subject: Re: numeric data type
Date: 2006-11-16 20:37:55
Message-ID: 005d01c709bf$185c63a0$c70117ac@ITLaptop (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Numeric and Integer type are exactly that - numbers.

If you want to _store_ it in the data with the leading 0, then you need to
change the type to a varchar, then put a check constraint on the field to
ensure that each of the 2 characters are numeric.

Alternatively, you can leave it as a numeric / integer and add the leading 0
as part of the queries that access it. Let me know if you want an example
how to do it.


-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org] On Behalf Of Corey
Sent: Friday, 17 November 2006 2:14 AM
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] numeric data type

I've got the following:

cc_exp_month numeric(2,0)

So that I could input '06', for instance -- however the 0 doesn't make it's
way into the column... I get '6' instead.

I want to constrain this in the db, which is why I don't just use:

cc_exp_month integer

My question: what do I need to do to have the constraint ( two digits )
while still keeping the extra 0?


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?


In response to

pgsql-novice by date

Next:From: Tom AllisonDate: 2006-11-18 14:36:58
Subject: postgres authentication question
Previous:From: Richard Broersma JrDate: 2006-11-16 20:25:41
Subject: Re: numeric data type

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group