From: | Dawid Kuroczko <qnex42(at)gmail(dot)com> |
---|---|
To: | Ying Lu <ying_lu(at)cs(dot)concordia(dot)ca> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: About unsigned smallint? |
Date: | 2005-07-06 21:30:52 |
Message-ID: | 758d5e7f05070614307ab89091@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 7/6/05, Ying Lu <ying_lu(at)cs(dot)concordia(dot)ca> wrote:
> Greetings,
>
> Can I know whether postgreSQL 8.0 supports unsigned smallint please? I
> looked at the doc, it seems that OID is unsigned interger. While I was
> trying to create a simple table as:
> create table test (id unsigned smallint);
> or
> create table test (id smallint unsigned);
>
> It seems that postgreSQL did not support unsigned integer?
Well, PostgreSQL doesn't have "unsigned" types, unless you create
your own. If you want to have unsigned type, you can add a check
constraint or, even better, create a domain:
CREATE DOMAIN usmallint AS smallint CHECK (VALUE >= 0);
...while this gives you unsinged smallint type, its probably not
what you wanted. If you wanted a type which takes two bytes of
storage and stores values from 0 to 65535 then, well... its not it.
If you ask here, you'll probably get a good explanation why there
aren't unsinged types. My guess is that unsigned types add
complexity which is not really judged by their usefullness, but
thats only a guess.
If you need unsigned-like type for data consistency reasons, just
CREATE DOMAIN as shown above.
Regards,
Dawid
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2005-07-06 21:44:44 | Re: 7.3.2 closing connections, sometimes |
Previous Message | imoir | 2005-07-06 21:20:11 | postmaster link to postgres executable |