Thread: why unsigned numbers don't exist ?
Hello, I am newbie with PostgreSQL and I ask myself if it's possible to have unsigned numbers. Of course, I checked the doc and mailing list but anyone said explicitly that is not possible and why there are not used. Please give me the technical reason if you know it. Tkanks, jul -- (work) Julien.Jehannet at SecurityKeepers.com (home) jhanet at caramail.com 'Early to rise and early to bed makes a man healthy but socially dead.' Animaniacs
Julien Jehannet <Julien.Jehannet@SecurityKeepers.com> wrote: > I am newbie with PostgreSQL and I ask myself if it's possible to have > unsigned numbers. As far as I know, there is no separate data type for unsigned numbers, but you can of course use CHECK constraints like age INTEGER CHECK (age >= 0), (see http://www.ca.postgresql.org/docs/aw_pgsql_book/node132.html). HTH, Ray -- Those who are willing to trade their liberty for security deserve neither. Benjamin Franklin
Fri, Jun 08, 2001 at 12:22, J.H.M. Dassen (Ray) wrote: > > Julien Jehannet <Julien.Jehannet@SecurityKeepers.com> wrote: > > I am newbie with PostgreSQL and I ask myself if it's possible to have > > unsigned numbers. > > As far as I know, there is no separate data type for unsigned numbers, but > you can of course use CHECK constraints like > > age INTEGER CHECK (age >= 0), > > (see http://www.ca.postgresql.org/docs/aw_pgsql_book/node132.html). Thanks but in fact, I don't want to test if a number is just positive, I would use the whole range of an int4 from 0 to (2147483647*2). For example, if I use a serial, the range is between 0 and (2147483647*2). (humm, it may be possible to start the sequence with -2147483647 but I don't test). Well, this is my true problem: I have converted my date format into the unix time because I have a lot of basic tests to do with the data. Normally, a unsigned int4 is only needed but, like it's signed, I must to use a int8 or a NUMERIC(10). Do you think my method is stupid or have some good best practices to propose me. Thanks, jul P.S. Sorry for my poor english... -- (work) Julien.Jehannet at SecurityKeepers.com (home) jhanet at caramail.com 'Early to rise and early to bed makes a man healthy but socially dead.' Animaniacs, série burlesque américaine
Julien Jehannet writes: > Well, this is my true problem: > I have converted my date format into the unix time Why? There's a DATE type. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter
Fri, Jun 08, 2001 at 06:20, Peter Eisentraut wrote: > Julien Jehannet writes: > > > Well, this is my true problem: > > I have converted my date format into the unix time > > Why? There's a DATE type. Yes, I know. I'm using the TIMESTAMP type before but there exists some few problems with the JDBC driver. I read that new PostgreSQL can manage the Unix format but I'm sure that is more efficient to test just a difference of seconds (with 2 integers) than several casts with timestamps and call an function. (I have a lot of tests of this kind) Am I wrong ?? Furthemore, my applications must access to the Unix time format. In your opinion, what is the best solution, int8 or numeric ?? Sincerely, jul -- (work) Julien.Jehannet at SecurityKeepers.com (home) jhanet at caramail.com 'Early to rise and early to bed makes a man healthy but socially dead.' Animaniacs, série burlesque américaine