Re: Create table error

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Kumar S <ps_postgres(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Create table error
Date: 2004-09-14 21:55:25
Message-ID: 20040914145017.U27974@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2004-09-14 23:07:16 Re: Serial datatype clarification
Previous Message Kumar S 2004-09-14 21:39:28 Re: Create table error