Re: Is there unsigned datatype in PostgreSQL?

Lists: pgsql-novice
From: Carfield Yim <mailing(at)desktop(dot)carfield(dot)com(dot)hk>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Is there unsigned datatype in PostgreSQL?
Date: 2001-07-18 17:47:40
Message-ID: Pine.LNX.4.33L2.0107190146570.21031-100000@desktop.carfield.com.hk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Is there unsigned datatype like unsigned int?

--

Carfield Yim, visit my homepage at http://www.carfield.com.hk


From: "Robby Slaughter" <webmaster(at)robbyslaughter(dot)com>
To: "Carfield Yim" <mailing(at)desktop(dot)carfield(dot)com(dot)hk>, <pgsql-novice(at)postgresql(dot)org>
Subject: RE: Is there unsigned datatype in PostgreSQL?
Date: 2001-07-18 19:58:52
Message-ID: EPEHLKLEHAHLONFOKNHNMEAJDDAA.webmaster@robbyslaughter.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Carfield,

Nope, there's not a native data type which is unsigned.

You could use the OID datatype, but that would be inelegant
and not very portable.

You could also use the NUMERIC data type and just use the
minimal number of points of precision, but that would
be inelegant and slower.

You can use a character field CHAR(x) with the number
of digits you want.

You can always go up to he next biggest INTEGER type.
(Numbers larger than 32,768? Go to INT4. Larger than 2 billion?
Go to INT 8. Larger than 4 x 10 ^ 18? Uh...(what are you
counting again?)

You could also just change your supporting to code to automatically
subtract the smallest negative number so that you effectively
get only positives.

HTH

-Robby

-----Original Message-----
From: pgsql-novice-owner(at)postgresql(dot)org
[mailto:pgsql-novice-owner(at)postgresql(dot)org]On Behalf Of Carfield Yim
Sent: Wednesday, July 18, 2001 12:48 PM
To: pgsql-novice(at)postgresql(dot)org
Subject: [NOVICE] Is there unsigned datatype in PostgreSQL?

Is there unsigned datatype like unsigned int?

--

Carfield Yim, visit my homepage at http://www.carfield.com.hk

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly


From: Henry House <hajhouse(at)houseag(dot)com>
To: Carfield Yim <mailing(at)desktop(dot)carfield(dot)com(dot)hk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Is there unsigned datatype in PostgreSQL?
Date: 2001-07-19 01:38:22
Message-ID: 20010718183822.A21783@houseag.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Thu, Jul 19, 2001 at 01:47:40AM +0800, Carfield Yim wrote:
> Is there unsigned datatype like unsigned int?

Oddly enough, no. If you are only interested in positive numbers, you could
use the function ABS() (absolute value) to convert numeric fields to positive
integers when you store them.

Also it is possible to add new data types to PostgreSQL using the C
interface, though the result will be non-portable.

--
Henry House
OpenPGP key available from http://romana.hajhouse.org/hajhouse.asc