Обсуждение: postgres types
Hello all,
Can I have UNSIGNED integer in PostgreSQL ?
E.g. how should I describe type of field to have
full range of 32 bits? If I describe filed as INT4,
I'll get SIGNED integer, insn't it?
Thanks!
-- Vladimir Zolotych gsmith@eurocom.od.ua
OID should be an unsigned int. Let us know if there are any problems. [Charset koi8-r unsupported, filtering to ASCII...] > > Hello all, > > Can I have UNSIGNED integer in PostgreSQL ? > E.g. how should I describe type of field to have > full range of 32 bits? If I describe filed as INT4, > I'll get SIGNED integer, insn't it? > > Thanks! > > > -- > Vladimir Zolotych gsmith@eurocom.od.ua > > -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Bruce Momjian writes: > OID should be an unsigned int. Let us know if there are any problems. The oid type is for storing oids, not arbitrary numbers. It might happen to do that too, but it isn't designed for it. To get unsigned numbers use a check contraint. Then everyone knows what's going on; don't rely on the particulars of the implementation. Anyway ... peter=# create table foo (a oid, b text); CREATE peter=# insert into foo values (-1, 'zzz'); INSERT 18730 1 peter=# select * from foo; a | b ----+----- -1 | zzz (1 row) > > Can I have UNSIGNED integer in PostgreSQL ? > > E.g. how should I describe type of field to have > > full range of 32 bits? If I describe filed as INT4, int8/bigint > > I'll get SIGNED integer, insn't it? Per SQL, all numbers are signed. -- Peter Eisentraut Sernanders väg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden