Re: Create table error - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: Create table error
Date
Msg-id 20040914145017.U27974@megazone.bigpanda.com
Whole thread Raw
In response to Re: Create table error  (Kumar S <ps_postgres@yahoo.com>)
List pgsql-novice
On Tue, 14 Sep 2004, Kumar S wrote:

> Thank you Stephan Szabo,
>  I removed additional information from parenthesis and
> it worked.
> What I wanted to store is a number (e.g:15099404)
> which is a publication ID from PubMed (medical litt.
> database).  This number I wanted to use further to
> build queries to extract the publication linked to
> that number.
>
> My collegue suggested that I could store that number
> as a string too because I will not be doing any
> calculations on that number.

Well, it all depends on how it's used.  For example,
would you want to sort on the field, and would you
want 9000 to come before or after 150000? Does the
value ever have leading zeros that it would be bad
to lose?

If you're really just using it as a value that's only ever compared to be
= (or <>), a string is fine (*). If it's got to have leading zeros, a
string is nearly necessary.  If you want numeric sorting on the field
you'd either need to cast in your queries or use a number. If you're
comparing like ids after 15099403 where you want a numeric comparison
rather than a textual one, you'll need to cast or use a numer.

(*) - You probably would want a constraint to keep the valid values
constrained appropriately.


pgsql-novice by date:

Previous
From: Kumar S
Date:
Subject: Re: Create table error
Next
From: Josh Berkus
Date:
Subject: Re: Serial datatype clarification